@hienlh/ppm 0.13.44 → 0.13.45
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/CHANGELOG.md +5 -0
- package/assets/skills/ppm/SKILL.md +1 -1
- package/assets/skills/ppm/references/http-api.md +1 -1
- package/dist/web/assets/ai-settings-section-Btix996C.js +2 -1
- package/dist/web/assets/ai-settings-section-Btix996C.js.map +1 -0
- package/dist/web/assets/api-client-DIhJ5qVW.js +2 -1
- package/dist/web/assets/api-client-DIhJ5qVW.js.map +1 -0
- package/dist/web/assets/api-settings-DnHv6JgF.js +2 -1
- package/dist/web/assets/api-settings-DnHv6JgF.js.map +1 -0
- package/dist/web/assets/arrow-up-Rcw6_KKu.js +2 -1
- package/dist/web/assets/arrow-up-Rcw6_KKu.js.map +1 -0
- package/dist/web/assets/audio-preview-B6a1Djtr.js +2 -1
- package/dist/web/assets/audio-preview-B6a1Djtr.js.map +1 -0
- package/dist/web/assets/chat-tab-Z5VNzYCz.js +2 -1
- package/dist/web/assets/chat-tab-Z5VNzYCz.js.map +1 -0
- package/dist/web/assets/chevron-right-DnHIvvcy.js +2 -1
- package/dist/web/assets/chevron-right-DnHIvvcy.js.map +1 -0
- package/dist/web/assets/code-DGBecc50.js +2 -1
- package/dist/web/assets/code-DGBecc50.js.map +1 -0
- package/dist/web/assets/code-editor-Clvs0e0Q.js +2 -1
- package/dist/web/assets/code-editor-Clvs0e0Q.js.map +1 -0
- package/dist/web/assets/conflict-editor-B6nO1gln.js +2 -1
- package/dist/web/assets/conflict-editor-B6nO1gln.js.map +1 -0
- package/dist/web/assets/createLucideIcon-BjHrJDVb.js +2 -1
- package/dist/web/assets/createLucideIcon-BjHrJDVb.js.map +1 -0
- package/dist/web/assets/csv-parser-Dly5nqE1.js +2 -1
- package/dist/web/assets/csv-parser-Dly5nqE1.js.map +1 -0
- package/dist/web/assets/csv-preview-CsqFmPzb.js +2 -1
- package/dist/web/assets/csv-preview-CsqFmPzb.js.map +1 -0
- package/dist/web/assets/data-grid-overlay-editor-aTzJjALy.js +2 -1
- package/dist/web/assets/data-grid-overlay-editor-aTzJjALy.js.map +1 -0
- package/dist/web/assets/data-grid-types-BISkUXAY.js +2 -1
- package/dist/web/assets/data-grid-types-BISkUXAY.js.map +1 -0
- package/dist/web/assets/database-DOWH9-Vv.js +2 -1
- package/dist/web/assets/database-DOWH9-Vv.js.map +1 -0
- package/dist/web/assets/database-viewer-Boup8MJ_.js +2 -1
- package/dist/web/assets/database-viewer-Boup8MJ_.js.map +1 -0
- package/dist/web/assets/diff-viewer-Je2KYGME.js +2 -1
- package/dist/web/assets/diff-viewer-Je2KYGME.js.map +1 -0
- package/dist/web/assets/dist-B1I_4Jtc.js +2 -1
- package/dist/web/assets/dist-B1I_4Jtc.js.map +1 -0
- package/dist/web/assets/dist-CcDNqGjt.js +2 -1
- package/dist/web/assets/dist-CcDNqGjt.js.map +1 -0
- package/dist/web/assets/dist-wf2npcsG.js +2 -1
- package/dist/web/assets/dist-wf2npcsG.js.map +1 -0
- package/dist/web/assets/esm-UZtw2QcY.js +2 -1
- package/dist/web/assets/esm-UZtw2QcY.js.map +1 -0
- package/dist/web/assets/extension-webview-T9TN70nb.js +2 -1
- package/dist/web/assets/extension-webview-T9TN70nb.js.map +1 -0
- package/dist/web/assets/file-exclamation-point-BwzaQ50n.js +2 -1
- package/dist/web/assets/file-exclamation-point-BwzaQ50n.js.map +1 -0
- package/dist/web/assets/file-store-DOxcU_7s.js +2 -1
- package/dist/web/assets/file-store-DOxcU_7s.js.map +1 -0
- package/dist/web/assets/glide-data-grid-CqT8WzTs.js +2 -1
- package/dist/web/assets/glide-data-grid-CqT8WzTs.js.map +1 -0
- package/dist/web/assets/image-preview-DeNUcGI9.js +2 -1
- package/dist/web/assets/image-preview-DeNUcGI9.js.map +1 -0
- package/dist/web/assets/index-DJtqbPFT.js +2 -1
- package/dist/web/assets/index-DJtqbPFT.js.map +1 -0
- package/dist/web/assets/input-_LFQwhzd.js +2 -1
- package/dist/web/assets/input-_LFQwhzd.js.map +1 -0
- package/dist/web/assets/katex-Bqvo_ZG0.js +2 -1
- package/dist/web/assets/katex-Bqvo_ZG0.js.map +1 -0
- package/dist/web/assets/lib-Bu71-TFS.js +2 -1
- package/dist/web/assets/lib-Bu71-TFS.js.map +1 -0
- package/dist/web/assets/markdown-renderer-CXPtICSx.js +2 -1
- package/dist/web/assets/markdown-renderer-CXPtICSx.js.map +1 -0
- package/dist/web/assets/number-overlay-editor-CewUR5pB.js +2 -1
- package/dist/web/assets/number-overlay-editor-CewUR5pB.js.map +1 -0
- package/dist/web/assets/pdf-preview-DI2JU2Lm.js +2 -1
- package/dist/web/assets/pdf-preview-DI2JU2Lm.js.map +1 -0
- package/dist/web/assets/port-forwarding-tab-Cuv_37LW.js +2 -1
- package/dist/web/assets/port-forwarding-tab-Cuv_37LW.js.map +1 -0
- package/dist/web/assets/postgres-viewer-D76ygOZo.js +2 -1
- package/dist/web/assets/postgres-viewer-D76ygOZo.js.map +1 -0
- package/dist/web/assets/react-DMIOAtcX.js +2 -1
- package/dist/web/assets/react-DMIOAtcX.js.map +1 -0
- package/dist/web/assets/refresh-cw-BjrAbUJe.js +2 -1
- package/dist/web/assets/refresh-cw-BjrAbUJe.js.map +1 -0
- package/dist/web/assets/scroll-area-BDi_FNzr.js +2 -1
- package/dist/web/assets/scroll-area-BDi_FNzr.js.map +1 -0
- package/dist/web/assets/search-tM8K5zWU.js +2 -1
- package/dist/web/assets/search-tM8K5zWU.js.map +1 -0
- package/dist/web/assets/settings-store-CVrIYYCB.js +2 -1
- package/dist/web/assets/settings-store-CVrIYYCB.js.map +1 -0
- package/dist/web/assets/sparkles-CulWHe4c.js +2 -1
- package/dist/web/assets/sparkles-CulWHe4c.js.map +1 -0
- package/dist/web/assets/sql-query-editor-lSlKMPlG.js +2 -1
- package/dist/web/assets/sql-query-editor-lSlKMPlG.js.map +1 -0
- package/dist/web/assets/sqlite-viewer-DwTatNwI.js +2 -1
- package/dist/web/assets/sqlite-viewer-DwTatNwI.js.map +1 -0
- package/dist/web/assets/tab-store-S9w6U5gm.js +2 -1
- package/dist/web/assets/tab-store-S9w6U5gm.js.map +1 -0
- package/dist/web/assets/table-BzjWcs87.js +2 -1
- package/dist/web/assets/table-BzjWcs87.js.map +1 -0
- package/dist/web/assets/terminal-tab-XKe1TZiV.js +2 -1
- package/dist/web/assets/terminal-tab-XKe1TZiV.js.map +1 -0
- package/dist/web/assets/text-wrap-DJz9Bgpa.js +2 -1
- package/dist/web/assets/text-wrap-DJz9Bgpa.js.map +1 -0
- package/dist/web/assets/use-blob-url-QX-XajU8.js +2 -1
- package/dist/web/assets/use-blob-url-QX-XajU8.js.map +1 -0
- package/dist/web/assets/use-monaco-theme-BePWbY58.js +2 -1
- package/dist/web/assets/use-monaco-theme-BePWbY58.js.map +1 -0
- package/dist/web/assets/utils-CQux7CsO.js +2 -1
- package/dist/web/assets/utils-CQux7CsO.js.map +1 -0
- package/dist/web/assets/vendor-markdown-0Mxgxy0L.js +2 -1
- package/dist/web/assets/vendor-markdown-0Mxgxy0L.js.map +1 -0
- package/dist/web/assets/vendor-mermaid-Cl50p6TB.js +2 -1
- package/dist/web/assets/vendor-mermaid-Cl50p6TB.js.map +1 -0
- package/dist/web/assets/vendor-ui-UXCWAcmi.js +2 -1
- package/dist/web/assets/vendor-ui-UXCWAcmi.js.map +1 -0
- package/dist/web/assets/vendor-xterm-K3_Xwigj.js +2 -1
- package/dist/web/assets/vendor-xterm-K3_Xwigj.js.map +1 -0
- package/dist/web/assets/video-preview-wHVbAYar.js +2 -1
- package/dist/web/assets/video-preview-wHVbAYar.js.map +1 -0
- package/dist/web/assets/x-BPReZWnP.js +2 -1
- package/dist/web/assets/x-BPReZWnP.js.map +1 -0
- package/dist/web/sw.js +2 -1
- package/dist/web/sw.js.map +1 -0
- package/package.json +1 -1
- package/vite.config.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -71,4 +71,4 @@ This skill covers the `ppm` CLI, its HTTP API, and its config DB. It does **not*
|
|
|
71
71
|
- Third-party extensions (inspect via `ppm ext list`).
|
|
72
72
|
- The Claude Agent SDK internals (separate skill).
|
|
73
73
|
|
|
74
|
-
<!-- Generated for PPM v0.13.
|
|
74
|
+
<!-- Generated for PPM v0.13.45 at build time. Re-run `ppm export skill --install` to refresh. -->
|
|
@@ -201,4 +201,4 @@ _Base URL: `http://localhost:8080` (default; override via `ppm config set port <
|
|
|
201
201
|
- `ws://<host>/ws/terminal` — PTY terminal multiplexer
|
|
202
202
|
- `ws://<host>/ws/extensions` — extension host channel
|
|
203
203
|
|
|
204
|
-
<!-- Generated from src/server/routes/ for PPM v0.13.
|
|
204
|
+
<!-- Generated from src/server/routes/ for PPM v0.13.45 -->
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,x as n}from"./vendor-markdown-0Mxgxy0L.js";import{S as r,a as i,c as a,d as o,f as s,g as c,h as l,l as u,m as d,n as f,o as p,p as m,r as h,s as g,u as _}from"./vendor-ui-UXCWAcmi.js";import{t as v}from"./createLucideIcon-BjHrJDVb.js";import{i as y}from"./dist-wf2npcsG.js";import{t as b}from"./input-_LFQwhzd.js";import{n as x}from"./x-BPReZWnP.js";import{t as S}from"./refresh-cw-BjrAbUJe.js";import{i as C,t as w}from"./api-client-DIhJ5qVW.js";import{n as T}from"./utils-CQux7CsO.js";import{a as E,h as D}from"./api-settings-DnHv6JgF.js";var O=v(`bell-off`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742`,key:`178tsu`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05`,key:`1hqiys`}]]),k=v(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),A=v(`bug`,[[`path`,{d:`M12 20v-9`,key:`1qisl0`}],[`path`,{d:`M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z`,key:`uouzyp`}],[`path`,{d:`M14.12 3.88 16 2`,key:`qol33r`}],[`path`,{d:`M21 21a4 4 0 0 0-3.81-4`,key:`1b0z45`}],[`path`,{d:`M21 5a4 4 0 0 1-3.55 3.97`,key:`5cxbf6`}],[`path`,{d:`M22 13h-4`,key:`1jl80f`}],[`path`,{d:`M3 21a4 4 0 0 1 3.81-4`,key:`1fjd4g`}],[`path`,{d:`M3 5a4 4 0 0 0 3.55 3.97`,key:`1d7oge`}],[`path`,{d:`M6 13H2`,key:`82j7cp`}],[`path`,{d:`m8 2 1.88 1.88`,key:`fmnt4t`}],[`path`,{d:`M9 7.13V6a3 3 0 1 1 6 0v1.13`,key:`1vgav8`}]]),j=v(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),M=v(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),N=v(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),P=v(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),F=e(n(),1),I=t();function L({className:e,...t}){return(0,I.jsx)(r,{"data-slot":`label`,className:T(`flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}var R=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(f,{className:T(`peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input`,e),...t,ref:n,children:(0,I.jsx)(h,{className:T(`pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0`)})}));R.displayName=f.displayName;function z({...e}){return(0,I.jsx)(o,{"data-slot":`select`,...e})}function B({...e}){return(0,I.jsx)(l,{"data-slot":`select-value`,...e})}function V({className:e,size:t=`default`,children:n,...r}){return(0,I.jsxs)(d,{"data-slot":`select-trigger`,"data-size":t,className:T(`flex w-fit items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[placeholder]:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...r,children:[n,(0,I.jsx)(p,{asChild:!0,children:(0,I.jsx)(j,{className:`size-4 opacity-50`})})]})}function H({className:e,children:t,position:n=`item-aligned`,align:r=`center`,...a}){return(0,I.jsx)(_,{children:(0,I.jsxs)(i,{"data-slot":`select-content`,className:T(`relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,align:r,...a,children:[(0,I.jsx)(W,{}),(0,I.jsx)(c,{className:T(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1`),children:t}),(0,I.jsx)(G,{})]})})}function U({className:e,children:t,...n}){return(0,I.jsxs)(g,{"data-slot":`select-item`,className:T(`relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,I.jsx)(`span`,{"data-slot":`select-item-indicator`,className:`absolute right-2 flex size-3.5 items-center justify-center`,children:(0,I.jsx)(a,{children:(0,I.jsx)(y,{className:`size-4`})})}),(0,I.jsx)(u,{children:t})]})}function W({className:e,...t}){return(0,I.jsx)(m,{"data-slot":`select-scroll-up-button`,className:T(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(M,{className:`size-4`})})}function G({className:e,...t}){return(0,I.jsx)(s,{"data-slot":`select-scroll-down-button`,className:T(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(j,{className:`size-4`})})}var K={claude:`C`,cursor:`▶`,codex:`◆`,gemini:`G`};function q({value:e,onChange:t,projectName:n}){let[r,i]=(0,F.useState)([]),[a,o]=(0,F.useState)(!1),s=(0,F.useRef)(null),c=(0,F.useRef)(0);(0,F.useEffect)(()=>{n&&w.get(`${C(n)}/chat/providers`).then(i).catch(()=>{})},[n]),(0,F.useEffect)(()=>{if(!a)return;let e=e=>{s.current&&!s.current.contains(e.target)&&o(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[a]),(0,F.useEffect)(()=>{a&&(c.current=Math.max(0,r.findIndex(t=>t.id===e)))},[a,e,r]);let l=(0,F.useCallback)(e=>{if(e.key===`Escape`){o(!1);return}if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;c.current=(c.current+t+r.length)%r.length,(s.current?.querySelector(`[data-idx="${c.current}"]`))?.focus()}if(e.key===`Enter`){e.preventDefault();let n=r[c.current];n&&(t(n.id),o(!1))}},[t,r]);if(r.length<=1)return null;let u=r.find(t=>t.id===e),d=K[e]||`?`;return(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),o(e=>!e)},className:`inline-flex items-center gap-1 px-2 py-1 rounded-md text-[11px] text-text-subtle hover:text-text-primary hover:bg-surface-elevated transition-colors border border-transparent hover:border-border`,"aria-label":`AI Provider: ${u?.name??e}`,children:[(0,I.jsx)(`span`,{className:`inline-flex h-3.5 w-3.5 items-center justify-center rounded text-[9px] font-bold bg-surface-elevated shrink-0`,children:d}),(0,I.jsx)(`span`,{className:`max-w-[80px] truncate capitalize`,children:u?.name??e})]}),a&&(0,I.jsxs)(`div`,{ref:s,role:`listbox`,"aria-label":`AI Providers`,onKeyDown:l,onMouseDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),className:`absolute bottom-full left-0 mb-1 z-50 w-56 rounded-lg border border-border bg-surface shadow-lg`,children:[(0,I.jsx)(`div`,{className:`px-3 py-2 border-b border-border`,children:(0,I.jsx)(`span`,{className:`text-xs font-medium text-text-secondary`,children:`Provider`})}),(0,I.jsx)(`div`,{className:`py-1`,children:r.map((n,r)=>{let i=K[n.id]||`?`,a=n.id===e;return(0,I.jsxs)(`button`,{"data-idx":r,role:`option`,"aria-selected":a,tabIndex:0,onClick:()=>{t(n.id),o(!1)},className:`w-full flex items-center gap-3 px-3 py-2 text-left transition-colors hover:bg-surface-elevated focus:bg-surface-elevated focus:outline-none ${a?`bg-surface-elevated`:``}`,children:[(0,I.jsx)(`span`,{className:`inline-flex h-5 w-5 items-center justify-center rounded text-[11px] font-bold bg-surface-elevated text-text-subtle shrink-0`,children:i}),(0,I.jsx)(`span`,{className:`flex-1 text-sm font-medium text-text-primary capitalize`,children:n.name}),a&&(0,I.jsx)(y,{className:`size-4 shrink-0 text-primary`})]},n.id)})})]})]})}function J({providerId:e}){return(0,I.jsx)(`span`,{className:`inline-flex h-4 w-4 items-center justify-center rounded text-[10px] font-bold bg-surface-elevated text-text-subtle shrink-0`,title:e,children:K[e]||`?`})}var Y=[{value:`low`,label:`Low`},{value:`medium`,label:`Medium`},{value:`high`,label:`High`}],X=[{value:`bypassPermissions`,label:`Bypass permissions (default)`},{value:`default`,label:`Ask before edits`},{value:`acceptEdits`,label:`Edit automatically`},{value:`plan`,label:`Plan mode`}],Z={claude:`Claude`,cursor:`Cursor`,codex:`Codex`,gemini:`Gemini`};function Q({compact:e}={}){let[t,n]=(0,F.useState)(null),[r,i]=(0,F.useState)(``),[a,o]=(0,F.useState)([]),[s,c]=(0,F.useState)(!1),[l,u]=(0,F.useState)(!1),[d,f]=(0,F.useState)(null),[p,m]=(0,F.useState)(0);(0,F.useEffect)(()=>{E().then(e=>{n(e),i(e.default_provider??`claude`)}).catch(e=>f(e.message))},[]),(0,F.useEffect)(()=>{r&&(c(!0),w.get(`/api/settings/ai/providers/${r}/models`).then(o).catch(()=>o([])).finally(()=>c(!1)))},[r]);let h=t?Object.keys(t.providers).filter(e=>e!==`mock`).map(e=>({id:e,name:Z[e]??e})):[],g=t?.providers[r],_=g?.type===`agent-sdk`||!g?.type&&r===`claude`,v=async(e,i)=>{if(t){u(!0),f(null);try{n(await D({providers:{[r]:{[e]:i}}})),m(e=>e+1)}catch(e){f(e.message)}finally{u(!1)}}},y=e?`text-[11px]`:`text-sm`,x=e?`text-xs`:`text-sm`,S=e?`space-y-2`:`space-y-4`,C=e?`space-y-1.5`:`space-y-3`,T=e?`space-y-1`:`space-y-1.5`;if(!t)return(0,I.jsxs)(`div`,{className:C,children:[(0,I.jsx)(`h3`,{className:`${x} font-medium text-text-secondary`,children:`AI Settings`}),(0,I.jsx)(`p`,{className:`${y} text-text-subtle`,children:d?`Error: ${d}`:`Loading...`})]});let O=_?a:[{value:`__default__`,label:`Auto (default)`},...a];return(0,I.jsxs)(`div`,{className:S,children:[(0,I.jsx)(`h3`,{className:`${x} font-medium text-text-secondary`,children:`AI Settings`}),h.length>1&&(0,I.jsx)(`div`,{className:`flex gap-0.5 border-b border-border/50 -mx-1 px-1`,children:h.map(e=>(0,I.jsxs)(`button`,{onClick:()=>i(e.id),className:`flex items-center gap-1 px-2 py-1 text-[11px] rounded-t transition-colors ${r===e.id?`text-primary border-b-2 border-primary font-medium`:`text-text-subtle hover:text-text-secondary`}`,children:[(0,I.jsx)(J,{providerId:e.id}),(0,I.jsx)(`span`,{className:`capitalize`,children:e.name})]},e.id))}),(0,I.jsxs)(`div`,{className:C,children:[a.length>0&&(0,I.jsxs)(`div`,{className:T,children:[(0,I.jsx)(L,{htmlFor:`ai-model`,className:e?y:void 0,children:`Model`}),(0,I.jsxs)(z,{value:_?g?.model??a[0]?.value:g?.model||`__default__`,onValueChange:e=>v(`model`,e===`__default__`?void 0:e),disabled:s,children:[(0,I.jsx)(V,{id:`ai-model`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,I.jsx)(B,{placeholder:s?`Loading models...`:`Select model`})}),(0,I.jsx)(H,{className:`max-h-[300px]`,children:O.map(e=>(0,I.jsx)(U,{value:e.value,children:e.label},e.value))})]})]}),_&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:T,children:[(0,I.jsx)(L,{htmlFor:`ai-base-url`,className:e?y:void 0,children:`Base URL`}),(0,I.jsx)(b,{id:`ai-base-url`,type:`url`,defaultValue:g?.base_url??``,placeholder:`https://api.anthropic.com (default)`,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{v(`base_url`,e.target.value.trim()||void 0)}},`baseurl-${r}-${p}`)]}),(0,I.jsxs)(`div`,{className:T,children:[(0,I.jsx)(L,{htmlFor:`ai-api-key`,className:e?y:void 0,children:`API Key / Token`}),(0,I.jsx)(b,{id:`ai-api-key`,type:`password`,defaultValue:g?.api_key??``,placeholder:`sk-ant-... (optional, overrides accounts)`,className:e?`h-7 text-[11px] font-mono`:`font-mono`,onBlur:e=>{let t=e.target.value.trim();t.startsWith(`••••`)||v(`api_key`,t||void 0)}},`apikey-${r}-${p}`),(0,I.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Direct API key or OAuth token. Leave empty to use connected accounts.`})]}),(0,I.jsxs)(`div`,{className:T,children:[(0,I.jsx)(L,{htmlFor:`ai-effort`,className:e?y:void 0,children:`Effort`}),(0,I.jsxs)(z,{value:g?.effort??`high`,onValueChange:e=>v(`effort`,e),children:[(0,I.jsx)(V,{id:`ai-effort`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,I.jsx)(B,{})}),(0,I.jsx)(H,{children:Y.map(e=>(0,I.jsx)(U,{value:e.value,children:e.label},e.value))})]})]}),(0,I.jsxs)(`div`,{className:T,children:[(0,I.jsx)(L,{htmlFor:`ai-max-turns`,className:e?y:void 0,children:`Max Turns (1-500)`}),(0,I.jsx)(b,{id:`ai-max-turns`,type:`number`,min:1,max:500,defaultValue:g?.max_turns??100,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{let t=parseInt(e.target.value);isNaN(t)||v(`max_turns`,t)}},`turns-${r}-${p}`)]}),(0,I.jsxs)(`div`,{className:T,children:[(0,I.jsx)(L,{htmlFor:`ai-budget`,className:e?y:void 0,children:`Max Budget (USD)`}),(0,I.jsx)(b,{id:`ai-budget`,type:`number`,step:.1,min:.01,max:50,defaultValue:g?.max_budget_usd??``,placeholder:`No limit`,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{let t=parseFloat(e.target.value);v(`max_budget_usd`,isNaN(t)?void 0:t)}},`budget-${r}-${p}`)]}),(0,I.jsxs)(`div`,{className:T,children:[(0,I.jsx)(L,{htmlFor:`ai-thinking`,className:e?y:void 0,children:`Thinking Budget (tokens)`}),(0,I.jsx)(b,{id:`ai-thinking`,type:`number`,min:0,defaultValue:g?.thinking_budget_tokens??``,placeholder:`Disabled`,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{let t=parseInt(e.target.value);v(`thinking_budget_tokens`,isNaN(t)?void 0:t)}},`thinking-${r}-${p}`)]}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(L,{htmlFor:`ai-agent-teams`,className:e?y:void 0,children:`Agent Teams`}),(0,I.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Experimental. Enables multi-agent collaboration with shared tasks and messaging. Uses ~7x more tokens.`})]}),(0,I.jsx)(R,{id:`ai-agent-teams`,checked:g?.agent_teams??!1,onCheckedChange:e=>v(`agent_teams`,e)})]}),g?.agent_teams&&(0,I.jsx)($,{compact:e})]}),(0,I.jsxs)(`div`,{className:T,children:[(0,I.jsx)(L,{htmlFor:`ai-permission-mode`,className:e?y:void 0,children:`Default Permission Mode`}),(0,I.jsxs)(z,{value:g?.permission_mode??`bypassPermissions`,onValueChange:e=>v(`permission_mode`,e),children:[(0,I.jsx)(V,{id:`ai-permission-mode`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,I.jsx)(B,{})}),(0,I.jsx)(H,{children:X.map(e=>(0,I.jsx)(U,{value:e.value,children:e.label},e.value))})]})]}),(0,I.jsxs)(`div`,{className:T,children:[(0,I.jsx)(L,{htmlFor:`ai-system-prompt`,className:e?y:void 0,children:`Additional Instructions`}),(0,I.jsx)(`textarea`,{id:`ai-system-prompt`,rows:e?3:4,defaultValue:g?.system_prompt??``,placeholder:`Enter additional instructions for ${r}...`,className:`w-full rounded-md border border-input bg-background px-3 py-2 ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${e?`text-[11px]`:`text-sm`}`,onBlur:e=>{v(`system_prompt`,e.target.value.trim()||void 0)}},`sysprompt-${r}-${p}`)]})]}),l&&(0,I.jsx)(`p`,{className:`text-xs text-text-subtle`,children:`Saving...`}),d&&(0,I.jsx)(`p`,{className:`text-xs text-red-500`,children:d})]})}function $({compact:e}){let[t,n]=(0,F.useState)([]),[r,i]=(0,F.useState)(!1),[a,o]=(0,F.useState)(null),s=(0,F.useCallback)(async()=>{i(!0);try{n(await w.get(`/api/teams`)??[])}catch{}i(!1)},[]);(0,F.useEffect)(()=>{s()},[s]);let c=async e=>{try{await w.del(`/api/teams/${encodeURIComponent(e)}`),n(t=>t.filter(t=>t.name!==e)),o(null)}catch{}};return t.length===0&&!r?null:(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsxs)(L,{className:e?`text-[11px]`:void 0,children:[`Teams (`,t.length,`)`]}),(0,I.jsx)(`button`,{onClick:s,className:`text-text-subtle hover:text-foreground p-1`,"aria-label":`Refresh teams`,children:(0,I.jsx)(S,{className:`size-3 ${r?`animate-spin`:``}`})})]}),t.map(e=>(0,I.jsxs)(`div`,{className:`flex items-center justify-between p-2 rounded bg-surface-elevated text-xs`,children:[(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`div`,{className:`font-medium truncate`,children:e.name}),e.description&&(0,I.jsx)(`div`,{className:`text-text-subtle truncate`,children:e.description}),(0,I.jsxs)(`div`,{className:`text-text-subtle`,children:[e.members?.length??e.memberCount??0,` members`,e.createdAt?` · ${new Date(e.createdAt).toLocaleDateString()}`:``]})]}),a===e.name?(0,I.jsxs)(`div`,{className:`flex gap-1 shrink-0 ml-2`,children:[(0,I.jsx)(`button`,{onClick:()=>c(e.name),className:`px-2 py-1 bg-red-600 text-white rounded text-[10px]`,children:`Delete`}),(0,I.jsx)(`button`,{onClick:()=>o(null),className:`px-2 py-1 bg-zinc-600 text-white rounded text-[10px]`,children:`Cancel`})]}):(0,I.jsx)(`button`,{onClick:()=>o(e.name),className:`shrink-0 text-text-subtle hover:text-red-500 p-1 ml-2`,"aria-label":`Delete team ${e.name}`,children:(0,I.jsx)(x,{className:`size-3.5`})})]},e.name))]})}export{O as _,H as a,B as c,P as d,N as f,k as g,A as h,z as i,R as l,j as m,J as n,U as o,M as p,q as r,V as s,Q as t,L as u};
|
|
1
|
+
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,x as n}from"./vendor-markdown-0Mxgxy0L.js";import{S as r,a as i,c as a,d as o,f as s,g as c,h as l,l as u,m as d,n as f,o as p,p as m,r as h,s as g,u as _}from"./vendor-ui-UXCWAcmi.js";import{t as v}from"./createLucideIcon-BjHrJDVb.js";import{i as y}from"./dist-wf2npcsG.js";import{t as b}from"./input-_LFQwhzd.js";import{n as x}from"./x-BPReZWnP.js";import{t as S}from"./refresh-cw-BjrAbUJe.js";import{i as C,t as w}from"./api-client-DIhJ5qVW.js";import{n as T}from"./utils-CQux7CsO.js";import{a as E,h as D}from"./api-settings-DnHv6JgF.js";var O=v(`bell-off`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742`,key:`178tsu`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05`,key:`1hqiys`}]]),k=v(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),A=v(`bug`,[[`path`,{d:`M12 20v-9`,key:`1qisl0`}],[`path`,{d:`M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z`,key:`uouzyp`}],[`path`,{d:`M14.12 3.88 16 2`,key:`qol33r`}],[`path`,{d:`M21 21a4 4 0 0 0-3.81-4`,key:`1b0z45`}],[`path`,{d:`M21 5a4 4 0 0 1-3.55 3.97`,key:`5cxbf6`}],[`path`,{d:`M22 13h-4`,key:`1jl80f`}],[`path`,{d:`M3 21a4 4 0 0 1 3.81-4`,key:`1fjd4g`}],[`path`,{d:`M3 5a4 4 0 0 0 3.55 3.97`,key:`1d7oge`}],[`path`,{d:`M6 13H2`,key:`82j7cp`}],[`path`,{d:`m8 2 1.88 1.88`,key:`fmnt4t`}],[`path`,{d:`M9 7.13V6a3 3 0 1 1 6 0v1.13`,key:`1vgav8`}]]),j=v(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),M=v(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),N=v(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),P=v(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),F=e(n(),1),I=t();function L({className:e,...t}){return(0,I.jsx)(r,{"data-slot":`label`,className:T(`flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}var R=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(f,{className:T(`peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input`,e),...t,ref:n,children:(0,I.jsx)(h,{className:T(`pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0`)})}));R.displayName=f.displayName;function z({...e}){return(0,I.jsx)(o,{"data-slot":`select`,...e})}function B({...e}){return(0,I.jsx)(l,{"data-slot":`select-value`,...e})}function V({className:e,size:t=`default`,children:n,...r}){return(0,I.jsxs)(d,{"data-slot":`select-trigger`,"data-size":t,className:T(`flex w-fit items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[placeholder]:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...r,children:[n,(0,I.jsx)(p,{asChild:!0,children:(0,I.jsx)(j,{className:`size-4 opacity-50`})})]})}function H({className:e,children:t,position:n=`item-aligned`,align:r=`center`,...a}){return(0,I.jsx)(_,{children:(0,I.jsxs)(i,{"data-slot":`select-content`,className:T(`relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,align:r,...a,children:[(0,I.jsx)(W,{}),(0,I.jsx)(c,{className:T(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1`),children:t}),(0,I.jsx)(G,{})]})})}function U({className:e,children:t,...n}){return(0,I.jsxs)(g,{"data-slot":`select-item`,className:T(`relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,I.jsx)(`span`,{"data-slot":`select-item-indicator`,className:`absolute right-2 flex size-3.5 items-center justify-center`,children:(0,I.jsx)(a,{children:(0,I.jsx)(y,{className:`size-4`})})}),(0,I.jsx)(u,{children:t})]})}function W({className:e,...t}){return(0,I.jsx)(m,{"data-slot":`select-scroll-up-button`,className:T(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(M,{className:`size-4`})})}function G({className:e,...t}){return(0,I.jsx)(s,{"data-slot":`select-scroll-down-button`,className:T(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(j,{className:`size-4`})})}var K={claude:`C`,cursor:`▶`,codex:`◆`,gemini:`G`};function q({value:e,onChange:t,projectName:n}){let[r,i]=(0,F.useState)([]),[a,o]=(0,F.useState)(!1),s=(0,F.useRef)(null),c=(0,F.useRef)(0);(0,F.useEffect)(()=>{n&&w.get(`${C(n)}/chat/providers`).then(i).catch(()=>{})},[n]),(0,F.useEffect)(()=>{if(!a)return;let e=e=>{s.current&&!s.current.contains(e.target)&&o(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[a]),(0,F.useEffect)(()=>{a&&(c.current=Math.max(0,r.findIndex(t=>t.id===e)))},[a,e,r]);let l=(0,F.useCallback)(e=>{if(e.key===`Escape`){o(!1);return}if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;c.current=(c.current+t+r.length)%r.length,(s.current?.querySelector(`[data-idx="${c.current}"]`))?.focus()}if(e.key===`Enter`){e.preventDefault();let n=r[c.current];n&&(t(n.id),o(!1))}},[t,r]);if(r.length<=1)return null;let u=r.find(t=>t.id===e),d=K[e]||`?`;return(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),o(e=>!e)},className:`inline-flex items-center gap-1 px-2 py-1 rounded-md text-[11px] text-text-subtle hover:text-text-primary hover:bg-surface-elevated transition-colors border border-transparent hover:border-border`,"aria-label":`AI Provider: ${u?.name??e}`,children:[(0,I.jsx)(`span`,{className:`inline-flex h-3.5 w-3.5 items-center justify-center rounded text-[9px] font-bold bg-surface-elevated shrink-0`,children:d}),(0,I.jsx)(`span`,{className:`max-w-[80px] truncate capitalize`,children:u?.name??e})]}),a&&(0,I.jsxs)(`div`,{ref:s,role:`listbox`,"aria-label":`AI Providers`,onKeyDown:l,onMouseDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),className:`absolute bottom-full left-0 mb-1 z-50 w-56 rounded-lg border border-border bg-surface shadow-lg`,children:[(0,I.jsx)(`div`,{className:`px-3 py-2 border-b border-border`,children:(0,I.jsx)(`span`,{className:`text-xs font-medium text-text-secondary`,children:`Provider`})}),(0,I.jsx)(`div`,{className:`py-1`,children:r.map((n,r)=>{let i=K[n.id]||`?`,a=n.id===e;return(0,I.jsxs)(`button`,{"data-idx":r,role:`option`,"aria-selected":a,tabIndex:0,onClick:()=>{t(n.id),o(!1)},className:`w-full flex items-center gap-3 px-3 py-2 text-left transition-colors hover:bg-surface-elevated focus:bg-surface-elevated focus:outline-none ${a?`bg-surface-elevated`:``}`,children:[(0,I.jsx)(`span`,{className:`inline-flex h-5 w-5 items-center justify-center rounded text-[11px] font-bold bg-surface-elevated text-text-subtle shrink-0`,children:i}),(0,I.jsx)(`span`,{className:`flex-1 text-sm font-medium text-text-primary capitalize`,children:n.name}),a&&(0,I.jsx)(y,{className:`size-4 shrink-0 text-primary`})]},n.id)})})]})]})}function J({providerId:e}){return(0,I.jsx)(`span`,{className:`inline-flex h-4 w-4 items-center justify-center rounded text-[10px] font-bold bg-surface-elevated text-text-subtle shrink-0`,title:e,children:K[e]||`?`})}var Y=[{value:`low`,label:`Low`},{value:`medium`,label:`Medium`},{value:`high`,label:`High`}],X=[{value:`bypassPermissions`,label:`Bypass permissions (default)`},{value:`default`,label:`Ask before edits`},{value:`acceptEdits`,label:`Edit automatically`},{value:`plan`,label:`Plan mode`}],Z={claude:`Claude`,cursor:`Cursor`,codex:`Codex`,gemini:`Gemini`};function Q({compact:e}={}){let[t,n]=(0,F.useState)(null),[r,i]=(0,F.useState)(``),[a,o]=(0,F.useState)([]),[s,c]=(0,F.useState)(!1),[l,u]=(0,F.useState)(!1),[d,f]=(0,F.useState)(null),[p,m]=(0,F.useState)(0);(0,F.useEffect)(()=>{E().then(e=>{n(e),i(e.default_provider??`claude`)}).catch(e=>f(e.message))},[]),(0,F.useEffect)(()=>{r&&(c(!0),w.get(`/api/settings/ai/providers/${r}/models`).then(o).catch(()=>o([])).finally(()=>c(!1)))},[r]);let h=t?Object.keys(t.providers).filter(e=>e!==`mock`).map(e=>({id:e,name:Z[e]??e})):[],g=t?.providers[r],_=g?.type===`agent-sdk`||!g?.type&&r===`claude`,v=async(e,i)=>{if(t){u(!0),f(null);try{n(await D({providers:{[r]:{[e]:i}}})),m(e=>e+1)}catch(e){f(e.message)}finally{u(!1)}}},y=e?`text-[11px]`:`text-sm`,x=e?`text-xs`:`text-sm`,S=e?`space-y-2`:`space-y-4`,C=e?`space-y-1.5`:`space-y-3`,T=e?`space-y-1`:`space-y-1.5`;if(!t)return(0,I.jsxs)(`div`,{className:C,children:[(0,I.jsx)(`h3`,{className:`${x} font-medium text-text-secondary`,children:`AI Settings`}),(0,I.jsx)(`p`,{className:`${y} text-text-subtle`,children:d?`Error: ${d}`:`Loading...`})]});let O=_?a:[{value:`__default__`,label:`Auto (default)`},...a];return(0,I.jsxs)(`div`,{className:S,children:[(0,I.jsx)(`h3`,{className:`${x} font-medium text-text-secondary`,children:`AI Settings`}),h.length>1&&(0,I.jsx)(`div`,{className:`flex gap-0.5 border-b border-border/50 -mx-1 px-1`,children:h.map(e=>(0,I.jsxs)(`button`,{onClick:()=>i(e.id),className:`flex items-center gap-1 px-2 py-1 text-[11px] rounded-t transition-colors ${r===e.id?`text-primary border-b-2 border-primary font-medium`:`text-text-subtle hover:text-text-secondary`}`,children:[(0,I.jsx)(J,{providerId:e.id}),(0,I.jsx)(`span`,{className:`capitalize`,children:e.name})]},e.id))}),(0,I.jsxs)(`div`,{className:C,children:[a.length>0&&(0,I.jsxs)(`div`,{className:T,children:[(0,I.jsx)(L,{htmlFor:`ai-model`,className:e?y:void 0,children:`Model`}),(0,I.jsxs)(z,{value:_?g?.model??a[0]?.value:g?.model||`__default__`,onValueChange:e=>v(`model`,e===`__default__`?void 0:e),disabled:s,children:[(0,I.jsx)(V,{id:`ai-model`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,I.jsx)(B,{placeholder:s?`Loading models...`:`Select model`})}),(0,I.jsx)(H,{className:`max-h-[300px]`,children:O.map(e=>(0,I.jsx)(U,{value:e.value,children:e.label},e.value))})]})]}),_&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:T,children:[(0,I.jsx)(L,{htmlFor:`ai-base-url`,className:e?y:void 0,children:`Base URL`}),(0,I.jsx)(b,{id:`ai-base-url`,type:`url`,defaultValue:g?.base_url??``,placeholder:`https://api.anthropic.com (default)`,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{v(`base_url`,e.target.value.trim()||void 0)}},`baseurl-${r}-${p}`)]}),(0,I.jsxs)(`div`,{className:T,children:[(0,I.jsx)(L,{htmlFor:`ai-api-key`,className:e?y:void 0,children:`API Key / Token`}),(0,I.jsx)(b,{id:`ai-api-key`,type:`password`,defaultValue:g?.api_key??``,placeholder:`sk-ant-... (optional, overrides accounts)`,className:e?`h-7 text-[11px] font-mono`:`font-mono`,onBlur:e=>{let t=e.target.value.trim();t.startsWith(`••••`)||v(`api_key`,t||void 0)}},`apikey-${r}-${p}`),(0,I.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Direct API key or OAuth token. Leave empty to use connected accounts.`})]}),(0,I.jsxs)(`div`,{className:T,children:[(0,I.jsx)(L,{htmlFor:`ai-effort`,className:e?y:void 0,children:`Effort`}),(0,I.jsxs)(z,{value:g?.effort??`high`,onValueChange:e=>v(`effort`,e),children:[(0,I.jsx)(V,{id:`ai-effort`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,I.jsx)(B,{})}),(0,I.jsx)(H,{children:Y.map(e=>(0,I.jsx)(U,{value:e.value,children:e.label},e.value))})]})]}),(0,I.jsxs)(`div`,{className:T,children:[(0,I.jsx)(L,{htmlFor:`ai-max-turns`,className:e?y:void 0,children:`Max Turns (1-500)`}),(0,I.jsx)(b,{id:`ai-max-turns`,type:`number`,min:1,max:500,defaultValue:g?.max_turns??100,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{let t=parseInt(e.target.value);isNaN(t)||v(`max_turns`,t)}},`turns-${r}-${p}`)]}),(0,I.jsxs)(`div`,{className:T,children:[(0,I.jsx)(L,{htmlFor:`ai-budget`,className:e?y:void 0,children:`Max Budget (USD)`}),(0,I.jsx)(b,{id:`ai-budget`,type:`number`,step:.1,min:.01,max:50,defaultValue:g?.max_budget_usd??``,placeholder:`No limit`,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{let t=parseFloat(e.target.value);v(`max_budget_usd`,isNaN(t)?void 0:t)}},`budget-${r}-${p}`)]}),(0,I.jsxs)(`div`,{className:T,children:[(0,I.jsx)(L,{htmlFor:`ai-thinking`,className:e?y:void 0,children:`Thinking Budget (tokens)`}),(0,I.jsx)(b,{id:`ai-thinking`,type:`number`,min:0,defaultValue:g?.thinking_budget_tokens??``,placeholder:`Disabled`,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{let t=parseInt(e.target.value);v(`thinking_budget_tokens`,isNaN(t)?void 0:t)}},`thinking-${r}-${p}`)]}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(L,{htmlFor:`ai-agent-teams`,className:e?y:void 0,children:`Agent Teams`}),(0,I.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Experimental. Enables multi-agent collaboration with shared tasks and messaging. Uses ~7x more tokens.`})]}),(0,I.jsx)(R,{id:`ai-agent-teams`,checked:g?.agent_teams??!1,onCheckedChange:e=>v(`agent_teams`,e)})]}),g?.agent_teams&&(0,I.jsx)($,{compact:e})]}),(0,I.jsxs)(`div`,{className:T,children:[(0,I.jsx)(L,{htmlFor:`ai-permission-mode`,className:e?y:void 0,children:`Default Permission Mode`}),(0,I.jsxs)(z,{value:g?.permission_mode??`bypassPermissions`,onValueChange:e=>v(`permission_mode`,e),children:[(0,I.jsx)(V,{id:`ai-permission-mode`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,I.jsx)(B,{})}),(0,I.jsx)(H,{children:X.map(e=>(0,I.jsx)(U,{value:e.value,children:e.label},e.value))})]})]}),(0,I.jsxs)(`div`,{className:T,children:[(0,I.jsx)(L,{htmlFor:`ai-system-prompt`,className:e?y:void 0,children:`Additional Instructions`}),(0,I.jsx)(`textarea`,{id:`ai-system-prompt`,rows:e?3:4,defaultValue:g?.system_prompt??``,placeholder:`Enter additional instructions for ${r}...`,className:`w-full rounded-md border border-input bg-background px-3 py-2 ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${e?`text-[11px]`:`text-sm`}`,onBlur:e=>{v(`system_prompt`,e.target.value.trim()||void 0)}},`sysprompt-${r}-${p}`)]})]}),l&&(0,I.jsx)(`p`,{className:`text-xs text-text-subtle`,children:`Saving...`}),d&&(0,I.jsx)(`p`,{className:`text-xs text-red-500`,children:d})]})}function $({compact:e}){let[t,n]=(0,F.useState)([]),[r,i]=(0,F.useState)(!1),[a,o]=(0,F.useState)(null),s=(0,F.useCallback)(async()=>{i(!0);try{n(await w.get(`/api/teams`)??[])}catch{}i(!1)},[]);(0,F.useEffect)(()=>{s()},[s]);let c=async e=>{try{await w.del(`/api/teams/${encodeURIComponent(e)}`),n(t=>t.filter(t=>t.name!==e)),o(null)}catch{}};return t.length===0&&!r?null:(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsxs)(L,{className:e?`text-[11px]`:void 0,children:[`Teams (`,t.length,`)`]}),(0,I.jsx)(`button`,{onClick:s,className:`text-text-subtle hover:text-foreground p-1`,"aria-label":`Refresh teams`,children:(0,I.jsx)(S,{className:`size-3 ${r?`animate-spin`:``}`})})]}),t.map(e=>(0,I.jsxs)(`div`,{className:`flex items-center justify-between p-2 rounded bg-surface-elevated text-xs`,children:[(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`div`,{className:`font-medium truncate`,children:e.name}),e.description&&(0,I.jsx)(`div`,{className:`text-text-subtle truncate`,children:e.description}),(0,I.jsxs)(`div`,{className:`text-text-subtle`,children:[e.members?.length??e.memberCount??0,` members`,e.createdAt?` · ${new Date(e.createdAt).toLocaleDateString()}`:``]})]}),a===e.name?(0,I.jsxs)(`div`,{className:`flex gap-1 shrink-0 ml-2`,children:[(0,I.jsx)(`button`,{onClick:()=>c(e.name),className:`px-2 py-1 bg-red-600 text-white rounded text-[10px]`,children:`Delete`}),(0,I.jsx)(`button`,{onClick:()=>o(null),className:`px-2 py-1 bg-zinc-600 text-white rounded text-[10px]`,children:`Cancel`})]}):(0,I.jsx)(`button`,{onClick:()=>o(e.name),className:`shrink-0 text-text-subtle hover:text-red-500 p-1 ml-2`,"aria-label":`Delete team ${e.name}`,children:(0,I.jsx)(x,{className:`size-3.5`})})]},e.name))]})}export{O as _,H as a,B as c,P as d,N as f,k as g,A as h,z as i,R as l,j as m,J as n,U as o,M as p,q as r,V as s,Q as t,L as u};
|
|
2
|
+
//# sourceMappingURL=ai-settings-section-Btix996C.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-settings-section-Btix996C.js","names":["__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode"],"sources":["../../../node_modules/.bun/lucide-react@0.577.0+b1ab299f0a400331/node_modules/lucide-react/dist/esm/icons/bell-off.js","../../../node_modules/.bun/lucide-react@0.577.0+b1ab299f0a400331/node_modules/lucide-react/dist/esm/icons/bot.js","../../../node_modules/.bun/lucide-react@0.577.0+b1ab299f0a400331/node_modules/lucide-react/dist/esm/icons/bug.js","../../../node_modules/.bun/lucide-react@0.577.0+b1ab299f0a400331/node_modules/lucide-react/dist/esm/icons/chevron-down.js","../../../node_modules/.bun/lucide-react@0.577.0+b1ab299f0a400331/node_modules/lucide-react/dist/esm/icons/chevron-up.js","../../../node_modules/.bun/lucide-react@0.577.0+b1ab299f0a400331/node_modules/lucide-react/dist/esm/icons/lock.js","../../../node_modules/.bun/lucide-react@0.577.0+b1ab299f0a400331/node_modules/lucide-react/dist/esm/icons/pencil.js","../../../src/web/components/ui/label.tsx","../../../src/web/components/ui/switch.tsx","../../../src/web/components/ui/select.tsx","../../../src/web/components/chat/provider-selector.tsx","../../../src/web/components/settings/ai-settings-section.tsx"],"sourcesContent":["/**\n * @license lucide-react v0.577.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst __iconNode = [\n [\"path\", { d: \"M10.268 21a2 2 0 0 0 3.464 0\", key: \"vwvbt9\" }],\n [\n \"path\",\n {\n d: \"M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742\",\n key: \"178tsu\"\n }\n ],\n [\"path\", { d: \"m2 2 20 20\", key: \"1ooewy\" }],\n [\"path\", { d: \"M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05\", key: \"1hqiys\" }]\n];\nconst BellOff = createLucideIcon(\"bell-off\", __iconNode);\n\nexport { __iconNode, BellOff as default };\n//# sourceMappingURL=bell-off.js.map\n","/**\n * @license lucide-react v0.577.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst __iconNode = [\n [\"path\", { d: \"M12 8V4H8\", key: \"hb8ula\" }],\n [\"rect\", { width: \"16\", height: \"12\", x: \"4\", y: \"8\", rx: \"2\", key: \"enze0r\" }],\n [\"path\", { d: \"M2 14h2\", key: \"vft8re\" }],\n [\"path\", { d: \"M20 14h2\", key: \"4cs60a\" }],\n [\"path\", { d: \"M15 13v2\", key: \"1xurst\" }],\n [\"path\", { d: \"M9 13v2\", key: \"rq6x2g\" }]\n];\nconst Bot = createLucideIcon(\"bot\", __iconNode);\n\nexport { __iconNode, Bot as default };\n//# sourceMappingURL=bot.js.map\n","/**\n * @license lucide-react v0.577.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst __iconNode = [\n [\"path\", { d: \"M12 20v-9\", key: \"1qisl0\" }],\n [\"path\", { d: \"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z\", key: \"uouzyp\" }],\n [\"path\", { d: \"M14.12 3.88 16 2\", key: \"qol33r\" }],\n [\"path\", { d: \"M21 21a4 4 0 0 0-3.81-4\", key: \"1b0z45\" }],\n [\"path\", { d: \"M21 5a4 4 0 0 1-3.55 3.97\", key: \"5cxbf6\" }],\n [\"path\", { d: \"M22 13h-4\", key: \"1jl80f\" }],\n [\"path\", { d: \"M3 21a4 4 0 0 1 3.81-4\", key: \"1fjd4g\" }],\n [\"path\", { d: \"M3 5a4 4 0 0 0 3.55 3.97\", key: \"1d7oge\" }],\n [\"path\", { d: \"M6 13H2\", key: \"82j7cp\" }],\n [\"path\", { d: \"m8 2 1.88 1.88\", key: \"fmnt4t\" }],\n [\"path\", { d: \"M9 7.13V6a3 3 0 1 1 6 0v1.13\", key: \"1vgav8\" }]\n];\nconst Bug = createLucideIcon(\"bug\", __iconNode);\n\nexport { __iconNode, Bug as default };\n//# sourceMappingURL=bug.js.map\n","/**\n * @license lucide-react v0.577.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst __iconNode = [[\"path\", { d: \"m6 9 6 6 6-6\", key: \"qrunsl\" }]];\nconst ChevronDown = createLucideIcon(\"chevron-down\", __iconNode);\n\nexport { __iconNode, ChevronDown as default };\n//# sourceMappingURL=chevron-down.js.map\n","/**\n * @license lucide-react v0.577.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst __iconNode = [[\"path\", { d: \"m18 15-6-6-6 6\", key: \"153udz\" }]];\nconst ChevronUp = createLucideIcon(\"chevron-up\", __iconNode);\n\nexport { __iconNode, ChevronUp as default };\n//# sourceMappingURL=chevron-up.js.map\n","/**\n * @license lucide-react v0.577.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst __iconNode = [\n [\"rect\", { width: \"18\", height: \"11\", x: \"3\", y: \"11\", rx: \"2\", ry: \"2\", key: \"1w4ew1\" }],\n [\"path\", { d: \"M7 11V7a5 5 0 0 1 10 0v4\", key: \"fwvmzm\" }]\n];\nconst Lock = createLucideIcon(\"lock\", __iconNode);\n\nexport { __iconNode, Lock as default };\n//# sourceMappingURL=lock.js.map\n","/**\n * @license lucide-react v0.577.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst __iconNode = [\n [\n \"path\",\n {\n d: \"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z\",\n key: \"1a8usu\"\n }\n ],\n [\"path\", { d: \"m15 5 4 4\", key: \"1mk7zo\" }]\n];\nconst Pencil = createLucideIcon(\"pencil\", __iconNode);\n\nexport { __iconNode, Pencil as default };\n//# sourceMappingURL=pencil.js.map\n","\"use client\"\n\nimport * as React from \"react\"\nimport { Label as LabelPrimitive } from \"radix-ui\"\n\nimport { cn } from \"@/lib/utils\"\n\nfunction Label({\n className,\n ...props\n}: React.ComponentProps<typeof LabelPrimitive.Root>) {\n return (\n <LabelPrimitive.Root\n data-slot=\"label\"\n className={cn(\n \"flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50\",\n className\n )}\n {...props}\n />\n )\n}\n\nexport { Label }\n","import * as React from \"react\"\nimport * as SwitchPrimitives from \"@radix-ui/react-switch\"\n\nimport { cn } from \"@/lib/utils\"\n\nconst Switch = React.forwardRef<\n React.ComponentRef<typeof SwitchPrimitives.Root>,\n React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root>\n>(({ className, ...props }, ref) => (\n <SwitchPrimitives.Root\n className={cn(\n \"peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input\",\n className\n )}\n {...props}\n ref={ref}\n >\n <SwitchPrimitives.Thumb\n className={cn(\n \"pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0\"\n )}\n />\n </SwitchPrimitives.Root>\n))\nSwitch.displayName = SwitchPrimitives.Root.displayName\n\nexport { Switch }\n","import * as React from \"react\"\nimport { CheckIcon, ChevronDownIcon, ChevronUpIcon } from \"lucide-react\"\nimport { Select as SelectPrimitive } from \"radix-ui\"\n\nimport { cn } from \"@/lib/utils\"\n\nfunction Select({\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Root>) {\n return <SelectPrimitive.Root data-slot=\"select\" {...props} />\n}\n\nfunction SelectGroup({\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Group>) {\n return <SelectPrimitive.Group data-slot=\"select-group\" {...props} />\n}\n\nfunction SelectValue({\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Value>) {\n return <SelectPrimitive.Value data-slot=\"select-value\" {...props} />\n}\n\nfunction SelectTrigger({\n className,\n size = \"default\",\n children,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Trigger> & {\n size?: \"sm\" | \"default\"\n}) {\n return (\n <SelectPrimitive.Trigger\n data-slot=\"select-trigger\"\n data-size={size}\n className={cn(\n \"flex w-fit items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[placeholder]:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground\",\n className\n )}\n {...props}\n >\n {children}\n <SelectPrimitive.Icon asChild>\n <ChevronDownIcon className=\"size-4 opacity-50\" />\n </SelectPrimitive.Icon>\n </SelectPrimitive.Trigger>\n )\n}\n\nfunction SelectContent({\n className,\n children,\n position = \"item-aligned\",\n align = \"center\",\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Content>) {\n return (\n <SelectPrimitive.Portal>\n <SelectPrimitive.Content\n data-slot=\"select-content\"\n className={cn(\n \"relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95\",\n position === \"popper\" &&\n \"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1\",\n className\n )}\n position={position}\n align={align}\n {...props}\n >\n <SelectScrollUpButton />\n <SelectPrimitive.Viewport\n className={cn(\n \"p-1\",\n position === \"popper\" &&\n \"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1\"\n )}\n >\n {children}\n </SelectPrimitive.Viewport>\n <SelectScrollDownButton />\n </SelectPrimitive.Content>\n </SelectPrimitive.Portal>\n )\n}\n\nfunction SelectLabel({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Label>) {\n return (\n <SelectPrimitive.Label\n data-slot=\"select-label\"\n className={cn(\"px-2 py-1.5 text-xs text-muted-foreground\", className)}\n {...props}\n />\n )\n}\n\nfunction SelectItem({\n className,\n children,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Item>) {\n return (\n <SelectPrimitive.Item\n data-slot=\"select-item\"\n className={cn(\n \"relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2\",\n className\n )}\n {...props}\n >\n <span\n data-slot=\"select-item-indicator\"\n className=\"absolute right-2 flex size-3.5 items-center justify-center\"\n >\n <SelectPrimitive.ItemIndicator>\n <CheckIcon className=\"size-4\" />\n </SelectPrimitive.ItemIndicator>\n </span>\n <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\n </SelectPrimitive.Item>\n )\n}\n\nfunction SelectSeparator({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Separator>) {\n return (\n <SelectPrimitive.Separator\n data-slot=\"select-separator\"\n className={cn(\"pointer-events-none -mx-1 my-1 h-px bg-border\", className)}\n {...props}\n />\n )\n}\n\nfunction SelectScrollUpButton({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.ScrollUpButton>) {\n return (\n <SelectPrimitive.ScrollUpButton\n data-slot=\"select-scroll-up-button\"\n className={cn(\n \"flex cursor-default items-center justify-center py-1\",\n className\n )}\n {...props}\n >\n <ChevronUpIcon className=\"size-4\" />\n </SelectPrimitive.ScrollUpButton>\n )\n}\n\nfunction SelectScrollDownButton({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.ScrollDownButton>) {\n return (\n <SelectPrimitive.ScrollDownButton\n data-slot=\"select-scroll-down-button\"\n className={cn(\n \"flex cursor-default items-center justify-center py-1\",\n className\n )}\n {...props}\n >\n <ChevronDownIcon className=\"size-4\" />\n </SelectPrimitive.ScrollDownButton>\n )\n}\n\nexport {\n Select,\n SelectContent,\n SelectGroup,\n SelectItem,\n SelectLabel,\n SelectScrollDownButton,\n SelectScrollUpButton,\n SelectSeparator,\n SelectTrigger,\n SelectValue,\n}\n","import { useState, useEffect, useRef, useCallback, type KeyboardEvent } from \"react\";\nimport { Check } from \"lucide-react\";\nimport { api, projectUrl } from \"@/lib/api-client\";\n\ninterface ProviderInfo {\n id: string;\n name: string;\n}\n\ninterface ProviderSelectorProps {\n value: string;\n onChange: (providerId: string) => void;\n projectName: string;\n}\n\nconst PROVIDER_ICONS: Record<string, string> = {\n claude: \"C\",\n cursor: \"▶\",\n codex: \"◆\",\n gemini: \"G\",\n};\n\n/**\n * Provider selector chip + popup — matches ModeSelector style.\n * Hidden when only 1 provider available.\n */\nexport function ProviderSelector({ value, onChange, projectName }: ProviderSelectorProps) {\n const [providers, setProviders] = useState<ProviderInfo[]>([]);\n const [open, setOpen] = useState(false);\n const panelRef = useRef<HTMLDivElement>(null);\n const focusedRef = useRef(0);\n\n useEffect(() => {\n if (!projectName) return;\n api.get<ProviderInfo[]>(`${projectUrl(projectName)}/chat/providers`)\n .then(setProviders)\n .catch(() => {});\n }, [projectName]);\n\n // Close on click outside\n useEffect(() => {\n if (!open) return;\n const handler = (e: MouseEvent) => {\n if (panelRef.current && !panelRef.current.contains(e.target as Node)) {\n setOpen(false);\n }\n };\n document.addEventListener(\"mousedown\", handler);\n return () => document.removeEventListener(\"mousedown\", handler);\n }, [open]);\n\n // Focus current on open\n useEffect(() => {\n if (open) {\n focusedRef.current = Math.max(0, providers.findIndex((p) => p.id === value));\n }\n }, [open, value, providers]);\n\n const handleKeyDown = useCallback((e: KeyboardEvent) => {\n if (e.key === \"Escape\") { setOpen(false); return; }\n if (e.key === \"ArrowDown\" || e.key === \"ArrowUp\") {\n e.preventDefault();\n const dir = e.key === \"ArrowDown\" ? 1 : -1;\n focusedRef.current = (focusedRef.current + dir + providers.length) % providers.length;\n const el = panelRef.current?.querySelector(`[data-idx=\"${focusedRef.current}\"]`) as HTMLElement;\n el?.focus();\n }\n if (e.key === \"Enter\") {\n e.preventDefault();\n const p = providers[focusedRef.current];\n if (p) { onChange(p.id); setOpen(false); }\n }\n }, [onChange, providers]);\n\n // Hide when only 1 provider\n if (providers.length <= 1) return null;\n\n const current = providers.find((p) => p.id === value);\n const icon = PROVIDER_ICONS[value] || \"?\";\n\n return (\n <div className=\"relative\">\n {/* Chip — same style as ModeChip */}\n <button\n type=\"button\"\n onClick={(e) => { e.stopPropagation(); setOpen((v) => !v); }}\n className=\"inline-flex items-center gap-1 px-2 py-1 rounded-md text-[11px] text-text-subtle hover:text-text-primary hover:bg-surface-elevated transition-colors border border-transparent hover:border-border\"\n aria-label={`AI Provider: ${current?.name ?? value}`}\n >\n <span className=\"inline-flex h-3.5 w-3.5 items-center justify-center rounded text-[9px] font-bold bg-surface-elevated shrink-0\">\n {icon}\n </span>\n <span className=\"max-w-[80px] truncate capitalize\">{current?.name ?? value}</span>\n </button>\n\n {/* Popup panel — same style as ModeSelector */}\n {open && (\n <div\n ref={panelRef}\n role=\"listbox\"\n aria-label=\"AI Providers\"\n onKeyDown={handleKeyDown}\n onMouseDown={(e) => e.stopPropagation()}\n onClick={(e) => e.stopPropagation()}\n className=\"absolute bottom-full left-0 mb-1 z-50 w-56 rounded-lg border border-border bg-surface shadow-lg\"\n >\n <div className=\"px-3 py-2 border-b border-border\">\n <span className=\"text-xs font-medium text-text-secondary\">Provider</span>\n </div>\n <div className=\"py-1\">\n {providers.map((p, idx) => {\n const pIcon = PROVIDER_ICONS[p.id] || \"?\";\n const isActive = p.id === value;\n return (\n <button\n key={p.id}\n data-idx={idx}\n role=\"option\"\n aria-selected={isActive}\n tabIndex={0}\n onClick={() => { onChange(p.id); setOpen(false); }}\n className={`w-full flex items-center gap-3 px-3 py-2 text-left transition-colors hover:bg-surface-elevated focus:bg-surface-elevated focus:outline-none ${isActive ? \"bg-surface-elevated\" : \"\"}`}\n >\n <span className=\"inline-flex h-5 w-5 items-center justify-center rounded text-[11px] font-bold bg-surface-elevated text-text-subtle shrink-0\">\n {pIcon}\n </span>\n <span className=\"flex-1 text-sm font-medium text-text-primary capitalize\">{p.name}</span>\n {isActive && <Check className=\"size-4 shrink-0 text-primary\" />}\n </button>\n );\n })}\n </div>\n </div>\n )}\n </div>\n );\n}\n\n/** Small provider badge for session lists */\nexport function ProviderBadge({ providerId }: { providerId: string }) {\n const icon = PROVIDER_ICONS[providerId] || \"?\";\n return (\n <span\n className=\"inline-flex h-4 w-4 items-center justify-center rounded text-[10px] font-bold bg-surface-elevated text-text-subtle shrink-0\"\n title={providerId}\n >\n {icon}\n </span>\n );\n}\n","import { useState, useEffect, useCallback } from \"react\";\nimport { RefreshCw, Trash2 } from \"lucide-react\";\nimport { Input } from \"@/components/ui/input\";\nimport { Label } from \"@/components/ui/label\";\nimport {\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from \"@/components/ui/select\";\nimport { Switch } from \"@/components/ui/switch\";\nimport { getAISettings, updateAISettings, type AISettings } from \"@/lib/api-settings\";\nimport { api } from \"@/lib/api-client\";\nimport { ProviderBadge } from \"@/components/chat/provider-selector\";\nimport type { ModelOption } from \"../../../types/chat\";\n\nconst EFFORT_OPTIONS = [\n { value: \"low\", label: \"Low\" },\n { value: \"medium\", label: \"Medium\" },\n { value: \"high\", label: \"High\" },\n];\n\nconst PERMISSION_MODE_OPTIONS = [\n { value: \"bypassPermissions\", label: \"Bypass permissions (default)\" },\n { value: \"default\", label: \"Ask before edits\" },\n { value: \"acceptEdits\", label: \"Edit automatically\" },\n { value: \"plan\", label: \"Plan mode\" },\n];\n\nconst PROVIDER_NAMES: Record<string, string> = {\n claude: \"Claude\",\n cursor: \"Cursor\",\n codex: \"Codex\",\n gemini: \"Gemini\",\n};\n\nexport function AISettingsSection({ compact }: { compact?: boolean } = {}) {\n const [settings, setSettings] = useState<AISettings | null>(null);\n const [activeTab, setActiveTab] = useState<string>(\"\");\n const [models, setModels] = useState<ModelOption[]>([]);\n const [modelsLoading, setModelsLoading] = useState(false);\n const [saving, setSaving] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const [revision, setRevision] = useState(0);\n\n useEffect(() => {\n getAISettings().then((s) => {\n setSettings(s);\n setActiveTab(s.default_provider ?? \"claude\");\n }).catch((e) => setError(e.message));\n }, []);\n\n // Fetch models when active tab changes — uses global settings endpoint\n useEffect(() => {\n if (!activeTab) return;\n setModelsLoading(true);\n api.get<ModelOption[]>(`/api/settings/ai/providers/${activeTab}/models`)\n .then(setModels)\n .catch(() => setModels([]))\n .finally(() => setModelsLoading(false));\n }, [activeTab]);\n\n const providerTabs = settings\n ? Object.keys(settings.providers)\n .filter((k) => k !== \"mock\")\n .map((id) => ({ id, name: PROVIDER_NAMES[id] ?? id }))\n : [];\n\n const config = settings?.providers[activeTab];\n const isSdkProvider = config?.type === \"agent-sdk\" || (!config?.type && activeTab === \"claude\");\n\n const handleSave = async (field: string, value: unknown) => {\n if (!settings) return;\n setSaving(true);\n setError(null);\n try {\n const updated = await updateAISettings({\n providers: { [activeTab]: { [field]: value } },\n });\n setSettings(updated);\n setRevision((r) => r + 1);\n } catch (e) {\n setError((e as Error).message);\n } finally {\n setSaving(false);\n }\n };\n\n const labelSize = compact ? \"text-[11px]\" : \"text-sm\";\n const headingSize = compact ? \"text-xs\" : \"text-sm\";\n const gapSize = compact ? \"space-y-2\" : \"space-y-4\";\n const innerGap = compact ? \"space-y-1.5\" : \"space-y-3\";\n const fieldGap = compact ? \"space-y-1\" : \"space-y-1.5\";\n\n if (!settings) {\n return (\n <div className={innerGap}>\n <h3 className={`${headingSize} font-medium text-text-secondary`}>AI Settings</h3>\n <p className={`${labelSize} text-text-subtle`}>\n {error ? `Error: ${error}` : \"Loading...\"}\n </p>\n </div>\n );\n }\n\n // Model select options: use fetched models, with \"auto\" option for non-SDK providers\n const modelOptions = isSdkProvider\n ? models\n : [{ value: \"__default__\", label: \"Auto (default)\" }, ...models];\n\n return (\n <div className={gapSize}>\n <h3 className={`${headingSize} font-medium text-text-secondary`}>AI Settings</h3>\n\n {/* Provider tabs */}\n {providerTabs.length > 1 && (\n <div className=\"flex gap-0.5 border-b border-border/50 -mx-1 px-1\">\n {providerTabs.map((p) => (\n <button\n key={p.id}\n onClick={() => setActiveTab(p.id)}\n className={`flex items-center gap-1 px-2 py-1 text-[11px] rounded-t transition-colors ${\n activeTab === p.id\n ? \"text-primary border-b-2 border-primary font-medium\"\n : \"text-text-subtle hover:text-text-secondary\"\n }`}\n >\n <ProviderBadge providerId={p.id} />\n <span className=\"capitalize\">{p.name}</span>\n </button>\n ))}\n </div>\n )}\n\n <div className={innerGap}>\n {/* Model selector — dynamic, works for all providers */}\n {models.length > 0 && (\n <div className={fieldGap}>\n <Label htmlFor=\"ai-model\" className={compact ? labelSize : undefined}>Model</Label>\n <Select\n value={isSdkProvider ? (config?.model ?? models[0]?.value) : (config?.model || \"__default__\")}\n onValueChange={(v) => handleSave(\"model\", v === \"__default__\" ? undefined : v)}\n disabled={modelsLoading}\n >\n <SelectTrigger id=\"ai-model\" className={`w-full ${compact ? \"h-7 text-[11px]\" : \"\"}`}>\n <SelectValue placeholder={modelsLoading ? \"Loading models...\" : \"Select model\"} />\n </SelectTrigger>\n <SelectContent className=\"max-h-[300px]\">\n {modelOptions.map((opt) => (\n <SelectItem key={opt.value} value={opt.value}>\n {opt.label}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n )}\n\n {/* SDK-specific fields */}\n {isSdkProvider && (\n <>\n <div className={fieldGap}>\n <Label htmlFor=\"ai-base-url\" className={compact ? labelSize : undefined}>Base URL</Label>\n <Input\n key={`baseurl-${activeTab}-${revision}`}\n id=\"ai-base-url\"\n type=\"url\"\n defaultValue={config?.base_url ?? \"\"}\n placeholder=\"https://api.anthropic.com (default)\"\n className={compact ? \"h-7 text-[11px]\" : undefined}\n onBlur={(e) => {\n const val = e.target.value.trim();\n handleSave(\"base_url\", val || undefined);\n }}\n />\n </div>\n\n <div className={fieldGap}>\n <Label htmlFor=\"ai-api-key\" className={compact ? labelSize : undefined}>API Key / Token</Label>\n <Input\n key={`apikey-${activeTab}-${revision}`}\n id=\"ai-api-key\"\n type=\"password\"\n defaultValue={config?.api_key ?? \"\"}\n placeholder=\"sk-ant-... (optional, overrides accounts)\"\n className={compact ? \"h-7 text-[11px] font-mono\" : \"font-mono\"}\n onBlur={(e) => {\n const val = e.target.value.trim();\n if (val.startsWith(\"••••\")) return;\n handleSave(\"api_key\", val || undefined);\n }}\n />\n <p className={`${compact ? \"text-[9px]\" : \"text-[11px]\"} text-muted-foreground`}>\n Direct API key or OAuth token. Leave empty to use connected accounts.\n </p>\n </div>\n\n <div className={fieldGap}>\n <Label htmlFor=\"ai-effort\" className={compact ? labelSize : undefined}>Effort</Label>\n <Select\n value={config?.effort ?? \"high\"}\n onValueChange={(v) => handleSave(\"effort\", v)}\n >\n <SelectTrigger id=\"ai-effort\" className={`w-full ${compact ? \"h-7 text-[11px]\" : \"\"}`}>\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {EFFORT_OPTIONS.map((opt) => (\n <SelectItem key={opt.value} value={opt.value}>\n {opt.label}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n\n <div className={fieldGap}>\n <Label htmlFor=\"ai-max-turns\" className={compact ? labelSize : undefined}>Max Turns (1-500)</Label>\n <Input\n key={`turns-${activeTab}-${revision}`}\n id=\"ai-max-turns\"\n type=\"number\"\n min={1}\n max={500}\n defaultValue={config?.max_turns ?? 100}\n className={compact ? \"h-7 text-[11px]\" : undefined}\n onBlur={(e) => {\n const val = parseInt(e.target.value);\n if (!isNaN(val)) handleSave(\"max_turns\", val);\n }}\n />\n </div>\n\n <div className={fieldGap}>\n <Label htmlFor=\"ai-budget\" className={compact ? labelSize : undefined}>Max Budget (USD)</Label>\n <Input\n key={`budget-${activeTab}-${revision}`}\n id=\"ai-budget\"\n type=\"number\"\n step={0.1}\n min={0.01}\n max={50}\n defaultValue={config?.max_budget_usd ?? \"\"}\n placeholder=\"No limit\"\n className={compact ? \"h-7 text-[11px]\" : undefined}\n onBlur={(e) => {\n const val = parseFloat(e.target.value);\n handleSave(\"max_budget_usd\", isNaN(val) ? undefined : val);\n }}\n />\n </div>\n\n <div className={fieldGap}>\n <Label htmlFor=\"ai-thinking\" className={compact ? labelSize : undefined}>Thinking Budget (tokens)</Label>\n <Input\n key={`thinking-${activeTab}-${revision}`}\n id=\"ai-thinking\"\n type=\"number\"\n min={0}\n defaultValue={config?.thinking_budget_tokens ?? \"\"}\n placeholder=\"Disabled\"\n className={compact ? \"h-7 text-[11px]\" : undefined}\n onBlur={(e) => {\n const val = parseInt(e.target.value);\n handleSave(\"thinking_budget_tokens\", isNaN(val) ? undefined : val);\n }}\n />\n </div>\n\n <div className=\"flex items-center justify-between gap-2\">\n <div>\n <Label htmlFor=\"ai-agent-teams\" className={compact ? labelSize : undefined}>Agent Teams</Label>\n <p className={`${compact ? \"text-[9px]\" : \"text-[11px]\"} text-muted-foreground`}>\n Experimental. Enables multi-agent collaboration with shared tasks and messaging. Uses ~7x more tokens.\n </p>\n </div>\n <Switch\n id=\"ai-agent-teams\"\n checked={config?.agent_teams ?? false}\n onCheckedChange={(v) => handleSave(\"agent_teams\", v)}\n />\n </div>\n\n {config?.agent_teams && (\n <TeamListSection compact={compact} />\n )}\n </>\n )}\n\n {/* Common fields: permission mode + system prompt (all providers) */}\n <div className={fieldGap}>\n <Label htmlFor=\"ai-permission-mode\" className={compact ? labelSize : undefined}>Default Permission Mode</Label>\n <Select\n value={config?.permission_mode ?? \"bypassPermissions\"}\n onValueChange={(v) => handleSave(\"permission_mode\", v)}\n >\n <SelectTrigger id=\"ai-permission-mode\" className={`w-full ${compact ? \"h-7 text-[11px]\" : \"\"}`}>\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {PERMISSION_MODE_OPTIONS.map((opt) => (\n <SelectItem key={opt.value} value={opt.value}>\n {opt.label}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n\n <div className={fieldGap}>\n <Label htmlFor=\"ai-system-prompt\" className={compact ? labelSize : undefined}>Additional Instructions</Label>\n <textarea\n key={`sysprompt-${activeTab}-${revision}`}\n id=\"ai-system-prompt\"\n rows={compact ? 3 : 4}\n defaultValue={config?.system_prompt ?? \"\"}\n placeholder={`Enter additional instructions for ${activeTab}...`}\n className={`w-full rounded-md border border-input bg-background px-3 py-2 ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${compact ? \"text-[11px]\" : \"text-sm\"}`}\n onBlur={(e) => {\n const val = e.target.value.trim();\n handleSave(\"system_prompt\", val || undefined);\n }}\n />\n </div>\n </div>\n\n {saving && <p className=\"text-xs text-text-subtle\">Saving...</p>}\n {error && <p className=\"text-xs text-red-500\">{error}</p>}\n </div>\n );\n}\n\n/** Team list shown below the Agent Teams toggle in AI Settings */\nfunction TeamListSection({ compact }: { compact?: boolean }) {\n const [teams, setTeams] = useState<any[]>([]);\n const [loading, setLoading] = useState(false);\n const [deleteConfirm, setDeleteConfirm] = useState<string | null>(null);\n\n const fetchTeams = useCallback(async () => {\n setLoading(true);\n try {\n const data = await api.get<any[]>(\"/api/teams\");\n setTeams(data ?? []);\n } catch {}\n setLoading(false);\n }, []);\n\n useEffect(() => { fetchTeams(); }, [fetchTeams]);\n\n const handleDelete = async (name: string) => {\n try {\n await api.del(`/api/teams/${encodeURIComponent(name)}`);\n setTeams((prev) => prev.filter((t) => t.name !== name));\n setDeleteConfirm(null);\n } catch {}\n };\n\n if (teams.length === 0 && !loading) return null;\n\n return (\n <div className=\"space-y-1.5\">\n <div className=\"flex items-center justify-between\">\n <Label className={compact ? \"text-[11px]\" : undefined}>\n Teams ({teams.length})\n </Label>\n <button onClick={fetchTeams} className=\"text-text-subtle hover:text-foreground p-1\" aria-label=\"Refresh teams\">\n <RefreshCw className={`size-3 ${loading ? \"animate-spin\" : \"\"}`} />\n </button>\n </div>\n {teams.map((team) => (\n <div key={team.name} className=\"flex items-center justify-between p-2 rounded bg-surface-elevated text-xs\">\n <div className=\"min-w-0\">\n <div className=\"font-medium truncate\">{team.name}</div>\n {team.description && <div className=\"text-text-subtle truncate\">{team.description}</div>}\n <div className=\"text-text-subtle\">\n {team.members?.length ?? team.memberCount ?? 0} members\n {team.createdAt ? ` · ${new Date(team.createdAt).toLocaleDateString()}` : \"\"}\n </div>\n </div>\n {deleteConfirm === team.name ? (\n <div className=\"flex gap-1 shrink-0 ml-2\">\n <button\n onClick={() => handleDelete(team.name)}\n className=\"px-2 py-1 bg-red-600 text-white rounded text-[10px]\"\n >\n Delete\n </button>\n <button\n onClick={() => setDeleteConfirm(null)}\n className=\"px-2 py-1 bg-zinc-600 text-white rounded text-[10px]\"\n >\n Cancel\n </button>\n </div>\n ) : (\n <button\n onClick={() => setDeleteConfirm(team.name)}\n className=\"shrink-0 text-text-subtle hover:text-red-500 p-1 ml-2\"\n aria-label={`Delete team ${team.name}`}\n >\n <Trash2 className=\"size-3.5\" />\n </button>\n )}\n </div>\n ))}\n </div>\n );\n}\n"],"x_google_ignoreList":[0,1,2,3,4,5,6],"mappings":"+lBAqBA,IAAM,EAAU,EAAiB,WAZd,CACjB,CAAC,OAAQ,CAAE,EAAG,+BAAgC,IAAK,SAAU,CAAC,CAC9D,CACE,OACA,CACE,EAAG,6EACH,IAAK,SACN,CACF,CACD,CAAC,OAAQ,CAAE,EAAG,aAAc,IAAK,SAAU,CAAC,CAC5C,CAAC,OAAQ,CAAE,EAAG,yDAA0D,IAAK,SAAU,CAAC,CACzF,CACuD,CCJlD,EAAM,EAAiB,MARV,CACjB,CAAC,OAAQ,CAAE,EAAG,YAAa,IAAK,SAAU,CAAC,CAC3C,CAAC,OAAQ,CAAE,MAAO,KAAM,OAAQ,KAAM,EAAG,IAAK,EAAG,IAAK,GAAI,IAAK,IAAK,SAAU,CAAC,CAC/E,CAAC,OAAQ,CAAE,EAAG,UAAW,IAAK,SAAU,CAAC,CACzC,CAAC,OAAQ,CAAE,EAAG,WAAY,IAAK,SAAU,CAAC,CAC1C,CAAC,OAAQ,CAAE,EAAG,WAAY,IAAK,SAAU,CAAC,CAC1C,CAAC,OAAQ,CAAE,EAAG,UAAW,IAAK,SAAU,CAAC,CAC1C,CAC8C,CCKzC,EAAM,EAAiB,MAbV,CACjB,CAAC,OAAQ,CAAE,EAAG,YAAa,IAAK,SAAU,CAAC,CAC3C,CAAC,OAAQ,CAAE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AK,CAC1C,UAAU,wDACV,aAAY,eAAe,EAAK,0BAE/B,EAAD,CAAQ,UAAU,WAAa,CAAA,CACxB,CAAA,CAEP,EAjCI,EAAK,KAiCT,CACN,CACE"}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-FhOqtrmT.js";var t=e({api:()=>i,getAuthToken:()=>s,projectUrl:()=>a,setAuthToken:()=>o}),n=`ppm-auth-token`,r=`ppm-auth-reload-ts`,i=new class{baseUrl;constructor(e=``){this.baseUrl=e}getToken(){return localStorage.getItem(n)}headers(){let e={"Content-Type":`application/json`},t=this.getToken();return t&&(e.Authorization=`Bearer ${t}`),e}async get(e,t){let n=await fetch(`${this.baseUrl}${e}`,{headers:this.headers(),signal:t?.signal});return this.handleResponse(n)}async post(e,t){let n=await fetch(`${this.baseUrl}${e}`,{method:`POST`,headers:this.headers(),body:t==null?void 0:JSON.stringify(t)});return this.handleResponse(n)}async put(e,t){let n=await fetch(`${this.baseUrl}${e}`,{method:`PUT`,headers:this.headers(),body:t==null?void 0:JSON.stringify(t)});return this.handleResponse(n)}async patch(e,t){let n=await fetch(`${this.baseUrl}${e}`,{method:`PATCH`,headers:this.headers(),body:t==null?void 0:JSON.stringify(t)});return this.handleResponse(n)}async del(e,t){let n=await fetch(`${this.baseUrl}${e}`,{method:`DELETE`,headers:this.headers(),body:t==null?void 0:JSON.stringify(t)});await this.handleResponse(n)}async handleResponse(e){if(e.status===401){localStorage.removeItem(n);let e=Number(sessionStorage.getItem(r)||`0`);throw Date.now()-e>3e3&&(sessionStorage.setItem(r,String(Date.now())),window.location.reload()),Error(`Unauthorized`)}let t;try{t=await e.json()}catch{throw Error(e.ok?`Empty response from server`:`Server error (HTTP ${e.status})`)}if(t.ok===!1)throw Error(t.error??`HTTP ${e.status}`);return t.data}};function a(e){return`/api/project/${encodeURIComponent(e)}`}function o(e){localStorage.setItem(n,e)}function s(){return localStorage.getItem(n)}export{o as a,a as i,t as n,s as r,i as t};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-FhOqtrmT.js";var t=e({api:()=>i,getAuthToken:()=>s,projectUrl:()=>a,setAuthToken:()=>o}),n=`ppm-auth-token`,r=`ppm-auth-reload-ts`,i=new class{baseUrl;constructor(e=``){this.baseUrl=e}getToken(){return localStorage.getItem(n)}headers(){let e={"Content-Type":`application/json`},t=this.getToken();return t&&(e.Authorization=`Bearer ${t}`),e}async get(e,t){let n=await fetch(`${this.baseUrl}${e}`,{headers:this.headers(),signal:t?.signal});return this.handleResponse(n)}async post(e,t){let n=await fetch(`${this.baseUrl}${e}`,{method:`POST`,headers:this.headers(),body:t==null?void 0:JSON.stringify(t)});return this.handleResponse(n)}async put(e,t){let n=await fetch(`${this.baseUrl}${e}`,{method:`PUT`,headers:this.headers(),body:t==null?void 0:JSON.stringify(t)});return this.handleResponse(n)}async patch(e,t){let n=await fetch(`${this.baseUrl}${e}`,{method:`PATCH`,headers:this.headers(),body:t==null?void 0:JSON.stringify(t)});return this.handleResponse(n)}async del(e,t){let n=await fetch(`${this.baseUrl}${e}`,{method:`DELETE`,headers:this.headers(),body:t==null?void 0:JSON.stringify(t)});await this.handleResponse(n)}async handleResponse(e){if(e.status===401){localStorage.removeItem(n);let e=Number(sessionStorage.getItem(r)||`0`);throw Date.now()-e>3e3&&(sessionStorage.setItem(r,String(Date.now())),window.location.reload()),Error(`Unauthorized`)}let t;try{t=await e.json()}catch{throw Error(e.ok?`Empty response from server`:`Server error (HTTP ${e.status})`)}if(t.ok===!1)throw Error(t.error??`HTTP ${e.status}`);return t.data}};function a(e){return`/api/project/${encodeURIComponent(e)}`}function o(e){localStorage.setItem(n,e)}function s(){return localStorage.getItem(n)}export{o as a,a as i,t as n,s as r,i as t};
|
|
2
|
+
//# sourceMappingURL=api-client-DIhJ5qVW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-client-DIhJ5qVW.js","names":[],"sources":["../../../src/web/lib/api-client.ts"],"sourcesContent":["const TOKEN_KEY = \"ppm-auth-token\";\nconst RELOAD_GUARD_KEY = \"ppm-auth-reload-ts\";\n\nclass ApiClient {\n private baseUrl: string;\n\n constructor(baseUrl = \"\") {\n this.baseUrl = baseUrl;\n }\n\n private getToken(): string | null {\n return localStorage.getItem(TOKEN_KEY);\n }\n\n private headers(): HeadersInit {\n const h: HeadersInit = { \"Content-Type\": \"application/json\" };\n const token = this.getToken();\n if (token) h[\"Authorization\"] = `Bearer ${token}`;\n return h;\n }\n\n /** Auto-unwraps {ok, data} envelope. Returns T directly. */\n async get<T>(path: string, options?: { signal?: AbortSignal }): Promise<T> {\n const res = await fetch(`${this.baseUrl}${path}`, {\n headers: this.headers(),\n signal: options?.signal,\n });\n return this.handleResponse<T>(res);\n }\n\n async post<T>(path: string, body?: unknown): Promise<T> {\n const res = await fetch(`${this.baseUrl}${path}`, {\n method: \"POST\",\n headers: this.headers(),\n body: body != null ? JSON.stringify(body) : undefined,\n });\n return this.handleResponse<T>(res);\n }\n\n async put<T>(path: string, body?: unknown): Promise<T> {\n const res = await fetch(`${this.baseUrl}${path}`, {\n method: \"PUT\",\n headers: this.headers(),\n body: body != null ? JSON.stringify(body) : undefined,\n });\n return this.handleResponse<T>(res);\n }\n\n async patch<T>(path: string, body?: unknown): Promise<T> {\n const res = await fetch(`${this.baseUrl}${path}`, {\n method: \"PATCH\",\n headers: this.headers(),\n body: body != null ? JSON.stringify(body) : undefined,\n });\n return this.handleResponse<T>(res);\n }\n\n async del(path: string, body?: unknown): Promise<void> {\n const res = await fetch(`${this.baseUrl}${path}`, {\n method: \"DELETE\",\n headers: this.headers(),\n body: body != null ? JSON.stringify(body) : undefined,\n });\n await this.handleResponse<void>(res);\n }\n\n private async handleResponse<T>(res: Response): Promise<T> {\n if (res.status === 401) {\n localStorage.removeItem(TOKEN_KEY);\n // Guard against infinite reload loops: skip reload if we already reloaded within 3s\n const lastReload = Number(sessionStorage.getItem(RELOAD_GUARD_KEY) || \"0\");\n if (Date.now() - lastReload > 3000) {\n sessionStorage.setItem(RELOAD_GUARD_KEY, String(Date.now()));\n window.location.reload();\n }\n throw new Error(\"Unauthorized\");\n }\n\n let json: any;\n try {\n json = await res.json();\n } catch {\n throw new Error(res.ok ? \"Empty response from server\" : `Server error (HTTP ${res.status})`);\n }\n\n if (json.ok === false) {\n throw new Error(json.error ?? `HTTP ${res.status}`);\n }\n\n return json.data as T;\n }\n}\n\nexport const api = new ApiClient();\n\n/** Build project-scoped API path prefix */\nexport function projectUrl(projectName: string): string {\n return `/api/project/${encodeURIComponent(projectName)}`;\n}\n\nexport function setAuthToken(token: string) {\n localStorage.setItem(TOKEN_KEY, token);\n}\n\nexport function clearAuthToken() {\n localStorage.removeItem(TOKEN_KEY);\n}\n\nexport function getAuthToken(): string | null {\n return localStorage.getItem(TOKEN_KEY);\n}\n"],"mappings":"+HAAM,EAAY,iBACZ,EAAmB,qBA4FZ,EAAM,IA1FnB,KAAgB,CACd,QAEA,YAAY,EAAU,GAAI,CACxB,KAAK,QAAU,EAGjB,UAAkC,CAChC,OAAO,aAAa,QAAQ,EAAU,CAGxC,SAA+B,CAC7B,IAAM,EAAiB,CAAE,eAAgB,mBAAoB,CACvD,EAAQ,KAAK,UAAU,CAE7B,OADI,IAAO,EAAE,cAAmB,UAAU,KACnC,EAIT,MAAM,IAAO,EAAc,EAAgD,CACzE,IAAM,EAAM,MAAM,MAAM,GAAG,KAAK,UAAU,IAAQ,CAChD,QAAS,KAAK,SAAS,CACvB,OAAQ,GAAS,OAClB,CAAC,CACF,OAAO,KAAK,eAAkB,EAAI,CAGpC,MAAM,KAAQ,EAAc,EAA4B,CACtD,IAAM,EAAM,MAAM,MAAM,GAAG,KAAK,UAAU,IAAQ,CAChD,OAAQ,OACR,QAAS,KAAK,SAAS,CACvB,KAAM,GAAQ,KAA8B,IAAA,GAAvB,KAAK,UAAU,EAAK,CAC1C,CAAC,CACF,OAAO,KAAK,eAAkB,EAAI,CAGpC,MAAM,IAAO,EAAc,EAA4B,CACrD,IAA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AAQ,EAAW,EAAM,CAOxC,SAAgB,GAA8B,CAC5C,OAAO,aAAa,QAAQ,EAAU"}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-FhOqtrmT.js";import{t}from"./api-client-DIhJ5qVW.js";var n=e({addAccount:()=>a,deleteAccount:()=>o,exchangeOAuthCode:()=>d,getAISettings:()=>g,getAccountSettings:()=>c,getAccounts:()=>r,getActiveAccount:()=>i,getAllAccountUsages:()=>f,getOAuthUrl:()=>u,getProxySettings:()=>v,getUsageHistory:()=>p,importAccounts:()=>m,patchAccount:()=>s,updateAISettings:()=>_,updateAccountSettings:()=>l,updateDeviceName:()=>h,updateProxySettings:()=>y});function r(){return t.get(`/api/accounts`)}function i(){return t.get(`/api/accounts/active`)}function a(e){return t.post(`/api/accounts`,e)}function o(e){return t.del(`/api/accounts/${e}`)}function s(e,n){return t.patch(`/api/accounts/${e}`,n)}function c(){return t.get(`/api/accounts/settings`)}function l(e){return t.put(`/api/accounts/settings`,e)}function u(){return t.get(`/api/accounts/oauth/url`)}function d(e,n){return t.post(`/api/accounts/oauth/exchange`,{code:e,state:n})}function f(){return t.get(`/api/accounts/usage`)}function p(e){return t.get(`/api/accounts/${e}/usage-history`)}function m(e){return t.post(`/api/accounts/import`,e)}function h(e){return t.put(`/api/settings/device-name`,{device_name:e})}function g(){return t.get(`/api/settings/ai`)}function _(e){return t.put(`/api/settings/ai`,e)}function v(){return t.get(`/api/settings/proxy`)}function y(e){return t.put(`/api/settings/proxy`,e)}export{y as _,g as a,i as c,v as d,p as f,l as g,_ as h,d as i,f as l,s as m,n,c as o,m as p,o as r,r as s,a as t,u};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-FhOqtrmT.js";import{t}from"./api-client-DIhJ5qVW.js";var n=e({addAccount:()=>a,deleteAccount:()=>o,exchangeOAuthCode:()=>d,getAISettings:()=>g,getAccountSettings:()=>c,getAccounts:()=>r,getActiveAccount:()=>i,getAllAccountUsages:()=>f,getOAuthUrl:()=>u,getProxySettings:()=>v,getUsageHistory:()=>p,importAccounts:()=>m,patchAccount:()=>s,updateAISettings:()=>_,updateAccountSettings:()=>l,updateDeviceName:()=>h,updateProxySettings:()=>y});function r(){return t.get(`/api/accounts`)}function i(){return t.get(`/api/accounts/active`)}function a(e){return t.post(`/api/accounts`,e)}function o(e){return t.del(`/api/accounts/${e}`)}function s(e,n){return t.patch(`/api/accounts/${e}`,n)}function c(){return t.get(`/api/accounts/settings`)}function l(e){return t.put(`/api/accounts/settings`,e)}function u(){return t.get(`/api/accounts/oauth/url`)}function d(e,n){return t.post(`/api/accounts/oauth/exchange`,{code:e,state:n})}function f(){return t.get(`/api/accounts/usage`)}function p(e){return t.get(`/api/accounts/${e}/usage-history`)}function m(e){return t.post(`/api/accounts/import`,e)}function h(e){return t.put(`/api/settings/device-name`,{device_name:e})}function g(){return t.get(`/api/settings/ai`)}function _(e){return t.put(`/api/settings/ai`,e)}function v(){return t.get(`/api/settings/proxy`)}function y(e){return t.put(`/api/settings/proxy`,e)}export{y as _,g as a,i as c,v as d,p as f,l as g,_ as h,d as i,f as l,s as m,n,c as o,m as p,o as r,r as s,a as t,u};
|
|
2
|
+
//# sourceMappingURL=api-settings-DnHv6JgF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-settings-DnHv6JgF.js","names":[],"sources":["../../../src/web/lib/api-settings.ts"],"sourcesContent":["import { api } from \"./api-client\";\n\nexport interface OAuthProfileData {\n account?: {\n uuid?: string;\n full_name?: string;\n display_name?: string;\n email?: string;\n has_claude_max?: boolean;\n has_claude_pro?: boolean;\n created_at?: string;\n };\n organization?: {\n uuid?: string;\n name?: string;\n organization_type?: string;\n billing_type?: string;\n rate_limit_tier?: string;\n has_extra_usage_enabled?: boolean;\n subscription_status?: string;\n subscription_created_at?: string;\n };\n application?: {\n uuid?: string;\n name?: string;\n slug?: string;\n };\n}\n\nexport interface AccountInfo {\n id: string;\n label: string | null;\n email: string | null;\n expiresAt: number | null;\n status: \"active\" | \"cooldown\" | \"disabled\";\n cooldownUntil: number | null;\n priority: number;\n totalRequests: number;\n lastUsedAt: number | null;\n profileData: OAuthProfileData | null;\n createdAt: number;\n hasRefreshToken: boolean;\n}\n\nexport interface VerifyResult {\n valid: boolean;\n email?: string;\n orgName?: string;\n subscriptionType?: string;\n authMethod?: string;\n profileData?: OAuthProfileData;\n}\n\nexport interface AccountSettings {\n strategy: \"round-robin\" | \"fill-first\" | \"lowest-usage\";\n maxRetry: number;\n activeCount: number;\n}\n\nexport function getAccounts(): Promise<AccountInfo[]> {\n return api.get<AccountInfo[]>(\"/api/accounts\");\n}\n\nexport function getActiveAccount(): Promise<AccountInfo | null> {\n return api.get<AccountInfo | null>(\"/api/accounts/active\");\n}\n\nexport function addAccount(params: { apiKey: string; label?: string }): Promise<AccountInfo> {\n return api.post<AccountInfo>(\"/api/accounts\", params);\n}\n\nexport function deleteAccount(id: string): Promise<void> {\n return api.del(`/api/accounts/${id}`);\n}\n\nexport function patchAccount(id: string, updates: { status: string }): Promise<AccountInfo | null> {\n return api.patch<AccountInfo | null>(`/api/accounts/${id}`, updates);\n}\n\nexport function getAccountSettings(): Promise<AccountSettings> {\n return api.get<AccountSettings>(\"/api/accounts/settings\");\n}\n\nexport function updateAccountSettings(s: Partial<Omit<AccountSettings, \"activeCount\">>): Promise<AccountSettings> {\n return api.put<AccountSettings>(\"/api/accounts/settings\", s);\n}\n\nexport interface AccountUsageEntry {\n accountId: string;\n accountLabel: string | null;\n accountStatus: string;\n isOAuth: boolean;\n usage: {\n lastFetchedAt?: string;\n session?: import(\"../../types/chat\").LimitBucket;\n weekly?: import(\"../../types/chat\").LimitBucket;\n weeklyOpus?: import(\"../../types/chat\").LimitBucket;\n weeklySonnet?: import(\"../../types/chat\").LimitBucket;\n };\n}\n\nexport function verifyAccount(id: string): Promise<VerifyResult> {\n return api.post<VerifyResult>(`/api/accounts/${id}/verify`);\n}\n\nexport function getOAuthUrl(): Promise<{ url: string; state: string }> {\n return api.get<{ url: string; state: string }>(\"/api/accounts/oauth/url\");\n}\n\nexport function exchangeOAuthCode(code: string, state: string): Promise<AccountInfo> {\n return api.post<AccountInfo>(\"/api/accounts/oauth/exchange\", { code, state });\n}\n\nexport function getAllAccountUsages(): Promise<AccountUsageEntry[]> {\n return api.get<AccountUsageEntry[]>(\"/api/accounts/usage\");\n}\n\nexport interface UsageSnapshot {\n id: number;\n account_id: string | null;\n five_hour_util: number | null;\n weekly_util: number | null;\n weekly_opus_util: number | null;\n weekly_sonnet_util: number | null;\n recorded_at: string;\n}\n\nexport function getUsageHistory(accountId: string): Promise<UsageSnapshot[]> {\n return api.get<UsageSnapshot[]>(`/api/accounts/${accountId}/usage-history`);\n}\n\nexport function importAccounts(params: { data: string; password: string }): Promise<{ imported: number; refreshed: number }> {\n return api.post<{ imported: number; refreshed: number }>(\"/api/accounts/import\", params);\n}\n\nexport interface TokenTestResult {\n accessToken: { status: string; code?: number; error?: string };\n refreshToken?: { status: string; code?: number; expiresIn?: number; newRefreshToken?: boolean; error?: string };\n}\n\nexport function testAccountToken(id: string, testRefresh = false): Promise<TokenTestResult> {\n return api.post<TokenTestResult>(`/api/accounts/${id}/test-token`, { testRefresh });\n}\n\nexport interface ExportedTokenInfo {\n id: string;\n label: string;\n email: string;\n preExportToken: string | null;\n preExportTokenFull: string | null;\n exportedToken: string | null;\n exportedTokenFull: string | null;\n postExportToken: string | null;\n postExportTokenFull: string | null;\n preExportExpires: number | null;\n exportedExpires: number | null;\n postExportExpires: number | null;\n tokenChanged: boolean;\n}\n\nexport function testExport(accountIds: string[], includeRefreshToken = false): Promise<ExportedTokenInfo[]> {\n return api.post<ExportedTokenInfo[]>(\"/api/accounts/test-export\", { accountIds, includeRefreshToken });\n}\n\nexport function testRawToken(token: string): Promise<{ status: string; code?: number; error?: string }> {\n return api.post<{ status: string; code?: number; error?: string }>(\"/api/accounts/test-raw-token\", { token });\n}\n\nexport interface AIProviderSettings {\n type?: string;\n api_key_env?: string;\n api_key?: string;\n base_url?: string;\n model?: string;\n effort?: string;\n max_turns?: number;\n max_budget_usd?: number;\n thinking_budget_tokens?: number;\n permission_mode?: string;\n system_prompt?: string;\n agent_teams?: boolean;\n}\n\nexport interface AISettings {\n default_provider: string;\n providers: Record<string, AIProviderSettings>;\n}\n\nexport function updateDeviceName(device_name: string): Promise<{ device_name: string }> {\n return api.put<{ device_name: string }>(\"/api/settings/device-name\", { device_name });\n}\n\nexport function getAISettings(): Promise<AISettings> {\n return api.get<AISettings>(\"/api/settings/ai\");\n}\n\nexport function updateAISettings(settings: Partial<AISettings>): Promise<AISettings> {\n return api.put<AISettings>(\"/api/settings/ai\", settings);\n}\n\n// ── Proxy ────────────────────────────────────────────────────────────\n\nexport interface ProxySettings {\n enabled: boolean;\n authKey: string | null;\n requestCount: number;\n localEndpoint: string;\n localOpenAiEndpoint: string;\n tunnelUrl: string | null;\n proxyEndpoint: string | null;\n openAiEndpoint: string | null;\n}\n\nexport function getProxySettings(): Promise<ProxySettings> {\n return api.get<ProxySettings>(\"/api/settings/proxy\");\n}\n\nexport function updateProxySettings(params: { enabled?: boolean; authKey?: string; generateKey?: boolean }): Promise<ProxySettings> {\n return api.put<ProxySettings>(\"/api/settings/proxy\", params);\n}\n"],"mappings":"8dA2DA,SAAgB,GAAsC,CACpD,OAAO,EAAI,IAAmB,gBAAgB,CAGhD,SAAgB,GAAgD,CAC9D,OAAO,EAAI,IAAwB,uBAAuB,CAG5D,SAAgB,EAAW,EAAkE,CAC3F,OAAO,EAAI,KAAkB,gBAAiB,EAAO,CAGvD,SAAgB,EAAc,EAA2B,CACvD,OAAO,EAAI,IAAI,iBAAiB,IAAK,CAGvC,SAAgB,EAAa,EAAY,EAA0D,CACjG,OAAO,EAAI,MAA0B,iBAAiB,IAAM,EAAQ,CAGtE,SAAgB,GAA+C,CAC7D,OAAO,EAAI,IAAqB,yBAAyB,CAG3D,SAAgB,EAAsB,EAA4E,CAChH,OAAO,EAAI,IAAqB,yBAA0B,EAAE,CAqB9D,SAAgB,GAAuD,CACrE,OAAO,EAAI,IAAoC,0BAA0B,CAG3E,SAAgB,EAAkB,EAAc,EAAqC,CACnF,OAAO,EAAI,KAAkB,+BAAgC,CAAE,OAAM,QAAO,CAAC,CAG/E,SAAgB,GAAoD,CAClE,OAAO,EAAI,IAAyB,sBAAsB,CAa5D,SAAgB,EAAgB,EAA6C,CAC3E,OAAO,EAAI,IAAqB,iBAAiB,EAAU,gBAAgB,CAG7E,SAAgB,EAAe,EAA8F,CAC3H,OAAO,EAAI,KAA8C,uBAAwB,EAAO,CAwD1F,SAAgB,EAAiB,EAAuD,CACtF,OAAO,EAAI,IAA6B,4BAA6B,CAAE,cAAa,CAAC,CAGvF,SAAgB,GAAqC,CACnD,OAAO,EAAI,IAAgB,mBAAmB,CAGhD,SAAgB,EAAiB,EAAoD,CACnF,OAAO,EAAI,IAAgB,mBAAoB,EAAS,CAgB1D,SAAgB,GAA2C,CACzD,OAAO,EAAI,IAAmB,sBAAsB,CAGtD,SAAgB,EAAoB,EAAgG,CAClI,OAAO,EAAI,IAAmB,sBAAuB,EAAO"}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import{t as e}from"./createLucideIcon-BjHrJDVb.js";var t=e(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]);export{t};
|
|
1
|
+
import{t as e}from"./createLucideIcon-BjHrJDVb.js";var t=e(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]);export{t};
|
|
2
|
+
//# sourceMappingURL=arrow-up-Rcw6_KKu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arrow-up-Rcw6_KKu.js","names":[],"sources":["../../../node_modules/.bun/lucide-react@0.577.0+b1ab299f0a400331/node_modules/lucide-react/dist/esm/icons/arrow-up.js"],"sourcesContent":["/**\n * @license lucide-react v0.577.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst __iconNode = [\n [\"path\", { d: \"m5 12 7-7 7 7\", key: \"hav0vg\" }],\n [\"path\", { d: \"M12 19V5\", key: \"x0mq9r\" }]\n];\nconst ArrowUp = createLucideIcon(\"arrow-up\", __iconNode);\n\nexport { __iconNode, ArrowUp as default };\n//# sourceMappingURL=arrow-up.js.map\n"],"x_google_ignoreList":[0],"mappings":"mDAaA,IAAM,EAAU,EAAiB,WAJd,CACjB,CAAC,OAAQ,CAAE,EAAG,gBAAiB,IAAK,SAAU,CAAC,CAC/C,CAAC,OAAQ,CAAE,EAAG,WAAY,IAAK,SAAU,CAAC,CAC3C,CACuD"}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import{b as e}from"./vendor-markdown-0Mxgxy0L.js";import{t}from"./createLucideIcon-BjHrJDVb.js";import{t as n}from"./file-exclamation-point-BwzaQ50n.js";import"./api-client-DIhJ5qVW.js";import{t as r}from"./utils-CQux7CsO.js";import{G as i}from"./index-DJtqbPFT.js";import{t as a}from"./use-blob-url-QX-XajU8.js";var o=t(`music`,[[`path`,{d:`M9 18V5l12-2v13`,key:`1jmyc2`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`circle`,{cx:`18`,cy:`16`,r:`3`,key:`1hluhg`}]]),s=e();function c({filePath:e,projectName:t}){let{blobUrl:c,error:l}=a(e,t);return l?(0,s.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-text-secondary`,children:[(0,s.jsx)(n,{className:`size-10 text-text-subtle`}),(0,s.jsx)(`p`,{className:`text-sm`,children:`Failed to load audio.`})]}):c?(0,s.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4 p-4 bg-surface`,children:[(0,s.jsx)(o,{className:`size-16 text-text-subtle`}),(0,s.jsx)(`p`,{className:`text-sm text-text-secondary truncate max-w-xs`,children:r(e)}),(0,s.jsx)(`audio`,{src:c,controls:!0,className:`w-full max-w-md`})]}):(0,s.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,s.jsx)(i,{className:`size-5 animate-spin text-text-subtle`})})}export{c as AudioPreview};
|
|
1
|
+
import{b as e}from"./vendor-markdown-0Mxgxy0L.js";import{t}from"./createLucideIcon-BjHrJDVb.js";import{t as n}from"./file-exclamation-point-BwzaQ50n.js";import"./api-client-DIhJ5qVW.js";import{t as r}from"./utils-CQux7CsO.js";import{G as i}from"./index-DJtqbPFT.js";import{t as a}from"./use-blob-url-QX-XajU8.js";var o=t(`music`,[[`path`,{d:`M9 18V5l12-2v13`,key:`1jmyc2`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`circle`,{cx:`18`,cy:`16`,r:`3`,key:`1hluhg`}]]),s=e();function c({filePath:e,projectName:t}){let{blobUrl:c,error:l}=a(e,t);return l?(0,s.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-text-secondary`,children:[(0,s.jsx)(n,{className:`size-10 text-text-subtle`}),(0,s.jsx)(`p`,{className:`text-sm`,children:`Failed to load audio.`})]}):c?(0,s.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4 p-4 bg-surface`,children:[(0,s.jsx)(o,{className:`size-16 text-text-subtle`}),(0,s.jsx)(`p`,{className:`text-sm text-text-secondary truncate max-w-xs`,children:r(e)}),(0,s.jsx)(`audio`,{src:c,controls:!0,className:`w-full max-w-md`})]}):(0,s.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,s.jsx)(i,{className:`size-5 animate-spin text-text-subtle`})})}export{c as AudioPreview};
|
|
2
|
+
//# sourceMappingURL=audio-preview-B6a1Djtr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audio-preview-B6a1Djtr.js","names":[],"sources":["../../../node_modules/.bun/lucide-react@0.577.0+b1ab299f0a400331/node_modules/lucide-react/dist/esm/icons/music.js","../../../src/web/components/editor/audio-preview.tsx"],"sourcesContent":["/**\n * @license lucide-react v0.577.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst __iconNode = [\n [\"path\", { d: \"M9 18V5l12-2v13\", key: \"1jmyc2\" }],\n [\"circle\", { cx: \"6\", cy: \"18\", r: \"3\", key: \"fqmcym\" }],\n [\"circle\", { cx: \"18\", cy: \"16\", r: \"3\", key: \"1hluhg\" }]\n];\nconst Music = createLucideIcon(\"music\", __iconNode);\n\nexport { __iconNode, Music as default };\n//# sourceMappingURL=music.js.map\n","import { Loader2, FileWarning, Music } from \"lucide-react\";\nimport { useBlobUrl } from \"./use-blob-url\";\nimport { basename } from \"@/lib/utils\";\n\nexport function AudioPreview({ filePath, projectName }: { filePath: string; projectName: string }) {\n const { blobUrl, error } = useBlobUrl(filePath, projectName);\n\n if (error) {\n return (\n <div className=\"flex flex-col items-center justify-center h-full gap-3 text-text-secondary\">\n <FileWarning className=\"size-10 text-text-subtle\" />\n <p className=\"text-sm\">Failed to load audio.</p>\n </div>\n );\n }\n if (!blobUrl) {\n return <div className=\"flex items-center justify-center h-full\"><Loader2 className=\"size-5 animate-spin text-text-subtle\" /></div>;\n }\n return (\n <div className=\"flex flex-col items-center justify-center h-full gap-4 p-4 bg-surface\">\n <Music className=\"size-16 text-text-subtle\" />\n <p className=\"text-sm text-text-secondary truncate max-w-xs\">{basename(filePath)}</p>\n <audio src={blobUrl} controls className=\"w-full max-w-md\" />\n </div>\n );\n}\n"],"x_google_ignoreList":[0],"mappings":"yTAcA,IAAM,EAAQ,EAAiB,QALZ,CACjB,CAAC,OAAQ,CAAE,EAAG,kBAAmB,IAAK,SAAU,CAAC,CACjD,CAAC,SAAU,CAAE,GAAI,IAAK,GAAI,KAAM,EAAG,IAAK,IAAK,SAAU,CAAC,CACxD,CAAC,SAAU,CAAE,GAAI,KAAM,GAAI,KAAM,EAAG,IAAK,IAAK,SAAU,CAAC,CAC1D,CACkD,OCVnD,SAAgB,EAAa,CAAE,WAAU,eAA0D,CACjG,GAAM,CAAE,UAAS,SAAU,EAAW,EAAU,EAAY,CAa5D,OAXI,GACF,EAAA,EAAA,MACG,MAAD,CAAK,UAAU,sFAAf,EAAA,EAAA,EAAA,KACG,EAAD,CAAa,UAAU,2BAA6B,CAAA,EAAA,EAAA,EAAA,KACnD,IAAD,CAAG,UAAU,mBAAU,wBAAyB,CAAA,CAC5C,GAGL,GAGL,EAAA,EAAA,MACG,MAAD,CAAK,UAAU,iFAAf,WACG,EAAD,CAAO,UAAU,2BAA6B,CAAA,WAC7C,IAAD,CAAG,UAAU,yDAAiD,EAAS,EAAS,CAAK,CAAA,WACpF,QAAD,CAAO,IAAK,EAAS,SAAA,GAAS,UAAU,kBAAoB,CAAA,CACxD,IAPN,EAAA,EAAA,KAAQ,MAAD,CAAK,UAAU,6DAA2C,EAAD,CAAS,UAAU,uCAAyC,CAAA,CAAM,CAAA"}
|
|
@@ -9,4 +9,5 @@ import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,x as n}from"./v
|
|
|
9
9
|
|
|
10
10
|
`).trim()}function zn({content:e,projectName:t,isStreaming:n}){let r=Rn(e);return r?(0,$.jsx)(rn,{fallbackContent:r,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`animate-pulse h-4 bg-muted rounded`}),children:(0,$.jsx)(ln,{content:r,projectName:t,codeActions:!0,isStreaming:n})})}):null}function Bn({approval:e,onRespond:t}){return(0,$.jsxs)(`div`,{className:`rounded-lg border-2 border-yellow-500/40 bg-yellow-500/10 p-3 space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-yellow-400 text-sm font-medium`,children:[(0,$.jsx)(st,{className:`size-4`}),(0,$.jsx)(`span`,{children:`Tool Approval Required`})]}),(0,$.jsx)(`div`,{className:`text-xs text-text-primary`,children:(0,$.jsx)(`span`,{className:`font-medium`,children:e.tool})}),(0,$.jsx)(`pre`,{className:`text-xs font-mono text-text-secondary overflow-x-auto bg-background rounded p-2 border border-border`,children:JSON.stringify(e.input,null,2)}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(`button`,{onClick:()=>t(e.requestId,!0),className:`px-4 py-1.5 rounded bg-green-600 text-white text-xs font-medium hover:bg-green-500 transition-colors`,children:`Allow`}),(0,$.jsx)(`button`,{onClick:()=>t(e.requestId,!1),className:`px-4 py-1.5 rounded bg-red-600 text-white text-xs font-medium hover:bg-red-500 transition-colors`,children:`Deny`})]})]})}function Vn({approval:e,onRespond:t}){return(0,$.jsx)(cn,{questions:e.input.questions??[],onSubmit:n=>t(e.requestId,!0,n),onSkip:()=>t(e.requestId,!1)})}function Hn(){let e=window;return e.SpeechRecognition??e.webkitSpeechRecognition??null}function Un(e){let[t,n]=(0,Q.useState)(!1),[r,i]=(0,Q.useState)(``),a=(0,Q.useRef)(null),o=(0,Q.useRef)(``),s=typeof window<`u`&&Hn()!==null;return{isListening:t,interimText:r,start:(0,Q.useCallback)(t=>{let r=Hn();if(!r)return;a.current?.abort();let s=new r;s.lang=e?.lang??`vi-VN`,s.continuous=!0,s.interimResults=!0,o.current=``,s.onresult=e=>{let n=``,r=``;for(let t=0;t<e.results.length;t++){let i=e.results[t];i.isFinal?r+=i[0].transcript:n+=i[0].transcript}r&&(o.current=r);let a=(o.current+` `+n).trim();i(n),t(a,n.length===0&&o.current.length>0)},s.onend=()=>{n(!1),i(``),o.current&&t(o.current.trim(),!0)},s.onerror=e=>{e.error!==`no-speech`&&e.error!==`aborted`&&console.warn(`[voice-input] error:`,e.error),n(!1),i(``)},a.current=s,s.start(),n(!0)},[e?.lang]),stop:(0,Q.useCallback)(()=>{a.current?.stop(),a.current=null,n(!1),i(``)},[]),supported:s}}var Wn=new Set([`image/png`,`image/jpeg`,`image/gif`,`image/webp`]),Gn=new Set([`application/pdf`]),Kn=[`text/`,`application/json`,`application/xml`,`application/javascript`,`application/typescript`,`application/x-yaml`,`application/toml`,`application/x-sh`],qn=new Set(`.ts,.tsx,.js,.jsx,.mjs,.cjs,.py,.rb,.go,.rs,.java,.kt,.swift,.c,.cpp,.h,.hpp,.cs,.json,.yaml,.yml,.toml,.xml,.md,.mdx,.txt,.csv,.tsv,.html,.css,.scss,.less,.sass,.sh,.bash,.zsh,.fish,.sql,.graphql,.gql,.env,.ini,.cfg,.conf,.dockerfile,.makefile,.vue,.svelte,.astro,.ipynb`.split(`,`));function Jn(e){return Wn.has(e.type)}function Yn(e){if(Wn.has(e.type)||Gn.has(e.type)||Kn.some(t=>e.type.startsWith(t)))return!0;let t=Xn(e.name);return!!(t&&qn.has(t))}function Xn(e){let t=e.lastIndexOf(`.`);return t===-1?``:e.slice(t).toLowerCase()}function Zn({attachments:e,onRemove:t}){return e.length===0?null:(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5 px-2 md:px-4 pt-2`,children:e.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-md border border-border bg-surface px-2 py-1 text-xs text-text-secondary max-w-48`,children:[e.previewUrl?(0,$.jsx)(`img`,{src:e.previewUrl,alt:e.name,className:`size-5 rounded object-cover shrink-0`}):e.isImage?(0,$.jsx)(et,{className:`size-3.5 shrink-0 text-text-subtle`}):(0,$.jsx)(Pe,{className:`size-3.5 shrink-0 text-text-subtle`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.name}),e.status===`uploading`?(0,$.jsx)(Z,{className:`size-3 shrink-0 animate-spin text-text-subtle`}):e.status===`error`?(0,$.jsx)(`span`,{className:`text-red-500 shrink-0`,title:`Upload failed`,children:`!`}):null,(0,$.jsx)(`button`,{type:`button`,onClick:()=>t(e.id),className:`shrink-0 rounded-sm p-0.5 hover:bg-border/50 transition-colors`,"aria-label":`Remove ${e.name}`,children:(0,$.jsx)(H,{className:`size-3`})})]},e.id))})}var Qn=[{id:`default`,label:`Ask before edits`,icon:Qe,description:`Claude will ask for approval before making each edit`},{id:`acceptEdits`,label:`Edit automatically`,icon:F,description:`Claude will edit files without asking first`},{id:`plan`,label:`Plan mode`,icon:Ze,description:`Claude will present a plan before editing`},{id:`bypassPermissions`,label:`Bypass permissions`,icon:ct,description:`Claude will not ask before running commands`}];function $n(e){return Qn.find(t=>t.id===e)?.label??`Unknown`}function er(e){return Qn.find(t=>t.id===e)?.icon??Qe}function tr({value:e,onChange:t,open:n,onOpenChange:r}){let i=(0,Q.useRef)(null),a=(0,Q.useRef)(0);(0,Q.useEffect)(()=>{if(!n)return;let e=e=>{i.current&&!i.current.contains(e.target)&&r(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[n,r]),(0,Q.useEffect)(()=>{n&&(a.current=Qn.findIndex(t=>t.id===e),a.current<0&&(a.current=0))},[n,e]);let o=(0,Q.useCallback)(e=>{if(e.key===`Escape`){r(!1);return}if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;a.current=(a.current+t+Qn.length)%Qn.length,(i.current?.querySelector(`[data-idx="${a.current}"]`))?.focus()}if(e.key===`Enter`){e.preventDefault();let n=Qn[a.current];n&&(t(n.id),r(!1))}},[t,r]);return n?(0,$.jsxs)(`div`,{ref:i,role:`listbox`,"aria-label":`Permission modes`,onKeyDown:o,onMouseDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),className:`absolute bottom-full left-0 mb-1 z-50 w-72 md:w-80 rounded-lg border border-border bg-surface shadow-lg`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-text-secondary`,children:`Modes`}),(0,$.jsx)(`kbd`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-surface-elevated text-text-subtle border border-border`,children:`Shift + Tab`})]}),(0,$.jsx)(`div`,{className:`py-1`,children:Qn.map((n,i)=>{let a=n.icon,o=n.id===e;return(0,$.jsxs)(`button`,{"data-idx":i,role:`option`,"aria-selected":o,tabIndex:0,onClick:()=>{t(n.id),r(!1)},className:`w-full flex items-start gap-3 px-3 py-2.5 text-left transition-colors hover:bg-surface-elevated focus:bg-surface-elevated focus:outline-none ${o?`bg-surface-elevated`:``}`,children:[(0,$.jsx)(a,{className:`size-4 mt-0.5 shrink-0 text-text-secondary`}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-text-primary`,children:n.label}),(0,$.jsx)(`div`,{className:`text-xs text-text-subtle leading-snug`,children:n.description})]}),o&&(0,$.jsx)(S,{className:`size-4 mt-0.5 shrink-0 text-primary`})]},n.id)})})]}):null}var nr=(0,Q.memo)(function({onSend:e,isStreaming:t,onCancel:n,disabled:r,projectName:a,onSlashStateChange:o,onSlashItemsLoaded:s,slashSelected:c,onFileStateChange:l,onFileItemsLoaded:u,fileSelected:d,externalFiles:f,externalPaths:p,onExternalPathsConsumed:m,onDisambiguate:h,initialValue:g,autoFocus:_,permissionMode:y,onModeChange:b,providerId:x,onProviderChange:S}){let C=(0,Q.useRef)(g??``),[w,T]=(0,Q.useState)(()=>(g??``).trim().length>0),[E,D]=(0,Q.useState)([]),[O,k]=(0,Q.useState)(!1),[A,j]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)(`next`),P=(0,Q.useRef)(null),F=(0,Q.useRef)(null),I=(0,Q.useRef)(null),L=(0,Q.useRef)([]),ee=(0,Q.useRef)([]),R=(0,Q.useRef)(0),z=(0,Q.useRef)(!1),B=(0,Q.useRef)(!1),te=(0,Q.useRef)(typeof CSS>`u`||!CSS.supports(`field-sizing`,`content`)),V=(0,Q.useCallback)(e=>{C.current=e,P.current&&(P.current.value=e),F.current&&(F.current.value=e),T(e.trim().length>0)},[]),H=(0,Q.useCallback)(()=>window.matchMedia(`(min-width: 768px)`).matches?P.current:F.current,[]),U=Un(),ne=(0,Q.useRef)(``),K=(0,Q.useCallback)(e=>{let t=ne.current;V(t?t+` `+e:e),te.current&&requestAnimationFrame(()=>{let e=H();e&&(e.style.height=`auto`,e.style.height=Math.min(e.scrollHeight,160)+`px`)})},[V,H]),ie=(0,Q.useCallback)(()=>{U.isListening?U.stop():(ne.current=C.current.trim(),U.start(K))},[U.isListening,U.start,U.stop,K]);(0,Q.useEffect)(()=>{let e=()=>{U.supported&&ie()};return window.addEventListener(`toggle-voice-input`,e),()=>window.removeEventListener(`toggle-voice-input`,e)},[U.supported,ie]),(0,Q.useEffect)(()=>{g&&(V(g),setTimeout(()=>{let e=P.current;e&&(e.focus(),e.selectionStart=e.selectionEnd=e.value.length)},50))},[g]),(0,Q.useEffect)(()=>{_&&setTimeout(()=>{H()?.focus()},100)},[]);let q=(0,Q.useCallback)(()=>{if(!a){L.current=[],s?.([],[]);return}G.get(`${W(a)}/chat/slash-items`).then(e=>{L.current=e.items,s?.(e.items,e.recentNames)}).catch(()=>{L.current=[],s?.([],[])})},[a,s]);(0,Q.useEffect)(()=>{q()},[q]),(0,Q.useEffect)(()=>{let e=()=>q();return window.addEventListener(`ppm:slash-items-refresh`,e),()=>window.removeEventListener(`ppm:slash-items-refresh`,e)},[q]),(0,Q.useEffect)(()=>{let e=()=>{if(!a){ee.current=[],u?.([]);return}let{fileIndex:e}=se.getState(),t=e.map(e=>({name:e.name,path:e.path,type:e.type}));ee.current=t,u?.(t)};e();let t=se.getState().fileIndex,n=se.getState().indexStatus;return se.subscribe(r=>{(r.fileIndex!==t||r.indexStatus!==n)&&(t=r.fileIndex,n=r.indexStatus,e())})},[a]),(0,Q.useEffect)(()=>{if(!c)return;let e=H();if(!e)return;let t=e.value,n=e.selectionStart,r=t.slice(0,n),i=t.slice(n),a=r.replace(/(?:^|\s)\/\S*$/,e=>`${e.startsWith(`/`)?``:e[0]}/${c.name} `);V(a+i),o?.(!1,``),z.current=!1,l?.(!1,``),B.current=!1,e.focus(),setTimeout(()=>{e.selectionStart=e.selectionEnd=a.length},0)},[c]),(0,Q.useEffect)(()=>{if(!d)return;let e=H();if(!e)return;let t=e.value,n=e.selectionStart,r=t.slice(0,n),i=t.slice(n),a=r.match(/@(\S*)$/);if(a){let t=r.length-a[0].length;V(r.slice(0,t)+`@${d.path} `+i);let n=t+d.path.length+2;setTimeout(()=>{e.selectionStart=e.selectionEnd=n,e.focus()},0)}else{let n=t+`@${d.path} `;V(n),setTimeout(()=>{e.selectionStart=e.selectionEnd=n.length,e.focus()},0)}l?.(!1,``),B.current=!1},[d]),(0,Q.useEffect)(()=>{!f||f.length===0||Y(f)},[f]),(0,Q.useEffect)(()=>{if(!p||p.length===0)return;let e=p.map(e=>`@${e}`).join(` `),t=C.current;V(t+(t.length>0&&!t.endsWith(` `)?` `:``)+e+` `),H()?.focus(),m?.()},[p]);let J=(0,Q.useCallback)(async e=>{if(!a)return null;try{let t=new FormData;t.append(`files`,e);let n={},r=re();r&&(n.Authorization=`Bearer ${r}`);let i=await(await fetch(`${W(a)}/chat/upload`,{method:`POST`,headers:n,body:t})).json();return i.ok&&Array.isArray(i.data)&&i.data.length>0?i.data[0].path:null}catch{return null}},[a]),Y=(0,Q.useCallback)(async e=>{for(let t of e){if(a)try{let e=await G.get(`${W(a)}/files/resolve?name=${encodeURIComponent(t.name)}`);if(e.matches.length===1){let t=C.current;V(t+(t.length>0&&!t.endsWith(` `)?` `:``)+`@${e.matches[0].path} `);continue}if(e.matches.length>1){h?.(e.matches);continue}}catch{}if(!Yn(t)){let e=C.current;V(e+(e.length>0&&!e.endsWith(` `)?` `:``)+t.name);continue}let e=ae(),n=Jn(t),r=n?URL.createObjectURL(t):void 0,i={id:e,name:t.name,file:t,isImage:n,previewUrl:r,status:`uploading`};D(e=>[...e,i]),J(t).then(t=>{D(n=>n.map(n=>n.id===e?{...n,serverPath:t??void 0,status:t?`ready`:`error`}:n))})}(F.current??P.current)?.focus()},[J,V,a,h]),X=(0,Q.useCallback)(e=>{D(t=>{let n=t.find(t=>t.id===e);return n?.previewUrl&&URL.revokeObjectURL(n.previewUrl),t.filter(t=>t.id!==e)})},[]),oe=(0,Q.useCallback)(()=>{let n=C.current.trim(),r=E.filter(e=>e.status===`ready`);if(!n&&r.length===0){j(!1);return}o?.(!1,``),z.current=!1,l?.(!1,``),B.current=!1,U.isListening&&U.stop(),e(n,r,t?M:void 0),V(``);for(let e of E)e.previewUrl&&URL.revokeObjectURL(e.previewUrl);D([]),j(!1),N(`next`),te.current&&(P.current&&(P.current.style.height=`auto`),F.current&&(F.current.style.height=`auto`))},[E,e,o,l,t,M,V]),ce=(0,Q.useCallback)(()=>{if(!r){if(E.some(e=>e.status===`uploading`)){(C.current.trim()||E.some(e=>e.status!==`error`))&&j(!0);return}oe()}},[E,r,oe]);(0,Q.useEffect)(()=>{A&&(E.some(e=>e.status===`uploading`)||oe())},[A,E,oe]);let le=(0,Q.useCallback)(e=>{if(e.key===`Enter`&&!e.shiftKey){e.preventDefault(),ce();return}if(e.shiftKey&&e.key===`Tab`){e.preventDefault();let t=[`default`,`acceptEdits`,`plan`,`bypassPermissions`],n=t[(t.indexOf(y??`bypassPermissions`)+1)%t.length];b?.(n)}},[ce,y,b]),ue=(0,Q.useCallback)((e,t)=>{let n=e.slice(0,t),r=n.includes(`/`),i=n.includes(`@`);if(!r&&!i){z.current&&=(o?.(!1,``),!1),B.current&&=(l?.(!1,``),!1);return}if(r){let e=n.match(/(?:^|\s)\/(\S*)$/);if(e&&L.current.length>0){let t=e[1]??``;o?.(!0,t),z.current=!0,B.current&&=(l?.(!1,``),!1);return}}if(i){let e=n.match(/@(\S*)$/);if(e&&ee.current.length>0){l?.(!0,e[1]??``),B.current=!0,z.current&&=(o?.(!1,``),!1);return}}z.current&&=(o?.(!1,``),!1),B.current&&=(l?.(!1,``),!1)},[o,l]),de=(0,Q.useCallback)(e=>{let t=e.target,n=t.value;C.current=n;let r=t===P.current?F.current:P.current;r&&(r.value=n),T(n.trim().length>0),ue(n,t.selectionStart),te.current&&(R.current&&cancelAnimationFrame(R.current),R.current=requestAnimationFrame(()=>{R.current=0,t.style.height=`auto`,t.style.height=Math.min(t.scrollHeight,t===F.current?80:160)+`px`}))},[ue]),fe=(0,Q.useCallback)(e=>{let t=e.clipboardData?.items;if(!t)return;let n=[];for(let e of t)if(e.kind===`file`){let t=e.getAsFile();t&&n.push(t)}n.length>0&&(e.preventDefault(),Y(n))},[Y]),pe=(0,Q.useCallback)(e=>{e.preventDefault();let t=e.dataTransfer.getData(`application/x-ppm-path`);if(t){let e=C.current;V(e+(e.length>0&&!e.endsWith(` `)?` `:``)+`@${t} `),H()?.focus();return}let n=Array.from(e.dataTransfer.files);n.length>0&&Y(n)},[Y,V,H]),me=(0,Q.useCallback)(e=>{e.preventDefault()},[]),he=(0,Q.useCallback)(()=>{I.current?.click()},[]),ge=(0,Q.useCallback)(e=>{let t=Array.from(e.target.files??[]);t.length>0&&Y(t),e.target.value=``},[Y]),_e=w||E.some(e=>e.status!==`error`),ve=t&&!_e;return(0,$.jsxs)(`div`,{className:`p-2 md:p-3 bg-background`,children:[(0,$.jsxs)(`div`,{className:`border border-border rounded-xl md:rounded-2xl bg-surface shadow-sm cursor-text`,onClick:e=>{r||e.target instanceof HTMLTextAreaElement||H()?.focus()},children:[(0,$.jsx)(Zn,{attachments:E,onRemove:X}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 px-2 pt-2 md:hidden relative`,children:[(0,$.jsx)(rr,{mode:y??`bypassPermissions`,onClick:()=>k(e=>!e)}),(0,$.jsx)(tr,{value:y??`bypassPermissions`,onChange:e=>b?.(e),open:O,onOpenChange:k}),S&&a&&(0,$.jsx)(v,{value:x??`claude`,onChange:S,projectName:a}),t&&(0,$.jsx)(ar,{value:M,onChange:N})]}),(0,$.jsxs)(`div`,{className:`flex items-end gap-1 md:hidden px-2 py-2`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),he()},disabled:r,className:`flex items-center justify-center size-7 shrink-0 rounded-full text-text-subtle hover:text-text-primary transition-colors disabled:opacity-50`,"aria-label":`Attach file`,children:(0,$.jsx)(ot,{className:`size-4`})}),(0,$.jsx)(`textarea`,{ref:F,defaultValue:g??``,onChange:de,onKeyDown:le,onPaste:fe,onDrop:pe,onDragOver:me,placeholder:t?`Follow-up...`:`Ask anything...`,disabled:r,rows:1,className:`flex-1 resize-none bg-transparent py-1.5 text-sm text-foreground placeholder:text-text-subtle focus:outline-none disabled:opacity-50 max-h-20 [field-sizing:content]`}),U.supported&&(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),ie()},disabled:r,className:`flex items-center justify-center size-7 shrink-0 rounded-full transition-colors disabled:opacity-50 ${U.isListening?`bg-red-600 text-white animate-pulse`:`text-text-subtle hover:text-text-primary`}`,"aria-label":U.isListening?`Stop voice input`:`Start voice input`,children:U.isListening?(0,$.jsx)(it,{className:`size-4`}):(0,$.jsx)(Ne,{className:`size-4`})}),ve?(0,$.jsx)(`button`,{onClick:e=>{e.stopPropagation(),n?.()},className:`flex items-center justify-center size-7 shrink-0 rounded-full bg-red-600 text-white hover:bg-red-500 transition-colors`,"aria-label":`Stop`,children:(0,$.jsx)(Ke,{className:`size-3`})}):(0,$.jsx)(`button`,{onClick:e=>{e.stopPropagation(),A?j(!1):ce()},disabled:r||!_e,className:`flex items-center justify-center size-7 shrink-0 rounded-full bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-30 transition-colors`,"aria-label":A?`Cancel queued send`:`Send`,children:A?(0,$.jsx)(Z,{className:`size-3.5 animate-spin`}):(0,$.jsx)(i,{className:`size-3.5`})})]}),(0,$.jsxs)(`div`,{className:`hidden md:block`,children:[(0,$.jsx)(`textarea`,{ref:P,defaultValue:g??``,onChange:de,onKeyDown:le,onPaste:fe,onDrop:pe,onDragOver:me,placeholder:t?`Follow-up or Stop...`:`Ask anything...`,disabled:r,rows:1,className:`w-full resize-none bg-transparent px-4 pt-3 pb-1 text-sm text-foreground placeholder:text-text-subtle focus:outline-none disabled:opacity-50 max-h-40 [field-sizing:content]`}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-3 pb-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),he()},disabled:r,className:`flex items-center justify-center size-8 rounded-full text-text-subtle hover:text-text-primary hover:bg-surface-elevated transition-colors disabled:opacity-50`,"aria-label":`Attach file`,children:(0,$.jsx)(ot,{className:`size-4`})}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(rr,{mode:y??`bypassPermissions`,onClick:()=>k(e=>!e)}),(0,$.jsx)(tr,{value:y??`bypassPermissions`,onChange:e=>b?.(e),open:O,onOpenChange:k})]}),S&&a&&(0,$.jsx)(v,{value:x??`claude`,onChange:S,projectName:a}),t&&(0,$.jsx)(ar,{value:M,onChange:N})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[U.supported&&(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),ie()},disabled:r,className:`flex items-center justify-center size-8 rounded-full transition-colors disabled:opacity-50 ${U.isListening?`bg-red-600 text-white animate-pulse`:`text-text-subtle hover:text-text-primary hover:bg-surface-elevated`}`,"aria-label":U.isListening?`Stop voice input`:`Start voice input`,children:U.isListening?(0,$.jsx)(it,{className:`size-4`}):(0,$.jsx)(Ne,{className:`size-4`})}),ve?(0,$.jsx)(`button`,{onClick:e=>{e.stopPropagation(),n?.()},className:`flex items-center justify-center size-8 rounded-full bg-red-600 text-white hover:bg-red-500 transition-colors`,"aria-label":`Stop response`,children:(0,$.jsx)(Ke,{className:`size-3.5`})}):(0,$.jsx)(`button`,{onClick:e=>{e.stopPropagation(),A?j(!1):ce()},disabled:r||!_e,className:`flex items-center justify-center size-8 rounded-full bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,"aria-label":A?`Cancel queued send`:`Send message`,children:A?(0,$.jsx)(Z,{className:`size-4 animate-spin`}):(0,$.jsx)(i,{className:`size-4`})})]})]})]})]}),(0,$.jsx)(`input`,{ref:I,type:`file`,multiple:!0,className:`hidden`,onChange:ge})]})});function rr({mode:e,onClick:t}){let n=er(e),r=$n(e);return(0,$.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),t()},className:`inline-flex items-center gap-1 px-2 py-1 rounded-md text-[11px] text-text-subtle hover:text-text-primary hover:bg-surface-elevated transition-colors border border-transparent hover:border-border`,"aria-label":`Permission mode: ${r}`,children:[(0,$.jsx)(n,{className:`size-3`}),(0,$.jsx)(`span`,{className:`max-w-[100px] truncate`,children:r})]})}var ir=[{value:`now`,label:`Interrupt`,Icon:ft},{value:`next`,label:`Queue`,Icon:tt},{value:`later`,label:`Later`,Icon:P}];function ar({value:e,onChange:t}){let n=(0,Q.useCallback)(()=>{let n=[`next`,`later`,`now`];t(n[(n.indexOf(e)+1)%n.length])},[e,t]),r=ir.find(t=>t.value===e)??ir[1],i=r.Icon;return(0,$.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),n()},className:`inline-flex items-center gap-1 px-2 py-1 rounded-md text-[11px] text-text-subtle hover:text-text-primary hover:bg-surface-elevated transition-colors border border-transparent hover:border-border`,"aria-label":`Message priority: ${r.label}`,title:`Priority: ${r.label} (click to cycle)`,children:[(0,$.jsx)(i,{className:`size-3`}),(0,$.jsx)(`span`,{children:r.label})]})}function or(e,t){if(e===t)return 0;if(e.length===0)return t.length;if(t.length===0)return e.length;let n=Array.from({length:t.length+1},(e,t)=>t),r=Array(t.length+1);for(let i=1;i<=e.length;i++){r[0]=i;for(let a=1;a<=t.length;a++){let o=e[i-1]===t[a-1]?0:1;r[a]=Math.min(r[a-1]+1,n[a]+1,n[a-1]+o)}[n,r]=[r,n]}return n[t.length]}function sr(e,t){let n=e.toLowerCase(),r=t.toLowerCase();if(r.startsWith(n))return{rank:0,distance:0};if(r.includes(n))return{rank:1,distance:r.indexOf(n)};let i=Math.max(Math.floor(n.length*.4),2),a=or(n,r.slice(0,n.length+i));return a<=i?{rank:2,distance:a}:null}function cr(e,t,n=20,r=[]){if(!t)return e;t=t.slice(0,50);let i=new Set(r),a=[];for(let n of e){let e=[sr(t,n.name),sr(t,n.description)].filter(e=>e!==null).sort((e,t)=>e.rank-t.rank||e.distance-t.distance)[0];e&&a.push({item:n,rank:e.rank,distance:e.distance,recent:i.has(n.name)})}return a.sort((e,t)=>e.rank-t.rank||e.distance-t.distance||(e.recent===t.recent?0:e.recent?-1:1)||e.item.name.localeCompare(t.item.name)),a.slice(0,n).map(e=>e.item)}function lr({items:e,filter:t,onSelect:n,onClose:r,visible:i,recentNames:a=[],projectName:o}){let[s,c]=(0,Q.useState)(0),[l,u]=(0,Q.useState)(!1),d=(0,Q.useRef)(null),f=(0,Q.useMemo)(()=>new Set(a),[a]),p=(0,Q.useMemo)(()=>{if(t)return{items:cr(e,t,20,a),recentCount:0};if(a.length>0){let t=[],n=[];for(let r of e)f.has(r.name)?t.push(r):n.push(r);return t.sort((e,t)=>a.indexOf(e.name)-a.indexOf(t.name)),{items:[...t,...n],recentCount:t.length}}return{items:e,recentCount:0}},[e,t,a,f]),m=p.items,h=p.recentCount;(0,Q.useEffect)(()=>{c(0)},[t]),(0,Q.useEffect)(()=>{let e=d.current;e&&e.children[s]?.scrollIntoView({block:`nearest`})},[s]);let g=(0,Q.useCallback)(e=>{if(!i||m.length===0)return!1;switch(e.key){case`ArrowUp`:return e.preventDefault(),c(e=>e>0?e-1:m.length-1),!0;case`ArrowDown`:return e.preventDefault(),c(e=>e<m.length-1?e+1:0),!0;case`Enter`:case`Tab`:return e.preventDefault(),m[s]&&n(m[s]),!0;case`Escape`:return e.preventDefault(),r(),!0}return!1},[i,m,s,n,r]);(0,Q.useEffect)(()=>{if(!i)return;let e=e=>{g(e)&&e.stopPropagation()};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[i,g]);let _=(0,Q.useCallback)(()=>{!o||l||(u(!0),G.del(`${W(o)}/chat/slash-items/cache`).then(()=>{window.dispatchEvent(new CustomEvent(`ppm:slash-items-refresh`))}).finally(()=>u(!1)))},[o,l]);return!i||m.length===0?null:(0,$.jsx)(`div`,{className:`max-h-52 overflow-y-auto border-b border-border bg-surface`,children:(0,$.jsx)(`div`,{ref:d,className:`py-1`,children:m.map((e,t)=>{let r=h>0&&t===0,i=h>0&&t===h;return(0,$.jsxs)(`div`,{children:[r&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-3 pt-1 pb-0.5`,children:[(0,$.jsxs)(`span`,{className:`text-[10px] font-medium text-text-subtle uppercase tracking-wider flex items-center gap-1`,children:[(0,$.jsx)(P,{className:`size-3`}),`Recent`]}),o&&(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),_()},className:`text-text-subtle hover:text-text-primary transition-colors p-0.5 rounded`,title:`Refresh skill list`,"aria-label":`Refresh skill list`,children:(0,$.jsx)(U,{className:`size-3 ${l?`animate-spin`:``}`})})]}),i&&(0,$.jsx)(`div`,{className:`px-3 pt-1.5 pb-0.5`,children:(0,$.jsx)(`span`,{className:`text-[10px] font-medium text-text-subtle uppercase tracking-wider`,children:`All`})}),(0,$.jsxs)(`button`,{className:`flex items-start gap-3 w-full px-3 py-2 text-left transition-colors ${t===s?`bg-primary/10 text-primary`:`hover:bg-surface-hover text-text-primary`}`,onMouseEnter:()=>c(t),onClick:()=>n(e),children:[(0,$.jsx)(`span`,{className:`shrink-0 mt-0.5`,children:e.type===`builtin`?(0,$.jsx)(ft,{className:`size-4 text-emerald-500`}):e.type===`skill`?(0,$.jsx)(ne,{className:`size-4 text-amber-500`}):(0,$.jsx)(Ee,{className:`size-4 text-blue-500`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,$.jsxs)(`span`,{className:`font-medium text-sm`,children:[`/`,e.name]}),e.argumentHint&&(0,$.jsx)(`span`,{className:`text-xs text-text-subtle`,children:e.argumentHint}),(0,$.jsx)(`span`,{className:`text-xs text-text-subtle capitalize ml-auto`,children:e.scope===`bundled`?`PPM`:e.scope===`user`?`global`:e.type})]}),e.description&&(0,$.jsx)(`p`,{className:`text-xs text-text-subtle mt-0.5 line-clamp-2`,children:e.description})]})]})]},`${e.type}-${e.name}`)})})})}function ur({items:e,filter:t,onSelect:n,onClose:r,visible:i}){let[a,o]=(0,Q.useState)(0),s=(0,Q.useRef)(null),c=(()=>{if(!t)return e.slice(0,50);let n=t.toLowerCase();return e.filter(e=>e.path.toLowerCase().includes(n)||e.name.toLowerCase().includes(n)).slice(0,50)})();(0,Q.useEffect)(()=>{o(0)},[t]),(0,Q.useEffect)(()=>{let e=s.current;e&&e.children[a]?.scrollIntoView({block:`nearest`})},[a]);let l=(0,Q.useCallback)(e=>{if(!i||c.length===0)return!1;switch(e.key){case`ArrowUp`:return e.preventDefault(),o(e=>e>0?e-1:c.length-1),!0;case`ArrowDown`:return e.preventDefault(),o(e=>e<c.length-1?e+1:0),!0;case`Enter`:case`Tab`:return e.preventDefault(),c[a]&&n(c[a]),!0;case`Escape`:return e.preventDefault(),r(),!0}return!1},[i,c,a,n,r]);return(0,Q.useEffect)(()=>{if(!i)return;let e=e=>{l(e)&&e.stopPropagation()};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[i,l]),!i||c.length===0?null:(0,$.jsx)(`div`,{className:`max-h-52 overflow-y-auto border-b border-border bg-surface`,children:(0,$.jsx)(`div`,{ref:s,className:`py-1`,children:c.map((e,t)=>(0,$.jsxs)(`button`,{className:`flex items-center gap-2 w-full px-3 py-1.5 text-left transition-colors ${t===a?`bg-primary/10 text-primary`:`hover:bg-surface-hover text-text-primary`}`,onMouseEnter:()=>o(t),onClick:()=>n(e),children:[(0,$.jsx)(`span`,{className:`shrink-0`,children:e.type===`directory`?(0,$.jsx)(Ve,{className:`size-4 text-amber-500`}):(0,$.jsx)(Te,{className:`size-4 text-blue-400`})}),(0,$.jsx)(`span`,{className:`text-sm truncate`,children:e.path})]},e.path))})})}function dr({projectName:e,onTagsChanged:t}){let[n,r]=(0,Q.useState)([]),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(!0),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)(``),[h,g]=(0,Q.useState)(``),[_,v]=(0,Q.useState)(`#22c55e`),[y,b]=(0,Q.useState)(!1),x=`${W(e)}/tags`,C=(0,Q.useCallback)(async()=>{try{let e=await G.get(x);r(e.tags),a(e.defaultTagId)}catch{}s(!1)},[x]);(0,Q.useEffect)(()=>{C()},[C]);let w=async()=>{if(h.trim())try{await G.post(x,{name:h.trim(),color:_}),g(``),b(!1),C(),t?.()}catch{}},T=async e=>{try{await G.patch(`${x}/${e}`,{name:d.trim()||void 0,color:p||void 0}),u(null),C(),t?.()}catch{}},E=async(e,n)=>{if(window.confirm(`Delete tag "${n}"? Sessions with this tag will become untagged.`))try{await G.del(`${x}/${e}`),C(),t?.()}catch{}},D=async e=>{let t=e===i?null:e;try{await G.patch(`${x}/default-tag`,{tagId:t}),a(t)}catch{}};return o?(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground animate-pulse`,children:`Loading tags...`}):(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-medium text-muted-foreground`,children:`Session Tags`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`button`,{onClick:async()=>{try{await G.post(`${x}/reset`,{}),C(),t?.()}catch{}},className:`p-1 rounded text-text-subtle hover:text-text-secondary`,title:`Reset to defaults`,children:(0,$.jsx)(we,{className:`size-3`})}),(0,$.jsx)(`button`,{onClick:()=>b(!y),className:`p-1 rounded text-primary hover:bg-primary/10`,title:`Add tag`,children:(0,$.jsx)(V,{className:`size-3.5`})})]})]}),y&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 px-1`,children:[(0,$.jsx)(`input`,{type:`color`,value:_,onChange:e=>v(e.target.value),className:`size-6 rounded cursor-pointer border-0 p-0`}),(0,$.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),onKeyDown:e=>{e.key===`Enter`&&w(),e.key===`Escape`&&b(!1)},placeholder:`Tag name`,className:`flex-1 min-w-0 bg-surface-elevated text-[11px] text-text-primary px-2 py-1 rounded border border-border outline-none focus:border-primary`,autoFocus:!0}),(0,$.jsx)(`button`,{onClick:w,className:`p-1 text-green-500 hover:text-green-400`,children:(0,$.jsx)(S,{className:`size-3.5`})}),(0,$.jsx)(`button`,{onClick:()=>b(!1),className:`p-1 text-text-subtle hover:text-text-secondary`,children:(0,$.jsx)(H,{className:`size-3.5`})})]}),(0,$.jsxs)(`div`,{className:`space-y-0.5`,children:[n.map(e=>(0,$.jsx)(`div`,{className:`flex items-center gap-1.5 px-1 py-1 rounded hover:bg-surface-elevated group`,children:l===e.id?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`input`,{type:`color`,value:p,onChange:e=>m(e.target.value),className:`size-5 rounded cursor-pointer border-0 p-0`}),(0,$.jsx)(`input`,{value:d,onChange:e=>f(e.target.value),onKeyDown:t=>{t.key===`Enter`&&T(e.id),t.key===`Escape`&&u(null)},className:`flex-1 min-w-0 bg-surface-elevated text-[11px] px-1.5 py-0.5 rounded border border-border outline-none focus:border-primary`,autoFocus:!0}),(0,$.jsx)(`button`,{onClick:()=>T(e.id),className:`p-0.5 text-green-500`,children:(0,$.jsx)(S,{className:`size-3`})}),(0,$.jsx)(`button`,{onClick:()=>u(null),className:`p-0.5 text-text-subtle`,children:(0,$.jsx)(H,{className:`size-3`})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`size-3 rounded-full shrink-0`,style:{backgroundColor:e.color}}),(0,$.jsx)(`span`,{className:`flex-1 text-[11px] text-text-primary truncate`,children:e.name}),(0,$.jsx)(`button`,{onClick:()=>D(e.id),className:`px-1.5 py-0.5 rounded text-[9px] font-medium transition-colors ${e.id===i?`bg-primary/15 text-primary border border-primary/30`:`text-text-subtle border border-transparent can-hover:opacity-0 can-hover:group-hover:opacity-100 hover:bg-surface-elevated hover:border-border`}`,title:e.id===i?`Default tag (click to unset)`:`Set as default for new sessions`,children:e.id===i?`Default`:`Set default`}),(0,$.jsx)(`button`,{onClick:()=>{u(e.id),f(e.name),m(e.color)},className:`p-0.5 rounded text-text-subtle hover:text-text-secondary can-hover:opacity-0 can-hover:group-hover:opacity-100`,children:(0,$.jsx)(c,{className:`size-3`})}),(0,$.jsx)(`button`,{onClick:()=>E(e.id,e.name),className:`p-0.5 rounded text-text-subtle hover:text-red-400 can-hover:opacity-0 can-hover:group-hover:opacity-100`,children:(0,$.jsx)(te,{className:`size-3`})})]})},e.id)),n.length===0&&(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground py-2 text-center`,children:`No tags. Click + to create one.`})]})]})}var fr=`ppm-hienlh`;function pr({open:e,onOpenChange:t,onSuccess:n}){let[r,i]=(0,Q.useState)(``),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)(``),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(`idle`);function y(){f(null),m(``),v(`idle`),u(null)}function b(){t(!1),y(),i(``),o(``),u(null)}async function S(){g(!0),u(null);try{let{url:e,state:t}=await be();f(t),v(`waiting`),window.open(e,`_blank`)}catch(e){u(e.message)}g(!1)}async function C(){if(!(!p.trim()||!d)){g(!0),u(null);try{let e=p.trim();e.includes(`#`)&&(e=e.split(`#`)[0]??e),await fe(e,d),b(),n(`Account connected via OAuth!`)}catch(e){u(e.message)}g(!1)}}async function w(){if(r.trim()){c(!0),u(null);try{await ye({apiKey:r.trim(),label:a.trim()||void 0}),b(),n(`Account added!`)}catch(e){u(e.message)}c(!1)}}let T=r.trim()?r.trim().startsWith(`sk-ant-oat`)?`OAuth token (Claude Max/Pro)`:r.trim().startsWith(`sk-ant-api`)?`API key`:`Unknown format`:``;return(0,$.jsx)(k,{open:e,onOpenChange:e=>{e||b()},children:(0,$.jsxs)(j,{className:`sm:max-w-md`,children:[(0,$.jsxs)(A,{children:[(0,$.jsx)(M,{className:`text-sm`,children:`Add Claude Account`}),(0,$.jsx)(D,{className:`text-xs leading-relaxed`,children:`Connect via OAuth (recommended) or paste a token manually.`})]}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`rounded-md border p-3 space-y-2`,children:[(0,$.jsx)(`p`,{className:`text-[11px] font-medium`,children:`Recommended: Login with Claude`}),_===`idle`?(0,$.jsx)(O,{size:`sm`,className:`w-full h-8 text-xs`,onClick:S,disabled:h,children:h?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{className:`size-3 animate-spin mr-1`}),` Opening...`]}):`Login with Claude`}):(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Authorize in the opened tab, then paste the code:`}),(0,$.jsx)(N,{placeholder:`Paste code here...`,value:p,onChange:e=>m(e.target.value),className:`text-xs h-8 font-mono`,autoFocus:!0}),(0,$.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,$.jsx)(O,{size:`sm`,className:`flex-1 h-7 text-xs`,onClick:C,disabled:!p.trim()||h,children:h?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{className:`size-3 animate-spin mr-1`}),` Connecting...`]}):`Connect`}),(0,$.jsx)(O,{size:`sm`,variant:`ghost`,className:`h-7 text-xs`,onClick:y,children:`Cancel`})]})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`flex-1 border-t`}),(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`or paste token`}),(0,$.jsx)(`div`,{className:`flex-1 border-t`})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(x,{htmlFor:`add-token`,className:`text-xs`,children:`Token`}),(0,$.jsx)(N,{id:`add-token`,type:`password`,placeholder:`sk-ant-...`,value:r,onChange:e=>i(e.target.value),className:`text-xs h-8 font-mono`}),T&&(0,$.jsxs)(`p`,{className:`text-[10px] text-muted-foreground`,children:[`Detected: `,T]})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(x,{htmlFor:`add-label`,className:`text-xs`,children:`Label (optional)`}),(0,$.jsx)(N,{id:`add-label`,placeholder:`e.g. Personal, Work`,value:a,onChange:e=>o(e.target.value),className:`text-xs h-8`})]})]}),l&&(0,$.jsx)(`div`,{className:`text-[11px] p-2 rounded bg-red-500/10 text-red-600`,children:l}),(0,$.jsxs)(E,{children:[(0,$.jsx)(O,{size:`sm`,variant:`outline`,className:`text-xs h-7`,onClick:b,children:`Cancel`}),(0,$.jsx)(O,{size:`sm`,className:`text-xs h-7`,onClick:w,disabled:!r.trim()||s,children:s?`Adding...`:`Add Token`})]})]})})}function mr({open:e,onOpenChange:t,accounts:n,preselectId:r,onMessage:i}){let a=n.filter(e=>e.hasRefreshToken),[o,s]=(0,Q.useState)(new Set),[c,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(!1);e&&!_&&(s(r?new Set([r]):new Set(a.map(e=>e.id))),v(!0)),!e&&_&&v(!1);function y(){t(!1),u(``),f(!1),m(!1)}async function b(e){if(o.size===0)return;g(!0);let t=c.trim()||fr;try{let n={"Content-Type":`application/json`},r=re();r&&(n.Authorization=`Bearer ${r}`);let a=await fetch(`/api/accounts/export`,{method:`POST`,headers:n,body:JSON.stringify({password:t,accountIds:[...o],includeRefreshToken:d,refreshBeforeExport:p})});if(!a.ok){let e=await a.json();throw Error(e.error??`Export failed: ${a.status}`)}let s=await a.text();if(e)try{await navigator.clipboard.writeText(s),i?.(`Backup copied to clipboard!`)}catch{gr(s),i?.(`Backup downloaded.`)}else gr(s),i?.(`Backup downloaded.`);y()}catch{}g(!1)}let S=o.size>0&&!h;return(0,$.jsx)(k,{open:e,onOpenChange:e=>{e||y()},children:(0,$.jsxs)(j,{className:`sm:max-w-md`,children:[(0,$.jsxs)(A,{children:[(0,$.jsxs)(M,{className:`text-sm flex items-center gap-1.5`,children:[(0,$.jsx)(l,{className:`size-3.5`}),` Export Accounts`]}),(0,$.jsx)(D,{className:`text-xs`,children:`Select accounts and set a password to protect the backup.`})]}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,$.jsx)(`p`,{className:`text-[11px] font-medium text-muted-foreground`,children:`Accounts to export`}),(0,$.jsx)(`button`,{className:`text-[10px] text-primary hover:underline cursor-pointer`,onClick:()=>s(o.size===a.length?new Set:new Set(a.map(e=>e.id))),children:o.size===a.length?`Deselect all`:`Select all`})]}),a.length===0?(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground p-2 border rounded`,children:`No exportable accounts.`}):(0,$.jsx)(`div`,{className:`max-h-36 overflow-y-auto space-y-1 border rounded p-2`,children:a.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,id:`exp-${e.id}`,checked:o.has(e.id),onChange:t=>{let n=new Set(o);t.target.checked?n.add(e.id):n.delete(e.id),s(n)},className:`size-3.5 accent-primary cursor-pointer`}),(0,$.jsx)(`label`,{htmlFor:`exp-${e.id}`,className:`text-xs cursor-pointer truncate`,children:e.label??e.email??e.id.slice(0,8)})]},e.id))})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(x,{className:`text-xs`,children:[`Password `,(0,$.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional)`})]}),(0,$.jsx)(N,{type:`password`,placeholder:`Leave empty for default`,value:c,onChange:e=>u(e.target.value),className:`text-xs h-8`,autoComplete:`new-password`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,id:`exp-full`,checked:d,onChange:e=>f(e.target.checked),className:`size-3.5 accent-primary cursor-pointer`}),(0,$.jsx)(`label`,{htmlFor:`exp-full`,className:`text-[11px] cursor-pointer`,children:`Include refresh tokens (full transfer)`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,id:`exp-refresh`,checked:p,onChange:e=>m(e.target.checked),className:`size-3.5 accent-primary cursor-pointer`}),(0,$.jsx)(`label`,{htmlFor:`exp-refresh`,className:`text-[11px] cursor-pointer`,children:`Refresh tokens before export`})]}),d?(0,$.jsxs)(`div`,{className:`rounded-md border border-red-500/30 bg-red-500/5 p-2.5`,children:[(0,$.jsx)(`p`,{className:`text-[10px] font-medium text-red-600`,children:`Full transfer — source accounts will expire`}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Refresh tokens included. Source machine expires in ~1h after target refreshes.`})]}):p?(0,$.jsx)(`div`,{className:`rounded-md border border-amber-500/30 bg-amber-500/5 p-2.5`,children:(0,$.jsx)(`p`,{className:`text-[10px] font-medium text-amber-600`,children:`Refresh before export — invalidates previous shares`})}):(0,$.jsx)(`div`,{className:`rounded-md border border-green-500/30 bg-green-500/5 p-2.5`,children:(0,$.jsx)(`p`,{className:`text-[10px] font-medium text-green-600`,children:`Share current token (safe)`})}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Encrypted with AES-256-GCM + scrypt.`})]}),(0,$.jsxs)(E,{className:`gap-1.5 flex-col sm:flex-row`,children:[(0,$.jsx)(O,{size:`sm`,variant:`outline`,className:`text-xs h-7 cursor-pointer`,onClick:y,children:`Cancel`}),(0,$.jsxs)(O,{size:`sm`,variant:`outline`,className:`text-xs h-7 cursor-pointer`,disabled:!S,onClick:()=>b(!0),children:[(0,$.jsx)(Ie,{className:`size-3 mr-1`}),` Copy`]}),(0,$.jsx)(O,{size:`sm`,className:`text-xs h-7 cursor-pointer`,disabled:!S,onClick:()=>b(!1),children:h?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{className:`size-3 animate-spin mr-1`}),` Exporting...`]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(z,{className:`size-3 mr-1`}),` Download`]})})]})]})})}function hr({open:e,onOpenChange:t,onSuccess:n}){let[r,i]=(0,Q.useState)(``),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(null);function f(){t(!1),i(``),o(``),d(null)}async function p(){if(r.trim()){c(!0),d(null);try{let e=await ge({data:r.trim(),password:a.trim()||fr});f(),n(`Imported ${e.imported} account(s)`)}catch(e){d(e.message||`Import failed`)}c(!1)}}return(0,$.jsx)(k,{open:e,onOpenChange:e=>{e||f()},children:(0,$.jsxs)(j,{className:`sm:max-w-md`,children:[(0,$.jsxs)(A,{children:[(0,$.jsxs)(M,{className:`text-sm flex items-center gap-1.5`,children:[(0,$.jsx)(l,{className:`size-3.5`}),` Import Accounts`]}),(0,$.jsx)(D,{className:`text-xs`,children:`Paste backup data and enter the export password. Imported accounts are temporary (~1h).`})]}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(x,{className:`text-xs`,children:`Backup data`}),(0,$.jsx)(`textarea`,{value:r,onChange:e=>i(e.target.value),placeholder:`Paste backup JSON here...`,rows:4,className:`w-full text-xs p-2 rounded border border-border bg-background font-mono resize-none focus:outline-none focus:ring-1 focus:ring-primary`})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(x,{className:`text-xs`,children:[`Password `,(0,$.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional)`})]}),(0,$.jsx)(N,{type:`password`,placeholder:`Leave empty for default`,value:a,onChange:e=>o(e.target.value),className:`text-xs h-8`,autoComplete:`current-password`})]})]}),u&&(0,$.jsx)(`div`,{className:`text-[11px] p-2 rounded bg-red-500/10 text-red-600`,children:u}),(0,$.jsxs)(E,{children:[(0,$.jsx)(O,{size:`sm`,variant:`outline`,className:`text-xs h-7 cursor-pointer`,onClick:f,children:`Cancel`}),(0,$.jsx)(O,{size:`sm`,className:`text-xs h-7 cursor-pointer`,disabled:!r.trim()||s,onClick:p,children:s?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{className:`size-3 animate-spin mr-1`}),` Importing...`]}):`Import`})]})]})})}function gr(e){let t=new Blob([e],{type:`application/json`}),n=document.createElement(`a`);n.href=URL.createObjectURL(t),n.download=`ppm-accounts-backup.json`,n.click(),URL.revokeObjectURL(n.href)}var _r=typeof window<`u`?window.matchMedia(`(min-width: 768px)`):null;function vr(e){return _r?.addEventListener(`change`,e),()=>_r?.removeEventListener(`change`,e)}function yr(){return _r?.matches??!0}function br(){let[e,t]=(0,Q.useState)(null),[n,r]=(0,Q.useState)(!0);return(0,Q.useEffect)(()=>{r(!0),he().then(t).finally(()=>r(!1))},[]),n?(0,$.jsx)(`p`,{className:`text-xs text-text-subtle py-4 text-center`,children:`Loading...`}):e?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-xs font-medium text-text-primary`,children:`Rotation Strategy`}),(0,$.jsxs)(f,{value:e.strategy,onValueChange:async e=>{t(await de({strategy:e}))},children:[(0,$.jsx)(y,{className:`w-full h-9 text-xs`,children:(0,$.jsx)(s,{})}),(0,$.jsxs)(o,{children:[(0,$.jsx)(g,{value:`round-robin`,children:`Round-robin`}),(0,$.jsx)(g,{value:`fill-first`,children:`Fill-first`}),(0,$.jsx)(g,{value:`lowest-usage`,children:`Lowest usage`})]})]}),(0,$.jsxs)(`p`,{className:`text-[10px] text-text-subtle`,children:[e.strategy===`round-robin`&&`Cycles through accounts evenly`,e.strategy===`fill-first`&&`Uses one account until its limit, then moves on`,e.strategy===`lowest-usage`&&`Picks the account with the lowest current usage`]})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-xs font-medium text-text-primary`,children:`Max Retry`}),(0,$.jsx)(`input`,{type:`number`,min:0,value:e.maxRetry,className:`w-full h-9 text-xs border rounded-md px-3 bg-background`,onChange:async e=>{let n=parseInt(e.target.value,10);!isNaN(n)&&n>=0&&t(await de({maxRetry:n}))}}),(0,$.jsx)(`p`,{className:`text-[10px] text-text-subtle`,children:`How many accounts to try on failure. 0 = try all available accounts.`})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs border-t border-border pt-3`,children:[(0,$.jsx)(`span`,{className:`text-text-subtle`,children:`Active accounts`}),(0,$.jsx)(`span`,{className:`font-medium text-text-primary`,children:e.activeCount})]})]}):(0,$.jsx)(`p`,{className:`text-xs text-text-subtle py-4 text-center`,children:`Failed to load settings`})}function xr({open:e,onOpenChange:t}){let n=(0,Q.useSyncExternalStore)(vr,yr);return e?n?(0,$.jsx)(k,{open:e,onOpenChange:t,children:(0,$.jsxs)(j,{className:`sm:max-w-sm`,children:[(0,$.jsx)(A,{children:(0,$.jsxs)(M,{className:`text-sm flex items-center gap-2`,children:[(0,$.jsx)(Se,{className:`size-4`}),` Rotation & Retry`]})}),(0,$.jsx)(br,{})]})}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`fixed inset-0 z-50 transition-opacity duration-200 opacity-100`,onClick:()=>t(!1),style:{backgroundColor:`rgba(0,0,0,0.5)`}}),(0,$.jsxs)(`div`,{className:q(`fixed bottom-0 left-0 right-0 z-50 bg-background rounded-t-2xl border-t border-border shadow-2xl`,`transition-transform duration-300 ease-out max-h-[85vh] overflow-y-auto`,`translate-y-0`),children:[(0,$.jsx)(`div`,{className:`flex justify-center pt-3 pb-1`,children:(0,$.jsx)(`div`,{className:`w-10 h-1 rounded-full bg-border`})}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-b border-border`,children:[(0,$.jsxs)(`span`,{className:`text-sm font-semibold flex items-center gap-2`,children:[(0,$.jsx)(Se,{className:`size-4`}),` Rotation & Retry`]}),(0,$.jsx)(`button`,{onClick:()=>t(!1),className:`flex items-center justify-center size-7 rounded-md hover:bg-surface-elevated transition-colors`,children:(0,$.jsx)(H,{className:`size-4`})})]}),(0,$.jsx)(`div`,{className:`px-4 py-4 pb-8`,children:(0,$.jsx)(br,{})})]})]}):null}var Sr=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],Cr=Array.from({length:24},(e,t)=>t);function wr(e,t){let n=Array.from({length:7},()=>Array.from({length:24},()=>({sum:0,count:0,avg:0})));for(let r of e){let e=t===`5h`?r.five_hour_util:r.weekly_util;if(e==null)continue;let i=new Date(r.recorded_at+(r.recorded_at.endsWith(`Z`)?``:`Z`)),a=(i.getDay()+6)%7,o=i.getHours();n[a][o].sum+=e,n[a][o].count+=1}for(let e of n)for(let t of e)t.avg=t.count>0?t.sum/t.count:0;return n}function Tr(e){return e.map(e=>{let t=e.reduce((e,t)=>e+t.sum,0),n=e.reduce((e,t)=>e+t.count,0);return n>0?t/n:0})}function Er(e){return Cr.map(t=>{let n=0,r=0;for(let i of e)n+=i[t].sum,r+=i[t].count;return r>0?n/r:0})}function Dr(e){return e===0?`bg-surface-elevated`:e<.3?`bg-green-500/30`:e<.5?`bg-green-500/60`:e<.7?`bg-amber-500/50`:e<.9?`bg-amber-500/80`:`bg-red-500/80`}function Or(e){return e<.3?`bg-green-500`:e<.7?`bg-amber-500`:`bg-red-500`}function kr({accountId:e}){let[t,n]=(0,Q.useState)(null),[r,i]=(0,Q.useState)(!0),[a,o]=(0,Q.useState)(`5h`);(0,Q.useEffect)(()=>{i(!0),ue(e).then(n).catch(()=>n([])).finally(()=>i(!1))},[e]);let s=(0,Q.useMemo)(()=>t?wr(t,a):null,[t,a]),c=(0,Q.useMemo)(()=>s?Tr(s):[],[s]),l=(0,Q.useMemo)(()=>s?Er(s):[],[s]),u=Math.max(...c,.01);if(Math.max(...l,.01),r)return(0,$.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,$.jsx)(Z,{className:`size-3 animate-spin text-text-subtle`})});if(!t||t.length===0)return(0,$.jsx)(`div`,{className:`text-[10px] text-text-subtle py-2 text-center`,children:`No usage history yet`});let d=t.length,f=new Set(t.map(e=>new Date(e.recorded_at+(e.recorded_at.endsWith(`Z`)?``:`Z`)).toDateString())).size;return(0,$.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-[10px] font-medium text-text-subtle`,children:`Usage Pattern (7d)`}),(0,$.jsxs)(`div`,{className:`flex gap-0.5 text-[9px]`,children:[(0,$.jsx)(`button`,{onClick:()=>o(`5h`),className:`px-1.5 py-0.5 rounded cursor-pointer transition-colors ${a===`5h`?`bg-primary/15 text-primary`:`text-text-subtle hover:text-text-secondary`}`,title:`5-hour rolling window limit — resets every 5 hours`,children:`5h`}),(0,$.jsx)(`button`,{onClick:()=>o(`weekly`),className:`px-1.5 py-0.5 rounded cursor-pointer transition-colors ${a===`weekly`?`bg-primary/15 text-primary`:`text-text-subtle hover:text-text-secondary`}`,title:`Weekly limit — resets every 7 days`,children:`Wk`})]})]}),(0,$.jsxs)(`p`,{className:`text-[9px] text-text-subtle leading-tight`,children:[`Avg `,a===`5h`?`5-hour`:`weekly`,` limit usage over `,f,`d (`,d,` samples). Higher % = closer to rate limit. Hover cells for details.`]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`text-[9px] text-text-subtle`,children:`Avg usage by day of week`}),(0,$.jsx)(`div`,{className:`flex flex-col gap-[2px] mt-0.5`,children:Sr.map((e,t)=>{let n=c[t]??0;return(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`text-[8px] text-text-subtle w-5 shrink-0 text-right tabular-nums`,children:e}),(0,$.jsx)(`div`,{className:`flex-1 h-2.5 bg-surface-elevated rounded-sm overflow-hidden`,children:(0,$.jsx)(`div`,{className:`h-full rounded-sm transition-all ${Or(n)}`,style:{width:`${Math.round(n/u*100)}%`}})}),(0,$.jsxs)(`span`,{className:`text-[8px] text-text-subtle w-6 shrink-0 text-right tabular-nums`,children:[Math.round(n*100),`%`]})]},e)})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`text-[9px] text-text-subtle`,children:`Avg usage by hour (0h-23h)`}),(0,$.jsx)(`div`,{className:`flex gap-[1px] mt-0.5`,children:Cr.map(e=>{let t=l[e]??0;return(0,$.jsxs)(`div`,{className:`flex-1 flex flex-col items-center gap-[1px]`,children:[(0,$.jsx)(`div`,{className:`w-full aspect-square rounded-[2px] ${Dr(t)}`,title:`${e}:00 — avg ${Math.round(t*100)}% usage`}),e%6==0&&(0,$.jsx)(`span`,{className:`text-[7px] text-text-subtle tabular-nums`,children:e})]},e)})})]}),s&&(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`text-[9px] text-text-subtle`,children:`Day x Hour heatmap`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-[1px] mt-0.5`,children:[Sr.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-[1px]`,children:[(0,$.jsx)(`span`,{className:`text-[7px] text-text-subtle w-4 shrink-0 text-right`,children:e.charAt(0)}),Cr.map(n=>{let r=s[t][n];return(0,$.jsx)(`div`,{className:`flex-1 aspect-square rounded-[1px] ${Dr(r.avg)}`,title:`${e} ${n}:00 — ${r.count>0?`avg ${Math.round(r.avg*100)}% (${r.count} samples)`:`no data`}`},n)})]},e)),(0,$.jsxs)(`div`,{className:`flex items-center gap-[1px]`,children:[(0,$.jsx)(`span`,{className:`w-4 shrink-0`}),Cr.map(e=>(0,$.jsx)(`div`,{className:`flex-1 text-center`,children:e%6==0&&(0,$.jsx)(`span`,{className:`text-[7px] text-text-subtle tabular-nums`,children:e})},e))]})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[8px] text-text-subtle`,children:[(0,$.jsx)(`span`,{children:`Low`}),(0,$.jsxs)(`div`,{className:`flex gap-[2px]`,children:[(0,$.jsx)(`div`,{className:`size-2 rounded-[1px] bg-green-500/30`}),(0,$.jsx)(`div`,{className:`size-2 rounded-[1px] bg-green-500/60`}),(0,$.jsx)(`div`,{className:`size-2 rounded-[1px] bg-amber-500/50`}),(0,$.jsx)(`div`,{className:`size-2 rounded-[1px] bg-amber-500/80`}),(0,$.jsx)(`div`,{className:`size-2 rounded-[1px] bg-red-500/80`})]}),(0,$.jsx)(`span`,{children:`High`}),(0,$.jsx)(`span`,{className:`ml-1`,children:`|`}),(0,$.jsx)(`div`,{className:`size-2 rounded-[1px] bg-surface-elevated border border-border/30`}),(0,$.jsx)(`span`,{children:`No data`})]})]})}function Ar(e){return e>=90?`text-red-500`:e>=70?`text-amber-500`:`text-green-500`}function jr(e){return e>=90?`bg-red-500`:e>=70?`bg-amber-500`:`bg-green-500`}function Mr(e){if(!e)return null;let t=null;if(e.resetsInMinutes!=null)t=e.resetsInMinutes;else if(e.resetsInHours!=null)t=Math.round(e.resetsInHours*60);else if(e.resetsAt){let n=new Date(e.resetsAt).getTime()-Date.now();t=n>0?Math.ceil(n/6e4):0}if(t==null)return null;if(t<=0)return`now`;let n=Math.floor(t/1440),r=Math.floor(t%1440/60),i=t%60;return n>0?i>0?`${n}d ${r}h ${i}m`:r>0?`${n}d ${r}h`:`${n}d`:r>0?i>0?`${r}h ${i}m`:`${r}h`:`${i}m`}function Nr({label:e,bucket:t}){if(!t)return null;let n=Math.round(t.utilization*100),r=Mr(t);return(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-text-primary`,children:e}),r&&(0,$.jsxs)(`span`,{className:`text-[10px] text-text-subtle`,title:`Resets in`,children:[`↻ `,r]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`flex-1 h-2 rounded-full bg-border overflow-hidden`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full transition-all ${jr(n)}`,style:{width:`${Math.min(n,100)}%`}})}),(0,$.jsxs)(`span`,{className:`text-xs font-medium tabular-nums w-10 text-right ${Ar(n)}`,children:[n,`%`]})]})]})}function Pr(e){let t=e-Date.now();if(t<=0)return`expired`;let n=Math.ceil(t/6e4),r=Math.floor(n/60),i=Math.floor(r/24);return i>0?`${i}d ${r%24}h`:r>0?`${r}h ${n%60}m`:`${n}m`}function Fr(e){if(!e)return{label:`unknown`,tip:`No account info available`,color:`text-text-subtle`};if(!e.expiresAt)return{label:`key`,tip:`API key (no expiry)`,color:`text-text-subtle`};let t=e.expiresAt*1e3<Date.now();return t&&e.hasRefreshToken?{label:`expired`,tip:`Token expired but has refresh token — will auto-renew`,color:`text-amber-500`}:t?{label:`expired`,tip:`Token expired, no refresh token`,color:`text-red-500`}:e.hasRefreshToken?{label:`long-lived`,tip:`OAuth token with refresh — long-lived`,color:`text-green-500`}:{label:`temp`,tip:`Temporary token without refresh — will expire`,color:`text-amber-500`}}function Ir(e){if(!e)return null;let t=Math.round((Date.now()-e)/1e3);if(t<5)return`just now`;if(t<60)return`${t}s ago`;let n=Math.floor(t/60);if(n<60)return`${n}m ago`;let r=Math.floor(n/60),i=n%60;return r<24?i>0?`${r}h ${i}m ago`:`${r}h ago`:`${Math.floor(r/24)}d ago`}function Lr({entry:e,isActive:t,accountInfo:n,onToggle:r,onDelete:i,onExport:a,onViewProfile:o,flash:s,fullscreen:c}){let{usage:l}=e,u=l.session||l.weekly||l.weeklyOpus||l.weeklySonnet,d=n?.status??e.accountStatus,f=!!(n&&!n.hasRefreshToken&&n.expiresAt&&n.expiresAt<Math.floor(Date.now()/1e3));return(0,$.jsxs)(`div`,{className:`rounded-md border p-2 transition-colors duration-500 ${c?`flex flex-col gap-1.5 overflow-hidden`:`space-y-1.5 min-w-[200px] shrink-0 snap-start`} ${f?`opacity-50`:``} ${s?`bg-primary/10 border-primary/40`:``} ${t?`border-primary/30 bg-primary/5`:`border-border/50`}`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium truncate flex-1 min-w-0`,children:e.accountLabel??e.accountId.slice(0,8)}),f&&(0,$.jsx)(`span`,{className:`text-[9px] text-red-500 shrink-0 font-medium`,children:`Expired`}),!e.isOAuth&&!f&&(0,$.jsx)(`span`,{className:`text-[9px] text-text-subtle shrink-0`,children:`API key`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5 shrink-0`,children:[!f&&o&&n?.profileData&&(0,$.jsx)(`button`,{className:`p-1 rounded cursor-pointer text-text-subtle hover:text-foreground hover:bg-surface-elevated transition-colors`,onClick:()=>o(n.profileData,e.accountId),title:`View profile`,children:(0,$.jsx)(B,{className:`size-3`})}),!f&&a&&e.isOAuth&&(0,$.jsx)(`button`,{className:`p-1 rounded cursor-pointer text-text-subtle hover:text-blue-500 hover:bg-surface-elevated transition-colors`,onClick:()=>a(e.accountId),title:`Export this account`,children:(0,$.jsx)(z,{className:`size-3`})}),!f&&r&&(0,$.jsx)(p,{checked:d!==`disabled`,onCheckedChange:()=>r(e.accountId,d),disabled:d===`cooldown`,className:`scale-[0.6] cursor-pointer`}),i&&(0,$.jsx)(`button`,{className:`p-1 rounded cursor-pointer text-text-subtle hover:text-red-500 hover:bg-surface-elevated transition-colors`,onClick:()=>i(e.accountId,e.accountLabel??e.accountId.slice(0,8)),title:`Remove account`,children:(0,$.jsx)(te,{className:`size-3`})})]})]}),u?(0,$.jsxs)(`div`,{className:c?`flex-1 flex flex-col justify-evenly min-h-0`:`space-y-1.5`,children:[(0,$.jsx)(Nr,{label:`5-Hour Session`,bucket:l.session}),(0,$.jsx)(Nr,{label:`Weekly`,bucket:l.weekly}),(0,$.jsx)(Nr,{label:`Weekly (Opus)`,bucket:l.weeklyOpus}),(0,$.jsx)(Nr,{label:`Weekly (Sonnet)`,bucket:l.weeklySonnet})]}):(0,$.jsx)(`p`,{className:`text-[10px] text-text-subtle`,children:e.isOAuth?`No usage data yet`:`Usage tracking not available for API keys`}),(()=>{let e=Fr(n);return(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[9px] text-text-subtle flex-wrap`,children:[l.lastFetchedAt&&(0,$.jsxs)(`span`,{title:`Last usage data update`,children:[`↻ `,Ir(new Date(l.lastFetchedAt).getTime())]}),n?.expiresAt&&n.expiresAt*1e3>Date.now()&&(0,$.jsxs)(`span`,{title:`Token expires in`,children:[`⏱ `,Pr(n.expiresAt*1e3)]}),(0,$.jsxs)(`span`,{className:e.color,title:e.tip,children:[`© `,e.label]})]})})()]})}function Rr({usage:e,visible:t,onClose:n,onReload:r,loading:i,lastFetchedAt:a}){let[o,s]=(0,Q.useState)([]),[c,l]=(0,Q.useState)([]),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(!0),[m,h]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(new Set),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(!1),[E,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(null),[A,j]=(0,Q.useState)(null),[M,N]=(0,Q.useState)(!1),[P,F]=(0,Q.useState)(null),I=(0,Q.useRef)(void 0),L=(0,Q.useRef)([]);function ee(e){I.current&&clearTimeout(I.current),F(e),I.current=setTimeout(()=>F(null),4e3)}function R(e){B(),e&&ee(e)}async function B(){let e=o.length>0;e?h(!0):p(!0);let[t,n,r]=await Promise.allSettled([pe(),ve(),le()]);if(t.status===`fulfilled`){let n=t.value;if(e&&L.current.length>0){let e=new Set,t=new Map(L.current.map(e=>[e.accountId,e]));for(let r of n){let n=t.get(r.accountId);if(!n){e.add(r.accountId);continue}let i=n.usage,a=r.usage;(i.session?.utilization!==a.session?.utilization||i.weekly?.utilization!==a.weekly?.utilization||i.weeklyOpus?.utilization!==a.weeklyOpus?.utilization||i.weeklySonnet?.utilization!==a.weeklySonnet?.utilization)&&e.add(r.accountId)}e.size>0&&(_(e),setTimeout(()=>_(new Set),1500))}L.current=n,s(n)}n.status===`fulfilled`&&l(n.value),r.status===`fulfilled`&&d(r.value?.id??null),p(!1),h(!1)}if((0,Q.useEffect)(()=>{t&&B()},[t]),(0,Q.useEffect)(()=>{!t||!a||B()},[a]),!t)return null;let te=new Map(c.map(e=>[e.id,e])),ne=e.queryCostUsd!=null||e.totalCostUsd!=null,W=o.length>0,re=o.length||1,G=Math.ceil(Math.sqrt(re)),K=Math.ceil(re/G);async function ie(e,t){await me(e,{status:t===`disabled`?`active`:`disabled`}),B(),r?.()}async function q(){if(O){try{await _e(O.id),ee(`Account "${O.display}" removed.`),B(),r?.()}catch(e){ee(`Failed to remove: ${e.message}`)}k(null)}}function ae(){j(null),C(!0)}return(0,$.jsxs)(`div`,{className:`relative border-b border-border bg-surface px-3 py-2.5 ${M?`fixed inset-0 z-50 flex flex-col gap-2.5 overflow-hidden`:`space-y-2.5 max-h-[350px] overflow-y-auto`}`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between shrink-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-xs font-semibold text-text-primary`,children:`Usage & Accounts`}),a&&(0,$.jsx)(`span`,{className:`text-[10px] text-text-subtle`,children:Ir(new Date(a).getTime())})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`button`,{onClick:()=>D(!0),className:`text-xs text-text-subtle hover:text-text-primary px-1 cursor-pointer`,title:`Rotation & retry settings`,children:(0,$.jsx)(Se,{className:`size-3`})}),W&&(0,$.jsx)(`button`,{onClick:()=>N(e=>!e),className:`text-xs text-text-subtle hover:text-text-primary px-1 cursor-pointer`,title:M?`Exit fullscreen`:`Fullscreen view`,children:M?(0,$.jsx)(at,{className:`size-3`}):(0,$.jsx)(rt,{className:`size-3`})}),r&&(0,$.jsx)(`button`,{onClick:()=>{r(),B()},disabled:i||m,className:`text-xs text-text-subtle hover:text-text-primary px-1 disabled:opacity-50 cursor-pointer`,title:`Refresh`,children:(0,$.jsx)(U,{className:`size-3 ${i||m?`animate-spin`:``}`})}),(0,$.jsx)(`button`,{onClick:()=>{N(!1),n()},className:`text-xs text-text-subtle hover:text-text-primary px-1 cursor-pointer`,children:(0,$.jsx)(H,{className:`size-3`})})]})]}),P&&(0,$.jsx)(`div`,{className:`text-[11px] p-1.5 rounded bg-green-500/10 text-green-600 text-center animate-in fade-in duration-200`,children:P}),W||f?(0,$.jsx)(`div`,{className:M?`flex-1 min-h-0 grid gap-2 overflow-hidden`:`flex gap-1.5 overflow-x-auto pb-1 -mx-3 px-3 snap-x snap-mandatory scrollbar-thin`,style:M?{gridTemplateColumns:`repeat(${G}, minmax(0, 1fr))`,gridTemplateRows:`repeat(${K}, minmax(0, 1fr))`}:void 0,children:f?(0,$.jsx)(`p`,{className:`text-[10px] text-text-subtle`,children:`Loading...`}):o.map(t=>(0,$.jsx)(Lr,{entry:t,isActive:t.accountId===(u??e.activeAccountId),accountInfo:te.get(t.accountId),onToggle:ie,onDelete:(e,t)=>k({id:e,display:t}),onExport:e=>{j(e),C(!0)},onViewProfile:(e,t)=>y({profile:e,accountId:t}),flash:g.has(t.accountId),fullscreen:M},t.accountId))}):(0,$.jsx)($.Fragment,{children:e.session||e.weekly||e.weeklyOpus||e.weeklySonnet?(0,$.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,$.jsx)(Nr,{label:`5-Hour Session`,bucket:e.session}),(0,$.jsx)(Nr,{label:`Weekly`,bucket:e.weekly}),(0,$.jsx)(Nr,{label:`Weekly (Opus)`,bucket:e.weeklyOpus}),(0,$.jsx)(Nr,{label:`Weekly (Sonnet)`,bucket:e.weeklySonnet})]}):(0,$.jsx)(`p`,{className:`text-xs text-text-subtle`,children:`No usage data available`})}),ne&&(0,$.jsxs)(`div`,{className:`border-t border-border pt-2 space-y-1`,children:[e.queryCostUsd!=null&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,$.jsx)(`span`,{className:`text-text-subtle`,children:`Last query`}),(0,$.jsxs)(`span`,{className:`text-text-primary font-medium tabular-nums`,children:[`$`,e.queryCostUsd.toFixed(4)]})]}),e.totalCostUsd!=null&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,$.jsx)(`span`,{className:`text-text-subtle`,children:`Session total`}),(0,$.jsxs)(`span`,{className:`text-text-primary font-medium tabular-nums`,children:[`$`,e.totalCostUsd.toFixed(4)]})]})]}),v&&(0,$.jsxs)(`div`,{className:`border-t border-border pt-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,$.jsx)(`span`,{className:`text-[10px] font-medium text-text-subtle`,children:`Profile`}),(0,$.jsx)(`button`,{className:`text-text-subtle hover:text-foreground cursor-pointer`,onClick:()=>y(null),children:(0,$.jsx)(H,{className:`size-3`})})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-[70px_1fr] gap-x-2 gap-y-0.5 text-[10px]`,children:[v.profile.account?.display_name&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`text-text-subtle`,children:`Name`}),(0,$.jsx)(`span`,{children:v.profile.account.display_name})]}),v.profile.account?.email&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`text-text-subtle`,children:`Email`}),(0,$.jsx)(`span`,{children:v.profile.account.email})]}),v.profile.organization?.name&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`text-text-subtle`,children:`Org`}),(0,$.jsx)(`span`,{children:v.profile.organization.name})]}),v.profile.organization?.organization_type&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`text-text-subtle`,children:`Type`}),(0,$.jsx)(`span`,{children:v.profile.organization.organization_type})]}),v.profile.organization?.rate_limit_tier&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`text-text-subtle`,children:`Tier`}),(0,$.jsx)(`span`,{children:v.profile.organization.rate_limit_tier})]}),v.profile.organization?.subscription_status&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`text-text-subtle`,children:`Status`}),(0,$.jsx)(`span`,{children:v.profile.organization.subscription_status})]})]}),(0,$.jsx)(kr,{accountId:v.accountId})]}),(0,$.jsxs)(`div`,{className:`border-t border-border pt-2 flex gap-1.5 shrink-0`,children:[(0,$.jsxs)(`button`,{onClick:()=>x(!0),className:`flex-1 flex items-center justify-center gap-1 rounded-md border border-border px-2 py-1 text-[11px] text-text-secondary hover:bg-surface-hover transition-colors cursor-pointer`,children:[(0,$.jsx)(V,{className:`size-3`}),` Add`]}),(0,$.jsxs)(`button`,{onClick:ae,className:`flex-1 flex items-center justify-center gap-1 rounded-md border border-border px-2 py-1 text-[11px] text-text-secondary hover:bg-surface-hover transition-colors cursor-pointer`,children:[(0,$.jsx)(z,{className:`size-3`}),` Export`]}),(0,$.jsxs)(`button`,{onClick:()=>T(!0),className:`flex-1 flex items-center justify-center gap-1 rounded-md border border-border px-2 py-1 text-[11px] text-text-secondary hover:bg-surface-hover transition-colors cursor-pointer`,children:[(0,$.jsx)(Ce,{className:`size-3`}),` Import`]})]}),O&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center bg-background/80 backdrop-blur-sm rounded-md`,children:(0,$.jsxs)(`div`,{className:`bg-surface border border-border rounded-lg shadow-lg p-4 mx-4 max-w-[280px] w-full space-y-3`,children:[(0,$.jsxs)(`p`,{className:`text-xs text-text-primary text-center`,children:[`Remove `,(0,$.jsx)(`strong`,{className:`text-foreground`,children:O.display}),`?`]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(`button`,{onClick:()=>k(null),className:`flex-1 px-3 py-1.5 rounded-md text-xs border border-border text-text-secondary hover:bg-surface-hover cursor-pointer transition-colors`,children:`Cancel`}),(0,$.jsx)(`button`,{onClick:q,className:`flex-1 px-3 py-1.5 rounded-md text-xs bg-red-500 text-white hover:bg-red-600 cursor-pointer transition-colors`,children:`Remove`})]})]})}),(0,$.jsx)(pr,{open:b,onOpenChange:x,onSuccess:R}),(0,$.jsx)(mr,{open:S,onOpenChange:e=>{C(e),e||j(null)},accounts:c,preselectId:A,onMessage:ee}),(0,$.jsx)(hr,{open:w,onOpenChange:T,onSuccess:R}),(0,$.jsx)(xr,{open:E,onOpenChange:D})]})}var zr={active:`bg-green-500`,idle:`bg-yellow-500`,shutdown:`bg-zinc-400`},Br={task_assignment:{label:`task`,className:`bg-blue-500/20 text-blue-400`},idle_notification:{label:`idle`,className:`bg-yellow-500/20 text-yellow-400`},completion:{label:`done`,className:`bg-green-500/20 text-green-400`},shutdown_request:{label:`shutdown`,className:`bg-red-500/20 text-red-400`},shutdown_approved:{label:`shutdown ✓`,className:`bg-zinc-500/20 text-zinc-400`}};function Vr({teamNames:e,messages:t}){let[n,r]=(0,Q.useState)(e[0]??``),[i,a]=(0,Q.useState)([]),[o,s]=(0,Q.useState)(!1),c=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{e.length>0&&!e.includes(n)&&r(e[0])},[e,n]);let l=(0,Q.useCallback)(async e=>{s(!0);try{a((await G.get(`/api/teams/${encodeURIComponent(e)}`))?.members??[])}catch{a([])}s(!1)},[]);(0,Q.useEffect)(()=>{n&&l(n)},[n,l]),(0,Q.useEffect)(()=>{c.current?.scrollIntoView({behavior:`smooth`})},[t.length]);let u=t.slice(-200);return(0,$.jsxs)(`div`,{className:`space-y-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 mb-2`,children:[(0,$.jsx)(`div`,{className:`flex items-center gap-1 overflow-x-auto min-w-0 flex-1`,children:e.map(e=>(0,$.jsx)(`button`,{onClick:()=>r(e),className:q(`px-2 py-0.5 text-[11px] rounded-md whitespace-nowrap transition-colors`,n===e?`bg-primary/10 text-primary font-medium`:`text-text-subtle hover:text-text-primary`),children:e},e))}),(0,$.jsx)(`button`,{onClick:()=>n&&l(n),className:`text-text-subtle hover:text-foreground p-1 shrink-0`,"aria-label":`Refresh`,children:(0,$.jsx)(U,{className:q(`size-3`,o&&`animate-spin`)})})]}),i.length>0&&(0,$.jsxs)(`div`,{className:`pb-2 mb-2 border-b border-border/30`,children:[(0,$.jsx)(`div`,{className:`text-[10px] text-text-subtle uppercase tracking-wider mb-1`,children:`Members`}),(0,$.jsx)(`div`,{className:`space-y-1`,children:i.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,$.jsx)(`span`,{className:q(`size-1.5 rounded-full shrink-0`,zr[e.status]??`bg-zinc-400`)}),(0,$.jsx)(`span`,{className:`font-medium truncate`,children:e.name}),e.model&&e.model!==`unknown`&&(0,$.jsxs)(`span`,{className:`text-text-subtle text-[10px]`,children:[`(`,e.model,`)`]}),(0,$.jsx)(`span`,{className:`ml-auto text-text-subtle text-[10px]`,children:e.status})]},e.name))})]}),(0,$.jsx)(`div`,{className:`max-h-40 overflow-y-auto`,children:u.length===0?(0,$.jsx)(`p`,{className:`text-xs text-text-subtle text-center py-2`,children:`No messages yet`}):(0,$.jsxs)(`div`,{className:`space-y-2`,children:[u.map((e,t)=>{let n=e.parsedType?Br[e.parsedType]:null,r=Hr(e.timestamp);return(0,$.jsxs)(`div`,{className:`text-xs`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 text-text-subtle`,children:[(0,$.jsx)(`span`,{className:`font-medium`,style:Ur(e.color),children:e.from}),(0,$.jsx)(`span`,{children:`→`}),(0,$.jsx)(`span`,{children:e.to}),(0,$.jsx)(`span`,{className:`ml-auto text-[10px]`,children:r})]}),(0,$.jsxs)(`div`,{className:`mt-0.5 text-foreground/90 break-words`,children:[n&&(0,$.jsx)(`span`,{className:q(`inline-block px-1 py-0 rounded text-[9px] mr-1`,n.className),children:n.label}),e.summary??Wr(e.text)]})]},`${e.timestamp}-${t}`)}),(0,$.jsx)(`div`,{ref:c})]})})]})}function Hr(e){try{return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}catch{return``}}function Ur(e){if(e&&(/^#[0-9a-fA-F]{3,8}$/.test(e)||/^[a-zA-Z]{3,20}$/.test(e)))return{color:e}}function Wr(e,t=120){if(!e)return``;try{let n=JSON.parse(e);return n.summary??n.text??e.slice(0,t)}catch{}return e.length>t?e.slice(0,t)+`...`:e}function Gr(e){return e>=90?`text-red-500`:e>=70?`text-amber-500`:`text-green-500`}function Kr({sessionId:e,projectName:t}){let[n,r]=(0,Q.useState)(!1);return(0,$.jsx)(`button`,{onClick:()=>{try{let n=G.get(`${W(t)}/chat/sessions/${e}/debug?project=${encodeURIComponent(t)}`).then(e=>{let t=[`PPM Session: ${e.ppmSessionId}`,`SDK Session: ${e.sdkSessionId}`,e.jsonlPath?`JSONL: ${e.jsonlPath}`:`JSONL: not found`,e.projectPath?`Project: ${e.projectPath}`:null].filter(Boolean).join(`
|
|
11
11
|
`);return new Blob([t],{type:`text/plain`})});navigator.clipboard.write([new ClipboardItem({"text/plain":n})]).then(()=>{r(!0),setTimeout(()=>r(!1),1500)})}catch{}},className:`p-1 rounded transition-colors ${n?`text-green-500 bg-green-500/10`:`text-text-subtle hover:text-text-secondary hover:bg-surface-elevated`}`,title:n?`Copied!`:`Copy session debug info`,children:n?(0,$.jsx)(Xe,{className:`size-3`}):(0,$.jsx)(d,{className:`size-3`})})}function qr({projectName:e,usageInfo:t,usageLoading:n,refreshUsage:r,lastFetchedAt:i,sessionId:o,providerId:s,onSelectSession:l,onBugReport:d,isConnected:f,onReload:p,teamActivity:m,teamMessages:g,onTeamOpen:_}){let[v,y]=(0,Q.useState)(null),[x,C]=(0,Q.useState)([]),[w,T]=(0,Q.useState)(!1),E=je(e=>e.notifications),D=je(e=>o?e.notifications.has(o):!1),O=je(e=>e.clearForSession),[k,A]=(0,Q.useState)(``),j=Oe(k,300),[M,N]=(0,Q.useState)(null),[P,F]=(0,Q.useState)(``),[I,z]=(0,Q.useState)(!1),[B,V]=(0,Q.useState)(!1),[ne,re]=(0,Q.useState)([]),[K,ie]=(0,Q.useState)(null),[ae,J]=(0,Q.useState)({}),[Y,oe]=(0,Q.useState)(!1),se=(0,Q.useRef)(null),ce=X(e=>e.openTab),le=e=>{y(t=>t===e?null:e)},ue=(0,Q.useCallback)(async t=>{if(e){T(!0);try{let n=new URLSearchParams({limit:`50`,offset:`0`});t&&n.set(`q`,t);let r=await G.get(`${W(e)}/chat/sessions?${n}`);C(r.sessions),z(r.hasMore)}catch{}finally{T(!1)}}},[e]),de=(0,Q.useCallback)(async()=>{if(!(!e||B||!I)){V(!0);try{let t=x.filter(e=>!e.pinned).length,n=new URLSearchParams({limit:`50`,offset:String(t)});j&&n.set(`q`,j);let r=await G.get(`${W(e)}/chat/sessions?${n}`);C(e=>{let t=new Set(e.map(e=>e.id)),n=r.sessions.filter(e=>!t.has(e.id));return[...e,...n]}),z(r.hasMore)}catch{}finally{V(!1)}}},[e,B,I,x,j]);(0,Q.useEffect)(()=>{v===`history`&&x.length===0&&ue()},[v]),(0,Q.useEffect)(()=>{v===`history`&&ue(j||void 0)},[j]);let fe=(0,Q.useCallback)(async()=>{if(e)try{let t=await G.get(`${W(e)}/tags`);re(t.tags),J(t.counts)}catch{}},[e]);(0,Q.useEffect)(()=>{v===`history`&&e&&fe()},[v,e,fe]);function pe(t){l?(l(t),y(null)):ce({type:`chat`,title:t.title||`Chat`,projectId:e??null,metadata:{projectName:e,sessionId:t.id,providerId:t.providerId},closable:!0})}let me=(0,Q.useCallback)((e,t)=>{t.stopPropagation(),N(e.id),F(e.title||``),setTimeout(()=>se.current?.select(),0)},[]),he=(0,Q.useCallback)(async()=>{if(!M||!P.trim()||!e){N(null);return}try{await G.patch(`${W(e)}/chat/sessions/${M}`,{title:P.trim()}),C(e=>e.map(e=>e.id===M?{...e,title:P.trim()}:e))}catch{}N(null)},[M,P,e]),ge=(0,Q.useCallback)(()=>N(null),[]),_e=(0,Q.useCallback)(async(t,n)=>{if(t.stopPropagation(),!e)return;let r=`${W(e)}/chat/sessions/${n.id}/pin`;try{n.pinned?await G.del(r):await G.put(r),C(e=>e.map(e=>e.id===n.id?{...e,pinned:!e.pinned}:e).sort((e,t)=>e.pinned&&!t.pinned?-1:!e.pinned&&t.pinned?1:new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime()))}catch{}},[e]),ve=(0,Q.useCallback)(async(t,n)=>{if(t.stopPropagation(),e&&window.confirm(`Delete this session? This cannot be undone.`))try{await G.del(`${W(e)}/chat/sessions/${n.id}?providerId=${n.providerId}`),C(e=>e.filter(e=>e.id!==n.id))}catch{}},[e]),ye=(0,Q.useCallback)((e,t)=>{C(n=>n.map(n=>n.id===e?{...n,tag:t}:n)),fe()},[fe]),be=(0,Q.useCallback)(async()=>{if(!e)return;let t=window.prompt(`Delete sessions older than how many days? (pinned sessions are kept)`,`30`);if(!t)return;let n=parseInt(t,10);if(!(!n||n<1)&&window.confirm(`Delete all unpinned sessions older than ${n} days? This cannot be undone.`)){T(!0);try{await G.del(`${W(e)}/chat/sessions?olderThanDays=${n}`),ue(j||void 0)}catch{}}},[e,ue,j]);(0,Q.useEffect)(()=>{if(v!==`history`)return;let t=t=>{if(t.target instanceof HTMLInputElement||t.target instanceof HTMLTextAreaElement)return;let n=parseInt(t.key);if(n>=1&&n<=ne.length&&o){let t=ne[n-1];t&&(G.patch(`${W(e)}/chat/sessions/${o}/tag`,{tagId:t.id}).catch(()=>{}),ye(o,{id:t.id,name:t.name,color:t.color}))}};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[v,ne,o,e,ye]);let xe=K===null?x:x.filter(e=>e.tag?.id===K),Se=!s||s===`claude`,Ce=t.fiveHour==null?null:Math.round(t.fiveHour*100),we=t.sevenDay==null?null:Math.round(t.sevenDay*100),Te=Ce!=null||we!=null?Gr(Math.max(Ce??0,we??0)):`text-text-subtle`;return(0,$.jsxs)(`div`,{className:`border-b border-border/50`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1`,children:[(0,$.jsxs)(`button`,{onClick:()=>le(`history`),className:`flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] transition-colors ${v===`history`?`text-primary bg-primary/10`:`text-text-secondary hover:text-foreground hover:bg-surface-elevated`}`,children:[(0,$.jsx)($e,{className:`size-3`}),(0,$.jsx)(`span`,{children:`History`})]}),o&&s&&s!==`mock`?(0,$.jsxs)(`button`,{onClick:()=>le(`config`),className:`flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] transition-colors ${v===`config`?`text-primary bg-primary/10`:`text-text-secondary hover:text-foreground hover:bg-surface-elevated`}`,title:`AI Settings`,children:[(0,$.jsx)(h,{providerId:s}),(0,$.jsx)(`span`,{className:`capitalize`,children:s})]}):(0,$.jsx)(`button`,{onClick:()=>le(`config`),className:`p-1 rounded transition-colors ${v===`config`?`text-primary bg-primary/10`:`text-text-subtle hover:text-text-secondary hover:bg-surface-elevated`}`,title:`AI Settings`,children:(0,$.jsx)(Me,{className:`size-3`})}),Se?(0,$.jsxs)(`button`,{onClick:()=>le(`usage`),className:`flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] font-medium tabular-nums transition-colors hover:bg-surface-elevated ${v===`usage`?`bg-primary/10`:``} ${Te}`,title:`Usage limits`,children:[(0,$.jsx)(qe,{className:`size-3`}),t.activeAccountLabel&&(0,$.jsxs)(`span`,{className:`text-text-secondary font-normal truncate max-w-[60px]`,children:[`[`,t.activeAccountLabel,`]`]}),(0,$.jsxs)(`span`,{children:[`5h:`,Ce==null?`--%`:`${Ce}%`]}),(0,$.jsx)(`span`,{className:`text-text-subtle`,children:`·`}),(0,$.jsxs)(`span`,{children:[`Wk:`,we==null?`--%`:`${we}%`]})]}):null,m?.hasTeams&&(0,$.jsxs)(`button`,{onClick:()=>{le(`team`),_?.()},className:`relative flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] transition-colors ${v===`team`?`text-primary bg-primary/10`:`text-text-secondary hover:text-foreground hover:bg-surface-elevated`}`,title:`Team activity`,children:[(0,$.jsx)(dt,{className:`size-3`}),(0,$.jsx)(`span`,{children:`Team`}),(m.unreadCount??0)>0&&(0,$.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 size-2 bg-primary rounded-full animate-pulse`})]}),(0,$.jsx)(`div`,{className:`flex-1`}),D&&o&&(0,$.jsx)(`button`,{onClick:()=>O(o),className:`p-1 rounded text-amber-500 hover:text-amber-400 hover:bg-surface-elevated transition-colors`,title:`Mark as read`,children:(0,$.jsx)(a,{className:`size-3`})}),o&&(0,$.jsx)(Kr,{sessionId:o,projectName:e}),p&&(0,$.jsxs)(`button`,{onClick:e=>{let t=e.currentTarget.querySelector(`svg`);t&&(t.classList.add(`animate-spin`),setTimeout(()=>t.classList.remove(`animate-spin`),600)),p()},className:`relative size-4 flex items-center justify-center`,title:f?`Reload messages`:`Disconnected — click to reload`,children:[(0,$.jsx)(U,{className:`size-3 ${f?`text-muted-foreground/60`:`text-red-400`}`,strokeWidth:2.5}),(0,$.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 size-1.5 rounded-full ${f?`bg-green-500`:`bg-red-500 animate-pulse`}`})]})]}),v===`history`&&(0,$.jsxs)(`div`,{className:`border-t border-border/30 bg-surface`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-1 border-b border-border/30`,children:[(0,$.jsx)(R,{className:`size-3 text-text-subtle shrink-0`}),(0,$.jsx)(`input`,{type:`text`,value:k,onChange:e=>A(e.target.value),placeholder:`Search sessions...`,className:`flex-1 bg-transparent text-[11px] text-text-primary outline-none placeholder:text-text-subtle`}),(0,$.jsx)(`button`,{onClick:be,className:`p-0.5 rounded text-text-subtle hover:text-red-400 transition-colors`,title:`Delete old sessions...`,children:(0,$.jsx)(Je,{className:`size-3`})}),(0,$.jsx)(`button`,{onClick:()=>ue(j||void 0),disabled:w,className:`p-0.5 rounded text-text-subtle hover:text-text-secondary transition-colors disabled:opacity-50`,title:`Refresh`,children:(0,$.jsx)(U,{className:`size-3 ${w?`animate-spin`:``}`})})]}),ne.length>0&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1 overflow-x-auto border-b border-border/30 scrollbar-none`,children:[(0,$.jsxs)(`button`,{onClick:()=>ie(null),className:`shrink-0 rounded-md border px-2 py-1 text-[10px] transition-colors ${K===null?`bg-primary/20 border-primary text-primary`:`border-border bg-surface text-text-secondary`}`,children:[`All (`,x.length,`)`]}),ne.map(e=>(0,$.jsxs)(`button`,{onClick:()=>ie(K===e.id?null:e.id),className:`shrink-0 flex items-center gap-1 rounded-md border px-2 py-1 text-[10px] transition-colors ${K===e.id?`border-current`:`border-border bg-surface`}`,style:K===e.id?{backgroundColor:e.color+`20`,color:e.color,borderColor:e.color}:void 0,children:[(0,$.jsx)(`span`,{className:`size-2 rounded-full shrink-0`,style:{backgroundColor:e.color}}),e.name,` (`,ae[e.id]??0,`)`]},e.id)),(0,$.jsx)(`button`,{onClick:()=>oe(!Y),className:`shrink-0 p-1 rounded transition-colors ${Y?`text-primary bg-primary/10`:`text-text-subtle hover:text-text-secondary`}`,title:`Manage tags`,children:(0,$.jsx)(ut,{className:`size-3`})})]}),Y&&(0,$.jsx)(`div`,{className:`border-b border-border/30 px-2 py-2 max-h-[180px] overflow-y-auto bg-surface-elevated/50`,children:(0,$.jsx)(dr,{projectName:e,onTagsChanged:fe})}),(0,$.jsx)(`div`,{className:`max-h-[200px] overflow-y-auto`,children:w&&x.length===0?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,$.jsx)(Z,{className:`size-3.5 animate-spin text-text-subtle`})}):xe.length===0?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-3 text-[11px] text-text-subtle`,children:k?`No matching sessions`:`No sessions yet`}):(0,$.jsxs)($.Fragment,{children:[xe.map(t=>{let n=E.get(t.id),r=!!n;return(0,$.jsx)(De,{session:t,projectName:e,projectTags:ne,onTogglePin:_e,onStartEditing:me,onDeleteSession:ve,onTagChanged:ye,children:(0,$.jsxs)(`div`,{className:q(`flex items-center gap-2 w-full px-3 py-1.5 text-left hover:bg-surface-elevated transition-colors group`,r&&`font-medium text-foreground`,r&&Ge(n.type),!r&&`text-text-secondary`),children:[(0,$.jsx)(h,{providerId:t.providerId}),t.tag&&(0,$.jsx)(`span`,{className:`size-2 rounded-full shrink-0`,style:{backgroundColor:t.tag.color},title:t.tag.name}),M===t.id?(0,$.jsxs)(`form`,{className:`flex items-center gap-1 flex-1 min-w-0`,onSubmit:e=>{e.preventDefault(),he()},children:[(0,$.jsx)(`input`,{ref:se,value:P,onChange:e=>F(e.target.value),onBlur:he,onKeyDown:e=>{e.key===`Escape`&&ge()},className:`flex-1 min-w-0 bg-surface-elevated text-[11px] text-text-primary px-1 py-0.5 rounded border border-border outline-none focus:border-primary`,autoFocus:!0}),(0,$.jsx)(`button`,{type:`submit`,className:`p-0.5 text-green-500 hover:text-green-400`,onClick:e=>e.stopPropagation(),children:(0,$.jsx)(S,{className:`size-3`})}),(0,$.jsx)(`button`,{type:`button`,className:`p-0.5 text-text-subtle hover:text-text-secondary`,onClick:e=>{e.stopPropagation(),ge()},children:(0,$.jsx)(H,{className:`size-3`})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`button`,{onClick:()=>pe(t),className:`text-[11px] truncate flex-1 text-left flex items-center gap-1`,children:[t.title?.startsWith(`[PPM]`)&&(0,$.jsx)(u,{className:`size-3 text-muted-foreground shrink-0`}),t.title?.startsWith(`[PPM]`)?t.title.slice(7):t.title||`Untitled`]}),(0,$.jsx)(`button`,{onClick:e=>_e(e,t),className:`p-0.5 rounded transition-all ${t.pinned?`text-primary hover:text-primary/70`:`text-text-subtle hover:text-text-secondary can-hover:opacity-0 can-hover:group-hover:opacity-100`}`,title:t.pinned?`Unpin session`:`Pin session`,children:t.pinned?(0,$.jsx)(ee,{className:`size-3`}):(0,$.jsx)(L,{className:`size-3`})}),(0,$.jsx)(`button`,{onClick:e=>me(t,e),className:`p-0.5 rounded text-text-subtle hover:text-text-secondary can-hover:opacity-0 can-hover:group-hover:opacity-100 transition-opacity`,title:`Rename session`,children:(0,$.jsx)(c,{className:`size-3`})}),(0,$.jsx)(`button`,{onClick:e=>ve(e,t),className:`p-0.5 rounded text-text-subtle hover:text-red-400 hover:bg-red-500/20 can-hover:opacity-0 can-hover:group-hover:opacity-100 transition-opacity`,title:`Delete session`,children:(0,$.jsx)(te,{className:`size-3`})})]}),M!==t.id&&t.updatedAt&&(0,$.jsx)(`span`,{className:`text-[10px] text-text-subtle shrink-0 w-16 text-right`,children:ke(t.updatedAt)})]})},t.id)}),I&&(0,$.jsxs)(`button`,{onClick:de,disabled:B,className:`flex items-center justify-center gap-1 w-full py-1.5 text-[11px] text-text-subtle hover:text-text-secondary hover:bg-surface-elevated transition-colors`,children:[B?(0,$.jsx)(Z,{className:`size-3 animate-spin`}):null,B?`Loading...`:`Load more`]})]})})]}),v===`config`&&(0,$.jsx)(`div`,{className:`border-t border-border/30 bg-surface px-3 py-2 max-h-[280px] overflow-y-auto`,children:(0,$.jsx)(b,{compact:!0})}),v===`team`&&m?.hasTeams&&(0,$.jsx)(`div`,{className:`border-t border-border/30 bg-surface px-3 py-2 max-h-[280px] overflow-y-auto`,children:(0,$.jsx)(Vr,{teamNames:m.teamNames,messages:g??[]})}),v===`usage`&&Se&&(0,$.jsx)(Rr,{usage:t,visible:!0,onClose:()=>y(null),onReload:r,loading:n,lastFetchedAt:i})]})}function Jr({metadata:e,tabId:t}){let[n,r]=(0,Q.useState)(e?.sessionId??null),[i,a]=(0,Q.useState)(e?.providerId??`claude`),[o,s]=(0,Q.useState)([]),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)([]),[g,_]=(0,Q.useState)([]),[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(``),[S,C]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(e?.permissionMode??void 0),E=(0,Q.useRef)(null),[D,O]=(0,Q.useState)(!1),[k,A]=(0,Q.useState)(null),[j,M]=(0,Q.useState)(null),[N,P]=(0,Q.useState)(null),F=(0,Q.useRef)(0),I=e?.projectName??``,L=X(e=>e.updateTab),ee=K(e=>e.version),{usageInfo:R,usageLoading:z,lastFetchedAt:B,refreshUsage:te}=kt(I,i);(0,Q.useEffect)(()=>{w||ce().then(e=>{let t=e.providers[e.default_provider??`claude`];T(t?.permission_mode??`bypassPermissions`)}).catch(()=>{})},[]),(0,Q.useEffect)(()=>{!t||!n||L(t,{metadata:{...e,sessionId:n,providerId:i,permissionMode:w}})},[n,i,w]);let{messages:V,renderedMessages:H,expandCompact:U,isCompactExpanded:ne,messagesLoading:re,isStreaming:q,phase:ae,isReconnecting:J,connectingElapsed:oe,pendingApproval:se,contextWindowPct:le,compactStatus:ue,statusMessage:de,sessionTitle:fe,sendMessage:pe,respondToApproval:me,cancelStreaming:he,reconnect:ge,refetchMessages:_e,isConnected:ve,teamActivity:ye,teamMessages:be,markTeamRead:xe,bashPartialOutput:Se}=Dt(n,i,I);(0,Q.useEffect)(()=>{if(ve&&E.current){let{content:e,permissionMode:t}=E.current;E.current=null,pe(e,{permissionMode:t})}},[ve,pe]),(0,Q.useEffect)(()=>{if(!n||!t)return;let e=()=>{if(document.hidden)return;let{panels:e,focusedPanelId:r}=Y.getState();e[r]?.activeTabId===t&&je.getState().clearForSession(n)};e(),document.addEventListener(`visibilitychange`,e);let r=Y.subscribe(e),i=je.subscribe(e);return()=>{document.removeEventListener(`visibilitychange`,e),r(),i()}},[n,t]),(0,Q.useEffect)(()=>{t&&fe&&L(t,{title:fe})},[fe]);let[we,Te]=(0,Q.useState)(e?.pendingMessage);(0,Q.useEffect)(()=>{we&&ve&&n&&t&&L(t,{metadata:{...e,pendingMessage:void 0}})},[ve,n]),(0,Q.useCallback)(()=>{X.getState().openTab({type:`chat`,title:`AI Chat`,metadata:{projectName:I,providerId:i},projectId:I||null,closable:!0})},[I,i]);let Ee=(0,Q.useCallback)(e=>{r(e.id),a(e.providerId),t&&L(t,{title:e.title||`Chat`})},[t,L]),De=(0,Q.useCallback)(async(e,t)=>{if(!(!n||!I))try{let{api:r,projectUrl:a}=await ie(async()=>{let{api:e,projectUrl:t}=await import(`./api-client-DIhJ5qVW.js`).then(e=>e.n);return{api:e,projectUrl:t}},__vite__mapDeps([12,1])),o=await r.post(`${a(I)}/chat/sessions/${n}/fork?providerId=${i}`,{messageId:t});X.getState().openTab({type:`chat`,title:`Fork: ${e.slice(0,30)}`,metadata:{projectName:I,sessionId:o.id,providerId:i,pendingMessage:e},projectId:I||null,closable:!0})}catch(e){console.error(`Fork failed:`,e)}},[n,I,i]),Oe=(0,Q.useCallback)((e,t)=>{if(t.length===0)return e;let n=t.filter(e=>e.serverPath).map(e=>e.serverPath).join(`
|
|
12
|
-
`);return n?(t.length===1?`[Attached file: ${n}]\n\n`:`[Attached files:\n${n}\n]\n\n`)+e:e},[]),ke=(0,Q.useCallback)(async(e,t=[],o)=>{let s=Oe(e,t);if(s.trim()){if(!n)try{let t=I,n=await G.post(`${W(t)}/chat/sessions`,{providerId:i,title:e.slice(0,50)});r(n.id),a(n.providerId),E.current={content:s,permissionMode:w};return}catch(e){console.error(`Failed to create session:`,e);return}pe(s,{permissionMode:w,priority:o})}},[n,i,I,pe,Oe,w]),Ae=(0,Q.useCallback)((e,t,n)=>{Te(void 0),ke(e,t,n)},[ke]),Me=(0,Q.useCallback)((e,t)=>{s(e),t&&h(t)},[]),Ne=(0,Q.useCallback)((e,t)=>{l(e),d(t)},[]),Pe=(0,Q.useCallback)(e=>{p(e),l(!1),d(``),setTimeout(()=>p(null),50),I&&(G.post(`${W(I)}/chat/slash-recents`,{name:e.name,type:e.type}).catch(()=>{}),h(t=>[e.name,...t.filter(t=>t!==e.name)].slice(0,5)))},[I]),Fe=(0,Q.useCallback)(()=>{l(!1),d(``)},[]),Ie=(0,Q.useCallback)(()=>M(null),[]),Le=(0,Q.useCallback)(e=>{P(e)},[]),ze=(0,Q.useCallback)(e=>{M([e.path]),P(null)},[]),Be=(0,Q.useCallback)((e,t)=>{y(e),x(t)},[]),Ve=(0,Q.useCallback)(e=>{C(e),y(!1),x(``),setTimeout(()=>C(null),50)},[]),He=(0,Q.useCallback)(()=>{y(!1),x(``)},[]);return(0,$.jsxs)(`div`,{className:`flex flex-col h-full relative`,onDragEnter:(0,Q.useCallback)(e=>{e.preventDefault(),F.current++,(e.dataTransfer.types.includes(`application/x-ppm-path`)||e.dataTransfer.types.includes(`Files`))&&O(!0)},[]),onDragLeave:(0,Q.useCallback)(e=>{e.preventDefault(),F.current--,F.current===0&&O(!1)},[]),onDragOver:(0,Q.useCallback)(e=>{e.preventDefault()},[]),onDrop:(0,Q.useCallback)(e=>{e.preventDefault(),F.current=0,O(!1);let t=e.dataTransfer.getData(`application/x-ppm-path`);if(t){M([t]);return}let n=Array.from(e.dataTransfer.files);n.length>0&&(A(n),setTimeout(()=>A(null),100))},[]),children:[D&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm border-2 border-dashed border-primary rounded-lg pointer-events-none`,children:(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-2 text-primary`,children:[(0,$.jsx)(Ce,{className:`size-8`}),(0,$.jsx)(`span`,{className:`text-sm font-medium`,children:`Drop files to attach`})]})}),J&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-50 flex items-center justify-center bg-background/60 backdrop-blur-sm`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(Z,{className:`size-4 animate-spin`}),(0,$.jsx)(`span`,{children:`Reconnecting...`})]})}),(0,$.jsx)(un,{messages:H,onExpandCompact:U,isCompactExpanded:ne,messagesLoading:re,pendingApproval:se,onApprovalResponse:me,isStreaming:q,phase:ae,connectingElapsed:oe,statusMessage:de,compactStatus:ue,projectName:I,onFork:q?void 0:De,onSelectSession:Ee,bashPartialOutput:Se}),(0,$.jsxs)(`div`,{className:`border-t border-border bg-background shrink-0`,children:[(0,$.jsx)(qr,{projectName:I,usageInfo:R,usageLoading:z,refreshUsage:te,lastFetchedAt:B,sessionId:n,providerId:i,onSelectSession:Ee,onBugReport:n?()=>Re(ee,{sessionId:n,projectName:I}):void 0,isConnected:ve,onReload:()=>{ve||ge(),_e()},teamActivity:ye,teamMessages:be,onTeamOpen:xe}),(0,$.jsx)(lr,{items:o,filter:u,onSelect:Pe,onClose:Fe,visible:c,recentNames:m,projectName:I}),(0,$.jsx)(ur,{items:g,filter:b,onSelect:Ve,onClose:He,visible:v}),N&&(0,$.jsx)(ur,{items:N,filter:``,onSelect:ze,onClose:()=>P(null),visible:!0}),(0,$.jsx)(nr,{onSend:Ae,isStreaming:q,onCancel:he,autoFocus:!e?.sessionId||!!we,initialValue:we,projectName:I,onSlashStateChange:Ne,onSlashItemsLoaded:Me,slashSelected:f,onFileStateChange:Be,onFileItemsLoaded:_,fileSelected:S,externalFiles:k,externalPaths:j,onExternalPathsConsumed:Ie,onDisambiguate:Le,permissionMode:w,onModeChange:T,providerId:i,onProviderChange:n?void 0:a})]})]})}export{Jr as ChatTab};
|
|
12
|
+
`);return n?(t.length===1?`[Attached file: ${n}]\n\n`:`[Attached files:\n${n}\n]\n\n`)+e:e},[]),ke=(0,Q.useCallback)(async(e,t=[],o)=>{let s=Oe(e,t);if(s.trim()){if(!n)try{let t=I,n=await G.post(`${W(t)}/chat/sessions`,{providerId:i,title:e.slice(0,50)});r(n.id),a(n.providerId),E.current={content:s,permissionMode:w};return}catch(e){console.error(`Failed to create session:`,e);return}pe(s,{permissionMode:w,priority:o})}},[n,i,I,pe,Oe,w]),Ae=(0,Q.useCallback)((e,t,n)=>{Te(void 0),ke(e,t,n)},[ke]),Me=(0,Q.useCallback)((e,t)=>{s(e),t&&h(t)},[]),Ne=(0,Q.useCallback)((e,t)=>{l(e),d(t)},[]),Pe=(0,Q.useCallback)(e=>{p(e),l(!1),d(``),setTimeout(()=>p(null),50),I&&(G.post(`${W(I)}/chat/slash-recents`,{name:e.name,type:e.type}).catch(()=>{}),h(t=>[e.name,...t.filter(t=>t!==e.name)].slice(0,5)))},[I]),Fe=(0,Q.useCallback)(()=>{l(!1),d(``)},[]),Ie=(0,Q.useCallback)(()=>M(null),[]),Le=(0,Q.useCallback)(e=>{P(e)},[]),ze=(0,Q.useCallback)(e=>{M([e.path]),P(null)},[]),Be=(0,Q.useCallback)((e,t)=>{y(e),x(t)},[]),Ve=(0,Q.useCallback)(e=>{C(e),y(!1),x(``),setTimeout(()=>C(null),50)},[]),He=(0,Q.useCallback)(()=>{y(!1),x(``)},[]);return(0,$.jsxs)(`div`,{className:`flex flex-col h-full relative`,onDragEnter:(0,Q.useCallback)(e=>{e.preventDefault(),F.current++,(e.dataTransfer.types.includes(`application/x-ppm-path`)||e.dataTransfer.types.includes(`Files`))&&O(!0)},[]),onDragLeave:(0,Q.useCallback)(e=>{e.preventDefault(),F.current--,F.current===0&&O(!1)},[]),onDragOver:(0,Q.useCallback)(e=>{e.preventDefault()},[]),onDrop:(0,Q.useCallback)(e=>{e.preventDefault(),F.current=0,O(!1);let t=e.dataTransfer.getData(`application/x-ppm-path`);if(t){M([t]);return}let n=Array.from(e.dataTransfer.files);n.length>0&&(A(n),setTimeout(()=>A(null),100))},[]),children:[D&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm border-2 border-dashed border-primary rounded-lg pointer-events-none`,children:(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-2 text-primary`,children:[(0,$.jsx)(Ce,{className:`size-8`}),(0,$.jsx)(`span`,{className:`text-sm font-medium`,children:`Drop files to attach`})]})}),J&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-50 flex items-center justify-center bg-background/60 backdrop-blur-sm`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(Z,{className:`size-4 animate-spin`}),(0,$.jsx)(`span`,{children:`Reconnecting...`})]})}),(0,$.jsx)(un,{messages:H,onExpandCompact:U,isCompactExpanded:ne,messagesLoading:re,pendingApproval:se,onApprovalResponse:me,isStreaming:q,phase:ae,connectingElapsed:oe,statusMessage:de,compactStatus:ue,projectName:I,onFork:q?void 0:De,onSelectSession:Ee,bashPartialOutput:Se}),(0,$.jsxs)(`div`,{className:`border-t border-border bg-background shrink-0`,children:[(0,$.jsx)(qr,{projectName:I,usageInfo:R,usageLoading:z,refreshUsage:te,lastFetchedAt:B,sessionId:n,providerId:i,onSelectSession:Ee,onBugReport:n?()=>Re(ee,{sessionId:n,projectName:I}):void 0,isConnected:ve,onReload:()=>{ve||ge(),_e()},teamActivity:ye,teamMessages:be,onTeamOpen:xe}),(0,$.jsx)(lr,{items:o,filter:u,onSelect:Pe,onClose:Fe,visible:c,recentNames:m,projectName:I}),(0,$.jsx)(ur,{items:g,filter:b,onSelect:Ve,onClose:He,visible:v}),N&&(0,$.jsx)(ur,{items:N,filter:``,onSelect:ze,onClose:()=>P(null),visible:!0}),(0,$.jsx)(nr,{onSend:Ae,isStreaming:q,onCancel:he,autoFocus:!e?.sessionId||!!we,initialValue:we,projectName:I,onSlashStateChange:Ne,onSlashItemsLoaded:Me,slashSelected:f,onFileStateChange:Be,onFileItemsLoaded:_,fileSelected:S,externalFiles:k,externalPaths:j,onExternalPathsConsumed:Ie,onDisambiguate:Le,permissionMode:w,onModeChange:T,providerId:i,onProviderChange:n?void 0:a})]})]})}export{Jr as ChatTab};
|
|
13
|
+
//# sourceMappingURL=chat-tab-Z5VNzYCz.js.map
|