@wkoutre/teamwork-os 1.0.3 → 1.0.5
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/README.md +0 -10
- package/cli.js +14 -2
- package/cli.jsc +0 -0
- package/dist/assets/AnalyticsPage-C24BvG1R.js +1 -0
- package/dist/assets/{BriefsPage-BsBjNIJT.js → BriefsPage-DrMSESEG.js} +1 -1
- package/dist/assets/{ChatPanel-BUNJ-rXp.js → ChatPanel-CC0ta99_.js} +1 -1
- package/dist/assets/{ContinuousImprovementPage-F6fizSUr.js → ContinuousImprovementPage-DyTwV7gP.js} +1 -1
- package/dist/assets/{HeartbeatPanel-q7mW5VDk.js → HeartbeatPanel-Dk6plplc.js} +1 -1
- package/dist/assets/IdeasContainer-DeZZF8d9.js +3 -0
- package/dist/assets/{MemoryExplore-wFiVBkXu.js → MemoryExplore-DS4IYHl2.js} +1 -1
- package/dist/assets/{MemoryHygiene-C_lFMujk.js → MemoryHygiene-DxUcjusq.js} +2 -2
- package/dist/assets/{MemoryInjections-F6D1_uAX.js → MemoryInjections-BO_kUrBn.js} +1 -1
- package/dist/assets/{MemoryPage-DS6LWMdS.js → MemoryPage-C2hIk5fW.js} +2 -2
- package/dist/assets/{MemoryWiki-cypT6R3l.js → MemoryWiki-Dh1MtBZV.js} +2 -2
- package/dist/assets/OrgPage-BAbdwx53.js +33 -0
- package/dist/assets/{SessionHistory-DwX-i9Io.js → SessionHistory-DXsOaHFV.js} +1 -1
- package/dist/assets/{SettingsPage-C6Xq22uB.js → SettingsPage-C1QRyGEh.js} +2 -2
- package/dist/assets/SupervisorDashboardPage-5IZyxfvh.css +1 -0
- package/dist/assets/SupervisorDashboardPage-Cnd1zMt9.js +1 -0
- package/dist/assets/{UsagePage-Cm8NsPw7.js → UsagePage-BcK454ym.js} +2 -2
- package/dist/assets/{events-CCBP4a9s.js → events-BK5ucyUu.js} +1 -1
- package/dist/assets/index-CiIY3MTP.css +1 -0
- package/dist/assets/index-DzJsiq8q.js +93 -0
- package/dist/assets/{lib-osArdP58.js → lib-CncUdc6D.js} +4 -4
- package/dist/assets/{types-CNhs8RVF.js → types-BeZJlDCI.js} +1 -1
- package/dist/assets/ui-DvNuX5MF.js +1 -0
- package/dist/index.html +5 -5
- package/gateway.jsc +0 -0
- package/onboarding-plugin/.claude-plugin/plugin.json +5 -0
- package/onboarding-plugin/skills/onboarding/SKILL.md +54 -0
- package/package.json +2 -1
- package/dist/assets/AnalyticsPage-BoafbdRY.js +0 -1
- package/dist/assets/IdeasContainer-DDhsyl1f.js +0 -3
- package/dist/assets/OrgPage-DP2-hcbf.js +0 -33
- package/dist/assets/SupervisorDashboardPage-BEuElLHE.css +0 -1
- package/dist/assets/SupervisorDashboardPage-CrsOGBZ8.js +0 -1
- package/dist/assets/index-C57L9wdB.css +0 -1
- package/dist/assets/index-tOLuwPW6.js +0 -93
- package/dist/assets/ui-Bx41p7g8.js +0 -1
- /package/dist/assets/{Button-xBBZQ0ie.js → Button-DTO6bgnL.js} +0 -0
- /package/dist/assets/{Input-HhV6M0tu.js → Input-iymdcwsf.js} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e,s as t,t as n}from"./jsx-runtime-Bq3x7umQ.js";import{c as r,r as i,s as a}from"./useWebSocket-Hg3RO6sx.js";import{f as o,i as s,n as c,o as l,p as u,s as d}from"./styles-Ds5gMQAQ.js";import{b as f}from"./events-CCBP4a9s.js";import{n as p}from"./types-CNhs8RVF.js";import{t as m}from"./Card-u29day7d.js";import{n as h,r as g}from"./Input-HhV6M0tu.js";import{t as _}from"./Button-xBBZQ0ie.js";import{N as v,Ot as y,P as b,c as x,f as ee,jt as S,kt as C,m as te,n as w,o as ne,p as re,r as ie,t as ae,vt as oe,yt as se}from"./index-tOLuwPW6.js";import{n as ce,t as le}from"./SettingsRow-4w9Ab9mk.js";var T=t(e(),1),E=n(),D={background:`var(--color-bg-raised)`,color:c.text,border:`1px solid ${c.border}`,borderRadius:6,padding:`4px 10px`,fontSize:13,cursor:`pointer`,minWidth:80},O=o,k=u;async function ue(e,t,n){t({status:`loading`});let r=await te(e);n.current=e,t(r.ok?{status:`loaded`,models:r.models}:{status:`error`,message:r.error})}function A(e,t,n){t({engine:{...e?.engine??{default:`claude`,defaultModel:``,maxRetries:2,retryBaseDelayMs:1e3,defaultEffortLevel:``,allowOverage:!0,noProgressTimeoutMs:15e5},...n}})}function de({settings:e,onUpdateSettings:t,runtimeConfig:n}){let r=e?.engine,i=r?.ollama?.host??``,[a,o]=(0,T.useState)(i),[u,f]=(0,T.useState)({status:`idle`}),p=(0,T.useRef)(null);(0,T.useEffect)(()=>{o(e=>e===i?e:i)},[i]),(0,T.useEffect)(()=>{if(!i){p.current=null,f({status:`idle`});return}p.current===i&&u.status!==`idle`||ue(i,f,p)},[i]);function m(n){let a=n.trim();if(a!==i){if(!a){t({engine:{...r??{default:`claude`,defaultModel:``,maxRetries:2,retryBaseDelayMs:1e3,defaultEffortLevel:``,allowOverage:!0,noProgressTimeoutMs:15e5},ollama:null}}),p.current=null,f({status:`idle`});return}A(e,t,{ollama:{host:a,defaultModel:r?.ollama?.defaultModel??``,timeoutMs:r?.ollama?.timeoutMs??3e5,maxToolCalls:r?.ollama?.maxToolCalls??10,maxTurns:r?.ollama?.maxTurns??10}}),ue(a,f,p)}}return(0,E.jsxs)(S,{title:`Engine Configuration`,description:`Configure the Claude CLI engine defaults for all agent sessions.`,children:[(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:10},children:[(0,E.jsx)(`div`,{style:O,children:(0,E.jsxs)(`div`,{style:k,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{style:d,children:`CLI Binary`}),(0,E.jsx)(`div`,{style:s,children:`Set via CLAUDE_COMMAND environment variable`})]}),(0,E.jsx)(y,{children:n?.claudeCommand??`claude`})]})}),(0,E.jsxs)(`div`,{style:O,children:[(0,E.jsxs)(`div`,{style:{marginBottom:8},children:[(0,E.jsx)(`div`,{style:d,children:`Default Model`}),(0,E.jsx)(`div`,{style:s,children:`Override per-employee, or leave empty for CLI default`})]}),(0,E.jsxs)(`select`,{value:r?.defaultModel??``,onChange:n=>A(e,t,{defaultModel:n.target.value}),style:{...l,cursor:`pointer`},children:[(0,E.jsx)(`option`,{value:``,children:`— use CLI default —`}),r?.defaultModel&&!re(r.defaultModel)&&(0,E.jsxs)(`option`,{value:r.defaultModel,children:[r.defaultModel,` (custom)`]}),ee.map(e=>(0,E.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,E.jsxs)(`div`,{style:O,children:[(0,E.jsxs)(`div`,{style:{...k,marginBottom:12},children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{style:d,children:`Max Retries`}),(0,E.jsx)(`div`,{style:s,children:`Retry on transient errors (rate limits, timeouts)`})]}),(0,E.jsx)(`select`,{value:r?.maxRetries??2,onChange:n=>A(e,t,{maxRetries:Number(n.target.value)}),style:D,children:[0,1,2,3,4,5].map(e=>(0,E.jsx)(`option`,{value:e,children:e},e))})]}),(0,E.jsx)(`div`,{style:{borderTop:`1px solid ${c.border}`,paddingTop:12},children:(0,E.jsxs)(`div`,{style:k,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{style:d,children:`Retry Base Delay`}),(0,E.jsx)(`div`,{style:s,children:`Exponential backoff base (doubled each retry)`})]}),(0,E.jsxs)(`select`,{value:r?.retryBaseDelayMs??1e3,onChange:n=>A(e,t,{retryBaseDelayMs:Number(n.target.value)}),style:D,children:[(0,E.jsx)(`option`,{value:500,children:`500ms`}),(0,E.jsx)(`option`,{value:1e3,children:`1s`}),(0,E.jsx)(`option`,{value:2e3,children:`2s`}),(0,E.jsx)(`option`,{value:5e3,children:`5s`}),(0,E.jsx)(`option`,{value:1e4,children:`10s`})]})]})})]}),(0,E.jsx)(`div`,{style:O,children:(0,E.jsxs)(`div`,{style:k,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{style:d,children:`Per-Session Timeout`}),(0,E.jsx)(`div`,{style:s,children:`Wall-clock budget per Claude session (single-shot, not idle-based). Per-job override in the Job edit form takes precedence. 0 disables.`})]}),(0,E.jsxs)(`select`,{value:r?.noProgressTimeoutMs??15e5,onChange:n=>A(e,t,{noProgressTimeoutMs:Number(n.target.value)}),style:D,children:[(0,E.jsx)(`option`,{value:0,children:`Disabled`}),(0,E.jsx)(`option`,{value:6e4,children:`1 min`}),(0,E.jsx)(`option`,{value:18e4,children:`3 min`}),(0,E.jsx)(`option`,{value:3e5,children:`5 min`}),(0,E.jsx)(`option`,{value:6e5,children:`10 min`}),(0,E.jsx)(`option`,{value:9e5,children:`15 min`}),(0,E.jsx)(`option`,{value:12e5,children:`20 min`}),(0,E.jsx)(`option`,{value:15e5,children:`25 min (default)`}),(0,E.jsx)(`option`,{value:18e5,children:`30 min`})]})]})}),(0,E.jsx)(`div`,{style:O,children:(0,E.jsxs)(`div`,{style:k,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{style:d,children:`Default Effort Level`}),(0,E.jsx)(`div`,{style:s,children:`Applied when employee doesn't specify one`})]}),(0,E.jsxs)(`select`,{value:r?.defaultEffortLevel??``,onChange:n=>A(e,t,{defaultEffortLevel:n.target.value}),style:D,children:[(0,E.jsx)(`option`,{value:``,children:`Auto`}),(0,E.jsx)(`option`,{value:`low`,children:`Low`}),(0,E.jsx)(`option`,{value:`medium`,children:`Medium`}),(0,E.jsx)(`option`,{value:`high`,children:`High`}),(0,E.jsx)(`option`,{value:`xhigh`,children:`Extra High`}),(0,E.jsx)(`option`,{value:`max`,children:`Maximum`})]})]})})]}),(0,E.jsxs)(`div`,{style:{marginTop:20},children:[(0,E.jsx)(`div`,{style:{fontSize:14,fontWeight:600,color:c.text,marginBottom:8},children:`Ollama Engine`}),(0,E.jsxs)(`p`,{style:{fontSize:12,color:`var(--color-text-muted)`,margin:`0 0 12px`},children:[`Connect a local or remote Ollama instance. Assign employees to use it with `,(0,E.jsx)(y,{size:`sm`,children:`engine: "ollama"`}),`.`]}),(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:10},children:[(0,E.jsxs)(`div`,{style:O,children:[(0,E.jsxs)(`div`,{style:{marginBottom:8},children:[(0,E.jsx)(`div`,{style:d,children:`Host URL`}),(0,E.jsx)(`div`,{style:s,children:`Ollama API endpoint (e.g., http://your-host:11434). Leave empty to disable. Saved + validated on blur.`})]}),(0,E.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),onBlur:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&e.target.blur()},placeholder:`http://hostname:11434`,style:l})]}),r?.ollama?.host&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`div`,{style:O,children:[(0,E.jsxs)(`div`,{style:{marginBottom:8},children:[(0,E.jsx)(`div`,{style:d,children:`Default Model`}),(0,E.jsx)(`div`,{style:s,children:u.status===`loading`?`Fetching models from Ollama…`:u.status===`error`?`Could not reach Ollama: ${u.message}`:`Pick a model advertised by the Ollama host (must support tool calling)`})]}),u.status===`loaded`?(0,E.jsxs)(`select`,{value:r.ollama.defaultModel??``,onChange:n=>A(e,t,{ollama:{...r.ollama,defaultModel:n.target.value}}),style:{...l,cursor:`pointer`},children:[(0,E.jsx)(`option`,{value:``,children:`— select a model —`}),r.ollama.defaultModel&&!u.models.includes(r.ollama.defaultModel)&&(0,E.jsxs)(`option`,{value:r.ollama.defaultModel,children:[r.ollama.defaultModel,` (not found on host)`]}),u.models.map(e=>(0,E.jsx)(`option`,{value:e,children:e},e))]}):(0,E.jsx)(`input`,{type:`text`,value:r.ollama.defaultModel??``,onChange:n=>A(e,t,{ollama:{...r.ollama,defaultModel:n.target.value}}),placeholder:`qwen3:latest`,style:l})]}),(0,E.jsxs)(`div`,{style:O,children:[(0,E.jsxs)(`div`,{style:{...k,marginBottom:12},children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{style:d,children:`Timeout`}),(0,E.jsx)(`div`,{style:s,children:`Max wall-clock time per session`})]}),(0,E.jsxs)(`select`,{value:r.ollama.timeoutMs??3e5,onChange:n=>A(e,t,{ollama:{...r.ollama,timeoutMs:Number(n.target.value)}}),style:D,children:[(0,E.jsx)(`option`,{value:6e4,children:`1 min`}),(0,E.jsx)(`option`,{value:12e4,children:`2 min`}),(0,E.jsx)(`option`,{value:3e5,children:`5 min`}),(0,E.jsx)(`option`,{value:6e5,children:`10 min`}),(0,E.jsx)(`option`,{value:9e5,children:`15 min`})]})]}),(0,E.jsxs)(`div`,{style:{borderTop:`1px solid ${c.border}`,paddingTop:12,...k,marginBottom:12},children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{style:d,children:`Max Tool Calls`}),(0,E.jsx)(`div`,{style:s,children:`Per turn (circuit breaker)`})]}),(0,E.jsx)(`select`,{value:r.ollama.maxToolCalls??10,onChange:n=>A(e,t,{ollama:{...r.ollama,maxToolCalls:Number(n.target.value)}}),style:D,children:[5,10,15,20,25,30].map(e=>(0,E.jsx)(`option`,{value:e,children:e},e))})]}),(0,E.jsxs)(`div`,{style:{borderTop:`1px solid ${c.border}`,paddingTop:12,...k},children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{style:d,children:`Max Turns`}),(0,E.jsx)(`div`,{style:s,children:`Max conversation turns per session`})]}),(0,E.jsx)(`select`,{value:r.ollama.maxTurns??10,onChange:n=>A(e,t,{ollama:{...r.ollama,maxTurns:Number(n.target.value)}}),style:D,children:[5,10,15,20,25,30].map(e=>(0,E.jsx)(`option`,{value:e,children:e},e))})]})]})]})]})]})]})}var j=o,M=u,fe={fontSize:12,color:c.muted};function pe(e,t){switch(e){case`connected`:return{label:`Connected (Socket Mode)`,color:c.green,bg:`rgba(63, 185, 80, 0.1)`};case`connecting`:return{label:`Connecting...`,color:`var(--color-warning)`,bg:`rgba(210, 153, 34, 0.1)`};case`reconnecting`:return{label:`Reconnecting...`,color:`var(--color-warning)`,bg:`rgba(210, 153, 34, 0.1)`};case`error`:return{label:`Connection Error`,color:c.red,bg:`rgba(248, 81, 73, 0.1)`};case`disconnected`:return t?{label:`Disconnected`,color:`var(--color-warning)`,bg:`rgba(210, 153, 34, 0.1)`}:{label:`Not Configured`,color:c.muted,bg:`rgba(139, 148, 158, 0.1)`};default:return t?{label:`Connected (Socket Mode)`,color:c.green,bg:`rgba(63, 185, 80, 0.1)`}:{label:`Not Configured`,color:c.muted,bg:`rgba(139, 148, 158, 0.1)`}}}var me=/^[a-zA-Z][a-zA-Z0-9_-]{0,127}$/;function he({settings:e,onUpdateSettings:t,runtimeConfig:n}){let r=n?.slackConfigured??!1,i=n?.slackConnectionStatus,a=pe(i,r),o=e?.slack?.includeChannelHistory??!0,l=e?.slack?.botMcpName??`slack-bot-mcp`,u=e?.slack?.responderEmployee??``,{employees:f}=x(),p={executive:0,manager:1,senior:2,employee:3},m=[...f].sort((e,t)=>{let n=p[e.rank]??9,r=p[t.rank]??9;return n===r?e.name.localeCompare(t.name):n-r}),g=u===``||m.some(e=>e.name===u),_=e=>{let n=e.trim();n!==l&&(n.length===0||!me.test(n)||t({slack:{includeChannelHistory:o,botMcpName:n}}))},v=e=>{t({slack:{includeChannelHistory:o,botMcpName:l,responderEmployee:e}})};return(0,E.jsx)(S,{title:`Slack Connector`,description:`Slack integration status and configuration. Tokens are set via environment variables.`,children:(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:10},children:[(0,E.jsxs)(`div`,{style:j,children:[(0,E.jsxs)(`div`,{style:M,children:[(0,E.jsx)(`div`,{style:d,children:`Connection Status`}),(0,E.jsx)(C,{label:a.label,color:a.color,bg:a.bg})]}),i===`error`&&n?.slackConnectionError&&(0,E.jsx)(`div`,{style:{fontSize:12,color:c.red,padding:`4px 0 2px`,lineHeight:1.4,opacity:.85},children:n.slackConnectionError})]}),(0,E.jsxs)(`div`,{style:j,children:[(0,E.jsxs)(`div`,{style:{...M,borderBottom:`1px solid ${c.border}`,paddingBottom:10},children:[(0,E.jsx)(`div`,{style:d,children:`App Token`}),(0,E.jsx)(`span`,{style:fe,children:r?`••••••••`:`Not set`})]}),(0,E.jsxs)(`div`,{style:{...M,paddingTop:10},children:[(0,E.jsx)(`div`,{style:d,children:`Bot Token`}),(0,E.jsx)(`span`,{style:fe,children:r?`••••••••`:`Not set`})]})]}),(0,E.jsxs)(`div`,{style:j,children:[(0,E.jsxs)(`div`,{style:{marginBottom:8},children:[(0,E.jsx)(`div`,{style:d,children:`Default Responder`}),(0,E.jsx)(`div`,{style:s,children:`Employee that handles incoming Slack DMs and mentions. When unset, falls back to default routing. Per-thread routing rules still apply.`})]}),(0,E.jsxs)(h,{compact:!0,value:u,onChange:e=>v(e.target.value),children:[(0,E.jsx)(`option`,{value:``,children:`— default routing —`}),!g&&(0,E.jsxs)(`option`,{value:u,children:[u,` (not found)`]}),m.map(e=>(0,E.jsxs)(`option`,{value:e.name,children:[e.displayName?`${e.displayName} (${e.name})`:e.name,e.rank===`employee`?``:` — ${e.rank}`]},e.name))]})]}),(0,E.jsxs)(`div`,{style:j,children:[(0,E.jsxs)(`div`,{style:{...M,borderBottom:`1px solid ${c.border}`,paddingBottom:10},children:[(0,E.jsx)(`div`,{style:d,children:`Allowed Users`}),(0,E.jsx)(`span`,{style:fe,children:n?.slackAllowFrom?n.slackAllowFrom.split(`,`).length+` user(s)`:`All users`})]}),(0,E.jsxs)(`div`,{style:{...M,paddingTop:10},children:[(0,E.jsx)(`div`,{style:d,children:`Ignore Old Messages on Boot`}),(0,E.jsx)(`span`,{style:{fontSize:11,fontWeight:500,color:n?.slackIgnoreOldOnBoot===!1?c.muted:c.green},children:n?.slackIgnoreOldOnBoot===!1?`No`:`Yes`})]})]}),(0,E.jsx)(`div`,{style:j,children:(0,E.jsxs)(`div`,{style:M,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{style:d,children:`Include Channel History`}),(0,E.jsx)(`div`,{style:s,children:`Prepend recent channel messages as context for non-thread messages.`})]}),(0,E.jsx)(b,{checked:o,onChange:e=>t({slack:{includeChannelHistory:e,botMcpName:l}})})]})}),(0,E.jsx)(`div`,{style:j,children:(0,E.jsxs)(`div`,{style:{...M,alignItems:`flex-start`,gap:16},children:[(0,E.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,E.jsx)(`div`,{style:d,children:`Bot MCP Name`}),(0,E.jsxs)(`div`,{style:s,children:[`MCP server name jobs post through (`,` `,(0,E.jsxs)(y,{size:`sm`,children:[`mcp__`,l,`__*`]}),` `,`). Jobs can reference`,` `,(0,E.jsx)(y,{size:`sm`,children:`{{SLACK_BOT_MCP_NAME}}`}),` `,`or`,` `,(0,E.jsx)(y,{size:`sm`,children:`{{SLACK_BOT_MCP_PREFIX}}`}),` `,`in their prompts — these expand to this value at runtime.`]})]}),(0,E.jsx)(`input`,{type:`text`,defaultValue:l,onBlur:e=>_(e.currentTarget.value),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()},spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,placeholder:`slack-bot-mcp`,"aria-label":`Bot MCP name`,style:{flexShrink:0,width:200,fontFamily:`ui-monospace, monospace`,fontSize:12,padding:`6px 8px`,background:c.darkBg,color:c.text,border:`1px solid ${c.border}`,borderRadius:6,outline:`none`}})]})}),(0,E.jsxs)(`div`,{style:{fontSize:12,color:c.muted,lineHeight:1.5,padding:`8px 12px`,background:`rgba(110,118,129,0.08)`,borderRadius:6,border:`1px solid ${c.border}`},children:[`Slack tokens are configured via environment variables. Set`,` `,(0,E.jsx)(y,{size:`sm`,children:`SLACK_APP_TOKEN`}),` `,`and`,` `,(0,E.jsx)(y,{size:`sm`,children:`SLACK_BOT_TOKEN`}),` `,`in your `,(0,E.jsx)(y,{size:`sm`,children:`.env`}),` file and restart the gateway.`]})]})})}var N=o,ge=u,_e={background:`var(--color-bg-raised)`,color:c.text,border:`1px solid ${c.border}`,borderRadius:6,padding:`4px 10px`,fontSize:13,cursor:`pointer`,minWidth:120},P={background:`none`,border:`none`,color:c.muted,fontSize:13,cursor:`pointer`,minWidth:44,minHeight:44,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,lineHeight:1,transition:`color 0.15s ease`};function F(e,t,n){t({orgDefaults:{...e?.orgDefaults??{defaultRank:`employee`,defaultDepartment:`general`,defaultMaxCostUsd:0,defaultMcpServers:[`gateway`]},...n}})}function ve({settings:e,onUpdateSettings:t}){let[n,r]=(0,T.useState)([]),[i,a]=(0,T.useState)(!0),[o,u]=(0,T.useState)(``),[f,p]=(0,T.useState)(``),[m,h]=(0,T.useState)(!1),[g,_]=(0,T.useState)(null),[v,y]=(0,T.useState)(``),[b,x]=(0,T.useState)(!1),[ee,S]=(0,T.useState)(null),C=(0,T.useCallback)(async()=>{try{let e=await fetch(`/api/org/departments`);e.ok&&r((await e.json()).departments)}catch{u(`Failed to load departments`)}finally{a(!1)}},[]);(0,T.useEffect)(()=>{C()},[C]);async function te(){let e=f.trim().toLowerCase().replace(/\s+/g,`-`);if(e){h(!0),u(``);try{let t=await fetch(`/api/org/departments`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:e})});if(!t.ok){u((await t.json()).error??`Failed to create department`);return}p(``),await C()}catch{u(`Request failed`)}finally{h(!1)}}}async function w(n){let r=v.trim().toLowerCase().replace(/\s+/g,`-`);if(!r||r===n){_(null);return}x(!0),u(``);try{let i=await fetch(`/api/org/departments/${encodeURIComponent(n)}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({newName:r})});if(!i.ok){u((await i.json()).error??`Failed to rename department`);return}_(null),e?.orgDefaults?.defaultDepartment===n&&F(e,t,{defaultDepartment:r}),await C()}catch{u(`Request failed`)}finally{x(!1)}}async function ne(n){x(!0),u(``);try{let r=await fetch(`/api/org/departments/${encodeURIComponent(n)}`,{method:`DELETE`});if(!r.ok){u((await r.json()).error??`Failed to delete department`);return}S(null),e?.orgDefaults?.defaultDepartment===n&&F(e,t,{defaultDepartment:``}),await C()}catch{u(`Request failed`)}finally{x(!1)}}return i?(0,E.jsx)(`div`,{style:N,children:(0,E.jsx)(`div`,{style:{fontSize:12,color:c.muted},children:`Loading departments...`})}):(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:10},children:[(0,E.jsxs)(`div`,{style:N,children:[(0,E.jsxs)(`div`,{style:{marginBottom:10},children:[(0,E.jsx)(`div`,{style:d,children:`Departments`}),(0,E.jsx)(`div`,{style:s,children:`Manage organizational departments. Changes propagate to all employees.`})]}),n.length===0?(0,E.jsx)(`div`,{style:{fontSize:12,color:c.muted,padding:`8px 0`},children:`No departments found. Add one below.`}):(0,E.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:n.map(e=>(0,E.jsx)(`div`,{children:g===e?(0,E.jsxs)(`div`,{style:{display:`flex`,gap:6,alignItems:`center`},children:[(0,E.jsx)(`input`,{type:`text`,value:v,onChange:e=>y(e.target.value),onKeyDown:t=>{t.key===`Enter`&&w(e),t.key===`Escape`&&_(null)},autoFocus:!0,style:{...l,flex:1}}),(0,E.jsx)(`button`,{onClick:()=>w(e),disabled:b,style:{...P,color:c.green,fontSize:12,fontWeight:500},children:b?`...`:`Save`}),(0,E.jsx)(`button`,{onClick:()=>_(null),style:P,children:`Cancel`})]}):ee===e?(0,E.jsxs)(`div`,{style:{display:`flex`,gap:8,alignItems:`center`,padding:`6px 8px`,background:`rgba(248, 81, 73, 0.06)`,borderRadius:6,border:`1px solid rgba(248, 81, 73, 0.2)`},children:[(0,E.jsxs)(`span`,{style:{fontSize:12,color:c.text,flex:1},children:[`Delete `,(0,E.jsx)(`strong`,{children:e}),`? Employees will be unassigned.`]}),(0,E.jsx)(`button`,{onClick:()=>ne(e),disabled:b,style:{...P,color:c.red,fontSize:12,fontWeight:500},children:b?`...`:`Delete`}),(0,E.jsx)(`button`,{onClick:()=>S(null),style:P,children:`Cancel`})]}):(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,padding:`6px 8px`,borderRadius:6,transition:`background 0.15s ease`},children:[(0,E.jsx)(`span`,{style:{fontSize:13,color:c.text,fontWeight:500,flex:1},children:e}),(0,E.jsx)(`button`,{onClick:()=>{_(e),y(e)},style:P,onMouseEnter:e=>e.currentTarget.style.color=c.text,onMouseLeave:e=>e.currentTarget.style.color=c.muted,"aria-label":`Rename ${e}`,children:`✎`}),(0,E.jsx)(`button`,{onClick:()=>S(e),style:P,onMouseEnter:e=>e.currentTarget.style.color=c.red,onMouseLeave:e=>e.currentTarget.style.color=c.muted,"aria-label":`Delete ${e}`,children:`×`})]})},e))}),(0,E.jsxs)(`div`,{style:{display:`flex`,gap:8,alignItems:`center`,marginTop:10,paddingTop:10,borderTop:`1px solid ${c.border}`},children:[(0,E.jsx)(`input`,{type:`text`,value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&te()},placeholder:`New department name`,style:{...l,flex:1}}),(0,E.jsx)(`button`,{onClick:te,disabled:m||!f.trim(),style:{background:`rgba(63, 185, 80, 0.15)`,border:`1px solid rgba(63, 185, 80, 0.4)`,color:c.green,fontSize:12,fontWeight:500,padding:`6px 14px`,borderRadius:6,cursor:m||!f.trim()?`default`:`pointer`,opacity:m||!f.trim()?.5:1,whiteSpace:`nowrap`,minHeight:32,transition:`all 0.15s ease`},children:m?`...`:`Add`})]}),o&&(0,E.jsx)(`div`,{style:{fontSize:12,color:c.red,marginTop:8},children:o})]}),(0,E.jsx)(`div`,{style:N,children:(0,E.jsxs)(`div`,{style:ge,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{style:d,children:`Default Department`}),(0,E.jsx)(`div`,{style:s,children:`Assigned to new employees if not specified`})]}),(0,E.jsxs)(`select`,{value:e?.orgDefaults?.defaultDepartment??``,onChange:n=>F(e,t,{defaultDepartment:n.target.value}),style:_e,children:[(0,E.jsx)(`option`,{value:``,children:`None`}),n.map(e=>(0,E.jsx)(`option`,{value:e,children:e},e))]})]})})]})}function ye({settings:e,onUpdateSettings:t}){let n=e?.orgDefaults;return(0,E.jsx)(S,{title:`Organization Defaults`,description:`Manage departments and set defaults for new employees.`,children:(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:10},children:[(0,E.jsx)(`div`,{style:N,children:(0,E.jsxs)(`div`,{style:ge,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{style:d,children:`Default Rank`}),(0,E.jsx)(`div`,{style:s,children:`Initial rank for newly created employees`})]}),(0,E.jsxs)(`select`,{value:n?.defaultRank??`employee`,onChange:n=>F(e,t,{defaultRank:n.target.value}),style:_e,children:[(0,E.jsx)(`option`,{value:`employee`,children:`Employee`}),(0,E.jsx)(`option`,{value:`senior`,children:`Senior`}),(0,E.jsx)(`option`,{value:`manager`,children:`Manager`}),(0,E.jsx)(`option`,{value:`executive`,children:`Executive`})]})]})}),(0,E.jsx)(ve,{settings:e,onUpdateSettings:t}),(0,E.jsx)(`div`,{style:N,children:(0,E.jsxs)(`div`,{style:ge,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{style:d,children:`Default Cost Limit (USD)`}),(0,E.jsx)(`div`,{style:s,children:`Per-session budget limit. 0 = unlimited.`})]}),(0,E.jsx)(`input`,{type:`number`,min:0,step:.5,value:n?.defaultMaxCostUsd??0,onChange:n=>F(e,t,{defaultMaxCostUsd:Math.max(0,Number(n.target.value))}),style:{...l,width:100,textAlign:`right`}})]})}),(0,E.jsxs)(`div`,{style:N,children:[(0,E.jsxs)(`div`,{style:{marginBottom:8},children:[(0,E.jsx)(`div`,{style:d,children:`Default MCP Access`}),(0,E.jsx)(`div`,{style:s,children:`Comma-separated list of MCP servers new employees can access`})]}),(0,E.jsx)(`input`,{type:`text`,value:(n?.defaultMcpServers??[`gateway`]).join(`, `),onChange:n=>{F(e,t,{defaultMcpServers:n.target.value.split(`,`).map(e=>e.trim()).filter(Boolean)})},placeholder:`e.g. gateway, slack`,style:l})]})]})})}function be({size:e=14,color:t=`currentColor`}){return(0,E.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 16 16`,fill:t,children:(0,E.jsx)(`path`,{d:`M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z`})})}function xe({size:e=14,color:t=`currentColor`}){return(0,E.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 100 100`,fill:`none`,children:[(0,E.jsx)(`path`,{d:`M6.017 4.313l55.333-4.087c6.797-.583 8.543-.19 12.817 2.917l17.663 12.443c2.913 2.14 3.883 2.723 3.883 5.053v68.243c0 4.277-1.553 6.807-6.99 7.193L24.467 99.967c-4.08.193-6.023-.39-8.16-3.113L3.3 79.94c-2.333-3.113-3.3-5.443-3.3-8.167V11.113c0-3.497 1.553-6.413 6.017-6.8z`,fill:t}),(0,E.jsx)(`path`,{d:`M61.35.227l-55.333 4.087C.573 4.7-.977 7.617-.977 11.113v60.66c0 2.723.967 5.053 3.3 8.167l12.99 16.913c2.137 2.723 4.08 3.307 8.16 3.113l64.257-3.89c5.433-.387 6.99-2.917 6.99-7.193V20.64c0-2.21-.82-2.873-3.277-4.627L75.753 3.57`,fill:t}),(0,E.jsx)(`path`,{d:`M28.45 26.32c0 2.723-.193 3.113-1.747 4.083L18.28 36.127c-1.553.97-2.327.583-2.327-1.553V16.18c0-2.527 1.163-3.887 3.3-4.08l9.107-.777c2.137-.193 3.09 1.163 3.09 3.5v11.497zm-3.69 53.963V40.597L62.08 38.07v39.3`,fill:`#fff`})]})}function Se({size:e=14,color:t=`currentColor`}){return(0,E.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 100 100`,fill:t,children:[(0,E.jsx)(`path`,{d:`M1.22541 61.5228c-.04261-.0915.00702-.1855.08037-.2555L49.2213 13.3509c.0697-.0697.1543-.1084.2441-.1048.104.0042.1936.0664.2496.1572l16.1758 26.2664-14.2742 14.2742L25.8428 80.6176c-.1015.1015-.2741.094-.356-.0171L1.22541 61.5228z`}),(0,E.jsx)(`path`,{d:`M75.4913 43.5228l-8.1697-13.2668L50.4444 47.1332l13.2668 8.1697L75.4913 43.5228z`}),(0,E.jsx)(`path`,{d:`M86.5913 48.5228l-6.1697-10.0168L67.7444 51.1832l10.0168 6.1697L86.5913 48.5228z`})]})}function Ce({size:e=14}){return(0,E.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,children:[(0,E.jsx)(`path`,{d:`M5.042 15.165a2.528 2.528 0 0 1-2.52 2.523A2.528 2.528 0 0 1 0 15.165a2.527 2.527 0 0 1 2.522-2.52h2.52v2.52z`,fill:`#E01E5A`}),(0,E.jsx)(`path`,{d:`M6.313 15.165a2.527 2.527 0 0 1 2.521-2.52 2.527 2.527 0 0 1 2.521 2.52v6.313A2.528 2.528 0 0 1 8.834 24a2.528 2.528 0 0 1-2.521-2.522v-6.313z`,fill:`#E01E5A`}),(0,E.jsx)(`path`,{d:`M8.834 5.042a2.528 2.528 0 0 1-2.521-2.52A2.528 2.528 0 0 1 8.834 0a2.528 2.528 0 0 1 2.521 2.522v2.52H8.834z`,fill:`#36C5F0`}),(0,E.jsx)(`path`,{d:`M8.834 6.313a2.528 2.528 0 0 1 2.521 2.521 2.528 2.528 0 0 1-2.521 2.521H2.522A2.528 2.528 0 0 1 0 8.834a2.528 2.528 0 0 1 2.522-2.521h6.312z`,fill:`#36C5F0`}),(0,E.jsx)(`path`,{d:`M18.956 8.834a2.528 2.528 0 0 1 2.522-2.521A2.528 2.528 0 0 1 24 8.834a2.528 2.528 0 0 1-2.522 2.521h-2.522V8.834z`,fill:`#2EB67D`}),(0,E.jsx)(`path`,{d:`M17.688 8.834a2.528 2.528 0 0 1-2.523 2.521 2.527 2.527 0 0 1-2.52-2.521V2.522A2.527 2.527 0 0 1 15.165 0a2.528 2.528 0 0 1 2.523 2.522v6.312z`,fill:`#2EB67D`}),(0,E.jsx)(`path`,{d:`M15.165 18.956a2.528 2.528 0 0 1 2.523 2.522A2.528 2.528 0 0 1 15.165 24a2.527 2.527 0 0 1-2.52-2.522v-2.522h2.52z`,fill:`#ECB22E`}),(0,E.jsx)(`path`,{d:`M15.165 17.688a2.527 2.527 0 0 1-2.52-2.523 2.526 2.526 0 0 1 2.52-2.52h6.313A2.527 2.527 0 0 1 24 15.165a2.528 2.528 0 0 1-2.522 2.523h-6.313z`,fill:`#ECB22E`})]})}var we=[{key:`github`,label:`GitHub`,icon:be,isActive:e=>!!e.connected,instruction:`Run gh auth login in your terminal`},{key:`notion`,label:`Notion`,icon:xe,isActive:e=>!!e.configured,instruction:`Add Notion MCP server to Claude`},{key:`linear`,label:`Linear`,icon:Se,isActive:e=>!!e.configured,instruction:`Add Linear MCP server to Claude`},{key:`slack`,label:`Slack`,icon:Ce,isActive:e=>!!e.configured,instruction:`Add Slack MCP server to Claude`}];function Te({integrations:e,onVerify:t,verifying:n}){return(0,E.jsxs)(S,{title:`Configured Integrations`,children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,marginBottom:12},children:[(0,E.jsxs)(`div`,{style:{fontSize:12,color:c.muted,lineHeight:1.5,flex:1,marginRight:12},children:[`Local integrations are detected automatically. To probe cloud-hosted MCP servers, click`,` `,(0,E.jsx)(`strong`,{style:{color:c.textSecondary},children:`Verify connections`}),` above.`]}),(0,E.jsx)(`button`,{onClick:t,disabled:n,style:{background:`rgba(210, 153, 34, 0.15)`,border:`1px solid rgba(210, 153, 34, 0.4)`,color:c.warning,fontSize:11,padding:`4px 12px`,borderRadius:6,cursor:n?`default`:`pointer`,opacity:n?.6:1,whiteSpace:`nowrap`,flexShrink:0,minHeight:32},children:n?`Verifying...`:`Verify connections`})]}),(0,E.jsx)(`div`,{style:{padding:`10px 14px`,background:`var(--color-subtle-bg)`,borderRadius:8,border:`1px solid ${c.border}`},children:(0,E.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8},children:we.map(t=>{let n=e?e[t.key]:void 0,r=n?t.isActive(n):!1,i=n?.verified===!0,a=n?.verifiedAt,o=t.icon;return(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,padding:`6px 0`,fontSize:13},children:[(0,E.jsx)(o,{size:15,color:i?c.green:r?c.warning:c.muted}),(0,E.jsx)(`span`,{style:{color:r||i?c.text:c.muted,fontWeight:500,minWidth:56},children:t.label}),i?(0,E.jsxs)(`span`,{style:{fontSize:11},children:[(0,E.jsx)(`span`,{style:{color:c.green},children:`✓ Connected`}),a&&(0,E.jsx)(`span`,{style:{color:c.muted,marginLeft:6},children:new Date(a).toLocaleDateString()})]}):r?(0,E.jsx)(`span`,{style:{color:c.warning,fontSize:11},children:`Installed — verify to check`}):(0,E.jsx)(`span`,{style:{color:c.muted,fontSize:11,opacity:.8},children:`Not detected — verify to check`})]},t.key)})})})]})}function Ee(e){return e==null}function De(e){return typeof e==`object`&&!!e}function Oe(e){return Array.isArray(e)?e:Ee(e)?[]:[e]}function ke(e,t){var n,r,i,a;if(t)for(a=Object.keys(t),n=0,r=a.length;n<r;n+=1)i=a[n],e[i]=t[i];return e}function Ae(e,t){var n=``,r;for(r=0;r<t;r+=1)n+=e;return n}function je(e){return e===0&&1/e==-1/0}var I={isNothing:Ee,isObject:De,toArray:Oe,repeat:Ae,isNegativeZero:je,extend:ke};function Me(e,t){var n=``,r=e.reason||`(unknown reason)`;return e.mark?(e.mark.name&&(n+=`in "`+e.mark.name+`" `),n+=`(`+(e.mark.line+1)+`:`+(e.mark.column+1)+`)`,!t&&e.mark.snippet&&(n+=`
|
|
1
|
+
import{n as e,s as t,t as n}from"./jsx-runtime-Bq3x7umQ.js";import{c as r,r as i,s as a}from"./useWebSocket-Hg3RO6sx.js";import{f as o,i as s,n as c,o as l,p as u,s as d}from"./styles-Ds5gMQAQ.js";import{b as f}from"./events-BK5ucyUu.js";import{n as p}from"./types-BeZJlDCI.js";import{t as m}from"./Card-u29day7d.js";import{t as h}from"./Button-DTO6bgnL.js";import{n as g,r as _}from"./Input-iymdcwsf.js";import{A as v,At as y,Dt as b,Ot as x,d as ee,en as te,f as S,ht as ne,mt as re,n as ie,o as ae,p as oe,r as se,t as ce,wt as C}from"./index-DzJsiq8q.js";import{n as le,t as w}from"./SettingsRow-4w9Ab9mk.js";var T=t(e(),1),E=n(),D={background:`var(--color-bg-raised)`,color:c.text,border:`1px solid ${c.border}`,borderRadius:6,padding:`4px 10px`,fontSize:13,cursor:`pointer`,minWidth:80},O=o,k=u;async function ue(e,t,n){t({status:`loading`});let r=await oe(e);n.current=e,t(r.ok?{status:`loaded`,models:r.models}:{status:`error`,message:r.error})}function A(e,t,n){t({engine:{...e?.engine??{default:`claude`,defaultModel:``,maxRetries:2,retryBaseDelayMs:1e3,defaultEffortLevel:``,allowOverage:!0,noProgressTimeoutMs:15e5},...n}})}function de({settings:e,onUpdateSettings:t,runtimeConfig:n}){let r=e?.engine,i=r?.ollama?.host??``,[a,o]=(0,T.useState)(i),[u,f]=(0,T.useState)({status:`idle`}),p=(0,T.useRef)(null);(0,T.useEffect)(()=>{o(e=>e===i?e:i)},[i]),(0,T.useEffect)(()=>{if(!i){p.current=null,f({status:`idle`});return}p.current===i&&u.status!==`idle`||ue(i,f,p)},[i]);function m(n){let a=n.trim();if(a!==i){if(!a){t({engine:{...r??{default:`claude`,defaultModel:``,maxRetries:2,retryBaseDelayMs:1e3,defaultEffortLevel:``,allowOverage:!0,noProgressTimeoutMs:15e5},ollama:null}}),p.current=null,f({status:`idle`});return}A(e,t,{ollama:{host:a,defaultModel:r?.ollama?.defaultModel??``,timeoutMs:r?.ollama?.timeoutMs??3e5,maxToolCalls:r?.ollama?.maxToolCalls??10,maxTurns:r?.ollama?.maxTurns??10}}),ue(a,f,p)}}return(0,E.jsxs)(y,{title:`Engine Configuration`,description:`Configure the Claude CLI engine defaults for all agent sessions.`,children:[(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:10},children:[(0,E.jsx)(`div`,{style:O,children:(0,E.jsxs)(`div`,{style:k,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{style:d,children:`CLI Binary`}),(0,E.jsx)(`div`,{style:s,children:`Set via CLAUDE_COMMAND environment variable`})]}),(0,E.jsx)(C,{children:n?.claudeCommand??`claude`})]})}),(0,E.jsxs)(`div`,{style:O,children:[(0,E.jsxs)(`div`,{style:{marginBottom:8},children:[(0,E.jsx)(`div`,{style:d,children:`Default Model`}),(0,E.jsx)(`div`,{style:s,children:`Override per-employee, or leave empty for CLI default`})]}),(0,E.jsxs)(`select`,{value:r?.defaultModel??``,onChange:n=>A(e,t,{defaultModel:n.target.value}),style:{...l,cursor:`pointer`},children:[(0,E.jsx)(`option`,{value:``,children:`— use CLI default —`}),r?.defaultModel&&!S(r.defaultModel)&&(0,E.jsxs)(`option`,{value:r.defaultModel,children:[r.defaultModel,` (custom)`]}),ee.map(e=>(0,E.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,E.jsxs)(`div`,{style:O,children:[(0,E.jsxs)(`div`,{style:{...k,marginBottom:12},children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{style:d,children:`Max Retries`}),(0,E.jsx)(`div`,{style:s,children:`Retry on transient errors (rate limits, timeouts)`})]}),(0,E.jsx)(`select`,{value:r?.maxRetries??2,onChange:n=>A(e,t,{maxRetries:Number(n.target.value)}),style:D,children:[0,1,2,3,4,5].map(e=>(0,E.jsx)(`option`,{value:e,children:e},e))})]}),(0,E.jsx)(`div`,{style:{borderTop:`1px solid ${c.border}`,paddingTop:12},children:(0,E.jsxs)(`div`,{style:k,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{style:d,children:`Retry Base Delay`}),(0,E.jsx)(`div`,{style:s,children:`Exponential backoff base (doubled each retry)`})]}),(0,E.jsxs)(`select`,{value:r?.retryBaseDelayMs??1e3,onChange:n=>A(e,t,{retryBaseDelayMs:Number(n.target.value)}),style:D,children:[(0,E.jsx)(`option`,{value:500,children:`500ms`}),(0,E.jsx)(`option`,{value:1e3,children:`1s`}),(0,E.jsx)(`option`,{value:2e3,children:`2s`}),(0,E.jsx)(`option`,{value:5e3,children:`5s`}),(0,E.jsx)(`option`,{value:1e4,children:`10s`})]})]})})]}),(0,E.jsx)(`div`,{style:O,children:(0,E.jsxs)(`div`,{style:k,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{style:d,children:`Per-Session Timeout`}),(0,E.jsx)(`div`,{style:s,children:`Wall-clock budget per Claude session (single-shot, not idle-based). Per-job override in the Job edit form takes precedence. 0 disables.`})]}),(0,E.jsxs)(`select`,{value:r?.noProgressTimeoutMs??15e5,onChange:n=>A(e,t,{noProgressTimeoutMs:Number(n.target.value)}),style:D,children:[(0,E.jsx)(`option`,{value:0,children:`Disabled`}),(0,E.jsx)(`option`,{value:6e4,children:`1 min`}),(0,E.jsx)(`option`,{value:18e4,children:`3 min`}),(0,E.jsx)(`option`,{value:3e5,children:`5 min`}),(0,E.jsx)(`option`,{value:6e5,children:`10 min`}),(0,E.jsx)(`option`,{value:9e5,children:`15 min`}),(0,E.jsx)(`option`,{value:12e5,children:`20 min`}),(0,E.jsx)(`option`,{value:15e5,children:`25 min (default)`}),(0,E.jsx)(`option`,{value:18e5,children:`30 min`})]})]})}),(0,E.jsx)(`div`,{style:O,children:(0,E.jsxs)(`div`,{style:k,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{style:d,children:`Default Effort Level`}),(0,E.jsx)(`div`,{style:s,children:`Applied when employee doesn't specify one`})]}),(0,E.jsxs)(`select`,{value:r?.defaultEffortLevel??``,onChange:n=>A(e,t,{defaultEffortLevel:n.target.value}),style:D,children:[(0,E.jsx)(`option`,{value:``,children:`Auto`}),(0,E.jsx)(`option`,{value:`low`,children:`Low`}),(0,E.jsx)(`option`,{value:`medium`,children:`Medium`}),(0,E.jsx)(`option`,{value:`high`,children:`High`}),(0,E.jsx)(`option`,{value:`xhigh`,children:`Extra High`}),(0,E.jsx)(`option`,{value:`max`,children:`Maximum`})]})]})})]}),(0,E.jsxs)(`div`,{style:{marginTop:20},children:[(0,E.jsx)(`div`,{style:{fontSize:14,fontWeight:600,color:c.text,marginBottom:8},children:`Ollama Engine`}),(0,E.jsxs)(`p`,{style:{fontSize:12,color:`var(--color-text-muted)`,margin:`0 0 12px`},children:[`Connect a local or remote Ollama instance. Assign employees to use it with `,(0,E.jsx)(C,{size:`sm`,children:`engine: "ollama"`}),`.`]}),(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:10},children:[(0,E.jsxs)(`div`,{style:O,children:[(0,E.jsxs)(`div`,{style:{marginBottom:8},children:[(0,E.jsx)(`div`,{style:d,children:`Host URL`}),(0,E.jsx)(`div`,{style:s,children:`Ollama API endpoint (e.g., http://your-host:11434). Leave empty to disable. Saved + validated on blur.`})]}),(0,E.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),onBlur:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&e.target.blur()},placeholder:`http://hostname:11434`,style:l})]}),r?.ollama?.host&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`div`,{style:O,children:[(0,E.jsxs)(`div`,{style:{marginBottom:8},children:[(0,E.jsx)(`div`,{style:d,children:`Default Model`}),(0,E.jsx)(`div`,{style:s,children:u.status===`loading`?`Fetching models from Ollama…`:u.status===`error`?`Could not reach Ollama: ${u.message}`:`Pick a model advertised by the Ollama host (must support tool calling)`})]}),u.status===`loaded`?(0,E.jsxs)(`select`,{value:r.ollama.defaultModel??``,onChange:n=>A(e,t,{ollama:{...r.ollama,defaultModel:n.target.value}}),style:{...l,cursor:`pointer`},children:[(0,E.jsx)(`option`,{value:``,children:`— select a model —`}),r.ollama.defaultModel&&!u.models.includes(r.ollama.defaultModel)&&(0,E.jsxs)(`option`,{value:r.ollama.defaultModel,children:[r.ollama.defaultModel,` (not found on host)`]}),u.models.map(e=>(0,E.jsx)(`option`,{value:e,children:e},e))]}):(0,E.jsx)(`input`,{type:`text`,value:r.ollama.defaultModel??``,onChange:n=>A(e,t,{ollama:{...r.ollama,defaultModel:n.target.value}}),placeholder:`qwen3:latest`,style:l})]}),(0,E.jsxs)(`div`,{style:O,children:[(0,E.jsxs)(`div`,{style:{...k,marginBottom:12},children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{style:d,children:`Timeout`}),(0,E.jsx)(`div`,{style:s,children:`Max wall-clock time per session`})]}),(0,E.jsxs)(`select`,{value:r.ollama.timeoutMs??3e5,onChange:n=>A(e,t,{ollama:{...r.ollama,timeoutMs:Number(n.target.value)}}),style:D,children:[(0,E.jsx)(`option`,{value:6e4,children:`1 min`}),(0,E.jsx)(`option`,{value:12e4,children:`2 min`}),(0,E.jsx)(`option`,{value:3e5,children:`5 min`}),(0,E.jsx)(`option`,{value:6e5,children:`10 min`}),(0,E.jsx)(`option`,{value:9e5,children:`15 min`})]})]}),(0,E.jsxs)(`div`,{style:{borderTop:`1px solid ${c.border}`,paddingTop:12,...k,marginBottom:12},children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{style:d,children:`Max Tool Calls`}),(0,E.jsx)(`div`,{style:s,children:`Per turn (circuit breaker)`})]}),(0,E.jsx)(`select`,{value:r.ollama.maxToolCalls??10,onChange:n=>A(e,t,{ollama:{...r.ollama,maxToolCalls:Number(n.target.value)}}),style:D,children:[5,10,15,20,25,30].map(e=>(0,E.jsx)(`option`,{value:e,children:e},e))})]}),(0,E.jsxs)(`div`,{style:{borderTop:`1px solid ${c.border}`,paddingTop:12,...k},children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{style:d,children:`Max Turns`}),(0,E.jsx)(`div`,{style:s,children:`Max conversation turns per session`})]}),(0,E.jsx)(`select`,{value:r.ollama.maxTurns??10,onChange:n=>A(e,t,{ollama:{...r.ollama,maxTurns:Number(n.target.value)}}),style:D,children:[5,10,15,20,25,30].map(e=>(0,E.jsx)(`option`,{value:e,children:e},e))})]})]})]})]})]})]})}var j=o,M=u,fe={fontSize:12,color:c.muted};function pe(e,t){switch(e){case`connected`:return{label:`Connected (Socket Mode)`,color:c.green,bg:`rgba(63, 185, 80, 0.1)`};case`connecting`:return{label:`Connecting...`,color:`var(--color-warning)`,bg:`rgba(210, 153, 34, 0.1)`};case`reconnecting`:return{label:`Reconnecting...`,color:`var(--color-warning)`,bg:`rgba(210, 153, 34, 0.1)`};case`error`:return{label:`Connection Error`,color:c.red,bg:`rgba(248, 81, 73, 0.1)`};case`disconnected`:return t?{label:`Disconnected`,color:`var(--color-warning)`,bg:`rgba(210, 153, 34, 0.1)`}:{label:`Not Configured`,color:c.muted,bg:`rgba(139, 148, 158, 0.1)`};default:return t?{label:`Connected (Socket Mode)`,color:c.green,bg:`rgba(63, 185, 80, 0.1)`}:{label:`Not Configured`,color:c.muted,bg:`rgba(139, 148, 158, 0.1)`}}}var me=/^[a-zA-Z][a-zA-Z0-9_-]{0,127}$/;function he({settings:e,onUpdateSettings:t,runtimeConfig:n}){let r=n?.slackConfigured??!1,i=n?.slackConnectionStatus,a=pe(i,r),o=e?.slack?.includeChannelHistory??!0,l=e?.slack?.botMcpName??`slack-bot-mcp`,u=e?.slack?.responderEmployee??``,{employees:f}=te(),p={executive:0,manager:1,senior:2,employee:3},m=[...f].sort((e,t)=>{let n=p[e.rank]??9,r=p[t.rank]??9;return n===r?e.name.localeCompare(t.name):n-r}),h=u===``||m.some(e=>e.name===u),_=e=>{let n=e.trim();n!==l&&(n.length===0||!me.test(n)||t({slack:{includeChannelHistory:o,botMcpName:n}}))},b=e=>{t({slack:{includeChannelHistory:o,botMcpName:l,responderEmployee:e}})};return(0,E.jsx)(y,{title:`Slack Connector`,description:`Slack integration status and configuration. Tokens are set via environment variables.`,children:(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:10},children:[(0,E.jsxs)(`div`,{style:j,children:[(0,E.jsxs)(`div`,{style:M,children:[(0,E.jsx)(`div`,{style:d,children:`Connection Status`}),(0,E.jsx)(x,{label:a.label,color:a.color,bg:a.bg})]}),i===`error`&&n?.slackConnectionError&&(0,E.jsx)(`div`,{style:{fontSize:12,color:c.red,padding:`4px 0 2px`,lineHeight:1.4,opacity:.85},children:n.slackConnectionError})]}),(0,E.jsxs)(`div`,{style:j,children:[(0,E.jsxs)(`div`,{style:{...M,borderBottom:`1px solid ${c.border}`,paddingBottom:10},children:[(0,E.jsx)(`div`,{style:d,children:`App Token`}),(0,E.jsx)(`span`,{style:fe,children:r?`••••••••`:`Not set`})]}),(0,E.jsxs)(`div`,{style:{...M,paddingTop:10},children:[(0,E.jsx)(`div`,{style:d,children:`Bot Token`}),(0,E.jsx)(`span`,{style:fe,children:r?`••••••••`:`Not set`})]})]}),(0,E.jsxs)(`div`,{style:j,children:[(0,E.jsxs)(`div`,{style:{marginBottom:8},children:[(0,E.jsx)(`div`,{style:d,children:`Default Responder`}),(0,E.jsx)(`div`,{style:s,children:`Employee that handles incoming Slack DMs and mentions. When unset, falls back to default routing. Per-thread routing rules still apply.`})]}),(0,E.jsxs)(g,{compact:!0,value:u,onChange:e=>b(e.target.value),children:[(0,E.jsx)(`option`,{value:``,children:`— default routing —`}),!h&&(0,E.jsxs)(`option`,{value:u,children:[u,` (not found)`]}),m.map(e=>(0,E.jsxs)(`option`,{value:e.name,children:[e.displayName?`${e.displayName} (${e.name})`:e.name,e.rank===`employee`?``:` — ${e.rank}`]},e.name))]})]}),(0,E.jsxs)(`div`,{style:j,children:[(0,E.jsxs)(`div`,{style:{...M,borderBottom:`1px solid ${c.border}`,paddingBottom:10},children:[(0,E.jsx)(`div`,{style:d,children:`Allowed Users`}),(0,E.jsx)(`span`,{style:fe,children:n?.slackAllowFrom?n.slackAllowFrom.split(`,`).length+` user(s)`:`All users`})]}),(0,E.jsxs)(`div`,{style:{...M,paddingTop:10},children:[(0,E.jsx)(`div`,{style:d,children:`Ignore Old Messages on Boot`}),(0,E.jsx)(`span`,{style:{fontSize:11,fontWeight:500,color:n?.slackIgnoreOldOnBoot===!1?c.muted:c.green},children:n?.slackIgnoreOldOnBoot===!1?`No`:`Yes`})]})]}),(0,E.jsx)(`div`,{style:j,children:(0,E.jsxs)(`div`,{style:M,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{style:d,children:`Include Channel History`}),(0,E.jsx)(`div`,{style:s,children:`Prepend recent channel messages as context for non-thread messages.`})]}),(0,E.jsx)(v,{checked:o,onChange:e=>t({slack:{includeChannelHistory:e,botMcpName:l}})})]})}),(0,E.jsx)(`div`,{style:j,children:(0,E.jsxs)(`div`,{style:{...M,alignItems:`flex-start`,gap:16},children:[(0,E.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,E.jsx)(`div`,{style:d,children:`Bot MCP Name`}),(0,E.jsxs)(`div`,{style:s,children:[`MCP server name jobs post through (`,` `,(0,E.jsxs)(C,{size:`sm`,children:[`mcp__`,l,`__*`]}),` `,`). Jobs can reference`,` `,(0,E.jsx)(C,{size:`sm`,children:`{{SLACK_BOT_MCP_NAME}}`}),` `,`or`,` `,(0,E.jsx)(C,{size:`sm`,children:`{{SLACK_BOT_MCP_PREFIX}}`}),` `,`in their prompts — these expand to this value at runtime.`]})]}),(0,E.jsx)(`input`,{type:`text`,defaultValue:l,onBlur:e=>_(e.currentTarget.value),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()},spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,placeholder:`slack-bot-mcp`,"aria-label":`Bot MCP name`,style:{flexShrink:0,width:200,fontFamily:`ui-monospace, monospace`,fontSize:12,padding:`6px 8px`,background:c.darkBg,color:c.text,border:`1px solid ${c.border}`,borderRadius:6,outline:`none`}})]})}),(0,E.jsxs)(`div`,{style:{fontSize:12,color:c.muted,lineHeight:1.5,padding:`8px 12px`,background:`rgba(110,118,129,0.08)`,borderRadius:6,border:`1px solid ${c.border}`},children:[`Slack tokens are configured via environment variables. Set`,` `,(0,E.jsx)(C,{size:`sm`,children:`SLACK_APP_TOKEN`}),` `,`and`,` `,(0,E.jsx)(C,{size:`sm`,children:`SLACK_BOT_TOKEN`}),` `,`in your `,(0,E.jsx)(C,{size:`sm`,children:`.env`}),` file and restart the gateway.`]})]})})}var N=o,ge=u,_e={background:`var(--color-bg-raised)`,color:c.text,border:`1px solid ${c.border}`,borderRadius:6,padding:`4px 10px`,fontSize:13,cursor:`pointer`,minWidth:120},P={background:`none`,border:`none`,color:c.muted,fontSize:13,cursor:`pointer`,minWidth:44,minHeight:44,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,lineHeight:1,transition:`color 0.15s ease`};function F(e,t,n){t({orgDefaults:{...e?.orgDefaults??{defaultRank:`employee`,defaultDepartment:`general`,defaultMaxCostUsd:0,defaultMcpServers:[`gateway`]},...n}})}function ve({settings:e,onUpdateSettings:t}){let[n,r]=(0,T.useState)([]),[i,a]=(0,T.useState)(!0),[o,u]=(0,T.useState)(``),[f,p]=(0,T.useState)(``),[m,h]=(0,T.useState)(!1),[g,_]=(0,T.useState)(null),[v,y]=(0,T.useState)(``),[b,x]=(0,T.useState)(!1),[ee,te]=(0,T.useState)(null),S=(0,T.useCallback)(async()=>{try{let e=await fetch(`/api/org/departments`);e.ok&&r((await e.json()).departments)}catch{u(`Failed to load departments`)}finally{a(!1)}},[]);(0,T.useEffect)(()=>{S()},[S]);async function ne(){let e=f.trim().toLowerCase().replace(/\s+/g,`-`);if(e){h(!0),u(``);try{let t=await fetch(`/api/org/departments`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:e})});if(!t.ok){u((await t.json()).error??`Failed to create department`);return}p(``),await S()}catch{u(`Request failed`)}finally{h(!1)}}}async function re(n){let r=v.trim().toLowerCase().replace(/\s+/g,`-`);if(!r||r===n){_(null);return}x(!0),u(``);try{let i=await fetch(`/api/org/departments/${encodeURIComponent(n)}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({newName:r})});if(!i.ok){u((await i.json()).error??`Failed to rename department`);return}_(null),e?.orgDefaults?.defaultDepartment===n&&F(e,t,{defaultDepartment:r}),await S()}catch{u(`Request failed`)}finally{x(!1)}}async function ie(n){x(!0),u(``);try{let r=await fetch(`/api/org/departments/${encodeURIComponent(n)}`,{method:`DELETE`});if(!r.ok){u((await r.json()).error??`Failed to delete department`);return}te(null),e?.orgDefaults?.defaultDepartment===n&&F(e,t,{defaultDepartment:``}),await S()}catch{u(`Request failed`)}finally{x(!1)}}return i?(0,E.jsx)(`div`,{style:N,children:(0,E.jsx)(`div`,{style:{fontSize:12,color:c.muted},children:`Loading departments...`})}):(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:10},children:[(0,E.jsxs)(`div`,{style:N,children:[(0,E.jsxs)(`div`,{style:{marginBottom:10},children:[(0,E.jsx)(`div`,{style:d,children:`Departments`}),(0,E.jsx)(`div`,{style:s,children:`Manage organizational departments. Changes propagate to all employees.`})]}),n.length===0?(0,E.jsx)(`div`,{style:{fontSize:12,color:c.muted,padding:`8px 0`},children:`No departments found. Add one below.`}):(0,E.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:n.map(e=>(0,E.jsx)(`div`,{children:g===e?(0,E.jsxs)(`div`,{style:{display:`flex`,gap:6,alignItems:`center`},children:[(0,E.jsx)(`input`,{type:`text`,value:v,onChange:e=>y(e.target.value),onKeyDown:t=>{t.key===`Enter`&&re(e),t.key===`Escape`&&_(null)},autoFocus:!0,style:{...l,flex:1}}),(0,E.jsx)(`button`,{onClick:()=>re(e),disabled:b,style:{...P,color:c.green,fontSize:12,fontWeight:500},children:b?`...`:`Save`}),(0,E.jsx)(`button`,{onClick:()=>_(null),style:P,children:`Cancel`})]}):ee===e?(0,E.jsxs)(`div`,{style:{display:`flex`,gap:8,alignItems:`center`,padding:`6px 8px`,background:`rgba(248, 81, 73, 0.06)`,borderRadius:6,border:`1px solid rgba(248, 81, 73, 0.2)`},children:[(0,E.jsxs)(`span`,{style:{fontSize:12,color:c.text,flex:1},children:[`Delete `,(0,E.jsx)(`strong`,{children:e}),`? Employees will be unassigned.`]}),(0,E.jsx)(`button`,{onClick:()=>ie(e),disabled:b,style:{...P,color:c.red,fontSize:12,fontWeight:500},children:b?`...`:`Delete`}),(0,E.jsx)(`button`,{onClick:()=>te(null),style:P,children:`Cancel`})]}):(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,padding:`6px 8px`,borderRadius:6,transition:`background 0.15s ease`},children:[(0,E.jsx)(`span`,{style:{fontSize:13,color:c.text,fontWeight:500,flex:1},children:e}),(0,E.jsx)(`button`,{onClick:()=>{_(e),y(e)},style:P,onMouseEnter:e=>e.currentTarget.style.color=c.text,onMouseLeave:e=>e.currentTarget.style.color=c.muted,"aria-label":`Rename ${e}`,children:`✎`}),(0,E.jsx)(`button`,{onClick:()=>te(e),style:P,onMouseEnter:e=>e.currentTarget.style.color=c.red,onMouseLeave:e=>e.currentTarget.style.color=c.muted,"aria-label":`Delete ${e}`,children:`×`})]})},e))}),(0,E.jsxs)(`div`,{style:{display:`flex`,gap:8,alignItems:`center`,marginTop:10,paddingTop:10,borderTop:`1px solid ${c.border}`},children:[(0,E.jsx)(`input`,{type:`text`,value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ne()},placeholder:`New department name`,style:{...l,flex:1}}),(0,E.jsx)(`button`,{onClick:ne,disabled:m||!f.trim(),style:{background:`rgba(63, 185, 80, 0.15)`,border:`1px solid rgba(63, 185, 80, 0.4)`,color:c.green,fontSize:12,fontWeight:500,padding:`6px 14px`,borderRadius:6,cursor:m||!f.trim()?`default`:`pointer`,opacity:m||!f.trim()?.5:1,whiteSpace:`nowrap`,minHeight:32,transition:`all 0.15s ease`},children:m?`...`:`Add`})]}),o&&(0,E.jsx)(`div`,{style:{fontSize:12,color:c.red,marginTop:8},children:o})]}),(0,E.jsx)(`div`,{style:N,children:(0,E.jsxs)(`div`,{style:ge,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{style:d,children:`Default Department`}),(0,E.jsx)(`div`,{style:s,children:`Assigned to new employees if not specified`})]}),(0,E.jsxs)(`select`,{value:e?.orgDefaults?.defaultDepartment??``,onChange:n=>F(e,t,{defaultDepartment:n.target.value}),style:_e,children:[(0,E.jsx)(`option`,{value:``,children:`None`}),n.map(e=>(0,E.jsx)(`option`,{value:e,children:e},e))]})]})})]})}function ye({settings:e,onUpdateSettings:t}){let n=e?.orgDefaults;return(0,E.jsx)(y,{title:`Organization Defaults`,description:`Manage departments and set defaults for new employees.`,children:(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:10},children:[(0,E.jsx)(`div`,{style:N,children:(0,E.jsxs)(`div`,{style:ge,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{style:d,children:`Default Rank`}),(0,E.jsx)(`div`,{style:s,children:`Initial rank for newly created employees`})]}),(0,E.jsxs)(`select`,{value:n?.defaultRank??`employee`,onChange:n=>F(e,t,{defaultRank:n.target.value}),style:_e,children:[(0,E.jsx)(`option`,{value:`employee`,children:`Employee`}),(0,E.jsx)(`option`,{value:`senior`,children:`Senior`}),(0,E.jsx)(`option`,{value:`manager`,children:`Manager`}),(0,E.jsx)(`option`,{value:`executive`,children:`Executive`})]})]})}),(0,E.jsx)(ve,{settings:e,onUpdateSettings:t}),(0,E.jsx)(`div`,{style:N,children:(0,E.jsxs)(`div`,{style:ge,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{style:d,children:`Default Cost Limit (USD)`}),(0,E.jsx)(`div`,{style:s,children:`Per-session budget limit. 0 = unlimited.`})]}),(0,E.jsx)(`input`,{type:`number`,min:0,step:.5,value:n?.defaultMaxCostUsd??0,onChange:n=>F(e,t,{defaultMaxCostUsd:Math.max(0,Number(n.target.value))}),style:{...l,width:100,textAlign:`right`}})]})}),(0,E.jsxs)(`div`,{style:N,children:[(0,E.jsxs)(`div`,{style:{marginBottom:8},children:[(0,E.jsx)(`div`,{style:d,children:`Default MCP Access`}),(0,E.jsx)(`div`,{style:s,children:`Comma-separated list of MCP servers new employees can access`})]}),(0,E.jsx)(`input`,{type:`text`,value:(n?.defaultMcpServers??[`gateway`]).join(`, `),onChange:n=>{F(e,t,{defaultMcpServers:n.target.value.split(`,`).map(e=>e.trim()).filter(Boolean)})},placeholder:`e.g. gateway, slack`,style:l})]})]})})}function be({size:e=14,color:t=`currentColor`}){return(0,E.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 16 16`,fill:t,children:(0,E.jsx)(`path`,{d:`M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z`})})}function xe({size:e=14,color:t=`currentColor`}){return(0,E.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 100 100`,fill:`none`,children:[(0,E.jsx)(`path`,{d:`M6.017 4.313l55.333-4.087c6.797-.583 8.543-.19 12.817 2.917l17.663 12.443c2.913 2.14 3.883 2.723 3.883 5.053v68.243c0 4.277-1.553 6.807-6.99 7.193L24.467 99.967c-4.08.193-6.023-.39-8.16-3.113L3.3 79.94c-2.333-3.113-3.3-5.443-3.3-8.167V11.113c0-3.497 1.553-6.413 6.017-6.8z`,fill:t}),(0,E.jsx)(`path`,{d:`M61.35.227l-55.333 4.087C.573 4.7-.977 7.617-.977 11.113v60.66c0 2.723.967 5.053 3.3 8.167l12.99 16.913c2.137 2.723 4.08 3.307 8.16 3.113l64.257-3.89c5.433-.387 6.99-2.917 6.99-7.193V20.64c0-2.21-.82-2.873-3.277-4.627L75.753 3.57`,fill:t}),(0,E.jsx)(`path`,{d:`M28.45 26.32c0 2.723-.193 3.113-1.747 4.083L18.28 36.127c-1.553.97-2.327.583-2.327-1.553V16.18c0-2.527 1.163-3.887 3.3-4.08l9.107-.777c2.137-.193 3.09 1.163 3.09 3.5v11.497zm-3.69 53.963V40.597L62.08 38.07v39.3`,fill:`#fff`})]})}function Se({size:e=14,color:t=`currentColor`}){return(0,E.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 100 100`,fill:t,children:[(0,E.jsx)(`path`,{d:`M1.22541 61.5228c-.04261-.0915.00702-.1855.08037-.2555L49.2213 13.3509c.0697-.0697.1543-.1084.2441-.1048.104.0042.1936.0664.2496.1572l16.1758 26.2664-14.2742 14.2742L25.8428 80.6176c-.1015.1015-.2741.094-.356-.0171L1.22541 61.5228z`}),(0,E.jsx)(`path`,{d:`M75.4913 43.5228l-8.1697-13.2668L50.4444 47.1332l13.2668 8.1697L75.4913 43.5228z`}),(0,E.jsx)(`path`,{d:`M86.5913 48.5228l-6.1697-10.0168L67.7444 51.1832l10.0168 6.1697L86.5913 48.5228z`})]})}function Ce({size:e=14}){return(0,E.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,children:[(0,E.jsx)(`path`,{d:`M5.042 15.165a2.528 2.528 0 0 1-2.52 2.523A2.528 2.528 0 0 1 0 15.165a2.527 2.527 0 0 1 2.522-2.52h2.52v2.52z`,fill:`#E01E5A`}),(0,E.jsx)(`path`,{d:`M6.313 15.165a2.527 2.527 0 0 1 2.521-2.52 2.527 2.527 0 0 1 2.521 2.52v6.313A2.528 2.528 0 0 1 8.834 24a2.528 2.528 0 0 1-2.521-2.522v-6.313z`,fill:`#E01E5A`}),(0,E.jsx)(`path`,{d:`M8.834 5.042a2.528 2.528 0 0 1-2.521-2.52A2.528 2.528 0 0 1 8.834 0a2.528 2.528 0 0 1 2.521 2.522v2.52H8.834z`,fill:`#36C5F0`}),(0,E.jsx)(`path`,{d:`M8.834 6.313a2.528 2.528 0 0 1 2.521 2.521 2.528 2.528 0 0 1-2.521 2.521H2.522A2.528 2.528 0 0 1 0 8.834a2.528 2.528 0 0 1 2.522-2.521h6.312z`,fill:`#36C5F0`}),(0,E.jsx)(`path`,{d:`M18.956 8.834a2.528 2.528 0 0 1 2.522-2.521A2.528 2.528 0 0 1 24 8.834a2.528 2.528 0 0 1-2.522 2.521h-2.522V8.834z`,fill:`#2EB67D`}),(0,E.jsx)(`path`,{d:`M17.688 8.834a2.528 2.528 0 0 1-2.523 2.521 2.527 2.527 0 0 1-2.52-2.521V2.522A2.527 2.527 0 0 1 15.165 0a2.528 2.528 0 0 1 2.523 2.522v6.312z`,fill:`#2EB67D`}),(0,E.jsx)(`path`,{d:`M15.165 18.956a2.528 2.528 0 0 1 2.523 2.522A2.528 2.528 0 0 1 15.165 24a2.527 2.527 0 0 1-2.52-2.522v-2.522h2.52z`,fill:`#ECB22E`}),(0,E.jsx)(`path`,{d:`M15.165 17.688a2.527 2.527 0 0 1-2.52-2.523 2.526 2.526 0 0 1 2.52-2.52h6.313A2.527 2.527 0 0 1 24 15.165a2.528 2.528 0 0 1-2.522 2.523h-6.313z`,fill:`#ECB22E`})]})}var we=[{key:`github`,label:`GitHub`,icon:be,isActive:e=>!!e.connected,instruction:`Run gh auth login in your terminal`},{key:`notion`,label:`Notion`,icon:xe,isActive:e=>!!e.configured,instruction:`Add Notion MCP server to Claude`},{key:`linear`,label:`Linear`,icon:Se,isActive:e=>!!e.configured,instruction:`Add Linear MCP server to Claude`},{key:`slack`,label:`Slack`,icon:Ce,isActive:e=>!!e.configured,instruction:`Add Slack MCP server to Claude`}];function Te({integrations:e,onVerify:t,verifying:n}){return(0,E.jsxs)(y,{title:`Configured Integrations`,children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,marginBottom:12},children:[(0,E.jsxs)(`div`,{style:{fontSize:12,color:c.muted,lineHeight:1.5,flex:1,marginRight:12},children:[`Local integrations are detected automatically. To probe cloud-hosted MCP servers, click`,` `,(0,E.jsx)(`strong`,{style:{color:c.textSecondary},children:`Verify connections`}),` above.`]}),(0,E.jsx)(`button`,{onClick:t,disabled:n,style:{background:`rgba(210, 153, 34, 0.15)`,border:`1px solid rgba(210, 153, 34, 0.4)`,color:c.warning,fontSize:11,padding:`4px 12px`,borderRadius:6,cursor:n?`default`:`pointer`,opacity:n?.6:1,whiteSpace:`nowrap`,flexShrink:0,minHeight:32},children:n?`Verifying...`:`Verify connections`})]}),(0,E.jsx)(`div`,{style:{padding:`10px 14px`,background:`var(--color-subtle-bg)`,borderRadius:8,border:`1px solid ${c.border}`},children:(0,E.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8},children:we.map(t=>{let n=e?e[t.key]:void 0,r=n?t.isActive(n):!1,i=n?.verified===!0,a=n?.verifiedAt,o=t.icon;return(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,padding:`6px 0`,fontSize:13},children:[(0,E.jsx)(o,{size:15,color:i?c.green:r?c.warning:c.muted}),(0,E.jsx)(`span`,{style:{color:r||i?c.text:c.muted,fontWeight:500,minWidth:56},children:t.label}),i?(0,E.jsxs)(`span`,{style:{fontSize:11},children:[(0,E.jsx)(`span`,{style:{color:c.green},children:`✓ Connected`}),a&&(0,E.jsx)(`span`,{style:{color:c.muted,marginLeft:6},children:new Date(a).toLocaleDateString()})]}):r?(0,E.jsx)(`span`,{style:{color:c.warning,fontSize:11},children:`Installed — verify to check`}):(0,E.jsx)(`span`,{style:{color:c.muted,fontSize:11,opacity:.8},children:`Not detected — verify to check`})]},t.key)})})})]})}function Ee(e){return e==null}function De(e){return typeof e==`object`&&!!e}function Oe(e){return Array.isArray(e)?e:Ee(e)?[]:[e]}function ke(e,t){var n,r,i,a;if(t)for(a=Object.keys(t),n=0,r=a.length;n<r;n+=1)i=a[n],e[i]=t[i];return e}function Ae(e,t){var n=``,r;for(r=0;r<t;r+=1)n+=e;return n}function je(e){return e===0&&1/e==-1/0}var I={isNothing:Ee,isObject:De,toArray:Oe,repeat:Ae,isNegativeZero:je,extend:ke};function Me(e,t){var n=``,r=e.reason||`(unknown reason)`;return e.mark?(e.mark.name&&(n+=`in "`+e.mark.name+`" `),n+=`(`+(e.mark.line+1)+`:`+(e.mark.column+1)+`)`,!t&&e.mark.snippet&&(n+=`
|
|
2
2
|
|
|
3
3
|
`+e.mark.snippet),r+` `+n):r}function Ne(e,t){Error.call(this),this.name=`YAMLException`,this.reason=e,this.mark=t,this.message=Me(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=Error().stack||``}Ne.prototype=Object.create(Error.prototype),Ne.prototype.constructor=Ne,Ne.prototype.toString=function(e){return this.name+`: `+Me(this,e)};var L=Ne;function Pe(e,t,n,r,i){var a=``,o=``,s=Math.floor(i/2)-1;return r-t>s&&(a=` ... `,t=r-s+a.length),n-r>s&&(o=` ...`,n=r+s-o.length),{str:a+e.slice(t,n).replace(/\t/g,`→`)+o,pos:r-t+a.length}}function Fe(e,t){return I.repeat(` `,t-e.length)+e}function Ie(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||=79,typeof t.indent!=`number`&&(t.indent=1),typeof t.linesBefore!=`number`&&(t.linesBefore=3),typeof t.linesAfter!=`number`&&(t.linesAfter=2);for(var n=/\r?\n|\r|\0/g,r=[0],i=[],a,o=-1;a=n.exec(e.buffer);)i.push(a.index),r.push(a.index+a[0].length),e.position<=a.index&&o<0&&(o=r.length-2);o<0&&(o=r.length-1);var s=``,c,l,u=Math.min(e.line+t.linesAfter,i.length).toString().length,d=t.maxLength-(t.indent+u+3);for(c=1;c<=t.linesBefore&&!(o-c<0);c++)l=Pe(e.buffer,r[o-c],i[o-c],e.position-(r[o]-r[o-c]),d),s=I.repeat(` `,t.indent)+Fe((e.line-c+1).toString(),u)+` | `+l.str+`
|
|
4
4
|
`+s;for(l=Pe(e.buffer,r[o],i[o],e.position,d),s+=I.repeat(` `,t.indent)+Fe((e.line+1).toString(),u)+` | `+l.str+`
|
|
@@ -29,7 +29,7 @@ import{n as e,s as t,t as n}from"./jsx-runtime-Bq3x7umQ.js";import{c as r,r as i
|
|
|
29
29
|
`+e.slice(i,a),i=a+1),o=s;return c+=`
|
|
30
30
|
`,e.length-i>t&&o>i?c+=e.slice(i,o)+`
|
|
31
31
|
`+e.slice(o+1):c+=e.slice(i),c.slice(1)}function Br(e){for(var t=``,n=0,r,i=0;i<e.length;n>=65536?i+=2:i++)n=Or(e,i),r=X[n],!r&&Cr(n)?(t+=e[i],n>=65536&&(t+=e[i+1])):t+=r||hr(n);return t}function Vr(e,t,n){var r=``,i=e.tag,a,o,s;for(a=0,o=n.length;a<o;a+=1)s=n[a],e.replacer&&(s=e.replacer.call(n,String(a),s)),(Q(e,t,s,!1,!1)||s===void 0&&Q(e,t,null,!1,!1))&&(r!==``&&(r+=`,`+(e.condenseFlow?``:` `)),r+=e.dump);e.tag=i,e.dump=`[`+r+`]`}function Hr(e,t,n,r){var i=``,a=e.tag,o,s,c;for(o=0,s=n.length;o<s;o+=1)c=n[o],e.replacer&&(c=e.replacer.call(n,String(o),c)),(Q(e,t+1,c,!0,!0,!1,!0)||c===void 0&&Q(e,t+1,null,!0,!0,!1,!0))&&((!r||i!==``)&&(i+=br(e,t)),e.dump&&Un===e.dump.charCodeAt(0)?i+=`-`:i+=`- `,i+=e.dump);e.tag=a,e.dump=i||`[]`}function Ur(e,t,n){var r=``,i=e.tag,a=Object.keys(n),o,s,c,l,u;for(o=0,s=a.length;o<s;o+=1)u=``,r!==``&&(u+=`, `),e.condenseFlow&&(u+=`"`),c=a[o],l=n[c],e.replacer&&(l=e.replacer.call(n,c,l)),Q(e,t,c,!1,!1)&&(e.dump.length>1024&&(u+=`? `),u+=e.dump+(e.condenseFlow?`"`:``)+`:`+(e.condenseFlow?``:` `),Q(e,t,l,!1,!1)&&(u+=e.dump,r+=u));e.tag=i,e.dump=`{`+r+`}`}function Wr(e,t,n,r){var i=``,a=e.tag,o=Object.keys(n),s,c,l,u,d,f;if(e.sortKeys===!0)o.sort();else if(typeof e.sortKeys==`function`)o.sort(e.sortKeys);else if(e.sortKeys)throw new L(`sortKeys must be a boolean or a function`);for(s=0,c=o.length;s<c;s+=1)f=``,(!r||i!==``)&&(f+=br(e,t)),l=o[s],u=n[l],e.replacer&&(u=e.replacer.call(n,l,u)),Q(e,t+1,l,!0,!0,!0)&&(d=e.tag!==null&&e.tag!==`?`||e.dump&&e.dump.length>1024,d&&(e.dump&&Un===e.dump.charCodeAt(0)?f+=`?`:f+=`? `),f+=e.dump,d&&(f+=br(e,t)),Q(e,t+1,u,!0,d)&&(e.dump&&Un===e.dump.charCodeAt(0)?f+=`:`:f+=`: `,f+=e.dump,i+=f));e.tag=a,e.dump=i||`{}`}function Gr(e,t,n){var r,i=n?e.explicitTypes:e.implicitTypes,a,o,s,c;for(a=0,o=i.length;a<o;a+=1)if(s=i[a],(s.instanceOf||s.predicate)&&(!s.instanceOf||typeof t==`object`&&t instanceof s.instanceOf)&&(!s.predicate||s.predicate(t))){if(n?s.multi&&s.representName?e.tag=s.representName(t):e.tag=s.tag:e.tag=`?`,s.represent){if(c=e.styleMap[s.tag]||s.defaultStyle,zn.call(s.represent)===`[object Function]`)r=s.represent(t,c);else if(Bn.call(s.represent,c))r=s.represent[c](t,c);else throw new L(`!<`+s.tag+`> tag resolver accepts not "`+c+`" style`);e.dump=r}return!0}return!1}function Q(e,t,n,r,i,a,o){e.tag=null,e.dump=n,Gr(e,n,!1)||Gr(e,n,!0);var s=zn.call(e.dump),c=r,l;r&&=e.flowLevel<0||e.flowLevel>t;var u=s===`[object Object]`||s===`[object Array]`,d,f;if(u&&(d=e.duplicates.indexOf(n),f=d!==-1),(e.tag!==null&&e.tag!==`?`||f||e.indent!==2&&t>0)&&(i=!1),f&&e.usedDuplicates[d])e.dump=`*ref_`+d;else{if(u&&f&&!e.usedDuplicates[d]&&(e.usedDuplicates[d]=!0),s===`[object Object]`)r&&Object.keys(e.dump).length!==0?(Wr(e,t,e.dump,i),f&&(e.dump=`&ref_`+d+e.dump)):(Ur(e,t,e.dump),f&&(e.dump=`&ref_`+d+` `+e.dump));else if(s===`[object Array]`)r&&e.dump.length!==0?(e.noArrayIndent&&!o&&t>0?Hr(e,t-1,e.dump,i):Hr(e,t,e.dump,i),f&&(e.dump=`&ref_`+d+e.dump)):(Vr(e,t,e.dump),f&&(e.dump=`&ref_`+d+` `+e.dump));else if(s===`[object String]`)e.tag!==`?`&&Fr(e,e.dump,t,a,c);else if(s===`[object Undefined]`)return!1;else{if(e.skipInvalid)return!1;throw new L(`unacceptable kind of an object to dump `+s)}e.tag!==null&&e.tag!==`?`&&(l=encodeURI(e.tag[0]===`!`?e.tag.slice(1):e.tag).replace(/!/g,`%21`),l=e.tag[0]===`!`?`!`+l:l.slice(0,18)===`tag:yaml.org,2002:`?`!!`+l.slice(18):`!<`+l+`>`,e.dump=l+` `+e.dump)}return!0}function Kr(e,t){var n=[],r=[],i,a;for(qr(e,n,r),i=0,a=r.length;i<a;i+=1)t.duplicates.push(n[r[i]]);t.usedDuplicates=Array(a)}function qr(e,t,n){var r,i,a;if(typeof e==`object`&&e)if(i=t.indexOf(e),i!==-1)n.indexOf(i)===-1&&n.push(i);else if(t.push(e),Array.isArray(e))for(i=0,a=e.length;i<a;i+=1)qr(e[i],t,n);else for(r=Object.keys(e),i=0,a=r.length;i<a;i+=1)qr(e[r[i]],t,n)}function Jr(e,t){t||={};var n=new vr(t);n.noRefs||Kr(e,n);var r=e;return n.replacer&&(r=n.replacer.call({"":r},``,r)),Q(n,0,r,!0,!0)?n.dump+`
|
|
32
|
-
`:``}var Yr={dump:Jr};function Xr(e,t){return function(){throw Error(`Function yaml.`+e+` is removed in js-yaml 4. Use yaml.`+t+` instead, which is now safe by default.`)}}var Zr={Type:R,Schema:Ge,FAILSAFE_SCHEMA:Ye,JSON_SCHEMA:vt,CORE_SCHEMA:yt,DEFAULT_SCHEMA:qt,load:Rn.load,loadAll:Rn.loadAll,dump:Yr.dump,YAMLException:L,types:{binary:Nt,float:_t,map:Je,null:$e,pairs:Ht,set:Kt,timestamp:Tt,bool:rt,int:ut,merge:Dt,omap:Rt,seq:qe,str:Ke},safeLoad:Xr(`safeLoad`,`load`),safeLoadAll:Xr(`safeLoadAll`,`loadAll`),safeDump:Xr(`safeDump`,`dump`)},Qr={name:`name`,light:`light`,backgroundColor:`background-color`,primaryColor:`primary-color`,positiveColor:`positive-color`,negativeColor:`negative-color`,contrastMultiplier:`contrast-multiplier`,textSaturationMultiplier:`text-saturation-multiplier`,customCSS:`custom-css`},$r=(()=>{let e={};for(let[t,n]of Object.entries(Qr))e[n]=t;return e})();function ei(e){let t;try{t=Zr.load(e)}catch(e){return{ok:!1,error:e instanceof Error?e.message:`Invalid YAML`}}if(!t||typeof t!=`object`)return{ok:!1,error:`Expected YAML object`};let n=t.theme??t;if(!n||typeof n!=`object`)return{ok:!1,error:"Missing `theme:` object"};let r={};for(let[e,t]of Object.entries(n)){let n=$r[e];n&&(n===`light`&&typeof t==`boolean`?r.light=t:((n===`contrastMultiplier`||n===`textSaturationMultiplier`)&&typeof t==`number`&&Number.isFinite(t)||typeof t==`string`)&&(r[n]=t))}return{ok:!0,theme:r}}function $(e){let t={};for(let[n,r]of Object.entries(Qr)){let i=e[n];n===`customCSS`&&i===``||(t[r]=i)}return Zr.dump({theme:t},{lineWidth:-1,noRefs:!0})}var ti=`Custom`;function ni(e){let[t,n,r]=e.trim().split(/\s+/).map(e=>Number(e));return{h:Number.isFinite(t)?t:0,sat:Number.isFinite(n)?n:0,l:Number.isFinite(r)?r:0}}function ri(e,t,n){return`${Math.round(e)} ${Math.round(t)} ${Math.round(n)}`}function ii(e){let{h:t,sat:n,l:r}=ni(e);return`hsl(${t} ${n}% ${r}%)`}function ai({preset:e,active:t,onClick:n,onDelete:r}){return(0,E.jsxs)(`div`,{style:{position:`relative`,background:t?`var(--color-primary-soft)`:`var(--color-bg-raised)`,border:`1px solid ${t?`var(--color-primary)`:`var(--color-border)`}`,borderRadius:`var(--radius-lg)`,transition:`border-color 0.15s, background 0.15s`},children:[(0,E.jsxs)(`button`,{onClick:n,style:{width:`100%`,background:`transparent`,border:`none`,borderRadius:`var(--radius-lg)`,padding:10,cursor:`pointer`,textAlign:`left`,display:`flex`,flexDirection:`column`,gap:8,minHeight:60,color:`var(--color-text)`,fontFamily:`inherit`},children:[(0,E.jsx)(`div`,{style:{display:`flex`,gap:4},children:[e.backgroundColor,e.primaryColor,e.positiveColor,e.negativeColor].map((e,t)=>(0,E.jsx)(`span`,{style:{width:18,height:18,borderRadius:`var(--radius-sm)`,background:ii(e),border:`1px solid var(--color-border)`}},t))}),(0,E.jsx)(`div`,{style:{fontSize:12,fontWeight:t?600:500,paddingRight:r?18:0},children:e.name})]}),r&&(0,E.jsx)(`button`,{onClick:e=>{e.stopPropagation(),r()},"aria-label":`Delete ${e.name}`,title:`Delete custom theme`,style:{position:`absolute`,top:6,right:6,width:18,height:18,display:`flex`,alignItems:`center`,justifyContent:`center`,background:`transparent`,border:`none`,color:`var(--color-text-muted)`,cursor:`pointer`,fontSize:14,lineHeight:1,padding:0,borderRadius:`var(--radius-sm)`},children:`×`})]})}function oi({label:e,value:t,onChange:n,min:r,max:i,step:a,hint:o}){return(0,E.jsx)(m,{padding:`sm`,style:{marginBottom:8},children:(0,E.jsxs)(v,{direction:`row`,align:`center`,justify:`between`,gap:12,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{style:{fontSize:13,color:`var(--color-text)`,fontWeight:500},children:e}),o&&(0,E.jsx)(`div`,{style:{fontSize:11,color:`var(--color-text-muted)`,marginTop:2},children:o})]}),(0,E.jsxs)(v,{direction:`row`,align:`center`,gap:8,children:[(0,E.jsx)(`input`,{type:`range`,min:r,max:i,step:a,value:t,onChange:e=>n(Number(e.target.value)),style:{width:140}}),(0,E.jsx)(`span`,{style:{fontSize:12,color:`var(--color-text-muted)`,fontVariantNumeric:`tabular-nums`,minWidth:32,textAlign:`right`},children:t.toFixed(2)})]})]})})}function si({label:e,value:t,max:n,onChange:r}){return(0,E.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:6,fontSize:11,color:`var(--color-text-muted)`},children:[(0,E.jsx)(`span`,{style:{width:10,display:`inline-block`},children:e}),(0,E.jsx)(`input`,{type:`range`,min:0,max:n,step:1,value:t,onChange:e=>r(Number(e.target.value)),style:{width:110}}),(0,E.jsx)(`span`,{style:{fontVariantNumeric:`tabular-nums`,minWidth:26,textAlign:`right`,color:`var(--color-text)`},children:Math.round(t)})]})}function ci({label:e,value:t,onChange:n}){let{h:r,sat:i,l:a}=ni(t);function o(e){n(ri(e.h??r,e.sat??i,e.l??a))}return(0,E.jsx)(m,{padding:`sm`,style:{marginBottom:8},children:(0,E.jsxs)(v,{direction:`row`,align:`center`,justify:`between`,gap:16,wrap:!0,children:[(0,E.jsxs)(v,{direction:`row`,align:`center`,gap:10,style:{minWidth:130},children:[(0,E.jsx)(`span`,{style:{width:22,height:22,borderRadius:`var(--radius-sm)`,background:ii(t),border:`1px solid var(--color-border)`,flexShrink:0}}),(0,E.jsx)(`div`,{style:{fontSize:13,color:`var(--color-text)`,fontWeight:500},children:e})]}),(0,E.jsxs)(v,{direction:`column`,gap:4,children:[(0,E.jsx)(si,{label:`H`,value:r,max:360,onChange:e=>o({h:e})}),(0,E.jsx)(si,{label:`S`,value:i,max:100,onChange:e=>o({sat:e})}),(0,E.jsx)(si,{label:`L`,value:a,max:100,onChange:e=>o({l:e})})]})]})})}function li({label:e,checked:t,onChange:n,hint:r}){return(0,E.jsx)(m,{padding:`sm`,style:{marginBottom:8},children:(0,E.jsxs)(v,{direction:`row`,align:`center`,justify:`between`,gap:12,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{style:{fontSize:13,color:`var(--color-text)`,fontWeight:500},children:e}),r&&(0,E.jsx)(`div`,{style:{fontSize:11,color:`var(--color-text-muted)`,marginTop:2},children:r})]}),(0,E.jsx)(`input`,{type:`checkbox`,checked:t,onChange:e=>n(e.target.checked),style:{width:18,height:18,cursor:`pointer`}})]})})}function ui({settings:e,onUpdateSettings:t}){let n=e?.appearance??w,r=e?.themePresets??[],[i,a]=(0,T.useState)(n),[o,s]=(0,T.useState)(()=>$(n)),[c,l]=(0,T.useState)(null),[u,d]=(0,T.useState)(null),f=new Set(ie.map(e=>e.name));function p(e,t){return t.name===e.name?!0:!f.has(e.name)&&t.name===ti?e.backgroundColor===t.backgroundColor&&e.primaryColor===t.primaryColor&&e.positiveColor===t.positiveColor&&e.negativeColor===t.negativeColor&&e.light===t.light:!1}let m=(0,T.useRef)(JSON.stringify(n)),h=(0,T.useRef)(null);(0,T.useEffect)(()=>{if(!e?.appearance)return;let t=JSON.stringify(e.appearance);t!==m.current&&(m.current=t,a(e.appearance),s($(e.appearance)))},[e?.appearance]),(0,T.useEffect)(()=>(ae(i),h.current&&window.clearTimeout(h.current),h.current=window.setTimeout(()=>{m.current=JSON.stringify(i),t({appearance:i})},400),()=>{h.current&&window.clearTimeout(h.current)}),[i,t]);function y(e){a(t=>({...t,...e,name:ti}))}function b(e){a(e),s($(e)),l(null)}function x(){let e=ei(o);if(!e.ok){l(e.error);return}l(null),a(t=>({...t,...e.theme,name:e.theme.name??ti}))}function ee(){let e=$(i);if(s(e),l(null),!navigator.clipboard){d(`Clipboard API unavailable (use HTTPS or localhost).`);return}navigator.clipboard.writeText(e).then(()=>d(`Copied to clipboard`)).catch(()=>d(`Copy failed`))}function C(){let e=window.prompt(`Name this theme:`,i.name===ti?``:i.name);if(e===null)return;let n=e.trim().slice(0,64);if(!n)return;if(f.has(n)){window.alert(`"${n}" is a built-in preset name. Pick a different name.`);return}let o={...i,name:n};t({themePresets:r.filter(e=>e.name!==n).concat(o),appearance:o}),a(o),s($(o))}function te(e){if(!window.confirm(`Delete "${e}"?`))return;let n={themePresets:r.filter(t=>t.name!==e)};i.name===e&&(n.appearance=w,a(w),s($(w))),t(n)}return(0,T.useEffect)(()=>{if(!u)return;let e=window.setTimeout(()=>d(null),2e3);return()=>window.clearTimeout(e)},[u]),(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(S,{title:`Theme Presets`,description:`Pick a theme or tune your own. Colors are HSL triplets; multipliers scale text contrast and saturation.`,children:[(0,E.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fit, minmax(180px, 1fr))`,gap:8},children:[ie.map(e=>(0,E.jsx)(ai,{preset:e,active:p(e,i),onClick:()=>b(e)},e.name)),r.map(e=>(0,E.jsx)(ai,{preset:e,active:p(e,i),onClick:()=>b(e),onDelete:()=>te(e.name)},`user:${e.name}`))]}),(0,E.jsxs)(v,{direction:`row`,align:`center`,gap:8,style:{marginTop:10},children:[(0,E.jsx)(_,{size:`sm`,onClick:C,children:`Save current as preset…`}),(0,E.jsx)(`span`,{style:{fontSize:11,color:`var(--color-text-muted)`},children:r.length>0?`${r.length} custom ${r.length===1?`theme`:`themes`} saved`:`Tune the sliders below then save to pin your favorite.`})]})]}),(0,E.jsx)(S,{title:`Mode`,children:(0,E.jsx)(li,{label:`Light mode`,checked:i.light,onChange:e=>y({light:e}),hint:`Inverts surface-lightness derivation so raised surfaces step down rather than up.`})}),(0,E.jsxs)(S,{title:`Colors`,description:`HSL values (H 0–360, S and L 0–100). Live swatches update as you drag.`,children:[(0,E.jsx)(ci,{label:`Background`,value:i.backgroundColor,onChange:e=>y({backgroundColor:e})}),(0,E.jsx)(ci,{label:`Primary`,value:i.primaryColor,onChange:e=>y({primaryColor:e})}),(0,E.jsx)(ci,{label:`Positive`,value:i.positiveColor,onChange:e=>y({positiveColor:e})}),(0,E.jsx)(ci,{label:`Negative`,value:i.negativeColor,onChange:e=>y({negativeColor:e})})]}),(0,E.jsxs)(S,{title:`Adjustments`,description:`Scale text contrast and saturation against the background. 1.0 = neutral.`,children:[(0,E.jsx)(oi,{label:`Contrast`,value:i.contrastMultiplier,onChange:e=>y({contrastMultiplier:e}),min:.5,max:2,step:.05}),(0,E.jsx)(oi,{label:`Text saturation`,value:i.textSaturationMultiplier,onChange:e=>y({textSaturationMultiplier:e}),min:.5,max:2,step:.05})]}),(0,E.jsx)(S,{title:`Custom CSS`,description:`Injected as a <style> tag at the end of <head>. Max 16 KB. Use for tweaks the tokens don't expose.`,children:(0,E.jsx)(g,{value:i.customCSS,onChange:e=>y({customCSS:e.target.value}),placeholder:`/* Your overrides here. Try:\\n.page-content-frame { max-width: 1400px; }\\n*/`,compact:!0,style:{minHeight:120}})}),(0,E.jsxs)(S,{title:`Import / Export YAML`,description:`Paste a theme YAML to try it; use Export to share your current theme.`,children:[(0,E.jsx)(g,{value:o,onChange:e=>s(e.target.value),compact:!0,style:{minHeight:140,borderColor:c?`var(--color-negative)`:void 0}}),c&&(0,E.jsx)(`div`,{style:{fontSize:12,color:`var(--color-negative)`,marginTop:6},children:c}),(0,E.jsxs)(v,{direction:`row`,align:`center`,gap:8,style:{marginTop:8},children:[(0,E.jsx)(_,{size:`sm`,onClick:x,children:`Import`}),(0,E.jsx)(_,{size:`sm`,onClick:ee,children:`Export + Copy`}),u&&(0,E.jsx)(`span`,{style:{fontSize:12,color:`var(--color-text-muted)`},children:u})]})]})]})}function di(e){let t=Math.round(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m ${t%60}s`:`${Math.floor(n/60)}h ${n%60}m`}function fi(e){switch(e){case`claude-binary`:return`Claude binary on PATH`;case`teamwork-home-writable`:return`~/.teamwork is writable`;case`sessions-db-readable`:return`sessions.db readable`;case`memory-db-readable`:return`memory.db readable`;case`jobs-dir`:return`Jobs directory`;case`org-scanned`:return`Organization scanned`;default:return e}}function pi(){let[e,t]=(0,T.useState)({status:`loading`}),n=(0,T.useCallback)(async()=>{t({status:`loading`});try{let e=await fetch(`/api/welcome`);if(!e.ok)throw Error(`HTTP ${e.status}`);t({status:`loaded`,data:await e.json(),fetchedAt:Date.now()})}catch(e){t({status:`error`,message:e instanceof Error?e.message:`unknown error`})}},[]);return(0,T.useEffect)(()=>{n()},[n]),(0,E.jsx)(S,{title:`Diagnostics`,description:`Startup health of the gateway — useful on first run and when something feels off.`,children:(0,E.jsxs)(`div`,{style:o,children:[e.status===`loading`&&(0,E.jsx)(`div`,{style:{...s,padding:12},children:`Checking…`}),e.status===`error`&&(0,E.jsxs)(`div`,{style:{padding:12},children:[(0,E.jsxs)(`div`,{style:{color:c.red,fontSize:13},children:[`Failed to load diagnostics: `,e.message]}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>void n(),style:{marginTop:12,minHeight:44,padding:`0 14px`,background:`var(--color-bg-raised)`,border:`1px solid ${c.border}`,borderRadius:6,color:c.text,fontSize:13,cursor:`pointer`},children:`Retry`})]}),e.status===`loaded`&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`12px 14px`,borderBottom:`1px solid ${c.border}`,gap:12,flexWrap:`wrap`},children:[(0,E.jsxs)(`div`,{style:{minWidth:0,flex:1},children:[(0,E.jsx)(`div`,{style:{fontSize:14,fontWeight:600,color:e.data.ok?c.green:c.red},children:e.data.ok?`All checks passing`:`One or more checks failing`}),(0,E.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:`0 10px`,fontSize:12,color:c.muted,marginTop:4},children:[(0,E.jsxs)(`span`,{children:[`v`,e.data.version]}),(0,E.jsxs)(`span`,{children:[`port `,e.data.port]}),(0,E.jsxs)(`span`,{children:[`uptime `,di(e.data.uptimeMs)]}),(0,E.jsxs)(`span`,{children:[e.data.jobCount,` job`,e.data.jobCount===1?``:`s`]}),(0,E.jsxs)(`span`,{children:[e.data.employeeCount,` employee`,e.data.employeeCount===1?``:`s`]})]})]}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>void n(),style:{minHeight:44,padding:`0 14px`,background:`var(--color-bg-raised)`,border:`1px solid ${c.border}`,borderRadius:6,color:c.text,fontSize:13,cursor:`pointer`},children:`Refresh`})]}),(0,E.jsx)(`ul`,{style:{listStyle:`none`,margin:0,padding:0},children:e.data.checks.map(e=>(0,E.jsxs)(`li`,{style:{display:`flex`,alignItems:`flex-start`,gap:10,padding:`10px 14px`,borderBottom:`1px solid ${c.border}`,fontSize:13},children:[(0,E.jsx)(`span`,{"aria-label":e.ok?`passing`:`failing`,style:{minWidth:18,color:e.ok?c.green:c.red,fontWeight:700},children:e.ok?`✓`:`✗`}),(0,E.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,E.jsx)(`div`,{style:{color:c.text},children:fi(e.name)}),e.detail&&(0,E.jsx)(`div`,{style:{fontSize:12,color:c.muted,marginTop:2,overflowWrap:`anywhere`,hyphens:`none`},children:e.detail})]})]},e.name))}),(0,E.jsxs)(`div`,{style:{padding:`10px 14px`,fontSize:11,color:c.muted},children:[`TEAMWORK_HOME: `,(0,E.jsx)(`span`,{style:{fontFamily:`ui-monospace, monospace`},children:e.data.teamworkHome})]})]})]})})}var mi=[{value:216e5,label:`6 hours`},{value:432e5,label:`12 hours`},{value:864e5,label:`24 hours (default)`},{value:1728e5,label:`48 hours`}];function hi(e,t,n){t({memorySteward:{...e?.memorySteward??{enabled:!0,scheduleMs:864e5},...n}})}function gi({settings:e,onUpdateSettings:t}){let n=e?.memorySteward??{enabled:!0,scheduleMs:864e5};return(0,E.jsx)(S,{title:`Memory Steward`,description:`Background process that scans memory files for hygiene issues and queues synthesis proposals.`,children:(0,E.jsxs)(ce,{children:[(0,E.jsx)(le,{label:`Enabled`,hint:`Run the steward on the schedule below.`,children:(0,E.jsx)(`input`,{type:`checkbox`,checked:n.enabled,onChange:n=>hi(e,t,{enabled:n.target.checked}),"aria-label":`Enable memory steward`})}),(0,E.jsx)(le,{label:`Schedule`,hint:`How often the steward scans all memory directories.`,divider:!0,children:(0,E.jsx)(h,{compact:!0,value:n.scheduleMs,disabled:!n.enabled,onChange:n=>hi(e,t,{scheduleMs:Number(n.target.value)}),children:mi.map(e=>(0,E.jsx)(`option`,{value:e.value,children:e.label},e.value))})})]})})}var _i=[{value:60,label:`1 minute`},{value:120,label:`2 minutes`},{value:300,label:`5 minutes (default)`},{value:600,label:`10 minutes`},{value:1800,label:`30 minutes`}],vi=5;function yi(e,t,n){t({prAutoFix:{...e?.prAutoFix??{enabled:!0,intervalSec:300,model:`claude-sonnet-4-6`,maxAttempts:vi},...n}})}function bi({settings:e,onUpdateSettings:t}){let n=e?.prAutoFix??{enabled:!0,intervalSec:300,model:`claude-sonnet-4-6`,maxAttempts:vi},r=n.maxAttempts??vi;return(0,E.jsx)(S,{title:`PR Auto-Fix`,description:`Automatically update branches that fall behind main, and attempt to resolve merge conflicts via a Claude session.`,children:(0,E.jsxs)(ce,{children:[(0,E.jsx)(le,{label:`Enabled`,hint:`Watch open PRs and fix BEHIND or CONFLICTING states automatically.`,children:(0,E.jsx)(`input`,{type:`checkbox`,checked:n.enabled,onChange:n=>yi(e,t,{enabled:n.target.checked}),"aria-label":`Enable PR auto-fix`})}),(0,E.jsx)(le,{label:`Poll interval`,hint:`How often to check PR states.`,divider:!0,children:(0,E.jsx)(h,{compact:!0,value:n.intervalSec,disabled:!n.enabled,onChange:n=>yi(e,t,{intervalSec:Number(n.target.value)}),children:_i.map(e=>(0,E.jsx)(`option`,{value:e.value,children:e.label},e.value))})}),(0,E.jsx)(le,{label:`Model`,hint:`Claude model used for rebase and CI-fix sessions.`,divider:!0,children:(0,E.jsx)(h,{compact:!0,value:n.model??`claude-sonnet-4-6`,disabled:!n.enabled,onChange:n=>yi(e,t,{model:n.target.value}),children:p.map(e=>(0,E.jsx)(`option`,{value:e,children:e},e))})}),(0,E.jsx)(le,{label:`Max attempts per push`,hint:`How many fix attempts before pausing and asking for input. A successful push resets the counter.`,divider:!0,children:(0,E.jsx)(h,{compact:!0,value:r,disabled:!n.enabled,onChange:n=>yi(e,t,{maxAttempts:Number(n.target.value)}),children:[1,2,3,4,5,6,7,8,9,10].map(e=>(0,E.jsxs)(`option`,{value:e,children:[e,e===vi?` (default)`:``]},e))})})]})})}var xi={gatewayPasses:[],jobs:[],employees:[]};async function Si(){let e=await fetch(`/api/spawn-profiles/usage`,{credentials:`include`});if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}function Ci(){let e=se(),[t,n]=(0,T.useState)(null),[r,a]=(0,T.useState)(null),[o,s]=(0,T.useState)(0);if(i(f,()=>s(e=>e+1)),(0,T.useEffect)(()=>{let e=!1;return Si().then(t=>{e||(n(t),a(null))}).catch(t=>{e||a(t instanceof Error?t.message:String(t))}),()=>{e=!0}},[o]),e.status===`loading`)return(0,E.jsx)(S,{title:`Spawn Profiles`,children:(0,E.jsx)(`div`,{style:{color:c.muted,fontSize:13},children:`Loading…`})});if(e.status===`error`)return(0,E.jsx)(S,{title:`Spawn Profiles`,children:(0,E.jsxs)(`div`,{style:{color:`var(--color-danger, #ff6b6b)`,fontSize:13},children:[`Failed to load profiles: `,e.error]})});let l=e.status===`ok`?e.data:[];return(0,E.jsxs)(S,{title:`Spawn Profiles`,description:`Each gateway-spawned Claude session can opt into a named SpawnProfile that sets MCP servers, enabled marketplace plugins, claude.ai opt-in, and whether user-folder settings are suppressed. Built-in profiles ship with the gateway; user overrides at ~/.teamwork/profiles/<name>.json win when present.`,children:[r&&(0,E.jsxs)(`div`,{style:{fontSize:12,color:`var(--color-danger, #ff6b6b)`,marginBottom:12},children:[`Failed to load usage map: `,r]}),l.length===0&&(0,E.jsx)(`div`,{style:{color:c.muted,fontSize:13},children:`No profiles found. (This is unexpected — built-ins should always be present.)`}),(0,E.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:24},children:l.map(e=>(0,E.jsx)(wi,{name:e.name,usage:t?.[e.name]??xi},e.name))})]})}function wi({name:e,usage:t}){let n=t.gatewayPasses.length===0&&t.jobs.length===0&&t.employees.length===0;return(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{style:{fontSize:11,fontWeight:600,textTransform:`uppercase`,letterSpacing:.5,color:c.muted,marginBottom:6},children:`Used by`}),(0,E.jsxs)(`div`,{style:{fontSize:12,color:n?c.muted:`var(--color-text)`,marginBottom:10,lineHeight:1.6},children:[n&&(0,E.jsx)(`span`,{children:`No active consumers.`}),!n&&(0,E.jsxs)(`ul`,{style:{margin:0,padding:`0 0 0 18px`},children:[t.gatewayPasses.map(e=>(0,E.jsxs)(`li`,{children:[(0,E.jsx)(`span`,{children:e.label}),(0,E.jsxs)(`span`,{style:{color:c.muted,marginLeft:6},children:[`(`,e.file,`)`]})]},`pass-${e.id}`)),t.jobs.map(e=>(0,E.jsxs)(`li`,{children:[`Job: `,(0,E.jsx)(`a`,{href:`#/cron?job=${encodeURIComponent(e.id)}`,style:{color:`var(--color-primary)`,textDecoration:`none`},children:e.name}),(0,E.jsxs)(`span`,{style:{color:c.muted,marginLeft:6},children:[`(`,e.id,`)`]})]},`job-${e.id}`)),t.employees.map(e=>(0,E.jsxs)(`li`,{children:[`Employee: `,(0,E.jsx)(`a`,{href:`#/org?employee=${encodeURIComponent(e.name)}`,style:{color:`var(--color-primary)`,textDecoration:`none`},children:e.displayName??e.name}),(0,E.jsxs)(`span`,{style:{color:c.muted,marginLeft:6},children:[`(`,e.department,`)`]})]},`emp-${e.name}`))]})]}),(0,E.jsx)(oe,{name:e,defaultExpanded:!0})]})}function Ti(){let[e,t]=(0,T.useState)(null);return(0,T.useEffect)(()=>{let e=!1;return(async()=>{try{let n=await fetch(`/api/auth/whoami`,{credentials:`include`});if(!n.ok)return;let r=await n.json();if(e)return;t({authRequired:r.authRequired,exp:r.exp,issuedAt:r.issuedAt,daysRemaining:r.daysRemaining??0})}catch{}})(),()=>{e=!0}},[]),e}function Ei(){return{display:`flex`,alignItems:`center`,gap:10,minHeight:44,padding:`0 12px`,borderRadius:8,border:`1px solid transparent`,background:`transparent`,color:c.muted,fontSize:13,fontWeight:500,cursor:`pointer`,fontFamily:`inherit`,transition:`background 0.15s, color 0.15s, border-color 0.15s`}}function Di(e,t){let n=e.currentTarget;t?(n.style.background=`rgba(255, 107, 107, 0.08)`,n.style.color=`var(--color-danger, #ff6b6b)`,n.style.borderColor=`var(--color-danger, #ff6b6b)`):(n.style.background=`transparent`,n.style.color=c.muted,n.style.borderColor=`transparent`)}function Oi(){let e=Ti(),[t,n]=(0,T.useState)(null);async function i(e){n(null),e===`everywhere`?await r():await a(),window.location.reload()}let o=e?.authRequired===!0,s=o?`Signed in · session expires in ${e.daysRemaining} day${e.daysRemaining===1?``:`s`}`:``,l=t===`everywhere`?`This invalidates every session you've started from any device. Other browsers and devices will also be signed out. You'll need your AUTH_TOKEN to sign in again.`:`You'll need your AUTH_TOKEN to sign back in. This only signs out this browser — other devices stay signed in.`,u=t===`everywhere`?`Sign out everywhere`:`Sign out`;return(0,E.jsxs)(`div`,{style:{marginTop:32,paddingTop:16,borderTop:`1px solid ${c.border}`},children:[(0,E.jsx)(`div`,{"aria-live":`polite`,style:{fontSize:12,color:c.muted,marginBottom:8,minHeight:16},children:s}),(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8,alignItems:`flex-start`},children:[(0,E.jsxs)(`button`,{type:`button`,onClick:()=>n(`this-device`),"aria-label":`Sign out`,style:Ei(),onMouseEnter:e=>Di(e,!0),onMouseLeave:e=>Di(e,!1),children:[(0,E.jsx)(`span`,{"aria-hidden":`true`,style:{fontSize:16,lineHeight:1},children:`⏻`}),(0,E.jsx)(`span`,{children:`Sign out`})]}),o&&(0,E.jsxs)(`button`,{type:`button`,onClick:()=>n(`everywhere`),"aria-label":`Sign out everywhere`,style:Ei(),onMouseEnter:e=>Di(e,!0),onMouseLeave:e=>Di(e,!1),children:[(0,E.jsx)(`span`,{"aria-hidden":`true`,style:{fontSize:16,lineHeight:1},children:`✕`}),(0,E.jsx)(`span`,{children:`Sign out everywhere`})]})]}),(0,E.jsx)(ne,{open:t!==null,title:t===`everywhere`?`Sign out on every device?`:`Sign out?`,body:l,confirmLabel:u,onConfirm:()=>t&&i(t),onCancel:()=>n(null)})]})}var ki=[{id:`appearance`,label:`Appearance`},{id:`engine`,label:`Engine`},{id:`integrations`,label:`Integrations`},{id:`slack`,label:`Slack`},{id:`organization`,label:`Organization`},{id:`memory`,label:`Memory`},{id:`pipeline`,label:`Pipeline`},{id:`spawn-profiles`,label:`Spawn Profiles`},{id:`diagnostics`,label:`Diagnostics`}];function Ai({settings:e,integrations:t,runtimeConfig:n,onUpdateSettings:r,onVerify:i,verifying:a}){let[o,s]=(0,T.useState)(`engine`),l=(0,T.useRef)(null),u=(0,T.useRef)(null);(0,T.useEffect)(()=>{let e=u.current;if(!e)return;let t=e.querySelector(`button[data-tab-id="${o}"]`);t&&t.scrollIntoView({behavior:`smooth`,block:`nearest`,inline:`center`})},[o]);function d(e){s(e),l.current?.scrollTo({top:0,behavior:`smooth`})}return(0,E.jsxs)(`div`,{className:`page-content-frame`,style:{padding:`32px 48px`,maxWidth:1100,margin:`0 auto`},children:[(0,E.jsx)(`h1`,{style:{fontSize:22,fontWeight:600,marginBottom:4},children:`Platform Settings`}),(0,E.jsx)(`p`,{style:{fontSize:13,color:c.muted,marginBottom:24},children:`Configure platform-wide settings for TeamworkOS. Cron job settings are in the Cron page header.`}),(0,E.jsx)(`div`,{className:`settings-mobile-tabs`,ref:u,style:{display:`none`,gap:4,marginBottom:20,overflowX:`auto`,WebkitOverflowScrolling:`touch`,scrollbarWidth:`none`,paddingBottom:4},children:ki.map(e=>(0,E.jsx)(`button`,{"data-tab-id":e.id,onClick:()=>d(e.id),style:{background:o===e.id?`rgba(188,140,255,0.12)`:`var(--color-subtle-bg)`,border:`1px solid ${o===e.id?`rgba(188,140,255,0.3)`:c.border}`,color:o===e.id?`var(--color-text)`:c.muted,fontSize:12,fontWeight:500,padding:`6px 14px`,borderRadius:6,cursor:`pointer`,whiteSpace:`nowrap`,minHeight:44,transition:`all 0.15s ease`,flexShrink:0},children:e.label},e.id))}),(0,E.jsxs)(`div`,{style:{display:`flex`,gap:32},children:[(0,E.jsx)(`nav`,{style:{width:160,flexShrink:0,position:`sticky`,top:80,alignSelf:`flex-start`,display:`flex`,flexDirection:`column`,gap:2},className:`settings-sidebar-nav`,children:ki.map(e=>(0,E.jsx)(`button`,{onClick:()=>d(e.id),style:{background:o===e.id?`rgba(188,140,255,0.08)`:`transparent`,border:`none`,borderLeft:`2px solid ${o===e.id?`var(--color-primary)`:`transparent`}`,color:o===e.id?`var(--color-text)`:c.muted,fontSize:13,fontWeight:o===e.id?500:400,padding:`8px 14px`,textAlign:`left`,cursor:`pointer`,borderRadius:`0 6px 6px 0`,transition:`all 0.15s ease`,minHeight:36},children:e.label},e.id))}),(0,E.jsxs)(`div`,{ref:l,style:{flex:1,minWidth:0},children:[o===`appearance`&&(0,E.jsx)(ui,{settings:e,onUpdateSettings:r}),o===`engine`&&(0,E.jsx)(de,{settings:e,onUpdateSettings:r,runtimeConfig:n}),o===`integrations`&&(0,E.jsx)(Te,{integrations:t,onVerify:i,verifying:a}),o===`slack`&&(0,E.jsx)(he,{settings:e,onUpdateSettings:r,runtimeConfig:n}),o===`organization`&&(0,E.jsx)(ye,{settings:e,onUpdateSettings:r}),o===`memory`&&(0,E.jsx)(gi,{settings:e,onUpdateSettings:r}),o===`pipeline`&&(0,E.jsx)(bi,{settings:e,onUpdateSettings:r}),o===`spawn-profiles`&&(0,E.jsx)(Ci,{}),o===`diagnostics`&&(0,E.jsx)(pi,{}),(0,E.jsx)(Oi,{})]})]}),(0,E.jsx)(`style`,{children:`
|
|
32
|
+
`:``}var Yr={dump:Jr};function Xr(e,t){return function(){throw Error(`Function yaml.`+e+` is removed in js-yaml 4. Use yaml.`+t+` instead, which is now safe by default.`)}}var Zr={Type:R,Schema:Ge,FAILSAFE_SCHEMA:Ye,JSON_SCHEMA:vt,CORE_SCHEMA:yt,DEFAULT_SCHEMA:qt,load:Rn.load,loadAll:Rn.loadAll,dump:Yr.dump,YAMLException:L,types:{binary:Nt,float:_t,map:Je,null:$e,pairs:Ht,set:Kt,timestamp:Tt,bool:rt,int:ut,merge:Dt,omap:Rt,seq:qe,str:Ke},safeLoad:Xr(`safeLoad`,`load`),safeLoadAll:Xr(`safeLoadAll`,`loadAll`),safeDump:Xr(`safeDump`,`dump`)},Qr={name:`name`,light:`light`,backgroundColor:`background-color`,primaryColor:`primary-color`,positiveColor:`positive-color`,negativeColor:`negative-color`,contrastMultiplier:`contrast-multiplier`,textSaturationMultiplier:`text-saturation-multiplier`,customCSS:`custom-css`},$r=(()=>{let e={};for(let[t,n]of Object.entries(Qr))e[n]=t;return e})();function ei(e){let t;try{t=Zr.load(e)}catch(e){return{ok:!1,error:e instanceof Error?e.message:`Invalid YAML`}}if(!t||typeof t!=`object`)return{ok:!1,error:`Expected YAML object`};let n=t.theme??t;if(!n||typeof n!=`object`)return{ok:!1,error:"Missing `theme:` object"};let r={};for(let[e,t]of Object.entries(n)){let n=$r[e];n&&(n===`light`&&typeof t==`boolean`?r.light=t:((n===`contrastMultiplier`||n===`textSaturationMultiplier`)&&typeof t==`number`&&Number.isFinite(t)||typeof t==`string`)&&(r[n]=t))}return{ok:!0,theme:r}}function $(e){let t={};for(let[n,r]of Object.entries(Qr)){let i=e[n];n===`customCSS`&&i===``||(t[r]=i)}return Zr.dump({theme:t},{lineWidth:-1,noRefs:!0})}var ti=`Custom`;function ni(e){let[t,n,r]=e.trim().split(/\s+/).map(e=>Number(e));return{h:Number.isFinite(t)?t:0,sat:Number.isFinite(n)?n:0,l:Number.isFinite(r)?r:0}}function ri(e,t,n){return`${Math.round(e)} ${Math.round(t)} ${Math.round(n)}`}function ii(e){let{h:t,sat:n,l:r}=ni(e);return`hsl(${t} ${n}% ${r}%)`}function ai({preset:e,active:t,onClick:n,onDelete:r}){return(0,E.jsxs)(`div`,{style:{position:`relative`,background:t?`var(--color-primary-soft)`:`var(--color-bg-raised)`,border:`1px solid ${t?`var(--color-primary)`:`var(--color-border)`}`,borderRadius:`var(--radius-lg)`,transition:`border-color 0.15s, background 0.15s`},children:[(0,E.jsxs)(`button`,{onClick:n,style:{width:`100%`,background:`transparent`,border:`none`,borderRadius:`var(--radius-lg)`,padding:10,cursor:`pointer`,textAlign:`left`,display:`flex`,flexDirection:`column`,gap:8,minHeight:60,color:`var(--color-text)`,fontFamily:`inherit`},children:[(0,E.jsx)(`div`,{style:{display:`flex`,gap:4},children:[e.backgroundColor,e.primaryColor,e.positiveColor,e.negativeColor].map((e,t)=>(0,E.jsx)(`span`,{style:{width:18,height:18,borderRadius:`var(--radius-sm)`,background:ii(e),border:`1px solid var(--color-border)`}},t))}),(0,E.jsx)(`div`,{style:{fontSize:12,fontWeight:t?600:500,paddingRight:r?18:0},children:e.name})]}),r&&(0,E.jsx)(`button`,{onClick:e=>{e.stopPropagation(),r()},"aria-label":`Delete ${e.name}`,title:`Delete custom theme`,style:{position:`absolute`,top:6,right:6,width:18,height:18,display:`flex`,alignItems:`center`,justifyContent:`center`,background:`transparent`,border:`none`,color:`var(--color-text-muted)`,cursor:`pointer`,fontSize:14,lineHeight:1,padding:0,borderRadius:`var(--radius-sm)`},children:`×`})]})}function oi({label:e,value:t,onChange:n,min:r,max:i,step:a,hint:o}){return(0,E.jsx)(m,{padding:`sm`,style:{marginBottom:8},children:(0,E.jsxs)(b,{direction:`row`,align:`center`,justify:`between`,gap:12,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{style:{fontSize:13,color:`var(--color-text)`,fontWeight:500},children:e}),o&&(0,E.jsx)(`div`,{style:{fontSize:11,color:`var(--color-text-muted)`,marginTop:2},children:o})]}),(0,E.jsxs)(b,{direction:`row`,align:`center`,gap:8,children:[(0,E.jsx)(`input`,{type:`range`,min:r,max:i,step:a,value:t,onChange:e=>n(Number(e.target.value)),style:{width:140}}),(0,E.jsx)(`span`,{style:{fontSize:12,color:`var(--color-text-muted)`,fontVariantNumeric:`tabular-nums`,minWidth:32,textAlign:`right`},children:t.toFixed(2)})]})]})})}function si({label:e,value:t,max:n,onChange:r}){return(0,E.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:6,fontSize:11,color:`var(--color-text-muted)`},children:[(0,E.jsx)(`span`,{style:{width:10,display:`inline-block`},children:e}),(0,E.jsx)(`input`,{type:`range`,min:0,max:n,step:1,value:t,onChange:e=>r(Number(e.target.value)),style:{width:110}}),(0,E.jsx)(`span`,{style:{fontVariantNumeric:`tabular-nums`,minWidth:26,textAlign:`right`,color:`var(--color-text)`},children:Math.round(t)})]})}function ci({label:e,value:t,onChange:n}){let{h:r,sat:i,l:a}=ni(t);function o(e){n(ri(e.h??r,e.sat??i,e.l??a))}return(0,E.jsx)(m,{padding:`sm`,style:{marginBottom:8},children:(0,E.jsxs)(b,{direction:`row`,align:`center`,justify:`between`,gap:16,wrap:!0,children:[(0,E.jsxs)(b,{direction:`row`,align:`center`,gap:10,style:{minWidth:130},children:[(0,E.jsx)(`span`,{style:{width:22,height:22,borderRadius:`var(--radius-sm)`,background:ii(t),border:`1px solid var(--color-border)`,flexShrink:0}}),(0,E.jsx)(`div`,{style:{fontSize:13,color:`var(--color-text)`,fontWeight:500},children:e})]}),(0,E.jsxs)(b,{direction:`column`,gap:4,children:[(0,E.jsx)(si,{label:`H`,value:r,max:360,onChange:e=>o({h:e})}),(0,E.jsx)(si,{label:`S`,value:i,max:100,onChange:e=>o({sat:e})}),(0,E.jsx)(si,{label:`L`,value:a,max:100,onChange:e=>o({l:e})})]})]})})}function li({label:e,checked:t,onChange:n,hint:r}){return(0,E.jsx)(m,{padding:`sm`,style:{marginBottom:8},children:(0,E.jsxs)(b,{direction:`row`,align:`center`,justify:`between`,gap:12,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{style:{fontSize:13,color:`var(--color-text)`,fontWeight:500},children:e}),r&&(0,E.jsx)(`div`,{style:{fontSize:11,color:`var(--color-text-muted)`,marginTop:2},children:r})]}),(0,E.jsx)(`input`,{type:`checkbox`,checked:t,onChange:e=>n(e.target.checked),style:{width:18,height:18,cursor:`pointer`}})]})})}function ui({settings:e,onUpdateSettings:t}){let n=e?.appearance??ie,r=e?.themePresets??[],[i,a]=(0,T.useState)(n),[o,s]=(0,T.useState)(()=>$(n)),[c,l]=(0,T.useState)(null),[u,d]=(0,T.useState)(null),f=new Set(se.map(e=>e.name));function p(e,t){return t.name===e.name?!0:!f.has(e.name)&&t.name===ti?e.backgroundColor===t.backgroundColor&&e.primaryColor===t.primaryColor&&e.positiveColor===t.positiveColor&&e.negativeColor===t.negativeColor&&e.light===t.light:!1}let m=(0,T.useRef)(JSON.stringify(n)),g=(0,T.useRef)(null);(0,T.useEffect)(()=>{if(!e?.appearance)return;let t=JSON.stringify(e.appearance);t!==m.current&&(m.current=t,a(e.appearance),s($(e.appearance)))},[e?.appearance]),(0,T.useEffect)(()=>(ce(i),g.current&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>{m.current=JSON.stringify(i),t({appearance:i})},400),()=>{g.current&&window.clearTimeout(g.current)}),[i,t]);function v(e){a(t=>({...t,...e,name:ti}))}function x(e){a(e),s($(e)),l(null)}function ee(){let e=ei(o);if(!e.ok){l(e.error);return}l(null),a(t=>({...t,...e.theme,name:e.theme.name??ti}))}function te(){let e=$(i);if(s(e),l(null),!navigator.clipboard){d(`Clipboard API unavailable (use HTTPS or localhost).`);return}navigator.clipboard.writeText(e).then(()=>d(`Copied to clipboard`)).catch(()=>d(`Copy failed`))}function S(){let e=window.prompt(`Name this theme:`,i.name===ti?``:i.name);if(e===null)return;let n=e.trim().slice(0,64);if(!n)return;if(f.has(n)){window.alert(`"${n}" is a built-in preset name. Pick a different name.`);return}let o={...i,name:n};t({themePresets:r.filter(e=>e.name!==n).concat(o),appearance:o}),a(o),s($(o))}function ne(e){if(!window.confirm(`Delete "${e}"?`))return;let n={themePresets:r.filter(t=>t.name!==e)};i.name===e&&(n.appearance=ie,a(ie),s($(ie))),t(n)}return(0,T.useEffect)(()=>{if(!u)return;let e=window.setTimeout(()=>d(null),2e3);return()=>window.clearTimeout(e)},[u]),(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(y,{title:`Theme Presets`,description:`Pick a theme or tune your own. Colors are HSL triplets; multipliers scale text contrast and saturation.`,children:[(0,E.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fit, minmax(180px, 1fr))`,gap:8},children:[se.map(e=>(0,E.jsx)(ai,{preset:e,active:p(e,i),onClick:()=>x(e)},e.name)),r.map(e=>(0,E.jsx)(ai,{preset:e,active:p(e,i),onClick:()=>x(e),onDelete:()=>ne(e.name)},`user:${e.name}`))]}),(0,E.jsxs)(b,{direction:`row`,align:`center`,gap:8,style:{marginTop:10},children:[(0,E.jsx)(h,{size:`sm`,onClick:S,children:`Save current as preset…`}),(0,E.jsx)(`span`,{style:{fontSize:11,color:`var(--color-text-muted)`},children:r.length>0?`${r.length} custom ${r.length===1?`theme`:`themes`} saved`:`Tune the sliders below then save to pin your favorite.`})]})]}),(0,E.jsx)(y,{title:`Mode`,children:(0,E.jsx)(li,{label:`Light mode`,checked:i.light,onChange:e=>v({light:e}),hint:`Inverts surface-lightness derivation so raised surfaces step down rather than up.`})}),(0,E.jsxs)(y,{title:`Colors`,description:`HSL values (H 0–360, S and L 0–100). Live swatches update as you drag.`,children:[(0,E.jsx)(ci,{label:`Background`,value:i.backgroundColor,onChange:e=>v({backgroundColor:e})}),(0,E.jsx)(ci,{label:`Primary`,value:i.primaryColor,onChange:e=>v({primaryColor:e})}),(0,E.jsx)(ci,{label:`Positive`,value:i.positiveColor,onChange:e=>v({positiveColor:e})}),(0,E.jsx)(ci,{label:`Negative`,value:i.negativeColor,onChange:e=>v({negativeColor:e})})]}),(0,E.jsxs)(y,{title:`Adjustments`,description:`Scale text contrast and saturation against the background. 1.0 = neutral.`,children:[(0,E.jsx)(oi,{label:`Contrast`,value:i.contrastMultiplier,onChange:e=>v({contrastMultiplier:e}),min:.5,max:2,step:.05}),(0,E.jsx)(oi,{label:`Text saturation`,value:i.textSaturationMultiplier,onChange:e=>v({textSaturationMultiplier:e}),min:.5,max:2,step:.05})]}),(0,E.jsx)(y,{title:`Custom CSS`,description:`Injected as a <style> tag at the end of <head>. Max 16 KB. Use for tweaks the tokens don't expose.`,children:(0,E.jsx)(_,{value:i.customCSS,onChange:e=>v({customCSS:e.target.value}),placeholder:`/* Your overrides here. Try:\\n.page-content-frame { max-width: 1400px; }\\n*/`,compact:!0,style:{minHeight:120}})}),(0,E.jsxs)(y,{title:`Import / Export YAML`,description:`Paste a theme YAML to try it; use Export to share your current theme.`,children:[(0,E.jsx)(_,{value:o,onChange:e=>s(e.target.value),compact:!0,style:{minHeight:140,borderColor:c?`var(--color-negative)`:void 0}}),c&&(0,E.jsx)(`div`,{style:{fontSize:12,color:`var(--color-negative)`,marginTop:6},children:c}),(0,E.jsxs)(b,{direction:`row`,align:`center`,gap:8,style:{marginTop:8},children:[(0,E.jsx)(h,{size:`sm`,onClick:ee,children:`Import`}),(0,E.jsx)(h,{size:`sm`,onClick:te,children:`Export + Copy`}),u&&(0,E.jsx)(`span`,{style:{fontSize:12,color:`var(--color-text-muted)`},children:u})]})]})]})}function di(e){let t=Math.round(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m ${t%60}s`:`${Math.floor(n/60)}h ${n%60}m`}function fi(e){switch(e){case`claude-binary`:return`Claude binary on PATH`;case`teamwork-home-writable`:return`~/.teamwork is writable`;case`sessions-db-readable`:return`sessions.db readable`;case`memory-db-readable`:return`memory.db readable`;case`jobs-dir`:return`Jobs directory`;case`org-scanned`:return`Organization scanned`;default:return e}}function pi(){let[e,t]=(0,T.useState)({status:`loading`}),n=(0,T.useCallback)(async()=>{t({status:`loading`});try{let e=await fetch(`/api/welcome`);if(!e.ok)throw Error(`HTTP ${e.status}`);t({status:`loaded`,data:await e.json(),fetchedAt:Date.now()})}catch(e){t({status:`error`,message:e instanceof Error?e.message:`unknown error`})}},[]);return(0,T.useEffect)(()=>{n()},[n]),(0,E.jsx)(y,{title:`Diagnostics`,description:`Startup health of the gateway — useful on first run and when something feels off.`,children:(0,E.jsxs)(`div`,{style:o,children:[e.status===`loading`&&(0,E.jsx)(`div`,{style:{...s,padding:12},children:`Checking…`}),e.status===`error`&&(0,E.jsxs)(`div`,{style:{padding:12},children:[(0,E.jsxs)(`div`,{style:{color:c.red,fontSize:13},children:[`Failed to load diagnostics: `,e.message]}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>void n(),style:{marginTop:12,minHeight:44,padding:`0 14px`,background:`var(--color-bg-raised)`,border:`1px solid ${c.border}`,borderRadius:6,color:c.text,fontSize:13,cursor:`pointer`},children:`Retry`})]}),e.status===`loaded`&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`12px 14px`,borderBottom:`1px solid ${c.border}`,gap:12,flexWrap:`wrap`},children:[(0,E.jsxs)(`div`,{style:{minWidth:0,flex:1},children:[(0,E.jsx)(`div`,{style:{fontSize:14,fontWeight:600,color:e.data.ok?c.green:c.red},children:e.data.ok?`All checks passing`:`One or more checks failing`}),(0,E.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:`0 10px`,fontSize:12,color:c.muted,marginTop:4},children:[(0,E.jsxs)(`span`,{children:[`v`,e.data.version]}),(0,E.jsxs)(`span`,{children:[`port `,e.data.port]}),(0,E.jsxs)(`span`,{children:[`uptime `,di(e.data.uptimeMs)]}),(0,E.jsxs)(`span`,{children:[e.data.jobCount,` job`,e.data.jobCount===1?``:`s`]}),(0,E.jsxs)(`span`,{children:[e.data.employeeCount,` employee`,e.data.employeeCount===1?``:`s`]})]})]}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>void n(),style:{minHeight:44,padding:`0 14px`,background:`var(--color-bg-raised)`,border:`1px solid ${c.border}`,borderRadius:6,color:c.text,fontSize:13,cursor:`pointer`},children:`Refresh`})]}),(0,E.jsx)(`ul`,{style:{listStyle:`none`,margin:0,padding:0},children:e.data.checks.map(e=>(0,E.jsxs)(`li`,{style:{display:`flex`,alignItems:`flex-start`,gap:10,padding:`10px 14px`,borderBottom:`1px solid ${c.border}`,fontSize:13},children:[(0,E.jsx)(`span`,{"aria-label":e.ok?`passing`:`failing`,style:{minWidth:18,color:e.ok?c.green:c.red,fontWeight:700},children:e.ok?`✓`:`✗`}),(0,E.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,E.jsx)(`div`,{style:{color:c.text},children:fi(e.name)}),e.detail&&(0,E.jsx)(`div`,{style:{fontSize:12,color:c.muted,marginTop:2,overflowWrap:`anywhere`,hyphens:`none`},children:e.detail})]})]},e.name))}),(0,E.jsxs)(`div`,{style:{padding:`10px 14px`,fontSize:11,color:c.muted},children:[`TEAMWORK_HOME: `,(0,E.jsx)(`span`,{style:{fontFamily:`ui-monospace, monospace`},children:e.data.teamworkHome})]})]})]})})}var mi=[{value:216e5,label:`6 hours`},{value:432e5,label:`12 hours`},{value:864e5,label:`24 hours (default)`},{value:1728e5,label:`48 hours`}];function hi(e,t,n){t({memorySteward:{...e?.memorySteward??{enabled:!0,scheduleMs:864e5},...n}})}function gi({settings:e,onUpdateSettings:t}){let n=e?.memorySteward??{enabled:!0,scheduleMs:864e5};return(0,E.jsx)(y,{title:`Memory Steward`,description:`Background process that scans memory files for hygiene issues and queues synthesis proposals.`,children:(0,E.jsxs)(le,{children:[(0,E.jsx)(w,{label:`Enabled`,hint:`Run the steward on the schedule below.`,children:(0,E.jsx)(`input`,{type:`checkbox`,checked:n.enabled,onChange:n=>hi(e,t,{enabled:n.target.checked}),"aria-label":`Enable memory steward`})}),(0,E.jsx)(w,{label:`Schedule`,hint:`How often the steward scans all memory directories.`,divider:!0,children:(0,E.jsx)(g,{compact:!0,value:n.scheduleMs,disabled:!n.enabled,onChange:n=>hi(e,t,{scheduleMs:Number(n.target.value)}),children:mi.map(e=>(0,E.jsx)(`option`,{value:e.value,children:e.label},e.value))})})]})})}var _i=[{value:60,label:`1 minute`},{value:120,label:`2 minutes`},{value:300,label:`5 minutes (default)`},{value:600,label:`10 minutes`},{value:1800,label:`30 minutes`}],vi=5;function yi(e,t,n){t({prAutoFix:{...e?.prAutoFix??{enabled:!0,intervalSec:300,model:`claude-sonnet-4-6`,maxAttempts:vi},...n}})}function bi({settings:e,onUpdateSettings:t}){let n=e?.prAutoFix??{enabled:!0,intervalSec:300,model:`claude-sonnet-4-6`,maxAttempts:vi},r=n.maxAttempts??vi;return(0,E.jsx)(y,{title:`PR Auto-Fix`,description:`Automatically update branches that fall behind main, and attempt to resolve merge conflicts via a Claude session.`,children:(0,E.jsxs)(le,{children:[(0,E.jsx)(w,{label:`Enabled`,hint:`Watch open PRs and fix BEHIND or CONFLICTING states automatically.`,children:(0,E.jsx)(`input`,{type:`checkbox`,checked:n.enabled,onChange:n=>yi(e,t,{enabled:n.target.checked}),"aria-label":`Enable PR auto-fix`})}),(0,E.jsx)(w,{label:`Poll interval`,hint:`How often to check PR states.`,divider:!0,children:(0,E.jsx)(g,{compact:!0,value:n.intervalSec,disabled:!n.enabled,onChange:n=>yi(e,t,{intervalSec:Number(n.target.value)}),children:_i.map(e=>(0,E.jsx)(`option`,{value:e.value,children:e.label},e.value))})}),(0,E.jsx)(w,{label:`Model`,hint:`Claude model used for rebase and CI-fix sessions.`,divider:!0,children:(0,E.jsx)(g,{compact:!0,value:n.model??`claude-sonnet-4-6`,disabled:!n.enabled,onChange:n=>yi(e,t,{model:n.target.value}),children:p.map(e=>(0,E.jsx)(`option`,{value:e,children:e},e))})}),(0,E.jsx)(w,{label:`Max attempts per push`,hint:`How many fix attempts before pausing and asking for input. A successful push resets the counter.`,divider:!0,children:(0,E.jsx)(g,{compact:!0,value:r,disabled:!n.enabled,onChange:n=>yi(e,t,{maxAttempts:Number(n.target.value)}),children:[1,2,3,4,5,6,7,8,9,10].map(e=>(0,E.jsxs)(`option`,{value:e,children:[e,e===vi?` (default)`:``]},e))})})]})})}var xi={gatewayPasses:[],jobs:[],employees:[]};async function Si(){let e=await fetch(`/api/spawn-profiles/usage`,{credentials:`include`});if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}function Ci(){let e=ne(),[t,n]=(0,T.useState)(null),[r,a]=(0,T.useState)(null),[o,s]=(0,T.useState)(0);if(i(f,()=>s(e=>e+1)),(0,T.useEffect)(()=>{let e=!1;return Si().then(t=>{e||(n(t),a(null))}).catch(t=>{e||a(t instanceof Error?t.message:String(t))}),()=>{e=!0}},[o]),e.status===`loading`)return(0,E.jsx)(y,{title:`Spawn Profiles`,children:(0,E.jsx)(`div`,{style:{color:c.muted,fontSize:13},children:`Loading…`})});if(e.status===`error`)return(0,E.jsx)(y,{title:`Spawn Profiles`,children:(0,E.jsxs)(`div`,{style:{color:`var(--color-danger, #ff6b6b)`,fontSize:13},children:[`Failed to load profiles: `,e.error]})});let l=e.status===`ok`?e.data:[];return(0,E.jsxs)(y,{title:`Spawn Profiles`,description:`Each gateway-spawned Claude session can opt into a named SpawnProfile that sets MCP servers, enabled marketplace plugins, claude.ai opt-in, and whether user-folder settings are suppressed. Built-in profiles ship with the gateway; user overrides at ~/.teamwork/profiles/<name>.json win when present.`,children:[r&&(0,E.jsxs)(`div`,{style:{fontSize:12,color:`var(--color-danger, #ff6b6b)`,marginBottom:12},children:[`Failed to load usage map: `,r]}),l.length===0&&(0,E.jsx)(`div`,{style:{color:c.muted,fontSize:13},children:`No profiles found. (This is unexpected — built-ins should always be present.)`}),(0,E.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:24},children:l.map(e=>(0,E.jsx)(wi,{name:e.name,usage:t?.[e.name]??xi},e.name))})]})}function wi({name:e,usage:t}){let n=t.gatewayPasses.length===0&&t.jobs.length===0&&t.employees.length===0;return(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{style:{fontSize:11,fontWeight:600,textTransform:`uppercase`,letterSpacing:.5,color:c.muted,marginBottom:6},children:`Used by`}),(0,E.jsxs)(`div`,{style:{fontSize:12,color:n?c.muted:`var(--color-text)`,marginBottom:10,lineHeight:1.6},children:[n&&(0,E.jsx)(`span`,{children:`No active consumers.`}),!n&&(0,E.jsxs)(`ul`,{style:{margin:0,padding:`0 0 0 18px`},children:[t.gatewayPasses.map(e=>(0,E.jsxs)(`li`,{children:[(0,E.jsx)(`span`,{children:e.label}),(0,E.jsxs)(`span`,{style:{color:c.muted,marginLeft:6},children:[`(`,e.file,`)`]})]},`pass-${e.id}`)),t.jobs.map(e=>(0,E.jsxs)(`li`,{children:[`Job: `,(0,E.jsx)(`a`,{href:`#/cron?job=${encodeURIComponent(e.id)}`,style:{color:`var(--color-primary)`,textDecoration:`none`},children:e.name}),(0,E.jsxs)(`span`,{style:{color:c.muted,marginLeft:6},children:[`(`,e.id,`)`]})]},`job-${e.id}`)),t.employees.map(e=>(0,E.jsxs)(`li`,{children:[`Employee: `,(0,E.jsx)(`a`,{href:`#/org?employee=${encodeURIComponent(e.name)}`,style:{color:`var(--color-primary)`,textDecoration:`none`},children:e.displayName??e.name}),(0,E.jsxs)(`span`,{style:{color:c.muted,marginLeft:6},children:[`(`,e.department,`)`]})]},`emp-${e.name}`))]})]}),(0,E.jsx)(re,{name:e,defaultExpanded:!0})]})}function Ti(){let[e,t]=(0,T.useState)(null);return(0,T.useEffect)(()=>{let e=!1;return(async()=>{try{let n=await fetch(`/api/auth/whoami`,{credentials:`include`});if(!n.ok)return;let r=await n.json();if(e)return;t({authRequired:r.authRequired,exp:r.exp,issuedAt:r.issuedAt,daysRemaining:r.daysRemaining??0})}catch{}})(),()=>{e=!0}},[]),e}function Ei(){return{display:`flex`,alignItems:`center`,gap:10,minHeight:44,padding:`0 12px`,borderRadius:8,border:`1px solid transparent`,background:`transparent`,color:c.muted,fontSize:13,fontWeight:500,cursor:`pointer`,fontFamily:`inherit`,transition:`background 0.15s, color 0.15s, border-color 0.15s`}}function Di(e,t){let n=e.currentTarget;t?(n.style.background=`rgba(255, 107, 107, 0.08)`,n.style.color=`var(--color-danger, #ff6b6b)`,n.style.borderColor=`var(--color-danger, #ff6b6b)`):(n.style.background=`transparent`,n.style.color=c.muted,n.style.borderColor=`transparent`)}function Oi(){let e=Ti(),[t,n]=(0,T.useState)(null);async function i(e){n(null),e===`everywhere`?await r():await a(),window.location.reload()}let o=e?.authRequired===!0,s=o?`Signed in · session expires in ${e.daysRemaining} day${e.daysRemaining===1?``:`s`}`:``,l=t===`everywhere`?`This invalidates every session you've started from any device. Other browsers and devices will also be signed out. You'll need your AUTH_TOKEN to sign in again.`:`You'll need your AUTH_TOKEN to sign back in. This only signs out this browser — other devices stay signed in.`,u=t===`everywhere`?`Sign out everywhere`:`Sign out`;return(0,E.jsxs)(`div`,{style:{marginTop:32,paddingTop:16,borderTop:`1px solid ${c.border}`},children:[(0,E.jsx)(`div`,{"aria-live":`polite`,style:{fontSize:12,color:c.muted,marginBottom:8,minHeight:16},children:s}),(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8,alignItems:`flex-start`},children:[(0,E.jsxs)(`button`,{type:`button`,onClick:()=>n(`this-device`),"aria-label":`Sign out`,style:Ei(),onMouseEnter:e=>Di(e,!0),onMouseLeave:e=>Di(e,!1),children:[(0,E.jsx)(`span`,{"aria-hidden":`true`,style:{fontSize:16,lineHeight:1},children:`⏻`}),(0,E.jsx)(`span`,{children:`Sign out`})]}),o&&(0,E.jsxs)(`button`,{type:`button`,onClick:()=>n(`everywhere`),"aria-label":`Sign out everywhere`,style:Ei(),onMouseEnter:e=>Di(e,!0),onMouseLeave:e=>Di(e,!1),children:[(0,E.jsx)(`span`,{"aria-hidden":`true`,style:{fontSize:16,lineHeight:1},children:`✕`}),(0,E.jsx)(`span`,{children:`Sign out everywhere`})]})]}),(0,E.jsx)(ae,{open:t!==null,title:t===`everywhere`?`Sign out on every device?`:`Sign out?`,body:l,confirmLabel:u,onConfirm:()=>t&&i(t),onCancel:()=>n(null)})]})}var ki=[{id:`appearance`,label:`Appearance`},{id:`engine`,label:`Engine`},{id:`integrations`,label:`Integrations`},{id:`slack`,label:`Slack`},{id:`organization`,label:`Organization`},{id:`memory`,label:`Memory`},{id:`pipeline`,label:`Pipeline`},{id:`spawn-profiles`,label:`Spawn Profiles`},{id:`diagnostics`,label:`Diagnostics`}];function Ai({settings:e,integrations:t,runtimeConfig:n,onUpdateSettings:r,onVerify:i,verifying:a}){let[o,s]=(0,T.useState)(`engine`),l=(0,T.useRef)(null),u=(0,T.useRef)(null);(0,T.useEffect)(()=>{let e=u.current;if(!e)return;let t=e.querySelector(`button[data-tab-id="${o}"]`);t&&t.scrollIntoView({behavior:`smooth`,block:`nearest`,inline:`center`})},[o]);function d(e){s(e),l.current?.scrollTo({top:0,behavior:`smooth`})}return(0,E.jsxs)(`div`,{className:`page-content-frame`,style:{padding:`32px 48px`,maxWidth:1100,margin:`0 auto`},children:[(0,E.jsx)(`h1`,{style:{fontSize:22,fontWeight:600,marginBottom:4},children:`Platform Settings`}),(0,E.jsx)(`p`,{style:{fontSize:13,color:c.muted,marginBottom:24},children:`Configure platform-wide settings for TeamworkOS. Cron job settings are in the Cron page header.`}),(0,E.jsx)(`div`,{className:`settings-mobile-tabs`,ref:u,style:{display:`none`,gap:4,marginBottom:20,overflowX:`auto`,WebkitOverflowScrolling:`touch`,scrollbarWidth:`none`,paddingBottom:4},children:ki.map(e=>(0,E.jsx)(`button`,{"data-tab-id":e.id,onClick:()=>d(e.id),style:{background:o===e.id?`rgba(188,140,255,0.12)`:`var(--color-subtle-bg)`,border:`1px solid ${o===e.id?`rgba(188,140,255,0.3)`:c.border}`,color:o===e.id?`var(--color-text)`:c.muted,fontSize:12,fontWeight:500,padding:`6px 14px`,borderRadius:6,cursor:`pointer`,whiteSpace:`nowrap`,minHeight:44,transition:`all 0.15s ease`,flexShrink:0},children:e.label},e.id))}),(0,E.jsxs)(`div`,{style:{display:`flex`,gap:32},children:[(0,E.jsx)(`nav`,{style:{width:160,flexShrink:0,position:`sticky`,top:80,alignSelf:`flex-start`,display:`flex`,flexDirection:`column`,gap:2},className:`settings-sidebar-nav`,children:ki.map(e=>(0,E.jsx)(`button`,{onClick:()=>d(e.id),style:{background:o===e.id?`rgba(188,140,255,0.08)`:`transparent`,border:`none`,borderLeft:`2px solid ${o===e.id?`var(--color-primary)`:`transparent`}`,color:o===e.id?`var(--color-text)`:c.muted,fontSize:13,fontWeight:o===e.id?500:400,padding:`8px 14px`,textAlign:`left`,cursor:`pointer`,borderRadius:`0 6px 6px 0`,transition:`all 0.15s ease`,minHeight:36},children:e.label},e.id))}),(0,E.jsxs)(`div`,{ref:l,style:{flex:1,minWidth:0},children:[o===`appearance`&&(0,E.jsx)(ui,{settings:e,onUpdateSettings:r}),o===`engine`&&(0,E.jsx)(de,{settings:e,onUpdateSettings:r,runtimeConfig:n}),o===`integrations`&&(0,E.jsx)(Te,{integrations:t,onVerify:i,verifying:a}),o===`slack`&&(0,E.jsx)(he,{settings:e,onUpdateSettings:r,runtimeConfig:n}),o===`organization`&&(0,E.jsx)(ye,{settings:e,onUpdateSettings:r}),o===`memory`&&(0,E.jsx)(gi,{settings:e,onUpdateSettings:r}),o===`pipeline`&&(0,E.jsx)(bi,{settings:e,onUpdateSettings:r}),o===`spawn-profiles`&&(0,E.jsx)(Ci,{}),o===`diagnostics`&&(0,E.jsx)(pi,{}),(0,E.jsx)(Oi,{})]})]}),(0,E.jsx)(`style`,{children:`
|
|
33
33
|
@media (max-width: 768px) {
|
|
34
34
|
.settings-sidebar-nav {
|
|
35
35
|
display: none !important;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._grid_xipgd_1{grid-template-columns:repeat(auto-fit,minmax(280px,1fr));gap:12px;display:grid}._tileLabel_xipgd_6{text-transform:uppercase;letter-spacing:.05em;color:var(--color-text-muted);font-size:12px}._tileValue_xipgd_12{font-variant-numeric:tabular-nums;margin-top:4px;font-size:36px;font-weight:600;line-height:1.1}._tileSub_xipgd_19{color:var(--color-text-muted);flex-wrap:wrap;gap:6px;margin-top:8px;font-size:13px;display:flex}._chip_xipgd_27{background:var(--color-surface-2);border-radius:4px;padding:2px 8px;font-size:12px}._section_1e62l_1{flex-direction:column;gap:12px;display:flex}._sectionHeader_1e62l_6{align-items:baseline;gap:8px;display:flex}._sectionTitle_1e62l_11{margin:0;font-size:15px;font-weight:600}._count_1e62l_16{color:var(--color-text-muted);font-variant-numeric:tabular-nums;font-size:13px}._list_1e62l_21{grid-template-columns:repeat(auto-fit,minmax(320px,1fr));gap:12px;display:grid}._card_1e62l_26{flex-direction:column;gap:10px;display:flex}._cardTop_1e62l_31{flex-wrap:wrap;align-items:center;gap:8px;display:flex}._kindChip_1e62l_37{font-family:var(--font-mono);background:var(--color-surface-2);border-radius:3px;padding:2px 6px;font-size:11px}._severity_1e62l_44{text-transform:uppercase;letter-spacing:.04em;border-radius:999px;padding:2px 8px;font-size:11px;font-weight:600}._severityCritical_1e62l_52{background:var(--color-negative-soft);color:var(--color-negative)}._severityWarning_1e62l_56{background:var(--color-warning-soft);color:var(--color-warning-text)}._occurrences_1e62l_60{color:var(--color-text-muted);font-variant-numeric:tabular-nums;margin-left:auto;font-size:12px}._jobs_1e62l_66{flex-wrap:wrap;gap:6px;display:flex}._jobChip_1e62l_71{background:var(--color-surface-2);border-radius:4px;padding:2px 8px;font-size:13px;font-weight:500}._sample_1e62l_78{font-family:var(--font-mono);color:var(--color-text-muted);white-space:pre-wrap;word-break:break-word;max-height:4.5em;font-size:12px;overflow:hidden}._diagnosis_1e62l_87{background:var(--color-surface-2);border-left:3px solid var(--color-info);border-radius:6px;flex-direction:column;gap:6px;padding:10px;display:flex}._diagBlock_1e62l_96{flex-direction:column;gap:2px;display:flex}._diagLabel_1e62l_101{text-transform:uppercase;letter-spacing:.05em;color:var(--color-text-muted);font-size:11px}._diagText_1e62l_107{color:var(--color-text);white-space:pre-wrap;word-break:break-word;font-size:13px}._diagPending_1e62l_113{color:var(--color-text-muted);align-items:center;gap:8px;font-size:13px;display:flex}._spinner_1e62l_120{border:2px solid var(--color-border-strong);border-top-color:var(--color-info);border-radius:50%;width:12px;height:12px}._diagError_1e62l_127{color:var(--color-negative);white-space:pre-wrap;word-break:break-word;font-size:13px}._actions_1e62l_133{flex-wrap:wrap;gap:8px;margin-top:2px;display:flex}._actionError_1e62l_139{color:var(--color-negative);font-size:12px}._escalatedNote_1e62l_143{color:var(--color-text-muted);font-size:12px}._list_ucrmt_1{border:1px solid var(--color-border);border-radius:8px;flex-direction:column;display:flex;overflow:hidden}._empty_ucrmt_8{text-align:center;color:var(--color-text-muted);padding:24px;font-size:14px}._page_1yg4h_1{flex-direction:column;gap:16px;max-width:1280px;margin:0 auto;padding:16px;display:flex}._header_1yg4h_9{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:12px;display:flex}._title_1yg4h_16{margin:0;font-size:20px;font-weight:600}._windowSelector_1yg4h_17{gap:4px;display:flex}._windowBtn_1yg4h_18{min-width:44px}._filterBar_1yg4h_19{flex-wrap:wrap;align-items:center;gap:8px;display:flex}._filterSelect_1yg4h_20{min-height:44px}._error_1yg4h_21{background:var(--color-negative-soft);color:var(--color-negative);border-radius:4px;padding:8px 12px;font-size:13px}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,s as t,t as n}from"./jsx-runtime-Bq3x7umQ.js";import{n as r}from"./useWebSocket-Hg3RO6sx.js";import{S as i}from"./events-BK5ucyUu.js";import{t as a}from"./Card-u29day7d.js";import{t as o}from"./Button-DTO6bgnL.js";import{n as s}from"./Input-iymdcwsf.js";import{$ as c,B as l,F as u,G as d,H as f,I as p,J as m,K as h,L as g,M as _,N as v,P as y,Q as b,R as x,U as S,V as ee,W as C,X as te,Y as w,Z as ne,at as T,ct as E,dt as D,et as re,it as O,j as k,lt as ie,nt as ae,ot as oe,q as se,rt as ce,st as le,tt as ue,ut as A,z as j}from"./index-DzJsiq8q.js";var de=[`open`,`escalated`,`resolved`,`dismissed`],M=t(e(),1);function N(e){let t=E(()=>se(e)),{isStatic:n}=(0,M.useContext)(le);if(n){let[,n]=(0,M.useState)(e);(0,M.useEffect)(()=>t.on(`change`,n),[])}return t}function P(e,t){let n=N(t()),r=()=>n.set(t());return r(),oe(()=>{let t=()=>ue.preRender(r,!1,!0),n=e.map(e=>e.on(`change`,t));return()=>{n.forEach(e=>e()),re(r)}}),n}var fe=e=>e&&typeof e==`object`&&e.mix,pe=e=>fe(e)?e.mix:void 0;function me(...e){let t=!Array.isArray(e[0]),n=t?0:-1,r=e[0+n],i=e[1+n],a=e[2+n],o=e[3+n],s=f(i,a,{mixer:pe(a[0]),...o});return t?s(r):s}function he(e){h.current=[],e();let t=P(h.current,e);return h.current=void 0,t}function F(e,t,n,r){if(typeof e==`function`)return he(e);let i=typeof t==`function`?t:me(t,n,r);return Array.isArray(e)?I(e,i):I([e],([e])=>i(e))}function I(e,t){let n=E(()=>[]);return P(e,()=>{n.length=0;let r=e.length;for(let t=0;t<r;t++)n[t]=e[t].get();return t(n)})}var L=(e,t,n)=>{let r=t-e;return((n-e)%r+r)%r+e};function R(e,t){return S(e)?e[L(0,e.length,t)]:e}function z(e){return typeof e==`object`&&!Array.isArray(e)}function B(e,t,n,r){return typeof e==`string`&&z(t)?w(e,n,r):e instanceof NodeList?Array.from(e):Array.isArray(e)?e:[e]}function ge(e,t,n){return e*(t+1)}function V(e,t,n,r){return typeof t==`number`?t:t.startsWith(`-`)||t.startsWith(`+`)?Math.max(0,e+parseFloat(t)):t===`<`?n:r.get(t)??e}function _e(e,t,n){for(let r=0;r<e.length;r++){let i=e[r];i.at>t&&i.at<n&&(m(e,i),r--)}}function ve(e,t,n,r,i,a){_e(e,i,a);for(let o=0;o<t.length;o++)e.push({value:t[o],at:d(i,a,r[o]),easing:R(n,o)})}function ye(e,t){for(let n=0;n<e.length;n++)e[n]=e[n]/(t+1)}function be(e,t){return e.at===t.at?e.value===null?1:t.value===null?-1:0:e.at-t.at}var xe=`easeInOut`,Se=20;function Ce(e,{defaultTransition:t={},...n}={},r,i){let a=t.duration||.3,o=new Map,s=new Map,u={},d=new Map,f=0,p=0,m=0;for(let n=0;n<e.length;n++){let o=e[n];if(typeof o==`string`){d.set(o,p);continue}else if(!Array.isArray(o)){d.set(o.name,V(p,o.at,f,d));continue}let[h,g,_={}]=o;_.at!==void 0&&(p=V(p,_.at,f,d));let v=0,y=(e,n,r,o=0,s=0)=>{let c=we(e),{delay:u=0,times:d=l(c),type:f=`keyframes`,repeat:h,repeatType:g,repeatDelay:_=0,...y}=n,{ease:b=t.ease||`easeOut`,duration:x}=n,S=typeof u==`function`?u(o,s):u,C=c.length,w=te(f)?f:i?.[f];if(C<=2&&w){let e=100;if(C===2&&De(c)){let t=c[1]-c[0];e=Math.abs(t)}let t={...y};x!==void 0&&(t.duration=ae(x));let n=ne(t,e,w);b=n.ease,x=n.duration}x??=a;let T=p+S;d.length===1&&d[0]===0&&(d[1]=1);let E=d.length-c.length;if(E>0&&ee(d,E),c.length===1&&c.unshift(null),h){O(h<Se,`Repeat count too high, must be less than 20`),x=ge(x,h);let e=[...c],t=[...d];b=Array.isArray(b)?[...b]:[b];let n=[...b];for(let r=0;r<h;r++){c.push(...e);for(let i=0;i<e.length;i++)d.push(t[i]+(r+1)),b.push(i===0?`linear`:R(n,i-1))}ye(d,h)}let D=T+x;ve(r,c,b,d,T,D),v=Math.max(S+x,v),m=Math.max(D,m)};if(c(h)){let e=H(h,s);y(g,_,U(`default`,e))}else{let e=B(h,g,r,u),t=e.length;for(let n=0;n<t;n++){g=g,_=_;let r=e[n],i=H(r,s);for(let e in g)y(g[e],Te(_,e),U(e,i),n,t)}}f=p,p+=v}return s.forEach((e,r)=>{for(let i in e){let a=e[i];a.sort(be);let s=[],c=[],l=[];for(let e=0;e<a.length;e++){let{at:t,value:n,easing:r}=a[e];s.push(n),c.push(ce(0,m,t)),l.push(r||`easeOut`)}c[0]!==0&&(c.unshift(0),s.unshift(s[0]),l.unshift(xe)),c[c.length-1]!==1&&(c.push(1),s.push(null)),o.has(r)||o.set(r,{keyframes:{},transition:{}});let u=o.get(r);u.keyframes[i]=s,u.transition[i]={...t,duration:m,ease:l,times:c,...n}}}),o}function H(e,t){return!t.has(e)&&t.set(e,{}),t.get(e)}function U(e,t){return t[e]||(t[e]=[]),t[e]}function we(e){return Array.isArray(e)?e:[e]}function Te(e,t){return e&&e[t]?{...e,...e[t]}:{...e}}var Ee=e=>typeof e==`number`,De=e=>e.every(Ee);function Oe(e,t){return e in t}var W=class extends y{constructor(){super(...arguments),this.type=`object`}readValueFromInstance(e,t){if(Oe(t,e)){let n=e[t];if(typeof n==`string`||typeof n==`number`)return n}}getBaseTargetFromProps(){}removeValueFromRenderState(e,t){delete t.output[e]}measureInstanceViewportBox(){return x()}build(e,t){Object.assign(e.output,t)}renderInstance(e,{output:t}){Object.assign(e,t)}sortInstanceNodePosition(){return 0}};function ke(e){let t={presenceContext:null,props:{},visualState:{renderState:{transform:{},transformOrigin:{},style:{},vars:{},attrs:{}},latestValues:{}}},n=p(e)?new _(t):new v(t);n.mount(e),u.set(e,n)}function Ae(e){let t=new W({presenceContext:null,props:{},visualState:{renderState:{output:{}},latestValues:{}}});t.mount(e),u.set(e,t)}function je(e,t){return c(e)||typeof e==`number`||typeof e==`string`&&!z(t)}function G(e,t,n,r){let i=[];if(je(e,t))i.push(g(e,z(t)&&t.default||t,n&&(n.default||n)));else{let a=B(e,t,r),o=a.length;O(!!o,`No valid elements provided.`);for(let e=0;e<o;e++){let r=a[e],s=r instanceof Element?ke:Ae;u.has(r)||s(r);let c=u.get(r),l={...n};`delay`in l&&typeof l.delay==`function`&&(l.delay=l.delay(e,o)),i.push(...j(c,{...t,transition:l},{}))}}return i}function Me(e,t,n){let r=[];return Ce(e,t,n,{spring:C}).forEach(({keyframes:e,transition:t},n)=>{r.push(...G(n,e,t))}),r}function Ne(e){return Array.isArray(e)&&e.some(Array.isArray)}function Pe(e){function t(t,n,r){let i=[];i=Ne(t)?Me(t,n,e):G(t,n,r,e);let a=new b(i);return e&&e.animations.push(a),a}return t}var Fe=Pe(),K={grid:`_grid_xipgd_1`,tileLabel:`_tileLabel_xipgd_6`,tileValue:`_tileValue_xipgd_12`,tileSub:`_tileSub_xipgd_19`,chip:`_chip_xipgd_27`},q=n();function J({value:e}){let t=N(0),n=F(t,e=>Math.floor(e).toString());return(0,M.useEffect)(()=>{let n=Fe(t,e,{duration:.6,ease:`easeOut`});return()=>{n.stop()}},[e,t]),(0,q.jsx)(k.span,{children:n})}function Y(e,t){return Object.entries(e).sort((e,t)=>t[1]-e[1]).slice(0,t)}function Ie({metrics:e}){let t=Object.values(e.failuresByKind).reduce((e,t)=>e+t,0),n=Object.values(e.remediationsByAction).reduce((e,t)=>e+t,0),r=Y(e.failuresByKind,3),i=Y(e.remediationsByAction,3);return(0,q.jsxs)(`div`,{className:K.grid,children:[(0,q.jsxs)(a,{children:[(0,q.jsx)(`div`,{className:K.tileLabel,children:`Failures`}),(0,q.jsx)(`div`,{className:K.tileValue,children:(0,q.jsx)(J,{value:t})}),(0,q.jsx)(`div`,{className:K.tileSub,children:r.length===0?`No failures`:r.map(([e,t])=>(0,q.jsxs)(`span`,{className:K.chip,children:[e,`: `,t]},e))})]}),(0,q.jsxs)(a,{children:[(0,q.jsx)(`div`,{className:K.tileLabel,children:`Remediations`}),(0,q.jsx)(`div`,{className:K.tileValue,children:(0,q.jsx)(J,{value:n})}),(0,q.jsx)(`div`,{className:K.tileSub,children:i.length===0?`None dispatched`:i.map(([e,t])=>(0,q.jsxs)(`span`,{className:K.chip,children:[e,`: `,t]},e))})]}),(0,q.jsxs)(a,{children:[(0,q.jsx)(`div`,{className:K.tileLabel,children:`Auto-resolved`}),(0,q.jsx)(`div`,{className:K.tileValue,children:(0,q.jsx)(J,{value:e.autoResolved})}),(0,q.jsx)(`div`,{className:K.tileSub,children:`jobs auto-unpaused`})]}),(0,q.jsxs)(a,{children:[(0,q.jsx)(`div`,{className:K.tileLabel,children:`Escalated`}),(0,q.jsx)(`div`,{className:K.tileValue,children:(0,q.jsx)(J,{value:e.escalated})}),(0,q.jsx)(`div`,{className:K.tileSub,children:`awaiting human action`})]})]})}var Le=new Set(de);function X(e){if(!e||typeof e!=`object`)return!1;let t=e;return!(typeof t.id!=`string`||t.id.length===0||typeof t.kind!=`string`||typeof t.normalizedMessage!=`string`||typeof t.sampleMessage!=`string`||!Array.isArray(t.affectedJobs)||typeof t.occurrenceCount!=`number`||typeof t.firstSeenAt!=`string`||typeof t.lastSeenAt!=`string`||t.severity!==`warning`&&t.severity!==`critical`||typeof t.status!=`string`||!Le.has(t.status)||typeof t.escalatedIdeaId!=`string`&&t.escalatedIdeaId!==null)}function Re(e){let[t,n]=(0,M.useState)([]),[a,o]=(0,M.useState)(!0),[s,c]=(0,M.useState)(null),l=(0,M.useCallback)(async(t,r)=>{let i=()=>r?.()??!1,a=e?`/api/supervisor/remediations?status=${encodeURIComponent(e)}`:`/api/supervisor/remediations`;o(!0),c(null);try{let e=await fetch(a,t?{signal:t}:void 0);if(!e.ok)throw Error(`HTTP ${e.status}`);let r=await e.json();if(i())return;let o=Array.isArray(r.items)?r.items:[],s=o.filter(X);s.length!==o.length&&console.warn(`[useRemediations] dropped ${o.length-s.length} malformed items`),n(s)}catch(e){if(i()||e instanceof Error&&e.name===`AbortError`)return;c(e instanceof Error?e.message:String(e))}finally{i()||o(!1)}},[e]);(0,M.useEffect)(()=>{let e=!1,t=new AbortController;return l(t.signal,()=>e),()=>{e=!0,t.abort()}},[l]);let{subscribe:u}=r();return(0,M.useEffect)(()=>u(i,e=>{try{let t=typeof e==`object`&&e?e.item:void 0;if(!X(t))return;n(e=>{let n=e.filter(e=>e.id!==t.id);return n.unshift(t),n})}catch(e){console.warn(`[useRemediations] supervisor.remediation handler threw`,e)}}),[u]),{items:t,loading:a,error:s,refetch:(0,M.useCallback)(()=>l(),[l])}}var Z={section:`_section_1e62l_1`,sectionHeader:`_sectionHeader_1e62l_6`,sectionTitle:`_sectionTitle_1e62l_11`,count:`_count_1e62l_16`,list:`_list_1e62l_21`,card:`_card_1e62l_26`,cardTop:`_cardTop_1e62l_31`,kindChip:`_kindChip_1e62l_37`,severity:`_severity_1e62l_44`,severityCritical:`_severityCritical_1e62l_52`,severityWarning:`_severityWarning_1e62l_56`,occurrences:`_occurrences_1e62l_60`,jobs:`_jobs_1e62l_66`,jobChip:`_jobChip_1e62l_71`,sample:`_sample_1e62l_78`,diagnosis:`_diagnosis_1e62l_87`,diagBlock:`_diagBlock_1e62l_96`,diagLabel:`_diagLabel_1e62l_101`,diagText:`_diagText_1e62l_107`,diagPending:`_diagPending_1e62l_113`,spinner:`_spinner_1e62l_120`,diagError:`_diagError_1e62l_127`,actions:`_actions_1e62l_133`,actionError:`_actionError_1e62l_139`,escalatedNote:`_escalatedNote_1e62l_143`},ze=20;function Be(e){return e===`critical`?Z.severityCritical:Z.severityWarning}function Ve({item:e,onChanged:t}){let[n,r]=(0,M.useState)(null),[i,s]=(0,M.useState)(null),c=(0,M.useCallback)(async n=>{r(n),s(null);try{let r=await fetch(`/api/supervisor/remediations/${encodeURIComponent(e.id)}/${n}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`});if(!r.ok)throw Error(`HTTP ${r.status}`);await t()}catch(e){s(`Action failed: ${e instanceof Error?e.message:String(e)}`)}finally{r(null)}},[e.id,t]),l=e.diagnosis,u=e.status===`escalated`,d=l?.state===`done`,f=n!==null||u||!d,p=u?`Already escalated`:d?void 0:`Diagnosis must finish before escalating`;return(0,q.jsxs)(a,{className:Z.card,children:[(0,q.jsxs)(`div`,{className:Z.cardTop,children:[(0,q.jsx)(`span`,{className:Z.kindChip,children:e.kind}),(0,q.jsx)(`span`,{className:`${Z.severity} ${Be(e.severity)}`,children:e.severity}),(0,q.jsxs)(`span`,{className:Z.occurrences,children:[`×`,e.occurrenceCount]})]}),(0,q.jsx)(`div`,{className:Z.jobs,children:e.affectedJobs.length===0?(0,q.jsx)(`span`,{className:Z.jobChip,children:`unknown job`}):e.affectedJobs.map(e=>(0,q.jsx)(`span`,{className:Z.jobChip,title:e.jobId,children:e.jobName},e.jobId))}),(0,q.jsx)(`div`,{className:Z.sample,children:e.sampleMessage}),l&&l.state===`pending`&&(0,q.jsxs)(`div`,{className:Z.diagPending,children:[(0,q.jsx)(k.span,{className:Z.spinner,animate:{rotate:360},transition:{repeat:1/0,duration:.9,ease:`linear`}}),`Diagnosing…`]}),l&&l.state===`failed`&&(0,q.jsxs)(`div`,{className:Z.diagError,children:[`Diagnosis failed`,l.error?`: ${l.error}`:`.`]}),l&&l.state===`done`&&(0,q.jsxs)(`div`,{className:Z.diagnosis,children:[l.rootCause&&(0,q.jsxs)(`div`,{className:Z.diagBlock,children:[(0,q.jsx)(`span`,{className:Z.diagLabel,children:`Root cause`}),(0,q.jsx)(`span`,{className:Z.diagText,children:l.rootCause})]}),l.proposedFix&&(0,q.jsxs)(`div`,{className:Z.diagBlock,children:[(0,q.jsx)(`span`,{className:Z.diagLabel,children:`Proposed fix`}),(0,q.jsx)(`span`,{className:Z.diagText,children:l.proposedFix})]})]}),u&&e.escalatedIdeaId&&(0,q.jsxs)(`div`,{className:Z.escalatedNote,children:[`Escalated to idea `,e.escalatedIdeaId]}),(0,q.jsxs)(`div`,{className:Z.actions,children:[(0,q.jsx)(o,{variant:`primary`,size:`sm`,disabled:f,title:p,onClick:()=>void c(`escalate`),children:n===`escalate`?`Escalating…`:`Escalate`}),(0,q.jsx)(o,{variant:`ghost`,size:`sm`,disabled:n!==null,onClick:()=>void c(`re-diagnose`),children:n===`re-diagnose`?`Re-diagnosing…`:`Re-diagnose`}),(0,q.jsx)(o,{variant:`positive`,size:`sm`,disabled:n!==null,onClick:()=>void c(`resolve`),children:n===`resolve`?`Resolving…`:`Resolve`}),(0,q.jsx)(o,{variant:`ghost`,size:`sm`,disabled:n!==null,onClick:()=>void c(`dismiss`),children:n===`dismiss`?`Dismissing…`:`Dismiss`})]}),i&&(0,q.jsx)(`div`,{className:Z.actionError,children:i})]})}var He=new Set([`open`,`escalated`]);function Ue(){let{items:e,refetch:t}=Re(),n=e.filter(e=>He.has(e.status));return n.length===0?null:(0,q.jsxs)(`div`,{className:Z.section,children:[(0,q.jsxs)(`div`,{className:Z.sectionHeader,children:[(0,q.jsx)(`h2`,{className:Z.sectionTitle,children:`Remediations`}),(0,q.jsxs)(`span`,{className:Z.count,children:[n.length,` open`]})]}),(0,q.jsx)(`div`,{className:Z.list,children:(0,q.jsx)(T,{initial:!0,children:n.map((e,n)=>(0,q.jsx)(k.div,{layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},transition:{duration:.2,delay:Math.min(n,ze)*.03,ease:`easeOut`},children:(0,q.jsx)(Ve,{item:e,onChanged:t})},e.id))})})]})}var Q={list:`_list_ucrmt_1`,empty:`_empty_ucrmt_8`},We=20;function Ge({events:e,onJobClick:t,ideaTitles:n}){return e.length===0?(0,q.jsx)(`div`,{className:Q.empty,children:`No supervisor activity in this window.`}):(0,q.jsx)(`div`,{className:Q.list,children:(0,q.jsx)(T,{initial:!0,children:e.map((e,r)=>(0,q.jsx)(k.div,{initial:{opacity:0,y:r===0?-8:4},animate:{opacity:1,y:0},exit:{opacity:0},transition:{duration:r===0?.25:.2,delay:Math.min(r,We)*.03,ease:`easeOut`},children:(0,q.jsx)(D,{event:e,onJobClick:t,ideaTitles:n})},e.id))})})}var $={page:`_page_1yg4h_1`,header:`_header_1yg4h_9`,title:`_title_1yg4h_16`,windowSelector:`_windowSelector_1yg4h_17`,windowBtn:`_windowBtn_1yg4h_18`,filterBar:`_filterBar_1yg4h_19`,filterSelect:`_filterSelect_1yg4h_20`,error:`_error_1yg4h_21`},Ke=[`remediation-opened`,`diagnosed`,`escalated`,`resolved`,`dismissed`,`slack-drafted`,`auto-unpaused`,`skipped`,`no-action`];function qe(){let e=A(),{titles:t}=ie();return(0,q.jsxs)(`div`,{className:$.page,children:[(0,q.jsxs)(`header`,{className:$.header,children:[(0,q.jsx)(`h1`,{className:$.title,children:`Job Health`}),(0,q.jsx)(`div`,{className:$.windowSelector,children:[`1d`,`7d`,`30d`].map(t=>(0,q.jsx)(o,{variant:e.timeWindow===t?`default`:`ghost`,onClick:()=>e.setTimeWindow(t),className:$.windowBtn,children:t},t))})]}),(0,q.jsx)(Ie,{metrics:e.metrics}),(0,q.jsx)(Ue,{}),(0,q.jsxs)(`div`,{className:$.filterBar,children:[(0,q.jsxs)(s,{value:e.filterAction??``,onChange:t=>e.setFilterAction(t.target.value===``?null:t.target.value),className:$.filterSelect,children:[(0,q.jsx)(`option`,{value:``,children:`All actions`}),Ke.map(e=>(0,q.jsx)(`option`,{value:e,children:e},e))]}),e.filterJobId&&(0,q.jsxs)(o,{variant:`ghost`,onClick:()=>e.setFilterJobId(null),children:[`Clear job filter (`,e.filterJobId,`)`]})]}),e.error&&(0,q.jsxs)(`div`,{className:$.error,children:[`Failed to load: `,e.error]}),(0,q.jsx)(Ge,{events:e.events,onJobClick:e.setFilterJobId,ideaTitles:t})]})}export{qe as SupervisorDashboardPage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e,s as t,t as n}from"./jsx-runtime-Bq3x7umQ.js";import{t as r}from"./react-dom-Cnw6SoYl.js";import{r as i}from"./useWebSocket-Hg3RO6sx.js";import{S as a}from"./events-CCBP4a9s.js";import{t as o}from"./Input-HhV6M0tu.js";import{t as s}from"./Button-xBBZQ0ie.js";import"./index-tOLuwPW6.js";import{C as c,D as l,E as u,O as d,S as f,T as p,_ as m,a as h,b as g,c as _,d as v,f as y,g as b,k as ee,l as x,m as S,n as C,p as w,r as T,s as E,t as D,u as te,v as O,w as k,x as A,y as ne}from"./generateCategoricalChart-pfORgeJG.js";import{t as j}from"./KpiTile-pXTBj77S.js";var M=t(e()),N=t(d()),P=t(S()),F=t(l()),re=t(u()),I=t(w()),ie=[`layout`,`type`,`stroke`,`connectNulls`,`isRange`,`ref`],ae=[`key`],L;function R(e){"@babel/helpers - typeof";return R=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},R(e)}function z(e,t){if(e==null)return{};var n=oe(e,t),r,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function oe(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function B(){return B=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},B.apply(this,arguments)}function V(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function H(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?V(Object(n),!0).forEach(function(t){G(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):V(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function se(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function ce(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,K(r.key),r)}}function le(e,t,n){return t&&ce(e.prototype,t),n&&ce(e,n),Object.defineProperty(e,`prototype`,{writable:!1}),e}function ue(e,t,n){return t=U(t),de(e,pe()?Reflect.construct(t,n||[],U(e).constructor):t.apply(e,n))}function de(e,t){if(t&&(R(t)===`object`||typeof t==`function`))return t;if(t!==void 0)throw TypeError(`Derived constructors may only return object or undefined`);return fe(e)}function fe(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function pe(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(pe=function(){return!!e})()}function U(e){return U=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},U(e)}function me(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function`);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,`prototype`,{writable:!1}),t&&W(e,t)}function W(e,t){return W=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},W(e,t)}function G(e,t,n){return t=K(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function K(e){var t=he(e,`string`);return R(t)==`symbol`?t:t+``}function he(e,t){if(R(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(R(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var q=function(e){function t(){var e;se(this,t);var n=[...arguments];return e=ue(this,t,[].concat(n)),G(e,`state`,{isAnimationFinished:!0}),G(e,`id`,p(`recharts-area-`)),G(e,`handleAnimationEnd`,function(){var t=e.props.onAnimationEnd;e.setState({isAnimationFinished:!0}),(0,N.default)(t)&&t()}),G(e,`handleAnimationStart`,function(){var t=e.props.onAnimationStart;e.setState({isAnimationFinished:!1}),(0,N.default)(t)&&t()}),e}return me(t,e),le(t,[{key:`renderDots`,value:function(e,n,r){var i=this.props.isAnimationActive,a=this.state.isAnimationFinished;if(i&&!a)return null;var o=this.props,s=o.dot,c=o.points,l=o.dataKey,u=A(this.props,!1),d=A(s,!0),f=c.map(function(e,n){var r=H(H(H({key:`dot-${n}`,r:3},u),d),{},{index:n,cx:e.x,cy:e.y,dataKey:l,value:e.value,payload:e.payload,points:c});return t.renderDotItem(s,r)}),p={clipPath:e?`url(#clipPath-${n?``:`dots-`}${r})`:null};return M.createElement(g,B({className:`recharts-area-dots`},p),f)}},{key:`renderHorizontalRect`,value:function(e){var t=this.props,n=t.baseLine,r=t.points,i=t.strokeWidth,a=r[0].x,o=r[r.length-1].x,s=e*Math.abs(a-o),c=(0,P.default)(r.map(function(e){return e.y||0}));return k(n)&&typeof n==`number`?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max((0,P.default)(n.map(function(e){return e.y||0})),c)),k(c)?M.createElement(`rect`,{x:a<o?a:a-s,y:0,width:s,height:Math.floor(c+(i?parseInt(`${i}`,10):1))}):null}},{key:`renderVerticalRect`,value:function(e){var t=this.props,n=t.baseLine,r=t.points,i=t.strokeWidth,a=r[0].y,o=r[r.length-1].y,s=e*Math.abs(a-o),c=(0,P.default)(r.map(function(e){return e.x||0}));return k(n)&&typeof n==`number`?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max((0,P.default)(n.map(function(e){return e.x||0})),c)),k(c)?M.createElement(`rect`,{x:0,y:a<o?a:a-s,width:c+(i?parseInt(`${i}`,10):1),height:Math.floor(s)}):null}},{key:`renderClipRect`,value:function(e){return this.props.layout===`vertical`?this.renderVerticalRect(e):this.renderHorizontalRect(e)}},{key:`renderAreaStatically`,value:function(e,t,n,r){var i=this.props,a=i.layout,o=i.type,s=i.stroke,c=i.connectNulls,l=i.isRange;i.ref;var u=z(i,ie);return M.createElement(g,{clipPath:n?`url(#clipPath-${r})`:null},M.createElement(x,B({},A(u,!0),{points:e,connectNulls:c,type:o,baseLine:t,layout:a,stroke:`none`,className:`recharts-area-area`})),s!==`none`&&M.createElement(x,B({},A(this.props,!1),{className:`recharts-area-curve`,layout:a,type:o,connectNulls:c,fill:`none`,points:e})),s!==`none`&&l&&M.createElement(x,B({},A(this.props,!1),{className:`recharts-area-curve`,layout:a,type:o,connectNulls:c,fill:`none`,points:t})))}},{key:`renderAreaWithAnimation`,value:function(e,t){var n=this,r=this.props,i=r.points,a=r.baseLine,o=r.isAnimationActive,s=r.animationBegin,l=r.animationDuration,u=r.animationEasing,d=r.animationId,f=this.state,p=f.prevPoints,m=f.prevBaseLine;return M.createElement(_,{begin:s,duration:l,isActive:o,easing:u,from:{t:0},to:{t:1},key:`area-${d}`,onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(r){var o=r.t;if(p){var s=p.length/i.length,l=i.map(function(e,t){var n=Math.floor(t*s);if(p[n]){var r=p[n],i=c(r.x,e.x),a=c(r.y,e.y);return H(H({},e),{},{x:i(o),y:a(o)})}return e}),u=k(a)&&typeof a==`number`?c(m,a)(o):(0,F.default)(a)||(0,re.default)(a)?c(m,0)(o):a.map(function(e,t){var n=Math.floor(t*s);if(m[n]){var r=m[n],i=c(r.x,e.x),a=c(r.y,e.y);return H(H({},e),{},{x:i(o),y:a(o)})}return e});return n.renderAreaStatically(l,u,e,t)}return M.createElement(g,null,M.createElement(`defs`,null,M.createElement(`clipPath`,{id:`animationClipPath-${t}`},n.renderClipRect(o))),M.createElement(g,{clipPath:`url(#animationClipPath-${t})`},n.renderAreaStatically(i,a,e,t)))})}},{key:`renderArea`,value:function(e,t){var n=this.props,r=n.points,i=n.baseLine,a=n.isAnimationActive,o=this.state,s=o.prevPoints,c=o.prevBaseLine,l=o.totalLength;return a&&r&&r.length&&(!s&&l>0||!(0,I.default)(s,r)||!(0,I.default)(c,i))?this.renderAreaWithAnimation(e,t):this.renderAreaStatically(r,i,e,t)}},{key:`render`,value:function(){var e=this.props,t=e.hide,n=e.dot,r=e.points,i=e.className,a=e.top,o=e.left,s=e.xAxis,c=e.yAxis,l=e.width,u=e.height,d=e.isAnimationActive,p=e.id;if(t||!r||!r.length)return null;var m=this.state.isAnimationFinished,h=r.length===1,_=ee(`recharts-area`,i),v=s&&s.allowDataOverflow,y=c&&c.allowDataOverflow,b=v||y,x=(0,F.default)(p)?this.id:p,S=A(n,!1)??{r:3,strokeWidth:2},C=S.r,w=C===void 0?3:C,T=S.strokeWidth,E=T===void 0?2:T,D=(f(n)?n:{}).clipDot,O=D===void 0?!0:D,k=w*2+E;return M.createElement(g,{className:_},v||y?M.createElement(`defs`,null,M.createElement(`clipPath`,{id:`clipPath-${x}`},M.createElement(`rect`,{x:v?o:o-l/2,y:y?a:a-u/2,width:v?l:l*2,height:y?u:u*2})),!O&&M.createElement(`clipPath`,{id:`clipPath-dots-${x}`},M.createElement(`rect`,{x:o-k/2,y:a-k/2,width:l+k,height:u+k}))):null,h?null:this.renderArea(b,x),(n||h)&&this.renderDots(b,O,x),(!d||m)&&te.renderCallByParent(this.props,r))}}],[{key:`getDerivedStateFromProps`,value:function(e,t){return e.animationId===t.prevAnimationId?e.points!==t.curPoints||e.baseLine!==t.curBaseLine?{curPoints:e.points,curBaseLine:e.baseLine}:null:{prevAnimationId:e.animationId,curPoints:e.points,curBaseLine:e.baseLine,prevPoints:t.curPoints,prevBaseLine:t.curBaseLine}}}])}(M.PureComponent);L=q,G(q,`displayName`,`Area`),G(q,`defaultProps`,{stroke:`#3182bd`,fill:`#3182bd`,fillOpacity:.6,xAxisId:0,yAxisId:0,legendType:`line`,connectNulls:!1,points:[],dot:!1,activeDot:!0,hide:!1,isAnimationActive:!O.isSsr,animationBegin:0,animationDuration:1500,animationEasing:`ease`}),G(q,`getBaseValue`,function(e,t,n,r){var i=e.layout,a=e.baseValue,o=t.props.baseValue??a;if(k(o)&&typeof o==`number`)return o;var s=i===`horizontal`?r:n,c=s.scale.domain();if(s.type===`number`){var l=Math.max(c[0],c[1]),u=Math.min(c[0],c[1]);return o===`dataMin`?u:o===`dataMax`||l<0?l:Math.max(Math.min(c[0],c[1]),0)}return o===`dataMin`?c[0]:o===`dataMax`?c[1]:c[0]}),G(q,`getComposedData`,function(e){var t=e.props,n=e.item,r=e.xAxis,i=e.yAxis,a=e.xAxisTicks,o=e.yAxisTicks,s=e.bandSize,c=e.dataKey,l=e.stackedData,u=e.dataStartIndex,d=e.displayedData,f=e.offset,p=t.layout,m=l&&l.length,h=L.getBaseValue(t,n,r,i),g=p===`horizontal`,_=!1,b=d.map(function(e,t){var n;m?n=l[u+t]:(n=y(e,c),Array.isArray(n)?_=!0:n=[h,n]);var d=n[1]==null||m&&y(e,c)==null;return g?{x:v({axis:r,ticks:a,bandSize:s,entry:e,index:t}),y:d?null:i.scale(n[1]),value:n,payload:e}:{x:d?null:r.scale(n[1]),y:v({axis:i,ticks:o,bandSize:s,entry:e,index:t}),value:n,payload:e}});return H({points:b,baseLine:m||_?b.map(function(e){var t=Array.isArray(e.value)?e.value[0]:null;return g?{x:e.x,y:t!=null&&e.y!=null?i.scale(t):null}:{x:t==null?null:r.scale(t),y:e.y}}):g?i.scale(h):r.scale(h),layout:p,isRange:_},f)}),G(q,`renderDotItem`,function(e,t){var n;if(M.isValidElement(e))n=M.cloneElement(e,t);else if((0,N.default)(e))n=e(t);else{var r=ee(`recharts-area-dot`,typeof e==`boolean`?``:e.className),i=t.key,a=z(t,ae);n=M.createElement(E,B({},a,{key:i,className:r}))}return n});var ge=D({chartName:`AreaChart`,GraphicalChild:q,axisComponents:[{axisType:`xAxis`,AxisComp:T},{axisType:`yAxis`,AxisComp:C}],formatAxisMap:h}),J={page:`_page_l9qss_1`,header:`_header_l9qss_2`,title:`_title_l9qss_3`,summary:`_summary_l9qss_4`,kpiGrid:`_kpiGrid_l9qss_5`,banner:`_banner_l9qss_6`,footer:`_footer_l9qss_7`,windowSeg:`_windowSeg_l9qss_8`,empty:`_empty_l9qss_10`,emptyHint:`_emptyHint_l9qss_11`,skeletonTile:`_skeletonTile_l9qss_12`,"usage-shimmer":`_usage-shimmer_l9qss_1`};function _e(e={}){let{window:t=`today`,start:n,end:r}=e,[o,s]=(0,M.useState)(null),[c,l]=(0,M.useState)(!0),[u,d]=(0,M.useState)(null),f=(0,M.useCallback)(()=>{let e=new URLSearchParams({window:t});return n&&e.set(`start`,n),r&&e.set(`end`,r),`/api/usage/pipeline?${e.toString()}`},[t,n,r]);(0,M.useEffect)(()=>{let e=new AbortController;return l(!0),d(null),fetch(f(),{signal:e.signal}).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status} ${e.statusText||``}`.trim());return await e.json()}).then(e=>{s(e),l(!1)}).catch(e=>{e instanceof DOMException&&e.name===`AbortError`||(d(e instanceof Error?e.message:String(e)),l(!1))}),()=>e.abort()},[f]);let p=(0,M.useRef)(null);return i(a,(0,M.useCallback)(()=>{p.current?.abort();let e=new AbortController;p.current=e,l(!0),fetch(f(),{signal:e.signal}).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return await e.json()}).then(e=>{s(e),l(!1)}).catch(e=>{e instanceof DOMException&&e.name===`AbortError`||(d(e instanceof Error?e.message:String(e)),l(!1))})},[f])),i(`ws:reconnected`,(0,M.useCallback)(()=>{p.current?.abort();let e=new AbortController;p.current=e,l(!0),fetch(f(),{signal:e.signal}).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return await e.json()}).then(e=>{s(e),l(!1)}).catch(e=>{e instanceof DOMException&&e.name===`AbortError`||(d(e instanceof Error?e.message:String(e)),l(!1))})},[f])),(0,M.useEffect)(()=>()=>{p.current?.abort()},[]),{data:o,isLoading:c,error:u}}var Y=n(),ve=[{key:`haiku`,color:`#38b2ac`,dash:`0`,label:`Haiku`},{key:`sonnet`,color:`#667eea`,dash:`4 2`,label:`Sonnet`},{key:`opus`,color:`#ed8936`,dash:`8 2`,label:`Opus`},{key:`other`,color:`#718096`,dash:`2 2`,label:`Other`}];function ye({perDay:e,isMobile:t}){return e.length===0?null:(0,Y.jsx)(b,{width:`100%`,height:280,children:(0,Y.jsxs)(ge,{data:e.map(e=>({date:e.date,...e.perModel})),margin:{top:10,right:16,left:0,bottom:0},children:[(0,Y.jsx)(T,{dataKey:`date`,tickFormatter:e=>t?e.slice(5):e,stroke:`var(--color-muted, #8a8f99)`}),(0,Y.jsx)(C,{tickFormatter:e=>`$${e.toFixed(2)}`,stroke:`var(--color-muted, #8a8f99)`}),(0,Y.jsx)(m,{formatter:e=>`$${e.toFixed(2)}`,contentStyle:{background:`var(--color-card-bg)`,border:`1px solid var(--color-border)`}}),(0,Y.jsx)(ne,{}),ve.map(e=>(0,Y.jsx)(q,{type:`monotone`,dataKey:e.key,stackId:`1`,stroke:e.color,fill:e.color,fillOpacity:.4,strokeDasharray:e.dash,name:e.label},e.key))]})})}var be=t(r(),1);function X(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o;n.key&&n.debug?.call(n)&&(o=Date.now());let s=e();if(!(s.length!==r.length||s.some((e,t)=>r[t]!==e)))return i;r=s;let c;if(n.key&&n.debug?.call(n)&&(c=Date.now()),i=t(...s),n.key&&n.debug?.call(n)){let e=Math.round((Date.now()-o)*100)/100,t=Math.round((Date.now()-c)*100)/100,r=t/16,i=(e,t)=>{for(e=String(e);e.length<t;)e=` `+e;return e};console.info(`%c⏱ ${i(t,5)} /${i(e,5)} ms`,`
|
|
1
|
+
import{n as e,s as t,t as n}from"./jsx-runtime-Bq3x7umQ.js";import{t as r}from"./react-dom-Cnw6SoYl.js";import{r as i}from"./useWebSocket-Hg3RO6sx.js";import{C as a}from"./events-BK5ucyUu.js";import{t as o}from"./Button-DTO6bgnL.js";import{t as s}from"./Input-iymdcwsf.js";import"./index-DzJsiq8q.js";import{C as c,D as l,E as u,O as d,S as f,T as p,_ as m,a as h,b as g,c as _,d as v,f as y,g as b,k as ee,l as x,m as S,n as C,p as w,r as T,s as E,t as D,u as te,v as O,w as k,x as A,y as ne}from"./generateCategoricalChart-pfORgeJG.js";import{t as j}from"./KpiTile-pXTBj77S.js";var M=t(e()),N=t(d()),P=t(S()),F=t(l()),re=t(u()),I=t(w()),ie=[`layout`,`type`,`stroke`,`connectNulls`,`isRange`,`ref`],ae=[`key`],L;function R(e){"@babel/helpers - typeof";return R=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},R(e)}function z(e,t){if(e==null)return{};var n=oe(e,t),r,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function oe(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function B(){return B=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},B.apply(this,arguments)}function V(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function H(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?V(Object(n),!0).forEach(function(t){G(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):V(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function se(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function ce(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,K(r.key),r)}}function le(e,t,n){return t&&ce(e.prototype,t),n&&ce(e,n),Object.defineProperty(e,`prototype`,{writable:!1}),e}function ue(e,t,n){return t=U(t),de(e,pe()?Reflect.construct(t,n||[],U(e).constructor):t.apply(e,n))}function de(e,t){if(t&&(R(t)===`object`||typeof t==`function`))return t;if(t!==void 0)throw TypeError(`Derived constructors may only return object or undefined`);return fe(e)}function fe(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function pe(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(pe=function(){return!!e})()}function U(e){return U=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},U(e)}function me(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function`);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,`prototype`,{writable:!1}),t&&W(e,t)}function W(e,t){return W=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},W(e,t)}function G(e,t,n){return t=K(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function K(e){var t=he(e,`string`);return R(t)==`symbol`?t:t+``}function he(e,t){if(R(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(R(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var q=function(e){function t(){var e;se(this,t);var n=[...arguments];return e=ue(this,t,[].concat(n)),G(e,`state`,{isAnimationFinished:!0}),G(e,`id`,p(`recharts-area-`)),G(e,`handleAnimationEnd`,function(){var t=e.props.onAnimationEnd;e.setState({isAnimationFinished:!0}),(0,N.default)(t)&&t()}),G(e,`handleAnimationStart`,function(){var t=e.props.onAnimationStart;e.setState({isAnimationFinished:!1}),(0,N.default)(t)&&t()}),e}return me(t,e),le(t,[{key:`renderDots`,value:function(e,n,r){var i=this.props.isAnimationActive,a=this.state.isAnimationFinished;if(i&&!a)return null;var o=this.props,s=o.dot,c=o.points,l=o.dataKey,u=A(this.props,!1),d=A(s,!0),f=c.map(function(e,n){var r=H(H(H({key:`dot-${n}`,r:3},u),d),{},{index:n,cx:e.x,cy:e.y,dataKey:l,value:e.value,payload:e.payload,points:c});return t.renderDotItem(s,r)}),p={clipPath:e?`url(#clipPath-${n?``:`dots-`}${r})`:null};return M.createElement(g,B({className:`recharts-area-dots`},p),f)}},{key:`renderHorizontalRect`,value:function(e){var t=this.props,n=t.baseLine,r=t.points,i=t.strokeWidth,a=r[0].x,o=r[r.length-1].x,s=e*Math.abs(a-o),c=(0,P.default)(r.map(function(e){return e.y||0}));return k(n)&&typeof n==`number`?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max((0,P.default)(n.map(function(e){return e.y||0})),c)),k(c)?M.createElement(`rect`,{x:a<o?a:a-s,y:0,width:s,height:Math.floor(c+(i?parseInt(`${i}`,10):1))}):null}},{key:`renderVerticalRect`,value:function(e){var t=this.props,n=t.baseLine,r=t.points,i=t.strokeWidth,a=r[0].y,o=r[r.length-1].y,s=e*Math.abs(a-o),c=(0,P.default)(r.map(function(e){return e.x||0}));return k(n)&&typeof n==`number`?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max((0,P.default)(n.map(function(e){return e.x||0})),c)),k(c)?M.createElement(`rect`,{x:0,y:a<o?a:a-s,width:c+(i?parseInt(`${i}`,10):1),height:Math.floor(s)}):null}},{key:`renderClipRect`,value:function(e){return this.props.layout===`vertical`?this.renderVerticalRect(e):this.renderHorizontalRect(e)}},{key:`renderAreaStatically`,value:function(e,t,n,r){var i=this.props,a=i.layout,o=i.type,s=i.stroke,c=i.connectNulls,l=i.isRange;i.ref;var u=z(i,ie);return M.createElement(g,{clipPath:n?`url(#clipPath-${r})`:null},M.createElement(x,B({},A(u,!0),{points:e,connectNulls:c,type:o,baseLine:t,layout:a,stroke:`none`,className:`recharts-area-area`})),s!==`none`&&M.createElement(x,B({},A(this.props,!1),{className:`recharts-area-curve`,layout:a,type:o,connectNulls:c,fill:`none`,points:e})),s!==`none`&&l&&M.createElement(x,B({},A(this.props,!1),{className:`recharts-area-curve`,layout:a,type:o,connectNulls:c,fill:`none`,points:t})))}},{key:`renderAreaWithAnimation`,value:function(e,t){var n=this,r=this.props,i=r.points,a=r.baseLine,o=r.isAnimationActive,s=r.animationBegin,l=r.animationDuration,u=r.animationEasing,d=r.animationId,f=this.state,p=f.prevPoints,m=f.prevBaseLine;return M.createElement(_,{begin:s,duration:l,isActive:o,easing:u,from:{t:0},to:{t:1},key:`area-${d}`,onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(r){var o=r.t;if(p){var s=p.length/i.length,l=i.map(function(e,t){var n=Math.floor(t*s);if(p[n]){var r=p[n],i=c(r.x,e.x),a=c(r.y,e.y);return H(H({},e),{},{x:i(o),y:a(o)})}return e}),u=k(a)&&typeof a==`number`?c(m,a)(o):(0,F.default)(a)||(0,re.default)(a)?c(m,0)(o):a.map(function(e,t){var n=Math.floor(t*s);if(m[n]){var r=m[n],i=c(r.x,e.x),a=c(r.y,e.y);return H(H({},e),{},{x:i(o),y:a(o)})}return e});return n.renderAreaStatically(l,u,e,t)}return M.createElement(g,null,M.createElement(`defs`,null,M.createElement(`clipPath`,{id:`animationClipPath-${t}`},n.renderClipRect(o))),M.createElement(g,{clipPath:`url(#animationClipPath-${t})`},n.renderAreaStatically(i,a,e,t)))})}},{key:`renderArea`,value:function(e,t){var n=this.props,r=n.points,i=n.baseLine,a=n.isAnimationActive,o=this.state,s=o.prevPoints,c=o.prevBaseLine,l=o.totalLength;return a&&r&&r.length&&(!s&&l>0||!(0,I.default)(s,r)||!(0,I.default)(c,i))?this.renderAreaWithAnimation(e,t):this.renderAreaStatically(r,i,e,t)}},{key:`render`,value:function(){var e=this.props,t=e.hide,n=e.dot,r=e.points,i=e.className,a=e.top,o=e.left,s=e.xAxis,c=e.yAxis,l=e.width,u=e.height,d=e.isAnimationActive,p=e.id;if(t||!r||!r.length)return null;var m=this.state.isAnimationFinished,h=r.length===1,_=ee(`recharts-area`,i),v=s&&s.allowDataOverflow,y=c&&c.allowDataOverflow,b=v||y,x=(0,F.default)(p)?this.id:p,S=A(n,!1)??{r:3,strokeWidth:2},C=S.r,w=C===void 0?3:C,T=S.strokeWidth,E=T===void 0?2:T,D=(f(n)?n:{}).clipDot,O=D===void 0?!0:D,k=w*2+E;return M.createElement(g,{className:_},v||y?M.createElement(`defs`,null,M.createElement(`clipPath`,{id:`clipPath-${x}`},M.createElement(`rect`,{x:v?o:o-l/2,y:y?a:a-u/2,width:v?l:l*2,height:y?u:u*2})),!O&&M.createElement(`clipPath`,{id:`clipPath-dots-${x}`},M.createElement(`rect`,{x:o-k/2,y:a-k/2,width:l+k,height:u+k}))):null,h?null:this.renderArea(b,x),(n||h)&&this.renderDots(b,O,x),(!d||m)&&te.renderCallByParent(this.props,r))}}],[{key:`getDerivedStateFromProps`,value:function(e,t){return e.animationId===t.prevAnimationId?e.points!==t.curPoints||e.baseLine!==t.curBaseLine?{curPoints:e.points,curBaseLine:e.baseLine}:null:{prevAnimationId:e.animationId,curPoints:e.points,curBaseLine:e.baseLine,prevPoints:t.curPoints,prevBaseLine:t.curBaseLine}}}])}(M.PureComponent);L=q,G(q,`displayName`,`Area`),G(q,`defaultProps`,{stroke:`#3182bd`,fill:`#3182bd`,fillOpacity:.6,xAxisId:0,yAxisId:0,legendType:`line`,connectNulls:!1,points:[],dot:!1,activeDot:!0,hide:!1,isAnimationActive:!O.isSsr,animationBegin:0,animationDuration:1500,animationEasing:`ease`}),G(q,`getBaseValue`,function(e,t,n,r){var i=e.layout,a=e.baseValue,o=t.props.baseValue??a;if(k(o)&&typeof o==`number`)return o;var s=i===`horizontal`?r:n,c=s.scale.domain();if(s.type===`number`){var l=Math.max(c[0],c[1]),u=Math.min(c[0],c[1]);return o===`dataMin`?u:o===`dataMax`||l<0?l:Math.max(Math.min(c[0],c[1]),0)}return o===`dataMin`?c[0]:o===`dataMax`?c[1]:c[0]}),G(q,`getComposedData`,function(e){var t=e.props,n=e.item,r=e.xAxis,i=e.yAxis,a=e.xAxisTicks,o=e.yAxisTicks,s=e.bandSize,c=e.dataKey,l=e.stackedData,u=e.dataStartIndex,d=e.displayedData,f=e.offset,p=t.layout,m=l&&l.length,h=L.getBaseValue(t,n,r,i),g=p===`horizontal`,_=!1,b=d.map(function(e,t){var n;m?n=l[u+t]:(n=y(e,c),Array.isArray(n)?_=!0:n=[h,n]);var d=n[1]==null||m&&y(e,c)==null;return g?{x:v({axis:r,ticks:a,bandSize:s,entry:e,index:t}),y:d?null:i.scale(n[1]),value:n,payload:e}:{x:d?null:r.scale(n[1]),y:v({axis:i,ticks:o,bandSize:s,entry:e,index:t}),value:n,payload:e}});return H({points:b,baseLine:m||_?b.map(function(e){var t=Array.isArray(e.value)?e.value[0]:null;return g?{x:e.x,y:t!=null&&e.y!=null?i.scale(t):null}:{x:t==null?null:r.scale(t),y:e.y}}):g?i.scale(h):r.scale(h),layout:p,isRange:_},f)}),G(q,`renderDotItem`,function(e,t){var n;if(M.isValidElement(e))n=M.cloneElement(e,t);else if((0,N.default)(e))n=e(t);else{var r=ee(`recharts-area-dot`,typeof e==`boolean`?``:e.className),i=t.key,a=z(t,ae);n=M.createElement(E,B({},a,{key:i,className:r}))}return n});var ge=D({chartName:`AreaChart`,GraphicalChild:q,axisComponents:[{axisType:`xAxis`,AxisComp:T},{axisType:`yAxis`,AxisComp:C}],formatAxisMap:h}),J={page:`_page_l9qss_1`,header:`_header_l9qss_2`,title:`_title_l9qss_3`,summary:`_summary_l9qss_4`,kpiGrid:`_kpiGrid_l9qss_5`,banner:`_banner_l9qss_6`,footer:`_footer_l9qss_7`,windowSeg:`_windowSeg_l9qss_8`,empty:`_empty_l9qss_10`,emptyHint:`_emptyHint_l9qss_11`,skeletonTile:`_skeletonTile_l9qss_12`,"usage-shimmer":`_usage-shimmer_l9qss_1`};function _e(e={}){let{window:t=`today`,start:n,end:r}=e,[o,s]=(0,M.useState)(null),[c,l]=(0,M.useState)(!0),[u,d]=(0,M.useState)(null),f=(0,M.useCallback)(()=>{let e=new URLSearchParams({window:t});return n&&e.set(`start`,n),r&&e.set(`end`,r),`/api/usage/pipeline?${e.toString()}`},[t,n,r]);(0,M.useEffect)(()=>{let e=new AbortController;return l(!0),d(null),fetch(f(),{signal:e.signal}).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status} ${e.statusText||``}`.trim());return await e.json()}).then(e=>{s(e),l(!1)}).catch(e=>{e instanceof DOMException&&e.name===`AbortError`||(d(e instanceof Error?e.message:String(e)),l(!1))}),()=>e.abort()},[f]);let p=(0,M.useRef)(null);return i(a,(0,M.useCallback)(()=>{p.current?.abort();let e=new AbortController;p.current=e,l(!0),fetch(f(),{signal:e.signal}).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return await e.json()}).then(e=>{s(e),l(!1)}).catch(e=>{e instanceof DOMException&&e.name===`AbortError`||(d(e instanceof Error?e.message:String(e)),l(!1))})},[f])),i(`ws:reconnected`,(0,M.useCallback)(()=>{p.current?.abort();let e=new AbortController;p.current=e,l(!0),fetch(f(),{signal:e.signal}).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return await e.json()}).then(e=>{s(e),l(!1)}).catch(e=>{e instanceof DOMException&&e.name===`AbortError`||(d(e instanceof Error?e.message:String(e)),l(!1))})},[f])),(0,M.useEffect)(()=>()=>{p.current?.abort()},[]),{data:o,isLoading:c,error:u}}var Y=n(),ve=[{key:`haiku`,color:`#38b2ac`,dash:`0`,label:`Haiku`},{key:`sonnet`,color:`#667eea`,dash:`4 2`,label:`Sonnet`},{key:`opus`,color:`#ed8936`,dash:`8 2`,label:`Opus`},{key:`other`,color:`#718096`,dash:`2 2`,label:`Other`}];function ye({perDay:e,isMobile:t}){return e.length===0?null:(0,Y.jsx)(b,{width:`100%`,height:280,children:(0,Y.jsxs)(ge,{data:e.map(e=>({date:e.date,...e.perModel})),margin:{top:10,right:16,left:0,bottom:0},children:[(0,Y.jsx)(T,{dataKey:`date`,tickFormatter:e=>t?e.slice(5):e,stroke:`var(--color-muted, #8a8f99)`}),(0,Y.jsx)(C,{tickFormatter:e=>`$${e.toFixed(2)}`,stroke:`var(--color-muted, #8a8f99)`}),(0,Y.jsx)(m,{formatter:e=>`$${e.toFixed(2)}`,contentStyle:{background:`var(--color-card-bg)`,border:`1px solid var(--color-border)`}}),(0,Y.jsx)(ne,{}),ve.map(e=>(0,Y.jsx)(q,{type:`monotone`,dataKey:e.key,stackId:`1`,stroke:e.color,fill:e.color,fillOpacity:.4,strokeDasharray:e.dash,name:e.label},e.key))]})})}var be=t(r(),1);function X(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o;n.key&&n.debug?.call(n)&&(o=Date.now());let s=e();if(!(s.length!==r.length||s.some((e,t)=>r[t]!==e)))return i;r=s;let c;if(n.key&&n.debug?.call(n)&&(c=Date.now()),i=t(...s),n.key&&n.debug?.call(n)){let e=Math.round((Date.now()-o)*100)/100,t=Math.round((Date.now()-c)*100)/100,r=t/16,i=(e,t)=>{for(e=String(e);e.length<t;)e=` `+e;return e};console.info(`%c⏱ ${i(t,5)} /${i(e,5)} ms`,`
|
|
2
2
|
font-size: .6rem;
|
|
3
3
|
font-weight: bold;
|
|
4
|
-
color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n?.key)}return n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i}return o.updateDeps=e=>{r=e},o}function Z(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var xe=(e,t)=>Math.abs(e-t)<1.01,Se=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},Ce=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},we=e=>e,Te=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let e=t;e<=n;e++)r.push(e);return r},Ee=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(Ce(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(Ce(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},De={passive:!0},Oe=typeof window>`u`?!0:`onscrollend`in window,ke=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=0,a=e.options.useScrollendEvent&&Oe?()=>void 0:Se(r,()=>{t(i,!1)},e.options.isScrollingResetDelay),o=r=>()=>{let{horizontal:o,isRtl:s}=e.options;i=o?n.scrollLeft*(s&&-1||1):n.scrollTop,a(),t(i,r)},s=o(!0),c=o(!1);n.addEventListener(`scroll`,s,De);let l=e.options.useScrollendEvent&&Oe;return l&&n.addEventListener(`scrollend`,c,De),()=>{n.removeEventListener(`scroll`,s),l&&n.removeEventListener(`scrollend`,c)}},Ae=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},je=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;let o=e+t;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:o,behavior:n})},Me=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([t,n])=>{n===void 0&&delete e[t]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:we,rangeExtractor:Te,onChange:()=>{},measureElement:Ae,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,...e}},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=X(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=X(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(e,t,n,r,i,a,o)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o}),{key:!1}),this.getMeasurements=X(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o},s)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let c=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1);let l=this.measurementsCache.slice(0,c),u=Array(a).fill(void 0);for(let e=0;e<c;e++){let t=l[e];t&&(u[t.lane]=e)}for(let i=c;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),c,d,f=o===`estimate`||s.has(e);if(a!==void 0&&this.options.lanes>1){c=a;let e=u[c],r=e===void 0?void 0:l[e];d=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?l[i-1]:this.getFurthestMeasurement(l,i);d=e?e.end+this.options.gap:t+n,c=e?e.lane:i%this.options.lanes,this.options.lanes>1&&f&&this.laneAssignments.set(i,c)}let p=s.get(e),m=typeof p==`number`?p:this.options.estimateSize(i),h=d+m;l[i]={index:i,start:d,size:m,end:h,key:e,lane:c},u[c]=i}return this.measurementsCache=l,l},{key:!1,debug:()=>this.options.debug}),this.calculateRange=X(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?Pe({measurements:e,outerSize:t,scrollOffset:n,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=X(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{let n=this.measurementsCache[e];if(!n)return;let r=t-(this.itemSizeCache.get(n.key)??n.size);r!==0&&(this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?n.start<this.getScrollOffset()+this.scrollAdjustments:this.shouldAdjustScrollPositionOnItemSizeChange(n,r,this))&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=r,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(n.index),this.itemSizeCache=new Map(this.itemSizeCache.set(n.key,t)),this.notify(!1))},this.getVirtualItems=X(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length!==0)return Z(t[Ne(0,t.length-1,e=>Z(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1)t=e[e.length-1]?.end??0;else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&xe(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.scrollState=null;return}}else this.scrollState.stableFrames=0,n&&(this.scrollState.lastTargetOffset=t,this.scrollState.behavior=`auto`,this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}));this.scheduleScrollReconcile()}},Ne=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function Pe({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){let i=e.length-1,a=t=>e[t].start;if(e.length<=r)return{startIndex:0,endIndex:i};let o=Ne(0,i,a,n),s=o;if(r===1)for(;s<i&&e[s].end<n+t;)s++;else if(r>1){let a=Array(r).fill(0);for(;s<i&&a.some(e=>e<n+t);){let t=e[s];a[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(i,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var Fe=typeof document<`u`?M.useLayoutEffect:M.useEffect;function Ie({useFlushSync:e=!0,...t}){let n=M.useReducer(()=>({}),{})[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,be.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=M.useState(()=>new Me(r));return i.setOptions(r),Fe(()=>i._didMount(),[]),Fe(()=>i._willUpdate()),i}function Le(e){return Ie({observeElementRect:Ee,observeElementOffset:ke,scrollToFn:je,...e})}var Q={wrap:`_wrap_y1zsk_1`,controls:`_controls_y1zsk_7`,table:`_table_y1zsk_13`,virtualScroll:`_virtualScroll_y1zsk_18`,virtualInner:`_virtualInner_y1zsk_24`,virtualRow:`_virtualRow_y1zsk_28`,footer:`_footer_y1zsk_35`,tier:`_tier_y1zsk_43`},Re=e=>e.includes(`haiku`)?`[H]`:e.includes(`sonnet`)?`[S]`:e.includes(`opus`)?`[O]`:`[?]`;function ze({rows:e,onIdeaClick:t}){let[n,r]=(0,M.useState)(`cost`),[i,a]=(0,M.useState)(!1),o=(0,M.useMemo)(()=>{let t=[...e];return n===`cost`?t.sort((e,t)=>(t.costUsd??-1)-(e.costUsd??-1)):n===`tokens`?t.sort((e,t)=>(t.tokensIn??0)+(t.tokensOut??0)-((e.tokensIn??0)+(e.tokensOut??0))):t.sort((e,t)=>t.timestamp.localeCompare(e.timestamp)),t},[e,n]),c=i?o:o.slice(0,100),l=(0,M.useRef)(null),u=Le({count:i?c.length:0,getScrollElement:()=>l.current,estimateSize:()=>48}),d=e=>(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{children:(0,Y.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>t(e.ideaId),title:e.ideaId,children:e.ideaId.slice(0,24)})}),(0,Y.jsx)(`td`,{children:e.phase}),(0,Y.jsxs)(`td`,{children:[(0,Y.jsx)(`span`,{className:Q.tier,children:Re(e.model)}),` `,e.model.replace(`claude-`,``)]}),(0,Y.jsx)(`td`,{children:e.tokensIn==null?(0,Y.jsx)(`span`,{"aria-label":`No token data`,children:`—`}):new Intl.NumberFormat(void 0,{notation:`compact`}).format((e.tokensIn??0)+(e.tokensOut??0))}),(0,Y.jsx)(`td`,{children:e.costUsd==null?(0,Y.jsx)(`span`,{"aria-label":`No cost data`,children:`—`}):new Intl.NumberFormat(void 0,{style:`currency`,currency:`USD`}).format(e.costUsd)})]},`${e.ideaId}:${e.phase}:${e.timestamp}`);return(0,Y.jsxs)(`div`,{className:Q.wrap,children:[(0,Y.jsxs)(`div`,{className:Q.controls,children:[(0,Y.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>r(`cost`),children:`Sort: Cost`}),(0,Y.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>r(`tokens`),children:`Sort: Tokens`}),(0,Y.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>r(`date`),children:`Sort: Date`})]}),i?(0,Y.jsx)(`div`,{ref:l,className:Q.virtualScroll,children:(0,Y.jsx)(`div`,{className:Q.virtualInner,style:{height:u.getTotalSize()},children:u.getVirtualItems().map(e=>(0,Y.jsx)(`div`,{className:Q.virtualRow,style:{transform:`translateY(${e.start}px)`},children:(0,Y.jsx)(`table`,{className:Q.table,children:(0,Y.jsx)(`tbody`,{children:d(c[e.index])})})},e.key))})}):(0,Y.jsxs)(`table`,{className:Q.table,children:[(0,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`th`,{children:`Idea`}),(0,Y.jsx)(`th`,{children:`Phase`}),(0,Y.jsx)(`th`,{children:`Model`}),(0,Y.jsx)(`th`,{children:`Tokens`}),(0,Y.jsx)(`th`,{children:`Cost`})]})}),(0,Y.jsx)(`tbody`,{children:c.map(d)})]}),!i&&e.length>100&&(0,Y.jsxs)(`div`,{className:Q.footer,children:[`Showing 100 of `,e.length,` rows. `,(0,Y.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>a(!0),children:`Show all`})]})]})}var Be=[`today`,`week`,`month`,`all`,`custom`],Ve=`tos.usage.window`,$=`tos.usage.customStart`,He=`tos.usage.customEnd`;function Ue(){let e=localStorage.getItem(Ve);return Be.includes(e??``)?e:`today`}function We(){let[e,t]=(0,M.useState)(typeof window<`u`?window.innerWidth:1024);return(0,M.useEffect)(()=>{let e=()=>t(window.innerWidth);return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),e}var Ge={today:`Today`,week:`Week`,month:`Month`,all:`All`,custom:`Custom`};function Ke({onIdeaClick:e}){let[t,n]=(0,M.useState)(Ue()),[r,i]=(0,M.useState)(()=>localStorage.getItem($)??``),[a,c]=(0,M.useState)(()=>localStorage.getItem(He)??``);(0,M.useEffect)(()=>{localStorage.setItem(Ve,t)},[t]),(0,M.useEffect)(()=>{localStorage.setItem($,r)},[r]),(0,M.useEffect)(()=>{localStorage.setItem(He,a)},[a]);let{data:l,isLoading:u,error:d}=_e({window:t,start:r||void 0,end:a||void 0}),f=We()<=640;return(0,Y.jsxs)(`div`,{className:J.page,children:[(0,Y.jsxs)(`div`,{className:J.header,children:[(0,Y.jsx)(`h1`,{className:J.title,children:`Usage`}),(0,Y.jsx)(`div`,{className:J.windowSeg,children:Be.map(e=>(0,Y.jsx)(s,{onClick:()=>n(e),"aria-pressed":t===e,children:Ge[e]},e))})]}),t===`custom`&&(0,Y.jsxs)(`div`,{className:J.summary,children:[(0,Y.jsx)(o,{type:`date`,value:r,onChange:e=>i(e.target.value),"aria-label":`Start date`}),` `,(0,Y.jsx)(o,{type:`date`,value:a,onChange:e=>c(e.target.value),"aria-label":`End date`})]}),l&&l.pricingMissingFor.length>0&&(0,Y.jsxs)(`div`,{className:J.banner,children:[`Pricing missing for `,l.pricingMissingFor.join(`, `),` (cost shown is a ceiling estimate).`]}),d&&(0,Y.jsxs)(`div`,{className:J.banner,children:[`Error: `,d]}),u&&(0,Y.jsx)(`div`,{className:J.kpiGrid,children:[0,1,2,3].map(e=>(0,Y.jsx)(`div`,{className:J.skeletonTile},e))}),!u&&l&&l.perRow.length===0&&(0,Y.jsxs)(`div`,{className:J.empty,children:[(0,Y.jsx)(`div`,{children:`No usage in this window`}),(0,Y.jsx)(`div`,{className:J.emptyHint,children:`Try widening the range`})]}),!u&&l&&l.perRow.length>0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:J.kpiGrid,children:[(0,Y.jsx)(j,{label:`Total cost`,value:new Intl.NumberFormat(void 0,{style:`currency`,currency:`USD`}).format(l.totalCostUsd)}),(0,Y.jsx)(j,{label:`Total tokens`,value:new Intl.NumberFormat(void 0,{notation:`compact`}).format(l.totalTokens)}),(0,Y.jsx)(j,{label:`Cache hit rate`,value:`${(l.cacheHitRate*100).toFixed(1)}%`}),(0,Y.jsx)(j,{label:`Phases run`,value:String(l.phasesRun)})]}),(0,Y.jsx)(ye,{perDay:l.perDay,isMobile:f}),(0,Y.jsx)(ze,{rows:l.perRow,onIdeaClick:e}),(0,Y.jsxs)(`div`,{className:J.footer,children:[`Override pricing via `,(0,Y.jsx)(`code`,{children:`teamos config set pricing.<model>.<key> <usd>`}),`.`]})]})]})}export{Ke as UsagePage};
|
|
4
|
+
color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n?.key)}return n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i}return o.updateDeps=e=>{r=e},o}function Z(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var xe=(e,t)=>Math.abs(e-t)<1.01,Se=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},Ce=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},we=e=>e,Te=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let e=t;e<=n;e++)r.push(e);return r},Ee=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(Ce(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(Ce(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},De={passive:!0},Oe=typeof window>`u`?!0:`onscrollend`in window,ke=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=0,a=e.options.useScrollendEvent&&Oe?()=>void 0:Se(r,()=>{t(i,!1)},e.options.isScrollingResetDelay),o=r=>()=>{let{horizontal:o,isRtl:s}=e.options;i=o?n.scrollLeft*(s&&-1||1):n.scrollTop,a(),t(i,r)},s=o(!0),c=o(!1);n.addEventListener(`scroll`,s,De);let l=e.options.useScrollendEvent&&Oe;return l&&n.addEventListener(`scrollend`,c,De),()=>{n.removeEventListener(`scroll`,s),l&&n.removeEventListener(`scrollend`,c)}},Ae=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},je=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;let o=e+t;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:o,behavior:n})},Me=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([t,n])=>{n===void 0&&delete e[t]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:we,rangeExtractor:Te,onChange:()=>{},measureElement:Ae,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,...e}},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=X(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=X(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(e,t,n,r,i,a,o)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o}),{key:!1}),this.getMeasurements=X(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o},s)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let c=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1);let l=this.measurementsCache.slice(0,c),u=Array(a).fill(void 0);for(let e=0;e<c;e++){let t=l[e];t&&(u[t.lane]=e)}for(let i=c;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),c,d,f=o===`estimate`||s.has(e);if(a!==void 0&&this.options.lanes>1){c=a;let e=u[c],r=e===void 0?void 0:l[e];d=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?l[i-1]:this.getFurthestMeasurement(l,i);d=e?e.end+this.options.gap:t+n,c=e?e.lane:i%this.options.lanes,this.options.lanes>1&&f&&this.laneAssignments.set(i,c)}let p=s.get(e),m=typeof p==`number`?p:this.options.estimateSize(i),h=d+m;l[i]={index:i,start:d,size:m,end:h,key:e,lane:c},u[c]=i}return this.measurementsCache=l,l},{key:!1,debug:()=>this.options.debug}),this.calculateRange=X(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?Pe({measurements:e,outerSize:t,scrollOffset:n,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=X(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{let n=this.measurementsCache[e];if(!n)return;let r=t-(this.itemSizeCache.get(n.key)??n.size);r!==0&&(this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?n.start<this.getScrollOffset()+this.scrollAdjustments:this.shouldAdjustScrollPositionOnItemSizeChange(n,r,this))&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=r,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(n.index),this.itemSizeCache=new Map(this.itemSizeCache.set(n.key,t)),this.notify(!1))},this.getVirtualItems=X(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length!==0)return Z(t[Ne(0,t.length-1,e=>Z(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1)t=e[e.length-1]?.end??0;else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&xe(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.scrollState=null;return}}else this.scrollState.stableFrames=0,n&&(this.scrollState.lastTargetOffset=t,this.scrollState.behavior=`auto`,this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}));this.scheduleScrollReconcile()}},Ne=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function Pe({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){let i=e.length-1,a=t=>e[t].start;if(e.length<=r)return{startIndex:0,endIndex:i};let o=Ne(0,i,a,n),s=o;if(r===1)for(;s<i&&e[s].end<n+t;)s++;else if(r>1){let a=Array(r).fill(0);for(;s<i&&a.some(e=>e<n+t);){let t=e[s];a[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(i,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var Fe=typeof document<`u`?M.useLayoutEffect:M.useEffect;function Ie({useFlushSync:e=!0,...t}){let n=M.useReducer(()=>({}),{})[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,be.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=M.useState(()=>new Me(r));return i.setOptions(r),Fe(()=>i._didMount(),[]),Fe(()=>i._willUpdate()),i}function Le(e){return Ie({observeElementRect:Ee,observeElementOffset:ke,scrollToFn:je,...e})}var Q={wrap:`_wrap_y1zsk_1`,controls:`_controls_y1zsk_7`,table:`_table_y1zsk_13`,virtualScroll:`_virtualScroll_y1zsk_18`,virtualInner:`_virtualInner_y1zsk_24`,virtualRow:`_virtualRow_y1zsk_28`,footer:`_footer_y1zsk_35`,tier:`_tier_y1zsk_43`},Re=e=>e.includes(`haiku`)?`[H]`:e.includes(`sonnet`)?`[S]`:e.includes(`opus`)?`[O]`:`[?]`;function ze({rows:e,onIdeaClick:t}){let[n,r]=(0,M.useState)(`cost`),[i,a]=(0,M.useState)(!1),s=(0,M.useMemo)(()=>{let t=[...e];return n===`cost`?t.sort((e,t)=>(t.costUsd??-1)-(e.costUsd??-1)):n===`tokens`?t.sort((e,t)=>(t.tokensIn??0)+(t.tokensOut??0)-((e.tokensIn??0)+(e.tokensOut??0))):t.sort((e,t)=>t.timestamp.localeCompare(e.timestamp)),t},[e,n]),c=i?s:s.slice(0,100),l=(0,M.useRef)(null),u=Le({count:i?c.length:0,getScrollElement:()=>l.current,estimateSize:()=>48}),d=e=>(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{children:(0,Y.jsx)(o,{variant:`ghost`,size:`sm`,onClick:()=>t(e.ideaId),title:e.ideaId,children:e.ideaId.slice(0,24)})}),(0,Y.jsx)(`td`,{children:e.phase}),(0,Y.jsxs)(`td`,{children:[(0,Y.jsx)(`span`,{className:Q.tier,children:Re(e.model)}),` `,e.model.replace(`claude-`,``)]}),(0,Y.jsx)(`td`,{children:e.tokensIn==null?(0,Y.jsx)(`span`,{"aria-label":`No token data`,children:`—`}):new Intl.NumberFormat(void 0,{notation:`compact`}).format((e.tokensIn??0)+(e.tokensOut??0))}),(0,Y.jsx)(`td`,{children:e.costUsd==null?(0,Y.jsx)(`span`,{"aria-label":`No cost data`,children:`—`}):new Intl.NumberFormat(void 0,{style:`currency`,currency:`USD`}).format(e.costUsd)})]},`${e.ideaId}:${e.phase}:${e.timestamp}`);return(0,Y.jsxs)(`div`,{className:Q.wrap,children:[(0,Y.jsxs)(`div`,{className:Q.controls,children:[(0,Y.jsx)(o,{variant:`ghost`,size:`sm`,onClick:()=>r(`cost`),children:`Sort: Cost`}),(0,Y.jsx)(o,{variant:`ghost`,size:`sm`,onClick:()=>r(`tokens`),children:`Sort: Tokens`}),(0,Y.jsx)(o,{variant:`ghost`,size:`sm`,onClick:()=>r(`date`),children:`Sort: Date`})]}),i?(0,Y.jsx)(`div`,{ref:l,className:Q.virtualScroll,children:(0,Y.jsx)(`div`,{className:Q.virtualInner,style:{height:u.getTotalSize()},children:u.getVirtualItems().map(e=>(0,Y.jsx)(`div`,{className:Q.virtualRow,style:{transform:`translateY(${e.start}px)`},children:(0,Y.jsx)(`table`,{className:Q.table,children:(0,Y.jsx)(`tbody`,{children:d(c[e.index])})})},e.key))})}):(0,Y.jsxs)(`table`,{className:Q.table,children:[(0,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`th`,{children:`Idea`}),(0,Y.jsx)(`th`,{children:`Phase`}),(0,Y.jsx)(`th`,{children:`Model`}),(0,Y.jsx)(`th`,{children:`Tokens`}),(0,Y.jsx)(`th`,{children:`Cost`})]})}),(0,Y.jsx)(`tbody`,{children:c.map(d)})]}),!i&&e.length>100&&(0,Y.jsxs)(`div`,{className:Q.footer,children:[`Showing 100 of `,e.length,` rows. `,(0,Y.jsx)(o,{variant:`ghost`,size:`sm`,onClick:()=>a(!0),children:`Show all`})]})]})}var Be=[`today`,`week`,`month`,`all`,`custom`],Ve=`tos.usage.window`,$=`tos.usage.customStart`,He=`tos.usage.customEnd`;function Ue(){let e=localStorage.getItem(Ve);return Be.includes(e??``)?e:`today`}function We(){let[e,t]=(0,M.useState)(typeof window<`u`?window.innerWidth:1024);return(0,M.useEffect)(()=>{let e=()=>t(window.innerWidth);return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),e}var Ge={today:`Today`,week:`Week`,month:`Month`,all:`All`,custom:`Custom`};function Ke({onIdeaClick:e}){let[t,n]=(0,M.useState)(Ue()),[r,i]=(0,M.useState)(()=>localStorage.getItem($)??``),[a,c]=(0,M.useState)(()=>localStorage.getItem(He)??``);(0,M.useEffect)(()=>{localStorage.setItem(Ve,t)},[t]),(0,M.useEffect)(()=>{localStorage.setItem($,r)},[r]),(0,M.useEffect)(()=>{localStorage.setItem(He,a)},[a]);let{data:l,isLoading:u,error:d}=_e({window:t,start:r||void 0,end:a||void 0}),f=We()<=640;return(0,Y.jsxs)(`div`,{className:J.page,children:[(0,Y.jsxs)(`div`,{className:J.header,children:[(0,Y.jsx)(`h1`,{className:J.title,children:`Usage`}),(0,Y.jsx)(`div`,{className:J.windowSeg,children:Be.map(e=>(0,Y.jsx)(o,{onClick:()=>n(e),"aria-pressed":t===e,children:Ge[e]},e))})]}),t===`custom`&&(0,Y.jsxs)(`div`,{className:J.summary,children:[(0,Y.jsx)(s,{type:`date`,value:r,onChange:e=>i(e.target.value),"aria-label":`Start date`}),` `,(0,Y.jsx)(s,{type:`date`,value:a,onChange:e=>c(e.target.value),"aria-label":`End date`})]}),l&&l.pricingMissingFor.length>0&&(0,Y.jsxs)(`div`,{className:J.banner,children:[`Pricing missing for `,l.pricingMissingFor.join(`, `),` (cost shown is a ceiling estimate).`]}),d&&(0,Y.jsxs)(`div`,{className:J.banner,children:[`Error: `,d]}),u&&(0,Y.jsx)(`div`,{className:J.kpiGrid,children:[0,1,2,3].map(e=>(0,Y.jsx)(`div`,{className:J.skeletonTile},e))}),!u&&l&&l.perRow.length===0&&(0,Y.jsxs)(`div`,{className:J.empty,children:[(0,Y.jsx)(`div`,{children:`No usage in this window`}),(0,Y.jsx)(`div`,{className:J.emptyHint,children:`Try widening the range`})]}),!u&&l&&l.perRow.length>0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:J.kpiGrid,children:[(0,Y.jsx)(j,{label:`Total cost`,value:new Intl.NumberFormat(void 0,{style:`currency`,currency:`USD`}).format(l.totalCostUsd)}),(0,Y.jsx)(j,{label:`Total tokens`,value:new Intl.NumberFormat(void 0,{notation:`compact`}).format(l.totalTokens)}),(0,Y.jsx)(j,{label:`Cache hit rate`,value:`${(l.cacheHitRate*100).toFixed(1)}%`}),(0,Y.jsx)(j,{label:`Phases run`,value:String(l.phasesRun)})]}),(0,Y.jsx)(ye,{perDay:l.perDay,isMobile:f}),(0,Y.jsx)(ze,{rows:l.perRow,onIdeaClick:e}),(0,Y.jsxs)(`div`,{className:J.footer,children:[`Override pricing via `,(0,Y.jsx)(`code`,{children:`teamos config set pricing.<model>.<key> <usd>`}),`.`]})]})]})}export{Ke as UsagePage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=`session:jsonl-append`,t=`session:jsonl-reset`,n=`session:passthrough-input`,r=`board:updated`,i=`gateway:restart-pending`,a=`ideas:reconciler-update`,o=`ideas:reconciler-run-recorded`,s=`ideas:migration-complete`,c=`usage:phase-complete`,l=`profile.state`,u=`spawn-profile:updated`,d=`heartbeat:tick:complete`,f=`heartbeat:tick:skipped`,p=`verifier.update`,m=`pr-auto-fix:state`,h=`supervisor.event`,g=`ci:dispatch-started`,_=`ci:no-findings`,v=`ci:pr-opened`,y=`ci:pr-merged`,b=`ci:pr-rejected`,x=`ci:error`,S=`ci:throttle-applied`;export{
|
|
1
|
+
var e=`session:jsonl-append`,t=`session:jsonl-reset`,n=`session:passthrough-input`,r=`board:updated`,i=`gateway:restart-pending`,a=`ideas:reconciler-update`,o=`ideas:reconciler-run-recorded`,s=`ideas:migration-complete`,c=`usage:phase-complete`,l=`profile.state`,u=`spawn-profile:updated`,d=`heartbeat:tick:complete`,f=`heartbeat:tick:skipped`,p=`verifier.update`,m=`pr-auto-fix:state`,h=`supervisor.event`,g=`ci:dispatch-started`,_=`ci:no-findings`,v=`ci:pr-opened`,y=`ci:pr-merged`,b=`ci:pr-rejected`,x=`ci:error`,S=`ci:throttle-applied`,C=`supervisor.remediation`;export{c as C,C as S,e as _,y as a,u as b,S as c,f as d,s as f,m as g,l as h,_ as i,i as l,a as m,g as n,v as o,o as p,x as r,b as s,r as t,d as u,t as v,p as w,h as x,n as y};
|