PageSourceSearch

https://app.rudys.ai/assets/WorkspaceDetail-D4Fgs0d3.js

js rudys.ai collected 2026-09-25 19:10:37 UTC 76,072 bytes, 31 lines download raw bytes

1import{s as de,r as a,c as j,j as e,i as k,C as K,B as i,X as V,aG as te,al as D,l as g,au as Xe,aw as Oe,ax as Pe,ay as ze,az as Ue,aA as Ge,I as Q,aB as Be,aC as He,E as wt,R as Xt,L as yt,ah as fe,ai as je,aj as ge,ak as Ne,av as We,ab as qe,ac as Ve,ad as Ye,ae as Ke,af as U,aF as Ze,aJ as Qt,u as ea,a7 as ce,aO as xt,b1 as ht,ar as Je,$ as bs,ao as kt,aE as sa,aH as ta,W as _t,q as ut,aD as vs,as as aa,ap as na,by as ra,Z as la,an as ia}from"./index-CP6ltJpz.js";import{S as ca}from"./switch-f4kTJhsW.js";import{T as da,a as oa,b as le,c as ie}from"./tabs-VdLGVsKF.js";import{T as Me,a as Ie,b as se,c as b,d as Fe,e as v}from"./table-uXwM4qkk.js";import{G as ma,P as xa}from"./progress-BRF4okBn.js";import{T as ws}from"./triangle-alert-DkKBMqo-.js";import{C as ha}from"./circle-pause-TY3WVKyG.js";import{f as Qe}from"./format-CKHqWWuY.js";import{C as ua}from"./chevron-left-DzfQjrO0.js";import{G as ys}from"./gauge-BcltYqQj.js";import{A as pt}from"./arrow-right-left-CjqRBYwP.js";import{R as pa}from"./rotate-ccw-CsA3iFpw.js";import{D as Ct}from"./dollar-sign-Bqim0eQx.js";import{T as fa}from"./trending-up-DsR__n04.js";import{U as ft}from"./user-plus-DFYc6it3.js";import{Z as ja}from"./zap-kNHihPQG.js";import{M as ga}from"./mail-BxKMHoaO.js";import"./en-US-wfBU2YNu.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const Na=de("Cpu",[["rect",{width:"16",height:"16",x:"4",y:"4",rx:"2",key:"14l7u7"}],["rect",{width:"6",height:"6",x:"9",y:"9",rx:"1",key:"5aljv4"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}
6],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]]);/**
7 * @license lucide-react v0.462.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const ba=de("Inbox",[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]]);/**
12 * @license lucide-react v0.462.0 - ISC
13 *
14 * This source code is licensed under the ISC license.
15 * See the LICENSE file in the root directory of this source tree.
16 */const va=de("MailOpen",[["path",{d:"M21.2 8.4c.5.38.8.97.8 1.6v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V10a2 2 0 0 1 .8-1.6l8-6a2 2 0 0 1 2.4 0l8 6Z",key:"1jhwl8"}],["path",{d:"m22 10-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 10",key:"1qfld7"}]]);/**
17 * @license lucide-react v0.462.0 - ISC
18 *
19 * This source code is licensed under the ISC license.
20 * See the LICENSE file in the root directory of this source tree.
21 */const wa=de("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);/**
22 * @license lucide-react v0.462.0 - ISC
23 *
24 * This source code is licensed under the ISC license.
25 * See the LICENSE file in the root directory of this source tree.
26 */const jt=de("Radio",[["path",{d:"M4.9 19.1C1 15.2 1 8.8 4.9 4.9",key:"1vaf9d"}],["path",{d:"M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5",key:"u1ii0m"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5",key:"1j5fej"}],["path",{d:"M19.1 4.9C23 8.8 23 15.1 19.1 19",key:"10b0cb"}]]);/**
27 * @license lucide-react v0.462.0 - ISC
28 *
29 * This source code is licensed under the ISC license.
30 * See the LICENSE file in the root directory of this source tree.
31 */const ya=de("Settings2",[["path",{d:"M20 7h-9",key:"3s1dr2"}],["path",{d:"M14 17H5",key:"gfn3mx"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]),gt={off:e.jsx(ha,{className:"h-4 w-4 text-muted-foreground"}),shadow:e.jsx(wt,{className:"h-4 w-4 text-blue-600"}),live:e.jsx(Xt,{className:"h-4 w-4 text-amber-600"})},Nt={auto:"text-green-700 bg-green-50 border-green-200",always_ask:"text-blue-700 bg-blue-50 border-blue-200",unlisted:"text-blue-700 bg-blue-50 border-blue-200",off:"text-muted-foreground bg-muted/50 border-muted",never:"text-red-700 bg-red-50 border-red-200"},bt={APPLIED:"text-green-700 bg-green-50 border-green-200",NEEDS_YOU:"text-blue-700 bg-blue-50 border-blue-200",REFUSED:"text-red-700 bg-red-50 border-red-200",EVALUATING:"text-muted-foreground bg-muted/50 border-muted"};function ka({workspaceId:d}){const[m,I]=a.useState(null),[Z,F]=a.useState(!0),[R,E]=a.useState(null),[h,O]=a.useState(null),[p,P]=a.useState(null),[o,A]=a.useState(null),[z,T]=a.useState(""),Y=a.useCallback(async()=>{var t,x;try{const N=await j.get(`/admin/workspace-usage/autopilot/${d}`);I(N.data)}catch(N){O(((x=(t=N.response)==null?void 0:t.data)==null?void 0:x.detail)||"Could not load autopilot settings.")}finally{F(!1)}},[d]);a.useEffect(()=>{Y()},[Y]);const B=async(t,x)=>{var N,M;O(null),P(null),E(t);try{const H=await j.put(`/admin/workspace-usage/autopilot/${d}`,{preset:t,confirm:x});I(H.data);const _=H.data.presets.find(W=>W.name===t);P(`Autopilot set to “${(_==null?void 0:_.label)||t}”.`)}catch(H){O(((M=(N=H.response)==null?void 0:N.data)==null?void 0:M.detail)||"Could not change the setting.")}finally{E(null),A(null),T("")}},S=async t=>{var x,N;O(null),P(null);try{const M=await j.delete(`/admin/workspace-usage/autopilot/${d}/breaker/${encodeURIComponent(t)}`);I(M.data),P("Capability re-armed. Autopilot may apply it again.")}catch(M){O(((N=(x=M.response)==null?void 0:x.data)==null?void 0:N.detail)||"Could not clear the demotion.")}},G=t=>{if(!R){if(t.requires_confirmation){T(""),A(t);return}B(t.name)}};if(Z)return e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-8",children:[e.jsx(k,{className:"h-4 w-4 animate-spin"}),"Loading autopilot settings…"]});if(!m)return e.jsxs("div",{className:"flex items-start gap-2 p-3 bg-red-50 border border-red-200 rounded-lg",children:[e.jsx(K,{className:"h-4 w-4 text-red-600 flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"flex-1 text-sm text-red-700",children:h||"Autopilot settings unavailable."})]});const l=m.counts.APPLIED||0,f=m.counts.NEEDS_YOU||0,w=m.counts.REFUSED||0;return e.jsxs("div",{className:"max-w-3xl",children:[h&&e.jsxs("div",{className:"flex items-start gap-2 p-3 bg-red-50 border border-red-200 rounded-lg mb-4",children:[e.jsx(K,{className:"h-4 w-4 text-red-600 flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"flex-1 text-sm text-red-700",children:h}),e.jsx(i,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>O(null),children:e.jsx(V,{className:"h-3.5 w-3.5"})})]}),p&&e.jsxs("div",{className:"flex items-start gap-2 p-3 bg-green-50 border border-green-200 rounded-lg mb-4",children:[e.jsx(te,{className:"h-4 w-4 text-green-600 flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"flex-1 text-sm text-green-700",children:p}),e.jsx(i,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>P(null),children:e.jsx(V,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx(D,{className:"text-sm font-medium block",children:"How much Rudy decides alone"}),e.jsx("a",{href:"/admin/autopilot-presets",className:"text-xs text-muted-foreground underline underline-offset-2 hover:text-foreground",children:"Manage presets"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Autopilot applies recurring-analysis recommendations within fixed rules. Anything the rules cannot decide still goes to the owner as a card."}),e.jsx("div",{className:"grid gap-3",children:m.presets.map(t=>{const x=m.preset===t.name,N=t.requires_confirmation;
31return e.jsx(g,{className:`cursor-pointer transition-all ${x?"border-primary/40 bg-primary/5 shadow-sm":N?"border-amber-200 hover:border-amber-300":"border-muted/50 hover:border-primary/20"}`,onClick:()=>G(t),children:e.jsx("div",{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-0.5",children:gt[t.mode||"off"]||gt.off}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-sm font-semibold",children:t.label}),x&&e.jsx("span",{className:"text-xs font-medium text-primary bg-primary/10 px-1.5 py-0.5 rounded",children:"Active"}),N&&!x&&e.jsxs("span",{className:"flex items-center gap-1 text-xs font-medium text-amber-700 bg-amber-50 border border-amber-200 px-1.5 py-0.5 rounded",children:[e.jsx(ws,{className:"h-3 w-3"}),"Spends money"]}),N&&x&&e.jsxs("span",{className:"flex items-center gap-1 text-xs font-medium text-amber-700 bg-amber-50 border border-amber-200 px-1.5 py-0.5 rounded",children:[e.jsx(ws,{className:"h-3 w-3"}),"Changing the live account"]}),R===t.name&&e.jsx(k,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:t.description}),e.jsxs("p",{className:"text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:"What it means: "}),e.jsx("span",{className:"font-medium",children:t.consequence})]}),N&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1.5",children:"You will be asked to confirm before this takes effect."})]})]})})},t.name)})}),m.preset===null&&e.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:"This workspace is on custom settings that do not match any preset. Choosing one above replaces them."})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"text-base font-medium mb-1",children:"What these rules allow"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Exactly what the gate will decide for each kind of change. Anything that says “asks you first” becomes a card instead."}),e.jsx(g,{className:"border-muted/50",children:e.jsx("div",{className:"divide-y divide-muted/50",children:m.rules.map(t=>e.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-2.5",children:[e.jsx("span",{className:"text-sm",children:t.label}),e.jsx("span",{className:`text-xs font-medium px-1.5 py-0.5 rounded border whitespace-nowrap ${Nt[t.tier]||Nt.off}`,children:t.tier_label})]},t.capability))})}),m.limits.length>0&&e.jsxs("div",{className:"mt-3",children:[e.jsx(D,{className:"text-xs font-medium mb-1.5 block",children:"Limits"}),e.jsx("ul",{className:"space-y-1",children:m.limits.map(t=>e.jsxs("li",{className:"text-xs text-muted-foreground flex gap-2",children:[e.jsx("span",{className:"text-muted-foreground/60",children:"•"}),t]},t))})]})]}),m.demotions.length>0&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"text-base font-medium mb-1",children:"Paused by the circuit breaker"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"These kinds of change went wrong twice in a row, so autopilot asks the owner first now — whatever the preset says. Re-arming lets it act on its own again."}),e.jsx(g,{className:"border-muted/50",children:e.jsx("div",{className:"divide-y divide-muted/50",children:m.demotions.map(t=>e.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-2.5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"text-sm",children:t.label}),t.demoted_at&&e.jsxs("span",{className:"text-xs text-muted-foreground ml-2",children:["since ",Qe(new Date(t.demoted_at),"d MMM")]})]}),e.jsx(i,{variant:"outline",size:"sm",onClick:()=>S(t.capability),children:"Re-arm"})]},t.capability))})})]}),e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-medium",children:"What it has done"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground mt-1",children:[e.jsxs("span",{children:[e.jsx("span",{className:"font-medium text-green-600",children:l})," done"]}),e.jsx("span",{children:"•"}),e.jsxs("span",{children:[e.jsx("span",{className:"font-medium text-blue-600",children:f})," sent to the owner"]}),e.jsx("span",{children:"•"}),e.jsxs("span",{children:[e.jsx("span",{className:"font-medium text-red-600",children:w})," refused"]})]})]}),e.jsxs(i,{variant:"ghost",size:"sm",onClick:Y,children:[e.jsx(Xe,{className:"h-3.5 w-3.5 mr-1.5"}),"Refresh"]})]}),e.jsx(Oe,{open:o!==null,onOpenChange:t=>{t||(A(null),T(""))},children:e.jsxs(Pe,{children:[e.jsxs(ze,{children:[e.jsxs(Ue,{className:"flex items-center gap-2",children:[e.jsx(ws,{className:"h-4 w-4 text-amber-600"}),"Let Rudy change this live account?"]}),e.jsx(Ge,{asChild:!0,children:e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsx("p",{children:"Autopilot will start applying changes to the customer’s real Google Ads account on its own, without anyone approving them first. Money is spent as a result."}),e.jsxs("div",{className:"rounded-lg border border-amber-200 bg-amber-50 p-3 text-amber-900",children:[e.jsxs("p",{className:"font-medium mb-1",children:[o==null?void 0:o.label,": what this preset allows"]}),e.jsx("p",{className:"text-xs mb-1",children:o==null?void 0:o.description}),e.jsx("p",{className:"text-xs font-medium",children:o==null?void 0:o.consequence})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"You can switch back to Off at any time, without confirming. Changes already applied are not undone."}),e.jsxs("div",{className:"pt-1",children:[e.jsxs(D,{htmlFor:"autopilot-confirm",className:"text-xs",children:["Type ",e.jsx("span",{className:"font-semibold",children:o==null?void 0:o.confirm_p
31hrase})," to continue"]}),e.jsx(Q,{id:"autopilot-confirm",value:z,onChange:t=>T(t.target.value),placeholder:(o==null?void 0:o.confirm_phrase)||"",autoComplete:"off",className:"mt-1.5"})]})]})})]}),e.jsxs(Be,{children:[e.jsx(He,{disabled:R!==null,children:"Cancel"}),e.jsxs(i,{variant:"default",disabled:R!==null||z.trim().toUpperCase()!==((o==null?void 0:o.confirm_phrase)||""),onClick:()=>{o&&B(o.name,z.trim())},children:[R!==null&&e.jsx(k,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Turn on live autopilot"]})]})]})}),m.recent.length===0?e.jsx(g,{className:"border-muted/50",children:e.jsx("div",{className:"p-5 text-sm text-muted-foreground",children:"Nothing yet. Actions appear here after the next recurring analysis runs."})}):e.jsx("div",{className:"space-y-2",children:m.recent.map(t=>e.jsx(g,{className:"border-muted/50",children:e.jsx("div",{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-sm font-medium",children:t.label}),e.jsx("span",{className:`text-xs font-medium px-1.5 py-0.5 rounded border ${bt[t.outcome]||bt.EVALUATING}`,children:t.outcome_label}),t.mode==="SHADOW"&&e.jsx("span",{className:"text-xs text-muted-foreground bg-muted/50 px-1.5 py-0.5 rounded",children:"recorded only"})]}),t.reason&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t.reason})]}),e.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:t.at?Qe(new Date(t.at),"d MMM HH:mm"):""})]})})},`${t.name}-${t.mode}`))})]})}function _a({workspaceId:d,organisation:m,onAssigned:I}){const[Z,F]=a.useState(!1),[R,E]=a.useState([]),[h,O]=a.useState(""),[p,P]=a.useState(!1),[o,A]=a.useState(!1),[z,T]=a.useState(null),Y=async()=>{F(!0),O(""),T(null),P(!0);try{const{data:S}=await j.get("/admin/organisations");E(S.filter(G=>G.is_active))}catch{T("Could not load partner organizations. Close and try again.")}finally{P(!1)}},B=async()=>{var G,l;const S=R.find(f=>f.id===h);if(S){A(!0),T(null);try{await j.put(`/admin/organisations/${S.id}/customers/${encodeURIComponent(d)}`),I({id:S.id,name:S.name}),F(!1)}catch(f){const w=(l=(G=f.response)==null?void 0:G.data)==null?void 0:l.detail;T(typeof w=="string"?w:"Could not add workspace to the organization.")}finally{A(!1)}}};return e.jsxs(g,{className:"p-5 mb-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-medium",children:"Partner organization"}),m?e.jsx(yt,{className:"text-sm underline underline-offset-4",to:`/admin/organisations/${m.id}`,children:m.name}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Add this workspace to a partner to manage it from their console."})]}),!m&&e.jsx(i,{variant:"outline",onClick:Y,children:"Add to partner organization"})]}),e.jsx(fe,{open:Z,onOpenChange:S=>{o||F(S)},children:e.jsxs(je,{children:[e.jsxs(ge,{children:[e.jsx(Ne,{children:"Add to partner organization"}),e.jsx(We,{children:"The partner’s staff will gain access to this workspace and manage it from their console. The current owner, collaborators, and credits stay in place. Custom domains become available without a workspace upgrade."})]}),p?e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(k,{className:"h-4 w-4 animate-spin"}),"Loading organizations…"]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{htmlFor:"partner-organisation",children:"Partner organization"}),e.jsxs(qe,{value:h,onValueChange:O,disabled:o,children:[e.jsx(Ve,{id:"partner-organisation",children:e.jsx(Ye,{placeholder:"Select an organization"})}),e.jsx(Ke,{children:R.map(S=>e.jsxs(U,{value:S.id,children:[S.name," (",S.slug,")"]},S.id))})]}),!R.length&&!z&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"No active partner organizations available."})]}),z&&e.jsxs("div",{className:"flex items-start gap-2 p-3 bg-red-50 border border-red-200 rounded-lg",role:"alert",children:[e.jsx(K,{className:"h-4 w-4 text-red-600 shrink-0 mt-0.5"}),e.jsx("p",{className:"flex-1 text-sm text-red-700",children:z}),e.jsx(i,{variant:"ghost",size:"sm","aria-label":"Dismiss error",onClick:()=>T(null),children:e.jsx(V,{className:"h-4 w-4"})})]}),e.jsxs(Ze,{children:[e.jsx(i,{variant:"outline",disabled:o,onClick:()=>F(!1),children:"Cancel"}),e.jsx(i,{disabled:!h||p||o,onClick:B,children:o?"Adding…":"Add workspace"})]})]})})]})}const vt={quality:{label:"Quality",description:"Maximum intelligence, no thinking limits. Use for complex tasks like full website builds or deep audits.",icon:e.jsx(ra,{className:"h-5 w-5 text-purple-500"}),costLabel:"~$2-10 per chat",qualityLabel:"Highest",bestFor:"Website builds, Google Ads audits, complex campaigns"},balanced:{label:"Balanced",description:"Smart thinking with a cap to prevent runaway costs. Good default for most workspaces.",icon:e.jsx(ys,{className:"h-5 w-5 text-blue-500"}),costLabel:"~$0.50-3 per chat",qualityLabel:"High",bestFor:"Most tasks, general workspace use"},budget:{label:"Budget",description:"Uses a smaller, cheaper model with tight limits. Good enough for simple c
31ontent tasks.",icon:e.jsx(Ct,{className:"h-5 w-5 text-green-500"}),costLabel:"~$0.10-0.50 per chat",qualityLabel:"Good",bestFor:"Blog writing, keyword research, simple tasks"},"opus-4-6-efficient":{label:"Opus 4.6 + Effort",description:"Newer model with effort control. Experimental — testing if it matches Opus 4.5 quality at lower cost.",icon:e.jsx(ja,{className:"h-5 w-5 text-amber-500"}),costLabel:"~$0.30-2 per chat",qualityLabel:"High (experimental)",bestFor:"A/B testing against Balanced preset"}},Ca=(d,m)=>({label:d,description:(m==null?void 0:m.provider)==="openrouter"?`Routed via OpenRouter (${(m==null?void 0:m.model)||"custom model"}).`:`Custom preset (${(m==null?void 0:m.model)||"custom model"}).`,icon:e.jsx(ys,{className:"h-5 w-5 text-muted-foreground"}),costLabel:m!=null&&m.max_budget_usd?`cap $${m.max_budget_usd}/chat`:"—",qualityLabel:"—",bestFor:"Admin-defined preset"}),Sa={SUBSCRIPTION_RENEWAL:"Monthly allowance",CHAT_MESSAGE:"Chat",LANDING_PAGE_BUILD:"Landing page build",ADMIN_ADJUSTMENT:"Admin adjustment",REFUND:"Refund",WORKSPACE_CHAT:"Chat",CREDIT_PACK_PURCHASE:"Credit pack",SIGNUP_BONUS:"Signup bonus",SUBSCRIPTION_WELCOME_BONUS:"Welcome bonus",SCHEDULED_TASK:"Scheduled task",ROLLOVER_EXPIRY:"Rollover expiry"};function Ea({workspaceId:d,notificationEmail:m,ownerEmail:I,publishedUrl:Z}){const[F,R]=a.useState([]),[E,h]=a.useState(null),[O,p]=a.useState(!0),[P,o]=a.useState(null),[A,z]=a.useState(null),T=async()=>{var l,f;p(!0),o(null);try{const[w,t]=await Promise.all([j.get(`/claude-workspace/${d}/form-submissions`),j.get(`/claude-workspace/${d}/form-submissions/count`)]);R(w.data),h(t.data)}catch(w){o(((f=(l=w.response)==null?void 0:l.data)==null?void 0:f.detail)||"Failed to load submissions.")}finally{p(!1)}};a.useEffect(()=>{T()},[d]);const Y=async()=>{var f,w;const l=F.filter(t=>!t.is_read).map(t=>t.id);if(l.length!==0)try{await j.post(`/claude-workspace/${d}/form-submissions/mark-read`,{submission_ids:l}),R(t=>t.map(x=>({...x,is_read:!0}))),h(t=>t?{...t,unread:0}:null)}catch(t){o(((w=(f=t.response)==null?void 0:f.data)==null?void 0:w.detail)||"Failed to mark as read.")}},B=async l=>{var f,w;try{await j.delete(`/claude-workspace/${d}/form-submissions/${l}`);const t=F.find(x=>x.id===l);R(x=>x.filter(N=>N.id!==l)),h(x=>x?{total:x.total-1,unread:t&&!t.is_read?x.unread-1:x.unread}:null),A===l&&z(null)}catch(t){o(((w=(f=t.response)==null?void 0:f.data)==null?void 0:w.detail)||"Failed to delete submission.")}},S=l=>{const f=new Date(l),w=new Date,t=w.getTime()-f.getTime(),x=Math.floor(t/6e4),N=Math.floor(t/36e5),M=Math.floor(t/864e5);return x<1?"Just now":x<60?`${x}m ago`:N<24?`${N}h ago`:M<7?`${M}d ago`:f.toLocaleDateString(void 0,{month:"short",day:"numeric",year:f.getFullYear()!==w.getFullYear()?"numeric":void 0})},G=m||I;return O?e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx(k,{className:"h-5 w-5 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:"Loading submissions..."})]}):e.jsxs("div",{className:"space-y-4",children:[P&&e.jsxs("div",{className:"flex items-start gap-2 p-3 bg-red-50 border border-red-200 rounded-lg",children:[e.jsx(K,{className:"h-4 w-4 text-red-600 flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"flex-1 text-sm text-red-700",children:P}),e.jsx(i,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>o(null),children:e.jsx(V,{className:"h-3.5 w-3.5"})})]}),e.jsxs(g,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(ya,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("h3",{className:"text-sm font-medium",children:"Email Receiver"})]}),e.jsxs("div",{className:"flex items-center gap-6 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Effective receiver: "}),e.jsx("span",{className:"font-medium",children:G||"Not configured"})]}),m&&e.jsxs("div",{children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Custom email: "}),e.jsx("span",{className:"text-amber-600 font-medium",children:m})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Owner: "}),e.jsx("span",{children:I})]}),Z&&e.jsxs("a",{href:Z,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground",children:[e.jsx(la,{className:"h-3 w-3"}),new URL(Z).hostname]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Submissions"}),E&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsxs("span",{children:[E.total," total"]}),E.unread>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-muted-foreground
31/30",children:"•"}),e.jsxs("span",{className:"text-primary font-medium",children:[E.unread," unread"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[E&&E.unread>0&&e.jsxs(i,{variant:"ghost",size:"sm",className:"text-xs h-7",onClick:Y,children:[e.jsx(wt,{className:"h-3.5 w-3.5 mr-1.5"}),"Mark all read"]}),e.jsx(i,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:T,children:e.jsx(Xe,{className:"h-3.5 w-3.5"})})]})]}),F.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(ba,{className:"h-10 w-10 text-muted-foreground/30 mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No form submissions yet"})]}):e.jsx("div",{className:"space-y-2",children:F.map(l=>{const f=A===l.id,w=Object.entries(l.fields_data).slice(0,3),t=Object.keys(l.fields_data).length>3,x=["name","full_name","fullName","first_name","firstName","contact_name"],N=["email","e-mail","mail","emailAddress","email_address"];let M=null,H=null;for(const _ of x)if(l.fields_data[_]){M=String(l.fields_data[_]);break}for(const _ of N)if(l.fields_data[_]){H=String(l.fields_data[_]);break}return e.jsx(g,{className:`overflow-hidden transition-all cursor-pointer hover:shadow-sm ${l.is_read?"":"border-l-2 border-l-primary bg-primary/[0.02]"}`,onClick:()=>z(f?null:l.id),children:e.jsx("div",{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:`mt-0.5 ${l.is_read?"text-muted-foreground/50":"text-primary"}`,children:l.is_read?e.jsx(va,{className:"h-4 w-4"}):e.jsx(ga,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:`font-medium text-sm truncate ${l.is_read?"text-muted-foreground":"text-foreground"}`,children:M||H||"Anonymous"}),!l.is_read&&e.jsx(ce,{variant:"secondary",className:"text-[10px] px-1.5 py-0 bg-primary/10 text-primary",children:"New"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mb-1.5",children:[e.jsx("span",{className:"bg-muted/50 px-1.5 py-0.5 rounded text-[10px] font-medium uppercase tracking-wide",children:l.form_name||l.form_id}),e.jsx("span",{className:"text-muted-foreground/50",children:"•"}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(_t,{className:"h-3 w-3"}),S(l.created_at)]}),l.ip_address&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-muted-foreground/50",children:"•"}),e.jsx("span",{children:l.ip_address})]})]}),!f&&w.length>0&&e.jsxs("div",{className:"text-xs text-muted-foreground line-clamp-1",children:[w.map(([_,W],be)=>e.jsxs("span",{children:[be>0&&" • ",e.jsxs("span",{className:"font-medium",children:[_,":"]})," ",String(W)]},_)),t&&e.jsxs("span",{className:"text-muted-foreground/50",children:[" +",Object.keys(l.fields_data).length-3," more"]})]}),f&&e.jsxs("div",{className:"mt-3 space-y-3",onClick:_=>_.stopPropagation(),children:[e.jsx("div",{className:"bg-muted/30 rounded-lg p-3 space-y-2",children:Object.entries(l.fields_data).map(([_,W])=>e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-medium",children:_.replace(/_/g," ")}),e.jsx("span",{className:"text-sm text-foreground break-words",children:typeof W=="boolean"?W?"Yes":"No":String(W)||"—"})]},_))}),(l.referrer||l.user_agent)&&e.jsx("div",{className:"flex items-center gap-4 text-xs text-muted-foreground/70",children:l.referrer&&e.jsxs("span",{className:"truncate max-w-[300px]",title:l.referrer,children:["Referrer: ",l.referrer]})}),e.jsx("div",{className:"flex items-center gap-2 pt-2 border-t",children:e.jsxs(i,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>B(l.id),children:[e.jsx(Je,{className:"h-3.5 w-3.5 mr-1.5"}),"Delete"]})})]})]}),e.jsx("div",{className:"text-muted-foreground/50 mt-1",children:f?e.jsx(ia,{className:"h-4 w-4"}):e.jsx(kt,{className:"h-4 w-4"})})]})})},l.id)})})]})}function Va(){var Zs,Js,Xs,Qs,et,st,tt,at,nt,rt,lt,it,ct,dt,ot,mt;const{workspaceId:d}
31=Qt(),[m]=ea(),I=m.get("month"),[Z,F]=a.useState(!0),[R,E]=a.useState(null),[h,O]=a.useState(null),[p,P]=a.useState({}),[o,A]=a.useState({}),[z,T]=a.useState(!1),[Y,B]=a.useState(null),[S,G]=a.useState(null),[l,f]=a.useState(!1),[w,t]=a.useState(!1),[x,N]=a.useState(""),[M,H]=a.useState(!1),[_,W]=a.useState(null),[be,ve]=a.useState(null),[es,ss]=a.useState(null),[St,ts]=a.useState(!1),[Et,we]=a.useState(!1),[ye,as]=a.useState(""),[ks,_s]=a.useState(!1),[Cs,oe]=a.useState(null),[Lt,ke]=a.useState(!1),[_e,Ce]=a.useState(""),[Ss,Es]=a.useState(!1),[Ls,me]=a.useState(null),[At,ns]=a.useState(!1),[rs,As]=a.useState(!1),[$t,Se]=a.useState(!1),[ls,$s]=a.useState(!1),[Ds,Rs]=a.useState(null),[Ee,Ts]=a.useState(!1),[is,Ms]=a.useState(!1),[y,xe]=a.useState(null),[cs,Le]=a.useState(!1),[ee,Dt]=a.useState(null),[Rt,Is]=a.useState(!1),[ds,Fs]=a.useState(null),[os,Os]=a.useState(!1),[ms,Tt]=a.useState(200),[Ae,Mt]=a.useState(!1),[C,It]=a.useState(null),[Ps,zs]=a.useState(!1),[Ft,xs]=a.useState(!1),[J,hs]=a.useState("allocate"),[$e,us]=a.useState(0),[Us,ps]=a.useState(""),[fs,Gs]=a.useState(!1),[Bs,ae]=a.useState(null),[he,Ot]=a.useState([]),[js,Pt]=a.useState(0),[ue,Hs]=a.useState(!1);a.useEffect(()=>{X()},[d,I]);const X=async()=>{var s,n;E(null),F(!0);try{const r=I?`?month=${I}`:"",[u,L]=await Promise.all([j.get(`/admin/workspace-usage/workspace/${d}${r}`),j.get("/admin/workspace-usage/presets")]);O(u.data),P(L.data.presets),A(u.data.workspace.agent_config||{})}catch(r){E(((n=(s=r.response)==null?void 0:s.data)==null?void 0:n.detail)||"Failed to load workspace details.")}finally{F(!1)}Ws(),De(0)},De=async s=>{if(d){Hs(!0);try{const n=await j.get(`/admin/workspace-usage/workspace/${d}/credit-transactions?limit=25&offset=${s}`);Ot(r=>s===0?n.data.transactions:[...r,...n.data.transactions]),Pt(n.data.total)}catch{}finally{Hs(!1)}}},Ws=async()=>{var s,n;if(d){zs(!0);try{const r=await j.get(`/users/admin/workspaces/${d}/credits`);It({balance:r.data.balance,banked_balance:r.data.banked_balance??0,rollover_balance:r.data.rollover_balance??r.data.balance,total_allocated:r.data.total_allocated,total_consumed:r.data.total_consumed,monthly_limit:r.data.monthly_limit,has_subscription:r.data.has_subscription})}catch(r){ae(((n=(s=r.response)==null?void 0:s.data)==null?void 0:n.detail)||"Failed to fetch credit balance.")}finally{zs(!1)}}},zt=()=>{hs("allocate"),us(0),ps(""),ae(null),xs(!0)},Ut=async s=>{var r,u;if(s.preventDefault(),!d)return;if($e<=0){ae("Credits amount must be greater than 0.");return}Gs(!0),ae(null);const n=J==="allocate"?`/users/admin/workspaces/${d}/allocate-credits`:`/users/admin/workspaces/${d}/deduct-credits`;try{await j.post(n,{credits:$e,notes:Us}),us(0),ps(""),await Ws(),De(0)}
31catch(L){ae(((u=(r=L.response)==null?void 0:r.data)==null?void 0:u.detail)||`Failed to ${J} credits.`)}finally{Gs(!1)}},Gt=async()=>{if(!(!d||ee)){Is(!0);try{const s=await j.get(`/admin/workspace-usage/workspace/${d}/info`);Dt(s.data)}catch{}finally{Is(!1)}}},Re=async s=>{if(d){Os(!0);try{const n=s??ms,r=await j.get(`/admin/workspace-usage/workspace/${d}/logs?tail=${n}`);Fs(r.data.logs)}catch{Fs("Failed to fetch logs.")}finally{Os(!1)}}};a.useEffect(()=>{(h==null?void 0:h.workspace.status)==="RUNNING"&&Gt()},[h==null?void 0:h.workspace.status]),a.useEffect(()=>{if(!Ae)return;const s=setInterval(()=>Re(),5e3);return()=>clearInterval(s)},[Ae,ms]);const qs=s=>{if(!s)return"—";try{return Qe(new Date(s),"MMM d, yyyy HH:mm")}catch{return s}},gs=s=>{if(!s)return"—";try{return Qe(new Date(s),"MMM d, yyyy")}catch{return s}},Vs=s=>s>=1024?`${(s/1024).toFixed(1)}G`:`${s.toFixed(0)}M`,Bt=s=>{A({preset:s}),f(!1),B(null)},Ht=async()=>{var s,n;G(null),B(null),T(!0);try{const r=await j.put(`/admin/workspace-usage/config/${d}`,o);B(`Saved! This workspace will use the "${r.data.effective_config.preset}" config for new chats.`),await X()}catch(r){G(((n=(s=r.response)==null?void 0:s.data)==null?void 0:n.detail)||"Failed to save config.")}finally{T(!1)}},Wt=async()=>{var s,n;if(!(!x.trim()||!d)){H(!0),ve(null),W(null),ss(null);try{const r=await j.post("/claude-workspace/admin/invite",{email:x.trim(),workspace_id:d});W(r.data.status==="granted"?`${r.data.email} now has access.`:`Invite sent to ${r.data.email}.`),r.data.invite_link&&ss(r.data.invite_link),await X()}catch(r){ve(((n=(s=r.response)==null?void 0:s.data)==null?void 0:n.detail)||"Failed to send invite.")}finally{H(!1)}}},Ns=()=>{t(!1),N(""),W(null),ve(null),ss(null),ts(!1)},qt=async s=>{Le(!0);try{await j.delete("/claude-workspace/admin/access",{params:{user_email:s,workspace_id:d}}),await X()}catch{}finally{Le(!1),xe(null)}},Vt=async s=>{Le(!0);try{await j.delete(`/claude-workspace/admin/invites/${s}`),await X()}catch{}finally{Le(!1),xe(null)}},Ys=async s=>{try{await navigator.clipboard.writeText(s),ts(!0),setTimeout(()=>ts(!1),2e3)}catch{}},Yt=async()=>{var s,n;if(ye.trim()){_s(!0),oe(null);try{await j.patch(`/claude-workspace/admin/workspaces/${d}`,{name:ye.trim()}),we(!1),as(""),await X()}catch(r){oe(((n=(s=r.response)==null?void 0:s.data)==null?void 0:n.detail)||"Failed to rename.")}finally{_s(!1)}}},Kt=async()=>{var s,n;if(_e.trim()){Es(!0),me(null);try{await j.post(`/claude-workspace/admin/workspaces/${d}/transfer-ownership`,{new_owner_email:_e.trim()}),ke(!1),Ce(""),await X()}catch(r){me(((n=(s=r.response)==null?void 0:s.data)==null?void 0:n.detail)||"Failed to transfer.")}finally{Es(!1)}}},Ks=async s=>{var n,r;if(d){Ts(!0),E(null);try{const u=new URLSearchParams;s&&u.set("transfer_ownership","true");const L=await j.post(`/claude-workspace/${d}/invite-link?${u.toString()}`);await navigator.clipboard.writeText(L.data.invite_link),Ms(!0),setTimeout(()=>Ms(!1),2e3)}catch(u){E(((r=(n=u.response)==null?void 0:n.data)==null?void 0:r.detail)||"Failed to generate invite link.")}finally{Ts(!1)}}},Zt=async()=>{var s,n,r,u,L,pe;$s(!0),E(null);try{const q=(await j.post(`/claude-workspace/admin/workspaces/${d}/reset-engines`)).data.summary||{},re=Te=>typeof Te=="number"?String(Te):Array.isArray(Te)?String(Te.length):"error";Rs(`Reset done — Get Found: ${re((s=q.get_found)==null?void 0:s.deleted_tasks)} tasks, ${re((n=q.get_found)==null?void 0:n.removed_files)} files · Ads: ${re((r=q.ads)==null?void 0:r.deleted_tasks)} tasks, ${re((u=q.ads)==null?void 0:u.removed_files)} files · Proposals: ${re(q.deleted_proposals)} · Needs-you files: ${re(q.needs_you_files)}`),Se(!1),await X()}catch(ne){E(((pe=(L=ne.response)==null?void 0:L.data)==null?void 0:pe.detail)||"Failed to reset engines."),Se(!1)}finally{$s(!1)}},Jt=async()=>{As(!0);try{await j.delete(`/claude-workspace/admin/workspaces/${d}`),window.location.href="/admin/workspaces"}catch{As(!1),ns(!1)}};if(Z)return e.jsxs("div",{className:"flex items-center justify-center py-24",children:[e.jsx(k,{className:"h-5 w-5 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:"Loading workspace details..."})]});if(R||!h)return e.jsx("div",{className:"p-6 max-w-7xl mx-auto",children:e.jsxs("div",{className:"flex items-start gap-2 p-3 bg-red-50 border border-red-200 rounded-lg",children:[e.jsx(K,{className:"h-4 w-4 text-red-600 flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"flex-1 text-sm text-red-700",children:R||"Workspace not found."})]})});const c=h.workspace,$=o.preset||((Zs=c.effective_config)==null?void 0:Zs.preset)||Object.keys(p)[0]||"";
31return e.jsxs("div",{className:"p-6 max-w-7xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(i,{variant:"ghost",size:"icon",asChild:!0,className:"h-8 w-8",children:e.jsx(yt,{to:`/admin/workspaces${I?`?month=${I}`:""}`,children:e.jsx(ua,{className:"h-4 w-4"})})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:c.name}),e.jsx(ce,{variant:c.status==="RUNNING"?"default":"secondary",className:c.status==="RUNNING"?"bg-green-600":"",children:c.status})]}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-0.5",children:["Owned by ",c.owner.name||c.owner.email,c.owner.name&&e.jsxs("span",{className:"ml-1",children:["(",c.owner.email,")"]})]}),c.github_repo_url&&e.jsxs("a",{href:c.github_repo_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground mt-0.5",children:[e.jsx(ma,{className:"h-3 w-3"}),"GitHub Backup"]}),e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsx(ys,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Eval fixture"}),e.jsx(ca,{checked:c.is_eval_fixture,onCheckedChange:async s=>{var n,r;try{await j.patch(`/admin/skill-evals/fixtures/${c.workspace_id}`,{is_eval_fixture:s}),await X()}catch(u){E(((r=(n=u.response)==null?void 0:n.data)==null?void 0:r.detail)||"Failed to toggle eval fixture")}}}),c.eval_status==="RUNNING"&&e.jsx(ce,{className:"bg-blue-100 text-blue-700 hover:bg-blue-100 text-[10px] px-1.5 py-0",children:"eval running"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(i,{variant:"ghost",size:"icon",className:"h-8 w-8",disabled:Ee,onClick:()=>Ks(!0),title:"Copy invite link (with ownership transfer)",children:Ee?e.jsx(k,{className:"h-4 w-4 animate-spin"}):is?e.jsx(te,{className:"h-4 w-4 text-green-600"}):e.jsx(xt,{className:"h-4 w-4"})}),e.jsx(i,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>{as(c.name),we(!0)},title:"Rename",children:e.jsx(ht,{className:"h-4 w-4"})}),e.jsx(i,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>ke(!0),title:"Transfer ownership",children:e.jsx(pt,{className:"h-4 w-4"})}),e.jsx(i,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>Se(!0),title:"Reset cards & engines",children:e.jsx(pa,{className:"h-4 w-4"})}),e.jsx(i,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>ns(!0),title:"Delete workspace",children:e.jsx(Je,{className:"h-4 w-4"})})]})]}),Ds&&e.jsxs("div",{className:"flex items-start gap-2 p-3 bg-muted/50 border rounded-lg mb-4",children:[e.jsx(te,{className:"h-4 w-4 text-green-600 flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"flex-1 text-sm text-muted-foreground",children:Ds}),e.jsx(i,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>Rs(null),children:e.jsx(V,{className:"h-3.5 w-3.5"})})]}),e.jsx(_a,{workspaceId:c.workspace_id,organisation:c.organisation,onAssigned:s=>O(n=>n&&{...n,workspace:{...n.workspace,organisation:s}})},c.workspace_id),e.jsxs(da,{defaultValue:"usage",children:[e.jsxs(oa,{children:[e.jsx(le,{value:"usage",children:"Usage"}),e.jsx(le,{value:"logs",onClick:()=>{ds===null&&Re()},children:"Logs"}),e.jsx(le,{value:"config",children:"Config"}),e.jsx(le,{value:"autopilot",children:"Autopilot"}),e.jsx(le,{value:"sharing",children:"Sharing"}),e.jsx(le,{value:"forms",children:"Form Submissions"})]}),e.jsxs(ie,{value:"usage",className:"space-y-6 mt-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsx(g,{className:"p-5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-9 w-9 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(Ct,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Cost (All Time)"}),e.jsxs("p",{className:"text-lg font-semibold",children:["$",c.total_cost_usd.toFixed(4)]})]})]})}),e.jsx(g,{className:"p-5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-9 w-9 rounded-lg bg-blue-500/10 flex items-center justify-center",children:e.jsx(fa,{className:"h-4 w-4 text-blue-500"})}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Monthly Cost (",h.month,")"]}),e.jsxs("p",{className:"text-lg font-semibold",children:["$",c.monthly_cost_usd.toFixed(4)]})]})]})}),e.jsx(g,{className:"p-5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-9 w-9 rounded-lg bg-amber-500/10 flex items-center justify-center",children:e.jsx(bs,{className:"h-4 w-4 text-amber-600"})}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Credits Used (",h.month,")"]}),e.jsx("p",{className:"text-lg font-semibold",children:(c.monthly_credits_consumed??0).toFixed(2)}),e.jsxs("p",{className:"text-[11px] text-muted-foreground",children:[(c.total_credits_consumed??0).toFixed(2)," all time"]})]})]})}),e.jsx(g,{className:"p-5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-9 w-9 rounded-lg bg-green-500/10 flex items-center justify-center",children:e.jsx("span",{className:"text-sm font-semibold text-green-500",children:c.sessions.length})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Sessions"}),e.jsxs("p",{className:"text-lg font-semibold",children:[c.sessions.reduce((s,n)=>s+n.message_count,0)," messages"]})]})]})})]}),e.jsxs(g,{className:"p-5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-9 w-9 rounded-lg bg-amber-500/10 flex items-center justify-center",children:e.jsx(bs,{className:"h-4 w-4 text-amber-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Credits"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Workspace credit balance",C&&!C.has_subscription&&e.jsx("span",{children:" · Free plan"})]})]})]}),e.jsxs(i,{size:"sm",variant:"outline",onClick:zt,disabled:Ps,children:[e.jsx(bs,{className:"h-3.5 w-3.5 mr-1.5"}),"Manage Credits"]})]}),Ps&&!C?e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(k,{className:"h-3 w-3 animate-spin"})," Loading credits..."]}):C?e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Balance"}),e.jsx("p",{className:"text-lg font-semibold",children:C.balance.toLocaleStr
31ing()}),C.banked_balance>0&&e.jsxs("p",{className:"text-[11px] text-muted-foreground mt-0.5",children:[C.rollover_balance.toLocaleString()," rollover · ",C.banked_balance.toLocaleString()," banked"]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Allocated"}),e.jsx("p",{className:"text-lg font-semibold",children:C.total_allocated.toLocaleString()})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Consumed"}),e.jsx("p",{className:"text-lg font-semibold",children:C.total_consumed.toLocaleString()})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Monthly Limit"}),e.jsx("p",{className:"text-lg font-semibold",children:C.monthly_limit!=null?C.monthly_limit.toLocaleString():"—"})]})]}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"No credit data."})]}),c.container_stats&&e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsx(g,{className:"p-5",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Memory Usage"}),e.jsxs("span",{className:"text-xs font-medium",children:[c.container_stats.memory_percent.toFixed(0),"%"]})]}),e.jsx(xa,{value:c.container_stats.memory_percent,className:`h-2 ${c.container_stats.memory_percent>80?"[&>div]:bg-red-500":c.container_stats.memory_percent>60?"[&>div]:bg-amber-500":""}`}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Vs(c.container_stats.memory_usage_mb)," / ",Vs(c.container_stats.memory_limit_mb)]})]})}),e.jsx(g,{className:"p-5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-9 w-9 rounded-lg bg-purple-500/10 flex items-center justify-center",children:e.jsx(Na,{className:"h-4 w-4 text-purple-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"CPU Usage"}),e.jsxs("p",{className:"text-lg font-semibold",children:[c.container_stats.cpu_percent.toFixed(1),"%"]})]})]})}),e.jsx(g,{className:"p-5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-9 w-9 rounded-lg bg-blue-500/10 flex items-center justify-center",children:e.jsx(jt,{className:"h-4 w-4 text-blue-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Active Sessions"}),e.jsx("p",{className:"text-lg font-semibold",children:((Js=c.active_sessions)==null?void 0:Js.length)||0}),(Xs=c.active_sessions)==null?void 0:Xs.map(s=>e.jsxs("p",{className:"text-xs text-muted-foreground truncate max-w-[200px]",children:[e.jsx("span",{className:s.status==="STREAMING"?"text-blue-600":"text-amber-600",children:s.status})," ",s.title||"Untitled"]},s.session_id))]})]})})]}),ee&&e.jsx(g,{className:"border-muted/50",children:e.jsxs("div",{className:"p-5",children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:"Container Info"}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Claude CLI"}),e.jsx("p",{className:"font-mono text-xs",children:ee.claude_cli_version||"—"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Agent SDK"}),e.jsx("p",{className:"font-mono text-xs",children:ee.claude_sdk_version||"—"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Node.js"}),e.jsx("p",{className:"font-mono text-xs",children:ee.node_version||"—"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Python"}),e.jsx("p",{className:"font-mono text-xs",children:ee.python_version||"—"})]})]}),((Qs=ee.plugins)==null?void 0:Qs.length)>0&&e.jsxs("div",{className:"mt-4 border-t pt-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Installed Plugins"}),e.jsx("div",{className:"space-y-1",children:ee.plugins.map(s=>e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:"font-medium",children:s.name}),e.jsxs("span",{className:"font-mono text-muted-foreground",children:[s.version," (",s.marketplace,")"]})]},s.name))})]})]})}),Rt&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(k,{className:"h-3 w-3 animate-spin"})," Loading container info..."]}),e.jsx(g,{children:c.sessions.length>0?e.jsxs(Me,{children:[e.jsx(Ie,{children:e.jsxs(se,{className:"bg-muted/30",children:[e.jsx(b,{children:"Session"}),e.jsx(b,{className:"text-center",children:"Messages"}),e.jsx(b,{className:"text-center",children:"Input Tokens"}),e.jsx(b,{className:"text-center",children:"Output Tokens"}),e.jsx(b,{className:"text-right",children:"Cost (USD)"}),e.jsx(b,{className:"text-right",children:"Credits"}),e.jsx(b,{className:"text-center",children:"Status"}),e.jsx(b,{children:"Created"})]})}),e.jsx(Fe,{children:c.sessions.map(s=>e.jsxs(se,{children:[e.jsxs(v,{children:[e.jsx("p",{className:"text-sm font-medium",children:s.title||"Untitled"}),e.jsxs("p",{className:"text-xs text-muted-foreground font-mono",children:[s.claude_session_id.slice(0,12),"..."]})]}),e.jsx(v,{className:"text-center",children:s.message_count}),e.jsx(v,{className:"text-center text-xs font-mono",children:s.total_input_tokens.toLocaleStr
31ing()}),e.jsx(v,{className:"text-center text-xs font-mono",children:s.total_output_tokens.toLocaleString()}),e.jsxs(v,{className:"text-right font-medium",children:["$",s.total_cost_usd.toFixed(4)]}),e.jsx(v,{className:"text-right text-sm",children:(s.total_credits_consumed??0)>0?(s.total_credits_consumed??0).toFixed(2):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(v,{className:"text-center",children:e.jsx("span",{className:`text-xs ${s.status==="STREAMING"?"text-blue-600":s.status==="IDLE"?"text-green-600":s.status==="ERROR"?"text-red-600":"text-muted-foreground"}`,children:s.status||"—"})}),e.jsx(v,{className:"text-xs text-muted-foreground",children:qs(s.created_at)})]},s.session_id))})]}):e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"No sessions in this workspace."})})}),e.jsxs(g,{children:[e.jsxs("div",{className:"p-5 pb-3 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium",children:"Credit Transactions"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[js," total"]})]}),e.jsx(i,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>De(0),disabled:ue,children:ue?e.jsx(k,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Xe,{className:"h-3.5 w-3.5"})})]}),he.length>0?e.jsxs(e.Fragment,{children:[e.jsxs(Me,{children:[e.jsx(Ie,{children:e.jsxs(se,{className:"bg-muted/30",children:[e.jsx(b,{children:"Date"}),e.jsx(b,{children:"Type"}),e.jsx(b,{children:"Actor"}),e.jsx(b,{children:"Details"}),e.jsx(b,{className:"text-right",children:"Credits"}),e.jsx(b,{className:"text-right",children:"Balance After"})]})}),e.jsx(Fe,{children:he.map(s=>{const n=s.metadata||{},r=typeof n.total_cost_usd=="number"?n.total_cost_usd:null,u=typeof n.cli_reported_cost_usd=="number"?n.cli_reported_cost_usd:null,L=n.notes||n.reason,pe=n.partial_deduction===!0,ne=Number(n.input_tokens)||0,q=Number(n.output_tokens)||0;return e.jsxs(se,{children:[e.jsx(v,{className:"text-xs text-muted-foreground whitespace-nowrap",children:qs(s.created_at)}),e.jsxs(v,{children:[e.jsx("span",{className:"text-sm",children:Sa[s.source]||s.source}),pe&&e.jsx(ce,{variant:"secondary",className:"ml-1.5 text-[10px] px-1.5 py-0",title:"Balance was lower than the computed credits — deduction clamped to the remaining balance",children:"partial"})]}),e.jsx(v,{className:"text-xs text-muted-foreground",children:s.actor_email||"—"}),e.jsxs(v,{className:"text-xs text-muted-foreground max-w-[300px]",children:[r!=null&&e.jsxs("span",{className:"block",children:["$",r.toFixed(4),u!=null&&u!==r&&e.jsxs("span",{className:"text-muted-foreground/70",title:"Cost reported by the Claude CLI before server-side calibration",children:[" ","· CLI $",u.toFixed(2)]})]}),(ne>0||q>0)&&e.jsxs("span",{className:"block text-muted-foreground/70",children:[ne.toLocaleString()," in · ",q.toLocaleString()," out"]}),L&&e.jsx("span",{className:"block truncate",title:L,children:L}),r==null&&ne===0&&q===0&&!L&&"—"]}
31),e.jsxs(v,{className:`text-right font-medium ${s.amount>0?"text-green-600":""}`,children:[s.amount>0?"+":"",s.amount.toFixed(2)]}),e.jsx(v,{className:"text-right text-sm text-muted-foreground",children:s.balance_after.toFixed(2)})]},s.id)})})]}),he.length<js&&e.jsx("div",{className:"flex justify-center py-3 border-t",children:e.jsxs(i,{variant:"ghost",size:"sm",className:"text-xs",onClick:()=>De(he.length),disabled:ue,children:[ue&&e.jsx(k,{className:"h-3 w-3 animate-spin mr-1.5"}),"Load more (",he.length," of ",js,")"]})})]}):e.jsx("div",{className:"flex items-center justify-center py-10",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:ue?"Loading transactions...":"No credit transactions yet."})})]})]}),e.jsxs(ie,{value:"logs",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(qe,{value:String(ms),onValueChange:s=>{Tt(Number(s)),Re(Number(s))},children:[e.jsx(Ve,{className:"w-[120px] h-8 text-xs",children:e.jsx(Ye,{})}),e.jsxs(Ke,{children:[e.jsx(U,{value:"50",children:"50 lines"}),e.jsx(U,{value:"100",children:"100 lines"}),e.jsx(U,{value:"200",children:"200 lines"}),e.jsx(U,{value:"500",children:"500 lines"}),e.jsx(U,{value:"1000",children:"1000 lines"})]})]}),e.jsxs(i,{variant:"outline",size:"sm",className:"h-8 gap-1.5 text-xs",onClick:()=>Re(),disabled:os,children:[os?e.jsx(k,{className:"h-3 w-3 animate-spin"}):e.jsx(Xe,{className:"h-3 w-3"}),"Refresh"]}),e.jsxs(i,{variant:Ae?"default":"outline",size:"sm",className:"h-8 gap-1.5 text-xs",onClick:()=>Mt(s=>!s),children:[e.jsx(jt,{className:`h-3 w-3 ${Ae?"animate-pulse":""}`}),"Auto-refresh"]})]}),e.jsx("pre",{className:"bg-zinc-950 text-zinc-200 text-xs font-mono p-4 rounded-lg overflow-auto max-h-[600px] whitespace-pre-wrap break-all",children:os&&!ds?"Loading logs...":ds||"No logs available."})]}),e.jsx(ie,{value:"config",className:"space-y-6 mt-4",children:e.jsxs("div",{className:"max-w-3xl",children:[S&&e.jsxs("div",{className:"flex items-start gap-2 p-3 bg-red-50 border border-red-200 rounded-lg mb-4",children:[e.jsx(K,{className:"h-4 w-4 text-red-600 flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"flex-1 text-sm text-red-700",children:S}),e.jsx(i,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>G(null),children:e.jsx(V,{className:"h-3.5 w-3.5"})})]}),Y&&e.jsxs("div",{className:"flex items-start gap-2 p-3 bg-green-50 border border-green-200 rounded-lg mb-4",children:[e.jsx(te,{className:"h-4 w-4 text-green-600 flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"flex-1 text-sm text-green-700",children:Y}),e.jsx(i,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>B(null),children:e.jsx(V,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx(D,{className:"text-sm font-medium mb-3 block",children:"Choose cost preset"}),e.jsx("div",{className:"grid gap-3",children:Object.keys(p).map(s=>{var L;const n=p[s],r=vt[s]||Ca(s,n),u=$===s;return e.jsx(g,{className:`cursor-pointer transition-all ${u?"border-primary/40 bg-primary/5 shadow-sm":"border-muted/50 hover:border-primary/20"}`,onClick:()=>Bt(s),children:e.jsx("div",{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-0.5",children:r.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-sm font-semibold",children:r.label}),u&&e.jsx("span",{className:"text-xs font-medium text-primary bg-primary/10 px-1.5 py-0.5 rounded",children:"Active"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:r.description}),e.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-xs",children:[e.jsxs("span",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Provider:"})," ",e.jsx("span",{className:"font-medium",children:(n==null?void 0:n.provider)||"anthropic"})]}),e.jsxs("span",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Model:"})," ",e.jsx("span",{className:"font-medium",children:(L=n==null?void 0:n.model)==null?void 0:L.replace("claude-","")})]}),e.jsxs("span",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Cost:"})," ",e.jsx("span",{className:"font-medium",children:r.costLabel})]}),e.jsxs("span",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Quality:"})," ",e.jsx("span",{className:"font-medium",children:r.qualityLabel})]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Best for: ",r.bestFor]})]})]})})},s)})})]}),p[$]&&e.jsx(g,{className:"border-muted/50 mb-6",children:e.jsxs("div",{className:"p-4",children:[e.jsxs("h3",{className:"text-sm font-medium mb-3",children:["What “",((et=vt[$])==null?void 0:et.label)||$,"” does"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Provider"}),e.jsx("span",{className:"font-medium",children:((st=p[$])==null?void 0:st.provider)||"anthropic"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Model"}),e.jsx("span",{className:"font-medium",children:(at=(tt=p[$])==null?void 0:tt.model)==null?void 0:at.replace("claude-","")})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Budget 
31cap / chat"}),e.jsxs("span",{className:"font-medium",children:["$",(nt=p[$])==null?void 0:nt.max_budget_usd]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Limiter"}),e.jsx("span",{className:"font-medium text-xs",children:"min(credits × $0.15, cap)"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Thinking cap"}),e.jsx("span",{className:"font-medium",children:(rt=p[$])!=null&&rt.max_thinking_tokens?`${(p[$].max_thinking_tokens/1e3).toFixed(0)}K tokens`:"Uncapped"})]}),((lt=p[$])==null?void 0:lt.effort_level)&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Effort level"}),e.jsx("span",{className:"font-medium",children:p[$].effort_level})]})]})]})}),e.jsxs("div",{className:"mb-6",children:[e.jsxs("button",{onClick:()=>f(!l),className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[l?e.jsx(kt,{className:"h-3.5 w-3.5"}):e.jsx(sa,{className:"h-3.5 w-3.5"}),"Advanced: override individual settings"]}),l&&e.jsx(g,{className:"border-muted/50 mt-3",children:e.jsxs("div",{className:"p-4",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"These override the selected preset. Leave blank to use the preset default."}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{children:[e.jsx(D,{className:"text-xs mb-1.5 block",children:"Provider"}),e.jsxs(qe,{value:o.provider||"default",onValueChange:s=>A(n=>({...n,provider:s==="default"?void 0:s})),children:[e.jsx(Ve,{className:"bg-muted/50 border-0 focus:bg-background focus:border focus:border-input h-8 text-sm",children:e.jsx(Ye,{placeholder:`Preset default (${((it=p[$])==null?void 0:it.provider)||"anthropic"})`})}),e.jsxs(Ke,{children:[e.jsx(U,{value:"default",children:"Preset default"}),e.jsx(U,{value:"anthropic",children:"Anthropic (official API)"}),e.jsx(U,{value:"openrouter",children:"OpenRouter"})]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground mt-1",children:"Takes effect on the next message — running containers don't need a restart."})]}),e.jsxs("div",{children:[e.jsx(D,{className:"text-xs mb-1.5 block",children:"Model"}),e.jsx(Q,{className:"bg-muted/50 border-0 focus:bg-background focus:border focus:border-input h-8 text-sm font-mono",placeholder:`Preset default (${((ct=p[$])==null?void 0:ct.model)||"—"})`,value:o.model||"",onChange:s=>A(n=>({...n,model:s.target.value||void 0}))}),e.jsx("p",{className:"text-[11px] text-muted-foreground mt-1",children:"Anthropic ID (claude-sonnet-4-6) or OpenRouter slug (anthropic/claude-sonnet-4.6) depending on provider."})]}),e.jsxs("div",{children:[e.jsx(D,{className:"text-xs mb-1.5 block",children:"Budget cap per chat ($)"}),e.jsx(Q,{type:"number",step:"0.5",min:"0.5",placeholder:`Preset default ($${((dt=p[$])==null?void 0:dt.max_budget_usd)??"—"})`,className:"bg-muted/50 border-0 focus:bg-background focus:border focus:border-input h-8 text-sm",value:o.max_budget_usd??"",onChange:s=>A(n=>({...n,max_budget_usd:s.target.value?parseFloat(s.target.value):void 0}))}),e.jsx("p",{className:"text-[11px] text-muted-foreground mt-1",children:"Actual budget = min(user credits × $0.15, this cap). No turn limit."})]}),e.jsxs("div",{children:[e.jsx(D,{className:"text-xs mb-1.5 block",children:"Max thinking tokens"}),e.jsx(Q,{type:"number",min:"0",step:"1000",placeholder:`Preset default (${(ot=p[$])!=null&&ot.max_thinking_tokens?`${(p[$].max_thinking_tokens/1e3).toFixed(0)}K`:"uncapped"})`,className:"bg-muted/50 border-0 focus:bg-background focus:border focus:border-input h-8 text-sm",value:o.max_thinking_tokens??"",onChange:s=>A(n=>({...n,max_thinking_tokens:s.target.value?parseInt(s.target.value):void 0}))}),e.jsx("p",{className:"text-[11px] text-muted-foreground mt-1",children:"Caps how many tokens the model spends on internal reasoning. Empty = use preset default. Thinking cannot be fully disabled — only capped."})]}),e.jsxs("div",{children:[e.jsx(D,{className:"text-xs mb-1.5 block",children:"Effort level (Opus 4.5 & 4.6)"}),e.jsxs(qe,{value:o.effort_level||"",onValueChange:s=>A(n=>({...n,effort_level:s||void 0})),children:[e.jsx(Ve,{className:"bg-muted/50 border-0 focus:bg-background focus:border focus:border-input h-8 text-sm",children:e.jsx(Ye,{placeholder:`Preset default (${((mt=p[$])==null?void 0:mt.effort_level)||"none"})`})}),e.jsxs(Ke,{children:[e.jsx(U,{value:"low",children:"Low"}),e.jsx(U,{value:"medium",children:"Medium"}),e.jsx(U,{value:"high",children:"High (default)"}),e.jsx(U,{value:"max",children:"Max (Opus 4.6 only)"})]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground mt-1",children:"Controls how much effort the model puts into responses. Applies to Opus 4.5 & 4.6. Lower effort = fewer output tokens = lower cost. “Max” is Opus 4.6 only."})]})]})]})})]}),e.jsxs(i,{onClick:Ht,disabled:z,children:[z&&e.jsx(k,{className:"h-4 w-4 animate-spin mr-2"}),"Save Config"]})]})}),e.jsx(ie,{value:"autopilot",className:"space-y-6 mt-4",children:d&&e.jsx(ka,{workspaceId:d})}),e.jsxs(ie,{value:"sharing",className:"space-y-6 mt-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Shared Access"}),e.jsxs(i,{onClick:()=>t(!0),size:"sm",className:"gap-1.5",children:[e.jsx(ft,{className:"h-3.5 w-3.5"}),"Invite User"]})]}),e.jsx(g,{children:c.shared_users.length>0?e.jsxs(Me,{children:[e.jsx(Ie,{children:e.jsxs(se,{children:[e.jsx(b,{children:"User"}),e.jsx(b,{children:"Role"}),e.jsx(b,{children:"Granted"}),e.jsx(b,{className:"text-right",children:"Actions"})]})}),e.jsx(Fe,{children:c.shared_users.map(s=>e.jsxs(se,{children:[e.jsx(v,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:s.user_email}),s.user_name&&e.jsx("p",{className:"text-xs text-muted-foreground",children:s.user_name})]})}),e.jsx(v,{children:e.jsxs(ce,{variant:"outline",className:"gap-1",children:[e.jsx(ta,{className:"h-3 w-3"}),s.role]}
31)}),e.jsx(v,{className:"text-sm text-muted-foreground",children:gs(s.granted_at)}),e.jsx(v,{className:"text-right",children:e.jsx(i,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>xe({type:"access",id:s.user_email,name:s.user_email}),title:"Revoke access",children:e.jsx(Je,{className:"h-4 w-4"})})})]},s.user_email))})]}):e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"No shared access grants."})})}),c.pending_invites.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Pending Invites"}),e.jsx(g,{children:e.jsxs(Me,{children:[e.jsx(Ie,{children:e.jsxs(se,{children:[e.jsx(b,{children:"Email"}),e.jsx(b,{children:"Status"}),e.jsx(b,{children:"Sent"}),e.jsx(b,{children:"Expires"}),e.jsx(b,{className:"text-right",children:"Actions"})]})}),e.jsx(Fe,{children:c.pending_invites.map(s=>e.jsxs(se,{children:[e.jsx(v,{className:"font-medium text-sm",children:s.email}),e.jsx(v,{children:e.jsx(ce,{variant:s.status==="pending"?"outline":s.status==="claimed"?"default":"secondary",className:s.status==="pending"?"text-amber-600 border-amber-600":s.status==="claimed"?"bg-green-600":"",children:s.status})}),e.jsx(v,{className:"text-sm text-muted-foreground",children:gs(s.created_at)}),e.jsx(v,{className:"text-sm text-muted-foreground",children:s.expires_at?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(_t,{className:"h-3 w-3"}),gs(s.expires_at)]}):"Never"}),e.jsx(v,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.invite_link&&e.jsx(i,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>Ys(s.invite_link),title:"Copy invite link",children:e.jsx(ut,{className:"h-4 w-4"})}),s.status==="pending"&&e.jsx(i,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>xe({type:"invite",id:s.id,name:s.email}),title:"Delete invite",children:e.jsx(Je,{className:"h-4 w-4"})})]})})]},s.id))})]})})]})]}),e.jsx(ie,{value:"forms",className:"space-y-6 mt-4",children:e.jsx(Ea,{workspaceId:d,notificationEmail:(h==null?void 0:h.workspace.notification_email)??null,ownerEmail:(h==null?void 0:h.workspace.owner.email)??null,publishedUrl:(h==null?void 0:h.workspace.published_url)??null})})]}),e.jsx(fe,{open:w,onOpenChange:s=>!s&&Ns(),children:e.jsxs(je,{className:"sm:max-w-[425px]",children:[e.jsxs(ge,{children:[e.jsxs(Ne,{className:"flex items-center gap-2",children:[e.jsx(ft,{className:"h-5 w-5"}),"Invite User"]}),e.jsxs(We,{children:["Invite a user to access “",c.name,"”. If they already have an account, access will be granted immediately."]})]}),_?e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"flex items-start gap-2 p-3 bg-green-50 border border-green-200 rounded-lg",children:[e.jsx(te,{className:"h-4 w-4 text-green-600 flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"flex-1 text-sm text-green-700",children:_})]}),es&&e.jsxs("div",{className:"bg-muted rounded-lg p-3",children:[e.jsx(D,{className:"text-xs text-muted-foreground",children:"Invite Link"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(Q,{value:es,readOnly:!0,className:"text-sm bg-background"}),e.jsx(i,{variant:"outline",size:"icon",onClick:()=>Ys(es),children:St?e.jsx(te,{className:"h-4 w-4"}):e.jsx(ut,{className:"h-4 w-4"})})]})]}),e.jsx(i,{className:"w-full",onClick:Ns,children:"Done"})]}):e.jsxs(e.Fragment,{children:[be&&e.jsxs("div",{className:"flex items-start gap-2 p-3 bg-red-50 border border-red-200 rounded-lg",children:[e.jsx(K,{className:"h-4 w-4 text-red-600 flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"flex-1 text-sm text-red-700",children:be}),e.jsx(i,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>ve(null),children:e.jsx(V,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{className:"space-y-4 py-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{children:"Email Address"}),e.jsx(Q,{type:"email",placeholder:"[email protected]",value:x,onChange:s=>N(s.target.value)})]})}),e.jsxs(Ze,{children:[e.jsx(i,{variant:"outline",onClick:Ns,children:"Cancel"}),e.jsxs(i,{onClick:Wt,disabled:M||!x.trim(),children:[M&&e.jsx(k,{className:"h-4 w-4 mr-2 animate-spin"}),"Send Invite"]})]})]})]})}),e.jsx(fe,{open:Et,onOpenChange:s=>{s||(we(!1),oe(null))},children:e.jsxs(je,{className:"sm:max-w-[425px]",children:[e.jsx(ge,{children:e.jsxs(Ne,{className:"flex items-center gap-2",children:[e.jsx(ht,{className:"h-5 w-5"}
31),"Rename Workspace"]})}),Cs&&e.jsxs("div",{className:"flex items-start gap-2 p-3 bg-red-50 border border-red-200 rounded-lg",children:[e.jsx(K,{className:"h-4 w-4 text-red-600 flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"flex-1 text-sm text-red-700",children:Cs}),e.jsx(i,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>oe(null),children:e.jsx(V,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{className:"space-y-4 py-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{children:"New Name"}),e.jsx(Q,{value:ye,onChange:s=>as(s.target.value),placeholder:"My Workspace"})]})}),e.jsxs(Ze,{children:[e.jsx(i,{variant:"outline",onClick:()=>{we(!1),oe(null)},children:"Cancel"}),e.jsxs(i,{onClick:Yt,disabled:ks||!ye.trim(),children:[ks&&e.jsx(k,{className:"h-4 w-4 mr-2 animate-spin"}),"Rename"]})]})]})}),e.jsx(fe,{open:Lt,onOpenChange:s=>{s||(ke(!1),me(null),Ce(""))},children:e.jsxs(je,{className:"sm:max-w-[425px]",children:[e.jsxs(ge,{children:[e.jsxs(Ne,{className:"flex items-center gap-2",children:[e.jsx(pt,{className:"h-5 w-5"}),"Transfer Ownership"]}),e.jsxs(We,{children:["Transfer ownership of “",c.name,"” to another user. The current owner (",c.owner.email,") will lose access."]})]}),Ls&&e.jsxs("div",{className:"flex items-start gap-2 p-3 bg-red-50 border border-red-200 rounded-lg",children:[e.jsx(K,{className:"h-4 w-4 text-red-600 flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"flex-1 text-sm text-red-700",children:Ls}),e.jsx(i,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>me(null),children:e.jsx(V,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{children:"Transfer to email"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Q,{type:"email",placeholder:"[email protected]",value:_e,onChange:s=>Ce(s.target.value),className:"flex-1"}),e.jsxs(i,{onClick:Kt,disabled:Ss||!_e.trim(),children:[Ss&&e.jsx(k,{className:"h-4 w-4 mr-2 animate-spin"}),"Transfer"]})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"or"})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{children:"Generate invite link"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Anyone with this link can claim ownership of the workspace."}),e.jsxs(i,{variant:"outline",className:"w-full gap-1.5",disabled:Ee,onClick:async()=>{await Ks(!0)},children:[Ee?e.jsx(k,{className:"h-3.5 w-3.5 animate-spin"}):is?e.jsx(te,{className:"h-3.5 w-3.5 text-green-600"}):e.jsx(xt,{className:"h-3.5 w-3.5"}),is?"Copied to clipboard!":"Copy Invite Link"]})]})]}),e.jsx(Ze,{children:e.jsx(i,{variant:"outline",onClick:()=>{ke(!1),me(null),Ce("")},children:"Close"})})]})}),e.jsx(Oe,{open:At,onOpenChange:ns,children:e.jsxs(Pe,{children:[e.jsxs(ze,{children:[e.jsx(Ue,{children:"Delete Workspace?"}),e.jsxs(Ge,{children:["This will permanently delete “",c.name,"” and all its sessions. This action cannot be undone."]})]}),e.jsxs(Be,{children:[e.jsx(He,{disabled:rs,children:"Cancel"}),e.jsxs(vs,{onClick:Jt,disabled:rs,className:"bg-destructive hover:bg-destructive/90",children:[rs&&e.jsx(k,{className:"h-4 w-4 mr-2 animate-spin"}),"Delete Workspace"]})]})]})}),e.jsx(Oe,{open:$t,onOpenChange:Se,children:e.jsxs(Pe,{children:[e.jsxs(ze,{children:[e.jsx(Ue,{children:"Reset cards & engines?"}),e.jsxs(Ge,{children:["Clears all proposal cards and engine state for “",c.name,"” — the Get Found content plan, drafts and scheduled tasks, the Ads opportunity and recommendations, and needs-you files. The published site, campaigns, reports and activity feed are kept. The engines re-bootstrap from scratch on the next page visit. This cannot be undone."]})]}),e.jsxs(Be,{children:[e.jsx(He,{disabled:ls,children:"Cancel"}),e.jsxs(vs,{onClick:Zt,disabled:ls,className:"bg-destructive hover:bg-destructive/90",children:[ls&&e.jsx(k,{className:"h-4 w-4 mr-2 animate-spin"}),"Reset"]})]})]})}),e.jsx(fe,{open:Ft,onOpenChange:xs,children:e.jsxs(je,{className:"max-w-lg",children:[e.jsxs(ge,{children:[e.jsx(Ne,{children:"Manage Credits"}),e.jsxs(We,{children:["Allocate or deduct credits for ",c.name]})]}),C?e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{className:"p-4",children:e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Current Balance"}),e.jsx("span",{className:"text-xl font-semibold",children:C.balance.toLocaleStr
31ing()})]}),C.banked_balance>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-muted-foreground pl-3",children:"↳ Rollover (monthly allowance)"}),e.jsx("span",{className:"font-medium",children:C.rollover_balance.toLocaleString()})]}),e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-muted-foreground pl-3",children:"↳ Banked (packs/bonus, never expires)"}),e.jsx("span",{className:"font-medium",children:C.banked_balance.toLocaleString()})]})]}),e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:"Total Allocated"}),e.jsx("span",{className:"font-medium",children:C.total_allocated.toLocaleString()})]}),e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:"Total Consumed"}),e.jsx("span",{className:"font-medium",children:C.total_consumed.toLocaleString()})]}),C.monthly_limit!=null&&e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:"Monthly Limit"}),e.jsx("span",{className:"font-medium",children:C.monthly_limit.toLocaleString()})]})]})}),Bs&&e.jsxs("div",{className:"flex items-start gap-2 p-3 bg-red-50 border border-red-200 rounded-lg",children:[e.jsx(K,{className:"h-4 w-4 text-red-600 flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"flex-1 text-sm text-red-700",children:Bs}),e.jsx(i,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>ae(null),children:e.jsx(V,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(i,{variant:J==="allocate"?"default":"outline",size:"sm",onClick:()=>hs("allocate"),className:"flex-1",children:[e.jsx(aa,{className:"h-3.5 w-3.5 mr-1.5"}),"Allocate"]}),e.jsxs(i,{variant:J==="deduct"?"default":"outline",size:"sm",onClick:()=>hs("deduct"),className:"flex-1",children:[e.jsx(wa,{className:"h-3.5 w-3.5 mr-1.5"}),"Deduct"]})]}),e.jsxs("form",{onSubmit:Ut,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs(D,{htmlFor:"credit_amount",className:"text-xs mb-1.5 block",children:["Credits to ",J==="allocate"?"Allocate":"Deduct"]}),e.jsx(Q,{id:"credit_amount",type:"number",min:"1",step:"1",value:$e||"",onChange:s=>us(parseInt(s.target.value)||0),placeholder:"e.g., 1000",required:!0}),e.jsx("p",{className:"text-[11px] text-muted-foreground mt-1",children:J==="allocate"?"Adds to the workspace's balance.":"Removes from the workspace's balance. Fails if balance is insufficient."})]}),e.jsxs("div",{children:[e.jsx(D,{htmlFor:"credit_notes",className:"text-xs mb-1.5 block",children:"Notes (Optional)"}),e.jsx(na,{id:"credit_notes",value:Us,onChange:s=>ps(s.target.value),placeholder:J==="allocate"?"Reason for allocation...":"Reason for deduction...",rows:3})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(i,{type:"button",variant:"outline",onClick:()=>xs(!1),disabled:fs,children:"Close"}),e.jsxs(i,{type:"submit",disabled:fs||$e<=0,variant:J==="deduct"?"destructive":"default",children:[fs&&e.jsx(k,{className:"h-4 w-4 mr-2 animate-spin"}),J==="allocate"?"Allocate Credits":"Deduct Credits"]})]})]})]}):e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(k,{className:"h-5 w-5 animate-spin text-muted-foreground"})})]})}),e.jsx(Oe,{open:!!y,onOpenChange:s=>!s&&xe(null),children:e.jsxs(Pe,{children:[e.jsxs(ze,{children:[e.jsx(Ue,{children:(y==null?void 0:y.type)==="access"?"Revoke Access?":"Delete Invite?"}),e.jsx(Ge,{children:(y==null?void 0:y.type)==="access"?`This will revoke ${y.name}'s access to this workspace.`:`This will delete the pending invite for ${y==null?void 0:y.name}.`})]}),e.jsxs(Be,{children:[e.jsx(He,{disabled:cs,children:"Cancel"}),e.jsxs(vs,{onClick:()=>{(y==null?void 0:y.type)==="access"?qt(y.id):(y==null?void 0:y.type)==="invite"&&Vt(y.id)},disabled:cs,className:"bg-destructive hover:bg-destructive/90",children:[cs&&e.jsx(k,{className:"h-4 w-4 mr-2 animate-spin"}),(y==null?void 0:y.type)==="access"?"Revoke Access":"Delete Invite"]})]})]})})]})}export{Va as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.