pisper 0.6.32 → 0.6.33
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.
- package/package.json +5 -5
- package/web/.vite/manifest.json +640 -640
- package/web/assets/{AppDialog-CA7tBvM8.js → AppDialog-bqakHiqz.js} +1 -1
- package/web/assets/{AppOverlays-yAnO5otc.js → AppOverlays-CgpAvY9q.js} +1 -1
- package/web/assets/{AssetsPage-NJ7uc7WV.js → AssetsPage-BIYsLgYo.js} +1 -1
- package/web/assets/{BoardPage-DzHXQHbY.js → BoardPage-C3a-6d1u.js} +3 -3
- package/web/assets/{ChannelsPage-DPVT00J9.js → ChannelsPage-6Opibsv4.js} +1 -1
- package/web/assets/{ChatAppearancePage-RygKPTc1.js → ChatAppearancePage-D5gk_aXZ.js} +1 -1
- package/web/assets/{ChatHistoryPage-CYU3FOWt.js → ChatHistoryPage-D576j6vI.js} +1 -1
- package/web/assets/{ChatPage-B9kyMRtf.js → ChatPage-BK61m32j.js} +3 -3
- package/web/assets/{ConfigPage-YOI6Jn64.js → ConfigPage-BmnOjD9j.js} +2 -2
- package/web/assets/{DesktopWindowControls-DaK-mWjx.js → DesktopWindowControls-DlV6D3IF.js} +1 -1
- package/web/assets/{FeaturePage-DI7N2J_K.js → FeaturePage-qCmYebNB.js} +1 -1
- package/web/assets/{FileAttachmentPreview-CUdxe5_7.js → FileAttachmentPreview-DkYkLnxt.js} +1 -1
- package/web/assets/{FloatingWidgets-CWAsDelc.js → FloatingWidgets-1EwlF6Oj.js} +1 -1
- package/web/assets/{FocusRuntimeControls-6sWPafoU.js → FocusRuntimeControls-DiS4SP0x.js} +1 -1
- package/web/assets/{GitDiffViewer-Djkbc29o.js → GitDiffViewer-BYB7_K9o.js} +1 -1
- package/web/assets/{ManageProjectsDialog-CReohSBv.js → ManageProjectsDialog-CDY8CAam.js} +1 -1
- package/web/assets/{MarkdownMessage-jypOknWO.js → MarkdownMessage-BH5Nh-UO.js} +1 -1
- package/web/assets/{McpPage-DZuv-kd4.js → McpPage-DFwh1tmO.js} +1 -1
- package/web/assets/{MemoryEvolution-ULgArXX6.js → MemoryEvolution-BG4nAEH8.js} +1 -1
- package/web/assets/{MemoryPage-CXNLDgIX.js → MemoryPage-CSZweuq_.js} +2 -2
- package/web/assets/{MobileNavigation-CEUnhv7K.js → MobileNavigation-DdvgJ1_H.js} +1 -1
- package/web/assets/{MorePage-DC_HNY-i.js → MorePage-CM0nAh27.js} +1 -1
- package/web/assets/{NewFolderDialog-rxwZ78bu.js → NewFolderDialog-BgVVLoLF.js} +1 -1
- package/web/assets/{PageHeader-DQkMisCZ.js → PageHeader-V6fYs6FB.js} +1 -1
- package/web/assets/{PhoneDrawer-D3eRtYUJ.js → PhoneDrawer-_T7G0UlW.js} +1 -1
- package/web/assets/{PhoneMenuButton-Qt9aL2yf.js → PhoneMenuButton-DlK5D8AZ.js} +1 -1
- package/web/assets/{PhoneTopBar-UNRjPZJo.js → PhoneTopBar-CI5JxBFX.js} +1 -1
- package/web/assets/{PluginsPage-B19V8jKI.js → PluginsPage-DHJHTTXh.js} +1 -1
- package/web/assets/{SafeModePrompt-DDwctKZu.js → SafeModePrompt-B4hmTRuN.js} +1 -1
- package/web/assets/{SchedulesPage-C-MlYxbU.js → SchedulesPage-6Qe506NG.js} +1 -1
- package/web/assets/{SessionBrowserPane-C7pYbebX.js → SessionBrowserPane-DBc3TNje.js} +2 -2
- package/web/assets/{SessionContextPanel-B2sS7myK.js → SessionContextPanel-A-apbPUv.js} +2 -2
- package/web/assets/{SessionHome-CS5HPhh0.js → SessionHome-D-iS34Q7.js} +1 -1
- package/web/assets/{SessionInspector-BHdqiu1D.js → SessionInspector-B41l7gKR.js} +1 -1
- package/web/assets/{SessionShell-CI6d2UxF.js → SessionShell-Byw5069L.js} +1 -1
- package/web/assets/{SettingsSidebar-SMxWLbhN.js → SettingsSidebar-CMu7qKbO.js} +1 -1
- package/web/assets/{ShortcutHelpDialog-DDyxtBqb.js → ShortcutHelpDialog-CaaKIjWq.js} +1 -1
- package/web/assets/{ShortcutKeys-CuiTSvO5.js → ShortcutKeys-DEP10d_k.js} +1 -1
- package/web/assets/{SidebarUpdateStatus-CgDyoVVT.js → SidebarUpdateStatus-4sXZK0UG.js} +1 -1
- package/web/assets/{SkillsPage-C217PvFK.js → SkillsPage-r_UPbRKb.js} +1 -1
- package/web/assets/{TaskProcessesPane-CRRUKQPY.js → TaskProcessesPane-VO8SPtCI.js} +1 -1
- package/web/assets/{TaskTerminalView-DZL83yst.js → TaskTerminalView-B5GUaW-L.js} +1 -1
- package/web/assets/{TerminalPanel-CeGX1ISs.js → TerminalPanel-toRRYBjv.js} +1 -1
- package/web/assets/{WebDesktopPet-mgzM1lUl.js → WebDesktopPet-CM4U0kvi.js} +1 -1
- package/web/assets/{WorkflowsPage-CsH9o0Vt.js → WorkflowsPage-BcXqmyBY.js} +1 -1
- package/web/assets/{WorkspacePicker-Bo197KnL.js → WorkspacePicker-BRa_IVqp.js} +1 -1
- package/web/assets/{api-Bn6Yqhfj.js → api-CCLf8CGI.js} +1 -1
- package/web/assets/{app-update-C17JitpX.js → app-update-DcdhTBg3.js} +1 -1
- package/web/assets/{approval-confirm-CLyo75Wg.js → approval-confirm-Db5cFtCd.js} +1 -1
- package/web/assets/{board-projects-B7ISKK5M.js → board-projects-C3_RLAYt.js} +1 -1
- package/web/assets/{bots-store-BM-RDFHS.js → bots-store-BYTwHk9o.js} +1 -1
- package/web/assets/{chat-api-BL_tZCbY.js → chat-api-PdHMtAmc.js} +1 -1
- package/web/assets/{client-store-D3sThJb-.js → client-store-Df-MtlGW.js} +1 -1
- package/web/assets/{config-search-Q-gLiXu_.js → config-search-Bk1H58rt.js} +1 -1
- package/web/assets/{desktop-hosts-B3CWL4di.js → desktop-hosts-kpDUJPHM.js} +1 -1
- package/web/assets/{dialog-DzLlhTSc.js → dialog-CEcIiRdx.js} +1 -1
- package/web/assets/{event-stream-DHX619rI.js → event-stream-B3CGgFfm.js} +1 -1
- package/web/assets/{events-BOOZIPa5.js → events-fUNyYQhT.js} +1 -1
- package/web/assets/{focus-session-composer-bits-vPmpISU7.js → focus-session-composer-bits-DWovCteo.js} +1 -1
- package/web/assets/{folder-paths-CfkxmkpU.js → folder-paths-e_B8xA6T.js} +1 -1
- package/web/assets/{hosts-DI7_AOnB.js → hosts-DlCCpVaG.js} +1 -1
- package/web/assets/{http-BLTlr2yB.js → http-Ck9ziPLg.js} +1 -1
- package/web/assets/{http-response-BVH7o4IQ.js → http-response-BMpatf4O.js} +1 -1
- package/web/assets/{i18n-D5Pj8hy6.js → i18n-D1oE4DVX.js} +1 -1
- package/web/assets/{index-DguGXGe9.js → index-Cd49jlmz.js} +2 -2
- package/web/assets/{machine-messages-BjYmTDz4.js → machine-messages-D5urBDZn.js} +1 -1
- package/web/assets/{machines-api-AYwQ9wWh.js → machines-api-Be-AjTEL.js} +1 -1
- package/web/assets/{memory-api-260Oa_xZ.js → memory-api-D9qnDSAr.js} +1 -1
- package/web/assets/{mount-app-CoTBrIGD.js → mount-app-D278htsi.js} +3 -3
- package/web/assets/{permission-rules-api-D2u3PIpr.js → permission-rules-api-i-sBmQT3.js} +1 -1
- package/web/assets/{pick-system-directory-BPDhvlE7.js → pick-system-directory-Cnb1L8Kd.js} +1 -1
- package/web/assets/{placements-deNW2Eg-.js → placements-BPrt5jd4.js} +2 -2
- package/web/assets/{popover-B-a7ZBQS.js → popover-5MqQ5QIH.js} +1 -1
- package/web/assets/{public-Dbs615LR.js → public-B7A7Bf7w.js} +1 -1
- package/web/assets/{public-BV32k5q1.js → public-BhSl1_DQ.js} +2 -2
- package/web/assets/{public-COJrQD9j.js → public-DAqU5ju6.js} +2 -2
- package/web/assets/{public-CoescP9_.js → public-DHE_Bffl.js} +1 -1
- package/web/assets/{public-components-jrX-6RqC.js → public-components-DS306Oz2.js} +1 -1
- package/web/assets/public-diff-e-dAYuJF.js +1 -0
- package/web/assets/public-events-DK8fPqRB.js +1 -0
- package/web/assets/{public-flags-B-hhqV7C.js → public-flags-_XZrt2pU.js} +1 -1
- package/web/assets/{public-folder-dialog-ywXpPZXJ.js → public-folder-dialog-DgKjmujY.js} +1 -1
- package/web/assets/{public-greeting-VN-jBq7k.js → public-greeting-DJIT1WWT.js} +1 -1
- package/web/assets/{public-session-CzxHzz2C.js → public-session-CuS3mRPA.js} +1 -1
- package/web/assets/{public-sidebar-BA8SJ3r0.js → public-sidebar-Cxg21QnN.js} +1 -1
- package/web/assets/{runtime-capabilities-store-CXahF-U2.js → runtime-capabilities-store-DcLHj_-T.js} +1 -1
- package/web/assets/{safe-mode-instance-Dex9ZvJH.js → safe-mode-instance-Dpp0f3FD.js} +1 -1
- package/web/assets/safe-mode-sentinel-CpYA8gLC.js +1 -0
- package/web/assets/{session-change-summary-api-CJ2yVJEm.js → session-change-summary-api-BzjbV-XG.js} +1 -1
- package/web/assets/{session-home-BTPHTXVm.js → session-home-BE2Q0var.js} +1 -1
- package/web/assets/{session-inspector-store-DFANj1eG.js → session-inspector-store-BxozyuFV.js} +1 -1
- package/web/assets/{session-organization-api-5GadAj0U.js → session-organization-api-CLAh265X.js} +1 -1
- package/web/assets/{session-scope-C9THRhK5.js → session-scope-BM93WXwD.js} +1 -1
- package/web/assets/{session-tree-actions-C7sDBs9_.js → session-tree-actions-BlqzMI3H.js} +1 -1
- package/web/assets/{session-tree-summary-D_mv7Xsy.js → session-tree-summary-B8SEWLOy.js} +1 -1
- package/web/assets/{shortcuts-CQYp4qaG.js → shortcuts-SQuwtLn8.js} +1 -1
- package/web/assets/{side-chat-context-BoevraRd.js → side-chat-context-Dw_WsQW3.js} +4 -4
- package/web/assets/{sidebar-Ddf5aEv6.js → sidebar-B6oY6pcm.js} +1 -1
- package/web/assets/{sidebar-store-DlicJ7L2.js → sidebar-store-DWzo4gcp.js} +1 -1
- package/web/assets/{speech-session--qKchPMR.js → speech-session-Dx6waD1F.js} +1 -1
- package/web/assets/{startup-queries-Cf6RSLkK.js → startup-queries-DG8R4Ryc.js} +1 -1
- package/web/assets/{use-i18n-vKUIcJX7.js → use-i18n-CrMP8KP1.js} +1 -1
- package/web/assets/{use-open-bot-CBgzzpYP.js → use-open-bot-DU7b6x-6.js} +1 -1
- package/web/assets/{use-studio-actions-C0IOFiXt.js → use-studio-actions-Cb0xo6pc.js} +1 -1
- package/web/assets/{useCatalogProjects-HPDUmiqp.js → useCatalogProjects-BJCTVrvM.js} +1 -1
- package/web/assets/{useMachines-CPMVc3JJ.js → useMachines-BnEhFLR-.js} +1 -1
- package/web/assets/{useNewProjectPicker-DvaRu71A.js → useNewProjectPicker-CsJnnQt_.js} +2 -2
- package/web/assets/{useNow-Df6N6r2Y.js → useNow-D9FGGV1H.js} +1 -1
- package/web/assets/{usePhoneShell-K9ZGSs1n.js → usePhoneShell-Bjigstxq.js} +1 -1
- package/web/assets/{useSessionListQuery-w1eeoWqD.js → useSessionListQuery-Bfjp1ecc.js} +1 -1
- package/web/assets/{useSessionRowActions-DQcnq6I1.js → useSessionRowActions-84-_ahHt.js} +1 -1
- package/web/assets/{useSidebarModel-De1pMvik.js → useSidebarModel-0OeDSimB.js} +1 -1
- package/web/assets/{workspace-folders-B5Z-ckI5.js → workspace-folders-1RLblom2.js} +1 -1
- package/web/assets/{workspace-order-store-hJOk5NHh.js → workspace-order-store-Du6GVhMP.js} +1 -1
- package/web/index.html +1 -1
- package/web/assets/public-diff-D6Sa7fGe.js +0 -1
- package/web/assets/public-events-D8WNal9Q.js +0 -1
- package/web/assets/safe-mode-sentinel-DRBisTV9.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SessionContextPanel-
|
|
2
|
-
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{h as t}from"./vendor-router-CSN_DGvx.js";import{t as n}from"./index-DguGXGe9.js";import{i as r,n as i,r as a}from"./vendor-react-DwNgTV1j.js";import{t as o}from"./use-i18n-vKUIcJX7.js";import{a as s,i as c,o as l}from"./vendor-state-GkUciC5H.js";import{t as u}from"./storage-DtvZ_lEu.js";import{u as d}from"./query-DFQayLF5.js";import{r as f,t as p}from"./useQuery-DfOU-27z.js";import{t as m}from"./startup-queries-Cf6RSLkK.js";import{n as h,r as g,t as _}from"./abort-signal-f4JsiYKX.js";import{i as v,t as y}from"./http-response-BVH7o4IQ.js";import{i as b,n as x}from"./http-BLTlr2yB.js";import{n as S,t as C}from"./api-Bn6Yqhfj.js";import{i as w}from"./runtime-capabilities-CPDBo3tu.js";import{t as T}from"./runtime-capabilities-store-CXahF-U2.js";import{n as E}from"./use-mobile-C2tPBAza.js";import{n as D,t as O}from"./client-store-D3sThJb-.js";import{t as k}from"./createLucideIcon-Cd-3GVxJ.js";import{r as A}from"./permission-rules-api-D2u3PIpr.js";import{t as j}from"./archive-ojKJT7Fp.js";import{t as M}from"./book-open-BuHHD9os.js";import{t as N}from"./bot-B3TaBp_T.js";import{t as P}from"./braces-DQcXLGFF.js";import{t as F}from"./check-2vYc6QaP.js";import{t as I}from"./chevron-down-CxtxIjiP.js";import{t as L}from"./chevron-left-BAtyp3_6.js";import{t as R}from"./chevron-right-C3t2Rckj.js";import{t as z}from"./circle-check-iEdCm3Pw.js";import{n as B,t as V}from"./image-plus-D7bzZog0.js";import{a as ee,i as te,n as ne,o as re,r as H,s as ie,t as ae}from"./focus-session-composer-bits-vPmpISU7.js";import{t as U}from"./corner-down-right--hxi-Ihy.js";import{t as W}from"./download-BCfIiuaL.js";import{o as oe}from"./GitDiffViewer-Djkbc29o.js";import{a as se,c as ce,d as G,f as le,g as K,h as ue,i as de,l as fe,m as pe,n as me,o as he,p as q,r as ge,s as _e,t as ve,u as ye}from"./FocusRuntimeControls-6sWPafoU.js";import{t as be}from"./file-Bllajneu.js";import{C as xe,D as Se,E as Ce,O as we,S as Te,T as Ee,_ as De,a as Oe,b as ke,c as Ae,d as je,f as Me,g as Ne,h as Pe,i as Fe,k as Ie,l as Le,m as Re,n as ze,o as Be,p as Ve,s as He,t as Ue,u as We,v as Ge,w as Ke,x as qe,y as Je}from"./side-chat-context-BoevraRd.js";import{t as Ye}from"./WorkspacePicker-Bo197KnL.js";import{t as Xe}from"./folder-open-FIShC5Qk.js";import{t as Ze}from"./git-branch-N7LGjtzt.js";import{n as Qe}from"./undo-2-C-xQ0UVT.js";import{t as $e}from"./link-2-mgasYn21.js";import{t as et}from"./loader-circle-BOwQzHB-.js";import{t as tt}from"./message-square-SKjZyY3v.js";import{t as nt}from"./panel-right-BSUtqUd8.js";import{t as rt}from"./paperclip-BCXrwYpb.js";import{t as it}from"./pencil-U08v_vV9.js";import{t as at}from"./play-DNDjDNGn.js";import{t as ot}from"./plus-fQbSqB1n.js";import{t as st}from"./refresh-cw-TbWxTY4K.js";import{t as ct}from"./search-D0mqDaf_.js";import{t as lt}from"./settings-QX0oWnVK.js";import{t as ut}from"./shield-alert-oZqX6MNu.js";import{t as J}from"./square-pen-hYbjKh6A.js";import{t as dt}from"./square-bHHVTT3G.js";import{t as ft}from"./tag-CqkeJlBf.js";import{t as pt}from"./trash-2-CNrPOoPR.js";import{t as mt}from"./triangle-alert-CE1q54ci.js";import{t as ht}from"./users-CCtFZzwl.js";import{t as gt}from"./workflow-Bg94dy8I.js";import{t as _t}from"./wrench-6pg6_bqI.js";import{t as vt}from"./x-07u4-129.js";import{t as yt}from"./brand-DIEc3fK8.js";import{t as bt}from"./checkbox-BrEHgFV0.js";import{c as xt,i as St,l as Ct,p as wt,r as Tt,t as Et}from"./dropdown-menu-Ds0gD8S8.js";import{t as Dt}from"./progress-5odAz3B9.js";import{t as Ot}from"./switch-D_G8wFhs.js";import{i as kt,r as At,t as jt}from"./tabs-DsgBuvJv.js";import{n as Mt,t as Nt}from"./segmented-control-xkrEOP_d.js";import{i as Pt,n as Ft,t as It}from"./tooltip-D4MFbqcG.js";import{t as Lt}from"./utils-C8uzG5AZ.js";import{n as Rt,t as Y}from"./button-CCcCN8tE.js";import{n as zt,t as Bt}from"./kbd-CAufZTkl.js";import{C as Vt,S as Ht,b as Ut,c as Wt,f as Gt,i as Kt,o as qt,p as Jt,r as Yt,s as Xt,u as Zt,w as Qt,x as $t,y as en}from"./events-BOOZIPa5.js";import{a as tn,c as nn,i as rn,n as an,r as on,s as sn,t as cn}from"./shortcuts-CQYp4qaG.js";import{n as ln,o as un,r as dn,t as fn}from"./sheet-BTaIEX4w.js";import{t as X}from"./chat-api-BL_tZCbY.js";import{n as pn}from"./session-organization-api-5GadAj0U.js";import{r as mn}from"./session-workspaces-Brm-8lHh.js";import{a as hn,n as gn,t as _n}from"./session-questions-Cf-1g85h.js";import{n as vn,o as yn,r as bn,t as xn}from"./format-DMJQzoZ7.js";import{t as Sn}from"./StatusGlyph-1KgitlUg.js";import{a as Cn,c as wn,d as Tn,m as En,o as Dn,p as On,u as kn}from"./run-activity-CwfO0cui.js";import{a as An,i as jn,l as Mn,s as Nn,t as Pn}from"./dialog-DzLlhTSc.js";import{t as Fn}from"./input-CPw-zkYh.js";import{i as In,n as Ln,t as Rn}from"./input-group-h8z63MzW.js";import{t as zn}from"./model-display-kDwvtxrW.js";import{t as Bn}from"./session-change-summary-api-CJ2yVJEm.js";import{t as Vn}from"./pick-system-directory-BPDhvlE7.js";import{n as Hn,r as Un,t as Wn}from"./PageState-Cz6vFMXv.js";import{t as Gn}from"./back-navigation-CK7X_5Bc.js";import{t as Kn}from"./MarkdownMessage-jypOknWO.js";import{t as qn}from"./esm-DCV8yILT.js";import{t as Jn}from"./motion-DTR4ZVle.js";import{t as Yn}from"./shortcut-aria-jHRmld9z.js";import{t as Xn}from"./app-primitives-Drz_SjnR.js";import{i as Zn,n as Qn,o as $n,r as er,s as tr,t as nr}from"./session-list-BRMu9JWa.js";import{a as rr,c as ir,l as ar,n as or,r as sr,s as cr,u as lr}from"./session-web-preview-guvsmkWE.js";import"./public-CoescP9_.js";import{n as ur,r as dr}from"./terminal-context-aIsIJPn8.js";import{n as fr,r as pr,t as mr}from"./session-inspector-store-DFANj1eG.js";import{a as hr,i as gr}from"./tool-labels-D-3gybP7.js";import{t as _r}from"./BrandLogo-k3CvJjd4.js";import{i as vr,n as yr,o as Z,s as br,t as xr}from"./session-tree-summary-D_mv7Xsy.js";import{fileRewindConfirmOptions as Sr,fileRewindNotice as Cr,notifyTreeNavigation as wr}from"./session-tree-actions-C7sDBs9_.js";import{a as Tr,c as Er,i as Dr,l as Or,n as kr,o as Ar,s as jr,t as Mr,u as Nr}from"./speech-session--qKchPMR.js";import{n as Pr,t as Fr}from"./web-preview-events-D7F0Z-Hy.js";var Ir=k(`audio-lines`,[[`path`,{d:`M2 10v3`,key:`1fnikh`}],[`path`,{d:`M6 6v11`,key:`11sgs0`}],[`path`,{d:`M10 3v18`,key:`yhl04a`}],[`path`,{d:`M14 8v7`,key:`3a1oy3`}],[`path`,{d:`M18 5v13`,key:`123xd1`}],[`path`,{d:`M22 10v3`,key:`154ddg`}]]),Lr=k(`badge-check`,[[`path`,{d:`M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z`,key:`3c2336`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Rr=k(`bookmark`,[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]),zr=k(`file-check-corner`,[[`path`,{d:`M10.5 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v6`,key:`g5mvt7`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m14 20 2 2 4-4`,key:`15kota`}]]),Br=k(`file-down`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 18v-6`,key:`17g6i2`}],[`path`,{d:`m9 15 3 3 3-3`,key:`1npd3o`}]]),Vr=k(`message-circle-question-mark`,[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Hr=k(`mic-off`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`,key:`1gzdoj`}],[`path`,{d:`M16.95 16.95A7 7 0 0 1 5 12v-2`,key:`cqa7eg`}],[`path`,{d:`M18.89 13.23A7 7 0 0 0 19 12v-2`,key:`16hl24`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`,key:`r2i35w`}]]),Ur=k(`mic`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`13`,rx:`3`,key:`s6n7sd`}]]),Wr=k(`shield`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]),Gr=k(`shrink`,[[`path`,{d:`m15 15 6 6m-6-6v4.8m0-4.8h4.8`,key:`17vawe`}],[`path`,{d:`M9 19.8V15m0 0H4.2M9 15l-6 6`,key:`chjx8e`}],[`path`,{d:`M15 4.2V9m0 0h4.8M15 9l6-6`,key:`lav6yq`}],[`path`,{d:`M9 4.2V9m0 0H4.2M9 9 3 3`,key:`1pxi2q`}]]),Kr=k(`target`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`6`,key:`1vlfrh`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),Q=e(r(),1),qr=c(()=>({getItem:e=>{try{return n.getItem(e)}catch{return null}},setItem:(e,t)=>{try{n.setItem(e,t)}catch{}},removeItem:e=>{try{n.removeItem(e)}catch{}}})),Jr=l()(s((e,t)=>({width:360,open:!1,setWidth:n=>{let r=ir(n);t().width!==r&&e({width:r})},setOpen:n=>{t().open!==n&&e({open:n})}}),{name:`pisper-session-context-layout`,version:2,storage:qr,migrate:e=>{let t=e&&typeof e==`object`&&!Array.isArray(e)?e:{};return{width:ir(`width`in t?t.width:void 0),open:`open`in t&&t.open===!0}},partialize:({width:e,open:t})=>({width:e,open:t}),merge:(e,t)=>({...t,width:ir(e&&typeof e==`object`&&!Array.isArray(e)&&`width`in e?e.width:void 0),open:!!(e&&typeof e==`object`&&!Array.isArray(e)&&`open`in e&&e.open===!0)})}));function Yr(e,t,n){let r=(0,Q.useRef)(n);r.current=n,(0,Q.useLayoutEffect)(()=>e?Gn.register(t,()=>r.current()):void 0,[e,t])}var $=a();function Xr({preferredWidth:e,onWidthChange:t,availableWidth:n,presentation:r,children:i,context:a,side:s=`right`,layoutId:c=`chat`,conversationHeaderInset:l=0}){let{t:u}=o(),d=(0,Q.useRef)(()=>{});(0,Q.useEffect)(()=>()=>d.current(),[]);let f=r===`aside`,p=r===`content`,m=ar(e,n),h=ar(720,n),g=e=>t(Math.max(280,Math.min(h,e))),_=n=>{if(n.button!==0)return;d.current(),n.preventDefault(),n.currentTarget.focus(),n.currentTarget.setPointerCapture(n.pointerId);let r=n.clientX,i=e=>g(m+(e.clientX-r)*(s===`left`?1:-1)),a=()=>{window.removeEventListener(`pointermove`,i),window.removeEventListener(`pointerup`,a),window.removeEventListener(`pointercancel`,o),window.removeEventListener(`keydown`,c)},o=()=>{t(e),a()},c=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),o())};d.current=a,window.addEventListener(`pointermove`,i),window.addEventListener(`pointerup`,a,{once:!0}),window.addEventListener(`pointercancel`,o,{once:!0}),window.addEventListener(`keydown`,c)},v=(0,$.jsx)(`div`,{id:`${c}-conversation`,"data-workspace-conversation":!0,inert:p,className:p?`hidden`:`min-h-0 min-w-0 flex-1 overflow-hidden`,style:f&&l?{paddingTop:l}:void 0,children:i},`conversation`),y=f?(0,$.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-orientation":`vertical`,"aria-label":u(`chat:sessionContext.resize`),title:u(`chat:sessionContext.resizeHint`),"aria-controls":`${c}-conversation ${c}-content`,"aria-valuemin":280,"aria-valuemax":h,"aria-valuenow":m,onPointerDown:_,onDoubleClick:()=>t(360),onKeyDown:e=>{if(![`ArrowLeft`,`ArrowRight`,`Home`,`End`,`Enter`].includes(e.key))return;if(e.preventDefault(),e.key===`Enter`){t(360);return}let n=e.shiftKey?64:16;g(e.key===`Home`?280:e.key===`End`?h:m+(e.key===`ArrowRight`?n:-n)*(s===`left`?1:-1))},className:`relative w-2 shrink-0 cursor-col-resize touch-none select-none outline-none after:absolute after:top-1/2 after:left-1/2 after:h-9 after:w-[3px] after:-translate-1/2 after:rounded-full after:bg-stroke-strong after:transition-colors after:duration-[var(--d-fast)] hover:after:bg-focus active:after:bg-focus focus-visible:after:bg-focus focus-visible:after:ring-3 focus-visible:after:ring-focus-ring`},`separator`):null,b=(0,$.jsx)(`div`,{id:`${c}-content`,className:f?`h-full min-h-0 shrink-0 overflow-hidden`:p?`h-full min-h-0 min-w-0 flex-1 overflow-hidden`:`hidden`,style:f?{width:m}:void 0,children:(f||p)&&a},`resource`);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{id:`${c}-context-layout`,"data-workspace-layout":!0,className:`flex h-full min-h-0 min-w-0 flex-1 overflow-hidden`,children:s===`left`?[b,y,v]:[v,y,b]}),r===`sheet`&&a]})}function Zr({sessionId:e,streaming:t,completed:n,runStartedAt:r,enabled:i,open:a,onReveal:o}){let s=(0,Q.useRef)(null),c=(0,Q.useRef)(o);(0,Q.useLayoutEffect)(()=>{c.current=o},[o]),(0,Q.useEffect)(()=>{let o=s.current,l={sessionId:e,streaming:t,completed:n,runStartedAt:r};if(s.current=l,!i||a||!cr(o,l))return;let u=new AbortController,d=!0;return X.getSessionFileChanges(e,{signal:u.signal}).then(({files:e})=>{d&&lr(o,l,e)&&c.current()}).catch(()=>{}),()=>{d=!1,u.abort()}},[n,i,a,r,e,t])}var Qr=`pisper:task-content-requested`,$r=[`changes`,`terminal`,`processes`,`sources`,`browser`];function ei(e){return!e||typeof e!=`object`||!(`kind`in e)?null:$r.find(t=>t===e.kind)||null}function ti({sessionId:e,cwd:t,taskName:n,sources:r,mobile:i,streaming:a}){let{t:s}=o(),c=dr(e),l=ur(),[u,d]=(0,Q.useState)(!1),f=(0,Q.useRef)(null),m=(0,Q.useRef)(!1),h=T(e=>e.capabilities),g=w(h,`vcs`),_=p({enabled:g,queryKey:[`task-project-changes`,e,t,a],queryFn:({signal:t})=>X.getVcsChanges(e,{signal:t})}),v=(0,Q.useMemo)(()=>Re(_.data?.diff||``,_.data?.files.map(e=>e.path)||[],_.data?.diffTruncated),[_.data]),y=()=>sr.getState().update(e,`new`,{type:`workspace`,summaryOpen:!1}),b=()=>document.getElementById(`task-${e}-summary-toggle`)?.focus();(0,Q.useEffect)(()=>{i||f.current?.focus()},[i]);let x=(t,n=``)=>{let r=sr.getState();if(r.update(e,t,{type:`open`,kind:t})===`limit`){d(!0);return}m.current=!0;let i=sr.getState().sessions[e]?.activeId;n&&i&&r.update(e,t,{type:`view`,id:i,patch:t===`sources`?{selectedSourceId:n,query:``,filter:``}:{expandedProcesses:[n],filter:``}})};Yr(!i,300,()=>{y(),b()});let S=`w-full justify-start gap-2 px-2 font-normal text-content`,C=`ml-auto shrink-0 text-xs text-content-muted tabular-nums`,E=(0,$.jsxs)($.Fragment,{children:[u&&(0,$.jsx)(`p`,{role:`alert`,className:`px-2 pb-1 text-xs text-danger`,children:s(`chat:sessionContext.pageLimit`)}),(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2 border-b border-stroke-soft px-2 pt-1 pb-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`truncate font-mono text-xs text-content-muted`,title:t,children:t.split(/[\\/]/).filter(Boolean).at(-1)||t}),(0,$.jsx)(`p`,{className:`mt-0.5 truncate text-sm font-medium text-content`,children:n})]}),(0,$.jsx)(Y,{variant:`ghost`,size:`icon`,className:`max-[650px]:size-11`,"aria-label":s(`chat:workbench.closeSummary`),onClick:()=>{y(),b()},children:(0,$.jsx)(vt,{size:16})})]}),(0,$.jsxs)(`section`,{className:`border-b border-stroke-soft py-1`,children:[(0,$.jsxs)(Y,{variant:`ghost`,className:`${S} h-auto min-h-8 whitespace-normal text-left`,disabled:!g,onClick:()=>x(`changes`),children:[(0,$.jsx)(oe,{size:16,className:`text-content-muted`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1`,children:s(`chat:workbench.projectChanges`)}),(0,$.jsx)(`span`,{className:C,children:g?_.isPending?`…`:_.isError||_.data?.error?s(`chat:workbench.unavailable`):_.data?.isRepo?_.data.files.length:`—`:s(`chat:workbench.unavailable`)})]}),(_.isError||_.data?.error)&&(0,$.jsx)(`p`,{role:`alert`,className:`px-2 py-1 text-xs text-danger`,children:s(`chat:workbench.changesFailed`)}),_.data?.isRepo&&!_.isError&&!_.data.error&&(0,$.jsxs)(`p`,{className:`px-2 pb-1 pl-8 font-mono text-xs tabular-nums text-content-muted`,children:[v.partial?`${s(`chat:workbench.partialCounts`)} `:``,(0,$.jsxs)(`span`,{className:`text-success`,children:[`+`,v.added]}),` `,(0,$.jsxs)(`span`,{className:`text-danger`,children:[`−`,v.removed]})]}),(0,$.jsxs)(Y,{variant:`ghost`,className:S,onClick:()=>x(`files`),children:[(0,$.jsx)(Ie,{size:16,className:`text-content-muted`}),s(`chat:workbench.taskSnapshots`)]})]}),(0,$.jsxs)(`section`,{className:`border-b border-stroke-soft py-1`,children:[(0,$.jsxs)(Y,{variant:`ghost`,className:S,onClick:()=>x(`processes`),children:[(0,$.jsx)(`span`,{children:s(`terminal:workspace.processes`)}),(0,$.jsx)(`span`,{className:C,children:c.length})]}),!l&&(0,$.jsx)(`p`,{className:`px-2 pb-1 text-xs text-content-muted`,children:s(`terminal:workspace.nativeOnly`)}),c.slice(0,3).map(e=>(0,$.jsxs)(Y,{variant:`ghost`,className:`${S} min-w-0`,onClick:()=>x(`processes`,e.id),children:[e.status===`running`?(0,$.jsx)(Rt,{className:`size-3.5`}):(0,$.jsx)(A,{size:15,className:`text-content-muted`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left font-mono text-xs`,children:e.profileId}),(0,$.jsx)(`span`,{className:C,children:e.status===`running`?s(`terminal:workspace.running`):e.status===`exited`?s(`terminal:workspace.exited`):s(`chat:workbench.otherState`)})]},e.id))]}),(0,$.jsxs)(`section`,{className:`pt-1`,children:[(0,$.jsxs)(Y,{variant:`ghost`,className:S,onClick:()=>x(`sources`),children:[(0,$.jsx)(`span`,{children:s(`chat:workbench.sources`)}),(0,$.jsx)(`span`,{className:C,children:r.length})]}),r.slice(0,3).map(e=>(0,$.jsxs)(Y,{variant:`ghost`,className:`${S} min-w-0`,onClick:()=>x(`sources`,e.id),children:[(0,$.jsx)($e,{size:15,className:`text-content-muted`}),(0,$.jsx)(`span`,{className:`truncate font-mono text-xs`,children:e.name||s(`chat:chatMessage.fileAttachment`)})]},e.id)),(0,$.jsx)(Y,{variant:`ghost`,className:`${S} text-content-muted`,onClick:()=>x(`sources`),children:s(`chat:workbench.viewAll`)})]})]});return i?(0,$.jsx)(fn,{open:!0,onOpenChange:e=>{e||y()},children:(0,$.jsxs)(ln,{side:`bottom`,showCloseButton:!1,"aria-describedby":void 0,className:`max-h-[80dvh] overflow-y-auto rounded-t-2xl p-3 pb-[max(16px,var(--pisper-safe-area-bottom))] [&_button]:min-h-11`,style:{left:`calc(44px + var(--pisper-safe-area-left, 0px))`,right:`var(--pisper-safe-area-right, 0px)`},onCloseAutoFocus:e=>{e.preventDefault(),m.current||b()},children:[(0,$.jsx)(un,{className:`sr-only`,children:s(`chat:workbench.summary`)}),E]})}):(0,$.jsx)(`div`,{ref:f,tabIndex:-1,id:`task-${e}-summary`,role:`region`,"aria-label":s(`chat:workbench.summary`),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),y(),b())},className:`absolute top-[52px] right-2 z-20 max-h-[calc(100%-64px)] w-80 max-w-[calc(100%-16px)] overflow-y-auto rounded-md bg-popover p-1 text-sm text-popover-foreground shadow-float`,children:E})}function ni(e){if(typeof e!=`string`||Array.from(e).some(e=>e.charCodeAt(0)<32))return``;let t=e.replace(/\\/g,`/`);return!t.startsWith(`/`)&&!/^[a-z]:\//i.test(t)?``:t.replace(/\/\.\//g,`/`).replace(/\/$/,``)||`/`}function ri(e){let t=[],n=new Set;for(let r of e)if(Array.isArray(r.attachments))for(let[e,i]of r.attachments.entries()){if(!i||typeof i!=`object`||Array.isArray(i))continue;let a=typeof i.id==`string`&&!i.id.startsWith(`path:`)&&i.id.length<=512&&!Array.from(i.id).some(e=>e.charCodeAt(0)<32)?i.id:``,o=ni(i.path),s=a?`asset`:o?`path`:`unresolved`,c=a?`asset:${a}`:o?`path:${o}`:`unresolved:${r.id}:${e}`;if(n.has(c))continue;n.add(c);let l=typeof i.name==`string`?i.name:o.split(`/`).pop()||a,u=typeof i.mimeType==`string`?i.mimeType:``,d={...a?{id:a,downloadUrl:`/api/assets/${encodeURIComponent(a)}/download`}:{},...o?{id:a||`path:${o}`,path:o}:{},name:l,mimeType:u,...typeof i.size==`number`&&Number.isFinite(i.size)&&i.size>=0?{size:i.size}:{},...typeof i.text==`string`?{text:i.text.slice(0,4e5)}:{}};t.push({id:c,name:l,method:s,messageId:r.id,attachment:d,available:s!==`unresolved`||typeof i.text==`string`,kind:u.startsWith(`image/`)?`image`:u.startsWith(`text/`)?`text`:`file`})}return t}function ii({width:e,mobile:t,contentOpen:n}){return n?t||e<660?`content`:`split`:`conversation`}var ai=(0,Q.lazy)(()=>t(()=>import(`./SessionContextPanel-B2sS7myK.js`).then(e=>({default:e.SessionContextPanel})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121])));function oi({sessionId:e,messages:t,taskName:n,cwd:r,panelId:i,active:a,mobile:s,plan:c,streaming:l,completed:u,runStartedAt:d,plansAvailable:f,requestConfirm:p,children:m}){let{t:h}=o(),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(null),b=(0,Q.useMemo)(()=>({headerHost:g,sourceActionHost:v,setSourceActionHost:y}),[g,v]),x=(0,Q.useMemo)(()=>ri(t),[t]),S=(0,Q.useRef)(Jr.getState().width).current,C=(0,Q.useRef)(null),[w,T]=(0,Q.useState)(0),E=(0,Q.useMemo)(()=>rr(),[]),D=sr(t=>t.sessions[e])||E,O=sr(e=>e.update);(0,Q.useLayoutEffect)(()=>{D.contentWidth??O(e,`new`,{type:`workspace`,contentWidth:S})},[D.contentWidth,e,S,O]),(0,Q.useLayoutEffect)(()=>{let e=C.current;if(!e)return;let t=()=>T(e.clientWidth);t();let n=null,r=new ResizeObserver(()=>{n!==null&&cancelAnimationFrame(n),n=requestAnimationFrame(()=>{n=null,t()})});return r.observe(e),()=>{r.disconnect(),n!==null&&cancelAnimationFrame(n)}},[]);let k=ii({width:w,mobile:s,contentOpen:D.contentOpen&&D.pages.length>0});Zr({sessionId:e,streaming:l,completed:u,runStartedAt:d,enabled:!0,open:D.contentOpen,onReveal:()=>O(e,`files`,{type:`open`,kind:`files`})}),(0,Q.useEffect)(()=>{if(!a)return;let t=t=>{let n=ei(t.detail);n&&O(e,n,{type:`open`,kind:n})};return window.addEventListener(Qr,t),()=>window.removeEventListener(Qr,t)},[a,e,O]);let A=()=>{window.dispatchEvent(new Event(Xt)),O(e,`files`,{type:`workspace`,contentOpen:!1}),requestAnimationFrame(()=>(document.getElementById(`task-${e}-new-content-tab`)||document.getElementById(`task-${e}-more`))?.focus())};Yr(a&&k===`content`,100,A);let j=D.contentOpen&&D.pages.length>0&&(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{role:`status`,className:`p-4 text-sm text-content-muted`,children:h(`chat:focusSession.gitLoading`)}),children:(0,$.jsx)(ai,{panelId:`${i}-context`,compact:!1,embedded:!0,active:a,sessionId:e,cwd:r,sources:x,tab:D.pages.find(e=>e.id===D.activeId)?.kind||`files`,plan:c,streaming:l,plansAvailable:f,requestConfirm:p,onTabChange:()=>{},onClose:A,onBack:A})});return(0,$.jsx)(Pe.Provider,{value:b,children:(0,$.jsxs)(`div`,{ref:C,id:`task-${e}-workspace`,tabIndex:-1,"data-task-workspace":e,"data-active":a,className:`relative flex h-full min-h-0 min-w-0 flex-col overflow-hidden bg-panel`,children:[(0,$.jsx)(`div`,{ref:_,className:k===`split`?`@container absolute left-0 top-0 z-10`:`@container shrink-0`,style:k===`split`?{width:`calc(100% - ${ar(D.contentWidth??S,w)+8}px)`}:void 0,"data-task-header":!0}),(0,$.jsx)(Xr,{preferredWidth:D.contentWidth??S,onWidthChange:t=>{O(e,`new`,{type:`workspace`,contentWidth:t}),Jr.getState().setWidth(t)},layoutId:i,availableWidth:w,conversationHeaderInset:48,presentation:k===`split`?`aside`:k===`content`?`content`:`closed`,context:j,children:m}),a&&D.summaryOpen&&(0,$.jsx)(ti,{sessionId:e,cwd:r,taskName:n,sources:x,mobile:s,streaming:l})]})})}function si(e,t){return e.open===t?e:{open:t,leaving:!t}}function ci(e){return e.leaving?{open:e.open,leaving:!1}:e}function li(e){return e.open||e.leaving}function ui(e,t=400){let[n,r]=(0,Q.useState)(()=>({open:e,leaving:!1})),i=n;n.open!==e&&(i=si(n,e),r(i));let a=i.leaving,o=(0,Q.useCallback)(()=>r(ci),[]);return(0,Q.useLayoutEffect)(()=>{if(!a)return;if(Jn()){o();return}let e=window.setTimeout(o,t);return()=>window.clearTimeout(e)},[t,o,a]),{mounted:li(i),leaving:a,finish:o}}function di(e){return[`running`,`waiting_approval`].includes(String(e.status||``))}function fi(e,t){return t(e===`running`?`chat:workflowRun.running`:e===`waiting_approval`?`chat:workflowRun.waitingApproval`:e===`completed`?`chat:workflowRun.completed`:e===`failed`?`chat:workflowRun.failed`:e===`cancelled`?`chat:workflowRun.stopped`:`chat:workflowRun.interrupted`)}function pi({sessionId:e,empty:t=null}){let{t:n}=o(),[r,i]=(0,Q.useState)([]),[a,s]=(0,Q.useState)(``),c=(0,Q.useCallback)(async()=>{try{let t=await X.getSessionWorkflowRuns(e);i(t.runs||[])}catch{}},[e]);if((0,Q.useEffect)(()=>{c();let e=window.setInterval(c,1500);return()=>window.clearInterval(e)},[c]),!r.length)return t;let l=`session-workflow-context grid min-w-0 gap-1 border-b border-stroke-soft pb-1.5 [&_strong]:text-xs [&_strong]:font-medium [&_strong]:text-content-muted [&_p]:max-h-[84px] [&_p]:overflow-auto [&_p]:text-xs [&_p]:leading-relaxed [&_p]:whitespace-pre-wrap [&_p]:text-content-secondary [&_p]:[overflow-wrap:anywhere] [&_pre]:max-h-[84px] [&_pre]:overflow-auto [&_pre]:rounded-xs [&_pre]:bg-code [&_pre]:px-1.5 [&_pre]:py-1 [&_pre]:font-mono [&_pre]:text-xs [&_pre]:leading-relaxed [&_pre]:whitespace-pre-wrap [&_pre]:text-content-secondary [&_pre]:[overflow-wrap:anywhere]`;return(0,$.jsx)(`div`,{className:`flex max-h-[210px] flex-col overflow-auto rounded-md border border-stroke bg-panel`,children:[...r].sort((e,t)=>Date.parse(t.startedAt)-Date.parse(e.startedAt)).slice(0,5).map(e=>{let t=a===e.id,r=Math.round((Number(e.completedNodes)||0)/Math.max(1,Number(e.totalNodes)||1)*100);return(0,$.jsxs)(`div`,{className:`session-workflow-run border-b border-stroke-soft last:border-b-0 ${e.status}`,children:[(0,$.jsxs)(`button`,{className:`session-workflow-summary grid w-full cursor-pointer grid-cols-[20px_minmax(120px,1fr)_minmax(80px,160px)_14px] items-center gap-2.5 border-0 px-3 py-2 text-left text-content transition-colors duration-(--d-fast) hover:bg-surface-subtle focus-visible:-outline-offset-2 max-[650px]:min-h-11 max-[650px]:grid-cols-[20px_minmax(0,1fr)_14px] max-[650px]:[&_[data-slot='progress']]:col-[2/4] [&_[data-slot='progress']]:h-1 [&_>_span:nth-child(2)]:flex [&_>_span:nth-child(2)]:min-w-0 [&_>_span:nth-child(2)]:flex-col [&_small]:truncate [&_small]:text-xs [&_small]:text-content-muted [&_small]:tabular-nums [&_strong]:truncate [&_strong]:text-sm [&_strong]:font-medium ${t?`bg-surface-subtle`:`bg-transparent`}`,"aria-expanded":t,onClick:()=>s(t?``:e.id),children:[(0,$.jsx)(`span`,{className:`grid size-5 place-items-center rounded-xs ${e.status===`completed`?`bg-success-soft text-success`:e.status===`failed`?`bg-danger-soft text-danger`:e.status===`waiting_approval`?`bg-warning-soft text-warning-strong`:`bg-surface-muted text-content-muted`}`,children:e.status===`running`?(0,$.jsx)(Rt,{className:`size-3.5`}):e.status===`completed`?(0,$.jsx)(F,{size:12}):e.status===`failed`?(0,$.jsx)(vt,{size:12}):(0,$.jsx)(gt,{size:12})}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`strong`,{children:e.workflowName}),(0,$.jsxs)(`small`,{children:[fi(e.status,n),` · v`,e.workflowRevision||1]})]}),(0,$.jsx)(Dt,{value:e.status===`completed`?100:r}),(0,$.jsx)(R,{size:14,className:`text-content-muted transition-transform duration-(--d-fast) ${t?`rotate-90`:``}`})]}),t&&(0,$.jsxs)(`div`,{className:`session-workflow-detail flex flex-col gap-1.5 border-t border-stroke-soft bg-surface-subtle py-2 pr-3 pl-[42px] max-[650px]:pl-3 [&_>_p]:text-xs [&_>_p]:text-content-muted`,children:[e.sourceMessage&&(0,$.jsxs)(`div`,{className:l,children:[(0,$.jsx)(`strong`,{children:n(`chat:workflowRun.request`)}),(0,$.jsx)(`p`,{children:e.sourceMessage})]}),e.inputs&&Object.keys(e.inputs).length>0&&(0,$.jsxs)(`div`,{className:l,children:[(0,$.jsx)(`strong`,{children:n(`chat:workflowRun.inputs`)}),(0,$.jsx)(`pre`,{children:JSON.stringify(e.inputs,null,2)})]}),(e.nodes||[]).map(t=>(0,$.jsxs)(`div`,{className:`session-workflow-node grid min-h-6 grid-cols-[15px_minmax(0,1fr)_auto] items-center gap-1.5 text-content-muted [&.completed]:text-success [&.failed]:text-danger [&_>_div]:flex [&_>_div]:gap-1 [&_>_span]:flex [&_>_span]:min-w-0 [&_>_span]:flex-col [&_small]:truncate [&_small]:text-xs [&_small]:text-content-muted [&_strong]:text-xs [&_strong]:font-medium [&_strong]:text-content ${t.status}`,children:[t.status===`completed`?(0,$.jsx)(F,{size:13}):t.status===`failed`?(0,$.jsx)(B,{size:13}):t.status===`running`?(0,$.jsx)(Rt,{className:`size-3.5`}):(0,$.jsx)(dt,{size:11}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`strong`,{children:t.label}),(t.error||t.summary)&&(0,$.jsx)(`small`,{children:t.error||t.summary})]}),t.status===`waiting_approval`&&(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Y,{size:`xs`,onClick:async()=>{await X.resolveWorkflowApproval(e.id,t.id,!0),await c()},children:n(`chat:workflowRun.approve`)}),(0,$.jsx)(Y,{size:`xs`,variant:`destructive`,onClick:async()=>{await X.resolveWorkflowApproval(e.id,t.id,!1),await c()},children:n(`chat:workflowRun.reject`)})]})]},t.id)),(e.error||e.summary)&&(0,$.jsx)(`p`,{children:e.error||e.summary}),di(e)&&(0,$.jsxs)(Y,{size:`xs`,variant:`destructive`,className:`self-start`,onClick:async()=>{await X.stopWorkflowRun(e.id),await c()},children:[(0,$.jsx)(dt,{"data-icon":`inline-start`}),n(`chat:workflowRun.stop`)]})]})]},e.id)})})}function mi(e,t){let[n,r]=(0,Q.useState)(()=>Date.now());(0,Q.useEffect)(()=>{if(!t)return;r(Date.now());let e=setInterval(()=>r(Date.now()),1e3);return()=>clearInterval(e)},[t]);let i=e?Date.parse(e):NaN;return t&&Number.isFinite(i)?Math.max(0,n-i):null}function hi(e,t){sr.getState().update(e,`side-chat`,{type:`open`,kind:`side-chat`}),t?.show(`side-chat`)}function gi(e,t){let{t:n,language:r}=o(),i=(0,Q.useContext)(Me),[a,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(!1),f=T(e=>e.capabilities.features.sessionExport===!0),p=e.name||n(`navigation:pageHeader.newChat`),{notify:m}=t,h=async()=>{if(!c){l(!0);try{await pn(e.id,{archived:!0}),m(n(`board:action.archived`,{title:p})),i?.onArchived?.(e.id)}catch{m(n(`board:action.failed`),`error`)}finally{l(!1)}}},g=async()=>{if(!u){d(!0);try{let t=await X.exportSessionMarkdown(e.id,r),i=URL.createObjectURL(t),a=document.createElement(`a`);a.href=i,a.download=`${p.replace(/[\\/:*?"<>|\p{Cc}]/gu,`-`).slice(0,80)||`session`}.md`,a.click(),window.setTimeout(()=>URL.revokeObjectURL(i),1e3),m(n(`chat:sessionMenu.exported`,{title:p}))}catch{m(n(`chat:sessionMenu.exportFailed`),`error`)}finally{d(!1)}}},_=typeof t.contextPercent==`number`&&Number.isFinite(t.contextPercent)?Math.round(Math.min(100,Math.max(0,t.contextPercent))):null,v=[{key:`rename`,icon:it,label:n(`chat:sessionMenu.rename`),onSelect:t.onRename},...t.onSideChat?[{key:`side-chat`,icon:tt,label:n(`board:inspector.sideChat`),onSelect:t.onSideChat,marker:`session-side-chat`}]:[],...f?[{key:`export`,icon:Br,label:n(`chat:sessionMenu.exportMarkdown`),onSelect:()=>void g(),disabled:u,marker:`session-export`}]:[],...e.machine?[]:[{key:`workspace`,icon:Xe,label:n(`board:session.moveWorkspace`),onSelect:t.onWorkspace,disabled:t.workspaceDisabled,separator:!0}],{key:`compact`,icon:Gr,label:n(`chat:sessionMenu.compactContext`),onSelect:()=>t.onCompact?.(),disabled:t.compactDisabled||!t.onCompact,trailing:_===null?void 0:`${_}%`,trailingTitle:_===null?void 0:n(`board:session.contextUsage`,{percent:_})},...t.workflowsAvailable?[{key:`workflows`,icon:gt,label:n(`chat:sessionMenu.workflowRuns`),onSelect:()=>s(!0)}]:[],{key:`voice`,icon:Ir,label:n(`chat:sessionMenu.voiceMode`),onSelect:t.onVoiceMode},{key:`archive`,icon:j,label:n(`board:card.archive`),onSelect:()=>void h(),disabled:c,separator:!0}];return{entries:v,items:(0,$.jsxs)($.Fragment,{children:[v.map(e=>{let t=e.icon,n=e.marker?{[`data-${e.marker}`]:!0}:{},r=(0,$.jsxs)(St,{disabled:e.disabled,onSelect:e.onSelect,...n,children:[(0,$.jsx)(t,{}),e.label,e.trailing&&(0,$.jsx)(Ct,{className:`font-mono tabular-nums`,title:e.trailingTitle,"data-session-context-usage":!0,children:e.trailing})]});return(0,$.jsxs)(Q.Fragment,{children:[e.separator&&(0,$.jsx)(xt,{}),r]},e.key)}),t.extraItems&&(0,$.jsx)(xt,{}),t.extraItems]}),dialog:(0,$.jsx)(Pn,{open:a,onOpenChange:s,children:(0,$.jsxs)(jn,{className:`max-w-lg`,children:[(0,$.jsxs)(Nn,{children:[(0,$.jsx)(Mn,{children:n(`board:session.workflowRuns`)}),(0,$.jsx)(An,{children:p})]}),a&&(0,$.jsx)(pi,{sessionId:e.id,empty:(0,$.jsx)(`p`,{className:`py-6 text-center text-sm text-content-muted`,children:n(`board:session.workflowRunsEmpty`)})})]})})}}var _i=(0,Q.lazy)(()=>t(()=>import(`./SessionInspector-BHdqiu1D.js`).then(e=>({default:e.SessionInspector})),__vite__mapDeps([122,1,3,4,5,2,6,7,8,9,23,24,10,11,12,13,14,15,16,18,17,123,20,22,19,25,26,27,21,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,124,125,126,127,128,116,117,129,119,120,121,130]))),vi=[];function yi(e){switch(e){case`changes`:return{tab:`changes`,changesView:`workspace`};case`files`:return{tab:`changes`,changesView:`session`};case`terminal`:case`processes`:return{tab:`terminal`,terminalView:e};case`sources`:return{tab:`files`};case`browser`:return{tab:`preview`};case`plan`:return{tab:`plan`};case`side-chat`:return{tab:`side-chat`};default:return null}}function bi(e){if(!(e instanceof HTMLElement)||e===document.body||e.closest(`[data-inspector-sheet]`))return null;let t=e.closest(`[role="menu"]`);if(!t)return e;let n=t.getAttribute(`aria-labelledby`);return n?document.getElementById(n):null}var xi=`a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), iframe, [tabindex]:not([tabindex="-1"])`;function Si(e){if(e.key!==`Tab`||e.altKey||e.ctrlKey||e.metaKey)return;let t=[...e.currentTarget.querySelectorAll(xi)].filter(e=>e.getClientRects().length>0);if(!t.length)return;let n=t[0],r=t[t.length-1],i=document.activeElement;(e.shiftKey?i===n:i===r)&&(e.preventDefault(),(e.shiftKey?r:n).focus())}function Ci(e){let t=e?.items??[];return t.length?{done:t.filter(e=>e.status===`completed`).length,total:t.length}:null}function wi({sessionId:e,messages:t,cwd:n,active:r,plan:i,goal:a=null,team:s=null,activity:c=vi,planTab:l,streaming:u,completed:d,runStartedAt:f,requestConfirm:p,remoteMachine:m=!1,children:h}){let{t:g}=o(),_=(0,Q.useContext)(Me),v=!!(_?.phone??null),y=v||!!(_?.compact||_?.overlayOnly),[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(null),w=(0,Q.useMemo)(()=>({headerHost:b,sourceActionHost:S,setSourceActionHost:C}),[b,S]),T=(0,Q.useMemo)(()=>ri(t),[t]),E=pr(e=>e.open),D=pr(e=>e.pinned),O=pr(e=>e.setOpen),k=pr(e=>e.widthPercent),A=pr(e=>e.width),j=pr(e=>e.setWidth),M=pr(e=>e.resetWidth),[N,P]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{y||P(!1)},[y]);let F=y?N:E,I=ui(v&&F),L=v&&I.leaving,R=(0,Q.useRef)(null),z=`session-${e}-inspector`,B=(0,Q.useRef)(null),[V,ee]=(0,Q.useState)(0);(0,Q.useLayoutEffect)(()=>{let e=B.current;if(!e)return;let t=()=>ee(e.clientWidth);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let te=fr({widthPercent:k,width:A},V||window.innerWidth),[ne,re]=(0,Q.useState)(0);(0,Q.useLayoutEffect)(()=>{if(!b)return;let e=()=>re(b.offsetHeight);e();let t=new ResizeObserver(e);return t.observe(b),()=>t.disconnect()},[b]);let H=(0,Q.useRef)(null),[ie,ae]=(0,Q.useState)(!1),[U,W]=(0,Q.useState)(!1),oe=(0,Q.useCallback)((e,t=!1)=>{if(window.dispatchEvent(new Event(Xt)),v&&e){let e=bi(document.activeElement);e&&(R.current=e)}ae(e),W(e&&t),y?P(e):O(e)},[y,O,v]),ce=(0,Q.useCallback)((e,t)=>{pr.getState().setTab(e),oe(!0,t)},[oe]),G=(0,Q.useCallback)(e=>ce(e,!0),[ce]),le=(0,Q.useCallback)(()=>{let e=document.activeElement,t=!!(e&&H.current?.contains(e))||y&&!v&&(!e||e===document.body);oe(!1),t&&requestAnimationFrame(()=>document.querySelector(`[aria-controls="${CSS.escape(z)}"][data-inspector-toggle]`)?.focus())},[y,z,oe,v]),K=(0,Q.useCallback)(()=>F?le():oe(!0,!0),[le,F,oe]),ue=(0,Q.useCallback)(t=>{t.preventDefault();let n=R.current;R.current=null,((n?.isConnected?n:null)??document.querySelector(`[data-session-changes][aria-controls="${CSS.escape(z)}"]`)??document.getElementById(`task-${e}-more`))?.focus({preventScroll:!0})},[z,e]),de=v?`sheet`:y?`overlay`:`aside`,fe=(0,Q.useMemo)(()=>({open:F,mode:de,panelId:z,toggle:K,show:G}),[F,de,z,G,K]),pe=(0,Q.useCallback)(e=>{let t=yi(e);if(!t)return;let n=pr.getState();t.terminalView&&n.setTerminalView(t.terminalView),t.changesView&&n.setChangesView(t.changesView),ce(t.tab,!1)},[ce]);(0,Q.useEffect)(()=>sr.subscribe((t,n)=>{let r=t.sessions[e],i=n.sessions[e];if(!r||r===i||!r.contentOpen)return;let a=r.pages.find(e=>e.id===r.activeId);if(!a)return;let o=i?.pages.find(e=>e.id===i.activeId);(r.activeId!==i?.activeId||!i?.contentOpen||a.kind===`browser`&&a.url!==o?.url)&&pe(a.kind)}),[pe,e]),(0,Q.useEffect)(()=>{if(!r)return;let t=t=>{let n=ei(t.detail);n&&sr.getState().update(e,n,{type:`open`,kind:n})};return window.addEventListener(Qr,t),()=>window.removeEventListener(Qr,t)},[r,e]),(0,Q.useEffect)(()=>{if(!r)return;let t=t=>{let n=t.detail;n===`side-chat`?hi(e,fe):n===`tree`&&B.current?.querySelector(`[data-session-branches]`)?.click()};return window.addEventListener(Kt,t),()=>window.removeEventListener(Kt,t)},[r,fe,e]),Zr({sessionId:e,streaming:u,completed:d,runStartedAt:f,enabled:!y,open:F,onReveal:()=>pe(`files`)});let me=nn(e=>e.bindings.toggleInspector);(0,Q.useEffect)(()=>{if(!r)return;let e=e=>{!on(e,me)||tn(e)||rn(e)&&e.key.length===1||(e.preventDefault(),K())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r,me,K]),Yr(r&&y&&N,100,le),Yr(r&&!y&&E&&!D,100,le);let he=(0,Q.useRef)(()=>{});(0,Q.useEffect)(()=>()=>he.current(),[]);let q=e=>{if(e.button!==0)return;he.current(),e.preventDefault(),e.currentTarget.focus(),e.currentTarget.setPointerCapture(e.pointerId);let t=e.clientX,n=te,r=e=>j(mr(n-(e.clientX-t),V),V),i=()=>{window.removeEventListener(`pointermove`,r),window.removeEventListener(`pointerup`,i),window.removeEventListener(`pointercancel`,i)};he.current=i,window.addEventListener(`pointermove`,r),window.addEventListener(`pointerup`,i,{once:!0}),window.addEventListener(`pointercancel`,i,{once:!0})},ge=u?Ci(i):null,_e=ie&&F&&!y,ve=y&&!v&&F&&V-420>=480?420:0,ye=(F||L)&&(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`p`,{role:`status`,className:`p-4 text-sm text-content-muted`,children:g(`chat:focusSession.gitLoading`)}),children:(0,$.jsx)(_i,{panelId:z,sessionId:e,cwd:n,streaming:u,plan:i,goal:a,team:s,activity:c,planTab:l,sources:T,mode:de,requestConfirm:p,onClose:le,onOpenComponents:_?.onOpenComponents,componentTabs:_?.componentTabs,autoFocus:de===`overlay`&&U,remoteMachine:m})});return(0,$.jsx)(Pe.Provider,{value:w,children:(0,$.jsx)(je.Provider,{value:fe,children:(0,$.jsxs)(`div`,{ref:B,id:`task-${e}-workspace`,tabIndex:-1,"data-task-workspace":e,"data-session-workspace":de,"data-active":r,className:Lt(`relative flex h-full min-h-0 min-w-0 overflow-hidden bg-panel`,v&&`pb-[var(--pisper-safe-area-bottom)] [[data-mobile-keyboard='open']_&]:pb-0`),children:[(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,"data-session-conversation":!0,children:[(0,$.jsx)(`div`,{ref:x,className:`@container shrink-0`,"data-task-header":!0}),ge&&(0,$.jsxs)(`div`,{className:`relative z-10 h-0.5 shrink-0 bg-surface-muted`,"data-plan-progress":!0,children:[(0,$.jsx)(`span`,{role:`progressbar`,"aria-label":g(`board:session.planLabel`,ge),"aria-valuemin":0,"aria-valuemax":ge.total,"aria-valuenow":ge.done,className:`absolute inset-0 origin-left bg-st-run transition-transform duration-(--d-base)`,style:{transform:`scaleX(${ge.done/ge.total})`}}),l&&(0,$.jsx)(`button`,{type:`button`,className:`absolute top-1.5 right-3 inline-flex h-6 items-center rounded-sm bg-panel px-2 font-mono text-xs text-content-secondary tabular-nums shadow-edge hover:bg-surface-hover hover:text-content focus-visible:outline-2 focus-visible:outline-focus pointer-coarse:h-11`,"aria-label":g(`board:session.planOpen`,{plan:g(`board:session.plan`,ge)}),"aria-controls":z,"data-plan-progress-open":!0,onClick:()=>G(`plan`),children:g(`board:session.plan`,ge)})]}),(0,$.jsx)(`div`,{className:Lt(`min-h-0 min-w-0 flex-1 overflow-hidden`,_e&&`animate-in duration-[220ms] ease-(--ease)`),"data-overlay-inset":ve||void 0,style:ve?{paddingRight:ve}:_e?{"--tw-enter-translate-x":`${te/2}px`}:void 0,children:h})]}),!y&&F&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-orientation":`vertical`,"aria-label":g(`chat:sessionContext.resize`),title:g(`chat:sessionContext.resizeHint`),"aria-controls":z,"aria-valuemin":360,"aria-valuemax":mr(1/0,V),"aria-valuenow":te,onPointerDown:q,onDoubleClick:M,onKeyDown:e=>{if(![`ArrowLeft`,`ArrowRight`,`Enter`].includes(e.key))return;if(e.preventDefault(),e.key===`Enter`){M();return}let t=e.shiftKey?64:16;j(mr(te+(e.key===`ArrowLeft`?t:-t),V),V)},className:`relative -mr-1 w-2 shrink-0 cursor-col-resize touch-none select-none outline-none after:absolute after:inset-y-0 after:left-1/2 after:w-px after:bg-stroke-soft after:transition-colors after:duration-(--d-fast) hover:after:w-[3px] hover:after:-translate-x-px hover:after:bg-focus focus-visible:after:w-[3px] focus-visible:after:bg-focus`}),(0,$.jsxs)(`aside`,{ref:H,className:Lt(`flex h-full min-h-0 shrink-0 flex-col overflow-hidden border-l border-stroke-soft`,ie&&`animate-in slide-in-from-right duration-[220ms] ease-(--ease)`),style:{width:te},"data-inspector-aside":!0,"data-inspector-pinned":D||void 0,children:[(0,$.jsx)(`div`,{"aria-hidden":`true`,"data-window-drag-region":!0,"data-inspector-titlebar-gap":!0,className:`hidden h-[52px] shrink-0 [[data-custom-titlebar]_&]:block`}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:ye})]})]}),y&&(F||L)&&(0,$.jsx)($.Fragment,{children:v?(0,$.jsx)(fn,{open:F,onOpenChange:e=>!e&&le(),children:(0,$.jsxs)(ln,{side:`bottom`,showCloseButton:!1,"data-inspector-sheet":!0,"data-sheet-leaving":L||void 0,onAnimationEnd:e=>{e.target===e.currentTarget&&!F&&I.finish()},onCloseAutoFocus:ue,className:`gap-0 data-[side=bottom]:h-[min(86dvh,calc(100dvh-var(--pisper-safe-area-top)-48px))] overflow-hidden rounded-t-(--r-sheet) bg-panel p-0 pb-[var(--pisper-safe-area-bottom)]`,children:[(0,$.jsx)(un,{className:`sr-only`,children:g(`board:inspector.label`)}),(0,$.jsx)(dn,{className:`sr-only`,children:g(`board:phone.inspectorDescription`)}),(0,$.jsx)(se,{onDismiss:le}),(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col [&_[data-slot=segmented-control]]:h-11 [&_[data-slot=segmented-control-item]]:h-10 [&_[data-slot=segmented-control-item]]:px-3`,children:ye})]})}):(0,$.jsx)(`aside`,{ref:H,"data-inspector-overlay":!0,onKeyDown:Si,className:Lt(`absolute right-0 bottom-0 z-30 max-w-[calc(100%-24px)] overflow-hidden border-l border-stroke bg-panel shadow-float`,`animate-in slide-in-from-right duration-[220ms] ease-(--ease)`),style:{width:420,top:ne},children:ye})})]})})})}var Ti=e(i(),1),Ei=(0,Q.createContext)(null),Di=(0,Q.lazy)(()=>t(()=>import(`./public-session-CzxHzz2C.js`),__vite__mapDeps([131,1,2,3,4,5,6,7,8,9,132,18,35,34,36,33,133,93,134,78,24,79,12,13,14,15,16,135,136,10,11,37,120])));function Oi({session:e,cwd:t,streaming:n,treeAvailable:r,branches:i,onOpenTree:a,...s}){let c=e.machine?`${e.machine.name}:${e.machine.cwd}`:t,{t:l,language:u}=o(),d=(0,Q.useContext)(je),f=gi(e,{...s,onSideChat:()=>hi(e.id,d)}),m=e.name||l(`navigation:pageHeader.newChat`),h=yn(e.projectless?``:c,u),g=e.machine?mn(e.machine):h,_=p({queryKey:[`session-change-summary`,e.id,n],queryFn:()=>Bn(e.id),staleTime:1e4}),v=_.data?.status===`known`?_.data:null,y=v?.changedFiles??0,b=nn(e=>e.bindings.toggleInspector),x=nn(e=>e.bindings.sessionTree),S=cn(b),C=cn(x),w=y>0?l(`board:session.changes`,{count:y,added:v?.added??0,removed:v?.removed??0}):null,T=w?`${l(`board:inspector.label`)} · ${w}`:l(`board:inspector.label`),E=S?l(`board:session.withShortcut`,{label:T,shortcut:S}):T,D=i>0?l(`board:session.treeBranches`,{count:i}):l(`board:session.tree`),O=C?l(`board:session.withShortcut`,{label:D,shortcut:C}):D;return(0,$.jsxs)(`header`,{"data-session-header":!0,"data-focus-region":`header`,"data-window-drag-region":!0,className:`flex h-[52px] min-w-0 shrink-0 items-center gap-2 pr-3 pl-4 [[data-custom-titlebar]_&]:pr-[144px]`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,"data-window-drag-region":!0,children:[e.botId&&(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Di,{botId:e.botId,part:`avatar`})}),(0,$.jsxs)(Et,{children:[(0,$.jsx)(wt,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,id:`task-${e.id}-more`,"data-session-menu":!0,className:Lt(`group inline-flex h-8 min-w-0 shrink items-center gap-1 rounded-sm px-2 text-[15px] leading-6 font-medium text-content hover:bg-surface-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-focus data-[state=open]:bg-surface-hover pointer-coarse:h-11`,Mt),"aria-label":l(`board:session.titleMenu`,{title:m}),children:[(0,$.jsx)(`span`,{className:`truncate`,"data-session-title":!0,children:m}),(0,$.jsx)(I,{className:`size-3.5 flex-none text-content-muted`,"aria-hidden":`true`})]})}),(0,$.jsx)(Tt,{align:`start`,className:`min-w-60`,children:f.items})]}),(0,$.jsx)(`span`,{className:`min-w-0 max-w-[160px] flex-none truncate font-mono text-xs text-content-muted @max-[560px]:hidden`,title:c,"data-session-project":!0,children:g}),e.botId&&(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Di,{botId:e.botId,part:`settings`})}),r&&(0,$.jsxs)(Y,{type:`button`,variant:`ghost`,className:Lt(`h-7 min-w-7 flex-none gap-1 px-1.5 font-mono text-xs font-normal text-content-muted tabular-nums hover:text-content pointer-coarse:h-11 pointer-coarse:min-w-11`),"aria-haspopup":`dialog`,"aria-label":O,title:O,"aria-keyshortcuts":Yn(x),"data-session-branches":i,onClick:e=>a(`branches`,e.currentTarget),children:[(0,$.jsx)(we,{className:`size-3.5`,"aria-hidden":`true`}),i>0&&(0,$.jsx)(`span`,{"aria-hidden":`true`,children:i})]})]}),d&&(0,$.jsx)(Y,{type:`button`,variant:`ghost`,className:Lt(`h-8 flex-none gap-1.5 px-2 text-[13px] font-normal text-content-secondary hover:text-content pointer-coarse:h-11`,w?``:`w-8 px-0 pointer-coarse:w-11`,d.open&&`bg-surface-hover text-content ring-1 ring-stroke ring-inset`),"data-inspector-toggle":!0,"data-session-changes":y,"aria-controls":d.panelId,"aria-expanded":d.open,"aria-label":E,title:E,"aria-keyshortcuts":Yn(b),onClick:d.toggle,children:w&&v?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(oe,{className:`size-3.5`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{"aria-hidden":`true`,children:l(`board:session.changedFiles`,{count:y})}),(0,$.jsxs)(`span`,{className:`font-mono text-xs text-success tabular-nums`,"aria-hidden":`true`,children:[`+`,v.added??0]}),(0,$.jsxs)(`span`,{className:`font-mono text-xs text-danger tabular-nums`,"aria-hidden":`true`,children:[`−`,v.removed??0]})]}):(0,$.jsx)(nt,{"aria-hidden":`true`})}),f.dialog]})}var ki=`outline-none focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-focus`,Ai={1:`grid-cols-1`,2:`grid-cols-2`,3:`grid-cols-3`};function ji({count:e,children:t}){return(0,$.jsx)(`div`,{className:Lt(`grid gap-2 px-1 pb-2`,Ai[e]??`grid-cols-3`),children:t})}function Mi({icon:e,label:t,className:n,...r}){return(0,$.jsxs)(`button`,{type:`button`,className:Lt(`flex h-[68px] min-w-0 cursor-pointer flex-col items-center justify-center gap-1.5 rounded-[var(--r-md)] bg-surface-muted px-1 text-[13px] text-content active:bg-surface-hover disabled:cursor-default disabled:text-content-faint`,ki,n),...r,children:[(0,$.jsx)(e,{className:`size-5 text-content-secondary`,strokeWidth:1.75,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`max-w-full truncate`,children:t})]})}function Ni({icon:e,label:t,hint:n,trailing:r,className:i,...a}){return(0,$.jsxs)(`button`,{type:`button`,className:Lt(`flex min-h-11 w-full min-w-0 cursor-pointer items-center gap-3 rounded-[var(--r-md)] px-3 text-left text-[15px] text-content active:bg-surface-hover disabled:cursor-default disabled:text-content-faint`,ki,i),...a,children:[(0,$.jsx)(e,{className:`size-[18px] flex-none text-content-secondary`,strokeWidth:1.75,"aria-hidden":`true`}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:t}),n&&(0,$.jsx)(`span`,{className:`truncate text-xs text-content-muted`,children:n})]}),r]})}var Pi=`relative grid size-11 flex-none place-items-center rounded-full bg-surface-muted text-content focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus active:bg-surface-hover dark:bg-surface-active`;function Fi({leading:e,session:t,cwd:n,streaming:r,runStartedAt:i,approvals:a,failed:s,stopped:c,treeAvailable:l,branches:u,onOpenTree:d,...f}){let m=t.machine?`${t.machine.name}:${t.machine.cwd}`:n,{t:h,language:g}=o(),_=(0,Q.useContext)(je),v=(0,Q.useContext)(Me),y=mi(i,r),b=gi(t,f),[x,S]=(0,Q.useState)(!1),C=(0,Q.useId)(),w=t.name||h(`navigation:pageHeader.newChat`),T=yn(t.projectless?``:m,g),E=t.machine?mn(t.machine):T,D=p({queryKey:[`session-change-summary`,t.id,r],queryFn:()=>Bn(t.id),staleTime:1e4}),O=D.data?.status===`known`?D.data.changedFiles??0:0,k=a>0?{kind:`approval`,label:h(`board:status.approval`)}:r?{kind:`running`,label:y===null?h(`board:status.running`):h(`board:phone.running`,{elapsed:xn(y)})}:s?{kind:`failed`,label:h(`board:status.failed`)}:c?{kind:`stopped`,label:h(`board:status.stopped`)}:null,A=()=>_?.show(`changes`),j=[...l?[{key:`tree`,icon:we,label:u>0?h(`board:session.treeBranches`,{count:u}):h(`board:session.tree`),shortLabel:h(`board:session.tree`),onSelect:()=>d(`branches`),marker:`session-tree`}]:[],{key:`side-chat`,icon:tt,label:h(`board:inspector.sideChat`),onSelect:()=>hi(t.id,_),marker:`session-side-chat`},..._?[{key:`inspector`,icon:oe,label:h(`board:phone.openInspector`),shortLabel:h(`board:phone.openInspectorShort`),onSelect:A,marker:`inspector-toggle`}]:[]];return(0,$.jsxs)(`header`,{"data-session-header":`phone`,className:`grid h-14 min-w-0 shrink-0 grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center bg-panel px-3`,children:[(0,$.jsx)(`div`,{className:`flex min-w-0 items-center`,children:e}),(0,$.jsxs)(`button`,{type:`button`,"data-session-menu-trigger":!0,"aria-haspopup":`dialog`,"aria-expanded":x,"aria-controls":x?C:void 0,"aria-label":h(`board:session.titleMenu`,{title:w}),className:`flex h-11 max-w-[min(58vw,260px)] min-w-0 flex-col items-center justify-center rounded-[var(--r-md)] px-2 outline-none focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-focus active:bg-surface-hover`,onClick:()=>S(!0),children:[(0,$.jsxs)(`span`,{className:`flex max-w-full min-w-0 items-center gap-0.5 text-base leading-5 font-semibold text-content`,children:[(0,$.jsx)(`span`,{className:`truncate`,"data-session-title":!0,children:w}),(0,$.jsx)(I,{className:`size-4 flex-none text-content-muted`,"aria-hidden":`true`})]}),(0,$.jsxs)(`span`,{className:`flex max-w-full min-w-0 items-center gap-1 text-xs leading-4 text-content-muted`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate font-mono`,title:m,"data-session-project":!0,children:E}),k&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,$.jsxs)(`span`,{className:Lt(`flex flex-none items-center gap-1`,(k.kind===`approval`||k.kind===`failed`)&&`font-medium text-warning-strong`),"data-session-status":k.kind,children:[(0,$.jsx)(Sn,{status:k.kind===`running`?`run`:k.kind===`stopped`?`stopped`:`attention`,className:`size-3`}),(0,$.jsx)(`span`,{className:`tabular-nums`,children:k.label})]})]})]})]}),(0,$.jsx)(`div`,{className:`flex min-w-0 items-center justify-end`,children:O>0&&_?(0,$.jsxs)(`button`,{type:`button`,"data-session-changes":O,"aria-haspopup":`dialog`,"aria-controls":_.panelId,"aria-label":h(`board:phone.changesLabel`,{count:O}),className:Pi,onClick:A,children:[(0,$.jsx)(oe,{className:`size-5`,strokeWidth:1.75,"aria-hidden":`true`}),(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`absolute top-1.5 right-1 grid h-4 min-w-4 place-items-center rounded-full bg-content px-1 text-[10px] leading-none font-semibold text-panel tabular-nums`,children:O>99?`99+`:O})]}):v?.phone?(0,$.jsx)(`button`,{type:`button`,"data-phone-new-task":!0,"aria-label":h(`navigation:shell.newTask`),className:Pi,onClick:v.phone.onNewTask,children:(0,$.jsx)(J,{className:`size-5`,strokeWidth:1.75,"aria-hidden":`true`})}):null}),(0,$.jsx)(fn,{open:x,onOpenChange:S,children:(0,$.jsxs)(ln,{id:C,side:`bottom`,showCloseButton:!1,"data-session-menu-sheet":!0,className:`max-h-[85dvh] gap-0 rounded-t-(--r-sheet) px-2 pt-1 pb-[calc(8px+var(--pisper-safe-area-bottom))]`,children:[(0,$.jsx)(se,{onDismiss:()=>S(!1)}),(0,$.jsx)(un,{className:`truncate px-3 pt-1 pb-0.5 text-base font-semibold`,children:w}),(0,$.jsx)(dn,{className:`truncate px-3 pb-2 font-mono text-xs text-content-muted`,children:T}),(0,$.jsx)(ji,{count:j.length,children:j.map(e=>{let t=e.marker?{[`data-${e.marker}`]:!0}:{};return(0,$.jsx)(Mi,{icon:e.icon,label:e.shortLabel||e.label,"aria-label":e.label,onClick:()=>{S(!1),e.onSelect()},...t},e.key)})}),(0,$.jsx)(`div`,{className:`min-h-0 overflow-y-auto`,role:`list`,children:b.entries.map(e=>{let t=e.marker?{[`data-${e.marker}`]:!0}:{};return(0,$.jsxs)(`div`,{role:`listitem`,children:[e.separator&&(0,$.jsx)(`div`,{"aria-hidden":`true`,className:`mx-3 my-1 h-px bg-stroke-soft`}),(0,$.jsx)(Ni,{icon:e.icon,label:e.label,disabled:e.disabled,trailing:e.trailing&&(0,$.jsx)(`span`,{className:`flex-none font-mono text-sm text-content-muted tabular-nums`,title:e.trailingTitle,"data-session-context-usage":!0,children:e.trailing}),onClick:()=>{S(!1),e.onSelect()},...t})]},e.key)})})]})}),b.dialog]})}function Ii({cwd:e,selection:t}){let{t:n}=o(),r=D(),i=(0,Q.useRef)(null);return{input:(0,$.jsx)(`input`,{ref:i,type:`file`,className:`hidden`,accept:G,multiple:!0,"aria-label":n(`chat:focusSession.addAttachment`),onChange:e=>{let n=[...e.currentTarget.files||[]];e.currentTarget.value=``,n.length&&t.addFiles(n)}}),choose:async()=>{if(r){i.current?.click();return}if(window.pisperDesktop?.pickFiles){try{let n=await window.pisperDesktop.pickFiles(e);t.addAttachments(q(n||[]))}catch(e){t.setError(e)}return}i.current?.click()}}}function Li({cwd:e,selection:t}){let{t:n}=o(),{input:r,choose:i}=Ii({cwd:e,selection:t});return(0,$.jsxs)($.Fragment,{children:[r,(0,$.jsxs)(`button`,{type:`button`,className:`relative grid size-[30px] min-w-[30px] flex-none cursor-pointer place-items-center rounded-sm border-0 bg-transparent text-content-muted transition-colors hover:bg-surface-hover hover:text-content disabled:cursor-not-allowed disabled:opacity-50 max-[650px]:size-11 max-[650px]:min-w-11 pointer-coarse:size-11 pointer-coarse:min-w-11`,title:n(`chat:focusSession.addAttachment`),"aria-label":n(`chat:focusSession.addAttachment`),onClick:()=>void i(),children:[(0,$.jsx)(rt,{size:16}),t.attachments.length>0&&(0,$.jsx)(`span`,{className:`absolute -top-1 -right-1 grid h-4 min-w-4 place-items-center rounded-full border-2 border-panel bg-star px-0.5 text-[10px] leading-none font-medium text-on-accent tabular-nums`,children:t.attachments.length})]})]})}function Ri({attachments:e,preparing:t=[],onRemove:n,compact:r=!1}){let{t:i}=o();return!e.length&&!t.length?null:(0,$.jsxs)(`div`,{className:`attachment-tray [&.compact]:max-h-[58px] flex max-h-[116px] flex-wrap gap-[6px] overflow-auto ${r?`compact`:``}`,children:[t.map(e=>(0,$.jsxs)(`div`,{className:`flex min-h-[42px] max-w-64 items-center gap-2 rounded-sm border border-stroke bg-surface-subtle pr-1 pl-2.5`,"aria-busy":`true`,children:[(0,$.jsx)(Rt,{className:`size-3.5`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-content`,children:e.name}),(0,$.jsx)(`span`,{className:`sr-only`,children:i(`chat:focusSession.preparingAttachments`)}),(0,$.jsx)(`button`,{type:`button`,className:`grid size-8 shrink-0 cursor-pointer place-items-center rounded-sm text-content-muted hover:bg-danger-soft hover:text-danger max-[650px]:size-11`,"aria-label":i(`chat:focusSession.removeName`,{name:e.name}),onClick:()=>n(e.id),children:(0,$.jsx)(vt,{size:14})})]},e.id)),e.map(e=>(0,$.jsxs)(`div`,{className:`attachment-chip grid min-h-[42px] min-w-[150px] max-w-[250px] grid-cols-[30px_minmax(0,1fr)_auto] items-center gap-2 rounded-sm border border-stroke bg-surface-subtle p-1.5 pr-1 [&_>_button]:grid [&_>_button]:size-7 [&_>_button]:cursor-pointer [&_>_button]:place-items-center [&_>_button]:rounded-xs [&_>_button]:text-content-muted [&_>_button:hover]:bg-danger-soft [&_>_button:hover]:text-danger max-[650px]:[&_>_button]:size-11 [&_>_img]:size-[30px] [&_>_img]:rounded-xs [&_>_img]:object-cover [&_>_span:nth-child(2)]:flex [&_>_span:nth-child(2)]:min-w-0 [&_>_span:nth-child(2)]:flex-col [&_small]:text-xs [&_small]:text-content-muted [&_small]:tabular-nums [&_strong]:truncate [&_strong]:font-mono [&_strong]:text-xs [&_strong]:font-medium [&_strong]:text-content`,children:[e.kind===`image`?(0,$.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:``}):(0,$.jsx)(`span`,{className:`grid size-[30px] place-items-center rounded-xs border border-key-border bg-key text-content-muted`,children:(0,$.jsx)(be,{size:13})}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`strong`,{children:e.name}),(0,$.jsxs)(`small`,{children:[e.kind===`path`?i(`chat:focusSession.localPath`):e.kind===`image`?i(`chat:focusSession.image`):e.kind===`document`?i(`chat:focusSession.document`):i(`chat:focusSession.text`),e.kind===`path`?``:` · ${vn(e.size)}`,e.truncated?` · ${i(`chat:focusSession.truncated`)}`:``]})]}),(0,$.jsx)(`button`,{type:`button`,"aria-label":i(`chat:focusSession.removeName`,{name:e.name}),onClick:()=>n(String(e.id||``)),children:(0,$.jsx)(vt,{size:12})})]},e.id))]})}function zi({open:e,sessionId:t,cwd:n=``,onClose:r,onSelect:i,onCommandSelect:a}){let{t:s}=o(),c=T(e=>e.capabilities),l=w(c,`workflows`),[u,d]=(0,Q.useState)([]),[f,p]=(0,Q.useState)(`all`),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)({}),[b,x]=(0,Q.useState)(!1),[S,E]=(0,Q.useState)(``);(0,Q.useEffect)(()=>{if(!e)return;let r=!0;return p(`all`),h(``),_(null),y({}),x(!0),E(``),Promise.all([t?X.getSessionCommands(t):X.getWorkspaceCommands(n),l?C(`/api/workflows`):Promise.resolve({workflows:[]}),C(`/api/plugins?sessionId=${encodeURIComponent(t)}`)]).then(([e,t,n])=>{if(!r)return;let i=new Set(n.callableToolNames||[]);d([...(e.commands||[]).map(e=>({kind:e.source,id:e.name,name:e.name,description:e.description||``,inputs:[],argumentHint:e.argumentHint,invocation:e.invocation})),...(t.workflows||[]).filter(e=>e.status===`published`).map(e=>({kind:`workflow`,id:e.id,name:e.name,description:e.description||``,inputs:e.inputs||[]})),...(n.plugins||[]).flatMap(e=>(e.capabilities||[]).filter(e=>i.has(e.name)).map(t=>({kind:`tool`,id:t.name,name:t.id?hr(t,s):String(t.label||t.name),description:t.id?gr(t,s):t.description,inputs:[],sourceName:e.name})))])}).catch(e=>{r&&(d([]),E(e instanceof Error?e.message:String(e)))}).finally(()=>r&&x(!1)),()=>{r=!1}},[n,e,t,s,l]);let D=(0,Q.useMemo)(()=>({all:u.length,prompt:u.filter(e=>e.kind===`prompt`).length,skill:u.filter(e=>e.kind===`skill`).length,tool:u.filter(e=>e.kind===`tool`).length,workflow:u.filter(e=>e.kind===`workflow`).length}),[u]),O=(0,Q.useMemo)(()=>{let e=m.trim().toLowerCase();return u.filter(t=>(f===`all`||t.kind===f)&&(!e||`${t.name} ${t.id} ${t.description} ${t.kind===`tool`?t.sourceName:``}`.toLowerCase().includes(e)))},[f,m,u]),k=e=>{let t=e;p(t),g&&t!==`all`&&g.kind!==t&&_(null)},A=e=>{_(e),y(Object.fromEntries(e.inputs.map(e=>[e.name,e.defaultValue??``])))};return(0,$.jsx)(Pn,{open:e,onOpenChange:e=>!e&&r(),children:(0,$.jsxs)(jn,{className:`chat-resource-dialog w-[min(820px,calc(100vw_-_32px))] h-[min(600px,calc(100dvh_-_32px))] max-w-[820px] sm:max-w-[820px] grid-rows-[auto_minmax(0,1fr)] overflow-hidden max-[650px]:w-[calc(100vw_-_16px)] max-[650px]:h-[calc(100dvh_-_16px)] z-[220] gap-0 p-0 ring-0`,overlayClassName:`z-[220]`,showCloseButton:!1,children:[(0,$.jsxs)(`div`,{className:`chat-resource-head flex items-start justify-between gap-4 border-b border-stroke-soft px-[18px] pt-4 pb-3.5 max-[650px]:p-3.5 [&_[data-slot='dialog-description']]:mt-0.5 [&_[data-slot='dialog-description']]:text-xs [&_[data-slot='dialog-description']]:text-content-muted [&_[data-slot='dialog-title']]:text-base [&_[data-slot='dialog-title']]:font-semibold`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Mn,{children:s(`chat:resourcePicker.title`)}),(0,$.jsx)(An,{children:s(`chat:resourcePicker.description`)})]}),(0,$.jsx)(Y,{size:`icon-sm`,variant:`ghost`,"aria-label":s(`chat:resourcePicker.close`),onClick:r,children:(0,$.jsx)(vt,{})})]}),(0,$.jsxs)(`div`,{className:`chat-resource-body grid min-h-0 grid-cols-[minmax(0,1.1fr)_minmax(260px,.9fr)] overflow-hidden max-[650px]:grid-cols-[1fr] max-[650px]:grid-rows-[minmax(0,1fr)_minmax(190px,auto)] max-[650px]:overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`chat-resource-browser flex min-h-0 min-w-0 flex-col border-r border-stroke-soft p-3 max-[650px]:min-h-0 max-[650px]:border-r-0 max-[650px]:border-b`,children:[(0,$.jsx)(jt,{value:f,onValueChange:k,className:`chat-resource-tabs w-full [&_[data-slot='tabs-list']]:grid [&_[data-slot='tabs-list']]:h-9 [&_[data-slot='tabs-list']]:w-full [&_[data-slot='tabs-list']]:rounded-sm [&_[data-slot='tabs-list']]:border [&_[data-slot='tabs-list']]:border-stroke [&_[data-slot='tabs-list']]:bg-surface-muted [&_[data-slot='tabs-list']]:p-0.5 [&_[data-slot='tabs-trigger']]:min-w-0 [&_[data-slot='tabs-trigger']]:gap-1 [&_[data-slot='tabs-trigger']]:rounded-xs [&_[data-slot='tabs-trigger']]:px-1.5 [&_[data-slot='tabs-trigger']]:text-xs [&_[data-slot='tabs-trigger']]:text-content-secondary [&_[data-slot='tabs-trigger'][data-state='active']]:bg-key [&_[data-slot='tabs-trigger'][data-state='active']]:text-content [&_[data-slot='tabs-trigger'][data-state='active']]:shadow-key [&_[data-slot='tabs-trigger']_small]:text-xs [&_[data-slot='tabs-trigger']_small]:font-normal [&_[data-slot='tabs-trigger']_small]:text-content-muted [&_[data-slot='tabs-trigger']_small]:tabular-nums ${l?`[&_[data-slot='tabs-list']]:grid-cols-[repeat(5,minmax(0,1fr))]`:`[&_[data-slot='tabs-list']]:grid-cols-[repeat(4,minmax(0,1fr))]`}`,children:(0,$.jsxs)(At,{"aria-label":s(`chat:resourcePicker.categories`),children:[(0,$.jsxs)(kt,{value:`all`,children:[s(`chat:resourcePicker.all`),(0,$.jsx)(`small`,{children:D.all})]}),(0,$.jsxs)(kt,{value:`prompt`,children:[s(`chat:resourcePicker.prompt`),(0,$.jsx)(`small`,{children:D.prompt})]}),(0,$.jsxs)(kt,{value:`skill`,children:[s(`chat:resourcePicker.skill`),(0,$.jsx)(`small`,{children:D.skill})]}),(0,$.jsxs)(kt,{value:`tool`,children:[s(`chat:resourcePicker.tool`),(0,$.jsx)(`small`,{children:D.tool})]}),l&&(0,$.jsxs)(kt,{value:`workflow`,children:[s(`chat:resourcePicker.workflow`),(0,$.jsx)(`small`,{children:D.workflow})]})]})}),(0,$.jsxs)(Rn,{className:`chat-resource-search mt-2`,children:[(0,$.jsx)(Ln,{children:(0,$.jsx)(ct,{"aria-hidden":`true`})}),(0,$.jsx)(In,{autoFocus:!0,value:m,"aria-label":s(`chat:resourcePicker.search`),onChange:e=>h(e.target.value),placeholder:s(`chat:resourcePicker.search`)})]}),(0,$.jsxs)(`div`,{className:`chat-resource-list mt-2 flex min-h-0 [flex:1_1_0] flex-col gap-px overflow-y-auto [overscroll-behavior:contain] [scrollbar-gutter:stable] [touch-action:pan-y] [&_>_button]:relative [&_>_button]:grid [&_>_button]:w-full [&_>_button]:cursor-pointer [&_>_button]:grid-cols-[28px_minmax(0,1fr)_auto] [&_>_button]:items-center [&_>_button]:gap-2 [&_>_button]:rounded-sm [&_>_button]:px-2 [&_>_button]:py-1.5 [&_>_button]:text-left [&_>_button]:text-content [&_>_button:hover]:bg-surface-hover [&_>_button.active]:bg-surface-hover [&_>_button.active]:before:absolute [&_>_button.active]:before:inset-y-1.5 [&_>_button.active]:before:left-0 [&_>_button.active]:before:w-[3px] [&_>_button.active]:before:rounded-full [&_>_button.active]:before:bg-star max-[650px]:[&_>_button]:min-h-11 [&_button_>_span:nth-child(2)]:flex [&_button_>_span:nth-child(2)]:min-w-0 [&_button_>_span:nth-child(2)]:flex-col [&_strong]:truncate [&_strong]:text-[13px] [&_strong]:font-medium [&_small]:truncate [&_small]:text-xs [&_small]:text-content-muted [&_em]:text-xs [&_em]:whitespace-nowrap [&_em]:text-content-muted [&_em]:not-italic [&_>_p]:m-auto [&_>_p]:text-xs [&_>_p]:text-content-muted`,children:[O.map(e=>{let t=e.kind===`prompt`?K:e.kind===`skill`?P:e.kind===`tool`?_t:gt;return(0,$.jsxs)(`button`,{type:`button`,className:g?.kind===e.kind&&g.id===e.id?`active`:``,onClick:()=>A(e),children:[(0,$.jsx)(`span`,{className:`list-icon grid size-7 place-items-center rounded-sm bg-surface-muted text-content-secondary`,children:(0,$.jsx)(t,{size:15})}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`strong`,{children:e.name}),(0,$.jsx)(`small`,{children:e.description})]}),(0,$.jsx)(`em`,{children:e.kind===`prompt`?s(`chat:resourcePicker.prompt`):e.kind===`skill`?`Skill`:e.kind===`tool`?s(`chat:resourcePicker.tool`):s(`chat:resourcePicker.workflow`)})]},`${e.kind}:${e.id}`)}),!O.length&&(0,$.jsx)(`p`,{children:b?s(`chat:resourcePicker.loading`):S||s(`chat:resourcePicker.empty`)})]})]}),(0,$.jsx)(`div`,{className:`chat-resource-config flex min-h-0 min-w-0 flex-col gap-4 overflow-y-auto overscroll-contain p-[18px] max-[650px]:max-h-[230px] max-[650px]:min-h-0 [&_>_div:first-child]:flex [&_>_div:first-child]:flex-col [&_>_div:first-child]:gap-1 [&_>_p]:m-auto [&_>_p]:text-xs [&_>_p]:text-content-muted [&_p]:text-xs [&_p]:text-content-muted [&_strong]:text-[15px] [&_strong]:font-medium`,children:g?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`strong`,{children:g.name}),(0,$.jsx)(`p`,{children:g.description||s(`chat:resourcePicker.noDescription`)})]}),g.kind===`workflow`&&g.inputs.length>0&&(0,$.jsx)(`div`,{className:`chat-resource-inputs flex flex-col gap-3 [&_label]:grid [&_label]:gap-1.5 [&_label]:text-xs [&_label]:font-medium [&_label]:text-content-secondary`,children:g.inputs.map(e=>(0,$.jsxs)(`label`,{children:[(0,$.jsxs)(`span`,{children:[e.label,e.required?` *`:``]}),e.type===`boolean`?(0,$.jsx)(bt,{checked:!!v[e.name],onCheckedChange:t=>y(n=>({...n,[e.name]:t===!0}))}):(0,$.jsx)(Fn,{type:e.type===`number`?`number`:`text`,required:e.required,value:String(v[e.name]??``),onChange:t=>y(n=>({...n,[e.name]:t.target.value}))})]},e.id))}),g.kind===`prompt`&&g.argumentHint&&(0,$.jsx)(`code`,{className:`w-fit max-w-full rounded-xs bg-inline-code px-1.5 py-1 font-mono text-xs [overflow-wrap:anywhere] text-content-secondary`,children:g.argumentHint}),(0,$.jsx)(Y,{className:`chat-resource-confirm min-h-8 min-w-[112px] self-start bg-star text-[var(--on-accent)] hover:bg-star-hover max-[650px]:min-h-11`,onClick:()=>{if(g){if(g.kind===`prompt`){a(g.invocation||`/${g.name}`),r();return}i({kind:g.kind,resourceId:g.id,resourceName:g.name,arguments:g.kind===`workflow`?v:void 0,behavior:g.kind===`workflow`?`background`:`foreground`}),r()}},children:g.kind===`prompt`?s(`chat:resourcePicker.insertPrompt`):s(`chat:resourcePicker.useResource`)})]}):(0,$.jsx)(`p`,{children:s(`chat:resourcePicker.chooseResource`)})})]})]})})}function Bi(e){let t=e.getHours();return t>=5&&t<11?`morning`:t>=11&&t<13?`noon`:t>=13&&t<18?`afternoon`:t>=18&&t<23?`evening`:`lateNight`}function Vi(e){let t=new Date(e);return t.setHours(e.getHours()+1,0,0,0),Math.max(1e3,t.getTime()-e.getTime())}function Hi(){let{t:e}=o(),[t,n]=(0,Q.useState)(()=>new Date);(0,Q.useEffect)(()=>{let e=window.setTimeout(()=>n(new Date),Vi(t));return()=>window.clearTimeout(e)},[t]);let r=Bi(t),i=e(r===`morning`?`chat:newTask.greetingMorning`:r===`noon`?`chat:newTask.greetingNoon`:r===`afternoon`?`chat:newTask.greetingAfternoon`:r===`evening`?`chat:newTask.greetingEvening`:`chat:newTask.greetingLateNight`);return(0,$.jsxs)(`div`,{className:`grid min-h-full content-center justify-items-center gap-2 text-center max-[650px]:gap-3`,"data-new-task-greeting":!0,children:[(0,$.jsx)(_r,{size:32}),(0,$.jsx)(`h2`,{className:`text-2xl! font-semibold tracking-[-.01em] text-balance text-content max-[650px]:text-xl!`,children:i}),(0,$.jsx)(`p`,{className:`max-w-[46ch] text-sm leading-6 text-content-muted max-[650px]:hidden`,children:e(`board:home.draftHint`)})]})}function Ui({phone:e,leading:t,project:n}){let{t:r}=o();return e?(0,$.jsxs)(`header`,{"data-session-header":`draft`,"data-focus-region":`header`,className:`grid h-14 min-w-0 shrink-0 grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center bg-panel px-3`,children:[(0,$.jsx)(`div`,{className:`flex min-w-0 items-center`,children:t}),(0,$.jsxs)(`div`,{className:`flex max-w-[min(58vw,260px)] min-w-0 flex-col items-center justify-center`,children:[(0,$.jsx)(`h1`,{className:`max-w-full truncate px-1.5 text-base leading-5 font-semibold text-content`,children:r(`board:home.draftTitle`)}),n]}),(0,$.jsx)(`span`,{"aria-hidden":`true`})]}):(0,$.jsxs)(`header`,{"data-session-header":`draft`,"data-focus-region":`header`,"data-window-drag-region":!0,className:`flex h-[52px] min-w-0 shrink-0 items-center gap-2 border-b border-stroke-soft pr-2 pl-4 [[data-custom-titlebar]_&]:pr-[144px]`,children:[t,(0,$.jsx)(`h1`,{className:`flex-none text-[15px] leading-6 font-semibold text-content`,children:r(`board:home.draftTitle`)}),(0,$.jsx)(`span`,{className:`min-w-0 truncate text-xs text-content-muted`,children:r(`board:home.draftSubtitle`)})]})}var Wi=1e3;function Gi({option:e,selected:t,disabled:n,onSelect:r}){let i=e.icon;return(0,$.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t,disabled:n,className:`grid min-h-12 w-full cursor-pointer grid-cols-[16px_minmax(0,1fr)_16px] items-center gap-2.5 rounded-sm px-2 py-1.5 text-left text-content hover:bg-surface-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-focus disabled:cursor-default disabled:opacity-50 disabled:hover:bg-transparent max-[650px]:min-h-14`,"data-mode-option":e.value,onClick:()=>r(e.value),children:[(0,$.jsx)(i,{size:16,strokeWidth:1.75,className:`text-content-secondary`,"aria-hidden":`true`}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-px`,children:[(0,$.jsx)(`span`,{className:Lt(`text-[13px] max-[650px]:text-[15px]`,t&&`font-medium`),children:e.label}),(0,$.jsx)(`small`,{className:`text-xs leading-normal text-content-muted max-[650px]:text-[13px]`,children:e.description})]}),t?(0,$.jsx)(F,{size:15,strokeWidth:2.25,"aria-hidden":`true`}):(0,$.jsx)(`span`,{})]})}function Ki({approvalMode:e,onApprovalModeChange:t,approvalDisabled:n=!1,runMode:r,onRunModeChange:i,runModeDisabled:a=!1,goalsAvailable:s,teamAvailable:c,goal:l,tokenBudget:u,onTokenBudgetChange:d,onSaveTokenBudget:f,sheet:p=!1,collapse:m=!1,open:h,onOpenChange:g}){let{t:_}=o(),[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(!1),S=h??b,C=e=>{h===void 0&&x(e),g?.(e)},w=[{value:`approval-required`,label:_(`chat:focusSession.approvalRequired`),description:_(`chat:focusSession.approvalRequiredShowsADiffBeforeWriting`),icon:zr},{value:`workspace-write`,label:_(`chat:focusSession.workspaceWrite`),description:_(`chat:focusSession.workspaceWriteRunsCommandsWithAutomaticApproval`),icon:Lr},{value:`full-access`,label:_(`chat:focusSession.fullAccess`),description:_(`chat:focusSession.fullAccessRunsShellWithoutPerCommandApproval`),icon:ut}],T=[{value:`plan`,label:_(`board:composer.planShort`),description:_(`chat:focusSession.planModeDescription`),icon:Qe},...s?[{value:`goal`,label:_(`board:composer.goalShort`),description:_(`chat:focusSession.goalModeDescription`),icon:Kr}]:[],...s&&c?[{value:`team`,label:_(`board:composer.teamShort`),description:_(`chat:focusSession.teamModeDescription`),icon:ht}]:[]],E=w.find(t=>t.value===e)||w[0],D=l?.status===`active`?l?.mode===`team`&&c?`team`:`goal`:r,O=T.find(e=>e.value===D)||T[0],k=O.value!==`plan`,A=E.value===`full-access`?ut:Wr,j=O.value===`team`?_(`board:composer.teamShort`):O.value===`goal`?_(`board:composer.goalShort`):``,M=j?`${j} · ${E.label}`:E.label,N=O.value===`plan`&&E.value===`approval-required`,P=!!l?.id,L=D===`team`?l?.teamTokenBudget:l?.tokenBudget,R=L==null?null:Number(L)>0?Number(L):null,z=u!==R,B=P?R==null?_(`chat:focusSession.usedUnlimitedGoalTokens`,{used:bn(l?.tokensUsed)}):_(`chat:focusSession.usedBudgetTokensUsed`,{used:l?.tokensUsed||0,budget:R||0}):``,V=`${_(`board:composer.modeChip`)} · ${M}`,ee=_(D===`team`?`chat:focusSession.teamTokenBudget`:`chat:focusSession.goalTokenBudget`),te=async()=>{if(!(v||!z||!P||!f)){y(!0);try{await f(u)}finally{y(!1)}}};return(0,$.jsxs)(de,{sheet:p,title:_(`board:composer.modeChip`),open:S,onOpenChange:C,align:`start`,side:`top`,className:`composer-mode-popover w-[300px] max-w-[calc(100vw_-_24px)] gap-1 p-1`,trigger:(0,$.jsxs)(`button`,{type:`button`,className:Lt(ae,`composer-mode-chip max-w-[220px] max-[650px]:min-w-9 max-[650px]:justify-center max-[650px]:gap-1`,k?`max-[650px]:px-2.5`:`max-[650px]:px-0`),"aria-label":V,title:V,hidden:m&&!k&&E.value!==`full-access`,"data-composer-mode":`${O.value}:${E.value}`,children:[k&&(0,$.jsx)(O.icon,{size:16,className:`hidden shrink-0 max-[650px]:block`,"aria-hidden":`true`}),(0,$.jsx)(A,{size:14,className:`shrink-0 max-[650px]:size-4`,"aria-hidden":`true`}),!N&&(0,$.jsx)(`span`,{className:`min-w-0 truncate max-[650px]:hidden`,children:M}),(0,$.jsx)(I,{size:14,className:`shrink-0 opacity-70 max-[650px]:hidden`,"aria-hidden":`true`})]}),children:[(0,$.jsxs)(`div`,{role:`radiogroup`,"aria-label":_(`chat:focusSession.approvalMode`),className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(`div`,{className:`px-2 pt-1.5 pb-1 text-xs font-medium text-content-muted`,children:_(`chat:focusSession.approvalMode`)}),w.map(e=>(0,$.jsx)(Gi,{option:e,selected:e.value===E.value,disabled:n,onSelect:e=>{C(!1),t(e)}},e.value))]}),T.length>1&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{role:`separator`,className:`mx-1 h-px bg-stroke-soft`}),(0,$.jsxs)(`div`,{className:`grid gap-1.5 px-2 pt-1.5 pb-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-h-7 items-center justify-between gap-2`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs font-medium text-content-muted`,children:[_(`chat:focusSession.executionMode`),(0,$.jsx)(Bt,{className:`font-normal max-[650px]:hidden pointer-coarse:hidden`,children:`⇧Tab`})]}),(0,$.jsx)(Nt,{size:`sm`,"aria-label":_(`chat:focusSession.executionMode`),value:D,disabled:a,options:T.map(({value:e,label:t})=>({value:e,label:t})),onValueChange:i})]}),(0,$.jsx)(`p`,{className:`text-xs leading-normal text-content-muted max-[650px]:text-[13px]`,children:O.description})]}),(k||P)&&(0,$.jsxs)(`div`,{className:`grid gap-1 px-2 pt-1 pb-1.5 text-xs`,children:[B&&(0,$.jsx)(`p`,{className:`text-content-muted tabular-nums`,children:B}),(0,$.jsxs)(`div`,{className:`grid grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`goal-token-budget-input`,className:`font-medium text-content-secondary`,children:ee}),(0,$.jsx)(Fn,{id:`goal-token-budget-input`,type:`number`,min:Wi,step:1e3,value:u??``,placeholder:_(`chat:focusSession.goalTokenBudgetUnlimited`),"aria-label":ee,disabled:v,className:`text-[13px] tabular-nums`,onChange:e=>{let t=e.target.value.trim();if(!t){d(null);return}let n=Number(t);Number.isFinite(n)&&d(Math.max(Wi,Math.round(n)))}}),P&&z?(0,$.jsxs)(Y,{type:`button`,variant:`outline`,size:`sm`,disabled:v,onClick:()=>void te(),children:[v?(0,$.jsx)(st,{className:`animate-spin`,size:12}):(0,$.jsx)(F,{size:12}),_(`chat:focusSession.goalBudgetSave`)]}):(0,$.jsx)(`span`,{})]}),(0,$.jsx)(`small`,{className:`text-content-muted`,children:_(D===`team`?`chat:focusSession.teamTokenBudgetHint`:P?`chat:focusSession.goalTokenBudgetUpdateHint`:`chat:focusSession.goalTokenBudgetHint`)})]})]})]})}function qi({trigger:e,open:t,onOpenChange:n,onAttachment:r,onResource:i,onVisual:a,steer:s,mode:c}){let{t:l}=o(),u=e=>{n(!1),window.setTimeout(e,0)};return(0,$.jsxs)(de,{sheet:!0,title:l(`board:composer.plusSheetTitle`),open:t,onOpenChange:n,trigger:e,sheetClassName:`px-2`,children:[(0,$.jsxs)(ji,{count:a?3:2,children:[(0,$.jsx)(Mi,{icon:rt,label:l(`board:composer.attachmentShort`),"data-composer-plus-item":`attachment`,onClick:()=>{n(!1),r()}}),(0,$.jsx)(Mi,{icon:P,label:l(`chat:resourcePicker.open`),"data-composer-plus-item":`resource`,onClick:()=>u(i)}),a&&(0,$.jsx)(Mi,{icon:V,label:l(`chat:focusSession.generateImage`),"data-composer-plus-item":`visual`,onClick:()=>u(a)})]}),s&&(0,$.jsx)(Ni,{icon:U,label:l(`board:composer.steerNow`),hint:l(`board:composer.steerHint`),disabled:s.disabled,"data-composer-steer":!0,onClick:()=>u(s.onSelect)}),c&&(0,$.jsx)(Ni,{icon:Wr,label:l(`board:composer.modeChip`),"data-composer-plus-item":`mode`,trailing:(0,$.jsxs)(`span`,{className:`flex flex-none items-center gap-1 text-sm text-content-muted`,children:[c.valueLabel,(0,$.jsx)(R,{className:`size-4`,"aria-hidden":`true`})]}),onClick:()=>u(c.onOpen)})]})}function Ji(e,t){let n=[`plan`];return t.goalsAvailable&&n.push(`goal`),t.goalsAvailable&&t.teamAvailable&&n.push(`team`),n.length<2?null:n[(n.indexOf(e)+1)%n.length]??`plan`}function Yi({state:e,cwd:t,onDismiss:n}){let{t:r}=o(),i=e.status===`streaming`;return(0,$.jsxs)(`section`,{"aria-label":r(`chat:sideQuestion.label`),"aria-busy":i,onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n())},className:`flex max-h-[min(45vh,420px)] min-w-0 flex-col rounded-lg border border-stroke bg-panel shadow-float`,children:[(0,$.jsxs)(`header`,{className:`flex min-w-0 items-start gap-2 border-b border-stroke-soft px-3 py-2`,children:[(0,$.jsx)(Vr,{size:15,"aria-hidden":`true`,className:`mt-0.5 shrink-0 text-content-muted`}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(`span`,{className:`text-xs text-content-muted`,children:r(`chat:sideQuestion.label`)}),(0,$.jsx)(`p`,{className:`m-0 line-clamp-2 text-[13px] text-content`,title:e.question,children:e.question})]}),(0,$.jsx)(Y,{variant:`ghost`,size:`icon-xs`,className:`shrink-0 pointer-coarse:size-11`,"aria-label":r(`chat:sideQuestion.close`),title:r(`chat:sideQuestion.close`),onClick:n,children:(0,$.jsx)(vt,{})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 overflow-y-auto overscroll-contain px-3 py-2 text-[13px]`,children:[e.answer?(0,$.jsx)(Kn,{cwd:t,streaming:i,children:e.answer}):i?(0,$.jsxs)(`p`,{role:`status`,className:`m-0 flex items-center gap-2 text-content-muted`,children:[(0,$.jsx)(Rt,{className:`size-4`}),r(`chat:sideQuestion.answering`)]}):e.status===`done`?(0,$.jsx)(`p`,{className:`m-0 text-content-muted`,children:e.toolCallIgnored?r(`chat:sideQuestion.toolIgnored`):r(`chat:sideQuestion.empty`)}):null,e.status===`error`&&(0,$.jsx)(`p`,{role:`alert`,className:`m-0 mt-1 text-[var(--danger)]`,children:r(`chat:sideQuestion.failed`,{error:e.error})})]}),(0,$.jsx)(`footer`,{className:`border-t border-stroke-soft px-3 py-1.5 text-xs text-content-muted`,children:r(`chat:sideQuestion.note`)})]})}function Xi(e){let[t,n]=(0,Q.useState)(null),r=(0,Q.useRef)(null),i=(0,Q.useCallback)(()=>{r.current?.abort(),r.current=null},[]),a=(0,Q.useCallback)(()=>{i(),n(null)},[i]);return(0,Q.useEffect)(()=>a,[e,a]),{state:t,ask:(0,Q.useCallback)(t=>{i();let a=new AbortController;r.current=a;let o=()=>r.current===a;n({question:t,answer:``,status:`streaming`,error:``,toolCallIgnored:!1}),X.askSideQuestion(e,t,{signal:a.signal,onDelta:e=>{o()&&n(t=>t&&{...t,answer:t.answer+e})}}).then(e=>{o()&&(r.current=null,n(t=>t&&{...t,answer:e.text||t.answer,status:`done`,toolCallIgnored:e.toolCallIgnored}))}).catch(e=>{o()&&(r.current=null,n(t=>t&&{...t,status:`error`,error:e instanceof Error?e.message:String(e)}))})},[i,e]),dismiss:a}}var Zi=new Set([`user`,`assistant`,`summary`,`compaction`,`position`]);function Qi(e,t,n){return t===`labeled`?!!e.label:t===`branches`?n||Zi.has(e.kind):!1}var $i=new Set([`tool`,`tool-call`]);function ea(e){let t=[],n=new Map;for(let r of e){let e=r.parentId?n.get(r.parentId):void 0,i={...r,children:[]};n.set(r.id,i),e?e.children.push(i):t.push(i)}return t}function ta(e){let t=[],n=[...e].reverse();for(;n.length>0;){let e=n.pop();if(e){t.push(e);for(let t=e.children.length-1;t>=0;--t)n.push(e.children[t])}}return t}function na(e,t){let n=[],r=new Map;for(let i of ta(e)){let e=i.parentId&&r.get(i.parentId)||null;if(!t(i)){r.set(i.id,e);continue}let a={...i,children:[]};r.set(i.id,a),e?e.children.push(a):n.push(a)}return n}function ra(e){let t=[e],n=e;for(;n.children.length===1;)n=n.children[0],t.push(n);let r={id:e.id,nodes:t,children:[],active:t.some(e=>e.active)},i=[{segment:r,children:n.children}];for(;i.length>0;){let e=i.pop();if(e)for(let t of e.children){let n=[t],r=t;for(;r.children.length===1;)r=r.children[0],n.push(r);let a={id:t.id,nodes:n,children:[],active:n.some(e=>e.active)};e.segment.children.push(a),i.push({segment:a,children:r.children})}}return r}function ia(e){return e.kind===`user`?Ce:e.kind===`assistant`?N:e.kind===`tool`||e.kind===`tool-call`?_t:e.kind===`settings`?lt:e.kind===`label`?ft:e.kind===`summary`||e.kind===`compaction`?K:e.kind===`position`?Ze:e.label?Rr:tt}function aa({nodes:e,viewportRef:t,selectedId:n,typeLabel:r,stateLabel:i,onSelect:a}){let o=qn({count:e.length,getScrollElement:()=>t.current,estimateSize:()=>64,getItemKey:t=>e[t]?.id??`mobile-tree-node-${t}`,overscan:12,useAnimationFrameWithResizeObserver:!0});return(0,Q.useEffect)(()=>{if(!n)return;let t=e.findIndex(e=>e.id===n);t>=0&&o.scrollToIndex(t,{align:`center`})},[e,n,o]),(0,$.jsx)(`div`,{className:`relative w-full`,style:{height:`${o.getTotalSize()}px`},children:o.getVirtualItems().map(t=>{let o=e[t.index],s=ia(o);return(0,$.jsx)(`div`,{className:`absolute top-0 left-0 w-full px-3 py-1`,style:{transform:`translateY(${t.start}px)`},children:(0,$.jsxs)(`button`,{type:`button`,className:`session-tree-node relative grid items-center gap-2 rounded-sm border border-stroke bg-panel text-left text-content transition-colors duration-(--d-fast) hover:bg-surface-subtle [&.selected]:border-key-border [&.selected]:bg-key [&.selected]:shadow-key [&.selected]:before:absolute [&.selected]:before:inset-y-2 [&.selected]:before:-left-px [&.selected]:before:w-[3px] [&.selected]:before:rounded-r-[3px] [&.selected]:before:bg-star min-h-14 w-full grid-cols-[34px_minmax(0,1fr)_auto] py-2 pr-2.5 pl-1 ${o.id===n?` selected`:``}${o.active?` active`:``}${o.leaf?` leaf`:``}`,"data-kind":o.kind,"data-pisper-tree-entry":o.id,onClick:()=>a(o.id),children:[(0,$.jsx)(`span`,{className:`session-tree-marker relative z-[2] grid size-6 place-items-center justify-self-center rounded-sm bg-surface-muted text-content-secondary [.session-tree-node[data-kind='tool']_&]:bg-warning-soft [.session-tree-node[data-kind='tool']_&]:text-warning-strong [.session-tree-node.leaf_&]:bg-star [.session-tree-node.leaf_&]:text-on-accent [.session-tree-mark.active_&]:bg-star-soft [.session-tree-mark.active_&]:text-star-strong`,children:(0,$.jsx)(s,{size:14})}),(0,$.jsxs)(`span`,{className:`session-tree-node-copy flex min-w-0 flex-col gap-0.5 [&_small]:truncate [&_small]:text-xs [&_small]:text-content-muted [&_strong]:truncate [&_strong]:text-sm [&_strong]:font-medium`,children:[(0,$.jsx)(`strong`,{children:o.label||o.text||r(o)}),(0,$.jsx)(`small`,{children:o.label&&o.text?o.text:r(o)})]}),(0,$.jsxs)(`span`,{className:`session-tree-node-state inline-flex min-w-0 shrink-0 items-center gap-1 text-xs text-content-muted [.session-tree-node.leaf_&]:text-accent-fg`,children:[o.label&&(0,$.jsx)(Rr,{size:12}),i(o)]})]})},t.key)})})}function oa({segment:e,viewportRef:t,selectedId:n,typeLabel:r,stateLabel:i,onSelect:a}){let{nodes:o,children:s}=e,c=o.length>120,l=qn({count:o.length,getScrollElement:()=>t.current,estimateSize:()=>56,getItemKey:e=>o[e]?.id??`tree-node-${e}`,overscan:12,scrollMargin:26,enabled:c,useAnimationFrameWithResizeObserver:!0}),u=e=>{let t=ia(e);return(0,$.jsxs)(`button`,{type:`button`,className:`session-tree-node relative grid items-center gap-2 rounded-sm border border-stroke bg-panel text-left text-content transition-colors duration-(--d-fast) hover:bg-surface-subtle [&.selected]:border-key-border [&.selected]:bg-key [&.selected]:shadow-key [&.selected]:before:absolute [&.selected]:before:inset-y-2 [&.selected]:before:-left-px [&.selected]:before:w-[3px] [&.selected]:before:rounded-r-[3px] [&.selected]:before:bg-star z-[1] min-h-12 w-[220px] cursor-pointer grid-cols-[30px_minmax(0,1fr)_auto] py-1.5 pr-2 pl-0.5 ${e.id===n?` selected`:``}${e.active?` active`:``}${e.leaf?` leaf`:``}`,"data-kind":e.kind,"data-pisper-tree-entry":e.id,onClick:()=>a(e.id),children:[(0,$.jsx)(`span`,{className:`session-tree-marker relative z-[2] grid size-6 place-items-center justify-self-center rounded-sm bg-surface-muted text-content-secondary [.session-tree-node[data-kind='tool']_&]:bg-warning-soft [.session-tree-node[data-kind='tool']_&]:text-warning-strong [.session-tree-node.leaf_&]:bg-star [.session-tree-node.leaf_&]:text-on-accent [.session-tree-mark.active_&]:bg-star-soft [.session-tree-mark.active_&]:text-star-strong`,children:(0,$.jsx)(t,{size:14})}),(0,$.jsxs)(`span`,{className:`session-tree-node-copy flex min-w-0 flex-col gap-0.5 [&_small]:truncate [&_small]:text-xs [&_small]:text-content-muted [&_strong]:truncate [&_strong]:text-sm [&_strong]:font-medium`,children:[(0,$.jsx)(`strong`,{children:e.label||e.text||r(e)}),(0,$.jsx)(`small`,{children:e.label&&e.text?e.text:r(e)})]}),(0,$.jsxs)(`span`,{className:`session-tree-node-state inline-flex min-w-0 shrink-0 items-center gap-1 text-xs text-content-muted [.session-tree-node.leaf_&]:text-accent-fg`,children:[e.label&&(0,$.jsx)(Rr,{size:12}),i(e)]})]},e.id)};return(0,Q.useEffect)(()=>{if(!c||!n)return;let e=o.findIndex(e=>e.id===n);e<0||l.scrollToIndex(e,{align:`center`})},[n,o,c,l]),(0,$.jsxs)(`div`,{className:`session-tree-segment relative flex min-w-[220px] flex-col items-center ${e.active?` active`:``}`,children:[(0,$.jsx)(`div`,{className:`session-tree-track relative z-[1] grid w-[220px] gap-2 before:absolute before:top-[22px] before:bottom-[22px] before:left-1/2 before:z-0 before:w-px before:bg-stroke-strong [.session-tree-segment.active_>_&::before]:bg-control`,children:c?(0,$.jsx)(`div`,{className:`relative w-[220px]`,style:{height:`${l.getTotalSize()}px`},children:l.getVirtualItems().map(e=>(0,$.jsx)(`div`,{className:`absolute top-0 left-0 w-[220px]`,style:{top:`${e.start-26}px`},children:u(o[e.index])},e.key))}):o.map(u)}),s.length>0&&(0,$.jsx)(`div`,{className:`session-tree-children relative flex items-start justify-center pt-7 before:absolute before:top-0 before:left-1/2 before:h-3.5 before:w-px before:bg-stroke-strong [.session-tree-segment.active_>_&::before]:bg-control`,children:s.map(e=>(0,$.jsx)(`div`,{className:`session-tree-child relative flex px-3 pt-3.5 before:absolute before:top-0 before:right-1/2 before:h-3.5 before:w-1/2 before:border-t before:border-stroke-strong after:absolute after:top-0 after:left-1/2 after:h-3.5 after:w-1/2 after:border-t after:border-l after:border-stroke-strong [&:first-child::before]:border-t-transparent [&:last-child::after]:border-t-transparent [&.active]:before:border-control [&.active]:after:border-control [&.active:first-child::before]:border-t-transparent [&.active:last-child::after]:border-t-transparent${e.active?` active`:``}`,children:(0,$.jsx)(oa,{segment:e,viewportRef:t,selectedId:n,typeLabel:r,stateLabel:i,onSelect:a})},e.id))})]})}function sa({view:e,onViewChange:t,showAllEntries:n,onShowAllEntriesChange:r,query:i,onQueryChange:a,loading:s,error:c,mobileLayout:l,viewportRef:u,segments:d,visibleNodes:f,selectedId:p,typeLabel:m,stateLabel:h,onSelect:g,visibleMarks:_,marksLoading:v,openingMark:y,onOpenMark:b,confirmingMark:x,onConfirmMark:S,onCancelMark:C}){let{t:w,language:T}=o(),E=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{x&&E.current?.focus()},[x]);let D=e=>{let t=Date.parse(e);return Number.isFinite(t)?new Intl.DateTimeFormat(T,{dateStyle:`medium`,timeStyle:`short`}).format(t):w(`navigation:appOverlays.unknownTime`)};return(0,$.jsxs)(`div`,{className:`chat-resource-browser flex min-h-0 min-w-0 flex-col bg-transparent session-tree-browser`,children:[(0,$.jsx)(jt,{className:`chat-resource-tabs session-tree-tabs px-3 pt-3`,value:e,onValueChange:e=>t(e),children:(0,$.jsxs)(At,{children:[(0,$.jsx)(kt,{value:`branches`,children:w(`chat:sessionTree.branches`)}),(0,$.jsx)(kt,{value:`labeled`,children:w(`chat:sessionTree.labeled`)}),(0,$.jsx)(kt,{value:`marks`,children:w(`chat:sessionTree.allMarks`)})]})}),(0,$.jsxs)(Rn,{className:`chat-resource-search mx-3 mt-2 w-auto flex-none`,children:[(0,$.jsx)(Ln,{children:(0,$.jsx)(ct,{"aria-hidden":`true`})}),(0,$.jsx)(In,{value:i,disabled:!!y,"aria-label":w(`chat:sessionTree.searchPlaceholder`),onChange:e=>a(e.target.value),placeholder:w(`chat:sessionTree.searchPlaceholder`)})]}),e===`branches`&&(0,$.jsxs)(`label`,{className:`mx-3 mt-2 flex min-h-6 flex-none cursor-pointer items-center gap-2 text-xs text-content-secondary max-[650px]:min-h-11`,children:[(0,$.jsx)(bt,{checked:n,onCheckedChange:e=>r(e===!0),"data-session-tree-all-entries":!0}),w(`chat:sessionTree.showAllEntries`)]}),e===`marks`?(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 basis-0 flex-col gap-2 overflow-auto overscroll-contain px-3.5 py-3`,"data-testid":`session-tree-marks-list`,children:[c&&(0,$.jsx)(`p`,{role:`alert`,className:`mx-0.5 text-xs text-danger`,children:c}),v?(0,$.jsx)(`p`,{className:`grid min-h-[180px] place-items-center text-xs text-content-muted`,children:w(`chat:sessionTree.loadingMarks`)}):_.length?_.map(e=>(0,$.jsxs)(Q.Fragment,{children:[(0,$.jsxs)(`button`,{type:`button`,className:`session-tree-mark grid cursor-pointer grid-cols-[30px_minmax(0,1fr)_auto] items-center gap-2 rounded-sm border border-stroke bg-panel py-2 pr-2.5 pl-1 text-left text-content transition-colors duration-(--d-fast) hover:bg-surface-subtle [&.active]:border-star-border [&_>_em]:rounded-xs [&_>_em]:bg-star-soft [&_>_em]:px-1.5 [&_>_em]:py-0.5 [&_>_em]:text-xs [&_>_em]:text-star-strong [&_>_em]:not-italic ${e.active?` active`:``}`,"aria-expanded":e.active?void 0:x===e,"data-session-tree-mark":e.active?`active`:`other-branch`,disabled:!!y,"aria-busy":y===e,onClick:()=>b(e),children:[(0,$.jsx)(`span`,{className:`session-tree-marker relative z-[2] grid size-6 place-items-center justify-self-center rounded-sm bg-surface-muted text-content-secondary [.session-tree-node[data-kind='tool']_&]:bg-warning-soft [.session-tree-node[data-kind='tool']_&]:text-warning-strong [.session-tree-node.leaf_&]:bg-star [.session-tree-node.leaf_&]:text-on-accent [.session-tree-mark.active_&]:bg-star-soft [.session-tree-mark.active_&]:text-star-strong`,children:y===e?(0,$.jsx)(Rt,{className:`size-3.5`}):(0,$.jsx)(ft,{size:14})}),(0,$.jsxs)(`span`,{className:`session-tree-node-copy flex min-w-0 flex-col gap-0.5 [&_small]:truncate [&_small]:text-xs [&_small]:text-content-muted [&_strong]:truncate [&_strong]:text-sm [&_strong]:font-medium`,children:[(0,$.jsx)(`strong`,{children:e.label}),(0,$.jsx)(`small`,{children:e.sessionName||w(`navigation:appOverlays.untitledChat`)}),(0,$.jsx)(`small`,{children:w(`chat:sessionTree.markTimes`,{sessionTime:D(e.sessionModified),nodeTime:D(e.nodeTimestamp)})})]}),y===e?(0,$.jsx)(`em`,{children:w(`chat:sessionTree.navigating`)}):e.active&&(0,$.jsx)(`em`,{children:w(`chat:sessionTree.markActive`)})]}),x===e&&(0,$.jsxs)(`div`,{role:`group`,"aria-label":w(`chat:sessionTree.otherBranchTitle`),className:`-mt-1 grid gap-2 rounded-sm border border-stroke bg-surface-subtle p-2.5 text-xs text-content-secondary`,"data-session-tree-mark-confirm":!0,children:[(0,$.jsxs)(`p`,{className:`flex items-start gap-1.5 text-content`,children:[(0,$.jsx)(we,{size:13,className:`mt-0.5 flex-none`,"aria-hidden":`true`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`strong`,{className:`font-medium`,children:w(`chat:sessionTree.otherBranchTitle`)}),(0,$.jsx)(`span`,{className:`block text-content-muted`,children:w(`chat:sessionTree.otherBranchMessage`)})]})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(Y,{type:`button`,size:`sm`,variant:`ghost`,className:`max-[650px]:h-11`,onClick:C,children:w(`common:ui.cancel`)}),(0,$.jsx)(Y,{ref:E,type:`button`,size:`sm`,className:`max-[650px]:h-11`,onClick:()=>S(e),children:w(`chat:sessionTree.switchBranch`)})]})]})]},`${e.sessionId}:${e.entryId}`)):(0,$.jsx)(`p`,{className:`grid min-h-[180px] place-items-center text-xs text-content-muted`,children:w(`chat:sessionTree.noMarksYet`)})]}):(0,$.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 basis-0 overflow-auto overscroll-contain [scrollbar-gutter:stable]`,"data-testid":`session-tree-list`,ref:u,children:d.length>0?l?(0,$.jsx)(aa,{nodes:f,viewportRef:u,selectedId:p,typeLabel:m,stateLabel:h,onSelect:g}):(0,$.jsx)(`div`,{className:`session-tree-canvas flex w-max min-w-full items-start justify-center gap-9 px-7 pt-6.5 pb-12`,children:d.map(e=>(0,$.jsx)(oa,{segment:e,viewportRef:u,selectedId:p,typeLabel:m,stateLabel:h,onSelect:g},e.id))}):(0,$.jsx)(`p`,{className:`grid min-h-[180px] place-items-center text-xs text-content-muted`,children:s?w(`chat:sessionTree.loading`):c||w(`chat:sessionTree.empty`)})})]})}function ca({label:e,onClick:t}){return(0,$.jsxs)(Y,{variant:`secondary`,className:`w-full min-w-0`,title:e,onClick:t,children:[(0,$.jsx)(tt,{size:13}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:e})]})}function la({mobileLayout:e,selected:t,loading:n,error:r,streaming:i,dataStreaming:a,parentSession:s,parentEntryId:c,childSessions:l,canLabel:u,canDerive:d,label:f,summarize:p,savingLabel:m,creatingChild:h,navigating:g,typeLabel:_,stateLabel:v,onBackToList:y,onLabelChange:b,onSummarizeChange:x,onSaveLabel:S,onRemoveLabel:C,onCreateChild:w,onNavigate:T,onRefresh:E,onOpenRelated:D}){let{t:O,language:k}=o();return(0,$.jsxs)(`div`,{className:`chat-resource-config session-tree-inspector flex min-h-0 min-w-0 flex-col gap-4 overflow-y-auto overscroll-contain bg-panel p-[18px] [&_>_p]:m-auto [&_>_p]:text-xs [&_>_p]:text-content-muted [&_p]:text-xs [&_p]:text-content-muted [&_strong]:text-[15px] [&_strong]:font-medium ${e?``:`border-l border-stroke-soft`}`,children:[e&&(0,$.jsx)(`div`,{className:`sticky top-0 z-[2] -mx-1.5 -mt-2 flex border-b border-stroke-soft bg-panel px-0.5 pb-2`,children:(0,$.jsxs)(Y,{variant:`ghost`,className:`min-h-11 justify-start px-2`,onClick:y,children:[(0,$.jsx)(L,{size:17}),O(`chat:sessionTree.backToNodes`)]})}),t?(0,$.jsxs)($.Fragment,{children:[(s||l.length>0)&&(0,$.jsxs)(`div`,{className:`session-tree-lineage flex flex-col gap-1.5 border-b border-stroke-soft pb-3 [&_>_strong]:text-xs [&_>_strong]:font-medium [&_>_strong]:text-content-muted [&_button]:justify-start [&_button]:text-left [&_button]:text-xs`,children:[(0,$.jsx)(`strong`,{children:O(`chat:sessionTree.conversationLineage`)}),s&&(0,$.jsx)(ca,{label:O(`chat:sessionTree.returnToOriginalChat`,{name:s.name||O(`chat:chatPage.newChat`)}),onClick:()=>D(s,c)}),l.map(e=>(0,$.jsx)(ca,{label:O(`chat:sessionTree.openSeparateChat`,{name:e.name||O(`chat:chatPage.newChat`)}),onClick:()=>D(e)},e.id))]}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`span`,{className:`session-tree-selection-kind mb-1 flex items-center justify-between gap-2 text-xs text-content-muted [&_em]:rounded-xs [&_em]:border [&_em]:border-star-border [&_em]:bg-star-soft [&_em]:px-1.5 [&_em]:py-0.5 [&_em]:font-medium [&_em]:text-star-strong [&_em]:not-italic`,children:[_(t),v(t)&&(0,$.jsx)(`em`,{children:v(t)})]}),(0,$.jsx)(`strong`,{children:t.label||_(t)}),(0,$.jsx)(`p`,{children:t.text||O(`chat:sessionTree.noPreview`)})]}),(0,$.jsxs)(`div`,{className:`chat-resource-inputs flex flex-col gap-3 [&_label]:grid [&_label]:gap-1.5 [&_label]:text-xs [&_label]:font-medium [&_label]:text-content-secondary`,children:[u&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{children:[(0,$.jsx)(`span`,{children:O(`chat:sessionTree.nodeLabel`)}),(0,$.jsx)(Fn,{value:f,maxLength:80,placeholder:O(`chat:sessionTree.labelPlaceholder`),onChange:e=>b(e.target.value)})]}),(0,$.jsxs)(Y,{variant:`secondary`,disabled:m||i||a,onClick:S,children:[(0,$.jsx)(ft,{size:14}),O(m?`chat:sessionTree.savingLabel`:`chat:sessionTree.saveLabel`)]}),!!t.label&&(0,$.jsxs)(Y,{variant:`secondary`,disabled:m||i||a,onClick:C,children:[(0,$.jsx)(pt,{size:14}),O(`chat:sessionTree.removeLabel`)]})]}),u&&(0,$.jsxs)(Y,{variant:`secondary`,disabled:h||i||a,onClick:w,children:[(0,$.jsx)(Se,{size:14}),O(h?`chat:sessionTree.creatingChildChat`:`chat:sessionTree.createChildChat`)]}),d&&(0,$.jsxs)(`label`,{className:`session-tree-summary-option cursor-pointer grid-cols-[minmax(0,1fr)_auto] items-center [&_small]:col-span-full [&_small]:leading-relaxed [&_small]:font-normal [&_small]:text-content-muted`,children:[(0,$.jsx)(`span`,{children:O(`chat:sessionTree.abandonedBranchSummary`)}),(0,$.jsx)(Ot,{checked:p,disabled:t.leaf||i||a,onCheckedChange:x,"data-session-tree-summary":!0}),(0,$.jsx)(`small`,{children:O(`chat:sessionTree.abandonedBranchSummaryHint`)})]})]}),d&&(0,$.jsx)(`p`,{children:O(`chat:sessionTree.sideEffectsRemain`)}),t.timestamp&&(0,$.jsx)(`p`,{children:new Intl.DateTimeFormat(k,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(t.timestamp))}),r&&(0,$.jsx)(`p`,{role:`alert`,className:`text-danger!`,children:r}),d&&(0,$.jsxs)(Y,{className:`chat-resource-confirm self-start`,disabled:g||t.leaf||i||a,onClick:T,children:[(0,$.jsx)(Ze,{size:15}),g?O(`chat:sessionTree.navigating`):t.leaf?O(`chat:sessionTree.currentPosition`):O(`chat:sessionTree.continueFromNode`)]})]}):(0,$.jsx)(`p`,{children:n?O(`chat:sessionTree.loading`):r||O(`chat:sessionTree.chooseNode`)}),r&&!t&&(0,$.jsx)(Y,{variant:`secondary`,onClick:E,children:O(`chat:sessionTree.retry`)})]})}function ua({open:e,sessionId:t,streaming:n,onClose:r,onNavigated:i,onCreateChildSession:a,initialView:s=`branches`,returnFocusRef:c,notify:l}){let{t:u,language:d}=o(),f=D(),p=E(),m=f||p,[h,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)([]),[y,b]=(0,Q.useState)(`branches`),[x,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(`list`),[T,O]=(0,Q.useState)(``),[k,A]=(0,Q.useState)(``),[j,M]=(0,Q.useState)(``),[N,P]=(0,Q.useState)([]),[F,I]=(0,Q.useState)(!1),[L,R]=(0,Q.useState)(!1),[z,B]=(0,Q.useState)(null),[V,ee]=(0,Q.useState)(null),[te,ne]=(0,Q.useState)(!1),[re,H]=(0,Q.useState)(!1),[ie,ae]=(0,Q.useState)(!1),[U,W]=(0,Q.useState)(!1),[oe,se]=(0,Q.useState)(!1),[ce,G]=(0,Q.useState)(``),le=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(!e||!t)return;let n=!1;return b(s),w(`list`),O(``),H(!0),G(``),Promise.all([X.getSessionTree(t),X.listSessions()]).then(([e,t])=>{n||(g(e),v(t.sessions||[]),A(e.leafId||e.nodes[0]?.id||``))}).catch(e=>{n||G(Z(e))}).finally(()=>{n||H(!1)}),()=>{n=!0}},[e,t]),(0,Q.useEffect)(()=>{e||(g(null),v([]),A(``),w(`list`),M(``),B(null),ee(null),ne(!1),G(``))},[e]),(0,Q.useEffect)(()=>{if(!e||y!==`marks`||F)return;let t=!0;return R(!0),G(``),X.listSessionTreeLabels(500).then(e=>{t&&(P(e.labels||[]),I(!0))}).catch(e=>t&&G(Z(e))).finally(()=>t&&R(!1)),()=>{t=!1}},[e,y,F]);let K=(0,Q.useMemo)(()=>{let e=T.trim().toLocaleLowerCase(d);return e?N.filter(t=>`${t.label} ${t.sessionName}`.toLocaleLowerCase(d).includes(e)):N},[N,d,T]),ue=async(e,t=!1)=>{if(!z){if(!e.active&&!t){ee(e);return}ee(null),B(e),G(``);try{let t=null;if(!e.active){if(t=await X.navigateSessionTreeTarget(e.sessionId,e.entryId),t.cancelled){B(null);return}yr(e.sessionId)}en(e.sessionId,`open`,e.entryId),r(),t&&l&&wr(e.sessionId,t,u(`chat:sessionTree.switchedBranch`),{notify:l,t:u})}catch(e){G(Z(e)),B(null)}}},de=(0,Q.useMemo)(()=>ea(h?.nodes||[]),[h]),fe=(0,Q.useCallback)(e=>({user:u(`chat:sessionTree.userMessage`),assistant:u(`chat:sessionTree.agentMessage`),tool:u(`chat:sessionTree.toolResult`),"tool-call":u(`chat:sessionTree.toolCall`),summary:u(`chat:sessionTree.branchSummary`),compaction:u(`chat:sessionTree.compactionSummary`),settings:u(`chat:sessionTree.settingsChange`),label:u(`chat:sessionTree.labelChange`),position:u(`chat:sessionTree.branchPosition`),extension:u(`chat:sessionTree.extensionEntry`),metadata:u(`chat:sessionTree.metadataEntry`),message:u(`chat:sessionTree.message`)})[e.kind]||e.type,[u]),pe=(0,Q.useMemo)(()=>{let e=T.trim().toLocaleLowerCase(d);return na(de,t=>Qi(t,y,x)?!e||`${t.label} ${t.text} ${fe(t)}`.toLocaleLowerCase(d).includes(e):!1)},[de,d,T,x,fe,y]),me=(0,Q.useMemo)(()=>pe.map(ra),[pe]),he=(0,Q.useMemo)(()=>ta(pe),[pe]),q=(0,Q.useMemo)(()=>ta(de),[de]).find(e=>e.id===k)||null,ge=h?.lineage?.parentSessionId?_.find(e=>e.id===h.lineage?.parentSessionId):null,_e=(h?.lineage?.childSessionIds||[]).map(e=>_.find(t=>t.id===e)).filter(e=>!!e),ve=q?.kind===`assistant`&&q.status===`completed`,ye=ve,be=q?!$i.has(q.kind):!1;(0,Q.useEffect)(()=>{M(q?.label||``),ne(!1)},[q?.id,q?.label]),(0,Q.useEffect)(()=>{if(k&&he.some(e=>e.id===k))return;let e=[...he].reverse().find(e=>e.active);A(e?.id||he[0]?.id||``)},[k,he]),(0,Q.useEffect)(()=>{if(!e||!k)return;let t=requestAnimationFrame(()=>{document.querySelector(`[data-testid="session-tree-list"] .session-tree-node.selected`)?.scrollIntoView({block:`center`})});return()=>cancelAnimationFrame(t)},[e,T,k,y,he.length]);let xe=async()=>{H(!0),G(``);try{let e=await X.getSessionTree(t);g(e),A(e.leafId||e.nodes[0]?.id||``)}catch(e){G(Z(e))}finally{H(!1)}},Se=async()=>{if(!(!q||ie)){ae(!0),G(``);try{let e=await X.setSessionTreeLabel(t,q.id,j);g(e),xr(t,e)}catch(e){G(Z(e))}finally{ae(!1)}}},Ce=async()=>{if(!(!q||ie)){ae(!0),G(``);try{let e=await X.setSessionTreeLabel(t,q.id,``);g(e),xr(t,e)}catch(e){G(Z(e))}finally{ae(!1)}}},Te=async()=>{if(!(!q||!ye||oe)){se(!0),G(``);try{await a(q.id),r()}catch(e){G(Z(e))}finally{se(!1)}}},Ee=(e,t=``)=>{e.id&&(en(e.id,`open`,t),r())},De=async()=>{if(!(!q||U||q.leaf||n||h?.streaming)){W(!0),G(``);try{let e=await X.navigateSessionTree(t,q.id,te);g(e),e.cancelled||(xr(t,e),await i(e.editorText),r(),l&&wr(t,e,u(`chat:chatPage.branchedFromNode`),{notify:l,t:u}))}catch(e){G(Z(e))}finally{W(!1)}}},Oe=e=>e.leaf?u(`chat:sessionTree.current`):e.branchPoint?u(`chat:sessionTree.fork`):e.active?u(`chat:sessionTree.active`):``;return(0,$.jsx)(Pn,{open:e,onOpenChange:e=>!e&&r(),children:(0,$.jsxs)(jn,{onCloseAutoFocus:e=>{let n=c?.current,r=n?.isConnected?n:document.getElementById(`task-${t}-more`);r?.closest(`[data-task-workspace]`)?.getAttribute(`data-active`)===`true`&&(e.preventDefault(),r.focus())},className:`chat-resource-dialog session-tree-dialog grid-rows-[auto_minmax(0,1fr)] gap-0 overflow-hidden border border-stroke bg-solid p-0 ${m?`!h-[calc(100dvh_-_16px)] !w-[calc(100vw_-_16px)] !max-w-none`:`!h-[min(760px,calc(100dvh_-_32px))] !w-[min(1120px,calc(100vw_-_32px))] !max-w-[1120px]`}`,showCloseButton:!1,children:[(0,$.jsxs)(`div`,{className:`chat-resource-head flex items-start justify-between gap-4 border-b border-stroke-soft px-[18px] pt-4 pb-3.5 max-[650px]:p-3.5 [&_[data-slot='dialog-description']]:mt-0.5 [&_[data-slot='dialog-description']]:text-xs [&_[data-slot='dialog-description']]:text-content-muted [&_[data-slot='dialog-title']]:text-base [&_[data-slot='dialog-title']]:font-semibold`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`session-tree-title flex items-center gap-2`,children:[(0,$.jsx)(we,{className:`size-4 text-content-muted`,strokeWidth:1.75,"aria-hidden":`true`}),(0,$.jsx)(Mn,{children:u(`chat:sessionTree.title`)})]}),(0,$.jsx)(An,{children:u(`chat:sessionTree.description`,{nodes:h?.nodeCount||0,branches:h?.branchCount||0})})]}),(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,className:`max-[650px]:size-11`,"aria-label":u(`common:ui.closeDialog`),title:u(`common:ui.closeDialog`),onClick:r,children:(0,$.jsx)(vt,{size:16})})]}),(0,$.jsxs)(`div`,{className:`chat-resource-body session-tree-layout grid min-h-0 overflow-hidden bg-background ${m?`grid-cols-1 grid-rows-[minmax(0,1fr)]`:`!grid-cols-[minmax(0,1fr)_292px]`}`,children:[(!m||C===`list`)&&(0,$.jsx)(sa,{view:y,onViewChange:e=>{b(e),ee(null),w(`list`)},showAllEntries:x,onShowAllEntriesChange:S,query:T,onQueryChange:O,loading:re,error:ce,mobileLayout:m,viewportRef:le,segments:me,visibleNodes:he,selectedId:k,typeLabel:fe,stateLabel:Oe,onSelect:e=>{A(e),m&&w(`detail`)},visibleMarks:K,marksLoading:L,openingMark:z,onOpenMark:e=>void ue(e),confirmingMark:V,onConfirmMark:e=>void ue(e,!0),onCancelMark:()=>ee(null)}),y!==`marks`&&(!m||C===`detail`)&&(0,$.jsx)(la,{mobileLayout:m,selected:q,loading:re,error:ce,streaming:n,dataStreaming:!!h?.streaming,parentSession:ge??null,parentEntryId:h?.lineage?.sourceEntryId||``,childSessions:_e,canLabel:ve,canDerive:be,label:j,summarize:te,savingLabel:ie,creatingChild:oe,navigating:U,typeLabel:fe,stateLabel:Oe,onBackToList:()=>w(`list`),onLabelChange:M,onSummarizeChange:ne,onSaveLabel:()=>void Se(),onRemoveLabel:()=>void Ce(),onCreateChild:()=>void Te(),onNavigate:()=>void De(),onRefresh:()=>void xe(),onOpenRelated:(e,t)=>Ee(e,t??``)})]})]})})}function da({visible:e,open:t,sessionId:n,streaming:r,revision:i,pulseToken:a,onOpenChange:s,onNavigated:c,onCreateChildSession:l,notify:u,children:d}){let{t:f}=o(),p=vr(n,{enabled:e,streaming:r,revision:i})?.branchCount??0,[m,h]=(0,Q.useState)(`branches`),[g,_]=(0,Q.useState)(!1),v=(0,Q.useRef)(0),y=(0,Q.useRef)(null);(0,Q.useEffect)(()=>()=>cancelAnimationFrame(v.current),[]),(0,Q.useEffect)(()=>{if(!a)return;_(!0);let e=window.setTimeout(()=>_(!1),1800);return()=>window.clearTimeout(e)},[a]);let b=p>0&&(0,$.jsx)(`i`,{"aria-hidden":`true`,className:`ml-auto size-1.5 rounded-full bg-star`}),x=e?(0,$.jsxs)(St,{"aria-label":f(`chat:sessionTree.menu`),"aria-haspopup":`dialog`,"data-pisper-recall-pulse":g||void 0,onSelect:()=>{y.current=null,h(`branches`),cancelAnimationFrame(v.current),v.current=requestAnimationFrame(()=>s(!0))},children:[(0,$.jsx)(we,{className:g?`motion-reduce:animate-none [animation:session-tree-new-node-pulse_1.8s_var(--ease-out)]`:void 0}),f(`chat:sessionTree.menu`),b]}):null;return(0,$.jsxs)($.Fragment,{children:[d(x,{branches:p,open:(e=`branches`,t=null)=>{y.current=t,h(e),cancelAnimationFrame(v.current),v.current=requestAnimationFrame(()=>s(!0))}}),e&&(0,$.jsx)(ua,{open:t,initialView:m,returnFocusRef:y,sessionId:n,streaming:r,onClose:()=>s(!1),onNavigated:c,onCreateChildSession:l,notify:u})]})}function fa({question:e,more:t,collapsed:n,onAnswer:r}){let{t:i}=o(),[a,s]=(0,Q.useState)(()=>e.questions.map(()=>({selected:[]}))),[c,l]=(0,Q.useState)(()=>e.questions.map(()=>!1)),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(``),m=e.questions.length===1&&!e.questions[0].multiSelect,h=gn(e,a);if(n)return(0,$.jsxs)(`p`,{"data-question-more":!0,className:`flex min-h-8 min-w-0 items-center gap-2 rounded-(--r-md) border border-st-attn-border px-3 text-xs text-st-attn`,children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 flex-none rounded-full bg-st-attn-fill`}),i(`board:question.waiting`,{count:t+1})]});let g=async t=>{if(!u){d(!0),p(``);try{await r(e.id,t)}catch{p(i(`board:question.failed`)),d(!1)}}},_=e=>e.map((e,t)=>{let n=c[t]?e.other?.trim():``;return n?{selected:e.selected,other:n}:{selected:e.selected}}),v=(t,n)=>{let r=e.questions[t],i=a.map((e,i)=>{if(i!==t)return e;if(!r.multiSelect)return{...e,selected:[n]};let a=e.selected.includes(n)?e.selected.filter(e=>e!==n):[...e.selected,n];return{...e,selected:a}});s(i),m&&g({answers:_(i)})};return(0,$.jsxs)(`div`,{"data-question-card":e.id,role:`group`,"aria-label":i(`board:question.label`),"aria-busy":u||void 0,onKeyDown:t=>{if(t.altKey||t.metaKey||t.ctrlKey)return;let n=t.target;if(n.closest(`textarea, input`))return;let r=a.findIndex(e=>!e.selected.length&&!e.other?.trim()),i=r<0?e.questions.length-1:r,o=Number(t.key);if(Number.isInteger(o)&&o>=1&&o<=6){let n=e.questions[i]?.options[o-1];if(!n)return;t.preventDefault(),v(i,n.label)}else t.key===`Enter`&&!n.closest(`button`)&&h&&(t.preventDefault(),g({answers:_(a)}))},className:`flex max-h-[min(60vh,560px)] min-w-0 flex-col gap-3 overflow-y-auto rounded-(--r-lg) border border-st-attn-border bg-st-attn-soft px-3.5 py-3 text-foreground`,children:[(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-xs font-medium text-warning-strong`,children:[(0,$.jsx)(Vr,{className:`size-4 flex-none`,"aria-hidden":`true`}),i(`board:question.title`),t>0&&(0,$.jsx)(`span`,{className:`font-normal text-content-muted`,children:i(`board:question.moreAfter`,{count:t})})]}),e.questions.map((t,n)=>{let r=a[n],o=t.header?`${t.header}:${t.question}`:t.question;return(0,$.jsxs)(`fieldset`,{"data-question-item":n,className:`flex min-w-0 flex-col gap-1.5`,children:[(0,$.jsxs)(`legend`,{className:`mb-1.5 flex min-w-0 flex-col gap-0.5`,children:[t.header&&(0,$.jsx)(`span`,{className:`text-xs font-medium text-content-muted`,children:t.header}),(0,$.jsx)(`span`,{className:`text-sm leading-5 text-content`,children:t.question})]}),(0,$.jsxs)(`div`,{role:t.multiSelect?`group`:`radiogroup`,"aria-label":o,className:`flex flex-wrap gap-1.5`,children:[t.options.map((e,i)=>{let a=r.selected.includes(e.label);return(0,$.jsxs)(`button`,{type:`button`,role:t.multiSelect?`checkbox`:`radio`,"aria-checked":a,disabled:u,"data-question-option":e.label,title:e.description||void 0,className:Lt(`flex min-h-9 max-w-full min-w-0 items-center gap-1.5 rounded-(--r-md) border px-2.5 py-1 text-left text-[13px] transition-colors duration-(--d-fast) focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-focus disabled:opacity-60 pointer-coarse:min-h-11`,a?`border-content bg-content text-panel`:`border-stroke-strong bg-panel text-content hover:bg-surface-hover`),onClick:()=>v(n,e.label),children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`font-mono text-[11px] opacity-60 pointer-coarse:hidden`,children:i+1}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,$.jsx)(`span`,{className:`break-words`,children:e.label}),e.description&&(0,$.jsx)(`span`,{className:Lt(`text-xs break-words`,a?`opacity-80`:`text-content-muted`),children:e.description})]}),a&&t.multiSelect&&(0,$.jsx)(F,{className:`size-3.5 flex-none`,"aria-hidden":`true`})]},e.label)}),(0,$.jsx)(`button`,{type:`button`,"aria-expanded":c[n],disabled:u,"data-question-other":n,className:Lt(`flex min-h-9 items-center rounded-(--r-md) border border-dashed border-stroke-strong px-2.5 text-[13px] text-content-secondary hover:bg-surface-hover focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-focus pointer-coarse:min-h-11`,c[n]&&`border-solid bg-panel`),onClick:()=>l(e=>e.map((e,t)=>t===n?!e:e)),children:i(`board:question.other`)})]}),c[n]&&(0,$.jsx)(`textarea`,{"aria-label":i(`board:question.otherLabel`,{question:t.question}),maxLength:_n.other,rows:2,disabled:u,value:r.other??``,placeholder:i(`board:question.otherPlaceholder`),className:`min-h-16 w-full resize-y rounded-(--r-md) border border-control bg-panel px-2.5 py-1.5 text-sm text-content outline-none focus:border-focus focus:ring-3 focus:ring-focus-ring max-[650px]:text-[16px]`,onChange:e=>{let t=e.target.value;s(e=>e.map((e,r)=>r===n?{...e,other:t}:e))},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&h&&(e.preventDefault(),g({answers:_(a)}))}})]},`${e.id}-${n}`)}),f&&(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-[var(--danger)]`,children:f}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,disabled:u,"data-question-skip":!0,className:`pointer-coarse:min-h-11`,onClick:()=>void g({skip:!0}),children:i(`board:question.skip`)}),(!m||c[0])&&(0,$.jsx)(Y,{type:`button`,size:`sm`,disabled:u||!h,loading:u,"data-question-submit":!0,className:`pointer-coarse:min-h-11`,onClick:()=>void g({answers:_(a)}),children:i(`board:question.submit`)})]})]})}async function pa({templatePrompt:e,configureHint:t,notify:n,onOpenModelSettings:r,onInsertPrompt:i}){try{let a=await C(`/api/visual/models`);a.image||a.video?i(e):(n?.(t),r?.())}catch{i(e)}}function ma(e){return(e.target instanceof Element?e.target:null)?.closest(`[data-shortcut-recorder], [role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"], .xterm, .terminal-xterm, .terminal-panel, [data-terminal]`)?!0:Array.from(document.querySelectorAll(`[role="dialog"], [role="alertdialog"], dialog[open]`)).some(e=>e.getClientRects().length>0)}function ha(e){let t=(0,Q.useRef)(e);t.current=e;let{enabled:n,binding:r}=e;(0,Q.useEffect)(()=>{if(!n||!r)return;let e=null,i=null,a=()=>{e=null,i&&(i=null,t.current.onCancel())},o=n=>{if(i&&n.key===`Escape`&&!n.isComposing){a(),n.preventDefault();return}!t.current.enabled||n.defaultPrevented||n.isComposing||n.keyCode===229||n.repeat||e||document.visibilityState===`hidden`||ma(n)||!on(n,r)||(e=n.code,t.current.onStart()&&(i={code:n.code,ctrl:n.ctrlKey,meta:n.metaKey,alt:n.altKey,shift:n.shiftKey},n.preventDefault()))},s=n=>{n.code===e&&(e=null),i&&(n.code===i.code||i.ctrl&&(!n.ctrlKey||n.code.startsWith(`Control`))||i.meta&&(!n.metaKey||n.code.startsWith(`Meta`))||i.alt&&(!n.altKey||n.code.startsWith(`Alt`))||i.shift&&(!n.shiftKey||n.code.startsWith(`Shift`)))&&(i=null,t.current.onRelease())},c=()=>{document.visibilityState===`hidden`&&a()};return window.addEventListener(`keydown`,o),window.addEventListener(`keyup`,s,!0),window.addEventListener(`blur`,a),document.addEventListener(`visibilitychange`,c),()=>{window.removeEventListener(`keydown`,o),window.removeEventListener(`keyup`,s,!0),window.removeEventListener(`blur`,a),document.removeEventListener(`visibilitychange`,c),a()}},[n,r])}function ga(e){if(!e.length)return 0;let t=0;for(let n=0;n<e.length;n+=1)t+=e[n]*e[n];let n=Math.sqrt(t/e.length);return n<.0056?0:Math.min(1,Math.sqrt(n)*2.6)}function _a(e=.35){let t=0;return{push(n){return t=t*(1-e)+n*e,t},reset(){t=0}}}function va(e,t=140){let n=e.trim();return n.length>t?`${n.slice(0,t-1)}…`:n}var ya=16e3,ba=20,xa=ya*ba/1e3;function Sa(e,{onsetMs:t=80,minVoicedMs:n=160,silenceMs:r=900}={}){for(let e of[t,n,r])if(!Number.isFinite(e)||e<=0)throw Error(`Invalid VAD endpoint duration`);let i=e(),a=new Int16Array(xa),o=0,s=0,c=0,l=0,u=!1,d=!1,f=!1,p=()=>u&&c*ba>=n;return{get hasSpeech(){return p()},acceptPcm(e){if(f||d)return!1;for(let n=0;n<e.length;n+=1){let f=Number.isFinite(e[n])?Math.max(-1,Math.min(1,e[n])):0;if(a[o++]=f*(f<0?32768:32767),o!==xa)continue;o=0;let m=i.processFrame(a);if(m<0)throw Error(`VAD frame processing failed`);if(m===1)s+=1,c+=1,l=0,s*ba>=t&&(u=!0);else if(s=0,l+=1,u||(c=0),l*ba>=r){if(p())return d=!0,!0;u=!1,c=0}}return!1},reset(){f||(i.destroy(),i=e(),o=s=c=l=0,u=d=!1,a.fill(0))},dispose(){f||(f=!0,o=0,i.destroy())}}}async function Ca(e={}){let{default:n,VADMode:r}=await t(async()=>{let{default:e,VADMode:t}=await import(`./embedded-D2rqyswH.js`);return{default:e,VADMode:t}},[]),i=await n();return Sa(()=>new i(e.mode??r.AGGRESSIVE,ya),e)}var wa=()=>new DOMException(`Speech setup cancelled.`,`AbortError`);function Ta(e){let[t,n]=(0,Q.useState)(null),[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(``),l=(0,Q.useRef)(null),u=(0,Q.useRef)(!1),d=(0,Q.useRef)(0),f=(0,Q.useRef)(0),p=(0,Q.useRef)(0),m=(0,Q.useRef)(e);m.current=e;let h=(0,Q.useCallback)(e=>{d.current++,f.current++;let t=l.current;l.current=null,t&&(t.signal.removeEventListener(`abort`,t.abort),e?t.reject(e):t.resolve()),u.current&&(i(!1),o(!1))},[]),_=(0,Q.useCallback)(e=>{u.current&&(n(e),c(``),l.current&&Nr(e,m.current).every(e=>e.status===`installed`)&&h())},[h]),v=(0,Q.useCallback)(async e=>{let t=d.current,n=++f.current,r=()=>u.current&&t===d.current&&n===f.current&&!e?.aborted;try{let t=await Er(e);r()&&_(t)}catch(e){if(r())throw e}},[_]);(0,Q.useEffect)(()=>(u.current=!0,v().catch(()=>{}),()=>{u.current=!1,h(wa())}),[h,v]),(0,Q.useEffect)(()=>{if(!r)return;let e=new AbortController,t,n=async()=>{try{await v(e.signal)}catch(t){e.signal.aborted||c(t instanceof Error?t.message:String(t))}finally{e.signal.aborted||(t=setTimeout(()=>void n(),750))}};return n(),()=>{e.abort(),clearTimeout(t)}},[r,v]);let y=(0,Q.useCallback)(async e=>{if(g(e),!u.current)throw wa();h(wa());let t=++f.current;return new Promise((n,r)=>{let a=()=>{l.current===o&&h(e.reason||wa())},o={signal:e,abort:a,resolve:n,reject:r};if(l.current=o,e.addEventListener(`abort`,a,{once:!0}),e.aborted){a();return}Er(e).then(n=>{!u.current||l.current!==o||e.aborted||(t===f.current&&_(n),l.current===o&&i(!0))},e=>{l.current===o&&h(e)})})},[_,h]),b=(0,Q.useCallback)(async e=>{let t=d.current,n=++p.current,r=()=>u.current&&t===d.current&&n===p.current;o(!0),c(``);try{await e(),r()&&await v()}catch(e){r()&&c(e instanceof Error?e.message:String(e))}finally{r()&&o(!1)}},[v]);return{catalog:t,open:r,loading:a,error:s,selectedVoice:t?.defaults.voice||``,ensureReady:y,models:t?Nr(t,e):[],show:()=>{h(wa()),i(!0),c(``)},close:()=>h(wa()),download:e=>b(()=>jr(e)),cancelDownload:e=>b(()=>Ar(e)),downloadAll:()=>b(async()=>{if(t)for(let e of Nr(t,m.current))[`installed`,`downloading`,`verifying`].includes(e.status)||await jr(e.id)})}}var Ea=8388608;function Da(e,t){return g(t),new Promise((n,r)=>{let i=()=>r(_(t));t.addEventListener(`abort`,i,{once:!0}),e.then(n,r).finally(()=>t.removeEventListener(`abort`,i))})}var Oa=10,ka=500;async function Aa(e,t,n,r){for(let i=0;;i+=1){let a=await fetch(`/api/speech/synthesize`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:e,voiceId:t,requestId:n}),signal:r});if(a.status!==409||i>=Oa)return a;let o=await a.json().catch(()=>({}));if(!o.error||!/busy/i.test(o.error))return a;await Da(new Promise(e=>setTimeout(e,ka)),r)}}async function ja(e){if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error||`Speech synthesis failed (${e.status}).`)}if(!e.headers.get(`content-type`)?.startsWith(`audio/wav`)||!e.body)throw Error(`Invalid speech audio response.`);let t=e.body.getReader(),n=[],r=0;try{for(;;){let{done:e,value:i}=await t.read();if(e)break;if(r+=i.byteLength,r>Ea)throw Error(`Speech audio exceeds the supported limit.`);n.push(i)}}finally{await t.cancel().catch(()=>{}),t.releaseLock()}if(r<44)throw Error(`Speech audio is empty.`);let i=new Uint8Array(r),a=0;for(let e of n)i.set(e,a),a+=e.length;return i.buffer}async function Ma(e,t,n,r){g(n);let i=h(n);try{await Na(e,t,i,r)}finally{i.abort(new DOMException(`Speech playback ended.`,`AbortError`)),i.dispose()}}async function Na(e,n,r,i){let{signal:a}=r,{speechSegments:o}=await Da(t(()=>import(`./speech-text-BTwYi9Sb.js`),__vite__mapDeps([137,91,1,2,3,88,89,90,34])),a);g(a);let s=(typeof e==`string`?(async function*(){yield*o(e)})():(await Da(t(()=>import(`./speech-stream-text-DF6aAUVb.js`),__vite__mapDeps([138,91,1,2,3,88,89,90,34,13,137])),a)).streamingSpeechSegments(e,a))[Symbol.asyncIterator](),c=!!window.__PISPER_MOBILE_APP__,l=new Set,u,d,f,p=e=>{(c?Or(`mobile_cancel_speech`,{requestId:e}):C(`/api/speech/cancel`,{method:`POST`,body:{requestId:e},timeout:3e3})).catch(()=>{})},m=()=>{for(let e of l)p(e);try{d?.stop()}catch{}f?.(a.reason||new DOMException(`Speech playback cancelled.`,`AbortError`))};a.addEventListener(`abort`,m,{once:!0});let _=e=>{g(a);let t=crypto.randomUUID();l.add(t);let r=(async()=>{if(c){let r=await Or(`mobile_synthesize_speech`,{text:e,voiceId:n,requestId:t});if(a.aborted&&(p(t),g(a)),!r||typeof r.audioId!=`string`||!r.audioId.trim()||r.audioId.length>128||!Number.isInteger(r.sampleRate)||r.sampleRate<8e3||r.sampleRate>48e3||!Number.isFinite(r.durationMs)||r.durationMs<=0||r.durationMs>45e3)throw Error(`Invalid native speech audio.`);return{requestId:t,native:r}}let r=h(a,6e4);try{let i=await Aa(e,n,t,r.signal);return{requestId:t,wav:await ja(i)}}finally{r.dispose()}})();return r.catch(()=>{}),r};try{if(!c){u=new AudioContext({sampleRate:24e3});let e;try{await Da(Promise.race([u.resume(),new Promise((t,n)=>{e=setTimeout(()=>n(Error(`Audio playback is unavailable.`)),5e3)})]),a)}finally{clearTimeout(e)}}let e=async()=>{let e=await Da(s.next(),a);return e.done?void 0:_(e.value)},t=e(),n=!1;for(;;){let r=await Da(t,a);if(g(a),!r)break;if(t=e(),t.catch(()=>{}),n=!0,i?.(),r.native){if((await Da(Or(`mobile_play_speech`,{audioId:r.native.audioId,requestId:r.requestId}),a))?.completed!==!0)throw Error(`Speech playback was interrupted.`)}else{let e=await Da(u.decodeAudioData(r.wav),a);if(g(a),e.numberOfChannels!==1||!Number.isFinite(e.duration)||e.duration<=0||e.duration>45)throw Error(`Invalid speech audio duration.`);let t=u.createBufferSource();d=t,t.buffer=e,t.connect(u.destination);try{await new Promise((e,n)=>{f=n,t.onended=()=>e(),t.start()})}finally{f=void 0,t.onended=null,t.disconnect(),d=void 0}}l.delete(r.requestId),g(a)}if(!n)throw Error(`The reply has no speakable text.`)}finally{a.removeEventListener(`abort`,m),r.abort(new DOMException(`Speech playback ended.`,`AbortError`)),s.return?.(void 0).catch(()=>{});for(let e of l)p(e);try{d?.stop()}catch{}await u?.close().catch(()=>{})}}var Pa={schemaVersion:1,scope:`Offline license texts and provenance notices for the catalogued speech resources and local derivatives. This document is not legal advice, commercial-use clearance, a complete training-data rights audit, or approval for redistribution or formal release. Packaging this small notice file does not package the large models or resolve pending obligations. Native sherpa binaries and their compiled or embedded dependencies require a separate license/linkage and source-delivery audit; switching TTS models does not prove the binaries contain no GPL components or satisfy their obligations.`,licenseIdsMeaning:`References identify retained license documents applicable to the described components or their stated source projects. Multiple references are not alternative dual-license choices and are not a complete SPDX expression. A repository declaration does not relicense unrelated bundled data.`,statusDefinitions:{confirmed:`The specific content or source match described in summary was verified; this is not a whole-chain rights guarantee.`,declared:`An upstream license declaration supports the classification, without a complete reproducible provenance proof.`,pending:`The listed provenance, rights, or distribution obligations remain unresolved even where a license declaration exists.`},pathScopes:{model:`Paths are relative to the original downloaded model root. A terminal /** matches every descendant; all other paths are exact.`,shared:`Paths are relative to the application's shared resource root.`},licenses:[{id:`apache-2.0`,name:`Apache License 2.0 (X-ASR source text)`,text:` Apache License
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SessionContextPanel-A-apbPUv.js","assets/rolldown-runtime-B0Z9INg1.js","assets/vendor-router-CSN_DGvx.js","assets/vendor-react-DwNgTV1j.js","assets/use-i18n-CrMP8KP1.js","assets/i18n-D1oE4DVX.js","assets/index-Cd49jlmz.js","assets/index-BTqJTVNA.css","assets/storage-DtvZ_lEu.js","assets/vendor-state-GkUciC5H.js","assets/runtime-capabilities-CPDBo3tu.js","assets/runtime-capabilities-store-DcLHj_-T.js","assets/api-CCLf8CGI.js","assets/abort-signal-f4JsiYKX.js","assets/http-response-BMpatf4O.js","assets/event-stream-B3CGgFfm.js","assets/http-Ck9ziPLg.js","assets/permission-rules-api-i-sBmQT3.js","assets/createLucideIcon-Cd-3GVxJ.js","assets/arrow-left-B8oVrQ2S.js","assets/check-2vYc6QaP.js","assets/chevron-right-C3t2Rckj.js","assets/SessionBrowserPane-DBc3TNje.js","assets/useQuery-DfOU-27z.js","assets/query-DFQayLF5.js","assets/arrow-right-DqLOhpA2.js","assets/arrow-up-DST6-qVQ.js","assets/chevron-down-CxtxIjiP.js","assets/download-BCfIiuaL.js","assets/earth-Ddy13fHh.js","assets/external-link-CEQqPcqc.js","assets/GitDiffViewer-BYB7_K9o.js","assets/x-07u4-129.js","assets/utils-C8uzG5AZ.js","assets/vendor-ui-DvrYggeS.js","assets/button-CCcCN8tE.js","assets/dist-41X0pdUs.js","assets/events-fUNyYQhT.js","assets/esm-DCV8yILT.js","assets/file-Bllajneu.js","assets/side-chat-context-Dw_WsQW3.js","assets/routes-DIeaqWVc.js","assets/session-board-status-D2lpFPiI.js","assets/usePhoneShell-Bjigstxq.js","assets/use-mobile-C2tPBAza.js","assets/client-store-Df-MtlGW.js","assets/arrow-down-CDGua-ue.js","assets/chevron-left-BAtyp3_6.js","assets/chevron-up-D_ZcXjqr.js","assets/copy-DHmIFc52.js","assets/ellipsis-CfGKfbq6.js","assets/eye-uWAPXNzJ.js","assets/folder-open-FIShC5Qk.js","assets/info-DATxy0fb.js","assets/undo-2-C-xQ0UVT.js","assets/loader-circle-BOwQzHB-.js","assets/refresh-cw-TbWxTY4K.js","assets/rotate-ccw-clock-CO6Bw-sF.js","assets/rotate-ccw-C0v8V77_.js","assets/shield-alert-oZqX6MNu.js","assets/shield-check-Gvek4RJ7.js","assets/square-bHHVTT3G.js","assets/tag-CqkeJlBf.js","assets/trash-2-CNrPOoPR.js","assets/dropdown-menu-Ds0gD8S8.js","assets/dist-BsRXXcSL.js","assets/dist-DzGQ7sLi.js","assets/es2015-DTZdOI9P.js","assets/dist-BRjj4UeB.js","assets/dist-OB2r6Xsr.js","assets/dist-BaBySQmo.js","assets/popover-5MqQ5QIH.js","assets/dialog-CEcIiRdx.js","assets/dist-BHkR6BLP.js","assets/tooltip-D4MFbqcG.js","assets/dist-BiRPwy4W.js","assets/shortcuts-SQuwtLn8.js","assets/chat-api-PdHMtAmc.js","assets/startup-queries-DG8R4Ryc.js","assets/mutation-b4pPvB7p.js","assets/format-DMJQzoZ7.js","assets/StatusGlyph-1KgitlUg.js","assets/run-activity-CwfO0cui.js","assets/input-CPw-zkYh.js","assets/PageState-Cz6vFMXv.js","assets/alert-DRIrgNI4.js","assets/vendor-motion-DSW3wzXK.js","assets/MarkdownMessage-BH5Nh-UO.js","assets/vendor-markdown-plugins-CT5L3KA9.js","assets/vendor-shiki-runtime-DM7fm4Bl.js","assets/vendor-markdown-plugins-DEcVZfaU.css","assets/vendor-markdown-CT6Z4fh8.js","assets/route-context-DvWDul4T.js","assets/motion-DTR4ZVle.js","assets/HoldToConfirmButton-BxdJ7icc.js","assets/card-C3A0b5KR.js","assets/session-web-preview-guvsmkWE.js","assets/BrandLogo-k3CvJjd4.js","assets/collapsible-Dcoy-qnz.js","assets/dist-DUSSw9eQ.js","assets/session-tree-summary-B8SEWLOy.js","assets/FileAttachmentPreview-DkYkLnxt.js","assets/tabs-DsgBuvJv.js","assets/git-branch-N7LGjtzt.js","assets/image-BY_c3FYU.js","assets/link-2-mgasYn21.js","assets/message-square-SKjZyY3v.js","assets/pause-CYWpPg1R.js","assets/triangle-alert-CE1q54ci.js","assets/session-change-summary-api-BzjbV-XG.js","assets/AppSelect-DQYKUW5E.js","assets/select-Bbk9bmXO.js","assets/chevrons-up-down-C2sEPdAh.js","assets/dist-BS3ekNDj.js","assets/web-preview-C7DdG9JP.js","assets/useNativeBrowser-C0j3zafh.js","assets/plus-fQbSqB1n.js","assets/square-terminal-BVG6cUT1.js","assets/sheet-BTaIEX4w.js","assets/public-DHE_Bffl.js","assets/public-events-DK8fPqRB.js","assets/terminal-context-aIsIJPn8.js","assets/SessionInspector-B41l7gKR.js","assets/bot-B3TaBp_T.js","assets/focus-session-composer-bits-DWovCteo.js","assets/braces-DQcXLGFF.js","assets/pencil-U08v_vV9.js","assets/wrench-6pg6_bqI.js","assets/kbd-CAufZTkl.js","assets/segmented-control-xkrEOP_d.js","assets/session-inspector-store-BxozyuFV.js","assets/public-session-CuS3mRPA.js","assets/settings-2-CXJjXJS9.js","assets/BotAvatar-CNL-APwP.js","assets/bots-store-BYTwHk9o.js","assets/workspace-folders-1RLblom2.js","assets/public-flags-_XZrt2pU.js","assets/speech-text-BTwYi9Sb.js","assets/speech-stream-text-DF6aAUVb.js","assets/speech-session-Dx6waD1F.js","assets/mobile-remote-fallback-LLMZWoIu.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{h as t}from"./vendor-router-CSN_DGvx.js";import{t as n}from"./index-Cd49jlmz.js";import{i as r,n as i,r as a}from"./vendor-react-DwNgTV1j.js";import{t as o}from"./use-i18n-CrMP8KP1.js";import{a as s,i as c,o as l}from"./vendor-state-GkUciC5H.js";import{t as u}from"./storage-DtvZ_lEu.js";import{u as d}from"./query-DFQayLF5.js";import{r as f,t as p}from"./useQuery-DfOU-27z.js";import{t as m}from"./startup-queries-DG8R4Ryc.js";import{n as h,r as g,t as _}from"./abort-signal-f4JsiYKX.js";import{i as v,t as y}from"./http-response-BMpatf4O.js";import{i as b,n as x}from"./http-Ck9ziPLg.js";import{n as S,t as C}from"./api-CCLf8CGI.js";import{i as w}from"./runtime-capabilities-CPDBo3tu.js";import{t as T}from"./runtime-capabilities-store-DcLHj_-T.js";import{n as E}from"./use-mobile-C2tPBAza.js";import{n as D,t as O}from"./client-store-Df-MtlGW.js";import{t as k}from"./createLucideIcon-Cd-3GVxJ.js";import{r as A}from"./permission-rules-api-i-sBmQT3.js";import{t as j}from"./archive-ojKJT7Fp.js";import{t as M}from"./book-open-BuHHD9os.js";import{t as N}from"./bot-B3TaBp_T.js";import{t as P}from"./braces-DQcXLGFF.js";import{t as F}from"./check-2vYc6QaP.js";import{t as I}from"./chevron-down-CxtxIjiP.js";import{t as L}from"./chevron-left-BAtyp3_6.js";import{t as R}from"./chevron-right-C3t2Rckj.js";import{t as z}from"./circle-check-iEdCm3Pw.js";import{n as B,t as V}from"./image-plus-D7bzZog0.js";import{a as ee,i as te,n as ne,o as re,r as H,s as ie,t as ae}from"./focus-session-composer-bits-DWovCteo.js";import{t as U}from"./corner-down-right--hxi-Ihy.js";import{t as W}from"./download-BCfIiuaL.js";import{o as oe}from"./GitDiffViewer-BYB7_K9o.js";import{a as se,c as ce,d as G,f as le,g as K,h as ue,i as de,l as fe,m as pe,n as me,o as he,p as q,r as ge,s as _e,t as ve,u as ye}from"./FocusRuntimeControls-DiS4SP0x.js";import{t as be}from"./file-Bllajneu.js";import{C as xe,D as Se,E as Ce,O as we,S as Te,T as Ee,_ as De,a as Oe,b as ke,c as Ae,d as je,f as Me,g as Ne,h as Pe,i as Fe,k as Ie,l as Le,m as Re,n as ze,o as Be,p as Ve,s as He,t as Ue,u as We,v as Ge,w as Ke,x as qe,y as Je}from"./side-chat-context-Dw_WsQW3.js";import{t as Ye}from"./WorkspacePicker-BRa_IVqp.js";import{t as Xe}from"./folder-open-FIShC5Qk.js";import{t as Ze}from"./git-branch-N7LGjtzt.js";import{n as Qe}from"./undo-2-C-xQ0UVT.js";import{t as $e}from"./link-2-mgasYn21.js";import{t as et}from"./loader-circle-BOwQzHB-.js";import{t as tt}from"./message-square-SKjZyY3v.js";import{t as nt}from"./panel-right-BSUtqUd8.js";import{t as rt}from"./paperclip-BCXrwYpb.js";import{t as it}from"./pencil-U08v_vV9.js";import{t as at}from"./play-DNDjDNGn.js";import{t as ot}from"./plus-fQbSqB1n.js";import{t as st}from"./refresh-cw-TbWxTY4K.js";import{t as ct}from"./search-D0mqDaf_.js";import{t as lt}from"./settings-QX0oWnVK.js";import{t as ut}from"./shield-alert-oZqX6MNu.js";import{t as J}from"./square-pen-hYbjKh6A.js";import{t as dt}from"./square-bHHVTT3G.js";import{t as ft}from"./tag-CqkeJlBf.js";import{t as pt}from"./trash-2-CNrPOoPR.js";import{t as mt}from"./triangle-alert-CE1q54ci.js";import{t as ht}from"./users-CCtFZzwl.js";import{t as gt}from"./workflow-Bg94dy8I.js";import{t as _t}from"./wrench-6pg6_bqI.js";import{t as vt}from"./x-07u4-129.js";import{t as yt}from"./brand-DIEc3fK8.js";import{t as bt}from"./checkbox-BrEHgFV0.js";import{c as xt,i as St,l as Ct,p as wt,r as Tt,t as Et}from"./dropdown-menu-Ds0gD8S8.js";import{t as Dt}from"./progress-5odAz3B9.js";import{t as Ot}from"./switch-D_G8wFhs.js";import{i as kt,r as At,t as jt}from"./tabs-DsgBuvJv.js";import{n as Mt,t as Nt}from"./segmented-control-xkrEOP_d.js";import{i as Pt,n as Ft,t as It}from"./tooltip-D4MFbqcG.js";import{t as Lt}from"./utils-C8uzG5AZ.js";import{n as Rt,t as Y}from"./button-CCcCN8tE.js";import{n as zt,t as Bt}from"./kbd-CAufZTkl.js";import{C as Vt,S as Ht,b as Ut,c as Wt,f as Gt,i as Kt,o as qt,p as Jt,r as Yt,s as Xt,u as Zt,w as Qt,x as $t,y as en}from"./events-fUNyYQhT.js";import{a as tn,c as nn,i as rn,n as an,r as on,s as sn,t as cn}from"./shortcuts-SQuwtLn8.js";import{n as ln,o as un,r as dn,t as fn}from"./sheet-BTaIEX4w.js";import{t as X}from"./chat-api-PdHMtAmc.js";import{n as pn}from"./session-organization-api-CLAh265X.js";import{r as mn}from"./session-workspaces-Brm-8lHh.js";import{a as hn,n as gn,t as _n}from"./session-questions-Cf-1g85h.js";import{n as vn,o as yn,r as bn,t as xn}from"./format-DMJQzoZ7.js";import{t as Sn}from"./StatusGlyph-1KgitlUg.js";import{a as Cn,c as wn,d as Tn,m as En,o as Dn,p as On,u as kn}from"./run-activity-CwfO0cui.js";import{a as An,i as jn,l as Mn,s as Nn,t as Pn}from"./dialog-CEcIiRdx.js";import{t as Fn}from"./input-CPw-zkYh.js";import{i as In,n as Ln,t as Rn}from"./input-group-h8z63MzW.js";import{t as zn}from"./model-display-kDwvtxrW.js";import{t as Bn}from"./session-change-summary-api-BzjbV-XG.js";import{t as Vn}from"./pick-system-directory-Cnb1L8Kd.js";import{n as Hn,r as Un,t as Wn}from"./PageState-Cz6vFMXv.js";import{t as Gn}from"./back-navigation-CK7X_5Bc.js";import{t as Kn}from"./MarkdownMessage-BH5Nh-UO.js";import{t as qn}from"./esm-DCV8yILT.js";import{t as Jn}from"./motion-DTR4ZVle.js";import{t as Yn}from"./shortcut-aria-jHRmld9z.js";import{t as Xn}from"./app-primitives-Drz_SjnR.js";import{i as Zn,n as Qn,o as $n,r as er,s as tr,t as nr}from"./session-list-BRMu9JWa.js";import{a as rr,c as ir,l as ar,n as or,r as sr,s as cr,u as lr}from"./session-web-preview-guvsmkWE.js";import"./public-DHE_Bffl.js";import{n as ur,r as dr}from"./terminal-context-aIsIJPn8.js";import{n as fr,r as pr,t as mr}from"./session-inspector-store-BxozyuFV.js";import{a as hr,i as gr}from"./tool-labels-D-3gybP7.js";import{t as _r}from"./BrandLogo-k3CvJjd4.js";import{i as vr,n as yr,o as Z,s as br,t as xr}from"./session-tree-summary-B8SEWLOy.js";import{fileRewindConfirmOptions as Sr,fileRewindNotice as Cr,notifyTreeNavigation as wr}from"./session-tree-actions-BlqzMI3H.js";import{a as Tr,c as Er,i as Dr,l as Or,n as kr,o as Ar,s as jr,t as Mr,u as Nr}from"./speech-session-Dx6waD1F.js";import{n as Pr,t as Fr}from"./web-preview-events-D7F0Z-Hy.js";var Ir=k(`audio-lines`,[[`path`,{d:`M2 10v3`,key:`1fnikh`}],[`path`,{d:`M6 6v11`,key:`11sgs0`}],[`path`,{d:`M10 3v18`,key:`yhl04a`}],[`path`,{d:`M14 8v7`,key:`3a1oy3`}],[`path`,{d:`M18 5v13`,key:`123xd1`}],[`path`,{d:`M22 10v3`,key:`154ddg`}]]),Lr=k(`badge-check`,[[`path`,{d:`M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z`,key:`3c2336`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Rr=k(`bookmark`,[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]),zr=k(`file-check-corner`,[[`path`,{d:`M10.5 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v6`,key:`g5mvt7`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m14 20 2 2 4-4`,key:`15kota`}]]),Br=k(`file-down`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 18v-6`,key:`17g6i2`}],[`path`,{d:`m9 15 3 3 3-3`,key:`1npd3o`}]]),Vr=k(`message-circle-question-mark`,[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Hr=k(`mic-off`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`,key:`1gzdoj`}],[`path`,{d:`M16.95 16.95A7 7 0 0 1 5 12v-2`,key:`cqa7eg`}],[`path`,{d:`M18.89 13.23A7 7 0 0 0 19 12v-2`,key:`16hl24`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`,key:`r2i35w`}]]),Ur=k(`mic`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`13`,rx:`3`,key:`s6n7sd`}]]),Wr=k(`shield`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]),Gr=k(`shrink`,[[`path`,{d:`m15 15 6 6m-6-6v4.8m0-4.8h4.8`,key:`17vawe`}],[`path`,{d:`M9 19.8V15m0 0H4.2M9 15l-6 6`,key:`chjx8e`}],[`path`,{d:`M15 4.2V9m0 0h4.8M15 9l6-6`,key:`lav6yq`}],[`path`,{d:`M9 4.2V9m0 0H4.2M9 9 3 3`,key:`1pxi2q`}]]),Kr=k(`target`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`6`,key:`1vlfrh`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),Q=e(r(),1),qr=c(()=>({getItem:e=>{try{return n.getItem(e)}catch{return null}},setItem:(e,t)=>{try{n.setItem(e,t)}catch{}},removeItem:e=>{try{n.removeItem(e)}catch{}}})),Jr=l()(s((e,t)=>({width:360,open:!1,setWidth:n=>{let r=ir(n);t().width!==r&&e({width:r})},setOpen:n=>{t().open!==n&&e({open:n})}}),{name:`pisper-session-context-layout`,version:2,storage:qr,migrate:e=>{let t=e&&typeof e==`object`&&!Array.isArray(e)?e:{};return{width:ir(`width`in t?t.width:void 0),open:`open`in t&&t.open===!0}},partialize:({width:e,open:t})=>({width:e,open:t}),merge:(e,t)=>({...t,width:ir(e&&typeof e==`object`&&!Array.isArray(e)&&`width`in e?e.width:void 0),open:!!(e&&typeof e==`object`&&!Array.isArray(e)&&`open`in e&&e.open===!0)})}));function Yr(e,t,n){let r=(0,Q.useRef)(n);r.current=n,(0,Q.useLayoutEffect)(()=>e?Gn.register(t,()=>r.current()):void 0,[e,t])}var $=a();function Xr({preferredWidth:e,onWidthChange:t,availableWidth:n,presentation:r,children:i,context:a,side:s=`right`,layoutId:c=`chat`,conversationHeaderInset:l=0}){let{t:u}=o(),d=(0,Q.useRef)(()=>{});(0,Q.useEffect)(()=>()=>d.current(),[]);let f=r===`aside`,p=r===`content`,m=ar(e,n),h=ar(720,n),g=e=>t(Math.max(280,Math.min(h,e))),_=n=>{if(n.button!==0)return;d.current(),n.preventDefault(),n.currentTarget.focus(),n.currentTarget.setPointerCapture(n.pointerId);let r=n.clientX,i=e=>g(m+(e.clientX-r)*(s===`left`?1:-1)),a=()=>{window.removeEventListener(`pointermove`,i),window.removeEventListener(`pointerup`,a),window.removeEventListener(`pointercancel`,o),window.removeEventListener(`keydown`,c)},o=()=>{t(e),a()},c=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),o())};d.current=a,window.addEventListener(`pointermove`,i),window.addEventListener(`pointerup`,a,{once:!0}),window.addEventListener(`pointercancel`,o,{once:!0}),window.addEventListener(`keydown`,c)},v=(0,$.jsx)(`div`,{id:`${c}-conversation`,"data-workspace-conversation":!0,inert:p,className:p?`hidden`:`min-h-0 min-w-0 flex-1 overflow-hidden`,style:f&&l?{paddingTop:l}:void 0,children:i},`conversation`),y=f?(0,$.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-orientation":`vertical`,"aria-label":u(`chat:sessionContext.resize`),title:u(`chat:sessionContext.resizeHint`),"aria-controls":`${c}-conversation ${c}-content`,"aria-valuemin":280,"aria-valuemax":h,"aria-valuenow":m,onPointerDown:_,onDoubleClick:()=>t(360),onKeyDown:e=>{if(![`ArrowLeft`,`ArrowRight`,`Home`,`End`,`Enter`].includes(e.key))return;if(e.preventDefault(),e.key===`Enter`){t(360);return}let n=e.shiftKey?64:16;g(e.key===`Home`?280:e.key===`End`?h:m+(e.key===`ArrowRight`?n:-n)*(s===`left`?1:-1))},className:`relative w-2 shrink-0 cursor-col-resize touch-none select-none outline-none after:absolute after:top-1/2 after:left-1/2 after:h-9 after:w-[3px] after:-translate-1/2 after:rounded-full after:bg-stroke-strong after:transition-colors after:duration-[var(--d-fast)] hover:after:bg-focus active:after:bg-focus focus-visible:after:bg-focus focus-visible:after:ring-3 focus-visible:after:ring-focus-ring`},`separator`):null,b=(0,$.jsx)(`div`,{id:`${c}-content`,className:f?`h-full min-h-0 shrink-0 overflow-hidden`:p?`h-full min-h-0 min-w-0 flex-1 overflow-hidden`:`hidden`,style:f?{width:m}:void 0,children:(f||p)&&a},`resource`);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{id:`${c}-context-layout`,"data-workspace-layout":!0,className:`flex h-full min-h-0 min-w-0 flex-1 overflow-hidden`,children:s===`left`?[b,y,v]:[v,y,b]}),r===`sheet`&&a]})}function Zr({sessionId:e,streaming:t,completed:n,runStartedAt:r,enabled:i,open:a,onReveal:o}){let s=(0,Q.useRef)(null),c=(0,Q.useRef)(o);(0,Q.useLayoutEffect)(()=>{c.current=o},[o]),(0,Q.useEffect)(()=>{let o=s.current,l={sessionId:e,streaming:t,completed:n,runStartedAt:r};if(s.current=l,!i||a||!cr(o,l))return;let u=new AbortController,d=!0;return X.getSessionFileChanges(e,{signal:u.signal}).then(({files:e})=>{d&&lr(o,l,e)&&c.current()}).catch(()=>{}),()=>{d=!1,u.abort()}},[n,i,a,r,e,t])}var Qr=`pisper:task-content-requested`,$r=[`changes`,`terminal`,`processes`,`sources`,`browser`];function ei(e){return!e||typeof e!=`object`||!(`kind`in e)?null:$r.find(t=>t===e.kind)||null}function ti({sessionId:e,cwd:t,taskName:n,sources:r,mobile:i,streaming:a}){let{t:s}=o(),c=dr(e),l=ur(),[u,d]=(0,Q.useState)(!1),f=(0,Q.useRef)(null),m=(0,Q.useRef)(!1),h=T(e=>e.capabilities),g=w(h,`vcs`),_=p({enabled:g,queryKey:[`task-project-changes`,e,t,a],queryFn:({signal:t})=>X.getVcsChanges(e,{signal:t})}),v=(0,Q.useMemo)(()=>Re(_.data?.diff||``,_.data?.files.map(e=>e.path)||[],_.data?.diffTruncated),[_.data]),y=()=>sr.getState().update(e,`new`,{type:`workspace`,summaryOpen:!1}),b=()=>document.getElementById(`task-${e}-summary-toggle`)?.focus();(0,Q.useEffect)(()=>{i||f.current?.focus()},[i]);let x=(t,n=``)=>{let r=sr.getState();if(r.update(e,t,{type:`open`,kind:t})===`limit`){d(!0);return}m.current=!0;let i=sr.getState().sessions[e]?.activeId;n&&i&&r.update(e,t,{type:`view`,id:i,patch:t===`sources`?{selectedSourceId:n,query:``,filter:``}:{expandedProcesses:[n],filter:``}})};Yr(!i,300,()=>{y(),b()});let S=`w-full justify-start gap-2 px-2 font-normal text-content`,C=`ml-auto shrink-0 text-xs text-content-muted tabular-nums`,E=(0,$.jsxs)($.Fragment,{children:[u&&(0,$.jsx)(`p`,{role:`alert`,className:`px-2 pb-1 text-xs text-danger`,children:s(`chat:sessionContext.pageLimit`)}),(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2 border-b border-stroke-soft px-2 pt-1 pb-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`truncate font-mono text-xs text-content-muted`,title:t,children:t.split(/[\\/]/).filter(Boolean).at(-1)||t}),(0,$.jsx)(`p`,{className:`mt-0.5 truncate text-sm font-medium text-content`,children:n})]}),(0,$.jsx)(Y,{variant:`ghost`,size:`icon`,className:`max-[650px]:size-11`,"aria-label":s(`chat:workbench.closeSummary`),onClick:()=>{y(),b()},children:(0,$.jsx)(vt,{size:16})})]}),(0,$.jsxs)(`section`,{className:`border-b border-stroke-soft py-1`,children:[(0,$.jsxs)(Y,{variant:`ghost`,className:`${S} h-auto min-h-8 whitespace-normal text-left`,disabled:!g,onClick:()=>x(`changes`),children:[(0,$.jsx)(oe,{size:16,className:`text-content-muted`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1`,children:s(`chat:workbench.projectChanges`)}),(0,$.jsx)(`span`,{className:C,children:g?_.isPending?`…`:_.isError||_.data?.error?s(`chat:workbench.unavailable`):_.data?.isRepo?_.data.files.length:`—`:s(`chat:workbench.unavailable`)})]}),(_.isError||_.data?.error)&&(0,$.jsx)(`p`,{role:`alert`,className:`px-2 py-1 text-xs text-danger`,children:s(`chat:workbench.changesFailed`)}),_.data?.isRepo&&!_.isError&&!_.data.error&&(0,$.jsxs)(`p`,{className:`px-2 pb-1 pl-8 font-mono text-xs tabular-nums text-content-muted`,children:[v.partial?`${s(`chat:workbench.partialCounts`)} `:``,(0,$.jsxs)(`span`,{className:`text-success`,children:[`+`,v.added]}),` `,(0,$.jsxs)(`span`,{className:`text-danger`,children:[`−`,v.removed]})]}),(0,$.jsxs)(Y,{variant:`ghost`,className:S,onClick:()=>x(`files`),children:[(0,$.jsx)(Ie,{size:16,className:`text-content-muted`}),s(`chat:workbench.taskSnapshots`)]})]}),(0,$.jsxs)(`section`,{className:`border-b border-stroke-soft py-1`,children:[(0,$.jsxs)(Y,{variant:`ghost`,className:S,onClick:()=>x(`processes`),children:[(0,$.jsx)(`span`,{children:s(`terminal:workspace.processes`)}),(0,$.jsx)(`span`,{className:C,children:c.length})]}),!l&&(0,$.jsx)(`p`,{className:`px-2 pb-1 text-xs text-content-muted`,children:s(`terminal:workspace.nativeOnly`)}),c.slice(0,3).map(e=>(0,$.jsxs)(Y,{variant:`ghost`,className:`${S} min-w-0`,onClick:()=>x(`processes`,e.id),children:[e.status===`running`?(0,$.jsx)(Rt,{className:`size-3.5`}):(0,$.jsx)(A,{size:15,className:`text-content-muted`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left font-mono text-xs`,children:e.profileId}),(0,$.jsx)(`span`,{className:C,children:e.status===`running`?s(`terminal:workspace.running`):e.status===`exited`?s(`terminal:workspace.exited`):s(`chat:workbench.otherState`)})]},e.id))]}),(0,$.jsxs)(`section`,{className:`pt-1`,children:[(0,$.jsxs)(Y,{variant:`ghost`,className:S,onClick:()=>x(`sources`),children:[(0,$.jsx)(`span`,{children:s(`chat:workbench.sources`)}),(0,$.jsx)(`span`,{className:C,children:r.length})]}),r.slice(0,3).map(e=>(0,$.jsxs)(Y,{variant:`ghost`,className:`${S} min-w-0`,onClick:()=>x(`sources`,e.id),children:[(0,$.jsx)($e,{size:15,className:`text-content-muted`}),(0,$.jsx)(`span`,{className:`truncate font-mono text-xs`,children:e.name||s(`chat:chatMessage.fileAttachment`)})]},e.id)),(0,$.jsx)(Y,{variant:`ghost`,className:`${S} text-content-muted`,onClick:()=>x(`sources`),children:s(`chat:workbench.viewAll`)})]})]});return i?(0,$.jsx)(fn,{open:!0,onOpenChange:e=>{e||y()},children:(0,$.jsxs)(ln,{side:`bottom`,showCloseButton:!1,"aria-describedby":void 0,className:`max-h-[80dvh] overflow-y-auto rounded-t-2xl p-3 pb-[max(16px,var(--pisper-safe-area-bottom))] [&_button]:min-h-11`,style:{left:`calc(44px + var(--pisper-safe-area-left, 0px))`,right:`var(--pisper-safe-area-right, 0px)`},onCloseAutoFocus:e=>{e.preventDefault(),m.current||b()},children:[(0,$.jsx)(un,{className:`sr-only`,children:s(`chat:workbench.summary`)}),E]})}):(0,$.jsx)(`div`,{ref:f,tabIndex:-1,id:`task-${e}-summary`,role:`region`,"aria-label":s(`chat:workbench.summary`),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),y(),b())},className:`absolute top-[52px] right-2 z-20 max-h-[calc(100%-64px)] w-80 max-w-[calc(100%-16px)] overflow-y-auto rounded-md bg-popover p-1 text-sm text-popover-foreground shadow-float`,children:E})}function ni(e){if(typeof e!=`string`||Array.from(e).some(e=>e.charCodeAt(0)<32))return``;let t=e.replace(/\\/g,`/`);return!t.startsWith(`/`)&&!/^[a-z]:\//i.test(t)?``:t.replace(/\/\.\//g,`/`).replace(/\/$/,``)||`/`}function ri(e){let t=[],n=new Set;for(let r of e)if(Array.isArray(r.attachments))for(let[e,i]of r.attachments.entries()){if(!i||typeof i!=`object`||Array.isArray(i))continue;let a=typeof i.id==`string`&&!i.id.startsWith(`path:`)&&i.id.length<=512&&!Array.from(i.id).some(e=>e.charCodeAt(0)<32)?i.id:``,o=ni(i.path),s=a?`asset`:o?`path`:`unresolved`,c=a?`asset:${a}`:o?`path:${o}`:`unresolved:${r.id}:${e}`;if(n.has(c))continue;n.add(c);let l=typeof i.name==`string`?i.name:o.split(`/`).pop()||a,u=typeof i.mimeType==`string`?i.mimeType:``,d={...a?{id:a,downloadUrl:`/api/assets/${encodeURIComponent(a)}/download`}:{},...o?{id:a||`path:${o}`,path:o}:{},name:l,mimeType:u,...typeof i.size==`number`&&Number.isFinite(i.size)&&i.size>=0?{size:i.size}:{},...typeof i.text==`string`?{text:i.text.slice(0,4e5)}:{}};t.push({id:c,name:l,method:s,messageId:r.id,attachment:d,available:s!==`unresolved`||typeof i.text==`string`,kind:u.startsWith(`image/`)?`image`:u.startsWith(`text/`)?`text`:`file`})}return t}function ii({width:e,mobile:t,contentOpen:n}){return n?t||e<660?`content`:`split`:`conversation`}var ai=(0,Q.lazy)(()=>t(()=>import(`./SessionContextPanel-A-apbPUv.js`).then(e=>({default:e.SessionContextPanel})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121])));function oi({sessionId:e,messages:t,taskName:n,cwd:r,panelId:i,active:a,mobile:s,plan:c,streaming:l,completed:u,runStartedAt:d,plansAvailable:f,requestConfirm:p,children:m}){let{t:h}=o(),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(null),b=(0,Q.useMemo)(()=>({headerHost:g,sourceActionHost:v,setSourceActionHost:y}),[g,v]),x=(0,Q.useMemo)(()=>ri(t),[t]),S=(0,Q.useRef)(Jr.getState().width).current,C=(0,Q.useRef)(null),[w,T]=(0,Q.useState)(0),E=(0,Q.useMemo)(()=>rr(),[]),D=sr(t=>t.sessions[e])||E,O=sr(e=>e.update);(0,Q.useLayoutEffect)(()=>{D.contentWidth??O(e,`new`,{type:`workspace`,contentWidth:S})},[D.contentWidth,e,S,O]),(0,Q.useLayoutEffect)(()=>{let e=C.current;if(!e)return;let t=()=>T(e.clientWidth);t();let n=null,r=new ResizeObserver(()=>{n!==null&&cancelAnimationFrame(n),n=requestAnimationFrame(()=>{n=null,t()})});return r.observe(e),()=>{r.disconnect(),n!==null&&cancelAnimationFrame(n)}},[]);let k=ii({width:w,mobile:s,contentOpen:D.contentOpen&&D.pages.length>0});Zr({sessionId:e,streaming:l,completed:u,runStartedAt:d,enabled:!0,open:D.contentOpen,onReveal:()=>O(e,`files`,{type:`open`,kind:`files`})}),(0,Q.useEffect)(()=>{if(!a)return;let t=t=>{let n=ei(t.detail);n&&O(e,n,{type:`open`,kind:n})};return window.addEventListener(Qr,t),()=>window.removeEventListener(Qr,t)},[a,e,O]);let A=()=>{window.dispatchEvent(new Event(Xt)),O(e,`files`,{type:`workspace`,contentOpen:!1}),requestAnimationFrame(()=>(document.getElementById(`task-${e}-new-content-tab`)||document.getElementById(`task-${e}-more`))?.focus())};Yr(a&&k===`content`,100,A);let j=D.contentOpen&&D.pages.length>0&&(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{role:`status`,className:`p-4 text-sm text-content-muted`,children:h(`chat:focusSession.gitLoading`)}),children:(0,$.jsx)(ai,{panelId:`${i}-context`,compact:!1,embedded:!0,active:a,sessionId:e,cwd:r,sources:x,tab:D.pages.find(e=>e.id===D.activeId)?.kind||`files`,plan:c,streaming:l,plansAvailable:f,requestConfirm:p,onTabChange:()=>{},onClose:A,onBack:A})});return(0,$.jsx)(Pe.Provider,{value:b,children:(0,$.jsxs)(`div`,{ref:C,id:`task-${e}-workspace`,tabIndex:-1,"data-task-workspace":e,"data-active":a,className:`relative flex h-full min-h-0 min-w-0 flex-col overflow-hidden bg-panel`,children:[(0,$.jsx)(`div`,{ref:_,className:k===`split`?`@container absolute left-0 top-0 z-10`:`@container shrink-0`,style:k===`split`?{width:`calc(100% - ${ar(D.contentWidth??S,w)+8}px)`}:void 0,"data-task-header":!0}),(0,$.jsx)(Xr,{preferredWidth:D.contentWidth??S,onWidthChange:t=>{O(e,`new`,{type:`workspace`,contentWidth:t}),Jr.getState().setWidth(t)},layoutId:i,availableWidth:w,conversationHeaderInset:48,presentation:k===`split`?`aside`:k===`content`?`content`:`closed`,context:j,children:m}),a&&D.summaryOpen&&(0,$.jsx)(ti,{sessionId:e,cwd:r,taskName:n,sources:x,mobile:s,streaming:l})]})})}function si(e,t){return e.open===t?e:{open:t,leaving:!t}}function ci(e){return e.leaving?{open:e.open,leaving:!1}:e}function li(e){return e.open||e.leaving}function ui(e,t=400){let[n,r]=(0,Q.useState)(()=>({open:e,leaving:!1})),i=n;n.open!==e&&(i=si(n,e),r(i));let a=i.leaving,o=(0,Q.useCallback)(()=>r(ci),[]);return(0,Q.useLayoutEffect)(()=>{if(!a)return;if(Jn()){o();return}let e=window.setTimeout(o,t);return()=>window.clearTimeout(e)},[t,o,a]),{mounted:li(i),leaving:a,finish:o}}function di(e){return[`running`,`waiting_approval`].includes(String(e.status||``))}function fi(e,t){return t(e===`running`?`chat:workflowRun.running`:e===`waiting_approval`?`chat:workflowRun.waitingApproval`:e===`completed`?`chat:workflowRun.completed`:e===`failed`?`chat:workflowRun.failed`:e===`cancelled`?`chat:workflowRun.stopped`:`chat:workflowRun.interrupted`)}function pi({sessionId:e,empty:t=null}){let{t:n}=o(),[r,i]=(0,Q.useState)([]),[a,s]=(0,Q.useState)(``),c=(0,Q.useCallback)(async()=>{try{let t=await X.getSessionWorkflowRuns(e);i(t.runs||[])}catch{}},[e]);if((0,Q.useEffect)(()=>{c();let e=window.setInterval(c,1500);return()=>window.clearInterval(e)},[c]),!r.length)return t;let l=`session-workflow-context grid min-w-0 gap-1 border-b border-stroke-soft pb-1.5 [&_strong]:text-xs [&_strong]:font-medium [&_strong]:text-content-muted [&_p]:max-h-[84px] [&_p]:overflow-auto [&_p]:text-xs [&_p]:leading-relaxed [&_p]:whitespace-pre-wrap [&_p]:text-content-secondary [&_p]:[overflow-wrap:anywhere] [&_pre]:max-h-[84px] [&_pre]:overflow-auto [&_pre]:rounded-xs [&_pre]:bg-code [&_pre]:px-1.5 [&_pre]:py-1 [&_pre]:font-mono [&_pre]:text-xs [&_pre]:leading-relaxed [&_pre]:whitespace-pre-wrap [&_pre]:text-content-secondary [&_pre]:[overflow-wrap:anywhere]`;return(0,$.jsx)(`div`,{className:`flex max-h-[210px] flex-col overflow-auto rounded-md border border-stroke bg-panel`,children:[...r].sort((e,t)=>Date.parse(t.startedAt)-Date.parse(e.startedAt)).slice(0,5).map(e=>{let t=a===e.id,r=Math.round((Number(e.completedNodes)||0)/Math.max(1,Number(e.totalNodes)||1)*100);return(0,$.jsxs)(`div`,{className:`session-workflow-run border-b border-stroke-soft last:border-b-0 ${e.status}`,children:[(0,$.jsxs)(`button`,{className:`session-workflow-summary grid w-full cursor-pointer grid-cols-[20px_minmax(120px,1fr)_minmax(80px,160px)_14px] items-center gap-2.5 border-0 px-3 py-2 text-left text-content transition-colors duration-(--d-fast) hover:bg-surface-subtle focus-visible:-outline-offset-2 max-[650px]:min-h-11 max-[650px]:grid-cols-[20px_minmax(0,1fr)_14px] max-[650px]:[&_[data-slot='progress']]:col-[2/4] [&_[data-slot='progress']]:h-1 [&_>_span:nth-child(2)]:flex [&_>_span:nth-child(2)]:min-w-0 [&_>_span:nth-child(2)]:flex-col [&_small]:truncate [&_small]:text-xs [&_small]:text-content-muted [&_small]:tabular-nums [&_strong]:truncate [&_strong]:text-sm [&_strong]:font-medium ${t?`bg-surface-subtle`:`bg-transparent`}`,"aria-expanded":t,onClick:()=>s(t?``:e.id),children:[(0,$.jsx)(`span`,{className:`grid size-5 place-items-center rounded-xs ${e.status===`completed`?`bg-success-soft text-success`:e.status===`failed`?`bg-danger-soft text-danger`:e.status===`waiting_approval`?`bg-warning-soft text-warning-strong`:`bg-surface-muted text-content-muted`}`,children:e.status===`running`?(0,$.jsx)(Rt,{className:`size-3.5`}):e.status===`completed`?(0,$.jsx)(F,{size:12}):e.status===`failed`?(0,$.jsx)(vt,{size:12}):(0,$.jsx)(gt,{size:12})}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`strong`,{children:e.workflowName}),(0,$.jsxs)(`small`,{children:[fi(e.status,n),` · v`,e.workflowRevision||1]})]}),(0,$.jsx)(Dt,{value:e.status===`completed`?100:r}),(0,$.jsx)(R,{size:14,className:`text-content-muted transition-transform duration-(--d-fast) ${t?`rotate-90`:``}`})]}),t&&(0,$.jsxs)(`div`,{className:`session-workflow-detail flex flex-col gap-1.5 border-t border-stroke-soft bg-surface-subtle py-2 pr-3 pl-[42px] max-[650px]:pl-3 [&_>_p]:text-xs [&_>_p]:text-content-muted`,children:[e.sourceMessage&&(0,$.jsxs)(`div`,{className:l,children:[(0,$.jsx)(`strong`,{children:n(`chat:workflowRun.request`)}),(0,$.jsx)(`p`,{children:e.sourceMessage})]}),e.inputs&&Object.keys(e.inputs).length>0&&(0,$.jsxs)(`div`,{className:l,children:[(0,$.jsx)(`strong`,{children:n(`chat:workflowRun.inputs`)}),(0,$.jsx)(`pre`,{children:JSON.stringify(e.inputs,null,2)})]}),(e.nodes||[]).map(t=>(0,$.jsxs)(`div`,{className:`session-workflow-node grid min-h-6 grid-cols-[15px_minmax(0,1fr)_auto] items-center gap-1.5 text-content-muted [&.completed]:text-success [&.failed]:text-danger [&_>_div]:flex [&_>_div]:gap-1 [&_>_span]:flex [&_>_span]:min-w-0 [&_>_span]:flex-col [&_small]:truncate [&_small]:text-xs [&_small]:text-content-muted [&_strong]:text-xs [&_strong]:font-medium [&_strong]:text-content ${t.status}`,children:[t.status===`completed`?(0,$.jsx)(F,{size:13}):t.status===`failed`?(0,$.jsx)(B,{size:13}):t.status===`running`?(0,$.jsx)(Rt,{className:`size-3.5`}):(0,$.jsx)(dt,{size:11}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`strong`,{children:t.label}),(t.error||t.summary)&&(0,$.jsx)(`small`,{children:t.error||t.summary})]}),t.status===`waiting_approval`&&(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Y,{size:`xs`,onClick:async()=>{await X.resolveWorkflowApproval(e.id,t.id,!0),await c()},children:n(`chat:workflowRun.approve`)}),(0,$.jsx)(Y,{size:`xs`,variant:`destructive`,onClick:async()=>{await X.resolveWorkflowApproval(e.id,t.id,!1),await c()},children:n(`chat:workflowRun.reject`)})]})]},t.id)),(e.error||e.summary)&&(0,$.jsx)(`p`,{children:e.error||e.summary}),di(e)&&(0,$.jsxs)(Y,{size:`xs`,variant:`destructive`,className:`self-start`,onClick:async()=>{await X.stopWorkflowRun(e.id),await c()},children:[(0,$.jsx)(dt,{"data-icon":`inline-start`}),n(`chat:workflowRun.stop`)]})]})]},e.id)})})}function mi(e,t){let[n,r]=(0,Q.useState)(()=>Date.now());(0,Q.useEffect)(()=>{if(!t)return;r(Date.now());let e=setInterval(()=>r(Date.now()),1e3);return()=>clearInterval(e)},[t]);let i=e?Date.parse(e):NaN;return t&&Number.isFinite(i)?Math.max(0,n-i):null}function hi(e,t){sr.getState().update(e,`side-chat`,{type:`open`,kind:`side-chat`}),t?.show(`side-chat`)}function gi(e,t){let{t:n,language:r}=o(),i=(0,Q.useContext)(Me),[a,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(!1),f=T(e=>e.capabilities.features.sessionExport===!0),p=e.name||n(`navigation:pageHeader.newChat`),{notify:m}=t,h=async()=>{if(!c){l(!0);try{await pn(e.id,{archived:!0}),m(n(`board:action.archived`,{title:p})),i?.onArchived?.(e.id)}catch{m(n(`board:action.failed`),`error`)}finally{l(!1)}}},g=async()=>{if(!u){d(!0);try{let t=await X.exportSessionMarkdown(e.id,r),i=URL.createObjectURL(t),a=document.createElement(`a`);a.href=i,a.download=`${p.replace(/[\\/:*?"<>|\p{Cc}]/gu,`-`).slice(0,80)||`session`}.md`,a.click(),window.setTimeout(()=>URL.revokeObjectURL(i),1e3),m(n(`chat:sessionMenu.exported`,{title:p}))}catch{m(n(`chat:sessionMenu.exportFailed`),`error`)}finally{d(!1)}}},_=typeof t.contextPercent==`number`&&Number.isFinite(t.contextPercent)?Math.round(Math.min(100,Math.max(0,t.contextPercent))):null,v=[{key:`rename`,icon:it,label:n(`chat:sessionMenu.rename`),onSelect:t.onRename},...t.onSideChat?[{key:`side-chat`,icon:tt,label:n(`board:inspector.sideChat`),onSelect:t.onSideChat,marker:`session-side-chat`}]:[],...f?[{key:`export`,icon:Br,label:n(`chat:sessionMenu.exportMarkdown`),onSelect:()=>void g(),disabled:u,marker:`session-export`}]:[],...e.machine?[]:[{key:`workspace`,icon:Xe,label:n(`board:session.moveWorkspace`),onSelect:t.onWorkspace,disabled:t.workspaceDisabled,separator:!0}],{key:`compact`,icon:Gr,label:n(`chat:sessionMenu.compactContext`),onSelect:()=>t.onCompact?.(),disabled:t.compactDisabled||!t.onCompact,trailing:_===null?void 0:`${_}%`,trailingTitle:_===null?void 0:n(`board:session.contextUsage`,{percent:_})},...t.workflowsAvailable?[{key:`workflows`,icon:gt,label:n(`chat:sessionMenu.workflowRuns`),onSelect:()=>s(!0)}]:[],{key:`voice`,icon:Ir,label:n(`chat:sessionMenu.voiceMode`),onSelect:t.onVoiceMode},{key:`archive`,icon:j,label:n(`board:card.archive`),onSelect:()=>void h(),disabled:c,separator:!0}];return{entries:v,items:(0,$.jsxs)($.Fragment,{children:[v.map(e=>{let t=e.icon,n=e.marker?{[`data-${e.marker}`]:!0}:{},r=(0,$.jsxs)(St,{disabled:e.disabled,onSelect:e.onSelect,...n,children:[(0,$.jsx)(t,{}),e.label,e.trailing&&(0,$.jsx)(Ct,{className:`font-mono tabular-nums`,title:e.trailingTitle,"data-session-context-usage":!0,children:e.trailing})]});return(0,$.jsxs)(Q.Fragment,{children:[e.separator&&(0,$.jsx)(xt,{}),r]},e.key)}),t.extraItems&&(0,$.jsx)(xt,{}),t.extraItems]}),dialog:(0,$.jsx)(Pn,{open:a,onOpenChange:s,children:(0,$.jsxs)(jn,{className:`max-w-lg`,children:[(0,$.jsxs)(Nn,{children:[(0,$.jsx)(Mn,{children:n(`board:session.workflowRuns`)}),(0,$.jsx)(An,{children:p})]}),a&&(0,$.jsx)(pi,{sessionId:e.id,empty:(0,$.jsx)(`p`,{className:`py-6 text-center text-sm text-content-muted`,children:n(`board:session.workflowRunsEmpty`)})})]})})}}var _i=(0,Q.lazy)(()=>t(()=>import(`./SessionInspector-B41l7gKR.js`).then(e=>({default:e.SessionInspector})),__vite__mapDeps([122,1,3,4,5,2,6,7,8,9,23,24,10,11,12,13,14,15,16,18,17,123,20,22,19,25,26,27,21,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,124,125,126,127,128,116,117,129,119,120,121,130]))),vi=[];function yi(e){switch(e){case`changes`:return{tab:`changes`,changesView:`workspace`};case`files`:return{tab:`changes`,changesView:`session`};case`terminal`:case`processes`:return{tab:`terminal`,terminalView:e};case`sources`:return{tab:`files`};case`browser`:return{tab:`preview`};case`plan`:return{tab:`plan`};case`side-chat`:return{tab:`side-chat`};default:return null}}function bi(e){if(!(e instanceof HTMLElement)||e===document.body||e.closest(`[data-inspector-sheet]`))return null;let t=e.closest(`[role="menu"]`);if(!t)return e;let n=t.getAttribute(`aria-labelledby`);return n?document.getElementById(n):null}var xi=`a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), iframe, [tabindex]:not([tabindex="-1"])`;function Si(e){if(e.key!==`Tab`||e.altKey||e.ctrlKey||e.metaKey)return;let t=[...e.currentTarget.querySelectorAll(xi)].filter(e=>e.getClientRects().length>0);if(!t.length)return;let n=t[0],r=t[t.length-1],i=document.activeElement;(e.shiftKey?i===n:i===r)&&(e.preventDefault(),(e.shiftKey?r:n).focus())}function Ci(e){let t=e?.items??[];return t.length?{done:t.filter(e=>e.status===`completed`).length,total:t.length}:null}function wi({sessionId:e,messages:t,cwd:n,active:r,plan:i,goal:a=null,team:s=null,activity:c=vi,planTab:l,streaming:u,completed:d,runStartedAt:f,requestConfirm:p,remoteMachine:m=!1,children:h}){let{t:g}=o(),_=(0,Q.useContext)(Me),v=!!(_?.phone??null),y=v||!!(_?.compact||_?.overlayOnly),[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(null),w=(0,Q.useMemo)(()=>({headerHost:b,sourceActionHost:S,setSourceActionHost:C}),[b,S]),T=(0,Q.useMemo)(()=>ri(t),[t]),E=pr(e=>e.open),D=pr(e=>e.pinned),O=pr(e=>e.setOpen),k=pr(e=>e.widthPercent),A=pr(e=>e.width),j=pr(e=>e.setWidth),M=pr(e=>e.resetWidth),[N,P]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{y||P(!1)},[y]);let F=y?N:E,I=ui(v&&F),L=v&&I.leaving,R=(0,Q.useRef)(null),z=`session-${e}-inspector`,B=(0,Q.useRef)(null),[V,ee]=(0,Q.useState)(0);(0,Q.useLayoutEffect)(()=>{let e=B.current;if(!e)return;let t=()=>ee(e.clientWidth);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let te=fr({widthPercent:k,width:A},V||window.innerWidth),[ne,re]=(0,Q.useState)(0);(0,Q.useLayoutEffect)(()=>{if(!b)return;let e=()=>re(b.offsetHeight);e();let t=new ResizeObserver(e);return t.observe(b),()=>t.disconnect()},[b]);let H=(0,Q.useRef)(null),[ie,ae]=(0,Q.useState)(!1),[U,W]=(0,Q.useState)(!1),oe=(0,Q.useCallback)((e,t=!1)=>{if(window.dispatchEvent(new Event(Xt)),v&&e){let e=bi(document.activeElement);e&&(R.current=e)}ae(e),W(e&&t),y?P(e):O(e)},[y,O,v]),ce=(0,Q.useCallback)((e,t)=>{pr.getState().setTab(e),oe(!0,t)},[oe]),G=(0,Q.useCallback)(e=>ce(e,!0),[ce]),le=(0,Q.useCallback)(()=>{let e=document.activeElement,t=!!(e&&H.current?.contains(e))||y&&!v&&(!e||e===document.body);oe(!1),t&&requestAnimationFrame(()=>document.querySelector(`[aria-controls="${CSS.escape(z)}"][data-inspector-toggle]`)?.focus())},[y,z,oe,v]),K=(0,Q.useCallback)(()=>F?le():oe(!0,!0),[le,F,oe]),ue=(0,Q.useCallback)(t=>{t.preventDefault();let n=R.current;R.current=null,((n?.isConnected?n:null)??document.querySelector(`[data-session-changes][aria-controls="${CSS.escape(z)}"]`)??document.getElementById(`task-${e}-more`))?.focus({preventScroll:!0})},[z,e]),de=v?`sheet`:y?`overlay`:`aside`,fe=(0,Q.useMemo)(()=>({open:F,mode:de,panelId:z,toggle:K,show:G}),[F,de,z,G,K]),pe=(0,Q.useCallback)(e=>{let t=yi(e);if(!t)return;let n=pr.getState();t.terminalView&&n.setTerminalView(t.terminalView),t.changesView&&n.setChangesView(t.changesView),ce(t.tab,!1)},[ce]);(0,Q.useEffect)(()=>sr.subscribe((t,n)=>{let r=t.sessions[e],i=n.sessions[e];if(!r||r===i||!r.contentOpen)return;let a=r.pages.find(e=>e.id===r.activeId);if(!a)return;let o=i?.pages.find(e=>e.id===i.activeId);(r.activeId!==i?.activeId||!i?.contentOpen||a.kind===`browser`&&a.url!==o?.url)&&pe(a.kind)}),[pe,e]),(0,Q.useEffect)(()=>{if(!r)return;let t=t=>{let n=ei(t.detail);n&&sr.getState().update(e,n,{type:`open`,kind:n})};return window.addEventListener(Qr,t),()=>window.removeEventListener(Qr,t)},[r,e]),(0,Q.useEffect)(()=>{if(!r)return;let t=t=>{let n=t.detail;n===`side-chat`?hi(e,fe):n===`tree`&&B.current?.querySelector(`[data-session-branches]`)?.click()};return window.addEventListener(Kt,t),()=>window.removeEventListener(Kt,t)},[r,fe,e]),Zr({sessionId:e,streaming:u,completed:d,runStartedAt:f,enabled:!y,open:F,onReveal:()=>pe(`files`)});let me=nn(e=>e.bindings.toggleInspector);(0,Q.useEffect)(()=>{if(!r)return;let e=e=>{!on(e,me)||tn(e)||rn(e)&&e.key.length===1||(e.preventDefault(),K())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r,me,K]),Yr(r&&y&&N,100,le),Yr(r&&!y&&E&&!D,100,le);let he=(0,Q.useRef)(()=>{});(0,Q.useEffect)(()=>()=>he.current(),[]);let q=e=>{if(e.button!==0)return;he.current(),e.preventDefault(),e.currentTarget.focus(),e.currentTarget.setPointerCapture(e.pointerId);let t=e.clientX,n=te,r=e=>j(mr(n-(e.clientX-t),V),V),i=()=>{window.removeEventListener(`pointermove`,r),window.removeEventListener(`pointerup`,i),window.removeEventListener(`pointercancel`,i)};he.current=i,window.addEventListener(`pointermove`,r),window.addEventListener(`pointerup`,i,{once:!0}),window.addEventListener(`pointercancel`,i,{once:!0})},ge=u?Ci(i):null,_e=ie&&F&&!y,ve=y&&!v&&F&&V-420>=480?420:0,ye=(F||L)&&(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`p`,{role:`status`,className:`p-4 text-sm text-content-muted`,children:g(`chat:focusSession.gitLoading`)}),children:(0,$.jsx)(_i,{panelId:z,sessionId:e,cwd:n,streaming:u,plan:i,goal:a,team:s,activity:c,planTab:l,sources:T,mode:de,requestConfirm:p,onClose:le,onOpenComponents:_?.onOpenComponents,componentTabs:_?.componentTabs,autoFocus:de===`overlay`&&U,remoteMachine:m})});return(0,$.jsx)(Pe.Provider,{value:w,children:(0,$.jsx)(je.Provider,{value:fe,children:(0,$.jsxs)(`div`,{ref:B,id:`task-${e}-workspace`,tabIndex:-1,"data-task-workspace":e,"data-session-workspace":de,"data-active":r,className:Lt(`relative flex h-full min-h-0 min-w-0 overflow-hidden bg-panel`,v&&`pb-[var(--pisper-safe-area-bottom)] [[data-mobile-keyboard='open']_&]:pb-0`),children:[(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,"data-session-conversation":!0,children:[(0,$.jsx)(`div`,{ref:x,className:`@container shrink-0`,"data-task-header":!0}),ge&&(0,$.jsxs)(`div`,{className:`relative z-10 h-0.5 shrink-0 bg-surface-muted`,"data-plan-progress":!0,children:[(0,$.jsx)(`span`,{role:`progressbar`,"aria-label":g(`board:session.planLabel`,ge),"aria-valuemin":0,"aria-valuemax":ge.total,"aria-valuenow":ge.done,className:`absolute inset-0 origin-left bg-st-run transition-transform duration-(--d-base)`,style:{transform:`scaleX(${ge.done/ge.total})`}}),l&&(0,$.jsx)(`button`,{type:`button`,className:`absolute top-1.5 right-3 inline-flex h-6 items-center rounded-sm bg-panel px-2 font-mono text-xs text-content-secondary tabular-nums shadow-edge hover:bg-surface-hover hover:text-content focus-visible:outline-2 focus-visible:outline-focus pointer-coarse:h-11`,"aria-label":g(`board:session.planOpen`,{plan:g(`board:session.plan`,ge)}),"aria-controls":z,"data-plan-progress-open":!0,onClick:()=>G(`plan`),children:g(`board:session.plan`,ge)})]}),(0,$.jsx)(`div`,{className:Lt(`min-h-0 min-w-0 flex-1 overflow-hidden`,_e&&`animate-in duration-[220ms] ease-(--ease)`),"data-overlay-inset":ve||void 0,style:ve?{paddingRight:ve}:_e?{"--tw-enter-translate-x":`${te/2}px`}:void 0,children:h})]}),!y&&F&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-orientation":`vertical`,"aria-label":g(`chat:sessionContext.resize`),title:g(`chat:sessionContext.resizeHint`),"aria-controls":z,"aria-valuemin":360,"aria-valuemax":mr(1/0,V),"aria-valuenow":te,onPointerDown:q,onDoubleClick:M,onKeyDown:e=>{if(![`ArrowLeft`,`ArrowRight`,`Enter`].includes(e.key))return;if(e.preventDefault(),e.key===`Enter`){M();return}let t=e.shiftKey?64:16;j(mr(te+(e.key===`ArrowLeft`?t:-t),V),V)},className:`relative -mr-1 w-2 shrink-0 cursor-col-resize touch-none select-none outline-none after:absolute after:inset-y-0 after:left-1/2 after:w-px after:bg-stroke-soft after:transition-colors after:duration-(--d-fast) hover:after:w-[3px] hover:after:-translate-x-px hover:after:bg-focus focus-visible:after:w-[3px] focus-visible:after:bg-focus`}),(0,$.jsxs)(`aside`,{ref:H,className:Lt(`flex h-full min-h-0 shrink-0 flex-col overflow-hidden border-l border-stroke-soft`,ie&&`animate-in slide-in-from-right duration-[220ms] ease-(--ease)`),style:{width:te},"data-inspector-aside":!0,"data-inspector-pinned":D||void 0,children:[(0,$.jsx)(`div`,{"aria-hidden":`true`,"data-window-drag-region":!0,"data-inspector-titlebar-gap":!0,className:`hidden h-[52px] shrink-0 [[data-custom-titlebar]_&]:block`}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:ye})]})]}),y&&(F||L)&&(0,$.jsx)($.Fragment,{children:v?(0,$.jsx)(fn,{open:F,onOpenChange:e=>!e&&le(),children:(0,$.jsxs)(ln,{side:`bottom`,showCloseButton:!1,"data-inspector-sheet":!0,"data-sheet-leaving":L||void 0,onAnimationEnd:e=>{e.target===e.currentTarget&&!F&&I.finish()},onCloseAutoFocus:ue,className:`gap-0 data-[side=bottom]:h-[min(86dvh,calc(100dvh-var(--pisper-safe-area-top)-48px))] overflow-hidden rounded-t-(--r-sheet) bg-panel p-0 pb-[var(--pisper-safe-area-bottom)]`,children:[(0,$.jsx)(un,{className:`sr-only`,children:g(`board:inspector.label`)}),(0,$.jsx)(dn,{className:`sr-only`,children:g(`board:phone.inspectorDescription`)}),(0,$.jsx)(se,{onDismiss:le}),(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col [&_[data-slot=segmented-control]]:h-11 [&_[data-slot=segmented-control-item]]:h-10 [&_[data-slot=segmented-control-item]]:px-3`,children:ye})]})}):(0,$.jsx)(`aside`,{ref:H,"data-inspector-overlay":!0,onKeyDown:Si,className:Lt(`absolute right-0 bottom-0 z-30 max-w-[calc(100%-24px)] overflow-hidden border-l border-stroke bg-panel shadow-float`,`animate-in slide-in-from-right duration-[220ms] ease-(--ease)`),style:{width:420,top:ne},children:ye})})]})})})}var Ti=e(i(),1),Ei=(0,Q.createContext)(null),Di=(0,Q.lazy)(()=>t(()=>import(`./public-session-CuS3mRPA.js`),__vite__mapDeps([131,1,2,3,4,5,6,7,8,9,132,18,35,34,36,33,133,93,134,78,24,79,12,13,14,15,16,135,136,10,11,37,120])));function Oi({session:e,cwd:t,streaming:n,treeAvailable:r,branches:i,onOpenTree:a,...s}){let c=e.machine?`${e.machine.name}:${e.machine.cwd}`:t,{t:l,language:u}=o(),d=(0,Q.useContext)(je),f=gi(e,{...s,onSideChat:()=>hi(e.id,d)}),m=e.name||l(`navigation:pageHeader.newChat`),h=yn(e.projectless?``:c,u),g=e.machine?mn(e.machine):h,_=p({queryKey:[`session-change-summary`,e.id,n],queryFn:()=>Bn(e.id),staleTime:1e4}),v=_.data?.status===`known`?_.data:null,y=v?.changedFiles??0,b=nn(e=>e.bindings.toggleInspector),x=nn(e=>e.bindings.sessionTree),S=cn(b),C=cn(x),w=y>0?l(`board:session.changes`,{count:y,added:v?.added??0,removed:v?.removed??0}):null,T=w?`${l(`board:inspector.label`)} · ${w}`:l(`board:inspector.label`),E=S?l(`board:session.withShortcut`,{label:T,shortcut:S}):T,D=i>0?l(`board:session.treeBranches`,{count:i}):l(`board:session.tree`),O=C?l(`board:session.withShortcut`,{label:D,shortcut:C}):D;return(0,$.jsxs)(`header`,{"data-session-header":!0,"data-focus-region":`header`,"data-window-drag-region":!0,className:`flex h-[52px] min-w-0 shrink-0 items-center gap-2 pr-3 pl-4 [[data-custom-titlebar]_&]:pr-[144px]`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,"data-window-drag-region":!0,children:[e.botId&&(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Di,{botId:e.botId,part:`avatar`})}),(0,$.jsxs)(Et,{children:[(0,$.jsx)(wt,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,id:`task-${e.id}-more`,"data-session-menu":!0,className:Lt(`group inline-flex h-8 min-w-0 shrink items-center gap-1 rounded-sm px-2 text-[15px] leading-6 font-medium text-content hover:bg-surface-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-focus data-[state=open]:bg-surface-hover pointer-coarse:h-11`,Mt),"aria-label":l(`board:session.titleMenu`,{title:m}),children:[(0,$.jsx)(`span`,{className:`truncate`,"data-session-title":!0,children:m}),(0,$.jsx)(I,{className:`size-3.5 flex-none text-content-muted`,"aria-hidden":`true`})]})}),(0,$.jsx)(Tt,{align:`start`,className:`min-w-60`,children:f.items})]}),(0,$.jsx)(`span`,{className:`min-w-0 max-w-[160px] flex-none truncate font-mono text-xs text-content-muted @max-[560px]:hidden`,title:c,"data-session-project":!0,children:g}),e.botId&&(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Di,{botId:e.botId,part:`settings`})}),r&&(0,$.jsxs)(Y,{type:`button`,variant:`ghost`,className:Lt(`h-7 min-w-7 flex-none gap-1 px-1.5 font-mono text-xs font-normal text-content-muted tabular-nums hover:text-content pointer-coarse:h-11 pointer-coarse:min-w-11`),"aria-haspopup":`dialog`,"aria-label":O,title:O,"aria-keyshortcuts":Yn(x),"data-session-branches":i,onClick:e=>a(`branches`,e.currentTarget),children:[(0,$.jsx)(we,{className:`size-3.5`,"aria-hidden":`true`}),i>0&&(0,$.jsx)(`span`,{"aria-hidden":`true`,children:i})]})]}),d&&(0,$.jsx)(Y,{type:`button`,variant:`ghost`,className:Lt(`h-8 flex-none gap-1.5 px-2 text-[13px] font-normal text-content-secondary hover:text-content pointer-coarse:h-11`,w?``:`w-8 px-0 pointer-coarse:w-11`,d.open&&`bg-surface-hover text-content ring-1 ring-stroke ring-inset`),"data-inspector-toggle":!0,"data-session-changes":y,"aria-controls":d.panelId,"aria-expanded":d.open,"aria-label":E,title:E,"aria-keyshortcuts":Yn(b),onClick:d.toggle,children:w&&v?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(oe,{className:`size-3.5`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{"aria-hidden":`true`,children:l(`board:session.changedFiles`,{count:y})}),(0,$.jsxs)(`span`,{className:`font-mono text-xs text-success tabular-nums`,"aria-hidden":`true`,children:[`+`,v.added??0]}),(0,$.jsxs)(`span`,{className:`font-mono text-xs text-danger tabular-nums`,"aria-hidden":`true`,children:[`−`,v.removed??0]})]}):(0,$.jsx)(nt,{"aria-hidden":`true`})}),f.dialog]})}var ki=`outline-none focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-focus`,Ai={1:`grid-cols-1`,2:`grid-cols-2`,3:`grid-cols-3`};function ji({count:e,children:t}){return(0,$.jsx)(`div`,{className:Lt(`grid gap-2 px-1 pb-2`,Ai[e]??`grid-cols-3`),children:t})}function Mi({icon:e,label:t,className:n,...r}){return(0,$.jsxs)(`button`,{type:`button`,className:Lt(`flex h-[68px] min-w-0 cursor-pointer flex-col items-center justify-center gap-1.5 rounded-[var(--r-md)] bg-surface-muted px-1 text-[13px] text-content active:bg-surface-hover disabled:cursor-default disabled:text-content-faint`,ki,n),...r,children:[(0,$.jsx)(e,{className:`size-5 text-content-secondary`,strokeWidth:1.75,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`max-w-full truncate`,children:t})]})}function Ni({icon:e,label:t,hint:n,trailing:r,className:i,...a}){return(0,$.jsxs)(`button`,{type:`button`,className:Lt(`flex min-h-11 w-full min-w-0 cursor-pointer items-center gap-3 rounded-[var(--r-md)] px-3 text-left text-[15px] text-content active:bg-surface-hover disabled:cursor-default disabled:text-content-faint`,ki,i),...a,children:[(0,$.jsx)(e,{className:`size-[18px] flex-none text-content-secondary`,strokeWidth:1.75,"aria-hidden":`true`}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:t}),n&&(0,$.jsx)(`span`,{className:`truncate text-xs text-content-muted`,children:n})]}),r]})}var Pi=`relative grid size-11 flex-none place-items-center rounded-full bg-surface-muted text-content focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus active:bg-surface-hover dark:bg-surface-active`;function Fi({leading:e,session:t,cwd:n,streaming:r,runStartedAt:i,approvals:a,failed:s,stopped:c,treeAvailable:l,branches:u,onOpenTree:d,...f}){let m=t.machine?`${t.machine.name}:${t.machine.cwd}`:n,{t:h,language:g}=o(),_=(0,Q.useContext)(je),v=(0,Q.useContext)(Me),y=mi(i,r),b=gi(t,f),[x,S]=(0,Q.useState)(!1),C=(0,Q.useId)(),w=t.name||h(`navigation:pageHeader.newChat`),T=yn(t.projectless?``:m,g),E=t.machine?mn(t.machine):T,D=p({queryKey:[`session-change-summary`,t.id,r],queryFn:()=>Bn(t.id),staleTime:1e4}),O=D.data?.status===`known`?D.data.changedFiles??0:0,k=a>0?{kind:`approval`,label:h(`board:status.approval`)}:r?{kind:`running`,label:y===null?h(`board:status.running`):h(`board:phone.running`,{elapsed:xn(y)})}:s?{kind:`failed`,label:h(`board:status.failed`)}:c?{kind:`stopped`,label:h(`board:status.stopped`)}:null,A=()=>_?.show(`changes`),j=[...l?[{key:`tree`,icon:we,label:u>0?h(`board:session.treeBranches`,{count:u}):h(`board:session.tree`),shortLabel:h(`board:session.tree`),onSelect:()=>d(`branches`),marker:`session-tree`}]:[],{key:`side-chat`,icon:tt,label:h(`board:inspector.sideChat`),onSelect:()=>hi(t.id,_),marker:`session-side-chat`},..._?[{key:`inspector`,icon:oe,label:h(`board:phone.openInspector`),shortLabel:h(`board:phone.openInspectorShort`),onSelect:A,marker:`inspector-toggle`}]:[]];return(0,$.jsxs)(`header`,{"data-session-header":`phone`,className:`grid h-14 min-w-0 shrink-0 grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center bg-panel px-3`,children:[(0,$.jsx)(`div`,{className:`flex min-w-0 items-center`,children:e}),(0,$.jsxs)(`button`,{type:`button`,"data-session-menu-trigger":!0,"aria-haspopup":`dialog`,"aria-expanded":x,"aria-controls":x?C:void 0,"aria-label":h(`board:session.titleMenu`,{title:w}),className:`flex h-11 max-w-[min(58vw,260px)] min-w-0 flex-col items-center justify-center rounded-[var(--r-md)] px-2 outline-none focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-focus active:bg-surface-hover`,onClick:()=>S(!0),children:[(0,$.jsxs)(`span`,{className:`flex max-w-full min-w-0 items-center gap-0.5 text-base leading-5 font-semibold text-content`,children:[(0,$.jsx)(`span`,{className:`truncate`,"data-session-title":!0,children:w}),(0,$.jsx)(I,{className:`size-4 flex-none text-content-muted`,"aria-hidden":`true`})]}),(0,$.jsxs)(`span`,{className:`flex max-w-full min-w-0 items-center gap-1 text-xs leading-4 text-content-muted`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate font-mono`,title:m,"data-session-project":!0,children:E}),k&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,$.jsxs)(`span`,{className:Lt(`flex flex-none items-center gap-1`,(k.kind===`approval`||k.kind===`failed`)&&`font-medium text-warning-strong`),"data-session-status":k.kind,children:[(0,$.jsx)(Sn,{status:k.kind===`running`?`run`:k.kind===`stopped`?`stopped`:`attention`,className:`size-3`}),(0,$.jsx)(`span`,{className:`tabular-nums`,children:k.label})]})]})]})]}),(0,$.jsx)(`div`,{className:`flex min-w-0 items-center justify-end`,children:O>0&&_?(0,$.jsxs)(`button`,{type:`button`,"data-session-changes":O,"aria-haspopup":`dialog`,"aria-controls":_.panelId,"aria-label":h(`board:phone.changesLabel`,{count:O}),className:Pi,onClick:A,children:[(0,$.jsx)(oe,{className:`size-5`,strokeWidth:1.75,"aria-hidden":`true`}),(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`absolute top-1.5 right-1 grid h-4 min-w-4 place-items-center rounded-full bg-content px-1 text-[10px] leading-none font-semibold text-panel tabular-nums`,children:O>99?`99+`:O})]}):v?.phone?(0,$.jsx)(`button`,{type:`button`,"data-phone-new-task":!0,"aria-label":h(`navigation:shell.newTask`),className:Pi,onClick:v.phone.onNewTask,children:(0,$.jsx)(J,{className:`size-5`,strokeWidth:1.75,"aria-hidden":`true`})}):null}),(0,$.jsx)(fn,{open:x,onOpenChange:S,children:(0,$.jsxs)(ln,{id:C,side:`bottom`,showCloseButton:!1,"data-session-menu-sheet":!0,className:`max-h-[85dvh] gap-0 rounded-t-(--r-sheet) px-2 pt-1 pb-[calc(8px+var(--pisper-safe-area-bottom))]`,children:[(0,$.jsx)(se,{onDismiss:()=>S(!1)}),(0,$.jsx)(un,{className:`truncate px-3 pt-1 pb-0.5 text-base font-semibold`,children:w}),(0,$.jsx)(dn,{className:`truncate px-3 pb-2 font-mono text-xs text-content-muted`,children:T}),(0,$.jsx)(ji,{count:j.length,children:j.map(e=>{let t=e.marker?{[`data-${e.marker}`]:!0}:{};return(0,$.jsx)(Mi,{icon:e.icon,label:e.shortLabel||e.label,"aria-label":e.label,onClick:()=>{S(!1),e.onSelect()},...t},e.key)})}),(0,$.jsx)(`div`,{className:`min-h-0 overflow-y-auto`,role:`list`,children:b.entries.map(e=>{let t=e.marker?{[`data-${e.marker}`]:!0}:{};return(0,$.jsxs)(`div`,{role:`listitem`,children:[e.separator&&(0,$.jsx)(`div`,{"aria-hidden":`true`,className:`mx-3 my-1 h-px bg-stroke-soft`}),(0,$.jsx)(Ni,{icon:e.icon,label:e.label,disabled:e.disabled,trailing:e.trailing&&(0,$.jsx)(`span`,{className:`flex-none font-mono text-sm text-content-muted tabular-nums`,title:e.trailingTitle,"data-session-context-usage":!0,children:e.trailing}),onClick:()=>{S(!1),e.onSelect()},...t})]},e.key)})})]})}),b.dialog]})}function Ii({cwd:e,selection:t}){let{t:n}=o(),r=D(),i=(0,Q.useRef)(null);return{input:(0,$.jsx)(`input`,{ref:i,type:`file`,className:`hidden`,accept:G,multiple:!0,"aria-label":n(`chat:focusSession.addAttachment`),onChange:e=>{let n=[...e.currentTarget.files||[]];e.currentTarget.value=``,n.length&&t.addFiles(n)}}),choose:async()=>{if(r){i.current?.click();return}if(window.pisperDesktop?.pickFiles){try{let n=await window.pisperDesktop.pickFiles(e);t.addAttachments(q(n||[]))}catch(e){t.setError(e)}return}i.current?.click()}}}function Li({cwd:e,selection:t}){let{t:n}=o(),{input:r,choose:i}=Ii({cwd:e,selection:t});return(0,$.jsxs)($.Fragment,{children:[r,(0,$.jsxs)(`button`,{type:`button`,className:`relative grid size-[30px] min-w-[30px] flex-none cursor-pointer place-items-center rounded-sm border-0 bg-transparent text-content-muted transition-colors hover:bg-surface-hover hover:text-content disabled:cursor-not-allowed disabled:opacity-50 max-[650px]:size-11 max-[650px]:min-w-11 pointer-coarse:size-11 pointer-coarse:min-w-11`,title:n(`chat:focusSession.addAttachment`),"aria-label":n(`chat:focusSession.addAttachment`),onClick:()=>void i(),children:[(0,$.jsx)(rt,{size:16}),t.attachments.length>0&&(0,$.jsx)(`span`,{className:`absolute -top-1 -right-1 grid h-4 min-w-4 place-items-center rounded-full border-2 border-panel bg-star px-0.5 text-[10px] leading-none font-medium text-on-accent tabular-nums`,children:t.attachments.length})]})]})}function Ri({attachments:e,preparing:t=[],onRemove:n,compact:r=!1}){let{t:i}=o();return!e.length&&!t.length?null:(0,$.jsxs)(`div`,{className:`attachment-tray [&.compact]:max-h-[58px] flex max-h-[116px] flex-wrap gap-[6px] overflow-auto ${r?`compact`:``}`,children:[t.map(e=>(0,$.jsxs)(`div`,{className:`flex min-h-[42px] max-w-64 items-center gap-2 rounded-sm border border-stroke bg-surface-subtle pr-1 pl-2.5`,"aria-busy":`true`,children:[(0,$.jsx)(Rt,{className:`size-3.5`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-content`,children:e.name}),(0,$.jsx)(`span`,{className:`sr-only`,children:i(`chat:focusSession.preparingAttachments`)}),(0,$.jsx)(`button`,{type:`button`,className:`grid size-8 shrink-0 cursor-pointer place-items-center rounded-sm text-content-muted hover:bg-danger-soft hover:text-danger max-[650px]:size-11`,"aria-label":i(`chat:focusSession.removeName`,{name:e.name}),onClick:()=>n(e.id),children:(0,$.jsx)(vt,{size:14})})]},e.id)),e.map(e=>(0,$.jsxs)(`div`,{className:`attachment-chip grid min-h-[42px] min-w-[150px] max-w-[250px] grid-cols-[30px_minmax(0,1fr)_auto] items-center gap-2 rounded-sm border border-stroke bg-surface-subtle p-1.5 pr-1 [&_>_button]:grid [&_>_button]:size-7 [&_>_button]:cursor-pointer [&_>_button]:place-items-center [&_>_button]:rounded-xs [&_>_button]:text-content-muted [&_>_button:hover]:bg-danger-soft [&_>_button:hover]:text-danger max-[650px]:[&_>_button]:size-11 [&_>_img]:size-[30px] [&_>_img]:rounded-xs [&_>_img]:object-cover [&_>_span:nth-child(2)]:flex [&_>_span:nth-child(2)]:min-w-0 [&_>_span:nth-child(2)]:flex-col [&_small]:text-xs [&_small]:text-content-muted [&_small]:tabular-nums [&_strong]:truncate [&_strong]:font-mono [&_strong]:text-xs [&_strong]:font-medium [&_strong]:text-content`,children:[e.kind===`image`?(0,$.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:``}):(0,$.jsx)(`span`,{className:`grid size-[30px] place-items-center rounded-xs border border-key-border bg-key text-content-muted`,children:(0,$.jsx)(be,{size:13})}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`strong`,{children:e.name}),(0,$.jsxs)(`small`,{children:[e.kind===`path`?i(`chat:focusSession.localPath`):e.kind===`image`?i(`chat:focusSession.image`):e.kind===`document`?i(`chat:focusSession.document`):i(`chat:focusSession.text`),e.kind===`path`?``:` · ${vn(e.size)}`,e.truncated?` · ${i(`chat:focusSession.truncated`)}`:``]})]}),(0,$.jsx)(`button`,{type:`button`,"aria-label":i(`chat:focusSession.removeName`,{name:e.name}),onClick:()=>n(String(e.id||``)),children:(0,$.jsx)(vt,{size:12})})]},e.id))]})}function zi({open:e,sessionId:t,cwd:n=``,onClose:r,onSelect:i,onCommandSelect:a}){let{t:s}=o(),c=T(e=>e.capabilities),l=w(c,`workflows`),[u,d]=(0,Q.useState)([]),[f,p]=(0,Q.useState)(`all`),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)({}),[b,x]=(0,Q.useState)(!1),[S,E]=(0,Q.useState)(``);(0,Q.useEffect)(()=>{if(!e)return;let r=!0;return p(`all`),h(``),_(null),y({}),x(!0),E(``),Promise.all([t?X.getSessionCommands(t):X.getWorkspaceCommands(n),l?C(`/api/workflows`):Promise.resolve({workflows:[]}),C(`/api/plugins?sessionId=${encodeURIComponent(t)}`)]).then(([e,t,n])=>{if(!r)return;let i=new Set(n.callableToolNames||[]);d([...(e.commands||[]).map(e=>({kind:e.source,id:e.name,name:e.name,description:e.description||``,inputs:[],argumentHint:e.argumentHint,invocation:e.invocation})),...(t.workflows||[]).filter(e=>e.status===`published`).map(e=>({kind:`workflow`,id:e.id,name:e.name,description:e.description||``,inputs:e.inputs||[]})),...(n.plugins||[]).flatMap(e=>(e.capabilities||[]).filter(e=>i.has(e.name)).map(t=>({kind:`tool`,id:t.name,name:t.id?hr(t,s):String(t.label||t.name),description:t.id?gr(t,s):t.description,inputs:[],sourceName:e.name})))])}).catch(e=>{r&&(d([]),E(e instanceof Error?e.message:String(e)))}).finally(()=>r&&x(!1)),()=>{r=!1}},[n,e,t,s,l]);let D=(0,Q.useMemo)(()=>({all:u.length,prompt:u.filter(e=>e.kind===`prompt`).length,skill:u.filter(e=>e.kind===`skill`).length,tool:u.filter(e=>e.kind===`tool`).length,workflow:u.filter(e=>e.kind===`workflow`).length}),[u]),O=(0,Q.useMemo)(()=>{let e=m.trim().toLowerCase();return u.filter(t=>(f===`all`||t.kind===f)&&(!e||`${t.name} ${t.id} ${t.description} ${t.kind===`tool`?t.sourceName:``}`.toLowerCase().includes(e)))},[f,m,u]),k=e=>{let t=e;p(t),g&&t!==`all`&&g.kind!==t&&_(null)},A=e=>{_(e),y(Object.fromEntries(e.inputs.map(e=>[e.name,e.defaultValue??``])))};return(0,$.jsx)(Pn,{open:e,onOpenChange:e=>!e&&r(),children:(0,$.jsxs)(jn,{className:`chat-resource-dialog w-[min(820px,calc(100vw_-_32px))] h-[min(600px,calc(100dvh_-_32px))] max-w-[820px] sm:max-w-[820px] grid-rows-[auto_minmax(0,1fr)] overflow-hidden max-[650px]:w-[calc(100vw_-_16px)] max-[650px]:h-[calc(100dvh_-_16px)] z-[220] gap-0 p-0 ring-0`,overlayClassName:`z-[220]`,showCloseButton:!1,children:[(0,$.jsxs)(`div`,{className:`chat-resource-head flex items-start justify-between gap-4 border-b border-stroke-soft px-[18px] pt-4 pb-3.5 max-[650px]:p-3.5 [&_[data-slot='dialog-description']]:mt-0.5 [&_[data-slot='dialog-description']]:text-xs [&_[data-slot='dialog-description']]:text-content-muted [&_[data-slot='dialog-title']]:text-base [&_[data-slot='dialog-title']]:font-semibold`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Mn,{children:s(`chat:resourcePicker.title`)}),(0,$.jsx)(An,{children:s(`chat:resourcePicker.description`)})]}),(0,$.jsx)(Y,{size:`icon-sm`,variant:`ghost`,"aria-label":s(`chat:resourcePicker.close`),onClick:r,children:(0,$.jsx)(vt,{})})]}),(0,$.jsxs)(`div`,{className:`chat-resource-body grid min-h-0 grid-cols-[minmax(0,1.1fr)_minmax(260px,.9fr)] overflow-hidden max-[650px]:grid-cols-[1fr] max-[650px]:grid-rows-[minmax(0,1fr)_minmax(190px,auto)] max-[650px]:overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`chat-resource-browser flex min-h-0 min-w-0 flex-col border-r border-stroke-soft p-3 max-[650px]:min-h-0 max-[650px]:border-r-0 max-[650px]:border-b`,children:[(0,$.jsx)(jt,{value:f,onValueChange:k,className:`chat-resource-tabs w-full [&_[data-slot='tabs-list']]:grid [&_[data-slot='tabs-list']]:h-9 [&_[data-slot='tabs-list']]:w-full [&_[data-slot='tabs-list']]:rounded-sm [&_[data-slot='tabs-list']]:border [&_[data-slot='tabs-list']]:border-stroke [&_[data-slot='tabs-list']]:bg-surface-muted [&_[data-slot='tabs-list']]:p-0.5 [&_[data-slot='tabs-trigger']]:min-w-0 [&_[data-slot='tabs-trigger']]:gap-1 [&_[data-slot='tabs-trigger']]:rounded-xs [&_[data-slot='tabs-trigger']]:px-1.5 [&_[data-slot='tabs-trigger']]:text-xs [&_[data-slot='tabs-trigger']]:text-content-secondary [&_[data-slot='tabs-trigger'][data-state='active']]:bg-key [&_[data-slot='tabs-trigger'][data-state='active']]:text-content [&_[data-slot='tabs-trigger'][data-state='active']]:shadow-key [&_[data-slot='tabs-trigger']_small]:text-xs [&_[data-slot='tabs-trigger']_small]:font-normal [&_[data-slot='tabs-trigger']_small]:text-content-muted [&_[data-slot='tabs-trigger']_small]:tabular-nums ${l?`[&_[data-slot='tabs-list']]:grid-cols-[repeat(5,minmax(0,1fr))]`:`[&_[data-slot='tabs-list']]:grid-cols-[repeat(4,minmax(0,1fr))]`}`,children:(0,$.jsxs)(At,{"aria-label":s(`chat:resourcePicker.categories`),children:[(0,$.jsxs)(kt,{value:`all`,children:[s(`chat:resourcePicker.all`),(0,$.jsx)(`small`,{children:D.all})]}),(0,$.jsxs)(kt,{value:`prompt`,children:[s(`chat:resourcePicker.prompt`),(0,$.jsx)(`small`,{children:D.prompt})]}),(0,$.jsxs)(kt,{value:`skill`,children:[s(`chat:resourcePicker.skill`),(0,$.jsx)(`small`,{children:D.skill})]}),(0,$.jsxs)(kt,{value:`tool`,children:[s(`chat:resourcePicker.tool`),(0,$.jsx)(`small`,{children:D.tool})]}),l&&(0,$.jsxs)(kt,{value:`workflow`,children:[s(`chat:resourcePicker.workflow`),(0,$.jsx)(`small`,{children:D.workflow})]})]})}),(0,$.jsxs)(Rn,{className:`chat-resource-search mt-2`,children:[(0,$.jsx)(Ln,{children:(0,$.jsx)(ct,{"aria-hidden":`true`})}),(0,$.jsx)(In,{autoFocus:!0,value:m,"aria-label":s(`chat:resourcePicker.search`),onChange:e=>h(e.target.value),placeholder:s(`chat:resourcePicker.search`)})]}),(0,$.jsxs)(`div`,{className:`chat-resource-list mt-2 flex min-h-0 [flex:1_1_0] flex-col gap-px overflow-y-auto [overscroll-behavior:contain] [scrollbar-gutter:stable] [touch-action:pan-y] [&_>_button]:relative [&_>_button]:grid [&_>_button]:w-full [&_>_button]:cursor-pointer [&_>_button]:grid-cols-[28px_minmax(0,1fr)_auto] [&_>_button]:items-center [&_>_button]:gap-2 [&_>_button]:rounded-sm [&_>_button]:px-2 [&_>_button]:py-1.5 [&_>_button]:text-left [&_>_button]:text-content [&_>_button:hover]:bg-surface-hover [&_>_button.active]:bg-surface-hover [&_>_button.active]:before:absolute [&_>_button.active]:before:inset-y-1.5 [&_>_button.active]:before:left-0 [&_>_button.active]:before:w-[3px] [&_>_button.active]:before:rounded-full [&_>_button.active]:before:bg-star max-[650px]:[&_>_button]:min-h-11 [&_button_>_span:nth-child(2)]:flex [&_button_>_span:nth-child(2)]:min-w-0 [&_button_>_span:nth-child(2)]:flex-col [&_strong]:truncate [&_strong]:text-[13px] [&_strong]:font-medium [&_small]:truncate [&_small]:text-xs [&_small]:text-content-muted [&_em]:text-xs [&_em]:whitespace-nowrap [&_em]:text-content-muted [&_em]:not-italic [&_>_p]:m-auto [&_>_p]:text-xs [&_>_p]:text-content-muted`,children:[O.map(e=>{let t=e.kind===`prompt`?K:e.kind===`skill`?P:e.kind===`tool`?_t:gt;return(0,$.jsxs)(`button`,{type:`button`,className:g?.kind===e.kind&&g.id===e.id?`active`:``,onClick:()=>A(e),children:[(0,$.jsx)(`span`,{className:`list-icon grid size-7 place-items-center rounded-sm bg-surface-muted text-content-secondary`,children:(0,$.jsx)(t,{size:15})}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`strong`,{children:e.name}),(0,$.jsx)(`small`,{children:e.description})]}),(0,$.jsx)(`em`,{children:e.kind===`prompt`?s(`chat:resourcePicker.prompt`):e.kind===`skill`?`Skill`:e.kind===`tool`?s(`chat:resourcePicker.tool`):s(`chat:resourcePicker.workflow`)})]},`${e.kind}:${e.id}`)}),!O.length&&(0,$.jsx)(`p`,{children:b?s(`chat:resourcePicker.loading`):S||s(`chat:resourcePicker.empty`)})]})]}),(0,$.jsx)(`div`,{className:`chat-resource-config flex min-h-0 min-w-0 flex-col gap-4 overflow-y-auto overscroll-contain p-[18px] max-[650px]:max-h-[230px] max-[650px]:min-h-0 [&_>_div:first-child]:flex [&_>_div:first-child]:flex-col [&_>_div:first-child]:gap-1 [&_>_p]:m-auto [&_>_p]:text-xs [&_>_p]:text-content-muted [&_p]:text-xs [&_p]:text-content-muted [&_strong]:text-[15px] [&_strong]:font-medium`,children:g?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`strong`,{children:g.name}),(0,$.jsx)(`p`,{children:g.description||s(`chat:resourcePicker.noDescription`)})]}),g.kind===`workflow`&&g.inputs.length>0&&(0,$.jsx)(`div`,{className:`chat-resource-inputs flex flex-col gap-3 [&_label]:grid [&_label]:gap-1.5 [&_label]:text-xs [&_label]:font-medium [&_label]:text-content-secondary`,children:g.inputs.map(e=>(0,$.jsxs)(`label`,{children:[(0,$.jsxs)(`span`,{children:[e.label,e.required?` *`:``]}),e.type===`boolean`?(0,$.jsx)(bt,{checked:!!v[e.name],onCheckedChange:t=>y(n=>({...n,[e.name]:t===!0}))}):(0,$.jsx)(Fn,{type:e.type===`number`?`number`:`text`,required:e.required,value:String(v[e.name]??``),onChange:t=>y(n=>({...n,[e.name]:t.target.value}))})]},e.id))}),g.kind===`prompt`&&g.argumentHint&&(0,$.jsx)(`code`,{className:`w-fit max-w-full rounded-xs bg-inline-code px-1.5 py-1 font-mono text-xs [overflow-wrap:anywhere] text-content-secondary`,children:g.argumentHint}),(0,$.jsx)(Y,{className:`chat-resource-confirm min-h-8 min-w-[112px] self-start bg-star text-[var(--on-accent)] hover:bg-star-hover max-[650px]:min-h-11`,onClick:()=>{if(g){if(g.kind===`prompt`){a(g.invocation||`/${g.name}`),r();return}i({kind:g.kind,resourceId:g.id,resourceName:g.name,arguments:g.kind===`workflow`?v:void 0,behavior:g.kind===`workflow`?`background`:`foreground`}),r()}},children:g.kind===`prompt`?s(`chat:resourcePicker.insertPrompt`):s(`chat:resourcePicker.useResource`)})]}):(0,$.jsx)(`p`,{children:s(`chat:resourcePicker.chooseResource`)})})]})]})})}function Bi(e){let t=e.getHours();return t>=5&&t<11?`morning`:t>=11&&t<13?`noon`:t>=13&&t<18?`afternoon`:t>=18&&t<23?`evening`:`lateNight`}function Vi(e){let t=new Date(e);return t.setHours(e.getHours()+1,0,0,0),Math.max(1e3,t.getTime()-e.getTime())}function Hi(){let{t:e}=o(),[t,n]=(0,Q.useState)(()=>new Date);(0,Q.useEffect)(()=>{let e=window.setTimeout(()=>n(new Date),Vi(t));return()=>window.clearTimeout(e)},[t]);let r=Bi(t),i=e(r===`morning`?`chat:newTask.greetingMorning`:r===`noon`?`chat:newTask.greetingNoon`:r===`afternoon`?`chat:newTask.greetingAfternoon`:r===`evening`?`chat:newTask.greetingEvening`:`chat:newTask.greetingLateNight`);return(0,$.jsxs)(`div`,{className:`grid min-h-full content-center justify-items-center gap-2 text-center max-[650px]:gap-3`,"data-new-task-greeting":!0,children:[(0,$.jsx)(_r,{size:32}),(0,$.jsx)(`h2`,{className:`text-2xl! font-semibold tracking-[-.01em] text-balance text-content max-[650px]:text-xl!`,children:i}),(0,$.jsx)(`p`,{className:`max-w-[46ch] text-sm leading-6 text-content-muted max-[650px]:hidden`,children:e(`board:home.draftHint`)})]})}function Ui({phone:e,leading:t,project:n}){let{t:r}=o();return e?(0,$.jsxs)(`header`,{"data-session-header":`draft`,"data-focus-region":`header`,className:`grid h-14 min-w-0 shrink-0 grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center bg-panel px-3`,children:[(0,$.jsx)(`div`,{className:`flex min-w-0 items-center`,children:t}),(0,$.jsxs)(`div`,{className:`flex max-w-[min(58vw,260px)] min-w-0 flex-col items-center justify-center`,children:[(0,$.jsx)(`h1`,{className:`max-w-full truncate px-1.5 text-base leading-5 font-semibold text-content`,children:r(`board:home.draftTitle`)}),n]}),(0,$.jsx)(`span`,{"aria-hidden":`true`})]}):(0,$.jsxs)(`header`,{"data-session-header":`draft`,"data-focus-region":`header`,"data-window-drag-region":!0,className:`flex h-[52px] min-w-0 shrink-0 items-center gap-2 border-b border-stroke-soft pr-2 pl-4 [[data-custom-titlebar]_&]:pr-[144px]`,children:[t,(0,$.jsx)(`h1`,{className:`flex-none text-[15px] leading-6 font-semibold text-content`,children:r(`board:home.draftTitle`)}),(0,$.jsx)(`span`,{className:`min-w-0 truncate text-xs text-content-muted`,children:r(`board:home.draftSubtitle`)})]})}var Wi=1e3;function Gi({option:e,selected:t,disabled:n,onSelect:r}){let i=e.icon;return(0,$.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t,disabled:n,className:`grid min-h-12 w-full cursor-pointer grid-cols-[16px_minmax(0,1fr)_16px] items-center gap-2.5 rounded-sm px-2 py-1.5 text-left text-content hover:bg-surface-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-focus disabled:cursor-default disabled:opacity-50 disabled:hover:bg-transparent max-[650px]:min-h-14`,"data-mode-option":e.value,onClick:()=>r(e.value),children:[(0,$.jsx)(i,{size:16,strokeWidth:1.75,className:`text-content-secondary`,"aria-hidden":`true`}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-px`,children:[(0,$.jsx)(`span`,{className:Lt(`text-[13px] max-[650px]:text-[15px]`,t&&`font-medium`),children:e.label}),(0,$.jsx)(`small`,{className:`text-xs leading-normal text-content-muted max-[650px]:text-[13px]`,children:e.description})]}),t?(0,$.jsx)(F,{size:15,strokeWidth:2.25,"aria-hidden":`true`}):(0,$.jsx)(`span`,{})]})}function Ki({approvalMode:e,onApprovalModeChange:t,approvalDisabled:n=!1,runMode:r,onRunModeChange:i,runModeDisabled:a=!1,goalsAvailable:s,teamAvailable:c,goal:l,tokenBudget:u,onTokenBudgetChange:d,onSaveTokenBudget:f,sheet:p=!1,collapse:m=!1,open:h,onOpenChange:g}){let{t:_}=o(),[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(!1),S=h??b,C=e=>{h===void 0&&x(e),g?.(e)},w=[{value:`approval-required`,label:_(`chat:focusSession.approvalRequired`),description:_(`chat:focusSession.approvalRequiredShowsADiffBeforeWriting`),icon:zr},{value:`workspace-write`,label:_(`chat:focusSession.workspaceWrite`),description:_(`chat:focusSession.workspaceWriteRunsCommandsWithAutomaticApproval`),icon:Lr},{value:`full-access`,label:_(`chat:focusSession.fullAccess`),description:_(`chat:focusSession.fullAccessRunsShellWithoutPerCommandApproval`),icon:ut}],T=[{value:`plan`,label:_(`board:composer.planShort`),description:_(`chat:focusSession.planModeDescription`),icon:Qe},...s?[{value:`goal`,label:_(`board:composer.goalShort`),description:_(`chat:focusSession.goalModeDescription`),icon:Kr}]:[],...s&&c?[{value:`team`,label:_(`board:composer.teamShort`),description:_(`chat:focusSession.teamModeDescription`),icon:ht}]:[]],E=w.find(t=>t.value===e)||w[0],D=l?.status===`active`?l?.mode===`team`&&c?`team`:`goal`:r,O=T.find(e=>e.value===D)||T[0],k=O.value!==`plan`,A=E.value===`full-access`?ut:Wr,j=O.value===`team`?_(`board:composer.teamShort`):O.value===`goal`?_(`board:composer.goalShort`):``,M=j?`${j} · ${E.label}`:E.label,N=O.value===`plan`&&E.value===`approval-required`,P=!!l?.id,L=D===`team`?l?.teamTokenBudget:l?.tokenBudget,R=L==null?null:Number(L)>0?Number(L):null,z=u!==R,B=P?R==null?_(`chat:focusSession.usedUnlimitedGoalTokens`,{used:bn(l?.tokensUsed)}):_(`chat:focusSession.usedBudgetTokensUsed`,{used:l?.tokensUsed||0,budget:R||0}):``,V=`${_(`board:composer.modeChip`)} · ${M}`,ee=_(D===`team`?`chat:focusSession.teamTokenBudget`:`chat:focusSession.goalTokenBudget`),te=async()=>{if(!(v||!z||!P||!f)){y(!0);try{await f(u)}finally{y(!1)}}};return(0,$.jsxs)(de,{sheet:p,title:_(`board:composer.modeChip`),open:S,onOpenChange:C,align:`start`,side:`top`,className:`composer-mode-popover w-[300px] max-w-[calc(100vw_-_24px)] gap-1 p-1`,trigger:(0,$.jsxs)(`button`,{type:`button`,className:Lt(ae,`composer-mode-chip max-w-[220px] max-[650px]:min-w-9 max-[650px]:justify-center max-[650px]:gap-1`,k?`max-[650px]:px-2.5`:`max-[650px]:px-0`),"aria-label":V,title:V,hidden:m&&!k&&E.value!==`full-access`,"data-composer-mode":`${O.value}:${E.value}`,children:[k&&(0,$.jsx)(O.icon,{size:16,className:`hidden shrink-0 max-[650px]:block`,"aria-hidden":`true`}),(0,$.jsx)(A,{size:14,className:`shrink-0 max-[650px]:size-4`,"aria-hidden":`true`}),!N&&(0,$.jsx)(`span`,{className:`min-w-0 truncate max-[650px]:hidden`,children:M}),(0,$.jsx)(I,{size:14,className:`shrink-0 opacity-70 max-[650px]:hidden`,"aria-hidden":`true`})]}),children:[(0,$.jsxs)(`div`,{role:`radiogroup`,"aria-label":_(`chat:focusSession.approvalMode`),className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(`div`,{className:`px-2 pt-1.5 pb-1 text-xs font-medium text-content-muted`,children:_(`chat:focusSession.approvalMode`)}),w.map(e=>(0,$.jsx)(Gi,{option:e,selected:e.value===E.value,disabled:n,onSelect:e=>{C(!1),t(e)}},e.value))]}),T.length>1&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{role:`separator`,className:`mx-1 h-px bg-stroke-soft`}),(0,$.jsxs)(`div`,{className:`grid gap-1.5 px-2 pt-1.5 pb-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-h-7 items-center justify-between gap-2`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs font-medium text-content-muted`,children:[_(`chat:focusSession.executionMode`),(0,$.jsx)(Bt,{className:`font-normal max-[650px]:hidden pointer-coarse:hidden`,children:`⇧Tab`})]}),(0,$.jsx)(Nt,{size:`sm`,"aria-label":_(`chat:focusSession.executionMode`),value:D,disabled:a,options:T.map(({value:e,label:t})=>({value:e,label:t})),onValueChange:i})]}),(0,$.jsx)(`p`,{className:`text-xs leading-normal text-content-muted max-[650px]:text-[13px]`,children:O.description})]}),(k||P)&&(0,$.jsxs)(`div`,{className:`grid gap-1 px-2 pt-1 pb-1.5 text-xs`,children:[B&&(0,$.jsx)(`p`,{className:`text-content-muted tabular-nums`,children:B}),(0,$.jsxs)(`div`,{className:`grid grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`goal-token-budget-input`,className:`font-medium text-content-secondary`,children:ee}),(0,$.jsx)(Fn,{id:`goal-token-budget-input`,type:`number`,min:Wi,step:1e3,value:u??``,placeholder:_(`chat:focusSession.goalTokenBudgetUnlimited`),"aria-label":ee,disabled:v,className:`text-[13px] tabular-nums`,onChange:e=>{let t=e.target.value.trim();if(!t){d(null);return}let n=Number(t);Number.isFinite(n)&&d(Math.max(Wi,Math.round(n)))}}),P&&z?(0,$.jsxs)(Y,{type:`button`,variant:`outline`,size:`sm`,disabled:v,onClick:()=>void te(),children:[v?(0,$.jsx)(st,{className:`animate-spin`,size:12}):(0,$.jsx)(F,{size:12}),_(`chat:focusSession.goalBudgetSave`)]}):(0,$.jsx)(`span`,{})]}),(0,$.jsx)(`small`,{className:`text-content-muted`,children:_(D===`team`?`chat:focusSession.teamTokenBudgetHint`:P?`chat:focusSession.goalTokenBudgetUpdateHint`:`chat:focusSession.goalTokenBudgetHint`)})]})]})]})}function qi({trigger:e,open:t,onOpenChange:n,onAttachment:r,onResource:i,onVisual:a,steer:s,mode:c}){let{t:l}=o(),u=e=>{n(!1),window.setTimeout(e,0)};return(0,$.jsxs)(de,{sheet:!0,title:l(`board:composer.plusSheetTitle`),open:t,onOpenChange:n,trigger:e,sheetClassName:`px-2`,children:[(0,$.jsxs)(ji,{count:a?3:2,children:[(0,$.jsx)(Mi,{icon:rt,label:l(`board:composer.attachmentShort`),"data-composer-plus-item":`attachment`,onClick:()=>{n(!1),r()}}),(0,$.jsx)(Mi,{icon:P,label:l(`chat:resourcePicker.open`),"data-composer-plus-item":`resource`,onClick:()=>u(i)}),a&&(0,$.jsx)(Mi,{icon:V,label:l(`chat:focusSession.generateImage`),"data-composer-plus-item":`visual`,onClick:()=>u(a)})]}),s&&(0,$.jsx)(Ni,{icon:U,label:l(`board:composer.steerNow`),hint:l(`board:composer.steerHint`),disabled:s.disabled,"data-composer-steer":!0,onClick:()=>u(s.onSelect)}),c&&(0,$.jsx)(Ni,{icon:Wr,label:l(`board:composer.modeChip`),"data-composer-plus-item":`mode`,trailing:(0,$.jsxs)(`span`,{className:`flex flex-none items-center gap-1 text-sm text-content-muted`,children:[c.valueLabel,(0,$.jsx)(R,{className:`size-4`,"aria-hidden":`true`})]}),onClick:()=>u(c.onOpen)})]})}function Ji(e,t){let n=[`plan`];return t.goalsAvailable&&n.push(`goal`),t.goalsAvailable&&t.teamAvailable&&n.push(`team`),n.length<2?null:n[(n.indexOf(e)+1)%n.length]??`plan`}function Yi({state:e,cwd:t,onDismiss:n}){let{t:r}=o(),i=e.status===`streaming`;return(0,$.jsxs)(`section`,{"aria-label":r(`chat:sideQuestion.label`),"aria-busy":i,onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n())},className:`flex max-h-[min(45vh,420px)] min-w-0 flex-col rounded-lg border border-stroke bg-panel shadow-float`,children:[(0,$.jsxs)(`header`,{className:`flex min-w-0 items-start gap-2 border-b border-stroke-soft px-3 py-2`,children:[(0,$.jsx)(Vr,{size:15,"aria-hidden":`true`,className:`mt-0.5 shrink-0 text-content-muted`}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(`span`,{className:`text-xs text-content-muted`,children:r(`chat:sideQuestion.label`)}),(0,$.jsx)(`p`,{className:`m-0 line-clamp-2 text-[13px] text-content`,title:e.question,children:e.question})]}),(0,$.jsx)(Y,{variant:`ghost`,size:`icon-xs`,className:`shrink-0 pointer-coarse:size-11`,"aria-label":r(`chat:sideQuestion.close`),title:r(`chat:sideQuestion.close`),onClick:n,children:(0,$.jsx)(vt,{})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 overflow-y-auto overscroll-contain px-3 py-2 text-[13px]`,children:[e.answer?(0,$.jsx)(Kn,{cwd:t,streaming:i,children:e.answer}):i?(0,$.jsxs)(`p`,{role:`status`,className:`m-0 flex items-center gap-2 text-content-muted`,children:[(0,$.jsx)(Rt,{className:`size-4`}),r(`chat:sideQuestion.answering`)]}):e.status===`done`?(0,$.jsx)(`p`,{className:`m-0 text-content-muted`,children:e.toolCallIgnored?r(`chat:sideQuestion.toolIgnored`):r(`chat:sideQuestion.empty`)}):null,e.status===`error`&&(0,$.jsx)(`p`,{role:`alert`,className:`m-0 mt-1 text-[var(--danger)]`,children:r(`chat:sideQuestion.failed`,{error:e.error})})]}),(0,$.jsx)(`footer`,{className:`border-t border-stroke-soft px-3 py-1.5 text-xs text-content-muted`,children:r(`chat:sideQuestion.note`)})]})}function Xi(e){let[t,n]=(0,Q.useState)(null),r=(0,Q.useRef)(null),i=(0,Q.useCallback)(()=>{r.current?.abort(),r.current=null},[]),a=(0,Q.useCallback)(()=>{i(),n(null)},[i]);return(0,Q.useEffect)(()=>a,[e,a]),{state:t,ask:(0,Q.useCallback)(t=>{i();let a=new AbortController;r.current=a;let o=()=>r.current===a;n({question:t,answer:``,status:`streaming`,error:``,toolCallIgnored:!1}),X.askSideQuestion(e,t,{signal:a.signal,onDelta:e=>{o()&&n(t=>t&&{...t,answer:t.answer+e})}}).then(e=>{o()&&(r.current=null,n(t=>t&&{...t,answer:e.text||t.answer,status:`done`,toolCallIgnored:e.toolCallIgnored}))}).catch(e=>{o()&&(r.current=null,n(t=>t&&{...t,status:`error`,error:e instanceof Error?e.message:String(e)}))})},[i,e]),dismiss:a}}var Zi=new Set([`user`,`assistant`,`summary`,`compaction`,`position`]);function Qi(e,t,n){return t===`labeled`?!!e.label:t===`branches`?n||Zi.has(e.kind):!1}var $i=new Set([`tool`,`tool-call`]);function ea(e){let t=[],n=new Map;for(let r of e){let e=r.parentId?n.get(r.parentId):void 0,i={...r,children:[]};n.set(r.id,i),e?e.children.push(i):t.push(i)}return t}function ta(e){let t=[],n=[...e].reverse();for(;n.length>0;){let e=n.pop();if(e){t.push(e);for(let t=e.children.length-1;t>=0;--t)n.push(e.children[t])}}return t}function na(e,t){let n=[],r=new Map;for(let i of ta(e)){let e=i.parentId&&r.get(i.parentId)||null;if(!t(i)){r.set(i.id,e);continue}let a={...i,children:[]};r.set(i.id,a),e?e.children.push(a):n.push(a)}return n}function ra(e){let t=[e],n=e;for(;n.children.length===1;)n=n.children[0],t.push(n);let r={id:e.id,nodes:t,children:[],active:t.some(e=>e.active)},i=[{segment:r,children:n.children}];for(;i.length>0;){let e=i.pop();if(e)for(let t of e.children){let n=[t],r=t;for(;r.children.length===1;)r=r.children[0],n.push(r);let a={id:t.id,nodes:n,children:[],active:n.some(e=>e.active)};e.segment.children.push(a),i.push({segment:a,children:r.children})}}return r}function ia(e){return e.kind===`user`?Ce:e.kind===`assistant`?N:e.kind===`tool`||e.kind===`tool-call`?_t:e.kind===`settings`?lt:e.kind===`label`?ft:e.kind===`summary`||e.kind===`compaction`?K:e.kind===`position`?Ze:e.label?Rr:tt}function aa({nodes:e,viewportRef:t,selectedId:n,typeLabel:r,stateLabel:i,onSelect:a}){let o=qn({count:e.length,getScrollElement:()=>t.current,estimateSize:()=>64,getItemKey:t=>e[t]?.id??`mobile-tree-node-${t}`,overscan:12,useAnimationFrameWithResizeObserver:!0});return(0,Q.useEffect)(()=>{if(!n)return;let t=e.findIndex(e=>e.id===n);t>=0&&o.scrollToIndex(t,{align:`center`})},[e,n,o]),(0,$.jsx)(`div`,{className:`relative w-full`,style:{height:`${o.getTotalSize()}px`},children:o.getVirtualItems().map(t=>{let o=e[t.index],s=ia(o);return(0,$.jsx)(`div`,{className:`absolute top-0 left-0 w-full px-3 py-1`,style:{transform:`translateY(${t.start}px)`},children:(0,$.jsxs)(`button`,{type:`button`,className:`session-tree-node relative grid items-center gap-2 rounded-sm border border-stroke bg-panel text-left text-content transition-colors duration-(--d-fast) hover:bg-surface-subtle [&.selected]:border-key-border [&.selected]:bg-key [&.selected]:shadow-key [&.selected]:before:absolute [&.selected]:before:inset-y-2 [&.selected]:before:-left-px [&.selected]:before:w-[3px] [&.selected]:before:rounded-r-[3px] [&.selected]:before:bg-star min-h-14 w-full grid-cols-[34px_minmax(0,1fr)_auto] py-2 pr-2.5 pl-1 ${o.id===n?` selected`:``}${o.active?` active`:``}${o.leaf?` leaf`:``}`,"data-kind":o.kind,"data-pisper-tree-entry":o.id,onClick:()=>a(o.id),children:[(0,$.jsx)(`span`,{className:`session-tree-marker relative z-[2] grid size-6 place-items-center justify-self-center rounded-sm bg-surface-muted text-content-secondary [.session-tree-node[data-kind='tool']_&]:bg-warning-soft [.session-tree-node[data-kind='tool']_&]:text-warning-strong [.session-tree-node.leaf_&]:bg-star [.session-tree-node.leaf_&]:text-on-accent [.session-tree-mark.active_&]:bg-star-soft [.session-tree-mark.active_&]:text-star-strong`,children:(0,$.jsx)(s,{size:14})}),(0,$.jsxs)(`span`,{className:`session-tree-node-copy flex min-w-0 flex-col gap-0.5 [&_small]:truncate [&_small]:text-xs [&_small]:text-content-muted [&_strong]:truncate [&_strong]:text-sm [&_strong]:font-medium`,children:[(0,$.jsx)(`strong`,{children:o.label||o.text||r(o)}),(0,$.jsx)(`small`,{children:o.label&&o.text?o.text:r(o)})]}),(0,$.jsxs)(`span`,{className:`session-tree-node-state inline-flex min-w-0 shrink-0 items-center gap-1 text-xs text-content-muted [.session-tree-node.leaf_&]:text-accent-fg`,children:[o.label&&(0,$.jsx)(Rr,{size:12}),i(o)]})]})},t.key)})})}function oa({segment:e,viewportRef:t,selectedId:n,typeLabel:r,stateLabel:i,onSelect:a}){let{nodes:o,children:s}=e,c=o.length>120,l=qn({count:o.length,getScrollElement:()=>t.current,estimateSize:()=>56,getItemKey:e=>o[e]?.id??`tree-node-${e}`,overscan:12,scrollMargin:26,enabled:c,useAnimationFrameWithResizeObserver:!0}),u=e=>{let t=ia(e);return(0,$.jsxs)(`button`,{type:`button`,className:`session-tree-node relative grid items-center gap-2 rounded-sm border border-stroke bg-panel text-left text-content transition-colors duration-(--d-fast) hover:bg-surface-subtle [&.selected]:border-key-border [&.selected]:bg-key [&.selected]:shadow-key [&.selected]:before:absolute [&.selected]:before:inset-y-2 [&.selected]:before:-left-px [&.selected]:before:w-[3px] [&.selected]:before:rounded-r-[3px] [&.selected]:before:bg-star z-[1] min-h-12 w-[220px] cursor-pointer grid-cols-[30px_minmax(0,1fr)_auto] py-1.5 pr-2 pl-0.5 ${e.id===n?` selected`:``}${e.active?` active`:``}${e.leaf?` leaf`:``}`,"data-kind":e.kind,"data-pisper-tree-entry":e.id,onClick:()=>a(e.id),children:[(0,$.jsx)(`span`,{className:`session-tree-marker relative z-[2] grid size-6 place-items-center justify-self-center rounded-sm bg-surface-muted text-content-secondary [.session-tree-node[data-kind='tool']_&]:bg-warning-soft [.session-tree-node[data-kind='tool']_&]:text-warning-strong [.session-tree-node.leaf_&]:bg-star [.session-tree-node.leaf_&]:text-on-accent [.session-tree-mark.active_&]:bg-star-soft [.session-tree-mark.active_&]:text-star-strong`,children:(0,$.jsx)(t,{size:14})}),(0,$.jsxs)(`span`,{className:`session-tree-node-copy flex min-w-0 flex-col gap-0.5 [&_small]:truncate [&_small]:text-xs [&_small]:text-content-muted [&_strong]:truncate [&_strong]:text-sm [&_strong]:font-medium`,children:[(0,$.jsx)(`strong`,{children:e.label||e.text||r(e)}),(0,$.jsx)(`small`,{children:e.label&&e.text?e.text:r(e)})]}),(0,$.jsxs)(`span`,{className:`session-tree-node-state inline-flex min-w-0 shrink-0 items-center gap-1 text-xs text-content-muted [.session-tree-node.leaf_&]:text-accent-fg`,children:[e.label&&(0,$.jsx)(Rr,{size:12}),i(e)]})]},e.id)};return(0,Q.useEffect)(()=>{if(!c||!n)return;let e=o.findIndex(e=>e.id===n);e<0||l.scrollToIndex(e,{align:`center`})},[n,o,c,l]),(0,$.jsxs)(`div`,{className:`session-tree-segment relative flex min-w-[220px] flex-col items-center ${e.active?` active`:``}`,children:[(0,$.jsx)(`div`,{className:`session-tree-track relative z-[1] grid w-[220px] gap-2 before:absolute before:top-[22px] before:bottom-[22px] before:left-1/2 before:z-0 before:w-px before:bg-stroke-strong [.session-tree-segment.active_>_&::before]:bg-control`,children:c?(0,$.jsx)(`div`,{className:`relative w-[220px]`,style:{height:`${l.getTotalSize()}px`},children:l.getVirtualItems().map(e=>(0,$.jsx)(`div`,{className:`absolute top-0 left-0 w-[220px]`,style:{top:`${e.start-26}px`},children:u(o[e.index])},e.key))}):o.map(u)}),s.length>0&&(0,$.jsx)(`div`,{className:`session-tree-children relative flex items-start justify-center pt-7 before:absolute before:top-0 before:left-1/2 before:h-3.5 before:w-px before:bg-stroke-strong [.session-tree-segment.active_>_&::before]:bg-control`,children:s.map(e=>(0,$.jsx)(`div`,{className:`session-tree-child relative flex px-3 pt-3.5 before:absolute before:top-0 before:right-1/2 before:h-3.5 before:w-1/2 before:border-t before:border-stroke-strong after:absolute after:top-0 after:left-1/2 after:h-3.5 after:w-1/2 after:border-t after:border-l after:border-stroke-strong [&:first-child::before]:border-t-transparent [&:last-child::after]:border-t-transparent [&.active]:before:border-control [&.active]:after:border-control [&.active:first-child::before]:border-t-transparent [&.active:last-child::after]:border-t-transparent${e.active?` active`:``}`,children:(0,$.jsx)(oa,{segment:e,viewportRef:t,selectedId:n,typeLabel:r,stateLabel:i,onSelect:a})},e.id))})]})}function sa({view:e,onViewChange:t,showAllEntries:n,onShowAllEntriesChange:r,query:i,onQueryChange:a,loading:s,error:c,mobileLayout:l,viewportRef:u,segments:d,visibleNodes:f,selectedId:p,typeLabel:m,stateLabel:h,onSelect:g,visibleMarks:_,marksLoading:v,openingMark:y,onOpenMark:b,confirmingMark:x,onConfirmMark:S,onCancelMark:C}){let{t:w,language:T}=o(),E=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{x&&E.current?.focus()},[x]);let D=e=>{let t=Date.parse(e);return Number.isFinite(t)?new Intl.DateTimeFormat(T,{dateStyle:`medium`,timeStyle:`short`}).format(t):w(`navigation:appOverlays.unknownTime`)};return(0,$.jsxs)(`div`,{className:`chat-resource-browser flex min-h-0 min-w-0 flex-col bg-transparent session-tree-browser`,children:[(0,$.jsx)(jt,{className:`chat-resource-tabs session-tree-tabs px-3 pt-3`,value:e,onValueChange:e=>t(e),children:(0,$.jsxs)(At,{children:[(0,$.jsx)(kt,{value:`branches`,children:w(`chat:sessionTree.branches`)}),(0,$.jsx)(kt,{value:`labeled`,children:w(`chat:sessionTree.labeled`)}),(0,$.jsx)(kt,{value:`marks`,children:w(`chat:sessionTree.allMarks`)})]})}),(0,$.jsxs)(Rn,{className:`chat-resource-search mx-3 mt-2 w-auto flex-none`,children:[(0,$.jsx)(Ln,{children:(0,$.jsx)(ct,{"aria-hidden":`true`})}),(0,$.jsx)(In,{value:i,disabled:!!y,"aria-label":w(`chat:sessionTree.searchPlaceholder`),onChange:e=>a(e.target.value),placeholder:w(`chat:sessionTree.searchPlaceholder`)})]}),e===`branches`&&(0,$.jsxs)(`label`,{className:`mx-3 mt-2 flex min-h-6 flex-none cursor-pointer items-center gap-2 text-xs text-content-secondary max-[650px]:min-h-11`,children:[(0,$.jsx)(bt,{checked:n,onCheckedChange:e=>r(e===!0),"data-session-tree-all-entries":!0}),w(`chat:sessionTree.showAllEntries`)]}),e===`marks`?(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 basis-0 flex-col gap-2 overflow-auto overscroll-contain px-3.5 py-3`,"data-testid":`session-tree-marks-list`,children:[c&&(0,$.jsx)(`p`,{role:`alert`,className:`mx-0.5 text-xs text-danger`,children:c}),v?(0,$.jsx)(`p`,{className:`grid min-h-[180px] place-items-center text-xs text-content-muted`,children:w(`chat:sessionTree.loadingMarks`)}):_.length?_.map(e=>(0,$.jsxs)(Q.Fragment,{children:[(0,$.jsxs)(`button`,{type:`button`,className:`session-tree-mark grid cursor-pointer grid-cols-[30px_minmax(0,1fr)_auto] items-center gap-2 rounded-sm border border-stroke bg-panel py-2 pr-2.5 pl-1 text-left text-content transition-colors duration-(--d-fast) hover:bg-surface-subtle [&.active]:border-star-border [&_>_em]:rounded-xs [&_>_em]:bg-star-soft [&_>_em]:px-1.5 [&_>_em]:py-0.5 [&_>_em]:text-xs [&_>_em]:text-star-strong [&_>_em]:not-italic ${e.active?` active`:``}`,"aria-expanded":e.active?void 0:x===e,"data-session-tree-mark":e.active?`active`:`other-branch`,disabled:!!y,"aria-busy":y===e,onClick:()=>b(e),children:[(0,$.jsx)(`span`,{className:`session-tree-marker relative z-[2] grid size-6 place-items-center justify-self-center rounded-sm bg-surface-muted text-content-secondary [.session-tree-node[data-kind='tool']_&]:bg-warning-soft [.session-tree-node[data-kind='tool']_&]:text-warning-strong [.session-tree-node.leaf_&]:bg-star [.session-tree-node.leaf_&]:text-on-accent [.session-tree-mark.active_&]:bg-star-soft [.session-tree-mark.active_&]:text-star-strong`,children:y===e?(0,$.jsx)(Rt,{className:`size-3.5`}):(0,$.jsx)(ft,{size:14})}),(0,$.jsxs)(`span`,{className:`session-tree-node-copy flex min-w-0 flex-col gap-0.5 [&_small]:truncate [&_small]:text-xs [&_small]:text-content-muted [&_strong]:truncate [&_strong]:text-sm [&_strong]:font-medium`,children:[(0,$.jsx)(`strong`,{children:e.label}),(0,$.jsx)(`small`,{children:e.sessionName||w(`navigation:appOverlays.untitledChat`)}),(0,$.jsx)(`small`,{children:w(`chat:sessionTree.markTimes`,{sessionTime:D(e.sessionModified),nodeTime:D(e.nodeTimestamp)})})]}),y===e?(0,$.jsx)(`em`,{children:w(`chat:sessionTree.navigating`)}):e.active&&(0,$.jsx)(`em`,{children:w(`chat:sessionTree.markActive`)})]}),x===e&&(0,$.jsxs)(`div`,{role:`group`,"aria-label":w(`chat:sessionTree.otherBranchTitle`),className:`-mt-1 grid gap-2 rounded-sm border border-stroke bg-surface-subtle p-2.5 text-xs text-content-secondary`,"data-session-tree-mark-confirm":!0,children:[(0,$.jsxs)(`p`,{className:`flex items-start gap-1.5 text-content`,children:[(0,$.jsx)(we,{size:13,className:`mt-0.5 flex-none`,"aria-hidden":`true`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`strong`,{className:`font-medium`,children:w(`chat:sessionTree.otherBranchTitle`)}),(0,$.jsx)(`span`,{className:`block text-content-muted`,children:w(`chat:sessionTree.otherBranchMessage`)})]})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(Y,{type:`button`,size:`sm`,variant:`ghost`,className:`max-[650px]:h-11`,onClick:C,children:w(`common:ui.cancel`)}),(0,$.jsx)(Y,{ref:E,type:`button`,size:`sm`,className:`max-[650px]:h-11`,onClick:()=>S(e),children:w(`chat:sessionTree.switchBranch`)})]})]})]},`${e.sessionId}:${e.entryId}`)):(0,$.jsx)(`p`,{className:`grid min-h-[180px] place-items-center text-xs text-content-muted`,children:w(`chat:sessionTree.noMarksYet`)})]}):(0,$.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 basis-0 overflow-auto overscroll-contain [scrollbar-gutter:stable]`,"data-testid":`session-tree-list`,ref:u,children:d.length>0?l?(0,$.jsx)(aa,{nodes:f,viewportRef:u,selectedId:p,typeLabel:m,stateLabel:h,onSelect:g}):(0,$.jsx)(`div`,{className:`session-tree-canvas flex w-max min-w-full items-start justify-center gap-9 px-7 pt-6.5 pb-12`,children:d.map(e=>(0,$.jsx)(oa,{segment:e,viewportRef:u,selectedId:p,typeLabel:m,stateLabel:h,onSelect:g},e.id))}):(0,$.jsx)(`p`,{className:`grid min-h-[180px] place-items-center text-xs text-content-muted`,children:s?w(`chat:sessionTree.loading`):c||w(`chat:sessionTree.empty`)})})]})}function ca({label:e,onClick:t}){return(0,$.jsxs)(Y,{variant:`secondary`,className:`w-full min-w-0`,title:e,onClick:t,children:[(0,$.jsx)(tt,{size:13}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:e})]})}function la({mobileLayout:e,selected:t,loading:n,error:r,streaming:i,dataStreaming:a,parentSession:s,parentEntryId:c,childSessions:l,canLabel:u,canDerive:d,label:f,summarize:p,savingLabel:m,creatingChild:h,navigating:g,typeLabel:_,stateLabel:v,onBackToList:y,onLabelChange:b,onSummarizeChange:x,onSaveLabel:S,onRemoveLabel:C,onCreateChild:w,onNavigate:T,onRefresh:E,onOpenRelated:D}){let{t:O,language:k}=o();return(0,$.jsxs)(`div`,{className:`chat-resource-config session-tree-inspector flex min-h-0 min-w-0 flex-col gap-4 overflow-y-auto overscroll-contain bg-panel p-[18px] [&_>_p]:m-auto [&_>_p]:text-xs [&_>_p]:text-content-muted [&_p]:text-xs [&_p]:text-content-muted [&_strong]:text-[15px] [&_strong]:font-medium ${e?``:`border-l border-stroke-soft`}`,children:[e&&(0,$.jsx)(`div`,{className:`sticky top-0 z-[2] -mx-1.5 -mt-2 flex border-b border-stroke-soft bg-panel px-0.5 pb-2`,children:(0,$.jsxs)(Y,{variant:`ghost`,className:`min-h-11 justify-start px-2`,onClick:y,children:[(0,$.jsx)(L,{size:17}),O(`chat:sessionTree.backToNodes`)]})}),t?(0,$.jsxs)($.Fragment,{children:[(s||l.length>0)&&(0,$.jsxs)(`div`,{className:`session-tree-lineage flex flex-col gap-1.5 border-b border-stroke-soft pb-3 [&_>_strong]:text-xs [&_>_strong]:font-medium [&_>_strong]:text-content-muted [&_button]:justify-start [&_button]:text-left [&_button]:text-xs`,children:[(0,$.jsx)(`strong`,{children:O(`chat:sessionTree.conversationLineage`)}),s&&(0,$.jsx)(ca,{label:O(`chat:sessionTree.returnToOriginalChat`,{name:s.name||O(`chat:chatPage.newChat`)}),onClick:()=>D(s,c)}),l.map(e=>(0,$.jsx)(ca,{label:O(`chat:sessionTree.openSeparateChat`,{name:e.name||O(`chat:chatPage.newChat`)}),onClick:()=>D(e)},e.id))]}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`span`,{className:`session-tree-selection-kind mb-1 flex items-center justify-between gap-2 text-xs text-content-muted [&_em]:rounded-xs [&_em]:border [&_em]:border-star-border [&_em]:bg-star-soft [&_em]:px-1.5 [&_em]:py-0.5 [&_em]:font-medium [&_em]:text-star-strong [&_em]:not-italic`,children:[_(t),v(t)&&(0,$.jsx)(`em`,{children:v(t)})]}),(0,$.jsx)(`strong`,{children:t.label||_(t)}),(0,$.jsx)(`p`,{children:t.text||O(`chat:sessionTree.noPreview`)})]}),(0,$.jsxs)(`div`,{className:`chat-resource-inputs flex flex-col gap-3 [&_label]:grid [&_label]:gap-1.5 [&_label]:text-xs [&_label]:font-medium [&_label]:text-content-secondary`,children:[u&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{children:[(0,$.jsx)(`span`,{children:O(`chat:sessionTree.nodeLabel`)}),(0,$.jsx)(Fn,{value:f,maxLength:80,placeholder:O(`chat:sessionTree.labelPlaceholder`),onChange:e=>b(e.target.value)})]}),(0,$.jsxs)(Y,{variant:`secondary`,disabled:m||i||a,onClick:S,children:[(0,$.jsx)(ft,{size:14}),O(m?`chat:sessionTree.savingLabel`:`chat:sessionTree.saveLabel`)]}),!!t.label&&(0,$.jsxs)(Y,{variant:`secondary`,disabled:m||i||a,onClick:C,children:[(0,$.jsx)(pt,{size:14}),O(`chat:sessionTree.removeLabel`)]})]}),u&&(0,$.jsxs)(Y,{variant:`secondary`,disabled:h||i||a,onClick:w,children:[(0,$.jsx)(Se,{size:14}),O(h?`chat:sessionTree.creatingChildChat`:`chat:sessionTree.createChildChat`)]}),d&&(0,$.jsxs)(`label`,{className:`session-tree-summary-option cursor-pointer grid-cols-[minmax(0,1fr)_auto] items-center [&_small]:col-span-full [&_small]:leading-relaxed [&_small]:font-normal [&_small]:text-content-muted`,children:[(0,$.jsx)(`span`,{children:O(`chat:sessionTree.abandonedBranchSummary`)}),(0,$.jsx)(Ot,{checked:p,disabled:t.leaf||i||a,onCheckedChange:x,"data-session-tree-summary":!0}),(0,$.jsx)(`small`,{children:O(`chat:sessionTree.abandonedBranchSummaryHint`)})]})]}),d&&(0,$.jsx)(`p`,{children:O(`chat:sessionTree.sideEffectsRemain`)}),t.timestamp&&(0,$.jsx)(`p`,{children:new Intl.DateTimeFormat(k,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(t.timestamp))}),r&&(0,$.jsx)(`p`,{role:`alert`,className:`text-danger!`,children:r}),d&&(0,$.jsxs)(Y,{className:`chat-resource-confirm self-start`,disabled:g||t.leaf||i||a,onClick:T,children:[(0,$.jsx)(Ze,{size:15}),g?O(`chat:sessionTree.navigating`):t.leaf?O(`chat:sessionTree.currentPosition`):O(`chat:sessionTree.continueFromNode`)]})]}):(0,$.jsx)(`p`,{children:n?O(`chat:sessionTree.loading`):r||O(`chat:sessionTree.chooseNode`)}),r&&!t&&(0,$.jsx)(Y,{variant:`secondary`,onClick:E,children:O(`chat:sessionTree.retry`)})]})}function ua({open:e,sessionId:t,streaming:n,onClose:r,onNavigated:i,onCreateChildSession:a,initialView:s=`branches`,returnFocusRef:c,notify:l}){let{t:u,language:d}=o(),f=D(),p=E(),m=f||p,[h,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)([]),[y,b]=(0,Q.useState)(`branches`),[x,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(`list`),[T,O]=(0,Q.useState)(``),[k,A]=(0,Q.useState)(``),[j,M]=(0,Q.useState)(``),[N,P]=(0,Q.useState)([]),[F,I]=(0,Q.useState)(!1),[L,R]=(0,Q.useState)(!1),[z,B]=(0,Q.useState)(null),[V,ee]=(0,Q.useState)(null),[te,ne]=(0,Q.useState)(!1),[re,H]=(0,Q.useState)(!1),[ie,ae]=(0,Q.useState)(!1),[U,W]=(0,Q.useState)(!1),[oe,se]=(0,Q.useState)(!1),[ce,G]=(0,Q.useState)(``),le=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(!e||!t)return;let n=!1;return b(s),w(`list`),O(``),H(!0),G(``),Promise.all([X.getSessionTree(t),X.listSessions()]).then(([e,t])=>{n||(g(e),v(t.sessions||[]),A(e.leafId||e.nodes[0]?.id||``))}).catch(e=>{n||G(Z(e))}).finally(()=>{n||H(!1)}),()=>{n=!0}},[e,t]),(0,Q.useEffect)(()=>{e||(g(null),v([]),A(``),w(`list`),M(``),B(null),ee(null),ne(!1),G(``))},[e]),(0,Q.useEffect)(()=>{if(!e||y!==`marks`||F)return;let t=!0;return R(!0),G(``),X.listSessionTreeLabels(500).then(e=>{t&&(P(e.labels||[]),I(!0))}).catch(e=>t&&G(Z(e))).finally(()=>t&&R(!1)),()=>{t=!1}},[e,y,F]);let K=(0,Q.useMemo)(()=>{let e=T.trim().toLocaleLowerCase(d);return e?N.filter(t=>`${t.label} ${t.sessionName}`.toLocaleLowerCase(d).includes(e)):N},[N,d,T]),ue=async(e,t=!1)=>{if(!z){if(!e.active&&!t){ee(e);return}ee(null),B(e),G(``);try{let t=null;if(!e.active){if(t=await X.navigateSessionTreeTarget(e.sessionId,e.entryId),t.cancelled){B(null);return}yr(e.sessionId)}en(e.sessionId,`open`,e.entryId),r(),t&&l&&wr(e.sessionId,t,u(`chat:sessionTree.switchedBranch`),{notify:l,t:u})}catch(e){G(Z(e)),B(null)}}},de=(0,Q.useMemo)(()=>ea(h?.nodes||[]),[h]),fe=(0,Q.useCallback)(e=>({user:u(`chat:sessionTree.userMessage`),assistant:u(`chat:sessionTree.agentMessage`),tool:u(`chat:sessionTree.toolResult`),"tool-call":u(`chat:sessionTree.toolCall`),summary:u(`chat:sessionTree.branchSummary`),compaction:u(`chat:sessionTree.compactionSummary`),settings:u(`chat:sessionTree.settingsChange`),label:u(`chat:sessionTree.labelChange`),position:u(`chat:sessionTree.branchPosition`),extension:u(`chat:sessionTree.extensionEntry`),metadata:u(`chat:sessionTree.metadataEntry`),message:u(`chat:sessionTree.message`)})[e.kind]||e.type,[u]),pe=(0,Q.useMemo)(()=>{let e=T.trim().toLocaleLowerCase(d);return na(de,t=>Qi(t,y,x)?!e||`${t.label} ${t.text} ${fe(t)}`.toLocaleLowerCase(d).includes(e):!1)},[de,d,T,x,fe,y]),me=(0,Q.useMemo)(()=>pe.map(ra),[pe]),he=(0,Q.useMemo)(()=>ta(pe),[pe]),q=(0,Q.useMemo)(()=>ta(de),[de]).find(e=>e.id===k)||null,ge=h?.lineage?.parentSessionId?_.find(e=>e.id===h.lineage?.parentSessionId):null,_e=(h?.lineage?.childSessionIds||[]).map(e=>_.find(t=>t.id===e)).filter(e=>!!e),ve=q?.kind===`assistant`&&q.status===`completed`,ye=ve,be=q?!$i.has(q.kind):!1;(0,Q.useEffect)(()=>{M(q?.label||``),ne(!1)},[q?.id,q?.label]),(0,Q.useEffect)(()=>{if(k&&he.some(e=>e.id===k))return;let e=[...he].reverse().find(e=>e.active);A(e?.id||he[0]?.id||``)},[k,he]),(0,Q.useEffect)(()=>{if(!e||!k)return;let t=requestAnimationFrame(()=>{document.querySelector(`[data-testid="session-tree-list"] .session-tree-node.selected`)?.scrollIntoView({block:`center`})});return()=>cancelAnimationFrame(t)},[e,T,k,y,he.length]);let xe=async()=>{H(!0),G(``);try{let e=await X.getSessionTree(t);g(e),A(e.leafId||e.nodes[0]?.id||``)}catch(e){G(Z(e))}finally{H(!1)}},Se=async()=>{if(!(!q||ie)){ae(!0),G(``);try{let e=await X.setSessionTreeLabel(t,q.id,j);g(e),xr(t,e)}catch(e){G(Z(e))}finally{ae(!1)}}},Ce=async()=>{if(!(!q||ie)){ae(!0),G(``);try{let e=await X.setSessionTreeLabel(t,q.id,``);g(e),xr(t,e)}catch(e){G(Z(e))}finally{ae(!1)}}},Te=async()=>{if(!(!q||!ye||oe)){se(!0),G(``);try{await a(q.id),r()}catch(e){G(Z(e))}finally{se(!1)}}},Ee=(e,t=``)=>{e.id&&(en(e.id,`open`,t),r())},De=async()=>{if(!(!q||U||q.leaf||n||h?.streaming)){W(!0),G(``);try{let e=await X.navigateSessionTree(t,q.id,te);g(e),e.cancelled||(xr(t,e),await i(e.editorText),r(),l&&wr(t,e,u(`chat:chatPage.branchedFromNode`),{notify:l,t:u}))}catch(e){G(Z(e))}finally{W(!1)}}},Oe=e=>e.leaf?u(`chat:sessionTree.current`):e.branchPoint?u(`chat:sessionTree.fork`):e.active?u(`chat:sessionTree.active`):``;return(0,$.jsx)(Pn,{open:e,onOpenChange:e=>!e&&r(),children:(0,$.jsxs)(jn,{onCloseAutoFocus:e=>{let n=c?.current,r=n?.isConnected?n:document.getElementById(`task-${t}-more`);r?.closest(`[data-task-workspace]`)?.getAttribute(`data-active`)===`true`&&(e.preventDefault(),r.focus())},className:`chat-resource-dialog session-tree-dialog grid-rows-[auto_minmax(0,1fr)] gap-0 overflow-hidden border border-stroke bg-solid p-0 ${m?`!h-[calc(100dvh_-_16px)] !w-[calc(100vw_-_16px)] !max-w-none`:`!h-[min(760px,calc(100dvh_-_32px))] !w-[min(1120px,calc(100vw_-_32px))] !max-w-[1120px]`}`,showCloseButton:!1,children:[(0,$.jsxs)(`div`,{className:`chat-resource-head flex items-start justify-between gap-4 border-b border-stroke-soft px-[18px] pt-4 pb-3.5 max-[650px]:p-3.5 [&_[data-slot='dialog-description']]:mt-0.5 [&_[data-slot='dialog-description']]:text-xs [&_[data-slot='dialog-description']]:text-content-muted [&_[data-slot='dialog-title']]:text-base [&_[data-slot='dialog-title']]:font-semibold`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`session-tree-title flex items-center gap-2`,children:[(0,$.jsx)(we,{className:`size-4 text-content-muted`,strokeWidth:1.75,"aria-hidden":`true`}),(0,$.jsx)(Mn,{children:u(`chat:sessionTree.title`)})]}),(0,$.jsx)(An,{children:u(`chat:sessionTree.description`,{nodes:h?.nodeCount||0,branches:h?.branchCount||0})})]}),(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,className:`max-[650px]:size-11`,"aria-label":u(`common:ui.closeDialog`),title:u(`common:ui.closeDialog`),onClick:r,children:(0,$.jsx)(vt,{size:16})})]}),(0,$.jsxs)(`div`,{className:`chat-resource-body session-tree-layout grid min-h-0 overflow-hidden bg-background ${m?`grid-cols-1 grid-rows-[minmax(0,1fr)]`:`!grid-cols-[minmax(0,1fr)_292px]`}`,children:[(!m||C===`list`)&&(0,$.jsx)(sa,{view:y,onViewChange:e=>{b(e),ee(null),w(`list`)},showAllEntries:x,onShowAllEntriesChange:S,query:T,onQueryChange:O,loading:re,error:ce,mobileLayout:m,viewportRef:le,segments:me,visibleNodes:he,selectedId:k,typeLabel:fe,stateLabel:Oe,onSelect:e=>{A(e),m&&w(`detail`)},visibleMarks:K,marksLoading:L,openingMark:z,onOpenMark:e=>void ue(e),confirmingMark:V,onConfirmMark:e=>void ue(e,!0),onCancelMark:()=>ee(null)}),y!==`marks`&&(!m||C===`detail`)&&(0,$.jsx)(la,{mobileLayout:m,selected:q,loading:re,error:ce,streaming:n,dataStreaming:!!h?.streaming,parentSession:ge??null,parentEntryId:h?.lineage?.sourceEntryId||``,childSessions:_e,canLabel:ve,canDerive:be,label:j,summarize:te,savingLabel:ie,creatingChild:oe,navigating:U,typeLabel:fe,stateLabel:Oe,onBackToList:()=>w(`list`),onLabelChange:M,onSummarizeChange:ne,onSaveLabel:()=>void Se(),onRemoveLabel:()=>void Ce(),onCreateChild:()=>void Te(),onNavigate:()=>void De(),onRefresh:()=>void xe(),onOpenRelated:(e,t)=>Ee(e,t??``)})]})]})})}function da({visible:e,open:t,sessionId:n,streaming:r,revision:i,pulseToken:a,onOpenChange:s,onNavigated:c,onCreateChildSession:l,notify:u,children:d}){let{t:f}=o(),p=vr(n,{enabled:e,streaming:r,revision:i})?.branchCount??0,[m,h]=(0,Q.useState)(`branches`),[g,_]=(0,Q.useState)(!1),v=(0,Q.useRef)(0),y=(0,Q.useRef)(null);(0,Q.useEffect)(()=>()=>cancelAnimationFrame(v.current),[]),(0,Q.useEffect)(()=>{if(!a)return;_(!0);let e=window.setTimeout(()=>_(!1),1800);return()=>window.clearTimeout(e)},[a]);let b=p>0&&(0,$.jsx)(`i`,{"aria-hidden":`true`,className:`ml-auto size-1.5 rounded-full bg-star`}),x=e?(0,$.jsxs)(St,{"aria-label":f(`chat:sessionTree.menu`),"aria-haspopup":`dialog`,"data-pisper-recall-pulse":g||void 0,onSelect:()=>{y.current=null,h(`branches`),cancelAnimationFrame(v.current),v.current=requestAnimationFrame(()=>s(!0))},children:[(0,$.jsx)(we,{className:g?`motion-reduce:animate-none [animation:session-tree-new-node-pulse_1.8s_var(--ease-out)]`:void 0}),f(`chat:sessionTree.menu`),b]}):null;return(0,$.jsxs)($.Fragment,{children:[d(x,{branches:p,open:(e=`branches`,t=null)=>{y.current=t,h(e),cancelAnimationFrame(v.current),v.current=requestAnimationFrame(()=>s(!0))}}),e&&(0,$.jsx)(ua,{open:t,initialView:m,returnFocusRef:y,sessionId:n,streaming:r,onClose:()=>s(!1),onNavigated:c,onCreateChildSession:l,notify:u})]})}function fa({question:e,more:t,collapsed:n,onAnswer:r}){let{t:i}=o(),[a,s]=(0,Q.useState)(()=>e.questions.map(()=>({selected:[]}))),[c,l]=(0,Q.useState)(()=>e.questions.map(()=>!1)),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(``),m=e.questions.length===1&&!e.questions[0].multiSelect,h=gn(e,a);if(n)return(0,$.jsxs)(`p`,{"data-question-more":!0,className:`flex min-h-8 min-w-0 items-center gap-2 rounded-(--r-md) border border-st-attn-border px-3 text-xs text-st-attn`,children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 flex-none rounded-full bg-st-attn-fill`}),i(`board:question.waiting`,{count:t+1})]});let g=async t=>{if(!u){d(!0),p(``);try{await r(e.id,t)}catch{p(i(`board:question.failed`)),d(!1)}}},_=e=>e.map((e,t)=>{let n=c[t]?e.other?.trim():``;return n?{selected:e.selected,other:n}:{selected:e.selected}}),v=(t,n)=>{let r=e.questions[t],i=a.map((e,i)=>{if(i!==t)return e;if(!r.multiSelect)return{...e,selected:[n]};let a=e.selected.includes(n)?e.selected.filter(e=>e!==n):[...e.selected,n];return{...e,selected:a}});s(i),m&&g({answers:_(i)})};return(0,$.jsxs)(`div`,{"data-question-card":e.id,role:`group`,"aria-label":i(`board:question.label`),"aria-busy":u||void 0,onKeyDown:t=>{if(t.altKey||t.metaKey||t.ctrlKey)return;let n=t.target;if(n.closest(`textarea, input`))return;let r=a.findIndex(e=>!e.selected.length&&!e.other?.trim()),i=r<0?e.questions.length-1:r,o=Number(t.key);if(Number.isInteger(o)&&o>=1&&o<=6){let n=e.questions[i]?.options[o-1];if(!n)return;t.preventDefault(),v(i,n.label)}else t.key===`Enter`&&!n.closest(`button`)&&h&&(t.preventDefault(),g({answers:_(a)}))},className:`flex max-h-[min(60vh,560px)] min-w-0 flex-col gap-3 overflow-y-auto rounded-(--r-lg) border border-st-attn-border bg-st-attn-soft px-3.5 py-3 text-foreground`,children:[(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-xs font-medium text-warning-strong`,children:[(0,$.jsx)(Vr,{className:`size-4 flex-none`,"aria-hidden":`true`}),i(`board:question.title`),t>0&&(0,$.jsx)(`span`,{className:`font-normal text-content-muted`,children:i(`board:question.moreAfter`,{count:t})})]}),e.questions.map((t,n)=>{let r=a[n],o=t.header?`${t.header}:${t.question}`:t.question;return(0,$.jsxs)(`fieldset`,{"data-question-item":n,className:`flex min-w-0 flex-col gap-1.5`,children:[(0,$.jsxs)(`legend`,{className:`mb-1.5 flex min-w-0 flex-col gap-0.5`,children:[t.header&&(0,$.jsx)(`span`,{className:`text-xs font-medium text-content-muted`,children:t.header}),(0,$.jsx)(`span`,{className:`text-sm leading-5 text-content`,children:t.question})]}),(0,$.jsxs)(`div`,{role:t.multiSelect?`group`:`radiogroup`,"aria-label":o,className:`flex flex-wrap gap-1.5`,children:[t.options.map((e,i)=>{let a=r.selected.includes(e.label);return(0,$.jsxs)(`button`,{type:`button`,role:t.multiSelect?`checkbox`:`radio`,"aria-checked":a,disabled:u,"data-question-option":e.label,title:e.description||void 0,className:Lt(`flex min-h-9 max-w-full min-w-0 items-center gap-1.5 rounded-(--r-md) border px-2.5 py-1 text-left text-[13px] transition-colors duration-(--d-fast) focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-focus disabled:opacity-60 pointer-coarse:min-h-11`,a?`border-content bg-content text-panel`:`border-stroke-strong bg-panel text-content hover:bg-surface-hover`),onClick:()=>v(n,e.label),children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`font-mono text-[11px] opacity-60 pointer-coarse:hidden`,children:i+1}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,$.jsx)(`span`,{className:`break-words`,children:e.label}),e.description&&(0,$.jsx)(`span`,{className:Lt(`text-xs break-words`,a?`opacity-80`:`text-content-muted`),children:e.description})]}),a&&t.multiSelect&&(0,$.jsx)(F,{className:`size-3.5 flex-none`,"aria-hidden":`true`})]},e.label)}),(0,$.jsx)(`button`,{type:`button`,"aria-expanded":c[n],disabled:u,"data-question-other":n,className:Lt(`flex min-h-9 items-center rounded-(--r-md) border border-dashed border-stroke-strong px-2.5 text-[13px] text-content-secondary hover:bg-surface-hover focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-focus pointer-coarse:min-h-11`,c[n]&&`border-solid bg-panel`),onClick:()=>l(e=>e.map((e,t)=>t===n?!e:e)),children:i(`board:question.other`)})]}),c[n]&&(0,$.jsx)(`textarea`,{"aria-label":i(`board:question.otherLabel`,{question:t.question}),maxLength:_n.other,rows:2,disabled:u,value:r.other??``,placeholder:i(`board:question.otherPlaceholder`),className:`min-h-16 w-full resize-y rounded-(--r-md) border border-control bg-panel px-2.5 py-1.5 text-sm text-content outline-none focus:border-focus focus:ring-3 focus:ring-focus-ring max-[650px]:text-[16px]`,onChange:e=>{let t=e.target.value;s(e=>e.map((e,r)=>r===n?{...e,other:t}:e))},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&h&&(e.preventDefault(),g({answers:_(a)}))}})]},`${e.id}-${n}`)}),f&&(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-[var(--danger)]`,children:f}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,disabled:u,"data-question-skip":!0,className:`pointer-coarse:min-h-11`,onClick:()=>void g({skip:!0}),children:i(`board:question.skip`)}),(!m||c[0])&&(0,$.jsx)(Y,{type:`button`,size:`sm`,disabled:u||!h,loading:u,"data-question-submit":!0,className:`pointer-coarse:min-h-11`,onClick:()=>void g({answers:_(a)}),children:i(`board:question.submit`)})]})]})}async function pa({templatePrompt:e,configureHint:t,notify:n,onOpenModelSettings:r,onInsertPrompt:i}){try{let a=await C(`/api/visual/models`);a.image||a.video?i(e):(n?.(t),r?.())}catch{i(e)}}function ma(e){return(e.target instanceof Element?e.target:null)?.closest(`[data-shortcut-recorder], [role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"], .xterm, .terminal-xterm, .terminal-panel, [data-terminal]`)?!0:Array.from(document.querySelectorAll(`[role="dialog"], [role="alertdialog"], dialog[open]`)).some(e=>e.getClientRects().length>0)}function ha(e){let t=(0,Q.useRef)(e);t.current=e;let{enabled:n,binding:r}=e;(0,Q.useEffect)(()=>{if(!n||!r)return;let e=null,i=null,a=()=>{e=null,i&&(i=null,t.current.onCancel())},o=n=>{if(i&&n.key===`Escape`&&!n.isComposing){a(),n.preventDefault();return}!t.current.enabled||n.defaultPrevented||n.isComposing||n.keyCode===229||n.repeat||e||document.visibilityState===`hidden`||ma(n)||!on(n,r)||(e=n.code,t.current.onStart()&&(i={code:n.code,ctrl:n.ctrlKey,meta:n.metaKey,alt:n.altKey,shift:n.shiftKey},n.preventDefault()))},s=n=>{n.code===e&&(e=null),i&&(n.code===i.code||i.ctrl&&(!n.ctrlKey||n.code.startsWith(`Control`))||i.meta&&(!n.metaKey||n.code.startsWith(`Meta`))||i.alt&&(!n.altKey||n.code.startsWith(`Alt`))||i.shift&&(!n.shiftKey||n.code.startsWith(`Shift`)))&&(i=null,t.current.onRelease())},c=()=>{document.visibilityState===`hidden`&&a()};return window.addEventListener(`keydown`,o),window.addEventListener(`keyup`,s,!0),window.addEventListener(`blur`,a),document.addEventListener(`visibilitychange`,c),()=>{window.removeEventListener(`keydown`,o),window.removeEventListener(`keyup`,s,!0),window.removeEventListener(`blur`,a),document.removeEventListener(`visibilitychange`,c),a()}},[n,r])}function ga(e){if(!e.length)return 0;let t=0;for(let n=0;n<e.length;n+=1)t+=e[n]*e[n];let n=Math.sqrt(t/e.length);return n<.0056?0:Math.min(1,Math.sqrt(n)*2.6)}function _a(e=.35){let t=0;return{push(n){return t=t*(1-e)+n*e,t},reset(){t=0}}}function va(e,t=140){let n=e.trim();return n.length>t?`${n.slice(0,t-1)}…`:n}var ya=16e3,ba=20,xa=ya*ba/1e3;function Sa(e,{onsetMs:t=80,minVoicedMs:n=160,silenceMs:r=900}={}){for(let e of[t,n,r])if(!Number.isFinite(e)||e<=0)throw Error(`Invalid VAD endpoint duration`);let i=e(),a=new Int16Array(xa),o=0,s=0,c=0,l=0,u=!1,d=!1,f=!1,p=()=>u&&c*ba>=n;return{get hasSpeech(){return p()},acceptPcm(e){if(f||d)return!1;for(let n=0;n<e.length;n+=1){let f=Number.isFinite(e[n])?Math.max(-1,Math.min(1,e[n])):0;if(a[o++]=f*(f<0?32768:32767),o!==xa)continue;o=0;let m=i.processFrame(a);if(m<0)throw Error(`VAD frame processing failed`);if(m===1)s+=1,c+=1,l=0,s*ba>=t&&(u=!0);else if(s=0,l+=1,u||(c=0),l*ba>=r){if(p())return d=!0,!0;u=!1,c=0}}return!1},reset(){f||(i.destroy(),i=e(),o=s=c=l=0,u=d=!1,a.fill(0))},dispose(){f||(f=!0,o=0,i.destroy())}}}async function Ca(e={}){let{default:n,VADMode:r}=await t(async()=>{let{default:e,VADMode:t}=await import(`./embedded-D2rqyswH.js`);return{default:e,VADMode:t}},[]),i=await n();return Sa(()=>new i(e.mode??r.AGGRESSIVE,ya),e)}var wa=()=>new DOMException(`Speech setup cancelled.`,`AbortError`);function Ta(e){let[t,n]=(0,Q.useState)(null),[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(``),l=(0,Q.useRef)(null),u=(0,Q.useRef)(!1),d=(0,Q.useRef)(0),f=(0,Q.useRef)(0),p=(0,Q.useRef)(0),m=(0,Q.useRef)(e);m.current=e;let h=(0,Q.useCallback)(e=>{d.current++,f.current++;let t=l.current;l.current=null,t&&(t.signal.removeEventListener(`abort`,t.abort),e?t.reject(e):t.resolve()),u.current&&(i(!1),o(!1))},[]),_=(0,Q.useCallback)(e=>{u.current&&(n(e),c(``),l.current&&Nr(e,m.current).every(e=>e.status===`installed`)&&h())},[h]),v=(0,Q.useCallback)(async e=>{let t=d.current,n=++f.current,r=()=>u.current&&t===d.current&&n===f.current&&!e?.aborted;try{let t=await Er(e);r()&&_(t)}catch(e){if(r())throw e}},[_]);(0,Q.useEffect)(()=>(u.current=!0,v().catch(()=>{}),()=>{u.current=!1,h(wa())}),[h,v]),(0,Q.useEffect)(()=>{if(!r)return;let e=new AbortController,t,n=async()=>{try{await v(e.signal)}catch(t){e.signal.aborted||c(t instanceof Error?t.message:String(t))}finally{e.signal.aborted||(t=setTimeout(()=>void n(),750))}};return n(),()=>{e.abort(),clearTimeout(t)}},[r,v]);let y=(0,Q.useCallback)(async e=>{if(g(e),!u.current)throw wa();h(wa());let t=++f.current;return new Promise((n,r)=>{let a=()=>{l.current===o&&h(e.reason||wa())},o={signal:e,abort:a,resolve:n,reject:r};if(l.current=o,e.addEventListener(`abort`,a,{once:!0}),e.aborted){a();return}Er(e).then(n=>{!u.current||l.current!==o||e.aborted||(t===f.current&&_(n),l.current===o&&i(!0))},e=>{l.current===o&&h(e)})})},[_,h]),b=(0,Q.useCallback)(async e=>{let t=d.current,n=++p.current,r=()=>u.current&&t===d.current&&n===p.current;o(!0),c(``);try{await e(),r()&&await v()}catch(e){r()&&c(e instanceof Error?e.message:String(e))}finally{r()&&o(!1)}},[v]);return{catalog:t,open:r,loading:a,error:s,selectedVoice:t?.defaults.voice||``,ensureReady:y,models:t?Nr(t,e):[],show:()=>{h(wa()),i(!0),c(``)},close:()=>h(wa()),download:e=>b(()=>jr(e)),cancelDownload:e=>b(()=>Ar(e)),downloadAll:()=>b(async()=>{if(t)for(let e of Nr(t,m.current))[`installed`,`downloading`,`verifying`].includes(e.status)||await jr(e.id)})}}var Ea=8388608;function Da(e,t){return g(t),new Promise((n,r)=>{let i=()=>r(_(t));t.addEventListener(`abort`,i,{once:!0}),e.then(n,r).finally(()=>t.removeEventListener(`abort`,i))})}var Oa=10,ka=500;async function Aa(e,t,n,r){for(let i=0;;i+=1){let a=await fetch(`/api/speech/synthesize`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:e,voiceId:t,requestId:n}),signal:r});if(a.status!==409||i>=Oa)return a;let o=await a.json().catch(()=>({}));if(!o.error||!/busy/i.test(o.error))return a;await Da(new Promise(e=>setTimeout(e,ka)),r)}}async function ja(e){if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error||`Speech synthesis failed (${e.status}).`)}if(!e.headers.get(`content-type`)?.startsWith(`audio/wav`)||!e.body)throw Error(`Invalid speech audio response.`);let t=e.body.getReader(),n=[],r=0;try{for(;;){let{done:e,value:i}=await t.read();if(e)break;if(r+=i.byteLength,r>Ea)throw Error(`Speech audio exceeds the supported limit.`);n.push(i)}}finally{await t.cancel().catch(()=>{}),t.releaseLock()}if(r<44)throw Error(`Speech audio is empty.`);let i=new Uint8Array(r),a=0;for(let e of n)i.set(e,a),a+=e.length;return i.buffer}async function Ma(e,t,n,r){g(n);let i=h(n);try{await Na(e,t,i,r)}finally{i.abort(new DOMException(`Speech playback ended.`,`AbortError`)),i.dispose()}}async function Na(e,n,r,i){let{signal:a}=r,{speechSegments:o}=await Da(t(()=>import(`./speech-text-BTwYi9Sb.js`),__vite__mapDeps([137,91,1,2,3,88,89,90,34])),a);g(a);let s=(typeof e==`string`?(async function*(){yield*o(e)})():(await Da(t(()=>import(`./speech-stream-text-DF6aAUVb.js`),__vite__mapDeps([138,91,1,2,3,88,89,90,34,13,137])),a)).streamingSpeechSegments(e,a))[Symbol.asyncIterator](),c=!!window.__PISPER_MOBILE_APP__,l=new Set,u,d,f,p=e=>{(c?Or(`mobile_cancel_speech`,{requestId:e}):C(`/api/speech/cancel`,{method:`POST`,body:{requestId:e},timeout:3e3})).catch(()=>{})},m=()=>{for(let e of l)p(e);try{d?.stop()}catch{}f?.(a.reason||new DOMException(`Speech playback cancelled.`,`AbortError`))};a.addEventListener(`abort`,m,{once:!0});let _=e=>{g(a);let t=crypto.randomUUID();l.add(t);let r=(async()=>{if(c){let r=await Or(`mobile_synthesize_speech`,{text:e,voiceId:n,requestId:t});if(a.aborted&&(p(t),g(a)),!r||typeof r.audioId!=`string`||!r.audioId.trim()||r.audioId.length>128||!Number.isInteger(r.sampleRate)||r.sampleRate<8e3||r.sampleRate>48e3||!Number.isFinite(r.durationMs)||r.durationMs<=0||r.durationMs>45e3)throw Error(`Invalid native speech audio.`);return{requestId:t,native:r}}let r=h(a,6e4);try{let i=await Aa(e,n,t,r.signal);return{requestId:t,wav:await ja(i)}}finally{r.dispose()}})();return r.catch(()=>{}),r};try{if(!c){u=new AudioContext({sampleRate:24e3});let e;try{await Da(Promise.race([u.resume(),new Promise((t,n)=>{e=setTimeout(()=>n(Error(`Audio playback is unavailable.`)),5e3)})]),a)}finally{clearTimeout(e)}}let e=async()=>{let e=await Da(s.next(),a);return e.done?void 0:_(e.value)},t=e(),n=!1;for(;;){let r=await Da(t,a);if(g(a),!r)break;if(t=e(),t.catch(()=>{}),n=!0,i?.(),r.native){if((await Da(Or(`mobile_play_speech`,{audioId:r.native.audioId,requestId:r.requestId}),a))?.completed!==!0)throw Error(`Speech playback was interrupted.`)}else{let e=await Da(u.decodeAudioData(r.wav),a);if(g(a),e.numberOfChannels!==1||!Number.isFinite(e.duration)||e.duration<=0||e.duration>45)throw Error(`Invalid speech audio duration.`);let t=u.createBufferSource();d=t,t.buffer=e,t.connect(u.destination);try{await new Promise((e,n)=>{f=n,t.onended=()=>e(),t.start()})}finally{f=void 0,t.onended=null,t.disconnect(),d=void 0}}l.delete(r.requestId),g(a)}if(!n)throw Error(`The reply has no speakable text.`)}finally{a.removeEventListener(`abort`,m),r.abort(new DOMException(`Speech playback ended.`,`AbortError`)),s.return?.(void 0).catch(()=>{});for(let e of l)p(e);try{d?.stop()}catch{}await u?.close().catch(()=>{})}}var Pa={schemaVersion:1,scope:`Offline license texts and provenance notices for the catalogued speech resources and local derivatives. This document is not legal advice, commercial-use clearance, a complete training-data rights audit, or approval for redistribution or formal release. Packaging this small notice file does not package the large models or resolve pending obligations. Native sherpa binaries and their compiled or embedded dependencies require a separate license/linkage and source-delivery audit; switching TTS models does not prove the binaries contain no GPL components or satisfy their obligations.`,licenseIdsMeaning:`References identify retained license documents applicable to the described components or their stated source projects. Multiple references are not alternative dual-license choices and are not a complete SPDX expression. A repository declaration does not relicense unrelated bundled data.`,statusDefinitions:{confirmed:`The specific content or source match described in summary was verified; this is not a whole-chain rights guarantee.`,declared:`An upstream license declaration supports the classification, without a complete reproducible provenance proof.`,pending:`The listed provenance, rights, or distribution obligations remain unresolved even where a license declaration exists.`},pathScopes:{model:`Paths are relative to the original downloaded model root. A terminal /** matches every descendant; all other paths are exact.`,shared:`Paths are relative to the application's shared resource root.`},licenses:[{id:`apache-2.0`,name:`Apache License 2.0 (X-ASR source text)`,text:` Apache License
|
|
3
3
|
Version 2.0, January 2004
|
|
4
4
|
http://www.apache.org/licenses/
|
|
5
5
|
|
|
@@ -508,7 +508,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
508
508
|
## Dictionary. Further addictions and improvements are planned
|
|
509
509
|
## for forthcoming releases.
|
|
510
510
|
##
|
|
511
|
-
`,sourceUrl:`https://raw.githubusercontent.com/myshell-ai/MeloTTS/209145371cff8fc3bd60d7be902ea69cbdb7965a/melo/text/cmudict.rep`,sha256:`08ee91f3c05c55160bdc599247ba53e5de8cc2597766fdb22b54a81cb24dd954`}],models:[{id:`x-asr-480ms-int8`,revision:`2026-06-05`,attribution:`X-ASR by Gilgamesh-J / GilgameshWind; trained using icefall and deployed with sherpa-onnx. The locked HF model card expressly covers model artifacts and declares Apache-2.0. The separately discovered GitHub license commit is not the locked HF revision. No root LICENSE or NOTICE was listed in the inspected HF tree; this is not proof that every historical distribution lacks NOTICE. Retain applicable upstream notices when found.`,archive:{url:`https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-x-asr-480ms-streaming-zipformer-transducer-zh-en-punct-int8-2026-06-05.tar.bz2`,sha256:`fa5f63d618e5a01526e275a358bb7772e403f84808a4769fba52cffd8160bf74`},groups:[{id:`xasr-weights`,pathScope:`model`,paths:[`encoder.int8.onnx`,`decoder.onnx`,`joiner.int8.onnx`],licenseIds:[`apache-2.0`],status:`pending`,summary:`Apache-2.0 is explicitly declared for X-ASR model artifacts. The sherpa export script describes icefall streaming ONNX export and INT8 quantization; installed file hashes match the catalog, but the 2026-06-05 archive-to-checkpoint/build identity is not established.`,pendingReasons:[`Exact checkpoint and source commits used to build the 2026-06-05 INT8 archive remain unverified; the export script downloads moving main URLs. Training-data rights are not fully audited.`],evidence:[{url:`https://hf-mirror.com/GilgameshWind/X-ASR-zh-en/resolve/689ff18c584d29910da37b6fe904db0c1489c9d1/README.md`,sha256:`7acc6f439d3e39e46de4298ccf8a8f6a483fdc5f9f5d08e61422b63760ec37b1`},{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/v1.13.7/scripts/zipformer-transducer/x-asr/export-streaming.sh`,sha256:`63b018fe72a29e9a41c6d4e358085b5ad1614e021c0d9f3c05a2d11f1dff0d81`}]},{id:`xasr-tokens`,pathScope:`model`,paths:[`tokens.txt`],licenseIds:[`apache-2.0`],status:`pending`,summary:`X-ASR token resource, not the SentencePiece or sherpa software. The punctuation export block downloads X-ASR-zh-en/zipformer/data/lang_5000_with_punctuation/tokens.txt. Catalog content SHA256: b818a60878b9aae978cbb8ad594acbd403d76d1af2e31ef4197c84e2dbdba27c.`,pendingReasons:[`The historical source revision for the token file in the 2026-06-05 archive is not pinned by the export script.`],evidence:[{url:`https://hf-mirror.com/GilgameshWind/X-ASR-zh-en/resolve/689ff18c584d29910da37b6fe904db0c1489c9d1/README.md`,sha256:`7acc6f439d3e39e46de4298ccf8a8f6a483fdc5f9f5d08e61422b63760ec37b1`},{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/v1.13.7/scripts/zipformer-transducer/x-asr/export-streaming.sh`,sha256:`63b018fe72a29e9a41c6d4e358085b5ad1614e021c0d9f3c05a2d11f1dff0d81`}]},{id:`xasr-bpe`,pathScope:`model`,paths:[`bpe.model`],licenseIds:[`apache-2.0`],status:`pending`,summary:`X-ASR BPE resource. The export script renames X-ASR-zh-en/zipformer/data/lang_5000_with_punctuation/bpe_punc.model to bpe.model. Its license classification comes from X-ASR, not from the software that reads the SentencePiece format.`,pendingReasons:[`The historical BPE source commit and exact archive build provenance remain unverified.`],evidence:[{url:`https://hf-mirror.com/GilgameshWind/X-ASR-zh-en/resolve/689ff18c584d29910da37b6fe904db0c1489c9d1/README.md`,sha256:`7acc6f439d3e39e46de4298ccf8a8f6a483fdc5f9f5d08e61422b63760ec37b1`},{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/v1.13.7/scripts/zipformer-transducer/x-asr/export-streaming.sh`,sha256:`63b018fe72a29e9a41c6d4e358085b5ad1614e021c0d9f3c05a2d11f1dff0d81`}]},{id:`xasr-bpe-vocab`,pathScope:`shared`,paths:[`speech-resources/xasr-bpe.vocab`],licenseIds:[`apache-2.0`],status:`pending`,summary:`Modified by Pisper: extracted the ordered SentencePiece pieces and scores as UTF-8 piece<TAB>score<LF> lines. This local text derivative retains the source resource license classification; it is not newly licensed as Pisper-owned model data. Original and derived hashes and generator are bound by xasr-bpe-extraction below.`,pendingReasons:[`The source BPE historical provenance remains pending as described in xasr-bpe. A text extraction does not resolve upstream rights.`],evidence:[{url:`https://hf-mirror.com/GilgameshWind/X-ASR-zh-en/resolve/689ff18c584d29910da37b6fe904db0c1489c9d1/README.md`,sha256:`7acc6f439d3e39e46de4298ccf8a8f6a483fdc5f9f5d08e61422b63760ec37b1`}]}],modifications:[{id:`xasr-bpe-extraction`,groupIds:[`xasr-bpe-vocab`],modifiedBy:`Pisper`,summary:`Local BPE text extraction, not retraining. The generator identity records the inspected repository implementation, not a claim about a historical upstream build date.`,source:{path:`bpe.model`,bytes:119265,sha256:`f87a38025a5fdd1e4e9591f6a44bb81295097ce0b80df6f4ab9f44e52c64ca5f`},derived:{path:`speech-resources/xasr-bpe.vocab`,bytes:61562,sha256:`01381aa0c3065832cb8d7462d529e3079a99be56c955ce93b4cb9b78e8aa34e5`},generator:{path:`scripts/speech-bpe.mjs`,sha256:`a1c85731aa3e0be89f04acc79830db784a9d43edb8af9f4fb723bb45bd725786`,method:`sentencePieceModelToVocab decodes ordered protobuf ModelProto.pieces and emits each piece, a tab, its finite score, and a newline without changing the BPE model.`}}]},{id:`vits-melo-tts-zh_en`,revision:`a0d5c6a264c0ef92d70d8661d8cc502d79627cd6`,archive:{url:`https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/vits-melo-tts-zh_en.tar.bz2`,bytes:167006755,sha256:`e58351ed7149f290a54534538badd4077cdbe6fddc964b24d0bee870415d1514`},attribution:`MeloTTS by MyShell.ai; sherpa-onnx ONNX conversion. The retained software license is Copyright (c) 2024 MyShell.ai, MIT. The neural-weight repository separately declares MIT; dictionary and FST resources have separate declarations and pending provenance. Pisper selects the original single female voice via public sid 0 and uses the same original FP32 ONNX, tokens, mixed-language lexicon, dictionary and normalization files on Desktop, Android and iOS. No retraining, quantization, graph/metadata patch or voice-subset derivative is made. The unused new_heteronym.fst and 133-byte model.int8.onnx Git LFS pointer in the transport archive are drained but not installed; retained model files are unchanged. These choices do not imply upstream/speaker endorsement, redistribution approval or completed native-platform acceptance.`,groups:[{id:`melo-weights`,pathScope:`model`,paths:[`model.onnx`],licenseIds:[`mit-melo`],status:`pending`,summary:`The myshell-ai/MeloTTS-Chinese model card at af5d207a364ea4208c6f589c89f57f88414bdd16 declares license: mit for the model repository; this is separate evidence from the MeloTTS software MIT license. The sherpa conversion package carries the exact MyShell.ai MIT text, and original ONNX metadata declares MIT license, melo-vits version 2, Chinese + English, n_speakers=1 and speaker_id=1. The conversion README explicitly describes a single female Chinese+English speaker. sherpa maps public sid 0 to the internal metadata speaker_id; Pisper does not change the graph, metadata or speaker embedding.`,pendingReasons:[`Exact historical checkpoint, training/conversion commits and reproducible archive build identity have not been established; the inspected conversion workflow uses moving upstream references. Training-data permissions, individual speaker consent and applicable personality/publicity rights are not fully audited. The discovered model card revision is evidence of a declaration, not proof of the historical conversion input.`],evidence:[{url:`https://hf-mirror.com/myshell-ai/MeloTTS-Chinese/resolve/af5d207a364ea4208c6f589c89f57f88414bdd16/README.md`,sha256:`40b5b860bacbb3947cbef838719e660d2fe4961eba5b484290b4bedc0253e208`},{url:`https://raw.githubusercontent.com/myshell-ai/MeloTTS/209145371cff8fc3bd60d7be902ea69cbdb7965a/LICENSE`,sha256:`88a50e5a02bbc2a5c2f084dc19da751aa97b1690f5fda76cd8005c8634d1ca70`},{url:`https://hf-mirror.com/csukuangfj/vits-melo-tts-zh_en/resolve/a0d5c6a264c0ef92d70d8661d8cc502d79627cd6/README.md`,sha256:`ae6e44dead53dfdbd5b4a77106226f3118eb910222b46cb5533a3860773fc6c7`},{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/scripts/melo-tts/export-onnx.py`,sha256:`c0be7727d59ad6ceaf39e909b4560b57e704091c69ac3fab6f2f2abfd931c916`},{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/scripts/melo-tts/run.sh`,sha256:`e2afb98d9028eded2983f780468337fc019a8306db926f89e3bdeed18af867bb`},{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/sherpa-onnx/csrc/offline-tts-vits-model.cc`,sha256:`060907349036d63b60d035843defe7078b83c8099e0d4de323446c7db0d653d0`}]},{id:`melo-tokens`,pathScope:`model`,paths:[`tokens.txt`],licenseIds:[`mit-melo`,`apache-2.0-sherpa`],status:`declared`,summary:`The sherpa Melo export writes enumerated model.hps symbols to tokens.txt. The original 655-byte token file is retained unchanged. Melo software is MIT; sherpa conversion code is Apache-2.0. These code declarations do not independently establish all underlying training-data rights.`,pendingReasons:[],evidence:[{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/scripts/melo-tts/export-onnx.py`,sha256:`c0be7727d59ad6ceaf39e909b4560b57e704091c69ac3fab6f2f2abfd931c916`},{url:`https://raw.githubusercontent.com/myshell-ai/MeloTTS/209145371cff8fc3bd60d7be902ea69cbdb7965a/LICENSE`,sha256:`88a50e5a02bbc2a5c2f084dc19da751aa97b1690f5fda76cd8005c8634d1ca70`},{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/LICENSE`,sha256:`cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30`}]},{id:`melo-cppjieba-dictionary`,pathScope:`model`,paths:[`dict/hmm_model.utf8`,`dict/idf.utf8`,`dict/jieba.dict.utf8`,`dict/pos_dict/char_state_tab.utf8`,`dict/pos_dict/prob_emit.utf8`,`dict/pos_dict/prob_start.utf8`,`dict/pos_dict/prob_trans.utf8`,`dict/README.md`,`dict/stop_words.utf8`],licenseIds:[`mit-cppjieba`],status:`confirmed`,summary:`Nine ordinary dictionary/README files are byte-identical to the separately HTTPS-downloaded CppJieba sherpa-onnx-2024-04-19 dict archive. The exact release source MIT license retains Copyright (c) 2013. This confirms the documented source-content match, not a whole-chain data-rights guarantee. The small Melo user.dict.utf8 is separately classified and is NOT the 829194-byte pypinyin-derived user dictionary from that source archive.`,pendingReasons:[],evidence:[{url:`https://ghfast.top/https://github.com/csukuangfj/cppjieba/releases/download/sherpa-onnx-2024-04-19/dict.tar.bz2`,sha256:`35c3877c9b9221a5b2d69bbf57d5dbf1ccbe5b7684c60eb42f93db6b2d494f26`},{url:`https://raw.githubusercontent.com/csukuangfj/cppjieba/f03dd931a00330c279c8590275850fd1f6749a18/LICENSE`,sha256:`ba898a14f729ba5e9965da34e3eecd5edd3795f2cc5d7c923b815ba79bb851b0`},{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/.github/workflows/export-melo-tts-to-onnx.yaml`,sha256:`fc90fc412fd6f3c8a7d593743372a077dd63b2c8ce0780ed9c3a7e05cc8b659e`}]},{id:`melo-user-dictionary`,pathScope:`model`,paths:[`dict/user.dict.utf8`],licenseIds:[`mit-cppjieba`,`mit-melo`],status:`pending`,summary:`Melo ships an unchanged 49-byte user dictionary containing four entries. It matches the locked Melo HF file but differs from the separately downloaded CppJieba release user dictionary. The package MIT text and CppJieba project MIT declaration are retained as source declarations, not proof that either automatically licenses every edit. This file is not attributed to the unrelated historical pypinyin-derived dictionary.`,pendingReasons:[`The exact historical source commit, modifier and license coverage for this 49-byte replacement have not been identified. Retain applicable modifier notices when established.`],evidence:[{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/.github/workflows/export-melo-tts-to-onnx.yaml`,sha256:`fc90fc412fd6f3c8a7d593743372a077dd63b2c8ce0780ed9c3a7e05cc8b659e`},{url:`https://raw.githubusercontent.com/csukuangfj/cppjieba/f03dd931a00330c279c8590275850fd1f6749a18/LICENSE`,sha256:`ba898a14f729ba5e9965da34e3eecd5edd3795f2cc5d7c923b815ba79bb851b0`},{url:`https://raw.githubusercontent.com/myshell-ai/MeloTTS/209145371cff8fc3bd60d7be902ea69cbdb7965a/LICENSE`,sha256:`88a50e5a02bbc2a5c2f084dc19da751aa97b1690f5fda76cd8005c8634d1ca70`},{url:`https://huggingface.co/csukuangfj/vits-melo-tts-zh_en/resolve/a0d5c6a264c0ef92d70d8661d8cc502d79627cd6/dict/user.dict.utf8`,sha256:`495bbf49270408a1234690e1e6a97328f30a482a7a72aa769e8a12e8714b0c62`}]},{id:`melo-english-lexicon`,pathScope:`model`,paths:[`lexicon.txt`],licenseIds:[`cmudict-0.6-1998`,`mit-melo`,`apache-2.0-sherpa`],status:`pending`,summary:`The English portion is generated by the sherpa Melo export from melo.text.english.eng_dict and refine_syllables, lowercasing words and adding language tone offsets plus kaldi/SF entries. The inspected Melo source reads cmudict.rep or a cached pickle. cmudict.rep contains its own Copyright 1998 Carnegie Mellon University unrestricted research/commercial permission and attribution notice, retained verbatim in cmudict-0.6-1998. This is NOT a substitution of a modern CMUdict BSD license. The retained notice hash covers the complete original comment header; the evidence hash covers the complete 3969309-byte source file. No package script or pickle was executed.`,pendingReasons:[`The precise historical dictionary/cache inputs and all intervening modifications used for this lexicon have not been pinned or reproduced. Trace cached-data equivalence and retain applicable original and modifier notices.`],evidence:[{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/scripts/melo-tts/export-onnx.py`,sha256:`c0be7727d59ad6ceaf39e909b4560b57e704091c69ac3fab6f2f2abfd931c916`},{url:`https://raw.githubusercontent.com/myshell-ai/MeloTTS/209145371cff8fc3bd60d7be902ea69cbdb7965a/melo/text/english.py`,sha256:`28527f574511bfc13fe1f2f6bbb5bfe4072c06e1c7e9b69598138aef81b9905b`},{url:`https://raw.githubusercontent.com/myshell-ai/MeloTTS/209145371cff8fc3bd60d7be902ea69cbdb7965a/melo/text/cmudict.rep`,sha256:`d127b5ce8b8e695732701e8efde04b9b0fa11991218b1fb9d21bd0c9264636aa`},{url:`https://raw.githubusercontent.com/myshell-ai/MeloTTS/209145371cff8fc3bd60d7be902ea69cbdb7965a/LICENSE`,sha256:`88a50e5a02bbc2a5c2f084dc19da751aa97b1690f5fda76cd8005c8634d1ca70`},{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/LICENSE`,sha256:`cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30`}]},{id:`melo-chinese-lexicon`,pathScope:`model`,paths:[`lexicon.txt`],licenseIds:[`mit-pypinyin`,`mit-melo`,`apache-2.0-sherpa`],status:`pending`,summary:`The Chinese portion is generated by the sherpa Melo export from pypinyin character/phrase dictionaries, lazy_pinyin and the Melo pinyin-to-symbol map. Melo code is MIT, sherpa conversion code Apache-2.0, and pypinyin declares MIT. Those software declarations do not relicense external dictionary inputs. The same 6837671-byte mixed-language lexicon is used unchanged on every platform.`,pendingReasons:[`Pin historical pypinyin versions, character/phrase JSON data and Melo phoneme mapping, reproduce the output and trace the actual underlying source-data terms. No particular Zdic, CC-CEDICT or Unihan license is asserted without proof of the actual input chain.`],evidence:[{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/scripts/melo-tts/export-onnx.py`,sha256:`c0be7727d59ad6ceaf39e909b4560b57e704091c69ac3fab6f2f2abfd931c916`},{url:`https://raw.githubusercontent.com/mozillazg/python-pinyin/8595294b1a97845e30f11ecfdb3caa4e61ac3988/pypinyin/pinyin_dict.py`,sha256:`245c1f70509432b289cde1f938157cd5ff1372d1d083b577d5fab72b4dfcda08`},{url:`https://raw.githubusercontent.com/mozillazg/python-pinyin/8595294b1a97845e30f11ecfdb3caa4e61ac3988/pypinyin/phrases_dict.py`,sha256:`3f6f39bbca68d8d1676ea463cd4620b934b03160cc5042fb9d9007b8f3a80b9e`},{url:`https://raw.githubusercontent.com/mozillazg/python-pinyin/8595294b1a97845e30f11ecfdb3caa4e61ac3988/LICENSE.txt`,sha256:`1e6c90014b4912815c296ee64bb6f6280af47e6d4c5d80e86232dfc5defe764c`},{url:`https://raw.githubusercontent.com/myshell-ai/MeloTTS/209145371cff8fc3bd60d7be902ea69cbdb7965a/LICENSE`,sha256:`88a50e5a02bbc2a5c2f084dc19da751aa97b1690f5fda76cd8005c8634d1ca70`}]},{id:`melo-normalization-fsts`,pathScope:`model`,paths:[`date.fst`,`number.fst`,`phone.fst`],licenseIds:[`apache-2.0-sherpa`],status:`pending`,summary:`All three FSTs are byte-identical to the separately downloaded data/date.fst, data/number.fst and data/phone.fst at csukuangfj/icefall-tts-aishell3-vits-low-2024-04-06 revision 57345c004e13ed640e408c4c29ab56187b18f065, the source repository named by the Melo packaging workflow. That source model card declares Apache-2.0; the full Apache text is retained from sherpa. Neither the OpenFst software license nor the Melo neural-weight MIT declaration independently grants rights to these FST data.`,pendingReasons:[`Exact editable generation rules, compiler/source revisions, underlying data provenance and applicable author/modifier notices remain unverified. No standalone FST LICENSE/NOTICE or complete reproducible source chain was found in the inspected source tree.`],evidence:[{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/.github/workflows/export-melo-tts-to-onnx.yaml`,sha256:`fc90fc412fd6f3c8a7d593743372a077dd63b2c8ce0780ed9c3a7e05cc8b659e`},{url:`https://hf-mirror.com/csukuangfj/icefall-tts-aishell3-vits-low-2024-04-06/resolve/57345c004e13ed640e408c4c29ab56187b18f065/README.md`,sha256:`98b45ea81164d1e1a1dd82255207053b15cd6c69d922a1c5cf3387ce604d4b74`},{url:`https://hf-mirror.com/csukuangfj/icefall-tts-aishell3-vits-low-2024-04-06/resolve/57345c004e13ed640e408c4c29ab56187b18f065/data/date.fst`,sha256:`eb8aa079ae3cb81d8f4404992f39d61a0cb990947512b5b8d1e54d1f6980e718`},{url:`https://hf-mirror.com/csukuangfj/icefall-tts-aishell3-vits-low-2024-04-06/resolve/57345c004e13ed640e408c4c29ab56187b18f065/data/number.fst`,sha256:`743f402181fcfebf76cc2f0546b71fa26476e626fbe4e460fb7b4c3a7a8bd5bd`},{url:`https://hf-mirror.com/csukuangfj/icefall-tts-aishell3-vits-low-2024-04-06/resolve/57345c004e13ed640e408c4c29ab56187b18f065/data/phone.fst`,sha256:`1ac2b6fa56b1442320c4de7db08353bab8963a2b57f365eebcdd3a2d3562f8d7`},{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/LICENSE`,sha256:`cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30`}]},{id:`melo-package-notices`,pathScope:`model`,paths:[`LICENSE`,`README.md`],licenseIds:[`mit-melo`],status:`confirmed`,summary:`LICENSE is byte-identical to the original MyShell.ai MIT text (Copyright (c) 2024 MyShell.ai), including its exact final newline behavior. README explicitly identifies the single female Chinese+English speaker. The package-level MIT file is not a blanket grant for every bundled dictionary or FST. No upstream NOTICE was listed in the inspected conversion and weight repository trees; this is not proof that none ever existed.`,pendingReasons:[],evidence:[{url:`https://raw.githubusercontent.com/myshell-ai/MeloTTS/209145371cff8fc3bd60d7be902ea69cbdb7965a/LICENSE`,sha256:`88a50e5a02bbc2a5c2f084dc19da751aa97b1690f5fda76cd8005c8634d1ca70`},{url:`https://hf-mirror.com/csukuangfj/vits-melo-tts-zh_en/resolve/a0d5c6a264c0ef92d70d8661d8cc502d79627cd6/README.md`,sha256:`ae6e44dead53dfdbd5b4a77106226f3118eb910222b46cb5533a3860773fc6c7`}]}],modifications:[]}]},Fa=Pa,Ia=e=>Pa.models.some(t=>t.id===e);function La({modelId:e,modelName:t,returnFocus:n,onClose:r}){let{t:i}=o(),a=Fa.models.find(t=>t.id===e);if(!a)return null;let s=new Set(a.groups.flatMap(e=>e.licenseIds)),c=Fa.licenses.filter(e=>s.has(e.id));return(0,$.jsx)(Pn,{open:!0,onOpenChange:e=>{e||r()},children:(0,$.jsxs)(jn,{className:`z-[130] max-h-[85dvh] min-w-0 grid-cols-1 overflow-y-auto rounded-lg sm:max-w-2xl`,overlayClassName:`z-[129]`,onEscapeKeyDown:e=>e.stopPropagation(),onCloseAutoFocus:e=>{e.preventDefault(),n.current?.isConnected&&n.current.focus()},children:[(0,$.jsxs)(Nn,{children:[(0,$.jsx)(Mn,{children:i(`chat:speechModels.notices`)}),(0,$.jsxs)(An,{className:`break-words`,children:[t,` (`,a.revision,`)`]})]}),(0,$.jsx)(`p`,{className:`break-words text-sm text-muted-foreground`,children:Fa.scope}),(0,$.jsx)(`p`,{className:`break-words text-sm text-muted-foreground`,children:Fa.licenseIdsMeaning}),(0,$.jsx)(`div`,{className:`min-w-0 divide-y divide-stroke-soft`,children:a.groups.map(e=>(0,$.jsxs)(`details`,{className:`min-w-0 py-3`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer break-words text-sm font-medium`,children:[e.id,e.status===`pending`&&(0,$.jsx)(`span`,{className:`ml-2 text-xs font-normal text-warning-strong`,children:i(`chat:speechModels.provenancePending`)})]}),(0,$.jsxs)(`div`,{className:`mt-3 min-w-0 space-y-3 text-sm`,children:[(0,$.jsx)(`p`,{className:`break-words`,children:e.summary}),e.pendingReasons.map(e=>(0,$.jsx)(`p`,{className:`break-words text-muted-foreground`,children:e},e)),(0,$.jsx)(`pre`,{className:`whitespace-pre-wrap break-all text-xs`,children:JSON.stringify({pathScope:e.pathScope,paths:e.paths,licenseIds:e.licenseIds,evidence:e.evidence},null,2)})]})]},e.id))}),(0,$.jsxs)(`details`,{className:`min-w-0 border-t pt-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:i(`chat:speechModels.modifications`)}),(0,$.jsx)(`pre`,{className:`mt-3 whitespace-pre-wrap break-all text-xs`,children:JSON.stringify(a.modifications,null,2)})]}),c.map(e=>(0,$.jsxs)(`details`,{className:`min-w-0 border-t pt-3`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer break-words text-sm font-medium`,children:[e.name,` (`,e.id,`)`]}),(0,$.jsx)(`pre`,{className:`mt-3 whitespace-pre-wrap break-words text-xs`,children:e.text})]},e.id)),(0,$.jsx)(`div`,{className:`flex justify-end border-t pt-3`,children:(0,$.jsxs)(It,{children:[(0,$.jsx)(Pt,{asChild:!0,children:(0,$.jsx)(Y,{size:`icon-sm`,variant:`outline`,onClick:()=>{let e=new Blob([JSON.stringify({...Fa,models:[a],licenses:c},null,2)],{type:`application/json;charset=utf-8`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`${a.id}-notices.json`,n.click(),window.setTimeout(()=>URL.revokeObjectURL(t),0)},"aria-label":i(`chat:speechModels.downloadNotices`),children:(0,$.jsx)(W,{})})}),(0,$.jsx)(Ft,{children:i(`chat:speechModels.downloadNotices`)})]})})]})})}var Ra=e=>`${new Intl.NumberFormat(void 0,{maximumFractionDigits:1}).format(e/1048576)} MiB`;function za({manager:e,onClose:t}){let{t:n}=o(),[r,i]=(0,Q.useState)(!1),[a,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(null),u=(0,Q.useRef)(null),d=(0,Q.useRef)(null),f=()=>{u.current?.abort(),u.current=null,i(!1)};(0,Q.useEffect)(()=>(e.open||(u.current?.abort(),u.current=null,i(!1),l(null)),()=>{u.current?.abort(),u.current=null}),[e.open]);let p={"not-installed":n(`chat:speechModels.notInstalled`),downloading:n(`chat:speechModels.downloading`),verifying:n(`chat:speechModels.verifying`),installed:n(`chat:speechModels.installed`),cancelled:n(`chat:speechModels.cancelled`),error:n(`chat:speechModels.failed`)},m=e.models.flatMap(e=>e.voices||[]),h=m.find(t=>t.id===e.selectedVoice),g=e.models.some(e=>e.kind===`tts`&&e.status===`installed`),_=e.models.filter(e=>e.status!==`installed`),v=_.some(e=>[`downloading`,`verifying`].includes(e.status)),y=()=>{l(null),f(),e.close(),t()},b=async()=>{if(u.current){f();return}if(!h||!g||_.length)return;let e=new AbortController;u.current=e,i(!0),s(``);try{await Ma(h.language===`en`?n(`chat:speechModels.previewEnglish`):n(`chat:speechModels.previewChinese`),h.id,e.signal)}catch(t){e.signal.aborted||s(t instanceof Error?t.message:String(t))}finally{u.current===e&&(u.current=null,i(!1))}};return(0,$.jsxs)(Pn,{open:e.open,onOpenChange:e=>{e||y()},children:[(0,$.jsxs)(jn,{className:`z-[110] max-h-[85dvh] overflow-y-auto sm:max-w-md`,overlayClassName:`z-[109]`,onEscapeKeyDown:e=>e.stopPropagation(),children:[(0,$.jsxs)(Nn,{children:[(0,$.jsx)(Mn,{children:n(`chat:speechModels.title`)}),(0,$.jsx)(An,{className:`sr-only`,children:n(`chat:speechModels.title`)})]}),!e.catalog&&!e.error&&(0,$.jsx)(et,{className:`mx-auto my-4 size-5 animate-spin`,"aria-label":n(`chat:speechModels.loading`)}),(0,$.jsx)(`div`,{className:`min-w-0 divide-y divide-stroke-soft`,children:e.models.map(t=>{let r=[`downloading`,`verifying`].includes(t.status),i=t.totalBytes?Math.min(100,Math.floor(t.downloadedBytes/t.totalBytes*100)):0,a=t.license?.url.startsWith(`https://`)?t.license.url:void 0;return(0,$.jsxs)(`section`,{className:`min-w-0 space-y-2 py-3 first:pt-0`,"aria-label":t.name,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t.kind===`asr`?n(`chat:speechModels.recognition`):n(`chat:speechModels.synthesis`)}),(0,$.jsx)(`div`,{className:`break-words font-medium`,children:t.name})]}),t.status===`installed`?(0,$.jsx)(z,{className:`size-5 shrink-0 text-success`,"aria-label":p.installed}):(0,$.jsxs)(It,{children:[(0,$.jsx)(Pt,{asChild:!0,children:(0,$.jsx)(Y,{size:`icon-sm`,variant:`outline`,disabled:e.loading,onClick:()=>{r?e.cancelDownload(t.id):e.download(t.id)},"aria-label":n(r?`chat:speechModels.cancelDownload`:`chat:speechModels.download`),children:r?(0,$.jsx)(dt,{}):(0,$.jsx)(W,{})})}),(0,$.jsx)(Ft,{children:n(r?`chat:speechModels.cancelDownload`:`chat:speechModels.download`)})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-1 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:p[t.status]}),(0,$.jsx)(`span`,{className:`tabular-nums`,children:r?`${Ra(t.downloadedBytes)} / ${Ra(t.totalBytes)}`:Ra(t.totalBytes)})]}),r&&(0,$.jsx)(Dt,{value:i,"aria-label":t.name,"aria-valuenow":i,"aria-valuemin":0,"aria-valuemax":100}),t.error&&(0,$.jsx)(`p`,{role:`alert`,className:`break-words text-xs text-destructive`,children:t.error}),t.license&&(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[(0,$.jsx)(`a`,{href:a,target:`_blank`,rel:`noreferrer`,className:`block break-words text-xs text-muted-foreground underline underline-offset-2`,children:t.license.name}),Ia(t.id)&&(0,$.jsxs)(It,{children:[(0,$.jsx)(Pt,{asChild:!0,children:(0,$.jsx)(Y,{size:`icon-sm`,variant:`ghost`,"aria-label":n(`chat:speechModels.notices`),onClick:e=>{d.current=e.currentTarget,f(),l(t)},children:(0,$.jsx)(M,{})})}),(0,$.jsx)(Ft,{children:n(`chat:speechModels.notices`)})]})]})]},t.id)})}),m.length>0&&(0,$.jsx)(`div`,{className:`space-y-2 border-t pt-3`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-sm`,children:n(`chat:speechModels.voice`)}),(0,$.jsxs)(It,{children:[(0,$.jsx)(Pt,{asChild:!0,children:(0,$.jsx)(Y,{size:`icon`,variant:`outline`,disabled:!g||_.length>0,onClick:()=>void b(),"aria-label":n(r?`chat:speechModels.stopPreview`:`chat:speechModels.preview`),children:r?(0,$.jsx)(dt,{}):(0,$.jsx)(at,{})})}),(0,$.jsx)(Ft,{children:n(r?`chat:speechModels.stopPreview`:`chat:speechModels.preview`)})]})]})}),(e.error||a)&&(0,$.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-destructive`,children:e.error||a}),(0,$.jsx)(`div`,{className:`flex justify-end border-t pt-3`,children:_.length?(0,$.jsxs)(Y,{disabled:e.loading||v,onClick:()=>void e.downloadAll(),children:[(0,$.jsx)(W,{}),n(`chat:speechModels.downloadAll`)]}):(0,$.jsx)(Y,{disabled:!e.catalog,onClick:y,children:n(`chat:speechModels.done`)})})]}),e.open&&c&&(0,$.jsx)(La,{modelId:c.id,modelName:c.name,returnFocus:d,onClose:()=>l(null)})]})}var Ba=16e3,Va=Ba*60;function Ha(e,t){let n=window.__TAURI__?.core?.invoke??window.__TAURI_INTERNALS__?.invoke;return n?n(e,t):Promise.reject(Error(`移动端原生桥不可用。`))}async function Ua(){if(!(typeof window>`u`||!window.__PISPER_MOBILE_APP__)&&(await Ha(`mobile_request_microphone_permission`)).state!==`granted`)throw Error(`microphone_permission_denied`)}async function Wa(e){let t=await e.text().catch(()=>``);try{return JSON.parse(t).error||`语音转写失败 (${e.status})`}catch{return t||`语音转写失败 (${e.status})`}}function Ga(e){let t=e.reduce((e,t)=>e+t.length,0),n=new Float32Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}var Ka=class{chatSessionId;chunks=[];pending=[];listeners=new Set;controller=null;sessionId=``;nativeRequestId=``;legacy=!1;flushTimer=0;sendChain=Promise.resolve();finished=!1;retainedSamples=0;terms=[];initializing=null;constructor(e=``){this.chatSessionId=e}start(){return this.initializing=this.initialize().catch(async e=>{throw await this.cancel(),e}),this.initializing}async initialize(){this.chunks=[],this.pending=[],this.finished=!1,this.retainedSamples=0;let e=new AbortController;this.controller=e,await b(),g(e.signal);let{loadSpeechHotwords:n,prepareSpeechSession:r}=await t(async()=>{let{loadSpeechHotwords:e,prepareSpeechSession:t}=await import(`./speech-session--qKchPMR.js`).then(e=>e.r);return{loadSpeechHotwords:e,prepareSpeechSession:t}},__vite__mapDeps([139,1,2,3,13,15,14,5,6,7,8,12,16])),{terms:i,hotwords:a}=await n(this.chatSessionId,e.signal);this.terms=i;let o=await r({kinds:[`asr`],hotwords:a},e.signal);if(g(o.signal),o.signal.addEventListener(`abort`,()=>{this.controller===e&&!e.signal.aborted&&this.cancel()},{once:!0}),window.__PISPER_MOBILE_APP__)return;let s=h(e.signal,3e4);try{let t=await fetch(`/api/speech/stream/start`,{method:`POST`,headers:{"X-Pisper-Chat-Session":this.chatSessionId},signal:s.signal});if(!t.ok){if(t.status===404){this.legacy=!0;return}throw Error(await Wa(t))}let n=await t.json();if(!n.id)throw Error(`语音识别会话创建失败。`);e.signal.aborted&&(await fetch(`/api/speech/stream/cancel`,{method:`POST`,headers:{"X-Pisper-Speech-Session":n.id}}).catch(()=>{}),g(e.signal)),this.sessionId=n.id,this.pending.push(...this.chunks.splice(0)),this.retainedSamples=0,this.flushTimer=window.setInterval(()=>void this.flushPending(),1e3)}finally{s.dispose()}}acceptPcm(e){if(!e.length||this.finished)return!1;if(window.__PISPER_MOBILE_APP__||!this.sessionId){let t=Va-this.retainedSamples;if(t<=0)return!0;let n=e.slice(0,t);return this.chunks.push(n),this.retainedSamples+=n.length,this.retainedSamples>=Va}let t=e.slice();return this.sessionId&&!this.legacy?this.pending.push(t):this.chunks.push(t),!1}onPartial(e){return this.listeners.add(e),()=>this.listeners.delete(e)}emitPartial(e){if(e)for(let t of this.listeners)t(e)}flushPending(){return this.sendChain=this.sendChain.then(async()=>{if(!this.sessionId||this.legacy||this.finished||!this.pending.length)return;let e=Ga(this.pending.splice(0));try{let t=await fetch(`/api/speech/stream/chunk`,{method:`POST`,headers:{"Content-Type":`application/octet-stream`,"X-Pisper-Sample-Rate":String(Ba),"X-Pisper-Speech-Session":this.sessionId},body:e.buffer,signal:this.controller?.signal});if(!t.ok)return;let n=await t.json();typeof n.text==`string`&&this.emitPartial(n.text.trim())}catch{}}),this.sendChain}async finishStreaming(){window.clearInterval(this.flushTimer),this.flushTimer=0,await this.flushPending(),this.finished=!0;let e=await fetch(`/api/speech/stream/finish`,{method:`POST`,headers:{"X-Pisper-Speech-Session":this.sessionId},signal:this.controller?.signal});if(!e.ok)throw Error(await Wa(e));let t=await e.json(),n=typeof t.text==`string`?t.text.trim():``;if(!n)throw Error(`未识别到语音内容。`);return this.emitPartial(n),n}async finishOneShot(e){if(window.__PISPER_MOBILE_APP__){let t=new Uint8Array(e.buffer),n=``,r=32768;for(let e=0;e<t.length;e+=r)n+=String.fromCharCode(...t.subarray(e,e+r));let i=this.controller;if(!i)throw new DOMException(`Speech recognition cancelled.`,`AbortError`);g(i.signal);let a=crypto.randomUUID();this.nativeRequestId=a;let o=await Ha(`mobile_transcribe_pcm`,{pcmBase64:btoa(n),hotwords:Tr(this.terms),requestId:a});if(g(i.signal),this.controller!==i)throw new DOMException(`Speech recognition cancelled.`,`AbortError`);let s=Dr(typeof o.text==`string`?o.text.trim():``,this.terms);if(!s)throw Error(`未识别到语音内容。`);return this.emitPartial(s),s}let t=await fetch(`/api/speech/transcribe`,{method:`POST`,headers:{"Content-Type":`application/octet-stream`,"X-Pisper-Sample-Rate":String(Ba),"X-Pisper-Chat-Session":this.chatSessionId},body:e.buffer,signal:this.controller?.signal});if(!t.ok)throw Error(await Wa(t));let n=await t.json(),r=typeof n.text==`string`?n.text.trim():``;if(!r)throw Error(`未识别到语音内容。`);return this.emitPartial(r),r}async finish(){if(await this.initializing,!this.controller)throw Error(`语音识别尚未启动。`);if(this.sessionId&&!this.legacy)return this.finishStreaming();this.finished=!0;let e=Ga(this.chunks);if(!e.length)throw Error(`没有采集到语音。`);return this.finishOneShot(e)}async cancel(){if(this.finished=!0,window.clearInterval(this.flushTimer),this.flushTimer=0,this.controller?.abort(),this.controller=null,this.chunks=[],this.pending=[],this.retainedSamples=0,this.nativeRequestId){let e=this.nativeRequestId;this.nativeRequestId=``,await Ha(`mobile_cancel_speech`,{requestId:e}).catch(()=>{})}if(this.sessionId&&!this.legacy){let e=this.sessionId;this.sessionId=``,await fetch(`/api/speech/stream/cancel`,{method:`POST`,headers:{"X-Pisper-Speech-Session":e}}).catch(()=>{})}}async dispose(){await this.cancel(),this.listeners.clear()}};function qa({chatSessionId:e=``}={}){return new Ka(e)}var Ja=`
|
|
511
|
+
`,sourceUrl:`https://raw.githubusercontent.com/myshell-ai/MeloTTS/209145371cff8fc3bd60d7be902ea69cbdb7965a/melo/text/cmudict.rep`,sha256:`08ee91f3c05c55160bdc599247ba53e5de8cc2597766fdb22b54a81cb24dd954`}],models:[{id:`x-asr-480ms-int8`,revision:`2026-06-05`,attribution:`X-ASR by Gilgamesh-J / GilgameshWind; trained using icefall and deployed with sherpa-onnx. The locked HF model card expressly covers model artifacts and declares Apache-2.0. The separately discovered GitHub license commit is not the locked HF revision. No root LICENSE or NOTICE was listed in the inspected HF tree; this is not proof that every historical distribution lacks NOTICE. Retain applicable upstream notices when found.`,archive:{url:`https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-x-asr-480ms-streaming-zipformer-transducer-zh-en-punct-int8-2026-06-05.tar.bz2`,sha256:`fa5f63d618e5a01526e275a358bb7772e403f84808a4769fba52cffd8160bf74`},groups:[{id:`xasr-weights`,pathScope:`model`,paths:[`encoder.int8.onnx`,`decoder.onnx`,`joiner.int8.onnx`],licenseIds:[`apache-2.0`],status:`pending`,summary:`Apache-2.0 is explicitly declared for X-ASR model artifacts. The sherpa export script describes icefall streaming ONNX export and INT8 quantization; installed file hashes match the catalog, but the 2026-06-05 archive-to-checkpoint/build identity is not established.`,pendingReasons:[`Exact checkpoint and source commits used to build the 2026-06-05 INT8 archive remain unverified; the export script downloads moving main URLs. Training-data rights are not fully audited.`],evidence:[{url:`https://hf-mirror.com/GilgameshWind/X-ASR-zh-en/resolve/689ff18c584d29910da37b6fe904db0c1489c9d1/README.md`,sha256:`7acc6f439d3e39e46de4298ccf8a8f6a483fdc5f9f5d08e61422b63760ec37b1`},{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/v1.13.7/scripts/zipformer-transducer/x-asr/export-streaming.sh`,sha256:`63b018fe72a29e9a41c6d4e358085b5ad1614e021c0d9f3c05a2d11f1dff0d81`}]},{id:`xasr-tokens`,pathScope:`model`,paths:[`tokens.txt`],licenseIds:[`apache-2.0`],status:`pending`,summary:`X-ASR token resource, not the SentencePiece or sherpa software. The punctuation export block downloads X-ASR-zh-en/zipformer/data/lang_5000_with_punctuation/tokens.txt. Catalog content SHA256: b818a60878b9aae978cbb8ad594acbd403d76d1af2e31ef4197c84e2dbdba27c.`,pendingReasons:[`The historical source revision for the token file in the 2026-06-05 archive is not pinned by the export script.`],evidence:[{url:`https://hf-mirror.com/GilgameshWind/X-ASR-zh-en/resolve/689ff18c584d29910da37b6fe904db0c1489c9d1/README.md`,sha256:`7acc6f439d3e39e46de4298ccf8a8f6a483fdc5f9f5d08e61422b63760ec37b1`},{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/v1.13.7/scripts/zipformer-transducer/x-asr/export-streaming.sh`,sha256:`63b018fe72a29e9a41c6d4e358085b5ad1614e021c0d9f3c05a2d11f1dff0d81`}]},{id:`xasr-bpe`,pathScope:`model`,paths:[`bpe.model`],licenseIds:[`apache-2.0`],status:`pending`,summary:`X-ASR BPE resource. The export script renames X-ASR-zh-en/zipformer/data/lang_5000_with_punctuation/bpe_punc.model to bpe.model. Its license classification comes from X-ASR, not from the software that reads the SentencePiece format.`,pendingReasons:[`The historical BPE source commit and exact archive build provenance remain unverified.`],evidence:[{url:`https://hf-mirror.com/GilgameshWind/X-ASR-zh-en/resolve/689ff18c584d29910da37b6fe904db0c1489c9d1/README.md`,sha256:`7acc6f439d3e39e46de4298ccf8a8f6a483fdc5f9f5d08e61422b63760ec37b1`},{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/v1.13.7/scripts/zipformer-transducer/x-asr/export-streaming.sh`,sha256:`63b018fe72a29e9a41c6d4e358085b5ad1614e021c0d9f3c05a2d11f1dff0d81`}]},{id:`xasr-bpe-vocab`,pathScope:`shared`,paths:[`speech-resources/xasr-bpe.vocab`],licenseIds:[`apache-2.0`],status:`pending`,summary:`Modified by Pisper: extracted the ordered SentencePiece pieces and scores as UTF-8 piece<TAB>score<LF> lines. This local text derivative retains the source resource license classification; it is not newly licensed as Pisper-owned model data. Original and derived hashes and generator are bound by xasr-bpe-extraction below.`,pendingReasons:[`The source BPE historical provenance remains pending as described in xasr-bpe. A text extraction does not resolve upstream rights.`],evidence:[{url:`https://hf-mirror.com/GilgameshWind/X-ASR-zh-en/resolve/689ff18c584d29910da37b6fe904db0c1489c9d1/README.md`,sha256:`7acc6f439d3e39e46de4298ccf8a8f6a483fdc5f9f5d08e61422b63760ec37b1`}]}],modifications:[{id:`xasr-bpe-extraction`,groupIds:[`xasr-bpe-vocab`],modifiedBy:`Pisper`,summary:`Local BPE text extraction, not retraining. The generator identity records the inspected repository implementation, not a claim about a historical upstream build date.`,source:{path:`bpe.model`,bytes:119265,sha256:`f87a38025a5fdd1e4e9591f6a44bb81295097ce0b80df6f4ab9f44e52c64ca5f`},derived:{path:`speech-resources/xasr-bpe.vocab`,bytes:61562,sha256:`01381aa0c3065832cb8d7462d529e3079a99be56c955ce93b4cb9b78e8aa34e5`},generator:{path:`scripts/speech-bpe.mjs`,sha256:`a1c85731aa3e0be89f04acc79830db784a9d43edb8af9f4fb723bb45bd725786`,method:`sentencePieceModelToVocab decodes ordered protobuf ModelProto.pieces and emits each piece, a tab, its finite score, and a newline without changing the BPE model.`}}]},{id:`vits-melo-tts-zh_en`,revision:`a0d5c6a264c0ef92d70d8661d8cc502d79627cd6`,archive:{url:`https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/vits-melo-tts-zh_en.tar.bz2`,bytes:167006755,sha256:`e58351ed7149f290a54534538badd4077cdbe6fddc964b24d0bee870415d1514`},attribution:`MeloTTS by MyShell.ai; sherpa-onnx ONNX conversion. The retained software license is Copyright (c) 2024 MyShell.ai, MIT. The neural-weight repository separately declares MIT; dictionary and FST resources have separate declarations and pending provenance. Pisper selects the original single female voice via public sid 0 and uses the same original FP32 ONNX, tokens, mixed-language lexicon, dictionary and normalization files on Desktop, Android and iOS. No retraining, quantization, graph/metadata patch or voice-subset derivative is made. The unused new_heteronym.fst and 133-byte model.int8.onnx Git LFS pointer in the transport archive are drained but not installed; retained model files are unchanged. These choices do not imply upstream/speaker endorsement, redistribution approval or completed native-platform acceptance.`,groups:[{id:`melo-weights`,pathScope:`model`,paths:[`model.onnx`],licenseIds:[`mit-melo`],status:`pending`,summary:`The myshell-ai/MeloTTS-Chinese model card at af5d207a364ea4208c6f589c89f57f88414bdd16 declares license: mit for the model repository; this is separate evidence from the MeloTTS software MIT license. The sherpa conversion package carries the exact MyShell.ai MIT text, and original ONNX metadata declares MIT license, melo-vits version 2, Chinese + English, n_speakers=1 and speaker_id=1. The conversion README explicitly describes a single female Chinese+English speaker. sherpa maps public sid 0 to the internal metadata speaker_id; Pisper does not change the graph, metadata or speaker embedding.`,pendingReasons:[`Exact historical checkpoint, training/conversion commits and reproducible archive build identity have not been established; the inspected conversion workflow uses moving upstream references. Training-data permissions, individual speaker consent and applicable personality/publicity rights are not fully audited. The discovered model card revision is evidence of a declaration, not proof of the historical conversion input.`],evidence:[{url:`https://hf-mirror.com/myshell-ai/MeloTTS-Chinese/resolve/af5d207a364ea4208c6f589c89f57f88414bdd16/README.md`,sha256:`40b5b860bacbb3947cbef838719e660d2fe4961eba5b484290b4bedc0253e208`},{url:`https://raw.githubusercontent.com/myshell-ai/MeloTTS/209145371cff8fc3bd60d7be902ea69cbdb7965a/LICENSE`,sha256:`88a50e5a02bbc2a5c2f084dc19da751aa97b1690f5fda76cd8005c8634d1ca70`},{url:`https://hf-mirror.com/csukuangfj/vits-melo-tts-zh_en/resolve/a0d5c6a264c0ef92d70d8661d8cc502d79627cd6/README.md`,sha256:`ae6e44dead53dfdbd5b4a77106226f3118eb910222b46cb5533a3860773fc6c7`},{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/scripts/melo-tts/export-onnx.py`,sha256:`c0be7727d59ad6ceaf39e909b4560b57e704091c69ac3fab6f2f2abfd931c916`},{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/scripts/melo-tts/run.sh`,sha256:`e2afb98d9028eded2983f780468337fc019a8306db926f89e3bdeed18af867bb`},{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/sherpa-onnx/csrc/offline-tts-vits-model.cc`,sha256:`060907349036d63b60d035843defe7078b83c8099e0d4de323446c7db0d653d0`}]},{id:`melo-tokens`,pathScope:`model`,paths:[`tokens.txt`],licenseIds:[`mit-melo`,`apache-2.0-sherpa`],status:`declared`,summary:`The sherpa Melo export writes enumerated model.hps symbols to tokens.txt. The original 655-byte token file is retained unchanged. Melo software is MIT; sherpa conversion code is Apache-2.0. These code declarations do not independently establish all underlying training-data rights.`,pendingReasons:[],evidence:[{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/scripts/melo-tts/export-onnx.py`,sha256:`c0be7727d59ad6ceaf39e909b4560b57e704091c69ac3fab6f2f2abfd931c916`},{url:`https://raw.githubusercontent.com/myshell-ai/MeloTTS/209145371cff8fc3bd60d7be902ea69cbdb7965a/LICENSE`,sha256:`88a50e5a02bbc2a5c2f084dc19da751aa97b1690f5fda76cd8005c8634d1ca70`},{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/LICENSE`,sha256:`cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30`}]},{id:`melo-cppjieba-dictionary`,pathScope:`model`,paths:[`dict/hmm_model.utf8`,`dict/idf.utf8`,`dict/jieba.dict.utf8`,`dict/pos_dict/char_state_tab.utf8`,`dict/pos_dict/prob_emit.utf8`,`dict/pos_dict/prob_start.utf8`,`dict/pos_dict/prob_trans.utf8`,`dict/README.md`,`dict/stop_words.utf8`],licenseIds:[`mit-cppjieba`],status:`confirmed`,summary:`Nine ordinary dictionary/README files are byte-identical to the separately HTTPS-downloaded CppJieba sherpa-onnx-2024-04-19 dict archive. The exact release source MIT license retains Copyright (c) 2013. This confirms the documented source-content match, not a whole-chain data-rights guarantee. The small Melo user.dict.utf8 is separately classified and is NOT the 829194-byte pypinyin-derived user dictionary from that source archive.`,pendingReasons:[],evidence:[{url:`https://ghfast.top/https://github.com/csukuangfj/cppjieba/releases/download/sherpa-onnx-2024-04-19/dict.tar.bz2`,sha256:`35c3877c9b9221a5b2d69bbf57d5dbf1ccbe5b7684c60eb42f93db6b2d494f26`},{url:`https://raw.githubusercontent.com/csukuangfj/cppjieba/f03dd931a00330c279c8590275850fd1f6749a18/LICENSE`,sha256:`ba898a14f729ba5e9965da34e3eecd5edd3795f2cc5d7c923b815ba79bb851b0`},{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/.github/workflows/export-melo-tts-to-onnx.yaml`,sha256:`fc90fc412fd6f3c8a7d593743372a077dd63b2c8ce0780ed9c3a7e05cc8b659e`}]},{id:`melo-user-dictionary`,pathScope:`model`,paths:[`dict/user.dict.utf8`],licenseIds:[`mit-cppjieba`,`mit-melo`],status:`pending`,summary:`Melo ships an unchanged 49-byte user dictionary containing four entries. It matches the locked Melo HF file but differs from the separately downloaded CppJieba release user dictionary. The package MIT text and CppJieba project MIT declaration are retained as source declarations, not proof that either automatically licenses every edit. This file is not attributed to the unrelated historical pypinyin-derived dictionary.`,pendingReasons:[`The exact historical source commit, modifier and license coverage for this 49-byte replacement have not been identified. Retain applicable modifier notices when established.`],evidence:[{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/.github/workflows/export-melo-tts-to-onnx.yaml`,sha256:`fc90fc412fd6f3c8a7d593743372a077dd63b2c8ce0780ed9c3a7e05cc8b659e`},{url:`https://raw.githubusercontent.com/csukuangfj/cppjieba/f03dd931a00330c279c8590275850fd1f6749a18/LICENSE`,sha256:`ba898a14f729ba5e9965da34e3eecd5edd3795f2cc5d7c923b815ba79bb851b0`},{url:`https://raw.githubusercontent.com/myshell-ai/MeloTTS/209145371cff8fc3bd60d7be902ea69cbdb7965a/LICENSE`,sha256:`88a50e5a02bbc2a5c2f084dc19da751aa97b1690f5fda76cd8005c8634d1ca70`},{url:`https://huggingface.co/csukuangfj/vits-melo-tts-zh_en/resolve/a0d5c6a264c0ef92d70d8661d8cc502d79627cd6/dict/user.dict.utf8`,sha256:`495bbf49270408a1234690e1e6a97328f30a482a7a72aa769e8a12e8714b0c62`}]},{id:`melo-english-lexicon`,pathScope:`model`,paths:[`lexicon.txt`],licenseIds:[`cmudict-0.6-1998`,`mit-melo`,`apache-2.0-sherpa`],status:`pending`,summary:`The English portion is generated by the sherpa Melo export from melo.text.english.eng_dict and refine_syllables, lowercasing words and adding language tone offsets plus kaldi/SF entries. The inspected Melo source reads cmudict.rep or a cached pickle. cmudict.rep contains its own Copyright 1998 Carnegie Mellon University unrestricted research/commercial permission and attribution notice, retained verbatim in cmudict-0.6-1998. This is NOT a substitution of a modern CMUdict BSD license. The retained notice hash covers the complete original comment header; the evidence hash covers the complete 3969309-byte source file. No package script or pickle was executed.`,pendingReasons:[`The precise historical dictionary/cache inputs and all intervening modifications used for this lexicon have not been pinned or reproduced. Trace cached-data equivalence and retain applicable original and modifier notices.`],evidence:[{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/scripts/melo-tts/export-onnx.py`,sha256:`c0be7727d59ad6ceaf39e909b4560b57e704091c69ac3fab6f2f2abfd931c916`},{url:`https://raw.githubusercontent.com/myshell-ai/MeloTTS/209145371cff8fc3bd60d7be902ea69cbdb7965a/melo/text/english.py`,sha256:`28527f574511bfc13fe1f2f6bbb5bfe4072c06e1c7e9b69598138aef81b9905b`},{url:`https://raw.githubusercontent.com/myshell-ai/MeloTTS/209145371cff8fc3bd60d7be902ea69cbdb7965a/melo/text/cmudict.rep`,sha256:`d127b5ce8b8e695732701e8efde04b9b0fa11991218b1fb9d21bd0c9264636aa`},{url:`https://raw.githubusercontent.com/myshell-ai/MeloTTS/209145371cff8fc3bd60d7be902ea69cbdb7965a/LICENSE`,sha256:`88a50e5a02bbc2a5c2f084dc19da751aa97b1690f5fda76cd8005c8634d1ca70`},{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/LICENSE`,sha256:`cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30`}]},{id:`melo-chinese-lexicon`,pathScope:`model`,paths:[`lexicon.txt`],licenseIds:[`mit-pypinyin`,`mit-melo`,`apache-2.0-sherpa`],status:`pending`,summary:`The Chinese portion is generated by the sherpa Melo export from pypinyin character/phrase dictionaries, lazy_pinyin and the Melo pinyin-to-symbol map. Melo code is MIT, sherpa conversion code Apache-2.0, and pypinyin declares MIT. Those software declarations do not relicense external dictionary inputs. The same 6837671-byte mixed-language lexicon is used unchanged on every platform.`,pendingReasons:[`Pin historical pypinyin versions, character/phrase JSON data and Melo phoneme mapping, reproduce the output and trace the actual underlying source-data terms. No particular Zdic, CC-CEDICT or Unihan license is asserted without proof of the actual input chain.`],evidence:[{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/scripts/melo-tts/export-onnx.py`,sha256:`c0be7727d59ad6ceaf39e909b4560b57e704091c69ac3fab6f2f2abfd931c916`},{url:`https://raw.githubusercontent.com/mozillazg/python-pinyin/8595294b1a97845e30f11ecfdb3caa4e61ac3988/pypinyin/pinyin_dict.py`,sha256:`245c1f70509432b289cde1f938157cd5ff1372d1d083b577d5fab72b4dfcda08`},{url:`https://raw.githubusercontent.com/mozillazg/python-pinyin/8595294b1a97845e30f11ecfdb3caa4e61ac3988/pypinyin/phrases_dict.py`,sha256:`3f6f39bbca68d8d1676ea463cd4620b934b03160cc5042fb9d9007b8f3a80b9e`},{url:`https://raw.githubusercontent.com/mozillazg/python-pinyin/8595294b1a97845e30f11ecfdb3caa4e61ac3988/LICENSE.txt`,sha256:`1e6c90014b4912815c296ee64bb6f6280af47e6d4c5d80e86232dfc5defe764c`},{url:`https://raw.githubusercontent.com/myshell-ai/MeloTTS/209145371cff8fc3bd60d7be902ea69cbdb7965a/LICENSE`,sha256:`88a50e5a02bbc2a5c2f084dc19da751aa97b1690f5fda76cd8005c8634d1ca70`}]},{id:`melo-normalization-fsts`,pathScope:`model`,paths:[`date.fst`,`number.fst`,`phone.fst`],licenseIds:[`apache-2.0-sherpa`],status:`pending`,summary:`All three FSTs are byte-identical to the separately downloaded data/date.fst, data/number.fst and data/phone.fst at csukuangfj/icefall-tts-aishell3-vits-low-2024-04-06 revision 57345c004e13ed640e408c4c29ab56187b18f065, the source repository named by the Melo packaging workflow. That source model card declares Apache-2.0; the full Apache text is retained from sherpa. Neither the OpenFst software license nor the Melo neural-weight MIT declaration independently grants rights to these FST data.`,pendingReasons:[`Exact editable generation rules, compiler/source revisions, underlying data provenance and applicable author/modifier notices remain unverified. No standalone FST LICENSE/NOTICE or complete reproducible source chain was found in the inspected source tree.`],evidence:[{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/.github/workflows/export-melo-tts-to-onnx.yaml`,sha256:`fc90fc412fd6f3c8a7d593743372a077dd63b2c8ce0780ed9c3a7e05cc8b659e`},{url:`https://hf-mirror.com/csukuangfj/icefall-tts-aishell3-vits-low-2024-04-06/resolve/57345c004e13ed640e408c4c29ab56187b18f065/README.md`,sha256:`98b45ea81164d1e1a1dd82255207053b15cd6c69d922a1c5cf3387ce604d4b74`},{url:`https://hf-mirror.com/csukuangfj/icefall-tts-aishell3-vits-low-2024-04-06/resolve/57345c004e13ed640e408c4c29ab56187b18f065/data/date.fst`,sha256:`eb8aa079ae3cb81d8f4404992f39d61a0cb990947512b5b8d1e54d1f6980e718`},{url:`https://hf-mirror.com/csukuangfj/icefall-tts-aishell3-vits-low-2024-04-06/resolve/57345c004e13ed640e408c4c29ab56187b18f065/data/number.fst`,sha256:`743f402181fcfebf76cc2f0546b71fa26476e626fbe4e460fb7b4c3a7a8bd5bd`},{url:`https://hf-mirror.com/csukuangfj/icefall-tts-aishell3-vits-low-2024-04-06/resolve/57345c004e13ed640e408c4c29ab56187b18f065/data/phone.fst`,sha256:`1ac2b6fa56b1442320c4de7db08353bab8963a2b57f365eebcdd3a2d3562f8d7`},{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/LICENSE`,sha256:`cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30`}]},{id:`melo-package-notices`,pathScope:`model`,paths:[`LICENSE`,`README.md`],licenseIds:[`mit-melo`],status:`confirmed`,summary:`LICENSE is byte-identical to the original MyShell.ai MIT text (Copyright (c) 2024 MyShell.ai), including its exact final newline behavior. README explicitly identifies the single female Chinese+English speaker. The package-level MIT file is not a blanket grant for every bundled dictionary or FST. No upstream NOTICE was listed in the inspected conversion and weight repository trees; this is not proof that none ever existed.`,pendingReasons:[],evidence:[{url:`https://raw.githubusercontent.com/myshell-ai/MeloTTS/209145371cff8fc3bd60d7be902ea69cbdb7965a/LICENSE`,sha256:`88a50e5a02bbc2a5c2f084dc19da751aa97b1690f5fda76cd8005c8634d1ca70`},{url:`https://hf-mirror.com/csukuangfj/vits-melo-tts-zh_en/resolve/a0d5c6a264c0ef92d70d8661d8cc502d79627cd6/README.md`,sha256:`ae6e44dead53dfdbd5b4a77106226f3118eb910222b46cb5533a3860773fc6c7`}]}],modifications:[]}]},Fa=Pa,Ia=e=>Pa.models.some(t=>t.id===e);function La({modelId:e,modelName:t,returnFocus:n,onClose:r}){let{t:i}=o(),a=Fa.models.find(t=>t.id===e);if(!a)return null;let s=new Set(a.groups.flatMap(e=>e.licenseIds)),c=Fa.licenses.filter(e=>s.has(e.id));return(0,$.jsx)(Pn,{open:!0,onOpenChange:e=>{e||r()},children:(0,$.jsxs)(jn,{className:`z-[130] max-h-[85dvh] min-w-0 grid-cols-1 overflow-y-auto rounded-lg sm:max-w-2xl`,overlayClassName:`z-[129]`,onEscapeKeyDown:e=>e.stopPropagation(),onCloseAutoFocus:e=>{e.preventDefault(),n.current?.isConnected&&n.current.focus()},children:[(0,$.jsxs)(Nn,{children:[(0,$.jsx)(Mn,{children:i(`chat:speechModels.notices`)}),(0,$.jsxs)(An,{className:`break-words`,children:[t,` (`,a.revision,`)`]})]}),(0,$.jsx)(`p`,{className:`break-words text-sm text-muted-foreground`,children:Fa.scope}),(0,$.jsx)(`p`,{className:`break-words text-sm text-muted-foreground`,children:Fa.licenseIdsMeaning}),(0,$.jsx)(`div`,{className:`min-w-0 divide-y divide-stroke-soft`,children:a.groups.map(e=>(0,$.jsxs)(`details`,{className:`min-w-0 py-3`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer break-words text-sm font-medium`,children:[e.id,e.status===`pending`&&(0,$.jsx)(`span`,{className:`ml-2 text-xs font-normal text-warning-strong`,children:i(`chat:speechModels.provenancePending`)})]}),(0,$.jsxs)(`div`,{className:`mt-3 min-w-0 space-y-3 text-sm`,children:[(0,$.jsx)(`p`,{className:`break-words`,children:e.summary}),e.pendingReasons.map(e=>(0,$.jsx)(`p`,{className:`break-words text-muted-foreground`,children:e},e)),(0,$.jsx)(`pre`,{className:`whitespace-pre-wrap break-all text-xs`,children:JSON.stringify({pathScope:e.pathScope,paths:e.paths,licenseIds:e.licenseIds,evidence:e.evidence},null,2)})]})]},e.id))}),(0,$.jsxs)(`details`,{className:`min-w-0 border-t pt-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:i(`chat:speechModels.modifications`)}),(0,$.jsx)(`pre`,{className:`mt-3 whitespace-pre-wrap break-all text-xs`,children:JSON.stringify(a.modifications,null,2)})]}),c.map(e=>(0,$.jsxs)(`details`,{className:`min-w-0 border-t pt-3`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer break-words text-sm font-medium`,children:[e.name,` (`,e.id,`)`]}),(0,$.jsx)(`pre`,{className:`mt-3 whitespace-pre-wrap break-words text-xs`,children:e.text})]},e.id)),(0,$.jsx)(`div`,{className:`flex justify-end border-t pt-3`,children:(0,$.jsxs)(It,{children:[(0,$.jsx)(Pt,{asChild:!0,children:(0,$.jsx)(Y,{size:`icon-sm`,variant:`outline`,onClick:()=>{let e=new Blob([JSON.stringify({...Fa,models:[a],licenses:c},null,2)],{type:`application/json;charset=utf-8`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`${a.id}-notices.json`,n.click(),window.setTimeout(()=>URL.revokeObjectURL(t),0)},"aria-label":i(`chat:speechModels.downloadNotices`),children:(0,$.jsx)(W,{})})}),(0,$.jsx)(Ft,{children:i(`chat:speechModels.downloadNotices`)})]})})]})})}var Ra=e=>`${new Intl.NumberFormat(void 0,{maximumFractionDigits:1}).format(e/1048576)} MiB`;function za({manager:e,onClose:t}){let{t:n}=o(),[r,i]=(0,Q.useState)(!1),[a,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(null),u=(0,Q.useRef)(null),d=(0,Q.useRef)(null),f=()=>{u.current?.abort(),u.current=null,i(!1)};(0,Q.useEffect)(()=>(e.open||(u.current?.abort(),u.current=null,i(!1),l(null)),()=>{u.current?.abort(),u.current=null}),[e.open]);let p={"not-installed":n(`chat:speechModels.notInstalled`),downloading:n(`chat:speechModels.downloading`),verifying:n(`chat:speechModels.verifying`),installed:n(`chat:speechModels.installed`),cancelled:n(`chat:speechModels.cancelled`),error:n(`chat:speechModels.failed`)},m=e.models.flatMap(e=>e.voices||[]),h=m.find(t=>t.id===e.selectedVoice),g=e.models.some(e=>e.kind===`tts`&&e.status===`installed`),_=e.models.filter(e=>e.status!==`installed`),v=_.some(e=>[`downloading`,`verifying`].includes(e.status)),y=()=>{l(null),f(),e.close(),t()},b=async()=>{if(u.current){f();return}if(!h||!g||_.length)return;let e=new AbortController;u.current=e,i(!0),s(``);try{await Ma(h.language===`en`?n(`chat:speechModels.previewEnglish`):n(`chat:speechModels.previewChinese`),h.id,e.signal)}catch(t){e.signal.aborted||s(t instanceof Error?t.message:String(t))}finally{u.current===e&&(u.current=null,i(!1))}};return(0,$.jsxs)(Pn,{open:e.open,onOpenChange:e=>{e||y()},children:[(0,$.jsxs)(jn,{className:`z-[110] max-h-[85dvh] overflow-y-auto sm:max-w-md`,overlayClassName:`z-[109]`,onEscapeKeyDown:e=>e.stopPropagation(),children:[(0,$.jsxs)(Nn,{children:[(0,$.jsx)(Mn,{children:n(`chat:speechModels.title`)}),(0,$.jsx)(An,{className:`sr-only`,children:n(`chat:speechModels.title`)})]}),!e.catalog&&!e.error&&(0,$.jsx)(et,{className:`mx-auto my-4 size-5 animate-spin`,"aria-label":n(`chat:speechModels.loading`)}),(0,$.jsx)(`div`,{className:`min-w-0 divide-y divide-stroke-soft`,children:e.models.map(t=>{let r=[`downloading`,`verifying`].includes(t.status),i=t.totalBytes?Math.min(100,Math.floor(t.downloadedBytes/t.totalBytes*100)):0,a=t.license?.url.startsWith(`https://`)?t.license.url:void 0;return(0,$.jsxs)(`section`,{className:`min-w-0 space-y-2 py-3 first:pt-0`,"aria-label":t.name,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t.kind===`asr`?n(`chat:speechModels.recognition`):n(`chat:speechModels.synthesis`)}),(0,$.jsx)(`div`,{className:`break-words font-medium`,children:t.name})]}),t.status===`installed`?(0,$.jsx)(z,{className:`size-5 shrink-0 text-success`,"aria-label":p.installed}):(0,$.jsxs)(It,{children:[(0,$.jsx)(Pt,{asChild:!0,children:(0,$.jsx)(Y,{size:`icon-sm`,variant:`outline`,disabled:e.loading,onClick:()=>{r?e.cancelDownload(t.id):e.download(t.id)},"aria-label":n(r?`chat:speechModels.cancelDownload`:`chat:speechModels.download`),children:r?(0,$.jsx)(dt,{}):(0,$.jsx)(W,{})})}),(0,$.jsx)(Ft,{children:n(r?`chat:speechModels.cancelDownload`:`chat:speechModels.download`)})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-1 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:p[t.status]}),(0,$.jsx)(`span`,{className:`tabular-nums`,children:r?`${Ra(t.downloadedBytes)} / ${Ra(t.totalBytes)}`:Ra(t.totalBytes)})]}),r&&(0,$.jsx)(Dt,{value:i,"aria-label":t.name,"aria-valuenow":i,"aria-valuemin":0,"aria-valuemax":100}),t.error&&(0,$.jsx)(`p`,{role:`alert`,className:`break-words text-xs text-destructive`,children:t.error}),t.license&&(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[(0,$.jsx)(`a`,{href:a,target:`_blank`,rel:`noreferrer`,className:`block break-words text-xs text-muted-foreground underline underline-offset-2`,children:t.license.name}),Ia(t.id)&&(0,$.jsxs)(It,{children:[(0,$.jsx)(Pt,{asChild:!0,children:(0,$.jsx)(Y,{size:`icon-sm`,variant:`ghost`,"aria-label":n(`chat:speechModels.notices`),onClick:e=>{d.current=e.currentTarget,f(),l(t)},children:(0,$.jsx)(M,{})})}),(0,$.jsx)(Ft,{children:n(`chat:speechModels.notices`)})]})]})]},t.id)})}),m.length>0&&(0,$.jsx)(`div`,{className:`space-y-2 border-t pt-3`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-sm`,children:n(`chat:speechModels.voice`)}),(0,$.jsxs)(It,{children:[(0,$.jsx)(Pt,{asChild:!0,children:(0,$.jsx)(Y,{size:`icon`,variant:`outline`,disabled:!g||_.length>0,onClick:()=>void b(),"aria-label":n(r?`chat:speechModels.stopPreview`:`chat:speechModels.preview`),children:r?(0,$.jsx)(dt,{}):(0,$.jsx)(at,{})})}),(0,$.jsx)(Ft,{children:n(r?`chat:speechModels.stopPreview`:`chat:speechModels.preview`)})]})]})}),(e.error||a)&&(0,$.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-destructive`,children:e.error||a}),(0,$.jsx)(`div`,{className:`flex justify-end border-t pt-3`,children:_.length?(0,$.jsxs)(Y,{disabled:e.loading||v,onClick:()=>void e.downloadAll(),children:[(0,$.jsx)(W,{}),n(`chat:speechModels.downloadAll`)]}):(0,$.jsx)(Y,{disabled:!e.catalog,onClick:y,children:n(`chat:speechModels.done`)})})]}),e.open&&c&&(0,$.jsx)(La,{modelId:c.id,modelName:c.name,returnFocus:d,onClose:()=>l(null)})]})}var Ba=16e3,Va=Ba*60;function Ha(e,t){let n=window.__TAURI__?.core?.invoke??window.__TAURI_INTERNALS__?.invoke;return n?n(e,t):Promise.reject(Error(`移动端原生桥不可用。`))}async function Ua(){if(!(typeof window>`u`||!window.__PISPER_MOBILE_APP__)&&(await Ha(`mobile_request_microphone_permission`)).state!==`granted`)throw Error(`microphone_permission_denied`)}async function Wa(e){let t=await e.text().catch(()=>``);try{return JSON.parse(t).error||`语音转写失败 (${e.status})`}catch{return t||`语音转写失败 (${e.status})`}}function Ga(e){let t=e.reduce((e,t)=>e+t.length,0),n=new Float32Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}var Ka=class{chatSessionId;chunks=[];pending=[];listeners=new Set;controller=null;sessionId=``;nativeRequestId=``;legacy=!1;flushTimer=0;sendChain=Promise.resolve();finished=!1;retainedSamples=0;terms=[];initializing=null;constructor(e=``){this.chatSessionId=e}start(){return this.initializing=this.initialize().catch(async e=>{throw await this.cancel(),e}),this.initializing}async initialize(){this.chunks=[],this.pending=[],this.finished=!1,this.retainedSamples=0;let e=new AbortController;this.controller=e,await b(),g(e.signal);let{loadSpeechHotwords:n,prepareSpeechSession:r}=await t(async()=>{let{loadSpeechHotwords:e,prepareSpeechSession:t}=await import(`./speech-session-Dx6waD1F.js`).then(e=>e.r);return{loadSpeechHotwords:e,prepareSpeechSession:t}},__vite__mapDeps([139,1,2,3,13,15,14,5,6,7,8,12,16])),{terms:i,hotwords:a}=await n(this.chatSessionId,e.signal);this.terms=i;let o=await r({kinds:[`asr`],hotwords:a},e.signal);if(g(o.signal),o.signal.addEventListener(`abort`,()=>{this.controller===e&&!e.signal.aborted&&this.cancel()},{once:!0}),window.__PISPER_MOBILE_APP__)return;let s=h(e.signal,3e4);try{let t=await fetch(`/api/speech/stream/start`,{method:`POST`,headers:{"X-Pisper-Chat-Session":this.chatSessionId},signal:s.signal});if(!t.ok){if(t.status===404){this.legacy=!0;return}throw Error(await Wa(t))}let n=await t.json();if(!n.id)throw Error(`语音识别会话创建失败。`);e.signal.aborted&&(await fetch(`/api/speech/stream/cancel`,{method:`POST`,headers:{"X-Pisper-Speech-Session":n.id}}).catch(()=>{}),g(e.signal)),this.sessionId=n.id,this.pending.push(...this.chunks.splice(0)),this.retainedSamples=0,this.flushTimer=window.setInterval(()=>void this.flushPending(),1e3)}finally{s.dispose()}}acceptPcm(e){if(!e.length||this.finished)return!1;if(window.__PISPER_MOBILE_APP__||!this.sessionId){let t=Va-this.retainedSamples;if(t<=0)return!0;let n=e.slice(0,t);return this.chunks.push(n),this.retainedSamples+=n.length,this.retainedSamples>=Va}let t=e.slice();return this.sessionId&&!this.legacy?this.pending.push(t):this.chunks.push(t),!1}onPartial(e){return this.listeners.add(e),()=>this.listeners.delete(e)}emitPartial(e){if(e)for(let t of this.listeners)t(e)}flushPending(){return this.sendChain=this.sendChain.then(async()=>{if(!this.sessionId||this.legacy||this.finished||!this.pending.length)return;let e=Ga(this.pending.splice(0));try{let t=await fetch(`/api/speech/stream/chunk`,{method:`POST`,headers:{"Content-Type":`application/octet-stream`,"X-Pisper-Sample-Rate":String(Ba),"X-Pisper-Speech-Session":this.sessionId},body:e.buffer,signal:this.controller?.signal});if(!t.ok)return;let n=await t.json();typeof n.text==`string`&&this.emitPartial(n.text.trim())}catch{}}),this.sendChain}async finishStreaming(){window.clearInterval(this.flushTimer),this.flushTimer=0,await this.flushPending(),this.finished=!0;let e=await fetch(`/api/speech/stream/finish`,{method:`POST`,headers:{"X-Pisper-Speech-Session":this.sessionId},signal:this.controller?.signal});if(!e.ok)throw Error(await Wa(e));let t=await e.json(),n=typeof t.text==`string`?t.text.trim():``;if(!n)throw Error(`未识别到语音内容。`);return this.emitPartial(n),n}async finishOneShot(e){if(window.__PISPER_MOBILE_APP__){let t=new Uint8Array(e.buffer),n=``,r=32768;for(let e=0;e<t.length;e+=r)n+=String.fromCharCode(...t.subarray(e,e+r));let i=this.controller;if(!i)throw new DOMException(`Speech recognition cancelled.`,`AbortError`);g(i.signal);let a=crypto.randomUUID();this.nativeRequestId=a;let o=await Ha(`mobile_transcribe_pcm`,{pcmBase64:btoa(n),hotwords:Tr(this.terms),requestId:a});if(g(i.signal),this.controller!==i)throw new DOMException(`Speech recognition cancelled.`,`AbortError`);let s=Dr(typeof o.text==`string`?o.text.trim():``,this.terms);if(!s)throw Error(`未识别到语音内容。`);return this.emitPartial(s),s}let t=await fetch(`/api/speech/transcribe`,{method:`POST`,headers:{"Content-Type":`application/octet-stream`,"X-Pisper-Sample-Rate":String(Ba),"X-Pisper-Chat-Session":this.chatSessionId},body:e.buffer,signal:this.controller?.signal});if(!t.ok)throw Error(await Wa(t));let n=await t.json(),r=typeof n.text==`string`?n.text.trim():``;if(!r)throw Error(`未识别到语音内容。`);return this.emitPartial(r),r}async finish(){if(await this.initializing,!this.controller)throw Error(`语音识别尚未启动。`);if(this.sessionId&&!this.legacy)return this.finishStreaming();this.finished=!0;let e=Ga(this.chunks);if(!e.length)throw Error(`没有采集到语音。`);return this.finishOneShot(e)}async cancel(){if(this.finished=!0,window.clearInterval(this.flushTimer),this.flushTimer=0,this.controller?.abort(),this.controller=null,this.chunks=[],this.pending=[],this.retainedSamples=0,this.nativeRequestId){let e=this.nativeRequestId;this.nativeRequestId=``,await Ha(`mobile_cancel_speech`,{requestId:e}).catch(()=>{})}if(this.sessionId&&!this.legacy){let e=this.sessionId;this.sessionId=``,await fetch(`/api/speech/stream/cancel`,{method:`POST`,headers:{"X-Pisper-Speech-Session":e}}).catch(()=>{})}}async dispose(){await this.cancel(),this.listeners.clear()}};function qa({chatSessionId:e=``}={}){return new Ka(e)}var Ja=`
|
|
512
512
|
class PisperVoiceInputProcessor extends AudioWorkletProcessor {
|
|
513
513
|
constructor(options) {
|
|
514
514
|
super()
|