@geminilight/mindos 0.7.2 → 0.7.4
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/_standalone/.mindos-build-version +1 -1
- package/_standalone/.next/BUILD_ID +1 -1
- package/_standalone/.next/app-path-routes-manifest.json +19 -19
- package/_standalone/.next/build-manifest.json +3 -3
- package/_standalone/.next/cache/.previewinfo +1 -1
- package/_standalone/.next/cache/.rscinfo +1 -1
- package/_standalone/.next/cache/config.json +3 -3
- package/_standalone/.next/prerender-manifest.json +3 -3
- package/_standalone/.next/react-loadable-manifest.json +4 -4
- package/_standalone/.next/server/app/.well-known/agent-card.json/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/_global-error.html +2 -2
- package/_standalone/.next/server/app/_global-error.rsc +1 -1
- package/_standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/_standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/_standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/_standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/_standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/_standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/_standalone/.next/server/app/_not-found/page.js +1 -1
- package/_standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/agents/[agentKey]/page.js +1 -1
- package/_standalone/.next/server/app/agents/[agentKey]/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/agents/[agentKey]/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/agents/page.js +1 -1
- package/_standalone/.next/server/app/agents/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/agents/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/a2a/agents/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/a2a/delegations/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/a2a/discover/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/a2a/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/acp/config/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/acp/detect/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/acp/install/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/acp/registry/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/acp/session/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/agent-activity/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/agents/copy-skill/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/agents/custom/detect/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/agents/custom/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/ask/route.js +4 -4
- package/_standalone/.next/server/app/api/ask/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/ask-sessions/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/auth/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/backlinks/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/bootstrap/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/changes/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/channels/verify/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/connect/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/embedding/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/export/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/extract-docx/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/extract-pdf/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/file/import/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/file/raw/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/file/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/files/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/git/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/graph/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/health/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/im/activity/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/im/config/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/im/feishu/long-connection/event/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/im/feishu/long-connection/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/im/status/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/im/test/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/im/webhook/feishu/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/im/webhook-status/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/inbox/clip/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/inbox/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/init/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/lint/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/mcp/agents/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/mcp/direct-tools/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/mcp/install/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/mcp/install-skill/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/mcp/restart/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/mcp/status/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/mcp/tools/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/mcp/uninstall/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/monitoring/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/obsidian/compat-report/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/obsidian/import/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/recent-files/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/restart/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/search/prewarm/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/search/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/settings/list-models/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/settings/reset-token/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/settings/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/settings/test-key/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/setup/check-path/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/setup/check-port/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/setup/generate-token/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/setup/ls/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/setup/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/skills/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/space-overview/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/sync/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/tree-version/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/uninstall/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/update/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/update-check/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/update-status/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/workflows/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/capture/history/page.js +1 -1
- package/_standalone/.next/server/app/capture/history/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/capture/history/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/capture/page.js +1 -1
- package/_standalone/.next/server/app/capture/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/capture/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/changelog/page.js +1 -1
- package/_standalone/.next/server/app/changelog/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/changelog/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/changes/page.js +1 -1
- package/_standalone/.next/server/app/changes/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/changes/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/echo/[segment]/page.js +1 -1
- package/_standalone/.next/server/app/echo/[segment]/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/echo/[segment]/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/echo/page.js +1 -1
- package/_standalone/.next/server/app/echo/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/echo/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/explore/page.js +1 -1
- package/_standalone/.next/server/app/explore/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/explore/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/help/page.js +1 -1
- package/_standalone/.next/server/app/help/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/help/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/inbox/history/page.js +1 -1
- package/_standalone/.next/server/app/inbox/history/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/inbox/history/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/login/page.js +1 -1
- package/_standalone/.next/server/app/login/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/page.js +1 -1
- package/_standalone/.next/server/app/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/setup/page.js +1 -1
- package/_standalone/.next/server/app/setup/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/setup/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/todo/page.js +1 -1
- package/_standalone/.next/server/app/todo/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/todo/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/trash/page.js +2 -2
- package/_standalone/.next/server/app/trash/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/view/[...path]/page.js +2 -2
- package/_standalone/.next/server/app/view/[...path]/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/view/[...path]/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/wiki/page.js +2 -0
- package/_standalone/.next/server/app/wiki/page.js.nft.json +1 -0
- package/_standalone/.next/server/app/wiki/page_client-reference-manifest.js +1 -0
- package/_standalone/.next/server/app-paths-manifest.json +19 -19
- package/_standalone/.next/server/chunks/2250.js +1 -1
- package/_standalone/.next/server/chunks/{1057.js → 3861.js} +2 -2
- package/_standalone/.next/server/chunks/4802.js +30 -30
- package/_standalone/.next/server/chunks/8388.js +1 -1
- package/_standalone/.next/server/middleware-build-manifest.js +1 -1
- package/_standalone/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/_standalone/.next/server/pages/500.html +2 -2
- package/_standalone/.next/server/server-reference-manifest.js +1 -1
- package/_standalone/.next/server/server-reference-manifest.json +1 -1
- package/_standalone/.next/static/chunks/{5581-bae715e40d227b5f.js → 5581-beecbc4ca5625aa9.js} +2 -2
- package/_standalone/.next/static/chunks/6762.c871d0bf3f45ba87.js +1 -0
- package/_standalone/.next/static/chunks/{8064-e65acd2762132099.js → 8064-acac37daf946082b.js} +1 -1
- package/_standalone/.next/static/chunks/{3985.695651f6b5cd768c.js → 8984.91fb8cde1983c564.js} +2 -2
- package/_standalone/.next/static/chunks/app/{layout-0cf6f2a65f605a0d.js → layout-20faba3bc0af7cd2.js} +19 -19
- package/_standalone/.next/static/chunks/app/trash/page-0c2c67929b71ef71.js +1 -0
- package/_standalone/.next/static/chunks/app/view/[...path]/not-found-fd06cc989103ebe7.js +1 -0
- package/_standalone/.next/static/chunks/app/view/[...path]/page-dba70888697ba910.js +12 -0
- package/_standalone/.next/static/chunks/app/wiki/page-9bc1fec84d343290.js +14 -0
- package/_standalone/.next/static/chunks/webpack-3c1d0331f1da64b8.js +1 -0
- package/_standalone/.next/trace +97 -97
- package/_standalone/MINDOS_ARCHITECTURE_DIAGRAM.md +488 -0
- package/_standalone/MINDOS_EXPLORATION_SUMMARY.md +229 -0
- package/_standalone/MINDOS_INFRASTRUCTURE_ANALYSIS.md +732 -0
- package/_standalone/__tests__/api/mcp-install.test.ts +8 -2
- package/_standalone/__tests__/core/embedding-provider.test.ts +78 -0
- package/_standalone/__tests__/skills/mindos-skill-copy-alignment.test.ts +10 -4
- package/_standalone/components/ask/AskHeader.tsx +25 -18
- package/_standalone/components/ask/SessionHistoryPanel.tsx +21 -12
- package/_standalone/components/settings/AiTab.tsx +3 -0
- package/_standalone/data/skills/mindos/SKILL.md +269 -0
- package/_standalone/data/skills/mindos/references/write-supplement.md +119 -0
- package/_standalone/data/skills/mindos-zh/SKILL.md +227 -0
- package/_standalone/data/skills/mindos-zh/references/write-supplement.md +119 -0
- package/app/__tests__/api/mcp-install.test.ts +8 -2
- package/app/__tests__/core/embedding-provider.test.ts +78 -0
- package/app/__tests__/skills/mindos-skill-copy-alignment.test.ts +10 -4
- package/app/app/api/ask/route.ts +14 -9
- package/app/app/view/[...path]/ViewPageClient.tsx +15 -12
- package/app/app/view/[...path]/not-found.tsx +9 -5
- package/app/components/ask/AskHeader.tsx +25 -18
- package/app/components/ask/SessionHistoryPanel.tsx +21 -12
- package/app/components/settings/AiTab.tsx +3 -0
- package/app/eslint.config.mjs +18 -0
- package/app/lib/core/embedding-provider.ts +12 -4
- package/app/lib/i18n/modules/settings.ts +2 -0
- package/app/package-lock.json +20214 -0
- package/app/tsconfig.tsbuildinfo +1 -0
- package/app/vitest.config.ts +14 -0
- package/assets/demo-flow-zh.html +622 -0
- package/assets/images/demo-flow-dark.png +0 -0
- package/assets/images/demo-flow-dark.webp +0 -0
- package/assets/images/demo-flow-light.png +0 -0
- package/assets/images/demo-flow-light.webp +0 -0
- package/assets/images/demo-flow-zh-dark.png +0 -0
- package/assets/images/demo-flow-zh-dark.webp +0 -0
- package/assets/images/demo-flow-zh-light.png +0 -0
- package/assets/images/demo-flow-zh-light.webp +0 -0
- package/assets/images/gui-sync-cv.png +0 -0
- package/assets/images/gui-sync-cv.webp +0 -0
- package/assets/images/mindos-chat.png +0 -0
- package/assets/images/mindos-chat.webp +0 -0
- package/assets/images/mindos-dashboard.png +0 -0
- package/assets/images/mindos-dashboard.webp +0 -0
- package/assets/images/mindos-echo.png +0 -0
- package/assets/images/mindos-echo.webp +0 -0
- package/assets/images/mindos-home.png +0 -0
- package/assets/images/mindos-home.webp +0 -0
- package/assets/images/wechat-qr.png +0 -0
- package/bin/lib/mcp-build.js +8 -0
- package/mcp/package-lock.json +2202 -0
- package/mcp/src/index.ts +783 -0
- package/package.json +13 -1
- package/.env.local.example +0 -38
- package/.playwright-cli/page-2026-04-12T12-26-53-393Z.yml +0 -6
- package/.playwright-cli/page-2026-04-12T12-27-20-256Z.yml +0 -120
- package/.syncinclude +0 -105
- package/MINDOS_SEARCH_DIAGRAM.txt +0 -243
- package/_standalone/.next/static/chunks/576.3cae31209383ddbd.js +0 -1
- package/_standalone/.next/static/chunks/app/trash/page-085f121c0815d542.js +0 -1
- package/_standalone/.next/static/chunks/app/view/[...path]/not-found-2a6eec67e91eaaf9.js +0 -1
- package/_standalone/.next/static/chunks/app/view/[...path]/page-faeaf8c09c1c6d7c.js +0 -12
- package/_standalone/.next/static/chunks/webpack-a1bb35f2d540e463.js +0 -1
- package/scripts/build-runtime-archive.sh +0 -151
- package/scripts/fix-postcss-deps.cjs +0 -75
- package/scripts/gen-renderer-index.js +0 -64
- package/scripts/hooks/block-public-merge.sh +0 -42
- package/scripts/hooks/pre-merge-commit +0 -4
- package/scripts/hooks/pre-push +0 -37
- package/scripts/hooks/prepare-commit-msg +0 -12
- package/scripts/migrate-agent-audit-log.js +0 -170
- package/scripts/migrate-agent-diff.js +0 -146
- package/scripts/parse-syncinclude.sh +0 -92
- package/scripts/prepare-standalone.mjs +0 -83
- package/scripts/release.sh +0 -145
- package/scripts/setup.js +0 -1427
- package/scripts/test-oss-upload.sh +0 -100
- package/scripts/verify-standalone.mjs +0 -129
- package/scripts/write-build-stamp.js +0 -40
- /package/_standalone/.next/static/{q5RP_Mx8BrCfvVDnLpRRc → 0UlbV2rA2i4B-8YYg41wQ}/_buildManifest.js +0 -0
- /package/_standalone/.next/static/{q5RP_Mx8BrCfvVDnLpRRc → 0UlbV2rA2i4B-8YYg41wQ}/_ssgManifest.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6762],{76762:(e,s,t)=>{t.r(s),t.d(s,{default:()=>b});var a=t(95155),r=t(12115),n=t(47650),i=t(33210),l=t(86901),o=t(41585),c=t(38798),d=t(6296),u=t(73321),m=t(91337),x=t(9339);let p=(0,x.createServerReference)("70150d2020055d09d6f43c75c429e95867052623af",x.callServer,void 0,x.findSourceMapURL,"createSpaceAction");var f=t(5292),h=t(70620);function b({t:e,dirPaths:s}){let t=(0,u.useRouter)(),[x,b]=(0,r.useState)(!1),[g,v]=(0,r.useState)(""),[N,j]=(0,r.useState)(""),[w,y]=(0,r.useState)(""),[k,S]=(0,r.useState)(!1),[C,A]=(0,r.useState)(""),[E,I]=(0,r.useState)(""),[L,z]=(0,r.useState)(null),[R,D]=(0,r.useState)(!0),K=(0,r.useRef)(null);(0,r.useEffect)(()=>{let e=()=>{b(!0),A(""),I(""),setTimeout(()=>K.current?.focus(),80)};return window.addEventListener("mindos:create-space",e),()=>window.removeEventListener("mindos:create-space",e)},[]),(0,r.useEffect)(()=>{x&&null===L&&(0,f.w)().then(e=>{z(e),D(e)})},[x,L]);let M=(0,r.useCallback)(()=>{b(!1),v(""),j(""),y(""),A(""),I(""),z(null)},[]),P=(0,r.useCallback)(s=>s.includes("/")||s.includes("\\")?(I(e.home.spaceNameNoSlash??"Name cannot contain / or \\"),!1):(I(""),!0),[e]),T=(0,r.useMemo)(()=>{let e=g.trim();return e?(w?w+"/":"")+e+"/":""},[g,w]),$=(0,r.useCallback)(async()=>{if(!g.trim()||k||!P(g))return;S(!0),A("");let s=g.trim(),a=await p(s,N,w);if(a.success){let e=a.path??s;R&&L&&(0,f.V)(s,e,N),M(),t.refresh(),window.dispatchEvent(new Event("mindos:files-changed")),t.push(`/view/${(0,m.O0)(e+"/")}`)}else(a.error??"").includes("already exists")?A(e.home.spaceExists??"A space with this name already exists"):A(e.home.spaceCreateFailed??"Failed to create space");S(!1)},[g,N,w,k,M,t,e,P,R,L]),_=(0,r.useCallback)(e=>{"Escape"===e.key&&M(),"Enter"===e.key&&!e.shiftKey&&e.target instanceof HTMLInputElement&&(e.preventDefault(),$())},[M,$]);if(!x)return null;let F=e.home;return(0,n.createPortal)((0,a.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onKeyDown:_,children:[(0,a.jsx)("div",{className:"absolute inset-0 overlay-backdrop",onClick:M}),(0,a.jsxs)("div",{role:"dialog","aria-modal":"true","aria-label":F.newSpace,className:"relative w-full max-w-md mx-4 rounded-2xl border border-border bg-card shadow-xl",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between px-5 pt-5 pb-3",children:[(0,a.jsx)("h3",{className:"text-base font-semibold text-foreground",children:F.newSpace}),(0,a.jsx)("button",{onClick:M,className:"p-1 rounded-md text-muted-foreground hover:bg-muted transition-colors",children:(0,a.jsx)(i.A,{size:14})})]}),(0,a.jsxs)("div",{className:"px-5 pb-5 flex flex-col gap-3",children:[(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:F.spaceLocation??"Location"}),(0,a.jsx)(h.A,{dirPaths:s,value:w,onChange:y,rootLabel:F.rootLevel??"Root"})]}),(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:F.spaceName}),(0,a.jsx)("input",{ref:K,type:"text",value:g,onChange:e=>{v(e.target.value),A(""),P(e.target.value)},placeholder:"e.g. \uD83D\uDCDD Notes",maxLength:80,"aria-invalid":!!E,"aria-describedby":E?"space-name-hint":void 0,className:`w-full px-3 py-2 text-sm rounded-lg border bg-background outline-none transition-colors ${E?"border-error focus-visible:border-error":"border-border focus-visible:ring-1 focus-visible:ring-ring"}`}),E&&(0,a.jsx)("span",{id:"space-name-hint",className:"text-xs text-error",children:E})]}),(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsxs)("label",{className:"text-xs font-medium text-muted-foreground",children:[F.spaceDescription," ",(0,a.jsxs)("span",{className:"opacity-50",children:["(",F.optional??"optional",")"]})]}),(0,a.jsx)("input",{type:"text",value:N,onChange:e=>j(e.target.value),placeholder:F.spaceDescPlaceholder??"Describe the purpose of this space",maxLength:200,className:"w-full px-3 py-2 text-sm rounded-lg border border-border bg-background text-foreground placeholder:text-muted-foreground outline-none focus-visible:ring-1 focus-visible:ring-ring transition-colors"})]}),(0,a.jsxs)("div",{className:"flex items-start gap-2.5 px-1 py-1",children:[(0,a.jsx)("button",{type:"button",role:"switch","aria-checked":R,disabled:!L,title:L?void 0:e.hints.configureAiKey,onClick:()=>D(e=>!e),className:`relative mt-0.5 inline-flex shrink-0 h-4 w-7 cursor-pointer rounded-full border-2 border-transparent transition-colors focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 ${R?"bg-[var(--amber)]":"bg-muted"}`,children:(0,a.jsx)("span",{className:`pointer-events-none inline-block h-3 w-3 rounded-full bg-white shadow-sm transition-transform ${R?"translate-x-3":"translate-x-0"}`})}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)(l.A,{size:12,className:"text-[var(--amber)] shrink-0"}),(0,a.jsx)("span",{className:"text-xs font-medium text-foreground",children:F.aiInit??"AI initialize content"})]}),!1===L&&(0,a.jsxs)("p",{className:"text-2xs text-muted-foreground mt-0.5 flex items-center gap-1",children:[(0,a.jsx)(o.A,{size:10,className:"text-[var(--amber)] shrink-0"}),F.aiInitNoKey??"Configure an API key in Settings → AI to enable"]}),L&&R&&(0,a.jsx)("p",{className:"text-2xs text-muted-foreground mt-0.5",children:F.aiInitHint??"AI will generate README and INSTRUCTION for this space"})]})]}),T&&(0,a.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground font-mono px-1",children:[(0,a.jsx)(c.A,{size:12,className:"shrink-0 text-[var(--amber)]"}),(0,a.jsx)("span",{className:"truncate",children:T})]}),C&&(0,a.jsx)("span",{role:"alert",className:"text-xs text-error px-1",children:C}),(0,a.jsxs)("div",{className:"flex items-center justify-end gap-2 pt-1",children:[(0,a.jsx)("button",{onClick:M,className:"px-4 py-2 rounded-lg text-sm font-medium text-muted-foreground transition-colors hover:bg-muted",children:F.cancelCreate}),(0,a.jsxs)("button",{onClick:$,disabled:!g.trim()||k||!!E,className:"flex items-center gap-1.5 px-4 py-2 rounded-lg text-sm font-medium bg-[var(--amber)] text-[var(--amber-foreground)] transition-colors hover:opacity-90 disabled:opacity-50 disabled:cursor-not-allowed",children:[k&&(0,a.jsx)(d.A,{size:14,className:"animate-spin"}),F.createSpace]})]})]})]})]}),document.body)}}}]);
|
package/_standalone/.next/static/chunks/{8064-e65acd2762132099.js → 8064-acac37daf946082b.js}
RENAMED
|
@@ -16,7 +16,7 @@ ${t.join("\n\n---\n\n")}`}if("ai-only"===t){let t=e.filter(e=>"assistant"===e.ro
|
|
|
16
16
|
|
|
17
17
|
${t.join("\n\n---\n\n")}`}return eS(e,"full",r)}function eC(e,t){let r="ai-only"===t?e.filter(e=>"assistant"===e.role):e,n=r.reduce((e,t)=>e+(0,X.Oo)(t.content).trim().length,0);return{msgCount:r.length,charCount:n}}function eA({text:e}){let{t}=(0,m.Y)(),[r,a]=(0,s.useState)(!1),o=(0,s.useRef)(null),l=(0,X.Oo)(e).trim();return l?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{ref:o,type:"button",onClick:e=>{e.stopPropagation(),a(e=>!e)},className:`p-1 rounded-md border transition-colors ${r?"border-[var(--amber)]/40 bg-[var(--amber)]/10 text-[var(--amber)]":"border-border/60 bg-card text-muted-foreground hover:text-[var(--amber)] shadow-sm"}`,title:t.ask?.saveToKB??"Save to knowledge base",children:(0,n.jsx)(W.A,{size:11})}),r&&(0,n.jsx)(eE,{anchorRef:o,content:l,onClose:()=>a(!1)})]}):null}function eE({anchorRef:e,content:t,onClose:r}){let{t:a}=(0,m.Y)(),o=a.ask,[l,i]=(0,s.useState)("select"),[u,c]=(0,s.useState)([]);(0,s.useEffect)(()=>{(0,ew.n)("/api/file?op=dirs").then(e=>c(e.dirs??[])).catch(()=>{})},[]);let d=[{role:"assistant",content:t}];return(0,n.jsxs)(eT,{anchorRef:e,onClose:r,children:["select"===l&&(0,n.jsx)(eR,{content:t,onSelect:i,onClose:r,ask:o}),"archive"===l&&(0,n.jsx)(e$,{content:t,defaultFilenamePrefix:"insight",dirPaths:u,onClose:r,ask:o}),"digest"===l&&(0,n.jsx)(e_,{messages:d,onClose:r,ask:o})]})}function eR({content:e,onSelect:t,onClose:r,ask:s}){let a=e.length>1e3?`~${(e.length/1e3).toFixed(1)}k`:`${e.length}`;return(0,n.jsxs)("div",{className:"p-3",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-2.5",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,n.jsx)(W.A,{size:11,className:"text-[var(--amber)]"}),(0,n.jsx)("span",{className:"text-xs font-semibold text-foreground",children:s?.saveToKBTitle??"Save to KB"}),(0,n.jsxs)("span",{className:"text-2xs text-muted-foreground",children:["(",a," chars)"]})]}),(0,n.jsx)("button",{type:"button",onClick:r,className:"text-2xs text-muted-foreground hover:text-foreground",children:s?.cancelSave??"Cancel"})]}),(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>t("archive"),className:"flex flex-col items-center gap-1 p-2.5 border border-[var(--amber)]/30 rounded-lg hover:border-[var(--amber)]/60 hover:shadow-sm active:scale-[0.98] transition-all",children:[(0,n.jsx)(W.A,{size:16,className:"text-[var(--amber)]"}),(0,n.jsx)("span",{className:"text-2xs font-medium text-foreground",children:s?.saveDirectly??"Save directly"}),(0,n.jsx)("span",{className:"text-[10px] text-muted-foreground text-center leading-tight",children:s?.saveDirectlyDesc??"Save as-is"})]}),(0,n.jsxs)("button",{type:"button",onClick:()=>t("digest"),className:"flex flex-col items-center gap-1 p-2.5 border border-border rounded-lg hover:border-[var(--amber)]/50 hover:shadow-sm active:scale-[0.98] transition-all",children:[(0,n.jsx)(p.A,{size:16,className:"text-[var(--amber)]"}),(0,n.jsx)("span",{className:"text-2xs font-medium text-foreground",children:s?.organizeToNote??"Organize to note"}),(0,n.jsx)("span",{className:"text-[10px] text-muted-foreground text-center leading-tight",children:s?.organizeToNoteDesc??"AI organizes"})]})]})]})}function ez({messages:e,disabled:t}){let{t:r}=(0,m.Y)(),[a,o]=(0,s.useState)(!1),l=(0,s.useRef)(null);return e.some(e=>"assistant"===e.role&&e.content.trim())?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{ref:l,type:"button",onClick:e=>{e.stopPropagation(),o(e=>!e)},disabled:t,className:`h-9 w-9 inline-flex items-center justify-center rounded-lg transition-colors ${a?"bg-[var(--amber)]/10 text-[var(--amber)]":"text-muted-foreground hover:text-foreground hover:bg-muted"} disabled:opacity-40`,title:r.ask?.saveSession??"Save session",children:(0,n.jsx)(W.A,{size:14})}),a&&(0,n.jsx)(eL,{anchorRef:l,messages:e,onClose:()=>o(!1)})]}):null}function eT({anchorRef:e,onClose:t,children:r}){let o=(0,s.useRef)(null),[l,i]=(0,s.useState)(null),u=(0,s.useCallback)(()=>{if(!e.current)return;let t=e.current.getBoundingClientRect();i({top:t.bottom+6,right:Math.max(8,window.innerWidth-t.right)})},[e]);return((0,s.useEffect)(()=>(u(),window.addEventListener("resize",u),()=>window.removeEventListener("resize",u)),[u]),(0,s.useEffect)(()=>{let r=e=>{"Escape"===e.key&&(e.preventDefault(),t())},n=r=>{let n=r.target;e.current?.contains(n)||o.current?.contains(n)||t()};return document.addEventListener("keydown",r),document.addEventListener("mousedown",n),()=>{document.removeEventListener("keydown",r),document.removeEventListener("mousedown",n)}},[e,t]),!l||"u"<typeof document)?null:(0,a.createPortal)((0,n.jsx)("div",{ref:o,className:"fixed z-50 rounded-xl border border-border bg-card shadow-lg animate-in fade-in-0 slide-in-from-top-1 duration-100",style:{top:l.top,right:l.right,width:300},children:r}),document.body)}function e$({content:e,defaultFilenamePrefix:t,dirPaths:r,onClose:a,ask:o}){let l,i,u=new Date,c=`${t}-${u.getFullYear()}-${String(u.getMonth()+1).padStart(2,"0")}-${String(u.getDate()).padStart(2,"0")}.md`,[d,m]=(0,s.useState)(""),[f,p]=(0,s.useState)(c),[g,h]=(0,s.useState)(!1),[b,v]=(0,s.useState)(!1),[y,j]=(0,s.useState)(""),w=(0,s.useRef)(null);(0,s.useEffect)(()=>{setTimeout(()=>{w.current?.focus(),w.current?.select()},100)},[]);let k=(i=(l=f.trim()||c).endsWith(".md")?l:`${l}.md`,d?`${d}/${i}`:i),N=(0,s.useCallback)(async()=>{h(!0),j("");try{await (0,ew.n)("/api/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:k,op:"create_file",content:function(e,t=new Date){let r=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0");return`> Saved from MindOS Ask \xb7 ${r}-${n}-${s}
|
|
18
18
|
|
|
19
|
-
${e}`}(e),source:"user"})}),v(!0),ek.oR.success(o?.savedToKB?.replace("{path}",k.split("/").pop())??"Saved"),setTimeout(a,1e3)}catch(e){j(e?.message?.includes("exist")?o?.fileExistsSwitch??"File exists":e?.message??"Failed")}finally{h(!1)}},[e,k,o,a]);return(0,n.jsxs)("div",{className:"p-3 space-y-2",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,n.jsx)(W.A,{size:11,className:"text-[var(--amber)]"}),(0,n.jsx)("span",{className:"text-xs font-semibold",children:o?.saveToKBTitle??"Save to KB"})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"text-2xs text-muted-foreground mb-0.5 block",children:o?.targetFolder??"Folder"}),(0,n.jsx)(eN.A,{dirPaths:r,value:d,onChange:m,rootLabel:"Root"})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"text-2xs text-muted-foreground mb-0.5 block",children:o?.fileName??"Filename"}),(0,n.jsx)("input",{ref:w,type:"text",value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{"Enter"===e.key&&N(),"Escape"===e.key&&a()},className:"w-full px-2 py-1 text-xs font-mono rounded-md border border-border bg-background text-foreground outline-none focus-visible:border-[var(--amber)]/50"})]}),(0,n.jsx)("div",{className:"text-[10px] text-muted-foreground/60 font-mono truncate",children:k}),y&&(0,n.jsxs)("div",{className:"flex items-center gap-1 text-2xs text-error",children:[(0,n.jsx)(J.A,{size:10}),y]}),(0,n.jsxs)("div",{className:"flex justify-end gap-1.5 pt-1 border-t border-border/30",children:[(0,n.jsx)("button",{type:"button",onClick:a,className:"px-2 py-0.5 text-2xs rounded text-muted-foreground hover:bg-muted",children:o?.cancelSave??"Cancel"}),(0,n.jsxs)("button",{type:"button",onClick:N,disabled:g||b||!f.trim(),className:`flex items-center gap-1 px-2.5 py-0.5 text-2xs font-medium rounded transition-colors ${b?"bg-success/10 text-success":"bg-[var(--amber)] text-[var(--amber-foreground)]"} disabled:opacity-50`,children:[g&&(0,n.jsx)(O.A,{size:9,className:"animate-spin"}),b&&(0,n.jsx)(x.A,{size:9}),o?.confirmSave??"Save"]})]})]})}function eL({anchorRef:e,messages:t,onClose:r}){let{t:a}=(0,m.Y)(),o=a.ask,[l,i]=(0,s.useState)("select"),[u,c]=(0,s.useState)([]);return(0,s.useEffect)(()=>{(0,ew.n)("/api/file?op=dirs").then(e=>c(e.dirs??[])).catch(()=>{})},[]),(0,n.jsxs)(eT,{anchorRef:e,onClose:r,children:["select"===l&&(0,n.jsx)(eM,{messages:t,onSelect:i,onClose:r,ask:o}),"archive"===l&&(0,n.jsx)(eD,{messages:t,dirPaths:u,onBack:()=>i("select"),onClose:r,ask:o}),"digest"===l&&(0,n.jsx)(e_,{messages:t,onClose:r,ask:o})]})}function eM({messages:e,onSelect:t,onClose:r,ask:s}){let a=eC(e,"full");return(0,n.jsxs)("div",{className:"p-3",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-2.5",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,n.jsx)(W.A,{size:11,className:"text-[var(--amber)]"}),(0,n.jsx)("span",{className:"text-xs font-semibold text-foreground",children:s?.saveSession??"Save Session"}),(0,n.jsxs)("span",{className:"text-2xs text-muted-foreground",children:["(",a.msgCount,")"]})]}),(0,n.jsx)("button",{type:"button",onClick:r,className:"text-2xs text-muted-foreground hover:text-foreground",children:s?.cancelSave??"Cancel"})]}),(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>t("archive"),className:"flex flex-col items-center gap-1 p-2.5 border border-[var(--amber)]/30 rounded-lg hover:border-[var(--amber)]/60 hover:shadow-sm active:scale-[0.98] transition-all",children:[(0,n.jsx)(W.A,{size:16,className:"text-[var(--amber)]"}),(0,n.jsx)("span",{className:"text-2xs font-medium text-foreground",children:s?.saveDirectly??"Save directly"}),(0,n.jsx)("span",{className:"text-[10px] text-muted-foreground text-center leading-tight",children:s?.saveDirectlyDesc??"Save as-is"})]}),(0,n.jsxs)("button",{type:"button",onClick:()=>t("digest"),className:"flex flex-col items-center gap-1 p-2.5 border border-border rounded-lg hover:border-[var(--amber)]/50 hover:shadow-sm active:scale-[0.98] transition-all",children:[(0,n.jsx)(p.A,{size:16,className:"text-[var(--amber)]"}),(0,n.jsx)("span",{className:"text-2xs font-medium text-foreground",children:s?.organizeToNote??"Organize to note"}),(0,n.jsx)("span",{className:"text-[10px] text-muted-foreground text-center leading-tight",children:s?.organizeToNoteDesc??"AI extracts insights"})]})]})]})}function eD({messages:e,dirPaths:t,onBack:r,onClose:a,ask:o}){let l,i,u=new Date,c=`session-${u.getFullYear()}-${String(u.getMonth()+1).padStart(2,"0")}-${String(u.getDate()).padStart(2,"0")}.md`,[d,m]=(0,s.useState)(""),[f,p]=(0,s.useState)(c),[h,b]=(0,s.useState)("full"),[v,y]=(0,s.useState)(!1),[j,w]=(0,s.useState)(!1),[k,N]=(0,s.useState)(!1),[S,C]=(0,s.useState)(""),A=(0,s.useRef)(null);(0,s.useEffect)(()=>{setTimeout(()=>{A.current?.focus(),A.current?.select()},100)},[]);let E=(i=(l=f.trim()||c).endsWith(".md")?l:`${l}.md`,d?`${d}/${i}`:i),R=eC(e,h),z=(0,s.useCallback)(async()=>{w(!0),C("");try{await (0,ew.n)("/api/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:E,op:"create_file",content:eS(e,h),source:"user"})}),N(!0),ek.oR.success(o?.savedToKB?.replace("{path}",E.split("/").pop())??"Saved"),setTimeout(a,1e3)}catch(e){C(e?.message?.includes("exist")?o?.fileExistsSwitch??"File exists":e?.message??"Failed")}finally{w(!1)}},[e,h,E,o,a]),T=eS(e,h).slice(0,300);return(0,n.jsxs)("div",{className:"p-3 space-y-2",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,n.jsx)("button",{type:"button",onClick:r,className:"text-muted-foreground hover:text-foreground",children:(0,n.jsx)(ed.A,{size:11,className:"rotate-180"})}),(0,n.jsx)(W.A,{size:11,className:"text-[var(--amber)]"}),(0,n.jsx)("span",{className:"text-xs font-semibold",children:o?.saveDirectly??"Save directly"})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"text-2xs text-muted-foreground mb-0.5 block",children:o?.targetFolder??"Folder"}),(0,n.jsx)(eN.A,{dirPaths:t,value:d,onChange:m,rootLabel:"Root"})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"text-2xs text-muted-foreground mb-0.5 block",children:o?.fileName??"Filename"}),(0,n.jsx)("input",{ref:A,type:"text",value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{"Enter"===e.key&&z(),"Escape"===e.key&&a()},className:"w-full px-2 py-1 text-xs font-mono rounded-md border border-border bg-background text-foreground outline-none focus-visible:border-[var(--amber)]/50"})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2.5",children:[["full","ai-only"].map(e=>(0,n.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,n.jsx)("input",{type:"radio",name:"fmt",checked:h===e,onChange:()=>b(e),className:"w-2.5 h-2.5 accent-[var(--amber)]"}),(0,n.jsx)("span",{className:"text-2xs",children:"full"===e?o?.formatFull??"Full":o?.formatAiOnly??"AI only"})]},e)),(0,n.jsxs)("span",{className:"text-[10px] text-muted-foreground ml-auto",children:[R.msgCount," msgs"]})]}),(0,n.jsxs)("button",{type:"button",onClick:()=>y(e=>!e),className:"flex items-center gap-0.5 text-[10px] text-muted-foreground hover:text-foreground",children:[v?(0,n.jsx)(g.A,{size:9}):(0,n.jsx)(ed.A,{size:9})," Preview"]}),v&&(0,n.jsxs)("pre",{className:"px-2 py-1 text-[10px] text-muted-foreground bg-muted/30 rounded-md max-h-24 overflow-auto whitespace-pre-wrap font-mono",children:[T,T.length>=300?"...":""]}),(0,n.jsx)("div",{className:"text-[10px] text-muted-foreground/60 font-mono truncate",children:E}),S&&(0,n.jsxs)("div",{className:"flex items-center gap-1 text-2xs text-error",children:[(0,n.jsx)(J.A,{size:10}),S]}),(0,n.jsxs)("div",{className:"flex justify-end gap-1.5 pt-1 border-t border-border/30",children:[(0,n.jsx)("button",{type:"button",onClick:a,className:"px-2 py-0.5 text-2xs rounded text-muted-foreground hover:bg-muted",children:o?.cancelSave??"Cancel"}),(0,n.jsxs)("button",{type:"button",onClick:z,disabled:j||k||!f.trim(),className:`flex items-center gap-1 px-2.5 py-0.5 text-2xs font-medium rounded transition-colors ${k?"bg-success/10 text-success":"bg-[var(--amber)] text-[var(--amber-foreground)]"} disabled:opacity-50`,children:[j&&(0,n.jsx)(O.A,{size:9,className:"animate-spin"}),k&&(0,n.jsx)(x.A,{size:9}),o?.confirmSave??"Save"]})]})]})}function e_({messages:e,onClose:t,ask:r}){let n=(0,s.useCallback)(()=>{let n=eS(e,"full");window.dispatchEvent(new CustomEvent("mindos:session-organize",{detail:{content:n,name:"conversation.md"}})),t(),ek.oR.success(r?.organizing??"AI is organizing...")},[e,t,r]);return(0,s.useEffect)(()=>{n()},[n]),null}var eP=r(9199);function eF({label:e,delay:t=800,children:r}){let[a,o]=(0,s.useState)(!1),l=(0,s.useRef)(null),i=(0,s.useCallback)(()=>{l.current=setTimeout(()=>o(!0),t)},[t]),u=(0,s.useCallback)(()=>{l.current&&(clearTimeout(l.current),l.current=null),o(!1)},[]);return(0,n.jsxs)("span",{className:"relative inline-flex",onMouseEnter:i,onMouseLeave:u,children:[r,a&&(0,n.jsx)("span",{role:"tooltip",className:"pointer-events-none absolute -top-8 left-1/2 -translate-x-1/2 whitespace-nowrap rounded-md bg-foreground/90 px-2 py-0.5 text-[11px] font-medium text-background shadow-sm animate-in fade-in-0 slide-in-from-bottom-1 duration-100 z-20",children:e})]})}function eI({content:e,isLastUserMessage:t,isLoading:r,onEdit:a,onResend:o,labels:l}){let[i,u]=(0,s.useState)(!1),c=(0,s.useRef)(!1),d=(0,s.useCallback)(()=>{(0,Z.l)(e).then(e=>{e&&(u(!0),setTimeout(()=>u(!1),2e3))})},[e]),m=(0,s.useCallback)(()=>{c.current||r||(c.current=!0,setTimeout(()=>{c.current=!1},300),o?.())},[o,r]),f="p-1 rounded-md bg-card border border-border/60 shadow-sm text-muted-foreground transition-colors";return(0,n.jsxs)("div",{className:"absolute -bottom-1 left-1 z-10 flex items-center gap-1 opacity-100 md:opacity-0 md:group-hover:opacity-100 transition-opacity",children:[(0,n.jsx)(eF,{label:l.copy,children:(0,n.jsx)("button",{type:"button",onClick:d,className:`${f} hover:text-foreground`,children:i?(0,n.jsx)(x.A,{size:11,className:"text-success"}):(0,n.jsx)(_.A,{size:11})})}),t&&!r&&a&&(0,n.jsx)(eF,{label:l.edit,children:(0,n.jsx)("button",{type:"button",onClick:a,className:`${f} hover:text-foreground`,children:(0,n.jsx)(U.A,{size:11})})}),t&&!r&&o&&(0,n.jsx)(eF,{label:l.regenerate,children:(0,n.jsx)("button",{type:"button",onClick:m,className:`${f} hover:text-[var(--amber)]`,children:(0,n.jsx)(eP.A,{size:11})})})]})}let eO=/^Use the skill ([^:]+):\s*/;function eH({text:e,label:t}){let[r,a]=(0,s.useState)(!1),o=(0,s.useCallback)(()=>{(0,Z.l)(e).then(e=>{e&&(a(!0),setTimeout(()=>a(!1),2e3))})},[e]);return(0,n.jsx)("button",{type:"button",onClick:o,className:"p-1 rounded-md bg-card border border-border/60 shadow-sm text-muted-foreground hover:text-foreground transition-colors",title:t??"Copy",children:r?(0,n.jsx)(x.A,{size:11,className:"text-success"}):(0,n.jsx)(_.A,{size:11})})}function eW({content:e,skillName:t,images:r,attachedFiles:s,uploadedFileNames:a}){let o=t??e.match(eO)?.[1],i=e.match(eO),u=i?e.slice(i[0].length):e,c=new Set(a??[]),d=s?.filter(e=>!c.has(e.split("/").pop()??e)),m=d&&d.length>0||a&&a.length>0;return(0,n.jsxs)(n.Fragment,{children:[r&&r.length>0&&(0,n.jsx)("div",{className:`flex flex-wrap gap-1.5${e?" mb-2":""}`,children:r.map((e,t)=>e.data?(0,n.jsx)("img",{src:`data:${e.mimeType};base64,${e.data}`,alt:`Image ${t+1}`,className:"max-h-48 max-w-full rounded-md object-contain"},t):(0,n.jsx)("div",{className:"h-12 px-3 rounded-md bg-muted flex items-center gap-1.5 text-xs text-muted-foreground",children:(0,n.jsxs)("span",{children:["[Image ",t+1,"]"]})},t))}),o&&(0,n.jsxs)("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[11px] font-medium bg-white/20 text-white/90 mr-1 align-middle",children:[(0,n.jsx)(P.A,{size:10,className:"shrink-0"}),o]}),o?u:e,m&&(0,n.jsxs)("div",{className:"mt-2 pt-1.5 border-t border-white/15 flex flex-wrap gap-1 whitespace-normal",role:"list","aria-label":"Attached files",children:[d?.map(e=>(0,n.jsxs)("span",{role:"listitem",className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] bg-white/10 text-white/80 min-w-0",title:e,children:[(0,n.jsx)(l.A,{size:9,className:"shrink-0 opacity-70"}),(0,n.jsx)("span",{className:"truncate max-w-[120px]",children:e.split("/").pop()})]},e)),a?.map(e=>(0,n.jsxs)("span",{role:"listitem",className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] bg-white/10 text-white/80 min-w-0",title:e,children:[(0,n.jsx)(F.A,{size:9,className:"shrink-0 opacity-70"}),(0,n.jsx)("span",{className:"truncate max-w-[120px]",children:e})]},e))]})]})}function eB({agentName:e}){return e?(0,n.jsxs)("div",{className:"mb-2 inline-flex items-center gap-1 rounded-full border border-[var(--amber)]/15 bg-[var(--amber)]/8 px-2 py-0.5 text-[10px] font-medium tracking-wide text-[var(--amber)]",children:[(0,n.jsx)(I.A,{size:10,className:"shrink-0"}),(0,n.jsx)("span",{children:e})]}):null}function eU({content:e,isStreaming:t}){let r=(0,X.Oo)(e);return r||t?(0,n.jsxs)("div",{className:"prose prose-sm prose-panel dark:prose-invert max-w-none text-foreground prose-p:my-2 prose-p:leading-relaxed prose-headings:font-semibold prose-headings:my-3 prose-h1:text-base prose-h2:text-[15px] prose-h3:text-sm prose-ul:my-1.5 prose-li:my-0.5 prose-ol:my-1.5 prose-code:text-[0.8em] prose-code:bg-muted/80 prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded-md prose-code:before:content-none prose-code:after:content-none prose-code:font-mono prose-pre:bg-muted/60 prose-pre:text-foreground prose-pre:text-xs prose-pre:rounded-lg prose-blockquote:border-l-[var(--amber)] prose-blockquote:text-muted-foreground prose-blockquote:not-italic prose-a:text-[var(--amber)] prose-a:no-underline hover:prose-a:underline prose-strong:text-foreground prose-strong:font-semibold prose-table:text-xs prose-th:py-1.5 prose-td:py-1 ",children:[(0,n.jsx)(Q.oz,{remarkPlugins:[V.A],children:r}),t&&(0,n.jsx)("span",{className:"inline-block w-1.5 h-3.5 bg-[var(--amber)] ml-0.5 align-middle animate-pulse rounded-full"})]}):null}function eY({message:e,isStreaming:t}){let r=e.parts;if(!r||0===r.length)return e.content?(0,n.jsx)(eU,{content:e.content,isStreaming:t}):null;let s=r[r.length-1],a=t&&"tool-call"===s.type&&("running"===s.state||"pending"===s.state);return(0,n.jsxs)("div",{children:[r.map((e,s)=>{if("reasoning"===e.type){let a=t&&s===r.length-1;return(0,n.jsx)(ej,{text:e.text,isStreaming:a},`reasoning-${s}`)}if("text"===e.type){let a=t&&s===r.length-1;return e.text?(0,n.jsx)(eU,{content:e.text,isStreaming:a},s):null}return"tool-call"===e.type?(0,n.jsx)(ev,{part:e},e.toolCallId):null}),a&&(0,n.jsxs)("div",{className:"flex items-center gap-2 py-1.5 mt-1.5",children:[(0,n.jsx)(O.A,{size:12,className:"animate-spin text-[var(--amber)]"}),(0,n.jsx)("span",{className:"text-xs text-muted-foreground animate-pulse",children:"Executing tool…"})]})]})}function eJ({parts:e}){if(!e)return null;let t=e.filter(e=>"tool-call"===e.type);if(0===t.length)return null;let r=t[t.length-1],s="tool-call"===r.type?r.toolName:"";return(0,n.jsxs)("div",{className:"flex items-center gap-1.5 mt-2 pt-1.5 border-t border-border/15 text-xs text-muted-foreground/60",children:[(0,n.jsx)(H.A,{size:10}),(0,n.jsxs)("span",{className:"font-medium",children:["Step ",t.length,s?` — ${s}`:""]})]})}let eK=(0,s.memo)(function({messages:e,isLoading:t,loadingPhase:r,emptyPrompt:a,emptyHint:o,suggestions:l,onSuggestionClick:i,onEditMessage:u,onResendMessage:c,labels:d}){let m=(0,s.useRef)(null),f=(0,s.useRef)(null),[x,g]=(0,s.useState)(!1),h=(0,s.useRef)(!1),b=(0,s.useRef)(e.length),v=(0,s.useMemo)(()=>{for(let t=e.length-1;t>=0;t--)if("user"===e[t].role)return t;return -1},[e]),y=(0,s.useCallback)((e="smooth")=>{let t=f.current;t&&t.scrollTo({top:t.scrollHeight,behavior:e})},[]);return(0,s.useEffect)(()=>{let t=e.length,r=t>b.current;if(b.current=t,r){h.current=!1,y("instant");return}h.current||y("instant")},[e,y]),(0,s.useEffect)(()=>{let e=f.current;if(!e)return;let t=!1,r=()=>{t||(t=!0,requestAnimationFrame(()=>{let{scrollTop:r,scrollHeight:n,clientHeight:s}=e,a=n-r-s;g(a>100),a<80&&(h.current=!1),t=!1}))},n=e=>{e.deltaY<0&&(h.current=!0)},s=0,a=e=>{s=e.touches[0]?.clientY??0},o=e=>{(e.touches[0]?.clientY??0)>s&&(h.current=!0)},l=e=>{["ArrowUp","PageUp","Home"].includes(e.key)&&(h.current=!0)};return e.addEventListener("scroll",r,{passive:!0}),e.addEventListener("wheel",n,{passive:!0}),e.addEventListener("touchstart",a,{passive:!0}),e.addEventListener("touchmove",o,{passive:!0}),e.addEventListener("keydown",l),()=>{e.removeEventListener("scroll",r),e.removeEventListener("wheel",n),e.removeEventListener("touchstart",a),e.removeEventListener("touchmove",o),e.removeEventListener("keydown",l)}},[]),(0,n.jsxs)("div",{ref:f,role:"log","aria-live":"polite",className:"relative flex-1 overflow-y-auto overflow-x-hidden px-4 py-5 space-y-5 min-h-0",children:[0===e.length&&(0,n.jsxs)("div",{className:"flex flex-col items-center justify-center flex-1 min-h-[260px] px-6 pt-10 pb-4",children:[(0,n.jsxs)("div",{className:"relative w-12 h-12 rounded-2xl bg-[var(--amber)]/10 flex items-center justify-center mb-6",children:[(0,n.jsx)("div",{className:"absolute inset-0 rounded-2xl bg-[var(--amber)]/5 scale-[1.4]"}),(0,n.jsx)(p.A,{size:22,className:"text-[var(--amber)] relative z-10"})]}),(0,n.jsx)("p",{className:"text-center text-[15px] font-semibold text-foreground tracking-tight mb-2",children:a}),o&&(0,n.jsx)("p",{className:"text-center text-xs text-muted-foreground/80 mb-10 tracking-wide",children:o}),(0,n.jsx)("div",{className:"flex flex-col gap-2.5 max-w-[280px] w-full",children:l.map((e,t)=>{let r=[W.A,B.A,U.A,Y.A],s=r[t%r.length];return(0,n.jsxs)("button",{type:"button",onClick:()=>i(e.prompt),className:"group/sug flex items-center gap-3 text-left text-[13px] px-3.5 py-3 rounded-xl border border-border/40 bg-transparent text-muted-foreground hover:text-foreground hover:border-[var(--amber)]/30 hover:bg-[var(--amber)]/5 transition-all leading-snug","aria-label":e.prompt,children:[(0,n.jsx)("span",{className:"shrink-0 w-8 h-8 rounded-lg bg-muted/60 flex items-center justify-center group-hover/sug:bg-[var(--amber)]/10 transition-colors",children:(0,n.jsx)(s,{size:15,className:"text-muted-foreground/70 group-hover/sug:text-[var(--amber)] transition-colors"})}),(0,n.jsx)("span",{className:"flex-1",children:e.label})]},t)})})]}),e.map((s,a)=>(0,n.jsxs)("div",{className:`flex gap-3 animate-[fadeSlideUp_0.22s_ease_both] ${"user"===s.role?"justify-end":"justify-start"}`,children:["assistant"===s.role&&(0,n.jsx)("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center shrink-0 mt-0.5 bg-[var(--amber)]/8",children:(0,n.jsx)(p.A,{size:13,className:"text-[var(--amber)]"})}),"user"===s.role?(0,n.jsxs)("div",{className:"group relative max-w-[85%] px-3.5 py-2.5 rounded-2xl rounded-br-lg text-sm leading-relaxed whitespace-pre-wrap bg-[var(--amber)] text-[var(--amber-foreground)] shadow-sm shadow-[var(--amber)]/10",children:[(0,n.jsx)(eW,{content:s.content,skillName:s.skillName,images:s.images,attachedFiles:s.attachedFiles,uploadedFileNames:s.uploadedFileNames}),(0,n.jsx)(eI,{content:s.content,isLastUserMessage:a===v,isLoading:t,onEdit:u?()=>u(a):void 0,onResend:c?()=>c(a):void 0,labels:{copy:d.copyMessage??"Copy",edit:d.editMessage??"Edit",regenerate:d.regenerateMessage??"Regenerate"}})]}):s.content.startsWith("__error__")?(0,n.jsxs)("div",{className:"max-w-[85%] px-3.5 py-3 rounded-2xl rounded-bl-md border border-error/30 bg-error/10 text-sm shadow-sm",children:[(0,n.jsx)(eB,{agentName:s.agentName}),(0,n.jsxs)("div",{className:"flex items-start gap-2.5 text-error",children:[(0,n.jsx)(J.A,{size:15,className:"shrink-0 mt-0.5"}),(0,n.jsx)("span",{className:"leading-relaxed font-medium",children:s.content.slice(9)})]})]}):(0,n.jsxs)("div",{className:"group relative max-w-[85%] px-3.5 py-2.5 rounded-2xl rounded-bl-lg bg-card border border-border/30 shadow-sm text-foreground text-sm",children:[(0,n.jsx)(eB,{agentName:s.agentName}),s.parts&&s.parts.length>0||(0,X.Oo)(s.content)?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(eY,{message:s,isStreaming:t&&a===e.length-1}),t&&a===e.length-1&&(0,n.jsx)(eJ,{parts:s.parts}),!(t&&a===e.length-1)&&(0,X.Oo)(s.content)&&(0,n.jsxs)("div",{className:"absolute -bottom-1 right-1 z-10 flex items-center gap-1 opacity-100 md:opacity-0 md:group-hover:opacity-100 transition-opacity",children:[(0,n.jsx)(eA,{text:s.content}),(0,n.jsx)(eH,{text:(0,X.Oo)(s.content),label:d.copyMessage})]})]}):t&&a===e.length-1?(0,n.jsxs)("div",{className:"flex items-center gap-2.5 py-1",children:["reconnecting"===r?(0,n.jsx)(K.A,{size:14,className:"text-[var(--amber)] animate-pulse"}):(0,n.jsx)(O.A,{size:14,className:"animate-spin text-[var(--amber)]"}),(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:(0,n.jsxs)("span",{className:"inline-flex items-center gap-1",children:["reconnecting"===r?d.reconnecting??"Reconnecting...":"connecting"===r?d.connecting:"thinking"===r?d.thinking:d.generating,(0,n.jsxs)("span",{className:"inline-flex gap-0.5",children:[(0,n.jsx)("span",{className:"w-1 h-1 rounded-full bg-[var(--amber)] animate-bounce [animation-delay:0ms]"}),(0,n.jsx)("span",{className:"w-1 h-1 rounded-full bg-[var(--amber)] animate-bounce [animation-delay:150ms]"}),(0,n.jsx)("span",{className:"w-1 h-1 rounded-full bg-[var(--amber)] animate-bounce [animation-delay:300ms]"})]})]})})]}):null]})]},a)),(0,n.jsx)("div",{ref:m}),x&&e.length>0&&(0,n.jsx)("button",{type:"button",onClick:()=>{h.current=!1,y()},className:"sticky bottom-2 left-1/2 -translate-x-1/2 z-10 p-2 rounded-full border border-border/60 bg-card shadow-md text-muted-foreground hover:text-foreground hover:bg-muted transition-all hover:shadow-lg",title:"Scroll to bottom",children:(0,n.jsx)(q.A,{size:14})})]})});function eq({text:e,query:t}){if(!t)return(0,n.jsx)(n.Fragment,{children:e});let r=e.toLowerCase().indexOf(t.toLowerCase());return -1===r?(0,n.jsx)(n.Fragment,{children:e}):(0,n.jsxs)(n.Fragment,{children:[e.slice(0,r),(0,n.jsx)("span",{className:"text-[var(--amber)] font-semibold",children:e.slice(r,r+t.length)}),e.slice(r+t.length)]})}function eQ({results:e,selectedIndex:t,query:r,onSelect:a}){let o=(0,s.useRef)(null),i=(0,s.useRef)(null),[u,c]=(0,s.useState)(280);return((0,s.useEffect)(()=>{let e=i.current;e&&c(Math.max(120,Math.min(320,Math.min(e.getBoundingClientRect().top-8,.5*window.innerHeight)-80)))},[e.length]),(0,s.useEffect)(()=>{let e=o.current;if(!e)return;let r=e.children[t];r?.scrollIntoView({block:"nearest"})},[t]),0===e.length)?null:(0,n.jsxs)("div",{ref:i,className:"border border-border rounded-lg bg-card shadow-lg overflow-hidden",children:[(0,n.jsxs)("div",{className:"px-3 py-1.5 border-b border-border flex items-center gap-1.5",children:[(0,n.jsx)(ee.A,{size:11,className:"text-muted-foreground/50"}),(0,n.jsx)("span",{className:"text-2xs font-medium text-muted-foreground/70 uppercase tracking-wider",children:"Files"}),(0,n.jsx)("span",{className:"text-2xs text-muted-foreground/40 ml-auto",children:e.length})]}),(0,n.jsx)("div",{ref:o,className:"overflow-y-auto",style:{maxHeight:u},children:e.map((e,s)=>{let o=e.split("/").pop()??e,i=e.split("/").slice(0,-1).join("/"),u=o.endsWith(".csv");return(0,n.jsxs)("button",{type:"button",onMouseDown:t=>{t.preventDefault(),a(e)},className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${s===t?"bg-accent text-foreground":"text-muted-foreground hover:bg-muted"}`,children:[u?(0,n.jsx)(ec.A,{size:13,className:"text-success shrink-0"}):(0,n.jsx)(l.A,{size:13,className:"text-muted-foreground shrink-0"}),(0,n.jsx)("span",{className:"truncate font-medium flex-1",title:o,children:(0,n.jsx)(eq,{text:o,query:r})}),i&&(0,n.jsx)("span",{className:"text-2xs text-muted-foreground/40 truncate max-w-[140px] shrink-0",title:i,children:(0,n.jsx)(eq,{text:i,query:r})})]},e)})}),(0,n.jsxs)("div",{className:"px-3 py-1.5 border-t border-border flex gap-3 text-2xs text-muted-foreground/40 shrink-0",children:[(0,n.jsx)("span",{children:"↑↓ navigate"}),(0,n.jsx)("span",{children:"↵ select"}),(0,n.jsx)("span",{children:"ESC dismiss"})]})]})}function eV({results:e,selectedIndex:t,query:r,onSelect:a}){let o=(0,s.useRef)(null),l=(0,s.useRef)(null),[i,u]=(0,s.useState)(280);return((0,s.useEffect)(()=>{let e=l.current;e&&u(Math.max(120,Math.min(320,Math.min(e.getBoundingClientRect().top-8,.5*window.innerHeight)-80)))},[e.length]),(0,s.useEffect)(()=>{let e=o.current;if(!e)return;let r=e.children[t];r?.scrollIntoView({block:"nearest"})},[t]),0===e.length)?null:(0,n.jsxs)("div",{ref:l,className:"border border-border rounded-lg bg-card shadow-lg overflow-hidden",children:[(0,n.jsxs)("div",{className:"px-3 py-1.5 border-b border-border flex items-center gap-1.5",children:[(0,n.jsx)(P.A,{size:11,className:"text-[var(--amber)]/50"}),(0,n.jsx)("span",{className:"text-2xs font-medium text-muted-foreground/70 uppercase tracking-wider",children:"Skills"}),(0,n.jsx)("span",{className:"text-2xs text-muted-foreground/40 ml-auto",children:e.length})]}),(0,n.jsx)("div",{ref:o,className:"overflow-y-auto",style:{maxHeight:i},children:e.map((e,s)=>(0,n.jsxs)("button",{type:"button",onMouseDown:t=>{t.preventDefault(),a(e)},className:`w-full flex items-center gap-2.5 px-3 py-2 text-left transition-colors ${s===t?"bg-accent text-foreground":"text-muted-foreground hover:bg-muted"}`,children:[(0,n.jsx)(P.A,{size:13,className:"text-[var(--amber)] shrink-0"}),(0,n.jsxs)("span",{className:"text-sm font-medium shrink-0",children:["/",(0,n.jsx)(eq,{text:e.name,query:r})]}),e.description&&(0,n.jsx)("span",{className:"text-2xs text-muted-foreground/50 truncate min-w-0 flex-1",title:e.description,children:e.description})]},e.name))}),(0,n.jsxs)("div",{className:"px-3 py-1.5 border-t border-border flex gap-3 text-2xs text-muted-foreground/40 shrink-0",children:[(0,n.jsx)("span",{children:"↑↓ navigate"}),(0,n.jsx)("span",{children:"↵ / Tab select"}),(0,n.jsx)("span",{children:"ESC dismiss"})]})]})}var eX=r(89823),eZ=r(36261);function eG({sessions:e,activeSessionId:t,onLoad:r,onDelete:a,onRename:o,onTogglePin:l,onClearAll:i,onClose:c,onNewChat:d}){let{t:p}=(0,m.Y)(),x=p.ask,[g,h]=(0,s.useState)(""),[b,v]=(0,s.useState)(null),[y,j]=(0,s.useState)(""),[w,N]=(0,s.useState)(!1),S=(0,s.useRef)(void 0),C=(0,s.useRef)(null),A=(0,s.useRef)(null);(0,s.useEffect)(()=>{C.current?.focus()},[]),(0,s.useEffect)(()=>{b&&setTimeout(()=>A.current?.focus(),0)},[b]),(0,s.useEffect)(()=>()=>{S.current&&clearTimeout(S.current)},[]);let E=(0,s.useMemo)(()=>{if(!g.trim())return e;let t=g.toLowerCase();return e.filter(e=>!!k(e).toLowerCase().includes(t)||e.messages.some(e=>e.content.toLowerCase().includes(t)))},[e,g]),R=(0,s.useMemo)(()=>{let e=[],t=[],r=[],n=[],s=[];for(let a of E){if(a.pinned){e.push(a);continue}let o=function(e){let t=new Date,r=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),n=r-864e5*t.getDay();return e>=r?"today":e>=r-864e5?"yesterday":e>=n?"week":"older"}(a.updatedAt);"today"===o?t.push(a):"yesterday"===o?r.push(a):"week"===o?n.push(a):s.push(a)}return{pinned:e,today:t,yesterday:r,week:n,older:s}},[E]),z=e.filter(e=>e.pinned).length,T=e.filter(e=>e.messages.length>0).length,$=(0,s.useCallback)(e=>{r(e),c()},[r,c]),L=(0,s.useCallback)(()=>{d(),c()},[d,c]),M=(0,s.useCallback)(e=>{v(e.id),j(k(e))},[]),D=(0,s.useCallback)(()=>{b&&y.trim()&&o(b,y.trim()),v(null)},[b,y,o]),_=(0,s.useCallback)(()=>{if(!w){N(!0),S.current&&clearTimeout(S.current),S.current=setTimeout(()=>N(!1),3e3);return}S.current&&clearTimeout(S.current),i(),N(!1)},[w,i]);(0,s.useEffect)(()=>{let e=e=>{"Escape"!==e.key||b||c()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[c,b]);let P=(e,r)=>0===r.length?null:(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"text-2xs font-medium text-muted-foreground/50 uppercase tracking-wider px-1 py-2",children:e}),(0,n.jsx)("div",{className:"flex flex-col gap-1",children:r.map(e=>(0,n.jsx)(e0,{session:e,isActive:e.id===t,editing:b===e.id,editValue:y,onEditValueChange:j,inputRef:A,onLoad:()=>$(e.id),onStartRename:()=>M(e),onCommitRename:D,onCancelRename:()=>v(null),onDelete:()=>a(e.id),onTogglePin:()=>l(e.id),ask:x},e.id))})]},e),F=E.length>0;return(0,n.jsxs)("div",{className:"flex flex-col flex-1 min-h-0 animate-in fade-in-0 duration-150",children:[(0,n.jsx)("div",{className:"px-4 pt-3 pb-2 shrink-0",children:(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)(B.A,{size:13,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground/50"}),(0,n.jsx)("input",{ref:C,type:"text",value:g,onChange:e=>h(e.target.value),placeholder:x?.historySearch??"Search conversations...",className:"w-full pl-8 pr-8 py-2 text-xs rounded-lg border border-border bg-background text-foreground placeholder:text-muted-foreground/40 outline-none focus-visible:border-[var(--amber)]/40 transition-colors"}),g&&(0,n.jsx)("button",{type:"button",onClick:()=>h(""),className:"absolute right-2 top-1/2 -translate-y-1/2 p-0.5 rounded text-muted-foreground/40 hover:text-foreground",children:(0,n.jsx)(u.A,{size:12})})]})}),(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 pb-2 shrink-0",children:[(0,n.jsxs)("span",{className:"text-2xs text-muted-foreground/60",children:[x?.historyStats?.(T)??`${T} conversations`,z>0&&(0,n.jsxs)(n.Fragment,{children:[" \xb7 ",z," ",x?.historyPinned??"pinned"]})]}),(0,n.jsxs)("button",{type:"button",onClick:L,className:"flex items-center gap-1 text-2xs text-[var(--amber)] hover:text-[var(--amber)]/80 transition-colors",children:[(0,n.jsx)(eX.A,{size:11}),(0,n.jsx)("span",{children:p.hints?.newChat??"New chat"})]})]}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto min-h-0 px-3 pb-3",children:F?(0,n.jsxs)("div",{className:"flex flex-col gap-1",children:[P(x?.historyPinned??"Pinned",R.pinned),P(x?.historyToday??"Today",R.today),P(x?.historyYesterday??"Yesterday",R.yesterday),P(x?.historyThisWeek??"This week",R.week),P(x?.historyOlder??"Older",R.older)]}):(0,n.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[(0,n.jsx)(f.A,{size:32,className:"text-muted-foreground/20 mb-3"}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground/60",children:g?"No matching conversations":x?.historyEmpty??"No conversations yet"}),!g&&(0,n.jsx)("p",{className:"text-2xs text-muted-foreground/40 mt-1",children:x?.historyEmptyHint??"Start a new chat to begin"})]})}),T>0&&(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-2.5 border-t border-border/40 shrink-0",children:[(0,n.jsx)("button",{type:"button",onClick:_,className:`text-2xs px-2 py-0.5 rounded-md transition-colors ${w?"bg-error/10 text-error font-medium":"text-muted-foreground/50 hover:text-error hover:bg-muted"}`,children:(0,n.jsxs)("span",{className:"flex items-center gap-1",children:[(0,n.jsx)(ea.A,{size:10}),w?x?.confirmClear??"Confirm clear?":x?.clearAll??"Clear all"]})}),(0,n.jsx)("span",{className:"text-2xs text-muted-foreground/40 tabular-nums",children:x?.historyCapacity?.(T)??`${T} of 30`})]})]})}function e0({session:e,isActive:t,editing:r,editValue:s,onEditValueChange:a,inputRef:o,onLoad:l,onStartRename:i,onCommitRename:u,onCancelRename:c,onDelete:d,onTogglePin:m,ask:p}){let x=k(e),g=function(e){let t=e.messages.find(e=>"user"===e.role);if(!t)return"";let r=t.content.replace(/\s+/g," ").trim();return r.length>60?`${r.slice(0,60)}...`:r}(e),h=e.messages.length;return(0,n.jsxs)("div",{className:`group relative rounded-lg transition-colors cursor-pointer ${t?"bg-[var(--amber)]/8 border border-[var(--amber)]/15":"hover:bg-muted/60 border border-transparent"}`,onClick:l,children:[t&&(0,n.jsx)("span",{className:"absolute left-0 top-3 bottom-3 w-[2px] rounded-r-full bg-[var(--amber)]"}),(0,n.jsxs)("div",{className:"px-3 py-2.5",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1.5 mb-0.5",children:[e.pinned&&(0,n.jsx)(es.A,{size:10,className:"shrink-0 text-[var(--amber)]/60 -rotate-45"}),r?(0,n.jsx)("input",{ref:o,type:"text",value:s,onChange:e=>a(e.target.value),onBlur:u,onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),u()),"Escape"===e.key&&(e.preventDefault(),c())},onClick:e=>e.stopPropagation(),className:"flex-1 min-w-0 bg-transparent border-b border-[var(--amber)] outline-none text-xs font-medium text-foreground"}):(0,n.jsx)("span",{className:"flex-1 min-w-0 text-xs font-medium text-foreground truncate",children:x}),(0,n.jsx)("span",{className:"text-2xs text-muted-foreground/40 shrink-0 tabular-nums",children:function(e){let t=Math.floor((Date.now()-e.getTime())/6e4);if(t<1)return"just now";if(t<60)return`${t}m ago`;let r=Math.floor(t/60);if(r<24)return`${r}h ago`;let n=Math.floor(r/24);return n<7?`${n}d ago`:e.toLocaleDateString(void 0,{month:"short",day:"numeric"})}(new Date(e.updatedAt))})]}),!r&&g&&(0,n.jsx)("p",{className:"text-2xs text-muted-foreground/50 truncate mt-0.5 pl-0.5",children:g}),!r&&(0,n.jsxs)("div",{className:"flex items-center justify-between mt-1.5",children:[(0,n.jsxs)("span",{className:"text-2xs text-muted-foreground/40 flex items-center gap-1",children:[(0,n.jsx)(f.A,{size:9}),p?.historyMsgs?.(h)??`${h} msgs`]}),(0,n.jsxs)("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("button",{type:"button",onClick:m,className:`p-1 rounded-md transition-colors ${e.pinned?"text-[var(--amber)] hover:text-muted-foreground":"text-muted-foreground/40 hover:text-[var(--amber)]"}`,title:e.pinned?"Unpin":"Pin",children:e.pinned?(0,n.jsx)(eZ.A,{size:11}):(0,n.jsx)(es.A,{size:11})}),(0,n.jsx)("button",{type:"button",onClick:i,className:"p-1 rounded-md text-muted-foreground/40 hover:text-foreground hover:bg-muted/60 transition-colors",title:p?.renameSession??"Rename",children:(0,n.jsx)(er.A,{size:11})}),(0,n.jsx)("button",{type:"button",onClick:d,className:"p-1 rounded-md text-muted-foreground/40 hover:text-error hover:bg-error/5 transition-colors",title:"Delete",children:(0,n.jsx)(ea.A,{size:11})})]})]})]})]})}var e1=r(60241),e2=r(24371),e5=r(52335),e3=r(94852);let e4=(0,s.memo)(function({isPanel:e,showHistory:t,onToggleHistory:r,onReset:o,isLoading:l,maximized:i,onMaximize:c,askMode:d,onModeSwitch:f,onClose:h,onDockToPanel:b,hideTitle:v,sessions:y,activeSessionId:j,onLoadSession:w,onDeleteSession:N,onRenameSession:S,onTogglePinSession:C,messages:A}){let{t:E}=(0,m.Y)(),R=y&&y.length>=2,z=e?"h-9 w-9 rounded-lg":"p-2 rounded-lg",T=y?.find(e=>e.id===j),$=T?k(T):null,[L,M]=(0,s.useState)(!1),D=(0,s.useRef)(null),_=(0,s.useRef)(null),[P,F]=(0,s.useState)(null),[I,O]=(0,s.useState)(""),H=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(!L)return;let e=e=>{let t=e.target;D.current&&!D.current.contains(t)&&_.current&&!_.current.contains(t)&&(M(!1),F(null))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[L]),(0,s.useEffect)(()=>{if(!L)return;let e=e=>{"Escape"===e.key&&(P?F(null):M(!1))};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[L,P]),(0,s.useEffect)(()=>{P&&setTimeout(()=>H.current?.focus(),0)},[P]);let W=(0,s.useCallback)(e=>{w?.(e),M(!1)},[w]),B=(0,s.useCallback)((e,t)=>{F(e),O("(empty session)"===t?"":t)},[]),U=(0,s.useCallback)(()=>{P&&S&&I.trim()&&S(P,I.trim()),F(null)},[P,I,S]),[Y,J]=(0,s.useState)(null);(0,s.useEffect)(()=>{if(!L||!D.current)return;let e=D.current.getBoundingClientRect();J({top:e.bottom+4,left:e.left,width:Math.max(e.width,280)})},[L]);let K=L&&Y&&y?(0,a.createPortal)((0,n.jsx)("div",{ref:_,className:"fixed z-50 rounded-xl border border-border/50 bg-card shadow-lg py-1 animate-in fade-in-0 slide-in-from-top-1 duration-100 max-h-[60vh] overflow-y-auto",style:{top:Y.top,left:Y.left,minWidth:Math.max(Y.width,280),maxWidth:340},role:"listbox",children:y.map(e=>{let t=e.id===j,r=k(e),s="(empty session)"===r?E.hints?.newChat??"New chat":r;return P===e.id?(0,n.jsx)("div",{className:"flex items-center gap-1 px-2 py-1.5",children:(0,n.jsx)("input",{ref:H,type:"text",value:I,onChange:e=>O(e.target.value),onKeyDown:e=>{"Enter"===e.key&&U(),"Escape"===e.key&&F(null)},onBlur:U,className:"flex-1 min-w-0 px-2 py-1 text-xs rounded-md border border-border bg-background text-foreground outline-none focus-visible:border-[var(--amber)]/50",placeholder:"Session name..."})},e.id):(0,n.jsxs)("div",{className:"group/item flex items-center",children:[(0,n.jsxs)("button",{type:"button",role:"option","aria-selected":t,onClick:()=>W(e.id),className:`flex-1 min-w-0 flex items-center gap-2 px-3 py-2.5 text-xs text-left transition-colors ${t?"text-foreground font-medium":"text-muted-foreground hover:text-foreground hover:bg-muted/50"}`,children:[e.pinned&&(0,n.jsx)(es.A,{size:10,className:"shrink-0 text-[var(--amber)]/60 -rotate-45"}),t&&!e.pinned&&(0,n.jsx)(x.A,{size:11,className:"shrink-0 text-[var(--amber)]"}),(0,n.jsx)("span",{className:"truncate",children:s})]}),(0,n.jsxs)("div",{className:"shrink-0 flex items-center gap-0.5 mr-1 opacity-0 group-hover/item:opacity-100 transition-opacity",children:[C&&(0,n.jsx)("button",{type:"button",onClick:t=>{t.stopPropagation(),C(e.id)},className:`p-1.5 rounded-md transition-colors ${e.pinned?"text-[var(--amber)] hover:text-muted-foreground hover:bg-muted/60":"text-muted-foreground/40 hover:text-[var(--amber)] hover:bg-[var(--amber)]/5"}`,"aria-label":e.pinned?"Unpin":"Pin",children:e.pinned?(0,n.jsx)(eZ.A,{size:10}):(0,n.jsx)(es.A,{size:10})}),S&&(0,n.jsx)("button",{type:"button",onClick:t=>{t.stopPropagation(),B(e.id,r)},className:"p-1.5 rounded-md text-muted-foreground/40 hover:text-foreground hover:bg-muted/60","aria-label":`Rename: ${s}`,children:(0,n.jsx)(er.A,{size:10})}),y.length>1&&N&&(0,n.jsx)("button",{type:"button",onClick:t=>{t.stopPropagation(),N(e.id)},className:"p-1.5 rounded-md text-muted-foreground/40 hover:text-error hover:bg-error/5","aria-label":`Delete: ${s}`,children:(0,n.jsx)(ea.A,{size:10})})]})]},e.id)})}),document.body):null;return(0,n.jsxs)("div",{className:`flex items-center justify-between px-4 shrink-0 ${e?"py-1.5":"py-2.5"}`,children:[!e&&(0,n.jsx)("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 w-8 h-1 rounded-full bg-muted-foreground/20 md:hidden"}),!v&&(0,n.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,n.jsx)("div",{className:"w-6 h-6 rounded-lg bg-[var(--amber)]/10 flex items-center justify-center shrink-0",children:t?(0,n.jsx)(ei.A,{size:13,className:"text-[var(--amber)]"}):(0,n.jsx)(p.A,{size:13,className:"text-[var(--amber)]"})}),t?(0,n.jsx)("span",{className:"text-sm font-medium text-[var(--amber)]",children:E.ask?.sessionHistory??"Session History"}):R&&$?(0,n.jsxs)("button",{ref:D,type:"button",onClick:()=>{y&&y.length>=2?M(e=>!e):r()},className:`flex items-center gap-1 min-w-0 text-sm font-medium text-[var(--amber)] hover:text-[var(--amber)]/80 hover:bg-muted/40 transition-colors ${e?"min-h-9 rounded-lg px-2":"rounded-lg"}`,"aria-expanded":L,"aria-haspopup":"listbox",children:[(0,n.jsx)("span",{className:"truncate max-w-[180px]",children:"(empty session)"===$?E.hints?.newChat??"New chat":$}),(0,n.jsx)(g.A,{size:12,className:`shrink-0 text-muted-foreground transition-transform duration-150 ${L?"rotate-180":""}`})]}):$?(0,n.jsx)("span",{className:"text-sm font-medium text-muted-foreground/60 truncate max-w-[180px]",children:"(empty session)"===$?E.hints?.newChat??"New chat":$}):(0,n.jsx)("span",{className:"text-sm font-medium text-muted-foreground/40",children:E.hints?.newChat??"New chat"})]}),v&&(0,n.jsx)("div",{}),(0,n.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,n.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),r()},"aria-pressed":t,className:`${z} inline-flex items-center justify-center transition-colors ${t?"bg-[var(--amber)]/10 text-[var(--amber)]":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,title:E.hints.sessionHistory,children:(0,n.jsx)(ei.A,{size:14})}),A&&A.length>0&&(0,n.jsx)(ez,{messages:A,disabled:l}),(0,n.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),o()},disabled:l,className:`${z} inline-flex items-center justify-center hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-40`,title:E.hints.newSession,children:(0,n.jsx)(eX.A,{size:14})}),c&&(0,n.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),c()},className:`${z} inline-flex items-center justify-center hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,title:i?E.hints.restorePanel:E.hints.maximizePanel,children:i?(0,n.jsx)(e1.A,{size:14}):(0,n.jsx)(e2.A,{size:14})}),b&&(0,n.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),b()},className:`${z} inline-flex items-center justify-center hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,title:E.hints.dockToSide??"Dock to side panel",children:(0,n.jsx)(e5.A,{size:14})}),f&&(0,n.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),f()},className:`${z} inline-flex items-center justify-center hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,title:"popup"===d?E.hints.dockToSide:E.hints.openAsPopup,children:"popup"===d?(0,n.jsx)(e5.A,{size:14}):(0,n.jsx)(e3.A,{size:14})}),h&&(0,n.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),h()},className:`${z} inline-flex items-center justify-center hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,title:E.hints.closePanel,"aria-label":"Close",children:(0,n.jsx)(u.A,{size:14})})]}),"u">typeof document&&K]})});var e8=r(38798);let e6={kb:{icon:l.A,cls:"text-muted-foreground"},upload:{icon:F.A,cls:"text-muted-foreground"},image:{icon:i.A,cls:"text-muted-foreground"},skill:{icon:P.A,cls:"text-[var(--amber)]"},agent:{icon:I.A,cls:"text-[var(--amber)]"}},e9={kb:"border-border/60 bg-muted/70 text-foreground shadow-sm",upload:"border-border/60 bg-muted/70 text-foreground shadow-sm",image:"border-border/60 bg-muted/70 text-foreground shadow-sm",skill:"border-[var(--amber)]/35 bg-[var(--amber)]/12 text-foreground shadow-sm",agent:"border-[var(--amber)]/35 bg-[var(--amber)]/12 text-foreground shadow-sm"};function e7({path:e,onRemove:t,variant:r="kb",imageData:o,imageMime:l,status:i,error:c,truncatedInfo:d}){let[m,f]=(0,s.useState)(!1),[p,x]=(0,s.useState)(!1),[g,h]=(0,s.useState)(!1),b=(0,s.useRef)(null),[v,y]=(0,s.useState)(null),[j,w]=(0,s.useState)(null);(0,s.useEffect)(()=>h(!0),[]);let k="kb"===r&&e.endsWith("/"),N=k?e.slice(0,-1):e,S=N.split("/").pop()??N,C="kb"===r&&!k&&S.endsWith(".csv"),{icon:A,cls:E}=k?{icon:e8.A,cls:"text-yellow-400"}:C?{icon:ec.A,cls:"text-success"}:e6[r],R=!!d,z=null,T="";"loading"===i?(z=O.A,T="text-muted-foreground animate-spin"):"error"===i?(z=J.A,T="text-destructive"):R?(z=em.A,T="text-[var(--amber)]"):"success"===i&&(z=ef.A,T="text-emerald-500");let $="error"===i?"border-destructive/40 bg-destructive/8 text-foreground shadow-sm":R?"border-[var(--amber)]/40 bg-[var(--amber)]/8 text-foreground shadow-sm":e9[r],L=null;if("error"===i&&c)L=c;else if(R){let e=d.totalChars>0?Math.round(d.includedChars/d.totalChars*100):0;L=`Document truncated — only ${e}% included (${Math.round(d.includedChars/1e3)}K / ${Math.round(d.totalChars/1e3)}K chars, ${d.totalPages} pages total)`}(0,s.useEffect)(()=>{if(!m||!b.current)return void y(null);let e=b.current.getBoundingClientRect();y({top:e.top-8,left:e.left})},[m]),(0,s.useEffect)(()=>{if(!p||!b.current)return void w(null);let e=b.current.getBoundingClientRect();w({top:e.top-8,left:e.left})},[p]);let M=m&&v&&o&&l?(0,n.jsx)("div",{className:"fixed z-50 p-1 rounded-lg border border-border bg-card shadow-lg pointer-events-none",style:{left:v.left,bottom:window.innerHeight-v.top},children:(0,n.jsx)("img",{src:`data:${l};base64,${o}`,alt:S,className:"max-h-48 max-w-64 rounded object-contain"})}):null,D=p&&j&&L?(0,n.jsx)("div",{className:`fixed z-50 px-2.5 py-1.5 rounded-lg border bg-card text-xs shadow-lg pointer-events-none max-w-[280px] ${"error"===i?"border-destructive/20 text-destructive":"border-[var(--amber)]/20 text-[var(--amber-text)]"}`,style:{left:j.left,bottom:window.innerHeight-j.top},children:L}):null;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("span",{ref:b,className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-xs border max-w-[220px] ${$}`,onMouseEnter:()=>{o&&f(!0),L&&x(!0)},onMouseLeave:()=>{f(!1),x(!1)},children:[(0,n.jsx)(A,{size:11,className:`${E} shrink-0`}),(0,n.jsx)("span",{className:"truncate",title:k?N:e,children:S}),z&&(0,n.jsx)(z,{size:10,className:`${T} shrink-0`}),(0,n.jsx)("button",{type:"button",onClick:t,"aria-label":`Remove ${S}`,className:"p-0.5 -mr-1 rounded hover:text-foreground transition-colors shrink-0 text-muted-foreground",children:(0,n.jsx)(u.A,{size:10})})]}),g&&M&&(0,a.createPortal)(M,document.body),g&&D&&(0,a.createPortal)(D,document.body)]})}function te({selectedAgent:e,onSelect:t,installedAgents:r,loading:o=!1}){let{t:l}=(0,m.Y)(),i=l.panels?.agents??{acpDefaultAgent:"MindOS",acpSelectAgent:"Select Agent",acpChangeAgent:"Change agent"},[c,d]=(0,s.useState)(!1),[f,p]=(0,s.useState)(null),h=(0,s.useRef)(null),b=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(!c||!h.current)return;let e=h.current.getBoundingClientRect(),t=e.top,r=t>window.innerHeight-e.bottom&&t>200?"up":"down";p({left:e.left,top:"up"===r?e.top-6:e.bottom+6,direction:r})},[c]),(0,s.useEffect)(()=>{if(!c)return;let e=e=>{let t=e.target;h.current&&!h.current.contains(t)&&b.current&&!b.current.contains(t)&&d(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[c]),(0,s.useEffect)(()=>{if(!c)return;let e=e=>{"Escape"===e.key&&d(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[c]),(0,s.useEffect)(()=>{if(!c||!h.current)return;let e=()=>{if(!h.current)return;let e=h.current.getBoundingClientRect(),t=e.top,r=t>window.innerHeight-e.bottom&&t>200?"up":"down";p({left:e.left,top:"up"===r?e.top-6:e.bottom+6,direction:r})};return window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[c]);let v=(0,s.useCallback)(()=>{t(null),d(!1)},[t]),y=(0,s.useCallback)(e=>{t({id:e.id,name:e.name}),d(!1)},[t]),j=(0,s.useCallback)(e=>{e.stopPropagation(),t(null)},[t]),w=!e,k=e?.name??i.acpDefaultAgent,N=c&&f?(0,n.jsxs)("div",{ref:b,role:"listbox","aria-label":i.acpSelectAgent,className:"fixed z-50 min-w-[180px] max-w-[240px] rounded-lg border border-border bg-card shadow-lg py-1 animate-in fade-in-0 zoom-in-95 duration-100",style:{left:f.left,..."up"===f.direction?{bottom:window.innerHeight-f.top}:{top:f.top}},children:[(0,n.jsxs)("button",{type:"button",role:"option","aria-selected":w,onClick:v,className:"flex w-full items-center gap-2 px-3 py-1.5 text-xs text-left transition-colors hover:bg-muted",children:[(0,n.jsx)(I.A,{size:12,className:"shrink-0 text-muted-foreground"}),(0,n.jsx)("span",{className:"flex-1 truncate font-medium",children:i.acpDefaultAgent}),w&&(0,n.jsx)(x.A,{size:11,className:"shrink-0 text-[var(--amber)]"})]}),r.length>0&&(0,n.jsx)("div",{className:"mx-2 my-1 border-t border-border/60"}),r.map(t=>{let r=e?.id===t.id;return(0,n.jsxs)("button",{type:"button",role:"option","aria-selected":r,onClick:()=>y(t),className:"flex w-full items-center gap-2 px-3 py-1.5 text-xs text-left transition-colors hover:bg-muted",children:[(0,n.jsx)("span",{className:"w-2 h-2 rounded-full bg-[var(--success)] shrink-0"}),(0,n.jsx)("span",{className:"flex-1 truncate",children:t.name}),r&&(0,n.jsx)(x.A,{size:11,className:"shrink-0 text-[var(--amber)]"})]},t.id)})]}):null;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("button",{ref:h,type:"button",onClick:()=>d(e=>!e),className:`
|
|
19
|
+
${e}`}(e),source:"user"})}),v(!0),ek.oR.success(o?.savedToKB?.replace("{path}",k.split("/").pop())??"Saved"),setTimeout(a,1e3)}catch(e){j(e?.message?.includes("exist")?o?.fileExistsSwitch??"File exists":e?.message??"Failed")}finally{h(!1)}},[e,k,o,a]);return(0,n.jsxs)("div",{className:"p-3 space-y-2",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,n.jsx)(W.A,{size:11,className:"text-[var(--amber)]"}),(0,n.jsx)("span",{className:"text-xs font-semibold",children:o?.saveToKBTitle??"Save to KB"})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"text-2xs text-muted-foreground mb-0.5 block",children:o?.targetFolder??"Folder"}),(0,n.jsx)(eN.A,{dirPaths:r,value:d,onChange:m,rootLabel:"Root"})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"text-2xs text-muted-foreground mb-0.5 block",children:o?.fileName??"Filename"}),(0,n.jsx)("input",{ref:w,type:"text",value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{"Enter"===e.key&&N(),"Escape"===e.key&&a()},className:"w-full px-2 py-1 text-xs font-mono rounded-md border border-border bg-background text-foreground outline-none focus-visible:border-[var(--amber)]/50"})]}),(0,n.jsx)("div",{className:"text-[10px] text-muted-foreground/60 font-mono truncate",children:k}),y&&(0,n.jsxs)("div",{className:"flex items-center gap-1 text-2xs text-error",children:[(0,n.jsx)(J.A,{size:10}),y]}),(0,n.jsxs)("div",{className:"flex justify-end gap-1.5 pt-1 border-t border-border/30",children:[(0,n.jsx)("button",{type:"button",onClick:a,className:"px-2 py-0.5 text-2xs rounded text-muted-foreground hover:bg-muted",children:o?.cancelSave??"Cancel"}),(0,n.jsxs)("button",{type:"button",onClick:N,disabled:g||b||!f.trim(),className:`flex items-center gap-1 px-2.5 py-0.5 text-2xs font-medium rounded transition-colors ${b?"bg-success/10 text-success":"bg-[var(--amber)] text-[var(--amber-foreground)]"} disabled:opacity-50`,children:[g&&(0,n.jsx)(O.A,{size:9,className:"animate-spin"}),b&&(0,n.jsx)(x.A,{size:9}),o?.confirmSave??"Save"]})]})]})}function eL({anchorRef:e,messages:t,onClose:r}){let{t:a}=(0,m.Y)(),o=a.ask,[l,i]=(0,s.useState)("select"),[u,c]=(0,s.useState)([]);return(0,s.useEffect)(()=>{(0,ew.n)("/api/file?op=dirs").then(e=>c(e.dirs??[])).catch(()=>{})},[]),(0,n.jsxs)(eT,{anchorRef:e,onClose:r,children:["select"===l&&(0,n.jsx)(eM,{messages:t,onSelect:i,onClose:r,ask:o}),"archive"===l&&(0,n.jsx)(eD,{messages:t,dirPaths:u,onBack:()=>i("select"),onClose:r,ask:o}),"digest"===l&&(0,n.jsx)(e_,{messages:t,onClose:r,ask:o})]})}function eM({messages:e,onSelect:t,onClose:r,ask:s}){let a=eC(e,"full");return(0,n.jsxs)("div",{className:"p-3",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-2.5",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,n.jsx)(W.A,{size:11,className:"text-[var(--amber)]"}),(0,n.jsx)("span",{className:"text-xs font-semibold text-foreground",children:s?.saveSession??"Save Session"}),(0,n.jsxs)("span",{className:"text-2xs text-muted-foreground",children:["(",a.msgCount,")"]})]}),(0,n.jsx)("button",{type:"button",onClick:r,className:"text-2xs text-muted-foreground hover:text-foreground",children:s?.cancelSave??"Cancel"})]}),(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>t("archive"),className:"flex flex-col items-center gap-1 p-2.5 border border-[var(--amber)]/30 rounded-lg hover:border-[var(--amber)]/60 hover:shadow-sm active:scale-[0.98] transition-all",children:[(0,n.jsx)(W.A,{size:16,className:"text-[var(--amber)]"}),(0,n.jsx)("span",{className:"text-2xs font-medium text-foreground",children:s?.saveDirectly??"Save directly"}),(0,n.jsx)("span",{className:"text-[10px] text-muted-foreground text-center leading-tight",children:s?.saveDirectlyDesc??"Save as-is"})]}),(0,n.jsxs)("button",{type:"button",onClick:()=>t("digest"),className:"flex flex-col items-center gap-1 p-2.5 border border-border rounded-lg hover:border-[var(--amber)]/50 hover:shadow-sm active:scale-[0.98] transition-all",children:[(0,n.jsx)(p.A,{size:16,className:"text-[var(--amber)]"}),(0,n.jsx)("span",{className:"text-2xs font-medium text-foreground",children:s?.organizeToNote??"Organize to note"}),(0,n.jsx)("span",{className:"text-[10px] text-muted-foreground text-center leading-tight",children:s?.organizeToNoteDesc??"AI extracts insights"})]})]})]})}function eD({messages:e,dirPaths:t,onBack:r,onClose:a,ask:o}){let l,i,u=new Date,c=`session-${u.getFullYear()}-${String(u.getMonth()+1).padStart(2,"0")}-${String(u.getDate()).padStart(2,"0")}.md`,[d,m]=(0,s.useState)(""),[f,p]=(0,s.useState)(c),[h,b]=(0,s.useState)("full"),[v,y]=(0,s.useState)(!1),[j,w]=(0,s.useState)(!1),[k,N]=(0,s.useState)(!1),[S,C]=(0,s.useState)(""),A=(0,s.useRef)(null);(0,s.useEffect)(()=>{setTimeout(()=>{A.current?.focus(),A.current?.select()},100)},[]);let E=(i=(l=f.trim()||c).endsWith(".md")?l:`${l}.md`,d?`${d}/${i}`:i),R=eC(e,h),z=(0,s.useCallback)(async()=>{w(!0),C("");try{await (0,ew.n)("/api/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:E,op:"create_file",content:eS(e,h),source:"user"})}),N(!0),ek.oR.success(o?.savedToKB?.replace("{path}",E.split("/").pop())??"Saved"),setTimeout(a,1e3)}catch(e){C(e?.message?.includes("exist")?o?.fileExistsSwitch??"File exists":e?.message??"Failed")}finally{w(!1)}},[e,h,E,o,a]),T=eS(e,h).slice(0,300);return(0,n.jsxs)("div",{className:"p-3 space-y-2",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,n.jsx)("button",{type:"button",onClick:r,className:"text-muted-foreground hover:text-foreground",children:(0,n.jsx)(ed.A,{size:11,className:"rotate-180"})}),(0,n.jsx)(W.A,{size:11,className:"text-[var(--amber)]"}),(0,n.jsx)("span",{className:"text-xs font-semibold",children:o?.saveDirectly??"Save directly"})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"text-2xs text-muted-foreground mb-0.5 block",children:o?.targetFolder??"Folder"}),(0,n.jsx)(eN.A,{dirPaths:t,value:d,onChange:m,rootLabel:"Root"})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"text-2xs text-muted-foreground mb-0.5 block",children:o?.fileName??"Filename"}),(0,n.jsx)("input",{ref:A,type:"text",value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{"Enter"===e.key&&z(),"Escape"===e.key&&a()},className:"w-full px-2 py-1 text-xs font-mono rounded-md border border-border bg-background text-foreground outline-none focus-visible:border-[var(--amber)]/50"})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2.5",children:[["full","ai-only"].map(e=>(0,n.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,n.jsx)("input",{type:"radio",name:"fmt",checked:h===e,onChange:()=>b(e),className:"w-2.5 h-2.5 accent-[var(--amber)]"}),(0,n.jsx)("span",{className:"text-2xs",children:"full"===e?o?.formatFull??"Full":o?.formatAiOnly??"AI only"})]},e)),(0,n.jsxs)("span",{className:"text-[10px] text-muted-foreground ml-auto",children:[R.msgCount," msgs"]})]}),(0,n.jsxs)("button",{type:"button",onClick:()=>y(e=>!e),className:"flex items-center gap-0.5 text-[10px] text-muted-foreground hover:text-foreground",children:[v?(0,n.jsx)(g.A,{size:9}):(0,n.jsx)(ed.A,{size:9})," Preview"]}),v&&(0,n.jsxs)("pre",{className:"px-2 py-1 text-[10px] text-muted-foreground bg-muted/30 rounded-md max-h-24 overflow-auto whitespace-pre-wrap font-mono",children:[T,T.length>=300?"...":""]}),(0,n.jsx)("div",{className:"text-[10px] text-muted-foreground/60 font-mono truncate",children:E}),S&&(0,n.jsxs)("div",{className:"flex items-center gap-1 text-2xs text-error",children:[(0,n.jsx)(J.A,{size:10}),S]}),(0,n.jsxs)("div",{className:"flex justify-end gap-1.5 pt-1 border-t border-border/30",children:[(0,n.jsx)("button",{type:"button",onClick:a,className:"px-2 py-0.5 text-2xs rounded text-muted-foreground hover:bg-muted",children:o?.cancelSave??"Cancel"}),(0,n.jsxs)("button",{type:"button",onClick:z,disabled:j||k||!f.trim(),className:`flex items-center gap-1 px-2.5 py-0.5 text-2xs font-medium rounded transition-colors ${k?"bg-success/10 text-success":"bg-[var(--amber)] text-[var(--amber-foreground)]"} disabled:opacity-50`,children:[j&&(0,n.jsx)(O.A,{size:9,className:"animate-spin"}),k&&(0,n.jsx)(x.A,{size:9}),o?.confirmSave??"Save"]})]})]})}function e_({messages:e,onClose:t,ask:r}){let n=(0,s.useCallback)(()=>{let n=eS(e,"full");window.dispatchEvent(new CustomEvent("mindos:session-organize",{detail:{content:n,name:"conversation.md"}})),t(),ek.oR.success(r?.organizing??"AI is organizing...")},[e,t,r]);return(0,s.useEffect)(()=>{n()},[n]),null}var eP=r(9199);function eF({label:e,delay:t=800,children:r}){let[a,o]=(0,s.useState)(!1),l=(0,s.useRef)(null),i=(0,s.useCallback)(()=>{l.current=setTimeout(()=>o(!0),t)},[t]),u=(0,s.useCallback)(()=>{l.current&&(clearTimeout(l.current),l.current=null),o(!1)},[]);return(0,n.jsxs)("span",{className:"relative inline-flex",onMouseEnter:i,onMouseLeave:u,children:[r,a&&(0,n.jsx)("span",{role:"tooltip",className:"pointer-events-none absolute -top-8 left-1/2 -translate-x-1/2 whitespace-nowrap rounded-md bg-foreground/90 px-2 py-0.5 text-[11px] font-medium text-background shadow-sm animate-in fade-in-0 slide-in-from-bottom-1 duration-100 z-20",children:e})]})}function eI({content:e,isLastUserMessage:t,isLoading:r,onEdit:a,onResend:o,labels:l}){let[i,u]=(0,s.useState)(!1),c=(0,s.useRef)(!1),d=(0,s.useCallback)(()=>{(0,Z.l)(e).then(e=>{e&&(u(!0),setTimeout(()=>u(!1),2e3))})},[e]),m=(0,s.useCallback)(()=>{c.current||r||(c.current=!0,setTimeout(()=>{c.current=!1},300),o?.())},[o,r]),f="p-1 rounded-md bg-card border border-border/60 shadow-sm text-muted-foreground transition-colors";return(0,n.jsxs)("div",{className:"absolute -bottom-1 left-1 z-10 flex items-center gap-1 opacity-100 md:opacity-0 md:group-hover:opacity-100 transition-opacity",children:[(0,n.jsx)(eF,{label:l.copy,children:(0,n.jsx)("button",{type:"button",onClick:d,className:`${f} hover:text-foreground`,children:i?(0,n.jsx)(x.A,{size:11,className:"text-success"}):(0,n.jsx)(_.A,{size:11})})}),t&&!r&&a&&(0,n.jsx)(eF,{label:l.edit,children:(0,n.jsx)("button",{type:"button",onClick:a,className:`${f} hover:text-foreground`,children:(0,n.jsx)(U.A,{size:11})})}),t&&!r&&o&&(0,n.jsx)(eF,{label:l.regenerate,children:(0,n.jsx)("button",{type:"button",onClick:m,className:`${f} hover:text-[var(--amber)]`,children:(0,n.jsx)(eP.A,{size:11})})})]})}let eO=/^Use the skill ([^:]+):\s*/;function eH({text:e,label:t}){let[r,a]=(0,s.useState)(!1),o=(0,s.useCallback)(()=>{(0,Z.l)(e).then(e=>{e&&(a(!0),setTimeout(()=>a(!1),2e3))})},[e]);return(0,n.jsx)("button",{type:"button",onClick:o,className:"p-1 rounded-md bg-card border border-border/60 shadow-sm text-muted-foreground hover:text-foreground transition-colors",title:t??"Copy",children:r?(0,n.jsx)(x.A,{size:11,className:"text-success"}):(0,n.jsx)(_.A,{size:11})})}function eW({content:e,skillName:t,images:r,attachedFiles:s,uploadedFileNames:a}){let o=t??e.match(eO)?.[1],i=e.match(eO),u=i?e.slice(i[0].length):e,c=new Set(a??[]),d=s?.filter(e=>!c.has(e.split("/").pop()??e)),m=d&&d.length>0||a&&a.length>0;return(0,n.jsxs)(n.Fragment,{children:[r&&r.length>0&&(0,n.jsx)("div",{className:`flex flex-wrap gap-1.5${e?" mb-2":""}`,children:r.map((e,t)=>e.data?(0,n.jsx)("img",{src:`data:${e.mimeType};base64,${e.data}`,alt:`Image ${t+1}`,className:"max-h-48 max-w-full rounded-md object-contain"},t):(0,n.jsx)("div",{className:"h-12 px-3 rounded-md bg-muted flex items-center gap-1.5 text-xs text-muted-foreground",children:(0,n.jsxs)("span",{children:["[Image ",t+1,"]"]})},t))}),o&&(0,n.jsxs)("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[11px] font-medium bg-white/20 text-white/90 mr-1 align-middle",children:[(0,n.jsx)(P.A,{size:10,className:"shrink-0"}),o]}),o?u:e,m&&(0,n.jsxs)("div",{className:"mt-2 pt-1.5 border-t border-white/15 flex flex-wrap gap-1 whitespace-normal",role:"list","aria-label":"Attached files",children:[d?.map(e=>(0,n.jsxs)("span",{role:"listitem",className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] bg-white/10 text-white/80 min-w-0",title:e,children:[(0,n.jsx)(l.A,{size:9,className:"shrink-0 opacity-70"}),(0,n.jsx)("span",{className:"truncate max-w-[120px]",children:e.split("/").pop()})]},e)),a?.map(e=>(0,n.jsxs)("span",{role:"listitem",className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] bg-white/10 text-white/80 min-w-0",title:e,children:[(0,n.jsx)(F.A,{size:9,className:"shrink-0 opacity-70"}),(0,n.jsx)("span",{className:"truncate max-w-[120px]",children:e})]},e))]})]})}function eB({agentName:e}){return e?(0,n.jsxs)("div",{className:"mb-2 inline-flex items-center gap-1 rounded-full border border-[var(--amber)]/15 bg-[var(--amber)]/8 px-2 py-0.5 text-[10px] font-medium tracking-wide text-[var(--amber)]",children:[(0,n.jsx)(I.A,{size:10,className:"shrink-0"}),(0,n.jsx)("span",{children:e})]}):null}function eU({content:e,isStreaming:t}){let r=(0,X.Oo)(e);return r||t?(0,n.jsxs)("div",{className:"prose prose-sm prose-panel dark:prose-invert max-w-none text-foreground prose-p:my-2 prose-p:leading-relaxed prose-headings:font-semibold prose-headings:my-3 prose-h1:text-base prose-h2:text-[15px] prose-h3:text-sm prose-ul:my-1.5 prose-li:my-0.5 prose-ol:my-1.5 prose-code:text-[0.8em] prose-code:bg-muted/80 prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded-md prose-code:before:content-none prose-code:after:content-none prose-code:font-mono prose-pre:bg-muted/60 prose-pre:text-foreground prose-pre:text-xs prose-pre:rounded-lg prose-blockquote:border-l-[var(--amber)] prose-blockquote:text-muted-foreground prose-blockquote:not-italic prose-a:text-[var(--amber)] prose-a:no-underline hover:prose-a:underline prose-strong:text-foreground prose-strong:font-semibold prose-table:text-xs prose-th:py-1.5 prose-td:py-1 ",children:[(0,n.jsx)(Q.oz,{remarkPlugins:[V.A],children:r}),t&&(0,n.jsx)("span",{className:"inline-block w-1.5 h-3.5 bg-[var(--amber)] ml-0.5 align-middle animate-pulse rounded-full"})]}):null}function eY({message:e,isStreaming:t}){let r=e.parts;if(!r||0===r.length)return e.content?(0,n.jsx)(eU,{content:e.content,isStreaming:t}):null;let s=r[r.length-1],a=t&&"tool-call"===s.type&&("running"===s.state||"pending"===s.state);return(0,n.jsxs)("div",{children:[r.map((e,s)=>{if("reasoning"===e.type){let a=t&&s===r.length-1;return(0,n.jsx)(ej,{text:e.text,isStreaming:a},`reasoning-${s}`)}if("text"===e.type){let a=t&&s===r.length-1;return e.text?(0,n.jsx)(eU,{content:e.text,isStreaming:a},s):null}return"tool-call"===e.type?(0,n.jsx)(ev,{part:e},e.toolCallId):null}),a&&(0,n.jsxs)("div",{className:"flex items-center gap-2 py-1.5 mt-1.5",children:[(0,n.jsx)(O.A,{size:12,className:"animate-spin text-[var(--amber)]"}),(0,n.jsx)("span",{className:"text-xs text-muted-foreground animate-pulse",children:"Executing tool…"})]})]})}function eJ({parts:e}){if(!e)return null;let t=e.filter(e=>"tool-call"===e.type);if(0===t.length)return null;let r=t[t.length-1],s="tool-call"===r.type?r.toolName:"";return(0,n.jsxs)("div",{className:"flex items-center gap-1.5 mt-2 pt-1.5 border-t border-border/15 text-xs text-muted-foreground/60",children:[(0,n.jsx)(H.A,{size:10}),(0,n.jsxs)("span",{className:"font-medium",children:["Step ",t.length,s?` — ${s}`:""]})]})}let eK=(0,s.memo)(function({messages:e,isLoading:t,loadingPhase:r,emptyPrompt:a,emptyHint:o,suggestions:l,onSuggestionClick:i,onEditMessage:u,onResendMessage:c,labels:d}){let m=(0,s.useRef)(null),f=(0,s.useRef)(null),[x,g]=(0,s.useState)(!1),h=(0,s.useRef)(!1),b=(0,s.useRef)(e.length),v=(0,s.useMemo)(()=>{for(let t=e.length-1;t>=0;t--)if("user"===e[t].role)return t;return -1},[e]),y=(0,s.useCallback)((e="smooth")=>{let t=f.current;t&&t.scrollTo({top:t.scrollHeight,behavior:e})},[]);return(0,s.useEffect)(()=>{let t=e.length,r=t>b.current;if(b.current=t,r){h.current=!1,y("instant");return}h.current||y("instant")},[e,y]),(0,s.useEffect)(()=>{let e=f.current;if(!e)return;let t=!1,r=()=>{t||(t=!0,requestAnimationFrame(()=>{let{scrollTop:r,scrollHeight:n,clientHeight:s}=e,a=n-r-s;g(a>100),a<80&&(h.current=!1),t=!1}))},n=e=>{e.deltaY<0&&(h.current=!0)},s=0,a=e=>{s=e.touches[0]?.clientY??0},o=e=>{(e.touches[0]?.clientY??0)>s&&(h.current=!0)},l=e=>{["ArrowUp","PageUp","Home"].includes(e.key)&&(h.current=!0)};return e.addEventListener("scroll",r,{passive:!0}),e.addEventListener("wheel",n,{passive:!0}),e.addEventListener("touchstart",a,{passive:!0}),e.addEventListener("touchmove",o,{passive:!0}),e.addEventListener("keydown",l),()=>{e.removeEventListener("scroll",r),e.removeEventListener("wheel",n),e.removeEventListener("touchstart",a),e.removeEventListener("touchmove",o),e.removeEventListener("keydown",l)}},[]),(0,n.jsxs)("div",{ref:f,role:"log","aria-live":"polite",className:"relative flex-1 overflow-y-auto overflow-x-hidden px-4 py-5 space-y-5 min-h-0",children:[0===e.length&&(0,n.jsxs)("div",{className:"flex flex-col items-center justify-center flex-1 min-h-[260px] px-6 pt-10 pb-4",children:[(0,n.jsxs)("div",{className:"relative w-12 h-12 rounded-2xl bg-[var(--amber)]/10 flex items-center justify-center mb-6",children:[(0,n.jsx)("div",{className:"absolute inset-0 rounded-2xl bg-[var(--amber)]/5 scale-[1.4]"}),(0,n.jsx)(p.A,{size:22,className:"text-[var(--amber)] relative z-10"})]}),(0,n.jsx)("p",{className:"text-center text-[15px] font-semibold text-foreground tracking-tight mb-2",children:a}),o&&(0,n.jsx)("p",{className:"text-center text-xs text-muted-foreground/80 mb-10 tracking-wide",children:o}),(0,n.jsx)("div",{className:"flex flex-col gap-2.5 max-w-[280px] w-full",children:l.map((e,t)=>{let r=[W.A,B.A,U.A,Y.A],s=r[t%r.length];return(0,n.jsxs)("button",{type:"button",onClick:()=>i(e.prompt),className:"group/sug flex items-center gap-3 text-left text-[13px] px-3.5 py-3 rounded-xl border border-border/40 bg-transparent text-muted-foreground hover:text-foreground hover:border-[var(--amber)]/30 hover:bg-[var(--amber)]/5 transition-all leading-snug","aria-label":e.prompt,children:[(0,n.jsx)("span",{className:"shrink-0 w-8 h-8 rounded-lg bg-muted/60 flex items-center justify-center group-hover/sug:bg-[var(--amber)]/10 transition-colors",children:(0,n.jsx)(s,{size:15,className:"text-muted-foreground/70 group-hover/sug:text-[var(--amber)] transition-colors"})}),(0,n.jsx)("span",{className:"flex-1",children:e.label})]},t)})})]}),e.map((s,a)=>(0,n.jsxs)("div",{className:`flex gap-3 animate-[fadeSlideUp_0.22s_ease_both] ${"user"===s.role?"justify-end":"justify-start"}`,children:["assistant"===s.role&&(0,n.jsx)("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center shrink-0 mt-0.5 bg-[var(--amber)]/8",children:(0,n.jsx)(p.A,{size:13,className:"text-[var(--amber)]"})}),"user"===s.role?(0,n.jsxs)("div",{className:"group relative max-w-[85%] px-3.5 py-2.5 rounded-2xl rounded-br-lg text-sm leading-relaxed whitespace-pre-wrap bg-[var(--amber)] text-[var(--amber-foreground)] shadow-sm shadow-[var(--amber)]/10",children:[(0,n.jsx)(eW,{content:s.content,skillName:s.skillName,images:s.images,attachedFiles:s.attachedFiles,uploadedFileNames:s.uploadedFileNames}),(0,n.jsx)(eI,{content:s.content,isLastUserMessage:a===v,isLoading:t,onEdit:u?()=>u(a):void 0,onResend:c?()=>c(a):void 0,labels:{copy:d.copyMessage??"Copy",edit:d.editMessage??"Edit",regenerate:d.regenerateMessage??"Regenerate"}})]}):s.content.startsWith("__error__")?(0,n.jsxs)("div",{className:"max-w-[85%] px-3.5 py-3 rounded-2xl rounded-bl-md border border-error/30 bg-error/10 text-sm shadow-sm",children:[(0,n.jsx)(eB,{agentName:s.agentName}),(0,n.jsxs)("div",{className:"flex items-start gap-2.5 text-error",children:[(0,n.jsx)(J.A,{size:15,className:"shrink-0 mt-0.5"}),(0,n.jsx)("span",{className:"leading-relaxed font-medium",children:s.content.slice(9)})]})]}):(0,n.jsxs)("div",{className:"group relative max-w-[85%] px-3.5 py-2.5 rounded-2xl rounded-bl-lg bg-card border border-border/30 shadow-sm text-foreground text-sm",children:[(0,n.jsx)(eB,{agentName:s.agentName}),s.parts&&s.parts.length>0||(0,X.Oo)(s.content)?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(eY,{message:s,isStreaming:t&&a===e.length-1}),t&&a===e.length-1&&(0,n.jsx)(eJ,{parts:s.parts}),!(t&&a===e.length-1)&&(0,X.Oo)(s.content)&&(0,n.jsxs)("div",{className:"absolute -bottom-1 right-1 z-10 flex items-center gap-1 opacity-100 md:opacity-0 md:group-hover:opacity-100 transition-opacity",children:[(0,n.jsx)(eA,{text:s.content}),(0,n.jsx)(eH,{text:(0,X.Oo)(s.content),label:d.copyMessage})]})]}):t&&a===e.length-1?(0,n.jsxs)("div",{className:"flex items-center gap-2.5 py-1",children:["reconnecting"===r?(0,n.jsx)(K.A,{size:14,className:"text-[var(--amber)] animate-pulse"}):(0,n.jsx)(O.A,{size:14,className:"animate-spin text-[var(--amber)]"}),(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:(0,n.jsxs)("span",{className:"inline-flex items-center gap-1",children:["reconnecting"===r?d.reconnecting??"Reconnecting...":"connecting"===r?d.connecting:"thinking"===r?d.thinking:d.generating,(0,n.jsxs)("span",{className:"inline-flex gap-0.5",children:[(0,n.jsx)("span",{className:"w-1 h-1 rounded-full bg-[var(--amber)] animate-bounce [animation-delay:0ms]"}),(0,n.jsx)("span",{className:"w-1 h-1 rounded-full bg-[var(--amber)] animate-bounce [animation-delay:150ms]"}),(0,n.jsx)("span",{className:"w-1 h-1 rounded-full bg-[var(--amber)] animate-bounce [animation-delay:300ms]"})]})]})})]}):null]})]},a)),(0,n.jsx)("div",{ref:m}),x&&e.length>0&&(0,n.jsx)("button",{type:"button",onClick:()=>{h.current=!1,y()},className:"sticky bottom-2 left-1/2 -translate-x-1/2 z-10 p-2 rounded-full border border-border/60 bg-card shadow-md text-muted-foreground hover:text-foreground hover:bg-muted transition-all hover:shadow-lg",title:"Scroll to bottom",children:(0,n.jsx)(q.A,{size:14})})]})});function eq({text:e,query:t}){if(!t)return(0,n.jsx)(n.Fragment,{children:e});let r=e.toLowerCase().indexOf(t.toLowerCase());return -1===r?(0,n.jsx)(n.Fragment,{children:e}):(0,n.jsxs)(n.Fragment,{children:[e.slice(0,r),(0,n.jsx)("span",{className:"text-[var(--amber)] font-semibold",children:e.slice(r,r+t.length)}),e.slice(r+t.length)]})}function eQ({results:e,selectedIndex:t,query:r,onSelect:a}){let o=(0,s.useRef)(null),i=(0,s.useRef)(null),[u,c]=(0,s.useState)(280);return((0,s.useEffect)(()=>{let e=i.current;e&&c(Math.max(120,Math.min(320,Math.min(e.getBoundingClientRect().top-8,.5*window.innerHeight)-80)))},[e.length]),(0,s.useEffect)(()=>{let e=o.current;if(!e)return;let r=e.children[t];r?.scrollIntoView({block:"nearest"})},[t]),0===e.length)?null:(0,n.jsxs)("div",{ref:i,className:"border border-border rounded-lg bg-card shadow-lg overflow-hidden",children:[(0,n.jsxs)("div",{className:"px-3 py-1.5 border-b border-border flex items-center gap-1.5",children:[(0,n.jsx)(ee.A,{size:11,className:"text-muted-foreground/50"}),(0,n.jsx)("span",{className:"text-2xs font-medium text-muted-foreground/70 uppercase tracking-wider",children:"Files"}),(0,n.jsx)("span",{className:"text-2xs text-muted-foreground/40 ml-auto",children:e.length})]}),(0,n.jsx)("div",{ref:o,className:"overflow-y-auto",style:{maxHeight:u},children:e.map((e,s)=>{let o=e.split("/").pop()??e,i=e.split("/").slice(0,-1).join("/"),u=o.endsWith(".csv");return(0,n.jsxs)("button",{type:"button",onMouseDown:t=>{t.preventDefault(),a(e)},className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${s===t?"bg-accent text-foreground":"text-muted-foreground hover:bg-muted"}`,children:[u?(0,n.jsx)(ec.A,{size:13,className:"text-success shrink-0"}):(0,n.jsx)(l.A,{size:13,className:"text-muted-foreground shrink-0"}),(0,n.jsx)("span",{className:"truncate font-medium flex-1",title:o,children:(0,n.jsx)(eq,{text:o,query:r})}),i&&(0,n.jsx)("span",{className:"text-2xs text-muted-foreground/40 truncate max-w-[140px] shrink-0",title:i,children:(0,n.jsx)(eq,{text:i,query:r})})]},e)})}),(0,n.jsxs)("div",{className:"px-3 py-1.5 border-t border-border flex gap-3 text-2xs text-muted-foreground/40 shrink-0",children:[(0,n.jsx)("span",{children:"↑↓ navigate"}),(0,n.jsx)("span",{children:"↵ select"}),(0,n.jsx)("span",{children:"ESC dismiss"})]})]})}function eV({results:e,selectedIndex:t,query:r,onSelect:a}){let o=(0,s.useRef)(null),l=(0,s.useRef)(null),[i,u]=(0,s.useState)(280);return((0,s.useEffect)(()=>{let e=l.current;e&&u(Math.max(120,Math.min(320,Math.min(e.getBoundingClientRect().top-8,.5*window.innerHeight)-80)))},[e.length]),(0,s.useEffect)(()=>{let e=o.current;if(!e)return;let r=e.children[t];r?.scrollIntoView({block:"nearest"})},[t]),0===e.length)?null:(0,n.jsxs)("div",{ref:l,className:"border border-border rounded-lg bg-card shadow-lg overflow-hidden",children:[(0,n.jsxs)("div",{className:"px-3 py-1.5 border-b border-border flex items-center gap-1.5",children:[(0,n.jsx)(P.A,{size:11,className:"text-[var(--amber)]/50"}),(0,n.jsx)("span",{className:"text-2xs font-medium text-muted-foreground/70 uppercase tracking-wider",children:"Skills"}),(0,n.jsx)("span",{className:"text-2xs text-muted-foreground/40 ml-auto",children:e.length})]}),(0,n.jsx)("div",{ref:o,className:"overflow-y-auto",style:{maxHeight:i},children:e.map((e,s)=>(0,n.jsxs)("button",{type:"button",onMouseDown:t=>{t.preventDefault(),a(e)},className:`w-full flex items-center gap-2.5 px-3 py-2 text-left transition-colors ${s===t?"bg-accent text-foreground":"text-muted-foreground hover:bg-muted"}`,children:[(0,n.jsx)(P.A,{size:13,className:"text-[var(--amber)] shrink-0"}),(0,n.jsxs)("span",{className:"text-sm font-medium shrink-0",children:["/",(0,n.jsx)(eq,{text:e.name,query:r})]}),e.description&&(0,n.jsx)("span",{className:"text-2xs text-muted-foreground/50 truncate min-w-0 flex-1",title:e.description,children:e.description})]},e.name))}),(0,n.jsxs)("div",{className:"px-3 py-1.5 border-t border-border flex gap-3 text-2xs text-muted-foreground/40 shrink-0",children:[(0,n.jsx)("span",{children:"↑↓ navigate"}),(0,n.jsx)("span",{children:"↵ / Tab select"}),(0,n.jsx)("span",{children:"ESC dismiss"})]})]})}var eX=r(89823),eZ=r(36261);function eG({sessions:e,activeSessionId:t,onLoad:r,onDelete:a,onRename:o,onTogglePin:l,onClearAll:i,onClose:c,onNewChat:d}){let{t:p}=(0,m.Y)(),[x,g]=(0,s.useTransition)(),h=p.ask,[b,v]=(0,s.useState)(""),[y,j]=(0,s.useState)(null),[w,N]=(0,s.useState)(""),[S,C]=(0,s.useState)(!1),A=(0,s.useRef)(void 0),E=(0,s.useRef)(null),R=(0,s.useRef)(null);(0,s.useEffect)(()=>{E.current?.focus()},[]),(0,s.useEffect)(()=>{y&&setTimeout(()=>R.current?.focus(),0)},[y]),(0,s.useEffect)(()=>()=>{A.current&&clearTimeout(A.current)},[]);let z=(0,s.useMemo)(()=>{if(!b.trim())return e;let t=b.toLowerCase();return e.filter(e=>!!k(e).toLowerCase().includes(t)||e.messages.some(e=>e.content.toLowerCase().includes(t)))},[e,b]),T=(0,s.useMemo)(()=>{let e=[],t=[],r=[],n=[],s=[];for(let a of z){if(a.pinned){e.push(a);continue}let o=function(e){let t=new Date,r=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),n=r-864e5*t.getDay();return e>=r?"today":e>=r-864e5?"yesterday":e>=n?"week":"older"}(a.updatedAt);"today"===o?t.push(a):"yesterday"===o?r.push(a):"week"===o?n.push(a):s.push(a)}return{pinned:e,today:t,yesterday:r,week:n,older:s}},[z]),$=e.filter(e=>e.pinned).length,L=e.filter(e=>e.messages.length>0).length,M=(0,s.useCallback)(e=>{g(()=>{r(e),c()})},[r,c]),D=(0,s.useCallback)(()=>{g(()=>{d(),c()})},[d,c]),_=(0,s.useCallback)(e=>{j(e.id),N(k(e))},[]),P=(0,s.useCallback)(()=>{g(()=>{y&&w.trim()&&o(y,w.trim()),j(null)})},[y,w,o]),F=(0,s.useCallback)(()=>{if(!S){C(!0),A.current&&clearTimeout(A.current),A.current=setTimeout(()=>C(!1),3e3);return}g(()=>{A.current&&clearTimeout(A.current),i(),C(!1)})},[S,i]);(0,s.useEffect)(()=>{let e=e=>{"Escape"!==e.key||y||c()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[c,y]);let I=(e,r)=>0===r.length?null:(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"text-2xs font-medium text-muted-foreground/50 uppercase tracking-wider px-1 py-2",children:e}),(0,n.jsx)("div",{className:"flex flex-col gap-1",children:r.map(e=>(0,n.jsx)(e0,{session:e,isActive:e.id===t,editing:y===e.id,editValue:w,onEditValueChange:N,inputRef:R,onLoad:()=>M(e.id),onStartRename:()=>_(e),onCommitRename:P,onCancelRename:()=>j(null),onDelete:()=>a(e.id),onTogglePin:()=>l(e.id),ask:h},e.id))})]},e),O=z.length>0;return(0,n.jsxs)("div",{className:"flex flex-col flex-1 min-h-0 animate-in fade-in-0 duration-150",children:[(0,n.jsx)("div",{className:"px-4 pt-3 pb-2 shrink-0",children:(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)(B.A,{size:13,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground/50"}),(0,n.jsx)("input",{ref:E,type:"text",value:b,onChange:e=>v(e.target.value),placeholder:h?.historySearch??"Search conversations...",className:"w-full pl-8 pr-8 py-2 text-xs rounded-lg border border-border bg-background text-foreground placeholder:text-muted-foreground/40 outline-none focus-visible:border-[var(--amber)]/40 transition-colors"}),b&&(0,n.jsx)("button",{type:"button",onClick:()=>v(""),className:"absolute right-2 top-1/2 -translate-y-1/2 p-0.5 rounded text-muted-foreground/40 hover:text-foreground",children:(0,n.jsx)(u.A,{size:12})})]})}),(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 pb-2 shrink-0",children:[(0,n.jsxs)("span",{className:"text-2xs text-muted-foreground/60",children:[h?.historyStats?.(L)??`${L} conversations`,$>0&&(0,n.jsxs)(n.Fragment,{children:[" \xb7 ",$," ",h?.historyPinned??"pinned"]})]}),(0,n.jsxs)("button",{type:"button",onClick:D,className:"flex items-center gap-1 text-2xs text-[var(--amber)] hover:text-[var(--amber)]/80 transition-colors",children:[(0,n.jsx)(eX.A,{size:11}),(0,n.jsx)("span",{children:p.hints?.newChat??"New chat"})]})]}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto min-h-0 px-3 pb-3",children:O?(0,n.jsxs)("div",{className:"flex flex-col gap-1",children:[I(h?.historyPinned??"Pinned",T.pinned),I(h?.historyToday??"Today",T.today),I(h?.historyYesterday??"Yesterday",T.yesterday),I(h?.historyThisWeek??"This week",T.week),I(h?.historyOlder??"Older",T.older)]}):(0,n.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[(0,n.jsx)(f.A,{size:32,className:"text-muted-foreground/20 mb-3"}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground/60",children:b?"No matching conversations":h?.historyEmpty??"No conversations yet"}),!b&&(0,n.jsx)("p",{className:"text-2xs text-muted-foreground/40 mt-1",children:h?.historyEmptyHint??"Start a new chat to begin"})]})}),L>0&&(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-2.5 border-t border-border/40 shrink-0",children:[(0,n.jsx)("button",{type:"button",onClick:F,className:`text-2xs px-2 py-0.5 rounded-md transition-colors ${S?"bg-error/10 text-error font-medium":"text-muted-foreground/50 hover:text-error hover:bg-muted"}`,children:(0,n.jsxs)("span",{className:"flex items-center gap-1",children:[(0,n.jsx)(ea.A,{size:10}),S?h?.confirmClear??"Confirm clear?":h?.clearAll??"Clear all"]})}),(0,n.jsx)("span",{className:"text-2xs text-muted-foreground/40 tabular-nums",children:h?.historyCapacity?.(L)??`${L} of 30`})]})]})}function e0({session:e,isActive:t,editing:r,editValue:s,onEditValueChange:a,inputRef:o,onLoad:l,onStartRename:i,onCommitRename:u,onCancelRename:c,onDelete:d,onTogglePin:m,ask:p}){let x=k(e),g=function(e){let t=e.messages.find(e=>"user"===e.role);if(!t)return"";let r=t.content.replace(/\s+/g," ").trim();return r.length>60?`${r.slice(0,60)}...`:r}(e),h=e.messages.length;return(0,n.jsxs)("div",{className:`group relative rounded-lg transition-colors cursor-pointer ${t?"bg-[var(--amber)]/8 border border-[var(--amber)]/15":"hover:bg-muted/60 border border-transparent"}`,onClick:l,children:[t&&(0,n.jsx)("span",{className:"absolute left-0 top-3 bottom-3 w-[2px] rounded-r-full bg-[var(--amber)]"}),(0,n.jsxs)("div",{className:"px-3 py-2.5",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1.5 mb-0.5",children:[e.pinned&&(0,n.jsx)(es.A,{size:10,className:"shrink-0 text-[var(--amber)]/60 -rotate-45"}),r?(0,n.jsx)("input",{ref:o,type:"text",value:s,onChange:e=>a(e.target.value),onBlur:u,onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),u()),"Escape"===e.key&&(e.preventDefault(),c())},onClick:e=>e.stopPropagation(),className:"flex-1 min-w-0 bg-transparent border-b border-[var(--amber)] outline-none text-xs font-medium text-foreground"}):(0,n.jsx)("span",{className:"flex-1 min-w-0 text-xs font-medium text-foreground truncate",children:x}),(0,n.jsx)("span",{className:"text-2xs text-muted-foreground/40 shrink-0 tabular-nums",children:function(e){let t=Math.floor((Date.now()-e.getTime())/6e4);if(t<1)return"just now";if(t<60)return`${t}m ago`;let r=Math.floor(t/60);if(r<24)return`${r}h ago`;let n=Math.floor(r/24);return n<7?`${n}d ago`:e.toLocaleDateString(void 0,{month:"short",day:"numeric"})}(new Date(e.updatedAt))})]}),!r&&g&&(0,n.jsx)("p",{className:"text-2xs text-muted-foreground/50 truncate mt-0.5 pl-0.5",children:g}),!r&&(0,n.jsxs)("div",{className:"flex items-center justify-between mt-1.5",children:[(0,n.jsxs)("span",{className:"text-2xs text-muted-foreground/40 flex items-center gap-1",children:[(0,n.jsx)(f.A,{size:9}),p?.historyMsgs?.(h)??`${h} msgs`]}),(0,n.jsxs)("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("button",{type:"button",onClick:m,className:`p-1 rounded-md transition-colors ${e.pinned?"text-[var(--amber)] hover:text-muted-foreground":"text-muted-foreground/40 hover:text-[var(--amber)]"}`,title:e.pinned?"Unpin":"Pin",children:e.pinned?(0,n.jsx)(eZ.A,{size:11}):(0,n.jsx)(es.A,{size:11})}),(0,n.jsx)("button",{type:"button",onClick:i,className:"p-1 rounded-md text-muted-foreground/40 hover:text-foreground hover:bg-muted/60 transition-colors",title:p?.renameSession??"Rename",children:(0,n.jsx)(er.A,{size:11})}),(0,n.jsx)("button",{type:"button",onClick:d,className:"p-1 rounded-md text-muted-foreground/40 hover:text-error hover:bg-error/5 transition-colors",title:"Delete",children:(0,n.jsx)(ea.A,{size:11})})]})]})]})]})}var e1=r(60241),e2=r(24371),e5=r(52335),e3=r(94852);let e4=(0,s.memo)(function({isPanel:e,showHistory:t,onToggleHistory:r,onReset:o,isLoading:l,maximized:i,onMaximize:c,askMode:d,onModeSwitch:f,onClose:h,onDockToPanel:b,hideTitle:v,sessions:y,activeSessionId:j,onLoadSession:w,onDeleteSession:N,onRenameSession:S,onTogglePinSession:C,messages:A}){let{t:E}=(0,m.Y)(),[R,z]=(0,s.useTransition)(),T=y&&y.length>=2,$=e?"h-9 w-9 rounded-lg":"p-2 rounded-lg",L=y?.find(e=>e.id===j),M=L?k(L):null,[D,_]=(0,s.useState)(!1),P=(0,s.useRef)(null),F=(0,s.useRef)(null),[I,O]=(0,s.useState)(null),[H,W]=(0,s.useState)(""),B=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(!D)return;let e=e=>{let t=e.target;P.current&&!P.current.contains(t)&&F.current&&!F.current.contains(t)&&(_(!1),O(null))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[D]),(0,s.useEffect)(()=>{if(!D)return;let e=e=>{"Escape"===e.key&&(I?O(null):_(!1))};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[D,I]),(0,s.useEffect)(()=>{I&&setTimeout(()=>B.current?.focus(),0)},[I]);let U=(0,s.useCallback)(e=>{z(()=>{w?.(e),_(!1)})},[w]),Y=(0,s.useCallback)((e,t)=>{O(e),W("(empty session)"===t?"":t)},[]),J=(0,s.useCallback)(()=>{z(()=>{I&&S&&H.trim()&&S(I,H.trim()),O(null)})},[I,H,S]),[K,q]=(0,s.useState)(null);(0,s.useEffect)(()=>{if(!D||!P.current)return;let e=P.current.getBoundingClientRect();q({top:e.bottom+4,left:e.left,width:Math.max(e.width,280)})},[D]);let Q=D&&K&&y?(0,a.createPortal)((0,n.jsx)("div",{ref:F,className:"fixed z-50 rounded-xl border border-border/50 bg-card shadow-lg py-1 animate-in fade-in-0 slide-in-from-top-1 duration-100 max-h-[60vh] overflow-y-auto",style:{top:K.top,left:K.left,minWidth:Math.max(K.width,280),maxWidth:340},role:"listbox",children:y.map(e=>{let t=e.id===j,r=k(e),s="(empty session)"===r?E.hints?.newChat??"New chat":r;return I===e.id?(0,n.jsx)("div",{className:"flex items-center gap-1 px-2 py-1.5",children:(0,n.jsx)("input",{ref:B,type:"text",value:H,onChange:e=>W(e.target.value),onKeyDown:e=>{"Enter"===e.key&&J(),"Escape"===e.key&&O(null)},onBlur:J,className:"flex-1 min-w-0 px-2 py-1 text-xs rounded-md border border-border bg-background text-foreground outline-none focus-visible:border-[var(--amber)]/50",placeholder:"Session name..."})},e.id):(0,n.jsxs)("div",{className:"group/item flex items-center",children:[(0,n.jsxs)("button",{type:"button",role:"option","aria-selected":t,onClick:()=>U(e.id),className:`flex-1 min-w-0 flex items-center gap-2 px-3 py-2.5 text-xs text-left transition-colors ${t?"text-foreground font-medium":"text-muted-foreground hover:text-foreground hover:bg-muted/50"}`,children:[e.pinned&&(0,n.jsx)(es.A,{size:10,className:"shrink-0 text-[var(--amber)]/60 -rotate-45"}),t&&!e.pinned&&(0,n.jsx)(x.A,{size:11,className:"shrink-0 text-[var(--amber)]"}),(0,n.jsx)("span",{className:"truncate",children:s})]}),(0,n.jsxs)("div",{className:"shrink-0 flex items-center gap-0.5 mr-1 opacity-0 group-hover/item:opacity-100 transition-opacity",children:[C&&(0,n.jsx)("button",{type:"button",onClick:t=>{t.stopPropagation(),C(e.id)},className:`p-1.5 rounded-md transition-colors ${e.pinned?"text-[var(--amber)] hover:text-muted-foreground hover:bg-muted/60":"text-muted-foreground/40 hover:text-[var(--amber)] hover:bg-[var(--amber)]/5"}`,"aria-label":e.pinned?"Unpin":"Pin",children:e.pinned?(0,n.jsx)(eZ.A,{size:10}):(0,n.jsx)(es.A,{size:10})}),S&&(0,n.jsx)("button",{type:"button",onClick:t=>{t.stopPropagation(),Y(e.id,r)},className:"p-1.5 rounded-md text-muted-foreground/40 hover:text-foreground hover:bg-muted/60","aria-label":`Rename: ${s}`,children:(0,n.jsx)(er.A,{size:10})}),y.length>1&&N&&(0,n.jsx)("button",{type:"button",onClick:t=>{t.stopPropagation(),N(e.id)},className:"p-1.5 rounded-md text-muted-foreground/40 hover:text-error hover:bg-error/5","aria-label":`Delete: ${s}`,children:(0,n.jsx)(ea.A,{size:10})})]})]},e.id)})}),document.body):null;return(0,n.jsxs)("div",{className:`flex items-center justify-between px-4 shrink-0 ${e?"py-1.5":"py-2.5"}`,children:[!e&&(0,n.jsx)("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 w-8 h-1 rounded-full bg-muted-foreground/20 md:hidden"}),!v&&(0,n.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,n.jsx)("div",{className:"w-6 h-6 rounded-lg bg-[var(--amber)]/10 flex items-center justify-center shrink-0",children:t?(0,n.jsx)(ei.A,{size:13,className:"text-[var(--amber)]"}):(0,n.jsx)(p.A,{size:13,className:"text-[var(--amber)]"})}),t?(0,n.jsx)("span",{className:"text-sm font-medium text-[var(--amber)]",children:E.ask?.sessionHistory??"Session History"}):T&&M?(0,n.jsxs)("button",{ref:P,type:"button",onClick:()=>{z(()=>{y&&y.length>=2?_(e=>!e):r()})},className:`flex items-center gap-1 min-w-0 text-sm font-medium text-[var(--amber)] hover:text-[var(--amber)]/80 hover:bg-muted/40 transition-colors ${e?"min-h-9 rounded-lg px-2":"rounded-lg"}`,"aria-expanded":D,"aria-haspopup":"listbox",children:[(0,n.jsx)("span",{className:"truncate max-w-[180px]",children:"(empty session)"===M?E.hints?.newChat??"New chat":M}),(0,n.jsx)(g.A,{size:12,className:`shrink-0 text-muted-foreground transition-transform duration-150 ${D?"rotate-180":""}`})]}):M?(0,n.jsx)("span",{className:"text-sm font-medium text-muted-foreground/60 truncate max-w-[180px]",children:"(empty session)"===M?E.hints?.newChat??"New chat":M}):(0,n.jsx)("span",{className:"text-sm font-medium text-muted-foreground/40",children:E.hints?.newChat??"New chat"})]}),v&&(0,n.jsx)("div",{}),(0,n.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,n.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),z(()=>r())},"aria-pressed":t,className:`${$} inline-flex items-center justify-center transition-colors ${t?"bg-[var(--amber)]/10 text-[var(--amber)]":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,title:E.hints.sessionHistory,children:(0,n.jsx)(ei.A,{size:14})}),A&&A.length>0&&(0,n.jsx)(ez,{messages:A,disabled:l}),(0,n.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),z(()=>o())},disabled:l,className:`${$} inline-flex items-center justify-center hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-40`,title:E.hints.newSession,children:(0,n.jsx)(eX.A,{size:14})}),c&&(0,n.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),z(()=>c())},className:`${$} inline-flex items-center justify-center hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,title:i?E.hints.restorePanel:E.hints.maximizePanel,children:i?(0,n.jsx)(e1.A,{size:14}):(0,n.jsx)(e2.A,{size:14})}),b&&(0,n.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),z(()=>b())},className:`${$} inline-flex items-center justify-center hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,title:E.hints.dockToSide??"Dock to side panel",children:(0,n.jsx)(e5.A,{size:14})}),f&&(0,n.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),z(()=>f())},className:`${$} inline-flex items-center justify-center hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,title:"popup"===d?E.hints.dockToSide:E.hints.openAsPopup,children:"popup"===d?(0,n.jsx)(e5.A,{size:14}):(0,n.jsx)(e3.A,{size:14})}),h&&(0,n.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),z(()=>h())},className:`${$} inline-flex items-center justify-center hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,title:E.hints.closePanel,"aria-label":"Close",children:(0,n.jsx)(u.A,{size:14})})]}),"u">typeof document&&Q]})});var e8=r(38798);let e6={kb:{icon:l.A,cls:"text-muted-foreground"},upload:{icon:F.A,cls:"text-muted-foreground"},image:{icon:i.A,cls:"text-muted-foreground"},skill:{icon:P.A,cls:"text-[var(--amber)]"},agent:{icon:I.A,cls:"text-[var(--amber)]"}},e9={kb:"border-border/60 bg-muted/70 text-foreground shadow-sm",upload:"border-border/60 bg-muted/70 text-foreground shadow-sm",image:"border-border/60 bg-muted/70 text-foreground shadow-sm",skill:"border-[var(--amber)]/35 bg-[var(--amber)]/12 text-foreground shadow-sm",agent:"border-[var(--amber)]/35 bg-[var(--amber)]/12 text-foreground shadow-sm"};function e7({path:e,onRemove:t,variant:r="kb",imageData:o,imageMime:l,status:i,error:c,truncatedInfo:d}){let[m,f]=(0,s.useState)(!1),[p,x]=(0,s.useState)(!1),[g,h]=(0,s.useState)(!1),b=(0,s.useRef)(null),[v,y]=(0,s.useState)(null),[j,w]=(0,s.useState)(null);(0,s.useEffect)(()=>h(!0),[]);let k="kb"===r&&e.endsWith("/"),N=k?e.slice(0,-1):e,S=N.split("/").pop()??N,C="kb"===r&&!k&&S.endsWith(".csv"),{icon:A,cls:E}=k?{icon:e8.A,cls:"text-yellow-400"}:C?{icon:ec.A,cls:"text-success"}:e6[r],R=!!d,z=null,T="";"loading"===i?(z=O.A,T="text-muted-foreground animate-spin"):"error"===i?(z=J.A,T="text-destructive"):R?(z=em.A,T="text-[var(--amber)]"):"success"===i&&(z=ef.A,T="text-emerald-500");let $="error"===i?"border-destructive/40 bg-destructive/8 text-foreground shadow-sm":R?"border-[var(--amber)]/40 bg-[var(--amber)]/8 text-foreground shadow-sm":e9[r],L=null;if("error"===i&&c)L=c;else if(R){let e=d.totalChars>0?Math.round(d.includedChars/d.totalChars*100):0;L=`Document truncated — only ${e}% included (${Math.round(d.includedChars/1e3)}K / ${Math.round(d.totalChars/1e3)}K chars, ${d.totalPages} pages total)`}(0,s.useEffect)(()=>{if(!m||!b.current)return void y(null);let e=b.current.getBoundingClientRect();y({top:e.top-8,left:e.left})},[m]),(0,s.useEffect)(()=>{if(!p||!b.current)return void w(null);let e=b.current.getBoundingClientRect();w({top:e.top-8,left:e.left})},[p]);let M=m&&v&&o&&l?(0,n.jsx)("div",{className:"fixed z-50 p-1 rounded-lg border border-border bg-card shadow-lg pointer-events-none",style:{left:v.left,bottom:window.innerHeight-v.top},children:(0,n.jsx)("img",{src:`data:${l};base64,${o}`,alt:S,className:"max-h-48 max-w-64 rounded object-contain"})}):null,D=p&&j&&L?(0,n.jsx)("div",{className:`fixed z-50 px-2.5 py-1.5 rounded-lg border bg-card text-xs shadow-lg pointer-events-none max-w-[280px] ${"error"===i?"border-destructive/20 text-destructive":"border-[var(--amber)]/20 text-[var(--amber-text)]"}`,style:{left:j.left,bottom:window.innerHeight-j.top},children:L}):null;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("span",{ref:b,className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-xs border max-w-[220px] ${$}`,onMouseEnter:()=>{o&&f(!0),L&&x(!0)},onMouseLeave:()=>{f(!1),x(!1)},children:[(0,n.jsx)(A,{size:11,className:`${E} shrink-0`}),(0,n.jsx)("span",{className:"truncate",title:k?N:e,children:S}),z&&(0,n.jsx)(z,{size:10,className:`${T} shrink-0`}),(0,n.jsx)("button",{type:"button",onClick:t,"aria-label":`Remove ${S}`,className:"p-0.5 -mr-1 rounded hover:text-foreground transition-colors shrink-0 text-muted-foreground",children:(0,n.jsx)(u.A,{size:10})})]}),g&&M&&(0,a.createPortal)(M,document.body),g&&D&&(0,a.createPortal)(D,document.body)]})}function te({selectedAgent:e,onSelect:t,installedAgents:r,loading:o=!1}){let{t:l}=(0,m.Y)(),i=l.panels?.agents??{acpDefaultAgent:"MindOS",acpSelectAgent:"Select Agent",acpChangeAgent:"Change agent"},[c,d]=(0,s.useState)(!1),[f,p]=(0,s.useState)(null),h=(0,s.useRef)(null),b=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(!c||!h.current)return;let e=h.current.getBoundingClientRect(),t=e.top,r=t>window.innerHeight-e.bottom&&t>200?"up":"down";p({left:e.left,top:"up"===r?e.top-6:e.bottom+6,direction:r})},[c]),(0,s.useEffect)(()=>{if(!c)return;let e=e=>{let t=e.target;h.current&&!h.current.contains(t)&&b.current&&!b.current.contains(t)&&d(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[c]),(0,s.useEffect)(()=>{if(!c)return;let e=e=>{"Escape"===e.key&&d(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[c]),(0,s.useEffect)(()=>{if(!c||!h.current)return;let e=()=>{if(!h.current)return;let e=h.current.getBoundingClientRect(),t=e.top,r=t>window.innerHeight-e.bottom&&t>200?"up":"down";p({left:e.left,top:"up"===r?e.top-6:e.bottom+6,direction:r})};return window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[c]);let v=(0,s.useCallback)(()=>{t(null),d(!1)},[t]),y=(0,s.useCallback)(e=>{t({id:e.id,name:e.name}),d(!1)},[t]),j=(0,s.useCallback)(e=>{e.stopPropagation(),t(null)},[t]),w=!e,k=e?.name??i.acpDefaultAgent,N=c&&f?(0,n.jsxs)("div",{ref:b,role:"listbox","aria-label":i.acpSelectAgent,className:"fixed z-50 min-w-[180px] max-w-[240px] rounded-lg border border-border bg-card shadow-lg py-1 animate-in fade-in-0 zoom-in-95 duration-100",style:{left:f.left,..."up"===f.direction?{bottom:window.innerHeight-f.top}:{top:f.top}},children:[(0,n.jsxs)("button",{type:"button",role:"option","aria-selected":w,onClick:v,className:"flex w-full items-center gap-2 px-3 py-1.5 text-xs text-left transition-colors hover:bg-muted",children:[(0,n.jsx)(I.A,{size:12,className:"shrink-0 text-muted-foreground"}),(0,n.jsx)("span",{className:"flex-1 truncate font-medium",children:i.acpDefaultAgent}),w&&(0,n.jsx)(x.A,{size:11,className:"shrink-0 text-[var(--amber)]"})]}),r.length>0&&(0,n.jsx)("div",{className:"mx-2 my-1 border-t border-border/60"}),r.map(t=>{let r=e?.id===t.id;return(0,n.jsxs)("button",{type:"button",role:"option","aria-selected":r,onClick:()=>y(t),className:"flex w-full items-center gap-2 px-3 py-1.5 text-xs text-left transition-colors hover:bg-muted",children:[(0,n.jsx)("span",{className:"w-2 h-2 rounded-full bg-[var(--success)] shrink-0"}),(0,n.jsx)("span",{className:"flex-1 truncate",children:t.name}),r&&(0,n.jsx)(x.A,{size:11,className:"shrink-0 text-[var(--amber)]"})]},t.id)})]}):null;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("button",{ref:h,type:"button",onClick:()=>d(e=>!e),className:`
|
|
20
20
|
inline-flex items-center gap-1 rounded-full px-2.5 py-0.5
|
|
21
21
|
text-2xs font-medium transition-colors
|
|
22
22
|
border focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring
|