@iaforged/context-code 2.0.1 → 2.0.3

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 (145) hide show
  1. package/dist/src/bridge/bridgeMain.js +1 -1
  2. package/dist/src/bridge/types.js +1 -1
  3. package/dist/src/cli/handlers/auth.js +1 -1
  4. package/dist/src/cli/handlers/mcp.js +1 -1
  5. package/dist/src/cli/print.js +1 -1
  6. package/dist/src/commands/copy/copy.js +1 -1
  7. package/dist/src/commands/heartbeat/heartbeat.js +1 -0
  8. package/dist/src/commands/heartbeat/index.js +1 -0
  9. package/dist/src/commands/insights.js +1 -1
  10. package/dist/src/commands/install-github-app/ExistingWorkflowStep.js +1 -1
  11. package/dist/src/commands/install-github-app/InstallAppStep.js +1 -1
  12. package/dist/src/commands/install-github-app/OAuthFlowStep.js +1 -1
  13. package/dist/src/commands/install-github-app/SuccessStep.js +1 -1
  14. package/dist/src/commands/install-github-app/setupGitHubActions.js +1 -1
  15. package/dist/src/commands/login-openai/index.js +1 -1
  16. package/dist/src/commands/mobile/mobile.js +1 -1
  17. package/dist/src/commands/remote-setup/remote-setup.js +1 -1
  18. package/dist/src/commands/swarm-auto/swarmAuto.js +1 -1
  19. package/dist/src/commands/timeline/timeline.js +1 -1
  20. package/dist/src/commands/webapp/webapp.js +1 -1
  21. package/dist/src/commands.js +1 -1
  22. package/dist/src/components/ApproveApiKey.js +1 -1
  23. package/dist/src/components/ChannelDowngradeDialog.js +1 -1
  24. package/dist/src/components/ClaudeCodeHint/PluginHintMenu.js +1 -1
  25. package/dist/src/components/ConsoleOAuthFlow.js +1 -1
  26. package/dist/src/components/CostThresholdDialog.js +1 -1
  27. package/dist/src/components/CtrlOToExpand.js +1 -1
  28. package/dist/src/components/CustomSelect/select.js +1 -1
  29. package/dist/src/components/DesktopHandoff.js +1 -1
  30. package/dist/src/components/DesktopUpsell/DesktopUpsellStartup.js +1 -1
  31. package/dist/src/components/ExportDialog.js +1 -1
  32. package/dist/src/components/Feedback.js +1 -1
  33. package/dist/src/components/FeedbackSurvey/FeedbackSurvey.js +1 -1
  34. package/dist/src/components/FeedbackSurvey/FeedbackSurveyView.js +1 -1
  35. package/dist/src/components/IdeAutoConnectDialog.js +1 -1
  36. package/dist/src/components/IdeOnboardingDialog.js +1 -1
  37. package/dist/src/components/IdleReturnDialog.js +1 -1
  38. package/dist/src/components/InterruptedByUser.js +1 -1
  39. package/dist/src/components/InvalidConfigDialog.js +1 -1
  40. package/dist/src/components/InvalidSettingsDialog.js +1 -1
  41. package/dist/src/components/LanguagePicker.js +1 -1
  42. package/dist/src/components/LogSelector.js +1 -1
  43. package/dist/src/components/LogoV2/ChannelsNotice.js +1 -1
  44. package/dist/src/components/LogoV2/LogoV2.js +1 -1
  45. package/dist/src/components/LogoV2/feedConfigs.js +1 -1
  46. package/dist/src/components/LspRecommendation/LspRecommendationMenu.js +1 -1
  47. package/dist/src/components/MCPServerApprovalDialog.js +1 -1
  48. package/dist/src/components/MCPServerDesktopImportDialog.js +1 -1
  49. package/dist/src/components/ManagedSettingsSecurityDialog/ManagedSettingsSecurityDialog.js +1 -1
  50. package/dist/src/components/MessageSelector.js +1 -1
  51. package/dist/src/components/OutputStylePicker.js +1 -1
  52. package/dist/src/components/PromptInput/PromptInput.js +1 -1
  53. package/dist/src/components/RemoteCallout.js +1 -1
  54. package/dist/src/components/ResumeTask.js +1 -1
  55. package/dist/src/components/Settings/Config.js +1 -1
  56. package/dist/src/components/ShowInIDEPrompt.js +1 -1
  57. package/dist/src/components/Stats.js +1 -1
  58. package/dist/src/components/TagTabs.js +1 -1
  59. package/dist/src/components/TeleportError.js +1 -1
  60. package/dist/src/components/TeleportResumeWrapper.js +1 -1
  61. package/dist/src/components/TextInput.js +1 -1
  62. package/dist/src/components/agents/new-agent-creation/wizard-steps/MethodStep.js +1 -1
  63. package/dist/src/components/design-system/KeyboardShortcutHint.js +1 -1
  64. package/dist/src/components/diff/DiffDetailView.js +1 -1
  65. package/dist/src/components/grove/Grove.js +1 -1
  66. package/dist/src/components/hooks/SelectEventMode.js +1 -1
  67. package/dist/src/components/hooks/SelectHookMode.js +1 -1
  68. package/dist/src/components/hooks/SelectMatcherMode.js +1 -1
  69. package/dist/src/components/hooks/ViewHookMode.js +1 -1
  70. package/dist/src/components/mcp/MCPAgentServerMenu.js +1 -1
  71. package/dist/src/components/mcp/utils/reconnectHelpers.js +1 -1
  72. package/dist/src/components/memory/MemoryFileSelector.js +1 -1
  73. package/dist/src/components/messages/AssistantTextMessage.js +1 -1
  74. package/dist/src/components/messages/PlanApprovalMessage.js +1 -1
  75. package/dist/src/components/messages/ShutdownMessage.js +1 -1
  76. package/dist/src/components/messages/SystemAPIErrorMessage.js +1 -1
  77. package/dist/src/components/messages/UserPlanMessage.js +1 -1
  78. package/dist/src/components/permissions/AskUserQuestionPermissionRequest/PreviewQuestionView.js +1 -1
  79. package/dist/src/components/permissions/ComputerUseApproval/ComputerUseApproval.js +1 -1
  80. package/dist/src/components/permissions/FileEditPermissionRequest/FileEditPermissionRequest.js +1 -1
  81. package/dist/src/components/permissions/FilePermissionDialog/FilePermissionDialog.js +1 -1
  82. package/dist/src/components/permissions/FilePermissionDialog/permissionOptions.js +1 -1
  83. package/dist/src/components/permissions/FileWritePermissionRequest/FileWritePermissionRequest.js +1 -1
  84. package/dist/src/components/permissions/FilesystemPermissionRequest/FilesystemPermissionRequest.js +1 -1
  85. package/dist/src/components/permissions/PermissionRequest.js +1 -1
  86. package/dist/src/components/permissions/SedEditPermissionRequest/SedEditPermissionRequest.js +1 -1
  87. package/dist/src/components/permissions/SkillPermissionRequest/SkillPermissionRequest.js +1 -1
  88. package/dist/src/components/permissions/WebFetchPermissionRequest/WebFetchPermissionRequest.js +1 -1
  89. package/dist/src/components/permissions/rules/AddPermissionRules.js +1 -1
  90. package/dist/src/components/permissions/rules/AddWorkspaceDirectory.js +1 -1
  91. package/dist/src/components/permissions/rules/PermissionRuleList.js +1 -1
  92. package/dist/src/components/permissions/rules/RemoveWorkspaceDirectory.js +1 -1
  93. package/dist/src/components/sandbox/SandboxConfigTab.js +1 -1
  94. package/dist/src/components/sandbox/SandboxOverridesTab.js +1 -1
  95. package/dist/src/components/tasks/RemoteSessionDetailDialog.js +1 -1
  96. package/dist/src/constants/outputStyles.js +1 -1
  97. package/dist/src/entrypoints/cli.js +1 -1
  98. package/dist/src/hooks/notifs/useCanSwitchToExistingSubscription.js +1 -1
  99. package/dist/src/main.js +1 -1
  100. package/dist/src/projectOnboardingState.js +1 -1
  101. package/dist/src/screens/REPL.js +1 -1
  102. package/dist/src/server/channelServer.js +1 -0
  103. package/dist/src/server/channelServer.test.js +1 -0
  104. package/dist/src/services/api/errors.js +1 -1
  105. package/dist/src/services/api/filesApi.js +1 -1
  106. package/dist/src/services/api/index.js +1 -1
  107. package/dist/src/services/tips/tipRegistry.js +1 -1
  108. package/dist/src/tasks/RemoteAgentTask/RemoteAgentTask.js +1 -1
  109. package/dist/src/tools/AgentTool/AgentTool.js +1 -1
  110. package/dist/src/tools/ConfigTool/supportedSettings.js +1 -1
  111. package/dist/src/tools/EnterWorktreeTool/EnterWorktreeTool.js +1 -1
  112. package/dist/src/tools/ExitWorktreeTool/ExitWorktreeTool.js +1 -1
  113. package/dist/src/tools/WebFetchTool/WebFetchTool.js +1 -1
  114. package/dist/src/utils/computerUse/cleanup.js +1 -1
  115. package/dist/src/utils/computerUse/wrapper.js +1 -1
  116. package/dist/src/utils/fileHistory.js +1 -1
  117. package/dist/src/utils/heartbeat.js +1 -0
  118. package/dist/src/utils/model/providers.js +1 -1
  119. package/dist/src/utils/permissions/filesystem.js +1 -1
  120. package/dist/src/utils/permissions/permissions.js +1 -1
  121. package/dist/src/utils/processUserInput/processSlashCommand.js +1 -1
  122. package/dist/src/utils/releaseNoteTranslations.js +1 -1
  123. package/dist/src/utils/shell/shellToolUtils.js +1 -1
  124. package/dist/src/utils/sideQuery.js +1 -1
  125. package/dist/src/utils/sshMcp/common.js +1 -0
  126. package/dist/src/utils/sshMcp/setup.js +1 -0
  127. package/dist/src/utils/sshMcp/sshMcpServer.js +1 -0
  128. package/dist/src/utils/sshMcp/sshMcpServer.test.js +1 -0
  129. package/dist/src/utils/teleport.js +1 -1
  130. package/dist/src/webapp/server.js +1 -1
  131. package/dist/sshMcpServer.js +1 -0
  132. package/dist/sshMcpServer.test.js +1 -0
  133. package/dist/webapp/chunk-AMCDNAIG.js +1 -0
  134. package/dist/webapp/{chunk-YUEYJPXQ.js → chunk-NFYBHCXF.js} +1 -1
  135. package/dist/webapp/{chunk-DFKSSBHI.js → chunk-OJZNEHPP.js} +1 -1
  136. package/dist/webapp/chunk-VAB2VXFI.js +1 -0
  137. package/dist/webapp/index.html +2 -2
  138. package/dist/webapp/main-MTQLKGXD.js +1 -0
  139. package/dist/webapp/ngsw.json +14 -14
  140. package/dist/webapp/styles-DIKEDJBH.css +1 -0
  141. package/package.json +2 -1
  142. package/dist/webapp/chunk-4SRNXNLW.js +0 -1
  143. package/dist/webapp/chunk-SIHYW6PA.js +0 -1
  144. package/dist/webapp/main-LBNRQBXX.js +0 -1
  145. package/dist/webapp/styles-FUPULZDX.css +0 -1
@@ -1 +1 @@
1
- import{feature as t}from"../../recovery/bunBundleShim.js";import{jsx as e,jsxs as o,Fragment as r}from"react/jsx-runtime";import n from"chalk";import*as s from"path";import*as i from"react";import{useCallback as a,useEffect as l,useMemo as m,useRef as c,useState as u,useSyncExternalStore as d}from"react";import{useNotifications as p}from"../../context/notifications.js";import{useCommandQueue as f}from"../../hooks/useCommandQueue.js";import{useIdeAtMentioned as g}from"../../hooks/useIdeAtMentioned.js";import{logEvent as h}from"../../services/analytics/index.js";import{useAppState as S,useAppStateStore as x,useSetAppState as y}from"../../state/AppState.js";import{getCwd as C}from"../../utils/cwd.js";import{isQueuedCommandEditable as v,popAllEditable as j}from"../../utils/messageQueueManager.js";import b from"strip-ansi";import{companionReservedColumns as k}from"../../buddy/CompanionSprite.js";import{findBuddyTriggerPositions as I,useBuddyNotification as A}from"../../buddy/useBuddyNotification.js";import{FastModePicker as T}from"../../commands/fast/fast.js";import{isUltrareviewEnabled as M}from"../../commands/review/ultrareviewEnabled.js";import{getNativeCSIuTerminalDisplayName as w}from"../../commands/terminalSetup/terminalSetup.js";import{hasCommand as P}from"../../commands.js";import{useIsModalOverlayActive as R}from"../../context/overlayContext.js";import{useSetPromptOverlayDialog as _}from"../../context/promptOverlayContext.js";import{formatImageRef as O,formatPastedTextRef as D,getPastedTextRefNumLines as F,parseReferences as H}from"../../history.js";import{useArrowKeyHistory as E}from"../../hooks/useArrowKeyHistory.js";import{useDoublePress as U}from"../../hooks/useDoublePress.js";import{useHistorySearch as B}from"../../hooks/useHistorySearch.js";import{useInputBuffer as L}from"../../hooks/useInputBuffer.js";import{useMainLoopModel as N}from"../../hooks/useMainLoopModel.js";import{usePromptSuggestion as $}from"../../hooks/usePromptSuggestion.js";import{useTerminalSize as K}from"../../hooks/useTerminalSize.js";import{useTypeahead as Q}from"../../hooks/useTypeahead.js";import{stringWidth as G}from"../../ink/stringWidth.js";import{Box as V,Text as W,useInput as Y}from"../../ink.js";import{useOptionalKeybindingContext as q}from"../../keybindings/KeybindingContext.js";import{getShortcutDisplay as z}from"../../keybindings/shortcutFormat.js";import{useKeybinding as J,useKeybindings as X}from"../../keybindings/useKeybinding.js";import{abortPromptSuggestion as Z,logSuggestionSuppressed as tt}from"../../services/PromptSuggestion/promptSuggestion.js";import{abortSpeculation as et}from"../../services/PromptSuggestion/speculation.js";import{getActiveAgentForInput as ot,getViewedTeammateTask as rt}from"../../state/selectors.js";import{enterTeammateView as nt,exitTeammateView as st,stopOrDismissAgent as it}from"../../state/teammateViewHelpers.js";import{getRunningTeammatesSorted as at}from"../../tasks/InProcessTeammateTask/InProcessTeammateTask.js";import{isPanelAgentTask as lt}from"../../tasks/LocalAgentTask/LocalAgentTask.js";import{isBackgroundTask as mt}from"../../tasks/types.js";import{AGENT_COLOR_TO_THEME_COLOR as ct,AGENT_COLORS as ut}from"../../tools/AgentTool/agentColorManager.js";import{isAgentSwarmsEnabled as dt}from"../../utils/agentSwarmsEnabled.js";import{count as pt}from"../../utils/array.js";import{Cursor as ft}from"../../utils/Cursor.js";import{getGlobalConfig as gt,saveGlobalConfig as ht}from"../../utils/config.js";import{logForDebugging as St}from"../../utils/debug.js";import{parseDirectMemberMessage as xt,sendDirectMemberMessage as yt}from"../../utils/directMemberMessage.js";import{env as Ct}from"../../utils/env.js";import{errorMessage as vt}from"../../utils/errors.js";import{isBilledAsExtraUsage as jt}from"../../utils/extraUsage.js";import{getFastModeUnavailableReason as bt,isFastModeAvailable as kt,isFastModeCooldown as It,isFastModeEnabled as At,isFastModeSupportedByModel as Tt}from"../../utils/fastMode.js";import{isFullscreenEnvEnabled as Mt}from"../../utils/fullscreen.js";import{getImageFromClipboard as wt,PASTE_THRESHOLD as Pt}from"../../utils/imagePaste.js";import{cacheImagePath as Rt,storeImage as _t}from"../../utils/imageStore.js";import{isMacosOptionChar as Ot,MACOS_OPTION_SPECIAL_CHARS as Dt}from"../../utils/keyboardShortcuts.js";import{logError as Ft}from"../../utils/log.js";import{isOpus1mMergeEnabled as Ht,modelDisplayString as Et}from"../../utils/model/model.js";import{setAutoModeActive as Ut}from"../../utils/permissions/autoModeState.js";import{cyclePermissionMode as Bt,getNextPermissionMode as Lt}from"../../utils/permissions/getNextPermissionMode.js";import{transitionPermissionMode as Nt}from"../../utils/permissions/permissionSetup.js";import{getPlatform as $t}from"../../utils/platform.js";import{editPromptInEditor as Kt}from"../../utils/promptEditor.js";import{hasAutoModeOptIn as Qt}from"../../utils/settings/settings.js";import{findBtwTriggerPositions as Gt}from"../../utils/sideQuestion.js";import{findSlashCommandPositions as Vt}from"../../utils/suggestions/commandSuggestions.js";import{findSlackChannelPositions as Wt,getKnownChannelsVersion as Yt,hasSlackMcpServer as qt,subscribeKnownChannels as zt}from"../../utils/suggestions/slackChannelSuggestions.js";import{isInProcessEnabled as Jt}from"../../utils/swarm/backends/registry.js";import{syncTeammateMode as Xt}from"../../utils/swarm/teamHelpers.js";import{getTeammateColor as Zt}from"../../utils/teammate.js";import{isInProcessTeammate as te}from"../../utils/teammateContext.js";import{writeToMailbox as ee}from"../../utils/teammateMailbox.js";import{findThinkingTriggerPositions as oe,getRainbowColor as re,isUltrathinkEnabled as ne}from"../../utils/thinking.js";import{findTokenBudgetPositions as se}from"../../utils/tokenBudget.js";import{findUltraplanTriggerPositions as ie,findUltrareviewTriggerPositions as ae}from"../../utils/ultraplan/keyword.js";import{AutoModeOptInDialog as le}from"../AutoModeOptInDialog.js";import{BridgeDialog as me}from"../BridgeDialog.js";import{ConfigurableShortcutHint as ce}from"../ConfigurableShortcutHint.js";import{getVisibleAgentTasks as ue,useCoordinatorTaskCount as de}from"../CoordinatorAgentStatus.js";import{getEffortNotificationText as pe}from"../EffortIndicator.js";import{getFastIconString as fe}from"../FastIcon.js";import{GlobalSearchDialog as ge}from"../GlobalSearchDialog.js";import{HistorySearchDialog as he}from"../HistorySearchDialog.js";import{ModelPicker as Se}from"../ModelPicker.js";import{QuickOpenDialog as xe}from"../QuickOpenDialog.js";import ye from"../TextInput.js";import{ThinkingToggle as Ce}from"../ThinkingToggle.js";import{BackgroundTasksDialog as ve}from"../tasks/BackgroundTasksDialog.js";import{shouldHideTasksFooter as je}from"../tasks/taskStatusUtils.js";import{TeamsDialog as be}from"../teams/TeamsDialog.js";import ke from"../VimTextInput.js";import{getModeFromInput as Ie,getValueFromInput as Ae}from"./inputModes.js";import{FOOTER_TEMPORARY_STATUS_TIMEOUT as Te,Notifications as Me}from"./Notifications.js";import we from"./PromptInputFooter.js";import{PromptInputModeIndicator as Pe}from"./PromptInputModeIndicator.js";import{PromptInputQueuedCommands as Re}from"./PromptInputQueuedCommands.js";import{PromptInputStashNotice as _e}from"./PromptInputStashNotice.js";import{useMaybeTruncateInput as Oe}from"./useMaybeTruncateInput.js";import{usePromptInputPlaceholder as De}from"./usePromptInputPlaceholder.js";import{useShowFastIconHint as Fe}from"./useShowFastIconHint.js";import{useSwarmBanner as He}from"./useSwarmBanner.js";import{isNonSpacePrintable as Ee,isVimModeEnabled as Ue}from"./utils.js";function buildBorderText(t,e,o){if(!t)return;return{content:` ${e?`${fe(!0,o)} ${n.dim("/fast")}`:fe(!0,o)} `,position:"top",align:"end",offset:0}}export default i.memo(function({debug:n,ideSelection:lt,toolPermissionContext:fe,setToolPermissionContext:Be,apiKeyStatus:Le,commands:Ne,agents:$e,isLoading:Ke,verbose:Qe,messages:Ge,onAutoUpdaterResult:Ve,autoUpdaterResult:We,input:Ye,onInputChange:qe,mode:ze,onModeChange:Je,stashedPrompt:Xe,setStashedPrompt:Ze,submitCount:to,onShowMessageSelector:eo,onMessageActionsEnter:oo,mcpClients:ro,pastedContents:no,setPastedContents:so,vimMode:io,setVimMode:ao,showBashesDialog:lo,setShowBashesDialog:mo,onExit:co,getToolUseContext:uo,onSubmit:po,onAgentSubmit:fo,isSearchingHistory:go,setIsSearchingHistory:ho,onDismissSideQuestion:So,isSideQuestionVisible:xo,helpOpen:yo,setHelpOpen:Co,hasSuppressedDialogs:vo,isLocalJSXCommandActive:jo=!1,insertTextRef:bo,voiceInterimRange:ko}){const Io=N(),Ao=R()||jo,[To,Mo]=u(!1),[wo,Po]=u({show:!1}),[Ro,_o]=u(Ye.length),Oo=i.useRef(Ye);l(()=>{Ye!==Oo.current&&(_o(Ye.length),Oo.current=Ye)},[Ye]);const Do=i.useCallback(t=>{Oo.current=t,qe(t)},[qe]);bo&&(bo.current={cursorOffset:Ro,insert:t=>{const e=Ro===Ye.length&&Ye.length>0&&!/\s$/.test(Ye)?" "+t:t,o=Ye.slice(0,Ro)+e+Ye.slice(Ro);Oo.current=o,qe(o),_o(Ro+e.length)},setInputWithCursor:(t,e)=>{Oo.current=t,qe(t),_o(e)}});const Fo=x(),Ho=y(),Eo=S(t=>t.tasks),Uo=S(t=>t.replBridgeConnected),Bo=S(t=>t.replBridgeExplicit),Lo=S(t=>t.replBridgeReconnecting),No=Uo&&(Bo||Lo),$o=(S(t=>!1),!1),Ko=S(t=>!1),Qo=S(t=>t.teamContext),Go=f(),Vo=S(t=>t.promptSuggestion),Wo=S(t=>t.speculation),Yo=S(t=>t.speculationSessionTimeSavedMs),qo=S(t=>t.viewingAgentTaskId),zo=S(t=>t.viewSelectionMode),Jo="teammates"===S(t=>t.expandedView),{companion:Xo,companionMuted:Zo}=t("BUDDY")?gt():{companion:void 0,companionMuted:void 0},tr=!!Xo&&!Zo,er=!(!t("KAIROS")&&!t("KAIROS_BRIEF"))&&(S(t=>t.isBriefOnly)&&!qo),or=S(t=>t.mainLoopModel),rr=S(t=>t.mainLoopModelForSession),nr=S(t=>t.thinkingEnabled),sr=S(t=>!!At()&&t.fastMode),ir=S(t=>t.effortValue),ar=rt(Fo.getState()),lr=ar?.identity.agentName,mr=ar?.identity.color&&ut.includes(ar.identity.color)?ar.identity.color:void 0,cr=m(()=>at(Eo),[Eo]),ur=cr.length>0||void 0!==ar,dr=m(()=>ar?{...fe,mode:ar.permissionMode}:fe,[ar,fe]),{historyQuery:pr,setHistoryQuery:fr,historyMatch:gr,historyFailedMatch:hr}=B(t=>{so(t.pastedContents),Yn(t.display)},Ye,Do,_o,Ro,Je,ze,go,ho,so,no),Sr=c(-1);-1===Sr.current&&(Sr.current=function(t){let e=0;for(const o of t)if("user"===o.type){if(o.imagePasteIds)for(const t of o.imagePasteIds)t>e&&(e=t);if(Array.isArray(o.message.content))for(const t of o.message.content)if("text"===t.type){const o=H(t.text);for(const t of o)t.id>e&&(e=t.id)}}return e+1}(Ge));const xr=c(!1),[yr,Cr]=u(!1),[vr,jr]=u(!1),[br,kr]=u(0),Ir=S(t=>t.coordinatorTaskIndex),Ar=a(t=>Ho(e=>{const o="function"==typeof t?t(e.coordinatorTaskIndex):t;return o===e.coordinatorTaskIndex?e:{...e,coordinatorTaskIndex:o}}),[Ho]),Tr=de(),Mr=m(()=>Object.values(Eo).some(t=>mt(t)&&!0),[Eo])?-1:0;l(()=>{Ir>=Tr?Ar(Math.max(Mr,Tr-1)):Ir<Mr&&Ar(Mr)},[Tr,Ir,Mr]);const[wr,Pr]=u(!1),[Rr,_r]=u(!1),[Or,Dr]=u(!1),[Fr,Hr]=u(!1),[Er,Ur]=u(!1),[Br,Lr]=u(!1),[Nr,$r]=u(!1),[Kr,Qr]=u(!1),[Gr,Vr]=u(!1),[Wr,Yr]=u(null),qr=c(null),zr=m(()=>{const t=Ye.indexOf("\n");return-1===t||Ro<=t},[Ye,Ro]),Jr=m(()=>{const t=Ye.lastIndexOf("\n");return-1===t||Ro>t},[Ye,Ro]),Xr=m(()=>{if(!dt())return[];if(Jt())return[];if(!Qo)return[];const t=pt(Object.values(Qo.teammates),t=>"team-lead"!==t.name);return[{name:Qo.teamName,memberCount:t,runningCount:0,idleCount:0}]},[Qo]),Zr=m(()=>pt(Object.values(Eo),t=>"running"===t.status),[Eo])>0&&!je(Eo,Jo),tn=Xr.length>0,en=m(()=>[Zr&&"tasks",$o,Ko&&"bagel",tn&&"teams",No&&"bridge",tr&&"companion"].filter(Boolean),[Zr,$o,Ko,tn,No,tr]),on=S(t=>t.footerSelection),rn=on&&en.includes(on)?on:null;l(()=>{on&&!rn&&Ho(t=>null===t.footerSelection?t:{...t,footerSelection:null})},[on,rn,Ho]);const nn="tasks"===rn,sn="tmux"===rn,an="teams"===rn,ln="bridge"===rn;function selectFooterItem(t){Ho(e=>e.footerSelection===t?e:{...e,footerSelection:t}),"tasks"===t&&(kr(0),Ar(Mr))}function navigateFooter(t,e=!1){const o=rn?en.indexOf(rn):-1,r=en[o+t];return r?(selectFooterItem(r),!0):!!(t<0&&e)&&(selectFooterItem(null),!0)}const{suggestion:mn,markAccepted:cn,logOutcomeAtSubmission:un,markShown:dn}=$({inputValue:Ye,isAssistantResponding:Ke}),pn=m(()=>go&&gr?Ae("string"==typeof gr?gr:gr.display):Ye,[go,gr,Ye]),fn=m(()=>oe(pn),[pn]),gn=S(t=>t.ultraplanSessionUrl),hn=S(t=>t.ultraplanLaunching),Sn=m(()=>!t("ULTRAPLAN")||gn||hn?[]:ie(pn),[pn,gn,hn]),xn=m(()=>M()?ae(pn):[],[pn]),yn=m(()=>Gt(pn),[pn]),Cn=m(()=>I(pn),[pn]),vn=m(()=>Vt(pn).filter(t=>{const e=pn.slice(t.start+1,t.end);return P(e,Ne)}),[pn,Ne]),jn=m(()=>t("TOKEN_BUDGET")?se(pn):[],[pn]),bn=d(zt,Yt),kn=m(()=>qt(Fo.getState().mcp.clients)?Wt(pn):[],[pn,bn]),In=m(()=>{if(!dt())return[];if(!Qo?.teammates)return[];const t=[],e=Qo.teammates;if(!e)return t;const o=/(^|\s)@([\w-]+)/g,r=Object.values(e);let n;for(;null!==(n=o.exec(pn));){const e=n[1]??"",o=n.index+e.length,s=n[0].trimStart(),i=n[2],a=r.find(t=>t.name===i);if(a?.color){const e=ct[a.color];e&&t.push({start:o,end:o+s.length,themeColor:e})}}return t},[pn,Qo]),An=m(()=>H(pn).filter(t=>t.match.startsWith("[Image")).map(t=>({start:t.index,end:t.index+t.match.length})),[pn]),Tn=An.some(t=>t.start===Ro);l(()=>{const t=An.find(t=>Ro>t.start&&Ro<t.end);if(t){const e=(t.start+t.end)/2;_o(Ro<e?t.start:t.end)}},[Ro,An,_o]);const Mn=m(()=>{const e=[];for(const t of An)Ro===t.start&&e.push({start:t.start,end:t.end,color:void 0,inverse:!0,priority:8});go&&gr&&!hr&&e.push({start:Ro,end:Ro+pr.length,color:"warning",priority:20});for(const t of yn)e.push({start:t.start,end:t.end,color:"warning",priority:15});for(const t of vn)e.push({start:t.start,end:t.end,color:"suggestion",priority:5});for(const t of jn)e.push({start:t.start,end:t.end,color:"suggestion",priority:5});for(const t of kn)e.push({start:t.start,end:t.end,color:"suggestion",priority:5});for(const t of In)e.push({start:t.start,end:t.end,color:t.themeColor,priority:5});if(ko&&e.push({start:ko.start,end:ko.end,color:void 0,dimColor:!0,priority:1}),ne())for(const t of fn)for(let o=t.start;o<t.end;o++)e.push({start:o,end:o+1,color:re(o-t.start),shimmerColor:re(o-t.start,!0),priority:10});if(t("ULTRAPLAN"))for(const t of Sn)for(let o=t.start;o<t.end;o++)e.push({start:o,end:o+1,color:re(o-t.start),shimmerColor:re(o-t.start,!0),priority:10});for(const t of xn)for(let o=t.start;o<t.end;o++)e.push({start:o,end:o+1,color:re(o-t.start),shimmerColor:re(o-t.start,!0),priority:10});for(const t of Cn)for(let o=t.start;o<t.end;o++)e.push({start:o,end:o+1,color:re(o-t.start),shimmerColor:re(o-t.start,!0),priority:10});return e},[go,pr,gr,hr,Ro,yn,An,In,vn,jn,kn,pn,ko,fn,Sn,xn,Cn]),{addNotification:wn,removeNotification:Pn}=p();l(()=>{fn.length&&ne()?wn({key:"ultrathink-active",text:"Effort set to high for this turn",priority:"immediate",timeoutMs:5e3}):Pn("ultrathink-active")},[wn,Pn,fn.length]),l(()=>{t("ULTRAPLAN")&&Sn.length?wn({key:"ultraplan-active",text:"This prompt will launch an ultraplan session in Context Code on the web",priority:"immediate",timeoutMs:5e3}):Pn("ultraplan-active")},[wn,Pn,Sn.length]),l(()=>{M()&&xn.length&&wn({key:"ultrareview-active",text:"Run /ultrareview after Claude finishes to review these changes in the cloud",priority:"immediate",timeoutMs:5e3})},[wn,xn.length]);const Rn=c(Ye.length),_n=c(Ye.length),On=a(()=>{Pn("stash-hint")},[Pn]);l(()=>{const t=Rn.current,r=_n.current,n=Ye.length;if(Rn.current=n,n>r)return void(_n.current=n);if(0===n)return void(_n.current=0);if(r>=20&&n<=5&&!(t>=20&&n<=5)){gt().hasUsedStash||wn({key:"stash-hint",jsx:o(W,{dimColor:!0,children:["Tip:"," ",e(ce,{action:"chat:stash",context:"Chat",fallback:"ctrl+s",description:"stash"})]}),priority:"immediate",timeoutMs:Te}),_n.current=n}},[Ye.length,wn]);const{pushToBuffer:Dn,undo:Fn,canUndo:Hn,clearBuffer:En}=L({maxBufferSize:50,debounceMs:1e3});Oe({input:Ye,pastedContents:no,onInputChange:Do,setCursorOffset:_o,setPastedContents:so});const Un=De({input:Ye,submitCount:to,viewingAgentName:lr}),Bn=a(t=>{if("?"===t)return h("tengu_help_toggled",{}),void Co(t=>!t);Co(!1),On(),Z(),et(Ho);const e=t.length===Ye.length+1,o=0===Ro,r=Ie(t);if(o&&"prompt"!==r){if(e)return void Je(r);if(0===Ye.length){Je(r);const e=Ae(t).replaceAll("\t"," ");return Dn(Ye,Ro,no),Do(e),void _o(e.length)}}const n=t.replaceAll("\t"," ");Ye!==n&&Dn(Ye,Ro,no),Ho(t=>null===t.footerSelection?t:{...t,footerSelection:null}),Do(n)},[Do,Je,Ye,Ro,Dn,no,On,Ho]),{resetHistory:Ln,onHistoryUp:Nn,onHistoryDown:$n,dismissSearchHint:Kn,historyIndex:Qn}=E((t,e,o)=>{Bn(t),Je(e),so(o)},Ye,no,_o,ze);l(()=>{go&&Kn()},[go,Kn]);const[Gn,Vn]=u({suggestions:[],selectedSuggestion:-1,commandArgumentHint:void 0}),Wn=a(t=>{Vn(e=>"function"==typeof t?t(e):t)},[]),Yn=a(async(t,e=!1)=>{t=t.trimEnd();const o=Fo.getState();if(o.footerSelection&&en.includes(o.footerSelection))return;if("selecting-agent"===o.viewSelectionMode)return;const r=Object.values(no).some(t=>"image"===t.type),n=Vo.text;if((""===t.trim()||t===n)&&n&&!r&&!o.viewingAgentTaskId){if("active"===Wo.status)return cn(),un(n,{skipReset:!0}),void po(n,{setCursorOffset:_o,clearBuffer:En,resetHistory:Ln},{state:Wo,speculationSessionTimeSavedMs:Yo,setAppState:Ho});Vo.shownAt>0&&(cn(),t=n)}if(dt()){const e=xt(t);if(e){const t=await yt(e.recipientName,e.message,Qo,ee);if(t.success)return wn({key:"direct-message-sent",text:`Sent to @${t.recipientName}`,priority:"immediate",timeoutMs:3e3}),Do(""),_o(0),En(),void Ln();t.error}}if(""===t.trim()&&!r)return;const s=Gn.suggestions.length>0&&Gn.suggestions.every(t=>"directory"===t.description);if(Gn.suggestions.length>0&&!e&&!s)return void St(`[onSubmit] early return: suggestions showing (count=${Gn.suggestions.length})`);Vo.text&&Vo.shownAt>0&&un(t),Pn("stash-hint");const i=ot(Fo.getState());if("leader"!==i.type&&fo)return h("tengu_transcript_input_to_teammate",{}),void await fo(t,i.task,{setCursorOffset:_o,clearBuffer:En,resetHistory:Ln});await po(t,{setCursorOffset:_o,clearBuffer:En,resetHistory:Ln})},[Vo,Wo,Yo,Qo,Fo,en,Gn.suggestions,po,fo,En,Ln,un,Ho,cn,no,Pn]),{suggestions:qn,selectedSuggestion:zn,commandArgumentHint:Jn,inlineGhostText:Xn,maxColumnWidth:Zn}=Q({commands:Ne,onInputChange:Do,onSubmit:Yn,setCursorOffset:_o,input:Ye,cursorOffset:Ro,mode:ze,agents:$e,setSuggestionsState:Wn,suggestionsState:Gn,suppressSuggestions:go||Qn>0,markAccepted:cn,onModeChange:Je}),ts="prompt"===ze&&0===qn.length&&mn&&!qo;function onImagePaste(t,e,o,r,n){h("tengu_paste_image",{}),Je("prompt");const s=Sr.current++,i={id:s,type:"image",content:t,mediaType:e||"image/png",filename:o||"Pasted image",dimensions:r,sourcePath:n};Rt(i),_t(i),so(t=>({...t,[s]:i}));insertTextAtCursor((xr.current?" ":"")+O(s)),xr.current=!0}ts&&dn(),!Vo.text||mn||0!==Vo.shownAt||qo||(tt("timing",Vo.text),Ho(t=>({...t,promptSuggestion:{text:null,promptId:null,shownAt:0,acceptedAt:0,generationRequestId:null}}))),l(()=>{const t=new Set(H(Ye).map(t=>t.id));so(e=>{const o=Object.values(e).filter(e=>"image"===e.type&&!t.has(e.id));if(0===o.length)return e;const r={...e};for(const t of o)delete r[t.id];return r})},[Ye,so]);const es=a((t,e)=>xr.current?(xr.current=!1,Ee(t,e)?" "+t:t):t,[]);function insertTextAtCursor(t){Dn(Ye,Ro,no);const e=Ye.slice(0,Ro)+t+Ye.slice(Ro);Do(e),_o(Ro+t.length)}const os=U(()=>{},()=>eo()),rs=a(()=>{const t=j(Ye,Ro);return!!t&&(Do(t.text),Je("prompt"),_o(t.cursorOffset),t.images.length>0&&so(e=>{const o={...e};for(const e of t.images)o[e.id]=e;return o}),!0)},[Do,Je,Ye,Ro,so]);g(ro,function(t){let e;h("tengu_ext_at_mentioned",{});const o=s.relative(C(),t.filePath);e=t.lineStart&&t.lineEnd?t.lineStart===t.lineEnd?`@${o}#L${t.lineStart} `:`@${o}#L${t.lineStart}-${t.lineEnd} `:`@${o} `;const r=Ye[Ro-1]??" ";/\s/.test(r)||(e=` ${e}`),insertTextAtCursor(e)});const ns=a(()=>{if(Hn){const t=Fn();t&&(Do(t.text),_o(t.cursorOffset),so(t.pastedContents))}},[Hn,Fn,Do,so]),ss=a(()=>{Dn(Ye,Ro,no);const t=Ye.slice(0,Ro)+"\n"+Ye.slice(Ro);Do(t),_o(Ro+1)},[Ye,Ro,Do,_o,Dn,no]),is=a(async()=>{h("tengu_external_editor_used",{}),_r(!0);try{const t=await Kt(Ye,no);t.error&&wn({key:"external-editor-error",text:t.error,color:"warning",priority:"high"}),null!==t.content&&t.content!==Ye&&(Dn(Ye,Ro,no),Do(t.content),_o(t.content.length))}catch(t){t instanceof Error&&Ft(t),wn({key:"external-editor-error",text:`External editor failed: ${vt(t)}`,color:"warning",priority:"high"})}finally{_r(!1)}},[Ye,Ro,no,Dn,Do,wn]),as=a(()=>{""===Ye.trim()&&void 0!==Xe?(Do(Xe.text),_o(Xe.cursorOffset),so(Xe.pastedContents),Ze(void 0)):""!==Ye.trim()&&(Ze({text:Ye,cursorOffset:Ro,pastedContents:no}),Do(""),_o(0),so({}),ht(t=>t.hasUsedStash?t:{...t,hasUsedStash:!0}))},[Ye,Ro,Xe,Do,Ze,no,so]),ls=a(()=>{Dr(t=>!t),yo&&Co(!1)},[yo]),ms=a(()=>{$r(t=>!t),yo&&Co(!1)},[yo]),cs=a(()=>{Qr(t=>!t),yo&&Co(!1)},[yo]),us=a(()=>{if(dt()&&ar&&qo){const t={...fe,mode:ar.permissionMode},e=Lt(t,void 0);h("tengu_mode_cycle",{to:e});const o=qo;return Ho(t=>{const r=t.tasks[o];return r&&"in_process_teammate"===r.type?r.permissionMode===e?t:{...t,tasks:{...t.tasks,[o]:{...r,permissionMode:e}}}:t}),void(yo&&Co(!1))}St(`[auto-mode] handleCycleMode: currentMode=${fe.mode} isAutoModeAvailable=${fe.isAutoModeAvailable} showAutoModeOptIn=${Gr} timeoutPending=${!!qr.current}`);const e=Lt(fe,Qo);let o=!1;if(t("TRANSCRIPT_CLASSIFIER")&&(o="auto"===e&&"auto"!==fe.mode&&!Qt()&&!qo),t("TRANSCRIPT_CLASSIFIER")&&o)return Yr(fe.mode),Ho(t=>({...t,toolPermissionContext:{...t.toolPermissionContext,mode:"auto"}})),Be({...fe,mode:"auto"}),qr.current&&clearTimeout(qr.current),qr.current=setTimeout((t,e)=>{t(!0),e.current=null},400,Vr,qr),void(yo&&Co(!1));t("TRANSCRIPT_CLASSIFIER")&&(Gr||qr.current)&&(Gr&&h("tengu_auto_mode_opt_in_dialog_decline",{}),Vr(!1),qr.current&&(clearTimeout(qr.current),qr.current=null),Yr(null));const{context:r}=Bt(fe,Qo);h("tengu_mode_cycle",{to:e}),"plan"===e&&ht(t=>({...t,lastPlanModeUse:Date.now()})),Ho(t=>({...t,toolPermissionContext:{...r,mode:e}})),Be({...r,mode:e}),Xt(e,Qo?.teamName),yo&&Co(!1)},[fe,Qo,qo,ar,Ho,Be,yo,Gr]),ds=a(()=>{if(t("TRANSCRIPT_CLASSIFIER")){Vr(!1),Yr(null);const t=Nt(Wr??fe.mode,"auto",fe);Ho(e=>({...e,toolPermissionContext:{...t,mode:"auto"}})),Be({...t,mode:"auto"}),yo&&Co(!1)}},[yo,Co,Wr,fe,Ho,Be]),ps=a(()=>{t("TRANSCRIPT_CLASSIFIER")&&(St(`[auto-mode] handleAutoModeOptInDecline: reverting to ${Wr}, setting isAutoModeAvailable=false`),Vr(!1),qr.current&&(clearTimeout(qr.current),qr.current=null),Wr&&(Ut(!1),Ho(t=>({...t,toolPermissionContext:{...t.toolPermissionContext,mode:Wr,isAutoModeAvailable:!1}})),Be({...fe,mode:Wr,isAutoModeAvailable:!1}),Yr(null)))},[Wr,fe,Ho,Be]),fs=a(()=>{wt().then(t=>{if(t)onImagePaste(t.base64,t.mediaType);else{const t=z("chat:imagePaste","Chat","ctrl+v"),e=Ct.isSSH()?"No image found in clipboard. You're SSH'd; try scp?":`No image found in clipboard. Use ${t} to paste images.`;wn({key:"no-image-in-clipboard",text:e,priority:"immediate",timeoutMs:1e3})}})},[wn,onImagePaste]),gs=q();l(()=>{if(gs&&!Ao)return gs.registerHandler({action:"chat:submit",context:"Chat",handler:()=>{Yn(Ye)}})},[gs,Ao,Yn,Ye]);const hs=m(()=>({"chat:undo":ns,"chat:newline":ss,"chat:externalEditor":is,"chat:stash":as,"chat:modelPicker":ls,"chat:thinkingToggle":cs,"chat:cycleMode":us,"chat:imagePaste":fs}),[ns,ss,is,as,ls,cs,us,fs]);X(hs,{context:"Chat",isActive:!Ao}),J("chat:messageActions",()=>oo?.(),{context:"Chat",isActive:!Ao&&!go}),J("chat:fastMode",ms,{context:"Chat",isActive:!Ao&&At()&&kt()}),J("help:dismiss",()=>{Co(!1)},{context:"Help",isActive:yo});const Ss=!!t("QUICK_SEARCH")&&!Ao;J("app:quickOpen",()=>{t("QUICK_SEARCH")&&(Hr(!0),Co(!1))},{context:"Global",isActive:Ss}),J("app:globalSearch",()=>{t("QUICK_SEARCH")&&(Ur(!0),Co(!1))},{context:"Global",isActive:Ss}),J("history:search",()=>{t("HISTORY_PICKER")&&(Lr(!0),Co(!1))},{context:"Global",isActive:!!t("HISTORY_PICKER")&&!Ao}),J("app:interrupt",()=>{et(Ho)},{context:"Global",isActive:!Ke&&"active"===Wo.status}),X({"footer:up":()=>{navigateFooter(-1,!0)},"footer:down":()=>{if(nn&&!ur)return mo(!0),void selectFooterItem(null);navigateFooter(1)},"footer:next":()=>{if(nn&&ur){const t=1+cr.length;return void kr(e=>(e+1)%t)}navigateFooter(1)},"footer:previous":()=>{if(nn&&ur){const t=1+cr.length;return void kr(e=>(e-1+t)%t)}navigateFooter(-1)},"footer:openSelected":()=>{if("selecting-agent"!==zo)switch(rn){case"companion":t("BUDDY")&&(selectFooterItem(null),Yn("/buddy"));break;case"tasks":if(ur)if(0===br)st(Ho);else{const t=cr[br-1];t&&nt(t.id,Ho)}else if(0===Ir&&Tr>0)st(Ho);else{const t=ue(Eo)[Ir-1]?.id;t?nt(t,Ho):(mo(!0),selectFooterItem(null))}break;case"tmux":0;break;case"bagel":break;case"teams":Cr(!0),selectFooterItem(null);break;case"bridge":jr(!0),selectFooterItem(null)}},"footer:clearSelection":()=>{selectFooterItem(null)},"footer:close":()=>{if(nn&&Ir>=1){const t=ue(Eo)[Ir-1];return!!t&&("viewing-agent"===zo&&t.id===qo?(Bn(Ye.slice(0,Ro)+"x"+Ye.slice(Ro)),void _o(Ro+1)):(it(t.id,Ho),void("running"!==t.status&&Ar(t=>Math.max(Mr,t-1)))))}return!1}},{context:"Footer",isActive:!!rn&&!Ao}),Y((t,r)=>{if(!(yr||Fr||Er||Br)){if("macos"===$t()&&Ot(t)){const r=Dt[t],n=w(),s=o(W,n?{dimColor:!0,children:["To enable ",r,", set ",e(W,{bold:!0,children:"Option as Meta"})," in"," ",n," preferences (⌘,)"]}:{dimColor:!0,children:["To enable ",r,", run /terminal-setup"]});wn({key:"option-meta-hint",jsx:s,priority:"immediate",timeoutMs:5e3})}if(rn&&t&&!r.ctrl&&!r.meta&&!r.escape&&!r.return)return Bn(Ye.slice(0,Ro)+t+Ye.slice(Ro)),void _o(Ro+t.length);if(0===Ro&&(r.escape||r.backspace||r.delete||r.ctrl&&"u"===t)&&(Je("prompt"),Co(!1)),yo&&""===Ye&&(r.backspace||r.delete)&&Co(!1),r.escape){if("active"===Wo.status)return void et(Ho);if(xo&&So)return void So();if(yo)return void Co(!1);if(rn)return;if(Go.some(v))return void rs();Ge.length>0&&!Ye&&!Ke&&os()}r.return&&yo&&Co(!1)}});const xs=He(),ys=!!At()&&It(),Cs=!!At()&&(sr&&(kt()||ys)),vs=Fe(Cs??!1),js=er?void 0:pe(ir,Io);l(()=>{js?wn({key:"effort-level",text:js,priority:"high",timeoutMs:12e3}):Pn("effort-level")},[js,wn,Pn]),A();const bs=!!t("BUDDY")&&S(t=>void 0!==t.companionReaction),{columns:ks,rows:Is}=K(),As=ks-3-k(ks,bs),Ts=Mt()?Math.max(3,Math.floor(Is/2)-5):void 0,Ms=a(t=>{if(!Ye||go)return;const e=ft.fromText(Ye,As,Ro),o=e.getViewportStartLine(Ts),r=e.measuredText.getOffsetFromPosition({line:t.localRow+o,column:t.localCol});_o(r)},[Ye,As,go,Ro,Ts]),ws=a(t=>mo(t??!0),[mo]),Ps=ts&&mn?mn:Un,Rs=m(()=>Ye.includes("\n"),[Ye]),_s=a((t,o)=>{let r=!1;Ho(e=>(r=At()&&!Tt(t)&&!!e.fastMode,{...e,mainLoopModel:t,mainLoopModelForSession:null,...r&&{fastMode:!1}})),Dr(!1);const n=(sr??!1)&&!r;let s=`Model set to ${Et(t)}`;jt(t,n,Ht())&&(s+=" · Billed as extra usage"),r&&(s+=" · Fast mode OFF"),wn({key:"model-switched",jsx:e(W,{children:s}),priority:"immediate",timeoutMs:3e3}),h("tengu_model_picker_hotkey",{model:t})},[Ho,wn,sr]),Os=a(()=>{Dr(!1)},[]),Ds=m(()=>Or?e(V,{flexDirection:"column",marginTop:1,children:e(Se,{initial:or,sessionModel:rr,onSelect:_s,onCancel:Os,isStandaloneCommand:!0,showFastModeNotice:At()&&sr&&Tt(or)&&kt()})}):null,[Or,or,rr,_s,Os]),Fs=a(t=>{$r(!1),t&&wn({key:"fast-mode-toggled",jsx:e(W,{children:t}),priority:"immediate",timeoutMs:3e3})},[wn]),Hs=m(()=>Nr?e(V,{flexDirection:"column",marginTop:1,children:e(T,{onDone:Fs,unavailableReason:bt()})}):null,[Nr,Fs]),Es=a(t=>{Ho(e=>({...e,thinkingEnabled:t})),Qr(!1),h("tengu_thinking_toggled_hotkey",{enabled:t}),wn({key:"thinking-toggled-hotkey",jsx:o(W,{color:t?"suggestion":void 0,dimColor:!t,children:["Thinking ",t?"on":"off"]}),priority:"immediate",timeoutMs:3e3})},[Ho,wn]),Us=a(()=>{Qr(!1)},[]),Bs=m(()=>Kr?e(V,{flexDirection:"column",marginTop:1,children:e(Ce,{currentValue:nr??!0,onSelect:Es,onCancel:Us,isMidConversation:Ge.some(t=>"assistant"===t.type)})}):null,[Kr,nr,Es,Us,Ge.length]),Ls=m(()=>t("TRANSCRIPT_CLASSIFIER")&&Gr?e(le,{onAccept:ds,onDecline:ps}):null,[Gr,ds,ps]);if(_(Mt()?Ls:null),lo)return e(ve,{onDone:()=>mo(!1),toolUseContext:uo(Ge,[],new AbortController,Io),initialDetailTaskId:"string"==typeof lo?lo:void 0});if(dt()&&yr)return e(be,{initialTeams:Xr,onDone:()=>{Cr(!1)}});if(t("QUICK_SEARCH")){const insertWithSpacing=t=>{const e=Ye[Ro-1]??" ";insertTextAtCursor(/\s/.test(e)?t:` ${t}`)};if(Fr)return e(xe,{onDone:()=>Hr(!1),onInsert:insertWithSpacing});if(Er)return e(ge,{onDone:()=>Ur(!1),onInsert:insertWithSpacing})}if(t("HISTORY_PICKER")&&Br)return e(he,{initialQuery:Ye,onSelect:t=>{const e=Ie(t.display),o=Ae(t.display);Je(e),Do(o),so(t.pastedContents),_o(o.length),Lr(!1)},onCancel:()=>Lr(!1)});if(Ds)return Ds;if(Hs)return Hs;if(Bs)return Bs;if(vr)return e(me,{onDone:()=>{jr(!1),selectFooterItem(null)}});const Ns={multiline:!0,onSubmit:Yn,onChange:Bn,value:gr?Ae("string"==typeof gr?gr:gr.display):Ye,onHistoryUp:function(){if(qn.length>1)return;if(!zr)return;Go.some(v)?rs():Nn()},onHistoryDown:function(){if(!(qn.length>1)&&Jr&&$n()&&en.length>0){const t=en[0];selectFooterItem(t),"tasks"!==t||gt().hasSeenTasksHint||ht(t=>t.hasSeenTasksHint?t:{...t,hasSeenTasksHint:!0})}},onHistoryReset:Ln,placeholder:Ps,onExit:co,onExitMessage:(t,e)=>Po({show:t,key:e}),onImagePaste,columns:As,maxVisibleLines:Ts,disableCursorMovementForUpDownKeys:qn.length>0||!!rn,disableEscapeDoublePress:qn.length>0,cursorOffset:Ro,onChangeCursorOffset:_o,onPaste:function(t){xr.current=!1;let e=b(t).replace(/\r/g,"\n").replaceAll("\t"," ");if(0===Ye.length){const t=Ie(e);"prompt"!==t&&(Je(t),e=Ae(e))}const o=F(e),r=Math.min((process.stdout.rows||24)-10,2);if(e.length>Pt||o>r){const t=Object.keys(no).map(Number);let r=Sr.current;t.length>0&&(r=Math.max(r,Math.max(...t)+1)),Sr.current=r+1;const n={id:r,type:"text",content:e};so(t=>({...t,[r]:n})),insertTextAtCursor(D(r,o))}else insertTextAtCursor(e)},onIsPastingChange:Pr,focus:!go&&!Ao&&!rn,showCursor:!rn&&!go&&!Tn,argumentHint:Jn,onUndo:Hn?()=>{const t=Fn();t&&(Do(t.text),_o(t.cursorOffset),so(t.pastedContents))}:void 0,highlights:Mn,inlineGhostText:Xn,inputFilter:es},getBorderColor=()=>{const t={bash:"bashBorder"};if(t[ze])return t[ze];if(te())return"promptBorder";const e=Zt();return e&&ut.includes(e)?ct[e]:"promptBorder"};if(Rr)return e(V,{flexDirection:"row",alignItems:"center",justifyContent:"center",borderColor:getBorderColor(),borderStyle:"round",borderLeft:!1,borderRight:!1,borderBottom:!0,width:"100%",children:e(W,{dimColor:!0,italic:!0,children:"Save and close editor to continue..."})});const $s=Ue()?e(ke,{...Ns,initialMode:io,onModeChange:ao}):e(ye,{...Ns});return o(V,{flexDirection:"column",marginTop:er?0:1,children:[!Mt()&&e(Re,{}),vo&&e(V,{marginTop:1,marginLeft:2,children:e(W,{dimColor:!0,children:"Waiting for permission…"})}),e(_e,{hasStash:void 0!==Xe}),xs?o(r,{children:[e(W,{color:xs.bgColor,children:xs.text?o(r,{children:["─".repeat(Math.max(0,ks-G(xs.text)-4)),o(W,{backgroundColor:xs.bgColor,color:"inverseText",children:[" ",xs.text," "]}),"──"]}):"─".repeat(ks)}),o(V,{flexDirection:"row",width:"100%",children:[e(Pe,{mode:ze,isLoading:Ke,viewingAgentName:lr,viewingAgentColor:mr}),e(V,{flexGrow:1,flexShrink:1,onClick:Ms,children:$s})]}),e(W,{color:xs.bgColor,children:"─".repeat(ks)})]}):o(V,{flexDirection:"row",alignItems:"flex-start",justifyContent:"flex-start",borderColor:getBorderColor(),borderStyle:"round",borderLeft:!1,borderRight:!1,borderBottom:!0,width:"100%",borderText:buildBorderText(Cs??!1,vs,ys),children:[e(Pe,{mode:ze,isLoading:Ke,viewingAgentName:lr,viewingAgentColor:mr}),e(V,{flexGrow:1,flexShrink:1,onClick:Ms,children:$s})]}),e(we,{apiKeyStatus:Le,debug:n,exitMessage:wo,vimMode:Ue()?io:void 0,mode:ze,autoUpdaterResult:We,isAutoUpdating:To,verbose:Qe,onAutoUpdaterResult:Ve,onChangeIsUpdating:Mo,suggestions:qn,selectedSuggestion:zn,maxColumnWidth:Zn,toolPermissionContext:dr,helpOpen:yo,suppressHint:Ye.length>0,isLoading:Ke,tasksSelected:nn,teamsSelected:an,bridgeSelected:ln,tmuxSelected:sn,teammateFooterIndex:br,ideSelection:lt,mcpClients:ro,isPasting:wr,isInputWrapped:Rs,messages:Ge,isSearching:go,historyQuery:pr,setHistoryQuery:fr,historyFailedMatch:hr,onOpenTasksDialog:Mt()?ws:void 0}),Mt()?null:Ls,Mt()?e(V,{position:"absolute",marginTop:er?-2:-1,height:0!==qn.length||Gr?0:1,width:"100%",paddingLeft:2,paddingRight:1,flexDirection:"column",justifyContent:"flex-end",overflow:"hidden",children:e(Me,{apiKeyStatus:Le,autoUpdaterResult:We,debug:n,isAutoUpdating:To,verbose:Qe,messages:Ge,onAutoUpdaterResult:Ve,onChangeIsUpdating:Mo,ideSelection:lt,mcpClients:ro,isInputWrapped:Rs})}):null]})});
1
+ import{feature as t}from"../../recovery/bunBundleShim.js";import{jsx as e,jsxs as o,Fragment as r}from"react/jsx-runtime";import n from"chalk";import*as s from"path";import*as i from"react";import{useCallback as a,useEffect as l,useMemo as m,useRef as c,useState as u,useSyncExternalStore as d}from"react";import{useNotifications as p}from"../../context/notifications.js";import{useCommandQueue as f}from"../../hooks/useCommandQueue.js";import{useIdeAtMentioned as g}from"../../hooks/useIdeAtMentioned.js";import{logEvent as h}from"../../services/analytics/index.js";import{useAppState as S,useAppStateStore as x,useSetAppState as y}from"../../state/AppState.js";import{getCwd as C}from"../../utils/cwd.js";import{isQueuedCommandEditable as v,popAllEditable as j}from"../../utils/messageQueueManager.js";import b from"strip-ansi";import{companionReservedColumns as k}from"../../buddy/CompanionSprite.js";import{findBuddyTriggerPositions as I,useBuddyNotification as A}from"../../buddy/useBuddyNotification.js";import{FastModePicker as T}from"../../commands/fast/fast.js";import{isUltrareviewEnabled as M}from"../../commands/review/ultrareviewEnabled.js";import{getNativeCSIuTerminalDisplayName as w}from"../../commands/terminalSetup/terminalSetup.js";import{hasCommand as P}from"../../commands.js";import{useIsModalOverlayActive as R}from"../../context/overlayContext.js";import{useSetPromptOverlayDialog as _}from"../../context/promptOverlayContext.js";import{formatImageRef as O,formatPastedTextRef as D,getPastedTextRefNumLines as F,parseReferences as H}from"../../history.js";import{useArrowKeyHistory as E}from"../../hooks/useArrowKeyHistory.js";import{useDoublePress as U}from"../../hooks/useDoublePress.js";import{useHistorySearch as B}from"../../hooks/useHistorySearch.js";import{useInputBuffer as L}from"../../hooks/useInputBuffer.js";import{useMainLoopModel as N}from"../../hooks/useMainLoopModel.js";import{usePromptSuggestion as $}from"../../hooks/usePromptSuggestion.js";import{useTerminalSize as K}from"../../hooks/useTerminalSize.js";import{useTypeahead as Q}from"../../hooks/useTypeahead.js";import{stringWidth as G}from"../../ink/stringWidth.js";import{Box as V,Text as W,useInput as Y}from"../../ink.js";import{useOptionalKeybindingContext as q}from"../../keybindings/KeybindingContext.js";import{getShortcutDisplay as z}from"../../keybindings/shortcutFormat.js";import{useKeybinding as J,useKeybindings as X}from"../../keybindings/useKeybinding.js";import{abortPromptSuggestion as Z,logSuggestionSuppressed as tt}from"../../services/PromptSuggestion/promptSuggestion.js";import{abortSpeculation as et}from"../../services/PromptSuggestion/speculation.js";import{getActiveAgentForInput as ot,getViewedTeammateTask as rt}from"../../state/selectors.js";import{enterTeammateView as nt,exitTeammateView as st,stopOrDismissAgent as it}from"../../state/teammateViewHelpers.js";import{getRunningTeammatesSorted as at}from"../../tasks/InProcessTeammateTask/InProcessTeammateTask.js";import{isPanelAgentTask as lt}from"../../tasks/LocalAgentTask/LocalAgentTask.js";import{isBackgroundTask as mt}from"../../tasks/types.js";import{AGENT_COLOR_TO_THEME_COLOR as ct,AGENT_COLORS as ut}from"../../tools/AgentTool/agentColorManager.js";import{isAgentSwarmsEnabled as dt}from"../../utils/agentSwarmsEnabled.js";import{count as pt}from"../../utils/array.js";import{Cursor as ft}from"../../utils/Cursor.js";import{getGlobalConfig as gt,saveGlobalConfig as ht}from"../../utils/config.js";import{logForDebugging as St}from"../../utils/debug.js";import{parseDirectMemberMessage as xt,sendDirectMemberMessage as yt}from"../../utils/directMemberMessage.js";import{env as Ct}from"../../utils/env.js";import{errorMessage as vt}from"../../utils/errors.js";import{isBilledAsExtraUsage as jt}from"../../utils/extraUsage.js";import{getFastModeUnavailableReason as bt,isFastModeAvailable as kt,isFastModeCooldown as It,isFastModeEnabled as At,isFastModeSupportedByModel as Tt}from"../../utils/fastMode.js";import{isFullscreenEnvEnabled as Mt}from"../../utils/fullscreen.js";import{getImageFromClipboard as wt,PASTE_THRESHOLD as Pt}from"../../utils/imagePaste.js";import{cacheImagePath as Rt,storeImage as _t}from"../../utils/imageStore.js";import{isMacosOptionChar as Ot,MACOS_OPTION_SPECIAL_CHARS as Dt}from"../../utils/keyboardShortcuts.js";import{logError as Ft}from"../../utils/log.js";import{isOpus1mMergeEnabled as Ht,modelDisplayString as Et}from"../../utils/model/model.js";import{setAutoModeActive as Ut}from"../../utils/permissions/autoModeState.js";import{cyclePermissionMode as Bt,getNextPermissionMode as Lt}from"../../utils/permissions/getNextPermissionMode.js";import{transitionPermissionMode as Nt}from"../../utils/permissions/permissionSetup.js";import{getPlatform as $t}from"../../utils/platform.js";import{editPromptInEditor as Kt}from"../../utils/promptEditor.js";import{hasAutoModeOptIn as Qt}from"../../utils/settings/settings.js";import{findBtwTriggerPositions as Gt}from"../../utils/sideQuestion.js";import{findSlashCommandPositions as Vt}from"../../utils/suggestions/commandSuggestions.js";import{findSlackChannelPositions as Wt,getKnownChannelsVersion as Yt,hasSlackMcpServer as qt,subscribeKnownChannels as zt}from"../../utils/suggestions/slackChannelSuggestions.js";import{isInProcessEnabled as Jt}from"../../utils/swarm/backends/registry.js";import{syncTeammateMode as Xt}from"../../utils/swarm/teamHelpers.js";import{getTeammateColor as Zt}from"../../utils/teammate.js";import{isInProcessTeammate as te}from"../../utils/teammateContext.js";import{writeToMailbox as ee}from"../../utils/teammateMailbox.js";import{findThinkingTriggerPositions as oe,getRainbowColor as re,isUltrathinkEnabled as ne}from"../../utils/thinking.js";import{findTokenBudgetPositions as se}from"../../utils/tokenBudget.js";import{findUltraplanTriggerPositions as ie,findUltrareviewTriggerPositions as ae}from"../../utils/ultraplan/keyword.js";import{AutoModeOptInDialog as le}from"../AutoModeOptInDialog.js";import{BridgeDialog as me}from"../BridgeDialog.js";import{ConfigurableShortcutHint as ce}from"../ConfigurableShortcutHint.js";import{getVisibleAgentTasks as ue,useCoordinatorTaskCount as de}from"../CoordinatorAgentStatus.js";import{getEffortNotificationText as pe}from"../EffortIndicator.js";import{getFastIconString as fe}from"../FastIcon.js";import{GlobalSearchDialog as ge}from"../GlobalSearchDialog.js";import{HistorySearchDialog as he}from"../HistorySearchDialog.js";import{ModelPicker as Se}from"../ModelPicker.js";import{QuickOpenDialog as xe}from"../QuickOpenDialog.js";import ye from"../TextInput.js";import{ThinkingToggle as Ce}from"../ThinkingToggle.js";import{BackgroundTasksDialog as ve}from"../tasks/BackgroundTasksDialog.js";import{shouldHideTasksFooter as je}from"../tasks/taskStatusUtils.js";import{TeamsDialog as be}from"../teams/TeamsDialog.js";import ke from"../VimTextInput.js";import{getModeFromInput as Ie,getValueFromInput as Ae}from"./inputModes.js";import{FOOTER_TEMPORARY_STATUS_TIMEOUT as Te,Notifications as Me}from"./Notifications.js";import we from"./PromptInputFooter.js";import{PromptInputModeIndicator as Pe}from"./PromptInputModeIndicator.js";import{PromptInputQueuedCommands as Re}from"./PromptInputQueuedCommands.js";import{PromptInputStashNotice as _e}from"./PromptInputStashNotice.js";import{useMaybeTruncateInput as Oe}from"./useMaybeTruncateInput.js";import{usePromptInputPlaceholder as De}from"./usePromptInputPlaceholder.js";import{useShowFastIconHint as Fe}from"./useShowFastIconHint.js";import{useSwarmBanner as He}from"./useSwarmBanner.js";import{isNonSpacePrintable as Ee,isVimModeEnabled as Ue}from"./utils.js";function buildBorderText(t,e,o){if(!t)return;return{content:` ${e?`${fe(!0,o)} ${n.dim("/fast")}`:fe(!0,o)} `,position:"top",align:"end",offset:0}}export default i.memo(function({debug:n,ideSelection:lt,toolPermissionContext:fe,setToolPermissionContext:Be,apiKeyStatus:Le,commands:Ne,agents:$e,isLoading:Ke,verbose:Qe,messages:Ge,onAutoUpdaterResult:Ve,autoUpdaterResult:We,input:Ye,onInputChange:qe,mode:ze,onModeChange:Je,stashedPrompt:Xe,setStashedPrompt:Ze,submitCount:to,onShowMessageSelector:eo,onMessageActionsEnter:oo,mcpClients:ro,pastedContents:no,setPastedContents:so,vimMode:io,setVimMode:ao,showBashesDialog:lo,setShowBashesDialog:mo,onExit:co,getToolUseContext:uo,onSubmit:po,onAgentSubmit:fo,isSearchingHistory:go,setIsSearchingHistory:ho,onDismissSideQuestion:So,isSideQuestionVisible:xo,helpOpen:yo,setHelpOpen:Co,hasSuppressedDialogs:vo,isLocalJSXCommandActive:jo=!1,insertTextRef:bo,voiceInterimRange:ko}){const Io=N(),Ao=R()||jo,[To,Mo]=u(!1),[wo,Po]=u({show:!1}),[Ro,_o]=u(Ye.length),Oo=i.useRef(Ye);l(()=>{Ye!==Oo.current&&(_o(Ye.length),Oo.current=Ye)},[Ye]);const Do=i.useCallback(t=>{Oo.current=t,qe(t)},[qe]);bo&&(bo.current={cursorOffset:Ro,insert:t=>{const e=Ro===Ye.length&&Ye.length>0&&!/\s$/.test(Ye)?" "+t:t,o=Ye.slice(0,Ro)+e+Ye.slice(Ro);Oo.current=o,qe(o),_o(Ro+e.length)},setInputWithCursor:(t,e)=>{Oo.current=t,qe(t),_o(e)}});const Fo=x(),Ho=y(),Eo=S(t=>t.tasks),Uo=S(t=>t.replBridgeConnected),Bo=S(t=>t.replBridgeExplicit),Lo=S(t=>t.replBridgeReconnecting),No=Uo&&(Bo||Lo),$o=(S(t=>!1),!1),Ko=S(t=>!1),Qo=S(t=>t.teamContext),Go=f(),Vo=S(t=>t.promptSuggestion),Wo=S(t=>t.speculation),Yo=S(t=>t.speculationSessionTimeSavedMs),qo=S(t=>t.viewingAgentTaskId),zo=S(t=>t.viewSelectionMode),Jo="teammates"===S(t=>t.expandedView),{companion:Xo,companionMuted:Zo}=t("BUDDY")?gt():{companion:void 0,companionMuted:void 0},tr=!!Xo&&!Zo,er=!(!t("KAIROS")&&!t("KAIROS_BRIEF"))&&(S(t=>t.isBriefOnly)&&!qo),or=S(t=>t.mainLoopModel),rr=S(t=>t.mainLoopModelForSession),nr=S(t=>t.thinkingEnabled),sr=S(t=>!!At()&&t.fastMode),ir=S(t=>t.effortValue),ar=rt(Fo.getState()),lr=ar?.identity.agentName,mr=ar?.identity.color&&ut.includes(ar.identity.color)?ar.identity.color:void 0,cr=m(()=>at(Eo),[Eo]),ur=cr.length>0||void 0!==ar,dr=m(()=>ar?{...fe,mode:ar.permissionMode}:fe,[ar,fe]),{historyQuery:pr,setHistoryQuery:fr,historyMatch:gr,historyFailedMatch:hr}=B(t=>{so(t.pastedContents),Yn(t.display)},Ye,Do,_o,Ro,Je,ze,go,ho,so,no),Sr=c(-1);-1===Sr.current&&(Sr.current=function(t){let e=0;for(const o of t)if("user"===o.type){if(o.imagePasteIds)for(const t of o.imagePasteIds)t>e&&(e=t);if(Array.isArray(o.message.content))for(const t of o.message.content)if("text"===t.type){const o=H(t.text);for(const t of o)t.id>e&&(e=t.id)}}return e+1}(Ge));const xr=c(!1),[yr,Cr]=u(!1),[vr,jr]=u(!1),[br,kr]=u(0),Ir=S(t=>t.coordinatorTaskIndex),Ar=a(t=>Ho(e=>{const o="function"==typeof t?t(e.coordinatorTaskIndex):t;return o===e.coordinatorTaskIndex?e:{...e,coordinatorTaskIndex:o}}),[Ho]),Tr=de(),Mr=m(()=>Object.values(Eo).some(t=>mt(t)&&!0),[Eo])?-1:0;l(()=>{Ir>=Tr?Ar(Math.max(Mr,Tr-1)):Ir<Mr&&Ar(Mr)},[Tr,Ir,Mr]);const[wr,Pr]=u(!1),[Rr,_r]=u(!1),[Or,Dr]=u(!1),[Fr,Hr]=u(!1),[Er,Ur]=u(!1),[Br,Lr]=u(!1),[Nr,$r]=u(!1),[Kr,Qr]=u(!1),[Gr,Vr]=u(!1),[Wr,Yr]=u(null),qr=c(null),zr=m(()=>{const t=Ye.indexOf("\n");return-1===t||Ro<=t},[Ye,Ro]),Jr=m(()=>{const t=Ye.lastIndexOf("\n");return-1===t||Ro>t},[Ye,Ro]),Xr=m(()=>{if(!dt())return[];if(Jt())return[];if(!Qo)return[];const t=pt(Object.values(Qo.teammates),t=>"team-lead"!==t.name);return[{name:Qo.teamName,memberCount:t,runningCount:0,idleCount:0}]},[Qo]),Zr=m(()=>pt(Object.values(Eo),t=>"running"===t.status),[Eo])>0&&!je(Eo,Jo),tn=Xr.length>0,en=m(()=>[Zr&&"tasks",$o,Ko&&"bagel",tn&&"teams",No&&"bridge",tr&&"companion"].filter(Boolean),[Zr,$o,Ko,tn,No,tr]),on=S(t=>t.footerSelection),rn=on&&en.includes(on)?on:null;l(()=>{on&&!rn&&Ho(t=>null===t.footerSelection?t:{...t,footerSelection:null})},[on,rn,Ho]);const nn="tasks"===rn,sn="tmux"===rn,an="teams"===rn,ln="bridge"===rn;function selectFooterItem(t){Ho(e=>e.footerSelection===t?e:{...e,footerSelection:t}),"tasks"===t&&(kr(0),Ar(Mr))}function navigateFooter(t,e=!1){const o=rn?en.indexOf(rn):-1,r=en[o+t];return r?(selectFooterItem(r),!0):!!(t<0&&e)&&(selectFooterItem(null),!0)}const{suggestion:mn,markAccepted:cn,logOutcomeAtSubmission:un,markShown:dn}=$({inputValue:Ye,isAssistantResponding:Ke}),pn=m(()=>go&&gr?Ae("string"==typeof gr?gr:gr.display):Ye,[go,gr,Ye]),fn=m(()=>oe(pn),[pn]),gn=S(t=>t.ultraplanSessionUrl),hn=S(t=>t.ultraplanLaunching),Sn=m(()=>!t("ULTRAPLAN")||gn||hn?[]:ie(pn),[pn,gn,hn]),xn=m(()=>M()?ae(pn):[],[pn]),yn=m(()=>Gt(pn),[pn]),Cn=m(()=>I(pn),[pn]),vn=m(()=>Vt(pn).filter(t=>{const e=pn.slice(t.start+1,t.end);return P(e,Ne)}),[pn,Ne]),jn=m(()=>t("TOKEN_BUDGET")?se(pn):[],[pn]),bn=d(zt,Yt),kn=m(()=>qt(Fo.getState().mcp.clients)?Wt(pn):[],[pn,bn]),In=m(()=>{if(!dt())return[];if(!Qo?.teammates)return[];const t=[],e=Qo.teammates;if(!e)return t;const o=/(^|\s)@([\w-]+)/g,r=Object.values(e);let n;for(;null!==(n=o.exec(pn));){const e=n[1]??"",o=n.index+e.length,s=n[0].trimStart(),i=n[2],a=r.find(t=>t.name===i);if(a?.color){const e=ct[a.color];e&&t.push({start:o,end:o+s.length,themeColor:e})}}return t},[pn,Qo]),An=m(()=>H(pn).filter(t=>t.match.startsWith("[Image")).map(t=>({start:t.index,end:t.index+t.match.length})),[pn]),Tn=An.some(t=>t.start===Ro);l(()=>{const t=An.find(t=>Ro>t.start&&Ro<t.end);if(t){const e=(t.start+t.end)/2;_o(Ro<e?t.start:t.end)}},[Ro,An,_o]);const Mn=m(()=>{const e=[];for(const t of An)Ro===t.start&&e.push({start:t.start,end:t.end,color:void 0,inverse:!0,priority:8});go&&gr&&!hr&&e.push({start:Ro,end:Ro+pr.length,color:"warning",priority:20});for(const t of yn)e.push({start:t.start,end:t.end,color:"warning",priority:15});for(const t of vn)e.push({start:t.start,end:t.end,color:"suggestion",priority:5});for(const t of jn)e.push({start:t.start,end:t.end,color:"suggestion",priority:5});for(const t of kn)e.push({start:t.start,end:t.end,color:"suggestion",priority:5});for(const t of In)e.push({start:t.start,end:t.end,color:t.themeColor,priority:5});if(ko&&e.push({start:ko.start,end:ko.end,color:void 0,dimColor:!0,priority:1}),ne())for(const t of fn)for(let o=t.start;o<t.end;o++)e.push({start:o,end:o+1,color:re(o-t.start),shimmerColor:re(o-t.start,!0),priority:10});if(t("ULTRAPLAN"))for(const t of Sn)for(let o=t.start;o<t.end;o++)e.push({start:o,end:o+1,color:re(o-t.start),shimmerColor:re(o-t.start,!0),priority:10});for(const t of xn)for(let o=t.start;o<t.end;o++)e.push({start:o,end:o+1,color:re(o-t.start),shimmerColor:re(o-t.start,!0),priority:10});for(const t of Cn)for(let o=t.start;o<t.end;o++)e.push({start:o,end:o+1,color:re(o-t.start),shimmerColor:re(o-t.start,!0),priority:10});return e},[go,pr,gr,hr,Ro,yn,An,In,vn,jn,kn,pn,ko,fn,Sn,xn,Cn]),{addNotification:wn,removeNotification:Pn}=p();l(()=>{fn.length&&ne()?wn({key:"ultrathink-active",text:"Effort set to high for this turn",priority:"immediate",timeoutMs:5e3}):Pn("ultrathink-active")},[wn,Pn,fn.length]),l(()=>{t("ULTRAPLAN")&&Sn.length?wn({key:"ultraplan-active",text:"This prompt will launch an ultraplan session in Context Code on the web",priority:"immediate",timeoutMs:5e3}):Pn("ultraplan-active")},[wn,Pn,Sn.length]),l(()=>{M()&&xn.length&&wn({key:"ultrareview-active",text:"Ejecuta /ultrareview cuando Context termine para revisar estos cambios en la nube",priority:"immediate",timeoutMs:5e3})},[wn,xn.length]);const Rn=c(Ye.length),_n=c(Ye.length),On=a(()=>{Pn("stash-hint")},[Pn]);l(()=>{const t=Rn.current,r=_n.current,n=Ye.length;if(Rn.current=n,n>r)return void(_n.current=n);if(0===n)return void(_n.current=0);if(r>=20&&n<=5&&!(t>=20&&n<=5)){gt().hasUsedStash||wn({key:"stash-hint",jsx:o(W,{dimColor:!0,children:["Tip:"," ",e(ce,{action:"chat:stash",context:"Chat",fallback:"ctrl+s",description:"stash"})]}),priority:"immediate",timeoutMs:Te}),_n.current=n}},[Ye.length,wn]);const{pushToBuffer:Dn,undo:Fn,canUndo:Hn,clearBuffer:En}=L({maxBufferSize:50,debounceMs:1e3});Oe({input:Ye,pastedContents:no,onInputChange:Do,setCursorOffset:_o,setPastedContents:so});const Un=De({input:Ye,submitCount:to,viewingAgentName:lr}),Bn=a(t=>{if("?"===t)return h("tengu_help_toggled",{}),void Co(t=>!t);Co(!1),On(),Z(),et(Ho);const e=t.length===Ye.length+1,o=0===Ro,r=Ie(t);if(o&&"prompt"!==r){if(e)return void Je(r);if(0===Ye.length){Je(r);const e=Ae(t).replaceAll("\t"," ");return Dn(Ye,Ro,no),Do(e),void _o(e.length)}}const n=t.replaceAll("\t"," ");Ye!==n&&Dn(Ye,Ro,no),Ho(t=>null===t.footerSelection?t:{...t,footerSelection:null}),Do(n)},[Do,Je,Ye,Ro,Dn,no,On,Ho]),{resetHistory:Ln,onHistoryUp:Nn,onHistoryDown:$n,dismissSearchHint:Kn,historyIndex:Qn}=E((t,e,o)=>{Bn(t),Je(e),so(o)},Ye,no,_o,ze);l(()=>{go&&Kn()},[go,Kn]);const[Gn,Vn]=u({suggestions:[],selectedSuggestion:-1,commandArgumentHint:void 0}),Wn=a(t=>{Vn(e=>"function"==typeof t?t(e):t)},[]),Yn=a(async(t,e=!1)=>{t=t.trimEnd();const o=Fo.getState();if(o.footerSelection&&en.includes(o.footerSelection))return;if("selecting-agent"===o.viewSelectionMode)return;const r=Object.values(no).some(t=>"image"===t.type),n=Vo.text;if((""===t.trim()||t===n)&&n&&!r&&!o.viewingAgentTaskId){if("active"===Wo.status)return cn(),un(n,{skipReset:!0}),void po(n,{setCursorOffset:_o,clearBuffer:En,resetHistory:Ln},{state:Wo,speculationSessionTimeSavedMs:Yo,setAppState:Ho});Vo.shownAt>0&&(cn(),t=n)}if(dt()){const e=xt(t);if(e){const t=await yt(e.recipientName,e.message,Qo,ee);if(t.success)return wn({key:"direct-message-sent",text:`Sent to @${t.recipientName}`,priority:"immediate",timeoutMs:3e3}),Do(""),_o(0),En(),void Ln();t.error}}if(""===t.trim()&&!r)return;const s=Gn.suggestions.length>0&&Gn.suggestions.every(t=>"directory"===t.description);if(Gn.suggestions.length>0&&!e&&!s)return void St(`[onSubmit] early return: suggestions showing (count=${Gn.suggestions.length})`);Vo.text&&Vo.shownAt>0&&un(t),Pn("stash-hint");const i=ot(Fo.getState());if("leader"!==i.type&&fo)return h("tengu_transcript_input_to_teammate",{}),void await fo(t,i.task,{setCursorOffset:_o,clearBuffer:En,resetHistory:Ln});await po(t,{setCursorOffset:_o,clearBuffer:En,resetHistory:Ln})},[Vo,Wo,Yo,Qo,Fo,en,Gn.suggestions,po,fo,En,Ln,un,Ho,cn,no,Pn]),{suggestions:qn,selectedSuggestion:zn,commandArgumentHint:Jn,inlineGhostText:Xn,maxColumnWidth:Zn}=Q({commands:Ne,onInputChange:Do,onSubmit:Yn,setCursorOffset:_o,input:Ye,cursorOffset:Ro,mode:ze,agents:$e,setSuggestionsState:Wn,suggestionsState:Gn,suppressSuggestions:go||Qn>0,markAccepted:cn,onModeChange:Je}),ts="prompt"===ze&&0===qn.length&&mn&&!qo;function onImagePaste(t,e,o,r,n){h("tengu_paste_image",{}),Je("prompt");const s=Sr.current++,i={id:s,type:"image",content:t,mediaType:e||"image/png",filename:o||"Pasted image",dimensions:r,sourcePath:n};Rt(i),_t(i),so(t=>({...t,[s]:i}));insertTextAtCursor((xr.current?" ":"")+O(s)),xr.current=!0}ts&&dn(),!Vo.text||mn||0!==Vo.shownAt||qo||(tt("timing",Vo.text),Ho(t=>({...t,promptSuggestion:{text:null,promptId:null,shownAt:0,acceptedAt:0,generationRequestId:null}}))),l(()=>{const t=new Set(H(Ye).map(t=>t.id));so(e=>{const o=Object.values(e).filter(e=>"image"===e.type&&!t.has(e.id));if(0===o.length)return e;const r={...e};for(const t of o)delete r[t.id];return r})},[Ye,so]);const es=a((t,e)=>xr.current?(xr.current=!1,Ee(t,e)?" "+t:t):t,[]);function insertTextAtCursor(t){Dn(Ye,Ro,no);const e=Ye.slice(0,Ro)+t+Ye.slice(Ro);Do(e),_o(Ro+t.length)}const os=U(()=>{},()=>eo()),rs=a(()=>{const t=j(Ye,Ro);return!!t&&(Do(t.text),Je("prompt"),_o(t.cursorOffset),t.images.length>0&&so(e=>{const o={...e};for(const e of t.images)o[e.id]=e;return o}),!0)},[Do,Je,Ye,Ro,so]);g(ro,function(t){let e;h("tengu_ext_at_mentioned",{});const o=s.relative(C(),t.filePath);e=t.lineStart&&t.lineEnd?t.lineStart===t.lineEnd?`@${o}#L${t.lineStart} `:`@${o}#L${t.lineStart}-${t.lineEnd} `:`@${o} `;const r=Ye[Ro-1]??" ";/\s/.test(r)||(e=` ${e}`),insertTextAtCursor(e)});const ns=a(()=>{if(Hn){const t=Fn();t&&(Do(t.text),_o(t.cursorOffset),so(t.pastedContents))}},[Hn,Fn,Do,so]),ss=a(()=>{Dn(Ye,Ro,no);const t=Ye.slice(0,Ro)+"\n"+Ye.slice(Ro);Do(t),_o(Ro+1)},[Ye,Ro,Do,_o,Dn,no]),is=a(async()=>{h("tengu_external_editor_used",{}),_r(!0);try{const t=await Kt(Ye,no);t.error&&wn({key:"external-editor-error",text:t.error,color:"warning",priority:"high"}),null!==t.content&&t.content!==Ye&&(Dn(Ye,Ro,no),Do(t.content),_o(t.content.length))}catch(t){t instanceof Error&&Ft(t),wn({key:"external-editor-error",text:`External editor failed: ${vt(t)}`,color:"warning",priority:"high"})}finally{_r(!1)}},[Ye,Ro,no,Dn,Do,wn]),as=a(()=>{""===Ye.trim()&&void 0!==Xe?(Do(Xe.text),_o(Xe.cursorOffset),so(Xe.pastedContents),Ze(void 0)):""!==Ye.trim()&&(Ze({text:Ye,cursorOffset:Ro,pastedContents:no}),Do(""),_o(0),so({}),ht(t=>t.hasUsedStash?t:{...t,hasUsedStash:!0}))},[Ye,Ro,Xe,Do,Ze,no,so]),ls=a(()=>{Dr(t=>!t),yo&&Co(!1)},[yo]),ms=a(()=>{$r(t=>!t),yo&&Co(!1)},[yo]),cs=a(()=>{Qr(t=>!t),yo&&Co(!1)},[yo]),us=a(()=>{if(dt()&&ar&&qo){const t={...fe,mode:ar.permissionMode},e=Lt(t,void 0);h("tengu_mode_cycle",{to:e});const o=qo;return Ho(t=>{const r=t.tasks[o];return r&&"in_process_teammate"===r.type?r.permissionMode===e?t:{...t,tasks:{...t.tasks,[o]:{...r,permissionMode:e}}}:t}),void(yo&&Co(!1))}St(`[auto-mode] handleCycleMode: currentMode=${fe.mode} isAutoModeAvailable=${fe.isAutoModeAvailable} showAutoModeOptIn=${Gr} timeoutPending=${!!qr.current}`);const e=Lt(fe,Qo);let o=!1;if(t("TRANSCRIPT_CLASSIFIER")&&(o="auto"===e&&"auto"!==fe.mode&&!Qt()&&!qo),t("TRANSCRIPT_CLASSIFIER")&&o)return Yr(fe.mode),Ho(t=>({...t,toolPermissionContext:{...t.toolPermissionContext,mode:"auto"}})),Be({...fe,mode:"auto"}),qr.current&&clearTimeout(qr.current),qr.current=setTimeout((t,e)=>{t(!0),e.current=null},400,Vr,qr),void(yo&&Co(!1));t("TRANSCRIPT_CLASSIFIER")&&(Gr||qr.current)&&(Gr&&h("tengu_auto_mode_opt_in_dialog_decline",{}),Vr(!1),qr.current&&(clearTimeout(qr.current),qr.current=null),Yr(null));const{context:r}=Bt(fe,Qo);h("tengu_mode_cycle",{to:e}),"plan"===e&&ht(t=>({...t,lastPlanModeUse:Date.now()})),Ho(t=>({...t,toolPermissionContext:{...r,mode:e}})),Be({...r,mode:e}),Xt(e,Qo?.teamName),yo&&Co(!1)},[fe,Qo,qo,ar,Ho,Be,yo,Gr]),ds=a(()=>{if(t("TRANSCRIPT_CLASSIFIER")){Vr(!1),Yr(null);const t=Nt(Wr??fe.mode,"auto",fe);Ho(e=>({...e,toolPermissionContext:{...t,mode:"auto"}})),Be({...t,mode:"auto"}),yo&&Co(!1)}},[yo,Co,Wr,fe,Ho,Be]),ps=a(()=>{t("TRANSCRIPT_CLASSIFIER")&&(St(`[auto-mode] handleAutoModeOptInDecline: reverting to ${Wr}, setting isAutoModeAvailable=false`),Vr(!1),qr.current&&(clearTimeout(qr.current),qr.current=null),Wr&&(Ut(!1),Ho(t=>({...t,toolPermissionContext:{...t.toolPermissionContext,mode:Wr,isAutoModeAvailable:!1}})),Be({...fe,mode:Wr,isAutoModeAvailable:!1}),Yr(null)))},[Wr,fe,Ho,Be]),fs=a(()=>{wt().then(t=>{if(t)onImagePaste(t.base64,t.mediaType);else{const t=z("chat:imagePaste","Chat","ctrl+v"),e=Ct.isSSH()?"No image found in clipboard. You're SSH'd; try scp?":`No image found in clipboard. Use ${t} to paste images.`;wn({key:"no-image-in-clipboard",text:e,priority:"immediate",timeoutMs:1e3})}})},[wn,onImagePaste]),gs=q();l(()=>{if(gs&&!Ao)return gs.registerHandler({action:"chat:submit",context:"Chat",handler:()=>{Yn(Ye)}})},[gs,Ao,Yn,Ye]);const hs=m(()=>({"chat:undo":ns,"chat:newline":ss,"chat:externalEditor":is,"chat:stash":as,"chat:modelPicker":ls,"chat:thinkingToggle":cs,"chat:cycleMode":us,"chat:imagePaste":fs}),[ns,ss,is,as,ls,cs,us,fs]);X(hs,{context:"Chat",isActive:!Ao}),J("chat:messageActions",()=>oo?.(),{context:"Chat",isActive:!Ao&&!go}),J("chat:fastMode",ms,{context:"Chat",isActive:!Ao&&At()&&kt()}),J("help:dismiss",()=>{Co(!1)},{context:"Help",isActive:yo});const Ss=!!t("QUICK_SEARCH")&&!Ao;J("app:quickOpen",()=>{t("QUICK_SEARCH")&&(Hr(!0),Co(!1))},{context:"Global",isActive:Ss}),J("app:globalSearch",()=>{t("QUICK_SEARCH")&&(Ur(!0),Co(!1))},{context:"Global",isActive:Ss}),J("history:search",()=>{t("HISTORY_PICKER")&&(Lr(!0),Co(!1))},{context:"Global",isActive:!!t("HISTORY_PICKER")&&!Ao}),J("app:interrupt",()=>{et(Ho)},{context:"Global",isActive:!Ke&&"active"===Wo.status}),X({"footer:up":()=>{navigateFooter(-1,!0)},"footer:down":()=>{if(nn&&!ur)return mo(!0),void selectFooterItem(null);navigateFooter(1)},"footer:next":()=>{if(nn&&ur){const t=1+cr.length;return void kr(e=>(e+1)%t)}navigateFooter(1)},"footer:previous":()=>{if(nn&&ur){const t=1+cr.length;return void kr(e=>(e-1+t)%t)}navigateFooter(-1)},"footer:openSelected":()=>{if("selecting-agent"!==zo)switch(rn){case"companion":t("BUDDY")&&(selectFooterItem(null),Yn("/buddy"));break;case"tasks":if(ur)if(0===br)st(Ho);else{const t=cr[br-1];t&&nt(t.id,Ho)}else if(0===Ir&&Tr>0)st(Ho);else{const t=ue(Eo)[Ir-1]?.id;t?nt(t,Ho):(mo(!0),selectFooterItem(null))}break;case"tmux":0;break;case"bagel":break;case"teams":Cr(!0),selectFooterItem(null);break;case"bridge":jr(!0),selectFooterItem(null)}},"footer:clearSelection":()=>{selectFooterItem(null)},"footer:close":()=>{if(nn&&Ir>=1){const t=ue(Eo)[Ir-1];return!!t&&("viewing-agent"===zo&&t.id===qo?(Bn(Ye.slice(0,Ro)+"x"+Ye.slice(Ro)),void _o(Ro+1)):(it(t.id,Ho),void("running"!==t.status&&Ar(t=>Math.max(Mr,t-1)))))}return!1}},{context:"Footer",isActive:!!rn&&!Ao}),Y((t,r)=>{if(!(yr||Fr||Er||Br)){if("macos"===$t()&&Ot(t)){const r=Dt[t],n=w(),s=o(W,n?{dimColor:!0,children:["To enable ",r,", set ",e(W,{bold:!0,children:"Option as Meta"})," in"," ",n," preferences (⌘,)"]}:{dimColor:!0,children:["To enable ",r,", run /terminal-setup"]});wn({key:"option-meta-hint",jsx:s,priority:"immediate",timeoutMs:5e3})}if(rn&&t&&!r.ctrl&&!r.meta&&!r.escape&&!r.return)return Bn(Ye.slice(0,Ro)+t+Ye.slice(Ro)),void _o(Ro+t.length);if(0===Ro&&(r.escape||r.backspace||r.delete||r.ctrl&&"u"===t)&&(Je("prompt"),Co(!1)),yo&&""===Ye&&(r.backspace||r.delete)&&Co(!1),r.escape){if("active"===Wo.status)return void et(Ho);if(xo&&So)return void So();if(yo)return void Co(!1);if(rn)return;if(Go.some(v))return void rs();Ge.length>0&&!Ye&&!Ke&&os()}r.return&&yo&&Co(!1)}});const xs=He(),ys=!!At()&&It(),Cs=!!At()&&(sr&&(kt()||ys)),vs=Fe(Cs??!1),js=er?void 0:pe(ir,Io);l(()=>{js?wn({key:"effort-level",text:js,priority:"high",timeoutMs:12e3}):Pn("effort-level")},[js,wn,Pn]),A();const bs=!!t("BUDDY")&&S(t=>void 0!==t.companionReaction),{columns:ks,rows:Is}=K(),As=ks-3-k(ks,bs),Ts=Mt()?Math.max(3,Math.floor(Is/2)-5):void 0,Ms=a(t=>{if(!Ye||go)return;const e=ft.fromText(Ye,As,Ro),o=e.getViewportStartLine(Ts),r=e.measuredText.getOffsetFromPosition({line:t.localRow+o,column:t.localCol});_o(r)},[Ye,As,go,Ro,Ts]),ws=a(t=>mo(t??!0),[mo]),Ps=ts&&mn?mn:Un,Rs=m(()=>Ye.includes("\n"),[Ye]),_s=a((t,o)=>{let r=!1;Ho(e=>(r=At()&&!Tt(t)&&!!e.fastMode,{...e,mainLoopModel:t,mainLoopModelForSession:null,...r&&{fastMode:!1}})),Dr(!1);const n=(sr??!1)&&!r;let s=`Model set to ${Et(t)}`;jt(t,n,Ht())&&(s+=" · Billed as extra usage"),r&&(s+=" · Fast mode OFF"),wn({key:"model-switched",jsx:e(W,{children:s}),priority:"immediate",timeoutMs:3e3}),h("tengu_model_picker_hotkey",{model:t})},[Ho,wn,sr]),Os=a(()=>{Dr(!1)},[]),Ds=m(()=>Or?e(V,{flexDirection:"column",marginTop:1,children:e(Se,{initial:or,sessionModel:rr,onSelect:_s,onCancel:Os,isStandaloneCommand:!0,showFastModeNotice:At()&&sr&&Tt(or)&&kt()})}):null,[Or,or,rr,_s,Os]),Fs=a(t=>{$r(!1),t&&wn({key:"fast-mode-toggled",jsx:e(W,{children:t}),priority:"immediate",timeoutMs:3e3})},[wn]),Hs=m(()=>Nr?e(V,{flexDirection:"column",marginTop:1,children:e(T,{onDone:Fs,unavailableReason:bt()})}):null,[Nr,Fs]),Es=a(t=>{Ho(e=>({...e,thinkingEnabled:t})),Qr(!1),h("tengu_thinking_toggled_hotkey",{enabled:t}),wn({key:"thinking-toggled-hotkey",jsx:o(W,{color:t?"suggestion":void 0,dimColor:!t,children:["Thinking ",t?"on":"off"]}),priority:"immediate",timeoutMs:3e3})},[Ho,wn]),Us=a(()=>{Qr(!1)},[]),Bs=m(()=>Kr?e(V,{flexDirection:"column",marginTop:1,children:e(Ce,{currentValue:nr??!0,onSelect:Es,onCancel:Us,isMidConversation:Ge.some(t=>"assistant"===t.type)})}):null,[Kr,nr,Es,Us,Ge.length]),Ls=m(()=>t("TRANSCRIPT_CLASSIFIER")&&Gr?e(le,{onAccept:ds,onDecline:ps}):null,[Gr,ds,ps]);if(_(Mt()?Ls:null),lo)return e(ve,{onDone:()=>mo(!1),toolUseContext:uo(Ge,[],new AbortController,Io),initialDetailTaskId:"string"==typeof lo?lo:void 0});if(dt()&&yr)return e(be,{initialTeams:Xr,onDone:()=>{Cr(!1)}});if(t("QUICK_SEARCH")){const insertWithSpacing=t=>{const e=Ye[Ro-1]??" ";insertTextAtCursor(/\s/.test(e)?t:` ${t}`)};if(Fr)return e(xe,{onDone:()=>Hr(!1),onInsert:insertWithSpacing});if(Er)return e(ge,{onDone:()=>Ur(!1),onInsert:insertWithSpacing})}if(t("HISTORY_PICKER")&&Br)return e(he,{initialQuery:Ye,onSelect:t=>{const e=Ie(t.display),o=Ae(t.display);Je(e),Do(o),so(t.pastedContents),_o(o.length),Lr(!1)},onCancel:()=>Lr(!1)});if(Ds)return Ds;if(Hs)return Hs;if(Bs)return Bs;if(vr)return e(me,{onDone:()=>{jr(!1),selectFooterItem(null)}});const Ns={multiline:!0,onSubmit:Yn,onChange:Bn,value:gr?Ae("string"==typeof gr?gr:gr.display):Ye,onHistoryUp:function(){if(qn.length>1)return;if(!zr)return;Go.some(v)?rs():Nn()},onHistoryDown:function(){if(!(qn.length>1)&&Jr&&$n()&&en.length>0){const t=en[0];selectFooterItem(t),"tasks"!==t||gt().hasSeenTasksHint||ht(t=>t.hasSeenTasksHint?t:{...t,hasSeenTasksHint:!0})}},onHistoryReset:Ln,placeholder:Ps,onExit:co,onExitMessage:(t,e)=>Po({show:t,key:e}),onImagePaste,columns:As,maxVisibleLines:Ts,disableCursorMovementForUpDownKeys:qn.length>0||!!rn,disableEscapeDoublePress:qn.length>0,cursorOffset:Ro,onChangeCursorOffset:_o,onPaste:function(t){xr.current=!1;let e=b(t).replace(/\r/g,"\n").replaceAll("\t"," ");if(0===Ye.length){const t=Ie(e);"prompt"!==t&&(Je(t),e=Ae(e))}const o=F(e),r=Math.min((process.stdout.rows||24)-10,2);if(e.length>Pt||o>r){const t=Object.keys(no).map(Number);let r=Sr.current;t.length>0&&(r=Math.max(r,Math.max(...t)+1)),Sr.current=r+1;const n={id:r,type:"text",content:e};so(t=>({...t,[r]:n})),insertTextAtCursor(D(r,o))}else insertTextAtCursor(e)},onIsPastingChange:Pr,focus:!go&&!Ao&&!rn,showCursor:!rn&&!go&&!Tn,argumentHint:Jn,onUndo:Hn?()=>{const t=Fn();t&&(Do(t.text),_o(t.cursorOffset),so(t.pastedContents))}:void 0,highlights:Mn,inlineGhostText:Xn,inputFilter:es},getBorderColor=()=>{const t={bash:"bashBorder"};if(t[ze])return t[ze];if(te())return"promptBorder";const e=Zt();return e&&ut.includes(e)?ct[e]:"promptBorder"};if(Rr)return e(V,{flexDirection:"row",alignItems:"center",justifyContent:"center",borderColor:getBorderColor(),borderStyle:"round",borderLeft:!1,borderRight:!1,borderBottom:!0,width:"100%",children:e(W,{dimColor:!0,italic:!0,children:"Save and close editor to continue..."})});const $s=Ue()?e(ke,{...Ns,initialMode:io,onModeChange:ao}):e(ye,{...Ns});return o(V,{flexDirection:"column",marginTop:er?0:1,children:[!Mt()&&e(Re,{}),vo&&e(V,{marginTop:1,marginLeft:2,children:e(W,{dimColor:!0,children:"Waiting for permission…"})}),e(_e,{hasStash:void 0!==Xe}),xs?o(r,{children:[e(W,{color:xs.bgColor,children:xs.text?o(r,{children:["─".repeat(Math.max(0,ks-G(xs.text)-4)),o(W,{backgroundColor:xs.bgColor,color:"inverseText",children:[" ",xs.text," "]}),"──"]}):"─".repeat(ks)}),o(V,{flexDirection:"row",width:"100%",children:[e(Pe,{mode:ze,isLoading:Ke,viewingAgentName:lr,viewingAgentColor:mr}),e(V,{flexGrow:1,flexShrink:1,onClick:Ms,children:$s})]}),e(W,{color:xs.bgColor,children:"─".repeat(ks)})]}):o(V,{flexDirection:"row",alignItems:"flex-start",justifyContent:"flex-start",borderColor:getBorderColor(),borderStyle:"round",borderLeft:!1,borderRight:!1,borderBottom:!0,width:"100%",borderText:buildBorderText(Cs??!1,vs,ys),children:[e(Pe,{mode:ze,isLoading:Ke,viewingAgentName:lr,viewingAgentColor:mr}),e(V,{flexGrow:1,flexShrink:1,onClick:Ms,children:$s})]}),e(we,{apiKeyStatus:Le,debug:n,exitMessage:wo,vimMode:Ue()?io:void 0,mode:ze,autoUpdaterResult:We,isAutoUpdating:To,verbose:Qe,onAutoUpdaterResult:Ve,onChangeIsUpdating:Mo,suggestions:qn,selectedSuggestion:zn,maxColumnWidth:Zn,toolPermissionContext:dr,helpOpen:yo,suppressHint:Ye.length>0,isLoading:Ke,tasksSelected:nn,teamsSelected:an,bridgeSelected:ln,tmuxSelected:sn,teammateFooterIndex:br,ideSelection:lt,mcpClients:ro,isPasting:wr,isInputWrapped:Rs,messages:Ge,isSearching:go,historyQuery:pr,setHistoryQuery:fr,historyFailedMatch:hr,onOpenTasksDialog:Mt()?ws:void 0}),Mt()?null:Ls,Mt()?e(V,{position:"absolute",marginTop:er?-2:-1,height:0!==qn.length||Gr?0:1,width:"100%",paddingLeft:2,paddingRight:1,flexDirection:"column",justifyContent:"flex-end",overflow:"hidden",children:e(Me,{apiKeyStatus:Le,autoUpdaterResult:We,debug:n,isAutoUpdating:To,verbose:Qe,messages:Ge,onAutoUpdaterResult:Ve,onChangeIsUpdating:Mo,ideSelection:lt,mcpClients:ro,isInputWrapped:Rs})}):null]})});
@@ -1 +1 @@
1
- import{jsx as e,jsxs as o}from"react/jsx-runtime";import{useCallback as n,useEffect as t,useRef as r}from"react";import{isBridgeEnabled as i}from"../bridge/bridgeEnabled.js";import{Box as s,Text as c}from"../ink.js";import{getClaudeAIOAuthTokens as l}from"../utils/auth.js";import{getGlobalConfig as a,saveGlobalConfig as m}from"../utils/config.js";import{Select as u}from"./CustomSelect/select.js";import{PermissionDialog as d}from"./permissions/PermissionDialog.js";export function RemoteCallout({onDone:i}){const l=r(i);l.current=i;const a=n(()=>{l.current("dismiss")},[]);t(()=>{m(e=>e.remoteDialogSeen?e:{...e,remoteDialogSeen:!0})},[]);const p=n(e=>{l.current(e)},[]);return e(d,{title:"Remote Control",children:o(s,{flexDirection:"column",paddingX:2,paddingY:1,children:[o(s,{marginBottom:1,flexDirection:"column",children:[e(c,{children:"Remote Control lets you access this CLI session from the web (claude.ai/code) or the Claude app, so you can pick up where you left off on any device."}),e(c,{children:" "}),e(c,{children:"You can disconnect remote access anytime by running /remote-control again."})]}),e(s,{children:e(u,{options:[{label:"Enable Remote Control for this session",description:"Opens a secure connection to claude.ai.",value:"enable"},{label:"Never mind",description:"You can always enable it later with /remote-control.",value:"dismiss"}],onChange:p,onCancel:a})})]})})}export function shouldShowRemoteCallout(){if(a().remoteDialogSeen)return!1;if(!i())return!1;const e=l();return!!e?.accessToken}
1
+ import{jsx as e,jsxs as o}from"react/jsx-runtime";import{useCallback as n,useEffect as r,useRef as t}from"react";import{isBridgeEnabled as i}from"../bridge/bridgeEnabled.js";import{Box as s,Text as c}from"../ink.js";import{getClaudeAIOAuthTokens as l}from"../utils/auth.js";import{getGlobalConfig as a,saveGlobalConfig as m}from"../utils/config.js";import{Select as u}from"./CustomSelect/select.js";import{PermissionDialog as d}from"./permissions/PermissionDialog.js";export function RemoteCallout({onDone:i}){const l=t(i);l.current=i;const a=n(()=>{l.current("dismiss")},[]);r(()=>{m(e=>e.remoteDialogSeen?e:{...e,remoteDialogSeen:!0})},[]);const p=n(e=>{l.current(e)},[]);return e(d,{title:"Remote Control",children:o(s,{flexDirection:"column",paddingX:2,paddingY:1,children:[o(s,{marginBottom:1,flexDirection:"column",children:[e(c,{children:"Remote Control lets you access this CLI session from the web (claude.ai/code) or the Claude app, so you can pick up where you left off on any device."}),e(c,{children:" "}),e(c,{children:"You can disconnect remote access anytime by running /remote-control again."})]}),e(s,{children:e(u,{options:[{label:"Habilitar Remote Control para esta sesión",description:"Abre una conexión segura con Context.",value:"enable"},{label:"Cancelar",description:"Siempre puedes habilitarlo después con /remote-control.",value:"dismiss"}],onChange:p,onCancel:a})})]})})}export function shouldShowRemoteCallout(){if(a().remoteDialogSeen)return!1;if(!i())return!1;const e=l();return!!e?.accessToken}
@@ -1 +1 @@
1
- import{jsx as e,jsxs as n}from"react/jsx-runtime";import{useCallback as r,useState as o}from"react";import{useTerminalSize as i}from"../hooks/useTerminalSize.js";import{fetchCodeSessionsFromSessionsAPI as t}from"../utils/teleport/api.js";import{Box as c,Text as l,useInput as d}from"../ink.js";import{useKeybinding as s}from"../keybindings/useKeybinding.js";import{useShortcutDisplay as a}from"../keybindings/useShortcutDisplay.js";import{logForDebugging as u}from"../utils/debug.js";import{detectCurrentRepository as m}from"../utils/detectRepository.js";import{formatRelativeTime as h}from"../utils/format.js";import{ConfigurableShortcutHint as f}from"./ConfigurableShortcutHint.js";import{Select as p}from"./CustomSelect/index.js";import{Byline as g}from"./design-system/Byline.js";import{KeyboardShortcutHint as C}from"./design-system/KeyboardShortcutHint.js";import{Spinner as x}from"./Spinner.js";import{TeleportError as b}from"./TeleportError.js";const y="Updated";export function ResumeTask({onSelect:j,onCancel:w,isEmbedded:S=!1}){const{rows:D}=i(),[E,k]=o([]),[T,$]=o(null),[v,R]=o(!0),[M,Y]=o(null),[F,G]=o(!1),[L,P]=o(!1),[_,H]=o(1),K=a("confirm:no","Confirmation","Esc"),q=r(async()=>{try{R(!0),Y(null);const e=await m();$(e),u(`Current repository: ${e||"not detected"}`);const n=await t();let r=n;e&&(r=n.filter(n=>{if(!n.repo)return!1;return`${n.repo.owner.login}/${n.repo.name}`===e}),u(`Filtered ${r.length} sessions for repo ${e} from ${n.length} total`));const o=[...r].sort((e,n)=>{const r=new Date(e.updated_at);return new Date(n.updated_at).getTime()-r.getTime()});k(o)}catch(e){const n=e instanceof Error?e.message:String(e);u(`Error loading code sessions: ${n}`),Y(function(e){const n=e.toLowerCase();if(n.includes("fetch")||n.includes("network")||n.includes("timeout"))return"network";if(n.includes("auth")||n.includes("token")||n.includes("permission")||n.includes("oauth")||n.includes("not authenticated")||n.includes("/login")||n.includes("console account")||n.includes("403"))return"auth";if(n.includes("api")||n.includes("rate limit")||n.includes("500")||n.includes("529"))return"api";return"other"}(n))}finally{R(!1),G(!1)}},[]);s("confirm:no",w,{context:"Confirmation"}),d((e,n)=>{if(!n.ctrl||"c"!==e)return n.ctrl&&"r"===e&&M?(G(!0),void q()):void(null!==M&&n.return&&w());w()});const z=r(()=>{P(!0),q()},[P,q]);if(!L)return e(b,{onComplete:z});if(v)return n(c,{flexDirection:"column",padding:1,children:[n(c,{flexDirection:"row",children:[e(x,{}),e(l,{bold:!0,children:"Loading Context Code sessions…"})]}),e(l,{dimColor:!0,children:F?"Retrying…":"Fetching your Context Code sessions…"})]});if(M)return n(c,{flexDirection:"column",padding:1,children:[e(l,{bold:!0,color:"error",children:"Error loading Context Code sessions"}),renderErrorSpecificGuidance(M),n(l,{dimColor:!0,children:["Press ",e(l,{bold:!0,children:"Ctrl+R"})," to retry · Press"," ",e(l,{bold:!0,children:K})," to cancel"]})]});if(0===E.length)return n(c,{flexDirection:"column",padding:1,children:[n(l,{bold:!0,children:["No Context Code sessions found",T&&n(l,{children:[" for ",T]})]}),e(c,{marginTop:1,children:n(l,{dimColor:!0,children:["Press ",e(l,{bold:!0,children:K})," to cancel"]})})]});const B=E.map(e=>({...e,timeString:h(new Date(e.updated_at))})),I=Math.max(7,...B.map(e=>e.timeString.length)),N=B.map(({timeString:e,title:n,id:r})=>({label:`${e.padEnd(I," ")} ${n}`,value:r})),O=Math.max(1,S?Math.min(E.length,5,D-6-7):Math.min(E.length,D-1-7)),U=O+7,A=E.length>O;return n(c,{flexDirection:"column",padding:1,height:U,children:[n(l,{bold:!0,children:["Select a session to resume",A&&n(l,{dimColor:!0,children:[" ","(",_," of ",E.length,")"]}),T&&n(l,{dimColor:!0,children:[" (",T,")"]}),":"]}),n(c,{flexDirection:"column",marginTop:1,flexGrow:1,children:[e(c,{marginLeft:2,children:n(l,{bold:!0,children:[y.padEnd(I," ")," ","Session Title"]})}),e(p,{visibleOptionCount:O,options:N,onChange:e=>{const n=E.find(n=>n.id===e);n&&j(n)},onFocus:e=>{const n=N.findIndex(n=>n.value===e);n>=0&&H(n+1)}})]}),e(c,{flexDirection:"row",children:e(l,{dimColor:!0,children:n(g,{children:[e(C,{shortcut:"↑/↓",action:"seleccionar"}),e(C,{shortcut:"Enter",action:"confirmar"}),e(f,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"cancelar"})]})})})]})}function renderErrorSpecificGuidance(r){switch(r){case"network":return e(c,{marginY:1,flexDirection:"column",children:e(l,{dimColor:!0,children:"Check your internet connection"})});case"auth":return n(c,{marginY:1,flexDirection:"column",children:[e(l,{dimColor:!0,children:"Teleport requires a Claude account"}),n(l,{dimColor:!0,children:["Run ",e(l,{bold:!0,children:"/login"}),' and select "Claude account with subscription"']})]});case"api":return e(c,{marginY:1,flexDirection:"column",children:e(l,{dimColor:!0,children:"Sorry, Claude encountered an error"})});case"other":return e(c,{marginY:1,flexDirection:"row",children:e(l,{dimColor:!0,children:"Sorry, Context Code encountered an error"})})}}
1
+ import{jsx as e,jsxs as n}from"react/jsx-runtime";import{useCallback as r,useState as o}from"react";import{useTerminalSize as i}from"../hooks/useTerminalSize.js";import{fetchCodeSessionsFromSessionsAPI as t}from"../utils/teleport/api.js";import{Box as c,Text as l,useInput as s}from"../ink.js";import{useKeybinding as d}from"../keybindings/useKeybinding.js";import{useShortcutDisplay as a}from"../keybindings/useShortcutDisplay.js";import{logForDebugging as m}from"../utils/debug.js";import{detectCurrentRepository as u}from"../utils/detectRepository.js";import{formatRelativeTime as h}from"../utils/format.js";import{ConfigurableShortcutHint as f}from"./ConfigurableShortcutHint.js";import{Select as p}from"./CustomSelect/index.js";import{Byline as g}from"./design-system/Byline.js";import{KeyboardShortcutHint as C}from"./design-system/KeyboardShortcutHint.js";import{Spinner as x}from"./Spinner.js";import{TeleportError as b}from"./TeleportError.js";const j="Updated";export function ResumeTask({onSelect:y,onCancel:w,isEmbedded:D=!1}){const{rows:S}=i(),[E,k]=o([]),[T,$]=o(null),[v,L]=o(!0),[M,R]=o(null),[Y,F]=o(!1),[G,P]=o(!1),[_,H]=o(1),K=a("confirm:no","Confirmation","Esc"),q=r(async()=>{try{L(!0),R(null);const e=await u();$(e),m(`Current repository: ${e||"not detected"}`);const n=await t();let r=n;e&&(r=n.filter(n=>{if(!n.repo)return!1;return`${n.repo.owner.login}/${n.repo.name}`===e}),m(`Filtered ${r.length} sessions for repo ${e} from ${n.length} total`));const o=[...r].sort((e,n)=>{const r=new Date(e.updated_at);return new Date(n.updated_at).getTime()-r.getTime()});k(o)}catch(e){const n=e instanceof Error?e.message:String(e);m(`Error loading code sessions: ${n}`),R(function(e){const n=e.toLowerCase();if(n.includes("fetch")||n.includes("network")||n.includes("timeout"))return"network";if(n.includes("auth")||n.includes("token")||n.includes("permission")||n.includes("oauth")||n.includes("not authenticated")||n.includes("/login")||n.includes("console account")||n.includes("403"))return"auth";if(n.includes("api")||n.includes("rate limit")||n.includes("500")||n.includes("529"))return"api";return"other"}(n))}finally{L(!1),F(!1)}},[]);d("confirm:no",w,{context:"Confirmation"}),s((e,n)=>{if(!n.ctrl||"c"!==e)return n.ctrl&&"r"===e&&M?(F(!0),void q()):void(null!==M&&n.return&&w());w()});const z=r(()=>{P(!0),q()},[P,q]);if(!G)return e(b,{onComplete:z});if(v)return n(c,{flexDirection:"column",padding:1,children:[n(c,{flexDirection:"row",children:[e(x,{}),e(l,{bold:!0,children:"Loading Context Code sessions…"})]}),e(l,{dimColor:!0,children:Y?"Retrying…":"Fetching your Context Code sessions…"})]});if(M)return n(c,{flexDirection:"column",padding:1,children:[e(l,{bold:!0,color:"error",children:"Error loading Context Code sessions"}),renderErrorSpecificGuidance(M),n(l,{dimColor:!0,children:["Press ",e(l,{bold:!0,children:"Ctrl+R"})," to retry · Press"," ",e(l,{bold:!0,children:K})," to cancel"]})]});if(0===E.length)return n(c,{flexDirection:"column",padding:1,children:[n(l,{bold:!0,children:["No Context Code sessions found",T&&n(l,{children:[" for ",T]})]}),e(c,{marginTop:1,children:n(l,{dimColor:!0,children:["Press ",e(l,{bold:!0,children:K})," to cancel"]})})]});const B=E.map(e=>({...e,timeString:h(new Date(e.updated_at))})),I=Math.max(7,...B.map(e=>e.timeString.length)),N=B.map(({timeString:e,title:n,id:r})=>({label:`${e.padEnd(I," ")} ${n}`,value:r})),O=Math.max(1,D?Math.min(E.length,5,S-6-7):Math.min(E.length,S-1-7)),U=O+7,V=E.length>O;return n(c,{flexDirection:"column",padding:1,height:U,children:[n(l,{bold:!0,children:["Select a session to resume",V&&n(l,{dimColor:!0,children:[" ","(",_," of ",E.length,")"]}),T&&n(l,{dimColor:!0,children:[" (",T,")"]}),":"]}),n(c,{flexDirection:"column",marginTop:1,flexGrow:1,children:[e(c,{marginLeft:2,children:n(l,{bold:!0,children:[j.padEnd(I," ")," ","Session Title"]})}),e(p,{visibleOptionCount:O,options:N,onChange:e=>{const n=E.find(n=>n.id===e);n&&y(n)},onFocus:e=>{const n=N.findIndex(n=>n.value===e);n>=0&&H(n+1)}})]}),e(c,{flexDirection:"row",children:e(l,{dimColor:!0,children:n(g,{children:[e(C,{shortcut:"↑/↓",action:"seleccionar"}),e(C,{shortcut:"Enter",action:"confirmar"}),e(f,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"cancelar"})]})})})]})}function renderErrorSpecificGuidance(r){switch(r){case"network":return e(c,{marginY:1,flexDirection:"column",children:e(l,{dimColor:!0,children:"Verifica tu conexión a internet"})});case"auth":return n(c,{marginY:1,flexDirection:"column",children:[e(l,{dimColor:!0,children:"Teleport requiere una cuenta de Context"}),n(l,{dimColor:!0,children:["Ejecuta ",e(l,{bold:!0,children:"/login"}),' y selecciona "Cuenta de Context con suscripción"']})]});case"api":return e(c,{marginY:1,flexDirection:"column",children:e(l,{dimColor:!0,children:"Lo sentimos, Context ha encontrado un error"})});case"other":return e(c,{marginY:1,flexDirection:"row",children:e(l,{dimColor:!0,children:"Lo sentimos, Context Code ha encontrado un error"})})}}
@@ -1 +1 @@
1
- import{MACRO as e,feature as t}from"../../recovery/bunBundleShim.js";import{jsx as n,jsxs as o,Fragment as a}from"react/jsx-runtime";import{createRequire as l}from"module";const i=l(import.meta.url);import{c as r}from"react/compiler-runtime";import{Box as s,Text as d,useTheme as u,useThemeSetting as c,useTerminalFocus as m}from"../../ink.js";import*as p from"react";import{useState as g,useCallback as h}from"react";import{useKeybinding as f,useKeybindings as b}from"../../keybindings/useKeybinding.js";import C from"figures";import{saveGlobalConfig as y,getCurrentProjectConfig as E}from"../../utils/config.js";import{normalizeApiKeyForConfig as S}from"../../utils/authPortable.js";import{getGlobalConfig as _,getAutoUpdaterDisabledReason as v,formatAutoUpdaterDisabledReason as I,getRemoteControlAtStartup as M}from"../../utils/config.js";import A from"chalk";import{permissionModeTitle as T,permissionModeFromString as D,toExternalPermissionMode as R,isExternalPermissionMode as k,EXTERNAL_PERMISSION_MODES as w,PERMISSION_MODES as x}from"../../utils/permissions/PermissionMode.js";import{getAutoModeEnabledState as P,hasAutoModeOptInAnySource as O,transitionPlanAutoMode as j}from"../../utils/permissions/permissionSetup.js";import{logError as N}from"../../utils/log.js";import{logEvent as B}from"../../services/analytics/index.js";import{isBridgeEnabled as F}from"../../bridge/bridgeEnabled.js";import{ThemePicker as K}from"../ThemePicker.js";import{useAppState as U,useSetAppState as L,useAppStateStore as H}from"../../state/AppState.js";import{ModelPicker as V}from"../ModelPicker.js";import{modelDisplayString as G,isOpus1mMergeEnabled as $}from"../../utils/model/model.js";import{isBilledAsExtraUsage as Y}from"../../utils/extraUsage.js";import{ClaudeMdExternalIncludesDialog as q}from"../ClaudeMdExternalIncludesDialog.js";import{ChannelDowngradeDialog as z}from"../ChannelDowngradeDialog.js";import{Dialog as W}from"../design-system/Dialog.js";import{Select as Q}from"../CustomSelect/index.js";import{OutputStylePicker as X}from"../OutputStylePicker.js";import{LanguagePicker as J}from"../LanguagePicker.js";import{getExternalClaudeMdIncludes as Z,getMemoryFiles as ee,hasExternalClaudeMdIncludes as te}from"../../utils/claudemd.js";import{KeyboardShortcutHint as ne}from"../design-system/KeyboardShortcutHint.js";import{ConfigurableShortcutHint as oe}from"../ConfigurableShortcutHint.js";import{Byline as ae}from"../design-system/Byline.js";import{useTabHeaderFocus as le}from"../design-system/Tabs.js";import{useIsInsideModal as ie}from"../../context/modalContext.js";import{SearchBox as re}from"../SearchBox.js";import{isSupportedTerminal as se,hasAccessToIDEExtensionDiffFeature as de}from"../../utils/ide.js";import{getInitialSettings as ue,getSettingsForSource as ce,updateSettingsForSource as me}from"../../utils/settings/settings.js";import{getUserMsgOptIn as pe,setUserMsgOptIn as ge}from"../../bootstrap/state.js";import{DEFAULT_OUTPUT_STYLE_NAME as he}from"../../constants/outputStyles.js";import{isEnvTruthy as fe,isRunningOnHomespace as be}from"../../utils/envUtils.js";import{getFeatureValue_CACHED_MAY_BE_STALE as Ce}from"../../services/analytics/growthbook.js";import{isAgentSwarmsEnabled as ye}from"../../utils/agentSwarmsEnabled.js";import{getCliTeammateModeOverride as Ee,clearCliTeammateModeOverride as Se}from"../../utils/swarm/backends/teammateModeSnapshot.js";import{getHardcodedTeammateModelFallback as _e}from"../../utils/swarm/teammateModel.js";import{useSearchInput as ve}from"../../hooks/useSearchInput.js";import{useTerminalSize as Ie}from"../../hooks/useTerminalSize.js";import{clearFastModeCooldown as Me,FAST_MODE_MODEL_DISPLAY as Ae,isFastModeAvailable as Te,isFastModeEnabled as De,getFastModeModel as Re,isFastModeSupportedByModel as ke}from"../../utils/fastMode.js";import{isFullscreenEnvEnabled as we}from"../../utils/fullscreen.js";export function Config({onClose:l,context:r,setTabsHidden:_e,onIsSearchModeChange:Pe,contentHeight:Oe}){const{headerFocused:je,focusHeader:Ne}=le(),Be=ie(),[,Fe]=u(),Ke=c(),[Ue,Le]=g(_()),He=p.useRef(_()),[Ve,Ge]=g(ue()),$e=p.useRef(ue()),[Ye,qe]=g(Ve?.outputStyle||he),ze=p.useRef(Ye),[We,Qe]=g(Ve?.language),Xe=p.useRef(We),[Je,Ze]=g(0),[et,tt]=g(0),[nt,ot]=g(!0),at=m(),{rows:lt}=Ie(),it=Oe??Math.min(Math.floor(.8*lt),30),rt=Math.max(5,it-10),st=U(e=>e.mainLoopModel),dt=U(e=>e.verbose),ut=U(e=>e.thinkingEnabled),ct=U(e=>!!De()&&e.fastMode),mt=U(e=>e.promptSuggestionEnabled),pt=!!t("TRANSCRIPT_CLASSIFIER")&&(O()||"enabled"===P()),gt=!(!t("KAIROS")&&!t("KAIROS_BRIEF"))&&i("../../tools/BriefTool/BriefTool.js").isBriefEntitled(),ht=L(),[ft,bt]=g({}),Ct=p.useRef(ut),[yt]=g(()=>ce("localSettings")),[Et]=g(()=>ce("userSettings")),St=p.useRef(Ke),_t=H(),[vt]=g(()=>{const e=_t.getState();return{mainLoopModel:e.mainLoopModel,mainLoopModelForSession:e.mainLoopModelForSession,verbose:e.verbose,thinkingEnabled:e.thinkingEnabled,fastMode:e.fastMode,promptSuggestionEnabled:e.promptSuggestionEnabled,isBriefOnly:e.isBriefOnly,replBridgeEnabled:e.replBridgeEnabled,replBridgeOutboundOnly:e.replBridgeOutboundOnly,settings:e.settings}}),[It]=g(()=>pe()),Mt=p.useRef(!1),[At,Tt]=g(!1),[Dt,Rt]=g(null),{query:kt,setQuery:wt,cursorOffset:xt}=ve({isActive:nt&&null===Dt&&!je,onExit:()=>ot(!1),onExitUp:Ne,passthroughCtrlKeys:["c","d"]}),Pt=nt&&!je;p.useEffect(()=>{Pe?.(Pt)},[Pt,Pe]);const Ot=de(r.options.mcpClients),jt=!fe(process.env.CONTEXT_CODE_DISABLE_FILE_CHECKPOINTING)&&!fe(process.env.CLAUDE_CODE_DISABLE_FILE_CHECKPOINTING),Nt=p.use(ee(!0)),Bt=te(Nt),Ft=v();function onChangeMainModelConfig(e){B("tengu_config_model_changed",{from_model:st,to_model:e}),ht(t=>({...t,mainLoopModel:e,mainLoopModelForSession:null})),bt(t=>{const n=G(e)+(Y(e,!1,$())?" · Billed as extra usage":"");if("model"in t){const{model:e,...o}=t;return{...o,model:n}}return{...t,model:n}})}const Kt=[{id:"autoCompactEnabled",label:"Auto-compact",value:Ue.autoCompactEnabled,type:"boolean",onChange(e){y(t=>({...t,autoCompactEnabled:e})),Le({..._(),autoCompactEnabled:e}),B("tengu_auto_compact_setting_changed",{enabled:e})}},{id:"spinnerTipsEnabled",label:"Show tips",value:Ve?.spinnerTipsEnabled??!0,type:"boolean",onChange(e){me("localSettings",{spinnerTipsEnabled:e}),Ge(t=>({...t,spinnerTipsEnabled:e})),B("tengu_tips_setting_changed",{enabled:e})}},{id:"prefersReducedMotion",label:"Reduce motion",value:Ve?.prefersReducedMotion??!1,type:"boolean",onChange(e){me("localSettings",{prefersReducedMotion:e}),Ge(t=>({...t,prefersReducedMotion:e})),ht(t=>({...t,settings:{...t.settings,prefersReducedMotion:e}})),B("tengu_reduce_motion_setting_changed",{enabled:e})}},{id:"thinkingEnabled",label:"Thinking mode",value:ut??!0,type:"boolean",onChange(e){ht(t=>({...t,thinkingEnabled:e})),me("userSettings",{alwaysThinkingEnabled:!!e&&void 0}),B("tengu_thinking_toggled",{enabled:e})}},...De()&&Te()?[{id:"fastMode",label:`Fast mode (${Ae} only)`,value:!!ct,type:"boolean",onChange(e){Me(),me("userSettings",{fastMode:!!e||void 0}),e?(ht(e=>({...e,mainLoopModel:Re(),mainLoopModelForSession:null,fastMode:!0})),bt(e=>({...e,model:Re(),"Fast mode":"ON"}))):(ht(e=>({...e,fastMode:!1})),bt(e=>({...e,"Fast mode":"OFF"})))}}]:[],...Ce("tengu_chomp_inflection",!1)?[{id:"promptSuggestionEnabled",label:"Prompt suggestions",value:mt,type:"boolean",onChange(e){ht(t=>({...t,promptSuggestionEnabled:e})),me("userSettings",{promptSuggestionEnabled:!!e&&void 0})}}]:[],...jt?[{id:"fileCheckpointingEnabled",label:"Rewind code (checkpoints)",value:Ue.fileCheckpointingEnabled,type:"boolean",onChange(e){y(t=>({...t,fileCheckpointingEnabled:e})),Le({..._(),fileCheckpointingEnabled:e}),B("tengu_file_history_snapshots_setting_changed",{enabled:e})}}]:[],{id:"verbose",label:"Verbose output",value:dt,type:"boolean",onChange:function(e){y(t=>({...t,verbose:e})),Le({..._(),verbose:e}),ht(t=>({...t,verbose:e})),bt(t=>{if("verbose"in t){const{verbose:e,...n}=t;return n}return{...t,verbose:e}})}},{id:"terminalProgressBarEnabled",label:"Terminal progress bar",value:Ue.terminalProgressBarEnabled,type:"boolean",onChange(e){y(t=>({...t,terminalProgressBarEnabled:e})),Le({..._(),terminalProgressBarEnabled:e}),B("tengu_terminal_progress_bar_setting_changed",{enabled:e})}},...Ce("tengu_terminal_sidebar",!1)?[{id:"showStatusInTerminalTab",label:"Show status in terminal tab",value:Ue.showStatusInTerminalTab??!1,type:"boolean",onChange(e){y(t=>({...t,showStatusInTerminalTab:e})),Le({..._(),showStatusInTerminalTab:e}),B("tengu_terminal_tab_status_setting_changed",{enabled:e})}}]:[],{id:"showTurnDuration",label:"Show turn duration",value:Ue.showTurnDuration,type:"boolean",onChange(e){y(t=>({...t,showTurnDuration:e})),Le({..._(),showTurnDuration:e}),B("tengu_show_turn_duration_setting_changed",{enabled:e})}},{id:"defaultPermissionMode",label:"Default permission mode",value:Ve?.permissions?.defaultMode||"default",options:(()=>{const e=["default","plan"],n=t("TRANSCRIPT_CLASSIFIER")?x:w,o=["bypassPermissions"];return t("TRANSCRIPT_CLASSIFIER")&&!pt&&o.push("auto"),[...e,...n.filter(t=>!e.includes(t)&&!o.includes(t))]})(),type:"enum",onChange(e){const t=D(e),n=k(t)?R(t):t,o=me("userSettings",{permissions:{...Ve?.permissions,defaultMode:n}});o.error?N(o.error):(Ge(e=>({...e,permissions:{...e?.permissions,defaultMode:n}})),bt(t=>({...t,defaultPermissionMode:e})),B("tengu_config_changed",{setting:"defaultPermissionMode",value:e}))}},...t("TRANSCRIPT_CLASSIFIER")&&pt?[{id:"useAutoModeDuringPlan",label:"Use auto mode during plan",value:Ve?.useAutoModeDuringPlan??!0,type:"boolean",onChange(e){me("userSettings",{useAutoModeDuringPlan:e}),Ge(t=>({...t,useAutoModeDuringPlan:e})),ht(e=>{const t=j(e.toolPermissionContext);return t===e.toolPermissionContext?e:{...e,toolPermissionContext:t}}),bt(t=>({...t,"Use auto mode during plan":e}))}}]:[],{id:"respectGitignore",label:"Respect .gitignore in file picker",value:Ue.respectGitignore,type:"boolean",onChange(e){y(t=>({...t,respectGitignore:e})),Le({..._(),respectGitignore:e}),B("tengu_respect_gitignore_setting_changed",{enabled:e})}},{id:"copyFullResponse",label:"Always copy full response (skip /copy picker)",value:Ue.copyFullResponse,type:"boolean",onChange(e){y(t=>({...t,copyFullResponse:e})),Le({..._(),copyFullResponse:e}),B("tengu_config_changed",{setting:"copyFullResponse",value:String(e)})}},...we()?[{id:"copyOnSelect",label:"Copy on select",value:Ue.copyOnSelect??!0,type:"boolean",onChange(e){y(t=>({...t,copyOnSelect:e})),Le({..._(),copyOnSelect:e}),B("tengu_config_changed",{setting:"copyOnSelect",value:String(e)})}}]:[],Ft?{id:"autoUpdatesChannel",label:"Auto-update channel",value:"disabled",type:"managedEnum",onChange(){}}:{id:"autoUpdatesChannel",label:"Auto-update channel",value:Ve?.autoUpdatesChannel??"latest",type:"managedEnum",onChange(){}},{id:"theme",label:"Theme",value:Ke,type:"managedEnum",onChange:Fe},{id:"notifChannel",label:t("KAIROS")||t("KAIROS_PUSH_NOTIFICATION")?"Local notifications":"Notifications",value:Ue.preferredNotifChannel,options:["auto","iterm2","terminal_bell","iterm2_with_bell","kitty","ghostty","notifications_disabled"],type:"enum",onChange(e){y(t=>({...t,preferredNotifChannel:e})),Le({..._(),preferredNotifChannel:e})}},...t("KAIROS")||t("KAIROS_PUSH_NOTIFICATION")?[{id:"taskCompleteNotifEnabled",label:"Push when idle",value:Ue.taskCompleteNotifEnabled??!1,type:"boolean",onChange(e){y(t=>({...t,taskCompleteNotifEnabled:e})),Le({..._(),taskCompleteNotifEnabled:e})}},{id:"inputNeededNotifEnabled",label:"Push when input needed",value:Ue.inputNeededNotifEnabled??!1,type:"boolean",onChange(e){y(t=>({...t,inputNeededNotifEnabled:e})),Le({..._(),inputNeededNotifEnabled:e})}},{id:"agentPushNotifEnabled",label:"Push when Claude decides",value:Ue.agentPushNotifEnabled??!1,type:"boolean",onChange(e){y(t=>({...t,agentPushNotifEnabled:e})),Le({..._(),agentPushNotifEnabled:e})}}]:[],{id:"outputStyle",label:"Output style",value:Ye,type:"managedEnum",onChange:()=>{}},...gt?[{id:"defaultView",label:"What you see by default",value:void 0===Ve?.defaultView?"default":String(Ve.defaultView),options:["transcript","chat","default"],type:"enum",onChange(e){const t="default"===e?void 0:e;me("localSettings",{defaultView:t}),Ge(e=>({...e,defaultView:t}));const n="chat"===t;ht(e=>e.isBriefOnly===n?e:{...e,isBriefOnly:n}),ge(n),bt(t=>({...t,"Default view":e})),B("tengu_default_view_setting_changed",{value:t??"unset"})}}]:[],{id:"language",label:"Language",value:We??"Default (English)",type:"managedEnum",onChange:()=>{}},{id:"editorMode",label:"Editor mode",value:"emacs"===Ue.editorMode?"normal":Ue.editorMode||"normal",options:["normal","vim"],type:"enum",onChange(e){y(t=>({...t,editorMode:e})),Le({..._(),editorMode:e}),B("tengu_editor_mode_changed",{mode:e,source:"config_panel"})}},{id:"prStatusFooterEnabled",label:"Show PR status footer",value:Ue.prStatusFooterEnabled??!0,type:"boolean",onChange(e){y(t=>t.prStatusFooterEnabled===e?t:{...t,prStatusFooterEnabled:e}),Le({..._(),prStatusFooterEnabled:e}),B("tengu_pr_status_footer_setting_changed",{enabled:e})}},{id:"model",label:"Model",value:null===st?"Default (recommended)":st,type:"managedEnum",onChange:onChangeMainModelConfig},...Ot?[{id:"diffTool",label:"Diff tool",value:Ue.diffTool??"auto",options:["terminal","auto"],type:"enum",onChange(e){y(t=>({...t,diffTool:e})),Le({..._(),diffTool:e}),B("tengu_diff_tool_changed",{tool:e,source:"config_panel"})}}]:[],...se()?[]:[{id:"autoConnectIde",label:"Auto-connect to IDE (external terminal)",value:Ue.autoConnectIde??!1,type:"boolean",onChange(e){y(t=>({...t,autoConnectIde:e})),Le({..._(),autoConnectIde:e}),B("tengu_auto_connect_ide_changed",{enabled:e,source:"config_panel"})}}],...se()?[{id:"autoInstallIdeExtension",label:"Auto-install IDE extension",value:Ue.autoInstallIdeExtension??!0,type:"boolean",onChange(e){y(t=>({...t,autoInstallIdeExtension:e})),Le({..._(),autoInstallIdeExtension:e}),B("tengu_auto_install_ide_extension_changed",{enabled:e,source:"config_panel"})}}]:[],{id:"claudeInChromeDefaultEnabled",label:"Claude in Chrome enabled by default",value:Ue.claudeInChromeDefaultEnabled??!0,type:"boolean",onChange(e){y(t=>({...t,claudeInChromeDefaultEnabled:e})),Le({..._(),claudeInChromeDefaultEnabled:e}),B("tengu_claude_in_chrome_setting_changed",{enabled:e})}},...ye()?(()=>{const e=Ee();return[{id:"teammateMode",label:e?`Teammate mode [overridden: ${e}]`:"Teammate mode",value:Ue.teammateMode??"auto",options:["auto","tmux","in-process"],type:"enum",onChange(e){"auto"!==e&&"tmux"!==e&&"in-process"!==e||(Se(e),y(t=>({...t,teammateMode:e})),Le({..._(),teammateMode:e}),B("tengu_teammate_mode_changed",{mode:e}))}},{id:"teammateDefaultModel",label:"Default teammate model",value:teammateModelDisplayString(Ue.teammateDefaultModel),type:"managedEnum",onChange(){}}]})():[],...t("BRIDGE_MODE")&&F()?[{id:"remoteControlAtStartup",label:"Enable Remote Control for all sessions",value:void 0===Ue.remoteControlAtStartup?"default":String(Ue.remoteControlAtStartup),options:["true","false","default"],type:"enum",onChange(e){if("default"===e)y(e=>{if(void 0===e.remoteControlAtStartup)return e;const t={...e};return delete t.remoteControlAtStartup,t}),Le({..._(),remoteControlAtStartup:void 0});else{const t="true"===e;y(e=>e.remoteControlAtStartup===t?e:{...e,remoteControlAtStartup:t}),Le({..._(),remoteControlAtStartup:t})}const t=M();ht(e=>e.replBridgeEnabled!==t||e.replBridgeOutboundOnly?{...e,replBridgeEnabled:t,replBridgeOutboundOnly:!1}:e)}}]:[],...Bt?[{id:"showExternalIncludesDialog",label:"External CLAUDE.md includes",value:E().hasClaudeMdExternalIncludesApproved?"true":"false",type:"managedEnum",onChange(){}}]:[],...process.env.ANTHROPIC_API_KEY&&!be()?[{id:"apiKey",label:o(d,{children:["Use custom API key:"," ",n(d,{bold:!0,children:S(process.env.ANTHROPIC_API_KEY)})]}),searchText:"Use custom API key",value:Boolean(process.env.ANTHROPIC_API_KEY&&Ue.customApiKeyResponses?.approved?.includes(S(process.env.ANTHROPIC_API_KEY))),type:"boolean",onChange(e){y(t=>{const n={...t};if(n.customApiKeyResponses||(n.customApiKeyResponses={approved:[],rejected:[]}),n.customApiKeyResponses.approved||(n.customApiKeyResponses={...n.customApiKeyResponses,approved:[]}),n.customApiKeyResponses.rejected||(n.customApiKeyResponses={...n.customApiKeyResponses,rejected:[]}),process.env.ANTHROPIC_API_KEY){const t=S(process.env.ANTHROPIC_API_KEY);n.customApiKeyResponses=e?{...n.customApiKeyResponses,approved:[...(n.customApiKeyResponses.approved??[]).filter(e=>e!==t),t],rejected:(n.customApiKeyResponses.rejected??[]).filter(e=>e!==t)}:{...n.customApiKeyResponses,approved:(n.customApiKeyResponses.approved??[]).filter(e=>e!==t),rejected:[...(n.customApiKeyResponses.rejected??[]).filter(e=>e!==t),t]}}return n}),Le(_())}}]:[]],Ut=p.useMemo(()=>{if(!kt)return Kt;const e=kt.toLowerCase();return Kt.filter(t=>{if(t.id.toLowerCase().includes(e))return!0;return("searchText"in t?t.searchText:t.label).toLowerCase().includes(e)})},[Kt,kt]);p.useEffect(()=>{if(Je>=Ut.length){const e=Math.max(0,Ut.length-1);return Ze(e),void tt(Math.max(0,e-rt+1))}tt(e=>Je<e?Je:Je>=e+rt?Je-rt+1:e)},[Ut.length,Je,rt]);const Lt=h(e=>{tt(t=>e<t?e:e>=t+rt?e-rt+1:t)},[rt]),Ht=h(()=>{if(null!==Dt)return;const e=Object.entries(ft).map(([e,t])=>(B("tengu_config_changed",{key:e,value:t}),`Set ${e} to ${A.bold(t)}`)),t=be()?void 0:process.env.ANTHROPIC_API_KEY,n=Boolean(t&&He.current.customApiKeyResponses?.approved?.includes(S(t))),o=Boolean(t&&Ue.customApiKeyResponses?.approved?.includes(S(t)));if(n!==o&&(e.push((o?"Enabled":"Disabled")+" custom API key"),B("tengu_config_changed",{key:"env.ANTHROPIC_API_KEY",value:o})),Ue.theme!==He.current.theme&&e.push(`Set theme to ${A.bold(Ue.theme)}`),Ue.preferredNotifChannel!==He.current.preferredNotifChannel&&e.push(`Set notifications to ${A.bold(Ue.preferredNotifChannel)}`),Ye!==ze.current&&e.push(`Set output style to ${A.bold(Ye)}`),We!==Xe.current&&e.push(`Set response language to ${A.bold(We??"Default (English)")}`),Ue.editorMode!==He.current.editorMode&&e.push(`Set editor mode to ${A.bold(Ue.editorMode||"emacs")}`),Ue.diffTool!==He.current.diffTool&&e.push(`Set diff tool to ${A.bold(Ue.diffTool)}`),Ue.autoConnectIde!==He.current.autoConnectIde&&e.push((Ue.autoConnectIde?"Enabled":"Disabled")+" auto-connect to IDE"),Ue.autoInstallIdeExtension!==He.current.autoInstallIdeExtension&&e.push((Ue.autoInstallIdeExtension?"Enabled":"Disabled")+" auto-install IDE extension"),Ue.autoCompactEnabled!==He.current.autoCompactEnabled&&e.push((Ue.autoCompactEnabled?"Enabled":"Disabled")+" auto-compact"),Ue.respectGitignore!==He.current.respectGitignore&&e.push((Ue.respectGitignore?"Enabled":"Disabled")+" respect .gitignore in file picker"),Ue.copyFullResponse!==He.current.copyFullResponse&&e.push((Ue.copyFullResponse?"Enabled":"Disabled")+" always copy full response"),Ue.copyOnSelect!==He.current.copyOnSelect&&e.push((Ue.copyOnSelect?"Enabled":"Disabled")+" copy on select"),Ue.terminalProgressBarEnabled!==He.current.terminalProgressBarEnabled&&e.push((Ue.terminalProgressBarEnabled?"Enabled":"Disabled")+" terminal progress bar"),Ue.showStatusInTerminalTab!==He.current.showStatusInTerminalTab&&e.push((Ue.showStatusInTerminalTab?"Enabled":"Disabled")+" terminal tab status"),Ue.showTurnDuration!==He.current.showTurnDuration&&e.push((Ue.showTurnDuration?"Enabled":"Disabled")+" turn duration"),Ue.remoteControlAtStartup!==He.current.remoteControlAtStartup){const t=void 0===Ue.remoteControlAtStartup?"Reset Remote Control to default":(Ue.remoteControlAtStartup?"Enabled":"Disabled")+" Remote Control for all sessions";e.push(t)}Ve?.autoUpdatesChannel!==$e.current?.autoUpdatesChannel&&e.push(`Set auto-update channel to ${A.bold(Ve?.autoUpdatesChannel??"latest")}`),e.length>0?l(e.join("\n")):l("Config dialog dismissed",{display:"system"})},[Dt,ft,Ue,st,Ye,We,Ve?.autoUpdatesChannel,De()?Ve?.fastMode:void 0,l]),Vt=h(()=>{Ke!==St.current&&Fe(St.current),y(()=>He.current);const e=yt;me("localSettings",{spinnerTipsEnabled:e?.spinnerTipsEnabled,prefersReducedMotion:e?.prefersReducedMotion,defaultView:e?.defaultView,outputStyle:e?.outputStyle});const n=Et;me("userSettings",{alwaysThinkingEnabled:n?.alwaysThinkingEnabled,fastMode:n?.fastMode,promptSuggestionEnabled:n?.promptSuggestionEnabled,autoUpdatesChannel:n?.autoUpdatesChannel,minimumVersion:n?.minimumVersion,language:n?.language,...t("TRANSCRIPT_CLASSIFIER")?{useAutoModeDuringPlan:n?.useAutoModeDuringPlan}:{},syntaxHighlightingDisabled:n?.syntaxHighlightingDisabled,permissions:void 0===n?.permissions?void 0:{...n.permissions,defaultMode:n.permissions.defaultMode}});const o=vt;ht(e=>({...e,mainLoopModel:o.mainLoopModel,mainLoopModelForSession:o.mainLoopModelForSession,verbose:o.verbose,thinkingEnabled:o.thinkingEnabled,fastMode:o.fastMode,promptSuggestionEnabled:o.promptSuggestionEnabled,isBriefOnly:o.isBriefOnly,replBridgeEnabled:o.replBridgeEnabled,replBridgeOutboundOnly:o.replBridgeOutboundOnly,settings:o.settings,toolPermissionContext:j(e.toolPermissionContext)})),pe()!==It&&ge(It)},[Ke,Fe,yt,Et,vt,It,ht]),Gt=h(()=>{null===Dt&&(Mt.current&&Vt(),l("Config dialog dismissed",{display:"system"}))},[Dt,Vt,l]);f("confirm:no",Gt,{context:"Settings",isActive:null===Dt&&!nt&&!je}),f("settings:close",Ht,{context:"Settings",isActive:null===Dt&&!nt&&!je});const $t=h(()=>{const e=Ut[Je];if(e&&e.onChange)if("boolean"!==e.type){if("theme"===e.id||"model"===e.id||"teammateDefaultModel"===e.id||"showExternalIncludesDialog"===e.id||"outputStyle"===e.id||"language"===e.id)switch(e.id){case"theme":return Rt("Theme"),void _e(!0);case"model":return Rt("Model"),void _e(!0);case"teammateDefaultModel":return Rt("TeammateModel"),void _e(!0);case"showExternalIncludesDialog":return Rt("ExternalIncludes"),void _e(!0);case"outputStyle":return Rt("OutputStyle"),void _e(!0);case"language":return Rt("Language"),void _e(!0)}if("autoUpdatesChannel"===e.id){if(Ft)return Rt("EnableAutoUpdates"),void _e(!0);return void("latest"===(Ve?.autoUpdatesChannel??"latest")?(Rt("ChannelDowngrade"),_e(!0)):(Mt.current=!0,me("userSettings",{autoUpdatesChannel:"latest",minimumVersion:void 0}),Ge(e=>({...e,autoUpdatesChannel:"latest",minimumVersion:void 0})),B("tengu_autoupdate_channel_changed",{channel:"latest"})))}if("enum"===e.type){Mt.current=!0;const t=(e.options.indexOf(e.value)+1)%e.options.length;return void e.onChange(e.options[t])}}else if(Mt.current=!0,e.onChange(!e.value),"thinkingEnabled"===e.id){!e.value===Ct.current?Tt(!1):r.messages.some(e=>"assistant"===e.type)&&Tt(!0)}},[Ft,Ut,Je,Ve?.autoUpdatesChannel,_e]),moveSelection=e=>{Tt(!1);const t=Math.max(0,Math.min(Ut.length-1,Je+e));Ze(t),Lt(t)};b({"select:previous":()=>{0===Je?(Tt(!1),ot(!0),tt(0)):moveSelection(-1)},"select:next":()=>moveSelection(1),"scroll:lineUp":()=>moveSelection(-1),"scroll:lineDown":()=>moveSelection(1),"select:accept":$t,"settings:search":()=>{ot(!0),wt("")}},{context:"Settings",isActive:null===Dt&&!nt&&!je});const Yt=h(e=>{if(null===Dt&&!je)return nt?"escape"===e.key?(e.preventDefault(),void(kt.length>0?wt(""):ot(!1))):void("return"!==e.key&&"down"!==e.key&&"wheeldown"!==e.key||(e.preventDefault(),ot(!1),Ze(0),tt(0))):"left"===e.key||"right"===e.key||"tab"===e.key?(e.preventDefault(),void $t()):void(e.ctrl||e.meta||"j"!==e.key&&"k"!==e.key&&"/"!==e.key&&1===e.key.length&&" "!==e.key&&(e.preventDefault(),ot(!0),wt(e.key)))},[Dt,je,nt,kt,wt,$t]);return n(s,{flexDirection:"column",width:"100%",tabIndex:0,autoFocus:!0,onKeyDown:Yt,children:"Theme"===Dt?o(a,{children:[n(K,{onThemeSelect:e=>{Mt.current=!0,Fe(e),Rt(null),_e(!1)},onCancel:()=>{Rt(null),_e(!1)},hideEscToCancel:!0,skipExitHandling:!0}),n(s,{children:n(d,{dimColor:!0,italic:!0,children:o(ae,{children:[n(ne,{shortcut:"Enter",action:"seleccionar"}),n(oe,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"cancelar"})]})})})]}):"Model"===Dt?o(a,{children:[n(V,{initial:st,onSelect:(e,t)=>{Mt.current=!0,onChangeMainModelConfig(e),Rt(null),_e(!1)},onCancel:()=>{Rt(null),_e(!1)},showFastModeNotice:!!De()&&(ct&&ke(st)&&Te())}),n(d,{dimColor:!0,children:o(ae,{children:[n(ne,{shortcut:"Enter",action:"confirmar"}),n(oe,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"cancelar"})]})})]}):"TeammateModel"===Dt?o(a,{children:[n(V,{initial:Ue.teammateDefaultModel??null,skipSettingsWrite:!0,headerText:"Default model for newly spawned teammates. The leader can override via the tool call's model parameter.",onSelect:(e,t)=>{Rt(null),_e(!1),void 0===Ue.teammateDefaultModel&&null===e||(Mt.current=!0,y(t=>t.teammateDefaultModel===e?t:{...t,teammateDefaultModel:e}),Le({..._(),teammateDefaultModel:e}),bt(t=>({...t,teammateDefaultModel:teammateModelDisplayString(e)})),B("tengu_teammate_default_model_changed",{model:e}))},onCancel:()=>{Rt(null),_e(!1)}}),n(d,{dimColor:!0,children:o(ae,{children:[n(ne,{shortcut:"Enter",action:"confirmar"}),n(oe,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"cancelar"})]})})]}):"ExternalIncludes"===Dt?o(a,{children:[n(q,{onDone:()=>{Rt(null),_e(!1)},externalIncludes:Z(Nt)}),n(d,{dimColor:!0,children:o(ae,{children:[n(ne,{shortcut:"Enter",action:"confirmar"}),n(oe,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"disable external includes"})]})})]}):"OutputStyle"===Dt?o(a,{children:[n(X,{initialStyle:Ye,onComplete:e=>{Mt.current=!0,qe(e??he),Rt(null),_e(!1),me("localSettings",{outputStyle:e}),B("tengu_output_style_changed",{style:e??he,source:"config_panel",settings_source:"localSettings"})},onCancel:()=>{Rt(null),_e(!1)}}),n(d,{dimColor:!0,children:o(ae,{children:[n(ne,{shortcut:"Enter",action:"confirmar"}),n(oe,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"cancelar"})]})})]}):"Language"===Dt?o(a,{children:[n(J,{initialLanguage:We,onComplete:e=>{Mt.current=!0,Qe(e),Rt(null),_e(!1),me("userSettings",{language:e}),B("tengu_language_changed",{language:e??"default",source:"config_panel"})},onCancel:()=>{Rt(null),_e(!1)}}),n(d,{dimColor:!0,children:o(ae,{children:[n(ne,{shortcut:"Enter",action:"confirmar"}),n(oe,{action:"confirm:no",context:"Settings",fallback:"Esc",description:"cancelar"})]})})]}):"EnableAutoUpdates"===Dt?n(W,{title:"Enable Auto-Updates",onCancel:()=>{Rt(null),_e(!1)},hideBorder:!0,hideInputGuide:!0,children:"config"!==Ft?.type?o(a,{children:[n(d,{children:"env"===Ft?.type?"Auto-updates are controlled by an environment variable and cannot be changed here.":"Auto-updates are disabled in development builds."}),"env"===Ft?.type&&o(d,{dimColor:!0,children:["Unset ",Ft.envVar," to re-enable auto-updates."]})]}):n(Q,{options:[{label:"Enable with latest channel",value:"latest"},{label:"Enable with stable channel",value:"stable"}],onChange:e=>{Mt.current=!0,Rt(null),_e(!1),y(e=>({...e,autoUpdates:!0})),Le({..._(),autoUpdates:!0}),me("userSettings",{autoUpdatesChannel:e,minimumVersion:void 0}),Ge(t=>({...t,autoUpdatesChannel:e,minimumVersion:void 0})),B("tengu_autoupdate_enabled",{channel:e})}})}):"ChannelDowngrade"===Dt?n(z,{currentVersion:e.VERSION,onChoice:t=>{if(Rt(null),_e(!1),"cancel"===t)return;Mt.current=!0;const n={autoUpdatesChannel:"stable"};"stay"===t&&(n.minimumVersion=e.VERSION),me("userSettings",n),Ge(e=>({...e,...n})),B("tengu_autoupdate_channel_changed",{channel:"stable",minimum_version_set:"stay"===t})}}):o(s,{flexDirection:"column",gap:1,marginY:Be?void 0:1,children:[n(re,{query:kt,isFocused:nt&&!je,isTerminalFocused:at,cursorOffset:xt,placeholder:"Search settings…"}),n(s,{flexDirection:"column",children:0===Ut.length?o(d,{dimColor:!0,italic:!0,children:['No settings match "',kt,'"']}):o(a,{children:[et>0&&o(d,{dimColor:!0,children:[C.arrowUp," ",et," more above"]}),Ut.slice(et,et+rt).map((e,t)=>{const l=et+t===Je&&!je&&!nt;return n(p.Fragment,{children:o(s,{children:[n(s,{width:44,children:o(d,{color:l?"suggestion":void 0,children:[l?C.pointer:" "," ",e.label]})}),n(s,{children:"boolean"===e.type?o(a,{children:[n(d,{color:l?"suggestion":void 0,children:e.value.toString()}),At&&"thinkingEnabled"===e.id&&o(d,{color:"warning",children:[" ","Changing thinking mode mid-conversation will increase latency and may reduce quality."]})]}):"theme"===e.id?n(d,{color:l?"suggestion":void 0,children:xe[e.value.toString()]??e.value.toString()}):"notifChannel"===e.id?n(d,{color:l?"suggestion":void 0,children:n(NotifChannelLabel,{value:e.value.toString()})}):"defaultPermissionMode"===e.id?n(d,{color:l?"suggestion":void 0,children:T(e.value)}):"autoUpdatesChannel"===e.id&&Ft?o(s,{flexDirection:"column",children:[n(d,{color:l?"suggestion":void 0,children:"disabled"}),o(d,{dimColor:!0,children:["(",I(Ft),")"]})]}):n(d,{color:l?"suggestion":void 0,children:e.value.toString()})},l?"selected":"unselected")]})},e.id)}),et+rt<Ut.length&&o(d,{dimColor:!0,children:[C.arrowDown," ",Ut.length-et-rt," ","more below"]})]})}),n(d,je?{dimColor:!0,children:o(ae,{children:[n(ne,{shortcut:"←/→ tab",action:"switch"}),n(ne,{shortcut:"↓",action:"return"}),n(oe,{action:"confirm:no",context:"Settings",fallback:"Esc",description:"cerrar"})]})}:nt?{dimColor:!0,children:o(ae,{children:[n(d,{children:"Type to filter"}),n(ne,{shortcut:"Enter/↓",action:"seleccionar"}),n(ne,{shortcut:"↑",action:"tabs"}),n(oe,{action:"confirm:no",context:"Settings",fallback:"Esc",description:"clear"})]})}:{dimColor:!0,children:o(ae,{children:[n(oe,{action:"select:accept",context:"Settings",fallback:"Space",description:"change"}),n(oe,{action:"settings:close",context:"Settings",fallback:"Enter",description:"save"}),n(oe,{action:"settings:search",context:"Settings",fallback:"/",description:"search"}),n(oe,{action:"confirm:no",context:"Settings",fallback:"Esc",description:"cancelar"})]})})]})})}function teammateModelDisplayString(e){return void 0===e?G(_e()):null===e?"Default (leader's model)":G(e)}const xe={auto:"Automático (según terminal)",dark:"Modo oscuro",light:"Modo claro","dark-daltonized":"Modo oscuro (apto para daltonismo)","light-daltonized":"Modo claro (apto para daltonismo)","dark-ansi":"Modo oscuro (solo colores ANSI)","light-ansi":"Modo claro (solo colores ANSI)"};function NotifChannelLabel(e){const t=r(4),{value:a}=e;switch(a){case"auto":return"Auto";case"iterm2":{let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o(d,{children:["iTerm2 ",n(d,{dimColor:!0,children:"(OSC 9)"})]}),t[0]=e):e=t[0],e}case"terminal_bell":{let e;return t[1]===Symbol.for("react.memo_cache_sentinel")?(e=o(d,{children:["Terminal Bell ",n(d,{dimColor:!0,children:"(\\a)"})]}),t[1]=e):e=t[1],e}case"kitty":{let e;return t[2]===Symbol.for("react.memo_cache_sentinel")?(e=o(d,{children:["Kitty ",n(d,{dimColor:!0,children:"(OSC 99)"})]}),t[2]=e):e=t[2],e}case"ghostty":{let e;return t[3]===Symbol.for("react.memo_cache_sentinel")?(e=o(d,{children:["Ghostty ",n(d,{dimColor:!0,children:"(OSC 777)"})]}),t[3]=e):e=t[3],e}case"iterm2_with_bell":return"iTerm2 w/ Bell";case"notifications_disabled":return"Disabled";default:return a}}
1
+ import{MACRO as e,feature as t}from"../../recovery/bunBundleShim.js";import{jsx as n,jsxs as o,Fragment as a}from"react/jsx-runtime";import{createRequire as l}from"module";const i=l(import.meta.url);import{c as r}from"react/compiler-runtime";import{Box as s,Text as d,useTheme as u,useThemeSetting as c,useTerminalFocus as m}from"../../ink.js";import*as p from"react";import{useState as g,useCallback as h}from"react";import{useKeybinding as f,useKeybindings as b}from"../../keybindings/useKeybinding.js";import C from"figures";import{saveGlobalConfig as y,getCurrentProjectConfig as E}from"../../utils/config.js";import{normalizeApiKeyForConfig as S}from"../../utils/authPortable.js";import{getGlobalConfig as _,getAutoUpdaterDisabledReason as v,formatAutoUpdaterDisabledReason as I,getRemoteControlAtStartup as M}from"../../utils/config.js";import A from"chalk";import{permissionModeTitle as T,permissionModeFromString as D,toExternalPermissionMode as R,isExternalPermissionMode as k,EXTERNAL_PERMISSION_MODES as x,PERMISSION_MODES as w}from"../../utils/permissions/PermissionMode.js";import{getAutoModeEnabledState as P,hasAutoModeOptInAnySource as O,transitionPlanAutoMode as j}from"../../utils/permissions/permissionSetup.js";import{logError as N}from"../../utils/log.js";import{logEvent as B}from"../../services/analytics/index.js";import{isBridgeEnabled as F}from"../../bridge/bridgeEnabled.js";import{ThemePicker as K}from"../ThemePicker.js";import{useAppState as U,useSetAppState as L,useAppStateStore as H}from"../../state/AppState.js";import{ModelPicker as V}from"../ModelPicker.js";import{modelDisplayString as G,isOpus1mMergeEnabled as $}from"../../utils/model/model.js";import{isBilledAsExtraUsage as Y}from"../../utils/extraUsage.js";import{ClaudeMdExternalIncludesDialog as q}from"../ClaudeMdExternalIncludesDialog.js";import{ChannelDowngradeDialog as z}from"../ChannelDowngradeDialog.js";import{Dialog as W}from"../design-system/Dialog.js";import{Select as Q}from"../CustomSelect/index.js";import{OutputStylePicker as X}from"../OutputStylePicker.js";import{LanguagePicker as J}from"../LanguagePicker.js";import{getExternalClaudeMdIncludes as Z,getMemoryFiles as ee,hasExternalClaudeMdIncludes as te}from"../../utils/claudemd.js";import{KeyboardShortcutHint as ne}from"../design-system/KeyboardShortcutHint.js";import{ConfigurableShortcutHint as oe}from"../ConfigurableShortcutHint.js";import{Byline as ae}from"../design-system/Byline.js";import{useTabHeaderFocus as le}from"../design-system/Tabs.js";import{useIsInsideModal as ie}from"../../context/modalContext.js";import{SearchBox as re}from"../SearchBox.js";import{isSupportedTerminal as se,hasAccessToIDEExtensionDiffFeature as de}from"../../utils/ide.js";import{getInitialSettings as ue,getSettingsForSource as ce,updateSettingsForSource as me}from"../../utils/settings/settings.js";import{getUserMsgOptIn as pe,setUserMsgOptIn as ge}from"../../bootstrap/state.js";import{DEFAULT_OUTPUT_STYLE_NAME as he}from"../../constants/outputStyles.js";import{isEnvTruthy as fe,isRunningOnHomespace as be}from"../../utils/envUtils.js";import{getFeatureValue_CACHED_MAY_BE_STALE as Ce}from"../../services/analytics/growthbook.js";import{isAgentSwarmsEnabled as ye}from"../../utils/agentSwarmsEnabled.js";import{getCliTeammateModeOverride as Ee,clearCliTeammateModeOverride as Se}from"../../utils/swarm/backends/teammateModeSnapshot.js";import{getHardcodedTeammateModelFallback as _e}from"../../utils/swarm/teammateModel.js";import{useSearchInput as ve}from"../../hooks/useSearchInput.js";import{useTerminalSize as Ie}from"../../hooks/useTerminalSize.js";import{clearFastModeCooldown as Me,FAST_MODE_MODEL_DISPLAY as Ae,isFastModeAvailable as Te,isFastModeEnabled as De,getFastModeModel as Re,isFastModeSupportedByModel as ke}from"../../utils/fastMode.js";import{isFullscreenEnvEnabled as xe}from"../../utils/fullscreen.js";export function Config({onClose:l,context:r,setTabsHidden:_e,onIsSearchModeChange:Pe,contentHeight:Oe}){const{headerFocused:je,focusHeader:Ne}=le(),Be=ie(),[,Fe]=u(),Ke=c(),[Ue,Le]=g(_()),He=p.useRef(_()),[Ve,Ge]=g(ue()),$e=p.useRef(ue()),[Ye,qe]=g(Ve?.outputStyle||he),ze=p.useRef(Ye),[We,Qe]=g(Ve?.language),Xe=p.useRef(We),[Je,Ze]=g(0),[et,tt]=g(0),[nt,ot]=g(!0),at=m(),{rows:lt}=Ie(),it=Oe??Math.min(Math.floor(.8*lt),30),rt=Math.max(5,it-10),st=U(e=>e.mainLoopModel),dt=U(e=>e.verbose),ut=U(e=>e.thinkingEnabled),ct=U(e=>!!De()&&e.fastMode),mt=U(e=>e.promptSuggestionEnabled),pt=!!t("TRANSCRIPT_CLASSIFIER")&&(O()||"enabled"===P()),gt=!(!t("KAIROS")&&!t("KAIROS_BRIEF"))&&i("../../tools/BriefTool/BriefTool.js").isBriefEntitled(),ht=L(),[ft,bt]=g({}),Ct=p.useRef(ut),[yt]=g(()=>ce("localSettings")),[Et]=g(()=>ce("userSettings")),St=p.useRef(Ke),_t=H(),[vt]=g(()=>{const e=_t.getState();return{mainLoopModel:e.mainLoopModel,mainLoopModelForSession:e.mainLoopModelForSession,verbose:e.verbose,thinkingEnabled:e.thinkingEnabled,fastMode:e.fastMode,promptSuggestionEnabled:e.promptSuggestionEnabled,isBriefOnly:e.isBriefOnly,replBridgeEnabled:e.replBridgeEnabled,replBridgeOutboundOnly:e.replBridgeOutboundOnly,settings:e.settings}}),[It]=g(()=>pe()),Mt=p.useRef(!1),[At,Tt]=g(!1),[Dt,Rt]=g(null),{query:kt,setQuery:xt,cursorOffset:wt}=ve({isActive:nt&&null===Dt&&!je,onExit:()=>ot(!1),onExitUp:Ne,passthroughCtrlKeys:["c","d"]}),Pt=nt&&!je;p.useEffect(()=>{Pe?.(Pt)},[Pt,Pe]);const Ot=de(r.options.mcpClients),jt=!fe(process.env.CONTEXT_CODE_DISABLE_FILE_CHECKPOINTING)&&!fe(process.env.CLAUDE_CODE_DISABLE_FILE_CHECKPOINTING),Nt=p.use(ee(!0)),Bt=te(Nt),Ft=v();function onChangeMainModelConfig(e){B("tengu_config_model_changed",{from_model:st,to_model:e}),ht(t=>({...t,mainLoopModel:e,mainLoopModelForSession:null})),bt(t=>{const n=G(e)+(Y(e,!1,$())?" · Billed as extra usage":"");if("model"in t){const{model:e,...o}=t;return{...o,model:n}}return{...t,model:n}})}const Kt=[{id:"autoCompactEnabled",label:"Auto-compact",value:Ue.autoCompactEnabled,type:"boolean",onChange(e){y(t=>({...t,autoCompactEnabled:e})),Le({..._(),autoCompactEnabled:e}),B("tengu_auto_compact_setting_changed",{enabled:e})}},{id:"spinnerTipsEnabled",label:"Show tips",value:Ve?.spinnerTipsEnabled??!0,type:"boolean",onChange(e){me("localSettings",{spinnerTipsEnabled:e}),Ge(t=>({...t,spinnerTipsEnabled:e})),B("tengu_tips_setting_changed",{enabled:e})}},{id:"prefersReducedMotion",label:"Reduce motion",value:Ve?.prefersReducedMotion??!1,type:"boolean",onChange(e){me("localSettings",{prefersReducedMotion:e}),Ge(t=>({...t,prefersReducedMotion:e})),ht(t=>({...t,settings:{...t.settings,prefersReducedMotion:e}})),B("tengu_reduce_motion_setting_changed",{enabled:e})}},{id:"thinkingEnabled",label:"Thinking mode",value:ut??!0,type:"boolean",onChange(e){ht(t=>({...t,thinkingEnabled:e})),me("userSettings",{alwaysThinkingEnabled:!!e&&void 0}),B("tengu_thinking_toggled",{enabled:e})}},...De()&&Te()?[{id:"fastMode",label:`Fast mode (${Ae} only)`,value:!!ct,type:"boolean",onChange(e){Me(),me("userSettings",{fastMode:!!e||void 0}),e?(ht(e=>({...e,mainLoopModel:Re(),mainLoopModelForSession:null,fastMode:!0})),bt(e=>({...e,model:Re(),"Fast mode":"ON"}))):(ht(e=>({...e,fastMode:!1})),bt(e=>({...e,"Fast mode":"OFF"})))}}]:[],...Ce("tengu_chomp_inflection",!1)?[{id:"promptSuggestionEnabled",label:"Prompt suggestions",value:mt,type:"boolean",onChange(e){ht(t=>({...t,promptSuggestionEnabled:e})),me("userSettings",{promptSuggestionEnabled:!!e&&void 0})}}]:[],...jt?[{id:"fileCheckpointingEnabled",label:"Rewind code (checkpoints)",value:Ue.fileCheckpointingEnabled,type:"boolean",onChange(e){y(t=>({...t,fileCheckpointingEnabled:e})),Le({..._(),fileCheckpointingEnabled:e}),B("tengu_file_history_snapshots_setting_changed",{enabled:e})}}]:[],{id:"verbose",label:"Verbose output",value:dt,type:"boolean",onChange:function(e){y(t=>({...t,verbose:e})),Le({..._(),verbose:e}),ht(t=>({...t,verbose:e})),bt(t=>{if("verbose"in t){const{verbose:e,...n}=t;return n}return{...t,verbose:e}})}},{id:"terminalProgressBarEnabled",label:"Terminal progress bar",value:Ue.terminalProgressBarEnabled,type:"boolean",onChange(e){y(t=>({...t,terminalProgressBarEnabled:e})),Le({..._(),terminalProgressBarEnabled:e}),B("tengu_terminal_progress_bar_setting_changed",{enabled:e})}},...Ce("tengu_terminal_sidebar",!1)?[{id:"showStatusInTerminalTab",label:"Show status in terminal tab",value:Ue.showStatusInTerminalTab??!1,type:"boolean",onChange(e){y(t=>({...t,showStatusInTerminalTab:e})),Le({..._(),showStatusInTerminalTab:e}),B("tengu_terminal_tab_status_setting_changed",{enabled:e})}}]:[],{id:"showTurnDuration",label:"Show turn duration",value:Ue.showTurnDuration,type:"boolean",onChange(e){y(t=>({...t,showTurnDuration:e})),Le({..._(),showTurnDuration:e}),B("tengu_show_turn_duration_setting_changed",{enabled:e})}},{id:"defaultPermissionMode",label:"Default permission mode",value:Ve?.permissions?.defaultMode||"default",options:(()=>{const e=["default","plan"],n=t("TRANSCRIPT_CLASSIFIER")?w:x,o=["bypassPermissions"];return t("TRANSCRIPT_CLASSIFIER")&&!pt&&o.push("auto"),[...e,...n.filter(t=>!e.includes(t)&&!o.includes(t))]})(),type:"enum",onChange(e){const t=D(e),n=k(t)?R(t):t,o=me("userSettings",{permissions:{...Ve?.permissions,defaultMode:n}});o.error?N(o.error):(Ge(e=>({...e,permissions:{...e?.permissions,defaultMode:n}})),bt(t=>({...t,defaultPermissionMode:e})),B("tengu_config_changed",{setting:"defaultPermissionMode",value:e}))}},...t("TRANSCRIPT_CLASSIFIER")&&pt?[{id:"useAutoModeDuringPlan",label:"Use auto mode during plan",value:Ve?.useAutoModeDuringPlan??!0,type:"boolean",onChange(e){me("userSettings",{useAutoModeDuringPlan:e}),Ge(t=>({...t,useAutoModeDuringPlan:e})),ht(e=>{const t=j(e.toolPermissionContext);return t===e.toolPermissionContext?e:{...e,toolPermissionContext:t}}),bt(t=>({...t,"Use auto mode during plan":e}))}}]:[],{id:"respectGitignore",label:"Respect .gitignore in file picker",value:Ue.respectGitignore,type:"boolean",onChange(e){y(t=>({...t,respectGitignore:e})),Le({..._(),respectGitignore:e}),B("tengu_respect_gitignore_setting_changed",{enabled:e})}},{id:"copyFullResponse",label:"Always copy full response (skip /copy picker)",value:Ue.copyFullResponse,type:"boolean",onChange(e){y(t=>({...t,copyFullResponse:e})),Le({..._(),copyFullResponse:e}),B("tengu_config_changed",{setting:"copyFullResponse",value:String(e)})}},...xe()?[{id:"copyOnSelect",label:"Copy on select",value:Ue.copyOnSelect??!0,type:"boolean",onChange(e){y(t=>({...t,copyOnSelect:e})),Le({..._(),copyOnSelect:e}),B("tengu_config_changed",{setting:"copyOnSelect",value:String(e)})}}]:[],Ft?{id:"autoUpdatesChannel",label:"Auto-update channel",value:"disabled",type:"managedEnum",onChange(){}}:{id:"autoUpdatesChannel",label:"Auto-update channel",value:Ve?.autoUpdatesChannel??"latest",type:"managedEnum",onChange(){}},{id:"theme",label:"Theme",value:Ke,type:"managedEnum",onChange:Fe},{id:"notifChannel",label:t("KAIROS")||t("KAIROS_PUSH_NOTIFICATION")?"Local notifications":"Notifications",value:Ue.preferredNotifChannel,options:["auto","iterm2","terminal_bell","iterm2_with_bell","kitty","ghostty","notifications_disabled"],type:"enum",onChange(e){y(t=>({...t,preferredNotifChannel:e})),Le({..._(),preferredNotifChannel:e})}},...t("KAIROS")||t("KAIROS_PUSH_NOTIFICATION")?[{id:"taskCompleteNotifEnabled",label:"Push when idle",value:Ue.taskCompleteNotifEnabled??!1,type:"boolean",onChange(e){y(t=>({...t,taskCompleteNotifEnabled:e})),Le({..._(),taskCompleteNotifEnabled:e})}},{id:"inputNeededNotifEnabled",label:"Push when input needed",value:Ue.inputNeededNotifEnabled??!1,type:"boolean",onChange(e){y(t=>({...t,inputNeededNotifEnabled:e})),Le({..._(),inputNeededNotifEnabled:e})}},{id:"agentPushNotifEnabled",label:"Push cuando Context decida",value:Ue.agentPushNotifEnabled??!1,type:"boolean",onChange(e){y(t=>({...t,agentPushNotifEnabled:e})),Le({..._(),agentPushNotifEnabled:e})}}]:[],{id:"outputStyle",label:"Output style",value:Ye,type:"managedEnum",onChange:()=>{}},...gt?[{id:"defaultView",label:"What you see by default",value:void 0===Ve?.defaultView?"default":String(Ve.defaultView),options:["transcript","chat","default"],type:"enum",onChange(e){const t="default"===e?void 0:e;me("localSettings",{defaultView:t}),Ge(e=>({...e,defaultView:t}));const n="chat"===t;ht(e=>e.isBriefOnly===n?e:{...e,isBriefOnly:n}),ge(n),bt(t=>({...t,"Default view":e})),B("tengu_default_view_setting_changed",{value:t??"unset"})}}]:[],{id:"language",label:"Language",value:We??"Default (English)",type:"managedEnum",onChange:()=>{}},{id:"editorMode",label:"Editor mode",value:"emacs"===Ue.editorMode?"normal":Ue.editorMode||"normal",options:["normal","vim"],type:"enum",onChange(e){y(t=>({...t,editorMode:e})),Le({..._(),editorMode:e}),B("tengu_editor_mode_changed",{mode:e,source:"config_panel"})}},{id:"prStatusFooterEnabled",label:"Show PR status footer",value:Ue.prStatusFooterEnabled??!0,type:"boolean",onChange(e){y(t=>t.prStatusFooterEnabled===e?t:{...t,prStatusFooterEnabled:e}),Le({..._(),prStatusFooterEnabled:e}),B("tengu_pr_status_footer_setting_changed",{enabled:e})}},{id:"model",label:"Model",value:null===st?"Default (recommended)":st,type:"managedEnum",onChange:onChangeMainModelConfig},...Ot?[{id:"diffTool",label:"Diff tool",value:Ue.diffTool??"auto",options:["terminal","auto"],type:"enum",onChange(e){y(t=>({...t,diffTool:e})),Le({..._(),diffTool:e}),B("tengu_diff_tool_changed",{tool:e,source:"config_panel"})}}]:[],...se()?[]:[{id:"autoConnectIde",label:"Auto-connect to IDE (external terminal)",value:Ue.autoConnectIde??!1,type:"boolean",onChange(e){y(t=>({...t,autoConnectIde:e})),Le({..._(),autoConnectIde:e}),B("tengu_auto_connect_ide_changed",{enabled:e,source:"config_panel"})}}],...se()?[{id:"autoInstallIdeExtension",label:"Auto-install IDE extension",value:Ue.autoInstallIdeExtension??!0,type:"boolean",onChange(e){y(t=>({...t,autoInstallIdeExtension:e})),Le({..._(),autoInstallIdeExtension:e}),B("tengu_auto_install_ide_extension_changed",{enabled:e,source:"config_panel"})}}]:[],{id:"claudeInChromeDefaultEnabled",label:"Context en Chrome habilitado por defecto",value:Ue.claudeInChromeDefaultEnabled??!0,type:"boolean",onChange(e){y(t=>({...t,claudeInChromeDefaultEnabled:e})),Le({..._(),claudeInChromeDefaultEnabled:e}),B("tengu_claude_in_chrome_setting_changed",{enabled:e})}},...ye()?(()=>{const e=Ee();return[{id:"teammateMode",label:e?`Teammate mode [overridden: ${e}]`:"Teammate mode",value:Ue.teammateMode??"auto",options:["auto","tmux","in-process"],type:"enum",onChange(e){"auto"!==e&&"tmux"!==e&&"in-process"!==e||(Se(e),y(t=>({...t,teammateMode:e})),Le({..._(),teammateMode:e}),B("tengu_teammate_mode_changed",{mode:e}))}},{id:"teammateDefaultModel",label:"Default teammate model",value:teammateModelDisplayString(Ue.teammateDefaultModel),type:"managedEnum",onChange(){}}]})():[],...t("BRIDGE_MODE")&&F()?[{id:"remoteControlAtStartup",label:"Enable Remote Control for all sessions",value:void 0===Ue.remoteControlAtStartup?"default":String(Ue.remoteControlAtStartup),options:["true","false","default"],type:"enum",onChange(e){if("default"===e)y(e=>{if(void 0===e.remoteControlAtStartup)return e;const t={...e};return delete t.remoteControlAtStartup,t}),Le({..._(),remoteControlAtStartup:void 0});else{const t="true"===e;y(e=>e.remoteControlAtStartup===t?e:{...e,remoteControlAtStartup:t}),Le({..._(),remoteControlAtStartup:t})}const t=M();ht(e=>e.replBridgeEnabled!==t||e.replBridgeOutboundOnly?{...e,replBridgeEnabled:t,replBridgeOutboundOnly:!1}:e)}}]:[],...Bt?[{id:"showExternalIncludesDialog",label:"External CLAUDE.md includes",value:E().hasClaudeMdExternalIncludesApproved?"true":"false",type:"managedEnum",onChange(){}}]:[],...process.env.ANTHROPIC_API_KEY&&!be()?[{id:"apiKey",label:o(d,{children:["Use custom API key:"," ",n(d,{bold:!0,children:S(process.env.ANTHROPIC_API_KEY)})]}),searchText:"Use custom API key",value:Boolean(process.env.ANTHROPIC_API_KEY&&Ue.customApiKeyResponses?.approved?.includes(S(process.env.ANTHROPIC_API_KEY))),type:"boolean",onChange(e){y(t=>{const n={...t};if(n.customApiKeyResponses||(n.customApiKeyResponses={approved:[],rejected:[]}),n.customApiKeyResponses.approved||(n.customApiKeyResponses={...n.customApiKeyResponses,approved:[]}),n.customApiKeyResponses.rejected||(n.customApiKeyResponses={...n.customApiKeyResponses,rejected:[]}),process.env.ANTHROPIC_API_KEY){const t=S(process.env.ANTHROPIC_API_KEY);n.customApiKeyResponses=e?{...n.customApiKeyResponses,approved:[...(n.customApiKeyResponses.approved??[]).filter(e=>e!==t),t],rejected:(n.customApiKeyResponses.rejected??[]).filter(e=>e!==t)}:{...n.customApiKeyResponses,approved:(n.customApiKeyResponses.approved??[]).filter(e=>e!==t),rejected:[...(n.customApiKeyResponses.rejected??[]).filter(e=>e!==t),t]}}return n}),Le(_())}}]:[]],Ut=p.useMemo(()=>{if(!kt)return Kt;const e=kt.toLowerCase();return Kt.filter(t=>{if(t.id.toLowerCase().includes(e))return!0;return("searchText"in t?t.searchText:t.label).toLowerCase().includes(e)})},[Kt,kt]);p.useEffect(()=>{if(Je>=Ut.length){const e=Math.max(0,Ut.length-1);return Ze(e),void tt(Math.max(0,e-rt+1))}tt(e=>Je<e?Je:Je>=e+rt?Je-rt+1:e)},[Ut.length,Je,rt]);const Lt=h(e=>{tt(t=>e<t?e:e>=t+rt?e-rt+1:t)},[rt]),Ht=h(()=>{if(null!==Dt)return;const e=Object.entries(ft).map(([e,t])=>(B("tengu_config_changed",{key:e,value:t}),`Set ${e} to ${A.bold(t)}`)),t=be()?void 0:process.env.ANTHROPIC_API_KEY,n=Boolean(t&&He.current.customApiKeyResponses?.approved?.includes(S(t))),o=Boolean(t&&Ue.customApiKeyResponses?.approved?.includes(S(t)));if(n!==o&&(e.push((o?"Enabled":"Disabled")+" custom API key"),B("tengu_config_changed",{key:"env.ANTHROPIC_API_KEY",value:o})),Ue.theme!==He.current.theme&&e.push(`Set theme to ${A.bold(Ue.theme)}`),Ue.preferredNotifChannel!==He.current.preferredNotifChannel&&e.push(`Set notifications to ${A.bold(Ue.preferredNotifChannel)}`),Ye!==ze.current&&e.push(`Set output style to ${A.bold(Ye)}`),We!==Xe.current&&e.push(`Set response language to ${A.bold(We??"Default (English)")}`),Ue.editorMode!==He.current.editorMode&&e.push(`Set editor mode to ${A.bold(Ue.editorMode||"emacs")}`),Ue.diffTool!==He.current.diffTool&&e.push(`Set diff tool to ${A.bold(Ue.diffTool)}`),Ue.autoConnectIde!==He.current.autoConnectIde&&e.push((Ue.autoConnectIde?"Enabled":"Disabled")+" auto-connect to IDE"),Ue.autoInstallIdeExtension!==He.current.autoInstallIdeExtension&&e.push((Ue.autoInstallIdeExtension?"Enabled":"Disabled")+" auto-install IDE extension"),Ue.autoCompactEnabled!==He.current.autoCompactEnabled&&e.push((Ue.autoCompactEnabled?"Enabled":"Disabled")+" auto-compact"),Ue.respectGitignore!==He.current.respectGitignore&&e.push((Ue.respectGitignore?"Enabled":"Disabled")+" respect .gitignore in file picker"),Ue.copyFullResponse!==He.current.copyFullResponse&&e.push((Ue.copyFullResponse?"Enabled":"Disabled")+" always copy full response"),Ue.copyOnSelect!==He.current.copyOnSelect&&e.push((Ue.copyOnSelect?"Enabled":"Disabled")+" copy on select"),Ue.terminalProgressBarEnabled!==He.current.terminalProgressBarEnabled&&e.push((Ue.terminalProgressBarEnabled?"Enabled":"Disabled")+" terminal progress bar"),Ue.showStatusInTerminalTab!==He.current.showStatusInTerminalTab&&e.push((Ue.showStatusInTerminalTab?"Enabled":"Disabled")+" terminal tab status"),Ue.showTurnDuration!==He.current.showTurnDuration&&e.push((Ue.showTurnDuration?"Enabled":"Disabled")+" turn duration"),Ue.remoteControlAtStartup!==He.current.remoteControlAtStartup){const t=void 0===Ue.remoteControlAtStartup?"Reset Remote Control to default":(Ue.remoteControlAtStartup?"Enabled":"Disabled")+" Remote Control for all sessions";e.push(t)}Ve?.autoUpdatesChannel!==$e.current?.autoUpdatesChannel&&e.push(`Set auto-update channel to ${A.bold(Ve?.autoUpdatesChannel??"latest")}`),e.length>0?l(e.join("\n")):l("Config dialog dismissed",{display:"system"})},[Dt,ft,Ue,st,Ye,We,Ve?.autoUpdatesChannel,De()?Ve?.fastMode:void 0,l]),Vt=h(()=>{Ke!==St.current&&Fe(St.current),y(()=>He.current);const e=yt;me("localSettings",{spinnerTipsEnabled:e?.spinnerTipsEnabled,prefersReducedMotion:e?.prefersReducedMotion,defaultView:e?.defaultView,outputStyle:e?.outputStyle});const n=Et;me("userSettings",{alwaysThinkingEnabled:n?.alwaysThinkingEnabled,fastMode:n?.fastMode,promptSuggestionEnabled:n?.promptSuggestionEnabled,autoUpdatesChannel:n?.autoUpdatesChannel,minimumVersion:n?.minimumVersion,language:n?.language,...t("TRANSCRIPT_CLASSIFIER")?{useAutoModeDuringPlan:n?.useAutoModeDuringPlan}:{},syntaxHighlightingDisabled:n?.syntaxHighlightingDisabled,permissions:void 0===n?.permissions?void 0:{...n.permissions,defaultMode:n.permissions.defaultMode}});const o=vt;ht(e=>({...e,mainLoopModel:o.mainLoopModel,mainLoopModelForSession:o.mainLoopModelForSession,verbose:o.verbose,thinkingEnabled:o.thinkingEnabled,fastMode:o.fastMode,promptSuggestionEnabled:o.promptSuggestionEnabled,isBriefOnly:o.isBriefOnly,replBridgeEnabled:o.replBridgeEnabled,replBridgeOutboundOnly:o.replBridgeOutboundOnly,settings:o.settings,toolPermissionContext:j(e.toolPermissionContext)})),pe()!==It&&ge(It)},[Ke,Fe,yt,Et,vt,It,ht]),Gt=h(()=>{null===Dt&&(Mt.current&&Vt(),l("Config dialog dismissed",{display:"system"}))},[Dt,Vt,l]);f("confirm:no",Gt,{context:"Settings",isActive:null===Dt&&!nt&&!je}),f("settings:close",Ht,{context:"Settings",isActive:null===Dt&&!nt&&!je});const $t=h(()=>{const e=Ut[Je];if(e&&e.onChange)if("boolean"!==e.type){if("theme"===e.id||"model"===e.id||"teammateDefaultModel"===e.id||"showExternalIncludesDialog"===e.id||"outputStyle"===e.id||"language"===e.id)switch(e.id){case"theme":return Rt("Theme"),void _e(!0);case"model":return Rt("Model"),void _e(!0);case"teammateDefaultModel":return Rt("TeammateModel"),void _e(!0);case"showExternalIncludesDialog":return Rt("ExternalIncludes"),void _e(!0);case"outputStyle":return Rt("OutputStyle"),void _e(!0);case"language":return Rt("Language"),void _e(!0)}if("autoUpdatesChannel"===e.id){if(Ft)return Rt("EnableAutoUpdates"),void _e(!0);return void("latest"===(Ve?.autoUpdatesChannel??"latest")?(Rt("ChannelDowngrade"),_e(!0)):(Mt.current=!0,me("userSettings",{autoUpdatesChannel:"latest",minimumVersion:void 0}),Ge(e=>({...e,autoUpdatesChannel:"latest",minimumVersion:void 0})),B("tengu_autoupdate_channel_changed",{channel:"latest"})))}if("enum"===e.type){Mt.current=!0;const t=(e.options.indexOf(e.value)+1)%e.options.length;return void e.onChange(e.options[t])}}else if(Mt.current=!0,e.onChange(!e.value),"thinkingEnabled"===e.id){!e.value===Ct.current?Tt(!1):r.messages.some(e=>"assistant"===e.type)&&Tt(!0)}},[Ft,Ut,Je,Ve?.autoUpdatesChannel,_e]),moveSelection=e=>{Tt(!1);const t=Math.max(0,Math.min(Ut.length-1,Je+e));Ze(t),Lt(t)};b({"select:previous":()=>{0===Je?(Tt(!1),ot(!0),tt(0)):moveSelection(-1)},"select:next":()=>moveSelection(1),"scroll:lineUp":()=>moveSelection(-1),"scroll:lineDown":()=>moveSelection(1),"select:accept":$t,"settings:search":()=>{ot(!0),xt("")}},{context:"Settings",isActive:null===Dt&&!nt&&!je});const Yt=h(e=>{if(null===Dt&&!je)return nt?"escape"===e.key?(e.preventDefault(),void(kt.length>0?xt(""):ot(!1))):void("return"!==e.key&&"down"!==e.key&&"wheeldown"!==e.key||(e.preventDefault(),ot(!1),Ze(0),tt(0))):"left"===e.key||"right"===e.key||"tab"===e.key?(e.preventDefault(),void $t()):void(e.ctrl||e.meta||"j"!==e.key&&"k"!==e.key&&"/"!==e.key&&1===e.key.length&&" "!==e.key&&(e.preventDefault(),ot(!0),xt(e.key)))},[Dt,je,nt,kt,xt,$t]);return n(s,{flexDirection:"column",width:"100%",tabIndex:0,autoFocus:!0,onKeyDown:Yt,children:"Theme"===Dt?o(a,{children:[n(K,{onThemeSelect:e=>{Mt.current=!0,Fe(e),Rt(null),_e(!1)},onCancel:()=>{Rt(null),_e(!1)},hideEscToCancel:!0,skipExitHandling:!0}),n(s,{children:n(d,{dimColor:!0,italic:!0,children:o(ae,{children:[n(ne,{shortcut:"Enter",action:"seleccionar"}),n(oe,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"cancelar"})]})})})]}):"Model"===Dt?o(a,{children:[n(V,{initial:st,onSelect:(e,t)=>{Mt.current=!0,onChangeMainModelConfig(e),Rt(null),_e(!1)},onCancel:()=>{Rt(null),_e(!1)},showFastModeNotice:!!De()&&(ct&&ke(st)&&Te())}),n(d,{dimColor:!0,children:o(ae,{children:[n(ne,{shortcut:"Enter",action:"confirmar"}),n(oe,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"cancelar"})]})})]}):"TeammateModel"===Dt?o(a,{children:[n(V,{initial:Ue.teammateDefaultModel??null,skipSettingsWrite:!0,headerText:"Default model for newly spawned teammates. The leader can override via the tool call's model parameter.",onSelect:(e,t)=>{Rt(null),_e(!1),void 0===Ue.teammateDefaultModel&&null===e||(Mt.current=!0,y(t=>t.teammateDefaultModel===e?t:{...t,teammateDefaultModel:e}),Le({..._(),teammateDefaultModel:e}),bt(t=>({...t,teammateDefaultModel:teammateModelDisplayString(e)})),B("tengu_teammate_default_model_changed",{model:e}))},onCancel:()=>{Rt(null),_e(!1)}}),n(d,{dimColor:!0,children:o(ae,{children:[n(ne,{shortcut:"Enter",action:"confirmar"}),n(oe,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"cancelar"})]})})]}):"ExternalIncludes"===Dt?o(a,{children:[n(q,{onDone:()=>{Rt(null),_e(!1)},externalIncludes:Z(Nt)}),n(d,{dimColor:!0,children:o(ae,{children:[n(ne,{shortcut:"Enter",action:"confirmar"}),n(oe,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"disable external includes"})]})})]}):"OutputStyle"===Dt?o(a,{children:[n(X,{initialStyle:Ye,onComplete:e=>{Mt.current=!0,qe(e??he),Rt(null),_e(!1),me("localSettings",{outputStyle:e}),B("tengu_output_style_changed",{style:e??he,source:"config_panel",settings_source:"localSettings"})},onCancel:()=>{Rt(null),_e(!1)}}),n(d,{dimColor:!0,children:o(ae,{children:[n(ne,{shortcut:"Enter",action:"confirmar"}),n(oe,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"cancelar"})]})})]}):"Language"===Dt?o(a,{children:[n(J,{initialLanguage:We,onComplete:e=>{Mt.current=!0,Qe(e),Rt(null),_e(!1),me("userSettings",{language:e}),B("tengu_language_changed",{language:e??"default",source:"config_panel"})},onCancel:()=>{Rt(null),_e(!1)}}),n(d,{dimColor:!0,children:o(ae,{children:[n(ne,{shortcut:"Enter",action:"confirmar"}),n(oe,{action:"confirm:no",context:"Settings",fallback:"Esc",description:"cancelar"})]})})]}):"EnableAutoUpdates"===Dt?n(W,{title:"Enable Auto-Updates",onCancel:()=>{Rt(null),_e(!1)},hideBorder:!0,hideInputGuide:!0,children:"config"!==Ft?.type?o(a,{children:[n(d,{children:"env"===Ft?.type?"Auto-updates are controlled by an environment variable and cannot be changed here.":"Auto-updates are disabled in development builds."}),"env"===Ft?.type&&o(d,{dimColor:!0,children:["Unset ",Ft.envVar," to re-enable auto-updates."]})]}):n(Q,{options:[{label:"Enable with latest channel",value:"latest"},{label:"Enable with stable channel",value:"stable"}],onChange:e=>{Mt.current=!0,Rt(null),_e(!1),y(e=>({...e,autoUpdates:!0})),Le({..._(),autoUpdates:!0}),me("userSettings",{autoUpdatesChannel:e,minimumVersion:void 0}),Ge(t=>({...t,autoUpdatesChannel:e,minimumVersion:void 0})),B("tengu_autoupdate_enabled",{channel:e})}})}):"ChannelDowngrade"===Dt?n(z,{currentVersion:e.VERSION,onChoice:t=>{if(Rt(null),_e(!1),"cancel"===t)return;Mt.current=!0;const n={autoUpdatesChannel:"stable"};"stay"===t&&(n.minimumVersion=e.VERSION),me("userSettings",n),Ge(e=>({...e,...n})),B("tengu_autoupdate_channel_changed",{channel:"stable",minimum_version_set:"stay"===t})}}):o(s,{flexDirection:"column",gap:1,marginY:Be?void 0:1,children:[n(re,{query:kt,isFocused:nt&&!je,isTerminalFocused:at,cursorOffset:wt,placeholder:"Search settings…"}),n(s,{flexDirection:"column",children:0===Ut.length?o(d,{dimColor:!0,italic:!0,children:['No settings match "',kt,'"']}):o(a,{children:[et>0&&o(d,{dimColor:!0,children:[C.arrowUp," ",et," more above"]}),Ut.slice(et,et+rt).map((e,t)=>{const l=et+t===Je&&!je&&!nt;return n(p.Fragment,{children:o(s,{children:[n(s,{width:44,children:o(d,{color:l?"suggestion":void 0,children:[l?C.pointer:" "," ",e.label]})}),n(s,{children:"boolean"===e.type?o(a,{children:[n(d,{color:l?"suggestion":void 0,children:e.value.toString()}),At&&"thinkingEnabled"===e.id&&o(d,{color:"warning",children:[" ","Changing thinking mode mid-conversation will increase latency and may reduce quality."]})]}):"theme"===e.id?n(d,{color:l?"suggestion":void 0,children:we[e.value.toString()]??e.value.toString()}):"notifChannel"===e.id?n(d,{color:l?"suggestion":void 0,children:n(NotifChannelLabel,{value:e.value.toString()})}):"defaultPermissionMode"===e.id?n(d,{color:l?"suggestion":void 0,children:T(e.value)}):"autoUpdatesChannel"===e.id&&Ft?o(s,{flexDirection:"column",children:[n(d,{color:l?"suggestion":void 0,children:"disabled"}),o(d,{dimColor:!0,children:["(",I(Ft),")"]})]}):n(d,{color:l?"suggestion":void 0,children:e.value.toString()})},l?"selected":"unselected")]})},e.id)}),et+rt<Ut.length&&o(d,{dimColor:!0,children:[C.arrowDown," ",Ut.length-et-rt," ","more below"]})]})}),n(d,je?{dimColor:!0,children:o(ae,{children:[n(ne,{shortcut:"←/→ tab",action:"switch"}),n(ne,{shortcut:"↓",action:"return"}),n(oe,{action:"confirm:no",context:"Settings",fallback:"Esc",description:"cerrar"})]})}:nt?{dimColor:!0,children:o(ae,{children:[n(d,{children:"Escribe para filtrar"}),n(ne,{shortcut:"Enter/↓",action:"seleccionar"}),n(ne,{shortcut:"↑",action:"tabs"}),n(oe,{action:"confirm:no",context:"Settings",fallback:"Esc",description:"clear"})]})}:{dimColor:!0,children:o(ae,{children:[n(oe,{action:"select:accept",context:"Settings",fallback:"Space",description:"change"}),n(oe,{action:"settings:close",context:"Settings",fallback:"Enter",description:"save"}),n(oe,{action:"settings:search",context:"Settings",fallback:"/",description:"search"}),n(oe,{action:"confirm:no",context:"Settings",fallback:"Esc",description:"cancelar"})]})})]})})}function teammateModelDisplayString(e){return void 0===e?G(_e()):null===e?"Default (leader's model)":G(e)}const we={auto:"Automático (según terminal)",dark:"Modo oscuro",light:"Modo claro","dark-daltonized":"Modo oscuro (apto para daltonismo)","light-daltonized":"Modo claro (apto para daltonismo)","dark-ansi":"Modo oscuro (solo colores ANSI)","light-ansi":"Modo claro (solo colores ANSI)"};function NotifChannelLabel(e){const t=r(4),{value:a}=e;switch(a){case"auto":return"Auto";case"iterm2":{let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o(d,{children:["iTerm2 ",n(d,{dimColor:!0,children:"(OSC 9)"})]}),t[0]=e):e=t[0],e}case"terminal_bell":{let e;return t[1]===Symbol.for("react.memo_cache_sentinel")?(e=o(d,{children:["Terminal Bell ",n(d,{dimColor:!0,children:"(\\a)"})]}),t[1]=e):e=t[1],e}case"kitty":{let e;return t[2]===Symbol.for("react.memo_cache_sentinel")?(e=o(d,{children:["Kitty ",n(d,{dimColor:!0,children:"(OSC 99)"})]}),t[2]=e):e=t[2],e}case"ghostty":{let e;return t[3]===Symbol.for("react.memo_cache_sentinel")?(e=o(d,{children:["Ghostty ",n(d,{dimColor:!0,children:"(OSC 777)"})]}),t[3]=e):e=t[3],e}case"iterm2_with_bell":return"iTerm2 w/ Bell";case"notifications_disabled":return"Disabled";default:return a}}
@@ -1 +1 @@
1
- import{jsxs as o,jsx as e}from"react/jsx-runtime";import{c as i}from"react/compiler-runtime";import{basename as n,relative as t}from"path";import{Box as r,Text as c}from"../ink.js";import{getCwd as s}from"../utils/cwd.js";import{isSupportedVSCodeTerminal as l}from"../utils/ide.js";import{Select as m}from"./CustomSelect/index.js";import{Pane as d}from"./design-system/Pane.js";export function ShowInIDEPrompt(p){const a=i(36),{onChange:u,options:f,input:h,filePath:g,ideName:y,symlinkTarget:j,rejectFeedback:k,acceptFeedback:v,setFocusedOption:x,onInputModeToggle:b,focusedOption:w,yesInputMode:C,noInputMode:I}=p;let T,D,S,F,M,O,P,E,$,_;a[0]!==y?(T=o(c,{bold:!0,color:"permission",children:["Opened changes in ",y," ⧉"]}),a[0]=y,a[1]=T):T=a[1],a[2]!==j?(D=j&&e(c,{color:"warning",children:t(s(),j).startsWith("..")?`This will modify ${j} (outside working directory) via a symlink`:`Symlink target: ${j}`}),a[2]=j,a[3]=D):D=a[3],a[4]===Symbol.for("react.memo_cache_sentinel")?(S=l()&&e(c,{dimColor:!0,children:"Save file to continue…"}),a[4]=S):S=a[4],a[5]!==g?(F=n(g),a[5]=g,a[6]=F):F=a[6],a[7]!==F?(M=o(c,{children:["Do you want to make this edit to"," ",e(c,{bold:!0,children:F}),"?"]}),a[7]=F,a[8]=M):M=a[8],a[9]!==v||a[10]!==h||a[11]!==u||a[12]!==f||a[13]!==k?(O=o=>{const e=f.find(e=>e.value===o);if(e){if("reject"===e.option.type){const o=k.trim();return void u(e.option,h,o||void 0)}if("accept-once"===e.option.type){const o=v.trim();return void u(e.option,h,o||void 0)}u(e.option,h)}},a[9]=v,a[10]=h,a[11]=u,a[12]=f,a[13]=k,a[14]=O):O=a[14],a[15]!==h||a[16]!==u?(P=()=>u({type:"reject"},h),a[15]=h,a[16]=u,a[17]=P):P=a[17],a[18]!==x?(E=o=>x(o),a[18]=x,a[19]=E):E=a[19],a[20]!==b||a[21]!==f||a[22]!==O||a[23]!==P||a[24]!==E?($=e(m,{options:f,inlineDescriptions:!0,onChange:O,onCancel:P,onFocus:E,onInputModeToggle:b}),a[20]=b,a[21]=f,a[22]=O,a[23]=P,a[24]=E,a[25]=$):$=a[25],a[26]!==M||a[27]!==$?(_=o(r,{flexDirection:"column",children:[M,$]}),a[26]=M,a[27]=$,a[28]=_):_=a[28];const N=("yes"===w&&!C||"no"===w&&!I)&&" · Tab to amend";let W,q;return a[29]!==N?(W=e(r,{marginTop:1,children:o(c,{dimColor:!0,children:["Esc para cancelar",N]})}),a[29]=N,a[30]=W):W=a[30],a[31]!==T||a[32]!==_||a[33]!==W||a[34]!==D?(q=e(d,{color:"permission",children:o(r,{flexDirection:"column",gap:1,children:[T,D,S,_,W]})}),a[31]=T,a[32]=_,a[33]=W,a[34]=D,a[35]=q):q=a[35],q}
1
+ import{jsxs as o,jsx as e}from"react/jsx-runtime";import{c as i}from"react/compiler-runtime";import{basename as n,relative as r}from"path";import{Box as t,Text as c}from"../ink.js";import{getCwd as a}from"../utils/cwd.js";import{isSupportedVSCodeTerminal as s}from"../utils/ide.js";import{Select as l}from"./CustomSelect/index.js";import{Pane as d}from"./design-system/Pane.js";export function ShowInIDEPrompt(m){const p=i(36),{onChange:u,options:f,input:h,filePath:j,ideName:b,symlinkTarget:g,rejectFeedback:y,acceptFeedback:v,setFocusedOption:x,onInputModeToggle:C,focusedOption:I,yesInputMode:D,noInputMode:T}=m;let k,F,M,w,E,P,S,O,$,_;p[0]!==b?(k=o(c,{bold:!0,color:"permission",children:["Cambios abiertos en ",b," ⧉"]}),p[0]=b,p[1]=k):k=p[1],p[2]!==g?(F=g&&e(c,{color:"warning",children:r(a(),g).startsWith("..")?`Esto modificará ${g} (fuera del directorio de trabajo) a través de un enlace simbólico`:`Destino del enlace simbólico: ${g}`}),p[2]=g,p[3]=F):F=p[3],p[4]===Symbol.for("react.memo_cache_sentinel")?(M=s()&&e(c,{dimColor:!0,children:"Guarda el archivo para continuar…"}),p[4]=M):M=p[4],p[5]!==j?(w=n(j),p[5]=j,p[6]=w):w=p[6],p[7]!==w?(E=o(c,{children:["¿Quieres aplicar esta edición a"," ",e(c,{bold:!0,children:w}),"?"]}),p[7]=w,p[8]=E):E=p[8],p[9]!==v||p[10]!==h||p[11]!==u||p[12]!==f||p[13]!==y?(P=o=>{const e=f.find(e=>e.value===o);if(e){if("reject"===e.option.type){const o=y.trim();return void u(e.option,h,o||void 0)}if("accept-once"===e.option.type){const o=v.trim();return void u(e.option,h,o||void 0)}u(e.option,h)}},p[9]=v,p[10]=h,p[11]=u,p[12]=f,p[13]=y,p[14]=P):P=p[14],p[15]!==h||p[16]!==u?(S=()=>u({type:"reject"},h),p[15]=h,p[16]=u,p[17]=S):S=p[17],p[18]!==x?(O=o=>x(o),p[18]=x,p[19]=O):O=p[19],p[20]!==C||p[21]!==f||p[22]!==P||p[23]!==S||p[24]!==O?($=e(l,{options:f,inlineDescriptions:!0,onChange:P,onCancel:S,onFocus:O,onInputModeToggle:C}),p[20]=C,p[21]=f,p[22]=P,p[23]=S,p[24]=O,p[25]=$):$=p[25],p[26]!==E||p[27]!==$?(_=o(t,{flexDirection:"column",children:[E,$]}),p[26]=E,p[27]=$,p[28]=_):_=p[28];const G=("yes"===I&&!D||"no"===I&&!T)&&" · Tab para modificar";let N,Q;return p[29]!==G?(N=e(t,{marginTop:1,children:o(c,{dimColor:!0,children:["Esc para cancelar",G]})}),p[29]=G,p[30]=N):N=p[30],p[31]!==k||p[32]!==_||p[33]!==N||p[34]!==F?(Q=e(d,{color:"permission",children:o(t,{flexDirection:"column",gap:1,children:[k,F,M,_,N]})}),p[31]=k,p[32]=_,p[33]=N,p[34]=F,p[35]=Q):Q=p[35],Q}
@@ -1 +1 @@
1
- import{feature as e}from"../recovery/bunBundleShim.js";import{jsx as t,jsxs as n,Fragment as o}from"react/jsx-runtime";import{c as r}from"react/compiler-runtime";import{plot as s}from"asciichart";import i from"chalk";import l from"figures";import{Suspense as a,use as c,useEffect as u,useMemo as d,useState as m}from"react";import p from"strip-ansi";import{useTerminalSize as g}from"../hooks/useTerminalSize.js";import{applyColor as f}from"../ink/colorize.js";import{stringWidth as k}from"../ink/stringWidth.js";import{Ansi as b,Box as T,Text as y,useInput as w}from"../ink.js";import{useKeybinding as x}from"../keybindings/useKeybinding.js";import{getGlobalConfig as S}from"../utils/config.js";import{formatDuration as v,formatNumber as D}from"../utils/format.js";import{generateHeatmap as M}from"../utils/heatmap.js";import{renderModelName as j}from"../utils/model/model.js";import{copyAnsiToClipboard as $}from"../utils/screenshotClipboard.js";import{aggregateClaudeCodeStatsForRange as A}from"../utils/stats.js";import{resolveThemeSetting as _}from"../utils/systemTheme.js";import{getTheme as C,themeColorToAnsi as O}from"../utils/theme.js";import{Pane as L}from"./design-system/Pane.js";import{Tab as F,Tabs as R,useTabHeaderFocus as B}from"./design-system/Tabs.js";import{Spinner as P}from"./Spinner.js";const E={"7d":"Last 7 days","30d":"Last 30 days",all:"All time"},H=["all","7d","30d"];export function Stats(e){const o=r(4),{onClose:s}=e;let i;o[0]===Symbol.for("react.memo_cache_sentinel")?(i=A("all").then(e=>e&&0!==e.totalSessions?{type:"success",data:e}:{type:"empty"}).catch(e=>({type:"error",message:e instanceof Error?e.message:"Failed to load stats"})),o[0]=i):i=o[0];const l=i;let c,u;return o[1]===Symbol.for("react.memo_cache_sentinel")?(c=n(T,{marginTop:1,children:[t(P,{}),t(y,{children:" Loading your Context Code stats…"})]}),o[1]=c):c=o[1],o[2]!==s?(u=t(a,{fallback:c,children:t(StatsContent,{allTimePromise:l,onClose:s})}),o[2]=s,o[3]=u):u=o[3],u}function StatsContent(o){const s=r(34),{allTimePromise:a,onClose:d}=o,g=c(a),[b,O]=m("all");let B;s[0]===Symbol.for("react.memo_cache_sentinel")?(B={},s[0]=B):B=s[0];const[E,I]=m(B),[U,W]=m(!1),[N,G]=m("Overview"),[K,Y]=m(null);let z,Q;s[1]!==b||s[2]!==E?(z=()=>{if("all"===b)return;if(E[b])return;let e=!1;return W(!0),A(b).then(t=>{e||(I(e=>({...e,[b]:t})),W(!1))}).catch(()=>{e||W(!1)}),()=>{e=!0}},Q=[b,E],s[1]=b,s[2]=E,s[3]=z,s[4]=Q):(z=s[3],Q=s[4]),u(z,Q);const q="all"===b?"success"===g.type?g.data:null:E[b]??("success"===g.type?g.data:null),J="success"===g.type?g.data:null;let V;s[5]!==d?(V=()=>{d("Stats dialog dismissed",{display:"system"})},s[5]=d,s[6]=V):V=s[6];const X=V;let Z,ee,te,ne,oe;if(s[7]===Symbol.for("react.memo_cache_sentinel")?(Z={context:"Confirmation"},s[7]=Z):Z=s[7],x("confirm:no",X,Z),s[8]!==N||s[9]!==b||s[10]!==q||s[11]!==d?(ee=(t,n)=>{!n.ctrl||"c"!==t&&"d"!==t||d("Stats dialog dismissed",{display:"system"}),n.tab&&G(_temp),"r"!==t||n.ctrl||n.meta||O(function(e){const t=H.indexOf(e);return H[(t+1)%H.length]}(b)),n.ctrl&&"s"===t&&q&&async function(t,n,o){o("copying…");const r=function(t,n){const o=[];"Overview"===n?o.push(...function(t){const n=[],o=C(_(S().theme)),h=e=>f(e,o.claude),r=18,s=40,l=18,row=(e,t,n,o)=>{const i=(e+":").padEnd(r),a=i.length+t.length,c=Math.max(2,s-a),u=(n+":").padEnd(l);return i+h(t)+" ".repeat(c)+u+h(o)};t.dailyActivity.length>0&&(n.push(M(t.dailyActivity,{terminalWidth:56})),n.push(""));const a=Object.entries(t.modelUsage).sort(([,e],[,t])=>t.inputTokens+t.outputTokens-(e.inputTokens+e.outputTokens)),c=a[0],u=a.reduce((e,[,t])=>e+t.inputTokens+t.outputTokens,0);c&&n.push(row("Favorite model",j(c[0]),"Total tokens",D(u)));n.push(""),n.push(row("Sessions",D(t.totalSessions),"Longest session",t.longestSession?v(t.longestSession.duration):"N/A"));const d=`${t.streaks.currentStreak} ${1===t.streaks.currentStreak?"day":"days"}`,m=`${t.streaks.longestStreak} ${1===t.streaks.longestStreak?"day":"days"}`;n.push(row("Current streak",d,"Longest streak",m));const p=`${t.activeDays}/${t.totalDays}`,g=null!==t.peakActivityHour?`${t.peakActivityHour}:00-${t.peakActivityHour+1}:00`:"N/A";n.push(row("Active days",p,"Peak hour",g)),!1;if(e("SHOT_STATS")&&t.shotDistribution){const e=t.shotDistribution,o=Object.values(e).reduce((e,t)=>e+t,0);if(o>0){const t=(Object.entries(e).reduce((e,[t,n])=>e+parseInt(t,10)*n,0)/o).toFixed(1),bucket=(t,n)=>Object.entries(e).filter(([e])=>{const o=parseInt(e,10);return o>=t&&(void 0===n||o<=n)}).reduce((e,[,t])=>e+t,0),pct=e=>Math.round(e/o*100),fmtBucket=(e,t)=>`${e} (${t}%)`,s=bucket(1,1),i=bucket(2,5),l=bucket(6,10),a=bucket(11);n.push(""),n.push("Shot distribution"),n.push(row("1-shot",fmtBucket(s,pct(s)),"2–5 shot",fmtBucket(i,pct(i)))),n.push(row("6–10 shot",fmtBucket(l,pct(l)),"11+ shot",fmtBucket(a,pct(a)))),n.push(`${"Avg/session:".padEnd(r)}${h(t)}`)}}n.push("");const k=generateFunFactoid(t,u);return n.push(h(k)),n.push(i.gray(`Stats from the last ${t.totalDays} days`)),n}(t)):o.push(...function(e){const t=[],n=Object.entries(e.modelUsage).sort(([,e],[,t])=>t.inputTokens+t.outputTokens-(e.inputTokens+e.outputTokens));if(0===n.length)return t.push(i.gray("No model usage data available")),t;const o=n[0],r=n.reduce((e,[,t])=>e+t.inputTokens+t.outputTokens,0),s=generateTokenChart(e.dailyModelTokens,n.map(([e])=>e),80);if(s){t.push(i.bold("Tokens per Day")),t.push(s.chart),t.push(i.gray(s.xAxisLabels));const e=s.legend.map(e=>`${e.coloredBullet} ${e.model}`).join(" · ");t.push(e),t.push("")}t.push(`${l.star} Favorite: ${i.magenta.bold(j(o?.[0]||""))} · ${l.circle} Total: ${i.magenta(D(r))} tokens`),t.push("");const a=n.slice(0,3);for(const[e,n]of a){const o=((n.inputTokens+n.outputTokens)/r*100).toFixed(1);t.push(`${l.bullet} ${i.bold(j(e))} ${i.gray(`(${o}%)`)}`),t.push(i.dim(` In: ${D(n.inputTokens)} · Out: ${D(n.outputTokens)}`))}return t}(t));for(;o.length>0&&""===p(o[o.length-1]).trim();)o.pop();if(o.length>0){const e=o[o.length-1],t=k(e),r="Overview"===n?70:80,s="/stats",l=Math.max(2,r-t-s.length);o[o.length-1]=e+" ".repeat(l)+i.gray(s)}return o.join("\n")}(t,n),s=await $(r);o(s.success?"copied!":"copy failed"),setTimeout(o,2e3,null)}(q,N,Y)},s[8]=N,s[9]=b,s[10]=q,s[11]=d,s[12]=ee):ee=s[12],w(ee),"error"===g.type){let e;return s[13]!==g.message?(e=t(T,{marginTop:1,children:n(y,{color:"error",children:["Failed to load stats: ",g.message]})}),s[13]=g.message,s[14]=e):e=s[14],e}if("empty"===g.type){let e;return s[15]===Symbol.for("react.memo_cache_sentinel")?(e=t(T,{marginTop:1,children:t(y,{color:"warning",children:"No stats available yet. Start using Context Code!"})}),s[15]=e):e=s[15],e}if(!q||!J){let e;return s[16]===Symbol.for("react.memo_cache_sentinel")?(e=n(T,{marginTop:1,children:[t(P,{}),t(y,{children:" Loading stats…"})]}),s[16]=e):e=s[16],e}s[17]!==J||s[18]!==b||s[19]!==q||s[20]!==U?(te=t(F,{title:"Overview",children:t(OverviewTab,{stats:q,allTimeStats:J,dateRange:b,isLoading:U})}),s[17]=J,s[18]=b,s[19]=q,s[20]=U,s[21]=te):te=s[21],s[22]!==b||s[23]!==q||s[24]!==U?(ne=t(F,{title:"Models",children:t(ModelsTab,{stats:q,dateRange:b,isLoading:U})}),s[22]=b,s[23]=q,s[24]=U,s[25]=ne):ne=s[25],s[26]!==te||s[27]!==ne?(oe=t(T,{flexDirection:"row",gap:1,marginBottom:1,children:n(R,{title:"",color:"claude",defaultTab:"Overview",children:[te,ne]})}),s[26]=te,s[27]=ne,s[28]=oe):oe=s[28];const re=K?` · ${K}`:"";let se,ie;return s[29]!==re?(se=t(T,{paddingLeft:2,children:n(y,{dimColor:!0,children:["Esc para cancelar · r para recorrer fechas · ctrl+s para copiar",re]})}),s[29]=re,s[30]=se):se=s[30],s[31]!==se||s[32]!==oe?(ie=n(L,{color:"claude",children:[oe,se]}),s[31]=se,s[32]=oe,s[33]=ie):ie=s[33],ie}function _temp(e){return"Overview"===e?"Models":"Overview"}function DateRangeSelector(e){const o=r(9),{dateRange:s,isLoading:i}=e;let l,a,c,u;return o[0]!==s?(l=H.map((e,o)=>n(y,{children:[o>0&&t(y,{dimColor:!0,children:" · "}),t(y,e===s?{bold:!0,color:"claude",children:E[e]}:{dimColor:!0,children:E[e]})]},e)),o[0]=s,o[1]=l):l=o[1],o[2]!==l?(a=t(T,{children:l}),o[2]=l,o[3]=a):a=o[3],o[4]!==i?(c=i&&t(P,{}),o[4]=i,o[5]=c):c=o[5],o[6]!==a||o[7]!==c?(u=n(T,{marginBottom:1,gap:1,children:[a,c]}),o[6]=a,o[7]=c,o[8]=u):u=o[8],u}function OverviewTab({stats:r,allTimeStats:s,dateRange:i,isLoading:l}){const{columns:a}=g(),c=Object.entries(r.modelUsage).sort(([,e],[,t])=>t.inputTokens+t.outputTokens-(e.inputTokens+e.outputTokens)),u=c[0],m=c.reduce((e,[,t])=>e+t.inputTokens+t.outputTokens,0),p=d(()=>generateFunFactoid(r,m),[r,m]),f="7d"===i?7:"30d"===i?30:r.totalDays;let k=null;if(e("SHOT_STATS")&&r.shotDistribution){const e=r.shotDistribution,t=Object.values(e).reduce((e,t)=>e+t,0);if(t>0){const n=Object.entries(e).reduce((e,[t,n])=>e+parseInt(t,10)*n,0),bucket=(t,n)=>Object.entries(e).filter(([e])=>{const o=parseInt(e,10);return o>=t&&(void 0===n||o<=n)}).reduce((e,[,t])=>e+t,0),pct=e=>Math.round(e/t*100),o=bucket(1,1),r=bucket(2,5),s=bucket(6,10),i=bucket(11);k={avgShots:(n/t).toFixed(1),buckets:[{label:"1-shot",count:o,pct:pct(o)},{label:"2–5 shot",count:r,pct:pct(r)},{label:"6–10 shot",count:s,pct:pct(s)},{label:"11+ shot",count:i,pct:pct(i)}]}}}return n(T,{flexDirection:"column",marginTop:1,children:[s.dailyActivity.length>0&&t(T,{flexDirection:"column",marginBottom:1,children:t(b,{children:M(s.dailyActivity,{terminalWidth:a})})}),t(DateRangeSelector,{dateRange:i,isLoading:l}),n(T,{flexDirection:"row",gap:4,marginBottom:1,children:[t(T,{flexDirection:"column",width:28,children:u&&n(y,{wrap:"truncate",children:["Favorite model:"," ",t(y,{color:"claude",bold:!0,children:j(u[0])})]})}),t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:["Total tokens:"," ",t(y,{color:"claude",children:D(m)})]})})]}),n(T,{flexDirection:"row",gap:4,children:[t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:["Sessions:"," ",t(y,{color:"claude",children:D(r.totalSessions)})]})}),t(T,{flexDirection:"column",width:28,children:r.longestSession&&n(y,{wrap:"truncate",children:["Longest session:"," ",t(y,{color:"claude",children:v(r.longestSession.duration)})]})})]}),n(T,{flexDirection:"row",gap:4,children:[t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:["Active days: ",t(y,{color:"claude",children:r.activeDays}),n(y,{color:"subtle",children:["/",f]})]})}),t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:["Longest streak:"," ",t(y,{color:"claude",bold:!0,children:r.streaks.longestStreak})," ",1===r.streaks.longestStreak?"day":"days"]})})]}),n(T,{flexDirection:"row",gap:4,children:[t(T,{flexDirection:"column",width:28,children:r.peakActivityDay&&n(y,{wrap:"truncate",children:["Most active day:"," ",t(y,{color:"claude",children:(w=r.peakActivityDay,new Date(w).toLocaleDateString("en-US",{month:"short",day:"numeric"}))})]})}),t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:["Current streak:"," ",t(y,{color:"claude",bold:!0,children:s.streaks.currentStreak})," ",1===s.streaks.currentStreak?"day":"days"]})})]}),!1,k&&n(o,{children:[t(T,{marginTop:1,children:t(y,{children:"Shot distribution"})}),n(T,{flexDirection:"row",gap:4,children:[t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:[k.buckets[0].label,":"," ",t(y,{color:"claude",children:k.buckets[0].count}),n(y,{color:"subtle",children:[" (",k.buckets[0].pct,"%)"]})]})}),t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:[k.buckets[1].label,":"," ",t(y,{color:"claude",children:k.buckets[1].count}),n(y,{color:"subtle",children:[" (",k.buckets[1].pct,"%)"]})]})})]}),n(T,{flexDirection:"row",gap:4,children:[t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:[k.buckets[2].label,":"," ",t(y,{color:"claude",children:k.buckets[2].count}),n(y,{color:"subtle",children:[" (",k.buckets[2].pct,"%)"]})]})}),t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:[k.buckets[3].label,":"," ",t(y,{color:"claude",children:k.buckets[3].count}),n(y,{color:"subtle",children:[" (",k.buckets[3].pct,"%)"]})]})})]}),t(T,{flexDirection:"row",gap:4,children:t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:["Avg/session:"," ",t(y,{color:"claude",children:k.avgShots})]})})})]}),p&&t(T,{marginTop:1,children:t(y,{color:"suggestion",children:p})})]});var w}const I=[{name:"The Little Prince",tokens:22e3},{name:"The Old Man and the Sea",tokens:35e3},{name:"A Christmas Carol",tokens:37e3},{name:"Animal Farm",tokens:39e3},{name:"Fahrenheit 451",tokens:6e4},{name:"The Great Gatsby",tokens:62e3},{name:"Slaughterhouse-Five",tokens:64e3},{name:"Brave New World",tokens:83e3},{name:"The Catcher in the Rye",tokens:95e3},{name:"Harry Potter and the Philosopher's Stone",tokens:103e3},{name:"The Hobbit",tokens:123e3},{name:"1984",tokens:123e3},{name:"To Kill a Mockingbird",tokens:13e4},{name:"Pride and Prejudice",tokens:156e3},{name:"Dune",tokens:244e3},{name:"Moby-Dick",tokens:268e3},{name:"Crime and Punishment",tokens:274e3},{name:"A Game of Thrones",tokens:381e3},{name:"Anna Karenina",tokens:468e3},{name:"Don Quixote",tokens:52e4},{name:"The Lord of the Rings",tokens:576e3},{name:"The Count of Monte Cristo",tokens:603e3},{name:"Les Misérables",tokens:689e3},{name:"War and Peace",tokens:73e4}],U=[{name:"a TED talk",minutes:18},{name:"an episode of The Office",minutes:22},{name:"listening to Abbey Road",minutes:47},{name:"a yoga class",minutes:60},{name:"a World Cup soccer match",minutes:90},{name:"a half marathon (average time)",minutes:120},{name:"the movie Inception",minutes:148},{name:"watching Titanic",minutes:195},{name:"a transatlantic flight",minutes:420},{name:"a full night of sleep",minutes:480}];function generateFunFactoid(e,t){const n=[];if(t>0){const e=I.filter(e=>t>=e.tokens);for(const o of e){const e=t/o.tokens;e>=2?n.push(`You've used ~${Math.floor(e)}x more tokens than ${o.name}`):n.push(`You've used the same number of tokens as ${o.name}`)}}if(e.longestSession){const t=e.longestSession.duration/6e4;for(const e of U){const o=t/e.minutes;o>=2&&n.push(`Your longest session is ~${Math.floor(o)}x longer than ${e.name}`)}}if(0===n.length)return"";return n[Math.floor(Math.random()*n.length)]}function ModelsTab(e){const o=r(15),{stats:s,dateRange:i,isLoading:a}=e,{headerFocused:c,focusHeader:u}=B(),[d,p]=m(0),{columns:f}=g(),k=Object.entries(s.modelUsage).sort(_temp7),x=!c;let S;if(o[0]!==x?(S={isActive:x},o[0]=x,o[1]=S):S=o[1],w((e,t)=>{t.downArrow&&d<k.length-4&&p(e=>Math.min(e+2,k.length-4)),t.upArrow&&(d>0?p(_temp8):u())},S),0===k.length){let e;return o[2]===Symbol.for("react.memo_cache_sentinel")?(e=t(T,{children:t(y,{color:"subtle",children:"No model usage data available"})}),o[2]=e):e=o[2],e}const v=k.reduce(_temp9,0),D=generateTokenChart(s.dailyModelTokens,k.map(_temp0),f),M=k.slice(d,d+4),j=Math.ceil(M.length/2),$=M.slice(0,j),A=M.slice(j),_=d>0,C=d<k.length-4,O=k.length>4;let L;o[3]!==i||o[4]!==a?(L=t(DateRangeSelector,{dateRange:i,isLoading:a}),o[3]=i,o[4]=a,o[5]=L):L=o[5];const F=T,R=A.map(e=>{const[n,o]=e;return t(ModelEntry,{model:n,usage:o,totalTokens:v},n)});let P,E;return o[6]!==F||o[7]!==R?(P=t(F,{flexDirection:"column",width:36,children:R}),o[6]=F,o[7]=R,o[8]=P):P=o[8],o[9]!==C||o[10]!==_||o[11]!==k||o[12]!==d||o[13]!==O?(E=O&&t(T,{marginTop:1,children:n(y,{color:"subtle",children:[_?l.arrowUp:" "," ",C?l.arrowDown:" "," ",d+1,"-",Math.min(d+4,k.length)," of"," ",k.length," models (↑↓ to scroll)"]})}),o[9]=C,o[10]=_,o[11]=k,o[12]=d,o[13]=O,o[14]=E):E=o[14],n(T,{flexDirection:"column",marginTop:1,children:[D&&n(T,{flexDirection:"column",marginBottom:1,children:[t(y,{bold:!0,children:"Tokens per Day"}),t(b,{children:D.chart}),t(y,{color:"subtle",children:D.xAxisLabels}),t(T,{children:D.legend.map(_temp1)})]}),L,n(T,{flexDirection:"row",gap:4,children:[t(T,{flexDirection:"column",width:36,children:$.map(e=>{const[n,o]=e;return t(ModelEntry,{model:n,usage:o,totalTokens:v},n)})}),P]}),E]})}function _temp1(e,o){return n(y,{children:[o>0?" · ":"",t(b,{children:e.coloredBullet})," ",e.model]},e.model)}function _temp0(e){const[t]=e;return t}function _temp9(e,t){const[,n]=t;return e+n.inputTokens+n.outputTokens}function _temp8(e){return Math.max(e-2,0)}function _temp7(e,t){const[,n]=e,[,o]=t;return o.inputTokens+o.outputTokens-(n.inputTokens+n.outputTokens)}function ModelEntry(e){const o=r(21),{model:s,usage:i,totalTokens:a}=e,c=(i.inputTokens+i.outputTokens)/a*100;let u;o[0]!==c?(u=c.toFixed(1),o[0]=c,o[1]=u):u=o[1];const d=u;let m,p,g,f,k,b,w,x;return o[2]!==s?(m=j(s),o[2]=s,o[3]=m):m=o[3],o[4]!==m?(p=t(y,{bold:!0,children:m}),o[4]=m,o[5]=p):p=o[5],o[6]!==d?(g=n(y,{color:"subtle",children:["(",d,"%)"]}),o[6]=d,o[7]=g):g=o[7],o[8]!==p||o[9]!==g?(f=n(y,{children:[l.bullet," ",p," ",g]}),o[8]=p,o[9]=g,o[10]=f):f=o[10],o[11]!==i.inputTokens?(k=D(i.inputTokens),o[11]=i.inputTokens,o[12]=k):k=o[12],o[13]!==i.outputTokens?(b=D(i.outputTokens),o[13]=i.outputTokens,o[14]=b):b=o[14],o[15]!==k||o[16]!==b?(w=n(y,{color:"subtle",children:[" ","In: ",k," · Out:"," ",b]}),o[15]=k,o[16]=b,o[17]=w):w=o[17],o[18]!==f||o[19]!==w?(x=n(T,{flexDirection:"column",children:[f,w]}),o[18]=f,o[19]=w,o[20]=x):x=o[20],x}function generateTokenChart(e,t,n){if(e.length<2||0===t.length)return null;const o=n-7,r=Math.min(52,Math.max(20,o));let i;if(e.length>=r)i=e.slice(-r);else{const t=Math.floor(r/e.length);i=[];for(const n of e)for(let e=0;e<t;e++)i.push(n)}const a=C(_(S().theme)),c=[O(a.suggestion),O(a.success),O(a.warning)],u=[],d=[],m=t.slice(0,3);for(let e=0;e<m.length;e++){const t=m[e],n=i.map(e=>e.tokensByModel[t]||0);if(n.some(e=>e>0)){u.push(n);const o=[a.suggestion,a.success,a.warning];d.push({model:j(t),coloredBullet:f(l.bullet,o[e%o.length])})}}if(0===u.length)return null;return{chart:s(u,{height:8,colors:c.slice(0,u.length),format:e=>{let t;return t=e>=1e6?(e/1e6).toFixed(1)+"M":e>=1e3?(e/1e3).toFixed(0)+"k":e.toFixed(0),t.padStart(6)}}),legend:d,xAxisLabels:function(e,t,n){if(0===e.length)return"";const o=Math.min(4,Math.max(2,Math.floor(e.length/8))),r=e.length-6,s=Math.floor(r/(o-1))||1,i=[];for(let t=0;t<o;t++){const n=Math.min(t*s,e.length-1),o=new Date(e[n].date).toLocaleDateString("en-US",{month:"short",day:"numeric"});i.push({pos:n,label:o})}let l=" ".repeat(n),a=0;for(const{pos:e,label:t}of i){const n=Math.max(1,e-a);l+=" ".repeat(n)+t,a=e+t.length}return l}(i,i.length,7)}}
1
+ import{feature as e}from"../recovery/bunBundleShim.js";import{jsx as t,jsxs as n,Fragment as o}from"react/jsx-runtime";import{c as r}from"react/compiler-runtime";import{plot as s}from"asciichart";import i from"chalk";import l from"figures";import{Suspense as a,use as c,useEffect as u,useMemo as d,useState as m}from"react";import p from"strip-ansi";import{useTerminalSize as g}from"../hooks/useTerminalSize.js";import{applyColor as f}from"../ink/colorize.js";import{stringWidth as k}from"../ink/stringWidth.js";import{Ansi as b,Box as T,Text as y,useInput as w}from"../ink.js";import{useKeybinding as x}from"../keybindings/useKeybinding.js";import{getGlobalConfig as S}from"../utils/config.js";import{formatDuration as v,formatNumber as D}from"../utils/format.js";import{generateHeatmap as M}from"../utils/heatmap.js";import{renderModelName as j}from"../utils/model/model.js";import{copyAnsiToClipboard as $}from"../utils/screenshotClipboard.js";import{aggregateClaudeCodeStatsForRange as A}from"../utils/stats.js";import{resolveThemeSetting as _}from"../utils/systemTheme.js";import{getTheme as C,themeColorToAnsi as O}from"../utils/theme.js";import{Pane as L}from"./design-system/Pane.js";import{Tab as F,Tabs as R,useTabHeaderFocus as B}from"./design-system/Tabs.js";import{Spinner as P}from"./Spinner.js";const E={"7d":"Last 7 days","30d":"Last 30 days",all:"All time"},H=["all","7d","30d"];export function Stats(e){const o=r(4),{onClose:s}=e;let i;o[0]===Symbol.for("react.memo_cache_sentinel")?(i=A("all").then(e=>e&&0!==e.totalSessions?{type:"success",data:e}:{type:"empty"}).catch(e=>({type:"error",message:e instanceof Error?e.message:"Failed to load stats"})),o[0]=i):i=o[0];const l=i;let c,u;return o[1]===Symbol.for("react.memo_cache_sentinel")?(c=n(T,{marginTop:1,children:[t(P,{}),t(y,{children:" Loading your Context Code stats…"})]}),o[1]=c):c=o[1],o[2]!==s?(u=t(a,{fallback:c,children:t(StatsContent,{allTimePromise:l,onClose:s})}),o[2]=s,o[3]=u):u=o[3],u}function StatsContent(o){const s=r(34),{allTimePromise:a,onClose:d}=o,g=c(a),[b,O]=m("all");let B;s[0]===Symbol.for("react.memo_cache_sentinel")?(B={},s[0]=B):B=s[0];const[E,I]=m(B),[U,W]=m(!1),[N,G]=m("Overview"),[K,Y]=m(null);let z,Q;s[1]!==b||s[2]!==E?(z=()=>{if("all"===b)return;if(E[b])return;let e=!1;return W(!0),A(b).then(t=>{e||(I(e=>({...e,[b]:t})),W(!1))}).catch(()=>{e||W(!1)}),()=>{e=!0}},Q=[b,E],s[1]=b,s[2]=E,s[3]=z,s[4]=Q):(z=s[3],Q=s[4]),u(z,Q);const q="all"===b?"success"===g.type?g.data:null:E[b]??("success"===g.type?g.data:null),J="success"===g.type?g.data:null;let V;s[5]!==d?(V=()=>{d("Stats dialog dismissed",{display:"system"})},s[5]=d,s[6]=V):V=s[6];const X=V;let Z,ee,te,ne,oe;if(s[7]===Symbol.for("react.memo_cache_sentinel")?(Z={context:"Confirmation"},s[7]=Z):Z=s[7],x("confirm:no",X,Z),s[8]!==N||s[9]!==b||s[10]!==q||s[11]!==d?(ee=(t,n)=>{!n.ctrl||"c"!==t&&"d"!==t||d("Stats dialog dismissed",{display:"system"}),n.tab&&G(_temp),"r"!==t||n.ctrl||n.meta||O(function(e){const t=H.indexOf(e);return H[(t+1)%H.length]}(b)),n.ctrl&&"s"===t&&q&&async function(t,n,o){o("copying…");const r=function(t,n){const o=[];"Overview"===n?o.push(...function(t){const n=[],o=C(_(S().theme)),h=e=>f(e,o.claude),r=18,s=40,l=18,row=(e,t,n,o)=>{const i=(e+":").padEnd(r),a=i.length+t.length,c=Math.max(2,s-a),u=(n+":").padEnd(l);return i+h(t)+" ".repeat(c)+u+h(o)};t.dailyActivity.length>0&&(n.push(M(t.dailyActivity,{terminalWidth:56})),n.push(""));const a=Object.entries(t.modelUsage).sort(([,e],[,t])=>t.inputTokens+t.outputTokens-(e.inputTokens+e.outputTokens)),c=a[0],u=a.reduce((e,[,t])=>e+t.inputTokens+t.outputTokens,0);c&&n.push(row("Favorite model",j(c[0]),"Total tokens",D(u)));n.push(""),n.push(row("Sessions",D(t.totalSessions),"Longest session",t.longestSession?v(t.longestSession.duration):"N/A"));const d=`${t.streaks.currentStreak} ${1===t.streaks.currentStreak?"day":"days"}`,m=`${t.streaks.longestStreak} ${1===t.streaks.longestStreak?"day":"days"}`;n.push(row("Current streak",d,"Longest streak",m));const p=`${t.activeDays}/${t.totalDays}`,g=null!==t.peakActivityHour?`${t.peakActivityHour}:00-${t.peakActivityHour+1}:00`:"N/A";n.push(row("Active days",p,"Peak hour",g)),!1;if(e("SHOT_STATS")&&t.shotDistribution){const e=t.shotDistribution,o=Object.values(e).reduce((e,t)=>e+t,0);if(o>0){const t=(Object.entries(e).reduce((e,[t,n])=>e+parseInt(t,10)*n,0)/o).toFixed(1),bucket=(t,n)=>Object.entries(e).filter(([e])=>{const o=parseInt(e,10);return o>=t&&(void 0===n||o<=n)}).reduce((e,[,t])=>e+t,0),pct=e=>Math.round(e/o*100),fmtBucket=(e,t)=>`${e} (${t}%)`,s=bucket(1,1),i=bucket(2,5),l=bucket(6,10),a=bucket(11);n.push(""),n.push("Shot distribution"),n.push(row("1-shot",fmtBucket(s,pct(s)),"2–5 shot",fmtBucket(i,pct(i)))),n.push(row("6–10 shot",fmtBucket(l,pct(l)),"11+ shot",fmtBucket(a,pct(a)))),n.push(`${"Avg/session:".padEnd(r)}${h(t)}`)}}n.push("");const k=generateFunFactoid(t,u);return n.push(h(k)),n.push(i.gray(`Stats from the last ${t.totalDays} days`)),n}(t)):o.push(...function(e){const t=[],n=Object.entries(e.modelUsage).sort(([,e],[,t])=>t.inputTokens+t.outputTokens-(e.inputTokens+e.outputTokens));if(0===n.length)return t.push(i.gray("No model usage data available")),t;const o=n[0],r=n.reduce((e,[,t])=>e+t.inputTokens+t.outputTokens,0),s=generateTokenChart(e.dailyModelTokens,n.map(([e])=>e),80);if(s){t.push(i.bold("Tokens per Day")),t.push(s.chart),t.push(i.gray(s.xAxisLabels));const e=s.legend.map(e=>`${e.coloredBullet} ${e.model}`).join(" · ");t.push(e),t.push("")}t.push(`${l.star} Favorite: ${i.magenta.bold(j(o?.[0]||""))} · ${l.circle} Total: ${i.magenta(D(r))} tokens`),t.push("");const a=n.slice(0,3);for(const[e,n]of a){const o=((n.inputTokens+n.outputTokens)/r*100).toFixed(1);t.push(`${l.bullet} ${i.bold(j(e))} ${i.gray(`(${o}%)`)}`),t.push(i.dim(` In: ${D(n.inputTokens)} · Out: ${D(n.outputTokens)}`))}return t}(t));for(;o.length>0&&""===p(o[o.length-1]).trim();)o.pop();if(o.length>0){const e=o[o.length-1],t=k(e),r="Overview"===n?70:80,s="/stats",l=Math.max(2,r-t-s.length);o[o.length-1]=e+" ".repeat(l)+i.gray(s)}return o.join("\n")}(t,n),s=await $(r);o(s.success?"copied!":"copy failed"),setTimeout(o,2e3,null)}(q,N,Y)},s[8]=N,s[9]=b,s[10]=q,s[11]=d,s[12]=ee):ee=s[12],w(ee),"error"===g.type){let e;return s[13]!==g.message?(e=t(T,{marginTop:1,children:n(y,{color:"error",children:["Error al cargar estadísticas: ",g.message]})}),s[13]=g.message,s[14]=e):e=s[14],e}if("empty"===g.type){let e;return s[15]===Symbol.for("react.memo_cache_sentinel")?(e=t(T,{marginTop:1,children:t(y,{color:"warning",children:"No stats available yet. Start using Context Code!"})}),s[15]=e):e=s[15],e}if(!q||!J){let e;return s[16]===Symbol.for("react.memo_cache_sentinel")?(e=n(T,{marginTop:1,children:[t(P,{}),t(y,{children:" Loading stats…"})]}),s[16]=e):e=s[16],e}s[17]!==J||s[18]!==b||s[19]!==q||s[20]!==U?(te=t(F,{title:"Overview",children:t(OverviewTab,{stats:q,allTimeStats:J,dateRange:b,isLoading:U})}),s[17]=J,s[18]=b,s[19]=q,s[20]=U,s[21]=te):te=s[21],s[22]!==b||s[23]!==q||s[24]!==U?(ne=t(F,{title:"Models",children:t(ModelsTab,{stats:q,dateRange:b,isLoading:U})}),s[22]=b,s[23]=q,s[24]=U,s[25]=ne):ne=s[25],s[26]!==te||s[27]!==ne?(oe=t(T,{flexDirection:"row",gap:1,marginBottom:1,children:n(R,{title:"",color:"claude",defaultTab:"Overview",children:[te,ne]})}),s[26]=te,s[27]=ne,s[28]=oe):oe=s[28];const re=K?` · ${K}`:"";let se,ie;return s[29]!==re?(se=t(T,{paddingLeft:2,children:n(y,{dimColor:!0,children:["Esc para cancelar · r para recorrer fechas · ctrl+s para copiar",re]})}),s[29]=re,s[30]=se):se=s[30],s[31]!==se||s[32]!==oe?(ie=n(L,{color:"claude",children:[oe,se]}),s[31]=se,s[32]=oe,s[33]=ie):ie=s[33],ie}function _temp(e){return"Overview"===e?"Models":"Overview"}function DateRangeSelector(e){const o=r(9),{dateRange:s,isLoading:i}=e;let l,a,c,u;return o[0]!==s?(l=H.map((e,o)=>n(y,{children:[o>0&&t(y,{dimColor:!0,children:" · "}),t(y,e===s?{bold:!0,color:"claude",children:E[e]}:{dimColor:!0,children:E[e]})]},e)),o[0]=s,o[1]=l):l=o[1],o[2]!==l?(a=t(T,{children:l}),o[2]=l,o[3]=a):a=o[3],o[4]!==i?(c=i&&t(P,{}),o[4]=i,o[5]=c):c=o[5],o[6]!==a||o[7]!==c?(u=n(T,{marginBottom:1,gap:1,children:[a,c]}),o[6]=a,o[7]=c,o[8]=u):u=o[8],u}function OverviewTab({stats:r,allTimeStats:s,dateRange:i,isLoading:l}){const{columns:a}=g(),c=Object.entries(r.modelUsage).sort(([,e],[,t])=>t.inputTokens+t.outputTokens-(e.inputTokens+e.outputTokens)),u=c[0],m=c.reduce((e,[,t])=>e+t.inputTokens+t.outputTokens,0),p=d(()=>generateFunFactoid(r,m),[r,m]),f="7d"===i?7:"30d"===i?30:r.totalDays;let k=null;if(e("SHOT_STATS")&&r.shotDistribution){const e=r.shotDistribution,t=Object.values(e).reduce((e,t)=>e+t,0);if(t>0){const n=Object.entries(e).reduce((e,[t,n])=>e+parseInt(t,10)*n,0),bucket=(t,n)=>Object.entries(e).filter(([e])=>{const o=parseInt(e,10);return o>=t&&(void 0===n||o<=n)}).reduce((e,[,t])=>e+t,0),pct=e=>Math.round(e/t*100),o=bucket(1,1),r=bucket(2,5),s=bucket(6,10),i=bucket(11);k={avgShots:(n/t).toFixed(1),buckets:[{label:"1-shot",count:o,pct:pct(o)},{label:"2–5 shot",count:r,pct:pct(r)},{label:"6–10 shot",count:s,pct:pct(s)},{label:"11+ shot",count:i,pct:pct(i)}]}}}return n(T,{flexDirection:"column",marginTop:1,children:[s.dailyActivity.length>0&&t(T,{flexDirection:"column",marginBottom:1,children:t(b,{children:M(s.dailyActivity,{terminalWidth:a})})}),t(DateRangeSelector,{dateRange:i,isLoading:l}),n(T,{flexDirection:"row",gap:4,marginBottom:1,children:[t(T,{flexDirection:"column",width:28,children:u&&n(y,{wrap:"truncate",children:["Favorite model:"," ",t(y,{color:"claude",bold:!0,children:j(u[0])})]})}),t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:["Total tokens:"," ",t(y,{color:"claude",children:D(m)})]})})]}),n(T,{flexDirection:"row",gap:4,children:[t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:["Sessions:"," ",t(y,{color:"claude",children:D(r.totalSessions)})]})}),t(T,{flexDirection:"column",width:28,children:r.longestSession&&n(y,{wrap:"truncate",children:["Longest session:"," ",t(y,{color:"claude",children:v(r.longestSession.duration)})]})})]}),n(T,{flexDirection:"row",gap:4,children:[t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:["Active days: ",t(y,{color:"claude",children:r.activeDays}),n(y,{color:"subtle",children:["/",f]})]})}),t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:["Longest streak:"," ",t(y,{color:"claude",bold:!0,children:r.streaks.longestStreak})," ",1===r.streaks.longestStreak?"day":"days"]})})]}),n(T,{flexDirection:"row",gap:4,children:[t(T,{flexDirection:"column",width:28,children:r.peakActivityDay&&n(y,{wrap:"truncate",children:["Most active day:"," ",t(y,{color:"claude",children:(w=r.peakActivityDay,new Date(w).toLocaleDateString("en-US",{month:"short",day:"numeric"}))})]})}),t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:["Current streak:"," ",t(y,{color:"claude",bold:!0,children:s.streaks.currentStreak})," ",1===s.streaks.currentStreak?"day":"days"]})})]}),!1,k&&n(o,{children:[t(T,{marginTop:1,children:t(y,{children:"Shot distribution"})}),n(T,{flexDirection:"row",gap:4,children:[t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:[k.buckets[0].label,":"," ",t(y,{color:"claude",children:k.buckets[0].count}),n(y,{color:"subtle",children:[" (",k.buckets[0].pct,"%)"]})]})}),t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:[k.buckets[1].label,":"," ",t(y,{color:"claude",children:k.buckets[1].count}),n(y,{color:"subtle",children:[" (",k.buckets[1].pct,"%)"]})]})})]}),n(T,{flexDirection:"row",gap:4,children:[t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:[k.buckets[2].label,":"," ",t(y,{color:"claude",children:k.buckets[2].count}),n(y,{color:"subtle",children:[" (",k.buckets[2].pct,"%)"]})]})}),t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:[k.buckets[3].label,":"," ",t(y,{color:"claude",children:k.buckets[3].count}),n(y,{color:"subtle",children:[" (",k.buckets[3].pct,"%)"]})]})})]}),t(T,{flexDirection:"row",gap:4,children:t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:["Avg/session:"," ",t(y,{color:"claude",children:k.avgShots})]})})})]}),p&&t(T,{marginTop:1,children:t(y,{color:"suggestion",children:p})})]});var w}const I=[{name:"The Little Prince",tokens:22e3},{name:"The Old Man and the Sea",tokens:35e3},{name:"A Christmas Carol",tokens:37e3},{name:"Animal Farm",tokens:39e3},{name:"Fahrenheit 451",tokens:6e4},{name:"The Great Gatsby",tokens:62e3},{name:"Slaughterhouse-Five",tokens:64e3},{name:"Brave New World",tokens:83e3},{name:"The Catcher in the Rye",tokens:95e3},{name:"Harry Potter and the Philosopher's Stone",tokens:103e3},{name:"The Hobbit",tokens:123e3},{name:"1984",tokens:123e3},{name:"To Kill a Mockingbird",tokens:13e4},{name:"Pride and Prejudice",tokens:156e3},{name:"Dune",tokens:244e3},{name:"Moby-Dick",tokens:268e3},{name:"Crime and Punishment",tokens:274e3},{name:"A Game of Thrones",tokens:381e3},{name:"Anna Karenina",tokens:468e3},{name:"Don Quixote",tokens:52e4},{name:"The Lord of the Rings",tokens:576e3},{name:"The Count of Monte Cristo",tokens:603e3},{name:"Les Misérables",tokens:689e3},{name:"War and Peace",tokens:73e4}],U=[{name:"a TED talk",minutes:18},{name:"an episode of The Office",minutes:22},{name:"listening to Abbey Road",minutes:47},{name:"a yoga class",minutes:60},{name:"a World Cup soccer match",minutes:90},{name:"a half marathon (average time)",minutes:120},{name:"the movie Inception",minutes:148},{name:"watching Titanic",minutes:195},{name:"a transatlantic flight",minutes:420},{name:"a full night of sleep",minutes:480}];function generateFunFactoid(e,t){const n=[];if(t>0){const e=I.filter(e=>t>=e.tokens);for(const o of e){const e=t/o.tokens;e>=2?n.push(`You've used ~${Math.floor(e)}x more tokens than ${o.name}`):n.push(`You've used the same number of tokens as ${o.name}`)}}if(e.longestSession){const t=e.longestSession.duration/6e4;for(const e of U){const o=t/e.minutes;o>=2&&n.push(`Your longest session is ~${Math.floor(o)}x longer than ${e.name}`)}}if(0===n.length)return"";return n[Math.floor(Math.random()*n.length)]}function ModelsTab(e){const o=r(15),{stats:s,dateRange:i,isLoading:a}=e,{headerFocused:c,focusHeader:u}=B(),[d,p]=m(0),{columns:f}=g(),k=Object.entries(s.modelUsage).sort(_temp7),x=!c;let S;if(o[0]!==x?(S={isActive:x},o[0]=x,o[1]=S):S=o[1],w((e,t)=>{t.downArrow&&d<k.length-4&&p(e=>Math.min(e+2,k.length-4)),t.upArrow&&(d>0?p(_temp8):u())},S),0===k.length){let e;return o[2]===Symbol.for("react.memo_cache_sentinel")?(e=t(T,{children:t(y,{color:"subtle",children:"No model usage data available"})}),o[2]=e):e=o[2],e}const v=k.reduce(_temp9,0),D=generateTokenChart(s.dailyModelTokens,k.map(_temp0),f),M=k.slice(d,d+4),j=Math.ceil(M.length/2),$=M.slice(0,j),A=M.slice(j),_=d>0,C=d<k.length-4,O=k.length>4;let L;o[3]!==i||o[4]!==a?(L=t(DateRangeSelector,{dateRange:i,isLoading:a}),o[3]=i,o[4]=a,o[5]=L):L=o[5];const F=T,R=A.map(e=>{const[n,o]=e;return t(ModelEntry,{model:n,usage:o,totalTokens:v},n)});let P,E;return o[6]!==F||o[7]!==R?(P=t(F,{flexDirection:"column",width:36,children:R}),o[6]=F,o[7]=R,o[8]=P):P=o[8],o[9]!==C||o[10]!==_||o[11]!==k||o[12]!==d||o[13]!==O?(E=O&&t(T,{marginTop:1,children:n(y,{color:"subtle",children:[_?l.arrowUp:" "," ",C?l.arrowDown:" "," ",d+1,"-",Math.min(d+4,k.length)," of"," ",k.length," models (↑↓ to scroll)"]})}),o[9]=C,o[10]=_,o[11]=k,o[12]=d,o[13]=O,o[14]=E):E=o[14],n(T,{flexDirection:"column",marginTop:1,children:[D&&n(T,{flexDirection:"column",marginBottom:1,children:[t(y,{bold:!0,children:"Tokens per Day"}),t(b,{children:D.chart}),t(y,{color:"subtle",children:D.xAxisLabels}),t(T,{children:D.legend.map(_temp1)})]}),L,n(T,{flexDirection:"row",gap:4,children:[t(T,{flexDirection:"column",width:36,children:$.map(e=>{const[n,o]=e;return t(ModelEntry,{model:n,usage:o,totalTokens:v},n)})}),P]}),E]})}function _temp1(e,o){return n(y,{children:[o>0?" · ":"",t(b,{children:e.coloredBullet})," ",e.model]},e.model)}function _temp0(e){const[t]=e;return t}function _temp9(e,t){const[,n]=t;return e+n.inputTokens+n.outputTokens}function _temp8(e){return Math.max(e-2,0)}function _temp7(e,t){const[,n]=e,[,o]=t;return o.inputTokens+o.outputTokens-(n.inputTokens+n.outputTokens)}function ModelEntry(e){const o=r(21),{model:s,usage:i,totalTokens:a}=e,c=(i.inputTokens+i.outputTokens)/a*100;let u;o[0]!==c?(u=c.toFixed(1),o[0]=c,o[1]=u):u=o[1];const d=u;let m,p,g,f,k,b,w,x;return o[2]!==s?(m=j(s),o[2]=s,o[3]=m):m=o[3],o[4]!==m?(p=t(y,{bold:!0,children:m}),o[4]=m,o[5]=p):p=o[5],o[6]!==d?(g=n(y,{color:"subtle",children:["(",d,"%)"]}),o[6]=d,o[7]=g):g=o[7],o[8]!==p||o[9]!==g?(f=n(y,{children:[l.bullet," ",p," ",g]}),o[8]=p,o[9]=g,o[10]=f):f=o[10],o[11]!==i.inputTokens?(k=D(i.inputTokens),o[11]=i.inputTokens,o[12]=k):k=o[12],o[13]!==i.outputTokens?(b=D(i.outputTokens),o[13]=i.outputTokens,o[14]=b):b=o[14],o[15]!==k||o[16]!==b?(w=n(y,{color:"subtle",children:[" ","In: ",k," · Out:"," ",b]}),o[15]=k,o[16]=b,o[17]=w):w=o[17],o[18]!==f||o[19]!==w?(x=n(T,{flexDirection:"column",children:[f,w]}),o[18]=f,o[19]=w,o[20]=x):x=o[20],x}function generateTokenChart(e,t,n){if(e.length<2||0===t.length)return null;const o=n-7,r=Math.min(52,Math.max(20,o));let i;if(e.length>=r)i=e.slice(-r);else{const t=Math.floor(r/e.length);i=[];for(const n of e)for(let e=0;e<t;e++)i.push(n)}const a=C(_(S().theme)),c=[O(a.suggestion),O(a.success),O(a.warning)],u=[],d=[],m=t.slice(0,3);for(let e=0;e<m.length;e++){const t=m[e],n=i.map(e=>e.tokensByModel[t]||0);if(n.some(e=>e>0)){u.push(n);const o=[a.suggestion,a.success,a.warning];d.push({model:j(t),coloredBullet:f(l.bullet,o[e%o.length])})}}if(0===u.length)return null;return{chart:s(u,{height:8,colors:c.slice(0,u.length),format:e=>{let t;return t=e>=1e6?(e/1e6).toFixed(1)+"M":e>=1e3?(e/1e3).toFixed(0)+"k":e.toFixed(0),t.padStart(6)}}),legend:d,xAxisLabels:function(e,t,n){if(0===e.length)return"";const o=Math.min(4,Math.max(2,Math.floor(e.length/8))),r=e.length-6,s=Math.floor(r/(o-1))||1,i=[];for(let t=0;t<o;t++){const n=Math.min(t*s,e.length-1),o=new Date(e[n].date).toLocaleDateString("en-US",{month:"short",day:"numeric"});i.push({pos:n,label:o})}let l=" ".repeat(n),a=0;for(const{pos:e,label:t}of i){const n=Math.max(1,e-a);l+=" ".repeat(n)+t,a=e+t.length}return l}(i,i.length,7)}}
@@ -1 +1 @@
1
- import{jsx as t,jsxs as o}from"react/jsx-runtime";import{stringWidth as n}from"../ink/stringWidth.js";import{Box as e,Text as r}from"../ink.js";import{truncateToWidth as i}from"../utils/format.js";const l="All",c=" (tab to cycle)",s="(tab to cycle)";export function TagTabs({tabs:a,selectedIndex:h,availableWidth:m,showAllProjects:d=!1}){const u=d?"Resume (All Projects)":"Resume",f=m-(u.length+1)-Math.max(18,14)-2,g=Math.max(0,Math.min(h,a.length-1)),x=Math.max(20,Math.floor(f/2)),p=a.map(t=>function(t,o){if(t===l)return 5;const e=n(t),r=o?Math.min(e,o-2-1):e;return Math.max(0,r)+2+1}(t,x));let b=0,j=a.length;if(p.reduce((t,o,n)=>t+o+(n<p.length-1?1:0),0)>f){const t=f-5;let o=p[g]??0;for(b=g,j=g+1;b>0||j<a.length;){const n=b>0,e=j<a.length;if(n){const n=(p[b-1]??0)+1;if(o+n<=t){b--,o+=n;continue}}if(e){const n=(p[j]??0)+1;if(o+n<=t){j++,o+=n;continue}}break}}const M=b,k=a.length-j,v=a.slice(b,j),A=v.map((t,o)=>b+o);return o(e,{flexDirection:"row",gap:1,children:[t(r,{color:"suggestion",children:u}),M>0&&o(r,{dimColor:!0,children:["← ",M]}),v.map((t,e)=>{const c=A[e]===g,s=t===l?t:`#${function(t,o){const e=o-2-1;return n(t)<=e?t:e<=1?t.charAt(0):i(t,e)}(t,x-2)}`;return o(r,{backgroundColor:c?"suggestion":void 0,color:c?"inverseText":void 0,bold:c,children:[" ",s," "]},t)}),k>0?o(r,{dimColor:!0,children:["→",k,c]}):t(r,{dimColor:!0,children:s})]})}
1
+ import{jsx as t,jsxs as n}from"react/jsx-runtime";import{stringWidth as r}from"../ink/stringWidth.js";import{Box as o,Text as e}from"../ink.js";import{truncateToWidth as i}from"../utils/format.js";const a="All",l=" (tab para alternar)",s="(tab para alternar)";export function TagTabs({tabs:c,selectedIndex:h,availableWidth:m,showAllProjects:d=!1}){const u=d?"Resume (All Projects)":"Resume",f=m-(u.length+1)-Math.max(23,19)-2,g=Math.max(0,Math.min(h,c.length-1)),p=Math.max(20,Math.floor(f/2)),x=c.map(t=>function(t,n){if(t===a)return 5;const o=r(t),e=n?Math.min(o,n-2-1):o;return Math.max(0,e)+2+1}(t,p));let b=0,j=c.length;if(x.reduce((t,n,r)=>t+n+(r<x.length-1?1:0),0)>f){const t=f-5;let n=x[g]??0;for(b=g,j=g+1;b>0||j<c.length;){const r=b>0,o=j<c.length;if(r){const r=(x[b-1]??0)+1;if(n+r<=t){b--,n+=r;continue}}if(o){const r=(x[j]??0)+1;if(n+r<=t){j++,n+=r;continue}}break}}const M=b,k=c.length-j,v=c.slice(b,j),A=v.map((t,n)=>b+n);return n(o,{flexDirection:"row",gap:1,children:[t(e,{color:"suggestion",children:u}),M>0&&n(e,{dimColor:!0,children:["← ",M]}),v.map((t,o)=>{const l=A[o]===g,s=t===a?t:`#${function(t,n){const o=n-2-1;return r(t)<=o?t:o<=1?t.charAt(0):i(t,o)}(t,p-2)}`;return n(e,{backgroundColor:l?"suggestion":void 0,color:l?"inverseText":void 0,bold:l,children:[" ",s," "]},t)}),k>0?n(e,{dimColor:!0,children:["→",k,l]}):t(e,{dimColor:!0,children:s})]})}
@@ -1 +1 @@
1
- import{jsx as e,jsxs as o}from"react/jsx-runtime";import{c as t}from"react/compiler-runtime";import{useEffect as n,useState as r}from"react";import{checkIsGitClean as i,checkNeedsClaudeAiLogin as s}from"../utils/background/remote/preconditions.js";import{gracefulShutdownSync as l}from"../utils/gracefulShutdown.js";import{Box as a,Text as c}from"../ink.js";import{ConsoleOAuthFlow as m}from"./ConsoleOAuthFlow.js";import{Select as d}from"./CustomSelect/index.js";import{Dialog as u}from"./design-system/Dialog.js";import{TeleportStash as f}from"./TeleportStash.js";const p=new Set;export function TeleportError(i){const s=t(18),{onComplete:l,errorsToIgnore:h}=i,g=void 0===h?p:h,[C,S]=r(null),[x,b]=r(!1);let j;s[0]!==g||s[1]!==l?(j=async()=>{const e=await getTeleportErrors(),o=new Set(Array.from(e).filter(e=>!g.has(e)));0!==o.size?o.has("needsLogin")?S("needsLogin"):o.has("needsGitStash")&&S("needsGitStash"):l()},s[0]=g,s[1]=l,s[2]=j):j=s[2];const w=j;let _,y;s[3]!==w?(_=()=>{w()},y=[w],s[3]=w,s[4]=_,s[5]=y):(_=s[4],y=s[5]),n(_,y);const L=_temp;let T;s[6]!==w?(T=()=>{b(!1),w()},s[6]=w,s[7]=T):T=s[7];const E=T;let G;s[8]===Symbol.for("react.memo_cache_sentinel")?(G=()=>{b(!0)},s[8]=G):G=s[8];const v=G;let A;s[9]===Symbol.for("react.memo_cache_sentinel")?(A=e=>{"login"===e?v():L()},s[9]=A):A=s[9];const D=A;let k;s[10]!==w?(k=()=>{w()},s[10]=w,s[11]=k):k=s[11];const M=k;if(!C)return null;switch(C){case"needsGitStash":{let o;return s[12]!==M?(o=e(f,{onStashAndContinue:M,onCancel:L}),s[12]=M,s[13]=o):o=s[13],o}case"needsLogin":{if(x){let o;return s[14]!==E?(o=e(m,{onDone:E,mode:"login",forceLoginMethod:"claudeai"}),s[14]=E,s[15]=o):o=s[15],o}let t,n;return s[16]===Symbol.for("react.memo_cache_sentinel")?(t=o(a,{flexDirection:"column",children:[e(c,{dimColor:!0,children:"Teleport requires a Claude.ai account."}),e(c,{dimColor:!0,children:"Your Claude Pro/Max subscription will be used by Context Code."})]}),s[16]=t):t=s[16],s[17]===Symbol.for("react.memo_cache_sentinel")?(n=o(u,{title:"Log in to Claude",onCancel:L,children:[t,e(d,{options:[{label:"Login with Claude account",value:"login"},{label:"Exit",value:"exit"}],onChange:D})]}),s[17]=n):n=s[17],n}}}function _temp(){l(0)}export async function getTeleportErrors(){const e=new Set,[o,t]=await Promise.all([s(),i()]);return o&&e.add("needsLogin"),t||e.add("needsGitStash"),e}
1
+ import{jsx as e,jsxs as o}from"react/jsx-runtime";import{c as t}from"react/compiler-runtime";import{useEffect as n,useState as r}from"react";import{checkIsGitClean as i,checkNeedsClaudeAiLogin as s}from"../utils/background/remote/preconditions.js";import{gracefulShutdownSync as l}from"../utils/gracefulShutdown.js";import{Box as a,Text as c}from"../ink.js";import{ConsoleOAuthFlow as m}from"./ConsoleOAuthFlow.js";import{Select as d}from"./CustomSelect/index.js";import{Dialog as u}from"./design-system/Dialog.js";import{TeleportStash as p}from"./TeleportStash.js";const f=new Set;export function TeleportError(i){const s=t(18),{onComplete:l,errorsToIgnore:h}=i,g=void 0===h?f:h,[S,C]=r(null),[x,j]=r(!1);let _;s[0]!==g||s[1]!==l?(_=async()=>{const e=await getTeleportErrors(),o=new Set(Array.from(e).filter(e=>!g.has(e)));0!==o.size?o.has("needsLogin")?C("needsLogin"):o.has("needsGitStash")&&C("needsGitStash"):l()},s[0]=g,s[1]=l,s[2]=_):_=s[2];const w=_;let y,b;s[3]!==w?(y=()=>{w()},b=[w],s[3]=w,s[4]=y,s[5]=b):(y=s[4],b=s[5]),n(y,b);const T=_temp;let L;s[6]!==w?(L=()=>{j(!1),w()},s[6]=w,s[7]=L):L=s[7];const G=L;let v;s[8]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{j(!0)},s[8]=v):v=s[8];const A=v;let D;s[9]===Symbol.for("react.memo_cache_sentinel")?(D=e=>{"login"===e?A():T()},s[9]=D):D=s[9];const E=D;let I;s[10]!==w?(I=()=>{w()},s[10]=w,s[11]=I):I=s[11];const k=I;if(!S)return null;switch(S){case"needsGitStash":{let o;return s[12]!==k?(o=e(p,{onStashAndContinue:k,onCancel:T}),s[12]=k,s[13]=o):o=s[13],o}case"needsLogin":{if(x){let o;return s[14]!==G?(o=e(m,{onDone:G,mode:"login",forceLoginMethod:"claudeai"}),s[14]=G,s[15]=o):o=s[15],o}let t,n;return s[16]===Symbol.for("react.memo_cache_sentinel")?(t=o(a,{flexDirection:"column",children:[e(c,{dimColor:!0,children:"Teleport requiere una cuenta de Context."}),e(c,{dimColor:!0,children:"Tu suscripción Pro/Max será usada por Context Code."})]}),s[16]=t):t=s[16],s[17]===Symbol.for("react.memo_cache_sentinel")?(n=o(u,{title:"Iniciar sesión en Context",onCancel:T,children:[t,e(d,{options:[{label:"Iniciar sesión con cuenta Context",value:"login"},{label:"Salir",value:"exit"}],onChange:E})]}),s[17]=n):n=s[17],n}}}function _temp(){l(0)}export async function getTeleportErrors(){const e=new Set,[o,t]=await Promise.all([s(),i()]);return o&&e.add("needsLogin"),t||e.add("needsGitStash"),e}
@@ -1 +1 @@
1
- import{jsx as e,jsxs as r}from"react/jsx-runtime";import{c as o}from"react/compiler-runtime";import{useEffect as i}from"react";import{logEvent as s}from"../services/analytics/index.js";import{useTeleportResume as t}from"../hooks/useTeleportResume.js";import{Box as n,Text as l}from"../ink.js";import{useKeybinding as c}from"../keybindings/useKeybinding.js";import{ResumeTask as m}from"./ResumeTask.js";import{Spinner as a}from"./Spinner.js";export function TeleportResumeWrapper(d){const p=o(25),{onComplete:u,onCancel:f,onError:g,isEmbedded:h,source:b}=d,_=void 0!==h&&h,{resumeSession:j,isResuming:x,error:y,selectedSession:S}=t(b);let C,R,k;p[0]!==b?(C=()=>{s("tengu_teleport_started",{source:b})},R=[b],p[0]=b,p[1]=C,p[2]=R):(C=p[1],R=p[2]),i(C,R),p[3]!==y||p[4]!==u||p[5]!==g||p[6]!==j?(k=async e=>{const r=await j(e);r?u(r):y&&g&&g(y.message,y.formattedMessage)},p[3]=y,p[4]=u,p[5]=g,p[6]=j,p[7]=k):k=p[7];const E=k;let T;p[8]!==f?(T=()=>{s("tengu_teleport_cancelled",{}),f()},p[8]=f,p[9]=T):T=p[9];const v=T,D=!!y&&!g;let w,A;if(p[10]!==D?(w={context:"Global",isActive:D},p[10]=D,p[11]=w):w=p[11],c("app:interrupt",v,w),x&&S){let o,i;return p[12]===Symbol.for("react.memo_cache_sentinel")?(o=r(n,{flexDirection:"row",children:[e(a,{}),e(l,{bold:!0,children:"Resuming session…"})]}),p[12]=o):o=p[12],p[13]!==S.title?(i=r(n,{flexDirection:"column",padding:1,children:[o,r(l,{dimColor:!0,children:['Loading "',S.title,'"…']})]}),p[13]=S.title,p[14]=i):i=p[14],i}if(y&&!g){let o,i,s,t;return p[15]===Symbol.for("react.memo_cache_sentinel")?(o=e(l,{bold:!0,color:"error",children:"Failed to resume session"}),p[15]=o):o=p[15],p[16]!==y.message?(i=e(l,{dimColor:!0,children:y.message}),p[16]=y.message,p[17]=i):i=p[17],p[18]===Symbol.for("react.memo_cache_sentinel")?(s=e(n,{marginTop:1,children:r(l,{dimColor:!0,children:["Press ",e(l,{bold:!0,children:"Esc"})," to cancel"]})}),p[18]=s):s=p[18],p[19]!==i?(t=r(n,{flexDirection:"column",padding:1,children:[o,i,s]}),p[19]=i,p[20]=t):t=p[20],t}return p[21]!==v||p[22]!==E||p[23]!==_?(A=e(m,{onSelect:E,onCancel:v,isEmbedded:_}),p[21]=v,p[22]=E,p[23]=_,p[24]=A):A=p[24],A}
1
+ import{jsx as e,jsxs as r}from"react/jsx-runtime";import{c as o}from"react/compiler-runtime";import{useEffect as i}from"react";import{logEvent as n}from"../services/analytics/index.js";import{useTeleportResume as t}from"../hooks/useTeleportResume.js";import{Box as s,Text as l}from"../ink.js";import{useKeybinding as c}from"../keybindings/useKeybinding.js";import{ResumeTask as m}from"./ResumeTask.js";import{Spinner as a}from"./Spinner.js";export function TeleportResumeWrapper(d){const p=o(25),{onComplete:u,onCancel:f,onError:g,isEmbedded:h,source:b}=d,_=void 0!==h&&h,{resumeSession:j,isResuming:x,error:y,selectedSession:S}=t(b);let C,E,R;p[0]!==b?(C=()=>{n("tengu_teleport_started",{source:b})},E=[b],p[0]=b,p[1]=C,p[2]=E):(C=p[1],E=p[2]),i(C,E),p[3]!==y||p[4]!==u||p[5]!==g||p[6]!==j?(R=async e=>{const r=await j(e);r?u(r):y&&g&&g(y.message,y.formattedMessage)},p[3]=y,p[4]=u,p[5]=g,p[6]=j,p[7]=R):R=p[7];const k=R;let T;p[8]!==f?(T=()=>{n("tengu_teleport_cancelled",{}),f()},p[8]=f,p[9]=T):T=p[9];const v=T,D=!!y&&!g;let w,A;if(p[10]!==D?(w={context:"Global",isActive:D},p[10]=D,p[11]=w):w=p[11],c("app:interrupt",v,w),x&&S){let o,i;return p[12]===Symbol.for("react.memo_cache_sentinel")?(o=r(s,{flexDirection:"row",children:[e(a,{}),e(l,{bold:!0,children:"Resuming session…"})]}),p[12]=o):o=p[12],p[13]!==S.title?(i=r(s,{flexDirection:"column",padding:1,children:[o,r(l,{dimColor:!0,children:['Loading "',S.title,'"…']})]}),p[13]=S.title,p[14]=i):i=p[14],i}if(y&&!g){let o,i,n,t;return p[15]===Symbol.for("react.memo_cache_sentinel")?(o=e(l,{bold:!0,color:"error",children:"Error al reanudar la sesión"}),p[15]=o):o=p[15],p[16]!==y.message?(i=e(l,{dimColor:!0,children:y.message}),p[16]=y.message,p[17]=i):i=p[17],p[18]===Symbol.for("react.memo_cache_sentinel")?(n=e(s,{marginTop:1,children:r(l,{dimColor:!0,children:["Press ",e(l,{bold:!0,children:"Esc"})," to cancel"]})}),p[18]=n):n=p[18],p[19]!==i?(t=r(s,{flexDirection:"column",padding:1,children:[o,i,n]}),p[19]=i,p[20]=t):t=p[20],t}return p[21]!==v||p[22]!==k||p[23]!==_?(A=e(m,{onSelect:k,onCancel:v,isEmbedded:_}),p[21]=v,p[22]=k,p[23]=_,p[24]=A):A=p[24],A}