@tickernelz/paperclip-pro-server 2026.928.0 → 2026.928.2

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.
Files changed (47) hide show
  1. package/dist/build-info.json +1 -1
  2. package/dist/routes/issues.d.ts.map +1 -1
  3. package/dist/routes/issues.js +19 -7
  4. package/dist/routes/issues.js.map +1 -1
  5. package/dist/routes/openapi.js +1 -1
  6. package/dist/routes/openapi.js.map +1 -1
  7. package/dist/services/adapter-config-schema.d.ts.map +1 -1
  8. package/dist/services/adapter-config-schema.js +32 -8
  9. package/dist/services/adapter-config-schema.js.map +1 -1
  10. package/dist/services/execution-workspaces.d.ts +6 -4
  11. package/dist/services/execution-workspaces.d.ts.map +1 -1
  12. package/dist/services/execution-workspaces.js +25 -4
  13. package/dist/services/execution-workspaces.js.map +1 -1
  14. package/dist/services/heartbeat.d.ts +9 -3
  15. package/dist/services/heartbeat.d.ts.map +1 -1
  16. package/dist/services/heartbeat.js +27 -3
  17. package/dist/services/heartbeat.js.map +1 -1
  18. package/dist/services/legacy-execution-recovery.d.ts.map +1 -1
  19. package/dist/services/legacy-execution-recovery.js +2 -1
  20. package/dist/services/legacy-execution-recovery.js.map +1 -1
  21. package/dist/services/steering-acknowledgements.d.ts +9 -0
  22. package/dist/services/steering-acknowledgements.d.ts.map +1 -0
  23. package/dist/services/steering-acknowledgements.js +25 -0
  24. package/dist/services/steering-acknowledgements.js.map +1 -0
  25. package/dist/services/task-watchdogs.d.ts +1 -1
  26. package/package.json +21 -21
  27. package/ui-dist/assets/{Agents.production-DWWgo4A7.js → Agents.production-jEVgGnQD.js} +2 -2
  28. package/ui-dist/assets/{CompanyActivity.production-DA1vWn15.js → CompanyActivity.production-D55CMhVL.js} +1 -1
  29. package/ui-dist/assets/{CompanyExport-B2fFD7mk.js → CompanyExport-BKFNfLEZ.js} +1 -1
  30. package/ui-dist/assets/{CompanySkills.production-CPTxTVTQ.js → CompanySkills.production-BAMuC3sl.js} +1 -1
  31. package/ui-dist/assets/{Costs.production-bu8MzAPR.js → Costs.production-BgKjdIvf.js} +1 -1
  32. package/ui-dist/assets/{MarkdownBody-D0eCfSWN.js → MarkdownBody-DJQ35hak.js} +1 -1
  33. package/ui-dist/assets/{MarkdownEditor-Pip4OXiJ.js → MarkdownEditor-DfrwLv1M.js} +1 -1
  34. package/ui-dist/assets/{OrgChart.production-BHlwZQTx.js → OrgChart.production-DB1AFxvf.js} +1 -1
  35. package/ui-dist/assets/{RoutineDetail.production-WBEY9g9e.js → RoutineDetail.production-2uUOMx6c.js} +1 -1
  36. package/ui-dist/assets/{RoutineRunVariablesDialog-IRX4TLng.js → RoutineRunVariablesDialog-Bt4KAWCh.js} +1 -1
  37. package/ui-dist/assets/{Routines.production-7tYNG689.js → Routines.production-Bc2tvohM.js} +1 -1
  38. package/ui-dist/assets/{checkbox-CmMbs2PZ.js → checkbox-757DLJRS.js} +1 -1
  39. package/ui-dist/assets/{definition-Dxm_TuVz.js → definition-CY8sfltb.js} +1 -1
  40. package/ui-dist/assets/{index-CZl9vxyj.js → index-Dgrf6BZM.js} +166 -166
  41. package/ui-dist/assets/index-J-4PQOv1.css +1 -0
  42. package/ui-dist/assets/{label-C2ddSDJj.js → label-BueB30Ch.js} +1 -1
  43. package/ui-dist/assets/{router-DyZkoSkG.js → router-Bb8nJWyv.js} +1 -1
  44. package/ui-dist/assets/{sheet-DeCxNmfl.js → sheet-CQJe5sfn.js} +1 -1
  45. package/ui-dist/index.html +9 -9
  46. package/ui-dist/sw.js +1 -1
  47. package/ui-dist/assets/index-GCNIGBzC.css +0 -1
@@ -1 +1 @@
1
- var ot=Object.defineProperty;var o=(i,h)=>ot(i,"name",{value:h,configurable:!0});import{i as Re}from"./rolldown-runtime-ZpX3ckPj.js";import{Fr as dt,L as J,Lr as lt,M,Pr as ct,S as Ie,T as m,U as ut,Y as v,nr as S,tr as qe,x as mt}from"./createLucideIcon-r3v6fbGz.js";import{i as O,n as B,r as pt,t as te}from"./tabs-DWRZjksg.js";import{r as gt,t as xt}from"./EmptyState-DPcc0zYh.js";import{t as ht}from"./chevron-down-F9aZv-V7.js";import{t as bt}from"./chevron-right-B9JUOr38.js";import{t as vt}from"./button-CAPbz11u.js";import{t as yt}from"./AgentIdentity-MCshmbhZ.js";import{i as R,o as $,r as F,s as L,t as q}from"./card-dmVcp3AX.js";import{t as se}from"./PageSkeleton-DHjTwRT3.js";import{$t as De,C as jt,D as N,E as Ae,Fn as ne,Gt as ft,Hn as re,In as ie,S as Fe,T as Ee,Wn as Nt,_t as ae,b as Ct,gt as wt,v as Tt,w as kt,x as Ke,xn as oe,y as St}from"./index-CZl9vxyj.js";var l=Re(lt(),1),e=Re(dt(),1),Bt="__none__";function Mt(){const i=new Date,h=i.getDay(),y=h===0?-6:1-h,u=new Date(i.getFullYear(),i.getMonth(),i.getDate()+y,0,0,0,0),j=new Date(u.getFullYear(),u.getMonth(),u.getDate()+6,23,59,59,999);return{from:u.toISOString(),to:j.toISOString()}}o(Mt,"currentWeekRange");function Pt({provider:i,rows:h}){const y=h.reduce((j,b)=>j+b.inputTokens+b.cachedInputTokens+b.outputTokens,0),u=h.reduce((j,b)=>j+b.costCents,0);return(0,e.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,e.jsx)("span",{children:J(i)}),(0,e.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:M(y)}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:m(u)})]})}o(Pt,"ProviderTabLabel");function It({biller:i,rows:h}){const y=h.reduce((j,b)=>j+b.inputTokens+b.cachedInputTokens+b.outputTokens,0),u=h.reduce((j,b)=>j+b.costCents,0);return(0,e.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,e.jsx)("span",{children:J(i)}),(0,e.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:M(y)}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:m(u)})]})}o(It,"BillerTabLabel");function C({label:i,value:h,subtitle:y,icon:u}){return(0,e.jsx)(q,{className:"block p-4",children:(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("div",{className:"text-(length:--text-micro) uppercase tracking-(--tracking-eyebrow) text-muted-foreground",children:i}),(0,e.jsx)("div",{className:"mt-2 text-2xl font-semibold tabular-nums",children:h}),(0,e.jsx)("div",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:y})]}),(0,e.jsx)("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-md border border-border",children:(0,e.jsx)(u,{className:"h-4 w-4 text-muted-foreground"})})]})})}o(C,"MetricTile");function _e({debitCents:i,creditCents:h,netCents:y,estimatedDebitCents:u,eventCount:j}){return(0,e.jsxs)(q,{children:[(0,e.jsxs)($,{className:"px-5 pt-5 pb-2",children:[(0,e.jsx)(L,{className:"text-base",children:"Finance ledger"}),(0,e.jsx)(R,{children:"Account-level charges that do not map to a single inference request."})]}),(0,e.jsxs)(F,{className:"grid gap-3 px-5 pb-5 pt-2 sm:grid-cols-2 xl:grid-cols-4",children:[(0,e.jsx)(C,{label:"Debits",value:m(i),subtitle:`${j} total event${j===1?"":"s"} in range`,icon:re}),(0,e.jsx)(C,{label:"Credits",value:m(h),subtitle:"Refunds, offsets, and credit returns",icon:Nt}),(0,e.jsx)(C,{label:"Net",value:m(y),subtitle:"Debit minus credit for the selected period",icon:oe}),(0,e.jsx)(C,{label:"Estimated",value:m(u),subtitle:"Estimated debits that are not yet invoice-authoritative",icon:ie})]})]})}o(_e,"FinanceSummaryCard");function Ot(){const{selectedCompanyId:i}=ut(),{setBreadcrumbs:h}=gt(),y=ct(),[u,j]=(0,l.useState)("overview"),[b,de]=(0,l.useState)("all"),[W,le]=(0,l.useState)("all"),{preset:E,setPreset:$e,customFrom:Le,setCustomFrom:We,customTo:ze,setCustomTo:Oe,from:g,to:x,customReady:D}=Ct();(0,l.useEffect)(()=>{h([{label:"Costs"}])},[h]);const[Qe,Ye]=(0,l.useState)(()=>new Date().toDateString()),X=(0,l.useRef)(null);(0,l.useEffect)(()=>{const t=o(()=>{const s=new Date,n=new Date(s.getFullYear(),s.getMonth(),s.getDate()+1).getTime()-s.getTime();X.current=setTimeout(()=>{Ye(new Date().toDateString()),t()},n)},"schedule");return t(),()=>{X.current!=null&&clearTimeout(X.current)}},[]);const P=(0,l.useMemo)(()=>Mt(),[Qe]),d=i??Bt,{data:A,isLoading:Ue,error:ce}=S({queryKey:v.budgets.overview(d),queryFn:o(()=>ae.overview(d),"queryFn"),enabled:!!i&&D,refetchInterval:3e4,staleTime:5e3}),ue=o(()=>{i&&(y.invalidateQueries({queryKey:v.budgets.overview(i)}),y.invalidateQueries({queryKey:v.dashboard(i)}),y.invalidateQueries({queryKey:v.agents.list(i)}),y.invalidateQueries({queryKey:v.projects.all(i)}))},"invalidateBudgetViews"),me=qe({mutationFn:o(t=>ae.upsertPolicy(d,{scopeType:t.scopeType,scopeId:t.scopeId,amount:t.amount,windowKind:t.windowKind}),"mutationFn"),onSuccess:ue}),K=qe({mutationFn:o(t=>ae.resolveIncident(d,t.incidentId,t),"mutationFn"),onSuccess:ue}),{data:a,isLoading:Ve,error:He}=S({queryKey:v.costs(d,g||void 0,x||void 0),queryFn:o(async()=>{const[t,s,n,r]=await Promise.all([N.summary(d,g||void 0,x||void 0),N.byAgent(d,g||void 0,x||void 0),N.byProject(d,g||void 0,x||void 0),N.byAgentModel(d,g||void 0,x||void 0)]);return{summary:t,byAgent:s,byProject:n,byAgentModel:r}},"queryFn"),enabled:!!i&&D}),{data:p,isLoading:pe,error:Z}=S({queryKey:[v.financeSummary(d,g||void 0,x||void 0),v.financeByBiller(d,g||void 0,x||void 0),v.financeByKind(d,g||void 0,x||void 0),v.financeEvents(d,g||void 0,x||void 0,18)],queryFn:o(async()=>{const[t,s,n,r]=await Promise.all([N.financeSummary(d,g||void 0,x||void 0),N.financeByBiller(d,g||void 0,x||void 0),N.financeByKind(d,g||void 0,x||void 0),N.financeEvents(d,g||void 0,x||void 0,18)]);return{summary:t,byBiller:s,byKind:n,events:r}},"queryFn"),enabled:!!i&&D}),[Ge,ge]=(0,l.useState)(new Set);(0,l.useEffect)(()=>{ge(new Set)},[d,g,x]);function Je(t){ge(s=>{const n=new Set(s);return n.has(t)?n.delete(t):n.add(t),n})}o(Je,"toggleAgent");const Xe=(0,l.useMemo)(()=>{const t=new Map;for(const s of a?.byAgentModel??[]){const n=t.get(s.agentId)??[];n.push(s),t.set(s.agentId,n)}for(const[s,n]of t)t.set(s,n.slice().sort((r,c)=>c.costCents-r.costCents));return t},[a?.byAgentModel]),{data:Q}=S({queryKey:v.usageByProvider(d,g||void 0,x||void 0),queryFn:o(()=>N.byProvider(d,g||void 0,x||void 0),"queryFn"),enabled:!!i&&D&&(u==="providers"||u==="billers"),refetchInterval:3e4,staleTime:1e4}),{data:xe}=S({queryKey:v.usageByBiller(d,g||void 0,x||void 0),queryFn:o(()=>N.byBiller(d,g||void 0,x||void 0),"queryFn"),enabled:!!i&&D&&u==="billers",refetchInterval:3e4,staleTime:1e4}),{data:he}=S({queryKey:v.usageByProvider(d,P.from,P.to),queryFn:o(()=>N.byProvider(d,P.from,P.to),"queryFn"),enabled:!!i&&(u==="providers"||u==="billers"),refetchInterval:3e4,staleTime:1e4}),{data:be}=S({queryKey:v.usageByBiller(d,P.from,P.to),queryFn:o(()=>N.byBiller(d,P.from,P.to),"queryFn"),enabled:!!i&&u==="billers",refetchInterval:3e4,staleTime:1e4}),{data:ve}=S({queryKey:v.usageWindowSpend(d),queryFn:o(()=>N.windowSpend(d),"queryFn"),enabled:!!i&&u==="providers",refetchInterval:3e4,staleTime:1e4}),{data:_,isLoading:ye}=S({queryKey:v.usageQuotaWindows(d),queryFn:o(()=>N.quotaWindows(d),"queryFn"),enabled:!!i&&u==="providers",refetchInterval:3e5,staleTime:6e4}),w=(0,l.useMemo)(()=>{const t=new Map;for(const s of Q??[]){const n=t.get(s.provider)??[];n.push(s),t.set(s.provider,n)}return t},[Q]),k=(0,l.useMemo)(()=>{const t=new Map;for(const s of xe??[]){const n=t.get(s.biller)??[];n.push(s),t.set(s.biller,n)}return t},[xe]),je=(0,l.useMemo)(()=>{const t=new Map;for(const s of he??[])t.set(s.provider,(t.get(s.provider)??0)+s.costCents);return t},[he]),fe=(0,l.useMemo)(()=>{const t=new Map;for(const s of be??[])t.set(s.biller,(t.get(s.biller)??0)+s.costCents);return t},[be]),Ne=(0,l.useMemo)(()=>{const t=new Map;for(const s of ve??[]){const n=t.get(s.provider)??[];n.push(s),t.set(s.provider,n)}return t},[ve]),Ce=(0,l.useMemo)(()=>{const t=new Map;for(const s of _??[])s.ok&&s.windows.length>0&&t.set(s.provider,s.windows);return t},[_]),we=(0,l.useMemo)(()=>{const t=new Map;for(const s of _??[])!s.ok&&s.error&&t.set(s.provider,s.error);return t},[_]),Te=(0,l.useMemo)(()=>{const t=new Map;for(const s of _??[])typeof s.source=="string"&&s.source.length>0&&t.set(s.provider,s.source);return t},[_]),ke=(0,l.useMemo)(()=>{const t=new Map;if(E!=="mtd")return t;const s=a?.summary.budgetCents??0;if(s<=0)return t;const n=a?.summary.spendCents??0,r=new Date,c=r.getDate(),T=new Date(r.getFullYear(),r.getMonth()+1,0).getDate();for(const[f,nt]of w){const ee=nt.reduce((rt,it)=>rt+it.costCents,0),Pe=s*(n>0?ee/n:0);if(Pe<=0){t.set(f,!1);continue}const at=ee/Math.max(c,1);t.set(f,ee+at*(T-c)>Pe)}return t},[E,a,w]),Y=(0,l.useMemo)(()=>Array.from(w.keys()),[w]),U=(0,l.useMemo)(()=>Array.from(k.keys()),[k]),V=b==="all"||Y.includes(b)?b:"all";(0,l.useEffect)(()=>{V!==b&&de("all")},[V,b]);const H=W==="all"||U.includes(W)?W:"all";(0,l.useEffect)(()=>{H!==W&&le("all")},[H,W]);const Ze=(0,l.useMemo)(()=>{const t=Array.from(w.keys()),s=t.reduce((r,c)=>r+(w.get(c)?.reduce((T,f)=>T+f.inputTokens+f.cachedInputTokens+f.outputTokens,0)??0),0),n=t.reduce((r,c)=>r+(w.get(c)?.reduce((T,f)=>T+f.costCents,0)??0),0);return[{value:"all",label:(0,e.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,e.jsx)("span",{children:"All providers"}),t.length>0?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:M(s)}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:m(n)})]}):null]})},...t.map(r=>({value:r,label:(0,e.jsx)(Pt,{provider:r,rows:w.get(r)??[]})}))]},[w]),et=(0,l.useMemo)(()=>{const t=Array.from(k.keys()),s=t.reduce((r,c)=>r+(k.get(c)?.reduce((T,f)=>T+f.inputTokens+f.cachedInputTokens+f.outputTokens,0)??0),0),n=t.reduce((r,c)=>r+(k.get(c)?.reduce((T,f)=>T+f.costCents,0)??0),0);return[{value:"all",label:(0,e.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,e.jsx)("span",{children:"All billers"}),t.length>0?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:M(s)}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:m(n)})]}):null]})},...t.map(r=>({value:r,label:(0,e.jsx)(It,{biller:r,rows:k.get(r)??[]})}))]},[k]),Se=(a?.byAgent??[]).reduce((t,s)=>t+s.inputTokens+s.cachedInputTokens+s.outputTokens,0),Be=p?.events??[],z=A?.policies??[],I=A?.activeIncidents??[],tt=(0,l.useMemo)(()=>({company:z.filter(t=>t.scopeType==="company"),agent:z.filter(t=>t.scopeType==="agent"),project:z.filter(t=>t.scopeType==="project")}),[z]);if(!i)return(0,e.jsx)(xt,{icon:ne,message:"Select a company to view costs."});const G=E==="custom"&&!D,st=(Ve||pe)&&D,Me=He??Z;return(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsxs)("div",{className:"space-y-5",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("h1",{className:"text-3xl font-semibold tracking-tight",children:"Costs"}),(0,e.jsx)("p",{className:"mt-2 max-w-2xl text-sm leading-6 text-muted-foreground",children:"Inference spend, platform fees, credits, and live quota windows."})]}),(0,e.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:Tt.map(t=>(0,e.jsx)(vt,{variant:E===t?"secondary":"ghost",size:"sm",onClick:o(()=>$e(t),"onClick"),"aria-pressed":E===t,children:St[t]},t))})]}),E==="custom"?(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2 border border-border p-3",children:[(0,e.jsx)("input",{type:"date",value:Le,onChange:o(t=>We(t.target.value),"onChange"),className:"h-9 rounded-md border border-input bg-background px-3 text-sm text-foreground"}),(0,e.jsx)("span",{className:"text-sm text-muted-foreground",children:"to"}),(0,e.jsx)("input",{type:"date",value:ze,onChange:o(t=>Oe(t.target.value),"onChange"),className:"h-9 rounded-md border border-input bg-background px-3 text-sm text-foreground"})]}):null,(0,e.jsxs)("div",{className:"grid gap-3 lg:grid-cols-4",children:[(0,e.jsx)(C,{label:"Inference spend",value:m(a?.summary.spendCents??0),subtitle:`${M(Se)} tokens across request-scoped events`,icon:ne}),(0,e.jsx)(C,{label:"Budget",value:I.length>0?String(I.length):a?.summary.budgetCents&&a.summary.budgetCents>0?`${a.summary.utilizationPercent}%`:"Open",subtitle:I.length>0?`${A?.pausedAgentCount??0} agents paused · ${A?.pausedProjectCount??0} projects paused`:a?.summary.budgetCents&&a.summary.budgetCents>0?`${m(a.summary.spendCents)} of ${m(a.summary.budgetCents)}`:"No monthly cap configured",icon:ie}),(0,e.jsx)(C,{label:"Finance net",value:m(p?.summary.netCents??0),subtitle:`${m(p?.summary.debitCents??0)} debits · ${m(p?.summary.creditCents??0)} credits`,icon:oe}),(0,e.jsx)(C,{label:"Finance events",value:String(p?.summary.eventCount??0),subtitle:`${m(p?.summary.estimatedDebitCents??0)} estimated in range`,icon:re})]})]}),(0,e.jsxs)(te,{value:u,onValueChange:o(t=>j(t),"onValueChange"),children:[(0,e.jsxs)(pt,{variant:"line",className:"justify-start",children:[(0,e.jsx)(O,{value:"overview",children:"Overview"}),(0,e.jsx)(O,{value:"budgets",children:"Budgets"}),(0,e.jsx)(O,{value:"providers",children:"Providers"}),(0,e.jsx)(O,{value:"billers",children:"Billers"}),(0,e.jsx)(O,{value:"finance",children:"Finance"})]}),(0,e.jsx)(B,{value:"overview",className:"mt-4 space-y-4",children:G?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select a start and end date to load data."}):st?(0,e.jsx)(se,{variant:"costs"}):Me?(0,e.jsx)("p",{className:"text-sm text-destructive",children:Me.message}):(0,e.jsxs)(e.Fragment,{children:[I.length>0?(0,e.jsx)("div",{className:"grid gap-4 xl:grid-cols-2",children:I.slice(0,2).map(t=>(0,e.jsx)(Ee,{incident:t,isMutating:K.isPending,onKeepPaused:o(()=>K.mutate({incidentId:t.id,action:"keep_paused"}),"onKeepPaused"),onRaiseAndResume:o(s=>K.mutate({incidentId:t.id,action:"raise_budget_and_resume",amount:s}),"onRaiseAndResume")},t.id))}):null,(0,e.jsxs)("div",{className:"grid gap-4 xl:grid-cols-(--gtc-31)",children:[(0,e.jsxs)(q,{children:[(0,e.jsxs)($,{className:"px-5 pt-5 pb-2",children:[(0,e.jsx)(L,{className:"text-base",children:"Inference ledger"}),(0,e.jsx)(R,{children:"Request-scoped inference spend for the selected period."})]}),(0,e.jsxs)(F,{className:"space-y-4 px-5 pb-5 pt-2",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-3xl font-semibold tabular-nums",children:m(a?.summary.spendCents??0)}),(0,e.jsx)("div",{className:"mt-1 text-sm text-muted-foreground",children:a?.summary.budgetCents&&a.summary.budgetCents>0?`Budget ${m(a.summary.budgetCents)}`:"Unlimited budget"})]}),(0,e.jsxs)("div",{className:"border border-border px-4 py-3 text-right",children:[(0,e.jsx)("div",{className:"text-(length:--text-micro) uppercase tracking-(--tracking-eyebrow) text-muted-foreground",children:"usage"}),(0,e.jsx)("div",{className:"mt-1 text-lg font-medium tabular-nums",children:M(Se)})]})]}),a?.summary.budgetCents&&a.summary.budgetCents>0?(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("div",{className:"h-2 overflow-hidden bg-muted",children:(0,e.jsx)("div",{className:Ie("h-full transition-(--tp-width-background-color) duration-150",a.summary.utilizationPercent>90?"bg-(--status-task-blocked)":a.summary.utilizationPercent>70?"bg-(--status-task-todo)":"bg-(--status-task-done)"),style:{width:`${Math.min(100,a.summary.utilizationPercent)}%`}})}),(0,e.jsxs)("div",{className:"text-xs text-muted-foreground",children:[a.summary.utilizationPercent,"% of monthly budget consumed in this range."]})]}):null]})]}),(0,e.jsx)(_e,{debitCents:p?.summary.debitCents??0,creditCents:p?.summary.creditCents??0,netCents:p?.summary.netCents??0,estimatedDebitCents:p?.summary.estimatedDebitCents??0,eventCount:p?.summary.eventCount??0})]}),(0,e.jsxs)("div",{className:"grid gap-4 xl:grid-cols-(--gtc-32)",children:[(0,e.jsxs)(q,{children:[(0,e.jsxs)($,{className:"px-5 pt-5 pb-2",children:[(0,e.jsx)(L,{className:"text-base",children:"By agent"}),(0,e.jsx)(R,{children:"What each agent consumed in the selected period."})]}),(0,e.jsx)(F,{className:"space-y-2 px-5 pb-5 pt-2",children:(a?.byAgent.length??0)===0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"No cost events yet."}):a?.byAgent.map(t=>{const s=Xe.get(t.agentId)??[],n=Ge.has(t.agentId),r=s.length>0;return(0,e.jsxs)("div",{className:"border border-border px-4 py-3",children:[(0,e.jsxs)("div",{className:Ie("flex items-start justify-between gap-3",r?"cursor-pointer select-none":""),onClick:o(()=>r&&Je(t.agentId),"onClick"),children:[(0,e.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[r?n?(0,e.jsx)(ht,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):(0,e.jsx)(bt,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):(0,e.jsx)("span",{className:"h-3 w-3 shrink-0"}),(0,e.jsx)(yt,{agent:{id:t.agentId,name:t.agentName??t.agentId,appearance:t.agentAppearance},size:"sm"}),t.agentStatus==="terminated"?(0,e.jsx)(ft,{status:"terminated"}):null]}),(0,e.jsxs)("div",{className:"text-right text-sm tabular-nums",children:[(0,e.jsx)("div",{className:"font-medium",children:m(t.costCents)}),(0,e.jsxs)("div",{className:"text-xs text-muted-foreground",children:["in ",M(t.inputTokens+t.cachedInputTokens)," · out ",M(t.outputTokens)]}),t.apiRunCount>0||t.subscriptionRunCount>0?(0,e.jsxs)("div",{className:"text-xs text-muted-foreground",children:[t.apiRunCount>0?`${t.apiRunCount} api`:"0 api"," · ",t.subscriptionRunCount>0?`${t.subscriptionRunCount} subscription`:"0 subscription"]}):null]})]}),n&&s.length>0?(0,e.jsx)("div",{className:"mt-3 space-y-2 border-l border-border pl-4",children:s.map(c=>{const T=t.costCents>0?Math.round(c.costCents/t.costCents*100):0;return(0,e.jsxs)("div",{className:"flex items-start justify-between gap-3 text-xs",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsxs)("div",{className:"truncate font-medium text-foreground",children:[J(c.provider),(0,e.jsx)("span",{className:"mx-1 text-border",children:"/"}),(0,e.jsx)("span",{className:"font-mono",children:c.model})]}),(0,e.jsxs)("div",{className:"truncate text-muted-foreground",children:[J(c.biller)," · ",mt(c.billingType)]})]}),(0,e.jsxs)("div",{className:"text-right tabular-nums",children:[(0,e.jsxs)("div",{className:"font-medium",children:[m(c.costCents),(0,e.jsxs)("span",{className:"ml-1 font-normal text-muted-foreground",children:["(",T,"%)"]})]}),(0,e.jsxs)("div",{className:"text-muted-foreground",children:[M(c.inputTokens+c.cachedInputTokens+c.outputTokens)," tok"]})]})]},`${c.provider}:${c.model}:${c.billingType}`)})}):null]},t.agentId)})})]}),(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsxs)(q,{children:[(0,e.jsxs)($,{className:"px-5 pt-5 pb-2",children:[(0,e.jsx)(L,{className:"text-base",children:"By project"}),(0,e.jsx)(R,{children:"Run costs attributed through project-linked tasks."})]}),(0,e.jsx)(F,{className:"space-y-2 px-5 pb-5 pt-2",children:(a?.byProject.length??0)===0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"No project-attributed run costs yet."}):a?.byProject.map((t,s)=>(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3 border border-border px-3 py-2 text-sm",children:[(0,e.jsx)("span",{className:"truncate",children:t.projectName??t.projectId??"Unattributed"}),(0,e.jsx)("span",{className:"font-medium tabular-nums",children:m(t.costCents)})]},t.projectId??`unattributed-${s}`))})]}),(0,e.jsx)(Fe,{rows:Be.slice(0,6),emptyMessage:"No finance events yet. Add account-level charges once biller invoices or credits land."})]})]})]})}),(0,e.jsx)(B,{value:"budgets",className:"mt-4 space-y-4",children:Ue?(0,e.jsx)(se,{variant:"costs"}):ce?(0,e.jsx)("p",{className:"text-sm text-destructive",children:ce.message}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(q,{className:"border-border/70 bg-(image:--gradient-extract-2)",children:[(0,e.jsxs)($,{className:"px-5 pt-5 pb-3",children:[(0,e.jsx)(L,{className:"text-base",children:"Budget control plane"}),(0,e.jsx)(R,{children:"Hard-stop spend limits for agents and projects. Provider subscription quota stays separate and appears under Providers."})]}),(0,e.jsxs)(F,{className:"grid gap-3 px-5 pb-5 pt-0 md:grid-cols-4",children:[(0,e.jsx)(C,{label:"Active incidents",value:String(I.length),subtitle:"Open soft or hard threshold crossings",icon:oe}),(0,e.jsx)(C,{label:"Pending approvals",value:String(A?.pendingApprovalCount??0),subtitle:"Budget override approvals awaiting board action",icon:re}),(0,e.jsx)(C,{label:"Paused agents",value:String(A?.pausedAgentCount??0),subtitle:"Agent heartbeats blocked by budget",icon:ie}),(0,e.jsx)(C,{label:"Paused projects",value:String(A?.pausedProjectCount??0),subtitle:"Project execution blocked by budget",icon:ne})]})]}),I.length>0?(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("h2",{className:"text-lg font-semibold",children:"Active incidents"}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Resolve hard stops here by raising the budget or explicitly keeping the scope paused."})]}),(0,e.jsx)("div",{className:"grid gap-4 xl:grid-cols-2",children:I.map(t=>(0,e.jsx)(Ee,{incident:t,isMutating:K.isPending,onKeepPaused:o(()=>K.mutate({incidentId:t.id,action:"keep_paused"}),"onKeepPaused"),onRaiseAndResume:o(s=>K.mutate({incidentId:t.id,action:"raise_budget_and_resume",amount:s}),"onRaiseAndResume")},t.id))})]}):null,(0,e.jsxs)("div",{className:"space-y-5",children:[["company","agent","project"].map(t=>{const s=tt[t];return s.length===0?null:(0,e.jsxs)("section",{className:"space-y-3",children:[(0,e.jsxs)("div",{children:[(0,e.jsxs)("h2",{className:"text-lg font-semibold capitalize",children:[t," budgets"]}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:t==="company"?"Company-wide monthly policy.":t==="agent"?"Recurring monthly spend policies for individual agents.":"Lifetime spend policies for execution-bound projects."})]}),(0,e.jsx)("div",{className:"grid gap-4 xl:grid-cols-2",children:s.map(n=>(0,e.jsx)(wt,{summary:n,isSaving:me.isPending,onSave:o(r=>me.mutate({scopeType:n.scopeType,scopeId:n.scopeId,amount:r,windowKind:n.windowKind}),"onSave")},n.policyId))})]},t)}),z.length===0?(0,e.jsx)(q,{children:(0,e.jsx)(F,{className:"px-5 py-8 text-sm text-muted-foreground",children:"No budget policies yet. Set agent and project budgets from their detail pages, or use the existing company monthly budget control."})}):null]})]})}),(0,e.jsx)(B,{value:"providers",className:"mt-4 space-y-4",children:G?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select a start and end date to load data."}):(0,e.jsx)(e.Fragment,{children:(0,e.jsxs)(te,{value:V,onValueChange:de,children:[(0,e.jsx)(De,{items:Ze,value:V}),(0,e.jsx)(B,{value:"all",className:"mt-4",children:Y.length===0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"No cost events in this period."}):(0,e.jsx)("div",{className:"grid gap-4 md:grid-cols-2",children:Y.map(t=>(0,e.jsx)(Ke,{provider:t,rows:w.get(t)??[],budgetMonthlyCents:a?.summary.budgetCents??0,totalCompanySpendCents:a?.summary.spendCents??0,weekSpendCents:je.get(t)??0,windowRows:Ne.get(t)??[],showDeficitNotch:ke.get(t)??!1,quotaWindows:Ce.get(t)??[],quotaError:we.get(t)??null,quotaSource:Te.get(t)??null,quotaLoading:ye},t))})}),Y.map(t=>(0,e.jsx)(B,{value:t,className:"mt-4",children:(0,e.jsx)(Ke,{provider:t,rows:w.get(t)??[],budgetMonthlyCents:a?.summary.budgetCents??0,totalCompanySpendCents:a?.summary.spendCents??0,weekSpendCents:je.get(t)??0,windowRows:Ne.get(t)??[],showDeficitNotch:ke.get(t)??!1,quotaWindows:Ce.get(t)??[],quotaError:we.get(t)??null,quotaSource:Te.get(t)??null,quotaLoading:ye})},t))]})})}),(0,e.jsx)(B,{value:"billers",className:"mt-4 space-y-4",children:G?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select a start and end date to load data."}):(0,e.jsx)(e.Fragment,{children:(0,e.jsxs)(te,{value:H,onValueChange:le,children:[(0,e.jsx)(De,{items:et,value:H}),(0,e.jsx)(B,{value:"all",className:"mt-4",children:U.length===0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"No billable events in this period."}):(0,e.jsx)("div",{className:"grid gap-4 md:grid-cols-2",children:U.map(t=>{const s=(k.get(t)??[])[0];if(!s)return null;const n=(Q??[]).filter(r=>r.biller===t);return(0,e.jsx)(Ae,{row:s,weekSpendCents:fe.get(t)??0,budgetMonthlyCents:a?.summary.budgetCents??0,totalCompanySpendCents:a?.summary.spendCents??0,providerRows:n},t)})})}),U.map(t=>{const s=(k.get(t)??[])[0];if(!s)return null;const n=(Q??[]).filter(r=>r.biller===t);return(0,e.jsx)(B,{value:t,className:"mt-4",children:(0,e.jsx)(Ae,{row:s,weekSpendCents:fe.get(t)??0,budgetMonthlyCents:a?.summary.budgetCents??0,totalCompanySpendCents:a?.summary.spendCents??0,providerRows:n})},t)})]})})}),(0,e.jsx)(B,{value:"finance",className:"mt-4 space-y-4",children:G?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select a start and end date to load data."}):pe?(0,e.jsx)(se,{variant:"costs"}):Z?(0,e.jsx)("p",{className:"text-sm text-destructive",children:Z.message}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(_e,{debitCents:p?.summary.debitCents??0,creditCents:p?.summary.creditCents??0,netCents:p?.summary.netCents??0,estimatedDebitCents:p?.summary.estimatedDebitCents??0,eventCount:p?.summary.eventCount??0}),(0,e.jsxs)("div",{className:"grid gap-4 xl:grid-cols-(--gtc-33)",children:[(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsxs)(q,{children:[(0,e.jsxs)($,{className:"px-5 pt-5 pb-2",children:[(0,e.jsx)(L,{className:"text-base",children:"By biller"}),(0,e.jsx)(R,{children:"Account-level financial events grouped by who charged or credited them."})]}),(0,e.jsx)(F,{className:"grid gap-4 px-5 pb-5 pt-2 md:grid-cols-2",children:(p?.byBiller.length??0)===0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"No finance events yet."}):p?.byBiller.map(t=>(0,e.jsx)(kt,{row:t},t.biller))})]}),(0,e.jsx)(Fe,{rows:Be})]}),(0,e.jsx)(jt,{rows:p?.byKind??[]})]})]})})]})]})}o(Ot,"Costs");export{Ot as Costs};
1
+ var ot=Object.defineProperty;var o=(i,h)=>ot(i,"name",{value:h,configurable:!0});import{i as Re}from"./rolldown-runtime-ZpX3ckPj.js";import{Fr as dt,L as J,Lr as lt,M,Pr as ct,S as Ie,T as m,U as ut,Y as v,nr as S,tr as qe,x as mt}from"./createLucideIcon-r3v6fbGz.js";import{i as O,n as B,r as pt,t as te}from"./tabs-DWRZjksg.js";import{r as gt,t as xt}from"./EmptyState-DPcc0zYh.js";import{t as ht}from"./chevron-down-F9aZv-V7.js";import{t as bt}from"./chevron-right-B9JUOr38.js";import{t as vt}from"./button-CAPbz11u.js";import{t as yt}from"./AgentIdentity-MCshmbhZ.js";import{i as R,o as $,r as F,s as L,t as q}from"./card-dmVcp3AX.js";import{t as se}from"./PageSkeleton-DHjTwRT3.js";import{$t as De,C as jt,D as N,E as Ae,Fn as ne,Gt as ft,Hn as re,In as ie,S as Fe,T as Ee,Wn as Nt,_t as ae,b as Ct,gt as wt,v as Tt,w as kt,x as Ke,xn as oe,y as St}from"./index-Dgrf6BZM.js";var l=Re(lt(),1),e=Re(dt(),1),Bt="__none__";function Mt(){const i=new Date,h=i.getDay(),y=h===0?-6:1-h,u=new Date(i.getFullYear(),i.getMonth(),i.getDate()+y,0,0,0,0),j=new Date(u.getFullYear(),u.getMonth(),u.getDate()+6,23,59,59,999);return{from:u.toISOString(),to:j.toISOString()}}o(Mt,"currentWeekRange");function Pt({provider:i,rows:h}){const y=h.reduce((j,b)=>j+b.inputTokens+b.cachedInputTokens+b.outputTokens,0),u=h.reduce((j,b)=>j+b.costCents,0);return(0,e.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,e.jsx)("span",{children:J(i)}),(0,e.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:M(y)}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:m(u)})]})}o(Pt,"ProviderTabLabel");function It({biller:i,rows:h}){const y=h.reduce((j,b)=>j+b.inputTokens+b.cachedInputTokens+b.outputTokens,0),u=h.reduce((j,b)=>j+b.costCents,0);return(0,e.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,e.jsx)("span",{children:J(i)}),(0,e.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:M(y)}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:m(u)})]})}o(It,"BillerTabLabel");function C({label:i,value:h,subtitle:y,icon:u}){return(0,e.jsx)(q,{className:"block p-4",children:(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("div",{className:"text-(length:--text-micro) uppercase tracking-(--tracking-eyebrow) text-muted-foreground",children:i}),(0,e.jsx)("div",{className:"mt-2 text-2xl font-semibold tabular-nums",children:h}),(0,e.jsx)("div",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:y})]}),(0,e.jsx)("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-md border border-border",children:(0,e.jsx)(u,{className:"h-4 w-4 text-muted-foreground"})})]})})}o(C,"MetricTile");function _e({debitCents:i,creditCents:h,netCents:y,estimatedDebitCents:u,eventCount:j}){return(0,e.jsxs)(q,{children:[(0,e.jsxs)($,{className:"px-5 pt-5 pb-2",children:[(0,e.jsx)(L,{className:"text-base",children:"Finance ledger"}),(0,e.jsx)(R,{children:"Account-level charges that do not map to a single inference request."})]}),(0,e.jsxs)(F,{className:"grid gap-3 px-5 pb-5 pt-2 sm:grid-cols-2 xl:grid-cols-4",children:[(0,e.jsx)(C,{label:"Debits",value:m(i),subtitle:`${j} total event${j===1?"":"s"} in range`,icon:re}),(0,e.jsx)(C,{label:"Credits",value:m(h),subtitle:"Refunds, offsets, and credit returns",icon:Nt}),(0,e.jsx)(C,{label:"Net",value:m(y),subtitle:"Debit minus credit for the selected period",icon:oe}),(0,e.jsx)(C,{label:"Estimated",value:m(u),subtitle:"Estimated debits that are not yet invoice-authoritative",icon:ie})]})]})}o(_e,"FinanceSummaryCard");function Ot(){const{selectedCompanyId:i}=ut(),{setBreadcrumbs:h}=gt(),y=ct(),[u,j]=(0,l.useState)("overview"),[b,de]=(0,l.useState)("all"),[W,le]=(0,l.useState)("all"),{preset:E,setPreset:$e,customFrom:Le,setCustomFrom:We,customTo:ze,setCustomTo:Oe,from:g,to:x,customReady:D}=Ct();(0,l.useEffect)(()=>{h([{label:"Costs"}])},[h]);const[Qe,Ye]=(0,l.useState)(()=>new Date().toDateString()),X=(0,l.useRef)(null);(0,l.useEffect)(()=>{const t=o(()=>{const s=new Date,n=new Date(s.getFullYear(),s.getMonth(),s.getDate()+1).getTime()-s.getTime();X.current=setTimeout(()=>{Ye(new Date().toDateString()),t()},n)},"schedule");return t(),()=>{X.current!=null&&clearTimeout(X.current)}},[]);const P=(0,l.useMemo)(()=>Mt(),[Qe]),d=i??Bt,{data:A,isLoading:Ue,error:ce}=S({queryKey:v.budgets.overview(d),queryFn:o(()=>ae.overview(d),"queryFn"),enabled:!!i&&D,refetchInterval:3e4,staleTime:5e3}),ue=o(()=>{i&&(y.invalidateQueries({queryKey:v.budgets.overview(i)}),y.invalidateQueries({queryKey:v.dashboard(i)}),y.invalidateQueries({queryKey:v.agents.list(i)}),y.invalidateQueries({queryKey:v.projects.all(i)}))},"invalidateBudgetViews"),me=qe({mutationFn:o(t=>ae.upsertPolicy(d,{scopeType:t.scopeType,scopeId:t.scopeId,amount:t.amount,windowKind:t.windowKind}),"mutationFn"),onSuccess:ue}),K=qe({mutationFn:o(t=>ae.resolveIncident(d,t.incidentId,t),"mutationFn"),onSuccess:ue}),{data:a,isLoading:Ve,error:He}=S({queryKey:v.costs(d,g||void 0,x||void 0),queryFn:o(async()=>{const[t,s,n,r]=await Promise.all([N.summary(d,g||void 0,x||void 0),N.byAgent(d,g||void 0,x||void 0),N.byProject(d,g||void 0,x||void 0),N.byAgentModel(d,g||void 0,x||void 0)]);return{summary:t,byAgent:s,byProject:n,byAgentModel:r}},"queryFn"),enabled:!!i&&D}),{data:p,isLoading:pe,error:Z}=S({queryKey:[v.financeSummary(d,g||void 0,x||void 0),v.financeByBiller(d,g||void 0,x||void 0),v.financeByKind(d,g||void 0,x||void 0),v.financeEvents(d,g||void 0,x||void 0,18)],queryFn:o(async()=>{const[t,s,n,r]=await Promise.all([N.financeSummary(d,g||void 0,x||void 0),N.financeByBiller(d,g||void 0,x||void 0),N.financeByKind(d,g||void 0,x||void 0),N.financeEvents(d,g||void 0,x||void 0,18)]);return{summary:t,byBiller:s,byKind:n,events:r}},"queryFn"),enabled:!!i&&D}),[Ge,ge]=(0,l.useState)(new Set);(0,l.useEffect)(()=>{ge(new Set)},[d,g,x]);function Je(t){ge(s=>{const n=new Set(s);return n.has(t)?n.delete(t):n.add(t),n})}o(Je,"toggleAgent");const Xe=(0,l.useMemo)(()=>{const t=new Map;for(const s of a?.byAgentModel??[]){const n=t.get(s.agentId)??[];n.push(s),t.set(s.agentId,n)}for(const[s,n]of t)t.set(s,n.slice().sort((r,c)=>c.costCents-r.costCents));return t},[a?.byAgentModel]),{data:Q}=S({queryKey:v.usageByProvider(d,g||void 0,x||void 0),queryFn:o(()=>N.byProvider(d,g||void 0,x||void 0),"queryFn"),enabled:!!i&&D&&(u==="providers"||u==="billers"),refetchInterval:3e4,staleTime:1e4}),{data:xe}=S({queryKey:v.usageByBiller(d,g||void 0,x||void 0),queryFn:o(()=>N.byBiller(d,g||void 0,x||void 0),"queryFn"),enabled:!!i&&D&&u==="billers",refetchInterval:3e4,staleTime:1e4}),{data:he}=S({queryKey:v.usageByProvider(d,P.from,P.to),queryFn:o(()=>N.byProvider(d,P.from,P.to),"queryFn"),enabled:!!i&&(u==="providers"||u==="billers"),refetchInterval:3e4,staleTime:1e4}),{data:be}=S({queryKey:v.usageByBiller(d,P.from,P.to),queryFn:o(()=>N.byBiller(d,P.from,P.to),"queryFn"),enabled:!!i&&u==="billers",refetchInterval:3e4,staleTime:1e4}),{data:ve}=S({queryKey:v.usageWindowSpend(d),queryFn:o(()=>N.windowSpend(d),"queryFn"),enabled:!!i&&u==="providers",refetchInterval:3e4,staleTime:1e4}),{data:_,isLoading:ye}=S({queryKey:v.usageQuotaWindows(d),queryFn:o(()=>N.quotaWindows(d),"queryFn"),enabled:!!i&&u==="providers",refetchInterval:3e5,staleTime:6e4}),w=(0,l.useMemo)(()=>{const t=new Map;for(const s of Q??[]){const n=t.get(s.provider)??[];n.push(s),t.set(s.provider,n)}return t},[Q]),k=(0,l.useMemo)(()=>{const t=new Map;for(const s of xe??[]){const n=t.get(s.biller)??[];n.push(s),t.set(s.biller,n)}return t},[xe]),je=(0,l.useMemo)(()=>{const t=new Map;for(const s of he??[])t.set(s.provider,(t.get(s.provider)??0)+s.costCents);return t},[he]),fe=(0,l.useMemo)(()=>{const t=new Map;for(const s of be??[])t.set(s.biller,(t.get(s.biller)??0)+s.costCents);return t},[be]),Ne=(0,l.useMemo)(()=>{const t=new Map;for(const s of ve??[]){const n=t.get(s.provider)??[];n.push(s),t.set(s.provider,n)}return t},[ve]),Ce=(0,l.useMemo)(()=>{const t=new Map;for(const s of _??[])s.ok&&s.windows.length>0&&t.set(s.provider,s.windows);return t},[_]),we=(0,l.useMemo)(()=>{const t=new Map;for(const s of _??[])!s.ok&&s.error&&t.set(s.provider,s.error);return t},[_]),Te=(0,l.useMemo)(()=>{const t=new Map;for(const s of _??[])typeof s.source=="string"&&s.source.length>0&&t.set(s.provider,s.source);return t},[_]),ke=(0,l.useMemo)(()=>{const t=new Map;if(E!=="mtd")return t;const s=a?.summary.budgetCents??0;if(s<=0)return t;const n=a?.summary.spendCents??0,r=new Date,c=r.getDate(),T=new Date(r.getFullYear(),r.getMonth()+1,0).getDate();for(const[f,nt]of w){const ee=nt.reduce((rt,it)=>rt+it.costCents,0),Pe=s*(n>0?ee/n:0);if(Pe<=0){t.set(f,!1);continue}const at=ee/Math.max(c,1);t.set(f,ee+at*(T-c)>Pe)}return t},[E,a,w]),Y=(0,l.useMemo)(()=>Array.from(w.keys()),[w]),U=(0,l.useMemo)(()=>Array.from(k.keys()),[k]),V=b==="all"||Y.includes(b)?b:"all";(0,l.useEffect)(()=>{V!==b&&de("all")},[V,b]);const H=W==="all"||U.includes(W)?W:"all";(0,l.useEffect)(()=>{H!==W&&le("all")},[H,W]);const Ze=(0,l.useMemo)(()=>{const t=Array.from(w.keys()),s=t.reduce((r,c)=>r+(w.get(c)?.reduce((T,f)=>T+f.inputTokens+f.cachedInputTokens+f.outputTokens,0)??0),0),n=t.reduce((r,c)=>r+(w.get(c)?.reduce((T,f)=>T+f.costCents,0)??0),0);return[{value:"all",label:(0,e.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,e.jsx)("span",{children:"All providers"}),t.length>0?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:M(s)}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:m(n)})]}):null]})},...t.map(r=>({value:r,label:(0,e.jsx)(Pt,{provider:r,rows:w.get(r)??[]})}))]},[w]),et=(0,l.useMemo)(()=>{const t=Array.from(k.keys()),s=t.reduce((r,c)=>r+(k.get(c)?.reduce((T,f)=>T+f.inputTokens+f.cachedInputTokens+f.outputTokens,0)??0),0),n=t.reduce((r,c)=>r+(k.get(c)?.reduce((T,f)=>T+f.costCents,0)??0),0);return[{value:"all",label:(0,e.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,e.jsx)("span",{children:"All billers"}),t.length>0?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:M(s)}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:m(n)})]}):null]})},...t.map(r=>({value:r,label:(0,e.jsx)(It,{biller:r,rows:k.get(r)??[]})}))]},[k]),Se=(a?.byAgent??[]).reduce((t,s)=>t+s.inputTokens+s.cachedInputTokens+s.outputTokens,0),Be=p?.events??[],z=A?.policies??[],I=A?.activeIncidents??[],tt=(0,l.useMemo)(()=>({company:z.filter(t=>t.scopeType==="company"),agent:z.filter(t=>t.scopeType==="agent"),project:z.filter(t=>t.scopeType==="project")}),[z]);if(!i)return(0,e.jsx)(xt,{icon:ne,message:"Select a company to view costs."});const G=E==="custom"&&!D,st=(Ve||pe)&&D,Me=He??Z;return(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsxs)("div",{className:"space-y-5",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("h1",{className:"text-3xl font-semibold tracking-tight",children:"Costs"}),(0,e.jsx)("p",{className:"mt-2 max-w-2xl text-sm leading-6 text-muted-foreground",children:"Inference spend, platform fees, credits, and live quota windows."})]}),(0,e.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:Tt.map(t=>(0,e.jsx)(vt,{variant:E===t?"secondary":"ghost",size:"sm",onClick:o(()=>$e(t),"onClick"),"aria-pressed":E===t,children:St[t]},t))})]}),E==="custom"?(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2 border border-border p-3",children:[(0,e.jsx)("input",{type:"date",value:Le,onChange:o(t=>We(t.target.value),"onChange"),className:"h-9 rounded-md border border-input bg-background px-3 text-sm text-foreground"}),(0,e.jsx)("span",{className:"text-sm text-muted-foreground",children:"to"}),(0,e.jsx)("input",{type:"date",value:ze,onChange:o(t=>Oe(t.target.value),"onChange"),className:"h-9 rounded-md border border-input bg-background px-3 text-sm text-foreground"})]}):null,(0,e.jsxs)("div",{className:"grid gap-3 lg:grid-cols-4",children:[(0,e.jsx)(C,{label:"Inference spend",value:m(a?.summary.spendCents??0),subtitle:`${M(Se)} tokens across request-scoped events`,icon:ne}),(0,e.jsx)(C,{label:"Budget",value:I.length>0?String(I.length):a?.summary.budgetCents&&a.summary.budgetCents>0?`${a.summary.utilizationPercent}%`:"Open",subtitle:I.length>0?`${A?.pausedAgentCount??0} agents paused · ${A?.pausedProjectCount??0} projects paused`:a?.summary.budgetCents&&a.summary.budgetCents>0?`${m(a.summary.spendCents)} of ${m(a.summary.budgetCents)}`:"No monthly cap configured",icon:ie}),(0,e.jsx)(C,{label:"Finance net",value:m(p?.summary.netCents??0),subtitle:`${m(p?.summary.debitCents??0)} debits · ${m(p?.summary.creditCents??0)} credits`,icon:oe}),(0,e.jsx)(C,{label:"Finance events",value:String(p?.summary.eventCount??0),subtitle:`${m(p?.summary.estimatedDebitCents??0)} estimated in range`,icon:re})]})]}),(0,e.jsxs)(te,{value:u,onValueChange:o(t=>j(t),"onValueChange"),children:[(0,e.jsxs)(pt,{variant:"line",className:"justify-start",children:[(0,e.jsx)(O,{value:"overview",children:"Overview"}),(0,e.jsx)(O,{value:"budgets",children:"Budgets"}),(0,e.jsx)(O,{value:"providers",children:"Providers"}),(0,e.jsx)(O,{value:"billers",children:"Billers"}),(0,e.jsx)(O,{value:"finance",children:"Finance"})]}),(0,e.jsx)(B,{value:"overview",className:"mt-4 space-y-4",children:G?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select a start and end date to load data."}):st?(0,e.jsx)(se,{variant:"costs"}):Me?(0,e.jsx)("p",{className:"text-sm text-destructive",children:Me.message}):(0,e.jsxs)(e.Fragment,{children:[I.length>0?(0,e.jsx)("div",{className:"grid gap-4 xl:grid-cols-2",children:I.slice(0,2).map(t=>(0,e.jsx)(Ee,{incident:t,isMutating:K.isPending,onKeepPaused:o(()=>K.mutate({incidentId:t.id,action:"keep_paused"}),"onKeepPaused"),onRaiseAndResume:o(s=>K.mutate({incidentId:t.id,action:"raise_budget_and_resume",amount:s}),"onRaiseAndResume")},t.id))}):null,(0,e.jsxs)("div",{className:"grid gap-4 xl:grid-cols-(--gtc-31)",children:[(0,e.jsxs)(q,{children:[(0,e.jsxs)($,{className:"px-5 pt-5 pb-2",children:[(0,e.jsx)(L,{className:"text-base",children:"Inference ledger"}),(0,e.jsx)(R,{children:"Request-scoped inference spend for the selected period."})]}),(0,e.jsxs)(F,{className:"space-y-4 px-5 pb-5 pt-2",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-3xl font-semibold tabular-nums",children:m(a?.summary.spendCents??0)}),(0,e.jsx)("div",{className:"mt-1 text-sm text-muted-foreground",children:a?.summary.budgetCents&&a.summary.budgetCents>0?`Budget ${m(a.summary.budgetCents)}`:"Unlimited budget"})]}),(0,e.jsxs)("div",{className:"border border-border px-4 py-3 text-right",children:[(0,e.jsx)("div",{className:"text-(length:--text-micro) uppercase tracking-(--tracking-eyebrow) text-muted-foreground",children:"usage"}),(0,e.jsx)("div",{className:"mt-1 text-lg font-medium tabular-nums",children:M(Se)})]})]}),a?.summary.budgetCents&&a.summary.budgetCents>0?(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("div",{className:"h-2 overflow-hidden bg-muted",children:(0,e.jsx)("div",{className:Ie("h-full transition-(--tp-width-background-color) duration-150",a.summary.utilizationPercent>90?"bg-(--status-task-blocked)":a.summary.utilizationPercent>70?"bg-(--status-task-todo)":"bg-(--status-task-done)"),style:{width:`${Math.min(100,a.summary.utilizationPercent)}%`}})}),(0,e.jsxs)("div",{className:"text-xs text-muted-foreground",children:[a.summary.utilizationPercent,"% of monthly budget consumed in this range."]})]}):null]})]}),(0,e.jsx)(_e,{debitCents:p?.summary.debitCents??0,creditCents:p?.summary.creditCents??0,netCents:p?.summary.netCents??0,estimatedDebitCents:p?.summary.estimatedDebitCents??0,eventCount:p?.summary.eventCount??0})]}),(0,e.jsxs)("div",{className:"grid gap-4 xl:grid-cols-(--gtc-32)",children:[(0,e.jsxs)(q,{children:[(0,e.jsxs)($,{className:"px-5 pt-5 pb-2",children:[(0,e.jsx)(L,{className:"text-base",children:"By agent"}),(0,e.jsx)(R,{children:"What each agent consumed in the selected period."})]}),(0,e.jsx)(F,{className:"space-y-2 px-5 pb-5 pt-2",children:(a?.byAgent.length??0)===0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"No cost events yet."}):a?.byAgent.map(t=>{const s=Xe.get(t.agentId)??[],n=Ge.has(t.agentId),r=s.length>0;return(0,e.jsxs)("div",{className:"border border-border px-4 py-3",children:[(0,e.jsxs)("div",{className:Ie("flex items-start justify-between gap-3",r?"cursor-pointer select-none":""),onClick:o(()=>r&&Je(t.agentId),"onClick"),children:[(0,e.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[r?n?(0,e.jsx)(ht,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):(0,e.jsx)(bt,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):(0,e.jsx)("span",{className:"h-3 w-3 shrink-0"}),(0,e.jsx)(yt,{agent:{id:t.agentId,name:t.agentName??t.agentId,appearance:t.agentAppearance},size:"sm"}),t.agentStatus==="terminated"?(0,e.jsx)(ft,{status:"terminated"}):null]}),(0,e.jsxs)("div",{className:"text-right text-sm tabular-nums",children:[(0,e.jsx)("div",{className:"font-medium",children:m(t.costCents)}),(0,e.jsxs)("div",{className:"text-xs text-muted-foreground",children:["in ",M(t.inputTokens+t.cachedInputTokens)," · out ",M(t.outputTokens)]}),t.apiRunCount>0||t.subscriptionRunCount>0?(0,e.jsxs)("div",{className:"text-xs text-muted-foreground",children:[t.apiRunCount>0?`${t.apiRunCount} api`:"0 api"," · ",t.subscriptionRunCount>0?`${t.subscriptionRunCount} subscription`:"0 subscription"]}):null]})]}),n&&s.length>0?(0,e.jsx)("div",{className:"mt-3 space-y-2 border-l border-border pl-4",children:s.map(c=>{const T=t.costCents>0?Math.round(c.costCents/t.costCents*100):0;return(0,e.jsxs)("div",{className:"flex items-start justify-between gap-3 text-xs",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsxs)("div",{className:"truncate font-medium text-foreground",children:[J(c.provider),(0,e.jsx)("span",{className:"mx-1 text-border",children:"/"}),(0,e.jsx)("span",{className:"font-mono",children:c.model})]}),(0,e.jsxs)("div",{className:"truncate text-muted-foreground",children:[J(c.biller)," · ",mt(c.billingType)]})]}),(0,e.jsxs)("div",{className:"text-right tabular-nums",children:[(0,e.jsxs)("div",{className:"font-medium",children:[m(c.costCents),(0,e.jsxs)("span",{className:"ml-1 font-normal text-muted-foreground",children:["(",T,"%)"]})]}),(0,e.jsxs)("div",{className:"text-muted-foreground",children:[M(c.inputTokens+c.cachedInputTokens+c.outputTokens)," tok"]})]})]},`${c.provider}:${c.model}:${c.billingType}`)})}):null]},t.agentId)})})]}),(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsxs)(q,{children:[(0,e.jsxs)($,{className:"px-5 pt-5 pb-2",children:[(0,e.jsx)(L,{className:"text-base",children:"By project"}),(0,e.jsx)(R,{children:"Run costs attributed through project-linked tasks."})]}),(0,e.jsx)(F,{className:"space-y-2 px-5 pb-5 pt-2",children:(a?.byProject.length??0)===0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"No project-attributed run costs yet."}):a?.byProject.map((t,s)=>(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3 border border-border px-3 py-2 text-sm",children:[(0,e.jsx)("span",{className:"truncate",children:t.projectName??t.projectId??"Unattributed"}),(0,e.jsx)("span",{className:"font-medium tabular-nums",children:m(t.costCents)})]},t.projectId??`unattributed-${s}`))})]}),(0,e.jsx)(Fe,{rows:Be.slice(0,6),emptyMessage:"No finance events yet. Add account-level charges once biller invoices or credits land."})]})]})]})}),(0,e.jsx)(B,{value:"budgets",className:"mt-4 space-y-4",children:Ue?(0,e.jsx)(se,{variant:"costs"}):ce?(0,e.jsx)("p",{className:"text-sm text-destructive",children:ce.message}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(q,{className:"border-border/70 bg-(image:--gradient-extract-2)",children:[(0,e.jsxs)($,{className:"px-5 pt-5 pb-3",children:[(0,e.jsx)(L,{className:"text-base",children:"Budget control plane"}),(0,e.jsx)(R,{children:"Hard-stop spend limits for agents and projects. Provider subscription quota stays separate and appears under Providers."})]}),(0,e.jsxs)(F,{className:"grid gap-3 px-5 pb-5 pt-0 md:grid-cols-4",children:[(0,e.jsx)(C,{label:"Active incidents",value:String(I.length),subtitle:"Open soft or hard threshold crossings",icon:oe}),(0,e.jsx)(C,{label:"Pending approvals",value:String(A?.pendingApprovalCount??0),subtitle:"Budget override approvals awaiting board action",icon:re}),(0,e.jsx)(C,{label:"Paused agents",value:String(A?.pausedAgentCount??0),subtitle:"Agent heartbeats blocked by budget",icon:ie}),(0,e.jsx)(C,{label:"Paused projects",value:String(A?.pausedProjectCount??0),subtitle:"Project execution blocked by budget",icon:ne})]})]}),I.length>0?(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("h2",{className:"text-lg font-semibold",children:"Active incidents"}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Resolve hard stops here by raising the budget or explicitly keeping the scope paused."})]}),(0,e.jsx)("div",{className:"grid gap-4 xl:grid-cols-2",children:I.map(t=>(0,e.jsx)(Ee,{incident:t,isMutating:K.isPending,onKeepPaused:o(()=>K.mutate({incidentId:t.id,action:"keep_paused"}),"onKeepPaused"),onRaiseAndResume:o(s=>K.mutate({incidentId:t.id,action:"raise_budget_and_resume",amount:s}),"onRaiseAndResume")},t.id))})]}):null,(0,e.jsxs)("div",{className:"space-y-5",children:[["company","agent","project"].map(t=>{const s=tt[t];return s.length===0?null:(0,e.jsxs)("section",{className:"space-y-3",children:[(0,e.jsxs)("div",{children:[(0,e.jsxs)("h2",{className:"text-lg font-semibold capitalize",children:[t," budgets"]}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:t==="company"?"Company-wide monthly policy.":t==="agent"?"Recurring monthly spend policies for individual agents.":"Lifetime spend policies for execution-bound projects."})]}),(0,e.jsx)("div",{className:"grid gap-4 xl:grid-cols-2",children:s.map(n=>(0,e.jsx)(wt,{summary:n,isSaving:me.isPending,onSave:o(r=>me.mutate({scopeType:n.scopeType,scopeId:n.scopeId,amount:r,windowKind:n.windowKind}),"onSave")},n.policyId))})]},t)}),z.length===0?(0,e.jsx)(q,{children:(0,e.jsx)(F,{className:"px-5 py-8 text-sm text-muted-foreground",children:"No budget policies yet. Set agent and project budgets from their detail pages, or use the existing company monthly budget control."})}):null]})]})}),(0,e.jsx)(B,{value:"providers",className:"mt-4 space-y-4",children:G?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select a start and end date to load data."}):(0,e.jsx)(e.Fragment,{children:(0,e.jsxs)(te,{value:V,onValueChange:de,children:[(0,e.jsx)(De,{items:Ze,value:V}),(0,e.jsx)(B,{value:"all",className:"mt-4",children:Y.length===0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"No cost events in this period."}):(0,e.jsx)("div",{className:"grid gap-4 md:grid-cols-2",children:Y.map(t=>(0,e.jsx)(Ke,{provider:t,rows:w.get(t)??[],budgetMonthlyCents:a?.summary.budgetCents??0,totalCompanySpendCents:a?.summary.spendCents??0,weekSpendCents:je.get(t)??0,windowRows:Ne.get(t)??[],showDeficitNotch:ke.get(t)??!1,quotaWindows:Ce.get(t)??[],quotaError:we.get(t)??null,quotaSource:Te.get(t)??null,quotaLoading:ye},t))})}),Y.map(t=>(0,e.jsx)(B,{value:t,className:"mt-4",children:(0,e.jsx)(Ke,{provider:t,rows:w.get(t)??[],budgetMonthlyCents:a?.summary.budgetCents??0,totalCompanySpendCents:a?.summary.spendCents??0,weekSpendCents:je.get(t)??0,windowRows:Ne.get(t)??[],showDeficitNotch:ke.get(t)??!1,quotaWindows:Ce.get(t)??[],quotaError:we.get(t)??null,quotaSource:Te.get(t)??null,quotaLoading:ye})},t))]})})}),(0,e.jsx)(B,{value:"billers",className:"mt-4 space-y-4",children:G?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select a start and end date to load data."}):(0,e.jsx)(e.Fragment,{children:(0,e.jsxs)(te,{value:H,onValueChange:le,children:[(0,e.jsx)(De,{items:et,value:H}),(0,e.jsx)(B,{value:"all",className:"mt-4",children:U.length===0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"No billable events in this period."}):(0,e.jsx)("div",{className:"grid gap-4 md:grid-cols-2",children:U.map(t=>{const s=(k.get(t)??[])[0];if(!s)return null;const n=(Q??[]).filter(r=>r.biller===t);return(0,e.jsx)(Ae,{row:s,weekSpendCents:fe.get(t)??0,budgetMonthlyCents:a?.summary.budgetCents??0,totalCompanySpendCents:a?.summary.spendCents??0,providerRows:n},t)})})}),U.map(t=>{const s=(k.get(t)??[])[0];if(!s)return null;const n=(Q??[]).filter(r=>r.biller===t);return(0,e.jsx)(B,{value:t,className:"mt-4",children:(0,e.jsx)(Ae,{row:s,weekSpendCents:fe.get(t)??0,budgetMonthlyCents:a?.summary.budgetCents??0,totalCompanySpendCents:a?.summary.spendCents??0,providerRows:n})},t)})]})})}),(0,e.jsx)(B,{value:"finance",className:"mt-4 space-y-4",children:G?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select a start and end date to load data."}):pe?(0,e.jsx)(se,{variant:"costs"}):Z?(0,e.jsx)("p",{className:"text-sm text-destructive",children:Z.message}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(_e,{debitCents:p?.summary.debitCents??0,creditCents:p?.summary.creditCents??0,netCents:p?.summary.netCents??0,estimatedDebitCents:p?.summary.estimatedDebitCents??0,eventCount:p?.summary.eventCount??0}),(0,e.jsxs)("div",{className:"grid gap-4 xl:grid-cols-(--gtc-33)",children:[(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsxs)(q,{children:[(0,e.jsxs)($,{className:"px-5 pt-5 pb-2",children:[(0,e.jsx)(L,{className:"text-base",children:"By biller"}),(0,e.jsx)(R,{children:"Account-level financial events grouped by who charged or credited them."})]}),(0,e.jsx)(F,{className:"grid gap-4 px-5 pb-5 pt-2 md:grid-cols-2",children:(p?.byBiller.length??0)===0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"No finance events yet."}):p?.byBiller.map(t=>(0,e.jsx)(kt,{row:t},t.biller))})]}),(0,e.jsx)(Fe,{rows:Be})]}),(0,e.jsx)(jt,{rows:p?.byKind??[]})]})]})})]})]})}o(Ot,"Costs");export{Ot as Costs};
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-G_BSi0G0.js","assets/preload-helper-CceJXRIF.js","assets/chunk-Y2CYZVJY-OvsAdhaO.js","assets/src-Bssc388C.js","assets/rolldown-runtime-ZpX3ckPj.js","assets/chunk-DU6HZSFF-2P5iNHqg.js","assets/chunk-75Z2AOVW-BaPl5WA6.js","assets/dist-Cj4C2HPs.js","assets/chunk-PWAF6VOD-CR3rNBNB.js","assets/chunk-GMAD6QVW-BfvaaEBW.js","assets/chunk-P2QGCYS3-CjqEi3mx.js","assets/chunk-4HAMMTFA-CGGd_Pxz.js","assets/rough.esm-DnC5Tr1g.js","assets/chunk-GVQU2GXP-Cwp_Wpj2.js","assets/chunk-OSK3NFVY-DlrxddG-.js","assets/line-CJEZO7lL.js","assets/path-D6mommQw.js","assets/array-CL5Tisss.js","assets/graphlib-DHhK3saS.js","assets/chunk-L3NEJ4N5-JUd1UqX1.js"])))=>i.map(i=>d[i]);
2
- var xn=Object.defineProperty;var o=(e,t)=>xn(e,"name",{value:t,configurable:!0});import{i as ye,n as Sn,t as ie}from"./rolldown-runtime-ZpX3ckPj.js";import{Fr as Bn,Lr as In,Pr as Pn,S as H,W as Ln,Xn as fe,Y as St,nr as Rn,t as Bt}from"./createLucideIcon-r3v6fbGz.js";import{t as jn}from"./preload-helper-CceJXRIF.js";import{B as Tn,a as Nn,c as _n,it as It,o as On,s as Mn,t as Ue}from"./router-DyZkoSkG.js";import{C as zn,D as Pt,F as Re,H as re,I as tt,J as He,K as $,L as $n,P as T,R as Un,S as Hn,U as le,W as Wn,Y as Z,_ as Vn,c as Kn,d as qn,f as Xn,g as ue,h as Yn,i as Lt,j as We,k as nt,l as Gn,m as Zn,p as Jn,r as Qn,u as er,x as Ve,z as tr}from"./mention-chips-DXumPrOR.js";import{c as nr,d as rr,h as rt,i as Rt,l as lr,m as or,n as ir,t as ur,u as jt,y as ar}from"./StatusIcon-BuUYMqqU.js";import{t as sr}from"./check-DDiXDm2i.js";import{p as cr}from"./button-CAPbz11u.js";import{i as pr,r as fr,t as hr}from"./clipboard-CYJ5Q78m.js";import{t as dr}from"./external-link-0lrOvZWO.js";var mr=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],Dr=Bt("file-code-corner",mr),gr=[["path",{d:"m16 16-3 3 3 3",key:"117b85"}],["path",{d:"M3 12h14.5a1 1 0 0 1 0 7H13",key:"18xa6z"}],["path",{d:"M3 19h6",key:"1ygdsz"}],["path",{d:"M3 5h18",key:"1u36vt"}]],Fr=Bt("text-wrap",gr);function J(e){const t=[];let n=-1,r=0,l=0;for(;++n<e.length;){const u=e.charCodeAt(n);let i="";if(u===37&&le(e.charCodeAt(n+1))&&le(e.charCodeAt(n+2)))l=2;else if(u<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(u))||(i=String.fromCharCode(u));else if(u>55295&&u<57344){const a=e.charCodeAt(n+1);u<56320&&a>56319&&a<57344?(i=String.fromCharCode(u,a),l=1):i="�"}else i=String.fromCharCode(u);i&&(t.push(e.slice(r,n),encodeURIComponent(i)),r=n+l+1,i=""),l&&(n+=l,l=0)}return t.join("")+e.slice(r)}o(J,"normalizeUri");var w=ye(In(),1),g=ye(Bn(),1);function yr(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}o(yr,"escapeStringRegexp");var Tt="paperclip.theme",wr="#18181b",Cr="#ffffff",Nt=(0,w.createContext)(void 0);function kr(){return typeof document>"u"||document.documentElement.classList.contains("dark")?"dark":"light"}o(kr,"resolveThemeFromDocument");function Er(){if(typeof window>"u")return!1;try{const e=window.localStorage.getItem(Tt);return e==="light"||e==="dark"}catch{return!1}}o(Er,"hasStoredTheme");function Ar(e){if(typeof document>"u")return;const t=e==="dark",n=document.documentElement;n.classList.toggle("dark",t),n.style.colorScheme=t?"dark":"light";const r=document.querySelector('meta[name="theme-color"]');r instanceof HTMLMetaElement&&r.setAttribute("content",t?wr:Cr)}o(Ar,"applyTheme");function oa({children:e}){const[t,n]=(0,w.useState)(()=>kr()),[r,l]=(0,w.useState)(()=>Er()),u=(0,w.useCallback)(c=>{l(!0),n(c)},[]),i=(0,w.useCallback)(()=>{l(!0),n(c=>c==="dark"?"light":"dark")},[]);(0,w.useEffect)(()=>{if(Ar(t),!!r)try{localStorage.setItem(Tt,t)}catch{}},[t,r]),(0,w.useEffect)(()=>{if(r||typeof window>"u"||typeof window.matchMedia!="function")return;const c=window.matchMedia("(prefers-color-scheme: dark)"),p=o(f=>{n(f.matches?"dark":"light")},"handleChange");return c.addEventListener("change",p),()=>c.removeEventListener("change",p)},[r]);const a=(0,w.useMemo)(()=>({theme:t,setTheme:u,toggleTheme:i}),[t,u,i]);return(0,g.jsx)(Nt.Provider,{value:a,children:e})}o(oa,"ThemeProvider");function vr(){const e=(0,w.useContext)(Nt);if(!e)throw new Error("useTheme must be used within ThemeProvider");return e}o(vr,"useTheme");function br(e,t){const n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}o(br,"stringify$1");var xr=/[ \t\n\f\r]/g;function Sr(e){return typeof e=="object"?e.type==="text"?lt(e.value):!1:lt(e)}o(Sr,"whitespace");function lt(e){return e.replace(xr,"")===""}o(lt,"empty");var ae=class{static{o(this,"Schema")}constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};ae.prototype.normal={};ae.prototype.property={};ae.prototype.space=void 0;function _t(e,t){const n={},r={};for(const l of e)Object.assign(n,l.property),Object.assign(r,l.normal);return new ae(n,r,t)}o(_t,"merge");function je(e){return e.toLowerCase()}o(je,"normalize$1");var N=class{static{o(this,"Info")}constructor(e,t){this.attribute=t,this.property=e}};N.prototype.attribute="";N.prototype.booleanish=!1;N.prototype.boolean=!1;N.prototype.commaOrSpaceSeparated=!1;N.prototype.commaSeparated=!1;N.prototype.defined=!1;N.prototype.mustUseProperty=!1;N.prototype.number=!1;N.prototype.overloadedBoolean=!1;N.prototype.property="";N.prototype.spaceSeparated=!1;N.prototype.space=void 0;var Te=Sn({boolean:o(()=>v,"boolean"),booleanish:o(()=>L,"booleanish"),commaOrSpaceSeparated:o(()=>M,"commaOrSpaceSeparated"),commaSeparated:o(()=>X,"commaSeparated"),number:o(()=>m,"number"),overloadedBoolean:o(()=>Ne,"overloadedBoolean"),spaceSeparated:o(()=>P,"spaceSeparated")}),Br=0,v=Y(),L=Y(),Ne=Y(),m=Y(),P=Y(),X=Y(),M=Y();function Y(){return 2**++Br}o(Y,"increment");var we=Object.keys(Te),Ke=class extends N{static{o(this,"DefinedInfo")}constructor(e,t,n,r){let l=-1;if(super(e,t),ot(this,"space",r),typeof n=="number")for(;++l<we.length;){const u=we[l];ot(this,we[l],(n&Te[u])===Te[u])}}};Ke.prototype.defined=!0;function ot(e,t,n){n&&(e[t]=n)}o(ot,"mark");function Q(e){const t={},n={};for(const[r,l]of Object.entries(e.properties)){const u=new Ke(r,e.transform(e.attributes||{},r),l,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(u.mustUseProperty=!0),t[r]=u,n[je(r)]=r,n[je(u.attribute)]=r}return new ae(t,n,e.space)}o(Q,"create");var Ot=Q({properties:{ariaActiveDescendant:null,ariaAtomic:L,ariaAutoComplete:null,ariaBusy:L,ariaChecked:L,ariaColCount:m,ariaColIndex:m,ariaColSpan:m,ariaControls:P,ariaCurrent:null,ariaDescribedBy:P,ariaDetails:null,ariaDisabled:L,ariaDropEffect:P,ariaErrorMessage:null,ariaExpanded:L,ariaFlowTo:P,ariaGrabbed:L,ariaHasPopup:null,ariaHidden:L,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:P,ariaLevel:m,ariaLive:null,ariaModal:L,ariaMultiLine:L,ariaMultiSelectable:L,ariaOrientation:null,ariaOwns:P,ariaPlaceholder:null,ariaPosInSet:m,ariaPressed:L,ariaReadOnly:L,ariaRelevant:null,ariaRequired:L,ariaRoleDescription:P,ariaRowCount:m,ariaRowIndex:m,ariaRowSpan:m,ariaSelected:L,ariaSetSize:m,ariaSort:null,ariaValueMax:m,ariaValueMin:m,ariaValueNow:m,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Mt(e,t){return t in e?e[t]:t}o(Mt,"caseSensitiveTransform");function zt(e,t){return Mt(e,t.toLowerCase())}o(zt,"caseInsensitiveTransform");var Ir=Q({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:X,acceptCharset:P,accessKey:P,action:null,allow:null,allowFullScreen:v,allowPaymentRequest:v,allowUserMedia:v,alpha:v,alt:null,as:null,async:v,autoCapitalize:null,autoComplete:P,autoFocus:v,autoPlay:v,blocking:P,capture:null,charSet:null,checked:v,cite:null,className:P,closedBy:null,colorSpace:null,cols:m,colSpan:m,command:null,commandFor:null,content:null,contentEditable:L,controls:v,controlsList:P,coords:m|X,crossOrigin:null,data:null,dateTime:null,decoding:null,default:v,defer:v,dir:null,dirName:null,disabled:v,download:Ne,draggable:L,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:v,formTarget:null,headers:P,height:m,hidden:Ne,high:m,href:null,hrefLang:null,htmlFor:P,httpEquiv:P,id:null,imageSizes:null,imageSrcSet:null,inert:v,inputMode:null,integrity:null,is:null,isMap:v,itemId:null,itemProp:P,itemRef:P,itemScope:v,itemType:P,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:v,low:m,manifest:null,max:null,maxLength:m,media:null,method:null,min:null,minLength:m,multiple:v,muted:v,name:null,nonce:null,noModule:v,noValidate:v,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:v,optimum:m,pattern:null,ping:P,placeholder:null,playsInline:v,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:v,referrerPolicy:null,rel:P,required:v,reversed:v,rows:m,rowSpan:m,sandbox:P,scope:null,scoped:v,seamless:v,selected:v,shadowRootClonable:v,shadowRootCustomElementRegistry:v,shadowRootDelegatesFocus:v,shadowRootMode:null,shadowRootSerializable:v,shape:null,size:m,sizes:null,slot:null,span:m,spellCheck:L,src:null,srcDoc:null,srcLang:null,srcSet:null,start:m,step:null,style:null,tabIndex:m,target:null,title:null,translate:null,type:null,typeMustMatch:v,useMap:null,value:L,width:m,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:P,axis:null,background:null,bgColor:null,border:m,borderColor:null,bottomMargin:m,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:v,declare:v,event:null,face:null,frame:null,frameBorder:null,hSpace:m,leftMargin:m,link:null,longDesc:null,lowSrc:null,marginHeight:m,marginWidth:m,noResize:v,noHref:v,noShade:v,noWrap:v,object:null,profile:null,prompt:null,rev:null,rightMargin:m,rules:null,scheme:null,scrolling:L,standby:null,summary:null,text:null,topMargin:m,valueType:null,version:null,vAlign:null,vLink:null,vSpace:m,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:v,disablePictureInPicture:v,disableRemotePlayback:v,exportParts:X,part:P,prefix:null,property:null,results:m,security:null,unselectable:null},space:"html",transform:zt}),Pr=Q({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:M,accentHeight:m,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:m,amplitude:m,arabicForm:null,ascent:m,attributeName:null,attributeType:null,azimuth:m,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:m,by:null,calcMode:null,capHeight:m,className:P,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:m,diffuseConstant:m,direction:null,display:null,dur:null,divisor:m,dominantBaseline:null,download:v,dx:null,dy:null,edgeMode:null,editable:null,elevation:m,enableBackground:null,end:null,event:null,exponent:m,externalResourcesRequired:null,fill:null,fillOpacity:m,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:X,g2:X,glyphName:X,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:m,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:m,horizOriginX:m,horizOriginY:m,id:null,ideographic:m,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:m,k:m,k1:m,k2:m,k3:m,k4:m,kernelMatrix:M,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:m,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:m,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:m,overlineThickness:m,paintOrder:null,panose1:null,path:null,pathLength:m,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:P,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:m,pointsAtY:m,pointsAtZ:m,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:M,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:M,rev:M,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:M,requiredFeatures:M,requiredFonts:M,requiredFormats:M,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:m,specularExponent:m,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:m,strikethroughThickness:m,string:null,stroke:null,strokeDashArray:M,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:m,strokeOpacity:m,strokeWidth:null,style:null,surfaceScale:m,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:M,tabIndex:m,tableValues:null,target:null,targetX:m,targetY:m,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:M,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:m,underlineThickness:m,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:m,values:null,vAlphabetic:m,vMathematical:m,vectorEffect:null,vHanging:m,vIdeographic:m,version:null,vertAdvY:m,vertOriginX:m,vertOriginY:m,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:m,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Mt}),$t=Q({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),Ut=Q({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:zt}),Ht=Q({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Lr={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Rr=/[A-Z]/g,it=/-[a-z]/g,jr=/^data[-\w.:]+$/i;function Tr(e,t){const n=je(t);let r=t,l=N;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&jr.test(t)){if(t.charAt(4)==="-"){const u=t.slice(5).replace(it,_r);r="data"+u.charAt(0).toUpperCase()+u.slice(1)}else{const u=t.slice(4);if(!it.test(u)){let i=u.replace(Rr,Nr);i.charAt(0)!=="-"&&(i="-"+i),t="data"+i}}l=Ke}return new l(r,t)}o(Tr,"find");function Nr(e){return"-"+e.toLowerCase()}o(Nr,"kebab");function _r(e){return e.charAt(1).toUpperCase()}o(_r,"camelcase");var Or=_t([Ot,Ir,$t,Ut,Ht],"html"),qe=_t([Ot,Pr,$t,Ut,Ht],"svg");function Mr(e){return e.join(" ").trim()}o(Mr,"stringify");var zr=ie(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,l=/^\s*/,u=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,a=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,p=/^\s+|\s+$/g,f=`
2
+ var xn=Object.defineProperty;var o=(e,t)=>xn(e,"name",{value:t,configurable:!0});import{i as ye,n as Sn,t as ie}from"./rolldown-runtime-ZpX3ckPj.js";import{Fr as Bn,Lr as In,Pr as Pn,S as H,W as Ln,Xn as fe,Y as St,nr as Rn,t as Bt}from"./createLucideIcon-r3v6fbGz.js";import{t as jn}from"./preload-helper-CceJXRIF.js";import{B as Tn,a as Nn,c as _n,it as It,o as On,s as Mn,t as Ue}from"./router-Bb8nJWyv.js";import{C as zn,D as Pt,F as Re,H as re,I as tt,J as He,K as $,L as $n,P as T,R as Un,S as Hn,U as le,W as Wn,Y as Z,_ as Vn,c as Kn,d as qn,f as Xn,g as ue,h as Yn,i as Lt,j as We,k as nt,l as Gn,m as Zn,p as Jn,r as Qn,u as er,x as Ve,z as tr}from"./mention-chips-DXumPrOR.js";import{c as nr,d as rr,h as rt,i as Rt,l as lr,m as or,n as ir,t as ur,u as jt,y as ar}from"./StatusIcon-BuUYMqqU.js";import{t as sr}from"./check-DDiXDm2i.js";import{p as cr}from"./button-CAPbz11u.js";import{i as pr,r as fr,t as hr}from"./clipboard-CYJ5Q78m.js";import{t as dr}from"./external-link-0lrOvZWO.js";var mr=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],Dr=Bt("file-code-corner",mr),gr=[["path",{d:"m16 16-3 3 3 3",key:"117b85"}],["path",{d:"M3 12h14.5a1 1 0 0 1 0 7H13",key:"18xa6z"}],["path",{d:"M3 19h6",key:"1ygdsz"}],["path",{d:"M3 5h18",key:"1u36vt"}]],Fr=Bt("text-wrap",gr);function J(e){const t=[];let n=-1,r=0,l=0;for(;++n<e.length;){const u=e.charCodeAt(n);let i="";if(u===37&&le(e.charCodeAt(n+1))&&le(e.charCodeAt(n+2)))l=2;else if(u<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(u))||(i=String.fromCharCode(u));else if(u>55295&&u<57344){const a=e.charCodeAt(n+1);u<56320&&a>56319&&a<57344?(i=String.fromCharCode(u,a),l=1):i="�"}else i=String.fromCharCode(u);i&&(t.push(e.slice(r,n),encodeURIComponent(i)),r=n+l+1,i=""),l&&(n+=l,l=0)}return t.join("")+e.slice(r)}o(J,"normalizeUri");var w=ye(In(),1),g=ye(Bn(),1);function yr(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}o(yr,"escapeStringRegexp");var Tt="paperclip.theme",wr="#18181b",Cr="#ffffff",Nt=(0,w.createContext)(void 0);function kr(){return typeof document>"u"||document.documentElement.classList.contains("dark")?"dark":"light"}o(kr,"resolveThemeFromDocument");function Er(){if(typeof window>"u")return!1;try{const e=window.localStorage.getItem(Tt);return e==="light"||e==="dark"}catch{return!1}}o(Er,"hasStoredTheme");function Ar(e){if(typeof document>"u")return;const t=e==="dark",n=document.documentElement;n.classList.toggle("dark",t),n.style.colorScheme=t?"dark":"light";const r=document.querySelector('meta[name="theme-color"]');r instanceof HTMLMetaElement&&r.setAttribute("content",t?wr:Cr)}o(Ar,"applyTheme");function oa({children:e}){const[t,n]=(0,w.useState)(()=>kr()),[r,l]=(0,w.useState)(()=>Er()),u=(0,w.useCallback)(c=>{l(!0),n(c)},[]),i=(0,w.useCallback)(()=>{l(!0),n(c=>c==="dark"?"light":"dark")},[]);(0,w.useEffect)(()=>{if(Ar(t),!!r)try{localStorage.setItem(Tt,t)}catch{}},[t,r]),(0,w.useEffect)(()=>{if(r||typeof window>"u"||typeof window.matchMedia!="function")return;const c=window.matchMedia("(prefers-color-scheme: dark)"),p=o(f=>{n(f.matches?"dark":"light")},"handleChange");return c.addEventListener("change",p),()=>c.removeEventListener("change",p)},[r]);const a=(0,w.useMemo)(()=>({theme:t,setTheme:u,toggleTheme:i}),[t,u,i]);return(0,g.jsx)(Nt.Provider,{value:a,children:e})}o(oa,"ThemeProvider");function vr(){const e=(0,w.useContext)(Nt);if(!e)throw new Error("useTheme must be used within ThemeProvider");return e}o(vr,"useTheme");function br(e,t){const n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}o(br,"stringify$1");var xr=/[ \t\n\f\r]/g;function Sr(e){return typeof e=="object"?e.type==="text"?lt(e.value):!1:lt(e)}o(Sr,"whitespace");function lt(e){return e.replace(xr,"")===""}o(lt,"empty");var ae=class{static{o(this,"Schema")}constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};ae.prototype.normal={};ae.prototype.property={};ae.prototype.space=void 0;function _t(e,t){const n={},r={};for(const l of e)Object.assign(n,l.property),Object.assign(r,l.normal);return new ae(n,r,t)}o(_t,"merge");function je(e){return e.toLowerCase()}o(je,"normalize$1");var N=class{static{o(this,"Info")}constructor(e,t){this.attribute=t,this.property=e}};N.prototype.attribute="";N.prototype.booleanish=!1;N.prototype.boolean=!1;N.prototype.commaOrSpaceSeparated=!1;N.prototype.commaSeparated=!1;N.prototype.defined=!1;N.prototype.mustUseProperty=!1;N.prototype.number=!1;N.prototype.overloadedBoolean=!1;N.prototype.property="";N.prototype.spaceSeparated=!1;N.prototype.space=void 0;var Te=Sn({boolean:o(()=>v,"boolean"),booleanish:o(()=>L,"booleanish"),commaOrSpaceSeparated:o(()=>M,"commaOrSpaceSeparated"),commaSeparated:o(()=>X,"commaSeparated"),number:o(()=>m,"number"),overloadedBoolean:o(()=>Ne,"overloadedBoolean"),spaceSeparated:o(()=>P,"spaceSeparated")}),Br=0,v=Y(),L=Y(),Ne=Y(),m=Y(),P=Y(),X=Y(),M=Y();function Y(){return 2**++Br}o(Y,"increment");var we=Object.keys(Te),Ke=class extends N{static{o(this,"DefinedInfo")}constructor(e,t,n,r){let l=-1;if(super(e,t),ot(this,"space",r),typeof n=="number")for(;++l<we.length;){const u=we[l];ot(this,we[l],(n&Te[u])===Te[u])}}};Ke.prototype.defined=!0;function ot(e,t,n){n&&(e[t]=n)}o(ot,"mark");function Q(e){const t={},n={};for(const[r,l]of Object.entries(e.properties)){const u=new Ke(r,e.transform(e.attributes||{},r),l,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(u.mustUseProperty=!0),t[r]=u,n[je(r)]=r,n[je(u.attribute)]=r}return new ae(t,n,e.space)}o(Q,"create");var Ot=Q({properties:{ariaActiveDescendant:null,ariaAtomic:L,ariaAutoComplete:null,ariaBusy:L,ariaChecked:L,ariaColCount:m,ariaColIndex:m,ariaColSpan:m,ariaControls:P,ariaCurrent:null,ariaDescribedBy:P,ariaDetails:null,ariaDisabled:L,ariaDropEffect:P,ariaErrorMessage:null,ariaExpanded:L,ariaFlowTo:P,ariaGrabbed:L,ariaHasPopup:null,ariaHidden:L,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:P,ariaLevel:m,ariaLive:null,ariaModal:L,ariaMultiLine:L,ariaMultiSelectable:L,ariaOrientation:null,ariaOwns:P,ariaPlaceholder:null,ariaPosInSet:m,ariaPressed:L,ariaReadOnly:L,ariaRelevant:null,ariaRequired:L,ariaRoleDescription:P,ariaRowCount:m,ariaRowIndex:m,ariaRowSpan:m,ariaSelected:L,ariaSetSize:m,ariaSort:null,ariaValueMax:m,ariaValueMin:m,ariaValueNow:m,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Mt(e,t){return t in e?e[t]:t}o(Mt,"caseSensitiveTransform");function zt(e,t){return Mt(e,t.toLowerCase())}o(zt,"caseInsensitiveTransform");var Ir=Q({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:X,acceptCharset:P,accessKey:P,action:null,allow:null,allowFullScreen:v,allowPaymentRequest:v,allowUserMedia:v,alpha:v,alt:null,as:null,async:v,autoCapitalize:null,autoComplete:P,autoFocus:v,autoPlay:v,blocking:P,capture:null,charSet:null,checked:v,cite:null,className:P,closedBy:null,colorSpace:null,cols:m,colSpan:m,command:null,commandFor:null,content:null,contentEditable:L,controls:v,controlsList:P,coords:m|X,crossOrigin:null,data:null,dateTime:null,decoding:null,default:v,defer:v,dir:null,dirName:null,disabled:v,download:Ne,draggable:L,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:v,formTarget:null,headers:P,height:m,hidden:Ne,high:m,href:null,hrefLang:null,htmlFor:P,httpEquiv:P,id:null,imageSizes:null,imageSrcSet:null,inert:v,inputMode:null,integrity:null,is:null,isMap:v,itemId:null,itemProp:P,itemRef:P,itemScope:v,itemType:P,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:v,low:m,manifest:null,max:null,maxLength:m,media:null,method:null,min:null,minLength:m,multiple:v,muted:v,name:null,nonce:null,noModule:v,noValidate:v,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:v,optimum:m,pattern:null,ping:P,placeholder:null,playsInline:v,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:v,referrerPolicy:null,rel:P,required:v,reversed:v,rows:m,rowSpan:m,sandbox:P,scope:null,scoped:v,seamless:v,selected:v,shadowRootClonable:v,shadowRootCustomElementRegistry:v,shadowRootDelegatesFocus:v,shadowRootMode:null,shadowRootSerializable:v,shape:null,size:m,sizes:null,slot:null,span:m,spellCheck:L,src:null,srcDoc:null,srcLang:null,srcSet:null,start:m,step:null,style:null,tabIndex:m,target:null,title:null,translate:null,type:null,typeMustMatch:v,useMap:null,value:L,width:m,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:P,axis:null,background:null,bgColor:null,border:m,borderColor:null,bottomMargin:m,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:v,declare:v,event:null,face:null,frame:null,frameBorder:null,hSpace:m,leftMargin:m,link:null,longDesc:null,lowSrc:null,marginHeight:m,marginWidth:m,noResize:v,noHref:v,noShade:v,noWrap:v,object:null,profile:null,prompt:null,rev:null,rightMargin:m,rules:null,scheme:null,scrolling:L,standby:null,summary:null,text:null,topMargin:m,valueType:null,version:null,vAlign:null,vLink:null,vSpace:m,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:v,disablePictureInPicture:v,disableRemotePlayback:v,exportParts:X,part:P,prefix:null,property:null,results:m,security:null,unselectable:null},space:"html",transform:zt}),Pr=Q({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:M,accentHeight:m,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:m,amplitude:m,arabicForm:null,ascent:m,attributeName:null,attributeType:null,azimuth:m,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:m,by:null,calcMode:null,capHeight:m,className:P,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:m,diffuseConstant:m,direction:null,display:null,dur:null,divisor:m,dominantBaseline:null,download:v,dx:null,dy:null,edgeMode:null,editable:null,elevation:m,enableBackground:null,end:null,event:null,exponent:m,externalResourcesRequired:null,fill:null,fillOpacity:m,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:X,g2:X,glyphName:X,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:m,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:m,horizOriginX:m,horizOriginY:m,id:null,ideographic:m,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:m,k:m,k1:m,k2:m,k3:m,k4:m,kernelMatrix:M,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:m,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:m,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:m,overlineThickness:m,paintOrder:null,panose1:null,path:null,pathLength:m,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:P,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:m,pointsAtY:m,pointsAtZ:m,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:M,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:M,rev:M,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:M,requiredFeatures:M,requiredFonts:M,requiredFormats:M,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:m,specularExponent:m,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:m,strikethroughThickness:m,string:null,stroke:null,strokeDashArray:M,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:m,strokeOpacity:m,strokeWidth:null,style:null,surfaceScale:m,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:M,tabIndex:m,tableValues:null,target:null,targetX:m,targetY:m,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:M,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:m,underlineThickness:m,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:m,values:null,vAlphabetic:m,vMathematical:m,vectorEffect:null,vHanging:m,vIdeographic:m,version:null,vertAdvY:m,vertOriginX:m,vertOriginY:m,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:m,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Mt}),$t=Q({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),Ut=Q({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:zt}),Ht=Q({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Lr={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Rr=/[A-Z]/g,it=/-[a-z]/g,jr=/^data[-\w.:]+$/i;function Tr(e,t){const n=je(t);let r=t,l=N;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&jr.test(t)){if(t.charAt(4)==="-"){const u=t.slice(5).replace(it,_r);r="data"+u.charAt(0).toUpperCase()+u.slice(1)}else{const u=t.slice(4);if(!it.test(u)){let i=u.replace(Rr,Nr);i.charAt(0)!=="-"&&(i="-"+i),t="data"+i}}l=Ke}return new l(r,t)}o(Tr,"find");function Nr(e){return"-"+e.toLowerCase()}o(Nr,"kebab");function _r(e){return e.charAt(1).toUpperCase()}o(_r,"camelcase");var Or=_t([Ot,Ir,$t,Ut,Ht],"html"),qe=_t([Ot,Pr,$t,Ut,Ht],"svg");function Mr(e){return e.join(" ").trim()}o(Mr,"stringify");var zr=ie(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,l=/^\s*/,u=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,a=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,p=/^\s+|\s+$/g,f=`
3
3
  `,s="/",h="*",d="",D="comment",F="declaration";function C(k,E){if(typeof k!="string")throw new TypeError("First argument must be a string");if(!k)return[];E=E||{};var A=1,y=1;function B(I){var S=I.match(r);S&&(A+=S.length);var O=I.lastIndexOf(f);y=~O?I.length-O:y+I.length}o(B,"updatePosition");function x(){var I={line:A,column:y};return function(S){return S.position=new _(I),ee(),S}}o(x,"position");function _(I){this.start=I,this.end={line:A,column:y},this.source=E.source}o(_,"Position"),_.prototype.content=k;function j(I){var S=new Error(E.source+":"+A+":"+y+": "+I);if(S.reason=I,S.filename=E.source,S.line=A,S.column=y,S.source=k,!E.silent)throw S}o(j,"error");function V(I){var S=I.exec(k);if(S){var O=S[0];return B(O),k=k.slice(O.length),S}}o(V,"match");function ee(){V(l)}o(ee,"whitespace");function R(I){var S;for(I=I||[];S=te();)S!==!1&&I.push(S);return I}o(R,"comments");function te(){var I=x();if(!(s!=k.charAt(0)||h!=k.charAt(1))){for(var S=2;d!=k.charAt(S)&&(h!=k.charAt(S)||s!=k.charAt(S+1));)++S;if(S+=2,d===k.charAt(S-1))return j("End of comment missing");var O=k.slice(2,S-2);return y+=2,B(O),k=k.slice(S),y+=2,I({type:D,comment:O})}}o(te,"comment");function ce(){var I=x(),S=V(u);if(S){if(te(),!V(i))return j("property missing ':'");var O=V(a),bn=I({type:F,property:b(S[0].replace(n,d)),value:O?b(O[0].replace(n,d)):d});return V(c),bn}}o(ce,"declaration");function pe(){var I=[];R(I);for(var S;S=ce();)S!==!1&&(I.push(S),R(I));return I}return o(pe,"declarations"),ee(),pe()}o(C,"index");function b(k){return k?k.replace(p,d):d}o(b,"trim"),t.exports=C})),$r=ie((e=>{var t=e&&e.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var n=t(zr());function r(l,u){let i=null;if(!l||typeof l!="string")return i;const a=(0,n.default)(l),c=typeof u=="function";return a.forEach(p=>{if(p.type!=="declaration")return;const{property:f,value:s}=p;c?u(f,s,p):s&&(i=i||{},i[f]=s)}),i}o(r,"StyleToObject")})),Ur=ie((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,l=/^-(webkit|moz|ms|o|khtml)-/,u=/^-(ms)-/,i=o(function(f){return!f||r.test(f)||t.test(f)},"skipCamelCase"),a=o(function(f,s){return s.toUpperCase()},"capitalize"),c=o(function(f,s){return"".concat(s,"-")},"trimHyphen"),p=o(function(f,s){return s===void 0&&(s={}),i(f)?f:(f=f.toLowerCase(),s.reactCompat?f=f.replace(u,c):f=f.replace(l,c),f.replace(n,a))},"camelCase");e.camelCase=p})),Hr=ie(((e,t)=>{var n=(e&&e.__importDefault||function(u){return u&&u.__esModule?u:{default:u}})($r()),r=Ur();function l(u,i){var a={};return!u||typeof u!="string"||(0,n.default)(u,function(c,p){c&&p&&(a[(0,r.camelCase)(c,i)]=p)}),a}o(l,"StyleToJS"),l.default=l,t.exports=l})),Wt=Vt("end"),Xe=Vt("start");function Vt(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}o(Vt,"point");function Wr(e){const t=Xe(e),n=Wt(e);if(t&&n)return{start:t,end:n}}o(Wr,"position");var Vr=ye(Hr(),1),Ye={}.hasOwnProperty,Kr=new Map,qr=/[A-Z]/g,Xr=new Set(["table","tbody","thead","tfoot","tr"]),Yr=new Set(["td","th"]),Kt="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Gr(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=ll(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=rl(n,t.jsx,t.jsxs)}const l={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?qe:Or,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},u=qt(l,e,void 0);return u&&typeof u!="string"?u:l.create(e,l.Fragment,{children:u||void 0},void 0)}o(Gr,"toJsxRuntime");function qt(e,t,n){if(t.type==="element")return Zr(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return Jr(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return el(e,t,n);if(t.type==="mdxjsEsm")return Qr(e,t);if(t.type==="root")return tl(e,t,n);if(t.type==="text")return nl(e,t)}o(qt,"one$1");function Zr(e,t,n){const r=e.schema;let l=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(l=qe,e.schema=l),e.ancestors.push(t);const u=Yt(e,t.tagName,!1),i=ol(e,t);let a=Ze(e,t);return Xr.has(t.tagName)&&(a=a.filter(function(c){return typeof c=="string"?!Sr(c):!0})),Xt(e,i,u,t),Ge(i,a),e.ancestors.pop(),e.schema=r,e.create(t,u,i,n)}o(Zr,"element");function Jr(e,t){if(t.data&&t.data.estree&&e.evaluater){const n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}oe(e,t.position)}o(Jr,"mdxExpression");function Qr(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);oe(e,t.position)}o(Qr,"mdxEsm");function el(e,t,n){const r=e.schema;let l=r;t.name==="svg"&&r.space==="html"&&(l=qe,e.schema=l),e.ancestors.push(t);const u=t.name===null?e.Fragment:Yt(e,t.name,!0),i=il(e,t),a=Ze(e,t);return Xt(e,i,u,t),Ge(i,a),e.ancestors.pop(),e.schema=r,e.create(t,u,i,n)}o(el,"mdxJsxElement");function tl(e,t,n){const r={};return Ge(r,Ze(e,t)),e.create(t,e.Fragment,r,n)}o(tl,"root$1");function nl(e,t){return t.value}o(nl,"text$2");function Xt(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}o(Xt,"addNode");function Ge(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}o(Ge,"addChildren");function rl(e,t,n){return r;function r(l,u,i,a){const c=Array.isArray(i.children)?n:t;return a?c(u,i,a):c(u,i)}}o(rl,"productionCreate");function ll(e,t){return n;function n(r,l,u,i){const a=Array.isArray(u.children),c=Xe(r);return t(l,u,i,a,{columnNumber:c?c.column-1:void 0,fileName:e,lineNumber:c?c.line:void 0},void 0)}}o(ll,"developmentCreate");function ol(e,t){const n={};let r,l;for(l in t.properties)if(l!=="children"&&Ye.call(t.properties,l)){const u=ul(e,l,t.properties[l]);if(u){const[i,a]=u;e.tableCellAlignToStyle&&i==="align"&&typeof a=="string"&&Yr.has(t.tagName)?r=a:n[i]=a}}if(r){const u=n.style||(n.style={});u[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}o(ol,"createElementProps");function il(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const l=r.data.estree.body[0];l.type;const u=l.expression;u.type;const i=u.properties[0];i.type,Object.assign(n,e.evaluater.evaluateExpression(i.argument))}else oe(e,t.position);else{const l=r.name;let u;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const i=r.value.data.estree.body[0];i.type,u=e.evaluater.evaluateExpression(i.expression)}else oe(e,t.position);else u=r.value===null?!0:r.value;n[l]=u}return n}o(il,"createJsxElementProps");function Ze(e,t){const n=[];let r=-1;const l=e.passKeys?new Map:Kr;for(;++r<t.children.length;){const u=t.children[r];let i;if(e.passKeys){const c=u.type==="element"?u.tagName:u.type==="mdxJsxFlowElement"||u.type==="mdxJsxTextElement"?u.name:void 0;if(c){const p=l.get(c)||0;i=c+"-"+p,l.set(c,p+1)}}const a=qt(e,u,i);a!==void 0&&n.push(a)}return n}o(Ze,"createChildren");function ul(e,t,n){const r=Tr(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?br(n):Mr(n)),r.property==="style"){let l=typeof n=="object"?n:al(e,String(n));return e.stylePropertyNameCase==="css"&&(l=sl(l)),["style",l]}return[e.elementAttributeNameCase==="react"&&r.space?Lr[r.property]||r.property:r.attribute,n]}}o(ul,"createProperty");function al(e,t){try{return(0,Vr.default)(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,l=new We("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw l.file=e.filePath||void 0,l.url=Kt+"#cannot-parse-style-attribute",l}}o(al,"parseStyle");function Yt(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const l=t.split(".");let u=-1,i;for(;++u<l.length;){const a=nt(l[u])?{type:"Identifier",name:l[u]}:{type:"Literal",value:l[u]};i=i?{type:"MemberExpression",object:i,property:a,computed:!!(u&&a.type==="Literal"),optional:!1}:a}r=i}else r=nt(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const l=r.value;return Ye.call(e.components,l)?e.components[l]:l}if(e.evaluater)return e.evaluater.evaluateExpression(r);oe(e)}o(Yt,"findComponentFromName");function oe(e,t){const n=new We("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=Kt+"#cannot-handle-mdx-estrees-without-createevaluater",n}o(oe,"crashEstree");function sl(e){const t={};let n;for(n in e)Ye.call(e,n)&&(t[cl(n)]=e[n]);return t}o(sl,"transformStylesToCssCasing");function cl(e){let t=e.replace(qr,pl);return t.slice(0,3)==="ms-"&&(t="-"+t),t}o(cl,"transformStyleToCssCasing");function pl(e){return"-"+e.toLowerCase()}o(pl,"toDash");var Ce={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]};function fl(e){const t=this;t.parser=n;function n(r){return Zn(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}o(n,"parser")}o(fl,"remarkParse");function hl(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}o(hl,"blockquote");function dl(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
4
4
  `}]}o(dl,"hardBreak");function ml(e,t){const n=t.value?t.value+`
5
5
  `:"",r={},l=t.lang?t.lang.split(/\s+/):[];l.length>0&&(r.className=["language-"+l[0]]);let u={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(u.data={meta:t.meta}),e.patch(t,u),u=e.applyData(t,u),u={type:"element",tagName:"pre",properties:{},children:[u]},e.patch(t,u),u}o(ml,"code$1");function Dl(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}o(Dl,"strikethrough");function gl(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}o(gl,"emphasis");function Fl(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),l=J(r.toLowerCase()),u=e.footnoteOrder.indexOf(r);let i,a=e.footnoteCounts.get(r);a===void 0?(a=0,e.footnoteOrder.push(r),i=e.footnoteOrder.length):i=u+1,a+=1,e.footnoteCounts.set(r,a);const c={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+l,id:n+"fnref-"+l+(a>1?"-"+a:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(i)}]};e.patch(t,c);const p={type:"element",tagName:"sup",properties:{},children:[c]};return e.patch(t,p),e.applyData(t,p)}o(Fl,"footnoteReference$1");function yl(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}o(yl,"heading");function wl(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}o(wl,"html");function Gt(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const l=e.all(t),u=l[0];u&&u.type==="text"?u.value="["+u.value:l.unshift({type:"text",value:"["});const i=l[l.length-1];return i&&i.type==="text"?i.value+=r:l.push({type:"text",value:r}),l}o(Gt,"revert");function Cl(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Gt(e,t);const l={src:J(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(l.title=r.title);const u={type:"element",tagName:"img",properties:l,children:[]};return e.patch(t,u),e.applyData(t,u)}o(Cl,"imageReference");function kl(e,t){const n={src:J(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}o(kl,"image");function El(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}o(El,"inlineCode");function Al(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Gt(e,t);const l={href:J(r.url||"")};r.title!==null&&r.title!==void 0&&(l.title=r.title);const u={type:"element",tagName:"a",properties:l,children:e.all(t)};return e.patch(t,u),e.applyData(t,u)}o(Al,"linkReference");function vl(e,t){const n={href:J(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}o(vl,"link");function bl(e,t,n){const r=e.all(t),l=n?xl(n):Zt(t),u={},i=[];if(typeof t.checked=="boolean"){const f=r[0];let s;f&&f.type==="element"&&f.tagName==="p"?s=f:(s={type:"element",tagName:"p",properties:{},children:[]},r.unshift(s)),s.children.length>0&&s.children.unshift({type:"text",value:" "}),s.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),u.className=["task-list-item"]}let a=-1;for(;++a<r.length;){const f=r[a];(l||a!==0||f.type!=="element"||f.tagName!=="p")&&i.push({type:"text",value:`
@@ -77,7 +77,7 @@ var Uk=Object.defineProperty;var s=(e,t)=>Uk(e,"name",{value:t,configurable:!0})
77
77
  `),t)),i=[])},"flushChunk");let l="",a=0,c=0,d=3,u=!1;for(const f of n){if(l){o(),r.push(f);const p=BU(f,c),v=p?RU.exec(p):null;if(v){const _=v[1].length,y=v[2];_<=d&&y[0]===l&&y.length>=a&&(l="",a=0,c=0,d=3)}continue}const h=NU.exec(f);if(h){const p=h[1],v=h[2],_=v[0],y=h[3];if(!(_==="`"&&y.includes("`"))){const x=p.match(OU)??[];o(),r.push(f),l=_,a=v.length,c=(p.match(DU)??[]).length,d=(x.length>0?x.reduce((C,b)=>C+b.length,0):0)+3,u=!1;continue}}const g=f.replace(LU,"");if(g.trim().length===0){o(),r.push(f),u=!1;continue}if(!u&&$U.test(g)){o(),r.push(f);continue}u=!0,i.push(f)}return o(),r.join(`
78
78
  `)}s(wk,"transformAngleBrackets");function ip(e){return e.includes("<")?wk(e,"escape"):e}s(ip,"escapeUnsupportedAngleBrackets");function UU(e){return e.includes("\\<")?wk(e,"unescape"):e}s(UU,"unescapeAngleBracketEscapes");var WU=/^( {0,3}(?:(?:> ?|(?:[-+*]|\d{1,9}[.)]) +))*)(`{3,}|~{3,})(.*)$/,zU=/(?:[-+*]|\d{1,9}[.)]) +/g,jU=/>/g,JU=/^( *)(`{3,}|~{3,})[ \t]*$/,Dx=/^( {0,3})\\>/;function GU(e,t){let n=e;for(let r=0;r<t;r+=1){const i=/^ {0,3}> ?/.exec(n);if(!i)return null;n=n.slice(i[0].length)}return n}s(GU,"stripBlockquotePrefix");function kk(e){if(!e.includes("\\>"))return e;const t=e.split(`
79
79
  `);let n="",r=0,i=0,o=3;for(let l=0;l<t.length;l+=1){const a=t[l];if(n){const d=GU(a,i),u=d?JU.exec(d):null;if(u){const f=u[1].length,h=u[2];f<=o&&h[0]===n&&h.length>=r&&(n="",r=0,i=0,o=3)}continue}const c=WU.exec(a);if(c){const d=c[1],u=c[2],f=u[0],h=c[3];if(!(f==="`"&&h.includes("`"))){const g=d.match(zU)??[];n=f,r=u.length,i=(d.match(jU)??[]).length,o=(g.length>0?g.reduce((p,v)=>p+v.length,0):0)+3;continue}}Dx.test(a)&&(t[l]=a.replace(Dx,"$1>"))}return t.join(`
80
- `)}s(kk,"unescapeBlockquoteMarkers");var qU=Tn({init(e){e.pub(jd,[t=>{let n=!1;return t.registerCommand(ea,r=>{if(n)return n=!1,!1;const i=r instanceof ClipboardEvent?r.clipboardData:null;if(!i)return!1;const o=i.getData("text/plain");if(!o||i.getData("text/html")||Sk(o))return!1;const l=Tk(o);if(l===o)return!1;r instanceof ClipboardEvent&&r.preventDefault();const a=new DataTransfer;a.setData("text/plain",l);const c=new ClipboardEvent("paste",{clipboardData:a,bubbles:!0,cancelable:!0});return n=!0,t.dispatchCommand(ea,c),!0},Vr)}])}}),ZU={list:s((e,t={})=>{const n=new URLSearchParams;t.q&&n.set("q",t.q),t.sort&&n.set("sort",t.sort),t.scope&&n.set("scope",t.scope);for(const i of t.categories??[])n.append("categories[]",i);for(const i of t.include??[])n.append("include[]",i);const r=n.toString();return Ce.get(`/companies/${encodeURIComponent(e)}/skills${r?`?${r}`:""}`)},"list"),categories:s(e=>Ce.get(`/companies/${encodeURIComponent(e)}/skills/categories`),"categories"),detail:s((e,t)=>Ce.get(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}`),"detail"),versions:s((e,t)=>Ce.get(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/versions`),"versions"),version:s((e,t,n)=>Ce.get(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/versions/${encodeURIComponent(n)}`),"version"),createVersion:s((e,t,n={})=>Ce.post(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/versions`,n),"createVersion"),testInputs:s((e,t)=>Ce.get(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/test-inputs`),"testInputs"),createTestInput:s((e,t,n)=>Ce.post(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/test-inputs`,n),"createTestInput"),updateTestInput:s((e,t,n,r)=>Ce.patch(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/test-inputs/${encodeURIComponent(n)}`,r),"updateTestInput"),deleteTestInput:s((e,t,n)=>Ce.delete(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/test-inputs/${encodeURIComponent(n)}`),"deleteTestInput"),testRunTemplates:s(e=>Ce.get(`/companies/${encodeURIComponent(e)}/skill-test-run-templates`),"testRunTemplates"),createTestRunTemplate:s((e,t)=>Ce.post(`/companies/${encodeURIComponent(e)}/skill-test-run-templates`,t),"createTestRunTemplate"),updateTestRunTemplate:s((e,t,n)=>Ce.patch(`/companies/${encodeURIComponent(e)}/skill-test-run-templates/${encodeURIComponent(t)}`,n),"updateTestRunTemplate"),deleteTestRunTemplate:s((e,t)=>Ce.delete(`/companies/${encodeURIComponent(e)}/skill-test-run-templates/${encodeURIComponent(t)}`),"deleteTestRunTemplate"),testRuns:s((e,t,n={})=>{const r=new URLSearchParams;n.inputId&&r.set("inputId",n.inputId);const i=r.toString();return Ce.get(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/test-runs${i?`?${i}`:""}`)},"testRuns"),testRunDetail:s((e,t,n)=>Ce.get(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/test-runs/${encodeURIComponent(n)}`),"testRunDetail"),createTestRun:s((e,t,n)=>Ce.post(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/test-runs`,n),"createTestRun"),cancelTestRun:s((e,t,n)=>Ce.post(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/test-runs/${encodeURIComponent(n)}/cancel`,{}),"cancelTestRun"),deleteTestRun:s((e,t,n)=>Ce.delete(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/test-runs/${encodeURIComponent(n)}`),"deleteTestRun"),star:s((e,t)=>Ce.post(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/star`,{}),"star"),unstar:s((e,t)=>Ce.delete(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/star`),"unstar"),fork:s((e,t,n={})=>Ce.post(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/fork`,n),"fork"),forkPrecheck:s((e,t)=>Ce.get(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/fork-precheck`),"forkPrecheck"),comments:s((e,t)=>Ce.get(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/comments`),"comments"),createComment:s((e,t,n)=>Ce.post(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/comments`,n),"createComment"),updateComment:s((e,t,n,r)=>Ce.patch(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/comments/${encodeURIComponent(n)}`,r),"updateComment"),deleteComment:s((e,t,n)=>Ce.delete(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/comments/${encodeURIComponent(n)}`),"deleteComment"),updateStatus:s((e,t)=>Ce.get(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/update-status`),"updateStatus"),file:s((e,t,n)=>Ce.get(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/files?path=${encodeURIComponent(n)}`),"file"),updateFile:s((e,t,n,r)=>Ce.patch(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/files`,{path:n,content:r}),"updateFile"),deleteFile:s((e,t,n)=>Ce.deleteWithBody(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/files`,n),"deleteFile"),create:s((e,t)=>Ce.post(`/companies/${encodeURIComponent(e)}/skills`,t),"create"),update:s((e,t,n)=>Ce.patch(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}`,n),"update"),importFromSource:s((e,t)=>Ce.post(`/companies/${encodeURIComponent(e)}/skills/import`,{source:t}),"importFromSource"),browseProject:s((e,t)=>Ce.post(`/companies/${encodeURIComponent(e)}/skills/browse-project`,t),"browseProject"),scanProjects:s((e,t={})=>Ce.post(`/companies/${encodeURIComponent(e)}/skills/scan-projects`,t),"scanProjects"),installUpdate:s((e,t)=>Ce.post(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/install-update`,{}),"installUpdate"),delete:s((e,t)=>Ce.delete(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}`),"delete"),catalogList:s((e={})=>{const t=new URLSearchParams;e.kind&&t.set("kind",e.kind),e.category&&t.set("category",e.category),e.q&&t.set("q",e.q);const n=t.toString();return Ce.get(`/skills/catalog${n?`?${n}`:""}`)},"catalogList"),catalogDetail:s(e=>Ce.get(`/skills/catalog/${encodeURIComponent(e)}`),"catalogDetail"),catalogFile:s((e,t="SKILL.md")=>Ce.get(`/skills/catalog/${encodeURIComponent(e)}/files?path=${encodeURIComponent(t)}`),"catalogFile"),installCatalog:s((e,t)=>Ce.post(`/companies/${encodeURIComponent(e)}/skills/install-catalog`,t),"installCatalog")},YU=["/steer","/queue"];function XU(e){return YU.includes(e)}s(XU,"isDeliveryCommand");var QU=["goal","steer","queue"];function Rx(e){return QU.includes(e)}s(Rx,"isAbsorbableCommand");function Lx(e,t){return e===""||e===t?!0:t==="goal"&&e==="go"}s(Lx,"labelMatchesCommand");function eW(e){const t=e.trim(),n=t.match(/^\[\/([A-Za-z]*)[ \t\u00a0]*\]\(<(\/[A-Za-z]+(?:[ \t\u00a0].*)?)>\)$/s);if(n){const i=n[1],o=n[2].replaceAll(" "," "),l=o.slice(1).split(/[ \t]/)[0]??"";return Rx(l)&&Lx(i,l)?o:t.replaceAll(" "," ")}const r=t.match(/^\[\/([A-Za-z]*)[ \t\u00a0]*\]\((\/[A-Za-z]+(?:%20|%C2%A0).*)\)$/s);if(r){const i=r[1],o=r[2],l=decodeURIComponent(o.slice(1).split(/(?:%20|%C2%A0)/)[0]??"");if(Rx(l)&&Lx(i,l))try{return decodeURIComponent(o).replaceAll(" "," ")}catch{return t}}return t.replaceAll(" "," ")}s(eW,"normalizeComposerCommandText");function eJ(e){const t=eW(e);if(!t)return{matched:!1};const n=t.search(/\s/),r=n===-1?t:t.slice(0,n);if(!XU(r))return{matched:!1};const i=n===-1?"":t.slice(n).trim();return i?{matched:!0,command:{mode:r.slice(1),prompt:i}}:{matched:!0,error:`${r} needs a message. Type ${r} followed by what you want to send.`}}s(eJ,"parseMessageDeliveryCommand");var tW=[{id:"action:steer",kind:"action",command:"steer",name:"Steer",description:"Send into the agent's running turn now.",aliases:["steer","steering","steered","now"]},{id:"action:queue",kind:"action",command:"queue",name:"Queue",description:"Queue for the next turn boundary.",aliases:["queue","queued","later","next"]}],nW={not_requested:"",board_only:"steering is only available to board users.",no_active_run:"there was no active run to steer.",legacy_protocol:"this runner's session protocol cannot accept a mid-turn steer.",conversation_issue:"conversation messages are delivered in order at turn boundaries.",steering_failed:"the steer did not land, so the message is queued and will be read at the next turn."},rW="this task could not be steered mid-turn.";function tJ(e){if(!e||e.deliveredAs==="steered")return null;const t=e.steeringUnavailable??null;return!t||t==="not_requested"?null:`Queued instead of steering the running turn — ${nW[t]??rW}`}s(tJ,"describeDeliveryDowngrade");function nJ(e){return e?.comment??void 0}s(nJ,"deliveryDispositionFromIssueUpdate");var Mk=(0,m.createContext)({slashCommands:[]});function rJ({children:e}){const{selectedCompanyId:t}=Jk(),{data:n=[]}=p0({queryKey:t?g0.companySkills.list(t):["company-skills","__none__"],queryFn:s(()=>ZU.list(t),"queryFn"),enabled:!!t}),{data:r=[]}=p0({queryKey:t?g0.routines.list(t):["routines","__none__","__all-projects__"],queryFn:s(()=>S8.list(t),"queryFn"),enabled:!!t}),i=(0,m.useMemo)(()=>({slashCommands:[...tW,...n.map(o=>({id:`skill:${o.id}`,kind:"skill",skillId:o.id,key:o.key,name:o.name,slug:o.slug,description:o.description??null,href:u9(o.id,o.slug),aliases:[o.slug,o.name,o.key]})),...r.filter(o=>o.status!=="archived").sort((o,l)=>o.title.localeCompare(l.title)).map(o=>({id:`routine:${o.id}`,kind:"routine",routineId:o.id,name:o.title,status:o.status,href:Kx(o.id),aliases:[`routine:${o.title}`,o.title,o.id]}))]}),[n,r]);return(0,H.jsx)(Mk.Provider,{value:i,children:e})}s(rJ,"EditorAutocompleteProvider");function iW(){return(0,m.useContext)(Mk)}s(iW,"useEditorAutocomplete");var iJ=Hx({MarkdownEditor:s(()=>AW,"MarkdownEditor"),computeMentionMenuPosition:s(()=>Dk,"computeMentionMenuPosition"),findClosestAutocompleteAnchor:s(()=>Fk,"findClosestAutocompleteAnchor"),findMentionMatch:s(()=>Ok,"findMentionMatch"),isSameAutocompleteSession:s(()=>Pk,"isSameAutocompleteSession"),issueMentionTitle:s(()=>Rk,"issueMentionTitle"),placeCaretAfterMentionAnchor:s(()=>Vk,"placeCaretAfterMentionAnchor"),placeCaretAtEditableEnd:s(()=>Bk,"placeCaretAtEditableEnd"),shouldAcceptAutocompleteKey:s(()=>$k,"shouldAcceptAutocompleteKey")}),oW=class extends m.Component{static{s(this,"MarkdownEditorRichErrorBoundary")}state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,t){this.props.onError(e)}render(){return this.state.hasError?null:this.props.children}};function oh(e,t){const n=new RegExp(`${t}\\s*=\\s*("([^"]*)"|'([^']*)'|([^\\s>]+))`,"i").exec(e);return n?.[2]??n?.[3]??n?.[4]??null}s(oh,"readHtmlAttribute");function sW(e){return e==="delete_small"?(0,H.jsx)(Qk,{"aria-hidden":!0}):rT[e]}s(sW,"editorIconFor");function lW(e){return e.replace(/<img\b([^>]*?)\/?>/gi,(t,n)=>{const r=oh(n,"src");if(!r)return t;const i=oh(n,"alt")??"image",o=oh(n,"title"),l=i.replace(/[[\]]/g,"\\$&"),a=o?.replace(/"/g,'\\"');return a?`![${l}](${r} "${a}")`:`![${l}](${r})`})}s(lW,"convertHtmlImagesToMarkdown");function $x(e){const t=e.replace(/\r\n/g,`
80
+ `)}s(kk,"unescapeBlockquoteMarkers");var qU=Tn({init(e){e.pub(jd,[t=>{let n=!1;return t.registerCommand(ea,r=>{if(n)return n=!1,!1;const i=r instanceof ClipboardEvent?r.clipboardData:null;if(!i)return!1;const o=i.getData("text/plain");if(!o||i.getData("text/html")||Sk(o))return!1;const l=Tk(o);if(l===o)return!1;r instanceof ClipboardEvent&&r.preventDefault();const a=new DataTransfer;a.setData("text/plain",l);const c=new ClipboardEvent("paste",{clipboardData:a,bubbles:!0,cancelable:!0});return n=!0,t.dispatchCommand(ea,c),!0},Vr)}])}}),ZU={list:s((e,t={})=>{const n=new URLSearchParams;t.q&&n.set("q",t.q),t.sort&&n.set("sort",t.sort),t.scope&&n.set("scope",t.scope);for(const i of t.categories??[])n.append("categories[]",i);for(const i of t.include??[])n.append("include[]",i);const r=n.toString();return Ce.get(`/companies/${encodeURIComponent(e)}/skills${r?`?${r}`:""}`)},"list"),categories:s(e=>Ce.get(`/companies/${encodeURIComponent(e)}/skills/categories`),"categories"),detail:s((e,t)=>Ce.get(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}`),"detail"),versions:s((e,t)=>Ce.get(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/versions`),"versions"),version:s((e,t,n)=>Ce.get(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/versions/${encodeURIComponent(n)}`),"version"),createVersion:s((e,t,n={})=>Ce.post(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/versions`,n),"createVersion"),testInputs:s((e,t)=>Ce.get(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/test-inputs`),"testInputs"),createTestInput:s((e,t,n)=>Ce.post(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/test-inputs`,n),"createTestInput"),updateTestInput:s((e,t,n,r)=>Ce.patch(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/test-inputs/${encodeURIComponent(n)}`,r),"updateTestInput"),deleteTestInput:s((e,t,n)=>Ce.delete(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/test-inputs/${encodeURIComponent(n)}`),"deleteTestInput"),testRunTemplates:s(e=>Ce.get(`/companies/${encodeURIComponent(e)}/skill-test-run-templates`),"testRunTemplates"),createTestRunTemplate:s((e,t)=>Ce.post(`/companies/${encodeURIComponent(e)}/skill-test-run-templates`,t),"createTestRunTemplate"),updateTestRunTemplate:s((e,t,n)=>Ce.patch(`/companies/${encodeURIComponent(e)}/skill-test-run-templates/${encodeURIComponent(t)}`,n),"updateTestRunTemplate"),deleteTestRunTemplate:s((e,t)=>Ce.delete(`/companies/${encodeURIComponent(e)}/skill-test-run-templates/${encodeURIComponent(t)}`),"deleteTestRunTemplate"),testRuns:s((e,t,n={})=>{const r=new URLSearchParams;n.inputId&&r.set("inputId",n.inputId);const i=r.toString();return Ce.get(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/test-runs${i?`?${i}`:""}`)},"testRuns"),testRunDetail:s((e,t,n)=>Ce.get(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/test-runs/${encodeURIComponent(n)}`),"testRunDetail"),createTestRun:s((e,t,n)=>Ce.post(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/test-runs`,n),"createTestRun"),cancelTestRun:s((e,t,n)=>Ce.post(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/test-runs/${encodeURIComponent(n)}/cancel`,{}),"cancelTestRun"),deleteTestRun:s((e,t,n)=>Ce.delete(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/test-runs/${encodeURIComponent(n)}`),"deleteTestRun"),star:s((e,t)=>Ce.post(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/star`,{}),"star"),unstar:s((e,t)=>Ce.delete(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/star`),"unstar"),fork:s((e,t,n={})=>Ce.post(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/fork`,n),"fork"),forkPrecheck:s((e,t)=>Ce.get(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/fork-precheck`),"forkPrecheck"),comments:s((e,t)=>Ce.get(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/comments`),"comments"),createComment:s((e,t,n)=>Ce.post(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/comments`,n),"createComment"),updateComment:s((e,t,n,r)=>Ce.patch(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/comments/${encodeURIComponent(n)}`,r),"updateComment"),deleteComment:s((e,t,n)=>Ce.delete(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/comments/${encodeURIComponent(n)}`),"deleteComment"),updateStatus:s((e,t)=>Ce.get(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/update-status`),"updateStatus"),file:s((e,t,n)=>Ce.get(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/files?path=${encodeURIComponent(n)}`),"file"),updateFile:s((e,t,n,r)=>Ce.patch(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/files`,{path:n,content:r}),"updateFile"),deleteFile:s((e,t,n)=>Ce.deleteWithBody(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/files`,n),"deleteFile"),create:s((e,t)=>Ce.post(`/companies/${encodeURIComponent(e)}/skills`,t),"create"),update:s((e,t,n)=>Ce.patch(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}`,n),"update"),importFromSource:s((e,t)=>Ce.post(`/companies/${encodeURIComponent(e)}/skills/import`,{source:t}),"importFromSource"),browseProject:s((e,t)=>Ce.post(`/companies/${encodeURIComponent(e)}/skills/browse-project`,t),"browseProject"),scanProjects:s((e,t={})=>Ce.post(`/companies/${encodeURIComponent(e)}/skills/scan-projects`,t),"scanProjects"),installUpdate:s((e,t)=>Ce.post(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/install-update`,{}),"installUpdate"),delete:s((e,t)=>Ce.delete(`/companies/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}`),"delete"),catalogList:s((e={})=>{const t=new URLSearchParams;e.kind&&t.set("kind",e.kind),e.category&&t.set("category",e.category),e.q&&t.set("q",e.q);const n=t.toString();return Ce.get(`/skills/catalog${n?`?${n}`:""}`)},"catalogList"),catalogDetail:s(e=>Ce.get(`/skills/catalog/${encodeURIComponent(e)}`),"catalogDetail"),catalogFile:s((e,t="SKILL.md")=>Ce.get(`/skills/catalog/${encodeURIComponent(e)}/files?path=${encodeURIComponent(t)}`),"catalogFile"),installCatalog:s((e,t)=>Ce.post(`/companies/${encodeURIComponent(e)}/skills/install-catalog`,t),"installCatalog")},YU=["/steer","/queue"];function XU(e){return YU.includes(e)}s(XU,"isDeliveryCommand");var QU=["goal","steer","queue"];function Rx(e){return QU.includes(e)}s(Rx,"isAbsorbableCommand");function Lx(e,t){return e===""||e===t?!0:t==="goal"&&e==="go"}s(Lx,"labelMatchesCommand");function eW(e){const t=e.trim(),n=t.match(/^\[\/([A-Za-z]*)[ \t\u00a0]*\]\(<(\/[A-Za-z]+(?:[ \t\u00a0].*)?)>\)$/s);if(n){const i=n[1],o=n[2].replaceAll(" "," "),l=o.slice(1).split(/[ \t]/)[0]??"";return Rx(l)&&Lx(i,l)?o:t.replaceAll(" "," ")}const r=t.match(/^\[\/([A-Za-z]*)[ \t\u00a0]*\]\((\/[A-Za-z]+(?:%20|%C2%A0).*)\)$/s);if(r){const i=r[1],o=r[2],l=decodeURIComponent(o.slice(1).split(/(?:%20|%C2%A0)/)[0]??"");if(Rx(l)&&Lx(i,l))try{return decodeURIComponent(o).replaceAll(" "," ")}catch{return t}}return t.replaceAll(" "," ")}s(eW,"normalizeComposerCommandText");function eJ(e){const t=eW(e);if(!t)return{matched:!1};const n=t.search(/\s/),r=n===-1?t:t.slice(0,n);if(!XU(r))return{matched:!1};const i=n===-1?"":t.slice(n).trim();return i?{matched:!0,command:{mode:r.slice(1),prompt:i}}:{matched:!0,error:`${r} needs a message. Type ${r} followed by what you want to send.`}}s(eJ,"parseMessageDeliveryCommand");var tW=[{id:"action:steer",kind:"action",command:"steer",name:"Steer",description:"Send into the agent's running turn now.",aliases:["steer","steering","steered","now"]},{id:"action:queue",kind:"action",command:"queue",name:"Queue",description:"Queue for the next turn boundary.",aliases:["queue","queued","later","next"]}],nW={not_requested:"",board_only:"steering is only available to board users.",no_active_run:"there was no active run to steer.",legacy_protocol:"this runner's session protocol cannot accept a mid-turn steer.",conversation_order:"an earlier chat message is still waiting, or this message resets the chat, so it keeps its place in line.",steering_failed:"the steer did not land, so the message is queued and will be read at the next turn."},rW="this task could not be steered mid-turn.";function tJ(e){if(!e||e.deliveredAs==="steered")return null;const t=e.steeringUnavailable??null;return!t||t==="not_requested"?null:`Queued instead of steering the running turn — ${nW[t]??rW}`}s(tJ,"describeDeliveryDowngrade");function nJ(e){return e?.comment??void 0}s(nJ,"deliveryDispositionFromIssueUpdate");var Mk=(0,m.createContext)({slashCommands:[]});function rJ({children:e}){const{selectedCompanyId:t}=Jk(),{data:n=[]}=p0({queryKey:t?g0.companySkills.list(t):["company-skills","__none__"],queryFn:s(()=>ZU.list(t),"queryFn"),enabled:!!t}),{data:r=[]}=p0({queryKey:t?g0.routines.list(t):["routines","__none__","__all-projects__"],queryFn:s(()=>S8.list(t),"queryFn"),enabled:!!t}),i=(0,m.useMemo)(()=>({slashCommands:[...tW,...n.map(o=>({id:`skill:${o.id}`,kind:"skill",skillId:o.id,key:o.key,name:o.name,slug:o.slug,description:o.description??null,href:u9(o.id,o.slug),aliases:[o.slug,o.name,o.key]})),...r.filter(o=>o.status!=="archived").sort((o,l)=>o.title.localeCompare(l.title)).map(o=>({id:`routine:${o.id}`,kind:"routine",routineId:o.id,name:o.title,status:o.status,href:Kx(o.id),aliases:[`routine:${o.title}`,o.title,o.id]}))]}),[n,r]);return(0,H.jsx)(Mk.Provider,{value:i,children:e})}s(rJ,"EditorAutocompleteProvider");function iW(){return(0,m.useContext)(Mk)}s(iW,"useEditorAutocomplete");var iJ=Hx({MarkdownEditor:s(()=>AW,"MarkdownEditor"),computeMentionMenuPosition:s(()=>Dk,"computeMentionMenuPosition"),findClosestAutocompleteAnchor:s(()=>Fk,"findClosestAutocompleteAnchor"),findMentionMatch:s(()=>Ok,"findMentionMatch"),isSameAutocompleteSession:s(()=>Pk,"isSameAutocompleteSession"),issueMentionTitle:s(()=>Rk,"issueMentionTitle"),placeCaretAfterMentionAnchor:s(()=>Vk,"placeCaretAfterMentionAnchor"),placeCaretAtEditableEnd:s(()=>Bk,"placeCaretAtEditableEnd"),shouldAcceptAutocompleteKey:s(()=>$k,"shouldAcceptAutocompleteKey")}),oW=class extends m.Component{static{s(this,"MarkdownEditorRichErrorBoundary")}state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,t){this.props.onError(e)}render(){return this.state.hasError?null:this.props.children}};function oh(e,t){const n=new RegExp(`${t}\\s*=\\s*("([^"]*)"|'([^']*)'|([^\\s>]+))`,"i").exec(e);return n?.[2]??n?.[3]??n?.[4]??null}s(oh,"readHtmlAttribute");function sW(e){return e==="delete_small"?(0,H.jsx)(Qk,{"aria-hidden":!0}):rT[e]}s(sW,"editorIconFor");function lW(e){return e.replace(/<img\b([^>]*?)\/?>/gi,(t,n)=>{const r=oh(n,"src");if(!r)return t;const i=oh(n,"alt")??"image",o=oh(n,"title"),l=i.replace(/[[\]]/g,"\\$&"),a=o?.replace(/"/g,'\\"');return a?`![${l}](${r} "${a}")`:`![${l}](${r})`})}s(lW,"convertHtmlImagesToMarkdown");function $x(e){const t=e.replace(/\r\n/g,`
81
81
  `).replace(/\r/g,`
82
82
  `),n=lW(kk(t));return ip(n)}s($x,"prepareMarkdownForEditor");function Sc(e){return UU(kk(e))}s(Sc,"toStoredMarkdown");function aW(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}s(aW,"escapeRegExp");function Ak(e){if(!e)return!1;if(e.nodeType===Node.TEXT_NODE)return(e.textContent??"").trim().length>0;if(e.nodeType!==Node.ELEMENT_NODE)return!1;const t=e;return["IMG","HR","TABLE","VIDEO","IFRAME"].includes(t.tagName)?!0:Array.from(t.childNodes).some(n=>Ak(n))}s(Ak,"hasMeaningfulEditorContent");function cW(e){return/!\[[\s\S]*?\]\([^)]+\)/.test(e)}s(cW,"hasMarkdownImage");function uW(e,t,n){const r=t.trim();if(!r)return!1;const i=cW(r),o=(e.textContent??"").trim();if(o.length===0)return i?!1:!Array.from(e.childNodes).some(a=>Ak(a));const l=n?.trim();return l&&o===l&&r!==l?!i:!1}s(uW,"isRichEditorDomEmpty");function dW(e){const t=e.trim();return t?!/^(javascript|data|vbscript):/i.test(t):!0}s(dW,"isSafeMarkdownLinkUrl");function Px(e){return e instanceof Error?e.message:typeof e=="string"?e:"Rich editor failed to render"}s(Px,"richEditorErrorMessage");var fW=100,hW=200,Ik=188,Nk=208,Fx=8,gW=34,pW=8,Vx=50,mW=10,vW={txt:"Text",md:"Markdown",js:"JavaScript",jsx:"JavaScript (JSX)",ts:"TypeScript",tsx:"TypeScript (TSX)",json:"JSON",bash:"Bash",sh:"Shell",python:"Python",go:"Go",rust:"Rust",sql:"SQL",html:"HTML",css:"CSS",yaml:"YAML",yml:"YAML"},_W={priority:0,match:s(()=>!0,"match"),Editor:z3};function Ok(e,t){let n=-1,r=null,i=null;for(let l=t-1;l>=0;l--){const a=e[l];if(a==="@"||a==="/"){(l===0||/\s/.test(e[l-1]))&&(n=l,r=a==="@"?"mention":"skill",i=a);break}if(a===`
83
83
  `||a==="\r")break}if(n===-1)return null;const o=e.slice(n+1,t);return r==="skill"&&/\s/.test(o)&&!o.toLowerCase().startsWith("routine:")?null:{trigger:r??"mention",marker:i??"@",query:o,atPos:n,endPos:t}}s(Ok,"findMentionMatch");function yW(e,t,n){const r=e.textContent?.length??0,i=s((o,l,a)=>{if(o<0||l>r||l<=o)return null;const c=document.createRange();c.setStart(e,o),c.setEnd(e,l);const d=c.getBoundingClientRect();return d.width===0&&d.height===0?null:{top:d.top,bottom:d.bottom,x:a==="right"?d.right:d.left}},"rectFromRange");return i(Math.max(0,t-1),t,"right")??i(t,Math.min(r,t+1),"left")??i(n,n+1,"right")??{top:0,bottom:0,x:0}}s(yW,"measureCaretRect");function xW(e){const t=window.getSelection();if(!t||t.rangeCount===0||!t.isCollapsed)return null;const n=t.getRangeAt(0),r=n.startContainer;if(r.nodeType!==Node.TEXT_NODE||!e.contains(r))return null;const i=r.textContent??"",o=n.startOffset,l=Ok(i,o);if(!l)return null;const a=yW(r,o,l.atPos),c=e.getBoundingClientRect();return{trigger:l.trigger,marker:l.marker,query:l.query,top:a.top-c.top,left:a.x-c.left,viewportTop:a.top,viewportBottom:a.bottom,viewportLeft:a.x,textNode:r,atPos:l.atPos,endPos:l.endPos}}s(xW,"detectMention");function CW(){const e=window.visualViewport;return e?{offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,width:e.width,height:e.height}:{offsetLeft:0,offsetTop:0,width:window.innerWidth,height:window.innerHeight}}s(CW,"getMentionMenuViewport");function Dk(e,t,n={width:Ik,height:Nk}){const r=t.offsetLeft+Fx,i=t.offsetLeft+t.width-n.width,o=t.offsetTop+Fx,l=t.offsetTop+t.height-n.height,a=t.offsetTop+e.viewportTop;let c;if(a>l){const u=t.offsetTop+e.viewportBottom-n.height;c=Math.max(o,Math.min(u,l))}else c=Math.max(o,a);const d=t.offsetLeft+e.viewportLeft+mW;return{top:c,left:Math.max(r,Math.min(d,i))}}s(Dk,"computeMentionMenuPosition");function bW(e){return{width:Ik,height:Math.min(Nk,Math.max(1,Math.min(e,8))*gW+pW)}}s(bW,"getMentionMenuSize");function EW(e,t){return!t||!e.contains(t)?!1:!!(t.nodeType===Node.ELEMENT_NODE?t:t.parentElement)?.closest("pre, code")}s(EW,"nodeInsideCodeLike");function Bx(e){if(!e)return!1;const t=window.getSelection();if(!t)return!1;for(const n of[t.anchorNode,t.focusNode])if(EW(e,n))return!0;return!1}s(Bx,"isSelectionInsideCodeLikeElement");function Rk(e){const t=e.name.trim(),n=e.issueIdentifier?.trim();return n&&t.toLowerCase().startsWith(n.toLowerCase())?t.slice(n.length).trim():t}s(Rk,"issueMentionTitle");function SW(e){if(e.kind==="issue"&&e.issueIdentifier)return`[${e.issueIdentifier}](${c9(e.issueIdentifier)}) `;if(e.kind==="project"&&e.projectId)return`[@${e.name}](${o9(e.projectId,e.projectColor??null)}) `;if(e.kind==="user"&&e.userId)return`[@${e.name}](${h9(e.userId)}) `;const t=e.agentId??e.id.replace(/^agent:/,"");return`[@${e.name}](${f9(t,e.agentIcon??null)}) `}s(SW,"mentionMarkdown");function Lk(e){return e.kind==="routine"?`/routine:${e.name}`:e.kind==="action"?`/${e.command}`:`/${e.slug}`}s(Lk,"slashCommandLabel");function TW(e){return e.kind==="action"?`/${e.command} `:e.kind==="routine"?`[${Lk(e)}](${Kx(e.routineId)}) `:`[/${e.slug}](${e.href}) `}s(TW,"slashCommandMarkdown");function wW(e){return e.kind==="skill"||e.kind==="routine"||e.kind==="action"?TW(e):SW(e)}s(wW,"autocompleteMarkdown");function $k(e,t,n=!1){return e==="Tab"?!0:e!=="Enter"?!1:t==="mention"||t==="skill"&&n}s($k,"shouldAcceptAutocompleteKey");function Pk(e,t){return!e||!t?!1:e.trigger===t.trigger&&e.marker===t.marker&&e.query===t.query&&e.textNode===t.textNode&&e.atPos===t.atPos&&e.endPos===t.endPos}s(Pk,"isSameAutocompleteSession");function kW(e,t){if(e.kind==="action")return!1;const n=lp(t);if(!n)return!1;if(e.kind==="skill")return n.kind==="skill"&&n.skillId===e.skillId;if(e.kind==="routine")return n.kind==="routine"&&n.routineId===e.routineId;if(e.kind==="issue"&&e.issueIdentifier)return n.kind==="issue"&&n.identifier===e.issueIdentifier;if(e.kind==="project"&&e.projectId)return n.kind==="project"&&n.projectId===e.projectId;if(e.kind==="user"&&e.userId)return n.kind==="user"&&n.userId===e.userId;const r=e.agentId??e.id.replace(/^agent:/,"");return n.kind==="agent"&&n.agentId===r}s(kW,"autocompleteOptionMatchesLink");function Fk(e,t,n){const r=Array.from(e.querySelectorAll("a")).filter(o=>o instanceof HTMLAnchorElement).filter(o=>kW(t,o.getAttribute("href")??""));if(r.length===0)return null;if(!n)return r[0]??null;const i=e.getBoundingClientRect();return r.sort((o,l)=>{const a=o.getBoundingClientRect(),c=l.getBoundingClientRect(),d=a.left-i.left,u=a.top-i.top,f=c.left-i.left,h=c.top-i.top;return Math.hypot(d-n.left,u-n.top)-Math.hypot(f-n.left,h-n.top)})[0]??null}s(Fk,"findClosestAutocompleteAnchor");function Vk(e){const t=window.getSelection();if(!t)return!1;const n=document.createRange(),r=e.nextSibling;if(r?.nodeType===Node.TEXT_NODE){const i=r.textContent??"";if(i.startsWith(" "))return n.setStart(r,1),n.collapse(!0),t.removeAllRanges(),t.addRange(n),!0;if(i.length>0)return n.setStart(r,0),n.collapse(!0),t.removeAllRanges(),t.addRange(n),!0}return n.setStartAfter(e),n.collapse(!0),t.removeAllRanges(),t.addRange(n),!0}s(Vk,"placeCaretAfterMentionAnchor");function Bk(e){const t=window.getSelection();if(!t)return!1;const n=document.createRange();return n.selectNodeContents(e),n.collapse(!1),t.removeAllRanges(),t.addRange(n),!0}s(Bk,"placeCaretAtEditableEnd");function MW(e,t,n){const r=`${t.marker}${t.query}`,i=wW(n),o=e.lastIndexOf(r);return o===-1?e:e.slice(0,o)+i+e.slice(o+r.length)}s(MW,"applyMention");var AW=(0,m.forwardRef)(s(function({value:t,onChange:n,placeholder:r,className:i,contentClassName:o,onBlur:l,imageUploadHandler:a,onDropFile:c,fileDropTarget:d="editor",bordered:u=!0,mentions:f,actionCommands:h=[],onSubmit:g,readOnly:p=!1},v){const _=(0,m.useMemo)(()=>$x(t),[t]),{slashCommands:y}=iW(),x=(0,m.useMemo)(()=>[...h,...y],[h,y]),C=(0,m.useRef)(null),b=(0,m.useRef)(null),S=(0,m.useRef)(null),M=(0,m.useRef)(_);M.current=_;const T=(0,m.useRef)(_),E=(0,m.useRef)(!0),A=(0,m.useRef)(null),[D,L]=(0,m.useState)(null),[G,$]=(0,m.useState)(!1),[W,z]=(0,m.useState)(null),me=(0,m.useRef)(0),q=(0,m.useRef)(a);q.current=a;const[le,ye]=(0,m.useState)(null),X=(0,m.useRef)(null),[ne,he]=(0,m.useState)(0),ge=(0,m.useRef)([]),se=(0,m.useRef)(!1),Z=(0,m.useRef)(!1),ee=le!==null&&(le.trigger==="mention"&&!!f?.length||le.trigger==="skill"&&x.length>0),pe=(0,m.useMemo)(()=>{const R=new Map;for(const Y of f??[]){if(Y.kind==="agent"){const Se=Y.agentId??Y.id.replace(/^agent:/,"");R.set(`agent:${Se}`,Y)}Y.kind==="user"&&Y.userId&&R.set(`user:${Y.userId}`,Y),Y.kind==="project"&&Y.projectId&&R.set(`project:${Y.projectId}`,Y)}return R},[f]),De=(0,m.useCallback)(R=>{b.current=R,R&&M.current!==T.current&&(A.current=M.current,R.setMarkdown(M.current),T.current=M.current)},[]),Ae=(0,m.useMemo)(()=>{if(!le)return[];const R=le.query.trim().toLowerCase();return le.trigger==="skill"?x.filter(Y=>R?Y.aliases.some(Se=>Se.toLowerCase().includes(R)):!0).slice(0,Vx):f?f.filter(Y=>Y.name.toLowerCase().includes(R)).slice(0,Vx):[]},[le,f,x]),Ge=(0,m.useCallback)(R=>{if(p)return;if(!W&&b.current){const k=b.current,O=ip(R);k.focus(()=>k.insertMarkdown(O),{defaultSelection:"rootEnd"});return}const Y=S.current;if(!Y){n(`${t}${R}`);return}const Se=Y.selectionStart??t.length,Fe=Y.selectionEnd??t.length;n(`${t.slice(0,Se)}${R}${t.slice(Fe)}`),requestAnimationFrame(()=>{Y.focus();const k=Se+R.length;Y.setSelectionRange(k,k)})},[n,p,W,t]);(0,m.useImperativeHandle)(v,()=>({focus:s(()=>{if(W){S.current?.focus();return}b.current?.focus(void 0,{defaultSelection:"rootEnd"})},"focus"),insertMarkdown:Ge,clear:s(()=>{T.current="",A.current="",b.current?.setMarkdown(""),S.current&&(S.current.value="")},"clear")}),[Ge,W]);const Pe=(0,m.useCallback)(R=>{R&&(R.style.height="auto",R.style.height=`${R.scrollHeight}px`)},[]);(0,m.useEffect)(()=>{W&&Pe(S.current)},[Pe,W,t]),(0,m.useEffect)(()=>{if(W||_.trim().length===0)return;const R=C.current;if(!R)return;let Y=0,Se=0,Fe=0;const k=s(()=>{const K=R.querySelector('[contenteditable="true"]');if(!(K instanceof HTMLElement))return!1;const J=document.activeElement;return J===K||K.contains(J)?!1:uW(K,_,r)},"looksEmpty"),O=s(()=>{window.clearTimeout(Y),window.clearTimeout(Se),Y=window.setTimeout(()=>{if(!k())return;const K=Fe;Se=window.setTimeout(()=>{Fe===K&&k()&&z({code:"MDE-EMPTY",message:"Rich editor failed to load content"})},hW)},fW)},"scheduleCheck");O();const N=new MutationObserver(()=>{Fe+=1,O()});return N.observe(R,{subtree:!0,childList:!0,characterData:!0}),()=>{window.clearTimeout(Y),window.clearTimeout(Se),N.disconnect()}},[_,r,W]);const lt=!!a,Ye=(0,m.useMemo)(()=>{const R=lt?async Se=>{const Fe=q.current;if(!Fe)throw new Error("No image upload handler");try{const k=await Fe(Se);return L(null),setTimeout(()=>{const O=T.current,N=aW(k),K=O.replace(new RegExp(`(!\\[[^\\]]*\\]\\(${N}\\))(?!\\n\\n)`,"g"),`$1
@@ -1 +1 @@
1
- var pt=Object.defineProperty;var u=(e,a)=>pt(e,"name",{value:a,configurable:!0});import{i as ot}from"./rolldown-runtime-ZpX3ckPj.js";import{En as yt,Fr as bt,Lr as vt,U as wt,Y as K,_ as Ct,nr as Q}from"./createLucideIcon-r3v6fbGz.js";import{o as jt,t as V}from"./router-DyZkoSkG.js";import{t as Mt}from"./AgentAvatar-PT82VwmU.js";import{t as J}from"./agents-BlSzFh-1.js";import{r as Nt,t as tt}from"./EmptyState-DPcc0zYh.js";import{k as kt,t as et}from"./button-CAPbz11u.js";import{n as Pt,t as Dt}from"./useHiddenSettings-2JpxuJV7.js";import{t as Yt}from"./card-dmVcp3AX.js";import{t as Zt}from"./PageSkeleton-DHjTwRT3.js";import{Dn as rt,On as Et,Pn as Tt,Yt as _t,en as Xt,hn as zt}from"./index-CZl9vxyj.js";var o=ot(vt(),1),n=ot(bt(),1),N=200,W=100,X=32,$t=80,L=60,Wt=.2,Lt=2,R=6;function Z(e){if(e.reports.length===0)return N;const a=e.reports.reduce((i,f)=>i+Z(f),0),d=(e.reports.length-1)*X;return Math.max(N,a+d)}u(Z,"subtreeWidth");function at(e,a,d){const i=Z(e),f=[];if(e.reports.length>0){const C=e.reports.reduce((k,P)=>k+Z(P),0),S=(e.reports.length-1)*X;let j=a+(i-C-S)/2;for(const k of e.reports){const P=Z(k);f.push(at(k,j,d+W+$t)),j+=P+X}}return{id:e.id,name:e.name,role:e.role,status:e.status,x:a+(i-N)/2,y:d,children:f}}u(at,"layoutTree");function St(e){if(e.length===0)return[];e.reduce((f,C)=>f+Z(C),0),(e.length-1)*X;let a=L;const d=L,i=[];for(const f of e){const C=Z(f);i.push(at(f,a,d)),a+=C+X}return i}u(St,"layoutForest");function Ht(e){const a=[];function d(i){a.push(i),i.children.forEach(d)}return u(d,"walk"),e.forEach(d),a}u(Ht,"flattenLayout");function Rt(e){const a=[];function d(i){for(const f of i.children)a.push({parent:i,child:f}),d(f)}return u(d,"walk"),e.forEach(d),a}u(Rt,"collectEdges");function A(e){return Math.min(Math.max(e,Wt),Lt)}u(A,"clampZoom");function At(e){return{x:e.clientX,y:e.clientY}}u(At,"touchPoint");function nt(e,a){const d=e.clientX-a.clientX,i=e.clientY-a.clientY;return Math.hypot(d,i)}u(nt,"touchDistance");function st(e,a,d){const i=d.getBoundingClientRect();return{x:(e.clientX+a.clientX)/2-i.left,y:(e.clientY+a.clientY)/2-i.top}}u(st,"touchCenter");var Ot={running:"var(--hex-22d3ee)",active:"var(--hex-4ade80)",paused:"var(--hex-facc15)",idle:"var(--hex-facc15)",error:"var(--hex-f87171)",terminated:"var(--hex-a3a3a3)"},Bt="var(--hex-a3a3a3)";function oe(){const{selectedCompanyId:e}=wt(),{setBreadcrumbs:a}=Nt(),d=jt(),i=!!Xt(),{hidden:f}=Dt(),C=!i&&!f.has("company.import"),S=!f.has("company.export"),{data:j,isLoading:k}=Q({queryKey:K.org(e),queryFn:u(()=>J.org(e),"queryFn"),enabled:!!e}),{data:P}=Q({queryKey:K.agents.list(e),queryFn:u(()=>J.list(e),"queryFn"),enabled:!!e}),ct=(0,o.useMemo)(()=>{const t=new Map;for(const r of P??[])t.set(r.id,r);return t},[P]);(0,o.useEffect)(()=>{a([{label:"Org Chart"}])},[a]);const z=(0,o.useMemo)(()=>St(j??[]),[j]),D=(0,o.useMemo)(()=>Ht(z),[z]),it=(0,o.useMemo)(()=>Rt(z),[z]),v=(0,o.useMemo)(()=>{if(D.length===0)return{width:800,height:600};let t=0,r=0;for(const s of D)t=Math.max(t,s.x+N),r=Math.max(r,s.y+W);return{width:t+L,height:r+L}},[D]),p=(0,o.useRef)(null),[l,M]=(0,o.useState)({x:0,y:0}),[h,E]=(0,o.useState)(1),[H,O]=(0,o.useState)(!1),T=(0,o.useRef)({x:0,y:0,panX:0,panY:0}),m=(0,o.useRef)({mode:null,startPoint:{x:0,y:0},startPan:{x:0,y:0},startZoom:1,startDistance:0,startCenter:{x:0,y:0},moved:!1}),$=(0,o.useRef)(!1),Y=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>{Y.current!==null&&window.clearTimeout(Y.current)},[]);const B=(0,o.useRef)(!1);(0,o.useEffect)(()=>{if(B.current||D.length===0||!p.current)return;B.current=!0;const t=p.current,r=t.clientWidth,s=t.clientHeight,c=(r-40)/v.width,x=(s-40)/v.height,g=Math.min(c,x,1),y=v.width*g,w=v.height*g;E(g),M({x:(r-y)/2,y:(s-w)/2})},[D,v]);const lt=(0,o.useCallback)(t=>{t.button===0&&(t.target.closest("[data-org-card]")||(O(!0),T.current={x:t.clientX,y:t.clientY,panX:l.x,panY:l.y}))},[l]),ut=(0,o.useCallback)(t=>{if(!H)return;const r=t.clientX-T.current.x,s=t.clientY-T.current.y;M({x:T.current.panX+r,y:T.current.panY+s})},[H]),q=(0,o.useCallback)(()=>{O(!1)},[]),dt=(0,o.useCallback)(t=>{t.preventDefault();const r=p.current;if(!r)return;const s=r.getBoundingClientRect(),c=t.clientX-s.left,x=t.clientY-s.top,g=t.deltaY<0?1.1:.9,y=A(h*g),w=y/h;M({x:c-w*(c-l.x),y:x-w*(x-l.y)}),E(y)},[h,l]),I=(0,o.useCallback)((t,r)=>{const s=A(t),c=s/h;M({x:r.x-c*(r.x-l.x),y:r.y-c*(r.y-l.y)}),E(s)},[h,l]),ht=(0,o.useCallback)(()=>{if(!p.current)return;const t=p.current.clientWidth,r=p.current.clientHeight,s=(t-40)/v.width,c=(r-40)/v.height,x=Math.min(s,c,1),g=v.width*x,y=v.height*x;E(x),M({x:(t-g)/2,y:(r-y)/2})},[v]),mt=(0,o.useCallback)(t=>{if(t.touches.length>=2&&p.current){const[s,c]=[t.touches[0],t.touches[1]];m.current={mode:"pinch",startPoint:{x:0,y:0},startPan:l,startZoom:h,startDistance:nt(s,c),startCenter:st(s,c,p.current),moved:!1};return}const r=t.touches[0];r&&(m.current={mode:"pan",startPoint:At(r),startPan:l,startZoom:h,startDistance:0,startCenter:{x:0,y:0},moved:!1})},[l,h]),ft=(0,o.useCallback)(t=>{const r=p.current;if(!r||!m.current.mode)return;if(t.touches.length>=2){const[g,y]=[t.touches[0],t.touches[1]],w=nt(g,y),_=st(g,y,r);if(m.current.mode!=="pinch"||m.current.startDistance===0){m.current={mode:"pinch",startPoint:{x:0,y:0},startPan:l,startZoom:h,startDistance:w,startCenter:_,moved:!1};return}const b=m.current,U=A(b.startZoom*(w/b.startDistance)),G=U/b.startZoom,xt=_.x-b.startCenter.x,gt=_.y-b.startCenter.y;b.moved=b.moved||Math.abs(w-b.startDistance)>R||Math.hypot(xt,gt)>R,E(U),M({x:_.x-G*(b.startCenter.x-b.startPan.x),y:_.y-G*(b.startCenter.y-b.startPan.y)});return}const s=t.touches[0];if(!s||m.current.mode!=="pan")return;const c=s.clientX-m.current.startPoint.x,x=s.clientY-m.current.startPoint.y;m.current.moved=m.current.moved||Math.hypot(c,x)>R,M({x:m.current.startPan.x+c,y:m.current.startPan.y+x})},[l,h]),F=(0,o.useCallback)(()=>{m.current.moved&&($.current=!0,Y.current!==null&&window.clearTimeout(Y.current),Y.current=window.setTimeout(()=>{$.current=!1,Y.current=null},400)),m.current={mode:null,startPoint:{x:0,y:0},startPan:l,startZoom:h,startDistance:0,startCenter:{x:0,y:0},moved:!1}},[l,h]);return e?k?(0,n.jsx)(Zt,{variant:"org-chart"}):j&&j.length===0?(0,n.jsx)(tt,{icon:rt,message:"No organizational hierarchy defined."}):(0,n.jsxs)("div",{className:"flex h-(--sz-calc-38) min-h-(--sz-420px) flex-col md:h-full md:min-h-0",children:[(0,n.jsxs)("div",{className:"mb-2 flex shrink-0 flex-wrap items-center justify-start gap-2",children:[C&&(0,n.jsx)(V,{to:"/company/import",children:(0,n.jsxs)(et,{variant:"outline",size:"sm",children:[(0,n.jsx)(zt,{className:"mr-1.5 h-3.5 w-3.5"}),"Import company"]})}),S&&(0,n.jsx)(V,{to:"/company/export",children:(0,n.jsxs)(et,{variant:"outline",size:"sm",children:[(0,n.jsx)(Tt,{className:"mr-1.5 h-3.5 w-3.5"}),"Export company"]})})]}),(0,n.jsxs)("div",{ref:p,"data-testid":"org-chart-viewport",className:"w-full flex-1 min-h-0 overflow-hidden relative bg-muted/20 border border-border rounded-lg",style:{cursor:H?"grabbing":"grab",touchAction:"none",overscrollBehavior:"contain"},onMouseDown:lt,onMouseMove:ut,onMouseUp:q,onMouseLeave:q,onWheel:dt,onTouchStart:mt,onTouchMove:ft,onTouchEnd:F,onTouchCancel:F,children:[(0,n.jsxs)("div",{className:"absolute top-3 right-3 z-10 flex flex-col gap-1.5",children:[(0,n.jsx)("button",{className:"flex size-9 items-center justify-center rounded border border-border bg-background text-sm transition-colors hover:bg-accent sm:size-7",onClick:u(()=>{const t=p.current;t&&I(h*1.2,{x:t.clientWidth/2,y:t.clientHeight/2})},"onClick"),title:"Zoom in","aria-label":"Zoom in",children:(0,n.jsx)(kt,{className:"h-4 w-4 sm:h-3.5 sm:w-3.5"})}),(0,n.jsx)("button",{className:"flex size-9 items-center justify-center rounded border border-border bg-background text-sm transition-colors hover:bg-accent sm:size-7",onClick:u(()=>{const t=p.current;t&&I(h*.8,{x:t.clientWidth/2,y:t.clientHeight/2})},"onClick"),title:"Zoom out","aria-label":"Zoom out",children:(0,n.jsx)(Pt,{className:"h-4 w-4 sm:h-3.5 sm:w-3.5"})}),(0,n.jsx)("button",{className:"flex size-9 items-center justify-center rounded border border-border bg-background text-(length:--text-nano) transition-colors hover:bg-accent sm:size-7",onClick:ht,title:"Fit to screen","aria-label":"Fit chart to screen",children:(0,n.jsx)(Et,{className:"h-4 w-4 sm:h-3.5 sm:w-3.5"})})]}),(0,n.jsx)("svg",{className:"absolute inset-0 pointer-events-none",style:{width:"100%",height:"100%"},children:(0,n.jsx)("g",{transform:`translate(${l.x}, ${l.y}) scale(${h})`,children:it.map(({parent:t,child:r})=>{const s=t.x+N/2,c=t.y+W,x=r.x+N/2,g=r.y,y=(c+g)/2;return(0,n.jsx)("path",{d:`M ${s} ${c} L ${s} ${y} L ${x} ${y} L ${x} ${g}`,fill:"none",stroke:"var(--border)",strokeWidth:1.5},`${t.id}-${r.id}`)})})}),(0,n.jsx)("div",{"data-testid":"org-chart-card-layer",className:"absolute inset-0",style:{transform:`translate(${l.x}px, ${l.y}px) scale(${h})`,transformOrigin:"0 0"},children:D.map(t=>{const r=ct.get(t.id),s=Ot[t.status]??Bt;return(0,n.jsx)(Yt,{"data-org-card":!0,className:"block absolute py-0 hover:shadow-md hover:border-foreground/20 transition-(--tp-box-shadow-border-color) duration-150 cursor-pointer select-none",style:{left:t.x,top:t.y,width:N,minHeight:W},onClick:u(()=>d(r?Ct(r):`/agents/${t.id}`),"onClick"),onClickCapture:u(c=>{$.current&&($.current=!1,c.preventDefault(),c.stopPropagation())},"onClickCapture"),children:(0,n.jsxs)("div",{className:"flex items-center px-4 py-3 gap-3",children:[(0,n.jsxs)("div",{className:"relative shrink-0",children:[(0,n.jsx)("div",{className:"w-9 h-9 rounded-full bg-muted flex items-center justify-center",children:(0,n.jsx)(Mt,{agent:r,size:16,className:"h-4.5 w-4.5 text-foreground/70"})}),(0,n.jsx)("span",{className:"absolute -bottom-0.5 -right-0.5 h-3 w-3 rounded-full border-2 border-card",style:{backgroundColor:s}})]}),(0,n.jsxs)("div",{className:"flex flex-col items-start min-w-0 flex-1",children:[(0,n.jsx)("span",{className:"text-sm font-semibold text-foreground leading-tight",children:t.name}),(0,n.jsx)("span",{className:"text-(length:--text-micro) text-muted-foreground leading-tight mt-0.5",children:r?.title??It(t.role)}),r&&(0,n.jsx)("span",{className:"text-(length:--text-nano) text-muted-foreground/60 font-mono leading-tight mt-1",children:_t(r.adapterType)}),r&&r.capabilities&&(0,n.jsx)("span",{className:"text-(length:--text-nano) text-muted-foreground/80 leading-tight mt-1 line-clamp-2",children:r.capabilities})]})]})},t.id)})})]})]}):(0,n.jsx)(tt,{icon:rt,message:"Select a company to view the org chart."})}u(oe,"OrgChart");var qt=yt;function It(e){return qt[e]??e}u(It,"roleLabel");export{oe as OrgChart};
1
+ var pt=Object.defineProperty;var u=(e,a)=>pt(e,"name",{value:a,configurable:!0});import{i as ot}from"./rolldown-runtime-ZpX3ckPj.js";import{En as yt,Fr as bt,Lr as vt,U as wt,Y as K,_ as Ct,nr as Q}from"./createLucideIcon-r3v6fbGz.js";import{o as jt,t as V}from"./router-Bb8nJWyv.js";import{t as Mt}from"./AgentAvatar-PT82VwmU.js";import{t as J}from"./agents-BlSzFh-1.js";import{r as Nt,t as tt}from"./EmptyState-DPcc0zYh.js";import{k as kt,t as et}from"./button-CAPbz11u.js";import{n as Pt,t as Dt}from"./useHiddenSettings-2JpxuJV7.js";import{t as Yt}from"./card-dmVcp3AX.js";import{t as Zt}from"./PageSkeleton-DHjTwRT3.js";import{Dn as rt,On as Et,Pn as Tt,Yt as _t,en as Xt,hn as zt}from"./index-Dgrf6BZM.js";var o=ot(vt(),1),n=ot(bt(),1),N=200,W=100,X=32,$t=80,L=60,Wt=.2,Lt=2,R=6;function Z(e){if(e.reports.length===0)return N;const a=e.reports.reduce((i,f)=>i+Z(f),0),d=(e.reports.length-1)*X;return Math.max(N,a+d)}u(Z,"subtreeWidth");function at(e,a,d){const i=Z(e),f=[];if(e.reports.length>0){const C=e.reports.reduce((k,P)=>k+Z(P),0),S=(e.reports.length-1)*X;let j=a+(i-C-S)/2;for(const k of e.reports){const P=Z(k);f.push(at(k,j,d+W+$t)),j+=P+X}}return{id:e.id,name:e.name,role:e.role,status:e.status,x:a+(i-N)/2,y:d,children:f}}u(at,"layoutTree");function St(e){if(e.length===0)return[];e.reduce((f,C)=>f+Z(C),0),(e.length-1)*X;let a=L;const d=L,i=[];for(const f of e){const C=Z(f);i.push(at(f,a,d)),a+=C+X}return i}u(St,"layoutForest");function Ht(e){const a=[];function d(i){a.push(i),i.children.forEach(d)}return u(d,"walk"),e.forEach(d),a}u(Ht,"flattenLayout");function Rt(e){const a=[];function d(i){for(const f of i.children)a.push({parent:i,child:f}),d(f)}return u(d,"walk"),e.forEach(d),a}u(Rt,"collectEdges");function A(e){return Math.min(Math.max(e,Wt),Lt)}u(A,"clampZoom");function At(e){return{x:e.clientX,y:e.clientY}}u(At,"touchPoint");function nt(e,a){const d=e.clientX-a.clientX,i=e.clientY-a.clientY;return Math.hypot(d,i)}u(nt,"touchDistance");function st(e,a,d){const i=d.getBoundingClientRect();return{x:(e.clientX+a.clientX)/2-i.left,y:(e.clientY+a.clientY)/2-i.top}}u(st,"touchCenter");var Ot={running:"var(--hex-22d3ee)",active:"var(--hex-4ade80)",paused:"var(--hex-facc15)",idle:"var(--hex-facc15)",error:"var(--hex-f87171)",terminated:"var(--hex-a3a3a3)"},Bt="var(--hex-a3a3a3)";function oe(){const{selectedCompanyId:e}=wt(),{setBreadcrumbs:a}=Nt(),d=jt(),i=!!Xt(),{hidden:f}=Dt(),C=!i&&!f.has("company.import"),S=!f.has("company.export"),{data:j,isLoading:k}=Q({queryKey:K.org(e),queryFn:u(()=>J.org(e),"queryFn"),enabled:!!e}),{data:P}=Q({queryKey:K.agents.list(e),queryFn:u(()=>J.list(e),"queryFn"),enabled:!!e}),ct=(0,o.useMemo)(()=>{const t=new Map;for(const r of P??[])t.set(r.id,r);return t},[P]);(0,o.useEffect)(()=>{a([{label:"Org Chart"}])},[a]);const z=(0,o.useMemo)(()=>St(j??[]),[j]),D=(0,o.useMemo)(()=>Ht(z),[z]),it=(0,o.useMemo)(()=>Rt(z),[z]),v=(0,o.useMemo)(()=>{if(D.length===0)return{width:800,height:600};let t=0,r=0;for(const s of D)t=Math.max(t,s.x+N),r=Math.max(r,s.y+W);return{width:t+L,height:r+L}},[D]),p=(0,o.useRef)(null),[l,M]=(0,o.useState)({x:0,y:0}),[h,E]=(0,o.useState)(1),[H,O]=(0,o.useState)(!1),T=(0,o.useRef)({x:0,y:0,panX:0,panY:0}),m=(0,o.useRef)({mode:null,startPoint:{x:0,y:0},startPan:{x:0,y:0},startZoom:1,startDistance:0,startCenter:{x:0,y:0},moved:!1}),$=(0,o.useRef)(!1),Y=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>{Y.current!==null&&window.clearTimeout(Y.current)},[]);const B=(0,o.useRef)(!1);(0,o.useEffect)(()=>{if(B.current||D.length===0||!p.current)return;B.current=!0;const t=p.current,r=t.clientWidth,s=t.clientHeight,c=(r-40)/v.width,x=(s-40)/v.height,g=Math.min(c,x,1),y=v.width*g,w=v.height*g;E(g),M({x:(r-y)/2,y:(s-w)/2})},[D,v]);const lt=(0,o.useCallback)(t=>{t.button===0&&(t.target.closest("[data-org-card]")||(O(!0),T.current={x:t.clientX,y:t.clientY,panX:l.x,panY:l.y}))},[l]),ut=(0,o.useCallback)(t=>{if(!H)return;const r=t.clientX-T.current.x,s=t.clientY-T.current.y;M({x:T.current.panX+r,y:T.current.panY+s})},[H]),q=(0,o.useCallback)(()=>{O(!1)},[]),dt=(0,o.useCallback)(t=>{t.preventDefault();const r=p.current;if(!r)return;const s=r.getBoundingClientRect(),c=t.clientX-s.left,x=t.clientY-s.top,g=t.deltaY<0?1.1:.9,y=A(h*g),w=y/h;M({x:c-w*(c-l.x),y:x-w*(x-l.y)}),E(y)},[h,l]),I=(0,o.useCallback)((t,r)=>{const s=A(t),c=s/h;M({x:r.x-c*(r.x-l.x),y:r.y-c*(r.y-l.y)}),E(s)},[h,l]),ht=(0,o.useCallback)(()=>{if(!p.current)return;const t=p.current.clientWidth,r=p.current.clientHeight,s=(t-40)/v.width,c=(r-40)/v.height,x=Math.min(s,c,1),g=v.width*x,y=v.height*x;E(x),M({x:(t-g)/2,y:(r-y)/2})},[v]),mt=(0,o.useCallback)(t=>{if(t.touches.length>=2&&p.current){const[s,c]=[t.touches[0],t.touches[1]];m.current={mode:"pinch",startPoint:{x:0,y:0},startPan:l,startZoom:h,startDistance:nt(s,c),startCenter:st(s,c,p.current),moved:!1};return}const r=t.touches[0];r&&(m.current={mode:"pan",startPoint:At(r),startPan:l,startZoom:h,startDistance:0,startCenter:{x:0,y:0},moved:!1})},[l,h]),ft=(0,o.useCallback)(t=>{const r=p.current;if(!r||!m.current.mode)return;if(t.touches.length>=2){const[g,y]=[t.touches[0],t.touches[1]],w=nt(g,y),_=st(g,y,r);if(m.current.mode!=="pinch"||m.current.startDistance===0){m.current={mode:"pinch",startPoint:{x:0,y:0},startPan:l,startZoom:h,startDistance:w,startCenter:_,moved:!1};return}const b=m.current,U=A(b.startZoom*(w/b.startDistance)),G=U/b.startZoom,xt=_.x-b.startCenter.x,gt=_.y-b.startCenter.y;b.moved=b.moved||Math.abs(w-b.startDistance)>R||Math.hypot(xt,gt)>R,E(U),M({x:_.x-G*(b.startCenter.x-b.startPan.x),y:_.y-G*(b.startCenter.y-b.startPan.y)});return}const s=t.touches[0];if(!s||m.current.mode!=="pan")return;const c=s.clientX-m.current.startPoint.x,x=s.clientY-m.current.startPoint.y;m.current.moved=m.current.moved||Math.hypot(c,x)>R,M({x:m.current.startPan.x+c,y:m.current.startPan.y+x})},[l,h]),F=(0,o.useCallback)(()=>{m.current.moved&&($.current=!0,Y.current!==null&&window.clearTimeout(Y.current),Y.current=window.setTimeout(()=>{$.current=!1,Y.current=null},400)),m.current={mode:null,startPoint:{x:0,y:0},startPan:l,startZoom:h,startDistance:0,startCenter:{x:0,y:0},moved:!1}},[l,h]);return e?k?(0,n.jsx)(Zt,{variant:"org-chart"}):j&&j.length===0?(0,n.jsx)(tt,{icon:rt,message:"No organizational hierarchy defined."}):(0,n.jsxs)("div",{className:"flex h-(--sz-calc-38) min-h-(--sz-420px) flex-col md:h-full md:min-h-0",children:[(0,n.jsxs)("div",{className:"mb-2 flex shrink-0 flex-wrap items-center justify-start gap-2",children:[C&&(0,n.jsx)(V,{to:"/company/import",children:(0,n.jsxs)(et,{variant:"outline",size:"sm",children:[(0,n.jsx)(zt,{className:"mr-1.5 h-3.5 w-3.5"}),"Import company"]})}),S&&(0,n.jsx)(V,{to:"/company/export",children:(0,n.jsxs)(et,{variant:"outline",size:"sm",children:[(0,n.jsx)(Tt,{className:"mr-1.5 h-3.5 w-3.5"}),"Export company"]})})]}),(0,n.jsxs)("div",{ref:p,"data-testid":"org-chart-viewport",className:"w-full flex-1 min-h-0 overflow-hidden relative bg-muted/20 border border-border rounded-lg",style:{cursor:H?"grabbing":"grab",touchAction:"none",overscrollBehavior:"contain"},onMouseDown:lt,onMouseMove:ut,onMouseUp:q,onMouseLeave:q,onWheel:dt,onTouchStart:mt,onTouchMove:ft,onTouchEnd:F,onTouchCancel:F,children:[(0,n.jsxs)("div",{className:"absolute top-3 right-3 z-10 flex flex-col gap-1.5",children:[(0,n.jsx)("button",{className:"flex size-9 items-center justify-center rounded border border-border bg-background text-sm transition-colors hover:bg-accent sm:size-7",onClick:u(()=>{const t=p.current;t&&I(h*1.2,{x:t.clientWidth/2,y:t.clientHeight/2})},"onClick"),title:"Zoom in","aria-label":"Zoom in",children:(0,n.jsx)(kt,{className:"h-4 w-4 sm:h-3.5 sm:w-3.5"})}),(0,n.jsx)("button",{className:"flex size-9 items-center justify-center rounded border border-border bg-background text-sm transition-colors hover:bg-accent sm:size-7",onClick:u(()=>{const t=p.current;t&&I(h*.8,{x:t.clientWidth/2,y:t.clientHeight/2})},"onClick"),title:"Zoom out","aria-label":"Zoom out",children:(0,n.jsx)(Pt,{className:"h-4 w-4 sm:h-3.5 sm:w-3.5"})}),(0,n.jsx)("button",{className:"flex size-9 items-center justify-center rounded border border-border bg-background text-(length:--text-nano) transition-colors hover:bg-accent sm:size-7",onClick:ht,title:"Fit to screen","aria-label":"Fit chart to screen",children:(0,n.jsx)(Et,{className:"h-4 w-4 sm:h-3.5 sm:w-3.5"})})]}),(0,n.jsx)("svg",{className:"absolute inset-0 pointer-events-none",style:{width:"100%",height:"100%"},children:(0,n.jsx)("g",{transform:`translate(${l.x}, ${l.y}) scale(${h})`,children:it.map(({parent:t,child:r})=>{const s=t.x+N/2,c=t.y+W,x=r.x+N/2,g=r.y,y=(c+g)/2;return(0,n.jsx)("path",{d:`M ${s} ${c} L ${s} ${y} L ${x} ${y} L ${x} ${g}`,fill:"none",stroke:"var(--border)",strokeWidth:1.5},`${t.id}-${r.id}`)})})}),(0,n.jsx)("div",{"data-testid":"org-chart-card-layer",className:"absolute inset-0",style:{transform:`translate(${l.x}px, ${l.y}px) scale(${h})`,transformOrigin:"0 0"},children:D.map(t=>{const r=ct.get(t.id),s=Ot[t.status]??Bt;return(0,n.jsx)(Yt,{"data-org-card":!0,className:"block absolute py-0 hover:shadow-md hover:border-foreground/20 transition-(--tp-box-shadow-border-color) duration-150 cursor-pointer select-none",style:{left:t.x,top:t.y,width:N,minHeight:W},onClick:u(()=>d(r?Ct(r):`/agents/${t.id}`),"onClick"),onClickCapture:u(c=>{$.current&&($.current=!1,c.preventDefault(),c.stopPropagation())},"onClickCapture"),children:(0,n.jsxs)("div",{className:"flex items-center px-4 py-3 gap-3",children:[(0,n.jsxs)("div",{className:"relative shrink-0",children:[(0,n.jsx)("div",{className:"w-9 h-9 rounded-full bg-muted flex items-center justify-center",children:(0,n.jsx)(Mt,{agent:r,size:16,className:"h-4.5 w-4.5 text-foreground/70"})}),(0,n.jsx)("span",{className:"absolute -bottom-0.5 -right-0.5 h-3 w-3 rounded-full border-2 border-card",style:{backgroundColor:s}})]}),(0,n.jsxs)("div",{className:"flex flex-col items-start min-w-0 flex-1",children:[(0,n.jsx)("span",{className:"text-sm font-semibold text-foreground leading-tight",children:t.name}),(0,n.jsx)("span",{className:"text-(length:--text-micro) text-muted-foreground leading-tight mt-0.5",children:r?.title??It(t.role)}),r&&(0,n.jsx)("span",{className:"text-(length:--text-nano) text-muted-foreground/60 font-mono leading-tight mt-1",children:_t(r.adapterType)}),r&&r.capabilities&&(0,n.jsx)("span",{className:"text-(length:--text-nano) text-muted-foreground/80 leading-tight mt-1 line-clamp-2",children:r.capabilities})]})]})},t.id)})})]})]}):(0,n.jsx)(tt,{icon:rt,message:"Select a company to view the org chart."})}u(oe,"OrgChart");var qt=yt;function It(e){return qt[e]??e}u(It,"roleLabel");export{oe as OrgChart};