@tickernelz/paperclip-pro-server 2026.929.4 → 2026.929.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build-info.json +1 -1
- package/dist/routes/issues.d.ts.map +1 -1
- package/dist/routes/issues.js +138 -1
- package/dist/routes/issues.js.map +1 -1
- package/dist/services/issues.d.ts.map +1 -1
- package/dist/services/issues.js +15 -1
- package/dist/services/issues.js.map +1 -1
- package/dist/services/recovery/issue-graph-liveness.d.ts +2 -1
- package/dist/services/recovery/issue-graph-liveness.d.ts.map +1 -1
- package/dist/services/recovery/issue-graph-liveness.js +20 -0
- package/dist/services/recovery/issue-graph-liveness.js.map +1 -1
- package/package.json +21 -21
- package/skills/paperclip/SKILL.md +10 -11
- package/skills/paperclip/references/api-reference.md +9 -7
- package/ui-dist/assets/{Agents.production-DXpBpIOx.js → Agents.production-B1rYmw_F.js} +2 -2
- package/ui-dist/assets/{CompanyActivity.production-B-5rst1B.js → CompanyActivity.production-8_P9Hbf6.js} +1 -1
- package/ui-dist/assets/{CompanyExport-Y9HhGogN.js → CompanyExport-DjCKz1zk.js} +1 -1
- package/ui-dist/assets/{CompanySkills.production-bUTxjLE1.js → CompanySkills.production-BHl_qJmr.js} +1 -1
- package/ui-dist/assets/{Costs.production-ejn6vYm8.js → Costs.production-UXGZUFPU.js} +1 -1
- package/ui-dist/assets/{OrgChart.production-CM87MbOq.js → OrgChart.production-CDnUnIIE.js} +1 -1
- package/ui-dist/assets/{RoutineDetail.production-MnUmgi4u.js → RoutineDetail.production-Bl23zT09.js} +1 -1
- package/ui-dist/assets/{Routines.production-lZoc_mDR.js → Routines.production-BO7eZ9iR.js} +1 -1
- package/ui-dist/assets/{definition-vPsS6JqV.js → definition-fKtTXfBN.js} +1 -1
- package/ui-dist/assets/{index-UH81I0E4.js → index--UKi-wFh.js} +4 -4
- package/ui-dist/index.html +1 -1
- package/ui-dist/sw.js +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/runtime-IAg0vdY9.js","assets/model-DL5biheO.js","assets/definition-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/runtime-IAg0vdY9.js","assets/model-DL5biheO.js","assets/definition-fKtTXfBN.js","assets/character-CguPM7IG.js","assets/prod-COP_vZWu.js","assets/rolldown-runtime-ZpX3ckPj.js","assets/CompanyExport-DjCKz1zk.js","assets/createLucideIcon-r3v6fbGz.js","assets/router-Bb8nJWyv.js","assets/preload-helper-CceJXRIF.js","assets/zap-P-cXfK28.js","assets/agents-BlSzFh-1.js","assets/EmptyState-DPcc0zYh.js","assets/button-CAPbz11u.js","assets/mention-chips-DXumPrOR.js","assets/bot-DZDpMzjD.js","assets/StatusIcon-DgMlA1TU.js","assets/clipboard-CYJ5Q78m.js","assets/loader-circle-BD9wx-lw.js","assets/octagon-alert-rGMwyrWA.js","assets/MarkdownBody-NJwkQWmo.js","assets/check-DDiXDm2i.js","assets/external-link-0lrOvZWO.js","assets/rotate-ccw-CRAQ3Xng.js","assets/PageSkeleton-DHjTwRT3.js","assets/skeleton-CKir8TUW.js","assets/Agents.production-B1rYmw_F.js","assets/AgentAvatar-PT82VwmU.js","assets/tabs-DWRZjksg.js","assets/dist-5v80Jc6A.js","assets/heartbeats-CK_aXmx5.js","assets/triangle-alert-CgJcxSQX.js","assets/SidebarContext-D01pu4wh.js","assets/environments-BVeNFanj.js","assets/Routines.production-BO7eZ9iR.js","assets/RoutineRunVariablesDialog-B1KRZJIl.js","assets/MarkdownEditor-DfrwLv1M.js","assets/dist-D1zgkcBw.js","assets/dist-DCJXgQu0.js","assets/sheet-CQJe5sfn.js","assets/checkbox-757DLJRS.js","assets/chevron-right-B9JUOr38.js","assets/label-BueB30Ch.js","assets/select-mS22eY6T.js","assets/chevron-down-F9aZv-V7.js","assets/useHiddenSettings-2JpxuJV7.js","assets/health-DeeeogeJ.js","assets/badge-Cf7ihb3q.js","assets/input-DpsS9it-.js","assets/company-members-BcZm1g8Q.js","assets/AgentIdentity-MCshmbhZ.js","assets/card-dmVcp3AX.js","assets/RoutineDetail.production-Bl23zT09.js","assets/save-DUnPDT6R.js","assets/CompanySkills.production-BHl_qJmr.js","assets/use-adapter-capabilities-BiWYK4zJ.js","assets/file-text-C9vgFckt.js","assets/CompanyActivity.production-8_P9Hbf6.js","assets/Costs.production-UXGZUFPU.js","assets/OrgChart.production-CDnUnIIE.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
var X_e=Object.defineProperty;var r=(e,s)=>X_e(e,"name",{value:s,configurable:!0});import{i as i5,n as Z_e,t as wv}from"./rolldown-runtime-ZpX3ckPj.js";import{$ as eIe,$n as ZC,$t as gle,A as tIe,An as AR,At as sIe,B as ble,Bn as nIe,Bt as vle,C as rIe,Cn as aIe,Ct as yle,D as _a,Dn as jle,Dt as iIe,E as pu,En as e1,Et as wle,F as QS,Fn as oIe,Fr as lIe,Ft as Nle,G as cIe,Gn as oz,Gt as kle,H as dIe,Hn as uIe,Ht as Sle,I as pS,In as mIe,Ir as Cle,It as hIe,J as lz,Jn as dl,Jt as Bp,K as pIe,Kn as JW,Kt as RR,L as Zu,Lr as cz,Lt as fIe,M as Ua,Mn as o5,Mr as l5,Mt as d2,N as TR,Nn as xIe,Nr as gIe,Nt as u2,O as XW,On as _le,Ot as bIe,P as a0,Pn as t1,Pr as Wt,Pt as ZW,Q as vIe,Qn as ER,Qt as Ile,R as dz,Rn as PR,Rt as aO,S as U,Sn as yIe,St as jIe,T as Gr,Tt as wIe,U as ps,Un as NIe,Ut as kIe,Vn as Ale,Vt as Kb,Wn as $M,Wt as SIe,X as qa,Xn as Re,Xt as MR,Y as P,Yn as wn,Yt as Rle,Z as Tle,Zn as CIe,Zt as s1,_ as Gu,_n as uz,_t as _Ie,an as Ele,at as Ple,b as eH,bn as IIe,bt as AIe,c as RIe,cn as TIe,ct as Mle,d as EIe,dn as PIe,dt as MIe,en as mz,er as DIe,et as Dle,fn as LIe,ft as m2,g as Nc,gn as $Ie,gr as OIe,gt as FIe,h as Nv,hn as BIe,hr as qIe,ht as zIe,i as c5,in as qp,it as tH,j as yh,jn as iO,jt as kj,k as Bi,kn as sH,kt as nH,l as n1,ln as Lle,lt as hz,m as Fw,mn as UIe,mt as KIe,n as rb,nn as VIe,nr as Z,nt as $le,o as WIe,on as rH,ot as HIe,pn as OM,pr as QIe,pt as Bw,q as d5,qn as Ole,qt as GIe,rn as Fle,rr as YIe,rt as GS,s as _b,sn as Ble,st as JIe,t as Gt,tn as pz,tr as Ne,tt as XIe,un as aH,ut as ZIe,v as eAe,vn as tAe,vt as sAe,w as qle,wn as nAe,wt as rAe,x as fz,xn as aAe,xt as iH,y as oH,yn as u5,yt as zle,z as Pr,zn as lH,zt as xz}from"./createLucideIcon-r3v6fbGz.js";import{t as jc}from"./preload-helper-CceJXRIF.js";import{$ as Cd,A as iAe,B as Rt,C as oAe,D as lAe,E as cH,F as dH,G as uH,H as DR,I as Ule,J as mH,K as cAe,L as dAe,M as Kle,N as uAe,O as mAe,P as sI,Q as hAe,R as pAe,S as LR,T as Vle,U as qw,V as $R,W as ml,X as Vg,Y as Vb,Z as po,_ as fAe,a as zw,at as Wle,b as pl,ct as Ai,d as xAe,et as i0,f as Wb,g as gAe,h as bAe,i as vAe,it as na,j as yAe,k as hH,l as jAe,m as Hle,n as o0,nt as wAe,o as Yn,ot as m5,p as h5,q as FM,r as kn,rt as NAe,st as Sa,t as Je,tt as ot,u as gz,v as Qm,w as OR,x as FR,y as kAe,z as Jy}from"./router-Bb8nJWyv.js";import{$ as bz,$n as vz,$t as YS,A as aw,An as Yu,At as bg,B as SAe,Bn as Qle,Bt as Sj,Cn as Gle,Ct as Wg,D as CAe,Dn as Yle,Dt as _Ae,E as IAe,En as Jle,Et as AAe,F as RAe,Fn as Xle,Ft as Zle,G as TAe,Gn as EAe,Gt as ece,H as PAe,Hn as MAe,Ht as tce,I as sce,In as DAe,It as iw,J as oO,Jn as r1,Jt as BR,K as LAe,Kn as nce,Kt as rce,L as $Ae,Ln as pH,Lt as OAe,M as Uw,Mn as Oc,Mt as zl,N as kv,Nn as ace,Nt as Kw,O as Tx,On as Mm,Ot as FAe,P as BAe,Pn as JS,Pt as Cc,Q as qAe,Qn as yz,Qt as ice,R as zAe,Rn as UAe,Rt as KAe,Sn as qR,St as VAe,T as WAe,Tn as oce,Tt as lce,U as HAe,Un as Vw,Ut as cce,V as QAe,Vn as GAe,Vt as YAe,W as dce,Wn as p5,Wt as JAe,X as fH,Xn as XAe,Xt as dx,Y as uce,Yn as Ww,Yt as mce,Z as hce,Zn as pce,Zt as Cj,_ as fce,_n as zR,_r as f5,_t as ZAe,a as e2e,an as xH,ar as Hw,at as t2e,b as s2e,bn as n2e,br as Hg,bt as Qw,c as BM,cn as xce,cr as Wl,ct as gce,d as UR,dn as bce,dr as r2e,dt as vce,en as _j,er as yce,et as jce,f as wce,fn as jz,fr as Nce,ft as wz,g as gH,gn as KR,gr as nf,gt as a2e,h as i2e,hn as kce,hr as Sce,ht as o2e,i as l2e,in as bH,ir as Gw,it as a1,j as vH,jn as lO,jt as Cce,k as _ce,kn as Ice,kt as Ij,l as c2e,ln as d2e,lr as fu,lt as cO,m as VR,mn as WR,mr as u2e,mt as m2e,n as h2e,nn as HR,nr as p2e,nt as f2e,o as x2e,on as g2e,or as sl,ot as b2e,p as Ace,pn as Rce,pr as v2e,pt as y2e,q as j2e,qn as Yw,qt as Tce,r as yx,rn as QR,rr as rf,rt as Rh,s as yH,sn as Ece,sr as nl,st as Pce,t as Nz,tn as Mce,tr as i1,tt as Sv,u as Dce,un as jH,ur as Ex,ut as dO,v as qM,vn as w2e,vr as GR,vt as nc,w as Lce,wn as wH,wt as o1,x as N2e,xn as $ce,xr as l1,xt as c1,y as k2e,yn as S2e,yr as x5,yt as Jw,z as C2e,zn as _2e}from"./RoutineRunVariablesDialog-B1KRZJIl.js";import{$ as Oce,Q as ir,Z as I2e,a as A2e,ct as R2e,et as NH,o as T2e,rt as Fce,s as E2e,tt as hd}from"./mention-chips-DXumPrOR.js";import{g as P2e}from"./dist-D1zgkcBw.js";import{i as M2e}from"./dist-5v80Jc6A.js";import{A as D2e,C as L2e,D as $2e,E as g5,M as Mg,N as Ul,O as $m,S as Do,T as jl,_ as b5,a as af,b as kz,c as v5,f as Dg,g as Dd,h as Bce,j as Aj,k as O2e,l as ua,m as Lg,n as jx,o as Th,p as Eh,r as Hb,s as of,t as kH,v as Ed,x as y5,y as nI}from"./zap-P-cXfK28.js";import{D as F2e,E as B2e,S as q2e,a as qce,c as Qr,d as yc,f as zce,i as z2e,l as wi,m as Qg,o as U2e,p as Px,r as K2e,s as Uce,t as kc,u as Gm,w as V2e,x as W2e}from"./MarkdownEditor-DfrwLv1M.js";import{_ as Sz,a as Kce,b as j5,c as Vce,d as Ph,f as Mh,g as Dh,h as Lh,i as XS,l as $h,m as Oh,n as H2e,o as Fh,p as Bh,r as Qh,s as Ym,t as Gh,u as qh,v as qi,y as Kl}from"./sheet-CQJe5sfn.js";import{a as Gi,c as Q2e,i as d1,l as Hc,n as G2e,o as Yi,r as Bl,s as Wce,t as gr}from"./AgentAvatar-PT82VwmU.js";import{A as Ti,C as di,D as Hce,E as Qce,O as ga,S as ax,T as Gce,_ as Cz,a as Js,b as Xw,c as Cn,d as Cv,f as Wn,g as ba,h as Hn,i as Y2e,k as Ia,l as J2e,m as pd,n as Dn,o as Ln,p as Qn,r as Ys,s as yr,t as $i,u as tn,v as va,w as X2e,x as Ib,y as hs}from"./checkbox-757DLJRS.js";import{_ as So,a as _z,c as w5,d as Uu,f as u1,g as Z2e,h as tx,l as eRe,m as m1,n as _v,o as N5,p as To,r as tRe,s as _i,t as Qs,u as h1,v as k5}from"./label-BueB30Ch.js";import{i as Pa,n as da,r as Vc,t as Ni}from"./tabs-DWRZjksg.js";import{a as Vn,c as ur,i as uO,n as Wc,o as sRe,r as Zn,s as nRe,t as Vt}from"./agents-BlSzFh-1.js";import{S as du,a as Yce,b as eo,d as Jce,f as YR,g as ma,l as Xce,m as _d,n as rRe,o as Zce,p as ede,t as Qi,u as aRe,v as tde,x as rc,y as iRe}from"./StatusIcon-DgMlA1TU.js";import{a as Sl,i as wx,n as Rm,r as Ga,t as Zw}from"./use-adapter-capabilities-BiWYK4zJ.js";import{a as Iv,c as Wu,i as p1,n as oRe,o as ld,r as qn,s as S5,t as Mn}from"./EmptyState-DPcc0zYh.js";import{t as Ji}from"./bot-DZDpMzjD.js";import{t as ds}from"./check-DDiXDm2i.js";import{t as sn}from"./chevron-down-F9aZv-V7.js";import{t as Tn}from"./chevron-right-B9JUOr38.js";import{a as lRe,c as Ma,i as Sn,l as f1,n as Da,o as sde,r as cRe,s as La,t as $a}from"./select-mS22eY6T.js";import{n as ud,r as zi,t as Qp}from"./save-DUnPDT6R.js";import{A as Nx,C as mO,D as dRe,_ as Iz,b as rI,c as uRe,h as mRe,i as hRe,j as ia,k as gn,l as kg,n as pRe,o as fRe,p as hO,r as Az,t as F,u as xRe,y as gRe}from"./button-CAPbz11u.js";import{i as Nr,n as bi,r as Co,t as Yr}from"./clipboard-CYJ5Q78m.js";import{t as xr}from"./external-link-0lrOvZWO.js";import{_ as bRe,a as vRe,b as Zm,c as nde,d as rde,f as yRe,g as jRe,h as Gp,i as wRe,l as NRe,m as kRe,n as ade,o as SRe,p as SH,r as ide,s as CRe,t as $n,u as ode,v as _Re,y as IRe}from"./MarkdownBody-NJwkQWmo.js";import{t as gi}from"./file-text-C9vgFckt.js";import{a as C5,i as $o,n as ARe,o as lde,r as x1,t as sa}from"./heartbeats-CK_aXmx5.js";import{t as at}from"./loader-circle-BD9wx-lw.js";import{n as eN,t as eh}from"./useHiddenSettings-2JpxuJV7.js";import{t as ow}from"./octagon-alert-rGMwyrWA.js";import{t as ki}from"./rotate-ccw-CRAQ3Xng.js";import{t as Is}from"./triangle-alert-CgJcxSQX.js";import{n as Va,t as RRe}from"./SidebarContext-D01pu4wh.js";import{n as TRe,t as lt}from"./badge-Cf7ihb3q.js";import{n as Er,t as Ci}from"./environments-BVeNFanj.js";import{t as At}from"./input-DpsS9it-.js";import{a as lf,i as g1,n as b1,o as hr,r as Mx,t as tN}from"./company-members-BcZm1g8Q.js";import{t as sm}from"./health-DeeeogeJ.js";import{t as jn}from"./skeleton-CKir8TUW.js";import{t as Ld}from"./AgentIdentity-MCshmbhZ.js";import{a as ERe,i as Nl,n as PRe,o as Xi,r as Wa,s as uo,t as Xs}from"./card-dmVcp3AX.js";import{t as ka}from"./PageSkeleton-DHjTwRT3.js";r((function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))a(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const l of o.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&a(l)}).observe(document,{childList:!0,subtree:!0});function n(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}r(n,"getFetchOpts");function a(i){if(i.ep)return;i.ep=!0;const o=n(i);fetch(i.href,o)}r(a,"processPreload")}),"polyfill")();var MRe=class extends QIe{static{r(this,"InfiniteQueryObserver")}constructor(e,s){super(e,s)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type="infinite",super.setOptions(e)}getOptimisticResult(e){return e._type="infinite",super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,s){const{state:n}=e,a=super.createResult(e,s),{isFetching:i,isRefetching:o,isError:l,isRefetchError:c}=a,d=n.fetchMeta?.fetchMore?.direction,m=l&&d==="forward",h=i&&d==="forward",p=l&&d==="backward",f=i&&d==="backward";return{...a,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:qIe(s,n.data),hasPreviousPage:OIe(s,n.data),isFetchNextPageError:m,isFetchingNextPage:h,isFetchPreviousPageError:p,isFetchingPreviousPage:f,isRefetchError:c&&!m&&!p,isRefetching:o&&!h&&!f}}};function Av(e,s){return YIe(e,MRe,s)}r(Av,"useInfiniteQuery");var DRe="adapter_auth_missing",LRe="document",$Re=80,ORe={markdown:"md",html:"html",json:"json",text:"txt"};function FRe(e){return e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,$Re).replace(/-+$/g,"")||LRe}r(FRe,"documentExportSlug");function BRe(e){return ORe[(e??"").trim().toLowerCase()]??"md"}r(BRe,"documentExportExtension");function CH(e,s){const n=s.replace(/^\.+/,"").toLowerCase()||"md";return`${FRe(e)}.${n}`}r(CH,"documentExportFileName");function pO(e){const s=new Set([e.targetIssueId]);if(e.type==="create_issue"){e.draft.parentId&&s.add(e.draft.parentId);for(const n of e.draft.blockedByIssueIds??[])s.add(n)}if(e.type==="resolve_blocker")for(const n of e.removeBlockedByIssueIds)s.add(n);return[...s]}r(pO,"decisionEffectTargetIssueIds");var qRe=new Set(["terminated","pending_approval","paused"]),zRe=new Set(["active","idle","running","error"]);function URe(e){return zRe.has(e)&&!qRe.has(e)}r(URe,"isAgentStatusInvokable");function YN(e){return e==="done"||e==="cancelled"}r(YN,"isPipelineTerminalStageKind");function cde(e){const s={};for(const n of e)(s[n.stageId]??=[]).push(n);return s}r(cde,"groupWarningsByStage");function dde(e){return e==="RESPONSIBLE_USER_UNAUTHORIZED"||e==="RESPONSIBLE_USER_UNAVAILABLE"}r(dde,"isResponsibleUserDenialCode");function v1(e){const s=e?.trim();return s&&s.length>0?s:"the responsible user"}r(v1,"responsibleUserLabel");function fO(e,s={}){const n=v1(s.userName);return e==="RESPONSIBLE_USER_UNAVAILABLE"?{code:e,tone:"unavailable",title:"Responsible user unavailable",description:`This run acts on behalf of ${n}, but that account was removed or deactivated, so its permissions can no longer be evaluated. The agent's own permissions are not enough on their own — every action still requires an active responsible user.`,recommendedAction:"Mark the work blocked and reassign a responsible user (or reactivate the account) before the agent continues."}:{code:e,tone:"unauthorized",title:"Responsible user not authorized",description:`This action was denied because ${n} — the user this run acts on behalf of — does not have permission to perform it. The agent may be allowed, but a run can never exceed the permissions of the user it acts for, so the action is blocked.`,recommendedAction:`Grant ${n} the required permission, or have someone who is authorized take this action instead.`}}r(fO,"describeResponsibleUserDenial");var KRe=["issue_write_not_visible","issue_write_actor_class_excluded","issue_write_responsible_user_ceiling","issue_write_responsible_user_unavailable","issue_write_assignee_run_lock","cross_issue_influence_cap_exceeded","cross_issue_influence_run_context_required","issue_write_attribution_spoof_rejected"];function VRe(e){const s=e?.trim();return s&&s.length>0?s:"this task"}r(VRe,"issueLabel$2");function WRe(e){const s=e?.trim();return s&&s.length>0?s:"the current assignee"}r(WRe,"assigneeLabel");function HRe(e){const s=e?.trim();return s&&s.length>0?s:"this agent"}r(HRe,"actorLabel$1");var QRe="create a child issue with the request in its description (issue creation is a separate, open write path) and let its assignee act";function GRe(e,s={}){const n=VRe(s.issueIdentifier),a=HRe(s.actorLabel),i=WRe(s.assigneeLabel),o=v1(s.responsibleUserName);switch(e){case"issue_write_not_visible":return{code:e,status:403,tone:"boundary",boundary:"Issue visibility",title:"Task is outside this actor's visibility",description:`Issue writes are open by default, but only for tasks the actor can already read. ${n} is not visible to ${a}, so its comment, update, child, and assignment channels are all closed — the wall is visibility, not the write itself.`,whoCanAct:`${i}, and any agent or board member the task is visible to.`,sanctionedPath:`Ask the board to widen visibility for ${a}, or ${QRe}.`};case"issue_write_actor_class_excluded":return{code:e,status:403,tone:"boundary",boundary:"Actor-class boundary",title:"This actor class cannot write to tasks",description:`Default-open issue writes are a standard-trust privilege. Low-trust, skill-test, and task-bridge scopes keep their existing tight walls, so ${a} cannot write to ${n} no matter who it acts for.`,whoCanAct:"A standard-trust agent in this company, or a board member.",sanctionedPath:"Report the request upward and let a standard-trust agent make the write — actor-class scope cannot be widened per task."};case"issue_write_responsible_user_ceiling":{const l=fO("RESPONSIBLE_USER_UNAUTHORIZED",{userName:s.responsibleUserName});return{code:e,status:403,tone:"boundary",boundary:"Responsible-user ceiling",title:l.title,description:`${l.description} The write to ${n} was refused for that reason.`,whoCanAct:`${o} once authorized, or anyone already permitted to write to ${n}.`,sanctionedPath:l.recommendedAction}}case"issue_write_responsible_user_unavailable":{const l=fO("RESPONSIBLE_USER_UNAVAILABLE",{userName:s.responsibleUserName});return{code:e,status:403,tone:"boundary",boundary:"Responsible-user availability",title:l.title,description:`${l.description} The write to ${n} was refused for that reason.`,whoCanAct:`A board member, or ${a} once it has an active responsible user.`,sanctionedPath:l.recommendedAction}}case"issue_write_assignee_run_lock":return{code:e,status:409,tone:"lock",boundary:"Run checkout lock",title:"Another agent's run owns this task",description:`${i} has ${n} checked out and a run is live. Checkout and run ownership stay assignee-scoped even though writes are open, so field edits belong to the run that holds the lock until it finishes.`,whoCanAct:`${i}'s live run, or an agent holding the manage-active-checkouts permission.`,sanctionedPath:`Comment instead of patching — comments stay open and wake ${i} — or wait for the run to release the lock and retry.`};case"cross_issue_influence_cap_exceeded":{const l=s.cap??20,c=s.count??null;return{code:e,status:429,tone:"cap",boundary:`Per-run cross-issue cap of ${l} writes`,title:"This run has spent its cross-issue write budget",description:`A single heartbeat run may make at most ${l} cross-issue comments or task updates combined${c!==null?`; this was attempt ${c}`:""}. The cap bounds runaway comment sprays and loops — it is a rate backstop, not a permission decision, so ${a} is still allowed to write to ${n}.`,whoCanAct:`${a} on its next heartbeat run, or ${i} on ${n} directly.`,sanctionedPath:"Consolidate what is left into one comment on your own task, or end the run and continue on the next heartbeat — the budget resets per run."}}case"cross_issue_influence_run_context_required":return{code:e,status:403,tone:"boundary",boundary:"Heartbeat run context",title:"Cross-issue writes need a run to attribute them to",description:"Every agent comment and task update is attributed to a heartbeat run so the cross-issue cap can be counted and the audit trail can name who acted for whom. This request arrived without a valid run, so it could not be contained.",whoCanAct:`${a}, once the request carries its own run id.`,sanctionedPath:"Send the `X-Paperclip-Run-Id` header with your current run (`$PAPERCLIP_RUN_ID`) and retry."};case"issue_write_attribution_spoof_rejected":return{code:e,status:422,tone:"attribution",boundary:"Server-derived attribution",title:"Responsible user cannot be chosen by the caller",description:"`onBehalfOfUserId` is derived from the authenticated actor, never from the request body — an agent cannot pick the human whose authority it rides. The attempt was recorded in the audit log.",whoCanAct:`${a} itself: the write is allowed, only the chosen attribution is not.`,sanctionedPath:`Remove \`onBehalfOfUserId\` from the request and retry; the server fills in ${o} from your run.`}}}r(GRe,"describeIssueWriteDenial");function ude(e){return(typeof e=="string"?e:e?.name??"").trim()}r(ude,"rawNameOf");function mde(e){const s=e.toLowerCase();return!!(s.includes("://")||s==="localhost"||s.startsWith("localhost:")||/^\d{1,3}(\.\d{1,3}){3}(:\d+)?$/.test(s)||/^[a-z0-9.-]+:\d+$/.test(s))}r(mde,"looksLikeNetworkAddress");function xO(e){return e.split(/[\s._-]+/).filter(Boolean).map(s=>s.charAt(0).toUpperCase()+s.slice(1).toLowerCase()).join(" ")}r(xO,"titleCaseIdentifier");function YRe(e){const s=/^plugin:\s*(.+)$/i.exec(e);if(!s)return null;let n=s[1].trim();return n=n.slice(n.lastIndexOf(".")+1),n=n.replace(/^plugin[-_]/i,""),xO(n)||"Custom app"}r(YRe,"pluginPackageLabel");function cf(e,s={}){const n=s.title?.trim();if(n)return n;const a=ude(e);if(!a||mde(a))return"Custom app";const i=YRe(a);if(i)return i;if(a.includes(":")&&!a.includes("://")){const o=a.slice(a.lastIndexOf(":")+1).trim();if(o)return xO(o)}return/\s/.test(a)||/[A-Z]/.test(a)?a:/[._-]/.test(a)?xO(a):a}r(cf,"humanizeConnectionDisplayName");function _H(e){const s=ude(e);return s&&mde(s)?`hosted at ${s}`:null}r(_H,"connectionDisplaySecondaryHint");var IH=`I want to connect an MCP (Model Context Protocol) server to Paperclip, and I need a paste-ready config.
|
|
3
3
|
|
|
4
4
|
Target server: <name the server, or ask me if I have not said>
|
|
@@ -284,7 +284,7 @@ self.onmessage = function (e) {
|
|
|
284
284
|
}
|
|
285
285
|
|
|
286
286
|
};
|
|
287
|
-
`;function PHe(){const e=new Blob([EHe],{type:"application/javascript"}),s=URL.createObjectURL(e);try{return new Worker(s)}finally{URL.revokeObjectURL(s)}}r(PHe,"createSandboxedWorker");var DF=new Map,FT=new Map,E2=new Set,P2=new Map,Zfe=null;function MHe(e){Zfe=e}r(MHe,"setDynamicParserResultNotifier");function exe(e,s){e.worker.postMessage(s)}r(exe,"sendToWorker");function DHe(e){return e.nextId++}r(DHe,"nextRequestId");function LHe(e,s){return`${s}\0${e}`}r(LHe,"lineCacheKey");function $He(){Zfe?.()}r($He,"notifyResultReady");function OHe(e,s,n){return new Promise(a=>{const i=DHe(e);e.pendingResolves.set(i,a),exe(e,{type:"parse",id:i,line:s,ts:n})})}r(OHe,"parseLineAsync");function zk(e){for(const s of e.pendingResolves.values())s([]);e.pendingResolves.clear()}r(zk,"drainPendingRequests");function FHe(e){return new Promise((s,n)=>{const a=PHe(),i={worker:a,ready:!1,nextId:1,pendingResolves:new Map},o=setTimeout(()=>{zk(i),a.terminate(),n(new Error("Parser worker init timed out"))},5e3);a.onmessage=l=>{const c=l.data;if(c.type==="ready"){clearTimeout(o),i.ready=!0,a.onmessage=d=>{const m=d.data;if(m.type==="result"){const h=i.pendingResolves.get(m.id);h&&(i.pendingResolves.delete(m.id),h(m.entries))}else m.type==="error"&&zk(i)},s(i);return}if(c.type==="error"){clearTimeout(o),zk(i),a.terminate(),n(new Error(c.message));return}},a.onerror=l=>{clearTimeout(o),zk(i),a.terminate(),n(new Error(`Worker error: ${l.message}`))},exe(i,{type:"init",source:e})})}r(FHe,"initSandboxedWorker");function BHe(e){const s=new Map,n=new Set;return{parseStdoutLine:r((i,o)=>{const l=LHe(i,o),c=s.get(l);return c?c.slice():(n.has(l)||(n.add(l),OHe(e,i,o).then(d=>{n.delete(l),s.set(l,d),$He()})),[])},"parseStdoutLine")}}r(BHe,"buildParserModule");async function LF(e){const s=FT.get(e);if(s)return s;if(E2.has(e))return null;const n=P2.get(e);if(n)return n;const a=(async()=>{try{const i=await fetch(`/api/adapters/${encodeURIComponent(e)}/ui-parser.js`);if(!i.ok)return E2.add(e),null;const o=await FHe(await i.text());DF.set(e,o);const l=BHe(o);return FT.set(e,l),l}catch{return E2.add(e),null}finally{P2.delete(e)}})();return P2.set(e,a),a}r(LF,"loadDynamicParser");function $F(e){const s=FT.has(e);FT.delete(e),E2.delete(e),P2.delete(e);const n=DF.get(e);return n&&(zk(n),n.worker.terminate(),DF.delete(e)),s}r($F,"invalidateDynamicParser");var M2=[],mE=new Map,OF=new Set,txe=new Map,F4=new Set,vI=new Map,FF=new Set;function sxe(e){return FF.add(e),()=>FF.delete(e)}r(sxe,"onAdapterChange");function nxe(){for(const e of FF)e()}r(nxe,"notifyAdapterChange");MHe(nxe);function qHe(){for(const e of[S9e,F9e,rVe,dVe,PVe,WVe,rWe,hWe,kWe,MWe,rHe,JWe,NVe,yHe,OT,THe])OF.add(e.type),txe.set(e.type,e),ob(e)}r(qHe,"registerBuiltInUIAdapters");function ob(e){const s=M2.findIndex(n=>n.type===e.type);s>=0?M2.splice(s,1,e):M2.push(e),mE.set(e.type,e),nxe()}r(ob,"registerUIAdapter");function rxe(e){return mE.get(e)??null}r(rxe,"findUIAdapter");qHe();function uN(e){const s=mE.get(e);if(!s){let n=!1;return{type:e,label:e,parseStdoutLine:r((a,i)=>(n||(n=!0,LF(e).then(o=>{o&&ob({type:e,label:e,parseStdoutLine:o.parseStdoutLine,createStdoutParser:o.createStdoutParser,ConfigFields:nv,buildAdapterConfig:bw})})),OT.parseStdoutLine(a,i)),"parseStdoutLine"),ConfigFields:nv,buildAdapterConfig:bw}}return s}r(uN,"getUIAdapter");function zHe(e){const s=new Set(e.filter(a=>!a.disabled&&!a.overrideDisabled).map(a=>a.type)),n=new Set(e.map(a=>a.type));for(const a of OF){const i=txe.get(a);if(!i)continue;const o=n.has(a),l=s.has(a),c=F4.has(a);if(o&&l&&!c){F4.add(a);const d=(vI.get(a)??0)+1;vI.set(a,d);let m=!1;const h=i.parseStdoutLine,p=e.find(f=>f.type===a)?.label??a;ob({type:a,label:p,parseStdoutLine:r((f,g)=>(m||(m=!0,LF(a).then(v=>{v&&vI.get(a)===d&&ob({type:a,label:p,parseStdoutLine:v.parseStdoutLine,createStdoutParser:v.createStdoutParser,ConfigFields:i.ConfigFields,buildAdapterConfig:i.buildAdapterConfig})})),h(f,g)),"parseStdoutLine"),ConfigFields:i.ConfigFields,buildAdapterConfig:i.buildAdapterConfig})}else(!o||!l)&&c&&(F4.delete(a),vI.delete(a),$F(a),ob(i))}for(const{type:a,label:i}of e){if(OF.has(a))continue;const o=mE.get(a);if(o&&o!==OT)continue;let l=!1;const c=o?.parseStdoutLine??OT.parseStdoutLine;ob({type:a,label:i,parseStdoutLine:r((d,m)=>(l||(l=!0,LF(a).then(h=>{h&&ob({type:a,label:i,parseStdoutLine:h.parseStdoutLine,createStdoutParser:h.createStdoutParser,ConfigFields:o?.ConfigFields??nv,buildAdapterConfig:o?.buildAdapterConfig??bw})})),c(d,m)),"parseStdoutLine"),ConfigFields:o?.ConfigFields??nv,buildAdapterConfig:o?.buildAdapterConfig??bw})}}r(zHe,"syncExternalAdapters");function xK(){return[...M2]}r(xK,"listUIAdapters");function BF(e){if(typeof e=="function")return{parseLine:e,reset:null};if(e.createStdoutParser){const s=e.createStdoutParser();return{parseLine:s.parseLine,reset:s.reset}}return{parseLine:e.parseStdoutLine,reset:null}}r(BF,"resolveStdoutParser");function axe(e,s){if((s.kind==="thinking"||s.kind==="assistant")&&s.delta){const n=e[e.length-1];if(n&&n.kind===s.kind&&n.delta&&n.channel===s.channel){n.text+=s.text,n.ts=s.ts;return}}e.push(s)}r(axe,"appendTranscriptEntry");function UHe(e,s){for(const n of s)axe(e,n)}r(UHe,"appendTranscriptEntries");function KHe(e,s=160){return e.length<=s?e:`${e.slice(0,s-3)}...`}r(KHe,"truncateTranscriptLine");function VHe(e){if(e instanceof Error&&e.message)return e.message;if(typeof e=="string"&&e)return e;try{return JSON.stringify(e)}catch{return String(e)}}r(VHe,"formatTranscriptParserError");function WHe(e,s,n,a){const i=VHe(n)||"unknown parser error",o=KHe(e);return{kind:"result",ts:s,text:Ku(`Chat transcript error: ${i}. Falling back for line: ${o}`,a),inputTokens:0,outputTokens:0,cachedTokens:0,costUsd:0,subtype:"transcript_parse_error",isError:!0,errors:[]}}r(WHe,"createTranscriptParseErrorEntry");function gK(e){const{entries:s,line:n,ts:a,parseLine:i,reset:o,redactionOptions:l}=e;try{UHe(s,i(n,a).map(c=>gBe(c,l)))}catch(c){o?.(),axe(s,WHe(n,a,c,l))}}r(gK,"appendParsedTranscriptLine");function ixe(e){const{entries:s,chunks:n,from:a,parseLine:i,reset:o,redactionOptions:l}=e;let c=e.stdoutBuffer;for(let d=a;d<n.length;d+=1){const m=n[d];if(m.stream==="stderr"){s.push({kind:"stderr",ts:m.ts,text:Ku(m.chunk,l)});continue}if(m.stream==="system"){s.push({kind:"system",ts:m.ts,text:Ku(m.chunk,l)});continue}const h=(c+m.chunk).split(/\r?\n/);c=h.pop()??"";for(const p of h){const f=p.trim();f&&gK({entries:s,line:f,ts:m.ts,parseLine:i,reset:o,redactionOptions:l})}}return c}r(ixe,"foldTranscriptChunks");function oxe(e,s,n){const a=[],i={enabled:n?.censorUsernameInLogs??!1},{parseLine:o,reset:l}=BF(s),c=ixe({entries:a,chunks:e,from:0,stdoutBuffer:"",parseLine:o,reset:l,redactionOptions:i}).trim();return c&&gK({entries:a,line:c,ts:e.length>0?e[e.length-1].ts:new Date().toISOString(),parseLine:o,reset:l,redactionOptions:i}),l?.(),a}r(oxe,"buildTranscript");var XY=[];function HHe(e,s){const n={enabled:s?.censorUsernameInLogs??!1},a=typeof e!="function"&&typeof e.createStdoutParser=="function";let i=BF(e),o=[],l="",c=XY,d=[];const m=r(()=>{i=BF(e),o=[],l="",c=XY},"restart"),h=r(f=>{if(f.length<c.length)return!1;for(let g=0;g<c.length;g+=1)if(f[g]!==c[g])return!1;return!0},"extendsFolded"),p=r(f=>{const g=l.trim();if(g&&a)return oxe(f,e,s);const v=o.slice(),y=v.length-1;return y>=0&&(v[y]={...v[y]}),g&&gK({entries:v,line:g,ts:f.length>0?f[f.length-1].ts:new Date().toISOString(),parseLine:i.parseLine,reset:i.reset,redactionOptions:n}),v},"publish");return{update(f){return f===c||(h(f)||m(),l=ixe({entries:o,chunks:f,from:c.length,stdoutBuffer:l,parseLine:i.parseLine,reset:i.reset,redactionOptions:n}),c=f,d=p(f)),d}}}r(HHe,"createIncrementalTranscript");function QHe({agents:e,value:s,onChange:n,disabled:a=!1,excludeAgentIds:i=[],disabledEmptyLabel:o="Reports to: N/A (CEO)",chooseLabel:l="Reports to..."}){const[c,d]=(0,u.useState)(!1),m=new Set(i),h=e.filter(v=>v.status!=="terminated"&&!m.has(v.id)),p=s?e.find(v=>v.id===s):null,f=p?.status==="terminated",g=!!(s&&!p);return(0,t.jsxs)(Zn,{open:c,onOpenChange:d,children:[(0,t.jsx)(ur,{asChild:!0,children:(0,t.jsx)("button",{type:"button",className:U("inline-flex max-w-full min-w-0 items-center gap-1.5 overflow-hidden rounded-md border border-border px-2 py-1 text-xs hover:bg-accent/50 transition-colors",f&&"border-amber-600/45 bg-amber-500/5",a&&"opacity-60 cursor-not-allowed"),disabled:a,children:g?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(yc,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),(0,t.jsx)("span",{className:"min-w-0 truncate text-muted-foreground",children:"Unknown manager (stale ID)"})]}):p?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(gr,{agent:p,size:16,className:"h-3 w-3 shrink-0 text-muted-foreground"}),(0,t.jsx)("span",{className:U("min-w-0 truncate",f&&"text-amber-900 dark:text-amber-200"),children:`Reports to ${p.name}${f?" (terminated)":""}`})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(yc,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),(0,t.jsx)("span",{className:"min-w-0 truncate",children:a?o:l})]})})}),(0,t.jsxs)(Vn,{className:"w-48 p-1",align:"start",children:[(0,t.jsx)("button",{type:"button",className:U("flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50",s===null&&"bg-accent"),onClick:r(()=>{n(null),d(!1)},"onClick"),children:"No manager"}),f&&(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden px-2 py-1.5 text-xs text-muted-foreground border-b border-border mb-0.5",children:[(0,t.jsx)(gr,{agent:p,size:16,className:"shrink-0 h-3 w-3"}),(0,t.jsxs)("span",{className:"min-w-0 truncate",children:["Current: ",p.name," (terminated)"]})]}),g&&(0,t.jsx)("div",{className:"px-2 py-1.5 text-xs text-muted-foreground border-b border-border mb-0.5",children:"Saved manager is missing from this organization. Choose a new manager or clear."}),h.map(v=>(0,t.jsxs)("button",{type:"button",className:U("flex items-center gap-2 w-full min-w-0 px-2 py-1.5 text-xs rounded hover:bg-accent/50 overflow-hidden",v.id===s&&"bg-accent"),onClick:r(()=>{n(v.id),d(!1)},"onClick"),children:[(0,t.jsx)(gr,{agent:v,size:16,className:"shrink-0 h-3 w-3 text-muted-foreground"}),(0,t.jsx)("span",{className:"min-w-0 truncate",children:v.name}),(0,t.jsx)("span",{className:"text-muted-foreground ml-auto shrink-0",children:mK[v.role]??v.role})]},v.id))]})]})}r(QHe,"ReportsToPicker");var GHe="__secret_folder__:";function YHe(e){return!e||e==="active"?null:(0,t.jsx)(lt,{variant:"outline",className:"ml-auto text-(length:--text-nano) font-normal text-muted-foreground",children:e})}r(YHe,"statusBadge");function lxe(e){return e.split("/").filter(s=>s.length>0)}r(lxe,"splitSecretPath$1");function D2(e){return e.join("/")}r(D2,"pathKey$1");function sk(e){return e.length>0?`/${e.join("/")}`:"/"}r(sk,"pathLabel");function JHe(e,s){return e.length<s.length?!1:s.every((n,a)=>e[a]===n)}r(JHe,"pathStartsWith");function ZY(e){return`${GHe}${D2(e)}`}r(ZY,"folderValue");function XHe(e,s,n){const a=s.length,i=new Map,o=[];for(const c of e){const d=lxe(c.name);if(JHe(d,s)){if(d.length>a+1){const m=d.slice(0,a+1),h=D2(m);if(!i.has(h)){const p=m[m.length-1]??"/",f=sk(m);i.set(h,{key:`folder-${h||"root"}`,value:ZY(m),label:p,title:f,searchText:f,kind:"folder",folderPath:h,pathHint:f})}continue}if(d.length===a+1||a===0&&d.length===0){const m=d.at(-1)??c.name;o.push({key:`browse-${c.id}`,value:c.id,label:m,title:c.name,searchText:`${c.key} ${c.name}`,secret:c,status:c.status,kind:"secret",pathHint:c.name,disabled:c.status!=="active"&&c.id!==n})}}}const l=[];if(s.length>0){const c=s.slice(0,-1);l.push({key:`folder-up-${D2(s)}`,value:ZY(c),label:"Up one folder",title:sk(c),searchText:sk(c),kind:"back",folderPath:D2(c),pathHint:sk(c)})}return l.push(...i.values(),...o),{id:"browse-secrets",label:s.length>0?sk(s):"Browse secrets",options:l}}r(XHe,"buildFolderGroup");function bK({secretId:e,secrets:s,recentlyUsedSecrets:n,disabled:a,onSelect:i,onCreateNew:o,triggerClassName:l,disablePortal:c}){const[d,m]=(0,u.useState)(""),h=(0,u.useMemo)(()=>s.find(w=>w.id===e)??null,[s,e]),p=!!e&&!h,f=(0,u.useMemo)(()=>d?d.split("/"):[],[d]),g=(0,u.useMemo)(()=>s.some(w=>lxe(w.name).length>1),[s]),v=(0,u.useMemo)(()=>{const w=[];p&&w.push({id:"current-missing",label:"Current",options:[{key:`missing-${e}`,value:e,label:`Missing secret (${e.slice(0,8)}…)`,title:`Missing secret (${e})`,missing:!0,disabled:!0}]});const S=(n??[]).filter(j=>j.status==="active"&&j.id!==e);return S.length>0&&w.push({id:"recently-used",label:"Recently used",options:S.map(j=>({key:`recent-${j.id}`,value:j.id,label:j.name,title:j.name,searchText:`${j.key} ${j.name}`,secret:j,status:j.status,kind:"secret"}))}),w.push({id:"all-secrets",label:S.length>0?"All secrets":void 0,options:s.map(j=>({key:`all-${j.id}`,value:j.id,label:j.name,title:j.name,searchText:`${j.key} ${j.name}`,secret:j,status:j.status,kind:"secret",disabled:j.status!=="active"&&j.id!==e}))}),w},[p,n,e,s]),y=(0,u.useCallback)((w,S)=>{if(!g||tRe(w))return S;const j=XHe(s,f,e),N=S.filter(_=>_.id==="current-missing"||_.id==="recently-used");return j.options.length>0?[...N,j]:N},[f,g,e,s]);return(0,t.jsx)(_v,{value:e||"",groups:v,onValueChange:r((w,S)=>{if(S.folderPath!==void 0)return m(S.folderPath),!1;m(""),i(w)},"onValueChange"),deriveGroups:y,disabled:a,disablePortal:c,placeholder:"Select secret…",searchPlaceholder:"Search secrets…",emptyMessage:"No matching secrets",triggerClassName:U("h-(--sz-34px) min-h-(--sz-34px) font-mono text-sm",p&&"border-destructive text-destructive",h&&h.status!=="active"&&"border-amber-500/60",l),renderValue:r(w=>{if(!w)return(0,t.jsx)("span",{className:"text-muted-foreground",children:"Select secret…"});if(w.missing)return(0,t.jsxs)("span",{className:"flex w-full min-w-0 items-center gap-1.5 text-destructive",children:[(0,t.jsx)(bi,{className:"size-3.5 shrink-0"}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:w.label})]});const S=w.status&&w.status!=="active";return(0,t.jsxs)("span",{className:"flex w-full min-w-0 items-center gap-1.5",title:w.title,children:[(0,t.jsx)(bi,{className:U("size-3.5 shrink-0",S?"text-amber-600":"text-muted-foreground")}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:w.label}),S?(0,t.jsxs)("span",{className:"text-amber-600",children:["(",w.status,")"]}):null]})},"renderValue"),renderOption:r((w,{selected:S})=>{if(w.kind==="folder"||w.kind==="back"){const j=w.kind==="back"?B3e:Wc;return(0,t.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",title:w.title??w.label,children:[(0,t.jsx)(j,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,t.jsxs)("span",{className:"flex min-w-0 flex-col",children:[(0,t.jsx)("span",{className:U("truncate text-sm",S&&"font-medium"),children:w.label}),w.pathHint?(0,t.jsx)("span",{className:"truncate font-mono text-(length:--text-micro) text-muted-foreground",children:w.pathHint}):null]})]})}return(0,t.jsxs)("span",{className:U("flex min-w-0 flex-1 items-center gap-1.5",w.disabled&&"opacity-60"),title:w.title??w.label,children:[(0,t.jsx)(bi,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,t.jsxs)("span",{className:"flex min-w-0 flex-col",children:[(0,t.jsx)("span",{className:U("min-w-0 truncate font-mono text-sm",S&&"font-medium"),children:w.label}),w.pathHint&&w.pathHint!==w.label?(0,t.jsx)("span",{className:"truncate font-mono text-(length:--text-micro) text-muted-foreground",children:w.pathHint}):null]}),YHe(w.status)]})},"renderOption"),createItem:o?{render:r(w=>(0,t.jsxs)("span",{className:"flex items-center gap-1.5 text-sm",children:[(0,t.jsx)(gn,{className:"size-3.5 shrink-0"}),w.trim()?(0,t.jsxs)("span",{children:["Create secret ",(0,t.jsxs)("span",{className:"font-mono",children:["“",w.trim(),"”"]}),"…"]}):(0,t.jsx)("span",{children:"Create new secret…"})]}),"render"),onSelect:r(w=>o(w),"onSelect")}:void 0})}r(bK,"SecretPicker");var ZHe=/^[a-z][a-z0-9_]*$/,eJ="w-full rounded-md border border-border px-2.5 py-1.5 bg-transparent outline-none text-sm font-mono placeholder:text-muted-foreground/40 focus-visible:ring-2 focus-visible:ring-ring/40";function cxe({mode:e,initialName:s,initialValue:n,existingSecretNames:a,onCancel:i,onSubmit:o}){const[l,c]=(0,u.useState)(s),[d,m]=(0,u.useState)(n),[h,p]=(0,u.useState)(!1),[f,g]=(0,u.useState)(!1),[v,y]=(0,u.useState)(null),[w,S]=(0,u.useState)(!1),j=l.trim(),N=j?ZHe.test(j)?a?.some(T=>T.toLowerCase()===j)?"A secret with this name already exists":null:"Use lowercase letters, digits and _":w?"Name is required":null,_=d.length===0&&w?"Value is required":null,R=!f&&j.length>0&&d.length>0&&!N;async function C(){if(S(!0),!!R){g(!0),y(null);try{await o(j,d)}catch(T){y(T instanceof Error?T.message:"Failed to create secret"),g(!1)}}}r(C,"handleSubmit");const A=e==="create"?"Create & bind":"Store & bind";return(0,t.jsxs)("div",{className:"w-72 space-y-3",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(nRe,{className:"text-sm font-medium",children:e==="create"?"Create secret":"Store value as secret"}),e==="store"?(0,t.jsxs)(sRe,{className:"text-(length:--text-micro) text-muted-foreground",children:["Moves the typed value into an encrypted organization secret and binds"," ",(0,t.jsx)("span",{className:"font-mono",children:s||"this variable"})," to it."]}):null]}),(0,t.jsxs)("label",{className:"block space-y-1",children:[(0,t.jsx)("span",{className:"text-(length:--text-micro) font-medium text-muted-foreground",children:"Name"}),(0,t.jsx)("input",{className:U(eJ,N&&"border-destructive focus-visible:ring-destructive/40"),value:l,autoFocus:!0,spellCheck:!1,placeholder:"secret_name","aria-label":"Secret name","aria-invalid":N?!0:void 0,onChange:r(T=>c(T.target.value),"onChange"),onBlur:r(()=>S(!0),"onBlur"),onKeyDown:r(T=>{T.key==="Enter"&&(T.preventDefault(),C())},"onKeyDown")}),N?(0,t.jsx)("span",{className:"block text-(length:--text-micro) text-destructive",children:N}):null]}),(0,t.jsxs)("label",{className:"block space-y-1",children:[(0,t.jsx)("span",{className:"text-(length:--text-micro) font-medium text-muted-foreground",children:"Value"}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("input",{className:U(eJ,"pr-8",_&&"border-destructive focus-visible:ring-destructive/40"),type:h?"text":"password",value:d,readOnly:e==="store",spellCheck:!1,placeholder:e==="create"?"value":void 0,"aria-label":"Secret value","aria-invalid":_?!0:void 0,onChange:e==="create"?T=>m(T.target.value):void 0}),(0,t.jsx)("button",{type:"button",className:"absolute right-1.5 top-1/2 -translate-y-1/2 rounded p-1 text-muted-foreground hover:text-foreground","aria-label":h?"Hide value":"Show value",onClick:r(()=>p(T=>!T),"onClick"),children:h?(0,t.jsx)(Jm,{className:"h-3.5 w-3.5"}):(0,t.jsx)(hd,{className:"h-3.5 w-3.5"})})]}),_?(0,t.jsx)("span",{className:"block text-(length:--text-micro) text-destructive",children:_}):null]}),v?(0,t.jsx)("p",{className:"text-(length:--text-micro) text-destructive",children:v}):null,(0,t.jsxs)("div",{className:"flex items-center justify-end gap-2 pt-0.5",children:[(0,t.jsx)(F,{type:"button",variant:"ghost",size:"sm",onClick:i,disabled:f,children:"Cancel"}),(0,t.jsxs)(F,{type:"button",size:"sm",onClick:r(()=>{C()},"onClick"),disabled:!R,children:[f?(0,t.jsx)(at,{className:"h-3.5 w-3.5 animate-spin"}):null,A]})]})]})}r(cxe,"SecretPopoverForm");function dxe(e){return(0,t.jsx)(cxe,{mode:"create",...e})}r(dxe,"CreateSecretPopover");function eQe(e){return(0,t.jsx)(cxe,{mode:"store",...e})}r(eQe,"ConvertToSecretPopover");var tQe=/(api[-_]?key|access[-_]?token|auth(?:_?token)?|authorization|bearer|secret|passwd|password|credential|jwt|private[-_]?key|cookie|connectionstring)/i,sQe=[/^sk-[A-Za-z0-9-_]{16,}$/,/^gh[pousr]_[A-Za-z0-9]{20,}$/,/^github_pat_[A-Za-z0-9_]{20,}$/,/^xox[baprs]-[A-Za-z0-9-]{10,}$/,/^AKIA[0-9A-Z]{16}$/,/^AIza[0-9A-Za-z\-_]{20,}$/,/-----BEGIN (?:[A-Z ]+ )?PRIVATE KEY-----/,/^eyJ[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+$/];function nQe(e){return e.length<24||/\s/.test(e)||!/^[A-Za-z0-9+/=_\-.]+$/.test(e)?!1:[/[a-z]/.test(e),/[A-Z]/.test(e),/[0-9]/.test(e)].filter(Boolean).length>=2}r(nQe,"looksHighEntropy");function rQe(e,s){return s?tQe.test(e)||sQe.some(n=>n.test(s))?!0:nQe(s):!1}r(rQe,"isSensitiveEnv");var tJ=0;function aQe(){return tJ+=1,`env-row-${tJ}`}r(aQe,"nextRowId");function ox(e="text"){return{id:aQe(),name:"",source:e,textValue:"",secretId:"",userSecretKey:"",required:!0,version:"latest"}}r(ox,"emptyRow");function iQe(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="secret_ref"}r(iQe,"isSecretRef");function oQe(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="plain"}r(oQe,"isPlainObj");function lQe(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="user_secret_ref"}r(lQe,"isUserSecretRef");function B4(e){return!e||typeof e!="object"?[]:Object.entries(e).map(([s,n])=>{if(typeof n=="string")return{...ox(),name:s,textValue:n};if(iQe(n)){const a=typeof n.version=="number"?n.version:"latest";return{...ox(),name:s,source:"secret",secretId:typeof n.secretId=="string"?n.secretId:"",version:a}}if(lQe(n)){const a=typeof n.version=="number"?n.version:"latest";return{...ox(),name:s,source:"user_secret",userSecretKey:typeof n.key=="string"?n.key:"",required:n.required!==!1,version:a}}return oQe(n)?{...ox(),name:s,source:"text",textValue:typeof n.value=="string"?n.value:""}:{...ox(),name:s}})}r(B4,"rowsFromValue");function L2(e){const s={};for(const n of e){const a=n.name.trim();if(a)if(n.source==="secret"){if(!n.secretId)continue;s[a]={type:"secret_ref",secretId:n.secretId,version:n.version}}else if(n.source==="user_secret"){const i=n.userSecretKey.trim();if(!i)continue;s[a]={type:"user_secret_ref",key:i,version:n.version,required:n.required}}else s[a]={type:"plain",value:n.textValue}}return Object.keys(s).length>0?s:void 0}r(L2,"valueFromRows");var sJ="CLAUDE_CODE_OAUTH_TOKEN";function fj(){return L2([{...ox("user_secret"),name:"CLAUDE_CODE_OAUTH_TOKEN",userSecretKey:"CLAUDE_CODE_OAUTH_TOKEN",required:!0,version:"latest"}])??{}}r(fj,"buildFixedClaudeOAuthBinding");var cQe=/^[A-Za-z_][A-Za-z0-9_]*$/;function dQe(e,s,n){const a=e.trim();if(!a)return null;if(!cQe.test(a))return{level:"error",message:"Invalid name — use letters, digits and _"};if(s.has(a))return{level:"error",message:"Duplicate name"};for(const i of n)if(i&&a.startsWith(i))return{level:"warn",message:"Reserved prefix — provided automatically and may be overridden"};return null}r(dQe,"validateName");function uQe(e){const s=new Map;for(const a of e){const i=a.name.trim();i&&s.set(i,(s.get(i)??0)+1)}const n=new Set;for(const[a,i]of s)i>1&&n.add(a);return n}r(uQe,"computeDuplicateNames");function mQe(e,s){return s===e.source?{kind:"noop"}:s==="secret"?e.textValue.trim()?{kind:"open-store",name:BT(e.name)||"secret",value:e.textValue}:{kind:"to-secret"}:{kind:"to-text",undoFrom:e.secretId?{...e}:null}}r(mQe,"planSourceSwitch");function uxe(e,s){if(e.source!=="secret"||!e.secretId)return null;const n=s.find(a=>a.id===e.secretId);return n?n.status!=="active"?{level:"warn",kind:"disabled",message:"Runs will fail until re-enabled or rebound."}:null:{level:"error",kind:"missing",message:"This secret no longer exists — runs will fail until you rebind."}}r(uxe,"computeRowHealth");function mxe(e,s){if(e.source!=="user_secret"||!e.userSecretKey||!s?.length)return null;const n=s.find(a=>a.key===e.userSecretKey);return n?n.status!=="active"?{level:"warn",kind:"disabled",message:"Runs will fail until this user secret definition is re-enabled or rebound."}:null:{level:"error",kind:"missing",message:"This user secret definition no longer exists — runs will fail until you rebind."}}r(mxe,"computeUserSecretRowHealth");function BT(e){return e.trim().toLowerCase().replace(/[^a-z0-9_]+/g,"_").replace(/^_+|_+$/g,"").slice(0,64)}r(BT,"secretNameFromKey");function _S(e){return e.trim().toUpperCase().replace(/[^A-Z0-9_]+/g,"_").replace(/^_+|_+$/g,"").slice(0,64)}r(_S,"envKeyFromSecretName");var hQe="w-full rounded-md border border-border px-2.5 py-1.5 bg-transparent outline-none text-sm font-mono placeholder:text-muted-foreground/40 focus-visible:ring-2 focus-visible:ring-ring/40",nJ="min-w-0 flex-1 bg-transparent px-2 py-1.5 text-sm font-mono outline-none placeholder:text-muted-foreground/40";function pQe({row:e,isLast:s,secrets:n,userSecretDefinitions:a,recentlyUsedSecrets:i,disabled:o,nameIssue:l,showNameIssue:c,dirtyFields:d,onPatch:m,onRemove:h,onNameBlur:p,onNamePaste:f,onEnterInValueLast:g,onCreateSecret:v,onToast:y,focusRequest:w,onFocusConsumed:S}){const j=(0,u.useRef)(null),N=(0,u.useRef)(null),_=(0,u.useRef)(null),[R,C]=(0,u.useState)(null),[A,T]=(0,u.useState)(!1),[I,$]=(0,u.useState)(null),O=uxe(e,n)??mxe(e,a),L=e.source==="secret"?n.find(te=>te.id===e.secretId)??null:null,E=(a?.length??0)>0,q=e.source==="text"&&!e.sensitiveDismissed&&rQe(e.name,e.textValue);(0,u.useEffect)(()=>{w&&(w==="name"?j.current?.focus():e.source==="text"?N.current?.focus():e.source==="secret"?_.current?.querySelector("[role=combobox]")?.focus():_.current?.querySelector("select,input")?.focus(),S())},[w,S,e.source]),(0,u.useEffect)(()=>{if(!I)return;const te=window.setTimeout(()=>$(null),5e3);return()=>window.clearTimeout(te)},[I]);function B(te){if(te==="user_secret"){if(e.source==="user_secret")return;m({source:"user_secret",secretId:"",version:"latest"}),window.setTimeout(()=>_.current?.querySelector("select,input")?.focus(),0);return}const ae=mQe(e,te);switch(ae.kind){case"noop":return;case"open-store":{const{name:de,value:J}=ae;window.setTimeout(()=>C({mode:"store",name:de,value:J}),0);return}case"to-secret":m({source:"secret",userSecretKey:"",required:!0}),window.setTimeout(()=>{_.current?.querySelector("[role=combobox]")?.focus()},0);return;case"to-text":ae.undoFrom&&$(ae.undoFrom),m({source:"text",secretId:"",userSecretKey:"",required:!0,version:"latest"}),window.setTimeout(()=>N.current?.focus(),0);return}}r(B,"switchSource");async function K(te,ae){const de=await v(te,ae);m({source:"secret",secretId:de.id,userSecretKey:"",required:!0,version:"latest",textValue:""}),y(`Secret ${de.name} created`),C(null)}r(K,"submitSecretPopover");function z(){const te=BT(e.name)||"secret",{textValue:ae}=e;window.setTimeout(()=>C({mode:"store",name:te,value:ae}),0)}r(z,"openStoreAsSecret");const D=e.source==="text"?"Text value":e.source==="secret"?"Organization secret reference":"User secret reference",V=`${e.id}-name-error`,H=`${e.id}-health`,ee=d.name||d.value,X=L?Math.max(0,L.latestVersion):0,le=e.version==="latest"?"latest":`v${e.version}`,ce=e.version!=="latest";return(0,t.jsxs)("div",{className:U("group/row grid grid-cols-(--gtc-13) items-start gap-x-1.5 gap-y-1 rounded-md px-1 py-1","@[40rem]/env:grid-cols-(--gtc-14) @[40rem]/env:items-center",ee&&"bg-amber-500/[0.06] ring-1 ring-amber-500/20"),children:[(0,t.jsx)("div",{className:"col-start-1 row-start-1 min-w-0 @[40rem]/env:row-start-1 @[40rem]/env:self-start",children:(0,t.jsx)("input",{ref:j,className:U(hQe,d.name&&"border-amber-500/70 bg-amber-500/10 focus-visible:ring-amber-500/40",c&&l?.level==="error"&&"border-destructive focus-visible:ring-destructive/40",c&&l?.level==="warn"&&"border-amber-500 focus-visible:ring-amber-500/40"),placeholder:"KEY",value:e.name,spellCheck:!1,disabled:o,"aria-label":"Variable name","aria-invalid":c&&l?.level==="error"?!0:void 0,"aria-describedby":c&&l?V:void 0,onChange:r(te=>m({name:te.target.value}),"onChange"),onBlur:p,onPaste:r(te=>{e.name||f(te.clipboardData.getData("text"))&&te.preventDefault()},"onPaste"),onKeyDown:r(te=>{te.key==="Enter"&&(te.preventDefault(),e.source==="text"?N.current?.focus():_.current?.querySelector("[role=combobox],select,input")?.focus())},"onKeyDown")})}),(0,t.jsxs)("div",{className:"col-span-2 col-start-1 row-start-2 min-w-0 @[40rem]/env:col-span-1 @[40rem]/env:col-start-2 @[40rem]/env:row-start-1",children:[(0,t.jsxs)(Zn,{open:R!==null,onOpenChange:r(te=>{te||C(null)},"onOpenChange"),children:[(0,t.jsx)(uO,{asChild:!0,children:(0,t.jsxs)("div",{ref:_,className:U("relative flex items-stretch overflow-hidden rounded-md border border-border bg-transparent focus-within:ring-2 focus-within:ring-ring/40",d.value&&"border-amber-500/70 bg-amber-500/10 focus-within:ring-amber-500/40",o&&"opacity-60"),children:[(0,t.jsxs)(ba,{children:[(0,t.jsxs)(Wn,{children:[(0,t.jsx)(Hn,{asChild:!0,children:(0,t.jsx)(ga,{asChild:!0,disabled:o,children:(0,t.jsxs)("button",{type:"button","aria-label":"Value source",className:"flex shrink-0 items-center gap-0.5 border-r border-border px-2 text-muted-foreground hover:bg-accent/50 disabled:pointer-events-none",children:[e.source==="text"?(0,t.jsx)(SPe,{className:"size-3.5"}):e.source==="secret"?(0,t.jsx)(bi,{className:"size-3.5"}):(0,t.jsx)(vu,{className:"size-3.5"}),(0,t.jsx)(sn,{className:"size-3 opacity-60"})]})})}),(0,t.jsx)(Qn,{side:"top",children:D})]}),(0,t.jsxs)(va,{align:"start",className:"w-56",children:[(0,t.jsxs)(hs,{className:"flex-col items-start gap-0.5",onSelect:r(()=>B("text"),"onSelect"),children:[(0,t.jsx)("span",{className:"text-sm",children:"Text value"}),(0,t.jsx)("span",{className:"text-(length:--text-micro) text-muted-foreground",children:"Store the value inline as plain text."})]}),(0,t.jsxs)(hs,{className:"flex-col items-start gap-0.5",onSelect:r(()=>B("secret"),"onSelect"),children:[(0,t.jsx)("span",{className:"text-sm",children:"Organization secret"}),(0,t.jsx)("span",{className:"text-(length:--text-micro) text-muted-foreground",children:"Resolve a stored organization secret at run start."})]}),(0,t.jsxs)(hs,{className:"flex-col items-start gap-0.5",onSelect:r(()=>B("user_secret"),"onSelect"),children:[(0,t.jsx)("span",{className:"text-sm",children:"User secret"}),(0,t.jsx)("span",{className:"text-(length:--text-micro) text-muted-foreground",children:"Resolve the responsible user's own value at run start."})]})]})]}),e.source==="text"?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("input",{ref:N,className:nJ,placeholder:"value",value:e.textValue,type:q?"password":"text",spellCheck:!1,disabled:o,"aria-label":"Variable value",onChange:r(te=>m({textValue:te.target.value}),"onChange"),onKeyDown:r(te=>{te.key==="Enter"&&s&&(te.preventDefault(),g())},"onKeyDown")}),q?(0,t.jsxs)("div",{className:"flex shrink-0 items-stretch border-l border-border",children:[(0,t.jsxs)("button",{type:"button",onClick:z,disabled:o,className:"flex items-center gap-1 px-2 text-(length:--text-micro) text-amber-700 hover:bg-amber-500/10 dark:text-amber-400",title:"This value looks sensitive — store it as a secret",children:[(0,t.jsx)(kl,{className:"size-3.5"}),(0,t.jsx)("span",{className:"hidden @[30rem]/env:inline",children:"Store as secret"})]}),(0,t.jsx)("button",{type:"button",onClick:r(()=>m({sensitiveDismissed:!0}),"onClick"),disabled:o,"aria-label":"Dismiss sensitive-value suggestion",title:"Dismiss — keep this value as plain text",className:"flex items-center px-1.5 text-amber-700/60 hover:bg-amber-500/10 hover:text-amber-700 dark:text-amber-400/60 dark:hover:text-amber-400",children:(0,t.jsx)(ir,{className:"size-3"})})]}):null]}):e.source==="secret"?(0,t.jsxs)("div",{className:"relative min-w-0 flex-1",children:[(0,t.jsx)(bK,{secretId:e.secretId,secrets:n,recentlyUsedSecrets:i,disabled:o,onSelect:r(te=>m({secretId:te,version:"latest"}),"onSelect"),onCreateNew:r(te=>C({mode:"create",name:BT(te)||te.trim(),value:""}),"onCreateNew"),triggerClassName:U("rounded-none border-0 bg-transparent shadow-none focus-visible:ring-0",L&&L.status==="active"&&"pr-24 has-[>svg]:!pr-24")}),L&&L.status==="active"?(0,t.jsxs)(Zn,{open:A,onOpenChange:T,children:[(0,t.jsx)(uO,{asChild:!0,children:(0,t.jsx)("button",{type:"button",disabled:o,onClick:r(te=>{te.preventDefault(),te.stopPropagation(),T(ae=>!ae)},"onClick"),"aria-label":"Version",className:U("absolute right-8 top-1/2 z-10 -translate-y-1/2 rounded px-1.5 py-0.5 text-(length:--text-nano) font-medium",ce?"bg-amber-500/15 text-amber-700 dark:text-amber-400":"text-muted-foreground hover:bg-accent"),children:le})}),(0,t.jsxs)(Vn,{align:"end",className:"w-44 p-1",role:"radiogroup","aria-label":"Secret version",children:[(0,t.jsxs)("button",{type:"button",role:"radio","aria-checked":e.version==="latest",onClick:r(()=>{m({version:"latest"}),T(!1)},"onClick"),className:U("flex w-full items-center justify-between rounded px-2 py-1.5 text-sm hover:bg-accent",e.version==="latest"&&"font-medium"),children:["latest ",(0,t.jsx)("span",{className:"text-(length:--text-micro) text-muted-foreground",children:"(recommended)"})]}),Array.from({length:X},(te,ae)=>X-ae).filter(te=>te>0).map(te=>(0,t.jsxs)("button",{type:"button",role:"radio","aria-checked":e.version===te,onClick:r(()=>{m({version:te}),T(!1)},"onClick"),className:U("flex w-full items-center rounded px-2 py-1.5 text-sm hover:bg-accent",e.version===te&&"font-medium text-amber-700 dark:text-amber-400"),children:["v",te]},te))]})]}):null]}):(0,t.jsxs)("div",{className:"grid min-w-0 flex-1 grid-cols-(--gtc-13)",children:[E?(0,t.jsxs)("select",{"aria-label":"User secret",value:e.userSecretKey,disabled:o,onChange:r(te=>{const ae=te.target.value,de=a?.find(J=>J.key===ae);m({userSecretKey:ae,...de&&!e.name.trim()?{name:de.key.toUpperCase()}:{}})},"onChange"),className:"min-w-0 bg-transparent px-2 py-1.5 text-sm font-mono outline-none disabled:pointer-events-none",children:[(0,t.jsx)("option",{value:"",children:"Select user secret..."}),e.userSecretKey&&!a?.some(te=>te.key===e.userSecretKey)?(0,t.jsxs)("option",{value:e.userSecretKey,children:["Unknown (",e.userSecretKey,")"]}):null,(a??[]).map(te=>(0,t.jsxs)("option",{value:te.key,children:[te.name,te.status!=="active"?` (${te.status})`:""]},te.id))]}):(0,t.jsx)("input",{className:nJ,placeholder:"user-secret key",value:e.userSecretKey,spellCheck:!1,disabled:o,"aria-label":"User secret key",onChange:r(te=>m({userSecretKey:te.target.value}),"onChange")}),(0,t.jsxs)("select",{"aria-label":"Requirement",value:e.required?"required":"optional",disabled:o,onChange:r(te=>m({required:te.target.value==="required"}),"onChange"),className:"border-l border-border bg-transparent px-2 py-1.5 text-xs font-medium text-muted-foreground outline-none disabled:pointer-events-none",children:[(0,t.jsx)("option",{value:"required",children:"Required"}),(0,t.jsx)("option",{value:"optional",children:"Optional"})]})]})]})}),(0,t.jsx)(Vn,{align:"start",className:"w-auto p-3",onInteractOutside:r(te=>{const ae=te.detail.originalEvent.target;ae&&_.current?.contains(ae)&&te.preventDefault()},"onInteractOutside"),children:R?.mode==="store"?(0,t.jsx)(eQe,{initialName:R.name,initialValue:R.value,existingSecretNames:n.map(te=>te.name),onCancel:r(()=>C(null),"onCancel"),onSubmit:K}):R?.mode==="create"?(0,t.jsx)(dxe,{initialName:R.name,initialValue:R.value,existingSecretNames:n.map(te=>te.name),onCancel:r(()=>C(null),"onCancel"),onSubmit:K}):null})]}),O?(0,t.jsx)("p",{id:H,role:"status",className:U("mt-0.5 text-(length:--text-micro)",O.level==="error"?"text-destructive":"text-amber-600 dark:text-amber-400"),children:O.message}):null,I?(0,t.jsxs)("p",{className:"mt-0.5 inline-flex items-center gap-2 text-(length:--text-micro) text-muted-foreground",children:["Reverted to text —"," ",(0,t.jsx)("button",{type:"button",className:"font-medium text-foreground underline underline-offset-2 hover:text-primary",onClick:r(()=>{m({source:"secret",secretId:I.secretId,version:I.version,textValue:""}),$(null)},"onClick"),children:"Undo"})]}):null]}),c&&l?(0,t.jsx)("p",{id:V,className:U("col-span-2 col-start-1 row-start-3 min-w-0 text-(length:--text-micro) @[40rem]/env:col-span-2 @[40rem]/env:row-start-2",l.level==="error"?"text-destructive":"text-amber-600 dark:text-amber-400"),children:l.message}):null,(0,t.jsxs)("div",{className:"col-start-2 row-start-1 flex items-center justify-end gap-0.5 self-start @[40rem]/env:col-start-3 @[40rem]/env:self-center",children:[e.source==="text"&&!q&&(e.name.trim()||e.textValue)?(0,t.jsxs)(ba,{children:[(0,t.jsx)(ga,{asChild:!0,disabled:o,children:(0,t.jsx)("button",{type:"button","aria-label":"More actions",className:"rounded p-1 text-muted-foreground opacity-100 hover:bg-accent hover:text-foreground @[40rem]/env:opacity-0 @[40rem]/env:group-hover/row:opacity-100 @[40rem]/env:group-focus-within/row:opacity-100",children:(0,t.jsx)(Ti,{className:"size-4"})})}),(0,t.jsx)(va,{align:"end",children:(0,t.jsx)(hs,{onSelect:r(()=>{window.setTimeout(z,0)},"onSelect"),children:"Store as secret…"})})]}):null,(0,t.jsx)("button",{type:"button",onClick:h,disabled:o,"aria-label":`Remove ${e.name.trim()||"variable"}`,className:"rounded p-1 text-muted-foreground opacity-100 hover:bg-destructive/10 hover:text-destructive @[40rem]/env:opacity-0 @[40rem]/env:group-hover/row:opacity-100 @[40rem]/env:group-focus-within/row:opacity-100",children:(0,t.jsx)(ir,{className:"size-4"})})]})]})}r(pQe,"EnvironmentVariableRow");var fQe=/^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=(.*)$/;function xQe(e){const s=e.indexOf(" #");return s>=0?e.slice(0,s):e}r(xQe,"stripInlineComment");function gQe(e){const s=e.trim();if(s.length>=2){const n=s[0],a=s[s.length-1];if(n==='"'&&a==='"'||n==="'"&&a==="'")return s.slice(1,-1)}return xQe(s).trim()}r(gQe,"unquote");function bQe(e){const s=[];for(const n of e.split(/\r?\n/)){const a=n.trim();if(!a||a.startsWith("#"))continue;const i=fQe.exec(a);if(!i)continue;const o=i[1],l=gQe(i[2]);s.push({key:o,value:l})}return s}r(bQe,"parseDotenv");var vQe=["PAPERCLIP_"],yQe="Set the KEY to the env var name the process expects, for example GH_TOKEN. Choose a secret to resolve a stored value at run start. PAPERCLIP_* variables are injected automatically.";function qF(e){if(!e||typeof e!="object")return[];const s=new Map;for(const[n,a]of Object.entries(e)){const i=n.trim();if(i)if(typeof a=="string")s.set(i,{type:"plain",value:a});else if(a?.type==="secret_ref"){const o=typeof a.secretId=="string"?a.secretId:"";if(!o)continue;s.set(i,{type:"secret_ref",secretId:o,version:typeof a.version=="number"?a.version:"latest"})}else if(a?.type==="user_secret_ref"){const o=typeof a.key=="string"?a.key.trim():"";if(!o)continue;s.set(i,{type:"user_secret_ref",key:o,version:typeof a.version=="number"?a.version:"latest",required:a.required!==!1})}else a?.type==="plain"?s.set(i,{type:"plain",value:typeof a.value=="string"?a.value:""}):s.set(i,{type:"plain",value:""})}return[...s.entries()].sort(([n],[a])=>n.localeCompare(a))}r(qF,"normalizedEnvEntries");function nk(e){return JSON.stringify(qF(e))}r(nk,"normalizedEnvKey");var q4=3;function z4(e){const s=e.slice(0,q4).join(", ");return e.length>q4?`${s} +${e.length-q4} more`:s}r(z4,"formatChangedNames");function rJ(e){return e.map(s=>({...s}))}r(rJ,"cloneRows");function jQe(e,s){return s?{name:e.name.trim()!==s.name.trim(),value:e.source!==s.source||e.textValue!==s.textValue||e.secretId!==s.secretId||e.userSecretKey!==s.userSecretKey||e.required!==s.required||e.version!==s.version}:{name:!!e.name.trim(),value:e.source!=="text"||!!e.textValue||!!e.secretId||e.version!=="latest"}}r(jQe,"rowDirtyFields");var rv=(0,u.forwardRef)(r(function({value:s,onChange:n,secrets:a,userSecretDefinitions:i,onCreateSecret:o,recentlyUsedSecrets:l,disabled:c,reservedPrefixes:d=vQe,footerHint:m,onDirtyChange:h,hideDraftActions:p=!1},f){const g=_c(),v=(0,u.useRef)(null),[y,w]=(0,u.useState)(()=>B4(s)),S=(0,u.useRef)(y),[j,N]=(0,u.useState)(()=>rJ(y)),_=(0,u.useMemo)(()=>nk(s),[]),R=(0,u.useRef)(_),C=(0,u.useRef)(_),A=(0,u.useRef)(null),[T,I]=(0,u.useState)(_),[$,O]=(0,u.useState)(()=>new Set(B4(s).map(oe=>oe.name.trim()).filter(Boolean))),[L,E]=(0,u.useState)(null);(0,u.useEffect)(()=>{S.current=y},[y]);function q(oe,ye=S.current){R.current=oe,I(oe),N(rJ(ye))}r(q,"markCommitted");function B(oe){O(ye=>{const Ae=new Set(ye);for(const xe of oe){const _e=xe.name.trim();_e&&Ae.add(_e)}return Ae})}r(B,"touchCommittedNames");function K(oe){const ye=B4(oe);return w(ye),B(ye),ye}r(K,"adoptExternalValue"),(0,u.useEffect)(()=>{const oe=nk(s);if(oe===C.current)return;C.current=oe;const ye=nk(L2(S.current)),Ae=ye!==R.current,xe=A.current===oe;if(xe&&(A.current=null),!Ae){q(oe,K(s));return}(xe||ye===oe)&&(B(S.current),q(oe))},[s]);const z=(0,u.useMemo)(()=>L2(y),[y]),D=(0,u.useMemo)(()=>nk(z),[z]),V=D!==T;(0,u.useEffect)(()=>{h?.(!c&&V)},[c,V,h]);const H=(0,u.useMemo)(()=>{const oe=new Map(qF(L2(j)).map(([_e,Ge])=>[_e,JSON.stringify(Ge)])),ye=new Map(qF(z).map(([_e,Ge])=>[_e,JSON.stringify(Ge)])),Ae=[],xe=[];for(const[_e,Ge]of ye)oe.has(_e)?oe.get(_e)!==Ge&&xe.push(_e):Ae.push(_e);return{added:Ae,changed:xe,removed:[...oe.keys()].filter(_e=>!ye.has(_e))}},[j,z]),ee=(0,u.useMemo)(()=>{const oe=[];return H.added.length>0&&oe.push(`New: ${z4(H.added)}`),H.changed.length>0&&oe.push(`Edited: ${z4(H.changed)}`),H.removed.length>0&&oe.push(`Removed: ${z4(H.removed)}`),oe.join(" · ")},[H]);(0,u.useEffect)(()=>{if(c||!V)return;function oe(ye){ye.preventDefault(),ye.returnValue=""}return r(oe,"handleBeforeUnload"),window.addEventListener("beforeunload",oe),()=>window.removeEventListener("beforeunload",oe)},[c,V]);const X=(0,u.useCallback)(()=>c||!V?null:(A.current=D,(0,Jp.flushSync)(()=>{n(z)}),z??{}),[c,z,D,V,n]);(0,u.useImperativeHandle)(f,()=>({flushPendingDraft:X}),[X]),(0,u.useEffect)(()=>{const oe=v.current?.closest("form");if(!oe)return;function ye(){X()}return r(ye,"handleSubmit"),oe.addEventListener("submit",ye,!0),()=>oe.removeEventListener("submit",ye,!0)},[X]),(0,u.useEffect)(()=>{const oe=v.current;if(!oe)return;const ye=oe;function Ae(xe){const _e=xe.target;if(!(_e instanceof Element)||ye.contains(_e))return;const Ge=_e.closest("button");if(!Ge||Ge.disabled)return;const $e=`${Ge.getAttribute("aria-label")??""} ${Ge.textContent??""}`;(Ge.type==="submit"||/\b(save|create|update|test|import)\b/i.test($e))&&X()}return r(Ae,"handleDocumentClick"),document.addEventListener("click",Ae,!0),()=>document.removeEventListener("click",Ae,!0)},[X]);function le(oe){w(oe)}r(le,"updateDraft");function ce(oe,ye){le(y.map(Ae=>Ae.id===oe?{...Ae,...ye}:Ae))}r(ce,"patchRow");function te(oe){le(y.filter(ye=>ye.id!==oe))}r(te,"removeRow");function ae(){const oe=ox();w([...y,oe]),E({rowId:oe.id,field:"name"})}r(ae,"addRow");function de(oe){const ye=y.find(Ae=>Ae.id===oe)?.name.trim();ye&&O(Ae=>{if(Ae.has(ye))return Ae;const xe=new Set(Ae);return xe.add(ye),xe})}r(de,"markTouched");function J(oe,ye){const Ae=bQe(oe);if(Ae.length===0)return!1;const xe=y.filter(_e=>_e.id!==ye).map(_e=>({..._e}));for(const{key:_e,value:Ge}of Ae){const $e=xe.find(Ye=>Ye.name.trim()===_e);$e?($e.name=_e,$e.source="text",$e.textValue=Ge,$e.secretId="",$e.sensitiveDismissed=!1,$e.userSecretKey="",$e.required=!0):xe.push({...ox(),name:_e,textValue:Ge})}return le(xe),g?.pushToast({title:`Imported ${Ae.length} variable${Ae.length===1?"":"s"}`,tone:"success"}),!0}r(J,"bulkImport");function Y(oe){const ye=y.map(_e=>({..._e})),Ae=ye[ye.length-1];let xe;Ae&&!Ae.name&&!Ae.textValue&&!Ae.secretId&&!Ae.userSecretKey?xe=Ae:(xe=ox(),ye.push(xe)),xe.source="secret",xe.secretId=oe.id,xe.version="latest",xe.name||(xe.name=_S(oe.name)),le(ye)}r(Y,"bindRecentSecret");function G(){V&&(A.current=D,n(z))}r(G,"saveDraft");function fe(){A.current=null,C.current=nk(s);const oe=K(s);q(C.current,oe)}r(fe,"revertDraft");const se=(0,u.useMemo)(()=>uQe(y),[y]),re=(0,u.useMemo)(()=>y.reduce((oe,ye)=>uxe(ye,a)||mxe(ye,i)?oe+1:oe,0),[y,a,i]),ie=(0,u.useMemo)(()=>{const oe=new Set(y.filter(ye=>ye.source==="secret"&&ye.secretId).map(ye=>ye.secretId));return(l??[]).filter(ye=>ye.status==="active"&&!oe.has(ye.id)).slice(0,8)},[l,y]),me=y.length>0,pe=m===void 0?yQe:m,be=(0,u.useMemo)(()=>new Map(j.map(oe=>[oe.id,oe])),[j]);return(0,t.jsx)(pd,{children:(0,t.jsxs)("div",{ref:v,className:"@container/env space-y-2",children:[re>1?(0,t.jsxs)("p",{className:"inline-flex items-center gap-1.5 text-(length:--text-micro) font-medium text-amber-700 dark:text-amber-400",children:[(0,t.jsx)(zi,{className:"size-3.5"}),re," bindings need attention"]}):null,me?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"hidden gap-x-1.5 @[40rem]/env:grid @[40rem]/env:grid-cols-(--gtc-14)",children:[(0,t.jsx)("span",{className:"text-(length:--text-micro) font-medium uppercase tracking-wide text-muted-foreground",children:"Name"}),(0,t.jsx)("span",{className:"text-(length:--text-micro) font-medium uppercase tracking-wide text-muted-foreground",children:"Value"}),(0,t.jsx)("span",{})]}),y.map((oe,ye)=>{const Ae=dQe(oe.name,se,d),xe=$.has(oe.name.trim());return(0,t.jsx)(pQe,{row:oe,isLast:ye===y.length-1,secrets:a,userSecretDefinitions:i,recentlyUsedSecrets:l,disabled:c,nameIssue:Ae,showNameIssue:xe,dirtyFields:jQe(oe,be.get(oe.id)),onPatch:r(_e=>ce(oe.id,_e),"onPatch"),onRemove:r(()=>te(oe.id),"onRemove"),onNameBlur:r(()=>de(oe.id),"onNameBlur"),onNamePaste:r(_e=>J(_e,oe.id),"onNamePaste"),onEnterInValueLast:ae,onCreateSecret:o,onToast:r(_e=>g?.pushToast({title:_e,tone:"success"}),"onToast"),focusRequest:L?.rowId===oe.id?L.field:null,onFocusConsumed:r(()=>E(null),"onFocusConsumed")},oe.id)})]}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"No environment variables"}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 pt-1",children:[(0,t.jsxs)("button",{type:"button",onClick:ae,disabled:c,className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:pointer-events-none disabled:opacity-50",children:[(0,t.jsx)(gn,{className:"size-3.5"}),"Add variable"]}),ie.length>0&&!c?(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 text-(length:--text-micro) text-muted-foreground/70",children:[(0,t.jsx)(bi,{className:"size-3"}),"Recently used:"]}),ie.map(oe=>(0,t.jsxs)("button",{type:"button",onClick:r(()=>Y(oe),"onClick"),className:"inline-flex items-center gap-1 rounded-full border border-border px-2 py-0.5 font-mono text-(length:--text-micro) text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",title:`Bind ${oe.name}`,children:["+ ",oe.name]},oe.id))]}):null]}),V&&!c&&!p?(0,t.jsxs)("div",{role:"status",className:"mt-3 flex w-full flex-col gap-3 rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-3 text-amber-950 shadow-sm dark:bg-amber-500/15 dark:text-amber-100 @[34rem]/env:flex-row @[34rem]/env:items-center @[34rem]/env:justify-between",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium",children:[(0,t.jsx)("span",{className:"size-2 rounded-full bg-amber-500 shadow-(--shadow-extract-13)"}),(0,t.jsx)("span",{children:"Unsaved changes"})]}),ee?(0,t.jsx)("p",{className:"min-w-0 truncate pl-4 text-xs text-amber-950/80 dark:text-amber-100/80",title:ee,children:ee}):null]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("button",{type:"button",onClick:fe,className:"inline-flex h-9 items-center gap-1.5 rounded-md border border-amber-500/30 bg-background px-3 text-sm font-medium text-foreground transition-colors hover:bg-amber-500/10 dark:bg-background/80",children:[(0,t.jsx)(ki,{className:"size-4"}),"Revert"]}),(0,t.jsxs)("button",{type:"button",onClick:G,className:"inline-flex h-9 items-center gap-1.5 rounded-md bg-primary px-4 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90",children:[(0,t.jsx)(Qp,{className:"size-4"}),"Save"]})]})]}):null,pe?(0,t.jsx)("p",{className:"text-(length:--text-micro) text-muted-foreground/70",children:pe}):null,y.some(oe=>oe.source==="user_secret"&&oe.userSecretKey)?(0,t.jsxs)("p",{className:"inline-flex items-start gap-1 text-(length:--text-micro) text-muted-foreground/70",children:[(0,t.jsx)(vu,{className:"mt-0.5 size-3 shrink-0"}),(0,t.jsx)("span",{children:"User secrets resolve from the user responsible for the run. Required bindings fail until that user sets their value under Secrets → My secrets."})]}):null]})})},"EnvironmentVariablesEditor")),wQe="env.",B1="access.",zF=/^[A-Za-z_][A-Za-z0-9_]*$/;function hxe(e){return e?e.startsWith("access.")?"api":e.startsWith("env.")?"env":"config":"config"}r(hxe,"deliveryModeForConfigPath");function pxe(e){switch(e){case"env":return"Env var";case"api":return"API access";default:return"Config"}}r(pxe,"deliveryModeLabel");function NQe(e){switch(e){case"env":return"Injected as an environment variable at run start.";case"api":return"Fetched on demand via the run-bound agent API. Never written to the environment.";default:return"Provided through adapter configuration."}}r(NQe,"deliveryModeDescription");function fxe(e){return e?e.startsWith("access.")?e.slice(7):e.startsWith("env.")?e.slice(4):e:""}r(fxe,"aliasFromConfigPath");function kQe(e){switch(e){case"agent_api":return"Agent API";case"plugin_worker":return"Plugin worker";case"tool_connection":return"Tool connection";default:return e.charAt(0).toUpperCase()+e.slice(1)}}r(kQe,"consumerTypeLabel");var SQe={numeric:!0,sensitivity:"base"};function Uk(e){return e.kind==="company"?e.secret.name:e.definition.name}r(Uk,"getSecretPathRowName");function Nw(e){return e.split("/").filter(s=>s.length>0)}r(Nw,"splitSecretPath");function U4(e){return Nw(e).join("/")}r(U4,"normalizeSecretPath");function aJ(e,s){return s.every((n,a)=>e[a]===n)}r(aJ,"startsWithSegments");function iJ(e,s){return e.localeCompare(s,void 0,SQe)}r(iJ,"compareNames");function CQe(e,s){const n=Nw(s),a=e.map(c=>({row:c,name:Uk(c),segments:Nw(Uk(c))})),i=new Set,o=[];for(const c of a){if(!aJ(c.segments,n))continue;const d=c.segments.length-n.length;(d===0||d===1)&&o.push(c.row),d>=2&&i.add(c.segments[n.length])}const l=[...i].map(c=>{const d=[...n,c],m=new Set;let h=0;for(const p of a){if(!aJ(p.segments,d))continue;const f=p.segments.length-d.length;if(!(f<1)){h+=1;for(let g=1;g<f;g+=1)m.add(p.segments.slice(d.length,d.length+g).join("/"))}}return{name:c,path:d.join("/"),secretCount:h,folderCount:m.size}});return l.sort((c,d)=>iJ(c.name,d.name)),o.sort((c,d)=>iJ(Uk(c),Uk(d))),{folders:l,secrets:o}}r(CQe,"buildSecretPathListing");function _Qe(e){const s=Nw(e);return s.map((n,a)=>({name:n,path:s.slice(0,a+1).join("/")}))}r(_Qe,"buildSecretPathBreadcrumbs");function IQe(e){return e.trim()?e.includes("/")?"Folder name cannot contain slashes.":null:"Folder name is required."}r(IQe,"validateSecretFolderSegment");function vC({name:e,basePath:s="",className:n,leafClassName:a}){const i=Nw(e),o=Nw(s),l=o.length>0&&o.every((h,p)=>i[p]===h)&&i.length>o.length?i.slice(o.length):i,c=l.length>0?l:[e],d=c[c.length-1],m=c.slice(0,-1).join("/");return(0,t.jsxs)("span",{className:U("min-w-0 truncate",n),children:[m?(0,t.jsxs)("span",{className:"text-muted-foreground",children:[m,"/"]}):null,(0,t.jsx)("span",{className:U("font-medium text-foreground",a),children:d})]})}r(vC,"SecretPathName");function AQe(e,s){const n=e?`sha256:${e.slice(0,10)}…`:"no fingerprint",a=typeof s=="number"?`${s} ${s===1?"byte":"bytes"}`:null;return a?`${n} · ${a}`:n}r(AQe,"fingerprintLabel");function xxe({fingerprint:e,length:s,className:n}){const{pushToast:a}=pa(),i=AQe(e,s);if(!e)return(0,t.jsxs)("span",{className:U("inline-flex items-center gap-1 font-mono",n),children:[(0,t.jsx)(NH,{className:"size-3 shrink-0"}),i]});const o=`sha256:${e}`;return(0,t.jsxs)("button",{type:"button",onClick:r(()=>{Yr(o).then(()=>a({title:"Fingerprint copied",tone:"success"})).catch(()=>a({title:"Couldn’t copy fingerprint",tone:"error"}))},"onClick"),title:`Copy full digest — ${o}`,className:U("inline-flex items-center gap-1 font-mono hover:text-foreground",n),children:[(0,t.jsx)(NH,{className:"size-3 shrink-0"}),i,(0,t.jsx)(Nr,{className:"size-3 shrink-0 opacity-60"})]})}r(xxe,"FingerprintChip");function vK({justification:e,className:s}){return(0,t.jsxs)("div",{className:U("space-y-0.5",s),children:[(0,t.jsx)("p",{className:"text-(length:--text-micro) text-muted-foreground",children:"Reason given by the agent"}),(0,t.jsxs)("p",{className:"whitespace-pre-wrap break-words text-xs text-foreground/80",children:["“",e,"”"]})]})}r(vK,"ProposalJustification");function yC({agent:e,className:s}){return(0,t.jsxs)("span",{className:U("inline-flex min-w-0 items-center gap-1",s),children:[(0,t.jsx)(gr,{agent:e,size:16,className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,t.jsx)("span",{className:"min-w-0 truncate",children:e.name})]})}r(yC,"AgentRefChip");function yK({configPath:e}){const s=hxe(e),n=s==="env",a=s==="api";return(0,t.jsxs)(lt,{variant:"outline",className:U("h-5 gap-1 px-1.5 text-(length:--text-nano) font-normal",n&&"border-sky-500/30 bg-sky-500/10 text-sky-700 dark:text-sky-300",a&&"border-violet-500/30 bg-violet-500/10 text-violet-700 dark:text-violet-300",!n&&!a&&"border-border bg-muted/40 text-muted-foreground"),children:[n?(0,t.jsx)(sue,{className:"size-3"}):a?(0,t.jsx)(E5,{className:"size-3"}):null,pxe(s)]})}r(yK,"DeliveryBadge$1");function jK({className:e}){return(0,t.jsxs)(lt,{variant:"outline",className:U("h-5 gap-1 px-1.5 text-(length:--text-nano) font-medium","border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-300",e),children:[(0,t.jsx)(kl,{className:"size-3"})," Proposed"]})}r(jK,"ProposedBadge");function hE(e){return fxe(e.configPath)}r(hE,"bindingEnvKey");function wK(e){return e.secretProposalId?{name:e.secretProposalName??"proposed secret",pending:!0}:{name:e.secretName??"secret",pending:!1}}r(wK,"bindingSecretLabel");function oJ(e){return e instanceof wn?e.message||`Request failed: ${e.status}`:e instanceof Error?e.message:"Something went wrong. Try again."}r(oJ,"readableError");function gxe(e,s=[]){const n=Wt(),{pushToast:a}=pa(),[i,o]=(0,u.useState)(null),[l,c]=(0,u.useState)(null),[d,m]=(0,u.useState)(""),[h,p]=(0,u.useState)(null),f=(0,u.useCallback)(()=>{e&&(n.invalidateQueries({queryKey:["secret-proposals",e]}),n.invalidateQueries({queryKey:P.secrets.list(e)}))},[e,n]),g=Ne({mutationFn:r(j=>{const{proposal:N}=j;if(N.kind==="secret"){const _=j.folder.trim()?`${j.folder.trim().replace(/\/+$/,"")}/${j.leaf.trim()}`:j.leaf.trim();return fr.approveProposal(e,N.id,{overrides:{name:_,description:j.description.trim()||null,providerConfigId:j.providerConfigId||null}})}return fr.approveProposal(e,N.id,{cascade:j.cascade||void 0})},"mutationFn"),onSuccess:r(j=>{a({title:j.kind==="secret"?"Secret approved":"Binding approved",body:j.kind==="secret"?j.proposedName??"Secret created":`${j.target?.name??"Agent"} · ${hE(j)||"binding"}`,tone:"success"}),o(null),p(null),f()},"onSuccess"),onError:r(j=>p(oJ(j)),"onError")}),v=Ne({mutationFn:r(({proposal:j,reason:N})=>fr.rejectProposal(e,j.id,{reason:N.trim()}),"mutationFn"),onSuccess:r(j=>{a({title:"Proposal rejected",body:j.kind==="secret"?j.proposedName??void 0:void 0,tone:"info"}),c(null),m(""),p(null),f()},"onSuccess"),onError:r(j=>p(oJ(j)),"onError")}),y=(0,u.useCallback)(j=>{p(null);const N=(j.proposedName??"").split("/"),_=N.pop()??"";o({proposal:j,folder:N.join("/"),leaf:_,description:j.proposedDescription??"",providerConfigId:s.find(R=>R.provider==="local_encrypted"&&R.isDefault)?.id??"",cascade:!!j.secretProposalId})},[s]),w=(0,u.useCallback)(j=>{p(null),m(""),c(j)},[]),S=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(RQe,{draft:i,error:h,pending:g.isPending,providerConfigs:s,onChange:o,onCancel:r(()=>{o(null),p(null)},"onCancel"),onConfirm:r(()=>i&&g.mutate(i),"onConfirm")}),(0,t.jsx)(EQe,{proposal:l,reason:d,error:h,pending:v.isPending,onReasonChange:m,onCancel:r(()=>{c(null),m(""),p(null)},"onCancel"),onConfirm:r(()=>l&&v.mutate({proposal:l,reason:d}),"onConfirm")})]});return{requestApprove:y,requestReject:w,isBusy:g.isPending||v.isPending,dialogs:S}}r(gxe,"useProposalReview");function RQe({draft:e,error:s,pending:n,providerConfigs:a,onChange:i,onCancel:o,onConfirm:l}){const c=e?.proposal.kind==="secret",d=e?e.folder.trim()?`${e.folder.trim().replace(/\/+$/,"")}/${e.leaf.trim()}`:e.leaf.trim():"",m=a.filter(p=>p.provider==="local_encrypted"),h=c?!!(e&&e.leaf.trim()):!0;return(0,t.jsx)(Ys,{open:!!e,onOpenChange:r(p=>!p&&o(),"onOpenChange"),children:(0,t.jsx)(Js,{className:"sm:max-w-lg",children:e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(Cn,{children:[(0,t.jsx)(tn,{children:c?"Approve & create secret":"Approve binding"}),(0,t.jsx)(Ln,{children:c?"The value is created as the proposing agent recorded it. Re-folder or rename it before it lands.":"Grant the target agent access to this secret. This runs with your permissions."})]}),(0,t.jsxs)("div",{className:"space-y-1.5 rounded-md border border-border bg-muted/30 p-2.5 text-xs",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[(0,t.jsx)("span",{children:"Proposed by"}),(0,t.jsx)(yC,{agent:e.proposal.proposedBy,className:"font-medium text-foreground"})]}),(0,t.jsx)(vK,{justification:e.proposal.justification})]}),c?(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(Qs,{htmlFor:"approve-folder",children:"Folder"}),(0,t.jsx)(At,{id:"approve-folder",value:e.folder,onChange:r(p=>i({...e,folder:p.target.value}),"onChange"),placeholder:"dev/github",className:"font-mono text-xs"})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(Qs,{htmlFor:"approve-name",children:"Name"}),(0,t.jsx)(At,{id:"approve-name",value:e.leaf,onChange:r(p=>i({...e,leaf:p.target.value}),"onChange"),placeholder:"client-secret",autoFocus:!0,"aria-invalid":!e.leaf.trim(),className:"font-mono text-xs"})]})]}),(0,t.jsxs)("p",{className:"text-(length:--text-micro) text-muted-foreground",children:["Lands as"," ",d?(0,t.jsx)(vC,{name:d,className:"font-mono"}):(0,t.jsx)("span",{className:"italic",children:"enter a name"})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(Qs,{htmlFor:"approve-description",children:"Description"}),(0,t.jsx)(At,{id:"approve-description",value:e.description,onChange:r(p=>i({...e,description:p.target.value}),"onChange"),placeholder:"Optional"})]}),m.length>0?(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(Qs,{htmlFor:"approve-provider-config",children:"Provider vault"}),(0,t.jsxs)("select",{id:"approve-provider-config",value:e.providerConfigId,onChange:r(p=>i({...e,providerConfigId:p.target.value}),"onChange"),className:"h-9 w-full rounded-md border border-input bg-transparent px-2 text-sm outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50",children:[(0,t.jsx)("option",{value:"",children:"Deployment default"}),m.map(p=>(0,t.jsx)("option",{value:p.id,children:p.displayName},p.id))]})]}):null,(0,t.jsx)("div",{className:"rounded-md border border-border bg-background px-2.5 py-1.5 text-xs text-muted-foreground",children:(0,t.jsx)(xxe,{fingerprint:e.proposal.valueFingerprintSha256,length:e.proposal.valueLength})})]}):(0,t.jsx)(TQe,{draft:e,onChange:i}),s?(0,t.jsx)("p",{className:"text-xs text-destructive",role:"alert",children:s}):null,(0,t.jsxs)(yr,{children:[(0,t.jsx)(F,{variant:"ghost",onClick:o,disabled:n,children:"Cancel"}),(0,t.jsx)(F,{onClick:l,disabled:n||!h,children:n?"Approving…":c?"Approve & create":e.cascade?"Approve secret & bind":"Approve binding"})]})]}):null})})}r(RQe,"ApproveDialog");function TQe({draft:e,onChange:s}){const{proposal:n}=e,a=wK(n),i=hE(n);return(0,t.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,t.jsxs)("div",{className:"space-y-2 rounded-md border border-border p-3",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"Target agent"}),n.target?(0,t.jsx)(yC,{agent:n.target,className:"text-sm font-medium"}):(0,t.jsx)("span",{className:"text-muted-foreground",children:"—"})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"Delivered as"}),(0,t.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,t.jsx)(yK,{configPath:n.configPath}),(0,t.jsx)("code",{className:"font-mono text-xs",children:i||n.configPath})]})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"Secret"}),(0,t.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,t.jsx)(bi,{className:"size-3.5 text-muted-foreground"}),(0,t.jsx)("span",{className:"font-medium",children:a.name}),a.pending?(0,t.jsx)(jK,{}):null]})]})]}),n.secretProposalId?(0,t.jsxs)("label",{className:"flex items-start gap-2 rounded-md border border-amber-500/30 bg-amber-500/5 p-2.5 text-xs",children:[(0,t.jsx)($i,{checked:e.cascade,onCheckedChange:r(o=>s({...e,cascade:o===!0}),"onCheckedChange"),className:"mt-0.5","aria-label":"Also approve the proposed secret"}),(0,t.jsxs)("span",{className:"text-foreground/90",children:["Also approve the proposed secret"," ",(0,t.jsx)("span",{className:"font-medium",children:a.name})," and create it in the same step. The binding can’t land without it."]})]}):null]})}r(TQe,"BindingApproveBody");function EQe({proposal:e,reason:s,error:n,pending:a,onReasonChange:i,onCancel:o,onConfirm:l}){const c=s.trim().length>0;return(0,t.jsx)(Ys,{open:!!e,onOpenChange:r(d=>!d&&o(),"onOpenChange"),children:(0,t.jsx)(Js,{className:"sm:max-w-md",children:e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(Cn,{children:[(0,t.jsx)(tn,{children:"Reject proposal"}),(0,t.jsxs)(Ln,{children:["The reason is sent back to"," ",(0,t.jsx)(yC,{agent:e.proposedBy,className:"text-foreground"}),". Dependent bindings are rejected too."]})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(Qs,{htmlFor:"reject-reason",children:"Reason"}),(0,t.jsx)(Dn,{id:"reject-reason",value:s,onChange:r(d=>i(d.target.value),"onChange"),rows:3,autoFocus:!0,placeholder:"Why is this being rejected?"})]}),n?(0,t.jsx)("p",{className:"text-xs text-destructive",role:"alert",children:n}):null,(0,t.jsxs)(yr,{children:[(0,t.jsx)(F,{variant:"ghost",onClick:o,disabled:a,children:"Cancel"}),(0,t.jsx)(F,{variant:"destructive",onClick:l,disabled:a||!c,children:a?"Rejecting…":"Reject"})]})]}):null})})}r(EQe,"RejectDialog");function bxe({proposal:e,onApprove:s,onReject:n,disabled:a,size:i="sm"}){const o=!e.viewerCanApprove,l=i==="xs"?"h-7 px-2 text-xs":"",c=(0,t.jsx)(F,{size:"sm",className:l,disabled:a||o,onClick:r(()=>s(e),"onClick"),children:"Approve"});return(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[o?(0,t.jsx)(pd,{children:(0,t.jsxs)(Wn,{children:[(0,t.jsx)(Hn,{asChild:!0,children:(0,t.jsx)("span",{tabIndex:0,children:c})}),(0,t.jsx)(Qn,{className:"max-w-72",children:e.approveBlockReason??"You don’t have permission to approve this."})]})}):c,(0,t.jsx)(F,{size:"sm",variant:"outline",className:l,disabled:a,onClick:r(()=>n(e),"onClick"),children:"Reject"})]})}r(bxe,"ProposalActions");function vxe(e){return typeof e!="object"||e===null||Array.isArray(e)?null:e}r(vxe,"asRecord$15");function yxe(e){const s=vxe(e);if(!s||s.type!=="secret_ref")return null;const n=typeof s.secretId=="string"?s.secretId:"";return n?{secretId:n,version:typeof s.version=="number"?s.version:"latest"}:null}r(yxe,"readSecretRef");function PQe(e){const s=vxe(e?.env);if(!s)return[];const n=[];for(const[a,i]of Object.entries(s)){const o=yxe(i);o&&n.push({name:a,...o})}return n}r(PQe,"parseEnvSecretRefs");function MQe(e){if(!e)return[];const s=[];for(const[n,a]of Object.entries(e)){if(!n.startsWith("access."))continue;const i=yxe(a);i&&s.push({name:n.slice(B1.length),...i})}return s}r(MQe,"parseAccessGrants");function DQe(e,s){const n=new Map,a=r(i=>{let o=n.get(i);return o||(o={secretId:i,envKeys:[],apiAliases:[]},n.set(i,o)),o},"ensure");for(const i of e)a(i.secretId).envKeys.push(i.name);for(const i of s)a(i.secretId).apiAliases.push(i.name);return[...n.values()]}r(DQe,"summarizeAgentBindings");var lJ=0;function jxe(){return lJ+=1,`access-row-${lJ}`}r(jxe,"nextAccessRowId");function K4(e){return e.map(s=>({id:jxe(),alias:s.name,secretId:s.secretId,version:s.version}))}r(K4,"entriesToRows");function cJ(e){const s={};for(const n of e){const a=n.alias.trim();!a||!zF.test(a)||!n.secretId||(s[a]={type:"secret_ref",secretId:n.secretId,version:n.version})}return s}r(cJ,"rowsToAccessMap");function dJ(e){return JSON.stringify(Object.keys(e).sort().map(s=>{const n=e[s];return[s,n.secretId,n.version??"latest"]}))}r(dJ,"normalizeAccessMapKey");function uJ({mode:e}){return e==="env"?(0,t.jsxs)(lt,{variant:"outline",className:"h-5 gap-1 px-1.5 text-(length:--text-nano) font-normal border-sky-500/30 bg-sky-500/10 text-sky-700 dark:text-sky-300",children:[(0,t.jsx)(sue,{className:"size-3"})," Env var"]}):(0,t.jsxs)(lt,{variant:"outline",className:"h-5 gap-1 px-1.5 text-(length:--text-nano) font-normal border-violet-500/30 bg-violet-500/10 text-violet-700 dark:text-violet-300",children:[(0,t.jsx)(E5,{className:"size-3"})," API access"]})}r(uJ,"DeliveryBadge");function LQe({config:e,secrets:s,onChange:n,onCreateSecret:a,disabled:i,proposals:o,onApproveProposal:l,onRejectProposal:c}){const d=(0,u.useMemo)(()=>(o??[]).filter(L=>L.kind==="binding"),[o]),m=(0,u.useMemo)(()=>PQe(e),[e]),h=(0,u.useMemo)(()=>MQe(e),[e]),p=(0,u.useMemo)(()=>DQe(m,h),[m,h]),f=(0,u.useMemo)(()=>cJ(K4(h)),[h]),g=(0,u.useMemo)(()=>dJ(f),[f]),[v,y]=(0,u.useState)(()=>K4(h)),[w,S]=(0,u.useState)(null),j=(0,u.useRef)(new Map),N=(0,u.useRef)(g),_=(0,u.useRef)(g);(0,u.useEffect)(()=>{g!==_.current&&(_.current=g,g!==N.current&&y(K4(h)))},[g,h]);const R=r(L=>s.find(E=>E.id===L)?.name??`${L.slice(0,8)}…`,"secretName");function C(L){y(L);const E=cJ(L);N.current=dJ(E),n(E)}r(C,"emit");function A(L,E){C(v.map(q=>q.id===L?{...q,...E}:q))}r(A,"patchRow");function T(L){C(v.filter(E=>E.id!==L))}r(T,"removeRow");function I(){y(L=>[...L,{id:jxe(),alias:"",secretId:"",version:"latest"}])}r(I,"addRow");const $=(0,u.useMemo)(()=>{const L=new Map;for(const E of v){const q=E.alias.trim();q&&L.set(q,(L.get(q)??0)+1)}return L},[v]),O=p.length>0;return(0,t.jsxs)("div",{className:"space-y-3",children:[O?(0,t.jsx)("div",{className:"space-y-1.5",children:p.map(L=>(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 rounded-md border border-border bg-muted/30 px-2.5 py-1.5 text-xs",children:[(0,t.jsx)(bi,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,t.jsx)("span",{className:"font-medium",children:R(L.secretId)}),L.envKeys.length>0?(0,t.jsx)(uJ,{mode:"env"}):null,L.apiAliases.length>0?(0,t.jsx)(uJ,{mode:"api"}):null,(0,t.jsx)("span",{className:"min-w-0 truncate font-mono text-(length:--text-micro) text-muted-foreground",children:[...L.envKeys.map(E=>`${wQe}${E}`),...L.apiAliases.map(E=>`${B1}${E}`)].join(" · ")})]},L.secretId))}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"No secrets are bound to this agent yet."}),d.length>0&&l&&c?(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("div",{className:"text-(length:--text-micro) font-medium uppercase tracking-wide text-muted-foreground",children:"Proposed access"}),d.map(L=>{const E=wK(L),q=hE(L);return(0,t.jsxs)("div",{className:"flex flex-col gap-2 rounded-md border border-amber-500/30 bg-amber-500/5 px-2.5 py-2 text-xs sm:flex-row sm:items-center",children:[(0,t.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[(0,t.jsx)(yK,{configPath:L.configPath}),(0,t.jsx)("code",{className:"font-mono",children:q||L.configPath}),(0,t.jsx)("span",{className:"text-muted-foreground",children:"→"}),(0,t.jsx)(bi,{className:"size-3 text-muted-foreground"}),(0,t.jsx)("span",{className:"font-medium",children:E.name}),E.pending?(0,t.jsx)(jK,{}):null]}),(0,t.jsxs)("p",{className:"flex flex-wrap items-center gap-1 text-muted-foreground",children:[(0,t.jsxs)("span",{children:["proposed by ",L.proposedBy.name]}),(0,t.jsx)("span",{"aria-hidden":"true",children:"·"}),(0,t.jsxs)("span",{className:"truncate italic",children:["“",L.justification,"”"]})]})]}),(0,t.jsx)(bxe,{proposal:L,onApprove:l,onReject:c,disabled:i,size:"xs"})]},L.id)})]}):null,(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("div",{className:"text-(length:--text-micro) font-medium uppercase tracking-wide text-muted-foreground",children:"API access (no env var)"}),v.length>0?(0,t.jsx)("div",{className:"space-y-2",children:v.map(L=>{const E=L.alias.trim(),q=!!E&&!zF.test(E),B=!!E&&($.get(E)??0)>1,K=s.find(z=>z.id===L.secretId)??null;return(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsxs)("div",{className:"grid grid-cols-(--gtc-65) items-start gap-1.5",children:[(0,t.jsx)("div",{children:(0,t.jsx)(At,{value:L.alias,onChange:r(z=>A(L.id,{alias:z.target.value}),"onChange"),onBlur:r(z=>{const D=z.target.value.trim();if(D&&!zF.test(D)){const V=_S(D);V&&V!==D&&A(L.id,{alias:V})}},"onBlur"),placeholder:"ALIAS","aria-label":"Access alias",disabled:i,className:U("h-9 font-mono text-sm",(q||B)&&"border-destructive text-destructive")})}),(0,t.jsxs)("div",{className:"flex min-w-0 items-start gap-1.5",children:[(0,t.jsxs)(Zn,{open:w?.rowId===L.id,onOpenChange:r(z=>{!z&&w?.rowId===L.id&&S(null)},"onOpenChange"),children:[(0,t.jsx)(uO,{asChild:!0,children:(0,t.jsx)("div",{ref:r(z=>{z?j.current.set(L.id,z):j.current.delete(L.id)},"ref"),className:"min-w-0 flex-1",children:(0,t.jsx)(bK,{secretId:L.secretId,secrets:s,onSelect:r(z=>A(L.id,{secretId:z,version:"latest",alias:!L.alias.trim()&&z?_S(R(z)):L.alias}),"onSelect"),onCreateNew:a?z=>{window.setTimeout(()=>{S({rowId:L.id,name:BT(z)||z.trim()})},0)}:void 0,disabled:i,triggerClassName:"h-9 min-h-9"})})}),(0,t.jsx)(Vn,{align:"start",className:"w-auto p-3",onInteractOutside:r(z=>{const D=z.detail.originalEvent.target;D&&j.current.get(L.id)?.contains(D)&&z.preventDefault()},"onInteractOutside"),children:w?.rowId===L.id&&a?(0,t.jsx)(dxe,{initialName:w.name,initialValue:"",existingSecretNames:s.map(z=>z.name),onCancel:r(()=>S(null),"onCancel"),onSubmit:r(async(z,D)=>{const V=await a(z,D);A(L.id,{secretId:V.id,version:"latest",alias:L.alias.trim()||_S(V.name)}),S(null)},"onSubmit")}):null})]}),(0,t.jsxs)("select",{className:"h-9 shrink-0 rounded-md border border-border bg-background px-2 text-xs outline-none disabled:cursor-not-allowed disabled:opacity-60",value:L.version===void 0?"latest":String(L.version),onChange:r(z=>{const D=z.target.value;A(L.id,{version:D==="latest"?"latest":Number.parseInt(D,10)})},"onChange"),disabled:i||!K,"aria-label":"Version",children:[(0,t.jsx)("option",{value:"latest",children:"latest"}),K?Array.from({length:Math.max(0,K.latestVersion)},(z,D)=>{const V=K.latestVersion-D;return V<=0?null:(0,t.jsxs)("option",{value:V,children:["v",V]},V)}):null]})]}),(0,t.jsx)("button",{type:"button",onClick:r(()=>T(L.id),"onClick"),disabled:i,"aria-label":"Remove API access",className:"mt-1 inline-flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:pointer-events-none disabled:opacity-50",children:(0,t.jsx)(Ia,{className:"size-3.5"})})]}),q?(0,t.jsx)("p",{className:"pl-0.5 text-(length:--text-micro) text-destructive",children:"Invalid alias — use letters, digits and _"}):B?(0,t.jsx)("p",{className:"pl-0.5 text-(length:--text-micro) text-destructive",children:"Duplicate alias"}):null]},L.id)})}):null,(0,t.jsxs)("button",{type:"button",onClick:I,disabled:i,className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:pointer-events-none disabled:opacity-50",children:[(0,t.jsx)(gn,{className:"size-3.5"}),"Add API access"]})]}),(0,t.jsxs)("p",{className:"text-(length:--text-micro) text-muted-foreground/70",children:[NQe("api")," The agent reads them by alias through ",(0,t.jsx)("code",{children:"GET /agents/me/secrets"}),"."]})]})}r(LQe,"AgentSecretAccessEditor");function $Qe(e){if(typeof e!="string")return null;const s=e.trim();return s.length>0?s:null}r($Qe,"asNonEmptyString$3");function OQe(e){return $Qe(e)!==null}r(OQe,"hasLegacyWorkingDirectory");function FQe(e){return e.isCreate?!1:OQe(e.adapterConfig?.cwd)}r(FQe,"shouldShowLegacyWorkingDirectoryField");var wxe=new Set;function BQe(e){return wxe.has(e)}r(BQe,"isAdapterTypeHidden");function qQe(e){wxe=new Set(e)}r(qQe,"setDisabledAdapterTypes");function zQe(e){return!Um(e).hideFromVisualSelection}r(zQe,"isVisualAdapterChoice");function Nxe(e,s=xK()){const n=e??mf;return s.map(a=>({value:a.type,label:n(a.type),comingSoon:!!Um(a.type).comingSoon,hidden:BQe(a.type),experimental:!!Um(a.type).experimental}))}r(Nxe,"listAdapterOptions");function kxe(e={}){const s=e.enabled??!0,{data:n}=Z({queryKey:P.adapters.all,queryFn:r(()=>Rm.list(),"queryFn"),enabled:s,staleTime:3e5});return n&&zHe(n.filter(a=>a.source==="external").map(a=>({type:a.type,label:a.label,disabled:a.disabled,overrideDisabled:a.overridePaused}))),(0,u.useEffect)(()=>{n&&qQe(n.filter(a=>a.disabled).map(a=>a.type))},[n]),(0,u.useMemo)(()=>new Set(n?.filter(a=>a.disabled).map(a=>a.type)??[]),[n])}r(kxe,"useDisabledAdaptersSync");function UQe(e={}){const s=e.enabled??!0,{data:n}=Z({queryKey:P.adapters.all,queryFn:r(()=>Rm.list(),"queryFn"),enabled:s,staleTime:3e5});return n!==void 0}r(UQe,"useAdapterRegistryLoaded");function qT(e){return Object.fromEntries(Object.entries(e).filter(([,s])=>s!==void 0))}r(qT,"omitUndefinedEntries");function yI(e,s){const n={};if(Object.keys(s.identity).length>0&&Object.assign(n,s.identity),s.adapterType!==void 0&&(n.adapterType=s.adapterType),s.adapterType!==void 0||Object.keys(s.adapterConfig).length>0){const a=e.adapterConfig??{};n.adapterConfig=qT(s.adapterType!==void 0?{...Object.fromEntries(aIe.filter(i=>a[i]!==void 0).map(i=>[i,a[i]])),...s.adapterConfig}:{...a,...s.adapterConfig}),n.replaceAdapterConfig=!0}if(Object.keys(s.heartbeat).length>0||Object.keys(s.debug).length>0){const a=e.runtimeConfig??{},i=n.runtimeConfig??{...a};if(Object.keys(s.heartbeat).length>0&&(i.heartbeat={...a.heartbeat??{},...s.heartbeat}),Object.keys(s.debug).length>0){const o=qT({...a.debug??{},...s.debug});Object.keys(o).length===0?delete i.debug:i.debug=o}n.runtimeConfig=i}return Object.keys(s.runtime).length>0&&Object.assign(n,s.runtime),n}r(yI,"buildAgentUpdatePatch");var KQe="kubernetes";function VQe(e){return e.driver!=="sandbox"?!1:e.config?.provider===KQe}r(VQe,"isKubernetesSandboxEnvironment");function NK(e,s){return e!=="kubernetes"?{forced:!1,kubernetesEnvironment:null}:{forced:!0,kubernetesEnvironment:s.find(n=>VQe(n))??null}}r(NK,"resolveForcedKubernetesEnvironment");var V4={identity:{},adapterConfig:{},heartbeat:{},debug:{},runtime:{}},rk={};function WQe(e){return e==="claude_local"||e==="codex_local"||e==="paperclip_runner"||e==="opencode_local"}r(WQe,"supportsAdapterModelRefresh");function HQe(e,s){return nhe(e,s).model}r(HQe,"resolvePaperclipRunnerTransitionModel");function mJ(e){return Object.keys(e.identity).length>0||e.adapterType!==void 0||Object.keys(e.adapterConfig).length>0||Object.keys(e.heartbeat).length>0||Object.keys(e.debug).length>0||Object.keys(e.runtime).length>0}r(mJ,"isOverlayDirty");function UF(e,s){if(Object.is(e,s))return!0;if(Array.isArray(e)&&Array.isArray(s))return e.length===s.length&&e.every((n,a)=>UF(n,s[a]));if(typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof s=="object"&&s!==null&&!Array.isArray(s)){const n=Object.entries(e),a=s;return n.length===Object.keys(a).length&&n.every(([i,o])=>i in a&&UF(o,a[i]))}return!1}r(UF,"overlayValuesEqual");function QQe(e,s){const n=r((a,i)=>Object.fromEntries(Object.entries(a).filter(([o,l])=>!(o in i)||!UF(l,i[o]))),"subtractGroup");return{identity:n(e.identity,s.identity),...e.adapterType!==void 0&&e.adapterType!==s.adapterType?{adapterType:e.adapterType}:{},adapterConfig:n(e.adapterConfig,s.adapterConfig),heartbeat:n(e.heartbeat,s.heartbeat),debug:n(e.debug,s.debug),runtime:n(e.runtime,s.runtime)}}r(QQe,"subtractPersistedOverlay");var vm="w-full rounded-md border border-border px-2.5 py-1.5 bg-transparent outline-none text-sm font-mono placeholder:text-muted-foreground/40";function GQe(e){return e.split(",").map(s=>s.trim()).filter(Boolean)}r(GQe,"parseCommaArgs");function YQe(e){return Array.isArray(e)?e.filter(s=>typeof s=="string").join(", "):typeof e=="string"?e:""}r(YQe,"formatArgList");var JQe=[{id:"",label:"Auto"},{id:"minimal",label:"Minimal"},{id:"low",label:"Low"},{id:"medium",label:"Medium"},{id:"high",label:"High"},{id:"xhigh",label:"X-High"},{id:"max",label:"Max"}],XQe=[{id:"",label:"Auto"},{id:"plan",label:"Plan"},{id:"ask",label:"Ask"}],ZQe=[{id:"",label:"Auto"},{id:"low",label:"Low"},{id:"medium",label:"Medium"},{id:"high",label:"High"}],eGe=[{id:"",label:"Auto"},{id:"low",label:"Low"},{id:"high",label:"High"},{id:"max",label:"Max"}],tGe=2,hJ=10,sGe=1,Sxe=300;function $2(e,s,n){return Math.max(s,Math.min(n,Math.floor(e)))}r($2,"clampInteger");function nGe(e){return $2(e,0,Sxe)*1e3}r(nGe,"clampDelayMsFromSeconds");function rGe({order:e,className:s,children:n}){if(!e)return(0,t.jsx)("div",{className:s,children:n});const a=r(o=>{const l=(0,u.isValidElement)(o)?o.props["data-config-section"]:void 0,c=l?e.indexOf(l):-1;return c<0?e.length:c},"rank"),i=u.Children.toArray(n).sort((o,l)=>a(o)-a(l));return(0,t.jsx)("div",{className:s,children:i})}r(rGe,"ConfigSections");function Cxe(e){const{mode:s,adapterModels:n}=e,a=s==="create",i=e.sectionLayout==="cards",o=e.showAdapterTypeField??!0,l=e.showAdapterTestEnvironmentButton??!0,c=l&&!e.onTestActionChange&&!e.compactTestFeedback,d=!e.onTestFeedbackChange,m=e.showCreateRunPolicySection??!0,h=e.hideInstructionsFile??!1,p=e.canConfigureProviderTrace===!0,{selectedCompanyId:f}=ps(),g=Wt(),v=(0,u.useRef)(null),y=kxe(),{data:w=[]}=Z({queryKey:f?P.secrets.list(f):["secrets","none"],queryFn:r(()=>fr.list(f),"queryFn"),enabled:!!f}),{data:S=[]}=Z({queryKey:f?P.secrets.userDefinitions(f):["user-secret-definitions","none"],queryFn:r(()=>fr.listUserSecretDefinitions(f),"queryFn"),enabled:!!f,retry:!1}),j=a?null:e.agent.id,{data:N=[]}=Z({queryKey:f?P.secrets.proposals(f,"pending"):["secret-proposals","none"],queryFn:r(()=>fr.listProposals(f,"pending"),"queryFn"),enabled:!!f&&!a,retry:!1}),_=(0,u.useMemo)(()=>N.filter(et=>et.kind==="binding"&&et.target?.id===j),[N,j]),R=gxe(f,[]),{data:C}=Z({queryKey:P.instance.experimentalSettings,queryFn:r(()=>Er.getExperimental(),"queryFn"),retry:!1}),A=(0,u.useMemo)(()=>{const et=new Set(y);return C?.enableNativeRunner!==!0&&et.add("paperclip_runner"),et},[y,C?.enableNativeRunner]),T=C?.enableEnvironments===!0,I=C?.enableManagedSandboxOnly===!0,$=C===void 0||I,{data:O}=Z({queryKey:P.instance.generalSettings,queryFn:r(()=>Er.getGeneral(),"queryFn"),retry:!1}),{data:L}=Z({queryKey:P.instance.settings,queryFn:r(()=>Er.get(),"queryFn"),retry:!1}),{data:E=[]}=Z({queryKey:f?P.environments.list(f):["environments","none"],queryFn:r(()=>Ci.list(f),"queryFn"),enabled:!!f&&(T||O?.executionMode==="kubernetes")}),{forced:q,kubernetesEnvironment:B}=(0,u.useMemo)(()=>NK(O?.executionMode,E),[O?.executionMode,E]),K=Ne({mutationFn:r(et=>{if(!f)throw new Error("Select an organization to create secrets");return fr.create(f,et)},"mutationFn"),onSuccess:r(()=>{f&&g.invalidateQueries({queryKey:P.secrets.list(f)})},"onSuccess")}),z=Ne({mutationFn:r(async({file:et,namespace:Ht})=>{if(!f)throw new Error("Select an organization to upload images");return m0.uploadImage(f,et,Ht)},"mutationFn")}),[D,V]=(0,u.useState)(V4),[H,ee]=(0,u.useState)(!1),[X,le]=(0,u.useState)(0),ce=(0,u.useRef)(null),te=(0,u.useRef)(null),ae=(0,u.useRef)(!1);(0,u.useEffect)(()=>{if(!a){if(ce.current!==null&&e.agent!==ce.current&&!ae.current){const et=te.current;te.current=null,V(Ht=>et?QQe(Ht,et):{...V4})}ce.current=e.agent}},[a,a?void 0:e.agent]);const de=!a&&(mJ(D)||H);function J(et,Ht,un){const Os=D[et];return Ht in Os?Os[Ht]:un}r(J,"eff");function Y(et,Ht,un){V(Os=>({...Os,[et]:{...Os[et],[Ht]:un}}))}r(Y,"mark");function G(){return v.current?.flushPendingDraft()??null}r(G,"flushEnvironmentDraft");const fe=(0,u.useCallback)(et=>{a||V(Ht=>{const un={...e.agent.adapterConfig??{},...Ht.adapterConfig},Os={...Ht.adapterConfig};for(const[Jn,vr]of Object.entries(et))Os[`${B1}${Jn}`]=vr;for(const Jn of Object.keys(un))Jn.startsWith("access.")&&(Jn.slice(7)in et||(Os[Jn]=void 0));return{...Ht,adapterConfig:Os}})},[a,a?void 0:e.agent]),se=(0,u.useCallback)(()=>{V({...V4}),ee(!1),le(et=>et+1)},[]),re=(0,u.useCallback)(async()=>{if(a)return;const et=G(),Ht=et?{...D,adapterConfig:{...D.adapterConfig,env:et}}:D;mJ(Ht)&&await e.onSave(yI(e.agent,Ht))},[a,de,D,e]);(0,u.useEffect)(()=>{a||(e.onDirtyChange?.(de),e.onSaveActionChange?.(re),e.onCancelActionChange?.(se))},[a,de,e.onDirtyChange,e.onSaveActionChange,e.onCancelActionChange,re,se]),(0,u.useEffect)(()=>{if(!a)return()=>{e.onSaveActionChange?.(null),e.onCancelActionChange?.(null),e.onDirtyChange?.(!1)}},[a,e.onDirtyChange,e.onSaveActionChange,e.onCancelActionChange]);const ie=a?{}:e.agent.adapterConfig??{},me=a?{}:e.agent.runtimeConfig??{},pe=a?{}:me.heartbeat??{},be=a?{}:me.debug??{},oe=a?e.values.adapterType:D.adapterType??e.agent.adapterType,ye=Zw(),Ae=ye(oe),xe=Ae.supportsInstructionsBundle||Ae.supportsSkills||Ae.supportsLocalAgentJwt,_e=xe&&!$&&FQe({isCreate:a,adapterConfig:ie}),Ge=(0,u.useMemo)(()=>uN(oe),[oe]),$e=(0,u.useMemo)(()=>new Set(CTe(oe)),[oe]),Ye=a?e.values:null,ue=a?et=>e.onChange(et):null;a&&Ye.claudeStoredSessionId;const Oe=r(()=>{f&&g.invalidateQueries({queryKey:P.secrets.userDefinitions(f)})},"invalidateUserSecretDefinitions"),dt=r(et=>{if(!a||!ue)return;const Ht=Ye.envBindings??{};ue({envBindings:{...Ht,...fj()},claudeStoredSessionId:et}),Oe()},"handleClaudeLoginStored"),xt=r(async()=>{if(a)return;const et={...G()??J("adapterConfig","env",ie.env??rk),...fj()},Ht={...D,adapterConfig:{...D.adapterConfig,env:et}};V(Ht),await e.onSave({...yI(e.agent,Ht),applyStoredClaudeLogin:!0}),Oe()},"handleClaudeLoginStoredEdit"),De=r(async et=>{if(a||!et.companyIdentityDiffers)return;const Ht={...G()??J("adapterConfig","env",ie.env??rk),CODEX_HOME:{type:"secret_ref",secretId:et.secretId,version:"latest"}},un={...D,adapterConfig:{...D.adapterConfig,env:Ht}};V(un),te.current=un,ae.current=!0;try{await e.onSave(yI(e.agent,un))}catch(Os){throw te.current=null,Os}finally{ae.current=!1}Oe()},"handleCodexAccountBindingEdit"),Qe=r(()=>{if(!a||!ue)return;const et=Ye.envBindings??{};ue({envBindings:{...et,...fj()},claudeApplyStoredLogin:!0}),Oe()},"handleApplyStoredClaudeLogin"),ht=r(async()=>{if(a)return;const et={...G()??J("adapterConfig","env",ie.env??rk),...fj()},Ht={...D,adapterConfig:{...D.adapterConfig,env:et}};V(Ht),await e.onSave({...yI(e.agent,Ht),applyStoredClaudeLogin:!0}),Oe()},"handleApplyStoredClaudeLoginEdit"),We=a?Ye.defaultEnvironmentId??"":J("identity","defaultEnvironmentId",e.agent.defaultEnvironmentId??""),Ke=(0,u.useMemo)(()=>We?(E.find(et=>et.id===We)??null)?.driver==="local"?"":We:"",[E,We]),gt=(0,u.useMemo)(()=>E.find(et=>et.id===Ke)??null,[Ke,E]),tt=(0,u.useMemo)(()=>{const et=L?.defaultEnvironmentId??null;return et?(E.find(Ht=>Ht.id===et)??null)?.driver==="local"?"":et:""},[E,L?.defaultEnvironmentId]),Se=(0,u.useMemo)(()=>E.find(et=>et.id===tt)??null,[E,tt]),ke=(0,u.useMemo)(()=>{try{return vw({agentDefaultEnvironmentId:We||null,instanceDefaultEnvironmentId:L?.defaultEnvironmentId??null,localDefaultEnvironmentId:jw(E),managedSandboxOnly:C?.enableManagedSandboxOnly===!0,managedSandboxEnvironmentId:yw(E),visibleEnvironmentIds:E.map(et=>et.id)})}catch{return null}},[We,L?.defaultEnvironmentId,E,C?.enableManagedSandboxOnly]),Xe=(0,u.useMemo)(()=>E.find(et=>et.id===ke)??null,[E,ke]),{data:ut}=Z({queryKey:f?P.environments.capabilities(f):["environment-capabilities","none"],queryFn:r(()=>Ci.capabilities(f),"queryFn"),enabled:!!f&&Ae.login!=null});(0,u.useEffect)(()=>{!a||!ue||!q||!B||Ke!==B.id&&ue({defaultEnvironmentId:B.id})},[a,ue,q,B,Ke]);const Lt=(0,u.useMemo)(()=>E.filter(et=>{if(!$e.has(et.driver)||et.driver==="local")return!1;if(et.driver!=="sandbox")return!0;const Ht=typeof et.config?.provider=="string"?et.config.provider:null;return Ht!==null&&Ht!=="fake"}),[E,$e]),Xt=(0,u.useMemo)(()=>!gt||Lt.some(et=>et.id===gt.id)?Lt:[...Lt,gt],[gt,Lt]),fs=T&&(q||Ke.length>0||Lt.length>=1),Ve=Se?ww(Se):I?"Paperclip Computer":"Local",He=oe==="paperclip_runner"?String(a?e.values.adapterSchemaValues?.provider??"codex":J("adapterConfig","provider",ie.provider==="acpx"&&ie.acpxAgent==="codex"?"codex":ie.provider??"codex")):void 0,ct=oe==="opencode_local"&&u2.safeParse(D.runtime.runtimeConfig?.aiConnection??me.aiConnection).data?.provider==="openrouter"?"openrouter":He,ze=f?P.agents.adapterModels(f,oe,Ke||null,ct):["agents","none","adapter-models",oe],{data:is,error:Fe}=Z({queryKey:ze,queryFn:r(()=>Vt.adapterModels(f,oe,{environmentId:Ke||null,provider:ct}),"queryFn"),enabled:!!f}),[Qt,It]=(0,u.useState)(null),[Ms,Ue]=(0,u.useState)(!1),pt=is??n??[],$t="command",{data:gs,refetch:Ts}=Z({queryKey:f?P.agents.detectModel(f,oe):["agents","none","detect-model",oe],queryFn:r(()=>{if(!f)throw new Error("Select an organization to detect the model");return Vt.detectModel(f,oe)},"queryFn"),enabled:!!(f&&xe&&oe!=="opencode_local"&&oe!=="paperclip_runner")}),St=gs?.model??null;gs?.candidates;const{data:we=[]}=Z({queryKey:f?P.agents.list(f):["agents","none","list"],queryFn:r(()=>Vt.list(f),"queryFn"),enabled:!!(!a&&f)}),Pe={mode:s,isCreate:a,adapterType:oe,values:a?e.values:null,set:a?et=>e.onChange(et):null,config:ie,eff:J,mark:Y,models:pt,hideInstructionsFile:h||$,managedSandboxOnly:$},[it,Ot]=(0,u.useState)(!1),[ft,us]=(0,u.useState)(!1),cn=Rfe(oe),xs=r(et=>(0,t.jsxs)(t.Fragment,{children:[oe==="claude_local"&&(0,t.jsx)(k9e,{...Pe,section:et}),(0,t.jsx)(Ge.ConfigFields,{...Pe,section:et,hideModel:xe})]}),"renderAdapterFields"),[bs,qe]=(0,u.useState)(!1),[wt,kt]=(0,u.useState)(!1);function Ee(et){if(a){const un=Ge.buildAdapterConfig(Ye);return et&&Object.assign(un,et),qT(un)}const Ht={...ie,...D.adapterConfig};return et&&Object.assign(Ht,et),qT(Ht)}r(Ee,"buildAdapterConfigForTest");const Le=Ne({mutationFn:r(async()=>{if(!f)throw new Error("Select an organization to test adapter environment");const et=G(),Ht=et?{env:et}:void 0;let un=L,Os=E,Jn=C?.enableManagedSandboxOnly===!0;if(!We)try{const[rs,pn,Hs]=await Promise.all([g.ensureQueryData({queryKey:P.instance.settings,queryFn:r(()=>Er.get(),"queryFn")}),g.ensureQueryData({queryKey:P.environments.list(f),queryFn:r(()=>Ci.list(f),"queryFn")}),g.ensureQueryData({queryKey:P.instance.experimentalSettings,queryFn:r(()=>Er.getExperimental(),"queryFn")})]);un=rs,Os=pn,Jn=Hs?.enableManagedSandboxOnly===!0}catch{throw new Error("Could not load environment settings to determine which environment to test in. Retry the test.")}const vr=vw({agentDefaultEnvironmentId:We||null,instanceDefaultEnvironmentId:un?.defaultEnvironmentId??null,localDefaultEnvironmentId:jw(Os),managedSandboxOnly:Jn,managedSandboxEnvironmentId:yw(Os),visibleEnvironmentIds:Os.map(rs=>rs.id)}),Na=Ee(Ht),zn=a?void 0:e.agent.id,Xn=a?void 0:u2.safeParse(D.runtime.runtimeConfig?.aiConnection??e.agent.runtimeConfig.aiConnection).data;if(e.compactTestFeedback){const rs=oe==="paperclip_runner"?Na.provider==="codex"?"codex_local":Na.provider==="acpx"&&Na.acpxAgent==="claude"?"claude_local":oe:oe;return wfe({companyId:f,adapterType:oe,providerAdapter:rs,adapterConfig:Na,agentId:zn,aiConnection:Xn,environmentId:vr})}return Vt.testEnvironment(f,oe,{adapterConfig:Na,agentId:zn,aiConnection:Xn,environmentId:vr})},"mutationFn")}),[Ze,Nt]=(0,u.useState)(!1),[Ut,Dt]=(0,u.useState)(null),Ft="Test",Yt=!a&&!!e.isSaving,Ws=Ze||Yt||!f,_n=(0,u.useRef)(Le.reset);_n.current=Le.reset;const In=(0,u.useRef)(()=>{});In.current=()=>{if(!a||!ue)return;const et=Ye.envBindings??{},Ht=Ye.claudeStoredSessionId!=null||Ye.claudeApplyStoredLogin===!0,un=sJ in et;if(!Ht&&!un)return;const Os={...et};delete Os[sJ],ue({envBindings:Os,claudeStoredSessionId:null,claudeApplyStoredLogin:!1})},(0,u.useEffect)(()=>{_n.current(),Dt(null),In.current()},[oe,ke]);const en=Ae.login!=null,Us=Le.data,ws=Us!=null&&ye(Us.adapterType).login!=null,nn=Us&&ws?Us.checks.find(et=>et.code==="adapter_auth_missing")??null:null,zs=typeof Xe?.config?.provider=="string"?Xe.config.provider:null,An=zs!=null&&ut?.sandboxProviders?.[zs]?.supportsLoginPty===!0,hn=Ae.login!=null,rn=(a||!(D.runtime.runtimeConfig?.aiConnection??me.aiConnection))&&en&&Xe?.driver==="sandbox"&&!!ke&&!!f&&!!nn&&(!hn||An),pr=(0,u.useCallback)(async()=>{if(!f)throw new Error("Select an organization to test adapter environment");Nt(!0),Dt(null),Le.reset();try{return await Le.mutateAsync()}catch(et){throw Dt(et instanceof Error?et.message:"Environment test failed"),et}finally{Nt(!1)}},[f,Le]),Zs=(0,u.useRef)(()=>{});(0,u.useEffect)(()=>{Zs.current=()=>{Ws||pr().catch(()=>{})}},[pr,Ws]);const er=(0,u.useCallback)(()=>{Zs.current()},[]);(0,u.useEffect)(()=>{if(!(!l||!e.onTestActionChange))return e.onTestActionChange(er),()=>{e.onTestActionChange?.(null)}},[l,e.onTestActionChange,er]),(0,u.useEffect)(()=>{if(!(!l||!e.onTestActionStateChange))return e.onTestActionStateChange({disabled:Ws,pending:Ze}),()=>{e.onTestActionStateChange?.({disabled:!0,pending:!1})}},[l,e.onTestActionStateChange,Ws,Ze]),(0,u.useEffect)(()=>{if(e.onTestFeedbackChange)return e.onTestFeedbackChange({errorMessage:Ut??(Le.error instanceof Error?Le.error.message:Le.error?"Environment test failed":null),result:Le.data??null,login:rn&&f&&ke?{companyId:f,adapterType:oe,environmentId:ke}:null}),()=>{e.onTestFeedbackChange?.({errorMessage:null,result:null,login:null})}},[e.onTestFeedbackChange,Ut,Le.data,Le.error,rn,f,oe,ke]);const tr=a?Ye.model??"":J("adapterConfig","model",String(ie.model??"")),Ur=typeof tr=="string"?tr:"";async function mr(){if(f){Ue(!0),It(null);try{const et=await Vt.adapterModels(f,oe,{refresh:!0,environmentId:Ke||null,provider:ct});g.setQueryData(ze,et)}catch(et){It(et instanceof Error?et.message:"Failed to refresh adapter models.")}finally{Ue(!1)}}}r(mr,"handleRefreshModels");const br=oe==="codex_local"?"modelReasoningEffort":oe==="cursor"?"mode":oe==="opencode_local"?"variant":oe==="grok_local"?"reasoningEffort":oe==="pi_local"?"thinking":"effort",sr=oe==="codex_local"?uC(Ur,"Auto").map(et=>({id:et.value,label:et.label})):oe==="cursor"?XQe:oe==="opencode_local"?JQe:oe==="kimi_local"?eGe:oe==="pi_local"?[{id:"",label:"Auto"},...["off","minimal","low","medium","high","xhigh"].map(et=>({id:et,label:et}))]:oe==="claude_local"||oe==="grok_local"?[{id:"",label:"Auto"},...DT(oe,Ur).map(et=>({id:et,label:et==="xhigh"?"X-High":et[0].toUpperCase()+et.slice(1)}))]:ZQe,ra=a?Ye.thinkingEffort:oe==="codex_local"?J("adapterConfig","modelReasoningEffort",String(ie.modelReasoningEffort??ie.reasoningEffort??"")):oe==="cursor"?J("adapterConfig","mode",String(ie.mode??"")):oe==="opencode_local"?J("adapterConfig","variant",String(ie.variant??"")):J("adapterConfig",br,String(ie[br]??"")),Bn=oe!=="gemini_local"&&oe!=="cursor_cloud"&&oe!=="paperclip_runner",_r=oe==="codex_local"?a?!!Ye.search:J("adapterConfig","search",!!ie.search):!1,ya=(0,u.useMemo)(()=>{if(a)return{heartbeat:{enabled:Ye.heartbeatEnabled,intervalSec:Ye.intervalSec}};const et={...me.heartbeat&&typeof me.heartbeat=="object"?me.heartbeat:{},...D.heartbeat};return{...me,heartbeat:et}},[a,D.heartbeat,me,Ye]),Nn=eH(ya.heartbeat),On=eH(Nn.maxTurnContinuation),on=eAe(On.enabled,!0),cr=$2(oH(On.maxAttempts,tGe),0,hJ),bt=$2(oH(On.delayMs,sGe*1e3)/1e3,0,Sxe);function Ds(et){Y("heartbeat","maxTurnContinuation",{...On,...et})}r(Ds,"updateMaxTurnContinuation");const Fs=(0,t.jsx)(rv,{ref:v,onDirtyChange:ee,hideDraftActions:!a&&e.hideInlineSave,value:a?Ye.envBindings??rk:J("adapterConfig","env",ie.env??rk),secrets:w,userSecretDefinitions:S,onCreateSecret:r(async(et,Ht)=>await K.mutateAsync({name:et,value:Ht}),"onCreateSecret"),onChange:r(et=>a?ue({envBindings:et??{},envVars:""}):Y("adapterConfig","env",et),"onChange")},X);return!a&&e.content==="secrets"?(0,t.jsxs)("div",{className:U("relative",i&&"space-y-6"),children:[de&&!e.hideInlineSave&&(0,t.jsx)("div",{className:"sticky top-0 z-10 flex items-center justify-end border-b border-primary/20 bg-background/90 px-4 py-2 backdrop-blur-sm",children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"Unsaved changes"}),(0,t.jsx)(F,{size:"sm",onClick:re,disabled:e.isSaving,children:e.isSaving?"Saving...":"Save"})]})}),e.environmentVariablesPlacement==="secrets"&&(0,t.jsxs)("div",{"data-config-section":"environment-variables",className:U(!i&&"border-b border-border"),children:[i?(0,t.jsx)("h3",{className:"mb-3 text-sm font-medium",children:"Environment variables"}):(0,t.jsx)("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground",children:"Environment variables"}),(0,t.jsx)("div",{className:U(i?"rounded-lg border border-border p-4":"px-4 pb-3"),children:Fs})]}),(0,t.jsxs)("div",{"data-config-section":"secrets",className:U(!i&&"border-b border-border"),children:[i?(0,t.jsx)("h3",{className:"mb-3 text-sm font-medium",children:"Secret access"}):(0,t.jsx)("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground",children:"Secret access"}),(0,t.jsxs)("div",{className:U(i?"space-y-3 rounded-lg border border-border p-4":"space-y-3 px-4 pb-3"),children:[(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:fi.secretAccess}),(0,t.jsx)(LQe,{config:{...ie,...D.adapterConfig},secrets:w,onChange:fe,onCreateSecret:r((et,Ht)=>K.mutateAsync({name:et,value:Ht}),"onCreateSecret"),proposals:_,onApproveProposal:R.requestApprove,onRejectProposal:R.requestReject}),R.dialogs]})]})]}):(0,t.jsxs)(rGe,{order:e.sectionOrder,className:U("relative",i&&"space-y-6"),children:[de&&!e.hideInlineSave&&(0,t.jsx)("div",{className:"sticky top-0 z-10 flex items-center justify-end px-4 py-2 bg-background/90 backdrop-blur-sm border-b border-primary/20",children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"Unsaved changes"}),(0,t.jsx)(F,{size:"sm",onClick:re,disabled:!a&&e.isSaving,children:!a&&e.isSaving?"Saving...":"Save"})]})}),!a&&(0,t.jsxs)("div",{"data-config-section":"identity",className:U(!i&&"border-b border-border"),children:[i?(0,t.jsx)("h3",{className:"text-sm font-medium mb-3",children:e.sectionTitles?.identity??"Identity"}):(0,t.jsx)("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground",children:"Identity"}),(0,t.jsxs)("div",{className:U(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:[(0,t.jsx)(ys,{label:"Name",hint:fi.name,children:(0,t.jsx)(Ba,{value:J("identity","name",e.agent.name),onCommit:r(et=>Y("identity","name",et),"onCommit"),immediate:!0,className:vm,placeholder:"Agent name"})}),(0,t.jsx)(ys,{label:"Title",hint:fi.title,children:(0,t.jsx)(Ba,{value:J("identity","title",e.agent.title??""),onCommit:r(et=>Y("identity","title",et||null),"onCommit"),immediate:!0,className:vm,placeholder:"e.g. VP of Engineering"})}),(0,t.jsx)(ys,{label:"Reports to",hint:fi.reportsTo,children:(0,t.jsx)(QHe,{agents:we,value:J("identity","reportsTo",e.agent.reportsTo??null),onChange:r(et=>Y("identity","reportsTo",et),"onChange"),excludeAgentIds:[e.agent.id],chooseLabel:"Choose manager…"})}),xe&&!e.hidePromptTemplate&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ys,{label:"Prompt Template",hint:fi.promptTemplate,children:(0,t.jsx)(kc,{value:J("adapterConfig","promptTemplate",String(ie.promptTemplate??"")),onChange:r(et=>Y("adapterConfig","promptTemplate",et??""),"onChange"),placeholder:"You are agent {{ agent.name }}. Your role is {{ agent.role }}...",contentClassName:"min-h-(--sz-88px) text-sm font-mono",imageUploadHandler:r(async et=>{const Ht=`agents/${e.agent.id}/prompt-template`;return(await z.mutateAsync({file:et,namespace:Ht})).contentPath},"imageUploadHandler")})}),(0,t.jsx)("div",{className:"rounded-md border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-xs text-amber-900 dark:text-amber-100",children:"Prompt template is replayed on every heartbeat. Keep it compact and dynamic to avoid recurring token cost and cache churn."})]})]})]}),q?(0,t.jsxs)("div",{"data-config-section":"environment",className:U(!i&&(a?"border-t border-border":"border-b border-border")),children:[i?(0,t.jsx)("h3",{className:"text-sm font-medium mb-3",children:"Environment"}):(0,t.jsx)("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground",children:"Environment"}),(0,t.jsx)("div",{className:U(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:(0,t.jsx)(ys,{label:"Default environment",hint:"This instance runs all agents in the Kubernetes sandbox. Local execution is disabled.",children:B?(0,t.jsxs)("div",{className:U(vm,"flex items-center text-muted-foreground"),children:[B.name," · Kubernetes sandbox"]}):(0,t.jsx)("div",{className:"rounded-md border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-xs text-amber-800 dark:text-amber-200",children:"This instance requires the Kubernetes sandbox, but no managed Kubernetes environment is available for this organization yet. Configure one before creating agents; execution will not fall back to local."})})})]}):fs?(0,t.jsxs)("div",{"data-config-section":"environment",className:U(!i&&(a?"border-t border-border":"border-b border-border")),children:[i?(0,t.jsx)("h3",{className:"text-sm font-medium mb-3",children:"Environment"}):(0,t.jsx)("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground",children:"Environment"}),(0,t.jsx)("div",{className:U(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:(0,t.jsx)(ys,{label:"Environment override",children:(0,t.jsx)("div",{className:"space-y-2",children:(0,t.jsxs)("select",{className:vm,value:Ke,onChange:r(et=>{const Ht=et.target.value;if(a){ue({defaultEnvironmentId:Ht});return}Y("identity","defaultEnvironmentId",Ht||null)},"onChange"),children:[(0,t.jsxs)("option",{value:"",children:["Default: ",Ve]}),Xt.map(et=>(0,t.jsx)("option",{value:et.id,children:ww(et)},et.id))]})})})})]}):null,(0,t.jsxs)("div",{"data-config-section":"adapter",className:U(!i&&(a?"border-t border-border":"border-b border-border")),children:[(0,t.jsxs)("div",{className:U(i?"flex items-center justify-between mb-3":"px-4 py-2 flex items-center justify-between gap-2"),children:[i?(0,t.jsx)("h3",{className:"text-sm font-medium",children:e.sectionTitles?.adapter??"Adapter"}):(0,t.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:"Adapter"}),c&&(0,t.jsx)(F,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2.5 text-xs",onClick:er,disabled:Ws,children:Ze?`${Ft}...`:Ft})]}),(0,t.jsxs)("div",{className:U(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:[o&&(0,t.jsx)(ys,{label:"Adapter type",hint:fi.adapterType,children:(0,t.jsx)(Ixe,{value:oe,disabledTypes:A,onChange:r(et=>{if(a){const{adapterType:Ht,...un}=t0,Os={...un,adapterType:et};et==="codex_local"?Os.dangerouslyBypassSandbox=!0:et==="gemini_local"?Os.model="auto":et==="kimi_local"?Os.model="kimi-code/kimi-for-coding":et==="cursor"?Os.model="auto":et==="opencode_local"?Os.model="openai/gpt-5.2-codex":et==="paperclip_runner"&&(Os.model=pw),ue(Os)}else V(Ht=>({...Ht,adapterType:et,adapterConfig:{model:et==="gemini_local"?"auto":et==="kimi_local"?"kimi-code/kimi-for-coding":et==="opencode_local"?"openai/gpt-5.2-codex":et==="cursor"?"auto":et==="paperclip_runner"?HQe(oe,ie.model):"",effort:"",modelReasoningEffort:"",variant:"",mode:"",...et==="codex_local"?{dangerouslyBypassApprovalsAndSandbox:!0}:et==="paperclip_runner"?{...nhe(oe,J("adapterConfig","model",ie.model))}:{}}}))},"onChange")})}),!a&&f&&(0,t.jsx)(jfe,{companyId:f,agentId:e.agent.id,agentName:e.agent.name,adapterType:oe==="paperclip_runner"?J("adapterConfig","provider",ie.provider)==="codex"?"codex_local":J("adapterConfig","provider",ie.provider)==="opencode"?"opencode_local":J("adapterConfig","provider",ie.provider)==="acpx"&&J("adapterConfig","acpxAgent",ie.acpxAgent)==="claude"?"claude_local":oe:oe,value:u2.safeParse(D.runtime.runtimeConfig?.aiConnection??me.aiConnection).data,model:String(J("adapterConfig","model",ie.model)??""),environmentId:Ke||void 0,legacy:!0,onChange:r(et=>Y("runtime","runtimeConfig",{...me,aiConnection:et}),"onChange")}),d&&!e.compactTestFeedback&&(Ut||Le.error)&&(0,t.jsx)("div",{className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:Ut??(Le.error instanceof Error?Le.error.message:"Environment test failed")}),d&&!e.compactTestFeedback&&Le.data&&(0,t.jsx)(uGe,{result:Le.data}),d&&rn&&(0,t.jsx)(kK,{companyId:f,adapterType:oe,environmentId:ke,onStored:a?dt:xt,onApplyStored:a?Qe:ht,onAccountBinding:a?void 0:De},`${oe}:${ke}`),_e&&(0,t.jsx)(ys,{label:"Working directory (deprecated)",hint:fi.cwd,children:(0,t.jsxs)("div",{className:"flex items-center gap-2 rounded-md border border-border px-2.5 py-1.5",children:[(0,t.jsx)(Co,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),(0,t.jsx)(Ba,{value:a?Ye.cwd:J("adapterConfig","cwd",String(ie.cwd??"")),onCommit:r(et=>a?ue({cwd:et}):Y("adapterConfig","cwd",et||void 0),"onCommit"),immediate:!0,className:"w-full bg-transparent outline-none text-sm font-mono placeholder:text-muted-foreground/40",placeholder:"/path/to/project"}),(0,t.jsx)(fd,{})]})}),xs("adapter"),xe&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(SK,{models:pt,value:Ur,onChange:r(et=>{const Ht=DT(oe,et),un=["codex_local","claude_local","grok_local"].includes(oe)&&!!ra&&!Ht.includes(String(ra));if(a){ue({model:et,...un?{thinkingEffort:""}:{}});return}Y("adapterConfig","model",et||void 0),un&&(Y("adapterConfig",br,void 0),Y("adapterConfig","reasoningEffort",void 0))},"onChange"),open:bs,onOpenChange:qe,defaultLabel:oe==="claude_local"?"Default (claude-opus-5)":void 0,allowDefault:oe!=="opencode_local"&&oe!=="pi_local"&&oe!=="paperclip_runner",required:oe==="opencode_local"||oe==="pi_local",groupByProvider:oe==="opencode_local"||oe==="pi_local",creatable:!0,detectedModel:St,detectedModelCandidates:[],onDetectModel:oe==="opencode_local"||oe==="paperclip_runner"?void 0:async()=>(await Ts()).data?.model??null,onRefreshModels:WQe(oe)?mr:void 0,refreshingModels:Ms,detectModelLabel:"Detect model",emptyDetectHint:"No model detected. Select or enter one manually."}),(Qt||Fe)&&(0,t.jsx)("p",{className:"text-xs text-destructive",children:Qt??(Fe instanceof Error?Fe.message:"Failed to load adapter models.")}),oe==="opencode_local"&>&>.driver!=="local"&&(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Live OpenCode model discovery only runs for Local environments. Using the curated list and manual entry for ",gt.name,"."]}),Bn&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(mGe,{value:ra,options:sr,onChange:r(et=>a?ue({thinkingEffort:et}):Y("adapterConfig",br,et||void 0),"onChange"),open:wt,onOpenChange:kt}),oe==="codex_local"&&_r&&ra==="minimal"&&(0,t.jsx)("p",{className:"text-xs text-amber-400",children:"Codex may reject `minimal` thinking when search is enabled."})]})]})]})]}),(0,t.jsxs)("div",{"data-config-section":"configuration",className:U(!i&&"border-b border-border"),children:[i?(0,t.jsx)("h3",{className:"text-sm font-medium mb-3",children:"Configuration"}):(0,t.jsx)("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground",children:"Configuration"}),(0,t.jsxs)("div",{className:U(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:[!a&&typeof ie.bootstrapPromptTemplate=="string"&&ie.bootstrapPromptTemplate&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ys,{label:"Bootstrap prompt (legacy)",hint:fi.bootstrapPrompt,children:(0,t.jsx)(kc,{value:J("adapterConfig","bootstrapPromptTemplate",String(ie.bootstrapPromptTemplate??"")),onChange:r(et=>Y("adapterConfig","bootstrapPromptTemplate",et||void 0),"onChange"),placeholder:"Optional initial setup prompt for the first run",contentClassName:"min-h-(--sz-44px) text-sm font-mono",imageUploadHandler:r(async et=>{const Ht=`agents/${e.agent.id}/bootstrap-prompt`;return(await z.mutateAsync({file:et,namespace:Ht})).contentPath},"imageUploadHandler")})}),(0,t.jsx)("div",{className:"rounded-md border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-xs text-amber-800 dark:text-amber-200",children:"Bootstrap prompt is legacy and will be removed in a future release. Consider moving this content into the agent's prompt template or instructions file instead."})]}),xs("configuration"),(xe||oe==="process"||cn?.fields.some(et=>_F(et.key)==="advanced"))&&(0,t.jsx)(R2,{title:"Advanced",open:ft,onToggle:r(()=>us(!ft),"onToggle"),children:(0,t.jsxs)("div",{className:"space-y-3",children:[xe&&(0,t.jsxs)(t.Fragment,{children:[" ",!$&&(0,t.jsx)(ys,{label:"Command",hint:fi.localCommand,children:(0,t.jsx)(Ba,{value:a?Ye.command:J("adapterConfig",$t,String(ie.command??"")),onCommit:r(et=>a?ue({command:et}):Y("adapterConfig",$t,et||null),"onCommit"),immediate:!0,className:vm,placeholder:{claude_local:"claude",codex_local:"codex",gemini_local:"gemini",kimi_local:"kimi",pi_local:"pi",cursor:"agent",opencode_local:"opencode"}[oe]??oe.replace(/_local$/,"")})}),(0,t.jsx)(ys,{label:"Extra args (comma-separated)",hint:fi.extraArgs,children:(0,t.jsx)(Ba,{value:a?Ye.extraArgs:J("adapterConfig","extraArgs",YQe(ie.extraArgs)),onCommit:r(et=>a?ue({extraArgs:et}):Y("adapterConfig","extraArgs",et?.trim()?GQe(et):null),"onCommit"),className:vm,placeholder:"e.g. --verbose, --foo=bar"})})]}),xs("advanced")]})})]})]}),e.environmentVariablesPlacement!=="secrets"&&(xe||cn?.fields.some(et=>_F(et.key)==="environment"))&&(0,t.jsxs)("div",{"data-config-section":"environment-variables",className:U(!i&&"border-b border-border"),children:[i?(0,t.jsx)("h3",{className:"text-sm font-medium mb-3",children:"Environment variables"}):(0,t.jsx)("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground",children:"Environment variables"}),(0,t.jsx)("div",{className:U(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:xe?Fs:xs("environment")})]}),a&&m?(0,t.jsxs)("div",{"data-config-section":"run-policy",className:U(!i&&"border-b border-border"),children:[i?(0,t.jsxs)("h3",{className:"text-sm font-medium flex items-center gap-2 mb-3",children:[(0,t.jsx)(nI,{className:"h-3 w-3"})," Run Policy"]}):(0,t.jsxs)("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground flex items-center gap-2",children:[(0,t.jsx)(nI,{className:"h-3 w-3"})," Run Policy"]}),(0,t.jsxs)("div",{className:U(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:[(0,t.jsx)(AY,{label:"Heartbeat on interval",hint:fi.heartbeatInterval,checked:Ye.heartbeatEnabled,onCheckedChange:r(et=>ue({heartbeatEnabled:et}),"onCheckedChange"),number:Ye.intervalSec,onNumberChange:r(et=>ue({intervalSec:et}),"onNumberChange"),numberLabel:"sec",numberPrefix:"Run heartbeat every",numberHint:fi.intervalSec,showNumber:Ye.heartbeatEnabled}),(0,t.jsx)(R2,{title:"Advanced Run Policy",open:it,onToggle:r(()=>Ot(!it),"onToggle"),children:(0,t.jsx)("div",{className:"space-y-3",children:xs("runPolicy")})})]})]}):a?null:(0,t.jsxs)("div",{"data-config-section":"run-policy",className:U(!i&&"border-b border-border"),children:[i?(0,t.jsxs)("h3",{className:"text-sm font-medium flex items-center gap-2 mb-3",children:[(0,t.jsx)(nI,{className:"h-3 w-3"})," Run Policy"]}):(0,t.jsxs)("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground flex items-center gap-2",children:[(0,t.jsx)(nI,{className:"h-3 w-3"})," Run Policy"]}),(0,t.jsxs)("div",{className:U(i?"border border-border rounded-lg overflow-hidden":""),children:[(0,t.jsx)("div",{className:U(i?"p-4 space-y-3":"px-4 pb-3 space-y-3"),children:(0,t.jsx)(AY,{label:"Heartbeat on interval",hint:fi.heartbeatInterval,checked:J("heartbeat","enabled",pe.enabled===!0),onCheckedChange:r(et=>Y("heartbeat","enabled",et),"onCheckedChange"),number:J("heartbeat","intervalSec",Number(pe.intervalSec??300)),onNumberChange:r(et=>Y("heartbeat","intervalSec",et),"onNumberChange"),numberLabel:"sec",numberPrefix:"Run heartbeat every",numberHint:fi.intervalSec,showNumber:J("heartbeat","enabled",pe.enabled===!0)})}),(0,t.jsx)(R2,{title:"Advanced Run Policy",bordered:i,open:it,onToggle:r(()=>Ot(!it),"onToggle"),children:(0,t.jsxs)("div",{className:"space-y-3",children:[xs("runPolicy"),xe&&(0,t.jsx)(t.Fragment,{children:!a&&(0,t.jsxs)(t.Fragment,{children:[!cn?.fields.some(et=>et.key==="timeoutSec")&&(0,t.jsx)(ys,{label:"Timeout (sec)",hint:fi.timeoutSec,children:(0,t.jsx)(sc,{value:J("adapterConfig","timeoutSec",Number(ie.timeoutSec??0)),onCommit:r(et=>Y("adapterConfig","timeoutSec",et),"onCommit"),immediate:!0,className:vm})}),!cn?.fields.some(et=>et.key==="graceSec")&&(0,t.jsx)(ys,{label:"Interrupt grace period (sec)",hint:fi.graceSec,children:(0,t.jsx)(sc,{value:J("adapterConfig","graceSec",Number(ie.graceSec??15)),onCommit:r(et=>Y("adapterConfig","graceSec",et),"onCommit"),immediate:!0,className:vm})})]})}),(0,t.jsx)(od,{label:"Wake on demand",hint:fi.wakeOnDemand,checked:J("heartbeat","wakeOnDemand",pe.wakeOnDemand!==!1),onChange:r(et=>Y("heartbeat","wakeOnDemand",et),"onChange")}),(0,t.jsx)(ys,{label:"Cooldown (sec)",hint:fi.cooldownSec,children:(0,t.jsx)(sc,{value:J("heartbeat","cooldownSec",Number(pe.cooldownSec??10)),onCommit:r(et=>Y("heartbeat","cooldownSec",et),"onCommit"),immediate:!0,className:vm})}),(0,t.jsx)(ys,{label:"Max concurrent runs",hint:fi.maxConcurrentRuns,children:(0,t.jsx)(sc,{value:J("heartbeat","maxConcurrentRuns",Number(pe.maxConcurrentRuns??20)),onCommit:r(et=>Y("heartbeat","maxConcurrentRuns",et),"onCommit"),immediate:!0,className:vm})}),(0,t.jsxs)("div",{className:"rounded-md border border-border/70 px-3 py-2",children:[(0,t.jsx)(od,{label:"Continue after max-turn stop",hint:fi.maxTurnContinuationEnabled,checked:on,onChange:r(et=>Ds({enabled:et}),"onChange")}),on?(0,t.jsxs)("div",{className:"mt-3 grid gap-3 sm:grid-cols-2",children:[(0,t.jsx)(ys,{label:"Continuation attempts",hint:fi.maxTurnContinuationMaxAttempts,children:(0,t.jsx)(sc,{value:cr,onCommit:r(et=>Ds({maxAttempts:$2(et,0,hJ)}),"onCommit"),immediate:!0,className:vm})}),(0,t.jsx)(ys,{label:"Continuation delay (sec)",hint:fi.maxTurnContinuationDelaySec,children:(0,t.jsx)(sc,{value:bt,onCommit:r(et=>Ds({delayMs:nGe(et)}),"onCommit"),immediate:!0,className:vm})})]}):null]})]})})]})]}),!a&&p?(0,t.jsxs)("div",{className:U(!i&&"border-b border-border"),children:[i?(0,t.jsxs)("h3",{className:"mb-3 flex items-center gap-2 text-sm font-medium",children:[(0,t.jsx)(Aj,{className:"h-3 w-3"})," Debugging"]}):(0,t.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2 text-xs font-medium text-muted-foreground",children:[(0,t.jsx)(Aj,{className:"h-3 w-3"})," Debugging"]}),(0,t.jsxs)("div",{className:U("border-border bg-accent/30",i?"rounded-lg border p-4":"mx-4 mb-4 rounded-md border px-3 py-3"),children:[(0,t.jsx)(od,{label:"Capture raw provider traces",hint:"Stores exact provider traffic for every future run until disabled. Traces may contain sensitive prompts and tool arguments, are administrator-only, and expire after 24 hours.",checked:J("debug","providerTrace",be.providerTrace)==="raw",onChange:r(et=>Y("debug","providerTrace",et?"raw":void 0),"onChange")}),J("debug","providerTrace",be.providerTrace)==="raw"?(0,t.jsxs)("div",{className:"mt-3 flex items-start gap-2 rounded-md border border-border bg-background/60 px-3 py-2 text-xs text-foreground",children:[(0,t.jsx)(Aj,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),(0,t.jsx)("span",{children:"Raw tracing is on for future runs. Paperclip keeps at most 64 MiB per run and automatically deletes it after 24 hours."})]}):null]})]}):null,e.compactTestFeedback&&d&&l&&(0,t.jsx)(Sfe,{state:Ze?"running":Ut||Le.error?"fail":Us?.status??"idle",result:Us??null,error:Ut??(Le.error instanceof Error?Le.error.message:null),onTest:er,disabled:Ws})]})}r(Cxe,"AgentConfigForm");var KF=new Set(["authenticated","failed","timed_out","cancelled"]),VF=2e3;function WF({value:e,label:s}){const[n,a]=(0,u.useState)(!1),i=(0,u.useRef)(null);return(0,u.useEffect)(()=>()=>{i.current&&clearTimeout(i.current)},[]),(0,t.jsx)(F,{type:"button",variant:"ghost",size:"icon-xs","aria-label":s,title:s,className:"text-muted-foreground hover:text-foreground",onClick:r(async()=>{try{await Yr(e),a(!0)}catch{a(!1)}i.current&&clearTimeout(i.current),i.current=setTimeout(()=>a(!1),1500)},"onClick"),children:n?(0,t.jsx)(ds,{className:"size-3"}):(0,t.jsx)(Nr,{className:"size-3"})})}r(WF,"AdapterLoginCopyButton");function aGe({status:e,message:s}){return e==="authenticated"?(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-foreground",children:[(0,t.jsx)(ds,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{children:"Authenticated. The environment has credentials now."})]}):(0,t.jsxs)("div",{className:"flex items-start gap-2 text-(length:--text-micro) text-destructive",children:[(0,t.jsx)(Is,{className:"size-3 shrink-0"}),(0,t.jsxs)("span",{children:[e==="timed_out"?"Login timed out":e==="cancelled"?"Login cancelled":"Login failed",s?`: ${s}`:"."]})]})}r(aGe,"AdapterLoginTerminalState");var iGe={claude_local:"Anthropic",codex_local:"OpenAI"};function _xe(e){const s=iGe[e];return s?`Sign in to ${s}`:"Sign in to the environment"}r(_xe,"adapterLoginTitle");function kK(e){return Zw()(e.adapterType).login?.panelMode==="submitted_browser_code"?(0,t.jsx)(dGe,{...e}):(0,t.jsx)(oGe,{...e})}r(kK,"AdapterLoginPanel");function oGe({companyId:e,adapterType:s,environmentId:n,autoStart:a,onConnected:i,onAccountBinding:o,chrome:l="panel",aiConnection:c,onPromptReady:d}){const[m,h]=(0,u.useState)(null),[p,f]=(0,u.useState)(null),[g,v]=(0,u.useState)(null),[y,w]=(0,u.useState)("idle"),S=(0,u.useRef)(!1),j=Ne({mutationFn:r(()=>Vt.startAdapterAuthLogin(e,s,{environmentId:n,aiConnection:c}),"mutationFn"),onSuccess:r(te=>{S.current=!1,f(null),v(null),w("idle"),h(te.sessionId)},"onSuccess"),onError:r(te=>{f(te instanceof Error?te.message:"Could not start the login.")},"onError")}),N=(0,u.useCallback)(()=>{S.current=!1,h(null),v(null),f(null)},[]),_=Ne({mutationFn:r(()=>Vt.cancelAdapterAuthLogin(e,s,m),"mutationFn"),onSuccess:N,onError:r(te=>{f(te instanceof Error?te.message:"Could not cancel the login.")},"onError")}),R=Z({queryKey:["adapter-login-active-session",e,s],queryFn:r(async()=>{try{const te=await Vt.getActiveAdapterAuthLoginSession(e,s);if(!te)return null;if(c&&te.environmentId!==n||!!te.aiConnection!=!!c||c&&(te.aiConnection?.provider!==c.provider||te.aiConnection?.method!==c.method||te.aiConnection?.connectionId!==c.connectionId||te.aiConnection?.ownership!==c.ownership||te.aiConnection?.allAgents!==c.allAgents||JSON.stringify(te.aiConnection?.agentIds)!==JSON.stringify(c.agentIds)))throw new Error("Another sign-in attempt is active. Finish or cancel it in its original account setup before starting this one.");return te}catch(te){if(te instanceof wn&&te.status===404)return null;throw te}},"queryFn"),retry:!1,gcTime:0,staleTime:0}),[C,A]=(0,u.useState)(!1),T=Z({queryKey:["adapter-login-status",e,s,m],queryFn:r(()=>Vt.getAdapterAuthLoginStatus(e,s,m),"queryFn"),enabled:!!m&&!C,retry:r((te,ae)=>ae instanceof wn&&ae.status===404?!1:te<3,"retry"),refetchInterval:r(te=>{const ae=te.state.data?.status;return ae&&KF.has(ae)?!1:VF},"refetchInterval")});(0,u.useEffect)(()=>{const te=T.data?.prompt??null;te&&v(te)},[T.data]);const I=T.data??j.data??null,$=I?.status??null,O=g,L=$?KF.has($):!1,E=!!m&&!L,q=j.isPending||E||y==="saving",B=(0,u.useRef)(!1);(0,u.useEffect)(()=>{if(B.current||!R.isFetched)return;B.current=!0;const te=R.data;te&&(S.current=!0,f(null),v(te.prompt??null),h(te.sessionId))},[R.isFetched,R.data]),(0,u.useEffect)(()=>{const te=T.error;if(!(te instanceof wn&&te.status===404)||!S.current||C)return;A(!0);const ae=m;(async()=>(ae&&await Vt.cancelAdapterAuthLogin(e,s,ae).catch(()=>{}),A(!1),N()))()},[T.error,C,m,e,s,N]);const K=(0,u.useRef)(!1),z=(0,u.useRef)(j.mutate);z.current=j.mutate,(0,u.useEffect)(()=>{if(!(!a||K.current)){if(R.isError){K.current=!0,f(R.error instanceof Error?R.error.message:"Could not check for an active login.");return}R.isSuccess&&(K.current=!0,!R.data&&z.current())}},[a,R.isSuccess,R.isError,R.data,R.error]);const D=(0,u.useRef)(!1),V=(0,u.useRef)(i);V.current=i,(0,u.useEffect)(()=>{$!=="authenticated"||D.current||(D.current=!0,V.current?.(m??void 0))},[$]);const H=(0,u.useRef)(null),ee=(0,u.useRef)(o);ee.current=o;const X=T.data?.codexAccountBinding??null,le=(0,u.useCallback)(async te=>{const ae=ee.current;if(ae){w("saving");try{await ae(te),w("bound")}catch{w("failed")}}},[]);(0,u.useEffect)(()=>{$!=="authenticated"||!m||H.current!==m&&(!X||!X.companyIdentityDiffers||!ee.current||(H.current=m,le(X)))},[$,m,X,le]);const ce=(0,u.useRef)(d);if(ce.current=d,(0,u.useEffect)(()=>{ce.current?.(O?.url??null)},[O]),l==="onboarding"){const te=L&&$&&$!=="authenticated";return(0,t.jsx)(Lfe,{loading:!O&&!p&&!te,providerName:Mfe(s),authorizationUrl:O?.url,mode:"displayed_code",children:p?(0,t.jsx)("p",{role:"alert",className:"pl-2 text-xs text-destructive",children:p}):te?(0,t.jsx)("p",{role:"alert",className:"pl-2 text-xs text-destructive",children:$==="timed_out"?"The login timed out. Start it again.":$==="cancelled"?"The login was cancelled.":"The login did not finish. Start it again."}):(0,t.jsx)(a9e,{code:O?.code??"",autoCopy:!0})})}return(0,t.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 px-3 py-2 flex flex-col gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-foreground",children:_xe(s)}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[E&&(0,t.jsx)(F,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground hover:text-foreground",disabled:_.isPending,onClick:r(()=>_.mutate(),"onClick"),children:"Cancel"}),(0,t.jsx)(F,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2.5 text-xs",disabled:q,onClick:r(()=>j.mutate(),"onClick"),children:"Sign in"})]})]}),p&&(0,t.jsx)("div",{role:"alert",className:"text-(length:--text-micro) text-destructive",children:p}),(0,t.jsxs)("div",{role:"status","aria-live":"polite",className:"space-y-2 empty:hidden",children:[E&&!O&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-muted-foreground",children:[(0,t.jsx)(at,{className:"size-3 animate-spin shrink-0"}),(0,t.jsx)("span",{children:"Preparing..."})]}),E&&O&&(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("div",{className:"text-(length:--text-micro) text-muted-foreground",children:"Copy the code, then open the authentication page."}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("div",{className:"text-(length:--text-micro) uppercase tracking-wide text-muted-foreground",children:"1. Code"}),(0,t.jsx)("span",{className:"font-mono text-xs text-foreground break-all",children:O.code})]}),(0,t.jsx)(WF,{value:O.code,label:"Copy code"})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("div",{className:"text-(length:--text-micro) uppercase tracking-wide text-muted-foreground",children:"2. Authentication URL"}),(0,t.jsx)("span",{className:"font-mono text-xs text-foreground break-all",children:O.url})]}),(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsx)(WF,{value:O.url,label:"Copy URL"}),(0,t.jsx)(F,{asChild:!0,type:"button",variant:"ghost",size:"icon-xs","aria-label":"Open the authentication page",title:"Open the authentication page",className:"text-muted-foreground hover:text-foreground",children:(0,t.jsx)("a",{href:O.url,target:"_blank",rel:"noreferrer noopener",children:(0,t.jsx)(xr,{className:"size-3"})})})]})]})]}),L&&$&&(0,t.jsx)(aGe,{status:$,message:I?.failure?.message??null}),$==="authenticated"&&y==="saving"&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-muted-foreground",children:[(0,t.jsx)(at,{className:"size-3 animate-spin shrink-0"}),(0,t.jsx)("span",{children:"Binding this agent to the signed-in account..."})]}),$==="authenticated"&&y==="bound"&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-foreground",children:[(0,t.jsx)(ds,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{children:"Agent bound to the signed-in account."})]}),$==="authenticated"&&y==="failed"&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro)",children:[(0,t.jsx)(Is,{className:"size-3 shrink-0 text-destructive"}),(0,t.jsx)("span",{className:"text-destructive",children:"Could not bind this agent to the signed-in account."}),(0,t.jsx)(F,{type:"button",variant:"outline",size:"sm",className:"h-6 px-2 text-xs",onClick:r(()=>{X&&le(X)},"onClick"),children:"Retry"})]})]})]})}r(oGe,"DisplayedCodeLoginPanel");var lGe=new Set(["failed","timed_out","cancelled"]),pJ="The login did not finish. Start the login again.",cGe=9e5,fJ="The login timed out. Start the login again.";function dGe({companyId:e,adapterType:s,environmentId:n,onStored:a,onApplyStored:i,autoStart:o,onConnected:l,onCodeSubmitted:c,onSubmitFailed:d,chrome:m="panel",aiConnection:h,onPromptReady:p}){const[f,g]=(0,u.useState)(null),[v,y]=(0,u.useState)(null),[w,S]=(0,u.useState)(null),[j,N]=(0,u.useState)(!1),[_,R]=(0,u.useState)(""),[C,A]=(0,u.useState)(null),[T,I]=(0,u.useState)(!1),[$,O]=(0,u.useState)(!1),[L,E]=(0,u.useState)(!1),[q,B]=(0,u.useState)(!1),K=(0,u.useRef)(!1),[z,D]=(0,u.useState)(!1),V=(0,u.useRef)(!1),H=r(()=>{y(null),S(null),N(!1),R(""),A(null),I(!1),O(!1),B(!1),E(!1),K.current=!1},"resetLocalState"),ee=Z({queryKey:["claude-oauth-token-status",e],queryFn:r(async()=>{try{return await Vt.getClaudeOAuthTokenStatus(e)}catch(tt){if(tt instanceof wn&&tt.status===404)return null;throw tt}},"queryFn"),retry:r((tt,Se)=>Se instanceof wn&&Se.status===404?!1:tt<2,"retry")}).data??null,X=Ne({mutationFn:r(()=>Vt.startClaudeSetupTokenLogin(e,{environmentId:n,aiConnection:h,...ee&&!h?{overwrite:{expectedSecretId:ee.secretId,expectedLatestVersion:ee.latestVersion}}:{}}),"mutationFn"),onSuccess:r(tt=>{V.current=!1,H(),g(tt.sessionId)},"onSuccess"),onError:r(tt=>{y(tt instanceof Error?tt.message:"Could not start the login.")},"onError")}),le=r(()=>{V.current=!1,g(null),H()},"clearActiveSession"),ce=Ne({mutationFn:r(()=>Vt.cancelClaudeSetupTokenLogin(e,f),"mutationFn"),onSuccess:r(()=>{le()},"onSuccess"),onError:r(tt=>{if(tt instanceof wn&&tt.status===404){le();return}y(tt instanceof Error?tt.message:"Could not cancel the login.")},"onError")}),te=(0,u.useCallback)(tt=>{Vt.cancelClaudeSetupTokenLogin(e,tt).catch(()=>{})},[e]),ae=Z({queryKey:["claude-setup-token-active-session",e],queryFn:r(async()=>{try{const tt=await Vt.getActiveClaudeSetupTokenLoginSession(e);if(!tt)return null;if(h&&tt.environmentId!==n||!!tt.aiConnection!=!!h||h&&(tt.aiConnection?.provider!==h.provider||tt.aiConnection?.method!==h.method||tt.aiConnection?.connectionId!==h.connectionId||tt.aiConnection?.ownership!==h.ownership||tt.aiConnection?.allAgents!==h.allAgents||JSON.stringify(tt.aiConnection?.agentIds)!==JSON.stringify(h.agentIds)))throw new Error("Another sign-in attempt is active. Finish or cancel it in its original account setup before starting this one.");return tt}catch(tt){if(tt instanceof wn&&tt.status===404)return null;throw tt}},"queryFn"),retry:!1,gcTime:0,staleTime:0}),[de,J]=(0,u.useState)(!1),Y=!!f&&!$&&!q&&!de,G=Z({queryKey:["claude-setup-token-status",e,f],queryFn:r(()=>Vt.getClaudeSetupTokenLoginStatus(e,f),"queryFn"),enabled:Y,retry:r((tt,Se)=>Se instanceof wn&&Se.status===404?!1:tt<3,"retry"),refetchInterval:r(tt=>{if($||q)return!1;const Se=tt.state.data?.status;return Se&&KF.has(Se)?!1:VF},"refetchInterval")});(0,u.useEffect)(()=>{const tt=G.error;if(tt instanceof wn&&tt.status===404){if(V.current){if(de)return;J(!0);const Se=f;(async()=>(Se&&await Vt.cancelClaudeSetupTokenLogin(e,Se).catch(()=>{}),J(!1),le()))();return}B(!0)}},[G.error,de,f,e]);const fe=(0,u.useRef)(!1);(0,u.useEffect)(()=>{if(fe.current||!ae.isFetched)return;fe.current=!0;const tt=ae.data;tt&&(V.current=!0,H(),g(tt.sessionId),tt.prompt&&(S(tt.prompt.authorizationUrl),tt.prompt.transportAdvisory&&N(!0)))},[ae.isFetched,ae.data]);const se=Z({queryKey:["claude-setup-token-prompt",e,f],enabled:Y&&!w,queryFn:r(async()=>{try{return await Vt.getClaudeSetupTokenLoginPrompt(e,f)}catch(tt){if(tt instanceof wn&&tt.status===404)return null;throw tt}},"queryFn"),refetchInterval:r(tt=>$||tt.state.data?.authorizationUrl?!1:VF,"refetchInterval")});(0,u.useEffect)(()=>{const tt=se.data?.authorizationUrl??null;tt&&S(tt),se.data?.transportAdvisory&&N(!0)},[se.data]);const re=Ne({mutationFn:r(tt=>Vt.submitClaudeSetupTokenBrowserCode(e,f,tt),"mutationFn"),onError:r(tt=>{y(tt instanceof Error?tt.message:"Could not submit the browser code.")},"onError")}),ie=Ne({mutationFn:r(()=>Vt.completeClaudeSetupTokenLogin(e,f),"mutationFn"),onSuccess:r(tt=>{A(tt.storedSessionId),a?.(tt.storedSessionId)},"onSuccess"),onError:r(()=>{I(!0)},"onError")}),me=G.data?.status??X.data?.status??null,pe=G.data?.expiresAt??X.data?.expiresAt??null,be=(0,u.useRef)(ie.mutate);be.current=ie.mutate,(0,u.useEffect)(()=>{me==="authenticated"&&!K.current&&(K.current=!0,be.current())},[me]);const oe=C!==null,ye=T||q||!!(me&&lGe.has(me)),Ae=me==="authenticated"&&!oe&&!T,xe=!!f&&!oe&&!ye&&!$,_e=X.isPending||xe;(0,u.useEffect)(()=>{if(!xe)return;const tt=pe!==null?new Date(pe).getTime():NaN,Se=Number.isFinite(tt)?Math.max(0,tt-Date.now()):cGe,ke=setTimeout(()=>{f&&te(f),O(!0)},Se);return()=>clearTimeout(ke)},[xe,pe,f,te]);const Ge=_.trim(),$e=xe&&!!w&&!Ae&&KIe(Ge)&&!re.isPending&&!L,Ye=(0,u.useRef)(c);Ye.current=c;const ue=(0,u.useRef)(d);ue.current=d;const Oe=r(()=>{$e&&(y(null),re.mutate(Ge),E(!0),Ye.current?.(),m!=="onboarding"&&R(""))},"handleSubmit"),dt=(0,u.useRef)(!1),xt=(0,u.useRef)(X.mutate);xt.current=X.mutate,(0,u.useEffect)(()=>{if(!(!o||dt.current)){if(ae.isError){dt.current=!0,y(ae.error instanceof Error?ae.error.message:"Could not check for an active login.");return}ae.isSuccess&&(dt.current=!0,!ae.data&&xt.current())}},[o,ae.isSuccess,ae.isError,ae.data,ae.error]);const De=(0,u.useRef)(Oe);De.current=Oe;const Qe=m==="onboarding",ht=(0,u.useRef)(!1);(0,u.useEffect)(()=>{!Qe||!ht.current||(ht.current=!1,$e&&De.current())},[Qe,$e,_]);const We=(0,u.useRef)(!1),Ke=(0,u.useRef)(l);Ke.current=l,(0,u.useEffect)(()=>{!oe||We.current||(We.current=!0,Ke.current?.(f??void 0))},[oe]),(0,u.useEffect)(()=>{L&&(!v&&!ye&&!$||(E(!1),ue.current?.()))},[L,v,ye,$]);const gt=(0,u.useRef)(p);if(gt.current=p,(0,u.useEffect)(()=>{gt.current?.(w)},[w]),m==="onboarding"){const tt=ye||$;return(0,t.jsxs)(Lfe,{loading:!w&&!v&&!tt,providerName:Mfe(s),authorizationUrl:w??void 0,mode:"submitted_code",children:[j&&(0,t.jsxs)("p",{className:"flex items-start gap-2 pl-2 text-xs text-amber-700 dark:text-amber-200",children:[(0,t.jsx)(Is,{className:"mt-0.5 size-3 shrink-0"}),"This connection is not encrypted. The login code travels in clear text on this network. Continue only on a network you trust."]}),v?(0,t.jsx)("p",{role:"alert",className:"pl-2 text-xs text-destructive",children:v}):tt?(0,t.jsx)("p",{role:"alert",className:"pl-2 text-xs text-destructive",children:$&&!ye?fJ:pJ}):(0,t.jsx)(cE,{value:_,onChange:R,onSubmit:Oe,onPaste:r(()=>{ht.current=!0},"onPaste"),masked:!0,disabled:re.isPending||Ae||L})]})}return(0,t.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 px-3 py-2 flex flex-col gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-foreground",children:_xe(s)}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[xe&&(0,t.jsx)(F,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground hover:text-foreground",disabled:ce.isPending,onClick:r(()=>ce.mutate(),"onClick"),children:"Cancel"}),i&&ee&&!xe&&!oe&&!z&&(0,t.jsx)(F,{type:"button",variant:"default",size:"sm",className:"h-7 px-2.5 text-xs",onClick:r(()=>{i(),D(!0)},"onClick"),children:"Use saved login"}),(0,t.jsx)(F,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2.5 text-xs",disabled:_e,onClick:r(()=>X.mutate(),"onClick"),children:ee&&!xe&&!oe?"Sign in to replace":"Sign in"})]})]}),ee&&!xe&&!oe&&!z&&(0,t.jsx)("div",{className:"text-(length:--text-micro) text-muted-foreground",children:"You have a saved Claude login. Use it to bind this agent, or log in again to replace the stored token."}),z&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-foreground",children:[(0,t.jsx)(ds,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{children:"The saved Claude login is bound to this agent now."})]}),v&&(0,t.jsx)("div",{role:"alert",className:"text-(length:--text-micro) text-destructive",children:v}),(0,t.jsxs)("div",{role:"status","aria-live":"polite",className:"space-y-2 empty:hidden",children:[xe&&!w&&!Ae&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-muted-foreground",children:[(0,t.jsx)(at,{className:"size-3 animate-spin shrink-0"}),(0,t.jsx)("span",{children:"Preparing..."})]}),xe&&w&&!Ae&&(0,t.jsxs)("div",{className:"space-y-2",children:[j&&(0,t.jsxs)("div",{className:"flex items-start gap-2 rounded-md border border-amber-300 bg-amber-50 px-2 py-1.5 text-(length:--text-micro) text-amber-800 dark:border-amber-500/40 dark:bg-amber-500/10 dark:text-amber-200",children:[(0,t.jsx)(Is,{className:"size-3 shrink-0 mt-0.5"}),(0,t.jsx)("span",{children:"This connection is not encrypted. The login code travels in clear text on this network. Continue only on a network you trust."})]}),(0,t.jsx)("div",{className:"text-(length:--text-micro) text-muted-foreground",children:"Open the authorization page, then enter the browser code it shows."}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("div",{className:"text-(length:--text-micro) uppercase tracking-wide text-muted-foreground",children:"1. Authorization URL"}),(0,t.jsx)("span",{className:"font-mono text-xs text-foreground break-all",children:w})]}),(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsx)(WF,{value:w,label:"Copy URL"}),(0,t.jsx)(F,{asChild:!0,type:"button",variant:"ghost",size:"icon-xs","aria-label":"Open the authorization page",title:"Open the authorization page",className:"text-muted-foreground hover:text-foreground",children:(0,t.jsx)("a",{href:w,target:"_blank",rel:"noreferrer noopener",children:(0,t.jsx)(xr,{className:"size-3"})})})]})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("div",{className:"text-(length:--text-micro) uppercase tracking-wide text-muted-foreground",children:"2. Browser code"}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("input",{"aria-label":"Browser code",type:"text",autoComplete:"off",spellCheck:!1,value:_,onChange:r(tt=>R(tt.target.value),"onChange"),onKeyDown:r(tt=>{tt.key==="Enter"&&(tt.preventDefault(),Oe())},"onKeyDown"),className:"flex-1 min-w-0 rounded-md border border-border bg-background px-2 py-1 font-mono text-xs text-foreground"}),(0,t.jsx)(F,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2.5 text-xs",disabled:!$e,onClick:Oe,children:"Submit"})]})]})]}),Ae&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-muted-foreground",children:[(0,t.jsx)(at,{className:"size-3 animate-spin shrink-0"}),(0,t.jsx)("span",{children:"Completing the login…"})]}),oe&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-foreground",children:[(0,t.jsx)(ds,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{children:"Authenticated. The environment has credentials now."})]}),ye&&(0,t.jsxs)("div",{className:"flex items-start gap-2 text-(length:--text-micro) text-destructive",children:[(0,t.jsx)(Is,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{children:pJ})]}),$&&!ye&&!oe&&(0,t.jsxs)("div",{className:"flex items-start gap-2 text-(length:--text-micro) text-destructive",children:[(0,t.jsx)(Is,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{children:fJ})]})]})]})}r(dGe,"SubmittedBrowserCodeLoginPanel");function uGe({result:e}){const s=e.status==="pass"?"Passed":e.status==="warn"?"Warnings":"Failed",n=e.status==="pass"?"text-green-700 dark:text-green-300 border-green-300 dark:border-green-500/40 bg-green-50 dark:bg-green-500/10":e.status==="warn"?"text-amber-700 dark:text-amber-300 border-amber-300 dark:border-amber-500/40 bg-amber-50 dark:bg-amber-500/10":"text-red-700 dark:text-red-300 border-red-300 dark:border-red-500/40 bg-red-50 dark:bg-red-500/10";return(0,t.jsxs)("div",{className:`rounded-md border px-3 py-2 text-xs ${n}`,children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("span",{className:"font-medium",children:s}),(0,t.jsx)("span",{className:"text-(length:--text-micro) opacity-80",children:new Date(e.testedAt).toLocaleTimeString()})]}),(0,t.jsx)("div",{className:"mt-2 space-y-1.5",children:e.checks.map((a,i)=>(0,t.jsxs)("div",{className:"text-(length:--text-micro) leading-relaxed break-words",children:[(0,t.jsx)("span",{className:"font-medium uppercase tracking-wide opacity-80",children:a.level}),(0,t.jsx)("span",{className:"mx-1 opacity-60",children:"·"}),(0,t.jsx)("span",{children:a.message}),a.detail&&(0,t.jsxs)("span",{className:"block opacity-75 break-all",children:["(",a.detail,")"]}),a.hint&&(0,t.jsxs)("span",{className:"block opacity-90 break-words",children:["Hint: ",a.hint]})]},`${a.code}-${i}`))})]})}r(uGe,"AdapterEnvironmentResult$1");function Ixe({value:e,onChange:s,disabledTypes:n}){const[a,i]=(0,u.useState)(!1),o=Um(e),l=(0,u.useMemo)(()=>Nxe(c=>gw[c]??mf(c)).filter(c=>!n.has(c.value)),[n]);return(0,t.jsxs)(Zn,{open:a,onOpenChange:i,children:[(0,t.jsx)(ur,{asChild:!0,children:(0,t.jsxs)("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-sm hover:bg-accent/50 transition-colors w-full justify-between",children:[(0,t.jsxs)("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[e==="opencode_local"?(0,t.jsx)(IF,{className:"h-3.5 w-3.5"}):null,(0,t.jsx)("span",{className:"truncate",children:gw[e]??mf(e)}),o.experimental&&(0,t.jsx)(xJ,{})]}),(0,t.jsx)(sn,{className:"h-3 w-3 text-muted-foreground"})]})}),(0,t.jsx)(Vn,{className:"w-(--radix-popover-trigger-width) p-1",align:"start",children:l.map(c=>(0,t.jsxs)("button",{disabled:c.comingSoon,className:U("flex items-center justify-between w-full px-2 py-1.5 text-sm rounded",c.comingSoon?"opacity-40 cursor-not-allowed":"hover:bg-accent/50",c.value===e&&!c.comingSoon&&"bg-accent"),onClick:r(()=>{c.comingSoon||(s(c.value),i(!1))},"onClick"),children:[(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[c.value==="opencode_local"?(0,t.jsx)(IF,{className:"h-3.5 w-3.5"}):null,(0,t.jsx)("span",{children:c.label}),c.experimental&&(0,t.jsx)(xJ,{})]}),c.comingSoon&&(0,t.jsx)("span",{className:"text-(length:--text-nano) text-muted-foreground",children:"Coming soon"})]},c.value))})]})}r(Ixe,"AdapterTypeDropdown");function xJ(){return(0,t.jsx)("span",{className:"shrink-0 rounded border border-amber-500/30 bg-amber-500/10 px-1.5 py-0.5 text-(length:--text-nano) font-medium leading-none text-amber-700 dark:text-amber-200",children:"Experimental"})}r(xJ,"ExperimentalBadge$1");function SK({models:e,value:s,onChange:n,open:a,onOpenChange:i,allowDefault:o,required:l,groupByProvider:c,creatable:d,detectedModel:m,detectedModelCandidates:h,onDetectModel:p,onRefreshModels:f,refreshingModels:g,detectModelLabel:v,emptyDetectHint:y,defaultLabel:w}){const[S,j]=(0,u.useState)(""),[N,_]=(0,u.useState)(!1),R=e.find(L=>L.id===s),C=S.trim(),A=!!(d&&C&&!e.some(L=>L.id.toLowerCase()===C.toLowerCase())),T=(0,u.useMemo)(()=>{const L=new Set;m&&L.add(m);for(const E of h??[])E&&L.add(E);return L},[m,h]),I=(0,u.useMemo)(()=>e.filter(L=>{if(T.has(L.id))return!1;if(!S.trim())return!0;const E=S.toLowerCase(),q=YO(L.id)??"";return L.id.toLowerCase().includes(E)||L.label.toLowerCase().includes(E)||q.toLowerCase().includes(E)}),[e,S,T]),$=(0,u.useMemo)(()=>{if(!c)return[{provider:"models",entries:[...I].sort((E,q)=>E.id.localeCompare(q.id))}];const L=new Map;for(const E of I){const q=YO(E.id)??"other",B=L.get(q)??[];B.push(E),L.set(q,B)}return Array.from(L.entries()).sort(([E],[q])=>E.localeCompare(q)).map(([E,q])=>({provider:E,entries:[...q].sort((B,K)=>B.id.localeCompare(K.id))}))},[I,c]);async function O(){if(p){_(!0);try{const L=await p();L&&(n(L),i(!1),j(""))}finally{_(!1)}}}return r(O,"handleDetectModel"),(0,t.jsx)(ys,{label:"Model",hint:fi.model,children:(0,t.jsxs)(Zn,{open:a,onOpenChange:r(L=>{i(L),L||j("")},"onOpenChange"),children:[(0,t.jsx)(ur,{asChild:!0,children:(0,t.jsxs)("button",{type:"button",className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-sm hover:bg-accent/50 transition-colors w-full justify-between",children:[(0,t.jsx)("span",{className:U(!s&&"text-muted-foreground"),children:R?R.label:s||(o?w??"Default":l?"Select model (required)":"Select model")}),(0,t.jsx)(sn,{className:"h-3 w-3 text-muted-foreground"})]})}),(0,t.jsxs)(Vn,{className:"w-(--radix-popover-trigger-width) p-1",align:"start",children:[(0,t.jsxs)("div",{className:"relative mb-1",children:[(0,t.jsx)("input",{className:"w-full px-2 py-1.5 pr-6 text-xs bg-transparent outline-none border-b border-border placeholder:text-muted-foreground/50",placeholder:d?"Search models... (type to create)":"Search models...",value:S,onChange:r(L=>j(L.target.value),"onChange"),autoFocus:!0}),S&&(0,t.jsx)("button",{type:"button",className:"absolute right-1.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",onClick:r(()=>j(""),"onClick"),children:(0,t.jsxs)("svg",{"aria-hidden":"true",focusable:"false",className:"h-3 w-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,t.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),p&&!S.trim()&&(0,t.jsxs)("button",{type:"button",className:"flex items-center gap-1.5 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50 text-muted-foreground",onClick:r(()=>{O()},"onClick"),disabled:N,children:[(0,t.jsxs)("svg",{"aria-hidden":"true",focusable:"false",className:"h-3 w-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),(0,t.jsx)("path",{d:"M3 3v5h5"})]}),N?"Detecting...":m?v?.replace(/^Detect\b/,"Re-detect")??"Re-detect from config":v??"Detect from config"]}),f&&!S.trim()&&(0,t.jsxs)("button",{type:"button",className:"flex items-center gap-1.5 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50 text-muted-foreground",onClick:r(()=>{f()},"onClick"),disabled:g,children:[(0,t.jsxs)("svg",{"aria-hidden":"true",focusable:"false",className:"h-3 w-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M3 12a9 9 0 0 1 15.28-6.36L21 8"}),(0,t.jsx)("path",{d:"M21 3v5h-5"}),(0,t.jsx)("path",{d:"M21 12a9 9 0 0 1-15.28 6.36L3 16"}),(0,t.jsx)("path",{d:"M8 16H3v5"})]}),g?"Refreshing...":"Refresh models"]}),s&&(!e.some(L=>L.id===s)||T.has(s))&&(0,t.jsxs)("button",{type:"button",className:U("flex items-center w-full px-2 py-1.5 text-sm rounded bg-accent/50"),onClick:r(()=>{i(!1)},"onClick"),children:[(0,t.jsx)("span",{className:"block w-full text-left truncate font-mono text-xs",title:s,children:e.find(L=>L.id===s)?.label??s}),(0,t.jsx)(lt,{variant:"outline",className:"ml-auto text-(length:--text-nano) px-1.5 bg-green-500/15 text-green-400 border-green-500/20",children:"current"})]}),m&&m!==s&&(0,t.jsxs)("button",{type:"button",className:U("flex items-center w-full px-2 py-1.5 text-sm rounded hover:bg-accent/50"),onClick:r(()=>{n(m),i(!1)},"onClick"),children:[(0,t.jsx)("span",{className:"block w-full text-left truncate font-mono text-xs",title:m,children:e.find(L=>L.id===m)?.label??m}),(0,t.jsx)(lt,{variant:"outline",className:"ml-auto text-(length:--text-nano) px-1.5 bg-blue-500/15 text-blue-400 border-blue-500/20",children:"detected"})]}),h?.filter(L=>L&&L!==m&&L!==s).map(L=>{const E=e.find(q=>q.id===L);return(0,t.jsxs)("button",{type:"button",className:U("flex items-center w-full px-2 py-1.5 text-sm rounded hover:bg-accent/50"),onClick:r(()=>{n(L),i(!1)},"onClick"),children:[(0,t.jsx)("span",{className:"block w-full text-left truncate font-mono text-xs",title:L,children:E?.label??L}),(0,t.jsx)(lt,{variant:"outline",className:"ml-auto text-(length:--text-nano) px-1.5 bg-sky-500/15 text-sky-400 border-sky-500/20",children:"config"})]},`detected-${L}`)}),(0,t.jsxs)("div",{className:"max-h-(--sz-240px) overflow-y-auto",children:[o&&(0,t.jsx)("button",{type:"button",className:U("flex items-center gap-2 w-full px-2 py-1.5 text-sm rounded hover:bg-accent/50",!s&&"bg-accent"),onClick:r(()=>{n(""),i(!1)},"onClick"),children:"Default"}),A&&(0,t.jsxs)("button",{type:"button",className:"flex items-center justify-between gap-2 w-full px-2 py-1.5 text-sm rounded hover:bg-accent/50",onClick:r(()=>{n(C),i(!1),j("")},"onClick"),children:[(0,t.jsx)("span",{children:"Use manual model"}),(0,t.jsx)("span",{className:"text-xs font-mono text-muted-foreground",children:C})]}),$.map(L=>(0,t.jsxs)("div",{className:"mb-1 last:mb-0",children:[c&&(0,t.jsxs)("div",{className:"px-2 py-1 text-(length:--text-nano) uppercase tracking-wide text-muted-foreground",children:[L.provider," (",L.entries.length,")"]}),L.entries.map(E=>(0,t.jsx)("button",{type:"button",className:U("flex items-center w-full px-2 py-1.5 text-sm rounded hover:bg-accent/50",E.id===s&&"bg-accent"),onClick:r(()=>{n(E.id),i(!1)},"onClick"),children:(0,t.jsx)("span",{className:"block w-full text-left truncate",title:E.id,children:c?GBe(E.id):E.label})},E.id))]},L.provider)),I.length===0&&!A&&T.size===0&&(0,t.jsx)("div",{className:"px-2 py-2 space-y-2",children:(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:p?y??"No model detected yet. Enter a provider/model manually.":"No models found."})})]})]})]})})}r(SK,"ModelDropdown");function mGe({value:e,options:s,onChange:n,open:a,onOpenChange:i}){const o=s.find(l=>l.id===e)??s[0];return(0,t.jsx)(ys,{label:"Thinking effort",hint:fi.thinkingEffort,children:(0,t.jsxs)(Zn,{open:a,onOpenChange:i,children:[(0,t.jsx)(ur,{asChild:!0,children:(0,t.jsxs)("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-sm hover:bg-accent/50 transition-colors w-full justify-between",children:[(0,t.jsx)("span",{className:U(!e&&"text-muted-foreground"),children:o?.label??"Auto"}),(0,t.jsx)(sn,{className:"h-3 w-3 text-muted-foreground"})]})}),(0,t.jsx)(Vn,{className:"w-(--radix-popover-trigger-width) p-1",align:"start",children:s.map(l=>(0,t.jsxs)("button",{className:U("flex items-center justify-between w-full px-2 py-1.5 text-sm rounded hover:bg-accent/50",l.id===e&&"bg-accent"),onClick:r(()=>{n(l.id),i(!1)},"onClick"),children:[(0,t.jsx)("span",{children:l.label}),l.id?(0,t.jsx)("span",{className:"text-xs text-muted-foreground font-mono",children:l.id}):null]},l.id||"auto"))})]})})}r(mGe,"ThinkingEffortDropdown");function Axe(e){const s=`paperclip.agent-appearance.${e}`;function n(){try{const l=Mle.safeParse(JSON.parse(sessionStorage.getItem(s)??"null"));if(l.success)return l.data}catch{}const o=m2();try{sessionStorage.setItem(s,JSON.stringify(o))}catch{}return o}r(n,"readDraft");const[a,i]=(0,u.useState)(()=>({key:s,appearance:n()}));return a.key!==s&&i({key:s,appearance:n()}),{appearance:a.appearance,clear(){try{sessionStorage.removeItem(s)}catch{}}}}r(Axe,"useAgentAppearanceDraft");var ak=null,jI=new Set,ik={subscribe(e){return jI.add(e),()=>{jI.delete(e)}},getSnapshot(){return ak},acquire(e){if(ak)return!1;ak=e;for(const s of jI)s();return!0},release(e){if(ak===e){ak=null;for(const s of jI)s()}}};function jC({agent:e,appearance:s,size:n=256,state:a="idle",muted:i=!1,motion:o="auto",trackingRegion:l,trackingScope:c="region",followCursor:d=!0,followRotation:m=!0,className:h,label:p,name:f}){const g=(0,u.useMemo)(()=>Bw(s??e?.appearance,e?.id),[s,e?.appearance,e?.id]),v=(0,u.useRef)(null),y=(0,u.useRef)(null),w=(0,u.useRef)(null),S=(0,u.useRef)(Symbol("agent-character")),j=(0,u.useSyncExternalStore)(ik.subscribe,ik.getSnapshot,()=>null),[N,_]=(0,u.useState)(!1),[R,C]=(0,u.useState)(!0),[A,T]=(0,u.useState)(!1),[I,$]=(0,u.useState)(!1),O=N&&!R&&!A&&o==="auto"&&a!=="rest";return(0,u.useEffect)(()=>{if(typeof matchMedia!="function"||typeof IntersectionObserver!="function")return;const L=matchMedia("(prefers-reduced-motion: reduce)"),E=r(()=>C(L.matches),"change");E(),L.addEventListener("change",E);const q=new IntersectionObserver(B=>_(B[0]?.isIntersecting??!1));return v.current&&q.observe(v.current),()=>{q.disconnect(),L.removeEventListener("change",E)}},[]),(0,u.useEffect)(()=>{O&&j===null&&ik.acquire(S.current),O||ik.release(S.current)},[O,j]),(0,u.useEffect)(()=>()=>ik.release(S.current),[]),(0,u.useEffect)(()=>{if(!O||j!==S.current)return;let L=!1;return $(!1),Promise.all([jc(()=>import("./runtime-IAg0vdY9.js"),__vite__mapDeps([0,1])),jc(()=>import("./definition-vPsS6JqV.js"),__vite__mapDeps([2,3,1]))]).then(([E,q])=>{L||!y.current||(w.current=E.createCharacter(y.current,q.characterDefinition(g,i),{animation:q.animationId(a),trackingRegion:l?.current??v.current??void 0,followCursor:d,followRotation:m,trackingScope:c,displaySize:n,onError:r(()=>T(!0),"onError")}),$(!0))}).catch(()=>{L||T(!0)}),()=>{L=!0,w.current?.destroy(),w.current=null,$(!1)}},[O,j,l,c,n,d,m]),(0,u.useEffect)(()=>{w.current&&jc(()=>import("./definition-vPsS6JqV.js").then(L=>{w.current?.setDefinition(L.characterDefinition(g,i)),w.current?.setAnimation(L.animationId(a))}),__vite__mapDeps([2,3,1]))},[g,i,a,I]),(0,t.jsxs)("span",{ref:v,role:p?"img":void 0,"aria-label":p,"aria-hidden":p?void 0:!0,className:U("relative inline-block shrink-0",G2e[n],h),children:[(0,t.jsx)(gr,{agent:e,appearance:g,size:n<256?256:n,name:f,pose:a,muted:i,className:U("size-full",I&&"invisible")}),(0,t.jsx)("span",{ref:y,className:"absolute inset-0"})]})}r(jC,"AgentCharacter");var hGe=new Set(["claude_local","codex_local","opencode_local","grok_local"]);function Rxe(e,{cloud:s,nativeRunnerEnabled:n}){return s?hGe.has(e):e!=="paperclip_runner"||n}r(Rxe,"isNewAgentAdapterAllowed");var pGe={claude_local:{src:"/brands/claude-color.svg"},codex_local:{src:"/brands/codex-color.svg"},gemini_local:{src:"/brands/adapters/gemini-color.svg"},kimi_local:{src:"/brands/adapters/kimi-color-light.svg",dark:"/brands/adapters/kimi-color.svg"},...Object.fromEntries([["cursor","cursor"],["cursor_cloud","cursor"],["grok_local","grok"],["hermes_local","hermesagent"],["hermes_gateway","hermesagent"],["pi_local","pi"]].map(([e,s])=>[e,{src:`/brands/adapters/${s}.svg`,dark:`/brands/adapters/${s}-dark.svg`}]))};function CK({type:e,className:s="size-6"}){const n=Um(e).icon,a=pGe[e];return a?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("img",{src:a.src,className:U("shrink-0 object-contain",a.dark&&"dark:hidden",s),alt:""}),a.dark&&(0,t.jsx)("img",{src:a.dark,className:U("hidden shrink-0 object-contain dark:block",s),alt:""})]}):(0,t.jsx)(n,{className:s})}r(CK,"AdapterMark");function fGe(){const{selectedCompanyId:e}=ps(),{appearance:s}=Axe(`${e}:new-agent`);return(0,t.jsx)(jC,{appearance:s,state:"sleepy",muted:!0,size:256,className:"size-48",trackingScope:"page"})}r(fGe,"AgentBasicsCharacter");function Txe({open:e,onClose:s,onContinue:n,initialAdapter:a="",onInvite:i}){const o=(0,u.useId)(),l=!!Yc(),c=Z({queryKey:P.instance.experimentalSettings,queryFn:Er.getExperimental,enabled:e,retry:!1}),[d,m]=(0,u.useState)(""),[h,p]=(0,u.useState)(a),[f,g]=(0,u.useState)("codex"),[v,y]=(0,u.useState)("name"),{data:w,isPending:S,error:j}=Z({queryKey:P.adapters.all,queryFn:Rm.list,enabled:e}),N=(w??[]).filter(R=>R.loaded&&!R.disabled&&Rxe(R.type,{cloud:l,nativeRunnerEnabled:c.data?.enableNativeRunner===!0})&&!["process","http"].includes(R.type)&&!Um(R.type).comingSoon),_=N.some(R=>R.type===h);return(0,t.jsx)(Ys,{open:e,onOpenChange:r(R=>{R||s()},"onOpenChange"),children:(0,t.jsxs)(Js,{className:U("flex max-h-(--sz-calc-18) flex-col gap-0 overflow-hidden p-0 sm:max-w-(--sz-640px)",v==="name"&&"sm:max-w-(--sz-560px)"),children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 px-6 py-5 text-xs text-muted-foreground","aria-label":"New agent progress",children:[(0,t.jsx)("span",{className:U(v==="name"&&"font-medium text-foreground"),children:"1. Name"}),(0,t.jsx)(Tn,{className:"size-3"}),(0,t.jsx)("span",{className:U(v==="adapter"&&"font-medium text-foreground"),children:"2. Adapter"})]}),(0,t.jsxs)("form",{className:"flex min-h-0 flex-col",onSubmit:r(R=>{R.preventDefault(),d.trim()&&(v==="name"?y("adapter"):_&&n({name:d.trim(),adapterType:h,runnerProvider:f}))},"onSubmit"),children:[(0,t.jsxs)("div",{className:"flex min-h-0 flex-col gap-7 overflow-y-auto px-6 pb-8 sm:px-10",children:[(0,t.jsxs)("div",{className:"flex flex-col items-center gap-4 text-center",children:[e&&(0,t.jsx)(fGe,{}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(tn,{className:"text-3xl font-semibold tracking-tight",children:v==="name"?"Meet your next agent":"Choose an adapter"}),(0,t.jsx)(Ln,{className:"text-base",children:v==="name"?"Start with a name. Make them your own.":`How should ${d.trim()} work?`})]})]}),v==="name"?(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("label",{htmlFor:o,className:"text-sm font-medium",children:"Agent name"}),(0,t.jsx)(At,{id:o,autoFocus:!0,maxLength:100,placeholder:"e.g. Darnold",value:d,onChange:r(R=>m(R.target.value),"onChange"),className:"h-12 text-base"}),i&&(0,t.jsx)(F,{type:"button",variant:"link",className:"px-0 text-muted-foreground",onClick:i,children:"Invite an external agent"})]}):(0,t.jsxs)("fieldset",{className:"space-y-4",children:[(0,t.jsx)("legend",{className:"sr-only",children:"Adapter"}),S&&(0,t.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:"Loading adapters…"}),j&&(0,t.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:j.message}),(0,t.jsx)("div",{className:U("grid grid-cols-2 gap-3",N.length!==4&&"sm:grid-cols-3"),children:N.map(R=>{const C=Um(R.type);return(0,t.jsxs)("label",{className:"relative cursor-pointer",children:[(0,t.jsx)("input",{type:"radio",name:"new-agent-adapter",value:R.type,checked:h===R.type,onChange:r(()=>p(R.type),"onChange"),className:"peer sr-only"}),(0,t.jsxs)("span",{className:U("flex h-full flex-col items-center gap-2 rounded-lg border px-3 py-4 text-center peer-focus-visible:ring-2 peer-focus-visible:ring-ring hover:bg-accent/40",h===R.type?"border-foreground/40 bg-accent":"border-border bg-card"),children:[(0,t.jsx)(CK,{type:R.type}),(0,t.jsx)("span",{className:"text-sm font-medium",children:C.label}),h===R.type&&(0,t.jsx)(ds,{className:"absolute right-2 top-2 size-3.5"})]})]},R.type)})}),_&&h==="paperclip_runner"&&(0,t.jsxs)("label",{className:"flex flex-col gap-2 text-sm font-medium",children:["Runner",(0,t.jsxs)("select",{className:"rounded-md border border-border bg-background px-3 py-2",value:f,onChange:r(R=>g(R.target.value),"onChange"),children:[(0,t.jsx)("option",{value:"codex",children:"Codex (app server)"}),(0,t.jsx)("option",{value:"claude",children:"Claude (ACPX)"}),(0,t.jsx)("option",{value:"opencode",children:"OpenCode"})]})]})]})]}),(0,t.jsxs)("div",{className:"flex justify-between gap-4 border-t border-border px-6 py-4",children:[(0,t.jsx)(F,{type:"button",variant:"ghost",onClick:r(()=>v==="name"?s():y("name"),"onClick"),children:v==="name"?"Cancel":(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Sl,{className:"size-4"}),"Back"]})}),(0,t.jsxs)(F,{type:"submit",disabled:!d.trim()||v==="adapter"&&!_,children:[v==="name"?"Choose adapter":"Configure agent",(0,t.jsx)(zo,{className:"size-4"})]})]})]})]})})}r(Txe,"AgentBasicsDialog");var xGe={subscription:"Subscription",api:"API"};function gGe({mode:e}){return(0,t.jsx)("span",{className:"relative flex h-4 w-full items-center justify-center overflow-hidden text-(length:--text-micro) text-muted-foreground",children:(0,t.jsx)(dN,{initial:!1,mode:"sync",children:(0,t.jsx)(Zo.span,{className:"absolute inset-0 flex items-center justify-center whitespace-nowrap",initial:{opacity:0,y:EY},animate:{opacity:1,y:0,transition:z7e},exit:{opacity:0,y:EY,transition:U7e},children:xGe[e]},e)})})}r(gGe,"CredentialTag");function bGe({source:e,mode:s,selected:n,onSelect:a,buttonRef:i,settling:o}){return(0,t.jsxs)("button",{ref:i,type:"button",role:"radio","aria-checked":n,onClick:a,className:U("flex min-w-0 flex-1 cursor-pointer flex-col items-center gap-1.5 self-stretch rounded-md border p-3","transition-(--tp-border-color-background-color) ease-(--motion-ease-standard)",o?"duration-(--motion-duration-slow)":"duration-(--motion-duration-fast)","outline-none focus-visible:ring-ring/50 focus-visible:ring-(length:--rad-3)",n?"border-foreground/40 bg-accent":"border-border bg-card hover:bg-accent/40"),children:[(0,t.jsx)("span",{className:"flex size-(--sz-30px) shrink-0 items-center justify-center",children:e.icon}),(0,t.jsx)("span",{className:"text-(length:--text-compact) font-medium text-foreground",children:e.label}),(0,t.jsx)(gGe,{mode:s})]})}r(bGe,"ModelSourceTile");function Exe({sources:e,mode:s,selectedId:n,onSelect:a,label:i,collapsed:o=!1,settling:l=!1}){const c=(0,u.useRef)(new Map),d=r(h=>{if(e.length===0)return;const p=e.findIndex(g=>g.id===n),f=e[((p===-1?h>0?-1:0:p)+h+e.length)%e.length];a(f.id),c.current.get(f.id)?.focus()},"moveSelection"),m=o?e.filter(h=>h.id===n):e;return(0,t.jsx)("div",{role:"radiogroup","aria-label":i,className:U("flex items-start gap-3",o&&"justify-center"),onKeyDown:r(h=>{o||(h.key==="ArrowRight"||h.key==="ArrowDown"?(h.preventDefault(),d(1)):(h.key==="ArrowLeft"||h.key==="ArrowUp")&&(h.preventDefault(),d(-1)))},"onKeyDown"),children:(0,t.jsx)(dN,{initial:!1,mode:"popLayout",children:m.map(h=>(0,t.jsx)(Zo.div,{layout:!0,transition:Pfe,exit:{opacity:0,transition:Z7e},className:U("flex min-w-0",o?"w-(--sz-source-tile-two-up)":"flex-1"),children:(0,t.jsx)(bGe,{source:h,mode:s,selected:h.id===n,onSelect:r(()=>a(h.id),"onSelect"),settling:l,buttonRef:r(p=>{p?c.current.set(h.id,p):c.current.delete(h.id)},"buttonRef")})},h.id))})})}r(Exe,"ModelSourceTiles");var W4={subscription:"Use API key instead",api:"Use subscription instead"},vGe={subscription:"api",api:"subscription"};function Pxe({mode:e,onChange:s}){return(0,t.jsxs)("button",{type:"button",onClick:r(()=>s(vGe[e]),"onClick"),className:U("group grid cursor-pointer px-3 py-2 text-left text-sm font-medium","rounded-md outline-none focus-visible:ring-ring/50 focus-visible:ring-(length:--rad-3)"),children:[Object.keys(W4).map(n=>(0,t.jsx)("span",{"aria-hidden":!0,className:"invisible col-start-1 row-start-1 whitespace-nowrap",children:W4[n]},n)),(0,t.jsx)(dN,{initial:!1,mode:"sync",children:(0,t.jsx)(Zo.span,{className:U("col-start-1 row-start-1 justify-self-start whitespace-nowrap","underline decoration-muted-foreground/40 underline-offset-4","text-muted-foreground transition-colors","group-hover:text-foreground group-hover:decoration-foreground/40"),initial:{opacity:0},animate:{opacity:1,transition:pK},exit:{opacity:0,transition:K7e},children:W4[e]},e)})]})}r(Pxe,"CredentialModeLink");function Mxe({onBack:e,primaryLabel:s,primaryDisabled:n,loading:a,loadingLabel:i,primaryIcon:o,onPrimary:l}){const c=a&&i?i:s,d=o??(a?"spinner":"arrow");return(0,t.jsxs)("div",{className:"flex items-center justify-between pt-9",children:[e?(0,t.jsxs)(F,{variant:"ghost",size:"lg",className:"rounded-full has-[>svg]:pl-4 has-[>svg]:pr-5",onClick:e,disabled:a,children:[(0,t.jsx)(Sl,{className:"mr-1 size-3.5"}),"Back"]}):(0,t.jsx)("span",{}),(0,t.jsx)(Zo.div,{layout:!0,transition:H7e,className:"min-w-0",children:(0,t.jsx)(F,{size:"lg",className:"w-full rounded-full px-6",onClick:l,disabled:n||a,children:(0,t.jsxs)(Zo.span,{className:"flex items-center whitespace-nowrap",initial:{opacity:0},animate:{opacity:1},transition:Q7e,children:[d==="spinner"?(0,t.jsx)(at,{className:"mr-1 size-4 animate-spin"}):null,c,d==="arrow"?(0,t.jsx)(zo,{className:"ml-1 size-3.5"}):null]},`${c}:${d}`)})})]})}r(Mxe,"FooterNav");function Dxe({companyId:e,adapterType:s,environmentId:n,canLogin:a,localEnvironment:i=!1,onConnected:o,onBack:l,testConnection:c,testError:d,managedAccount:m}){const h=Z({queryKey:P.health,queryFn:sm.get,enabled:i}),p=i&&(h.data?.localAiLoginSupported??h.data?.deploymentMode==="local_trusted"),f=(0,u.useRef)(0);(0,u.useEffect)(()=>()=>{f.current++},[]);const g=r(()=>{f.current++,$(!1),S(!1),N(null),R("preparing")},"cancel"),[v,y]=(0,u.useState)(m?.initialMethod==="api_key"?"api":m?"subscription":null),[w,S]=(0,u.useState)(!1),[j,N]=(0,u.useState)(null),[_,R]=(0,u.useState)("preparing"),C=(0,u.useRef)("ready"),[A,T]=(0,u.useState)(""),[I,$]=(0,u.useState)(!1),[O,L]=(0,u.useState)(null),[E,q]=(0,u.useState)(null),B=s==="claude_local"?"Claude":s==="grok_local"?"Grok":"OpenAI",K=s==="claude_local"?"ANTHROPIC_API_KEY":s==="grok_local"?"XAI_API_KEY":"OPENAI_API_KEY",z=s==="claude_local"?"anthropic":s==="grok_local"?"xai":"openai",D=bfe(e,K),V=m?{...D,options:[],subscriptions:[],loading:!1}:D,[H,ee]=(0,u.useState)(null),X=V.subscriptions.length?V.subscriptions.find(re=>re.id===(H??V.subscriptions[0]?.id)):void 0,[le,ce]=(0,u.useState)(null),te=V.options.find(re=>re.id===(le??V.options[0]?.id)),ae=m?{...V.storedLogin,data:void 0,isPending:!1,isError:!1}:V.storedLogin,de=(0,u.useRef)(null),J=v??(V.subscriptions.length>0||s==="claude_local"&&!X&&ae.data?"subscription":V.options.length?"api":"subscription"),Y=Lhe(e,m?.intent??{provider:z,method:"subscription",name:`My ${B} subscription`,ownership:"personal",agentIds:[],allAgents:!0},p&&J==="subscription"&&!X&&!ae.data,{allowHostClaude:h.data?.deploymentMode==="local_trusted"}),G=Z({queryKey:P.agents.authSignal(e,s,n),queryFn:r(()=>Vt.getAdapterAuthSignal(e,s,n??void 0),"queryFn"),retry:!1,enabled:!m});async function fe(){if(I||m?.disabled)return;const re=++f.current;$(!0),L(null);try{if(m){if(J==="subscription"&&!p)return;const pe=de.current??await(J==="api"?mu.create(e,{...m.intent,method:"api_key",apiKey:A.trim()}):Y.connect(m.intent));de.current=pe,T(""),re===f.current&&m.onComplete({...pe,method:J==="api"?"api_key":"subscription"});return}let ie=J==="api"?te?te.aiConnection?{env:{},aiConnection:te.aiConnection}:{env:{[K]:te.binding}}:E??{env:{},credentials:{[K]:A.trim()}}:{...X?.aiConnection?{aiConnection:X.aiConnection}:{},env:X?.binding?{CODEX_HOME:X.binding}:{},...s==="claude_local"&&!X&&ae.data?{env:fj(),applyStoredClaudeLogin:!0}:{}};if(J==="subscription"&&p&&!X&&!ae.data&&(de.current??=await Y.connect(),ie={env:{},aiConnection:{provider:z,method:"subscription",mode:"responsible_user"}}),ie.credentials&&(await mu.create(e,{provider:z,method:"api_key",name:`My ${B} API`,ownership:"personal",apiKey:ie.credentials[K],agentIds:[],allAgents:!0}),ie={env:{},aiConnection:{provider:z,method:"api_key",mode:"responsible_user"}}),re!==f.current)return;J==="api"&&(T(""),te||q(ie));const me=await c(ie);if(re!==f.current)return;me?o(ie):L("The provider did not respond. Check the connection and try again.")}catch(ie){if(re!==f.current)return;m&&T(""),L(ie instanceof Error?ie.message:"Could not connect to the provider.")}finally{re===f.current&&$(!1)}}r(fe,"connect");const se=J==="subscription"&&a&&n&&!X&&!V.loading&&!ae.data&&(!!m||G.data?.status!=="present"||H==="");return(0,t.jsxs)("div",{className:"min-w-0 max-w-full",children:[(0,t.jsx)(Exe,{label:"Connect your model provider",sources:[{id:s,label:B,icon:(0,t.jsx)(CK,{type:s})}],mode:J,selectedId:w?s:null,collapsed:w,onSelect:r(()=>{m?.disabled||S(!0)},"onSelect")}),!w&&!m?.fixedMethod&&(0,t.jsx)("div",{className:"-ml-3 mt-1",children:(0,t.jsx)(Pxe,{mode:J,onChange:r(re=>{de.current=null,y(re),L(null)},"onChange")})}),!w&&V.options.length>0&&(0,t.jsxs)("p",{className:"mt-2 text-sm text-muted-foreground",children:[V.options.length," saved API"," ",V.options.length===1?"key available":"keys available","."]}),J==="subscription"&&V.subscriptions.length>0&&(0,t.jsx)($j,{options:V.subscriptions,value:X?.id??"",onChange:ee,loading:!1,error:!1,kind:"subscription",disabled:I}),(0,t.jsx)(Zo.div,{initial:!1,animate:{height:w?"auto":0,opacity:w?1:0},transition:{height:cd,opacity:oE},className:"overflow-hidden",children:w&&(0,t.jsx)("div",{className:"pt-5",children:J==="api"?(0,t.jsxs)(lE,{instruction:V.options.length?"Choose a saved API key or enter a new one":`Provide your ${B} API key to connect`,children:[(0,t.jsx)($j,{...V,value:te?.id??"",disabled:I,onChange:r(re=>{ce(re),T(""),q(null),L(null)},"onChange")}),!te&&(0,t.jsx)(cE,{label:"API key",masked:!0,autoFocus:!0,value:A,placeholder:E?"Key entered. Retry the connection.":"Enter API key here",onChange:r(re=>{ce(""),T(re),q(null)},"onChange"),onSubmit:r(()=>{fe()},"onSubmit"),disabled:I})]}):se?(0,t.jsx)(kK,{companyId:e,adapterType:s,environmentId:n,chrome:"onboarding",aiConnection:m?.intent??{provider:z,method:"subscription",name:`My ${B} subscription`,ownership:"personal",agentIds:[],allAgents:!0},autoStart:!0,onStored:r(()=>{},"onStored"),onPromptReady:r(re=>{N(re),R(ie=>re?ie==="preparing"?"ready":ie:"preparing")},"onPromptReady"),onCodeSubmitted:r(()=>{C.current=_==="waiting"?"waiting":"ready",R("connecting")},"onCodeSubmitted"),onSubmitFailed:r(()=>{R(re=>re==="connecting"?C.current:re)},"onSubmitFailed"),onConnected:r(re=>{if(m){if(!re){L("The login did not return a saved connection. Try again.");return}const me=f.current;R("connecting"),mu.loginResult(e,re).then(pe=>{me===f.current&&m.onComplete({...pe,method:"subscription"})}).catch(()=>{me===f.current&&(R("ready"),L("Could not retrieve the saved connection. Go back and retry."))});return}const ie={env:{},aiConnection:{provider:z,method:"subscription",mode:"responsible_user"}};q(ie),o(ie)},"onConnected")}):X?null:p&&!ae.data?(0,t.jsx)(fK,{adapterType:s,login:{...Y,retry:r(()=>{L(null),Y.retry()},"retry")}}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:ae.data?"Use your saved Claude subscription for this agent.":a?"Use the existing provider connection for this environment.":"This environment does not support browser sign-in. Choose a sign-in environment or connect with an API key."})})}),J==="subscription"&&ae.isError&&(0,t.jsx)("p",{role:"alert",className:"mt-4 text-sm text-destructive",children:"Could not check your saved Claude subscription. Try again."}),O&&(0,t.jsx)("p",{role:"alert",className:"mt-4 text-sm text-destructive",children:d??O}),i&&h.isError&&(0,t.jsx)("p",{role:"alert",className:"mt-4 text-sm text-destructive",children:"Could not prepare sign-in. Reload this page to try again."}),(0,t.jsx)(Mxe,{onBack:r(()=>{w?g():l()},"onBack"),primaryLabel:w&&se?_==="waiting"?"Waiting for code":_==="connecting"?"Connecting":`Sign in to ${B}`:I?"Connecting":J==="subscription"&&(ae.data||X)?"Use saved subscription":J==="api"&&te?"Use saved API key":"Connect",primaryDisabled:m?.disabled||!!m&&J==="subscription"&&!a&&!p||i&&h.isPending||Y.preparing||!!Y.error||!m&&G.isPending||V.loading||s==="claude_local"&&ae.isPending||!w||!!se&&(!j||_!=="ready")||J==="api"&&!A.trim()&&!E&&!te,loading:I,primaryIcon:w&&se?_==="ready"?"none":"spinner":void 0,onPrimary:r(()=>{if(se){if(!j||_!=="ready")return;window.open(j,"_blank","noreferrer,noopener"),R("waiting")}else fe()},"onPrimary")})]})}r(Dxe,"AgentProviderConnection");function zT(e){return e.provider==="openrouter"?(0,t.jsx)(jGe,{...e}):(0,t.jsx)(yGe,{...e})}r(zT,"AiConnectionCredentialStep");function yGe({companyId:e,provider:s,initialMethod:n,fixedMethod:a,connectionId:i,name:o,ownership:l,agentIds:c,allAgents:d,environmentId:m,onComplete:h,onCancel:p}){const[f,g]=(0,u.useState)(o),[v,y]=(0,u.useState)(),w=Wt(),S=Z({queryKey:P.environments.list(e),queryFn:r(()=>Ci.list(e),"queryFn")}),j=Z({queryKey:P.environments.capabilities(e),queryFn:r(()=>Ci.capabilities(e),"queryFn")}),N=Z({queryKey:P.instance.settings,queryFn:Er.get}),_=Z({queryKey:P.instance.experimentalSettings,queryFn:Er.getExperimental}),R=Z({queryKey:P.instance.generalSettings,queryFn:Er.getGeneral}),C=NK(R.data?.executionMode,S.data??[]);let A=null,T;try{A=C.forced?C.kubernetesEnvironment?.id??null:vw({agentDefaultEnvironmentId:m??v,instanceDefaultEnvironmentId:N.data?.defaultEnvironmentId,localDefaultEnvironmentId:jw(S.data),managedSandboxOnly:_.data?.enableManagedSandboxOnly,managedSandboxEnvironmentId:yw(S.data),visibleEnvironmentIds:S.data?.map(K=>K.id)})}catch(K){T=K instanceof Error?K.message:"Could not resolve the sign-in environment."}const I=(S.data??[]).filter(K=>K.status==="active"&&(K.driver==="local"||K.driver==="sandbox"&&typeof K.config.provider=="string"&&j.data?.sandboxProviders?.[K.config.provider]?.supportsLoginPty===!0));!C.forced&&!m&&!v&&!I.some(K=>K.id===A)&&(A=I[0]?.id??null);const $=S.data?.find(K=>K.id===A),O=typeof $?.config.provider=="string"?$.config.provider:"",L=$?.driver==="sandbox"&&j.data?.sandboxProviders?.[O]?.supportsLoginPty===!0,E=[S,j,N,_,R].some(K=>K.isPending),q=T??[S,j,N,_,R].find(K=>K.error)?.error?.message,B={provider:s,method:"subscription",name:f,ownership:l,agentIds:c,allAgents:d,connectionId:i};return(0,t.jsxs)("div",{className:"mx-auto w-full min-w-0 max-w-xl space-y-6",children:[(0,t.jsxs)("label",{className:"block space-y-2 text-sm",children:["Connection name",(0,t.jsx)(At,{value:f,onChange:r(K=>g(K.target.value),"onChange"),disabled:!!i})]}),!m&&!C.forced&&I.length>1&&(0,t.jsxs)($a,{value:A??"",onValueChange:y,children:[(0,t.jsx)(La,{"aria-label":"Sign-in environment",children:(0,t.jsx)(Ma,{placeholder:"Sign-in environment"})}),(0,t.jsx)(Da,{children:I.map(K=>(0,t.jsx)(Sn,{value:K.id,children:K.name},K.id))})]}),q&&(0,t.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:q}),E?(0,t.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:"Preparing sign-in…"}):(0,t.jsx)(Dxe,{companyId:e,adapterType:s==="anthropic"?"claude_local":s==="xai"?"grok_local":"codex_local",environmentId:A,canLogin:L,localEnvironment:$?.driver==="local",onBack:p,onConnected:r(()=>{},"onConnected"),testConnection:r(async()=>!1,"testConnection"),managedAccount:{intent:B,initialMethod:n,fixedMethod:a||!!i,disabled:E||!!q||!f.trim(),onComplete:r(K=>{w.invalidateQueries({queryKey:["ai-connections",e]}),h(K)},"onComplete")}},A??"local")]})}r(yGe,"SubscriptionConnectionStep");function jGe({companyId:e,provider:s,connectionId:n,name:a,ownership:i,agentIds:o,allAgents:l,onComplete:c,onCancel:d}){const[m,h]=(0,u.useState)(a),[p,f]=(0,u.useState)(""),g=Wt(),v=Ne({mutationFn:r(()=>mu.create(e,{provider:s,method:"api_key",name:m,ownership:i,agentIds:o,allAgents:l,connectionId:n,apiKey:p}),"mutationFn"),onSuccess:r(y=>{g.invalidateQueries({queryKey:["ai-connections",e]}),c({...y,method:"api_key"})},"onSuccess"),onSettled:r(()=>f(""),"onSettled")});return(0,t.jsxs)("div",{className:"mx-auto w-full min-w-0 max-w-xl space-y-4",children:[(0,t.jsxs)("label",{className:"block space-y-2 text-sm",children:["Connection name",(0,t.jsx)(At,{value:m,onChange:r(y=>h(y.target.value),"onChange"),disabled:!!n})]}),v.error&&(0,t.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:v.error.message}),(0,t.jsx)($fe,{providerName:"OpenRouter",value:p,onChange:f,onSubmit:r(()=>v.mutate(),"onSubmit"),disabled:v.isPending,placeholder:"Enter API key here",autoFocus:!0}),(0,t.jsxs)("div",{className:"flex justify-between gap-2",children:[(0,t.jsx)(F,{variant:"ghost",onClick:d,children:"Cancel"}),(0,t.jsx)(F,{disabled:!m.trim()||!p.trim()||v.isPending,onClick:r(()=>v.mutate(),"onClick"),children:v.isPending?"Connecting…":"Connect"})]})]})}r(jGe,"ApiKeyConnectionStep");var wGe=new RegExp(`\\b(${["mcp","server","profile","policy","gateway","transport","stdio","endpoint"].join("|")})s?\\b`,"gi");function Lxe(e){return e.replace(wGe,"").replace(/\s{2,}/g," ").replace(/\s+([.,])/g,"$1").trim()}r(Lxe,"sanitizeProsumerCopy");var NGe={zapier:{tagline:"Reach 9,000+ apps your team already uses.",short:"Reach 9,000+ apps from your agents."},github:{tagline:"Read code and pull requests, comment on issues.",short:"Read code and pull requests, comment on issues."},slack:{tagline:"Send and read messages in your team's channels.",short:"Send and read messages in your channels."},notion:{tagline:"Read and update pages in your workspace.",short:"Read and update pages in your workspace."},railway:{tagline:"Inspect services, read logs, and manage deployments.",short:"Connect Railway for deployments, logs, and container access."},posthog:{tagline:"Explore product usage, errors, flags, and experiments.",short:"Sign in with PostHog. Project pinning and access controls are optional."},linear:{tagline:"Create, update and read tickets.",short:"Create, update and read tickets."},"google-sheets":{tagline:"Read and update selected spreadsheets.",short:"Read spreadsheets or update the files you choose."},gmail:{tagline:"Read mail and create drafts for your review.",short:"Read mail and create drafts for your review."},"google-drive":{tagline:"Find, read, and create files in Drive.",short:"Find, read, and create files in Drive."},"google-docs":{tagline:"Read and update documents.",short:"Read and update documents."},"google-slides":{tagline:"Read and update presentations.",short:"Read and update presentations."},"google-calendar":{tagline:"Review calendars and manage events.",short:"Review calendars and manage events."},"google-chat":{tagline:"Read conversations and send messages.",short:"Read conversations and send messages."},"google-people":{tagline:"Look up contacts and people in your directory.",short:"Look up contacts and people in your directory."},"google-workspace-search":{tagline:"Search across your Google workspace.",short:"Search across your Google workspace."},hubspot:{tagline:"Look up contacts and update deal stages.",short:"Look up contacts and update deal stages."},intercom:{tagline:"Read and reply to customer conversations.",short:"Read and reply to customer conversations."},figma:{tagline:"Read files and post comments on frames.",short:"Read files and post comments on frames."},stripe:{tagline:"Read customers, invoices, and payouts.",short:"Read customers, invoices, and payouts."},context7:{tagline:"Look up up-to-date docs for your libraries.",short:"Look up up-to-date docs for your libraries."}},kGe={tagline:"Give your agents access to this app.",short:"Give your agents access to this app."};function $xe(e,s){const n=NGe[e];if(n)return n;if(s){const a=Lxe(s);if(a)return{tagline:a,short:a}}return kGe}r($xe,"appCopyFor");function gJ(e,s,n){return n<=1?`Your ${e} key`:Lxe(s)||`Your ${e} key`}r(gJ,"credentialFieldLabel");var SGe=1500;function hf(e=SGe){const[s,n]=(0,u.useState)("idle"),a=(0,u.useRef)(null),i=(0,u.useRef)(0);(0,u.useEffect)(()=>()=>{a.current!==null&&window.clearTimeout(a.current)},[]);const o=(0,u.useCallback)(async l=>{const c=++i.current;let d="copied";try{await Yr(l)}catch{d="failed"}return i.current!==c||(n(d),a.current!==null&&window.clearTimeout(a.current),a.current=window.setTimeout(()=>{i.current===c&&(n("idle"),a.current=null)},e)),d},[e]);return{status:s,copied:s==="copied",failed:s==="failed",copy:o}}r(hf,"useCopyAction");function _K(){const e=_c()?.pushToast;return(0,u.useCallback)(async(s,n="Copied")=>{try{return await Yr(s),e?.({title:n,tone:"success",dedupeKey:`copy:${n}`}),!0}catch{return e?.({title:"Couldn’t copy to clipboard",body:"Select and copy the value manually.",tone:"error",dedupeKey:"copy-failed"}),!1}},[e])}r(_K,"useCopyToast");var CGe="/cloud/connections/handoff",_Ge="/cloud/connections/reauth",UT="paperclip.cloud-oauth-handoff.v1",gx=class extends Error{static{r(this,"OAuthHandoffError")}code;constructor(e,s){super(e),this.code=s,this.name="OAuthHandoffError"}};function IK(e){if(e===void 0)return null;if(!e||typeof e!="object"||Array.isArray(e))throw new gx("Paperclip Cloud returned an invalid sign-in handoff.","invalid_handoff");const s=e;if(s.kind!=="paperclip_cloud"||typeof s.session!="string"||s.session.length<16||s.session.length>512||!/^[A-Za-z0-9_-]+$/.test(s.session))throw new gx("Paperclip Cloud returned an invalid sign-in handoff.","invalid_handoff");return{kind:"paperclip_cloud",session:s.session}}r(IK,"parseHandoff");function IGe(e,s){return e===404||s==="SESSION_NOT_AVAILABLE"?new gx("This sign-in expired. Start the connection again.","expired"):e===401||e===403?new gx("Paperclip Cloud could not authorize this connection for your account.","forbidden"):new gx("Paperclip Cloud couldn’t prepare secure sign-in. Try again.","unavailable")}r(IGe,"handoffFailure");async function AGe(e,s){const n=s.request??fetch;let a,i;for(let o=0;o<2;o+=1)try{if(a=await n(CGe,{method:"POST",headers:{"content-type":"application/json",accept:"application/json"},credentials:"include",body:JSON.stringify({session:e}),signal:s.signal}),a.status<500||o===1)return a}catch(l){if(s.signal?.aborted||l instanceof DOMException&&l.name==="AbortError")throw l;if(i=l,o===1)break}if(a)return a;throw new gx(i instanceof Error?i.message:"Paperclip Cloud couldn’t prepare secure sign-in. Try again.","unavailable")}r(AGe,"postCloudHandoff");function RGe(e,s){if(typeof e!="string"||typeof window>"u")return null;try{const n=new URL(e,window.location.origin);return n.origin!==window.location.origin||n.pathname!==_Ge||n.username||n.password||n.hash||n.searchParams.size!==1||n.searchParams.get("session")!==s?null:{kind:"reauthentication",url:n.toString(),host:n.host}}catch{return null}}r(RGe,"exactReauthenticationTarget");async function kw(e,s={}){const n=IK(e.handoff);if(!n){const l=yT(e.authorizationUrl);if(!l.ok)throw new gx(l.message,"invalid_handoff");return{kind:"authorization",url:l.url,host:l.host}}const a=await AGe(n.session,s),i=await a.json().catch(()=>null);if(!a.ok){if(i?.error==="RECENT_LOGIN_REQUIRED"){const l=RGe(i.reauthenticationUrl,n.session);if(l)return l}throw IGe(a.status,i?.error)}const o=yT(typeof i?.authorizationUrl=="string"?i.authorizationUrl:void 0);if(!o.ok)throw new gx("Paperclip Cloud returned an invalid provider sign-in address.","invalid_handoff");return{kind:"authorization",url:o.url,host:o.host}}r(kw,"prepareOAuthNavigation");function wC(e,s=window.sessionStorage){const n=IK({kind:"paperclip_cloud",session:e});if(!n)throw new gx("Paperclip Cloud returned an invalid sign-in handoff.","invalid_handoff");const a={version:1,session:n.session,savedAt:Date.now()};s.setItem(UT,JSON.stringify(a))}r(wC,"savePendingCloudHandoff");function TGe(e=window.sessionStorage){const s=e.getItem(UT);if(!s)return null;try{const n=JSON.parse(s);if(n.version!==1||typeof n.savedAt!="number"||Date.now()-n.savedAt>9e5)throw new Error("expired");return IK({kind:"paperclip_cloud",session:n.session})}catch{return e.removeItem(UT),null}}r(TGe,"readPendingCloudHandoff");function bJ(e=window.sessionStorage){e.removeItem(UT)}r(bJ,"clearPendingCloudHandoff");function pE({host:e,className:s}){return(0,t.jsxs)("div",{className:U("flex flex-wrap items-center gap-2 text-xs",s),children:[(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 font-medium text-amber-700 dark:text-amber-400",children:[(0,t.jsx)(kl,{className:"h-3 w-3"}),"Unverified server"]}),e?(0,t.jsx)("span",{className:"font-mono text-muted-foreground",children:e}):null]})}r(pE,"UnverifiedServerBadge");function fE(e){return!!(e&&kle({...e,methods:e.methods.filter(s=>(s.purpose??"tool")!=="channel"&&s.transport!=="chat_sdk")}))}r(fE,"appSupportsToolCatalogSetup");var EGe=SIe.filter(e=>gle(e).some(s=>Bp(s))).map(e=>e.slug);function PGe(e){return EGe.some(s=>s===e)}r(PGe,"isMcpDirectOAuthConnectSlug");function HF(e,s){const n=new URLSearchParams({source:e});return s&&n.set("intent",s),`/apps/connect?${n.toString()}`}r(HF,"appSourceConnectHref");function MGe(e,s){return`/apps/connect?${new URLSearchParams({source:e,resume:s}).toString()}`}r(MGe,"appSourceResumeHref");function H4(e){return e?`/apps/vercel-connect?${new URLSearchParams({source:e}).toString()}`:"/apps/vercel-connect"}r(H4,"vercelConnectSourceHref");function DGe(e){return e.serviceSlug??e.appKey??e.sourceSlug??void 0}r(DGe,"resolveAppsConnectRouteKey");function LGe(e,{chatConnectorsEnabled:s=!1}={}){if(e.get("byo")==="1")return!!(e.get("reconnect")?.trim()&&e.get("applicationId")?.trim()&&e.get("link")?.trim());const n=e.get("source")??"",a=s1(n);return!s&&a?.methods.some(i=>i.transport==="chat_sdk")&&!a.methods.some(i=>(i.purpose??"tool")!=="channel"&&i.transport!=="chat_sdk")?!1:mz(n)&&e.get("reconnect")?.trim()?!0:s?kle(a):fE(a)}r(LGe,"canEnterAppsConnect");var Q4=" for the organization",$Ge=" for the company";function vJ(e,s){const n=e.trim();if(s!=="organization")return n;const a=n.toLocaleLowerCase();return a.endsWith(Q4)?n:a.endsWith($Ge)?`${n.slice(0,n.length-16).trimEnd()}${Q4}`:`${n}${Q4}`}r(vJ,"connectionNameForGrantKind");function OGe(e){switch(e){case"active":return"Connected";case"needs_reauthorization":return"Needs attention";case"expired":return"Expired";case"revoked":return"Revoked";default:return"Not connected"}}r(OGe,"grantStatusLabel");function FGe(e){switch(e){case"active":return"connected";case"needs_reauthorization":case"expired":return"attention";case"revoked":return"inactive";default:return"missing"}}r(FGe,"grantStatusTone");function BGe(e,s={}){const n=e?.providerTenant?.name?.trim();return n||(e?.kind==="user"?s.subjectLabel?.trim()||"Connected account":e?.kind==="agent"?s.subjectLabel?.trim()||"Dedicated account":"Shared credential")}r(BGe,"grantAccountLabel");function qGe(e){return new Set((e?.members??[]).filter(s=>s.subjectType==="user").map(s=>s.subjectId))}r(qGe,"audienceUserIds");function zGe(e){return e.find(s=>s.kind==="organization"&&s.isDefault)??e.find(s=>s.kind==="organization")??null}r(zGe,"organizationGrant");function UGe(e,s){return s?e.find(n=>n.kind==="user"&&n.subjectUserId===s)??null:null}r(UGe,"personalGrantFor");function KGe(e,s){if(!s)return null;const n=e.find(a=>a.userId===s);return n&&(n.name?.trim()||n.email?.trim())||null}r(KGe,"memberLabel");var yJ=0;function QF(){return yJ+=1,{id:`header-${yJ}`,name:"",value:""}}r(QF,"newCustomHeaderRow");function IS(e){try{return new URL(e).host||null}catch{return null}}r(IS,"endpointHost");function VGe(e=window.location.origin){const s=new URL("/api/tools/oauth/callback",e),n=s.hostname.toLowerCase().replace(/^\[|\]$/g,"");return s.protocol==="http:"&&(n==="127.0.0.1"||n==="::1")&&(s.hostname="localhost"),s.toString()}r(VGe,"oauthCallbackUrlForBrowser");function G4(e){try{const s=new URL(e);return`${s.host.replace(/^www\./,"")}${s.pathname==="/"?"":s.pathname.replace(/\/+$/,"")}`.slice(0,160)||null}catch{return null}}r(G4,"defaultGenericMcpName");function jJ(e,s){const n=s?.trim()||"Paperclip couldn't connect to that address. Check it and try again.";switch(e){case"mcp_remote_url_missing":case"mcp_remote_url_invalid":return{title:"That doesn't look like a server address",body:"Paste the full address, starting with https:// — for example https://mcp.example.com/mcp.",focus:"url"};case"remote_http_private_endpoint":return{title:"That address is inside a private network",body:"This Paperclip is reachable from the internet, so it won't call addresses on your local network. Use the server's public address instead.",focus:"url"};case"remote_http_dns_failed":return{title:"We couldn't find that host",body:"The address didn't resolve. Check the spelling, or confirm the server is published on the internet.",focus:"url"};case"mcp_header_rejected":return{title:"Paperclip can't send that header",body:n,focus:"credentials"};case"tool_access_name_conflict":return{title:"Paperclip couldn’t name this connection",body:"Try connecting again.",focus:"none"};case"oauth_challenge":return{title:"This server wants a credential",body:"It asked us to authenticate but didn't offer a sign-in Paperclip can complete on its own. Add the key or headers its docs list under Advanced authentication.",focus:"credentials"};case"oauth_manual_client_required":case"oauth_manual_client_rebinding_required":return{title:"This server needs sign-in details you create yourself",body:"Register Paperclip in the provider's settings, then add the client ID and secret it gives you under Advanced authentication.",focus:"credentials"};case"oauth_redirect_origin_unsupported":case"oauth_redirect_uri_invalid":return{title:"This Paperclip needs a public HTTPS address first",body:"Sign-in sends the operator back to Paperclip, so this instance has to be reachable over HTTPS. Ask your Paperclip admin to configure it.",focus:"deployment"};case"runtime_error":return{title:"We couldn't reach that server",body:"Nothing answered at that address. Confirm the server is running and the address is right, then try again.",focus:"url"};default:return{title:"Paperclip couldn't connect",body:n,focus:"none"}}}r(jJ,"genericConnectGuidance");function Oxe(e){const s=new Set;for(const n of e){const a=n.name.trim();if(!a&&!n.value.trim())continue;const i=iIe(a);if(!i.ok)return nH(a,i.reason);const o=bIe(n.value);if(!o.ok)return nH(a,o.reason);if(!n.value.trim())return`Add a value for "${a}", or remove the row.`;const l=a.toLowerCase();if(s.has(l))return`"${a}" is listed twice.`;s.add(l)}return null}r(Oxe,"customHeaderError");function WGe(e){const s={},n=e.keyValue.trim();if((e.authMode==="bearer"||e.authMode==="auto"&&e.needsKey)&&n&&(s["credentials.authorization"]=n),e.authMode==="custom_headers")for(const l of e.headers){const c=l.name.trim();!c||!l.value.trim()||(s[`headers.${c}`]=l.value)}const a=e.name.trim(),i=e.oauthClientId.trim(),o=e.oauthClientSecret.trim();return{link:e.link,...a?{name:a}:{},...e.authMode==="auto"?{}:{authMode:e.authMode},...Object.keys(s).length>0?{credentialValues:s}:{},...e.authMode==="oauth"&&i?{oauthClient:{clientId:i,...o?{clientSecret:o}:{}}}:{}}}r(WGe,"genericConnectPayload");function HGe(e){return e.link.trim()?e.authMode==="auto"?!e.needsKey||e.keyValue.trim().length>0:e.authMode==="bearer"?e.keyValue.trim().length>0:e.authMode==="custom_headers"?e.headers.filter(s=>s.name.trim()&&s.value.trim()).length>0&&Oxe(e.headers)===null:!0:!1}r(HGe,"canSubmitGenericConnect");function Sw(e){const s=new Set;let n=!1;for(const a of e??[])a.targetType==="company"?n=!0:a.targetType==="agent"&&s.add(a.targetId);return{onAll:n,agentIds:s}}r(Sw,"installStateFrom");function Fxe(e,s){return e.onAll||e.agentIds.has(s)}r(Fxe,"isAgentInstalled");function Bxe(e,s){return s.onAll?[{targetType:"company",targetId:e}]:[...s.agentIds].map(n=>({targetType:"agent",targetId:n}))}r(Bxe,"installPayload");var QGe="Has access — tick to load its tools into this agent's context.";function qxe(e){return`paperclip.connector-enrollment-access:${e}`}r(qxe,"enrollmentAccessStorageKey");function GGe(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const s=e;if(typeof s.companyId!="string"||!s.companyId.trim()||!(s.grantKind==="user"||s.grantKind==="agent"||s.grantKind==="organization")||s.installChoice!=="specific"&&s.installChoice!=="all"||!Array.isArray(s.agentIds)||s.agentIds.some(a=>typeof a!="string"||!a.trim()))return!1;const n=new Set(s.agentIds);return n.size!==s.agentIds.length?!1:s.grantKind==="agent"?s.installChoice==="specific"&&n.size===1:s.installChoice==="all"?n.size===0:n.size>0}r(GGe,"validEnrollmentAccessState");function YGe(e,s,n){try{window.sessionStorage.setItem(qxe(s),JSON.stringify({...n,companyId:e}))}catch{}}r(YGe,"saveEnrollmentAccessState");function JGe(e){const s=qxe(e);try{const n=window.sessionStorage.getItem(s);if(window.sessionStorage.removeItem(s),!n)return null;const a=JSON.parse(n);return GGe(a)?a:null}catch{return null}}r(JGe,"consumeEnrollmentAccessState");function wJ(e){if(!e)return null;try{const s=new URL(e);return s.protocol==="https:"&&s.hostname.toLowerCase()==="github.com"?s.toString():null}catch{return null}}r(wJ,"githubRecoveryUrl");function NJ(e,s){return e==="denied"?"Authorization was cancelled or declined. Your saved connection was not changed.":s==="github_installation_required"?"GitHub access is required. Install Paperclip and grant at least one repository, then try again.":"Authorization did not complete. Your saved connection is still here, so you can try again."}r(NJ,"oauthCallbackErrorMessage");var XGe={access:"access",key:"setup",success:"complete"};function kJ(e){return e.requestedAppKey?e.resumeConnectionId||e.routeStage==="setup"?"key":"access":e.hasPrefilledLink||e.zapierSource?"access":"gallery"}r(kJ,"requestedConnectionInitialStep");function ZGe(e){const s=e.galleryApps.find(a=>a.slug===e.requestedAppKey);if(s)return s;if(!e.reconnectConnection)return null;const n=e.applications.find(a=>a.id===e.reconnectConnection?.applicationId);return Cx(n)!==e.requestedAppKey?null:mz(e.requestedAppKey)}r(ZGe,"requestedConnectionEntry");function eYe(e){return!e.reconnectConnection||!e.reconnectApplication||e.reconnectConnection.applicationId!==e.reconnectApplication.id?!1:e.requestedAppKey?Cx(e.reconnectApplication)===e.requestedAppKey:e.byo&&e.applicationId===e.reconnectApplication.id}r(eYe,"retainedReconnectMatches");function tYe(e){return e.credentialSource==="vercel_connect"&&!e.available&&!e.retainedReconnectMatches}r(tYe,"isVercelConnectUnavailable");function sYe(e){return e.available===!1&&!(e.reconnectConnectionId&&e.reconnectSourceMatches)}r(sYe,"isConnectionDefinitionUnavailable");function nYe(e){return!e.hasRequestedEntry||e.supportedMethodCount===0||e.unsupportedOAuth||e.vercelUnavailable||e.definitionUnavailable?e.reconnectConnectionId?"reconnect_unavailable":"fallback":"ready"}r(nYe,"requestedConnectionSetupResolution");function SJ(e,s,n,a){const i=XGe[s]??"setup",o=new URLSearchParams({source:e,stage:i});return a?.resumeConnectionId&&o.set("resume",a.resumeConnectionId),a?.reconnectConnectionId&&o.set("reconnect",a.reconnectConnectionId),a?.interactionId&&o.set("intent",a.interactionId),a?.connectionMethodKey&&o.set("method",a.connectionMethodKey),`${n==="vercel_connect"?"/apps/vercel-connect":"/apps/connect"}?${o.toString()}`}r(SJ,"appConnectHref");function wI(e,s){if(!s)return e;const[n,a=""]=e.split("?",2),i=new URLSearchParams(a);return i.set("intent",s),`${n}?${i.toString()}`}r(wI,"withConnectionIntent");var CJ=["Pick app","Access","Add your key"],_J={gallery:0,access:1,key:2},rYe={access:0,key:1},aYe=["Access","Add MCP URL"],iYe=["Access","Sign in"];function Y4(e,s=!1){return s&&e?.auth!=="none"&&(!e?.grantKinds||e.grantKinds.includes("user"))?"user":e?.grantKinds?.length===1||e?.grantKinds&&!e.grantKinds.includes("organization")?e.grantKinds[0]:"organization"}r(Y4,"defaultGrantKindFor");function oYe(e){const s=e.config?.oauth;if(!s||typeof s!="object"||Array.isArray(s))return;const n=s.connectorSubjectAgentId;return typeof n=="string"?n:void 0}r(oYe,"configuredAgentIdentity");function Kk(e,s){const n=typeof s=="string"?s:s?.key;return e?.slug==="google-sheets"&&n==="local"}r(Kk,"isGoogleSheetsRobotMethod");function ok(e){return e?Object.fromEntries([...e.tenantFields??[],...e.extensionFields??[]].filter(s=>s.defaultValue!==void 0).map(s=>[s.key,s.defaultValue])):{}}r(ok,"defaultMethodConfig");function ej(e,s){if(!e)return[];const n=q1(e);return s==="vercel_connect"?n.filter(a=>!!a.credentialSources?.vercelConnect):n}r(ej,"connectionMethodsForCredentialSource");function q1(e){return gle(e).filter(s=>(s.purpose??"tool")!=="channel")}r(q1,"availableToolConnectionMethods");function NI(e,s){const n=q1(e);return s?n.find(a=>a.key===s)??null:pz(n)}r(NI,"availableToolConnectionMethod");function Fj(e){const s=pz(e);return e.length===1||s?.capabilityProfile||s?.grantKinds?.includes("agent")?s:null}r(Fj,"recommendedSetupConnectionMethod");function IJ(e){return Fj(e?e.methods.filter(s=>(s.purpose??"tool")==="tool"&&(s.oauthStrategy==="paperclip_cloud_connector"||s.oauthStrategy==="paperclip_id_connector")):[])}r(IJ,"recommendedManagedConnectorMethod");function AJ(e){if(!e)return!1;const s=q1(e),n=s.length===1?s[0]:null;return!!(n&&Bp(n)&&!GIe(n))}r(AJ,"canUseAutomaticOAuthFastPath");function RJ(e){if(!e)return null;const s=q1(e),n=s.length===1?s[0]:null;return n&&Bp(n)?n:null}r(RJ,"automaticOAuthMethod");function lYe(e){const s=e.metadata;if(!s)return null;const n=s.sourceTemplateKey??s.galleryKey;return typeof n=="string"?n:null}r(lYe,"appSourceSlug");function cYe(e){const s=e.config?.sourceTemplateKey??e.transportConfig.sourceTemplateKey;return typeof s=="string"?s:null}r(cYe,"connectionSourceSlug");function TJ(e,s,n,a={}){if(!e)return null;const i=new Set(s.filter(o=>o.status!=="archived"&&lYe(o)===e&&(!a.applicationId||o.id===a.applicationId)).map(o=>o.id));return n.find(o=>{const l=a.applicationId?o.applicationId===a.applicationId:i.has(o.applicationId)||cYe(o)===e;return o.status!=="archived"&&(!a.draftOnly||o.status==="draft")&&o.authKind==="oauth"&&l})??null}r(TJ,"reusableOAuthConnection");function zxe(e,s,n){if(e.origin!==s||!e.data||typeof e.data!="object")return null;const a=e.data;return a.type!=="paperclip.connection-intent.oauth"||a.interactionId!==n?null:a.outcome==="connected"||a.outcome==="declined"||a.outcome==="failed"?a.outcome:null}r(zxe,"readConnectionIntentOAuthOutcome");function xE(e={}){const[s]=Ai(),n=Sa(),{selectedCompanyId:a}=ps(),i=Dhe(),o=e.interactionId||s.get("intent")||void 0,l=e.serviceSlug||s.get("source")||n.appKey||s.get("appKey"),c=(0,u.useMemo)(()=>{if(o&&kj(l))try{return sessionStorage.getItem(`paperclip:mcp-intent-draft:${a}:${o}`)}catch{}return null},[o,a,l]),d=e.configuredConnection?.id||s.get("resume")||s.get("reconnect")||c,m=!!(d&&(!l||kj(l))),h=Z({queryKey:["tools","connection",d],queryFn:r(()=>cs.getConnection(d),"queryFn"),enabled:m}),p=l||h.data?.config?.sourceTemplateKey,f=s.get("method")||h.data?.config?.connectionMethodKey;return m&&h.isPending?(0,t.jsx)("p",{className:"p-6 text-sm text-muted-foreground",children:"Loading connection…"}):m&&h.isError?(0,t.jsxs)("div",{role:"alert",className:"space-y-3 p-6",children:[(0,t.jsx)("p",{children:"Could not load this connection. Your saved access and credentials have not changed."}),(0,t.jsx)(F,{variant:"outline",onClick:r(()=>{h.refetch()},"onClick"),children:"Try again"})]}):!e.byoOnly&&(e.credentialSource??"paperclip_vault")==="paperclip_vault"&&kj(p)&&(!f||d2(p,f))?i.loaded?i.enabled?(0,t.jsx)(p6e,{...e,interactionId:o,providerId:p,connection:h.data},`${o||"page"}:${p}`):(0,t.jsx)("p",{role:"status",className:"p-6 text-sm text-muted-foreground",children:"Enable MCP aggregators in Settings → Experimental to set up this connection."}):(0,t.jsx)("p",{className:"p-6 text-sm text-muted-foreground",children:"Loading connection settings…"}):(0,t.jsx)(dYe,{...e})}r(xE,"ConnectionSetupFlow");function dYe({byoOnly:e=!1,credentialSource:s="paperclip_vault",host:n="page",serviceSlug:a,requestedAgentId:i,interactionId:o,forceNewConnection:l=!1,existingConnections:c=[],configuredConnection:d,onUseExisting:m,onComplete:h,onOAuthDeclined:p,aiConnection:f,onPhaseChange:g,onCancel:v,renderCredentialStep:y}={}){const w=Yn(),S=(0,u.useCallback)((Be,Et)=>{n==="page"&&(Et?w(Be,Et):w(Be))},[n,w]),j=Sa(),{selectedCompany:N,selectedCompanyId:_}=ps(),{enabled:R}=$x(),{setBreadcrumbs:C}=qn(),{pushToast:A}=Ei(),[T]=Ai(),I=o?.trim()||T.get("intent")?.trim()||null,$=j.appKey??T.get("appKey")??void 0,O=T.get("source")?.trim()||null,L=l||T.get("new")==="1",E=T.get("stage")?.trim()||null,q=T.get("method")?.trim()||null,B=T.get("resume")?.trim()||null,K=T.get("oauth"),z=T.get("code"),D=wJ(T.get("installation_url")),V=wJ(T.get("management_url")),H=d?.id??(T.get("reconnect")?.trim()||null),ee=T.get("identity")==="user"?"user":T.get("identity")==="organization"?"organization":null,X=s==="vercel_connect",le=a??O,ce=s==="paperclip_vault"&&PGe(le)?le:null,te=DGe({serviceSlug:a,appKey:$,sourceSlug:O}),ae=(a??O??$)==="zapier",de=ae?void 0:te,J=!!d||n==="page"&&(e||T.get("byo")==="1"),[Y]=(0,u.useState)(()=>n==="page"&&T.get("cloud_connector")==="enrolled"&&de?JGe(de):null),[G]=(0,u.useState)(()=>{const Be=T.get("link")?.trim()??"";return{link:/^https?:\/\//i.test(Be)?Be:"",name:d?.name??T.get("name")?.trim()??"",applicationId:d?.applicationId??(T.get("applicationId")?.trim()||void 0)}}),[fe,se]=(0,u.useState)(()=>kJ({requestedAppKey:de,routeStage:E,resumeConnectionId:B,hasPrefilledLink:!!G.link,zapierSource:ae})),[re,ie]=(0,u.useState)(null),[me,pe]=(0,u.useState)(""),[be,oe]=(0,u.useState)(G.link),[ye,Ae]=(0,u.useState)(G.name||(ae?"Zapier":"")),[xe,_e]=(0,u.useState)(!1),[Ge,$e]=(0,u.useState)(""),[Ye,ue]=(0,u.useState)("auto"),[Oe,dt]=(0,u.useState)(()=>[QF()]),[xt,De]=(0,u.useState)(""),[Qe,ht]=(0,u.useState)(""),[We,Ke]=(0,u.useState)(!1),[gt,tt]=(0,u.useState)(null),[Se,ke]=(0,u.useState)(!1),[Xe,ut]=(0,u.useState)({}),[Lt,Xt]=(0,u.useState)(""),[fs,Ve]=(0,u.useState)(""),[He,ct]=(0,u.useState)(""),[ze,is]=(0,u.useState)(f&&f.mode!=="responsible_user"?`ai-${f.method}`:""),[Fe,Qt]=(0,u.useState)({}),[It,Ms]=(0,u.useState)(""),[Ue,pt]=(0,u.useState)(null),[$t,gs]=(0,u.useState)(null),[Ts,St]=(0,u.useState)({}),[we,Pe]=(0,u.useState)("all"),[it,Ot]=(0,u.useState)(new Set),[ft,us]=(0,u.useState)(()=>new Set(Y?.agentIds??(i?[i]:[]))),[cn,xs]=(0,u.useState)(Y?.grantKind??ee??(i?"user":"organization")),[bs,qe]=(0,u.useState)(Y?.installChoice??(i?"specific":"all")),wt=!!(B&&(K==="failed"||K==="denied")),[kt,Ee]=(0,u.useState)(wt?"error":"entry"),[Le,Ze]=(0,u.useState)(()=>wt?NJ(K,z):null),[Nt,Ut]=(0,u.useState)(null),Dt=(0,u.useRef)(!1),Ft=(0,u.useRef)(!1),Yt=(0,u.useRef)(null),[Ws,_n]=(0,u.useState)(null),In=(0,u.useRef)(null),[en,Us]=(0,u.useState)(null),[ws,nn]=(0,u.useState)(null),zs=(0,u.useRef)(null),[An,hn]=(0,u.useState)(c.length>0&&!!m),[rn,pr]=(0,u.useState)(null),[Zs,er]=(0,u.useState)(null),[tr,Ur]=(0,u.useState)(null),mr=(0,u.useCallback)(()=>{n!=="dialog"||In.current?.closed===!1||(In.current=window.open("about:blank","paperclip-connection-oauth","popup,width=720,height=760,resizable=yes,scrollbars=yes"))},[n]),br=(0,u.useCallback)(Be=>{if(n!=="dialog"){Sc(Be);return}nn(Be);const Et=In.current;if(!Et||Et.closed){Ee("error"),Ze("Paperclip couldn’t open the sign-in window. Open sign-in in a new tab to continue."),g?.("needs_retry");return}Et.location.assign(Be),Et.focus()},[n,g]),sr=(0,u.useCallback)(()=>{In.current=null,Ze(null),Ee("redirecting"),g?.("authorizing")},[g]);(0,u.useEffect)(()=>{if(n!=="dialog"||kt!=="redirecting")return;const Be=window.setInterval(()=>{In.current?.closed&&(Ee("error"),Ze("The sign-in window closed. If authorization did not finish, try again."),nn(null),g?.("needs_retry"))},1e3);return()=>window.clearInterval(Be)},[n,kt,g]);const ra=(0,u.useCallback)(async Be=>{zs.current?.abort();const Et=new AbortController;zs.current=Et;try{const Ps=await kw(Be,{signal:Et.signal});if(Ps.kind==="reauthentication"){const Rn=n==="dialog"?In.current:window;if(!Rn||Rn.closed||!Be.handoff)throw new Error("Paperclip couldn’t preserve this sign-in while refreshing your account.");wC(Be.handoff.session,Rn.sessionStorage),Ee("starting")}else Ut(Ps.host),Ee("redirecting");br(Ps.url)}catch(Ps){if(Et.signal.aborted)return;Ee("error"),Ze(Ps instanceof Error?Ps.message:"Paperclip couldn’t start secure sign-in. Try again."),g?.("needs_retry")}finally{zs.current===Et&&(zs.current=null)}},[n,g,br]);(0,u.useEffect)(()=>()=>zs.current?.abort(),[]),(0,u.useEffect)(()=>{if(n!=="dialog"||!I)return;const Be=r(Et=>{const Ps=zxe(Et,window.location.origin,I);if(Ps==="connected"){Ee("entry"),nn(null),h?.({resolvedByCallback:!0});return}if(Ps==="declined"){Ee("error"),Ze("Authorization was cancelled. You can try again."),g?.("needs_retry");return}Ps==="failed"&&(Ee("error"),Ze("Authorization did not complete. Try again when you’re ready."))},"receiveOAuthOutcome");return window.addEventListener("message",Be),()=>window.removeEventListener("message",Be)},[I,n,h,p]),(0,u.useEffect)(()=>{if(n!=="dialog"||I||!en)return;let Be=!1,Et=!1;const Ps=window.setInterval(async()=>{if(Et||Be)return;const Rn=In.current;if(!Rn||Rn.closed){Us(null),Ee("error"),Ze("The sign-in window closed. Try again to finish connecting GitHub.");return}let Ir;try{Ir=new URL(Rn.location.href)}catch{return}if(!(Ir.origin!==window.location.origin||!Ir.pathname.includes(en))){if(Ir.searchParams.has("oauth")){Us(null),Ee("error"),Ze("Authorization did not complete. Finish setup in the sign-in window or try again.");return}if(Ir.searchParams.get("success")==="1"){Et=!0;try{const za=await cs.getConnection(en);!Be&&za.status==="active"&&(Us(null),Rn.close(),h?.({connectionId:za.id}))}catch{Be||(Us(null),Ee("error"),Ze("Could not confirm the connection. Try again."))}finally{Et=!1}}}},1e3);return()=>{Be=!0,window.clearInterval(Ps)}},[I,en,n,h]);const Bn=r(()=>{ue("auto"),dt([QF()]),De(""),ht(""),Ke(!1),tt(null),ke(!1)},"resetGenericAuthState"),_r=r(Be=>{if(n==="page"&&!I&&s==="paperclip_vault"&&kj(Be.slug)){S(`/apps/connect?source=${Be.slug}`);return}if(Be.slug==="zapier"){ie(null),pe(""),oe(""),Ae("Zapier"),_e(!1),$e(""),Bn(),ut({}),gs(null),se("access"),S(wI("/apps/connect?source=zapier",I));return}if(s==="paperclip_vault"&&AJ(Be)){S(HF(Be.slug,I));return}ie(Be),pe(Be.name),oe(""),Ae(""),_e(!1),$e(""),Bn(),ut({}),Xt(""),Ve(""),ct("");const Et=Fj(ej(Be,s));is(Et?.key??""),Qt(ok(Et)),Ms(""),pt(null),gs(null),us(new Set(i?[i]:[])),qe(i?"specific":"all"),xs(or??Y4(Et,!!i)),se("access"),S(s==="vercel_connect"?wI(H4(Be.slug),I):HF(Be.slug,I))},"useMatchedGalleryEntry"),ya=r(()=>{se("gallery"),S(wI(s==="vercel_connect"?H4():e?"/apps/byo":"/apps",I))},"backToGallery");(0,u.useEffect)(()=>{if(n==="page")return C([{label:"Connectors",href:"/apps"},{label:X?"Vercel Connect":e?"Connect your own tool":"Connect an app"}]),()=>C([])},[e,n,C,X]);const Nn=Z({queryKey:P.apps.gallery(_??"__none__"),queryFn:r(()=>cs.listGallery(_),"queryFn"),select:(0,u.useCallback)(Be=>I?{...Be,apps:Be.apps.map(Et=>({...Et,methods:Et.methods.filter(Ps=>f?Ps.ai?.provider===f.provider&&(f.mode==="responsible_user"||Ps.ai.method===f.method):Ps.transport!=="runtime_auth")})).filter(Et=>Et.methods.length>0)}:Be,[I,f?.provider,f?.method,f?.mode]),enabled:!!_}),On=(0,u.useMemo)(()=>(Nn.data?.apps??[]).filter(Be=>R||!Be.methods.some(Et=>Et.transport==="chat_sdk")||fE(Be)),[Nn.data,R]),on=de?mz(de):null,cr=!!on?.methods.some(Be=>Be.oauthStrategy==="paperclip_cloud_connector"||Be.oauthStrategy==="paperclip_id_connector"),bt=!!re?.methods.some(Be=>Be.oauthStrategy==="paperclip_cloud_connector"||Be.oauthStrategy==="paperclip_id_connector"),Ds=re&&cr&&!bt?IJ(on):null,[Fs,et]=(0,u.useState)(null),Ht=Z({queryKey:["cloud-connector","enrollment"],queryFn:r(()=>cs.getCloudConnectorEnrollment(),"queryFn"),refetchInterval:Fs?2e3:!1,enabled:!!(_&&cr&&!bt)}),[un,Os]=(0,u.useState)(null),Jn=(0,u.useCallback)(()=>{In.current?.close(),In.current=null,et(null)},[]),vr=(0,u.useCallback)(()=>{!_||!de||YGe(_,de,{grantKind:cn,installChoice:bs,agentIds:bs==="specific"?[...ft]:[]})},[cn,ft,bs,de,_]),Na=(0,u.useCallback)(Be=>{const Et=yT(Be);if(!Et.ok){Jn(),Os(Et.message);return}if(n==="dialog"){et(Et.url);const Ps=In.current;Ps&&!Ps.closed?(Ps.location.assign(Et.url),Ps.focus()):Os("Open authorization in a new tab to continue.");return}Sc(Et.url)},[n,Jn]);(0,u.useEffect)(()=>{!Fs||Ht.data?.status!=="active"||(Jn(),Os(null),Nn.refetch())},[Fs,Ht.data?.status,Nn.refetch,Jn]);const zn=Ne({mutationFn:r(()=>cs.startCloudConnectorEnrollment(_,N?.name,de?SJ(de,"key",s,{resumeConnectionId:B,reconnectConnectionId:H,interactionId:I})+(n==="dialog"?"&enrollment_host=dialog":""):void 0),"mutationFn"),onSuccess:r(Be=>{if(!Be.verificationUrl){Jn(),Os("Paperclip Cloud did not return an enrollment link. Try again.");return}Na(Be.verificationUrl)},"onSuccess"),onError:r(Be=>{Jn(),Os(Be instanceof Error?Be.message:"Paperclip couldn’t reach Paperclip Cloud. Try again.")},"onError")}),Xn=Z({queryKey:P.tools.applications(_??"__none__"),queryFn:r(()=>cs.listApplications(_),"queryFn"),enabled:!!_&&(!!ce||!!B||!!H),refetchOnMount:"always"}),rs=Z({queryKey:P.tools.connections(_??"__none__"),queryFn:r(()=>cs.listConnections(_),"queryFn"),enabled:!!_&&(!!ce||!!B||!!H),refetchOnMount:"always"}),pn=(0,u.useMemo)(()=>l?null:TJ(ce,Xn.data?.applications??[],rs.data?.connections??[],L?{applicationId:G.applicationId,draftOnly:!0}:{}),[Xn.data,rs.data,L,ce,G.applicationId,l]),Hs=(0,u.useMemo)(()=>H?(rs.data?.connections??[]).find(Be=>Be.id===H)??null:null,[rs.data,H]),Zt=(0,u.useRef)(null);(0,u.useEffect)(()=>{if(!d||!rs.isFetchedAfterMount||!Hs||Zt.current===Hs.id)return;const Be=Hs.config?.url??Hs.transportConfig?.url??Hs.transportConfig?.serverUrl??Hs.config?.serverUrl;typeof Be!="string"||!/^https?:\/\//i.test(Be)||(Zt.current=Hs.id,oe(Et=>Et||Be))},[d,rs.isFetchedAfterMount,Hs]);const ks=(0,u.useMemo)(()=>Hs?(Xn.data?.applications??[]).find(Be=>Be.id===Hs.applicationId)??null:null,[Xn.data,Hs]),Un=eYe({requestedAppKey:de,byo:J,applicationId:G.applicationId,reconnectConnection:Hs,reconnectApplication:ks}),En=(0,u.useMemo)(()=>B?(rs.data?.connections??[]).find(Be=>Be.id===B)??null:null,[rs.data,B]),dr=En??Hs,or=dr?dr.credentialPolicy==="per_user"?"user":dr.credentialPolicy==="per_agent"?"agent":"organization":ee,aa=En?.authKind==="oauth"?En:pn,ls=pn?pn.credentialPolicy==="per_user"?"user":pn.credentialPolicy==="per_agent"?"agent":"organization":null,Ls=or??ls;(0,u.useEffect)(()=>{Ls&&xs(Ls)},[Ls]);const mn=(0,u.useMemo)(()=>be&&!re?MR(be,On):null,[re,On,be]),Fn=re?NI(re,ze||null):null,Kr=Fn&&Bp(Fn)?Fn:RJ(re),kr=s==="paperclip_vault"&&Kr?re:null,Mr=s==="paperclip_vault"&&AJ(re)?re:null,Jr=!!ce&&(!Xn.isFetchedAfterMount||!rs.isFetchedAfterMount),je=r(Be=>{se(Be),re&&S(SJ(re.slug,Be,s,{connectionMethodKey:re.methods.find(Et=>Et.key===ze)?.ai?ze:void 0,resumeConnectionId:B,reconnectConnectionId:H,interactionId:I}))},"setAppStep"),qt=Ne({mutationFn:r(Be=>cs.startOAuth(Be.id,{asCurrentUser:Be.credentialPolicy==="per_user",...Be.credentialPolicy==="per_agent"?{asAgentId:oYe(Be)??[...ft][0]}:{},...I?{interactionId:I}:{}}),"mutationFn"),onSuccess:r(Be=>{ra(Be)},"onSuccess"),onError:r(Be=>{const Et=Be instanceof wn&&Be.body&&typeof Be.body=="object"?Be.body.details:null;Ee("error"),g?.("needs_retry"),Ze(Et?.code==="invalid_grant"?"Your authorization expired or was revoked. Reconnect to continue.":Be instanceof Error?Be.message:"Paperclip couldn’t start secure sign-in. Try again.")},"onError")}),bn=qt.mutate,Gn=(0,u.useCallback)(Be=>{g?.("authorizing"),mr(),n==="dialog"&&!I&&Us(Be.id),bn(Be)},[bn,g,mr,n,I]),Br=r(async Be=>{if(i)return;const Et=Bxe(_,(Ls??cn)!=="agent"&&bs==="all"?{onAll:!0,agentIds:new Set}:{onAll:!1,agentIds:ft});await cs.putConnectionInstalls(Be,Et)},"applyAccessInstalls"),nr=Ls??cn,Oa=Ne({mutationFn:r(async Be=>{const Et=Be??re;let Ps;if(Et){const Rn=Ls??cn,Ir=NI(Et,ze||null),za=Kk(Et,Ir)?eF(It).ids:[],ea=me.trim(),Ui=vJ(ea||Et.name,Rn);Ps=await cs.connectApp(_,{galleryKey:Et.slug,...ze?{connectionMethodKey:ze}:{},name:Ui,credentialSource:s,...s==="paperclip_vault"?{credentialValues:Xe}:{},...s==="vercel_connect"?{vercelConnect:{connector:He.trim()}}:{},...Lt.trim()?{oauthClient:{clientId:Lt.trim(),...fs?{clientSecret:fs}:{}}}:{},configValues:Kk(Et,Ir)?{allowedSpreadsheetIds:za}:Object.keys(Fe).length>0?Fe:void 0,applicationId:G.applicationId,...B?{resumeConnectionId:B}:H?{reconnectConnectionId:H}:{},...Rn!=="organization"?{grantKind:Rn}:{},...Rn==="agent"?{subjectAgentId:[...ft][0]}:{}})}else{const Rn=WGe({link:be,name:ye,authMode:Ye,needsKey:xe,keyValue:Ge,headers:Oe,oauthClientId:xt,oauthClientSecret:Qe}),Ir=vJ(Rn.name??G4(be)??"Custom app",nr);Ps=await cs.connectApp(_,{...Rn,...H?{reconnectConnectionId:H}:{},...ae||mn?.slug==="zapier"?{galleryKey:"zapier",connectionMethodKey:"generated-url"}:{},name:Ir,applicationId:G.applicationId,...nr!=="organization"?{grantKind:nr}:{},...nr==="agent"?{subjectAgentId:[...ft][0]}:{}})}return Ps.auth?.kind==="oauth"&&!B&&!H&&await Br(Ps.connectionId),Ps},"mutationFn"),onSuccess:r(Be=>{if(Be.auth?.kind==="oauth"){if(gs(Be),Be.auth.manualClientRequired){tt(jJ("oauth_manual_client_required",null)),ue("oauth"),Ke(!0),ke(!1);return}if(n==="dialog"||I){Ee("starting"),ke(!re),Gn(Be.connection);return}const Ps=Be.auth.startUrl?.trim();if(!Ps){Ee("starting"),ke(!0),Gn(Be.connection);return}ke(!0),ra({authorizationUrl:Ps,handoff:Be.auth.handoff});return}tt(null),gs(Be);const Et={};for(const Ps of Be.actions.readOnly)Et[Ps.catalogEntryId]=!0;for(const Ps of Be.actions.canMakeChanges)Et[Ps.catalogEntryId]=!0;St(Et),Tt.mutate({result:Be,enabled:Et})},"onSuccess"),onError:r(Be=>{const Et=Be instanceof wn&&Be.body&&typeof Be.body=="object"?Be.body.details:null;if(kr){Ee("error"),g?.("needs_retry"),Ze(Et?.code==="invalid_grant"?"Your authorization expired or was revoked. Reconnect to continue.":Be instanceof Error?Be.message:"Paperclip couldn’t start secure sign-in. Try again.");return}if(!re&&be){const Ps=typeof Et?.code=="string"?Et.code:null,Rn=jJ(Ps,Be instanceof Error?Be.message:null);tt(Rn),ke(!1),Rn.focus==="credentials"&&Ke(!0);return}A({title:"Couldn’t connect",body:Be instanceof Error?Be.message:"Please check your key and try again.",tone:"error"})},"onError")}),ne=Oa.mutate,rt=(0,u.useCallback)(Be=>{const Et=Be??re;(Et?NI(Et,ze||null):null)?.auth==="oauth"&&mr(),ne(Be)},[ze,re,ne,mr]);(0,u.useEffect)(()=>{if(!de||Nn.isLoading||!Nn.data||H&&(!rs.isFetchedAfterMount||!Xn.isFetchedAfterMount))return;const Be=ZGe({requestedAppKey:de,galleryApps:Nn.data.apps,reconnectConnection:Hs,applications:Xn.data?.applications??[]}),Et=!!Be?.methods.some(ri=>ri.oauthStrategy==="paperclip_cloud_connector"||ri.oauthStrategy==="paperclip_id_connector");if(cr&&!Et&&Ht.isLoading)return;const Ps=ej(Be,s),Rn=f??(Hs?.connectionPurpose==="ai"?ZW.safeParse(Hs.config?.ai).data:void 0),Ir=Ps.find(ri=>Rn?ri.ai?.provider===Rn.provider&&(!("mode"in Rn)||Rn.mode!=="responsible_user")&&ri.ai.method===Rn.method:ri.key===q)??(cr&&!Et?IJ(on):null)??Fj(Ps),za=Ps.length===1?Ps[0]:null,ea=s==="paperclip_vault"&&!!RJ(Be),Ui=tYe({credentialSource:s,available:Nn.data.credentialSources?.vercelConnect.available===!0,retainedReconnectMatches:!!(H&&Un)}),Ar=Ps.length===1&&za?.auth==="oauth"&&!Bp(za)&&!RR(za),fo=sYe({available:Be?.availability?.available,reconnectConnectionId:H,reconnectSourceMatches:Un}),_o=nYe({reconnectConnectionId:H,hasRequestedEntry:!!Be,supportedMethodCount:Ps.length,unsupportedOAuth:Ar,vercelUnavailable:Ui,definitionUnavailable:fo});if(_o!=="ready"){if(ie(null),se("gallery"),_o==="reconnect_unavailable"&&H){Ur(H);return}S(wI(s==="vercel_connect"?H4():"/apps/connect",I),{replace:!0});return}if(Ur(null),!!Be){if(re?.slug!==Be.slug){ie(Be),pe(Be.name),oe(""),Ae(""),_e(!1),$e(""),ut({}),Xt(""),Ve(""),ct(""),is(Ir?.key??""),Qt(ok(Ir)),Ms(""),pt(null),gs(null);const ri=Y?.companyId===_?Y:null;xs(or??ri?.grantKind??Y4(Ir,!!i)),us(new Set(ri?.agentIds??(i?[i]:[]))),qe(ri?.installChoice??(i?"specific":"all")),se(kJ({requestedAppKey:de,routeStage:E,resumeConnectionId:B,hasPrefilledLink:!!G.link,zapierSource:ae}))}else bt!==Et&&(ie(Be),is(Ir?.key??""),Qt(ok(Ir)));if(!(ea&&(!Xn.isFetchedAfterMount||!rs.isFetchedAfterMount))&&!(ea&&Ft.current)&&ea&&(Xn.isError||rs.isError)){Ee("error"),Ze("Paperclip couldn’t check for an existing connection. Try again."),se("key");return}}},[f,q,Xn.isError,Xn.isFetchedAfterMount,Xn.data,rs.isError,rs.isFetchedAfterMount,Ht.data?.configured,Ht.isLoading,ze,s,re?.slug,bt,Nn.data,Nn.isLoading,S,or,Hs,H,Un,B,on,de,i,Y,E,ae]),(0,u.useEffect)(()=>{Hs?.connectionPurpose==="ai"&&fe==="access"&&se("key")},[Hs?.connectionPurpose,fe]),(0,u.useEffect)(()=>{Yt.current=null,_n(null)},[B]),(0,u.useEffect)(()=>{if(!En||!re||En.status!=="draft"||Yt.current===En.id)return;const Be=En.config&&typeof En.config=="object"?En.config:{},Et=typeof Be.sourceTemplateKey=="string"?Be.sourceTemplateKey:null;if(Et&&Et!==re.slug)return;const Ps=typeof Be.connectionMethodKey=="string"?Be.connectionMethodKey:null,Rn=Ps?ej(re,s).find(za=>za.key===Ps)??null:null;if(pe(En.name||re.name),Rn){is(Rn.key);const za=Be.methodConfig&&typeof Be.methodConfig=="object"?Be.methodConfig:{};Qt({...ok(Rn),...Object.fromEntries(Object.entries(za).filter(ea=>typeof ea[1]=="string"||typeof ea[1]=="boolean"))})}const Ir=Be.oauth&&typeof Be.oauth=="object"?Be.oauth:null;Ir?.clientRegistrationSource==="manual"&&typeof Ir.clientId=="string"&&Xt(Ir.clientId),K==="failed"||K==="denied"?(Ee("error"),Ze(NJ(K,z))):(Ee("entry"),Ze(null)),se("key"),Yt.current=En.id,_n(En.id)},[s,re,z,K,En]);const Tt=Ne({mutationFn:r(async Be=>{const{result:Et,enabled:Ps}=Be,Rn=Object.entries(Ps).filter(([,Ar])=>Ar).map(([Ar])=>Ar),Ir=new Set(Array.isArray(Et.suggestedDefaults.askFirstRiskLevels)?Et.suggestedDefaults.askFirstRiskLevels.filter(Ar=>typeof Ar=="string"):[]),za=Et.actions.canMakeChanges.filter(Ar=>Ps[Ar.catalogEntryId]&&Ir.has(Ar.riskLevel)).map(Ar=>Ar.catalogEntryId),ea=bs==="all"?"all_agents":{agentIds:Array.from(ft)},Ui=await cs.finishApp(_,Et.connectionId,{enabledCatalogEntryIds:Rn,askFirstCatalogEntryIds:za,access:ea,...i?{preserveExistingAccess:!0}:{}});return await Br(Et.connectionId),Ui},"mutationFn"),onSuccess:r((Be,Et)=>{je("success"),h?.({connectionId:Et.result.connectionId})},"onSuccess"),onError:r(Be=>{je("access"),A({title:"Couldn’t finish setup",body:Be instanceof Error?Be.message:"Please try again.",tone:"error"})},"onError")});if(!_)return(0,t.jsx)("div",{className:"p-6 text-sm text-muted-foreground",children:"Select an organization to connect apps."});if((B||H)&&(rs.isError||Xn.isError))return(0,t.jsxs)("div",{className:"mx-auto max-w-xl rounded-xl border border-border bg-card p-6",children:[(0,t.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:"Couldn’t load connection setup"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Paperclip couldn’t check the retained connection. The retained connection was not changed."}),(0,t.jsxs)("div",{className:"mt-5 flex flex-wrap gap-2",children:[(0,t.jsx)(F,{type:"button",onClick:r(async()=>{const[Be,Et]=await Promise.all([rs.refetch(),Xn.refetch()]);!Be.isError&&!Et.isError&&(Ze(null),Ee("entry"))},"onClick"),children:"Try again"}),(0,t.jsx)(F,{type:"button",variant:"outline",onClick:r(()=>S("/apps"),"onClick"),children:"Back to apps"})]})]});if(B&&rs.isFetchedAfterMount&&!En)return(0,t.jsxs)("div",{className:"mx-auto max-w-xl rounded-xl border border-border bg-card p-6",children:[(0,t.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:"This setup can’t be resumed"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"The saved connection no longer exists or is not available to this organization."}),(0,t.jsx)(F,{type:"button",variant:"outline",className:"mt-5",onClick:r(()=>S("/apps"),"onClick"),children:"Back to apps"})]});if(H&&rs.isFetchedAfterMount&&Xn.isFetchedAfterMount&&(!Hs||!Un))return(0,t.jsxs)("div",{className:"mx-auto max-w-xl rounded-xl border border-border bg-card p-6",children:[(0,t.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:"This connection can’t be reconnected"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:Hs?"This reconnect link does not match the retained connection's provider.":"The retained connection no longer exists or is not available to this organization."}),(0,t.jsx)(F,{type:"button",variant:"outline",className:"mt-5",onClick:r(()=>S("/apps"),"onClick"),children:"Back to apps"})]});if((B||H)&&Nn.isError)return(0,t.jsxs)("div",{className:"mx-auto max-w-xl rounded-xl border border-border bg-card p-6",children:[(0,t.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:"Couldn’t load connection setup"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Paperclip couldn’t load the provider details needed to restore this connection. The retained connection was not changed."}),(0,t.jsxs)("div",{className:"mt-5 flex flex-wrap gap-2",children:[(0,t.jsx)(F,{type:"button",onClick:r(()=>{Nn.refetch()},"onClick"),children:"Try again"}),(0,t.jsx)(F,{type:"button",variant:"outline",onClick:r(()=>S("/apps"),"onClick"),children:"Back to apps"})]})]});if(H&&tr===H)return(0,t.jsxs)("div",{className:"mx-auto max-w-xl rounded-xl border border-border bg-card p-6",children:[(0,t.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:"This connection can’t be reconnected"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Paperclip no longer has a supported setup method for this retained connection. The retained connection was not changed."}),(0,t.jsx)(F,{type:"button",variant:"outline",className:"mt-5",onClick:r(()=>S("/apps"),"onClick"),children:"Back to apps"})]});if(B&&(!rs.isFetchedAfterMount||Nn.isLoading||!re||Ws!==En?.id))return(0,t.jsxs)("div",{className:"mx-auto max-w-xl space-y-4","aria-label":"Loading saved connection setup",children:[(0,t.jsx)(jn,{className:"h-8 w-48"}),(0,t.jsx)(jn,{className:"h-40 w-full rounded-xl"})]});if(H&&(!rs.isFetchedAfterMount||!Xn.isFetchedAfterMount||Nn.isLoading||de&&!re))return(0,t.jsxs)("div",{className:"mx-auto max-w-xl space-y-4","aria-label":"Loading retained connection setup",children:[(0,t.jsx)(jn,{className:"h-8 w-48"}),(0,t.jsx)(jn,{className:"h-40 w-full rounded-xl"})]});if(An&&m)return(0,t.jsxs)("div",{className:"max-w-5xl","data-testid":"connection-existing-choice",children:[(0,t.jsxs)("div",{className:"mb-6",children:[(0,t.jsxs)("h1",{className:"text-2xl font-bold tracking-tight",children:["Use an existing ",de?"connection":"app connection"]}),(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"Reuse a connection without changing who already has access, or connect a new one."})]}),(0,t.jsx)(TU,{choices:c.map(Be=>({id:Be.id,name:Be.name,description:Be.status==="active"&&Be.enabled?"Ready to use":"Setup needs attention"})),pendingId:rn,onSelect:r(async Be=>{pr(Be),er(null);try{await m(Be)}catch(Et){er(Et instanceof Error?Et.message:"Couldn’t use this connection."),pr(null)}},"onSelect")}),Zs?(0,t.jsx)(Ga,{tone:"danger",className:"mt-4",children:Zs}):null,(0,t.jsxs)("div",{className:"mt-5 flex flex-wrap gap-2",children:[(0,t.jsx)(F,{type:"button",variant:"outline",onClick:r(()=>hn(!1),"onClick"),children:d?"Review connection setup":"Connect new"}),v?(0,t.jsx)(F,{type:"button",variant:"ghost",onClick:v,children:"Cancel"}):null]})]});const Ns=!!(kr&&fe==="key"&&(Mr||kt!=="entry")),Gs=!!(fe==="key"&&re&&cr&&!bt&&Ht.data?.configured===!0),an=!!(fe==="key"&&re&&cr&&!bt&&(Ht.isLoading||Ht.isError||Ht.data?.configured!==!0));if(Ns&&kr)return(0,t.jsx)(GF,{entry:kr,resuming:!!B,phase:kt,error:Le,recoveryActions:z==="github_installation_required"?{installationUrl:D,managementUrl:V}:void 0,authorizationHost:Nt,authorizationUrl:ws,onOpenAuthorization:sr,onRetry:r(async()=>{Ze(null),Ee("starting");const Be=$t?.connection??aa;if(Be){Gn(Be);return}Ft.current=!0;try{const[Et,Ps]=await Promise.all([Xn.refetch(),rs.refetch()]);if(Et.isError||Ps.isError){Ee("error"),Ze("Paperclip couldn’t check for an existing connection. Try again.");return}const Rn=(B?(Ps.data?.connections??[]).find(Ir=>Ir.id===B&&Ir.authKind==="oauth")??null:null)??TJ(ce,Et.data?.applications??[],Ps.data?.connections??[],L?{applicationId:G.applicationId,draftOnly:!0}:{});if(!Dt.current&&!B){Rn&&xs(Rn.credentialPolicy==="per_user"?"user":Rn.credentialPolicy==="per_agent"?"agent":"organization"),Ee("entry"),Ze(null),se("access");return}Rn?Gn(Rn):Oa.mutate(kr)}finally{Ft.current=!1}},"onRetry"),onBack:r(()=>{zs.current?.abort(),Ee("entry"),Ze(null),je("access")},"onBack"),onCancel:r(()=>{zs.current?.abort(),(v??(()=>S("/apps")))()},"onCancel")});if(Se&&!re&&be&&fe==="key")return(0,t.jsx)(GF,{identity:{name:ye.trim()||IS(be)||"this server",unverifiedHost:IS(be)},steps:{labels:CJ,activeIndex:_J.key},phase:kt,error:Le,authorizationHost:Nt,authorizationUrl:ws,onOpenAuthorization:sr,onRetry:r(()=>{Ze(null);const Be=$t?.connection;if(Be){Ee("starting"),Gn(Be);return}ke(!1),Ee("entry")},"onRetry"),onBack:r(()=>{zs.current?.abort(),ke(!1),Ee("entry"),Ze(null)},"onBack"),onCancel:r(()=>{zs.current?.abort(),(v??(()=>S("/apps")))()},"onCancel")});const Xr=$t?.application.name??re?.name??(ye.trim()||G4(be)||"this app"),zt=ej(re,s),ns=Ds?[Ds]:zt,ln=X?On.filter(Be=>ej(Be,s).length>0):On,Zr=ae?Nn.data?.apps.find(Be=>Be.slug==="zapier")??null:null,Kn=(Hs?.connectionPurpose==="ai"?ZW.safeParse(Hs.config?.ai).data:void 0)??re?.methods.find(Be=>Be.key===ze)?.ai??(!ze&&re?.methods.every(Be=>Be.ai)?re.methods[0]?.ai:void 0),Fa=re?y?.({app:re,name:me||re.name,grantKind:nr,agentIds:[...ft],allAgents:bs==="all",onBack:r(()=>je("access"),"onBack")})??(Kn&&_?(0,t.jsx)(t.Fragment,{children:(0,t.jsx)(zT,{companyId:_,provider:Kn.provider,fixedMethod:!!(f&&f.mode!=="responsible_user"),initialMethod:Hs?.connectionPurpose==="ai"?(Hs.config?.ai).method:Kn.method,connectionId:Hs?.connectionPurpose==="ai"?Hs.id:void 0,name:Hs?.connectionPurpose==="ai"?Hs.name:me||`My ${re.name} ${Kn.method==="subscription"?"subscription":"API"}`,ownership:(Hs?.connectionPurpose==="ai"?Hs.credentialPolicy==="shared":nr==="organization")?"shared":"personal",agentIds:[...ft],allAgents:bs==="all",onCancel:r(()=>v?v():S("/apps"),"onCancel"),onComplete:r(Be=>{h?.({connectionId:Be.connectionId}),h||S(`/apps/${Be.connectionId}/permissions`)},"onComplete")})}):void 0):void 0,si=Hs?.connectionPurpose==="ai"?["Reconnect account"]:Fa!==void 0?["Access","Connect account"]:ae?aYe:re&&ns.length>1?["Access","Choose connection"]:re&&ns[0]?.auth==="oauth"?["Access","Sign in"]:Kk(re,ze)?["Access","Share sheet"]:re?["Access","Add your key"]:CJ,yi=re?ze?ns.find(Be=>Be.key===ze)??null:ns[0]??null:null,Si=re?yi?.auth??"none":Ye==="none"?"none":Ye==="oauth"?"oauth":"api_key",to=!!Mr,Xa=to?`Continue to ${re?.name??"sign-in"}`:Si==="oauth"?"Continue":"Save and continue",Te=Hs?.connectionPurpose==="ai"?0:(ae||re)&&fe!=="gallery"&&fe!=="success"?rYe[fe]:fe==="success"?si.length:_J[fe];return(0,t.jsxs)("div",{className:"max-w-5xl",children:[fe!=="success"&&!(e&&fe==="gallery")&&(0,t.jsx)(AK,{subtitle:fe==="gallery"?X?"Choose a reviewed app to connect through Vercel.":"Pick the app you want your agents to use.":`Step ${Te+1} of ${si.length}`,step:fe,activeIndex:Te,labels:si,appIdentity:ae?{name:"Zapier",logoUrl:Zr?.branding.logoUrl??null,darkLogoUrl:Zr?.branding.darkLogoUrl??null}:re&&fe!=="gallery"?{name:re.name,logoUrl:re.branding.logoUrl,darkLogoUrl:re.branding.darkLogoUrl??null}:void 0,unverifiedHost:!re&&!ae&&fe!=="gallery"?IS(be):null,onCancel:v??(()=>S("/apps"))}),fe==="gallery"&&(0,t.jsx)(mYe,{loading:Nn.isLoading,initialLink:be,apps:ln,vercelConnect:X,vercelConnectAvailability:Nn.data?.credentialSources?.vercelConnect??null,byo:J,byoOnly:e,source:T.get("source"),onPick:_r,onUseLink:r(Be=>{const Et=MR(Be,On);ie(null),pe(""),oe(Be),Ae(Et?.name??G4(Be)??""),_e(!1),$e(""),ut({}),Ms(""),pt(null),us(new Set(i?[i]:[])),qe(i?"specific":"all"),xs(or??(i?"user":"organization")),se("access")},"onUseLink")}),Gs&&re?(0,t.jsxs)("div",{className:"mx-auto max-w-xl rounded-xl border border-border bg-card p-6",children:[(0,t.jsxs)("h2",{className:"text-lg font-semibold text-foreground",children:[re.name," sign-in is unavailable"]}),(0,t.jsxs)("p",{className:"mt-2 text-sm text-muted-foreground",children:["This instance is connected to Paperclip, but ",re.name," sign-in is not currently available. Try again shortly or contact your instance administrator."]}),(0,t.jsxs)("div",{className:"mt-6 flex items-center justify-between gap-3",children:[(0,t.jsx)(F,{type:"button",variant:"ghost",onClick:r(()=>je("access"),"onClick"),children:"Back"}),(0,t.jsxs)(F,{type:"button",disabled:Nn.isFetching,onClick:r(()=>{Nn.refetch()},"onClick"),children:[Nn.isFetching?(0,t.jsx)(at,{className:"h-4 w-4 animate-spin"}):null,"Try again"]})]})]}):fe==="key"&&re&&an?(0,t.jsx)("div",{className:"mx-auto max-w-xl",children:(0,t.jsxs)("div",{className:"rounded-xl border border-border bg-card p-6",children:[(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)("div",{className:"rounded-lg bg-muted p-2 text-muted-foreground",children:(0,t.jsx)(Gg,{className:"h-5 w-5"})}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:"Connect with Paperclip"}),(0,t.jsxs)("p",{className:"mt-2 text-sm text-muted-foreground",children:["You must connect this instance to Paperclip to connect to ",re.name," (you only need to do this once)."]})]})]}),Ht.isError||un?(0,t.jsx)(Ga,{tone:"danger",className:"mt-4",children:un??"Paperclip couldn’t check Cloud registration. Try again."}):null,Fs?(0,t.jsxs)("p",{className:"mt-4 text-sm text-muted-foreground",children:["Finish authorization in the opened window."," ",(0,t.jsx)("a",{className:"underline",href:Fs,target:"_blank",rel:"noopener noreferrer",children:"Open authorization in a new tab"})]}):null,(0,t.jsxs)("div",{className:"mt-6 flex items-center justify-between gap-3",children:[(0,t.jsx)(F,{type:"button",variant:"ghost",onClick:r(()=>je("access"),"onClick"),children:"Back"}),(0,t.jsxs)(F,{type:"button",disabled:Ht.isLoading||zn.isPending,onClick:r(()=>{Os(null),mr(),vr(),zn.mutate()},"onClick"),children:[zn.isPending?(0,t.jsx)(at,{className:"h-4 w-4 animate-spin"}):null,Ht.data?.status==="pending"?"Continue":"Connect with Paperclip"]})]})]})}):fe==="key"&&re&&Fa!==void 0?Fa:fe==="key"&&re?(0,t.jsx)(pYe,{entry:re,error:Oa.isError?Oa.error instanceof Error?Oa.error.message:"Please check your key and try again.":null,values:Xe,onChange:ut,oauthClientId:Lt,onOAuthClientIdChange:Xt,oauthClientSecret:fs,onOAuthClientSecretChange:Ve,credentialSource:s,vercelConnector:He,onVercelConnectorChange:ct,vercelConnectAvailability:Nn.data?.credentialSources?.vercelConnect??null,methodKey:ze,onMethodChange:r(Be=>{is(Be?.key??""),!or&&Be?.grantKinds&&!Be.grantKinds.includes(cn)&&xs(Y4(Be,!!i)),ut({}),Xt(""),Ve(""),ct(""),Qt(ok(Be))},"onMethodChange"),configValues:Fe,onConfigChange:Qt,googleSheetsLinks:It,googleSheetsError:Ue,onGoogleSheetsLinksChange:r(Be=>{Ms(Be),pt(null)},"onGoogleSheetsLinksChange"),submitting:Oa.isPending,onBack:r(()=>je("access"),"onBack"),onConnect:r(()=>{if(Kk(re,ze)){const Ps=eF(It);if(Ps.invalidCount>0){pt("That doesn't look like a Google Sheets link.");return}if(Ps.ids.length===0){pt("Paste at least one Google Sheets link.");return}}const Be=NI(re,ze||null),Et=!!(Be?.credentialFields?.length||Be?.tenantFields?.some(Ps=>!Ps.hidden)||Be?.extensionFields?.some(Ps=>!Ps.hidden));if(Be&&Bp(Be)&&aa&&!Et&&!Lt.trim()){Dt.current=!0,Ze(null),Ee("starting"),Gn(aa);return}Be&&Bp(Be)&&(Dt.current=!0,Ze(null),Ee("starting")),rt()},"onConnect")}):null,fe==="key"&&!re&&be&&!ae&&(0,t.jsx)(hYe,{link:be,name:ye,needsKey:xe,onNeedsKeyChange:r(Be=>{_e(Be),Be||$e("")},"onNeedsKeyChange"),keyValue:Ge,onKeyChange:$e,authMode:Ye,onAuthModeChange:r(Be=>{ue(Be),tt(null),Be!=="auto"&&_e(!1),Be!=="bearer"&&Be!=="auto"&&$e("")},"onAuthModeChange"),headers:Oe,onHeadersChange:r(Be=>{dt(Be),tt(null)},"onHeadersChange"),oauthClientId:xt,onOAuthClientIdChange:De,oauthClientSecret:Qe,onOAuthClientSecretChange:ht,advancedOpen:We,onAdvancedOpenChange:Ke,guidance:gt,matchedEntry:mn,onUseMatchedEntry:mn?()=>_r(mn):void 0,submitting:Oa.isPending||Se,onBack:r(()=>se("access"),"onBack"),onConnect:r(()=>{tt(null),Oa.mutate(void 0)},"onConnect")}),fe==="key"&&!re&&ae&&(0,t.jsx)(uYe,{link:be,onLinkChange:oe,submitting:Oa.isPending,onBack:r(()=>se("access"),"onBack"),onConnect:r(()=>Oa.mutate(void 0),"onConnect")}),fe==="access"&&(0,t.jsxs)(t.Fragment,{children:[re?.slug==="railway"&&(0,t.jsxs)("div",{className:"mb-6 space-y-3 text-sm text-muted-foreground",children:[(0,t.jsx)("p",{children:yi?.guidanceMd}),(0,t.jsx)("ul",{className:"list-disc space-y-2 pl-5",children:yi?.warnings?.map(Be=>(0,t.jsx)("li",{children:Be},Be))})]}),(0,t.jsx)(Kxe,{companyId:_,authKind:Si,grantKinds:Ls?[Ls]:yi?.grantKinds,grantKind:nr,setGrantKind:xs,installChoice:bs,setInstallChoice:qe,installAgentIds:ft,setInstallAgentIds:us,lockedAgentId:i,capabilities:Nn.data?.capabilities,githubIdentity:re?.slug==="github",submitLabel:Xa,continuesToProvider:to,identityLoading:!!kr&&Jr,preserveAgentAccess:!!(kr&&(aa||Hs)),pending:Oa.isPending||qt.isPending||!!(de&&!re),onBack:ya,onContinue:r(()=>{if(Mr){Dt.current=!0,Ze(null),Ee("starting"),je("key"),aa?Gn(aa):rt(Mr);return}re?je("key"):se("key")},"onContinue")})]}),fe==="success"&&(0,t.jsx)(gYe,{appName:Xr,logoUrl:re?.branding.logoUrl,darkLogoUrl:re?.branding.darkLogoUrl,summary:xYe({grantKind:nr,authKind:Si,installChoice:bs,installCount:ft.size,enabledCount:Object.values(Ts).filter(Boolean).length}),onDone:v??(()=>S("/apps"))})]})}r(dYe,"StandardConnectionSetupFlow");function AK({title:e,headingRef:s,subtitle:n,step:a,activeIndex:i,labels:o,appIdentity:l,unverifiedHost:c,onCancel:d}){return(0,t.jsxs)("div",{className:"mb-6",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[l?(0,t.jsx)(wc,{name:l.name,logoUrl:l.logoUrl,darkLogoUrl:l.darkLogoUrl,size:44}):null,(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{ref:s,tabIndex:s?-1:void 0,className:"text-2xl font-bold tracking-tight outline-none",children:e??(l?`Connect ${l.name}`:"Connect your own MCP server")}),(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:n}),c?(0,t.jsx)(pE,{host:c,className:"mt-2"}):null]})]}),d&&(0,t.jsx)(F,{variant:"ghost",size:"sm",onClick:d,children:"Cancel"})]}),a!=="gallery"&&(0,t.jsxs)("nav",{className:"mt-4","aria-label":"Setup progress","data-testid":"wizard-stepper",children:[(0,t.jsx)("ol",{className:"flex gap-2","aria-hidden":"true",children:o.map((m,h)=>(0,t.jsx)("li",{"data-testid":"wizard-step-dot","data-step-active":h===i?"true":void 0,className:U("h-1 w-20 rounded-full",h<=i?"bg-foreground":"bg-border")},m))}),(0,t.jsx)("div",{className:"mt-2 text-xs text-muted-foreground","data-testid":"wizard-step-labels",children:o.join(" · ")})]})]})}r(AK,"StepHeader");function GF({entry:e,identity:s,resuming:n=!1,phase:a,error:i,recoveryActions:o,authorizationHost:l,authorizationUrl:c,steps:d={labels:iYe,activeIndex:1},onRetry:m,onOpenAuthorization:h,onBack:p,onCancel:f}){const g=e?.name??s?.name??"this server",v=e?null:s?.unverifiedHost??null,y=a==="entry"?{title:n?`Finish connecting ${g}`:`Connect ${g} to Paperclip`,body:n?`Your connection is saved. Continue in ${g} to approve access; its identity and agent access will stay the same.`:`Paperclip will open ${g} so you can choose a workspace and approve access.`}:a==="starting"?{title:"Preparing secure sign-in",body:`Paperclip is creating a secure ${g} connection.`}:a==="redirecting"?{title:`Opening ${g}`,body:l?`Continue at ${l} to choose a workspace and approve access. Only approve access if you recognize that address.`:`Continue in ${g} to choose a workspace and approve access.`}:{title:`${g} couldn’t connect`,body:i??"Paperclip couldn’t start secure sign-in. Try again."};return(0,t.jsxs)("div",{className:"max-w-5xl",children:[(0,t.jsx)(AK,{subtitle:"Secure MCP sign-in",step:"key",activeIndex:d.activeIndex,labels:d.labels,appIdentity:e?{name:e.name,logoUrl:e.branding.logoUrl,darkLogoUrl:e.branding.darkLogoUrl}:void 0,unverifiedHost:v,onCancel:f}),(0,t.jsxs)("div",{className:"mx-auto max-w-xl",children:[(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)("span",{className:"mt-1 inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-lg border border-border bg-background",children:a==="error"?(0,t.jsx)(ic,{className:"h-5 w-5 text-destructive"}):a==="entry"?(0,t.jsx)(Dd,{className:"h-5 w-5 text-muted-foreground"}):(0,t.jsx)(at,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("h2",{className:"text-xl font-bold tracking-tight",children:y.title}),(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:y.body}),v?(0,t.jsx)(pE,{host:v,className:"mt-2"}):null]})]}),a==="error"&&o&&(o.installationUrl||o.managementUrl)?(0,t.jsxs)("div",{className:"mt-4 flex flex-wrap gap-2",children:[o.installationUrl?(0,t.jsx)(F,{type:"button",variant:"outline",asChild:!0,children:(0,t.jsxs)("a",{href:o.installationUrl,target:"_blank",rel:"noreferrer",children:["Install Paperclip on GitHub",(0,t.jsx)(Zi,{className:"ml-1.5 h-3.5 w-3.5"})]})}):null,o.managementUrl?(0,t.jsx)(F,{type:"button",variant:"ghost",asChild:!0,children:(0,t.jsx)("a",{href:o.managementUrl,target:"_blank",rel:"noreferrer",children:"Manage repositories on GitHub"})}):null]}):null,(0,t.jsxs)("div",{className:"mt-6 flex items-center gap-2",children:[a==="error"||a==="entry"?(0,t.jsx)(F,{type:"button",onClick:m,children:a==="entry"?n?`Finish with ${g}`:`Continue to ${g}`:"Try again"}):(0,t.jsx)(F,{type:"button",disabled:!0,children:a==="redirecting"?`Opening ${g}…`:"Preparing…"}),c?(0,t.jsx)(F,{variant:"outline",asChild:!0,children:(0,t.jsx)("a",{href:c,target:"_blank",rel:"noopener noreferrer",onClick:h,children:"Open sign-in in a new tab"})}):null,(0,t.jsx)(F,{type:"button",variant:"ghost",onClick:p,children:"Back"})]})]})]})}r(GF,"OAuthConnectStateScreen");function uYe({link:e,onLinkChange:s,submitting:n,onBack:a,onConnect:i}){const o=YF(e),l=o?new URL(o).hostname:"",c=l==="zapier.com"||l.endsWith(".zapier.com");return(0,t.jsxs)("div",{className:"mx-auto max-w-xl",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Zapier MCP URL"}),(0,t.jsx)(At,{type:"password",autoComplete:"off",spellCheck:!1,value:e,onChange:r(d=>s(d.target.value),"onChange"),onKeyDown:r(d=>{d.key==="Enter"&&c&&!n&&i()},"onKeyDown"),placeholder:"https://mcp.zapier.com/api/v1/connect?token=…",className:"mt-2 h-11",autoFocus:!0}),e.trim()&&!c&&(0,t.jsx)("p",{className:"mt-2 text-xs text-destructive",children:"Paste a valid Zapier URL to continue."})]}),(0,t.jsxs)("div",{className:"mt-6 flex items-center justify-between",children:[(0,t.jsx)(F,{variant:"ghost",onClick:a,disabled:n,children:"Back"}),(0,t.jsxs)(F,{onClick:i,disabled:n||!c,children:[n&&(0,t.jsx)(at,{className:"mr-2 h-4 w-4 animate-spin"}),n?"Checking…":"Check link"]})]})]})}r(uYe,"ZapierConnectStep");function mYe({loading:e,initialLink:s="",apps:n,byo:a=!1,byoOnly:i=!1,vercelConnect:o=!1,vercelConnectAvailability:l=null,source:c=null,onPick:d,onUseLink:m}){const[h,p]=(0,u.useState)(""),[f,g]=(0,u.useState)(s),v=(0,u.useRef)(!1);(0,u.useEffect)(()=>{v.current||g(s)},[s]);const[y,w]=(0,u.useState)(null),S=(0,u.useRef)(null),j=(0,u.useRef)(null),N=(0,u.useRef)(!1);(0,u.useEffect)(()=>{!a||e&&!i||N.current||(i||S.current?.scrollIntoView?.({block:"center"}),j.current?.focus(),j.current?.select(),N.current=!0)},[a,i,e]);const _=(0,u.useMemo)(()=>{const I=h.trim().toLowerCase();return n.filter($=>!I||$.name.toLowerCase().includes(I))},[n,h]),R=YF(f),C=R?MR(R,n):null,A=c==="zapier",T=r(()=>{const I=YF(f);if(!I){w("Paste a full http or https link.");return}w(null),m(I)},"continueWithLink");return e&&!i?(0,t.jsx)("div",{className:"grid grid-cols-2 gap-4 sm:grid-cols-3 lg:grid-cols-4",children:Array.from({length:8}).map((I,$)=>(0,t.jsx)(jn,{className:"h-32 w-full rounded-xl"},$))}):(0,t.jsxs)("div",{className:"space-y-6",children:[o?(0,t.jsxs)("div",{className:"rounded-xl border border-border bg-card p-5",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-lg font-bold tracking-tight",children:"Connect through Vercel"}),(0,t.jsx)("p",{className:"mt-1 max-w-2xl text-sm text-muted-foreground",children:"Create and manage the provider connector in Vercel. Paperclip stores its reference and applies agent access, policy, approval, and audit controls here."})]}),l?(0,t.jsx)(F,{asChild:!0,variant:"outline",size:"sm",className:"shrink-0",children:(0,t.jsxs)("a",{href:l.manageUrl,target:"_blank",rel:"noreferrer",children:["Open Vercel Connect",(0,t.jsx)(Zi,{className:"ml-2 h-3.5 w-3.5"})]})}):null]}),l?.available===!1?(0,t.jsx)(Ga,{tone:"danger",compact:!0,className:"mt-4",children:l.reason??"Vercel Connect is unavailable on this instance."}):null]}):null,!i&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)(ua,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),(0,t.jsx)(At,{value:h,onChange:r(I=>p(I.target.value),"onChange"),placeholder:"Search apps…",className:"h-11 pl-9"})]}),(0,t.jsx)("div",{className:"grid grid-cols-2 gap-4 sm:grid-cols-3 lg:grid-cols-4",children:_.map(I=>{const $=$xe(I.slug,I.description),O=q1(I),L=O.length===0||O.every(q=>q.auth==="oauth"&&!Bp(q)&&!RR(q)),E=I.availability?.available===!1||o&&l?.available!==!0;return(0,t.jsxs)("button",{type:"button",disabled:L||E,title:E?I.availability?.reason??l?.reason??void 0:void 0,onClick:r(()=>d(I),"onClick"),className:U("flex flex-col rounded-xl border border-border bg-card p-4 text-left transition-colors",L||E?"cursor-not-allowed opacity-60":"hover:border-foreground/30 hover:bg-accent/40"),children:[(0,t.jsx)(wc,{name:I.name,logoUrl:I.branding.logoUrl,darkLogoUrl:I.branding.darkLogoUrl,size:36}),(0,t.jsx)("div",{className:"mt-3 text-sm font-bold text-foreground",children:I.name}),(0,t.jsx)("div",{className:"mt-1 line-clamp-2 text-xs text-muted-foreground",children:$.tagline}),(0,t.jsx)("div",{className:"mt-3 text-xs font-semibold text-foreground",children:E?(0,t.jsx)("span",{className:"text-muted-foreground",children:I.availability?.reason??l?.reason??"Unavailable on this instance."}):L?(0,t.jsx)("span",{className:"text-muted-foreground",children:"Unavailable"}):(0,t.jsx)("span",{children:"Connect →"})})]},I.slug)})}),_.length===0&&(0,t.jsxs)("div",{className:"py-10 text-center text-sm text-muted-foreground",children:["No apps match “",h,"”."]})]}),o?null:(0,t.jsxs)("div",{ref:S,className:U("grid gap-4 border-t border-border pt-5 md:grid-cols-(--gtc-13)",a&&"-mx-3 rounded-xl border border-primary/40 bg-primary/[0.04] px-3 pb-4 md:mx-0"),children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm font-semibold text-foreground",children:[(0,t.jsx)(ic,{className:"h-4 w-4 text-muted-foreground"}),A?"Connect Zapier":a?"Connect your own MCP server":"Connect with a link"]}),(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:A?"Paste the complete MCP URL Zapier gives you, including its token.":a?"Paste your MCP server’s URL and every discovered tool will be available immediately.":"Paste a setup link from an app that is not listed here."}),!A&&(0,t.jsxs)("p",{className:"mt-1 text-xs text-muted-foreground",children:["Any remote tool URL works here — including a local MCP server like"," ",(0,t.jsx)("code",{className:"rounded bg-muted px-1 py-0.5 text-xs",children:"http://127.0.0.1:8848/mcp"}),"."]}),C&&(0,t.jsxs)("div",{className:"mt-3 flex items-center justify-between gap-3 rounded-lg border border-border bg-muted/40 px-3 py-2",children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2 text-sm",children:[(0,t.jsx)(wc,{name:C.name,logoUrl:C.branding.logoUrl,darkLogoUrl:C.branding.darkLogoUrl,size:24}),(0,t.jsxs)("span",{className:"truncate",children:["This looks like ",C.name,"."]})]}),(0,t.jsx)(F,{type:"button",size:"sm",variant:"outline",disabled:C.availability?.available===!1,onClick:r(()=>{if(w(null),C.slug==="zapier"){T();return}d(C)},"onClick"),children:C.availability?.available===!1?"Not available":C.slug==="zapier"?"Continue":`Use ${C.name}`})]})]}),(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-2 sm:min-w-(--sz-360px)",children:[(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(At,{ref:j,type:A||C?.slug==="zapier"?"password":"url",autoComplete:"off",spellCheck:!1,"aria-label":"MCP server URL",value:f,onChange:r(I=>{v.current=!0,g(I.target.value),w(null)},"onChange"),onKeyDown:r(I=>{I.key==="Enter"&&T()},"onKeyDown"),placeholder:A?"https://mcp.zapier.com/api/v1/connect?token=…":"https://example.com/actions",className:"h-10"}),(0,t.jsx)(F,{type:"button",variant:"outline",onClick:T,children:"Continue"})]}),y&&(0,t.jsx)("div",{className:"text-xs text-destructive",children:y})]})]})]})}r(mYe,"GalleryStep");function YF(e){try{const s=new URL(e.trim());return s.protocol!=="http:"&&s.protocol!=="https:"?null:s.toString()}catch{return null}}r(YF,"normalizeAppLink");function hYe({link:e,name:s,needsKey:n,onNeedsKeyChange:a,keyValue:i,onKeyChange:o,authMode:l,onAuthModeChange:c,headers:d,onHeadersChange:m,oauthClientId:h,onOAuthClientIdChange:p,oauthClientSecret:f,onOAuthClientSecretChange:g,advancedOpen:v,onAdvancedOpenChange:y,guidance:w,matchedEntry:S,onUseMatchedEntry:j,submitting:N,onBack:_,onConnect:R}){const C=IS(e),A=l==="custom_headers"?Oxe(d):null,T=HGe({link:e,name:s,authMode:l,needsKey:n,keyValue:i,headers:d,oauthClientId:h,oauthClientSecret:f}),I=l==="auto",$=S?.slug==="zapier"?Tle(e):e,O=r((L,E)=>{m(d.map(q=>q.id===L?{...q,...E}:q))},"updateHeader");return(0,t.jsxs)("div",{className:"mx-auto max-w-xl",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsx)("p",{className:"min-w-0 truncate font-mono text-sm text-muted-foreground",title:$,children:$}),(0,t.jsx)(pE,{host:C})]}),S&&j?(0,t.jsxs)("div",{className:"mt-6 flex flex-wrap items-center justify-between gap-3 rounded-lg border border-border bg-muted/40 px-3 py-2",children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2 text-sm",children:[(0,t.jsx)(wc,{name:S.name,logoUrl:S.branding.logoUrl,darkLogoUrl:S.branding.darkLogoUrl,size:24}),(0,t.jsxs)("span",{className:"truncate",children:["Paperclip has a guided setup for ",S.name,"."]})]}),(0,t.jsxs)(F,{type:"button",size:"sm",variant:"outline",onClick:j,children:["Use ",S.name]})]}):null,w?(0,t.jsx)("div",{className:"mt-6",children:(0,t.jsx)(Ga,{tone:"warning",title:w.title,children:w.body})}):null,(0,t.jsxs)("div",{className:"mt-6 space-y-6",children:[I&&(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"mr-2 text-sm font-medium text-foreground",children:"Does it need a key?"}),(0,t.jsxs)("div",{className:"mt-2 inline-flex rounded-lg border border-border bg-muted/50 p-1",children:[(0,t.jsx)(J4,{label:"No",selected:!n,onClick:r(()=>a(!1),"onClick")}),(0,t.jsx)(J4,{label:"Yes",selected:n,onClick:r(()=>a(!0),"onClick")})]}),(0,t.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:n?"Paste the key this app gave you.":"Most servers just work from the address — pick Yes only if the server gave you a key, or if it asks you to sign in."})]}),I&&n||l==="bearer"?(0,t.jsx)("div",{className:"space-y-4",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",htmlFor:"generic-mcp-key",children:"App key"}),(0,t.jsx)(At,{id:"generic-mcp-key",type:"password",autoComplete:"off",value:i,onChange:r(L=>o(L.target.value),"onChange"),placeholder:"••••••••••••••••",className:"mt-2 h-11 font-mono"})]})}):null,(0,t.jsxs)(sl,{open:v,onOpenChange:y,children:[(0,t.jsxs)(Wl,{className:"flex w-full items-center justify-between rounded-lg border border-border bg-background px-3 py-2 text-left text-sm font-medium text-foreground hover:bg-accent/40",children:["Advanced authentication",(0,t.jsx)(sn,{className:U("h-4 w-4 text-muted-foreground transition-transform",v&&"rotate-180")})]}),(0,t.jsxs)(nl,{className:"space-y-5 pt-4",children:[(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Only needed when the server's docs are specific about how to authenticate."}),(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:EJ.map(L=>(0,t.jsx)(J4,{label:L.label,selected:l===L.mode,onClick:r(()=>c(L.mode),"onClick")},L.mode))}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:EJ.find(L=>L.mode===l)?.hint}),l==="custom_headers"?(0,t.jsxs)("div",{className:"space-y-3",children:[d.map(L=>(0,t.jsxs)("div",{className:"flex items-start gap-2",children:[(0,t.jsx)(At,{value:L.name,onChange:r(E=>O(L.id,{name:E.target.value}),"onChange"),placeholder:"Header name","aria-label":"Header name",className:"h-10 font-mono"}),(0,t.jsx)(At,{type:"password",autoComplete:"off",value:L.value,onChange:r(E=>O(L.id,{value:E.target.value}),"onChange"),placeholder:"Value","aria-label":L.name.trim()?`Value for ${L.name.trim()}`:"Header value",className:"h-10 font-mono"}),(0,t.jsx)(F,{type:"button",variant:"ghost",size:"sm",className:"h-10 shrink-0",onClick:r(()=>m(d.filter(E=>E.id!==L.id)),"onClick"),disabled:d.length===1,children:"Remove"})]},L.id)),(0,t.jsx)(F,{type:"button",variant:"outline",size:"sm",onClick:r(()=>m([...d,QF()]),"onClick"),children:"Add another header"}),A?(0,t.jsx)("p",{className:"text-xs text-destructive",children:A}):null]}):null,l==="oauth"?(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Paperclip sets sign-in up on its own whenever the server allows it. Only fill these in when the server's docs tell you to register Paperclip yourself first."}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",htmlFor:"generic-mcp-client-id",children:"Client ID"}),(0,t.jsx)(At,{id:"generic-mcp-client-id",value:h,onChange:r(L=>p(L.target.value),"onChange"),autoComplete:"off",placeholder:"Optional",className:"mt-2 h-11 font-mono"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",htmlFor:"generic-mcp-client-secret",children:"Client secret"}),(0,t.jsx)(At,{id:"generic-mcp-client-secret",type:"password",autoComplete:"off",value:f,onChange:r(L=>g(L.target.value),"onChange"),placeholder:"Optional",className:"mt-2 h-11 font-mono"})]})]}):null]})]})]}),(0,t.jsxs)("div",{className:"mt-8 flex items-center justify-between",children:[(0,t.jsx)(F,{variant:"ghost",onClick:_,disabled:N,children:"Back"}),(0,t.jsxs)(F,{onClick:R,disabled:N||!T||!!A,children:[N&&(0,t.jsx)(at,{className:"mr-2 h-4 w-4 animate-spin"}),N?"Checking…":"Check link"]})]})]})}r(hYe,"LinkConnectStep");var EJ=[{mode:"auto",label:"Let Paperclip check",hint:"Paperclip asks the server what it needs and walks you through it. Start here."},{mode:"none",label:"No sign-in needed",hint:"The server is open to anyone with the address."},{mode:"bearer",label:"Key or token",hint:"Paperclip sends your key as an Authorization header."},{mode:"custom_headers",label:"Custom headers",hint:"For servers that name their own headers. Values are stored as Paperclip secrets and can’t be read back."},{mode:"oauth",label:"Browser sign-in",hint:"You’ll sign in at the provider. Add a client ID and secret only if the provider requires you to register Paperclip first."}];function J4({label:e,selected:s,onClick:n}){return(0,t.jsx)("button",{type:"button",onClick:n,"aria-pressed":s,className:U("min-w-(--sz-64px) rounded-md px-4 py-1.5 text-sm font-medium transition-colors",s?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:e})}r(J4,"SegmentedOption");function pYe({entry:e,error:s,values:n,onChange:a,oauthClientId:i,onOAuthClientIdChange:o,oauthClientSecret:l,onOAuthClientSecretChange:c,credentialSource:d,vercelConnector:m,onVercelConnectorChange:h,vercelConnectAvailability:p,methodKey:f,onMethodChange:g,configValues:v,onConfigChange:y,googleSheetsLinks:w,googleSheetsError:S,onGoogleSheetsLinksChange:j,submitting:N,onBack:_,onConnect:R}){const C=(0,u.useMemo)(()=>ej(e,d),[d,e]),A=f?C.find($e=>$e.key===f)??null:Fj(C),T=(0,u.useMemo)(()=>C.some($e=>$e.capabilityProfile)?Array.from(C.reduce(($e,Ye)=>{const ue=Ye.capabilityProfile.key,Oe=$e.get(ue);return Oe?Oe.methods.push(Ye):$e.set(ue,{key:ue,label:Ye.capabilityProfile?.label??Ye.label??Ye.key,description:Ye.capabilityProfile?.description??Ye.whenToUse,methods:[Ye]}),$e},new Map)).map(([,$e])=>$e):[],[C]),I=A?.capabilityProfile?.key??A?.key??"",$=T.map($e=>$e.key).join("|"),[O,L]=(0,u.useState)(I||Fj(C)?.capabilityProfile?.key||(T.length===1?T[0].key:""));(0,u.useEffect)(()=>{if(I){L(I);return}L($e=>T.some(Ye=>Ye.key===$e)?$e:Fj(C)?.capabilityProfile?.key||(T.length===1?T[0].key:""))},[$,T,C,I]);const E=T.length>1?T.find($e=>$e.key===O)?.methods??[]:C,q=(A?.credentialFields??[]).map($e=>({...$e,configPath:Rle($e),helpUrl:A?.consoleLinks?.keys??A?.consoleLinks?.docs??""})),B=A?.credentialSources?.vercelConnect??null,K=d==="vercel_connect",z=K||q.every($e=>$e.required===!1||(n[$e.configPath]?.trim().length??0)>0),D=RR(A),V=D&&!Bp(A),H=K||!V||i.trim().length>0,ee=!K||m.trim().length>0,X=A?.auth==="oauth"&&D?VGe():null,le=[...A?.tenantFields??[],...A?.extensionFields??[]],ce=le.filter($e=>!$e.hidden),te=ce.filter($e=>$e.advanced!==!0),ae=ce.filter($e=>$e.advanced===!0),[de,J]=(0,u.useState)(!1),Y=le.every($e=>{if(!$e.required)return!0;const Ye=v[$e.key];return typeof Ye=="boolean"||typeof Ye=="string"&&Ye.trim().length>0}),G=A?.configRequirements?.atLeastOneOf??[],fe=G.length===0||G.some($e=>{const Ye=v[$e];return typeof Ye=="string"&&Ye.trim().length>0}),se=(T.length<=1||!!O)&&(E.length<=1?!!A:!!f),re=e.availability?.robotEmail??null,ie=e.availability?.available===!1,me=!K&&D&&!V,pe=ae.length>0||me,be=T.length>1?(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:"What should Paperclip be able to do?"}),(0,t.jsx)(uu,{ariaLabel:`Access level for ${e.name}`,className:"mt-2",value:O,onValueChange:r($e=>{const Ye=T.find(ue=>ue.key===$e);Ye&&(L($e),g(pz(Ye.methods)))},"onValueChange"),options:T.map($e=>({value:$e.key,title:$e.label,description:$e.description}))}),!O&&(0,t.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Choose an access level to continue."})]}):null,oe=E.find($e=>$e.oauthStrategy==="paperclip_cloud_connector"&&kIe($e.connectorProfile??"")),ye=oe&&E.find($e=>RR($e)&&!Bp($e)),Ae=A?.key===ye?.key,xe=(0,u.useId)(),_e=oe&&ye&&E.length===2?(0,t.jsx)(F,{type:"button",variant:"link",className:"h-auto p-0 text-xs text-muted-foreground underline underline-offset-2 hover:text-foreground","aria-expanded":Ae,"aria-controls":xe,disabled:N,onClick:r(()=>g(Ae?oe:ye),"onClick"),children:Ae?"Use Paperclip instead":"Use your own Google OAuth app"}):E.length>1?(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:"How do you want to connect?"}),(0,t.jsx)(uu,{ariaLabel:`How to connect ${e.name}`,className:"mt-2",value:f,onValueChange:r($e=>{const Ye=E.find(ue=>ue.key===$e);Ye&&g(Ye)},"onValueChange"),options:E.map($e=>({value:$e.key,title:$e.label??($e.auth==="oauth"?`Sign in with ${e.name}`:"Use an API key")}))}),!A&&(0,t.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Choose a connection method to continue."})]}):null;if(Kk(e,A)){const $e=eF(w),Ye=!ie&&!!re&&w.trim().length>0;return(0,t.jsxs)("div",{className:"mx-auto max-w-xl",children:[(0,t.jsxs)("div",{className:"space-y-6",children:[be,re?(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Share each sheet with this email"}),(0,t.jsxs)("div",{className:"mt-2 flex min-w-0 flex-col gap-2 sm:flex-row",children:[(0,t.jsx)("div",{title:re,className:"min-h-11 min-w-0 flex-1 rounded-md border border-input bg-muted/40 px-3 py-2.5 font-mono text-xs leading-tight text-foreground break-all",children:re}),(0,t.jsx)(Uxe,{value:re,ariaLabel:"Copy sharing email"})]}),(0,t.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"In Google Sheets, click Share and add this email as an Editor. Then paste the sheet links below."})]}):(0,t.jsx)("div",{className:"rounded-lg bg-muted/50 p-4 text-sm text-muted-foreground",children:"Google Sheets is not available on this instance yet."}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Paste links to the sheets you shared"}),(0,t.jsx)(Dn,{value:w,onChange:r(ue=>j(ue.target.value),"onChange"),placeholder:"https://docs.google.com/spreadsheets/d/...",className:"mt-2 min-h-28"}),(0,t.jsx)("div",{className:"mt-2 text-xs text-muted-foreground",children:$e.ids.length>0?`${$e.ids.length} ${$e.ids.length===1?"sheet":"sheets"} ready to connect.`:"Paste one link per line. Both .../edit and .../edit#gid=... links work."}),S&&(0,t.jsx)("div",{className:"mt-2 text-xs text-destructive",children:S})]})]}),(0,t.jsxs)("div",{className:"mt-8 flex items-center justify-between",children:[(0,t.jsx)(F,{variant:"ghost",onClick:_,disabled:N,children:"Back"}),(0,t.jsxs)(F,{onClick:R,disabled:N||!Ye,children:[N&&(0,t.jsx)(at,{className:"mr-2 h-4 w-4 animate-spin"}),N?"Checking…":"Connect"]})]})]})}const Ge=A?.consoleLinks?.docs??e.docsUrl;return(0,t.jsxs)("div",{className:"mx-auto max-w-xl",children:[Ge?(0,t.jsx)("div",{className:"mb-4 flex justify-end",children:(0,t.jsxs)("a",{href:Ge,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-xs font-medium text-muted-foreground underline underline-offset-2 hover:text-foreground",children:["Review requirements",(0,t.jsx)(Zi,{className:"h-3 w-3"})]})}):null,(0,t.jsxs)("div",{className:"space-y-6",children:[be,_e,K&&B&&p?(0,t.jsxs)("div",{className:"space-y-4 rounded-lg border border-border p-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-sm font-medium text-foreground",children:"Create or attach the connector in Vercel"}),(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Paperclip does not copy Vercel’s setup forms. Finish connector setup there, then paste its UID below."}),(0,t.jsxs)("a",{href:p.manageUrl,target:"_blank",rel:"noreferrer",className:"mt-2 inline-flex items-center gap-1 text-xs font-semibold text-foreground underline underline-offset-2",children:["Open Vercel Connect",(0,t.jsx)(Zi,{className:"h-3 w-3"})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",htmlFor:"vercel-connect-connector",children:"Connector UID or ID"}),(0,t.jsx)(At,{id:"vercel-connect-connector",value:m,onChange:r($e=>h($e.target.value),"onChange"),autoComplete:"off",placeholder:"service/my-connector or scl_…",className:"mt-2 h-11 font-mono"}),(0,t.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Paperclip validates the connector and stores only its reference and redacted verification metadata."})]})]}):null,s?(0,t.jsx)("div",{role:"alert",children:(0,t.jsx)(Ga,{tone:"danger",children:s})}):null,te.map($e=>(0,t.jsx)(MJ,{field:$e,value:v[$e.key],onChange:r(Ye=>y({...v,[$e.key]:Ye}),"onChange")},$e.key)),pe&&(0,t.jsxs)(sl,{open:de,onOpenChange:J,children:[(0,t.jsxs)(Wl,{className:"flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground",children:[(0,t.jsx)(sn,{className:U("h-4 w-4 transition-transform",de&&"rotate-180")}),"Advanced"]}),(0,t.jsx)(nl,{className:"pt-4",children:(0,t.jsxs)("div",{className:"space-y-6",children:[ae.map($e=>(0,t.jsx)(MJ,{field:$e,value:v[$e.key],onChange:r(Ye=>y({...v,[$e.key]:Ye}),"onChange")},$e.key)),me?(0,t.jsx)(PJ,{entry:e,method:A,callbackUrl:X,clientId:i,onClientIdChange:o,clientSecret:l,onClientSecretChange:c,required:!1}):null]})})]}),!K&&A?.auth==="oauth"&&V?(0,t.jsx)("div",{id:xe,role:"region","aria-label":"Your OAuth app",children:(0,t.jsx)(PJ,{entry:e,method:A,callbackUrl:X,clientId:i,onClientIdChange:o,clientSecret:l,onClientSecretChange:c,required:!0})}):null,K||!A||q.length===0?null:q.map($e=>(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:gJ(e.name,$e.label,q.length)}),(0,t.jsx)(At,{type:"password","aria-label":gJ(e.name,$e.label,q.length),autoComplete:"off",value:n[$e.configPath]??"",onChange:r(Ye=>a({...n,[$e.configPath]:Ye.target.value}),"onChange"),placeholder:"••••••••••••••••",className:"mt-2 h-11 font-mono"}),$e.helpUrl&&(0,t.jsxs)("a",{href:$e.helpUrl,target:"_blank",rel:"noreferrer",className:"mt-2 inline-flex items-center gap-1 text-xs font-semibold text-foreground underline underline-offset-2",children:["Where do I find this?",(0,t.jsx)(Zi,{className:"h-3 w-3"})]})]},$e.configPath))]}),(0,t.jsxs)("div",{className:"mt-8 flex items-center justify-between",children:[(0,t.jsx)(F,{variant:"ghost",onClick:_,disabled:N,children:"Back"}),(0,t.jsxs)(F,{onClick:R,disabled:N||!se||!z||!H||!ee||!Y||!fe,children:[N&&(0,t.jsx)(at,{className:"mr-2 h-4 w-4 animate-spin"}),N?"Checking…":K?A?.auth==="oauth"?"Validate and continue":"Validate and connect":A?.auth==="oauth"?e.slug==="github"?"Continue to GitHub":"Continue to sign in":"Connect"]})]})]})}r(pYe,"KeyStep");function Uxe({value:e,ariaLabel:s}){const{copied:n,failed:a,copy:i}=hf();return(0,t.jsxs)(F,{type:"button",variant:"outline",className:"shrink-0","aria-label":s,onClick:r(()=>{i(e)},"onClick"),children:[n?(0,t.jsx)(ds,{className:"mr-2 h-4 w-4"}):(0,t.jsx)(Nr,{className:"mr-2 h-4 w-4"}),n?"Copied":a?"Copy failed":"Copy"]})}r(Uxe,"CopyValueButton");function PJ({entry:e,method:s,callbackUrl:n,clientId:a,onClientIdChange:i,clientSecret:o,onClientSecretChange:l,required:c}){return(0,t.jsxs)("div",{className:"space-y-4 rounded-lg border border-border p-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-sm font-medium text-foreground",children:c?"Your OAuth app":"Use your own OAuth app"}),(0,t.jsxs)("p",{className:"mt-1 text-xs text-muted-foreground",children:["Register Paperclip's callback URI in ",e.name,", then enter the customer-owned client details."]}),s.consoleLinks?.register?(0,t.jsxs)("a",{href:s.consoleLinks.register,target:"_blank",rel:"noreferrer",className:"mt-2 inline-flex items-center gap-1 text-xs font-semibold text-foreground underline underline-offset-2",children:["Open ",e.name," app settings",(0,t.jsx)(Zi,{className:"h-3 w-3"})]}):null]}),n?(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Paperclip callback URL"}),(0,t.jsxs)("div",{className:"mt-2 flex min-w-0 flex-col gap-2 sm:flex-row",children:[(0,t.jsx)("div",{title:n,className:"min-h-11 min-w-0 flex-1 rounded-md border border-input bg-muted/40 px-3 py-2.5 font-mono text-xs leading-tight text-foreground break-all",children:n}),(0,t.jsx)(Uxe,{value:n,ariaLabel:"Copy callback URL"})]}),(0,t.jsxs)("p",{className:"mt-2 text-xs text-muted-foreground",children:["Add this exact URL to ",e.name," before continuing. It must match the authorization request."]})]}):null,(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",htmlFor:"curated-oauth-client-id",children:"Client ID"}),(0,t.jsx)(At,{id:"curated-oauth-client-id",value:a,onChange:r(d=>i(d.target.value),"onChange"),autoComplete:"off",placeholder:c?"Required":"Optional",className:"mt-2 h-11 font-mono"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",htmlFor:"curated-oauth-client-secret",children:"Client secret"}),(0,t.jsx)(At,{id:"curated-oauth-client-secret",type:"password",value:o,onChange:r(d=>l(d.target.value),"onChange"),autoComplete:"off",placeholder:"Optional for public clients",className:"mt-2 h-11 font-mono"})]})]})}r(PJ,"OAuthClientFields");function MJ({field:e,value:s,onChange:n}){return e.type==="checkbox"?(0,t.jsxs)("div",{className:"flex items-start justify-between gap-4 rounded-lg border border-border p-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-sm font-medium text-foreground",children:e.label}),e.helperMd&&(0,t.jsx)("div",{className:"mt-1 text-xs text-muted-foreground",children:e.helperMd})]}),(0,t.jsx)(_i,{checked:s===!0,onCheckedChange:n})]}):(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:e.label}),e.type==="textarea"?(0,t.jsx)(Dn,{value:typeof s=="string"?s:"",onChange:r(a=>n(a.target.value),"onChange"),placeholder:e.placeholder,className:"mt-2 min-h-24"}):e.type==="select"?(0,t.jsxs)("select",{value:typeof s=="string"?s:"",onChange:r(a=>n(a.target.value),"onChange"),className:"mt-2 h-11 w-full rounded-md border border-input bg-background px-3 text-sm text-foreground outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30",children:[(0,t.jsx)("option",{value:"",disabled:!0,children:"Select an option"}),(e.options??[]).map(a=>(0,t.jsx)("option",{value:a.value,children:a.label},a.value))]}):(0,t.jsx)(At,{value:typeof s=="string"?s:"",onChange:r(a=>n(a.target.value),"onChange"),placeholder:e.placeholder,className:"mt-2 h-11"}),e.helperMd&&(0,t.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:e.helperMd})]})}r(MJ,"MethodConfigField");function Kxe({companyId:e,...s}){const n=Z({queryKey:P.agents.list(e),queryFn:r(()=>Vt.list(e),"queryFn")});return(0,t.jsx)(Vxe,{...s,agents:(n.data??[]).filter(a=>a.status!=="terminated"),agentsLoading:n.isLoading})}r(Kxe,"AccessStep");function Vxe({agents:e,agentsLoading:s=!1,authKind:n,grantKinds:a,grantKind:i,setGrantKind:o,installChoice:l,setInstallChoice:c,installAgentIds:d,setInstallAgentIds:m,lockedAgentId:h,capabilities:p,githubIdentity:f=!1,submitLabel:g,continuesToProvider:v=!1,identityLoading:y=!1,preserveAgentAccess:w=!1,pending:S=!1,onBack:j,onContinue:N}){const _=p?.editableAgentIds,R=_?e.filter(B=>_.includes(B.id)):e,C=p?.canSetCompanyInstall??!0,A=p?.canCreateOrganizationGrant??!0,T=n!=="none",I=a??["user","organization"],$=(!T||i==="user"||i==="agent"||A)&&(w?!0:h?d.has(h):i==="agent"?l==="specific"&&d.size===1:l==="all"?C:d.size>0),O=h?e.find(B=>B.id===h)?.name??"the requesting agent":null,L=f?"Connect GitHub as":"Which humans can use this credential?",E=i==="agent"?"Which agent owns this GitHub account?":f&&i==="user"?"Which agents may use your GitHub when you’re responsible?":f?"Which agents may use the shared GitHub account?":"Which agents can use this connection?",q=f?E:"Which agents can use this connection?";return(0,t.jsxs)("div",{className:"mx-auto max-w-2xl",children:[(0,t.jsx)("div",{className:"overflow-hidden rounded-xl border border-border",children:(0,t.jsxs)("div",{className:"divide-y divide-border",children:[(0,t.jsxs)("section",{className:"p-6",children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:L}),f&&i==="agent"?(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"This agent uses this GitHub account for everyone’s work, instead of the person giving instructions."}):null,y?(0,t.jsxs)("div",{className:"mt-4 grid gap-2 sm:grid-cols-2","aria-label":"Loading connection identity",children:[(0,t.jsx)(jn,{className:"h-20 w-full rounded-md"}),(0,t.jsx)(jn,{className:"h-20 w-full rounded-md"})]}):T&&I.length===1?(0,t.jsxs)("div",{className:"mt-4 flex items-center gap-3 rounded-md border border-border p-4",children:[I[0]==="user"?(0,t.jsx)(vu,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}):I[0]==="agent"?(0,t.jsx)(Ji,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}):(0,t.jsx)(Rj,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-sm font-medium text-foreground",children:I[0]==="user"?f?"My GitHub account":"Just me":I[0]==="agent"?"A dedicated account for an agent":f?"Shared organization GitHub account (advanced)":"Any human in the organization"}),f?(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:I[0]==="user"?"Agents use it only for runs where you are the responsible person.":I[0]==="agent"?"That agent always uses this account, regardless of who starts the run.":"Eligible agents use one shared credential, regardless of who starts the run."}):null]})]}):T?(0,t.jsx)(uu,{ariaLabel:f?L:"Which humans can use this credential?",className:"mt-4 sm:grid-cols-2",value:i,onValueChange:r(B=>{const K=B;o(K),K==="agent"&&(c("specific"),d.size>1&&m(new Set([[...d][0]])))},"onValueChange"),options:[{value:"user",title:f?"My GitHub account":"Just me",description:f?"Agents use it only for runs where you are the responsible person.":void 0,icon:(0,t.jsx)(vu,{className:"h-4 w-4","aria-hidden":"true"})},{value:"agent",title:"A dedicated account for an agent",description:f?"That agent always uses this account, regardless of who starts the run.":void 0,icon:(0,t.jsx)(Ji,{className:"h-4 w-4","aria-hidden":"true"})},{value:"organization",title:f?"Shared organization GitHub account (advanced)":"Any human in the organization",description:f?"Eligible agents use one shared credential, regardless of who starts the run.":void 0,icon:(0,t.jsx)(Rj,{className:"h-4 w-4","aria-hidden":"true"}),accessibleLabel:A?f?"Shared organization GitHub account (advanced)":"Any human in the organization":`${f?"Shared organization GitHub account (advanced)":"Any human in the organization"}. Unavailable: ${p?.organizationGrantReason??"Only a connection manager can share this credential with the organization."}`,tooltip:A?void 0:p?.organizationGrantReason??"Only a connection manager can share this credential with the organization.",disabled:!A}].filter(B=>I.includes(B.value))}):(0,t.jsx)("p",{className:"mt-4 text-sm text-muted-foreground",children:"No identity required"})]}),(0,t.jsxs)("section",{className:"p-6",children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:E}),w?(0,t.jsxs)("div",{className:"mt-4 flex items-start gap-3 rounded-md border border-border bg-muted/40 p-4",children:[(0,t.jsx)(Rj,{className:"mt-0.5 h-4 w-4 shrink-0 text-primary","aria-hidden":"true"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-sm font-medium text-foreground",children:"Existing agent access stays the same"}),(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Reconnecting replaces the credential without changing which agents can use it."})]})]}):h?(0,t.jsxs)("p",{className:"mt-2 text-sm text-muted-foreground",children:["This task grants access only to ",(0,t.jsx)("span",{className:"font-medium text-foreground",children:O}),". Existing connection access is left unchanged."]}):i==="agent"?(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Choose exactly one agent. This identity cannot be shared with other agents."}):(0,t.jsx)(uu,{ariaLabel:q,className:"mt-4 sm:grid-cols-2",value:l,onValueChange:r(B=>c(B),"onValueChange"),options:[{value:"specific",title:f?"Only agents I choose":"Just agents I pick",description:f?i==="user"?"Only selected agents may use your GitHub when you’re responsible.":"Only selected agents may use the shared account.":void 0,icon:(0,t.jsx)(Ji,{className:"h-4 w-4","aria-hidden":"true"})},{value:"all",title:"Any agent",description:f?i==="user"?"Every agent may use your GitHub when you’re responsible.":"Every agent may use the shared account.":void 0,icon:(0,t.jsx)(fYe,{}),accessibleLabel:C?"Any agent":`Any agent. Unavailable: ${p?.companyInstallReason??"Only someone who can configure this connection can choose this."}`,tooltip:C?void 0:p?.companyInstallReason??"Only someone who can configure this connection can choose this.",disabled:!C}]}),!w&&!h&&l==="specific"?(0,t.jsx)("div",{className:"mt-3",children:(0,t.jsx)(Pv,{agents:R,selectedAgentIds:d,onChange:r(B=>m(i==="agent"&&B.size>1?new Set([[...B].at(-1)]):B),"onChange"),loading:s,emptyMessage:"You cannot edit any agents yet.",showSelectionPreview:!1})}):null]})]})}),(0,t.jsxs)("div",{className:"mt-6 flex flex-col-reverse gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,t.jsx)(F,{variant:"ghost",className:"w-full sm:w-auto",onClick:j,disabled:S,children:"Back"}),(0,t.jsxs)(F,{className:"w-full sm:w-auto",onClick:N,disabled:!$||y||S,children:[S?(0,t.jsx)(at,{className:"h-4 w-4 animate-spin","aria-hidden":"true"}):null,g,!S&&v?(0,t.jsx)(Zi,{className:"h-4 w-4","aria-hidden":"true"}):null]})]})]})}r(Vxe,"AccessStepContent");function fYe(){return(0,t.jsxs)("span",{className:"relative block h-4 w-5","aria-hidden":"true",children:[(0,t.jsx)(Ji,{className:"absolute left-0 top-0 h-3.5 w-3.5"}),(0,t.jsx)(Ji,{className:"absolute bottom-0 right-0 h-3.5 w-3.5"})]})}r(fYe,"BotGroupIcon");function xYe(e){const s=e.authKind==="none"?"No identity required":e.grantKind==="user"?"Your identity":e.grantKind==="agent"?"Dedicated agent identity":"Organization identity",n=e.installChoice==="all"?"Any agent":`${e.installCount} selected ${e.installCount===1?"agent":"agents"}`;return[{label:"Identity",value:s},{label:"Available to",value:n},{label:"Actions",value:`${e.enabledCount} ${e.enabledCount===1?"action":"actions"} on`}]}r(xYe,"accessSummaryLines");function gYe({appName:e,logoUrl:s,darkLogoUrl:n,summary:a,onDone:i}){return(0,t.jsxs)("div",{className:"mx-auto max-w-md py-10 text-center",children:[(0,t.jsx)("div",{className:"mx-auto flex h-20 w-20 items-center justify-center rounded-full border-2 border-emerald-500 bg-emerald-500/10",children:(0,t.jsx)(ds,{className:"h-9 w-9 text-emerald-600 dark:text-emerald-400"})}),(0,t.jsxs)("div",{className:"mt-6 flex items-center justify-center gap-2",children:[(0,t.jsx)(wc,{name:e,logoUrl:s,darkLogoUrl:n,size:28}),(0,t.jsxs)("h2",{className:"text-2xl font-bold tracking-tight",children:[e," is ready."]})]}),(0,t.jsx)("dl",{className:"mx-auto mt-6 max-w-xs space-y-1 text-left",children:a.map(o=>(0,t.jsxs)("div",{className:"flex items-baseline justify-between gap-4",children:[(0,t.jsx)("dt",{className:"text-xs font-medium text-muted-foreground",children:o.label}),(0,t.jsx)("dd",{className:"text-sm text-foreground",children:o.value})]},o.label))}),(0,t.jsx)("div",{className:"mt-8",children:(0,t.jsx)(F,{size:"lg",className:"px-10",onClick:i,children:"View connection"})})]})}r(gYe,"ConnectionSetupCompletionScreen");function Wxe(){const{newProjectOpen:e,closeNewProject:s}=x1(),{selectedCompanyId:n}=ps();return n&&e?(0,t.jsx)(bYe,{companyId:n,onClose:s},n):null}r(Wxe,"NewProjectDialog");function bYe({companyId:e,onClose:s}){const n=Wt(),[a,i]=(0,u.useState)(""),[o,l]=(0,u.useState)([]),[c,d]=(0,u.useState)(!1),m=(0,u.useRef)(null),h=Ne({mutationFn:r(()=>ma.create(e,{name:a.trim(),status:"planned",repositoryIds:o.map(p=>p.id)}),"mutationFn"),onSuccess:r(()=>{n.invalidateQueries({queryKey:P.projects.all(e)}),s()},"onSuccess")});return(0,t.jsx)(Ys,{open:!0,onOpenChange:r(p=>{!p&&!h.isPending&&s()},"onOpenChange"),children:(0,t.jsx)(Js,{showCloseButton:!1,"aria-describedby":void 0,className:"flex max-h-(--sz-calc-18) flex-col gap-0 overflow-hidden p-0 shadow-sm sm:max-w-lg",onOpenAutoFocus:r(p=>{p.preventDefault(),m.current?.focus()},"onOpenAutoFocus"),children:c?(0,t.jsxs)("div",{className:"min-h-0 overflow-y-auto p-5",children:[(0,t.jsx)(tn,{className:"sr-only",children:"Connect GitHub"}),(0,t.jsx)(xE,{host:"dialog",serviceSlug:"github",forceNewConnection:!0,onCancel:r(()=>d(!1),"onCancel"),onComplete:r(()=>{n.invalidateQueries({queryKey:RU(e)}),d(!1)},"onComplete")})]}):(0,t.jsxs)("form",{className:"flex min-h-0 flex-col overflow-hidden",onSubmit:r(p=>{p.preventDefault(),a.trim()&&!h.isPending&&h.mutate()},"onSubmit"),children:[(0,t.jsxs)("div",{className:"flex shrink-0 flex-col gap-4 px-5 pb-4 pt-5",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsx)(tn,{className:"text-lg font-semibold",children:"Create project"}),(0,t.jsx)(F,{type:"button",variant:"ghost",size:"icon-sm",disabled:h.isPending,"aria-label":"Close new project",onClick:s,children:(0,t.jsx)(ir,{className:"size-4"})})]}),(0,t.jsxs)("div",{className:"flex items-center gap-3 rounded-lg border border-input px-3 focus-within:border-ring focus-within:ring-1 focus-within:ring-ring",children:[(0,t.jsx)(Wc,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),(0,t.jsx)("input",{ref:m,"aria-label":"Project name",value:a,disabled:h.isPending,onChange:r(p=>i(p.target.value),"onChange"),placeholder:"Project name",required:!0,className:"h-10 w-full min-w-0 border-0 bg-transparent text-base outline-none placeholder:text-muted-foreground md:text-sm"})]})]}),(0,t.jsx)("div",{role:"region","aria-label":"Source repositories",tabIndex:0,className:"min-h-0 overflow-y-auto overscroll-contain px-5 pb-1 outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring",children:(0,t.jsx)(mhe,{companyId:e,selected:o,onChange:l,onConnect:r(()=>d(!0),"onConnect"),disabled:h.isPending})}),h.isError&&(0,t.jsx)("p",{role:"alert",className:"px-5 pt-3 text-sm text-destructive",children:h.error.message}),(0,t.jsxs)("div",{className:"flex shrink-0 justify-end gap-2 px-5 py-5",children:[(0,t.jsx)(F,{type:"button",variant:"ghost",disabled:h.isPending,onClick:s,children:"Cancel"}),(0,t.jsx)(F,{type:"submit",disabled:!a.trim()||h.isPending,children:h.isPending?"Creating…":"Create project"})]})]})})})}r(bYe,"NewProjectForm");var bx={list:r(e=>Re.get(`/companies/${e}/goals`),"list"),get:r(e=>Re.get(`/goals/${e}`),"get"),create:r((e,s)=>Re.post(`/companies/${e}/goals`,s),"create"),update:r((e,s)=>Re.patch(`/goals/${e}`,s),"update"),remove:r(e=>Re.delete(`/goals/${e}`),"remove")};function Hxe(e){return{"--sc":`var(${e})`}}r(Hxe,"scStyle");function vYe(e){const s=e.replace(/_/g," ");return s.charAt(0).toUpperCase()+s.slice(1)}r(vYe,"sentenceCaseStatus");function ti({status:e,label:s}){return(0,t.jsx)("span",{className:U("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium whitespace-nowrap shrink-0",mO[e]??"bg-muted text-muted-foreground"),children:s??e.replace(/[_-]/g," ")})}r(ti,"StatusBadge$5");function Qxe({status:e}){const s=fRe[e]??"--status-agent-idle",n=e==="active"?"idle":e;return(0,t.jsx)("span",{className:"status-chip inline-flex items-center rounded-full border px-3 py-1 text-xs font-medium leading-none whitespace-nowrap shrink-0",style:Hxe(s),children:n.replace(/_/g," ")})}r(Qxe,"AgentStatusBadge");function Tp({status:e,externalConversationState:s}){const n=e==="in_review"&&s==="waiting"?"idle":e,a=dRe[n]??"--status-task-backlog";return(0,t.jsxs)("span",{className:U("status-chip inline-flex items-center gap-1.5 rounded-full border px-3 py-1 text-xs font-normal leading-none whitespace-nowrap shrink-0",n==="cancelled"&&"line-through"),style:Hxe(a),children:[(0,t.jsx)(p1,{status:n,size:"sm"}),vYe(n)]})}r(Tp,"IssueStatusBadge");var DJ={company:"Organization",team:"Team",agent:"Agent",task:"Task"};function Gxe(){const{newGoalOpen:e,newGoalDefaults:s,closeNewGoal:n}=x1(),{selectedCompanyId:a,selectedCompany:i}=ps(),o=Wt(),[l,c]=(0,u.useState)(""),[d,m]=(0,u.useState)(""),[h,p]=(0,u.useState)("planned"),[f,g]=(0,u.useState)("task"),[v,y]=(0,u.useState)(""),[w,S]=(0,u.useState)(!1),[j,N]=(0,u.useState)(!1),[_,R]=(0,u.useState)(!1),[C,A]=(0,u.useState)(!1),T=(0,u.useRef)(null),I=v||s.parentId||"",{data:$}=Z({queryKey:P.goals.list(a),queryFn:r(()=>bx.list(a),"queryFn"),enabled:!!a&&e}),O=Ne({mutationFn:r(z=>bx.create(a,z),"mutationFn"),onSuccess:r(()=>{o.invalidateQueries({queryKey:P.goals.list(a)}),E(),n()},"onSuccess")}),L=Ne({mutationFn:r(async z=>{if(!a)throw new Error("No organization selected");return m0.uploadImage(a,z,"goals/drafts")},"mutationFn")});function E(){c(""),m(""),p("planned"),g("task"),y(""),S(!1)}r(E,"reset");function q(){!a||!l.trim()||O.mutate({title:l.trim(),description:d.trim()||void 0,status:h,level:f,...I?{parentId:I}:{}})}r(q,"handleSubmit");function B(z){z.key==="Enter"&&(z.metaKey||z.ctrlKey)&&(z.preventDefault(),q())}r(B,"handleKeyDown");const K=($??[]).find(z=>z.id===I);return(0,t.jsx)(Ys,{open:e,onOpenChange:r(z=>{z||(E(),n())},"onOpenChange"),children:(0,t.jsxs)(Js,{showCloseButton:!1,className:U("p-0 gap-0",w?"sm:max-w-2xl":"sm:max-w-lg"),onKeyDown:B,children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-border",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[i&&(0,t.jsx)("span",{className:"bg-muted px-1.5 py-0.5 rounded text-xs font-medium",children:i.issuePrefix}),(0,t.jsx)("span",{className:"text-muted-foreground/60",children:"›"}),(0,t.jsx)("span",{children:s.parentId?"New sub-goal":"New goal"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)(F,{variant:"ghost",size:"icon-xs",className:"text-muted-foreground",onClick:r(()=>S(!w),"onClick"),children:w?(0,t.jsx)(qz,{className:"h-3.5 w-3.5"}):(0,t.jsx)(l0,{className:"h-3.5 w-3.5"})}),(0,t.jsx)(F,{variant:"ghost",size:"icon-xs",className:"text-muted-foreground",onClick:r(()=>{E(),n()},"onClick"),children:(0,t.jsx)("span",{className:"text-lg leading-none",children:"×"})})]})]}),(0,t.jsx)("div",{className:"px-4 pt-4 pb-2 shrink-0",children:(0,t.jsx)("input",{className:"w-full text-lg font-semibold bg-transparent outline-none placeholder:text-muted-foreground/50",placeholder:"Goal title",value:l,onChange:r(z=>c(z.target.value),"onChange"),onKeyDown:r(z=>{z.key==="Tab"&&!z.shiftKey&&(z.preventDefault(),T.current?.focus())},"onKeyDown"),autoFocus:!0})}),(0,t.jsx)("div",{className:"px-4 pb-2 overflow-y-auto max-h-(--sz-50vh)",children:(0,t.jsx)(kc,{ref:T,value:d,onChange:m,placeholder:"Add description...",bordered:!1,contentClassName:U("text-sm text-muted-foreground",w?"min-h-(--sz-220px)":"min-h-(--sz-120px)"),imageUploadHandler:r(async z=>(await L.mutateAsync(z)).contentPath,"imageUploadHandler")})}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 px-4 py-2 border-t border-border flex-wrap",children:[(0,t.jsxs)(Zn,{open:j,onOpenChange:N,children:[(0,t.jsx)(ur,{asChild:!0,children:(0,t.jsx)("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2 py-1 text-xs hover:bg-accent/50 transition-colors",children:(0,t.jsx)(ti,{status:h})})}),(0,t.jsx)(Vn,{className:"w-40 p-1",align:"start",children:_le.map(z=>(0,t.jsx)("button",{className:U("flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50 capitalize",z===h&&"bg-accent"),onClick:r(()=>{p(z),N(!1)},"onClick"),children:z},z))})]}),(0,t.jsxs)(Zn,{open:_,onOpenChange:R,children:[(0,t.jsx)(ur,{asChild:!0,children:(0,t.jsxs)("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2 py-1 text-xs hover:bg-accent/50 transition-colors",children:[(0,t.jsx)(pl,{className:"h-3 w-3 text-muted-foreground"}),DJ[f]??f]})}),(0,t.jsx)(Vn,{className:"w-40 p-1",align:"start",children:jle.map(z=>(0,t.jsx)("button",{className:U("flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50",z===f&&"bg-accent"),onClick:r(()=>{g(z),R(!1)},"onClick"),children:DJ[z]??z},z))})]}),(0,t.jsxs)(Zn,{open:C,onOpenChange:A,children:[(0,t.jsx)(ur,{asChild:!0,children:(0,t.jsxs)("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2 py-1 text-xs hover:bg-accent/50 transition-colors",children:[(0,t.jsx)(af,{className:"h-3 w-3 text-muted-foreground"}),K?K.title:"Parent goal"]})}),(0,t.jsxs)(Vn,{className:"w-48 p-1",align:"start",children:[(0,t.jsx)("button",{className:U("flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50",!I&&"bg-accent"),onClick:r(()=>{y(""),A(!1)},"onClick"),children:"No parent"}),($??[]).map(z=>(0,t.jsx)("button",{className:U("flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50 truncate",z.id===I&&"bg-accent"),onClick:r(()=>{y(z.id),A(!1)},"onClick"),children:z.title},z.id))]})]})]}),(0,t.jsx)("div",{className:"flex items-center justify-end px-4 py-2.5 border-t border-border",children:(0,t.jsx)(F,{size:"sm",disabled:!l.trim()||O.isPending,onClick:q,children:O.isPending?"Creating…":s.parentId?"Create sub-goal":"Create goal"})})]})})}r(Gxe,"NewGoalDialog");function yYe(e){const s=jYe(e),n=wYe(e);return`You're invited to join a Paperclip company as an agent.
|
|
287
|
+
`;function PHe(){const e=new Blob([EHe],{type:"application/javascript"}),s=URL.createObjectURL(e);try{return new Worker(s)}finally{URL.revokeObjectURL(s)}}r(PHe,"createSandboxedWorker");var DF=new Map,FT=new Map,E2=new Set,P2=new Map,Zfe=null;function MHe(e){Zfe=e}r(MHe,"setDynamicParserResultNotifier");function exe(e,s){e.worker.postMessage(s)}r(exe,"sendToWorker");function DHe(e){return e.nextId++}r(DHe,"nextRequestId");function LHe(e,s){return`${s}\0${e}`}r(LHe,"lineCacheKey");function $He(){Zfe?.()}r($He,"notifyResultReady");function OHe(e,s,n){return new Promise(a=>{const i=DHe(e);e.pendingResolves.set(i,a),exe(e,{type:"parse",id:i,line:s,ts:n})})}r(OHe,"parseLineAsync");function zk(e){for(const s of e.pendingResolves.values())s([]);e.pendingResolves.clear()}r(zk,"drainPendingRequests");function FHe(e){return new Promise((s,n)=>{const a=PHe(),i={worker:a,ready:!1,nextId:1,pendingResolves:new Map},o=setTimeout(()=>{zk(i),a.terminate(),n(new Error("Parser worker init timed out"))},5e3);a.onmessage=l=>{const c=l.data;if(c.type==="ready"){clearTimeout(o),i.ready=!0,a.onmessage=d=>{const m=d.data;if(m.type==="result"){const h=i.pendingResolves.get(m.id);h&&(i.pendingResolves.delete(m.id),h(m.entries))}else m.type==="error"&&zk(i)},s(i);return}if(c.type==="error"){clearTimeout(o),zk(i),a.terminate(),n(new Error(c.message));return}},a.onerror=l=>{clearTimeout(o),zk(i),a.terminate(),n(new Error(`Worker error: ${l.message}`))},exe(i,{type:"init",source:e})})}r(FHe,"initSandboxedWorker");function BHe(e){const s=new Map,n=new Set;return{parseStdoutLine:r((i,o)=>{const l=LHe(i,o),c=s.get(l);return c?c.slice():(n.has(l)||(n.add(l),OHe(e,i,o).then(d=>{n.delete(l),s.set(l,d),$He()})),[])},"parseStdoutLine")}}r(BHe,"buildParserModule");async function LF(e){const s=FT.get(e);if(s)return s;if(E2.has(e))return null;const n=P2.get(e);if(n)return n;const a=(async()=>{try{const i=await fetch(`/api/adapters/${encodeURIComponent(e)}/ui-parser.js`);if(!i.ok)return E2.add(e),null;const o=await FHe(await i.text());DF.set(e,o);const l=BHe(o);return FT.set(e,l),l}catch{return E2.add(e),null}finally{P2.delete(e)}})();return P2.set(e,a),a}r(LF,"loadDynamicParser");function $F(e){const s=FT.has(e);FT.delete(e),E2.delete(e),P2.delete(e);const n=DF.get(e);return n&&(zk(n),n.worker.terminate(),DF.delete(e)),s}r($F,"invalidateDynamicParser");var M2=[],mE=new Map,OF=new Set,txe=new Map,F4=new Set,vI=new Map,FF=new Set;function sxe(e){return FF.add(e),()=>FF.delete(e)}r(sxe,"onAdapterChange");function nxe(){for(const e of FF)e()}r(nxe,"notifyAdapterChange");MHe(nxe);function qHe(){for(const e of[S9e,F9e,rVe,dVe,PVe,WVe,rWe,hWe,kWe,MWe,rHe,JWe,NVe,yHe,OT,THe])OF.add(e.type),txe.set(e.type,e),ob(e)}r(qHe,"registerBuiltInUIAdapters");function ob(e){const s=M2.findIndex(n=>n.type===e.type);s>=0?M2.splice(s,1,e):M2.push(e),mE.set(e.type,e),nxe()}r(ob,"registerUIAdapter");function rxe(e){return mE.get(e)??null}r(rxe,"findUIAdapter");qHe();function uN(e){const s=mE.get(e);if(!s){let n=!1;return{type:e,label:e,parseStdoutLine:r((a,i)=>(n||(n=!0,LF(e).then(o=>{o&&ob({type:e,label:e,parseStdoutLine:o.parseStdoutLine,createStdoutParser:o.createStdoutParser,ConfigFields:nv,buildAdapterConfig:bw})})),OT.parseStdoutLine(a,i)),"parseStdoutLine"),ConfigFields:nv,buildAdapterConfig:bw}}return s}r(uN,"getUIAdapter");function zHe(e){const s=new Set(e.filter(a=>!a.disabled&&!a.overrideDisabled).map(a=>a.type)),n=new Set(e.map(a=>a.type));for(const a of OF){const i=txe.get(a);if(!i)continue;const o=n.has(a),l=s.has(a),c=F4.has(a);if(o&&l&&!c){F4.add(a);const d=(vI.get(a)??0)+1;vI.set(a,d);let m=!1;const h=i.parseStdoutLine,p=e.find(f=>f.type===a)?.label??a;ob({type:a,label:p,parseStdoutLine:r((f,g)=>(m||(m=!0,LF(a).then(v=>{v&&vI.get(a)===d&&ob({type:a,label:p,parseStdoutLine:v.parseStdoutLine,createStdoutParser:v.createStdoutParser,ConfigFields:i.ConfigFields,buildAdapterConfig:i.buildAdapterConfig})})),h(f,g)),"parseStdoutLine"),ConfigFields:i.ConfigFields,buildAdapterConfig:i.buildAdapterConfig})}else(!o||!l)&&c&&(F4.delete(a),vI.delete(a),$F(a),ob(i))}for(const{type:a,label:i}of e){if(OF.has(a))continue;const o=mE.get(a);if(o&&o!==OT)continue;let l=!1;const c=o?.parseStdoutLine??OT.parseStdoutLine;ob({type:a,label:i,parseStdoutLine:r((d,m)=>(l||(l=!0,LF(a).then(h=>{h&&ob({type:a,label:i,parseStdoutLine:h.parseStdoutLine,createStdoutParser:h.createStdoutParser,ConfigFields:o?.ConfigFields??nv,buildAdapterConfig:o?.buildAdapterConfig??bw})})),c(d,m)),"parseStdoutLine"),ConfigFields:o?.ConfigFields??nv,buildAdapterConfig:o?.buildAdapterConfig??bw})}}r(zHe,"syncExternalAdapters");function xK(){return[...M2]}r(xK,"listUIAdapters");function BF(e){if(typeof e=="function")return{parseLine:e,reset:null};if(e.createStdoutParser){const s=e.createStdoutParser();return{parseLine:s.parseLine,reset:s.reset}}return{parseLine:e.parseStdoutLine,reset:null}}r(BF,"resolveStdoutParser");function axe(e,s){if((s.kind==="thinking"||s.kind==="assistant")&&s.delta){const n=e[e.length-1];if(n&&n.kind===s.kind&&n.delta&&n.channel===s.channel){n.text+=s.text,n.ts=s.ts;return}}e.push(s)}r(axe,"appendTranscriptEntry");function UHe(e,s){for(const n of s)axe(e,n)}r(UHe,"appendTranscriptEntries");function KHe(e,s=160){return e.length<=s?e:`${e.slice(0,s-3)}...`}r(KHe,"truncateTranscriptLine");function VHe(e){if(e instanceof Error&&e.message)return e.message;if(typeof e=="string"&&e)return e;try{return JSON.stringify(e)}catch{return String(e)}}r(VHe,"formatTranscriptParserError");function WHe(e,s,n,a){const i=VHe(n)||"unknown parser error",o=KHe(e);return{kind:"result",ts:s,text:Ku(`Chat transcript error: ${i}. Falling back for line: ${o}`,a),inputTokens:0,outputTokens:0,cachedTokens:0,costUsd:0,subtype:"transcript_parse_error",isError:!0,errors:[]}}r(WHe,"createTranscriptParseErrorEntry");function gK(e){const{entries:s,line:n,ts:a,parseLine:i,reset:o,redactionOptions:l}=e;try{UHe(s,i(n,a).map(c=>gBe(c,l)))}catch(c){o?.(),axe(s,WHe(n,a,c,l))}}r(gK,"appendParsedTranscriptLine");function ixe(e){const{entries:s,chunks:n,from:a,parseLine:i,reset:o,redactionOptions:l}=e;let c=e.stdoutBuffer;for(let d=a;d<n.length;d+=1){const m=n[d];if(m.stream==="stderr"){s.push({kind:"stderr",ts:m.ts,text:Ku(m.chunk,l)});continue}if(m.stream==="system"){s.push({kind:"system",ts:m.ts,text:Ku(m.chunk,l)});continue}const h=(c+m.chunk).split(/\r?\n/);c=h.pop()??"";for(const p of h){const f=p.trim();f&&gK({entries:s,line:f,ts:m.ts,parseLine:i,reset:o,redactionOptions:l})}}return c}r(ixe,"foldTranscriptChunks");function oxe(e,s,n){const a=[],i={enabled:n?.censorUsernameInLogs??!1},{parseLine:o,reset:l}=BF(s),c=ixe({entries:a,chunks:e,from:0,stdoutBuffer:"",parseLine:o,reset:l,redactionOptions:i}).trim();return c&&gK({entries:a,line:c,ts:e.length>0?e[e.length-1].ts:new Date().toISOString(),parseLine:o,reset:l,redactionOptions:i}),l?.(),a}r(oxe,"buildTranscript");var XY=[];function HHe(e,s){const n={enabled:s?.censorUsernameInLogs??!1},a=typeof e!="function"&&typeof e.createStdoutParser=="function";let i=BF(e),o=[],l="",c=XY,d=[];const m=r(()=>{i=BF(e),o=[],l="",c=XY},"restart"),h=r(f=>{if(f.length<c.length)return!1;for(let g=0;g<c.length;g+=1)if(f[g]!==c[g])return!1;return!0},"extendsFolded"),p=r(f=>{const g=l.trim();if(g&&a)return oxe(f,e,s);const v=o.slice(),y=v.length-1;return y>=0&&(v[y]={...v[y]}),g&&gK({entries:v,line:g,ts:f.length>0?f[f.length-1].ts:new Date().toISOString(),parseLine:i.parseLine,reset:i.reset,redactionOptions:n}),v},"publish");return{update(f){return f===c||(h(f)||m(),l=ixe({entries:o,chunks:f,from:c.length,stdoutBuffer:l,parseLine:i.parseLine,reset:i.reset,redactionOptions:n}),c=f,d=p(f)),d}}}r(HHe,"createIncrementalTranscript");function QHe({agents:e,value:s,onChange:n,disabled:a=!1,excludeAgentIds:i=[],disabledEmptyLabel:o="Reports to: N/A (CEO)",chooseLabel:l="Reports to..."}){const[c,d]=(0,u.useState)(!1),m=new Set(i),h=e.filter(v=>v.status!=="terminated"&&!m.has(v.id)),p=s?e.find(v=>v.id===s):null,f=p?.status==="terminated",g=!!(s&&!p);return(0,t.jsxs)(Zn,{open:c,onOpenChange:d,children:[(0,t.jsx)(ur,{asChild:!0,children:(0,t.jsx)("button",{type:"button",className:U("inline-flex max-w-full min-w-0 items-center gap-1.5 overflow-hidden rounded-md border border-border px-2 py-1 text-xs hover:bg-accent/50 transition-colors",f&&"border-amber-600/45 bg-amber-500/5",a&&"opacity-60 cursor-not-allowed"),disabled:a,children:g?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(yc,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),(0,t.jsx)("span",{className:"min-w-0 truncate text-muted-foreground",children:"Unknown manager (stale ID)"})]}):p?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(gr,{agent:p,size:16,className:"h-3 w-3 shrink-0 text-muted-foreground"}),(0,t.jsx)("span",{className:U("min-w-0 truncate",f&&"text-amber-900 dark:text-amber-200"),children:`Reports to ${p.name}${f?" (terminated)":""}`})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(yc,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),(0,t.jsx)("span",{className:"min-w-0 truncate",children:a?o:l})]})})}),(0,t.jsxs)(Vn,{className:"w-48 p-1",align:"start",children:[(0,t.jsx)("button",{type:"button",className:U("flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50",s===null&&"bg-accent"),onClick:r(()=>{n(null),d(!1)},"onClick"),children:"No manager"}),f&&(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden px-2 py-1.5 text-xs text-muted-foreground border-b border-border mb-0.5",children:[(0,t.jsx)(gr,{agent:p,size:16,className:"shrink-0 h-3 w-3"}),(0,t.jsxs)("span",{className:"min-w-0 truncate",children:["Current: ",p.name," (terminated)"]})]}),g&&(0,t.jsx)("div",{className:"px-2 py-1.5 text-xs text-muted-foreground border-b border-border mb-0.5",children:"Saved manager is missing from this organization. Choose a new manager or clear."}),h.map(v=>(0,t.jsxs)("button",{type:"button",className:U("flex items-center gap-2 w-full min-w-0 px-2 py-1.5 text-xs rounded hover:bg-accent/50 overflow-hidden",v.id===s&&"bg-accent"),onClick:r(()=>{n(v.id),d(!1)},"onClick"),children:[(0,t.jsx)(gr,{agent:v,size:16,className:"shrink-0 h-3 w-3 text-muted-foreground"}),(0,t.jsx)("span",{className:"min-w-0 truncate",children:v.name}),(0,t.jsx)("span",{className:"text-muted-foreground ml-auto shrink-0",children:mK[v.role]??v.role})]},v.id))]})]})}r(QHe,"ReportsToPicker");var GHe="__secret_folder__:";function YHe(e){return!e||e==="active"?null:(0,t.jsx)(lt,{variant:"outline",className:"ml-auto text-(length:--text-nano) font-normal text-muted-foreground",children:e})}r(YHe,"statusBadge");function lxe(e){return e.split("/").filter(s=>s.length>0)}r(lxe,"splitSecretPath$1");function D2(e){return e.join("/")}r(D2,"pathKey$1");function sk(e){return e.length>0?`/${e.join("/")}`:"/"}r(sk,"pathLabel");function JHe(e,s){return e.length<s.length?!1:s.every((n,a)=>e[a]===n)}r(JHe,"pathStartsWith");function ZY(e){return`${GHe}${D2(e)}`}r(ZY,"folderValue");function XHe(e,s,n){const a=s.length,i=new Map,o=[];for(const c of e){const d=lxe(c.name);if(JHe(d,s)){if(d.length>a+1){const m=d.slice(0,a+1),h=D2(m);if(!i.has(h)){const p=m[m.length-1]??"/",f=sk(m);i.set(h,{key:`folder-${h||"root"}`,value:ZY(m),label:p,title:f,searchText:f,kind:"folder",folderPath:h,pathHint:f})}continue}if(d.length===a+1||a===0&&d.length===0){const m=d.at(-1)??c.name;o.push({key:`browse-${c.id}`,value:c.id,label:m,title:c.name,searchText:`${c.key} ${c.name}`,secret:c,status:c.status,kind:"secret",pathHint:c.name,disabled:c.status!=="active"&&c.id!==n})}}}const l=[];if(s.length>0){const c=s.slice(0,-1);l.push({key:`folder-up-${D2(s)}`,value:ZY(c),label:"Up one folder",title:sk(c),searchText:sk(c),kind:"back",folderPath:D2(c),pathHint:sk(c)})}return l.push(...i.values(),...o),{id:"browse-secrets",label:s.length>0?sk(s):"Browse secrets",options:l}}r(XHe,"buildFolderGroup");function bK({secretId:e,secrets:s,recentlyUsedSecrets:n,disabled:a,onSelect:i,onCreateNew:o,triggerClassName:l,disablePortal:c}){const[d,m]=(0,u.useState)(""),h=(0,u.useMemo)(()=>s.find(w=>w.id===e)??null,[s,e]),p=!!e&&!h,f=(0,u.useMemo)(()=>d?d.split("/"):[],[d]),g=(0,u.useMemo)(()=>s.some(w=>lxe(w.name).length>1),[s]),v=(0,u.useMemo)(()=>{const w=[];p&&w.push({id:"current-missing",label:"Current",options:[{key:`missing-${e}`,value:e,label:`Missing secret (${e.slice(0,8)}…)`,title:`Missing secret (${e})`,missing:!0,disabled:!0}]});const S=(n??[]).filter(j=>j.status==="active"&&j.id!==e);return S.length>0&&w.push({id:"recently-used",label:"Recently used",options:S.map(j=>({key:`recent-${j.id}`,value:j.id,label:j.name,title:j.name,searchText:`${j.key} ${j.name}`,secret:j,status:j.status,kind:"secret"}))}),w.push({id:"all-secrets",label:S.length>0?"All secrets":void 0,options:s.map(j=>({key:`all-${j.id}`,value:j.id,label:j.name,title:j.name,searchText:`${j.key} ${j.name}`,secret:j,status:j.status,kind:"secret",disabled:j.status!=="active"&&j.id!==e}))}),w},[p,n,e,s]),y=(0,u.useCallback)((w,S)=>{if(!g||tRe(w))return S;const j=XHe(s,f,e),N=S.filter(_=>_.id==="current-missing"||_.id==="recently-used");return j.options.length>0?[...N,j]:N},[f,g,e,s]);return(0,t.jsx)(_v,{value:e||"",groups:v,onValueChange:r((w,S)=>{if(S.folderPath!==void 0)return m(S.folderPath),!1;m(""),i(w)},"onValueChange"),deriveGroups:y,disabled:a,disablePortal:c,placeholder:"Select secret…",searchPlaceholder:"Search secrets…",emptyMessage:"No matching secrets",triggerClassName:U("h-(--sz-34px) min-h-(--sz-34px) font-mono text-sm",p&&"border-destructive text-destructive",h&&h.status!=="active"&&"border-amber-500/60",l),renderValue:r(w=>{if(!w)return(0,t.jsx)("span",{className:"text-muted-foreground",children:"Select secret…"});if(w.missing)return(0,t.jsxs)("span",{className:"flex w-full min-w-0 items-center gap-1.5 text-destructive",children:[(0,t.jsx)(bi,{className:"size-3.5 shrink-0"}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:w.label})]});const S=w.status&&w.status!=="active";return(0,t.jsxs)("span",{className:"flex w-full min-w-0 items-center gap-1.5",title:w.title,children:[(0,t.jsx)(bi,{className:U("size-3.5 shrink-0",S?"text-amber-600":"text-muted-foreground")}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:w.label}),S?(0,t.jsxs)("span",{className:"text-amber-600",children:["(",w.status,")"]}):null]})},"renderValue"),renderOption:r((w,{selected:S})=>{if(w.kind==="folder"||w.kind==="back"){const j=w.kind==="back"?B3e:Wc;return(0,t.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",title:w.title??w.label,children:[(0,t.jsx)(j,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,t.jsxs)("span",{className:"flex min-w-0 flex-col",children:[(0,t.jsx)("span",{className:U("truncate text-sm",S&&"font-medium"),children:w.label}),w.pathHint?(0,t.jsx)("span",{className:"truncate font-mono text-(length:--text-micro) text-muted-foreground",children:w.pathHint}):null]})]})}return(0,t.jsxs)("span",{className:U("flex min-w-0 flex-1 items-center gap-1.5",w.disabled&&"opacity-60"),title:w.title??w.label,children:[(0,t.jsx)(bi,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,t.jsxs)("span",{className:"flex min-w-0 flex-col",children:[(0,t.jsx)("span",{className:U("min-w-0 truncate font-mono text-sm",S&&"font-medium"),children:w.label}),w.pathHint&&w.pathHint!==w.label?(0,t.jsx)("span",{className:"truncate font-mono text-(length:--text-micro) text-muted-foreground",children:w.pathHint}):null]}),YHe(w.status)]})},"renderOption"),createItem:o?{render:r(w=>(0,t.jsxs)("span",{className:"flex items-center gap-1.5 text-sm",children:[(0,t.jsx)(gn,{className:"size-3.5 shrink-0"}),w.trim()?(0,t.jsxs)("span",{children:["Create secret ",(0,t.jsxs)("span",{className:"font-mono",children:["“",w.trim(),"”"]}),"…"]}):(0,t.jsx)("span",{children:"Create new secret…"})]}),"render"),onSelect:r(w=>o(w),"onSelect")}:void 0})}r(bK,"SecretPicker");var ZHe=/^[a-z][a-z0-9_]*$/,eJ="w-full rounded-md border border-border px-2.5 py-1.5 bg-transparent outline-none text-sm font-mono placeholder:text-muted-foreground/40 focus-visible:ring-2 focus-visible:ring-ring/40";function cxe({mode:e,initialName:s,initialValue:n,existingSecretNames:a,onCancel:i,onSubmit:o}){const[l,c]=(0,u.useState)(s),[d,m]=(0,u.useState)(n),[h,p]=(0,u.useState)(!1),[f,g]=(0,u.useState)(!1),[v,y]=(0,u.useState)(null),[w,S]=(0,u.useState)(!1),j=l.trim(),N=j?ZHe.test(j)?a?.some(T=>T.toLowerCase()===j)?"A secret with this name already exists":null:"Use lowercase letters, digits and _":w?"Name is required":null,_=d.length===0&&w?"Value is required":null,R=!f&&j.length>0&&d.length>0&&!N;async function C(){if(S(!0),!!R){g(!0),y(null);try{await o(j,d)}catch(T){y(T instanceof Error?T.message:"Failed to create secret"),g(!1)}}}r(C,"handleSubmit");const A=e==="create"?"Create & bind":"Store & bind";return(0,t.jsxs)("div",{className:"w-72 space-y-3",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(nRe,{className:"text-sm font-medium",children:e==="create"?"Create secret":"Store value as secret"}),e==="store"?(0,t.jsxs)(sRe,{className:"text-(length:--text-micro) text-muted-foreground",children:["Moves the typed value into an encrypted organization secret and binds"," ",(0,t.jsx)("span",{className:"font-mono",children:s||"this variable"})," to it."]}):null]}),(0,t.jsxs)("label",{className:"block space-y-1",children:[(0,t.jsx)("span",{className:"text-(length:--text-micro) font-medium text-muted-foreground",children:"Name"}),(0,t.jsx)("input",{className:U(eJ,N&&"border-destructive focus-visible:ring-destructive/40"),value:l,autoFocus:!0,spellCheck:!1,placeholder:"secret_name","aria-label":"Secret name","aria-invalid":N?!0:void 0,onChange:r(T=>c(T.target.value),"onChange"),onBlur:r(()=>S(!0),"onBlur"),onKeyDown:r(T=>{T.key==="Enter"&&(T.preventDefault(),C())},"onKeyDown")}),N?(0,t.jsx)("span",{className:"block text-(length:--text-micro) text-destructive",children:N}):null]}),(0,t.jsxs)("label",{className:"block space-y-1",children:[(0,t.jsx)("span",{className:"text-(length:--text-micro) font-medium text-muted-foreground",children:"Value"}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("input",{className:U(eJ,"pr-8",_&&"border-destructive focus-visible:ring-destructive/40"),type:h?"text":"password",value:d,readOnly:e==="store",spellCheck:!1,placeholder:e==="create"?"value":void 0,"aria-label":"Secret value","aria-invalid":_?!0:void 0,onChange:e==="create"?T=>m(T.target.value):void 0}),(0,t.jsx)("button",{type:"button",className:"absolute right-1.5 top-1/2 -translate-y-1/2 rounded p-1 text-muted-foreground hover:text-foreground","aria-label":h?"Hide value":"Show value",onClick:r(()=>p(T=>!T),"onClick"),children:h?(0,t.jsx)(Jm,{className:"h-3.5 w-3.5"}):(0,t.jsx)(hd,{className:"h-3.5 w-3.5"})})]}),_?(0,t.jsx)("span",{className:"block text-(length:--text-micro) text-destructive",children:_}):null]}),v?(0,t.jsx)("p",{className:"text-(length:--text-micro) text-destructive",children:v}):null,(0,t.jsxs)("div",{className:"flex items-center justify-end gap-2 pt-0.5",children:[(0,t.jsx)(F,{type:"button",variant:"ghost",size:"sm",onClick:i,disabled:f,children:"Cancel"}),(0,t.jsxs)(F,{type:"button",size:"sm",onClick:r(()=>{C()},"onClick"),disabled:!R,children:[f?(0,t.jsx)(at,{className:"h-3.5 w-3.5 animate-spin"}):null,A]})]})]})}r(cxe,"SecretPopoverForm");function dxe(e){return(0,t.jsx)(cxe,{mode:"create",...e})}r(dxe,"CreateSecretPopover");function eQe(e){return(0,t.jsx)(cxe,{mode:"store",...e})}r(eQe,"ConvertToSecretPopover");var tQe=/(api[-_]?key|access[-_]?token|auth(?:_?token)?|authorization|bearer|secret|passwd|password|credential|jwt|private[-_]?key|cookie|connectionstring)/i,sQe=[/^sk-[A-Za-z0-9-_]{16,}$/,/^gh[pousr]_[A-Za-z0-9]{20,}$/,/^github_pat_[A-Za-z0-9_]{20,}$/,/^xox[baprs]-[A-Za-z0-9-]{10,}$/,/^AKIA[0-9A-Z]{16}$/,/^AIza[0-9A-Za-z\-_]{20,}$/,/-----BEGIN (?:[A-Z ]+ )?PRIVATE KEY-----/,/^eyJ[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+$/];function nQe(e){return e.length<24||/\s/.test(e)||!/^[A-Za-z0-9+/=_\-.]+$/.test(e)?!1:[/[a-z]/.test(e),/[A-Z]/.test(e),/[0-9]/.test(e)].filter(Boolean).length>=2}r(nQe,"looksHighEntropy");function rQe(e,s){return s?tQe.test(e)||sQe.some(n=>n.test(s))?!0:nQe(s):!1}r(rQe,"isSensitiveEnv");var tJ=0;function aQe(){return tJ+=1,`env-row-${tJ}`}r(aQe,"nextRowId");function ox(e="text"){return{id:aQe(),name:"",source:e,textValue:"",secretId:"",userSecretKey:"",required:!0,version:"latest"}}r(ox,"emptyRow");function iQe(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="secret_ref"}r(iQe,"isSecretRef");function oQe(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="plain"}r(oQe,"isPlainObj");function lQe(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="user_secret_ref"}r(lQe,"isUserSecretRef");function B4(e){return!e||typeof e!="object"?[]:Object.entries(e).map(([s,n])=>{if(typeof n=="string")return{...ox(),name:s,textValue:n};if(iQe(n)){const a=typeof n.version=="number"?n.version:"latest";return{...ox(),name:s,source:"secret",secretId:typeof n.secretId=="string"?n.secretId:"",version:a}}if(lQe(n)){const a=typeof n.version=="number"?n.version:"latest";return{...ox(),name:s,source:"user_secret",userSecretKey:typeof n.key=="string"?n.key:"",required:n.required!==!1,version:a}}return oQe(n)?{...ox(),name:s,source:"text",textValue:typeof n.value=="string"?n.value:""}:{...ox(),name:s}})}r(B4,"rowsFromValue");function L2(e){const s={};for(const n of e){const a=n.name.trim();if(a)if(n.source==="secret"){if(!n.secretId)continue;s[a]={type:"secret_ref",secretId:n.secretId,version:n.version}}else if(n.source==="user_secret"){const i=n.userSecretKey.trim();if(!i)continue;s[a]={type:"user_secret_ref",key:i,version:n.version,required:n.required}}else s[a]={type:"plain",value:n.textValue}}return Object.keys(s).length>0?s:void 0}r(L2,"valueFromRows");var sJ="CLAUDE_CODE_OAUTH_TOKEN";function fj(){return L2([{...ox("user_secret"),name:"CLAUDE_CODE_OAUTH_TOKEN",userSecretKey:"CLAUDE_CODE_OAUTH_TOKEN",required:!0,version:"latest"}])??{}}r(fj,"buildFixedClaudeOAuthBinding");var cQe=/^[A-Za-z_][A-Za-z0-9_]*$/;function dQe(e,s,n){const a=e.trim();if(!a)return null;if(!cQe.test(a))return{level:"error",message:"Invalid name — use letters, digits and _"};if(s.has(a))return{level:"error",message:"Duplicate name"};for(const i of n)if(i&&a.startsWith(i))return{level:"warn",message:"Reserved prefix — provided automatically and may be overridden"};return null}r(dQe,"validateName");function uQe(e){const s=new Map;for(const a of e){const i=a.name.trim();i&&s.set(i,(s.get(i)??0)+1)}const n=new Set;for(const[a,i]of s)i>1&&n.add(a);return n}r(uQe,"computeDuplicateNames");function mQe(e,s){return s===e.source?{kind:"noop"}:s==="secret"?e.textValue.trim()?{kind:"open-store",name:BT(e.name)||"secret",value:e.textValue}:{kind:"to-secret"}:{kind:"to-text",undoFrom:e.secretId?{...e}:null}}r(mQe,"planSourceSwitch");function uxe(e,s){if(e.source!=="secret"||!e.secretId)return null;const n=s.find(a=>a.id===e.secretId);return n?n.status!=="active"?{level:"warn",kind:"disabled",message:"Runs will fail until re-enabled or rebound."}:null:{level:"error",kind:"missing",message:"This secret no longer exists — runs will fail until you rebind."}}r(uxe,"computeRowHealth");function mxe(e,s){if(e.source!=="user_secret"||!e.userSecretKey||!s?.length)return null;const n=s.find(a=>a.key===e.userSecretKey);return n?n.status!=="active"?{level:"warn",kind:"disabled",message:"Runs will fail until this user secret definition is re-enabled or rebound."}:null:{level:"error",kind:"missing",message:"This user secret definition no longer exists — runs will fail until you rebind."}}r(mxe,"computeUserSecretRowHealth");function BT(e){return e.trim().toLowerCase().replace(/[^a-z0-9_]+/g,"_").replace(/^_+|_+$/g,"").slice(0,64)}r(BT,"secretNameFromKey");function _S(e){return e.trim().toUpperCase().replace(/[^A-Z0-9_]+/g,"_").replace(/^_+|_+$/g,"").slice(0,64)}r(_S,"envKeyFromSecretName");var hQe="w-full rounded-md border border-border px-2.5 py-1.5 bg-transparent outline-none text-sm font-mono placeholder:text-muted-foreground/40 focus-visible:ring-2 focus-visible:ring-ring/40",nJ="min-w-0 flex-1 bg-transparent px-2 py-1.5 text-sm font-mono outline-none placeholder:text-muted-foreground/40";function pQe({row:e,isLast:s,secrets:n,userSecretDefinitions:a,recentlyUsedSecrets:i,disabled:o,nameIssue:l,showNameIssue:c,dirtyFields:d,onPatch:m,onRemove:h,onNameBlur:p,onNamePaste:f,onEnterInValueLast:g,onCreateSecret:v,onToast:y,focusRequest:w,onFocusConsumed:S}){const j=(0,u.useRef)(null),N=(0,u.useRef)(null),_=(0,u.useRef)(null),[R,C]=(0,u.useState)(null),[A,T]=(0,u.useState)(!1),[I,$]=(0,u.useState)(null),O=uxe(e,n)??mxe(e,a),L=e.source==="secret"?n.find(te=>te.id===e.secretId)??null:null,E=(a?.length??0)>0,q=e.source==="text"&&!e.sensitiveDismissed&&rQe(e.name,e.textValue);(0,u.useEffect)(()=>{w&&(w==="name"?j.current?.focus():e.source==="text"?N.current?.focus():e.source==="secret"?_.current?.querySelector("[role=combobox]")?.focus():_.current?.querySelector("select,input")?.focus(),S())},[w,S,e.source]),(0,u.useEffect)(()=>{if(!I)return;const te=window.setTimeout(()=>$(null),5e3);return()=>window.clearTimeout(te)},[I]);function B(te){if(te==="user_secret"){if(e.source==="user_secret")return;m({source:"user_secret",secretId:"",version:"latest"}),window.setTimeout(()=>_.current?.querySelector("select,input")?.focus(),0);return}const ae=mQe(e,te);switch(ae.kind){case"noop":return;case"open-store":{const{name:de,value:J}=ae;window.setTimeout(()=>C({mode:"store",name:de,value:J}),0);return}case"to-secret":m({source:"secret",userSecretKey:"",required:!0}),window.setTimeout(()=>{_.current?.querySelector("[role=combobox]")?.focus()},0);return;case"to-text":ae.undoFrom&&$(ae.undoFrom),m({source:"text",secretId:"",userSecretKey:"",required:!0,version:"latest"}),window.setTimeout(()=>N.current?.focus(),0);return}}r(B,"switchSource");async function K(te,ae){const de=await v(te,ae);m({source:"secret",secretId:de.id,userSecretKey:"",required:!0,version:"latest",textValue:""}),y(`Secret ${de.name} created`),C(null)}r(K,"submitSecretPopover");function z(){const te=BT(e.name)||"secret",{textValue:ae}=e;window.setTimeout(()=>C({mode:"store",name:te,value:ae}),0)}r(z,"openStoreAsSecret");const D=e.source==="text"?"Text value":e.source==="secret"?"Organization secret reference":"User secret reference",V=`${e.id}-name-error`,H=`${e.id}-health`,ee=d.name||d.value,X=L?Math.max(0,L.latestVersion):0,le=e.version==="latest"?"latest":`v${e.version}`,ce=e.version!=="latest";return(0,t.jsxs)("div",{className:U("group/row grid grid-cols-(--gtc-13) items-start gap-x-1.5 gap-y-1 rounded-md px-1 py-1","@[40rem]/env:grid-cols-(--gtc-14) @[40rem]/env:items-center",ee&&"bg-amber-500/[0.06] ring-1 ring-amber-500/20"),children:[(0,t.jsx)("div",{className:"col-start-1 row-start-1 min-w-0 @[40rem]/env:row-start-1 @[40rem]/env:self-start",children:(0,t.jsx)("input",{ref:j,className:U(hQe,d.name&&"border-amber-500/70 bg-amber-500/10 focus-visible:ring-amber-500/40",c&&l?.level==="error"&&"border-destructive focus-visible:ring-destructive/40",c&&l?.level==="warn"&&"border-amber-500 focus-visible:ring-amber-500/40"),placeholder:"KEY",value:e.name,spellCheck:!1,disabled:o,"aria-label":"Variable name","aria-invalid":c&&l?.level==="error"?!0:void 0,"aria-describedby":c&&l?V:void 0,onChange:r(te=>m({name:te.target.value}),"onChange"),onBlur:p,onPaste:r(te=>{e.name||f(te.clipboardData.getData("text"))&&te.preventDefault()},"onPaste"),onKeyDown:r(te=>{te.key==="Enter"&&(te.preventDefault(),e.source==="text"?N.current?.focus():_.current?.querySelector("[role=combobox],select,input")?.focus())},"onKeyDown")})}),(0,t.jsxs)("div",{className:"col-span-2 col-start-1 row-start-2 min-w-0 @[40rem]/env:col-span-1 @[40rem]/env:col-start-2 @[40rem]/env:row-start-1",children:[(0,t.jsxs)(Zn,{open:R!==null,onOpenChange:r(te=>{te||C(null)},"onOpenChange"),children:[(0,t.jsx)(uO,{asChild:!0,children:(0,t.jsxs)("div",{ref:_,className:U("relative flex items-stretch overflow-hidden rounded-md border border-border bg-transparent focus-within:ring-2 focus-within:ring-ring/40",d.value&&"border-amber-500/70 bg-amber-500/10 focus-within:ring-amber-500/40",o&&"opacity-60"),children:[(0,t.jsxs)(ba,{children:[(0,t.jsxs)(Wn,{children:[(0,t.jsx)(Hn,{asChild:!0,children:(0,t.jsx)(ga,{asChild:!0,disabled:o,children:(0,t.jsxs)("button",{type:"button","aria-label":"Value source",className:"flex shrink-0 items-center gap-0.5 border-r border-border px-2 text-muted-foreground hover:bg-accent/50 disabled:pointer-events-none",children:[e.source==="text"?(0,t.jsx)(SPe,{className:"size-3.5"}):e.source==="secret"?(0,t.jsx)(bi,{className:"size-3.5"}):(0,t.jsx)(vu,{className:"size-3.5"}),(0,t.jsx)(sn,{className:"size-3 opacity-60"})]})})}),(0,t.jsx)(Qn,{side:"top",children:D})]}),(0,t.jsxs)(va,{align:"start",className:"w-56",children:[(0,t.jsxs)(hs,{className:"flex-col items-start gap-0.5",onSelect:r(()=>B("text"),"onSelect"),children:[(0,t.jsx)("span",{className:"text-sm",children:"Text value"}),(0,t.jsx)("span",{className:"text-(length:--text-micro) text-muted-foreground",children:"Store the value inline as plain text."})]}),(0,t.jsxs)(hs,{className:"flex-col items-start gap-0.5",onSelect:r(()=>B("secret"),"onSelect"),children:[(0,t.jsx)("span",{className:"text-sm",children:"Organization secret"}),(0,t.jsx)("span",{className:"text-(length:--text-micro) text-muted-foreground",children:"Resolve a stored organization secret at run start."})]}),(0,t.jsxs)(hs,{className:"flex-col items-start gap-0.5",onSelect:r(()=>B("user_secret"),"onSelect"),children:[(0,t.jsx)("span",{className:"text-sm",children:"User secret"}),(0,t.jsx)("span",{className:"text-(length:--text-micro) text-muted-foreground",children:"Resolve the responsible user's own value at run start."})]})]})]}),e.source==="text"?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("input",{ref:N,className:nJ,placeholder:"value",value:e.textValue,type:q?"password":"text",spellCheck:!1,disabled:o,"aria-label":"Variable value",onChange:r(te=>m({textValue:te.target.value}),"onChange"),onKeyDown:r(te=>{te.key==="Enter"&&s&&(te.preventDefault(),g())},"onKeyDown")}),q?(0,t.jsxs)("div",{className:"flex shrink-0 items-stretch border-l border-border",children:[(0,t.jsxs)("button",{type:"button",onClick:z,disabled:o,className:"flex items-center gap-1 px-2 text-(length:--text-micro) text-amber-700 hover:bg-amber-500/10 dark:text-amber-400",title:"This value looks sensitive — store it as a secret",children:[(0,t.jsx)(kl,{className:"size-3.5"}),(0,t.jsx)("span",{className:"hidden @[30rem]/env:inline",children:"Store as secret"})]}),(0,t.jsx)("button",{type:"button",onClick:r(()=>m({sensitiveDismissed:!0}),"onClick"),disabled:o,"aria-label":"Dismiss sensitive-value suggestion",title:"Dismiss — keep this value as plain text",className:"flex items-center px-1.5 text-amber-700/60 hover:bg-amber-500/10 hover:text-amber-700 dark:text-amber-400/60 dark:hover:text-amber-400",children:(0,t.jsx)(ir,{className:"size-3"})})]}):null]}):e.source==="secret"?(0,t.jsxs)("div",{className:"relative min-w-0 flex-1",children:[(0,t.jsx)(bK,{secretId:e.secretId,secrets:n,recentlyUsedSecrets:i,disabled:o,onSelect:r(te=>m({secretId:te,version:"latest"}),"onSelect"),onCreateNew:r(te=>C({mode:"create",name:BT(te)||te.trim(),value:""}),"onCreateNew"),triggerClassName:U("rounded-none border-0 bg-transparent shadow-none focus-visible:ring-0",L&&L.status==="active"&&"pr-24 has-[>svg]:!pr-24")}),L&&L.status==="active"?(0,t.jsxs)(Zn,{open:A,onOpenChange:T,children:[(0,t.jsx)(uO,{asChild:!0,children:(0,t.jsx)("button",{type:"button",disabled:o,onClick:r(te=>{te.preventDefault(),te.stopPropagation(),T(ae=>!ae)},"onClick"),"aria-label":"Version",className:U("absolute right-8 top-1/2 z-10 -translate-y-1/2 rounded px-1.5 py-0.5 text-(length:--text-nano) font-medium",ce?"bg-amber-500/15 text-amber-700 dark:text-amber-400":"text-muted-foreground hover:bg-accent"),children:le})}),(0,t.jsxs)(Vn,{align:"end",className:"w-44 p-1",role:"radiogroup","aria-label":"Secret version",children:[(0,t.jsxs)("button",{type:"button",role:"radio","aria-checked":e.version==="latest",onClick:r(()=>{m({version:"latest"}),T(!1)},"onClick"),className:U("flex w-full items-center justify-between rounded px-2 py-1.5 text-sm hover:bg-accent",e.version==="latest"&&"font-medium"),children:["latest ",(0,t.jsx)("span",{className:"text-(length:--text-micro) text-muted-foreground",children:"(recommended)"})]}),Array.from({length:X},(te,ae)=>X-ae).filter(te=>te>0).map(te=>(0,t.jsxs)("button",{type:"button",role:"radio","aria-checked":e.version===te,onClick:r(()=>{m({version:te}),T(!1)},"onClick"),className:U("flex w-full items-center rounded px-2 py-1.5 text-sm hover:bg-accent",e.version===te&&"font-medium text-amber-700 dark:text-amber-400"),children:["v",te]},te))]})]}):null]}):(0,t.jsxs)("div",{className:"grid min-w-0 flex-1 grid-cols-(--gtc-13)",children:[E?(0,t.jsxs)("select",{"aria-label":"User secret",value:e.userSecretKey,disabled:o,onChange:r(te=>{const ae=te.target.value,de=a?.find(J=>J.key===ae);m({userSecretKey:ae,...de&&!e.name.trim()?{name:de.key.toUpperCase()}:{}})},"onChange"),className:"min-w-0 bg-transparent px-2 py-1.5 text-sm font-mono outline-none disabled:pointer-events-none",children:[(0,t.jsx)("option",{value:"",children:"Select user secret..."}),e.userSecretKey&&!a?.some(te=>te.key===e.userSecretKey)?(0,t.jsxs)("option",{value:e.userSecretKey,children:["Unknown (",e.userSecretKey,")"]}):null,(a??[]).map(te=>(0,t.jsxs)("option",{value:te.key,children:[te.name,te.status!=="active"?` (${te.status})`:""]},te.id))]}):(0,t.jsx)("input",{className:nJ,placeholder:"user-secret key",value:e.userSecretKey,spellCheck:!1,disabled:o,"aria-label":"User secret key",onChange:r(te=>m({userSecretKey:te.target.value}),"onChange")}),(0,t.jsxs)("select",{"aria-label":"Requirement",value:e.required?"required":"optional",disabled:o,onChange:r(te=>m({required:te.target.value==="required"}),"onChange"),className:"border-l border-border bg-transparent px-2 py-1.5 text-xs font-medium text-muted-foreground outline-none disabled:pointer-events-none",children:[(0,t.jsx)("option",{value:"required",children:"Required"}),(0,t.jsx)("option",{value:"optional",children:"Optional"})]})]})]})}),(0,t.jsx)(Vn,{align:"start",className:"w-auto p-3",onInteractOutside:r(te=>{const ae=te.detail.originalEvent.target;ae&&_.current?.contains(ae)&&te.preventDefault()},"onInteractOutside"),children:R?.mode==="store"?(0,t.jsx)(eQe,{initialName:R.name,initialValue:R.value,existingSecretNames:n.map(te=>te.name),onCancel:r(()=>C(null),"onCancel"),onSubmit:K}):R?.mode==="create"?(0,t.jsx)(dxe,{initialName:R.name,initialValue:R.value,existingSecretNames:n.map(te=>te.name),onCancel:r(()=>C(null),"onCancel"),onSubmit:K}):null})]}),O?(0,t.jsx)("p",{id:H,role:"status",className:U("mt-0.5 text-(length:--text-micro)",O.level==="error"?"text-destructive":"text-amber-600 dark:text-amber-400"),children:O.message}):null,I?(0,t.jsxs)("p",{className:"mt-0.5 inline-flex items-center gap-2 text-(length:--text-micro) text-muted-foreground",children:["Reverted to text —"," ",(0,t.jsx)("button",{type:"button",className:"font-medium text-foreground underline underline-offset-2 hover:text-primary",onClick:r(()=>{m({source:"secret",secretId:I.secretId,version:I.version,textValue:""}),$(null)},"onClick"),children:"Undo"})]}):null]}),c&&l?(0,t.jsx)("p",{id:V,className:U("col-span-2 col-start-1 row-start-3 min-w-0 text-(length:--text-micro) @[40rem]/env:col-span-2 @[40rem]/env:row-start-2",l.level==="error"?"text-destructive":"text-amber-600 dark:text-amber-400"),children:l.message}):null,(0,t.jsxs)("div",{className:"col-start-2 row-start-1 flex items-center justify-end gap-0.5 self-start @[40rem]/env:col-start-3 @[40rem]/env:self-center",children:[e.source==="text"&&!q&&(e.name.trim()||e.textValue)?(0,t.jsxs)(ba,{children:[(0,t.jsx)(ga,{asChild:!0,disabled:o,children:(0,t.jsx)("button",{type:"button","aria-label":"More actions",className:"rounded p-1 text-muted-foreground opacity-100 hover:bg-accent hover:text-foreground @[40rem]/env:opacity-0 @[40rem]/env:group-hover/row:opacity-100 @[40rem]/env:group-focus-within/row:opacity-100",children:(0,t.jsx)(Ti,{className:"size-4"})})}),(0,t.jsx)(va,{align:"end",children:(0,t.jsx)(hs,{onSelect:r(()=>{window.setTimeout(z,0)},"onSelect"),children:"Store as secret…"})})]}):null,(0,t.jsx)("button",{type:"button",onClick:h,disabled:o,"aria-label":`Remove ${e.name.trim()||"variable"}`,className:"rounded p-1 text-muted-foreground opacity-100 hover:bg-destructive/10 hover:text-destructive @[40rem]/env:opacity-0 @[40rem]/env:group-hover/row:opacity-100 @[40rem]/env:group-focus-within/row:opacity-100",children:(0,t.jsx)(ir,{className:"size-4"})})]})]})}r(pQe,"EnvironmentVariableRow");var fQe=/^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=(.*)$/;function xQe(e){const s=e.indexOf(" #");return s>=0?e.slice(0,s):e}r(xQe,"stripInlineComment");function gQe(e){const s=e.trim();if(s.length>=2){const n=s[0],a=s[s.length-1];if(n==='"'&&a==='"'||n==="'"&&a==="'")return s.slice(1,-1)}return xQe(s).trim()}r(gQe,"unquote");function bQe(e){const s=[];for(const n of e.split(/\r?\n/)){const a=n.trim();if(!a||a.startsWith("#"))continue;const i=fQe.exec(a);if(!i)continue;const o=i[1],l=gQe(i[2]);s.push({key:o,value:l})}return s}r(bQe,"parseDotenv");var vQe=["PAPERCLIP_"],yQe="Set the KEY to the env var name the process expects, for example GH_TOKEN. Choose a secret to resolve a stored value at run start. PAPERCLIP_* variables are injected automatically.";function qF(e){if(!e||typeof e!="object")return[];const s=new Map;for(const[n,a]of Object.entries(e)){const i=n.trim();if(i)if(typeof a=="string")s.set(i,{type:"plain",value:a});else if(a?.type==="secret_ref"){const o=typeof a.secretId=="string"?a.secretId:"";if(!o)continue;s.set(i,{type:"secret_ref",secretId:o,version:typeof a.version=="number"?a.version:"latest"})}else if(a?.type==="user_secret_ref"){const o=typeof a.key=="string"?a.key.trim():"";if(!o)continue;s.set(i,{type:"user_secret_ref",key:o,version:typeof a.version=="number"?a.version:"latest",required:a.required!==!1})}else a?.type==="plain"?s.set(i,{type:"plain",value:typeof a.value=="string"?a.value:""}):s.set(i,{type:"plain",value:""})}return[...s.entries()].sort(([n],[a])=>n.localeCompare(a))}r(qF,"normalizedEnvEntries");function nk(e){return JSON.stringify(qF(e))}r(nk,"normalizedEnvKey");var q4=3;function z4(e){const s=e.slice(0,q4).join(", ");return e.length>q4?`${s} +${e.length-q4} more`:s}r(z4,"formatChangedNames");function rJ(e){return e.map(s=>({...s}))}r(rJ,"cloneRows");function jQe(e,s){return s?{name:e.name.trim()!==s.name.trim(),value:e.source!==s.source||e.textValue!==s.textValue||e.secretId!==s.secretId||e.userSecretKey!==s.userSecretKey||e.required!==s.required||e.version!==s.version}:{name:!!e.name.trim(),value:e.source!=="text"||!!e.textValue||!!e.secretId||e.version!=="latest"}}r(jQe,"rowDirtyFields");var rv=(0,u.forwardRef)(r(function({value:s,onChange:n,secrets:a,userSecretDefinitions:i,onCreateSecret:o,recentlyUsedSecrets:l,disabled:c,reservedPrefixes:d=vQe,footerHint:m,onDirtyChange:h,hideDraftActions:p=!1},f){const g=_c(),v=(0,u.useRef)(null),[y,w]=(0,u.useState)(()=>B4(s)),S=(0,u.useRef)(y),[j,N]=(0,u.useState)(()=>rJ(y)),_=(0,u.useMemo)(()=>nk(s),[]),R=(0,u.useRef)(_),C=(0,u.useRef)(_),A=(0,u.useRef)(null),[T,I]=(0,u.useState)(_),[$,O]=(0,u.useState)(()=>new Set(B4(s).map(oe=>oe.name.trim()).filter(Boolean))),[L,E]=(0,u.useState)(null);(0,u.useEffect)(()=>{S.current=y},[y]);function q(oe,ye=S.current){R.current=oe,I(oe),N(rJ(ye))}r(q,"markCommitted");function B(oe){O(ye=>{const Ae=new Set(ye);for(const xe of oe){const _e=xe.name.trim();_e&&Ae.add(_e)}return Ae})}r(B,"touchCommittedNames");function K(oe){const ye=B4(oe);return w(ye),B(ye),ye}r(K,"adoptExternalValue"),(0,u.useEffect)(()=>{const oe=nk(s);if(oe===C.current)return;C.current=oe;const ye=nk(L2(S.current)),Ae=ye!==R.current,xe=A.current===oe;if(xe&&(A.current=null),!Ae){q(oe,K(s));return}(xe||ye===oe)&&(B(S.current),q(oe))},[s]);const z=(0,u.useMemo)(()=>L2(y),[y]),D=(0,u.useMemo)(()=>nk(z),[z]),V=D!==T;(0,u.useEffect)(()=>{h?.(!c&&V)},[c,V,h]);const H=(0,u.useMemo)(()=>{const oe=new Map(qF(L2(j)).map(([_e,Ge])=>[_e,JSON.stringify(Ge)])),ye=new Map(qF(z).map(([_e,Ge])=>[_e,JSON.stringify(Ge)])),Ae=[],xe=[];for(const[_e,Ge]of ye)oe.has(_e)?oe.get(_e)!==Ge&&xe.push(_e):Ae.push(_e);return{added:Ae,changed:xe,removed:[...oe.keys()].filter(_e=>!ye.has(_e))}},[j,z]),ee=(0,u.useMemo)(()=>{const oe=[];return H.added.length>0&&oe.push(`New: ${z4(H.added)}`),H.changed.length>0&&oe.push(`Edited: ${z4(H.changed)}`),H.removed.length>0&&oe.push(`Removed: ${z4(H.removed)}`),oe.join(" · ")},[H]);(0,u.useEffect)(()=>{if(c||!V)return;function oe(ye){ye.preventDefault(),ye.returnValue=""}return r(oe,"handleBeforeUnload"),window.addEventListener("beforeunload",oe),()=>window.removeEventListener("beforeunload",oe)},[c,V]);const X=(0,u.useCallback)(()=>c||!V?null:(A.current=D,(0,Jp.flushSync)(()=>{n(z)}),z??{}),[c,z,D,V,n]);(0,u.useImperativeHandle)(f,()=>({flushPendingDraft:X}),[X]),(0,u.useEffect)(()=>{const oe=v.current?.closest("form");if(!oe)return;function ye(){X()}return r(ye,"handleSubmit"),oe.addEventListener("submit",ye,!0),()=>oe.removeEventListener("submit",ye,!0)},[X]),(0,u.useEffect)(()=>{const oe=v.current;if(!oe)return;const ye=oe;function Ae(xe){const _e=xe.target;if(!(_e instanceof Element)||ye.contains(_e))return;const Ge=_e.closest("button");if(!Ge||Ge.disabled)return;const $e=`${Ge.getAttribute("aria-label")??""} ${Ge.textContent??""}`;(Ge.type==="submit"||/\b(save|create|update|test|import)\b/i.test($e))&&X()}return r(Ae,"handleDocumentClick"),document.addEventListener("click",Ae,!0),()=>document.removeEventListener("click",Ae,!0)},[X]);function le(oe){w(oe)}r(le,"updateDraft");function ce(oe,ye){le(y.map(Ae=>Ae.id===oe?{...Ae,...ye}:Ae))}r(ce,"patchRow");function te(oe){le(y.filter(ye=>ye.id!==oe))}r(te,"removeRow");function ae(){const oe=ox();w([...y,oe]),E({rowId:oe.id,field:"name"})}r(ae,"addRow");function de(oe){const ye=y.find(Ae=>Ae.id===oe)?.name.trim();ye&&O(Ae=>{if(Ae.has(ye))return Ae;const xe=new Set(Ae);return xe.add(ye),xe})}r(de,"markTouched");function J(oe,ye){const Ae=bQe(oe);if(Ae.length===0)return!1;const xe=y.filter(_e=>_e.id!==ye).map(_e=>({..._e}));for(const{key:_e,value:Ge}of Ae){const $e=xe.find(Ye=>Ye.name.trim()===_e);$e?($e.name=_e,$e.source="text",$e.textValue=Ge,$e.secretId="",$e.sensitiveDismissed=!1,$e.userSecretKey="",$e.required=!0):xe.push({...ox(),name:_e,textValue:Ge})}return le(xe),g?.pushToast({title:`Imported ${Ae.length} variable${Ae.length===1?"":"s"}`,tone:"success"}),!0}r(J,"bulkImport");function Y(oe){const ye=y.map(_e=>({..._e})),Ae=ye[ye.length-1];let xe;Ae&&!Ae.name&&!Ae.textValue&&!Ae.secretId&&!Ae.userSecretKey?xe=Ae:(xe=ox(),ye.push(xe)),xe.source="secret",xe.secretId=oe.id,xe.version="latest",xe.name||(xe.name=_S(oe.name)),le(ye)}r(Y,"bindRecentSecret");function G(){V&&(A.current=D,n(z))}r(G,"saveDraft");function fe(){A.current=null,C.current=nk(s);const oe=K(s);q(C.current,oe)}r(fe,"revertDraft");const se=(0,u.useMemo)(()=>uQe(y),[y]),re=(0,u.useMemo)(()=>y.reduce((oe,ye)=>uxe(ye,a)||mxe(ye,i)?oe+1:oe,0),[y,a,i]),ie=(0,u.useMemo)(()=>{const oe=new Set(y.filter(ye=>ye.source==="secret"&&ye.secretId).map(ye=>ye.secretId));return(l??[]).filter(ye=>ye.status==="active"&&!oe.has(ye.id)).slice(0,8)},[l,y]),me=y.length>0,pe=m===void 0?yQe:m,be=(0,u.useMemo)(()=>new Map(j.map(oe=>[oe.id,oe])),[j]);return(0,t.jsx)(pd,{children:(0,t.jsxs)("div",{ref:v,className:"@container/env space-y-2",children:[re>1?(0,t.jsxs)("p",{className:"inline-flex items-center gap-1.5 text-(length:--text-micro) font-medium text-amber-700 dark:text-amber-400",children:[(0,t.jsx)(zi,{className:"size-3.5"}),re," bindings need attention"]}):null,me?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"hidden gap-x-1.5 @[40rem]/env:grid @[40rem]/env:grid-cols-(--gtc-14)",children:[(0,t.jsx)("span",{className:"text-(length:--text-micro) font-medium uppercase tracking-wide text-muted-foreground",children:"Name"}),(0,t.jsx)("span",{className:"text-(length:--text-micro) font-medium uppercase tracking-wide text-muted-foreground",children:"Value"}),(0,t.jsx)("span",{})]}),y.map((oe,ye)=>{const Ae=dQe(oe.name,se,d),xe=$.has(oe.name.trim());return(0,t.jsx)(pQe,{row:oe,isLast:ye===y.length-1,secrets:a,userSecretDefinitions:i,recentlyUsedSecrets:l,disabled:c,nameIssue:Ae,showNameIssue:xe,dirtyFields:jQe(oe,be.get(oe.id)),onPatch:r(_e=>ce(oe.id,_e),"onPatch"),onRemove:r(()=>te(oe.id),"onRemove"),onNameBlur:r(()=>de(oe.id),"onNameBlur"),onNamePaste:r(_e=>J(_e,oe.id),"onNamePaste"),onEnterInValueLast:ae,onCreateSecret:o,onToast:r(_e=>g?.pushToast({title:_e,tone:"success"}),"onToast"),focusRequest:L?.rowId===oe.id?L.field:null,onFocusConsumed:r(()=>E(null),"onFocusConsumed")},oe.id)})]}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"No environment variables"}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 pt-1",children:[(0,t.jsxs)("button",{type:"button",onClick:ae,disabled:c,className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:pointer-events-none disabled:opacity-50",children:[(0,t.jsx)(gn,{className:"size-3.5"}),"Add variable"]}),ie.length>0&&!c?(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 text-(length:--text-micro) text-muted-foreground/70",children:[(0,t.jsx)(bi,{className:"size-3"}),"Recently used:"]}),ie.map(oe=>(0,t.jsxs)("button",{type:"button",onClick:r(()=>Y(oe),"onClick"),className:"inline-flex items-center gap-1 rounded-full border border-border px-2 py-0.5 font-mono text-(length:--text-micro) text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",title:`Bind ${oe.name}`,children:["+ ",oe.name]},oe.id))]}):null]}),V&&!c&&!p?(0,t.jsxs)("div",{role:"status",className:"mt-3 flex w-full flex-col gap-3 rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-3 text-amber-950 shadow-sm dark:bg-amber-500/15 dark:text-amber-100 @[34rem]/env:flex-row @[34rem]/env:items-center @[34rem]/env:justify-between",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium",children:[(0,t.jsx)("span",{className:"size-2 rounded-full bg-amber-500 shadow-(--shadow-extract-13)"}),(0,t.jsx)("span",{children:"Unsaved changes"})]}),ee?(0,t.jsx)("p",{className:"min-w-0 truncate pl-4 text-xs text-amber-950/80 dark:text-amber-100/80",title:ee,children:ee}):null]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("button",{type:"button",onClick:fe,className:"inline-flex h-9 items-center gap-1.5 rounded-md border border-amber-500/30 bg-background px-3 text-sm font-medium text-foreground transition-colors hover:bg-amber-500/10 dark:bg-background/80",children:[(0,t.jsx)(ki,{className:"size-4"}),"Revert"]}),(0,t.jsxs)("button",{type:"button",onClick:G,className:"inline-flex h-9 items-center gap-1.5 rounded-md bg-primary px-4 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90",children:[(0,t.jsx)(Qp,{className:"size-4"}),"Save"]})]})]}):null,pe?(0,t.jsx)("p",{className:"text-(length:--text-micro) text-muted-foreground/70",children:pe}):null,y.some(oe=>oe.source==="user_secret"&&oe.userSecretKey)?(0,t.jsxs)("p",{className:"inline-flex items-start gap-1 text-(length:--text-micro) text-muted-foreground/70",children:[(0,t.jsx)(vu,{className:"mt-0.5 size-3 shrink-0"}),(0,t.jsx)("span",{children:"User secrets resolve from the user responsible for the run. Required bindings fail until that user sets their value under Secrets → My secrets."})]}):null]})})},"EnvironmentVariablesEditor")),wQe="env.",B1="access.",zF=/^[A-Za-z_][A-Za-z0-9_]*$/;function hxe(e){return e?e.startsWith("access.")?"api":e.startsWith("env.")?"env":"config":"config"}r(hxe,"deliveryModeForConfigPath");function pxe(e){switch(e){case"env":return"Env var";case"api":return"API access";default:return"Config"}}r(pxe,"deliveryModeLabel");function NQe(e){switch(e){case"env":return"Injected as an environment variable at run start.";case"api":return"Fetched on demand via the run-bound agent API. Never written to the environment.";default:return"Provided through adapter configuration."}}r(NQe,"deliveryModeDescription");function fxe(e){return e?e.startsWith("access.")?e.slice(7):e.startsWith("env.")?e.slice(4):e:""}r(fxe,"aliasFromConfigPath");function kQe(e){switch(e){case"agent_api":return"Agent API";case"plugin_worker":return"Plugin worker";case"tool_connection":return"Tool connection";default:return e.charAt(0).toUpperCase()+e.slice(1)}}r(kQe,"consumerTypeLabel");var SQe={numeric:!0,sensitivity:"base"};function Uk(e){return e.kind==="company"?e.secret.name:e.definition.name}r(Uk,"getSecretPathRowName");function Nw(e){return e.split("/").filter(s=>s.length>0)}r(Nw,"splitSecretPath");function U4(e){return Nw(e).join("/")}r(U4,"normalizeSecretPath");function aJ(e,s){return s.every((n,a)=>e[a]===n)}r(aJ,"startsWithSegments");function iJ(e,s){return e.localeCompare(s,void 0,SQe)}r(iJ,"compareNames");function CQe(e,s){const n=Nw(s),a=e.map(c=>({row:c,name:Uk(c),segments:Nw(Uk(c))})),i=new Set,o=[];for(const c of a){if(!aJ(c.segments,n))continue;const d=c.segments.length-n.length;(d===0||d===1)&&o.push(c.row),d>=2&&i.add(c.segments[n.length])}const l=[...i].map(c=>{const d=[...n,c],m=new Set;let h=0;for(const p of a){if(!aJ(p.segments,d))continue;const f=p.segments.length-d.length;if(!(f<1)){h+=1;for(let g=1;g<f;g+=1)m.add(p.segments.slice(d.length,d.length+g).join("/"))}}return{name:c,path:d.join("/"),secretCount:h,folderCount:m.size}});return l.sort((c,d)=>iJ(c.name,d.name)),o.sort((c,d)=>iJ(Uk(c),Uk(d))),{folders:l,secrets:o}}r(CQe,"buildSecretPathListing");function _Qe(e){const s=Nw(e);return s.map((n,a)=>({name:n,path:s.slice(0,a+1).join("/")}))}r(_Qe,"buildSecretPathBreadcrumbs");function IQe(e){return e.trim()?e.includes("/")?"Folder name cannot contain slashes.":null:"Folder name is required."}r(IQe,"validateSecretFolderSegment");function vC({name:e,basePath:s="",className:n,leafClassName:a}){const i=Nw(e),o=Nw(s),l=o.length>0&&o.every((h,p)=>i[p]===h)&&i.length>o.length?i.slice(o.length):i,c=l.length>0?l:[e],d=c[c.length-1],m=c.slice(0,-1).join("/");return(0,t.jsxs)("span",{className:U("min-w-0 truncate",n),children:[m?(0,t.jsxs)("span",{className:"text-muted-foreground",children:[m,"/"]}):null,(0,t.jsx)("span",{className:U("font-medium text-foreground",a),children:d})]})}r(vC,"SecretPathName");function AQe(e,s){const n=e?`sha256:${e.slice(0,10)}…`:"no fingerprint",a=typeof s=="number"?`${s} ${s===1?"byte":"bytes"}`:null;return a?`${n} · ${a}`:n}r(AQe,"fingerprintLabel");function xxe({fingerprint:e,length:s,className:n}){const{pushToast:a}=pa(),i=AQe(e,s);if(!e)return(0,t.jsxs)("span",{className:U("inline-flex items-center gap-1 font-mono",n),children:[(0,t.jsx)(NH,{className:"size-3 shrink-0"}),i]});const o=`sha256:${e}`;return(0,t.jsxs)("button",{type:"button",onClick:r(()=>{Yr(o).then(()=>a({title:"Fingerprint copied",tone:"success"})).catch(()=>a({title:"Couldn’t copy fingerprint",tone:"error"}))},"onClick"),title:`Copy full digest — ${o}`,className:U("inline-flex items-center gap-1 font-mono hover:text-foreground",n),children:[(0,t.jsx)(NH,{className:"size-3 shrink-0"}),i,(0,t.jsx)(Nr,{className:"size-3 shrink-0 opacity-60"})]})}r(xxe,"FingerprintChip");function vK({justification:e,className:s}){return(0,t.jsxs)("div",{className:U("space-y-0.5",s),children:[(0,t.jsx)("p",{className:"text-(length:--text-micro) text-muted-foreground",children:"Reason given by the agent"}),(0,t.jsxs)("p",{className:"whitespace-pre-wrap break-words text-xs text-foreground/80",children:["“",e,"”"]})]})}r(vK,"ProposalJustification");function yC({agent:e,className:s}){return(0,t.jsxs)("span",{className:U("inline-flex min-w-0 items-center gap-1",s),children:[(0,t.jsx)(gr,{agent:e,size:16,className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,t.jsx)("span",{className:"min-w-0 truncate",children:e.name})]})}r(yC,"AgentRefChip");function yK({configPath:e}){const s=hxe(e),n=s==="env",a=s==="api";return(0,t.jsxs)(lt,{variant:"outline",className:U("h-5 gap-1 px-1.5 text-(length:--text-nano) font-normal",n&&"border-sky-500/30 bg-sky-500/10 text-sky-700 dark:text-sky-300",a&&"border-violet-500/30 bg-violet-500/10 text-violet-700 dark:text-violet-300",!n&&!a&&"border-border bg-muted/40 text-muted-foreground"),children:[n?(0,t.jsx)(sue,{className:"size-3"}):a?(0,t.jsx)(E5,{className:"size-3"}):null,pxe(s)]})}r(yK,"DeliveryBadge$1");function jK({className:e}){return(0,t.jsxs)(lt,{variant:"outline",className:U("h-5 gap-1 px-1.5 text-(length:--text-nano) font-medium","border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-300",e),children:[(0,t.jsx)(kl,{className:"size-3"})," Proposed"]})}r(jK,"ProposedBadge");function hE(e){return fxe(e.configPath)}r(hE,"bindingEnvKey");function wK(e){return e.secretProposalId?{name:e.secretProposalName??"proposed secret",pending:!0}:{name:e.secretName??"secret",pending:!1}}r(wK,"bindingSecretLabel");function oJ(e){return e instanceof wn?e.message||`Request failed: ${e.status}`:e instanceof Error?e.message:"Something went wrong. Try again."}r(oJ,"readableError");function gxe(e,s=[]){const n=Wt(),{pushToast:a}=pa(),[i,o]=(0,u.useState)(null),[l,c]=(0,u.useState)(null),[d,m]=(0,u.useState)(""),[h,p]=(0,u.useState)(null),f=(0,u.useCallback)(()=>{e&&(n.invalidateQueries({queryKey:["secret-proposals",e]}),n.invalidateQueries({queryKey:P.secrets.list(e)}))},[e,n]),g=Ne({mutationFn:r(j=>{const{proposal:N}=j;if(N.kind==="secret"){const _=j.folder.trim()?`${j.folder.trim().replace(/\/+$/,"")}/${j.leaf.trim()}`:j.leaf.trim();return fr.approveProposal(e,N.id,{overrides:{name:_,description:j.description.trim()||null,providerConfigId:j.providerConfigId||null}})}return fr.approveProposal(e,N.id,{cascade:j.cascade||void 0})},"mutationFn"),onSuccess:r(j=>{a({title:j.kind==="secret"?"Secret approved":"Binding approved",body:j.kind==="secret"?j.proposedName??"Secret created":`${j.target?.name??"Agent"} · ${hE(j)||"binding"}`,tone:"success"}),o(null),p(null),f()},"onSuccess"),onError:r(j=>p(oJ(j)),"onError")}),v=Ne({mutationFn:r(({proposal:j,reason:N})=>fr.rejectProposal(e,j.id,{reason:N.trim()}),"mutationFn"),onSuccess:r(j=>{a({title:"Proposal rejected",body:j.kind==="secret"?j.proposedName??void 0:void 0,tone:"info"}),c(null),m(""),p(null),f()},"onSuccess"),onError:r(j=>p(oJ(j)),"onError")}),y=(0,u.useCallback)(j=>{p(null);const N=(j.proposedName??"").split("/"),_=N.pop()??"";o({proposal:j,folder:N.join("/"),leaf:_,description:j.proposedDescription??"",providerConfigId:s.find(R=>R.provider==="local_encrypted"&&R.isDefault)?.id??"",cascade:!!j.secretProposalId})},[s]),w=(0,u.useCallback)(j=>{p(null),m(""),c(j)},[]),S=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(RQe,{draft:i,error:h,pending:g.isPending,providerConfigs:s,onChange:o,onCancel:r(()=>{o(null),p(null)},"onCancel"),onConfirm:r(()=>i&&g.mutate(i),"onConfirm")}),(0,t.jsx)(EQe,{proposal:l,reason:d,error:h,pending:v.isPending,onReasonChange:m,onCancel:r(()=>{c(null),m(""),p(null)},"onCancel"),onConfirm:r(()=>l&&v.mutate({proposal:l,reason:d}),"onConfirm")})]});return{requestApprove:y,requestReject:w,isBusy:g.isPending||v.isPending,dialogs:S}}r(gxe,"useProposalReview");function RQe({draft:e,error:s,pending:n,providerConfigs:a,onChange:i,onCancel:o,onConfirm:l}){const c=e?.proposal.kind==="secret",d=e?e.folder.trim()?`${e.folder.trim().replace(/\/+$/,"")}/${e.leaf.trim()}`:e.leaf.trim():"",m=a.filter(p=>p.provider==="local_encrypted"),h=c?!!(e&&e.leaf.trim()):!0;return(0,t.jsx)(Ys,{open:!!e,onOpenChange:r(p=>!p&&o(),"onOpenChange"),children:(0,t.jsx)(Js,{className:"sm:max-w-lg",children:e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(Cn,{children:[(0,t.jsx)(tn,{children:c?"Approve & create secret":"Approve binding"}),(0,t.jsx)(Ln,{children:c?"The value is created as the proposing agent recorded it. Re-folder or rename it before it lands.":"Grant the target agent access to this secret. This runs with your permissions."})]}),(0,t.jsxs)("div",{className:"space-y-1.5 rounded-md border border-border bg-muted/30 p-2.5 text-xs",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[(0,t.jsx)("span",{children:"Proposed by"}),(0,t.jsx)(yC,{agent:e.proposal.proposedBy,className:"font-medium text-foreground"})]}),(0,t.jsx)(vK,{justification:e.proposal.justification})]}),c?(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(Qs,{htmlFor:"approve-folder",children:"Folder"}),(0,t.jsx)(At,{id:"approve-folder",value:e.folder,onChange:r(p=>i({...e,folder:p.target.value}),"onChange"),placeholder:"dev/github",className:"font-mono text-xs"})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(Qs,{htmlFor:"approve-name",children:"Name"}),(0,t.jsx)(At,{id:"approve-name",value:e.leaf,onChange:r(p=>i({...e,leaf:p.target.value}),"onChange"),placeholder:"client-secret",autoFocus:!0,"aria-invalid":!e.leaf.trim(),className:"font-mono text-xs"})]})]}),(0,t.jsxs)("p",{className:"text-(length:--text-micro) text-muted-foreground",children:["Lands as"," ",d?(0,t.jsx)(vC,{name:d,className:"font-mono"}):(0,t.jsx)("span",{className:"italic",children:"enter a name"})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(Qs,{htmlFor:"approve-description",children:"Description"}),(0,t.jsx)(At,{id:"approve-description",value:e.description,onChange:r(p=>i({...e,description:p.target.value}),"onChange"),placeholder:"Optional"})]}),m.length>0?(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(Qs,{htmlFor:"approve-provider-config",children:"Provider vault"}),(0,t.jsxs)("select",{id:"approve-provider-config",value:e.providerConfigId,onChange:r(p=>i({...e,providerConfigId:p.target.value}),"onChange"),className:"h-9 w-full rounded-md border border-input bg-transparent px-2 text-sm outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50",children:[(0,t.jsx)("option",{value:"",children:"Deployment default"}),m.map(p=>(0,t.jsx)("option",{value:p.id,children:p.displayName},p.id))]})]}):null,(0,t.jsx)("div",{className:"rounded-md border border-border bg-background px-2.5 py-1.5 text-xs text-muted-foreground",children:(0,t.jsx)(xxe,{fingerprint:e.proposal.valueFingerprintSha256,length:e.proposal.valueLength})})]}):(0,t.jsx)(TQe,{draft:e,onChange:i}),s?(0,t.jsx)("p",{className:"text-xs text-destructive",role:"alert",children:s}):null,(0,t.jsxs)(yr,{children:[(0,t.jsx)(F,{variant:"ghost",onClick:o,disabled:n,children:"Cancel"}),(0,t.jsx)(F,{onClick:l,disabled:n||!h,children:n?"Approving…":c?"Approve & create":e.cascade?"Approve secret & bind":"Approve binding"})]})]}):null})})}r(RQe,"ApproveDialog");function TQe({draft:e,onChange:s}){const{proposal:n}=e,a=wK(n),i=hE(n);return(0,t.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,t.jsxs)("div",{className:"space-y-2 rounded-md border border-border p-3",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"Target agent"}),n.target?(0,t.jsx)(yC,{agent:n.target,className:"text-sm font-medium"}):(0,t.jsx)("span",{className:"text-muted-foreground",children:"—"})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"Delivered as"}),(0,t.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,t.jsx)(yK,{configPath:n.configPath}),(0,t.jsx)("code",{className:"font-mono text-xs",children:i||n.configPath})]})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"Secret"}),(0,t.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,t.jsx)(bi,{className:"size-3.5 text-muted-foreground"}),(0,t.jsx)("span",{className:"font-medium",children:a.name}),a.pending?(0,t.jsx)(jK,{}):null]})]})]}),n.secretProposalId?(0,t.jsxs)("label",{className:"flex items-start gap-2 rounded-md border border-amber-500/30 bg-amber-500/5 p-2.5 text-xs",children:[(0,t.jsx)($i,{checked:e.cascade,onCheckedChange:r(o=>s({...e,cascade:o===!0}),"onCheckedChange"),className:"mt-0.5","aria-label":"Also approve the proposed secret"}),(0,t.jsxs)("span",{className:"text-foreground/90",children:["Also approve the proposed secret"," ",(0,t.jsx)("span",{className:"font-medium",children:a.name})," and create it in the same step. The binding can’t land without it."]})]}):null]})}r(TQe,"BindingApproveBody");function EQe({proposal:e,reason:s,error:n,pending:a,onReasonChange:i,onCancel:o,onConfirm:l}){const c=s.trim().length>0;return(0,t.jsx)(Ys,{open:!!e,onOpenChange:r(d=>!d&&o(),"onOpenChange"),children:(0,t.jsx)(Js,{className:"sm:max-w-md",children:e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(Cn,{children:[(0,t.jsx)(tn,{children:"Reject proposal"}),(0,t.jsxs)(Ln,{children:["The reason is sent back to"," ",(0,t.jsx)(yC,{agent:e.proposedBy,className:"text-foreground"}),". Dependent bindings are rejected too."]})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(Qs,{htmlFor:"reject-reason",children:"Reason"}),(0,t.jsx)(Dn,{id:"reject-reason",value:s,onChange:r(d=>i(d.target.value),"onChange"),rows:3,autoFocus:!0,placeholder:"Why is this being rejected?"})]}),n?(0,t.jsx)("p",{className:"text-xs text-destructive",role:"alert",children:n}):null,(0,t.jsxs)(yr,{children:[(0,t.jsx)(F,{variant:"ghost",onClick:o,disabled:a,children:"Cancel"}),(0,t.jsx)(F,{variant:"destructive",onClick:l,disabled:a||!c,children:a?"Rejecting…":"Reject"})]})]}):null})})}r(EQe,"RejectDialog");function bxe({proposal:e,onApprove:s,onReject:n,disabled:a,size:i="sm"}){const o=!e.viewerCanApprove,l=i==="xs"?"h-7 px-2 text-xs":"",c=(0,t.jsx)(F,{size:"sm",className:l,disabled:a||o,onClick:r(()=>s(e),"onClick"),children:"Approve"});return(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[o?(0,t.jsx)(pd,{children:(0,t.jsxs)(Wn,{children:[(0,t.jsx)(Hn,{asChild:!0,children:(0,t.jsx)("span",{tabIndex:0,children:c})}),(0,t.jsx)(Qn,{className:"max-w-72",children:e.approveBlockReason??"You don’t have permission to approve this."})]})}):c,(0,t.jsx)(F,{size:"sm",variant:"outline",className:l,disabled:a,onClick:r(()=>n(e),"onClick"),children:"Reject"})]})}r(bxe,"ProposalActions");function vxe(e){return typeof e!="object"||e===null||Array.isArray(e)?null:e}r(vxe,"asRecord$15");function yxe(e){const s=vxe(e);if(!s||s.type!=="secret_ref")return null;const n=typeof s.secretId=="string"?s.secretId:"";return n?{secretId:n,version:typeof s.version=="number"?s.version:"latest"}:null}r(yxe,"readSecretRef");function PQe(e){const s=vxe(e?.env);if(!s)return[];const n=[];for(const[a,i]of Object.entries(s)){const o=yxe(i);o&&n.push({name:a,...o})}return n}r(PQe,"parseEnvSecretRefs");function MQe(e){if(!e)return[];const s=[];for(const[n,a]of Object.entries(e)){if(!n.startsWith("access."))continue;const i=yxe(a);i&&s.push({name:n.slice(B1.length),...i})}return s}r(MQe,"parseAccessGrants");function DQe(e,s){const n=new Map,a=r(i=>{let o=n.get(i);return o||(o={secretId:i,envKeys:[],apiAliases:[]},n.set(i,o)),o},"ensure");for(const i of e)a(i.secretId).envKeys.push(i.name);for(const i of s)a(i.secretId).apiAliases.push(i.name);return[...n.values()]}r(DQe,"summarizeAgentBindings");var lJ=0;function jxe(){return lJ+=1,`access-row-${lJ}`}r(jxe,"nextAccessRowId");function K4(e){return e.map(s=>({id:jxe(),alias:s.name,secretId:s.secretId,version:s.version}))}r(K4,"entriesToRows");function cJ(e){const s={};for(const n of e){const a=n.alias.trim();!a||!zF.test(a)||!n.secretId||(s[a]={type:"secret_ref",secretId:n.secretId,version:n.version})}return s}r(cJ,"rowsToAccessMap");function dJ(e){return JSON.stringify(Object.keys(e).sort().map(s=>{const n=e[s];return[s,n.secretId,n.version??"latest"]}))}r(dJ,"normalizeAccessMapKey");function uJ({mode:e}){return e==="env"?(0,t.jsxs)(lt,{variant:"outline",className:"h-5 gap-1 px-1.5 text-(length:--text-nano) font-normal border-sky-500/30 bg-sky-500/10 text-sky-700 dark:text-sky-300",children:[(0,t.jsx)(sue,{className:"size-3"})," Env var"]}):(0,t.jsxs)(lt,{variant:"outline",className:"h-5 gap-1 px-1.5 text-(length:--text-nano) font-normal border-violet-500/30 bg-violet-500/10 text-violet-700 dark:text-violet-300",children:[(0,t.jsx)(E5,{className:"size-3"})," API access"]})}r(uJ,"DeliveryBadge");function LQe({config:e,secrets:s,onChange:n,onCreateSecret:a,disabled:i,proposals:o,onApproveProposal:l,onRejectProposal:c}){const d=(0,u.useMemo)(()=>(o??[]).filter(L=>L.kind==="binding"),[o]),m=(0,u.useMemo)(()=>PQe(e),[e]),h=(0,u.useMemo)(()=>MQe(e),[e]),p=(0,u.useMemo)(()=>DQe(m,h),[m,h]),f=(0,u.useMemo)(()=>cJ(K4(h)),[h]),g=(0,u.useMemo)(()=>dJ(f),[f]),[v,y]=(0,u.useState)(()=>K4(h)),[w,S]=(0,u.useState)(null),j=(0,u.useRef)(new Map),N=(0,u.useRef)(g),_=(0,u.useRef)(g);(0,u.useEffect)(()=>{g!==_.current&&(_.current=g,g!==N.current&&y(K4(h)))},[g,h]);const R=r(L=>s.find(E=>E.id===L)?.name??`${L.slice(0,8)}…`,"secretName");function C(L){y(L);const E=cJ(L);N.current=dJ(E),n(E)}r(C,"emit");function A(L,E){C(v.map(q=>q.id===L?{...q,...E}:q))}r(A,"patchRow");function T(L){C(v.filter(E=>E.id!==L))}r(T,"removeRow");function I(){y(L=>[...L,{id:jxe(),alias:"",secretId:"",version:"latest"}])}r(I,"addRow");const $=(0,u.useMemo)(()=>{const L=new Map;for(const E of v){const q=E.alias.trim();q&&L.set(q,(L.get(q)??0)+1)}return L},[v]),O=p.length>0;return(0,t.jsxs)("div",{className:"space-y-3",children:[O?(0,t.jsx)("div",{className:"space-y-1.5",children:p.map(L=>(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 rounded-md border border-border bg-muted/30 px-2.5 py-1.5 text-xs",children:[(0,t.jsx)(bi,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,t.jsx)("span",{className:"font-medium",children:R(L.secretId)}),L.envKeys.length>0?(0,t.jsx)(uJ,{mode:"env"}):null,L.apiAliases.length>0?(0,t.jsx)(uJ,{mode:"api"}):null,(0,t.jsx)("span",{className:"min-w-0 truncate font-mono text-(length:--text-micro) text-muted-foreground",children:[...L.envKeys.map(E=>`${wQe}${E}`),...L.apiAliases.map(E=>`${B1}${E}`)].join(" · ")})]},L.secretId))}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"No secrets are bound to this agent yet."}),d.length>0&&l&&c?(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("div",{className:"text-(length:--text-micro) font-medium uppercase tracking-wide text-muted-foreground",children:"Proposed access"}),d.map(L=>{const E=wK(L),q=hE(L);return(0,t.jsxs)("div",{className:"flex flex-col gap-2 rounded-md border border-amber-500/30 bg-amber-500/5 px-2.5 py-2 text-xs sm:flex-row sm:items-center",children:[(0,t.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[(0,t.jsx)(yK,{configPath:L.configPath}),(0,t.jsx)("code",{className:"font-mono",children:q||L.configPath}),(0,t.jsx)("span",{className:"text-muted-foreground",children:"→"}),(0,t.jsx)(bi,{className:"size-3 text-muted-foreground"}),(0,t.jsx)("span",{className:"font-medium",children:E.name}),E.pending?(0,t.jsx)(jK,{}):null]}),(0,t.jsxs)("p",{className:"flex flex-wrap items-center gap-1 text-muted-foreground",children:[(0,t.jsxs)("span",{children:["proposed by ",L.proposedBy.name]}),(0,t.jsx)("span",{"aria-hidden":"true",children:"·"}),(0,t.jsxs)("span",{className:"truncate italic",children:["“",L.justification,"”"]})]})]}),(0,t.jsx)(bxe,{proposal:L,onApprove:l,onReject:c,disabled:i,size:"xs"})]},L.id)})]}):null,(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("div",{className:"text-(length:--text-micro) font-medium uppercase tracking-wide text-muted-foreground",children:"API access (no env var)"}),v.length>0?(0,t.jsx)("div",{className:"space-y-2",children:v.map(L=>{const E=L.alias.trim(),q=!!E&&!zF.test(E),B=!!E&&($.get(E)??0)>1,K=s.find(z=>z.id===L.secretId)??null;return(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsxs)("div",{className:"grid grid-cols-(--gtc-65) items-start gap-1.5",children:[(0,t.jsx)("div",{children:(0,t.jsx)(At,{value:L.alias,onChange:r(z=>A(L.id,{alias:z.target.value}),"onChange"),onBlur:r(z=>{const D=z.target.value.trim();if(D&&!zF.test(D)){const V=_S(D);V&&V!==D&&A(L.id,{alias:V})}},"onBlur"),placeholder:"ALIAS","aria-label":"Access alias",disabled:i,className:U("h-9 font-mono text-sm",(q||B)&&"border-destructive text-destructive")})}),(0,t.jsxs)("div",{className:"flex min-w-0 items-start gap-1.5",children:[(0,t.jsxs)(Zn,{open:w?.rowId===L.id,onOpenChange:r(z=>{!z&&w?.rowId===L.id&&S(null)},"onOpenChange"),children:[(0,t.jsx)(uO,{asChild:!0,children:(0,t.jsx)("div",{ref:r(z=>{z?j.current.set(L.id,z):j.current.delete(L.id)},"ref"),className:"min-w-0 flex-1",children:(0,t.jsx)(bK,{secretId:L.secretId,secrets:s,onSelect:r(z=>A(L.id,{secretId:z,version:"latest",alias:!L.alias.trim()&&z?_S(R(z)):L.alias}),"onSelect"),onCreateNew:a?z=>{window.setTimeout(()=>{S({rowId:L.id,name:BT(z)||z.trim()})},0)}:void 0,disabled:i,triggerClassName:"h-9 min-h-9"})})}),(0,t.jsx)(Vn,{align:"start",className:"w-auto p-3",onInteractOutside:r(z=>{const D=z.detail.originalEvent.target;D&&j.current.get(L.id)?.contains(D)&&z.preventDefault()},"onInteractOutside"),children:w?.rowId===L.id&&a?(0,t.jsx)(dxe,{initialName:w.name,initialValue:"",existingSecretNames:s.map(z=>z.name),onCancel:r(()=>S(null),"onCancel"),onSubmit:r(async(z,D)=>{const V=await a(z,D);A(L.id,{secretId:V.id,version:"latest",alias:L.alias.trim()||_S(V.name)}),S(null)},"onSubmit")}):null})]}),(0,t.jsxs)("select",{className:"h-9 shrink-0 rounded-md border border-border bg-background px-2 text-xs outline-none disabled:cursor-not-allowed disabled:opacity-60",value:L.version===void 0?"latest":String(L.version),onChange:r(z=>{const D=z.target.value;A(L.id,{version:D==="latest"?"latest":Number.parseInt(D,10)})},"onChange"),disabled:i||!K,"aria-label":"Version",children:[(0,t.jsx)("option",{value:"latest",children:"latest"}),K?Array.from({length:Math.max(0,K.latestVersion)},(z,D)=>{const V=K.latestVersion-D;return V<=0?null:(0,t.jsxs)("option",{value:V,children:["v",V]},V)}):null]})]}),(0,t.jsx)("button",{type:"button",onClick:r(()=>T(L.id),"onClick"),disabled:i,"aria-label":"Remove API access",className:"mt-1 inline-flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:pointer-events-none disabled:opacity-50",children:(0,t.jsx)(Ia,{className:"size-3.5"})})]}),q?(0,t.jsx)("p",{className:"pl-0.5 text-(length:--text-micro) text-destructive",children:"Invalid alias — use letters, digits and _"}):B?(0,t.jsx)("p",{className:"pl-0.5 text-(length:--text-micro) text-destructive",children:"Duplicate alias"}):null]},L.id)})}):null,(0,t.jsxs)("button",{type:"button",onClick:I,disabled:i,className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:pointer-events-none disabled:opacity-50",children:[(0,t.jsx)(gn,{className:"size-3.5"}),"Add API access"]})]}),(0,t.jsxs)("p",{className:"text-(length:--text-micro) text-muted-foreground/70",children:[NQe("api")," The agent reads them by alias through ",(0,t.jsx)("code",{children:"GET /agents/me/secrets"}),"."]})]})}r(LQe,"AgentSecretAccessEditor");function $Qe(e){if(typeof e!="string")return null;const s=e.trim();return s.length>0?s:null}r($Qe,"asNonEmptyString$3");function OQe(e){return $Qe(e)!==null}r(OQe,"hasLegacyWorkingDirectory");function FQe(e){return e.isCreate?!1:OQe(e.adapterConfig?.cwd)}r(FQe,"shouldShowLegacyWorkingDirectoryField");var wxe=new Set;function BQe(e){return wxe.has(e)}r(BQe,"isAdapterTypeHidden");function qQe(e){wxe=new Set(e)}r(qQe,"setDisabledAdapterTypes");function zQe(e){return!Um(e).hideFromVisualSelection}r(zQe,"isVisualAdapterChoice");function Nxe(e,s=xK()){const n=e??mf;return s.map(a=>({value:a.type,label:n(a.type),comingSoon:!!Um(a.type).comingSoon,hidden:BQe(a.type),experimental:!!Um(a.type).experimental}))}r(Nxe,"listAdapterOptions");function kxe(e={}){const s=e.enabled??!0,{data:n}=Z({queryKey:P.adapters.all,queryFn:r(()=>Rm.list(),"queryFn"),enabled:s,staleTime:3e5});return n&&zHe(n.filter(a=>a.source==="external").map(a=>({type:a.type,label:a.label,disabled:a.disabled,overrideDisabled:a.overridePaused}))),(0,u.useEffect)(()=>{n&&qQe(n.filter(a=>a.disabled).map(a=>a.type))},[n]),(0,u.useMemo)(()=>new Set(n?.filter(a=>a.disabled).map(a=>a.type)??[]),[n])}r(kxe,"useDisabledAdaptersSync");function UQe(e={}){const s=e.enabled??!0,{data:n}=Z({queryKey:P.adapters.all,queryFn:r(()=>Rm.list(),"queryFn"),enabled:s,staleTime:3e5});return n!==void 0}r(UQe,"useAdapterRegistryLoaded");function qT(e){return Object.fromEntries(Object.entries(e).filter(([,s])=>s!==void 0))}r(qT,"omitUndefinedEntries");function yI(e,s){const n={};if(Object.keys(s.identity).length>0&&Object.assign(n,s.identity),s.adapterType!==void 0&&(n.adapterType=s.adapterType),s.adapterType!==void 0||Object.keys(s.adapterConfig).length>0){const a=e.adapterConfig??{};n.adapterConfig=qT(s.adapterType!==void 0?{...Object.fromEntries(aIe.filter(i=>a[i]!==void 0).map(i=>[i,a[i]])),...s.adapterConfig}:{...a,...s.adapterConfig}),n.replaceAdapterConfig=!0}if(Object.keys(s.heartbeat).length>0||Object.keys(s.debug).length>0){const a=e.runtimeConfig??{},i=n.runtimeConfig??{...a};if(Object.keys(s.heartbeat).length>0&&(i.heartbeat={...a.heartbeat??{},...s.heartbeat}),Object.keys(s.debug).length>0){const o=qT({...a.debug??{},...s.debug});Object.keys(o).length===0?delete i.debug:i.debug=o}n.runtimeConfig=i}return Object.keys(s.runtime).length>0&&Object.assign(n,s.runtime),n}r(yI,"buildAgentUpdatePatch");var KQe="kubernetes";function VQe(e){return e.driver!=="sandbox"?!1:e.config?.provider===KQe}r(VQe,"isKubernetesSandboxEnvironment");function NK(e,s){return e!=="kubernetes"?{forced:!1,kubernetesEnvironment:null}:{forced:!0,kubernetesEnvironment:s.find(n=>VQe(n))??null}}r(NK,"resolveForcedKubernetesEnvironment");var V4={identity:{},adapterConfig:{},heartbeat:{},debug:{},runtime:{}},rk={};function WQe(e){return e==="claude_local"||e==="codex_local"||e==="paperclip_runner"||e==="opencode_local"}r(WQe,"supportsAdapterModelRefresh");function HQe(e,s){return nhe(e,s).model}r(HQe,"resolvePaperclipRunnerTransitionModel");function mJ(e){return Object.keys(e.identity).length>0||e.adapterType!==void 0||Object.keys(e.adapterConfig).length>0||Object.keys(e.heartbeat).length>0||Object.keys(e.debug).length>0||Object.keys(e.runtime).length>0}r(mJ,"isOverlayDirty");function UF(e,s){if(Object.is(e,s))return!0;if(Array.isArray(e)&&Array.isArray(s))return e.length===s.length&&e.every((n,a)=>UF(n,s[a]));if(typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof s=="object"&&s!==null&&!Array.isArray(s)){const n=Object.entries(e),a=s;return n.length===Object.keys(a).length&&n.every(([i,o])=>i in a&&UF(o,a[i]))}return!1}r(UF,"overlayValuesEqual");function QQe(e,s){const n=r((a,i)=>Object.fromEntries(Object.entries(a).filter(([o,l])=>!(o in i)||!UF(l,i[o]))),"subtractGroup");return{identity:n(e.identity,s.identity),...e.adapterType!==void 0&&e.adapterType!==s.adapterType?{adapterType:e.adapterType}:{},adapterConfig:n(e.adapterConfig,s.adapterConfig),heartbeat:n(e.heartbeat,s.heartbeat),debug:n(e.debug,s.debug),runtime:n(e.runtime,s.runtime)}}r(QQe,"subtractPersistedOverlay");var vm="w-full rounded-md border border-border px-2.5 py-1.5 bg-transparent outline-none text-sm font-mono placeholder:text-muted-foreground/40";function GQe(e){return e.split(",").map(s=>s.trim()).filter(Boolean)}r(GQe,"parseCommaArgs");function YQe(e){return Array.isArray(e)?e.filter(s=>typeof s=="string").join(", "):typeof e=="string"?e:""}r(YQe,"formatArgList");var JQe=[{id:"",label:"Auto"},{id:"minimal",label:"Minimal"},{id:"low",label:"Low"},{id:"medium",label:"Medium"},{id:"high",label:"High"},{id:"xhigh",label:"X-High"},{id:"max",label:"Max"}],XQe=[{id:"",label:"Auto"},{id:"plan",label:"Plan"},{id:"ask",label:"Ask"}],ZQe=[{id:"",label:"Auto"},{id:"low",label:"Low"},{id:"medium",label:"Medium"},{id:"high",label:"High"}],eGe=[{id:"",label:"Auto"},{id:"low",label:"Low"},{id:"high",label:"High"},{id:"max",label:"Max"}],tGe=2,hJ=10,sGe=1,Sxe=300;function $2(e,s,n){return Math.max(s,Math.min(n,Math.floor(e)))}r($2,"clampInteger");function nGe(e){return $2(e,0,Sxe)*1e3}r(nGe,"clampDelayMsFromSeconds");function rGe({order:e,className:s,children:n}){if(!e)return(0,t.jsx)("div",{className:s,children:n});const a=r(o=>{const l=(0,u.isValidElement)(o)?o.props["data-config-section"]:void 0,c=l?e.indexOf(l):-1;return c<0?e.length:c},"rank"),i=u.Children.toArray(n).sort((o,l)=>a(o)-a(l));return(0,t.jsx)("div",{className:s,children:i})}r(rGe,"ConfigSections");function Cxe(e){const{mode:s,adapterModels:n}=e,a=s==="create",i=e.sectionLayout==="cards",o=e.showAdapterTypeField??!0,l=e.showAdapterTestEnvironmentButton??!0,c=l&&!e.onTestActionChange&&!e.compactTestFeedback,d=!e.onTestFeedbackChange,m=e.showCreateRunPolicySection??!0,h=e.hideInstructionsFile??!1,p=e.canConfigureProviderTrace===!0,{selectedCompanyId:f}=ps(),g=Wt(),v=(0,u.useRef)(null),y=kxe(),{data:w=[]}=Z({queryKey:f?P.secrets.list(f):["secrets","none"],queryFn:r(()=>fr.list(f),"queryFn"),enabled:!!f}),{data:S=[]}=Z({queryKey:f?P.secrets.userDefinitions(f):["user-secret-definitions","none"],queryFn:r(()=>fr.listUserSecretDefinitions(f),"queryFn"),enabled:!!f,retry:!1}),j=a?null:e.agent.id,{data:N=[]}=Z({queryKey:f?P.secrets.proposals(f,"pending"):["secret-proposals","none"],queryFn:r(()=>fr.listProposals(f,"pending"),"queryFn"),enabled:!!f&&!a,retry:!1}),_=(0,u.useMemo)(()=>N.filter(et=>et.kind==="binding"&&et.target?.id===j),[N,j]),R=gxe(f,[]),{data:C}=Z({queryKey:P.instance.experimentalSettings,queryFn:r(()=>Er.getExperimental(),"queryFn"),retry:!1}),A=(0,u.useMemo)(()=>{const et=new Set(y);return C?.enableNativeRunner!==!0&&et.add("paperclip_runner"),et},[y,C?.enableNativeRunner]),T=C?.enableEnvironments===!0,I=C?.enableManagedSandboxOnly===!0,$=C===void 0||I,{data:O}=Z({queryKey:P.instance.generalSettings,queryFn:r(()=>Er.getGeneral(),"queryFn"),retry:!1}),{data:L}=Z({queryKey:P.instance.settings,queryFn:r(()=>Er.get(),"queryFn"),retry:!1}),{data:E=[]}=Z({queryKey:f?P.environments.list(f):["environments","none"],queryFn:r(()=>Ci.list(f),"queryFn"),enabled:!!f&&(T||O?.executionMode==="kubernetes")}),{forced:q,kubernetesEnvironment:B}=(0,u.useMemo)(()=>NK(O?.executionMode,E),[O?.executionMode,E]),K=Ne({mutationFn:r(et=>{if(!f)throw new Error("Select an organization to create secrets");return fr.create(f,et)},"mutationFn"),onSuccess:r(()=>{f&&g.invalidateQueries({queryKey:P.secrets.list(f)})},"onSuccess")}),z=Ne({mutationFn:r(async({file:et,namespace:Ht})=>{if(!f)throw new Error("Select an organization to upload images");return m0.uploadImage(f,et,Ht)},"mutationFn")}),[D,V]=(0,u.useState)(V4),[H,ee]=(0,u.useState)(!1),[X,le]=(0,u.useState)(0),ce=(0,u.useRef)(null),te=(0,u.useRef)(null),ae=(0,u.useRef)(!1);(0,u.useEffect)(()=>{if(!a){if(ce.current!==null&&e.agent!==ce.current&&!ae.current){const et=te.current;te.current=null,V(Ht=>et?QQe(Ht,et):{...V4})}ce.current=e.agent}},[a,a?void 0:e.agent]);const de=!a&&(mJ(D)||H);function J(et,Ht,un){const Os=D[et];return Ht in Os?Os[Ht]:un}r(J,"eff");function Y(et,Ht,un){V(Os=>({...Os,[et]:{...Os[et],[Ht]:un}}))}r(Y,"mark");function G(){return v.current?.flushPendingDraft()??null}r(G,"flushEnvironmentDraft");const fe=(0,u.useCallback)(et=>{a||V(Ht=>{const un={...e.agent.adapterConfig??{},...Ht.adapterConfig},Os={...Ht.adapterConfig};for(const[Jn,vr]of Object.entries(et))Os[`${B1}${Jn}`]=vr;for(const Jn of Object.keys(un))Jn.startsWith("access.")&&(Jn.slice(7)in et||(Os[Jn]=void 0));return{...Ht,adapterConfig:Os}})},[a,a?void 0:e.agent]),se=(0,u.useCallback)(()=>{V({...V4}),ee(!1),le(et=>et+1)},[]),re=(0,u.useCallback)(async()=>{if(a)return;const et=G(),Ht=et?{...D,adapterConfig:{...D.adapterConfig,env:et}}:D;mJ(Ht)&&await e.onSave(yI(e.agent,Ht))},[a,de,D,e]);(0,u.useEffect)(()=>{a||(e.onDirtyChange?.(de),e.onSaveActionChange?.(re),e.onCancelActionChange?.(se))},[a,de,e.onDirtyChange,e.onSaveActionChange,e.onCancelActionChange,re,se]),(0,u.useEffect)(()=>{if(!a)return()=>{e.onSaveActionChange?.(null),e.onCancelActionChange?.(null),e.onDirtyChange?.(!1)}},[a,e.onDirtyChange,e.onSaveActionChange,e.onCancelActionChange]);const ie=a?{}:e.agent.adapterConfig??{},me=a?{}:e.agent.runtimeConfig??{},pe=a?{}:me.heartbeat??{},be=a?{}:me.debug??{},oe=a?e.values.adapterType:D.adapterType??e.agent.adapterType,ye=Zw(),Ae=ye(oe),xe=Ae.supportsInstructionsBundle||Ae.supportsSkills||Ae.supportsLocalAgentJwt,_e=xe&&!$&&FQe({isCreate:a,adapterConfig:ie}),Ge=(0,u.useMemo)(()=>uN(oe),[oe]),$e=(0,u.useMemo)(()=>new Set(CTe(oe)),[oe]),Ye=a?e.values:null,ue=a?et=>e.onChange(et):null;a&&Ye.claudeStoredSessionId;const Oe=r(()=>{f&&g.invalidateQueries({queryKey:P.secrets.userDefinitions(f)})},"invalidateUserSecretDefinitions"),dt=r(et=>{if(!a||!ue)return;const Ht=Ye.envBindings??{};ue({envBindings:{...Ht,...fj()},claudeStoredSessionId:et}),Oe()},"handleClaudeLoginStored"),xt=r(async()=>{if(a)return;const et={...G()??J("adapterConfig","env",ie.env??rk),...fj()},Ht={...D,adapterConfig:{...D.adapterConfig,env:et}};V(Ht),await e.onSave({...yI(e.agent,Ht),applyStoredClaudeLogin:!0}),Oe()},"handleClaudeLoginStoredEdit"),De=r(async et=>{if(a||!et.companyIdentityDiffers)return;const Ht={...G()??J("adapterConfig","env",ie.env??rk),CODEX_HOME:{type:"secret_ref",secretId:et.secretId,version:"latest"}},un={...D,adapterConfig:{...D.adapterConfig,env:Ht}};V(un),te.current=un,ae.current=!0;try{await e.onSave(yI(e.agent,un))}catch(Os){throw te.current=null,Os}finally{ae.current=!1}Oe()},"handleCodexAccountBindingEdit"),Qe=r(()=>{if(!a||!ue)return;const et=Ye.envBindings??{};ue({envBindings:{...et,...fj()},claudeApplyStoredLogin:!0}),Oe()},"handleApplyStoredClaudeLogin"),ht=r(async()=>{if(a)return;const et={...G()??J("adapterConfig","env",ie.env??rk),...fj()},Ht={...D,adapterConfig:{...D.adapterConfig,env:et}};V(Ht),await e.onSave({...yI(e.agent,Ht),applyStoredClaudeLogin:!0}),Oe()},"handleApplyStoredClaudeLoginEdit"),We=a?Ye.defaultEnvironmentId??"":J("identity","defaultEnvironmentId",e.agent.defaultEnvironmentId??""),Ke=(0,u.useMemo)(()=>We?(E.find(et=>et.id===We)??null)?.driver==="local"?"":We:"",[E,We]),gt=(0,u.useMemo)(()=>E.find(et=>et.id===Ke)??null,[Ke,E]),tt=(0,u.useMemo)(()=>{const et=L?.defaultEnvironmentId??null;return et?(E.find(Ht=>Ht.id===et)??null)?.driver==="local"?"":et:""},[E,L?.defaultEnvironmentId]),Se=(0,u.useMemo)(()=>E.find(et=>et.id===tt)??null,[E,tt]),ke=(0,u.useMemo)(()=>{try{return vw({agentDefaultEnvironmentId:We||null,instanceDefaultEnvironmentId:L?.defaultEnvironmentId??null,localDefaultEnvironmentId:jw(E),managedSandboxOnly:C?.enableManagedSandboxOnly===!0,managedSandboxEnvironmentId:yw(E),visibleEnvironmentIds:E.map(et=>et.id)})}catch{return null}},[We,L?.defaultEnvironmentId,E,C?.enableManagedSandboxOnly]),Xe=(0,u.useMemo)(()=>E.find(et=>et.id===ke)??null,[E,ke]),{data:ut}=Z({queryKey:f?P.environments.capabilities(f):["environment-capabilities","none"],queryFn:r(()=>Ci.capabilities(f),"queryFn"),enabled:!!f&&Ae.login!=null});(0,u.useEffect)(()=>{!a||!ue||!q||!B||Ke!==B.id&&ue({defaultEnvironmentId:B.id})},[a,ue,q,B,Ke]);const Lt=(0,u.useMemo)(()=>E.filter(et=>{if(!$e.has(et.driver)||et.driver==="local")return!1;if(et.driver!=="sandbox")return!0;const Ht=typeof et.config?.provider=="string"?et.config.provider:null;return Ht!==null&&Ht!=="fake"}),[E,$e]),Xt=(0,u.useMemo)(()=>!gt||Lt.some(et=>et.id===gt.id)?Lt:[...Lt,gt],[gt,Lt]),fs=T&&(q||Ke.length>0||Lt.length>=1),Ve=Se?ww(Se):I?"Paperclip Computer":"Local",He=oe==="paperclip_runner"?String(a?e.values.adapterSchemaValues?.provider??"codex":J("adapterConfig","provider",ie.provider==="acpx"&&ie.acpxAgent==="codex"?"codex":ie.provider??"codex")):void 0,ct=oe==="opencode_local"&&u2.safeParse(D.runtime.runtimeConfig?.aiConnection??me.aiConnection).data?.provider==="openrouter"?"openrouter":He,ze=f?P.agents.adapterModels(f,oe,Ke||null,ct):["agents","none","adapter-models",oe],{data:is,error:Fe}=Z({queryKey:ze,queryFn:r(()=>Vt.adapterModels(f,oe,{environmentId:Ke||null,provider:ct}),"queryFn"),enabled:!!f}),[Qt,It]=(0,u.useState)(null),[Ms,Ue]=(0,u.useState)(!1),pt=is??n??[],$t="command",{data:gs,refetch:Ts}=Z({queryKey:f?P.agents.detectModel(f,oe):["agents","none","detect-model",oe],queryFn:r(()=>{if(!f)throw new Error("Select an organization to detect the model");return Vt.detectModel(f,oe)},"queryFn"),enabled:!!(f&&xe&&oe!=="opencode_local"&&oe!=="paperclip_runner")}),St=gs?.model??null;gs?.candidates;const{data:we=[]}=Z({queryKey:f?P.agents.list(f):["agents","none","list"],queryFn:r(()=>Vt.list(f),"queryFn"),enabled:!!(!a&&f)}),Pe={mode:s,isCreate:a,adapterType:oe,values:a?e.values:null,set:a?et=>e.onChange(et):null,config:ie,eff:J,mark:Y,models:pt,hideInstructionsFile:h||$,managedSandboxOnly:$},[it,Ot]=(0,u.useState)(!1),[ft,us]=(0,u.useState)(!1),cn=Rfe(oe),xs=r(et=>(0,t.jsxs)(t.Fragment,{children:[oe==="claude_local"&&(0,t.jsx)(k9e,{...Pe,section:et}),(0,t.jsx)(Ge.ConfigFields,{...Pe,section:et,hideModel:xe})]}),"renderAdapterFields"),[bs,qe]=(0,u.useState)(!1),[wt,kt]=(0,u.useState)(!1);function Ee(et){if(a){const un=Ge.buildAdapterConfig(Ye);return et&&Object.assign(un,et),qT(un)}const Ht={...ie,...D.adapterConfig};return et&&Object.assign(Ht,et),qT(Ht)}r(Ee,"buildAdapterConfigForTest");const Le=Ne({mutationFn:r(async()=>{if(!f)throw new Error("Select an organization to test adapter environment");const et=G(),Ht=et?{env:et}:void 0;let un=L,Os=E,Jn=C?.enableManagedSandboxOnly===!0;if(!We)try{const[rs,pn,Hs]=await Promise.all([g.ensureQueryData({queryKey:P.instance.settings,queryFn:r(()=>Er.get(),"queryFn")}),g.ensureQueryData({queryKey:P.environments.list(f),queryFn:r(()=>Ci.list(f),"queryFn")}),g.ensureQueryData({queryKey:P.instance.experimentalSettings,queryFn:r(()=>Er.getExperimental(),"queryFn")})]);un=rs,Os=pn,Jn=Hs?.enableManagedSandboxOnly===!0}catch{throw new Error("Could not load environment settings to determine which environment to test in. Retry the test.")}const vr=vw({agentDefaultEnvironmentId:We||null,instanceDefaultEnvironmentId:un?.defaultEnvironmentId??null,localDefaultEnvironmentId:jw(Os),managedSandboxOnly:Jn,managedSandboxEnvironmentId:yw(Os),visibleEnvironmentIds:Os.map(rs=>rs.id)}),Na=Ee(Ht),zn=a?void 0:e.agent.id,Xn=a?void 0:u2.safeParse(D.runtime.runtimeConfig?.aiConnection??e.agent.runtimeConfig.aiConnection).data;if(e.compactTestFeedback){const rs=oe==="paperclip_runner"?Na.provider==="codex"?"codex_local":Na.provider==="acpx"&&Na.acpxAgent==="claude"?"claude_local":oe:oe;return wfe({companyId:f,adapterType:oe,providerAdapter:rs,adapterConfig:Na,agentId:zn,aiConnection:Xn,environmentId:vr})}return Vt.testEnvironment(f,oe,{adapterConfig:Na,agentId:zn,aiConnection:Xn,environmentId:vr})},"mutationFn")}),[Ze,Nt]=(0,u.useState)(!1),[Ut,Dt]=(0,u.useState)(null),Ft="Test",Yt=!a&&!!e.isSaving,Ws=Ze||Yt||!f,_n=(0,u.useRef)(Le.reset);_n.current=Le.reset;const In=(0,u.useRef)(()=>{});In.current=()=>{if(!a||!ue)return;const et=Ye.envBindings??{},Ht=Ye.claudeStoredSessionId!=null||Ye.claudeApplyStoredLogin===!0,un=sJ in et;if(!Ht&&!un)return;const Os={...et};delete Os[sJ],ue({envBindings:Os,claudeStoredSessionId:null,claudeApplyStoredLogin:!1})},(0,u.useEffect)(()=>{_n.current(),Dt(null),In.current()},[oe,ke]);const en=Ae.login!=null,Us=Le.data,ws=Us!=null&&ye(Us.adapterType).login!=null,nn=Us&&ws?Us.checks.find(et=>et.code==="adapter_auth_missing")??null:null,zs=typeof Xe?.config?.provider=="string"?Xe.config.provider:null,An=zs!=null&&ut?.sandboxProviders?.[zs]?.supportsLoginPty===!0,hn=Ae.login!=null,rn=(a||!(D.runtime.runtimeConfig?.aiConnection??me.aiConnection))&&en&&Xe?.driver==="sandbox"&&!!ke&&!!f&&!!nn&&(!hn||An),pr=(0,u.useCallback)(async()=>{if(!f)throw new Error("Select an organization to test adapter environment");Nt(!0),Dt(null),Le.reset();try{return await Le.mutateAsync()}catch(et){throw Dt(et instanceof Error?et.message:"Environment test failed"),et}finally{Nt(!1)}},[f,Le]),Zs=(0,u.useRef)(()=>{});(0,u.useEffect)(()=>{Zs.current=()=>{Ws||pr().catch(()=>{})}},[pr,Ws]);const er=(0,u.useCallback)(()=>{Zs.current()},[]);(0,u.useEffect)(()=>{if(!(!l||!e.onTestActionChange))return e.onTestActionChange(er),()=>{e.onTestActionChange?.(null)}},[l,e.onTestActionChange,er]),(0,u.useEffect)(()=>{if(!(!l||!e.onTestActionStateChange))return e.onTestActionStateChange({disabled:Ws,pending:Ze}),()=>{e.onTestActionStateChange?.({disabled:!0,pending:!1})}},[l,e.onTestActionStateChange,Ws,Ze]),(0,u.useEffect)(()=>{if(e.onTestFeedbackChange)return e.onTestFeedbackChange({errorMessage:Ut??(Le.error instanceof Error?Le.error.message:Le.error?"Environment test failed":null),result:Le.data??null,login:rn&&f&&ke?{companyId:f,adapterType:oe,environmentId:ke}:null}),()=>{e.onTestFeedbackChange?.({errorMessage:null,result:null,login:null})}},[e.onTestFeedbackChange,Ut,Le.data,Le.error,rn,f,oe,ke]);const tr=a?Ye.model??"":J("adapterConfig","model",String(ie.model??"")),Ur=typeof tr=="string"?tr:"";async function mr(){if(f){Ue(!0),It(null);try{const et=await Vt.adapterModels(f,oe,{refresh:!0,environmentId:Ke||null,provider:ct});g.setQueryData(ze,et)}catch(et){It(et instanceof Error?et.message:"Failed to refresh adapter models.")}finally{Ue(!1)}}}r(mr,"handleRefreshModels");const br=oe==="codex_local"?"modelReasoningEffort":oe==="cursor"?"mode":oe==="opencode_local"?"variant":oe==="grok_local"?"reasoningEffort":oe==="pi_local"?"thinking":"effort",sr=oe==="codex_local"?uC(Ur,"Auto").map(et=>({id:et.value,label:et.label})):oe==="cursor"?XQe:oe==="opencode_local"?JQe:oe==="kimi_local"?eGe:oe==="pi_local"?[{id:"",label:"Auto"},...["off","minimal","low","medium","high","xhigh"].map(et=>({id:et,label:et}))]:oe==="claude_local"||oe==="grok_local"?[{id:"",label:"Auto"},...DT(oe,Ur).map(et=>({id:et,label:et==="xhigh"?"X-High":et[0].toUpperCase()+et.slice(1)}))]:ZQe,ra=a?Ye.thinkingEffort:oe==="codex_local"?J("adapterConfig","modelReasoningEffort",String(ie.modelReasoningEffort??ie.reasoningEffort??"")):oe==="cursor"?J("adapterConfig","mode",String(ie.mode??"")):oe==="opencode_local"?J("adapterConfig","variant",String(ie.variant??"")):J("adapterConfig",br,String(ie[br]??"")),Bn=oe!=="gemini_local"&&oe!=="cursor_cloud"&&oe!=="paperclip_runner",_r=oe==="codex_local"?a?!!Ye.search:J("adapterConfig","search",!!ie.search):!1,ya=(0,u.useMemo)(()=>{if(a)return{heartbeat:{enabled:Ye.heartbeatEnabled,intervalSec:Ye.intervalSec}};const et={...me.heartbeat&&typeof me.heartbeat=="object"?me.heartbeat:{},...D.heartbeat};return{...me,heartbeat:et}},[a,D.heartbeat,me,Ye]),Nn=eH(ya.heartbeat),On=eH(Nn.maxTurnContinuation),on=eAe(On.enabled,!0),cr=$2(oH(On.maxAttempts,tGe),0,hJ),bt=$2(oH(On.delayMs,sGe*1e3)/1e3,0,Sxe);function Ds(et){Y("heartbeat","maxTurnContinuation",{...On,...et})}r(Ds,"updateMaxTurnContinuation");const Fs=(0,t.jsx)(rv,{ref:v,onDirtyChange:ee,hideDraftActions:!a&&e.hideInlineSave,value:a?Ye.envBindings??rk:J("adapterConfig","env",ie.env??rk),secrets:w,userSecretDefinitions:S,onCreateSecret:r(async(et,Ht)=>await K.mutateAsync({name:et,value:Ht}),"onCreateSecret"),onChange:r(et=>a?ue({envBindings:et??{},envVars:""}):Y("adapterConfig","env",et),"onChange")},X);return!a&&e.content==="secrets"?(0,t.jsxs)("div",{className:U("relative",i&&"space-y-6"),children:[de&&!e.hideInlineSave&&(0,t.jsx)("div",{className:"sticky top-0 z-10 flex items-center justify-end border-b border-primary/20 bg-background/90 px-4 py-2 backdrop-blur-sm",children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"Unsaved changes"}),(0,t.jsx)(F,{size:"sm",onClick:re,disabled:e.isSaving,children:e.isSaving?"Saving...":"Save"})]})}),e.environmentVariablesPlacement==="secrets"&&(0,t.jsxs)("div",{"data-config-section":"environment-variables",className:U(!i&&"border-b border-border"),children:[i?(0,t.jsx)("h3",{className:"mb-3 text-sm font-medium",children:"Environment variables"}):(0,t.jsx)("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground",children:"Environment variables"}),(0,t.jsx)("div",{className:U(i?"rounded-lg border border-border p-4":"px-4 pb-3"),children:Fs})]}),(0,t.jsxs)("div",{"data-config-section":"secrets",className:U(!i&&"border-b border-border"),children:[i?(0,t.jsx)("h3",{className:"mb-3 text-sm font-medium",children:"Secret access"}):(0,t.jsx)("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground",children:"Secret access"}),(0,t.jsxs)("div",{className:U(i?"space-y-3 rounded-lg border border-border p-4":"space-y-3 px-4 pb-3"),children:[(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:fi.secretAccess}),(0,t.jsx)(LQe,{config:{...ie,...D.adapterConfig},secrets:w,onChange:fe,onCreateSecret:r((et,Ht)=>K.mutateAsync({name:et,value:Ht}),"onCreateSecret"),proposals:_,onApproveProposal:R.requestApprove,onRejectProposal:R.requestReject}),R.dialogs]})]})]}):(0,t.jsxs)(rGe,{order:e.sectionOrder,className:U("relative",i&&"space-y-6"),children:[de&&!e.hideInlineSave&&(0,t.jsx)("div",{className:"sticky top-0 z-10 flex items-center justify-end px-4 py-2 bg-background/90 backdrop-blur-sm border-b border-primary/20",children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"Unsaved changes"}),(0,t.jsx)(F,{size:"sm",onClick:re,disabled:!a&&e.isSaving,children:!a&&e.isSaving?"Saving...":"Save"})]})}),!a&&(0,t.jsxs)("div",{"data-config-section":"identity",className:U(!i&&"border-b border-border"),children:[i?(0,t.jsx)("h3",{className:"text-sm font-medium mb-3",children:e.sectionTitles?.identity??"Identity"}):(0,t.jsx)("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground",children:"Identity"}),(0,t.jsxs)("div",{className:U(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:[(0,t.jsx)(ys,{label:"Name",hint:fi.name,children:(0,t.jsx)(Ba,{value:J("identity","name",e.agent.name),onCommit:r(et=>Y("identity","name",et),"onCommit"),immediate:!0,className:vm,placeholder:"Agent name"})}),(0,t.jsx)(ys,{label:"Title",hint:fi.title,children:(0,t.jsx)(Ba,{value:J("identity","title",e.agent.title??""),onCommit:r(et=>Y("identity","title",et||null),"onCommit"),immediate:!0,className:vm,placeholder:"e.g. VP of Engineering"})}),(0,t.jsx)(ys,{label:"Reports to",hint:fi.reportsTo,children:(0,t.jsx)(QHe,{agents:we,value:J("identity","reportsTo",e.agent.reportsTo??null),onChange:r(et=>Y("identity","reportsTo",et),"onChange"),excludeAgentIds:[e.agent.id],chooseLabel:"Choose manager…"})}),xe&&!e.hidePromptTemplate&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ys,{label:"Prompt Template",hint:fi.promptTemplate,children:(0,t.jsx)(kc,{value:J("adapterConfig","promptTemplate",String(ie.promptTemplate??"")),onChange:r(et=>Y("adapterConfig","promptTemplate",et??""),"onChange"),placeholder:"You are agent {{ agent.name }}. Your role is {{ agent.role }}...",contentClassName:"min-h-(--sz-88px) text-sm font-mono",imageUploadHandler:r(async et=>{const Ht=`agents/${e.agent.id}/prompt-template`;return(await z.mutateAsync({file:et,namespace:Ht})).contentPath},"imageUploadHandler")})}),(0,t.jsx)("div",{className:"rounded-md border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-xs text-amber-900 dark:text-amber-100",children:"Prompt template is replayed on every heartbeat. Keep it compact and dynamic to avoid recurring token cost and cache churn."})]})]})]}),q?(0,t.jsxs)("div",{"data-config-section":"environment",className:U(!i&&(a?"border-t border-border":"border-b border-border")),children:[i?(0,t.jsx)("h3",{className:"text-sm font-medium mb-3",children:"Environment"}):(0,t.jsx)("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground",children:"Environment"}),(0,t.jsx)("div",{className:U(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:(0,t.jsx)(ys,{label:"Default environment",hint:"This instance runs all agents in the Kubernetes sandbox. Local execution is disabled.",children:B?(0,t.jsxs)("div",{className:U(vm,"flex items-center text-muted-foreground"),children:[B.name," · Kubernetes sandbox"]}):(0,t.jsx)("div",{className:"rounded-md border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-xs text-amber-800 dark:text-amber-200",children:"This instance requires the Kubernetes sandbox, but no managed Kubernetes environment is available for this organization yet. Configure one before creating agents; execution will not fall back to local."})})})]}):fs?(0,t.jsxs)("div",{"data-config-section":"environment",className:U(!i&&(a?"border-t border-border":"border-b border-border")),children:[i?(0,t.jsx)("h3",{className:"text-sm font-medium mb-3",children:"Environment"}):(0,t.jsx)("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground",children:"Environment"}),(0,t.jsx)("div",{className:U(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:(0,t.jsx)(ys,{label:"Environment override",children:(0,t.jsx)("div",{className:"space-y-2",children:(0,t.jsxs)("select",{className:vm,value:Ke,onChange:r(et=>{const Ht=et.target.value;if(a){ue({defaultEnvironmentId:Ht});return}Y("identity","defaultEnvironmentId",Ht||null)},"onChange"),children:[(0,t.jsxs)("option",{value:"",children:["Default: ",Ve]}),Xt.map(et=>(0,t.jsx)("option",{value:et.id,children:ww(et)},et.id))]})})})})]}):null,(0,t.jsxs)("div",{"data-config-section":"adapter",className:U(!i&&(a?"border-t border-border":"border-b border-border")),children:[(0,t.jsxs)("div",{className:U(i?"flex items-center justify-between mb-3":"px-4 py-2 flex items-center justify-between gap-2"),children:[i?(0,t.jsx)("h3",{className:"text-sm font-medium",children:e.sectionTitles?.adapter??"Adapter"}):(0,t.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:"Adapter"}),c&&(0,t.jsx)(F,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2.5 text-xs",onClick:er,disabled:Ws,children:Ze?`${Ft}...`:Ft})]}),(0,t.jsxs)("div",{className:U(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:[o&&(0,t.jsx)(ys,{label:"Adapter type",hint:fi.adapterType,children:(0,t.jsx)(Ixe,{value:oe,disabledTypes:A,onChange:r(et=>{if(a){const{adapterType:Ht,...un}=t0,Os={...un,adapterType:et};et==="codex_local"?Os.dangerouslyBypassSandbox=!0:et==="gemini_local"?Os.model="auto":et==="kimi_local"?Os.model="kimi-code/kimi-for-coding":et==="cursor"?Os.model="auto":et==="opencode_local"?Os.model="openai/gpt-5.2-codex":et==="paperclip_runner"&&(Os.model=pw),ue(Os)}else V(Ht=>({...Ht,adapterType:et,adapterConfig:{model:et==="gemini_local"?"auto":et==="kimi_local"?"kimi-code/kimi-for-coding":et==="opencode_local"?"openai/gpt-5.2-codex":et==="cursor"?"auto":et==="paperclip_runner"?HQe(oe,ie.model):"",effort:"",modelReasoningEffort:"",variant:"",mode:"",...et==="codex_local"?{dangerouslyBypassApprovalsAndSandbox:!0}:et==="paperclip_runner"?{...nhe(oe,J("adapterConfig","model",ie.model))}:{}}}))},"onChange")})}),!a&&f&&(0,t.jsx)(jfe,{companyId:f,agentId:e.agent.id,agentName:e.agent.name,adapterType:oe==="paperclip_runner"?J("adapterConfig","provider",ie.provider)==="codex"?"codex_local":J("adapterConfig","provider",ie.provider)==="opencode"?"opencode_local":J("adapterConfig","provider",ie.provider)==="acpx"&&J("adapterConfig","acpxAgent",ie.acpxAgent)==="claude"?"claude_local":oe:oe,value:u2.safeParse(D.runtime.runtimeConfig?.aiConnection??me.aiConnection).data,model:String(J("adapterConfig","model",ie.model)??""),environmentId:Ke||void 0,legacy:!0,onChange:r(et=>Y("runtime","runtimeConfig",{...me,aiConnection:et}),"onChange")}),d&&!e.compactTestFeedback&&(Ut||Le.error)&&(0,t.jsx)("div",{className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:Ut??(Le.error instanceof Error?Le.error.message:"Environment test failed")}),d&&!e.compactTestFeedback&&Le.data&&(0,t.jsx)(uGe,{result:Le.data}),d&&rn&&(0,t.jsx)(kK,{companyId:f,adapterType:oe,environmentId:ke,onStored:a?dt:xt,onApplyStored:a?Qe:ht,onAccountBinding:a?void 0:De},`${oe}:${ke}`),_e&&(0,t.jsx)(ys,{label:"Working directory (deprecated)",hint:fi.cwd,children:(0,t.jsxs)("div",{className:"flex items-center gap-2 rounded-md border border-border px-2.5 py-1.5",children:[(0,t.jsx)(Co,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),(0,t.jsx)(Ba,{value:a?Ye.cwd:J("adapterConfig","cwd",String(ie.cwd??"")),onCommit:r(et=>a?ue({cwd:et}):Y("adapterConfig","cwd",et||void 0),"onCommit"),immediate:!0,className:"w-full bg-transparent outline-none text-sm font-mono placeholder:text-muted-foreground/40",placeholder:"/path/to/project"}),(0,t.jsx)(fd,{})]})}),xs("adapter"),xe&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(SK,{models:pt,value:Ur,onChange:r(et=>{const Ht=DT(oe,et),un=["codex_local","claude_local","grok_local"].includes(oe)&&!!ra&&!Ht.includes(String(ra));if(a){ue({model:et,...un?{thinkingEffort:""}:{}});return}Y("adapterConfig","model",et||void 0),un&&(Y("adapterConfig",br,void 0),Y("adapterConfig","reasoningEffort",void 0))},"onChange"),open:bs,onOpenChange:qe,defaultLabel:oe==="claude_local"?"Default (claude-opus-5)":void 0,allowDefault:oe!=="opencode_local"&&oe!=="pi_local"&&oe!=="paperclip_runner",required:oe==="opencode_local"||oe==="pi_local",groupByProvider:oe==="opencode_local"||oe==="pi_local",creatable:!0,detectedModel:St,detectedModelCandidates:[],onDetectModel:oe==="opencode_local"||oe==="paperclip_runner"?void 0:async()=>(await Ts()).data?.model??null,onRefreshModels:WQe(oe)?mr:void 0,refreshingModels:Ms,detectModelLabel:"Detect model",emptyDetectHint:"No model detected. Select or enter one manually."}),(Qt||Fe)&&(0,t.jsx)("p",{className:"text-xs text-destructive",children:Qt??(Fe instanceof Error?Fe.message:"Failed to load adapter models.")}),oe==="opencode_local"&>&>.driver!=="local"&&(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Live OpenCode model discovery only runs for Local environments. Using the curated list and manual entry for ",gt.name,"."]}),Bn&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(mGe,{value:ra,options:sr,onChange:r(et=>a?ue({thinkingEffort:et}):Y("adapterConfig",br,et||void 0),"onChange"),open:wt,onOpenChange:kt}),oe==="codex_local"&&_r&&ra==="minimal"&&(0,t.jsx)("p",{className:"text-xs text-amber-400",children:"Codex may reject `minimal` thinking when search is enabled."})]})]})]})]}),(0,t.jsxs)("div",{"data-config-section":"configuration",className:U(!i&&"border-b border-border"),children:[i?(0,t.jsx)("h3",{className:"text-sm font-medium mb-3",children:"Configuration"}):(0,t.jsx)("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground",children:"Configuration"}),(0,t.jsxs)("div",{className:U(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:[!a&&typeof ie.bootstrapPromptTemplate=="string"&&ie.bootstrapPromptTemplate&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ys,{label:"Bootstrap prompt (legacy)",hint:fi.bootstrapPrompt,children:(0,t.jsx)(kc,{value:J("adapterConfig","bootstrapPromptTemplate",String(ie.bootstrapPromptTemplate??"")),onChange:r(et=>Y("adapterConfig","bootstrapPromptTemplate",et||void 0),"onChange"),placeholder:"Optional initial setup prompt for the first run",contentClassName:"min-h-(--sz-44px) text-sm font-mono",imageUploadHandler:r(async et=>{const Ht=`agents/${e.agent.id}/bootstrap-prompt`;return(await z.mutateAsync({file:et,namespace:Ht})).contentPath},"imageUploadHandler")})}),(0,t.jsx)("div",{className:"rounded-md border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-xs text-amber-800 dark:text-amber-200",children:"Bootstrap prompt is legacy and will be removed in a future release. Consider moving this content into the agent's prompt template or instructions file instead."})]}),xs("configuration"),(xe||oe==="process"||cn?.fields.some(et=>_F(et.key)==="advanced"))&&(0,t.jsx)(R2,{title:"Advanced",open:ft,onToggle:r(()=>us(!ft),"onToggle"),children:(0,t.jsxs)("div",{className:"space-y-3",children:[xe&&(0,t.jsxs)(t.Fragment,{children:[" ",!$&&(0,t.jsx)(ys,{label:"Command",hint:fi.localCommand,children:(0,t.jsx)(Ba,{value:a?Ye.command:J("adapterConfig",$t,String(ie.command??"")),onCommit:r(et=>a?ue({command:et}):Y("adapterConfig",$t,et||null),"onCommit"),immediate:!0,className:vm,placeholder:{claude_local:"claude",codex_local:"codex",gemini_local:"gemini",kimi_local:"kimi",pi_local:"pi",cursor:"agent",opencode_local:"opencode"}[oe]??oe.replace(/_local$/,"")})}),(0,t.jsx)(ys,{label:"Extra args (comma-separated)",hint:fi.extraArgs,children:(0,t.jsx)(Ba,{value:a?Ye.extraArgs:J("adapterConfig","extraArgs",YQe(ie.extraArgs)),onCommit:r(et=>a?ue({extraArgs:et}):Y("adapterConfig","extraArgs",et?.trim()?GQe(et):null),"onCommit"),className:vm,placeholder:"e.g. --verbose, --foo=bar"})})]}),xs("advanced")]})})]})]}),e.environmentVariablesPlacement!=="secrets"&&(xe||cn?.fields.some(et=>_F(et.key)==="environment"))&&(0,t.jsxs)("div",{"data-config-section":"environment-variables",className:U(!i&&"border-b border-border"),children:[i?(0,t.jsx)("h3",{className:"text-sm font-medium mb-3",children:"Environment variables"}):(0,t.jsx)("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground",children:"Environment variables"}),(0,t.jsx)("div",{className:U(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:xe?Fs:xs("environment")})]}),a&&m?(0,t.jsxs)("div",{"data-config-section":"run-policy",className:U(!i&&"border-b border-border"),children:[i?(0,t.jsxs)("h3",{className:"text-sm font-medium flex items-center gap-2 mb-3",children:[(0,t.jsx)(nI,{className:"h-3 w-3"})," Run Policy"]}):(0,t.jsxs)("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground flex items-center gap-2",children:[(0,t.jsx)(nI,{className:"h-3 w-3"})," Run Policy"]}),(0,t.jsxs)("div",{className:U(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:[(0,t.jsx)(AY,{label:"Heartbeat on interval",hint:fi.heartbeatInterval,checked:Ye.heartbeatEnabled,onCheckedChange:r(et=>ue({heartbeatEnabled:et}),"onCheckedChange"),number:Ye.intervalSec,onNumberChange:r(et=>ue({intervalSec:et}),"onNumberChange"),numberLabel:"sec",numberPrefix:"Run heartbeat every",numberHint:fi.intervalSec,showNumber:Ye.heartbeatEnabled}),(0,t.jsx)(R2,{title:"Advanced Run Policy",open:it,onToggle:r(()=>Ot(!it),"onToggle"),children:(0,t.jsx)("div",{className:"space-y-3",children:xs("runPolicy")})})]})]}):a?null:(0,t.jsxs)("div",{"data-config-section":"run-policy",className:U(!i&&"border-b border-border"),children:[i?(0,t.jsxs)("h3",{className:"text-sm font-medium flex items-center gap-2 mb-3",children:[(0,t.jsx)(nI,{className:"h-3 w-3"})," Run Policy"]}):(0,t.jsxs)("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground flex items-center gap-2",children:[(0,t.jsx)(nI,{className:"h-3 w-3"})," Run Policy"]}),(0,t.jsxs)("div",{className:U(i?"border border-border rounded-lg overflow-hidden":""),children:[(0,t.jsx)("div",{className:U(i?"p-4 space-y-3":"px-4 pb-3 space-y-3"),children:(0,t.jsx)(AY,{label:"Heartbeat on interval",hint:fi.heartbeatInterval,checked:J("heartbeat","enabled",pe.enabled===!0),onCheckedChange:r(et=>Y("heartbeat","enabled",et),"onCheckedChange"),number:J("heartbeat","intervalSec",Number(pe.intervalSec??300)),onNumberChange:r(et=>Y("heartbeat","intervalSec",et),"onNumberChange"),numberLabel:"sec",numberPrefix:"Run heartbeat every",numberHint:fi.intervalSec,showNumber:J("heartbeat","enabled",pe.enabled===!0)})}),(0,t.jsx)(R2,{title:"Advanced Run Policy",bordered:i,open:it,onToggle:r(()=>Ot(!it),"onToggle"),children:(0,t.jsxs)("div",{className:"space-y-3",children:[xs("runPolicy"),xe&&(0,t.jsx)(t.Fragment,{children:!a&&(0,t.jsxs)(t.Fragment,{children:[!cn?.fields.some(et=>et.key==="timeoutSec")&&(0,t.jsx)(ys,{label:"Timeout (sec)",hint:fi.timeoutSec,children:(0,t.jsx)(sc,{value:J("adapterConfig","timeoutSec",Number(ie.timeoutSec??0)),onCommit:r(et=>Y("adapterConfig","timeoutSec",et),"onCommit"),immediate:!0,className:vm})}),!cn?.fields.some(et=>et.key==="graceSec")&&(0,t.jsx)(ys,{label:"Interrupt grace period (sec)",hint:fi.graceSec,children:(0,t.jsx)(sc,{value:J("adapterConfig","graceSec",Number(ie.graceSec??15)),onCommit:r(et=>Y("adapterConfig","graceSec",et),"onCommit"),immediate:!0,className:vm})})]})}),(0,t.jsx)(od,{label:"Wake on demand",hint:fi.wakeOnDemand,checked:J("heartbeat","wakeOnDemand",pe.wakeOnDemand!==!1),onChange:r(et=>Y("heartbeat","wakeOnDemand",et),"onChange")}),(0,t.jsx)(ys,{label:"Cooldown (sec)",hint:fi.cooldownSec,children:(0,t.jsx)(sc,{value:J("heartbeat","cooldownSec",Number(pe.cooldownSec??10)),onCommit:r(et=>Y("heartbeat","cooldownSec",et),"onCommit"),immediate:!0,className:vm})}),(0,t.jsx)(ys,{label:"Max concurrent runs",hint:fi.maxConcurrentRuns,children:(0,t.jsx)(sc,{value:J("heartbeat","maxConcurrentRuns",Number(pe.maxConcurrentRuns??20)),onCommit:r(et=>Y("heartbeat","maxConcurrentRuns",et),"onCommit"),immediate:!0,className:vm})}),(0,t.jsxs)("div",{className:"rounded-md border border-border/70 px-3 py-2",children:[(0,t.jsx)(od,{label:"Continue after max-turn stop",hint:fi.maxTurnContinuationEnabled,checked:on,onChange:r(et=>Ds({enabled:et}),"onChange")}),on?(0,t.jsxs)("div",{className:"mt-3 grid gap-3 sm:grid-cols-2",children:[(0,t.jsx)(ys,{label:"Continuation attempts",hint:fi.maxTurnContinuationMaxAttempts,children:(0,t.jsx)(sc,{value:cr,onCommit:r(et=>Ds({maxAttempts:$2(et,0,hJ)}),"onCommit"),immediate:!0,className:vm})}),(0,t.jsx)(ys,{label:"Continuation delay (sec)",hint:fi.maxTurnContinuationDelaySec,children:(0,t.jsx)(sc,{value:bt,onCommit:r(et=>Ds({delayMs:nGe(et)}),"onCommit"),immediate:!0,className:vm})})]}):null]})]})})]})]}),!a&&p?(0,t.jsxs)("div",{className:U(!i&&"border-b border-border"),children:[i?(0,t.jsxs)("h3",{className:"mb-3 flex items-center gap-2 text-sm font-medium",children:[(0,t.jsx)(Aj,{className:"h-3 w-3"})," Debugging"]}):(0,t.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2 text-xs font-medium text-muted-foreground",children:[(0,t.jsx)(Aj,{className:"h-3 w-3"})," Debugging"]}),(0,t.jsxs)("div",{className:U("border-border bg-accent/30",i?"rounded-lg border p-4":"mx-4 mb-4 rounded-md border px-3 py-3"),children:[(0,t.jsx)(od,{label:"Capture raw provider traces",hint:"Stores exact provider traffic for every future run until disabled. Traces may contain sensitive prompts and tool arguments, are administrator-only, and expire after 24 hours.",checked:J("debug","providerTrace",be.providerTrace)==="raw",onChange:r(et=>Y("debug","providerTrace",et?"raw":void 0),"onChange")}),J("debug","providerTrace",be.providerTrace)==="raw"?(0,t.jsxs)("div",{className:"mt-3 flex items-start gap-2 rounded-md border border-border bg-background/60 px-3 py-2 text-xs text-foreground",children:[(0,t.jsx)(Aj,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),(0,t.jsx)("span",{children:"Raw tracing is on for future runs. Paperclip keeps at most 64 MiB per run and automatically deletes it after 24 hours."})]}):null]})]}):null,e.compactTestFeedback&&d&&l&&(0,t.jsx)(Sfe,{state:Ze?"running":Ut||Le.error?"fail":Us?.status??"idle",result:Us??null,error:Ut??(Le.error instanceof Error?Le.error.message:null),onTest:er,disabled:Ws})]})}r(Cxe,"AgentConfigForm");var KF=new Set(["authenticated","failed","timed_out","cancelled"]),VF=2e3;function WF({value:e,label:s}){const[n,a]=(0,u.useState)(!1),i=(0,u.useRef)(null);return(0,u.useEffect)(()=>()=>{i.current&&clearTimeout(i.current)},[]),(0,t.jsx)(F,{type:"button",variant:"ghost",size:"icon-xs","aria-label":s,title:s,className:"text-muted-foreground hover:text-foreground",onClick:r(async()=>{try{await Yr(e),a(!0)}catch{a(!1)}i.current&&clearTimeout(i.current),i.current=setTimeout(()=>a(!1),1500)},"onClick"),children:n?(0,t.jsx)(ds,{className:"size-3"}):(0,t.jsx)(Nr,{className:"size-3"})})}r(WF,"AdapterLoginCopyButton");function aGe({status:e,message:s}){return e==="authenticated"?(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-foreground",children:[(0,t.jsx)(ds,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{children:"Authenticated. The environment has credentials now."})]}):(0,t.jsxs)("div",{className:"flex items-start gap-2 text-(length:--text-micro) text-destructive",children:[(0,t.jsx)(Is,{className:"size-3 shrink-0"}),(0,t.jsxs)("span",{children:[e==="timed_out"?"Login timed out":e==="cancelled"?"Login cancelled":"Login failed",s?`: ${s}`:"."]})]})}r(aGe,"AdapterLoginTerminalState");var iGe={claude_local:"Anthropic",codex_local:"OpenAI"};function _xe(e){const s=iGe[e];return s?`Sign in to ${s}`:"Sign in to the environment"}r(_xe,"adapterLoginTitle");function kK(e){return Zw()(e.adapterType).login?.panelMode==="submitted_browser_code"?(0,t.jsx)(dGe,{...e}):(0,t.jsx)(oGe,{...e})}r(kK,"AdapterLoginPanel");function oGe({companyId:e,adapterType:s,environmentId:n,autoStart:a,onConnected:i,onAccountBinding:o,chrome:l="panel",aiConnection:c,onPromptReady:d}){const[m,h]=(0,u.useState)(null),[p,f]=(0,u.useState)(null),[g,v]=(0,u.useState)(null),[y,w]=(0,u.useState)("idle"),S=(0,u.useRef)(!1),j=Ne({mutationFn:r(()=>Vt.startAdapterAuthLogin(e,s,{environmentId:n,aiConnection:c}),"mutationFn"),onSuccess:r(te=>{S.current=!1,f(null),v(null),w("idle"),h(te.sessionId)},"onSuccess"),onError:r(te=>{f(te instanceof Error?te.message:"Could not start the login.")},"onError")}),N=(0,u.useCallback)(()=>{S.current=!1,h(null),v(null),f(null)},[]),_=Ne({mutationFn:r(()=>Vt.cancelAdapterAuthLogin(e,s,m),"mutationFn"),onSuccess:N,onError:r(te=>{f(te instanceof Error?te.message:"Could not cancel the login.")},"onError")}),R=Z({queryKey:["adapter-login-active-session",e,s],queryFn:r(async()=>{try{const te=await Vt.getActiveAdapterAuthLoginSession(e,s);if(!te)return null;if(c&&te.environmentId!==n||!!te.aiConnection!=!!c||c&&(te.aiConnection?.provider!==c.provider||te.aiConnection?.method!==c.method||te.aiConnection?.connectionId!==c.connectionId||te.aiConnection?.ownership!==c.ownership||te.aiConnection?.allAgents!==c.allAgents||JSON.stringify(te.aiConnection?.agentIds)!==JSON.stringify(c.agentIds)))throw new Error("Another sign-in attempt is active. Finish or cancel it in its original account setup before starting this one.");return te}catch(te){if(te instanceof wn&&te.status===404)return null;throw te}},"queryFn"),retry:!1,gcTime:0,staleTime:0}),[C,A]=(0,u.useState)(!1),T=Z({queryKey:["adapter-login-status",e,s,m],queryFn:r(()=>Vt.getAdapterAuthLoginStatus(e,s,m),"queryFn"),enabled:!!m&&!C,retry:r((te,ae)=>ae instanceof wn&&ae.status===404?!1:te<3,"retry"),refetchInterval:r(te=>{const ae=te.state.data?.status;return ae&&KF.has(ae)?!1:VF},"refetchInterval")});(0,u.useEffect)(()=>{const te=T.data?.prompt??null;te&&v(te)},[T.data]);const I=T.data??j.data??null,$=I?.status??null,O=g,L=$?KF.has($):!1,E=!!m&&!L,q=j.isPending||E||y==="saving",B=(0,u.useRef)(!1);(0,u.useEffect)(()=>{if(B.current||!R.isFetched)return;B.current=!0;const te=R.data;te&&(S.current=!0,f(null),v(te.prompt??null),h(te.sessionId))},[R.isFetched,R.data]),(0,u.useEffect)(()=>{const te=T.error;if(!(te instanceof wn&&te.status===404)||!S.current||C)return;A(!0);const ae=m;(async()=>(ae&&await Vt.cancelAdapterAuthLogin(e,s,ae).catch(()=>{}),A(!1),N()))()},[T.error,C,m,e,s,N]);const K=(0,u.useRef)(!1),z=(0,u.useRef)(j.mutate);z.current=j.mutate,(0,u.useEffect)(()=>{if(!(!a||K.current)){if(R.isError){K.current=!0,f(R.error instanceof Error?R.error.message:"Could not check for an active login.");return}R.isSuccess&&(K.current=!0,!R.data&&z.current())}},[a,R.isSuccess,R.isError,R.data,R.error]);const D=(0,u.useRef)(!1),V=(0,u.useRef)(i);V.current=i,(0,u.useEffect)(()=>{$!=="authenticated"||D.current||(D.current=!0,V.current?.(m??void 0))},[$]);const H=(0,u.useRef)(null),ee=(0,u.useRef)(o);ee.current=o;const X=T.data?.codexAccountBinding??null,le=(0,u.useCallback)(async te=>{const ae=ee.current;if(ae){w("saving");try{await ae(te),w("bound")}catch{w("failed")}}},[]);(0,u.useEffect)(()=>{$!=="authenticated"||!m||H.current!==m&&(!X||!X.companyIdentityDiffers||!ee.current||(H.current=m,le(X)))},[$,m,X,le]);const ce=(0,u.useRef)(d);if(ce.current=d,(0,u.useEffect)(()=>{ce.current?.(O?.url??null)},[O]),l==="onboarding"){const te=L&&$&&$!=="authenticated";return(0,t.jsx)(Lfe,{loading:!O&&!p&&!te,providerName:Mfe(s),authorizationUrl:O?.url,mode:"displayed_code",children:p?(0,t.jsx)("p",{role:"alert",className:"pl-2 text-xs text-destructive",children:p}):te?(0,t.jsx)("p",{role:"alert",className:"pl-2 text-xs text-destructive",children:$==="timed_out"?"The login timed out. Start it again.":$==="cancelled"?"The login was cancelled.":"The login did not finish. Start it again."}):(0,t.jsx)(a9e,{code:O?.code??"",autoCopy:!0})})}return(0,t.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 px-3 py-2 flex flex-col gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-foreground",children:_xe(s)}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[E&&(0,t.jsx)(F,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground hover:text-foreground",disabled:_.isPending,onClick:r(()=>_.mutate(),"onClick"),children:"Cancel"}),(0,t.jsx)(F,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2.5 text-xs",disabled:q,onClick:r(()=>j.mutate(),"onClick"),children:"Sign in"})]})]}),p&&(0,t.jsx)("div",{role:"alert",className:"text-(length:--text-micro) text-destructive",children:p}),(0,t.jsxs)("div",{role:"status","aria-live":"polite",className:"space-y-2 empty:hidden",children:[E&&!O&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-muted-foreground",children:[(0,t.jsx)(at,{className:"size-3 animate-spin shrink-0"}),(0,t.jsx)("span",{children:"Preparing..."})]}),E&&O&&(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("div",{className:"text-(length:--text-micro) text-muted-foreground",children:"Copy the code, then open the authentication page."}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("div",{className:"text-(length:--text-micro) uppercase tracking-wide text-muted-foreground",children:"1. Code"}),(0,t.jsx)("span",{className:"font-mono text-xs text-foreground break-all",children:O.code})]}),(0,t.jsx)(WF,{value:O.code,label:"Copy code"})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("div",{className:"text-(length:--text-micro) uppercase tracking-wide text-muted-foreground",children:"2. Authentication URL"}),(0,t.jsx)("span",{className:"font-mono text-xs text-foreground break-all",children:O.url})]}),(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsx)(WF,{value:O.url,label:"Copy URL"}),(0,t.jsx)(F,{asChild:!0,type:"button",variant:"ghost",size:"icon-xs","aria-label":"Open the authentication page",title:"Open the authentication page",className:"text-muted-foreground hover:text-foreground",children:(0,t.jsx)("a",{href:O.url,target:"_blank",rel:"noreferrer noopener",children:(0,t.jsx)(xr,{className:"size-3"})})})]})]})]}),L&&$&&(0,t.jsx)(aGe,{status:$,message:I?.failure?.message??null}),$==="authenticated"&&y==="saving"&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-muted-foreground",children:[(0,t.jsx)(at,{className:"size-3 animate-spin shrink-0"}),(0,t.jsx)("span",{children:"Binding this agent to the signed-in account..."})]}),$==="authenticated"&&y==="bound"&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-foreground",children:[(0,t.jsx)(ds,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{children:"Agent bound to the signed-in account."})]}),$==="authenticated"&&y==="failed"&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro)",children:[(0,t.jsx)(Is,{className:"size-3 shrink-0 text-destructive"}),(0,t.jsx)("span",{className:"text-destructive",children:"Could not bind this agent to the signed-in account."}),(0,t.jsx)(F,{type:"button",variant:"outline",size:"sm",className:"h-6 px-2 text-xs",onClick:r(()=>{X&&le(X)},"onClick"),children:"Retry"})]})]})]})}r(oGe,"DisplayedCodeLoginPanel");var lGe=new Set(["failed","timed_out","cancelled"]),pJ="The login did not finish. Start the login again.",cGe=9e5,fJ="The login timed out. Start the login again.";function dGe({companyId:e,adapterType:s,environmentId:n,onStored:a,onApplyStored:i,autoStart:o,onConnected:l,onCodeSubmitted:c,onSubmitFailed:d,chrome:m="panel",aiConnection:h,onPromptReady:p}){const[f,g]=(0,u.useState)(null),[v,y]=(0,u.useState)(null),[w,S]=(0,u.useState)(null),[j,N]=(0,u.useState)(!1),[_,R]=(0,u.useState)(""),[C,A]=(0,u.useState)(null),[T,I]=(0,u.useState)(!1),[$,O]=(0,u.useState)(!1),[L,E]=(0,u.useState)(!1),[q,B]=(0,u.useState)(!1),K=(0,u.useRef)(!1),[z,D]=(0,u.useState)(!1),V=(0,u.useRef)(!1),H=r(()=>{y(null),S(null),N(!1),R(""),A(null),I(!1),O(!1),B(!1),E(!1),K.current=!1},"resetLocalState"),ee=Z({queryKey:["claude-oauth-token-status",e],queryFn:r(async()=>{try{return await Vt.getClaudeOAuthTokenStatus(e)}catch(tt){if(tt instanceof wn&&tt.status===404)return null;throw tt}},"queryFn"),retry:r((tt,Se)=>Se instanceof wn&&Se.status===404?!1:tt<2,"retry")}).data??null,X=Ne({mutationFn:r(()=>Vt.startClaudeSetupTokenLogin(e,{environmentId:n,aiConnection:h,...ee&&!h?{overwrite:{expectedSecretId:ee.secretId,expectedLatestVersion:ee.latestVersion}}:{}}),"mutationFn"),onSuccess:r(tt=>{V.current=!1,H(),g(tt.sessionId)},"onSuccess"),onError:r(tt=>{y(tt instanceof Error?tt.message:"Could not start the login.")},"onError")}),le=r(()=>{V.current=!1,g(null),H()},"clearActiveSession"),ce=Ne({mutationFn:r(()=>Vt.cancelClaudeSetupTokenLogin(e,f),"mutationFn"),onSuccess:r(()=>{le()},"onSuccess"),onError:r(tt=>{if(tt instanceof wn&&tt.status===404){le();return}y(tt instanceof Error?tt.message:"Could not cancel the login.")},"onError")}),te=(0,u.useCallback)(tt=>{Vt.cancelClaudeSetupTokenLogin(e,tt).catch(()=>{})},[e]),ae=Z({queryKey:["claude-setup-token-active-session",e],queryFn:r(async()=>{try{const tt=await Vt.getActiveClaudeSetupTokenLoginSession(e);if(!tt)return null;if(h&&tt.environmentId!==n||!!tt.aiConnection!=!!h||h&&(tt.aiConnection?.provider!==h.provider||tt.aiConnection?.method!==h.method||tt.aiConnection?.connectionId!==h.connectionId||tt.aiConnection?.ownership!==h.ownership||tt.aiConnection?.allAgents!==h.allAgents||JSON.stringify(tt.aiConnection?.agentIds)!==JSON.stringify(h.agentIds)))throw new Error("Another sign-in attempt is active. Finish or cancel it in its original account setup before starting this one.");return tt}catch(tt){if(tt instanceof wn&&tt.status===404)return null;throw tt}},"queryFn"),retry:!1,gcTime:0,staleTime:0}),[de,J]=(0,u.useState)(!1),Y=!!f&&!$&&!q&&!de,G=Z({queryKey:["claude-setup-token-status",e,f],queryFn:r(()=>Vt.getClaudeSetupTokenLoginStatus(e,f),"queryFn"),enabled:Y,retry:r((tt,Se)=>Se instanceof wn&&Se.status===404?!1:tt<3,"retry"),refetchInterval:r(tt=>{if($||q)return!1;const Se=tt.state.data?.status;return Se&&KF.has(Se)?!1:VF},"refetchInterval")});(0,u.useEffect)(()=>{const tt=G.error;if(tt instanceof wn&&tt.status===404){if(V.current){if(de)return;J(!0);const Se=f;(async()=>(Se&&await Vt.cancelClaudeSetupTokenLogin(e,Se).catch(()=>{}),J(!1),le()))();return}B(!0)}},[G.error,de,f,e]);const fe=(0,u.useRef)(!1);(0,u.useEffect)(()=>{if(fe.current||!ae.isFetched)return;fe.current=!0;const tt=ae.data;tt&&(V.current=!0,H(),g(tt.sessionId),tt.prompt&&(S(tt.prompt.authorizationUrl),tt.prompt.transportAdvisory&&N(!0)))},[ae.isFetched,ae.data]);const se=Z({queryKey:["claude-setup-token-prompt",e,f],enabled:Y&&!w,queryFn:r(async()=>{try{return await Vt.getClaudeSetupTokenLoginPrompt(e,f)}catch(tt){if(tt instanceof wn&&tt.status===404)return null;throw tt}},"queryFn"),refetchInterval:r(tt=>$||tt.state.data?.authorizationUrl?!1:VF,"refetchInterval")});(0,u.useEffect)(()=>{const tt=se.data?.authorizationUrl??null;tt&&S(tt),se.data?.transportAdvisory&&N(!0)},[se.data]);const re=Ne({mutationFn:r(tt=>Vt.submitClaudeSetupTokenBrowserCode(e,f,tt),"mutationFn"),onError:r(tt=>{y(tt instanceof Error?tt.message:"Could not submit the browser code.")},"onError")}),ie=Ne({mutationFn:r(()=>Vt.completeClaudeSetupTokenLogin(e,f),"mutationFn"),onSuccess:r(tt=>{A(tt.storedSessionId),a?.(tt.storedSessionId)},"onSuccess"),onError:r(()=>{I(!0)},"onError")}),me=G.data?.status??X.data?.status??null,pe=G.data?.expiresAt??X.data?.expiresAt??null,be=(0,u.useRef)(ie.mutate);be.current=ie.mutate,(0,u.useEffect)(()=>{me==="authenticated"&&!K.current&&(K.current=!0,be.current())},[me]);const oe=C!==null,ye=T||q||!!(me&&lGe.has(me)),Ae=me==="authenticated"&&!oe&&!T,xe=!!f&&!oe&&!ye&&!$,_e=X.isPending||xe;(0,u.useEffect)(()=>{if(!xe)return;const tt=pe!==null?new Date(pe).getTime():NaN,Se=Number.isFinite(tt)?Math.max(0,tt-Date.now()):cGe,ke=setTimeout(()=>{f&&te(f),O(!0)},Se);return()=>clearTimeout(ke)},[xe,pe,f,te]);const Ge=_.trim(),$e=xe&&!!w&&!Ae&&KIe(Ge)&&!re.isPending&&!L,Ye=(0,u.useRef)(c);Ye.current=c;const ue=(0,u.useRef)(d);ue.current=d;const Oe=r(()=>{$e&&(y(null),re.mutate(Ge),E(!0),Ye.current?.(),m!=="onboarding"&&R(""))},"handleSubmit"),dt=(0,u.useRef)(!1),xt=(0,u.useRef)(X.mutate);xt.current=X.mutate,(0,u.useEffect)(()=>{if(!(!o||dt.current)){if(ae.isError){dt.current=!0,y(ae.error instanceof Error?ae.error.message:"Could not check for an active login.");return}ae.isSuccess&&(dt.current=!0,!ae.data&&xt.current())}},[o,ae.isSuccess,ae.isError,ae.data,ae.error]);const De=(0,u.useRef)(Oe);De.current=Oe;const Qe=m==="onboarding",ht=(0,u.useRef)(!1);(0,u.useEffect)(()=>{!Qe||!ht.current||(ht.current=!1,$e&&De.current())},[Qe,$e,_]);const We=(0,u.useRef)(!1),Ke=(0,u.useRef)(l);Ke.current=l,(0,u.useEffect)(()=>{!oe||We.current||(We.current=!0,Ke.current?.(f??void 0))},[oe]),(0,u.useEffect)(()=>{L&&(!v&&!ye&&!$||(E(!1),ue.current?.()))},[L,v,ye,$]);const gt=(0,u.useRef)(p);if(gt.current=p,(0,u.useEffect)(()=>{gt.current?.(w)},[w]),m==="onboarding"){const tt=ye||$;return(0,t.jsxs)(Lfe,{loading:!w&&!v&&!tt,providerName:Mfe(s),authorizationUrl:w??void 0,mode:"submitted_code",children:[j&&(0,t.jsxs)("p",{className:"flex items-start gap-2 pl-2 text-xs text-amber-700 dark:text-amber-200",children:[(0,t.jsx)(Is,{className:"mt-0.5 size-3 shrink-0"}),"This connection is not encrypted. The login code travels in clear text on this network. Continue only on a network you trust."]}),v?(0,t.jsx)("p",{role:"alert",className:"pl-2 text-xs text-destructive",children:v}):tt?(0,t.jsx)("p",{role:"alert",className:"pl-2 text-xs text-destructive",children:$&&!ye?fJ:pJ}):(0,t.jsx)(cE,{value:_,onChange:R,onSubmit:Oe,onPaste:r(()=>{ht.current=!0},"onPaste"),masked:!0,disabled:re.isPending||Ae||L})]})}return(0,t.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 px-3 py-2 flex flex-col gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-foreground",children:_xe(s)}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[xe&&(0,t.jsx)(F,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground hover:text-foreground",disabled:ce.isPending,onClick:r(()=>ce.mutate(),"onClick"),children:"Cancel"}),i&&ee&&!xe&&!oe&&!z&&(0,t.jsx)(F,{type:"button",variant:"default",size:"sm",className:"h-7 px-2.5 text-xs",onClick:r(()=>{i(),D(!0)},"onClick"),children:"Use saved login"}),(0,t.jsx)(F,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2.5 text-xs",disabled:_e,onClick:r(()=>X.mutate(),"onClick"),children:ee&&!xe&&!oe?"Sign in to replace":"Sign in"})]})]}),ee&&!xe&&!oe&&!z&&(0,t.jsx)("div",{className:"text-(length:--text-micro) text-muted-foreground",children:"You have a saved Claude login. Use it to bind this agent, or log in again to replace the stored token."}),z&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-foreground",children:[(0,t.jsx)(ds,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{children:"The saved Claude login is bound to this agent now."})]}),v&&(0,t.jsx)("div",{role:"alert",className:"text-(length:--text-micro) text-destructive",children:v}),(0,t.jsxs)("div",{role:"status","aria-live":"polite",className:"space-y-2 empty:hidden",children:[xe&&!w&&!Ae&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-muted-foreground",children:[(0,t.jsx)(at,{className:"size-3 animate-spin shrink-0"}),(0,t.jsx)("span",{children:"Preparing..."})]}),xe&&w&&!Ae&&(0,t.jsxs)("div",{className:"space-y-2",children:[j&&(0,t.jsxs)("div",{className:"flex items-start gap-2 rounded-md border border-amber-300 bg-amber-50 px-2 py-1.5 text-(length:--text-micro) text-amber-800 dark:border-amber-500/40 dark:bg-amber-500/10 dark:text-amber-200",children:[(0,t.jsx)(Is,{className:"size-3 shrink-0 mt-0.5"}),(0,t.jsx)("span",{children:"This connection is not encrypted. The login code travels in clear text on this network. Continue only on a network you trust."})]}),(0,t.jsx)("div",{className:"text-(length:--text-micro) text-muted-foreground",children:"Open the authorization page, then enter the browser code it shows."}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("div",{className:"text-(length:--text-micro) uppercase tracking-wide text-muted-foreground",children:"1. Authorization URL"}),(0,t.jsx)("span",{className:"font-mono text-xs text-foreground break-all",children:w})]}),(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsx)(WF,{value:w,label:"Copy URL"}),(0,t.jsx)(F,{asChild:!0,type:"button",variant:"ghost",size:"icon-xs","aria-label":"Open the authorization page",title:"Open the authorization page",className:"text-muted-foreground hover:text-foreground",children:(0,t.jsx)("a",{href:w,target:"_blank",rel:"noreferrer noopener",children:(0,t.jsx)(xr,{className:"size-3"})})})]})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("div",{className:"text-(length:--text-micro) uppercase tracking-wide text-muted-foreground",children:"2. Browser code"}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("input",{"aria-label":"Browser code",type:"text",autoComplete:"off",spellCheck:!1,value:_,onChange:r(tt=>R(tt.target.value),"onChange"),onKeyDown:r(tt=>{tt.key==="Enter"&&(tt.preventDefault(),Oe())},"onKeyDown"),className:"flex-1 min-w-0 rounded-md border border-border bg-background px-2 py-1 font-mono text-xs text-foreground"}),(0,t.jsx)(F,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2.5 text-xs",disabled:!$e,onClick:Oe,children:"Submit"})]})]})]}),Ae&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-muted-foreground",children:[(0,t.jsx)(at,{className:"size-3 animate-spin shrink-0"}),(0,t.jsx)("span",{children:"Completing the login…"})]}),oe&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-foreground",children:[(0,t.jsx)(ds,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{children:"Authenticated. The environment has credentials now."})]}),ye&&(0,t.jsxs)("div",{className:"flex items-start gap-2 text-(length:--text-micro) text-destructive",children:[(0,t.jsx)(Is,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{children:pJ})]}),$&&!ye&&!oe&&(0,t.jsxs)("div",{className:"flex items-start gap-2 text-(length:--text-micro) text-destructive",children:[(0,t.jsx)(Is,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{children:fJ})]})]})]})}r(dGe,"SubmittedBrowserCodeLoginPanel");function uGe({result:e}){const s=e.status==="pass"?"Passed":e.status==="warn"?"Warnings":"Failed",n=e.status==="pass"?"text-green-700 dark:text-green-300 border-green-300 dark:border-green-500/40 bg-green-50 dark:bg-green-500/10":e.status==="warn"?"text-amber-700 dark:text-amber-300 border-amber-300 dark:border-amber-500/40 bg-amber-50 dark:bg-amber-500/10":"text-red-700 dark:text-red-300 border-red-300 dark:border-red-500/40 bg-red-50 dark:bg-red-500/10";return(0,t.jsxs)("div",{className:`rounded-md border px-3 py-2 text-xs ${n}`,children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("span",{className:"font-medium",children:s}),(0,t.jsx)("span",{className:"text-(length:--text-micro) opacity-80",children:new Date(e.testedAt).toLocaleTimeString()})]}),(0,t.jsx)("div",{className:"mt-2 space-y-1.5",children:e.checks.map((a,i)=>(0,t.jsxs)("div",{className:"text-(length:--text-micro) leading-relaxed break-words",children:[(0,t.jsx)("span",{className:"font-medium uppercase tracking-wide opacity-80",children:a.level}),(0,t.jsx)("span",{className:"mx-1 opacity-60",children:"·"}),(0,t.jsx)("span",{children:a.message}),a.detail&&(0,t.jsxs)("span",{className:"block opacity-75 break-all",children:["(",a.detail,")"]}),a.hint&&(0,t.jsxs)("span",{className:"block opacity-90 break-words",children:["Hint: ",a.hint]})]},`${a.code}-${i}`))})]})}r(uGe,"AdapterEnvironmentResult$1");function Ixe({value:e,onChange:s,disabledTypes:n}){const[a,i]=(0,u.useState)(!1),o=Um(e),l=(0,u.useMemo)(()=>Nxe(c=>gw[c]??mf(c)).filter(c=>!n.has(c.value)),[n]);return(0,t.jsxs)(Zn,{open:a,onOpenChange:i,children:[(0,t.jsx)(ur,{asChild:!0,children:(0,t.jsxs)("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-sm hover:bg-accent/50 transition-colors w-full justify-between",children:[(0,t.jsxs)("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[e==="opencode_local"?(0,t.jsx)(IF,{className:"h-3.5 w-3.5"}):null,(0,t.jsx)("span",{className:"truncate",children:gw[e]??mf(e)}),o.experimental&&(0,t.jsx)(xJ,{})]}),(0,t.jsx)(sn,{className:"h-3 w-3 text-muted-foreground"})]})}),(0,t.jsx)(Vn,{className:"w-(--radix-popover-trigger-width) p-1",align:"start",children:l.map(c=>(0,t.jsxs)("button",{disabled:c.comingSoon,className:U("flex items-center justify-between w-full px-2 py-1.5 text-sm rounded",c.comingSoon?"opacity-40 cursor-not-allowed":"hover:bg-accent/50",c.value===e&&!c.comingSoon&&"bg-accent"),onClick:r(()=>{c.comingSoon||(s(c.value),i(!1))},"onClick"),children:[(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[c.value==="opencode_local"?(0,t.jsx)(IF,{className:"h-3.5 w-3.5"}):null,(0,t.jsx)("span",{children:c.label}),c.experimental&&(0,t.jsx)(xJ,{})]}),c.comingSoon&&(0,t.jsx)("span",{className:"text-(length:--text-nano) text-muted-foreground",children:"Coming soon"})]},c.value))})]})}r(Ixe,"AdapterTypeDropdown");function xJ(){return(0,t.jsx)("span",{className:"shrink-0 rounded border border-amber-500/30 bg-amber-500/10 px-1.5 py-0.5 text-(length:--text-nano) font-medium leading-none text-amber-700 dark:text-amber-200",children:"Experimental"})}r(xJ,"ExperimentalBadge$1");function SK({models:e,value:s,onChange:n,open:a,onOpenChange:i,allowDefault:o,required:l,groupByProvider:c,creatable:d,detectedModel:m,detectedModelCandidates:h,onDetectModel:p,onRefreshModels:f,refreshingModels:g,detectModelLabel:v,emptyDetectHint:y,defaultLabel:w}){const[S,j]=(0,u.useState)(""),[N,_]=(0,u.useState)(!1),R=e.find(L=>L.id===s),C=S.trim(),A=!!(d&&C&&!e.some(L=>L.id.toLowerCase()===C.toLowerCase())),T=(0,u.useMemo)(()=>{const L=new Set;m&&L.add(m);for(const E of h??[])E&&L.add(E);return L},[m,h]),I=(0,u.useMemo)(()=>e.filter(L=>{if(T.has(L.id))return!1;if(!S.trim())return!0;const E=S.toLowerCase(),q=YO(L.id)??"";return L.id.toLowerCase().includes(E)||L.label.toLowerCase().includes(E)||q.toLowerCase().includes(E)}),[e,S,T]),$=(0,u.useMemo)(()=>{if(!c)return[{provider:"models",entries:[...I].sort((E,q)=>E.id.localeCompare(q.id))}];const L=new Map;for(const E of I){const q=YO(E.id)??"other",B=L.get(q)??[];B.push(E),L.set(q,B)}return Array.from(L.entries()).sort(([E],[q])=>E.localeCompare(q)).map(([E,q])=>({provider:E,entries:[...q].sort((B,K)=>B.id.localeCompare(K.id))}))},[I,c]);async function O(){if(p){_(!0);try{const L=await p();L&&(n(L),i(!1),j(""))}finally{_(!1)}}}return r(O,"handleDetectModel"),(0,t.jsx)(ys,{label:"Model",hint:fi.model,children:(0,t.jsxs)(Zn,{open:a,onOpenChange:r(L=>{i(L),L||j("")},"onOpenChange"),children:[(0,t.jsx)(ur,{asChild:!0,children:(0,t.jsxs)("button",{type:"button",className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-sm hover:bg-accent/50 transition-colors w-full justify-between",children:[(0,t.jsx)("span",{className:U(!s&&"text-muted-foreground"),children:R?R.label:s||(o?w??"Default":l?"Select model (required)":"Select model")}),(0,t.jsx)(sn,{className:"h-3 w-3 text-muted-foreground"})]})}),(0,t.jsxs)(Vn,{className:"w-(--radix-popover-trigger-width) p-1",align:"start",children:[(0,t.jsxs)("div",{className:"relative mb-1",children:[(0,t.jsx)("input",{className:"w-full px-2 py-1.5 pr-6 text-xs bg-transparent outline-none border-b border-border placeholder:text-muted-foreground/50",placeholder:d?"Search models... (type to create)":"Search models...",value:S,onChange:r(L=>j(L.target.value),"onChange"),autoFocus:!0}),S&&(0,t.jsx)("button",{type:"button",className:"absolute right-1.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",onClick:r(()=>j(""),"onClick"),children:(0,t.jsxs)("svg",{"aria-hidden":"true",focusable:"false",className:"h-3 w-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,t.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),p&&!S.trim()&&(0,t.jsxs)("button",{type:"button",className:"flex items-center gap-1.5 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50 text-muted-foreground",onClick:r(()=>{O()},"onClick"),disabled:N,children:[(0,t.jsxs)("svg",{"aria-hidden":"true",focusable:"false",className:"h-3 w-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),(0,t.jsx)("path",{d:"M3 3v5h5"})]}),N?"Detecting...":m?v?.replace(/^Detect\b/,"Re-detect")??"Re-detect from config":v??"Detect from config"]}),f&&!S.trim()&&(0,t.jsxs)("button",{type:"button",className:"flex items-center gap-1.5 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50 text-muted-foreground",onClick:r(()=>{f()},"onClick"),disabled:g,children:[(0,t.jsxs)("svg",{"aria-hidden":"true",focusable:"false",className:"h-3 w-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M3 12a9 9 0 0 1 15.28-6.36L21 8"}),(0,t.jsx)("path",{d:"M21 3v5h-5"}),(0,t.jsx)("path",{d:"M21 12a9 9 0 0 1-15.28 6.36L3 16"}),(0,t.jsx)("path",{d:"M8 16H3v5"})]}),g?"Refreshing...":"Refresh models"]}),s&&(!e.some(L=>L.id===s)||T.has(s))&&(0,t.jsxs)("button",{type:"button",className:U("flex items-center w-full px-2 py-1.5 text-sm rounded bg-accent/50"),onClick:r(()=>{i(!1)},"onClick"),children:[(0,t.jsx)("span",{className:"block w-full text-left truncate font-mono text-xs",title:s,children:e.find(L=>L.id===s)?.label??s}),(0,t.jsx)(lt,{variant:"outline",className:"ml-auto text-(length:--text-nano) px-1.5 bg-green-500/15 text-green-400 border-green-500/20",children:"current"})]}),m&&m!==s&&(0,t.jsxs)("button",{type:"button",className:U("flex items-center w-full px-2 py-1.5 text-sm rounded hover:bg-accent/50"),onClick:r(()=>{n(m),i(!1)},"onClick"),children:[(0,t.jsx)("span",{className:"block w-full text-left truncate font-mono text-xs",title:m,children:e.find(L=>L.id===m)?.label??m}),(0,t.jsx)(lt,{variant:"outline",className:"ml-auto text-(length:--text-nano) px-1.5 bg-blue-500/15 text-blue-400 border-blue-500/20",children:"detected"})]}),h?.filter(L=>L&&L!==m&&L!==s).map(L=>{const E=e.find(q=>q.id===L);return(0,t.jsxs)("button",{type:"button",className:U("flex items-center w-full px-2 py-1.5 text-sm rounded hover:bg-accent/50"),onClick:r(()=>{n(L),i(!1)},"onClick"),children:[(0,t.jsx)("span",{className:"block w-full text-left truncate font-mono text-xs",title:L,children:E?.label??L}),(0,t.jsx)(lt,{variant:"outline",className:"ml-auto text-(length:--text-nano) px-1.5 bg-sky-500/15 text-sky-400 border-sky-500/20",children:"config"})]},`detected-${L}`)}),(0,t.jsxs)("div",{className:"max-h-(--sz-240px) overflow-y-auto",children:[o&&(0,t.jsx)("button",{type:"button",className:U("flex items-center gap-2 w-full px-2 py-1.5 text-sm rounded hover:bg-accent/50",!s&&"bg-accent"),onClick:r(()=>{n(""),i(!1)},"onClick"),children:"Default"}),A&&(0,t.jsxs)("button",{type:"button",className:"flex items-center justify-between gap-2 w-full px-2 py-1.5 text-sm rounded hover:bg-accent/50",onClick:r(()=>{n(C),i(!1),j("")},"onClick"),children:[(0,t.jsx)("span",{children:"Use manual model"}),(0,t.jsx)("span",{className:"text-xs font-mono text-muted-foreground",children:C})]}),$.map(L=>(0,t.jsxs)("div",{className:"mb-1 last:mb-0",children:[c&&(0,t.jsxs)("div",{className:"px-2 py-1 text-(length:--text-nano) uppercase tracking-wide text-muted-foreground",children:[L.provider," (",L.entries.length,")"]}),L.entries.map(E=>(0,t.jsx)("button",{type:"button",className:U("flex items-center w-full px-2 py-1.5 text-sm rounded hover:bg-accent/50",E.id===s&&"bg-accent"),onClick:r(()=>{n(E.id),i(!1)},"onClick"),children:(0,t.jsx)("span",{className:"block w-full text-left truncate",title:E.id,children:c?GBe(E.id):E.label})},E.id))]},L.provider)),I.length===0&&!A&&T.size===0&&(0,t.jsx)("div",{className:"px-2 py-2 space-y-2",children:(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:p?y??"No model detected yet. Enter a provider/model manually.":"No models found."})})]})]})]})})}r(SK,"ModelDropdown");function mGe({value:e,options:s,onChange:n,open:a,onOpenChange:i}){const o=s.find(l=>l.id===e)??s[0];return(0,t.jsx)(ys,{label:"Thinking effort",hint:fi.thinkingEffort,children:(0,t.jsxs)(Zn,{open:a,onOpenChange:i,children:[(0,t.jsx)(ur,{asChild:!0,children:(0,t.jsxs)("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-sm hover:bg-accent/50 transition-colors w-full justify-between",children:[(0,t.jsx)("span",{className:U(!e&&"text-muted-foreground"),children:o?.label??"Auto"}),(0,t.jsx)(sn,{className:"h-3 w-3 text-muted-foreground"})]})}),(0,t.jsx)(Vn,{className:"w-(--radix-popover-trigger-width) p-1",align:"start",children:s.map(l=>(0,t.jsxs)("button",{className:U("flex items-center justify-between w-full px-2 py-1.5 text-sm rounded hover:bg-accent/50",l.id===e&&"bg-accent"),onClick:r(()=>{n(l.id),i(!1)},"onClick"),children:[(0,t.jsx)("span",{children:l.label}),l.id?(0,t.jsx)("span",{className:"text-xs text-muted-foreground font-mono",children:l.id}):null]},l.id||"auto"))})]})})}r(mGe,"ThinkingEffortDropdown");function Axe(e){const s=`paperclip.agent-appearance.${e}`;function n(){try{const l=Mle.safeParse(JSON.parse(sessionStorage.getItem(s)??"null"));if(l.success)return l.data}catch{}const o=m2();try{sessionStorage.setItem(s,JSON.stringify(o))}catch{}return o}r(n,"readDraft");const[a,i]=(0,u.useState)(()=>({key:s,appearance:n()}));return a.key!==s&&i({key:s,appearance:n()}),{appearance:a.appearance,clear(){try{sessionStorage.removeItem(s)}catch{}}}}r(Axe,"useAgentAppearanceDraft");var ak=null,jI=new Set,ik={subscribe(e){return jI.add(e),()=>{jI.delete(e)}},getSnapshot(){return ak},acquire(e){if(ak)return!1;ak=e;for(const s of jI)s();return!0},release(e){if(ak===e){ak=null;for(const s of jI)s()}}};function jC({agent:e,appearance:s,size:n=256,state:a="idle",muted:i=!1,motion:o="auto",trackingRegion:l,trackingScope:c="region",followCursor:d=!0,followRotation:m=!0,className:h,label:p,name:f}){const g=(0,u.useMemo)(()=>Bw(s??e?.appearance,e?.id),[s,e?.appearance,e?.id]),v=(0,u.useRef)(null),y=(0,u.useRef)(null),w=(0,u.useRef)(null),S=(0,u.useRef)(Symbol("agent-character")),j=(0,u.useSyncExternalStore)(ik.subscribe,ik.getSnapshot,()=>null),[N,_]=(0,u.useState)(!1),[R,C]=(0,u.useState)(!0),[A,T]=(0,u.useState)(!1),[I,$]=(0,u.useState)(!1),O=N&&!R&&!A&&o==="auto"&&a!=="rest";return(0,u.useEffect)(()=>{if(typeof matchMedia!="function"||typeof IntersectionObserver!="function")return;const L=matchMedia("(prefers-reduced-motion: reduce)"),E=r(()=>C(L.matches),"change");E(),L.addEventListener("change",E);const q=new IntersectionObserver(B=>_(B[0]?.isIntersecting??!1));return v.current&&q.observe(v.current),()=>{q.disconnect(),L.removeEventListener("change",E)}},[]),(0,u.useEffect)(()=>{O&&j===null&&ik.acquire(S.current),O||ik.release(S.current)},[O,j]),(0,u.useEffect)(()=>()=>ik.release(S.current),[]),(0,u.useEffect)(()=>{if(!O||j!==S.current)return;let L=!1;return $(!1),Promise.all([jc(()=>import("./runtime-IAg0vdY9.js"),__vite__mapDeps([0,1])),jc(()=>import("./definition-fKtTXfBN.js"),__vite__mapDeps([2,3,1]))]).then(([E,q])=>{L||!y.current||(w.current=E.createCharacter(y.current,q.characterDefinition(g,i),{animation:q.animationId(a),trackingRegion:l?.current??v.current??void 0,followCursor:d,followRotation:m,trackingScope:c,displaySize:n,onError:r(()=>T(!0),"onError")}),$(!0))}).catch(()=>{L||T(!0)}),()=>{L=!0,w.current?.destroy(),w.current=null,$(!1)}},[O,j,l,c,n,d,m]),(0,u.useEffect)(()=>{w.current&&jc(()=>import("./definition-fKtTXfBN.js").then(L=>{w.current?.setDefinition(L.characterDefinition(g,i)),w.current?.setAnimation(L.animationId(a))}),__vite__mapDeps([2,3,1]))},[g,i,a,I]),(0,t.jsxs)("span",{ref:v,role:p?"img":void 0,"aria-label":p,"aria-hidden":p?void 0:!0,className:U("relative inline-block shrink-0",G2e[n],h),children:[(0,t.jsx)(gr,{agent:e,appearance:g,size:n<256?256:n,name:f,pose:a,muted:i,className:U("size-full",I&&"invisible")}),(0,t.jsx)("span",{ref:y,className:"absolute inset-0"})]})}r(jC,"AgentCharacter");var hGe=new Set(["claude_local","codex_local","opencode_local","grok_local"]);function Rxe(e,{cloud:s,nativeRunnerEnabled:n}){return s?hGe.has(e):e!=="paperclip_runner"||n}r(Rxe,"isNewAgentAdapterAllowed");var pGe={claude_local:{src:"/brands/claude-color.svg"},codex_local:{src:"/brands/codex-color.svg"},gemini_local:{src:"/brands/adapters/gemini-color.svg"},kimi_local:{src:"/brands/adapters/kimi-color-light.svg",dark:"/brands/adapters/kimi-color.svg"},...Object.fromEntries([["cursor","cursor"],["cursor_cloud","cursor"],["grok_local","grok"],["hermes_local","hermesagent"],["hermes_gateway","hermesagent"],["pi_local","pi"]].map(([e,s])=>[e,{src:`/brands/adapters/${s}.svg`,dark:`/brands/adapters/${s}-dark.svg`}]))};function CK({type:e,className:s="size-6"}){const n=Um(e).icon,a=pGe[e];return a?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("img",{src:a.src,className:U("shrink-0 object-contain",a.dark&&"dark:hidden",s),alt:""}),a.dark&&(0,t.jsx)("img",{src:a.dark,className:U("hidden shrink-0 object-contain dark:block",s),alt:""})]}):(0,t.jsx)(n,{className:s})}r(CK,"AdapterMark");function fGe(){const{selectedCompanyId:e}=ps(),{appearance:s}=Axe(`${e}:new-agent`);return(0,t.jsx)(jC,{appearance:s,state:"sleepy",muted:!0,size:256,className:"size-48",trackingScope:"page"})}r(fGe,"AgentBasicsCharacter");function Txe({open:e,onClose:s,onContinue:n,initialAdapter:a="",onInvite:i}){const o=(0,u.useId)(),l=!!Yc(),c=Z({queryKey:P.instance.experimentalSettings,queryFn:Er.getExperimental,enabled:e,retry:!1}),[d,m]=(0,u.useState)(""),[h,p]=(0,u.useState)(a),[f,g]=(0,u.useState)("codex"),[v,y]=(0,u.useState)("name"),{data:w,isPending:S,error:j}=Z({queryKey:P.adapters.all,queryFn:Rm.list,enabled:e}),N=(w??[]).filter(R=>R.loaded&&!R.disabled&&Rxe(R.type,{cloud:l,nativeRunnerEnabled:c.data?.enableNativeRunner===!0})&&!["process","http"].includes(R.type)&&!Um(R.type).comingSoon),_=N.some(R=>R.type===h);return(0,t.jsx)(Ys,{open:e,onOpenChange:r(R=>{R||s()},"onOpenChange"),children:(0,t.jsxs)(Js,{className:U("flex max-h-(--sz-calc-18) flex-col gap-0 overflow-hidden p-0 sm:max-w-(--sz-640px)",v==="name"&&"sm:max-w-(--sz-560px)"),children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 px-6 py-5 text-xs text-muted-foreground","aria-label":"New agent progress",children:[(0,t.jsx)("span",{className:U(v==="name"&&"font-medium text-foreground"),children:"1. Name"}),(0,t.jsx)(Tn,{className:"size-3"}),(0,t.jsx)("span",{className:U(v==="adapter"&&"font-medium text-foreground"),children:"2. Adapter"})]}),(0,t.jsxs)("form",{className:"flex min-h-0 flex-col",onSubmit:r(R=>{R.preventDefault(),d.trim()&&(v==="name"?y("adapter"):_&&n({name:d.trim(),adapterType:h,runnerProvider:f}))},"onSubmit"),children:[(0,t.jsxs)("div",{className:"flex min-h-0 flex-col gap-7 overflow-y-auto px-6 pb-8 sm:px-10",children:[(0,t.jsxs)("div",{className:"flex flex-col items-center gap-4 text-center",children:[e&&(0,t.jsx)(fGe,{}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(tn,{className:"text-3xl font-semibold tracking-tight",children:v==="name"?"Meet your next agent":"Choose an adapter"}),(0,t.jsx)(Ln,{className:"text-base",children:v==="name"?"Start with a name. Make them your own.":`How should ${d.trim()} work?`})]})]}),v==="name"?(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("label",{htmlFor:o,className:"text-sm font-medium",children:"Agent name"}),(0,t.jsx)(At,{id:o,autoFocus:!0,maxLength:100,placeholder:"e.g. Darnold",value:d,onChange:r(R=>m(R.target.value),"onChange"),className:"h-12 text-base"}),i&&(0,t.jsx)(F,{type:"button",variant:"link",className:"px-0 text-muted-foreground",onClick:i,children:"Invite an external agent"})]}):(0,t.jsxs)("fieldset",{className:"space-y-4",children:[(0,t.jsx)("legend",{className:"sr-only",children:"Adapter"}),S&&(0,t.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:"Loading adapters…"}),j&&(0,t.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:j.message}),(0,t.jsx)("div",{className:U("grid grid-cols-2 gap-3",N.length!==4&&"sm:grid-cols-3"),children:N.map(R=>{const C=Um(R.type);return(0,t.jsxs)("label",{className:"relative cursor-pointer",children:[(0,t.jsx)("input",{type:"radio",name:"new-agent-adapter",value:R.type,checked:h===R.type,onChange:r(()=>p(R.type),"onChange"),className:"peer sr-only"}),(0,t.jsxs)("span",{className:U("flex h-full flex-col items-center gap-2 rounded-lg border px-3 py-4 text-center peer-focus-visible:ring-2 peer-focus-visible:ring-ring hover:bg-accent/40",h===R.type?"border-foreground/40 bg-accent":"border-border bg-card"),children:[(0,t.jsx)(CK,{type:R.type}),(0,t.jsx)("span",{className:"text-sm font-medium",children:C.label}),h===R.type&&(0,t.jsx)(ds,{className:"absolute right-2 top-2 size-3.5"})]})]},R.type)})}),_&&h==="paperclip_runner"&&(0,t.jsxs)("label",{className:"flex flex-col gap-2 text-sm font-medium",children:["Runner",(0,t.jsxs)("select",{className:"rounded-md border border-border bg-background px-3 py-2",value:f,onChange:r(R=>g(R.target.value),"onChange"),children:[(0,t.jsx)("option",{value:"codex",children:"Codex (app server)"}),(0,t.jsx)("option",{value:"claude",children:"Claude (ACPX)"}),(0,t.jsx)("option",{value:"opencode",children:"OpenCode"})]})]})]})]}),(0,t.jsxs)("div",{className:"flex justify-between gap-4 border-t border-border px-6 py-4",children:[(0,t.jsx)(F,{type:"button",variant:"ghost",onClick:r(()=>v==="name"?s():y("name"),"onClick"),children:v==="name"?"Cancel":(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Sl,{className:"size-4"}),"Back"]})}),(0,t.jsxs)(F,{type:"submit",disabled:!d.trim()||v==="adapter"&&!_,children:[v==="name"?"Choose adapter":"Configure agent",(0,t.jsx)(zo,{className:"size-4"})]})]})]})]})})}r(Txe,"AgentBasicsDialog");var xGe={subscription:"Subscription",api:"API"};function gGe({mode:e}){return(0,t.jsx)("span",{className:"relative flex h-4 w-full items-center justify-center overflow-hidden text-(length:--text-micro) text-muted-foreground",children:(0,t.jsx)(dN,{initial:!1,mode:"sync",children:(0,t.jsx)(Zo.span,{className:"absolute inset-0 flex items-center justify-center whitespace-nowrap",initial:{opacity:0,y:EY},animate:{opacity:1,y:0,transition:z7e},exit:{opacity:0,y:EY,transition:U7e},children:xGe[e]},e)})})}r(gGe,"CredentialTag");function bGe({source:e,mode:s,selected:n,onSelect:a,buttonRef:i,settling:o}){return(0,t.jsxs)("button",{ref:i,type:"button",role:"radio","aria-checked":n,onClick:a,className:U("flex min-w-0 flex-1 cursor-pointer flex-col items-center gap-1.5 self-stretch rounded-md border p-3","transition-(--tp-border-color-background-color) ease-(--motion-ease-standard)",o?"duration-(--motion-duration-slow)":"duration-(--motion-duration-fast)","outline-none focus-visible:ring-ring/50 focus-visible:ring-(length:--rad-3)",n?"border-foreground/40 bg-accent":"border-border bg-card hover:bg-accent/40"),children:[(0,t.jsx)("span",{className:"flex size-(--sz-30px) shrink-0 items-center justify-center",children:e.icon}),(0,t.jsx)("span",{className:"text-(length:--text-compact) font-medium text-foreground",children:e.label}),(0,t.jsx)(gGe,{mode:s})]})}r(bGe,"ModelSourceTile");function Exe({sources:e,mode:s,selectedId:n,onSelect:a,label:i,collapsed:o=!1,settling:l=!1}){const c=(0,u.useRef)(new Map),d=r(h=>{if(e.length===0)return;const p=e.findIndex(g=>g.id===n),f=e[((p===-1?h>0?-1:0:p)+h+e.length)%e.length];a(f.id),c.current.get(f.id)?.focus()},"moveSelection"),m=o?e.filter(h=>h.id===n):e;return(0,t.jsx)("div",{role:"radiogroup","aria-label":i,className:U("flex items-start gap-3",o&&"justify-center"),onKeyDown:r(h=>{o||(h.key==="ArrowRight"||h.key==="ArrowDown"?(h.preventDefault(),d(1)):(h.key==="ArrowLeft"||h.key==="ArrowUp")&&(h.preventDefault(),d(-1)))},"onKeyDown"),children:(0,t.jsx)(dN,{initial:!1,mode:"popLayout",children:m.map(h=>(0,t.jsx)(Zo.div,{layout:!0,transition:Pfe,exit:{opacity:0,transition:Z7e},className:U("flex min-w-0",o?"w-(--sz-source-tile-two-up)":"flex-1"),children:(0,t.jsx)(bGe,{source:h,mode:s,selected:h.id===n,onSelect:r(()=>a(h.id),"onSelect"),settling:l,buttonRef:r(p=>{p?c.current.set(h.id,p):c.current.delete(h.id)},"buttonRef")})},h.id))})})}r(Exe,"ModelSourceTiles");var W4={subscription:"Use API key instead",api:"Use subscription instead"},vGe={subscription:"api",api:"subscription"};function Pxe({mode:e,onChange:s}){return(0,t.jsxs)("button",{type:"button",onClick:r(()=>s(vGe[e]),"onClick"),className:U("group grid cursor-pointer px-3 py-2 text-left text-sm font-medium","rounded-md outline-none focus-visible:ring-ring/50 focus-visible:ring-(length:--rad-3)"),children:[Object.keys(W4).map(n=>(0,t.jsx)("span",{"aria-hidden":!0,className:"invisible col-start-1 row-start-1 whitespace-nowrap",children:W4[n]},n)),(0,t.jsx)(dN,{initial:!1,mode:"sync",children:(0,t.jsx)(Zo.span,{className:U("col-start-1 row-start-1 justify-self-start whitespace-nowrap","underline decoration-muted-foreground/40 underline-offset-4","text-muted-foreground transition-colors","group-hover:text-foreground group-hover:decoration-foreground/40"),initial:{opacity:0},animate:{opacity:1,transition:pK},exit:{opacity:0,transition:K7e},children:W4[e]},e)})]})}r(Pxe,"CredentialModeLink");function Mxe({onBack:e,primaryLabel:s,primaryDisabled:n,loading:a,loadingLabel:i,primaryIcon:o,onPrimary:l}){const c=a&&i?i:s,d=o??(a?"spinner":"arrow");return(0,t.jsxs)("div",{className:"flex items-center justify-between pt-9",children:[e?(0,t.jsxs)(F,{variant:"ghost",size:"lg",className:"rounded-full has-[>svg]:pl-4 has-[>svg]:pr-5",onClick:e,disabled:a,children:[(0,t.jsx)(Sl,{className:"mr-1 size-3.5"}),"Back"]}):(0,t.jsx)("span",{}),(0,t.jsx)(Zo.div,{layout:!0,transition:H7e,className:"min-w-0",children:(0,t.jsx)(F,{size:"lg",className:"w-full rounded-full px-6",onClick:l,disabled:n||a,children:(0,t.jsxs)(Zo.span,{className:"flex items-center whitespace-nowrap",initial:{opacity:0},animate:{opacity:1},transition:Q7e,children:[d==="spinner"?(0,t.jsx)(at,{className:"mr-1 size-4 animate-spin"}):null,c,d==="arrow"?(0,t.jsx)(zo,{className:"ml-1 size-3.5"}):null]},`${c}:${d}`)})})]})}r(Mxe,"FooterNav");function Dxe({companyId:e,adapterType:s,environmentId:n,canLogin:a,localEnvironment:i=!1,onConnected:o,onBack:l,testConnection:c,testError:d,managedAccount:m}){const h=Z({queryKey:P.health,queryFn:sm.get,enabled:i}),p=i&&(h.data?.localAiLoginSupported??h.data?.deploymentMode==="local_trusted"),f=(0,u.useRef)(0);(0,u.useEffect)(()=>()=>{f.current++},[]);const g=r(()=>{f.current++,$(!1),S(!1),N(null),R("preparing")},"cancel"),[v,y]=(0,u.useState)(m?.initialMethod==="api_key"?"api":m?"subscription":null),[w,S]=(0,u.useState)(!1),[j,N]=(0,u.useState)(null),[_,R]=(0,u.useState)("preparing"),C=(0,u.useRef)("ready"),[A,T]=(0,u.useState)(""),[I,$]=(0,u.useState)(!1),[O,L]=(0,u.useState)(null),[E,q]=(0,u.useState)(null),B=s==="claude_local"?"Claude":s==="grok_local"?"Grok":"OpenAI",K=s==="claude_local"?"ANTHROPIC_API_KEY":s==="grok_local"?"XAI_API_KEY":"OPENAI_API_KEY",z=s==="claude_local"?"anthropic":s==="grok_local"?"xai":"openai",D=bfe(e,K),V=m?{...D,options:[],subscriptions:[],loading:!1}:D,[H,ee]=(0,u.useState)(null),X=V.subscriptions.length?V.subscriptions.find(re=>re.id===(H??V.subscriptions[0]?.id)):void 0,[le,ce]=(0,u.useState)(null),te=V.options.find(re=>re.id===(le??V.options[0]?.id)),ae=m?{...V.storedLogin,data:void 0,isPending:!1,isError:!1}:V.storedLogin,de=(0,u.useRef)(null),J=v??(V.subscriptions.length>0||s==="claude_local"&&!X&&ae.data?"subscription":V.options.length?"api":"subscription"),Y=Lhe(e,m?.intent??{provider:z,method:"subscription",name:`My ${B} subscription`,ownership:"personal",agentIds:[],allAgents:!0},p&&J==="subscription"&&!X&&!ae.data,{allowHostClaude:h.data?.deploymentMode==="local_trusted"}),G=Z({queryKey:P.agents.authSignal(e,s,n),queryFn:r(()=>Vt.getAdapterAuthSignal(e,s,n??void 0),"queryFn"),retry:!1,enabled:!m});async function fe(){if(I||m?.disabled)return;const re=++f.current;$(!0),L(null);try{if(m){if(J==="subscription"&&!p)return;const pe=de.current??await(J==="api"?mu.create(e,{...m.intent,method:"api_key",apiKey:A.trim()}):Y.connect(m.intent));de.current=pe,T(""),re===f.current&&m.onComplete({...pe,method:J==="api"?"api_key":"subscription"});return}let ie=J==="api"?te?te.aiConnection?{env:{},aiConnection:te.aiConnection}:{env:{[K]:te.binding}}:E??{env:{},credentials:{[K]:A.trim()}}:{...X?.aiConnection?{aiConnection:X.aiConnection}:{},env:X?.binding?{CODEX_HOME:X.binding}:{},...s==="claude_local"&&!X&&ae.data?{env:fj(),applyStoredClaudeLogin:!0}:{}};if(J==="subscription"&&p&&!X&&!ae.data&&(de.current??=await Y.connect(),ie={env:{},aiConnection:{provider:z,method:"subscription",mode:"responsible_user"}}),ie.credentials&&(await mu.create(e,{provider:z,method:"api_key",name:`My ${B} API`,ownership:"personal",apiKey:ie.credentials[K],agentIds:[],allAgents:!0}),ie={env:{},aiConnection:{provider:z,method:"api_key",mode:"responsible_user"}}),re!==f.current)return;J==="api"&&(T(""),te||q(ie));const me=await c(ie);if(re!==f.current)return;me?o(ie):L("The provider did not respond. Check the connection and try again.")}catch(ie){if(re!==f.current)return;m&&T(""),L(ie instanceof Error?ie.message:"Could not connect to the provider.")}finally{re===f.current&&$(!1)}}r(fe,"connect");const se=J==="subscription"&&a&&n&&!X&&!V.loading&&!ae.data&&(!!m||G.data?.status!=="present"||H==="");return(0,t.jsxs)("div",{className:"min-w-0 max-w-full",children:[(0,t.jsx)(Exe,{label:"Connect your model provider",sources:[{id:s,label:B,icon:(0,t.jsx)(CK,{type:s})}],mode:J,selectedId:w?s:null,collapsed:w,onSelect:r(()=>{m?.disabled||S(!0)},"onSelect")}),!w&&!m?.fixedMethod&&(0,t.jsx)("div",{className:"-ml-3 mt-1",children:(0,t.jsx)(Pxe,{mode:J,onChange:r(re=>{de.current=null,y(re),L(null)},"onChange")})}),!w&&V.options.length>0&&(0,t.jsxs)("p",{className:"mt-2 text-sm text-muted-foreground",children:[V.options.length," saved API"," ",V.options.length===1?"key available":"keys available","."]}),J==="subscription"&&V.subscriptions.length>0&&(0,t.jsx)($j,{options:V.subscriptions,value:X?.id??"",onChange:ee,loading:!1,error:!1,kind:"subscription",disabled:I}),(0,t.jsx)(Zo.div,{initial:!1,animate:{height:w?"auto":0,opacity:w?1:0},transition:{height:cd,opacity:oE},className:"overflow-hidden",children:w&&(0,t.jsx)("div",{className:"pt-5",children:J==="api"?(0,t.jsxs)(lE,{instruction:V.options.length?"Choose a saved API key or enter a new one":`Provide your ${B} API key to connect`,children:[(0,t.jsx)($j,{...V,value:te?.id??"",disabled:I,onChange:r(re=>{ce(re),T(""),q(null),L(null)},"onChange")}),!te&&(0,t.jsx)(cE,{label:"API key",masked:!0,autoFocus:!0,value:A,placeholder:E?"Key entered. Retry the connection.":"Enter API key here",onChange:r(re=>{ce(""),T(re),q(null)},"onChange"),onSubmit:r(()=>{fe()},"onSubmit"),disabled:I})]}):se?(0,t.jsx)(kK,{companyId:e,adapterType:s,environmentId:n,chrome:"onboarding",aiConnection:m?.intent??{provider:z,method:"subscription",name:`My ${B} subscription`,ownership:"personal",agentIds:[],allAgents:!0},autoStart:!0,onStored:r(()=>{},"onStored"),onPromptReady:r(re=>{N(re),R(ie=>re?ie==="preparing"?"ready":ie:"preparing")},"onPromptReady"),onCodeSubmitted:r(()=>{C.current=_==="waiting"?"waiting":"ready",R("connecting")},"onCodeSubmitted"),onSubmitFailed:r(()=>{R(re=>re==="connecting"?C.current:re)},"onSubmitFailed"),onConnected:r(re=>{if(m){if(!re){L("The login did not return a saved connection. Try again.");return}const me=f.current;R("connecting"),mu.loginResult(e,re).then(pe=>{me===f.current&&m.onComplete({...pe,method:"subscription"})}).catch(()=>{me===f.current&&(R("ready"),L("Could not retrieve the saved connection. Go back and retry."))});return}const ie={env:{},aiConnection:{provider:z,method:"subscription",mode:"responsible_user"}};q(ie),o(ie)},"onConnected")}):X?null:p&&!ae.data?(0,t.jsx)(fK,{adapterType:s,login:{...Y,retry:r(()=>{L(null),Y.retry()},"retry")}}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:ae.data?"Use your saved Claude subscription for this agent.":a?"Use the existing provider connection for this environment.":"This environment does not support browser sign-in. Choose a sign-in environment or connect with an API key."})})}),J==="subscription"&&ae.isError&&(0,t.jsx)("p",{role:"alert",className:"mt-4 text-sm text-destructive",children:"Could not check your saved Claude subscription. Try again."}),O&&(0,t.jsx)("p",{role:"alert",className:"mt-4 text-sm text-destructive",children:d??O}),i&&h.isError&&(0,t.jsx)("p",{role:"alert",className:"mt-4 text-sm text-destructive",children:"Could not prepare sign-in. Reload this page to try again."}),(0,t.jsx)(Mxe,{onBack:r(()=>{w?g():l()},"onBack"),primaryLabel:w&&se?_==="waiting"?"Waiting for code":_==="connecting"?"Connecting":`Sign in to ${B}`:I?"Connecting":J==="subscription"&&(ae.data||X)?"Use saved subscription":J==="api"&&te?"Use saved API key":"Connect",primaryDisabled:m?.disabled||!!m&&J==="subscription"&&!a&&!p||i&&h.isPending||Y.preparing||!!Y.error||!m&&G.isPending||V.loading||s==="claude_local"&&ae.isPending||!w||!!se&&(!j||_!=="ready")||J==="api"&&!A.trim()&&!E&&!te,loading:I,primaryIcon:w&&se?_==="ready"?"none":"spinner":void 0,onPrimary:r(()=>{if(se){if(!j||_!=="ready")return;window.open(j,"_blank","noreferrer,noopener"),R("waiting")}else fe()},"onPrimary")})]})}r(Dxe,"AgentProviderConnection");function zT(e){return e.provider==="openrouter"?(0,t.jsx)(jGe,{...e}):(0,t.jsx)(yGe,{...e})}r(zT,"AiConnectionCredentialStep");function yGe({companyId:e,provider:s,initialMethod:n,fixedMethod:a,connectionId:i,name:o,ownership:l,agentIds:c,allAgents:d,environmentId:m,onComplete:h,onCancel:p}){const[f,g]=(0,u.useState)(o),[v,y]=(0,u.useState)(),w=Wt(),S=Z({queryKey:P.environments.list(e),queryFn:r(()=>Ci.list(e),"queryFn")}),j=Z({queryKey:P.environments.capabilities(e),queryFn:r(()=>Ci.capabilities(e),"queryFn")}),N=Z({queryKey:P.instance.settings,queryFn:Er.get}),_=Z({queryKey:P.instance.experimentalSettings,queryFn:Er.getExperimental}),R=Z({queryKey:P.instance.generalSettings,queryFn:Er.getGeneral}),C=NK(R.data?.executionMode,S.data??[]);let A=null,T;try{A=C.forced?C.kubernetesEnvironment?.id??null:vw({agentDefaultEnvironmentId:m??v,instanceDefaultEnvironmentId:N.data?.defaultEnvironmentId,localDefaultEnvironmentId:jw(S.data),managedSandboxOnly:_.data?.enableManagedSandboxOnly,managedSandboxEnvironmentId:yw(S.data),visibleEnvironmentIds:S.data?.map(K=>K.id)})}catch(K){T=K instanceof Error?K.message:"Could not resolve the sign-in environment."}const I=(S.data??[]).filter(K=>K.status==="active"&&(K.driver==="local"||K.driver==="sandbox"&&typeof K.config.provider=="string"&&j.data?.sandboxProviders?.[K.config.provider]?.supportsLoginPty===!0));!C.forced&&!m&&!v&&!I.some(K=>K.id===A)&&(A=I[0]?.id??null);const $=S.data?.find(K=>K.id===A),O=typeof $?.config.provider=="string"?$.config.provider:"",L=$?.driver==="sandbox"&&j.data?.sandboxProviders?.[O]?.supportsLoginPty===!0,E=[S,j,N,_,R].some(K=>K.isPending),q=T??[S,j,N,_,R].find(K=>K.error)?.error?.message,B={provider:s,method:"subscription",name:f,ownership:l,agentIds:c,allAgents:d,connectionId:i};return(0,t.jsxs)("div",{className:"mx-auto w-full min-w-0 max-w-xl space-y-6",children:[(0,t.jsxs)("label",{className:"block space-y-2 text-sm",children:["Connection name",(0,t.jsx)(At,{value:f,onChange:r(K=>g(K.target.value),"onChange"),disabled:!!i})]}),!m&&!C.forced&&I.length>1&&(0,t.jsxs)($a,{value:A??"",onValueChange:y,children:[(0,t.jsx)(La,{"aria-label":"Sign-in environment",children:(0,t.jsx)(Ma,{placeholder:"Sign-in environment"})}),(0,t.jsx)(Da,{children:I.map(K=>(0,t.jsx)(Sn,{value:K.id,children:K.name},K.id))})]}),q&&(0,t.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:q}),E?(0,t.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:"Preparing sign-in…"}):(0,t.jsx)(Dxe,{companyId:e,adapterType:s==="anthropic"?"claude_local":s==="xai"?"grok_local":"codex_local",environmentId:A,canLogin:L,localEnvironment:$?.driver==="local",onBack:p,onConnected:r(()=>{},"onConnected"),testConnection:r(async()=>!1,"testConnection"),managedAccount:{intent:B,initialMethod:n,fixedMethod:a||!!i,disabled:E||!!q||!f.trim(),onComplete:r(K=>{w.invalidateQueries({queryKey:["ai-connections",e]}),h(K)},"onComplete")}},A??"local")]})}r(yGe,"SubscriptionConnectionStep");function jGe({companyId:e,provider:s,connectionId:n,name:a,ownership:i,agentIds:o,allAgents:l,onComplete:c,onCancel:d}){const[m,h]=(0,u.useState)(a),[p,f]=(0,u.useState)(""),g=Wt(),v=Ne({mutationFn:r(()=>mu.create(e,{provider:s,method:"api_key",name:m,ownership:i,agentIds:o,allAgents:l,connectionId:n,apiKey:p}),"mutationFn"),onSuccess:r(y=>{g.invalidateQueries({queryKey:["ai-connections",e]}),c({...y,method:"api_key"})},"onSuccess"),onSettled:r(()=>f(""),"onSettled")});return(0,t.jsxs)("div",{className:"mx-auto w-full min-w-0 max-w-xl space-y-4",children:[(0,t.jsxs)("label",{className:"block space-y-2 text-sm",children:["Connection name",(0,t.jsx)(At,{value:m,onChange:r(y=>h(y.target.value),"onChange"),disabled:!!n})]}),v.error&&(0,t.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:v.error.message}),(0,t.jsx)($fe,{providerName:"OpenRouter",value:p,onChange:f,onSubmit:r(()=>v.mutate(),"onSubmit"),disabled:v.isPending,placeholder:"Enter API key here",autoFocus:!0}),(0,t.jsxs)("div",{className:"flex justify-between gap-2",children:[(0,t.jsx)(F,{variant:"ghost",onClick:d,children:"Cancel"}),(0,t.jsx)(F,{disabled:!m.trim()||!p.trim()||v.isPending,onClick:r(()=>v.mutate(),"onClick"),children:v.isPending?"Connecting…":"Connect"})]})]})}r(jGe,"ApiKeyConnectionStep");var wGe=new RegExp(`\\b(${["mcp","server","profile","policy","gateway","transport","stdio","endpoint"].join("|")})s?\\b`,"gi");function Lxe(e){return e.replace(wGe,"").replace(/\s{2,}/g," ").replace(/\s+([.,])/g,"$1").trim()}r(Lxe,"sanitizeProsumerCopy");var NGe={zapier:{tagline:"Reach 9,000+ apps your team already uses.",short:"Reach 9,000+ apps from your agents."},github:{tagline:"Read code and pull requests, comment on issues.",short:"Read code and pull requests, comment on issues."},slack:{tagline:"Send and read messages in your team's channels.",short:"Send and read messages in your channels."},notion:{tagline:"Read and update pages in your workspace.",short:"Read and update pages in your workspace."},railway:{tagline:"Inspect services, read logs, and manage deployments.",short:"Connect Railway for deployments, logs, and container access."},posthog:{tagline:"Explore product usage, errors, flags, and experiments.",short:"Sign in with PostHog. Project pinning and access controls are optional."},linear:{tagline:"Create, update and read tickets.",short:"Create, update and read tickets."},"google-sheets":{tagline:"Read and update selected spreadsheets.",short:"Read spreadsheets or update the files you choose."},gmail:{tagline:"Read mail and create drafts for your review.",short:"Read mail and create drafts for your review."},"google-drive":{tagline:"Find, read, and create files in Drive.",short:"Find, read, and create files in Drive."},"google-docs":{tagline:"Read and update documents.",short:"Read and update documents."},"google-slides":{tagline:"Read and update presentations.",short:"Read and update presentations."},"google-calendar":{tagline:"Review calendars and manage events.",short:"Review calendars and manage events."},"google-chat":{tagline:"Read conversations and send messages.",short:"Read conversations and send messages."},"google-people":{tagline:"Look up contacts and people in your directory.",short:"Look up contacts and people in your directory."},"google-workspace-search":{tagline:"Search across your Google workspace.",short:"Search across your Google workspace."},hubspot:{tagline:"Look up contacts and update deal stages.",short:"Look up contacts and update deal stages."},intercom:{tagline:"Read and reply to customer conversations.",short:"Read and reply to customer conversations."},figma:{tagline:"Read files and post comments on frames.",short:"Read files and post comments on frames."},stripe:{tagline:"Read customers, invoices, and payouts.",short:"Read customers, invoices, and payouts."},context7:{tagline:"Look up up-to-date docs for your libraries.",short:"Look up up-to-date docs for your libraries."}},kGe={tagline:"Give your agents access to this app.",short:"Give your agents access to this app."};function $xe(e,s){const n=NGe[e];if(n)return n;if(s){const a=Lxe(s);if(a)return{tagline:a,short:a}}return kGe}r($xe,"appCopyFor");function gJ(e,s,n){return n<=1?`Your ${e} key`:Lxe(s)||`Your ${e} key`}r(gJ,"credentialFieldLabel");var SGe=1500;function hf(e=SGe){const[s,n]=(0,u.useState)("idle"),a=(0,u.useRef)(null),i=(0,u.useRef)(0);(0,u.useEffect)(()=>()=>{a.current!==null&&window.clearTimeout(a.current)},[]);const o=(0,u.useCallback)(async l=>{const c=++i.current;let d="copied";try{await Yr(l)}catch{d="failed"}return i.current!==c||(n(d),a.current!==null&&window.clearTimeout(a.current),a.current=window.setTimeout(()=>{i.current===c&&(n("idle"),a.current=null)},e)),d},[e]);return{status:s,copied:s==="copied",failed:s==="failed",copy:o}}r(hf,"useCopyAction");function _K(){const e=_c()?.pushToast;return(0,u.useCallback)(async(s,n="Copied")=>{try{return await Yr(s),e?.({title:n,tone:"success",dedupeKey:`copy:${n}`}),!0}catch{return e?.({title:"Couldn’t copy to clipboard",body:"Select and copy the value manually.",tone:"error",dedupeKey:"copy-failed"}),!1}},[e])}r(_K,"useCopyToast");var CGe="/cloud/connections/handoff",_Ge="/cloud/connections/reauth",UT="paperclip.cloud-oauth-handoff.v1",gx=class extends Error{static{r(this,"OAuthHandoffError")}code;constructor(e,s){super(e),this.code=s,this.name="OAuthHandoffError"}};function IK(e){if(e===void 0)return null;if(!e||typeof e!="object"||Array.isArray(e))throw new gx("Paperclip Cloud returned an invalid sign-in handoff.","invalid_handoff");const s=e;if(s.kind!=="paperclip_cloud"||typeof s.session!="string"||s.session.length<16||s.session.length>512||!/^[A-Za-z0-9_-]+$/.test(s.session))throw new gx("Paperclip Cloud returned an invalid sign-in handoff.","invalid_handoff");return{kind:"paperclip_cloud",session:s.session}}r(IK,"parseHandoff");function IGe(e,s){return e===404||s==="SESSION_NOT_AVAILABLE"?new gx("This sign-in expired. Start the connection again.","expired"):e===401||e===403?new gx("Paperclip Cloud could not authorize this connection for your account.","forbidden"):new gx("Paperclip Cloud couldn’t prepare secure sign-in. Try again.","unavailable")}r(IGe,"handoffFailure");async function AGe(e,s){const n=s.request??fetch;let a,i;for(let o=0;o<2;o+=1)try{if(a=await n(CGe,{method:"POST",headers:{"content-type":"application/json",accept:"application/json"},credentials:"include",body:JSON.stringify({session:e}),signal:s.signal}),a.status<500||o===1)return a}catch(l){if(s.signal?.aborted||l instanceof DOMException&&l.name==="AbortError")throw l;if(i=l,o===1)break}if(a)return a;throw new gx(i instanceof Error?i.message:"Paperclip Cloud couldn’t prepare secure sign-in. Try again.","unavailable")}r(AGe,"postCloudHandoff");function RGe(e,s){if(typeof e!="string"||typeof window>"u")return null;try{const n=new URL(e,window.location.origin);return n.origin!==window.location.origin||n.pathname!==_Ge||n.username||n.password||n.hash||n.searchParams.size!==1||n.searchParams.get("session")!==s?null:{kind:"reauthentication",url:n.toString(),host:n.host}}catch{return null}}r(RGe,"exactReauthenticationTarget");async function kw(e,s={}){const n=IK(e.handoff);if(!n){const l=yT(e.authorizationUrl);if(!l.ok)throw new gx(l.message,"invalid_handoff");return{kind:"authorization",url:l.url,host:l.host}}const a=await AGe(n.session,s),i=await a.json().catch(()=>null);if(!a.ok){if(i?.error==="RECENT_LOGIN_REQUIRED"){const l=RGe(i.reauthenticationUrl,n.session);if(l)return l}throw IGe(a.status,i?.error)}const o=yT(typeof i?.authorizationUrl=="string"?i.authorizationUrl:void 0);if(!o.ok)throw new gx("Paperclip Cloud returned an invalid provider sign-in address.","invalid_handoff");return{kind:"authorization",url:o.url,host:o.host}}r(kw,"prepareOAuthNavigation");function wC(e,s=window.sessionStorage){const n=IK({kind:"paperclip_cloud",session:e});if(!n)throw new gx("Paperclip Cloud returned an invalid sign-in handoff.","invalid_handoff");const a={version:1,session:n.session,savedAt:Date.now()};s.setItem(UT,JSON.stringify(a))}r(wC,"savePendingCloudHandoff");function TGe(e=window.sessionStorage){const s=e.getItem(UT);if(!s)return null;try{const n=JSON.parse(s);if(n.version!==1||typeof n.savedAt!="number"||Date.now()-n.savedAt>9e5)throw new Error("expired");return IK({kind:"paperclip_cloud",session:n.session})}catch{return e.removeItem(UT),null}}r(TGe,"readPendingCloudHandoff");function bJ(e=window.sessionStorage){e.removeItem(UT)}r(bJ,"clearPendingCloudHandoff");function pE({host:e,className:s}){return(0,t.jsxs)("div",{className:U("flex flex-wrap items-center gap-2 text-xs",s),children:[(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 font-medium text-amber-700 dark:text-amber-400",children:[(0,t.jsx)(kl,{className:"h-3 w-3"}),"Unverified server"]}),e?(0,t.jsx)("span",{className:"font-mono text-muted-foreground",children:e}):null]})}r(pE,"UnverifiedServerBadge");function fE(e){return!!(e&&kle({...e,methods:e.methods.filter(s=>(s.purpose??"tool")!=="channel"&&s.transport!=="chat_sdk")}))}r(fE,"appSupportsToolCatalogSetup");var EGe=SIe.filter(e=>gle(e).some(s=>Bp(s))).map(e=>e.slug);function PGe(e){return EGe.some(s=>s===e)}r(PGe,"isMcpDirectOAuthConnectSlug");function HF(e,s){const n=new URLSearchParams({source:e});return s&&n.set("intent",s),`/apps/connect?${n.toString()}`}r(HF,"appSourceConnectHref");function MGe(e,s){return`/apps/connect?${new URLSearchParams({source:e,resume:s}).toString()}`}r(MGe,"appSourceResumeHref");function H4(e){return e?`/apps/vercel-connect?${new URLSearchParams({source:e}).toString()}`:"/apps/vercel-connect"}r(H4,"vercelConnectSourceHref");function DGe(e){return e.serviceSlug??e.appKey??e.sourceSlug??void 0}r(DGe,"resolveAppsConnectRouteKey");function LGe(e,{chatConnectorsEnabled:s=!1}={}){if(e.get("byo")==="1")return!!(e.get("reconnect")?.trim()&&e.get("applicationId")?.trim()&&e.get("link")?.trim());const n=e.get("source")??"",a=s1(n);return!s&&a?.methods.some(i=>i.transport==="chat_sdk")&&!a.methods.some(i=>(i.purpose??"tool")!=="channel"&&i.transport!=="chat_sdk")?!1:mz(n)&&e.get("reconnect")?.trim()?!0:s?kle(a):fE(a)}r(LGe,"canEnterAppsConnect");var Q4=" for the organization",$Ge=" for the company";function vJ(e,s){const n=e.trim();if(s!=="organization")return n;const a=n.toLocaleLowerCase();return a.endsWith(Q4)?n:a.endsWith($Ge)?`${n.slice(0,n.length-16).trimEnd()}${Q4}`:`${n}${Q4}`}r(vJ,"connectionNameForGrantKind");function OGe(e){switch(e){case"active":return"Connected";case"needs_reauthorization":return"Needs attention";case"expired":return"Expired";case"revoked":return"Revoked";default:return"Not connected"}}r(OGe,"grantStatusLabel");function FGe(e){switch(e){case"active":return"connected";case"needs_reauthorization":case"expired":return"attention";case"revoked":return"inactive";default:return"missing"}}r(FGe,"grantStatusTone");function BGe(e,s={}){const n=e?.providerTenant?.name?.trim();return n||(e?.kind==="user"?s.subjectLabel?.trim()||"Connected account":e?.kind==="agent"?s.subjectLabel?.trim()||"Dedicated account":"Shared credential")}r(BGe,"grantAccountLabel");function qGe(e){return new Set((e?.members??[]).filter(s=>s.subjectType==="user").map(s=>s.subjectId))}r(qGe,"audienceUserIds");function zGe(e){return e.find(s=>s.kind==="organization"&&s.isDefault)??e.find(s=>s.kind==="organization")??null}r(zGe,"organizationGrant");function UGe(e,s){return s?e.find(n=>n.kind==="user"&&n.subjectUserId===s)??null:null}r(UGe,"personalGrantFor");function KGe(e,s){if(!s)return null;const n=e.find(a=>a.userId===s);return n&&(n.name?.trim()||n.email?.trim())||null}r(KGe,"memberLabel");var yJ=0;function QF(){return yJ+=1,{id:`header-${yJ}`,name:"",value:""}}r(QF,"newCustomHeaderRow");function IS(e){try{return new URL(e).host||null}catch{return null}}r(IS,"endpointHost");function VGe(e=window.location.origin){const s=new URL("/api/tools/oauth/callback",e),n=s.hostname.toLowerCase().replace(/^\[|\]$/g,"");return s.protocol==="http:"&&(n==="127.0.0.1"||n==="::1")&&(s.hostname="localhost"),s.toString()}r(VGe,"oauthCallbackUrlForBrowser");function G4(e){try{const s=new URL(e);return`${s.host.replace(/^www\./,"")}${s.pathname==="/"?"":s.pathname.replace(/\/+$/,"")}`.slice(0,160)||null}catch{return null}}r(G4,"defaultGenericMcpName");function jJ(e,s){const n=s?.trim()||"Paperclip couldn't connect to that address. Check it and try again.";switch(e){case"mcp_remote_url_missing":case"mcp_remote_url_invalid":return{title:"That doesn't look like a server address",body:"Paste the full address, starting with https:// — for example https://mcp.example.com/mcp.",focus:"url"};case"remote_http_private_endpoint":return{title:"That address is inside a private network",body:"This Paperclip is reachable from the internet, so it won't call addresses on your local network. Use the server's public address instead.",focus:"url"};case"remote_http_dns_failed":return{title:"We couldn't find that host",body:"The address didn't resolve. Check the spelling, or confirm the server is published on the internet.",focus:"url"};case"mcp_header_rejected":return{title:"Paperclip can't send that header",body:n,focus:"credentials"};case"tool_access_name_conflict":return{title:"Paperclip couldn’t name this connection",body:"Try connecting again.",focus:"none"};case"oauth_challenge":return{title:"This server wants a credential",body:"It asked us to authenticate but didn't offer a sign-in Paperclip can complete on its own. Add the key or headers its docs list under Advanced authentication.",focus:"credentials"};case"oauth_manual_client_required":case"oauth_manual_client_rebinding_required":return{title:"This server needs sign-in details you create yourself",body:"Register Paperclip in the provider's settings, then add the client ID and secret it gives you under Advanced authentication.",focus:"credentials"};case"oauth_redirect_origin_unsupported":case"oauth_redirect_uri_invalid":return{title:"This Paperclip needs a public HTTPS address first",body:"Sign-in sends the operator back to Paperclip, so this instance has to be reachable over HTTPS. Ask your Paperclip admin to configure it.",focus:"deployment"};case"runtime_error":return{title:"We couldn't reach that server",body:"Nothing answered at that address. Confirm the server is running and the address is right, then try again.",focus:"url"};default:return{title:"Paperclip couldn't connect",body:n,focus:"none"}}}r(jJ,"genericConnectGuidance");function Oxe(e){const s=new Set;for(const n of e){const a=n.name.trim();if(!a&&!n.value.trim())continue;const i=iIe(a);if(!i.ok)return nH(a,i.reason);const o=bIe(n.value);if(!o.ok)return nH(a,o.reason);if(!n.value.trim())return`Add a value for "${a}", or remove the row.`;const l=a.toLowerCase();if(s.has(l))return`"${a}" is listed twice.`;s.add(l)}return null}r(Oxe,"customHeaderError");function WGe(e){const s={},n=e.keyValue.trim();if((e.authMode==="bearer"||e.authMode==="auto"&&e.needsKey)&&n&&(s["credentials.authorization"]=n),e.authMode==="custom_headers")for(const l of e.headers){const c=l.name.trim();!c||!l.value.trim()||(s[`headers.${c}`]=l.value)}const a=e.name.trim(),i=e.oauthClientId.trim(),o=e.oauthClientSecret.trim();return{link:e.link,...a?{name:a}:{},...e.authMode==="auto"?{}:{authMode:e.authMode},...Object.keys(s).length>0?{credentialValues:s}:{},...e.authMode==="oauth"&&i?{oauthClient:{clientId:i,...o?{clientSecret:o}:{}}}:{}}}r(WGe,"genericConnectPayload");function HGe(e){return e.link.trim()?e.authMode==="auto"?!e.needsKey||e.keyValue.trim().length>0:e.authMode==="bearer"?e.keyValue.trim().length>0:e.authMode==="custom_headers"?e.headers.filter(s=>s.name.trim()&&s.value.trim()).length>0&&Oxe(e.headers)===null:!0:!1}r(HGe,"canSubmitGenericConnect");function Sw(e){const s=new Set;let n=!1;for(const a of e??[])a.targetType==="company"?n=!0:a.targetType==="agent"&&s.add(a.targetId);return{onAll:n,agentIds:s}}r(Sw,"installStateFrom");function Fxe(e,s){return e.onAll||e.agentIds.has(s)}r(Fxe,"isAgentInstalled");function Bxe(e,s){return s.onAll?[{targetType:"company",targetId:e}]:[...s.agentIds].map(n=>({targetType:"agent",targetId:n}))}r(Bxe,"installPayload");var QGe="Has access — tick to load its tools into this agent's context.";function qxe(e){return`paperclip.connector-enrollment-access:${e}`}r(qxe,"enrollmentAccessStorageKey");function GGe(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const s=e;if(typeof s.companyId!="string"||!s.companyId.trim()||!(s.grantKind==="user"||s.grantKind==="agent"||s.grantKind==="organization")||s.installChoice!=="specific"&&s.installChoice!=="all"||!Array.isArray(s.agentIds)||s.agentIds.some(a=>typeof a!="string"||!a.trim()))return!1;const n=new Set(s.agentIds);return n.size!==s.agentIds.length?!1:s.grantKind==="agent"?s.installChoice==="specific"&&n.size===1:s.installChoice==="all"?n.size===0:n.size>0}r(GGe,"validEnrollmentAccessState");function YGe(e,s,n){try{window.sessionStorage.setItem(qxe(s),JSON.stringify({...n,companyId:e}))}catch{}}r(YGe,"saveEnrollmentAccessState");function JGe(e){const s=qxe(e);try{const n=window.sessionStorage.getItem(s);if(window.sessionStorage.removeItem(s),!n)return null;const a=JSON.parse(n);return GGe(a)?a:null}catch{return null}}r(JGe,"consumeEnrollmentAccessState");function wJ(e){if(!e)return null;try{const s=new URL(e);return s.protocol==="https:"&&s.hostname.toLowerCase()==="github.com"?s.toString():null}catch{return null}}r(wJ,"githubRecoveryUrl");function NJ(e,s){return e==="denied"?"Authorization was cancelled or declined. Your saved connection was not changed.":s==="github_installation_required"?"GitHub access is required. Install Paperclip and grant at least one repository, then try again.":"Authorization did not complete. Your saved connection is still here, so you can try again."}r(NJ,"oauthCallbackErrorMessage");var XGe={access:"access",key:"setup",success:"complete"};function kJ(e){return e.requestedAppKey?e.resumeConnectionId||e.routeStage==="setup"?"key":"access":e.hasPrefilledLink||e.zapierSource?"access":"gallery"}r(kJ,"requestedConnectionInitialStep");function ZGe(e){const s=e.galleryApps.find(a=>a.slug===e.requestedAppKey);if(s)return s;if(!e.reconnectConnection)return null;const n=e.applications.find(a=>a.id===e.reconnectConnection?.applicationId);return Cx(n)!==e.requestedAppKey?null:mz(e.requestedAppKey)}r(ZGe,"requestedConnectionEntry");function eYe(e){return!e.reconnectConnection||!e.reconnectApplication||e.reconnectConnection.applicationId!==e.reconnectApplication.id?!1:e.requestedAppKey?Cx(e.reconnectApplication)===e.requestedAppKey:e.byo&&e.applicationId===e.reconnectApplication.id}r(eYe,"retainedReconnectMatches");function tYe(e){return e.credentialSource==="vercel_connect"&&!e.available&&!e.retainedReconnectMatches}r(tYe,"isVercelConnectUnavailable");function sYe(e){return e.available===!1&&!(e.reconnectConnectionId&&e.reconnectSourceMatches)}r(sYe,"isConnectionDefinitionUnavailable");function nYe(e){return!e.hasRequestedEntry||e.supportedMethodCount===0||e.unsupportedOAuth||e.vercelUnavailable||e.definitionUnavailable?e.reconnectConnectionId?"reconnect_unavailable":"fallback":"ready"}r(nYe,"requestedConnectionSetupResolution");function SJ(e,s,n,a){const i=XGe[s]??"setup",o=new URLSearchParams({source:e,stage:i});return a?.resumeConnectionId&&o.set("resume",a.resumeConnectionId),a?.reconnectConnectionId&&o.set("reconnect",a.reconnectConnectionId),a?.interactionId&&o.set("intent",a.interactionId),a?.connectionMethodKey&&o.set("method",a.connectionMethodKey),`${n==="vercel_connect"?"/apps/vercel-connect":"/apps/connect"}?${o.toString()}`}r(SJ,"appConnectHref");function wI(e,s){if(!s)return e;const[n,a=""]=e.split("?",2),i=new URLSearchParams(a);return i.set("intent",s),`${n}?${i.toString()}`}r(wI,"withConnectionIntent");var CJ=["Pick app","Access","Add your key"],_J={gallery:0,access:1,key:2},rYe={access:0,key:1},aYe=["Access","Add MCP URL"],iYe=["Access","Sign in"];function Y4(e,s=!1){return s&&e?.auth!=="none"&&(!e?.grantKinds||e.grantKinds.includes("user"))?"user":e?.grantKinds?.length===1||e?.grantKinds&&!e.grantKinds.includes("organization")?e.grantKinds[0]:"organization"}r(Y4,"defaultGrantKindFor");function oYe(e){const s=e.config?.oauth;if(!s||typeof s!="object"||Array.isArray(s))return;const n=s.connectorSubjectAgentId;return typeof n=="string"?n:void 0}r(oYe,"configuredAgentIdentity");function Kk(e,s){const n=typeof s=="string"?s:s?.key;return e?.slug==="google-sheets"&&n==="local"}r(Kk,"isGoogleSheetsRobotMethod");function ok(e){return e?Object.fromEntries([...e.tenantFields??[],...e.extensionFields??[]].filter(s=>s.defaultValue!==void 0).map(s=>[s.key,s.defaultValue])):{}}r(ok,"defaultMethodConfig");function ej(e,s){if(!e)return[];const n=q1(e);return s==="vercel_connect"?n.filter(a=>!!a.credentialSources?.vercelConnect):n}r(ej,"connectionMethodsForCredentialSource");function q1(e){return gle(e).filter(s=>(s.purpose??"tool")!=="channel")}r(q1,"availableToolConnectionMethods");function NI(e,s){const n=q1(e);return s?n.find(a=>a.key===s)??null:pz(n)}r(NI,"availableToolConnectionMethod");function Fj(e){const s=pz(e);return e.length===1||s?.capabilityProfile||s?.grantKinds?.includes("agent")?s:null}r(Fj,"recommendedSetupConnectionMethod");function IJ(e){return Fj(e?e.methods.filter(s=>(s.purpose??"tool")==="tool"&&(s.oauthStrategy==="paperclip_cloud_connector"||s.oauthStrategy==="paperclip_id_connector")):[])}r(IJ,"recommendedManagedConnectorMethod");function AJ(e){if(!e)return!1;const s=q1(e),n=s.length===1?s[0]:null;return!!(n&&Bp(n)&&!GIe(n))}r(AJ,"canUseAutomaticOAuthFastPath");function RJ(e){if(!e)return null;const s=q1(e),n=s.length===1?s[0]:null;return n&&Bp(n)?n:null}r(RJ,"automaticOAuthMethod");function lYe(e){const s=e.metadata;if(!s)return null;const n=s.sourceTemplateKey??s.galleryKey;return typeof n=="string"?n:null}r(lYe,"appSourceSlug");function cYe(e){const s=e.config?.sourceTemplateKey??e.transportConfig.sourceTemplateKey;return typeof s=="string"?s:null}r(cYe,"connectionSourceSlug");function TJ(e,s,n,a={}){if(!e)return null;const i=new Set(s.filter(o=>o.status!=="archived"&&lYe(o)===e&&(!a.applicationId||o.id===a.applicationId)).map(o=>o.id));return n.find(o=>{const l=a.applicationId?o.applicationId===a.applicationId:i.has(o.applicationId)||cYe(o)===e;return o.status!=="archived"&&(!a.draftOnly||o.status==="draft")&&o.authKind==="oauth"&&l})??null}r(TJ,"reusableOAuthConnection");function zxe(e,s,n){if(e.origin!==s||!e.data||typeof e.data!="object")return null;const a=e.data;return a.type!=="paperclip.connection-intent.oauth"||a.interactionId!==n?null:a.outcome==="connected"||a.outcome==="declined"||a.outcome==="failed"?a.outcome:null}r(zxe,"readConnectionIntentOAuthOutcome");function xE(e={}){const[s]=Ai(),n=Sa(),{selectedCompanyId:a}=ps(),i=Dhe(),o=e.interactionId||s.get("intent")||void 0,l=e.serviceSlug||s.get("source")||n.appKey||s.get("appKey"),c=(0,u.useMemo)(()=>{if(o&&kj(l))try{return sessionStorage.getItem(`paperclip:mcp-intent-draft:${a}:${o}`)}catch{}return null},[o,a,l]),d=e.configuredConnection?.id||s.get("resume")||s.get("reconnect")||c,m=!!(d&&(!l||kj(l))),h=Z({queryKey:["tools","connection",d],queryFn:r(()=>cs.getConnection(d),"queryFn"),enabled:m}),p=l||h.data?.config?.sourceTemplateKey,f=s.get("method")||h.data?.config?.connectionMethodKey;return m&&h.isPending?(0,t.jsx)("p",{className:"p-6 text-sm text-muted-foreground",children:"Loading connection…"}):m&&h.isError?(0,t.jsxs)("div",{role:"alert",className:"space-y-3 p-6",children:[(0,t.jsx)("p",{children:"Could not load this connection. Your saved access and credentials have not changed."}),(0,t.jsx)(F,{variant:"outline",onClick:r(()=>{h.refetch()},"onClick"),children:"Try again"})]}):!e.byoOnly&&(e.credentialSource??"paperclip_vault")==="paperclip_vault"&&kj(p)&&(!f||d2(p,f))?i.loaded?i.enabled?(0,t.jsx)(p6e,{...e,interactionId:o,providerId:p,connection:h.data},`${o||"page"}:${p}`):(0,t.jsx)("p",{role:"status",className:"p-6 text-sm text-muted-foreground",children:"Enable MCP aggregators in Settings → Experimental to set up this connection."}):(0,t.jsx)("p",{className:"p-6 text-sm text-muted-foreground",children:"Loading connection settings…"}):(0,t.jsx)(dYe,{...e})}r(xE,"ConnectionSetupFlow");function dYe({byoOnly:e=!1,credentialSource:s="paperclip_vault",host:n="page",serviceSlug:a,requestedAgentId:i,interactionId:o,forceNewConnection:l=!1,existingConnections:c=[],configuredConnection:d,onUseExisting:m,onComplete:h,onOAuthDeclined:p,aiConnection:f,onPhaseChange:g,onCancel:v,renderCredentialStep:y}={}){const w=Yn(),S=(0,u.useCallback)((Be,Et)=>{n==="page"&&(Et?w(Be,Et):w(Be))},[n,w]),j=Sa(),{selectedCompany:N,selectedCompanyId:_}=ps(),{enabled:R}=$x(),{setBreadcrumbs:C}=qn(),{pushToast:A}=Ei(),[T]=Ai(),I=o?.trim()||T.get("intent")?.trim()||null,$=j.appKey??T.get("appKey")??void 0,O=T.get("source")?.trim()||null,L=l||T.get("new")==="1",E=T.get("stage")?.trim()||null,q=T.get("method")?.trim()||null,B=T.get("resume")?.trim()||null,K=T.get("oauth"),z=T.get("code"),D=wJ(T.get("installation_url")),V=wJ(T.get("management_url")),H=d?.id??(T.get("reconnect")?.trim()||null),ee=T.get("identity")==="user"?"user":T.get("identity")==="organization"?"organization":null,X=s==="vercel_connect",le=a??O,ce=s==="paperclip_vault"&&PGe(le)?le:null,te=DGe({serviceSlug:a,appKey:$,sourceSlug:O}),ae=(a??O??$)==="zapier",de=ae?void 0:te,J=!!d||n==="page"&&(e||T.get("byo")==="1"),[Y]=(0,u.useState)(()=>n==="page"&&T.get("cloud_connector")==="enrolled"&&de?JGe(de):null),[G]=(0,u.useState)(()=>{const Be=T.get("link")?.trim()??"";return{link:/^https?:\/\//i.test(Be)?Be:"",name:d?.name??T.get("name")?.trim()??"",applicationId:d?.applicationId??(T.get("applicationId")?.trim()||void 0)}}),[fe,se]=(0,u.useState)(()=>kJ({requestedAppKey:de,routeStage:E,resumeConnectionId:B,hasPrefilledLink:!!G.link,zapierSource:ae})),[re,ie]=(0,u.useState)(null),[me,pe]=(0,u.useState)(""),[be,oe]=(0,u.useState)(G.link),[ye,Ae]=(0,u.useState)(G.name||(ae?"Zapier":"")),[xe,_e]=(0,u.useState)(!1),[Ge,$e]=(0,u.useState)(""),[Ye,ue]=(0,u.useState)("auto"),[Oe,dt]=(0,u.useState)(()=>[QF()]),[xt,De]=(0,u.useState)(""),[Qe,ht]=(0,u.useState)(""),[We,Ke]=(0,u.useState)(!1),[gt,tt]=(0,u.useState)(null),[Se,ke]=(0,u.useState)(!1),[Xe,ut]=(0,u.useState)({}),[Lt,Xt]=(0,u.useState)(""),[fs,Ve]=(0,u.useState)(""),[He,ct]=(0,u.useState)(""),[ze,is]=(0,u.useState)(f&&f.mode!=="responsible_user"?`ai-${f.method}`:""),[Fe,Qt]=(0,u.useState)({}),[It,Ms]=(0,u.useState)(""),[Ue,pt]=(0,u.useState)(null),[$t,gs]=(0,u.useState)(null),[Ts,St]=(0,u.useState)({}),[we,Pe]=(0,u.useState)("all"),[it,Ot]=(0,u.useState)(new Set),[ft,us]=(0,u.useState)(()=>new Set(Y?.agentIds??(i?[i]:[]))),[cn,xs]=(0,u.useState)(Y?.grantKind??ee??(i?"user":"organization")),[bs,qe]=(0,u.useState)(Y?.installChoice??(i?"specific":"all")),wt=!!(B&&(K==="failed"||K==="denied")),[kt,Ee]=(0,u.useState)(wt?"error":"entry"),[Le,Ze]=(0,u.useState)(()=>wt?NJ(K,z):null),[Nt,Ut]=(0,u.useState)(null),Dt=(0,u.useRef)(!1),Ft=(0,u.useRef)(!1),Yt=(0,u.useRef)(null),[Ws,_n]=(0,u.useState)(null),In=(0,u.useRef)(null),[en,Us]=(0,u.useState)(null),[ws,nn]=(0,u.useState)(null),zs=(0,u.useRef)(null),[An,hn]=(0,u.useState)(c.length>0&&!!m),[rn,pr]=(0,u.useState)(null),[Zs,er]=(0,u.useState)(null),[tr,Ur]=(0,u.useState)(null),mr=(0,u.useCallback)(()=>{n!=="dialog"||In.current?.closed===!1||(In.current=window.open("about:blank","paperclip-connection-oauth","popup,width=720,height=760,resizable=yes,scrollbars=yes"))},[n]),br=(0,u.useCallback)(Be=>{if(n!=="dialog"){Sc(Be);return}nn(Be);const Et=In.current;if(!Et||Et.closed){Ee("error"),Ze("Paperclip couldn’t open the sign-in window. Open sign-in in a new tab to continue."),g?.("needs_retry");return}Et.location.assign(Be),Et.focus()},[n,g]),sr=(0,u.useCallback)(()=>{In.current=null,Ze(null),Ee("redirecting"),g?.("authorizing")},[g]);(0,u.useEffect)(()=>{if(n!=="dialog"||kt!=="redirecting")return;const Be=window.setInterval(()=>{In.current?.closed&&(Ee("error"),Ze("The sign-in window closed. If authorization did not finish, try again."),nn(null),g?.("needs_retry"))},1e3);return()=>window.clearInterval(Be)},[n,kt,g]);const ra=(0,u.useCallback)(async Be=>{zs.current?.abort();const Et=new AbortController;zs.current=Et;try{const Ps=await kw(Be,{signal:Et.signal});if(Ps.kind==="reauthentication"){const Rn=n==="dialog"?In.current:window;if(!Rn||Rn.closed||!Be.handoff)throw new Error("Paperclip couldn’t preserve this sign-in while refreshing your account.");wC(Be.handoff.session,Rn.sessionStorage),Ee("starting")}else Ut(Ps.host),Ee("redirecting");br(Ps.url)}catch(Ps){if(Et.signal.aborted)return;Ee("error"),Ze(Ps instanceof Error?Ps.message:"Paperclip couldn’t start secure sign-in. Try again."),g?.("needs_retry")}finally{zs.current===Et&&(zs.current=null)}},[n,g,br]);(0,u.useEffect)(()=>()=>zs.current?.abort(),[]),(0,u.useEffect)(()=>{if(n!=="dialog"||!I)return;const Be=r(Et=>{const Ps=zxe(Et,window.location.origin,I);if(Ps==="connected"){Ee("entry"),nn(null),h?.({resolvedByCallback:!0});return}if(Ps==="declined"){Ee("error"),Ze("Authorization was cancelled. You can try again."),g?.("needs_retry");return}Ps==="failed"&&(Ee("error"),Ze("Authorization did not complete. Try again when you’re ready."))},"receiveOAuthOutcome");return window.addEventListener("message",Be),()=>window.removeEventListener("message",Be)},[I,n,h,p]),(0,u.useEffect)(()=>{if(n!=="dialog"||I||!en)return;let Be=!1,Et=!1;const Ps=window.setInterval(async()=>{if(Et||Be)return;const Rn=In.current;if(!Rn||Rn.closed){Us(null),Ee("error"),Ze("The sign-in window closed. Try again to finish connecting GitHub.");return}let Ir;try{Ir=new URL(Rn.location.href)}catch{return}if(!(Ir.origin!==window.location.origin||!Ir.pathname.includes(en))){if(Ir.searchParams.has("oauth")){Us(null),Ee("error"),Ze("Authorization did not complete. Finish setup in the sign-in window or try again.");return}if(Ir.searchParams.get("success")==="1"){Et=!0;try{const za=await cs.getConnection(en);!Be&&za.status==="active"&&(Us(null),Rn.close(),h?.({connectionId:za.id}))}catch{Be||(Us(null),Ee("error"),Ze("Could not confirm the connection. Try again."))}finally{Et=!1}}}},1e3);return()=>{Be=!0,window.clearInterval(Ps)}},[I,en,n,h]);const Bn=r(()=>{ue("auto"),dt([QF()]),De(""),ht(""),Ke(!1),tt(null),ke(!1)},"resetGenericAuthState"),_r=r(Be=>{if(n==="page"&&!I&&s==="paperclip_vault"&&kj(Be.slug)){S(`/apps/connect?source=${Be.slug}`);return}if(Be.slug==="zapier"){ie(null),pe(""),oe(""),Ae("Zapier"),_e(!1),$e(""),Bn(),ut({}),gs(null),se("access"),S(wI("/apps/connect?source=zapier",I));return}if(s==="paperclip_vault"&&AJ(Be)){S(HF(Be.slug,I));return}ie(Be),pe(Be.name),oe(""),Ae(""),_e(!1),$e(""),Bn(),ut({}),Xt(""),Ve(""),ct("");const Et=Fj(ej(Be,s));is(Et?.key??""),Qt(ok(Et)),Ms(""),pt(null),gs(null),us(new Set(i?[i]:[])),qe(i?"specific":"all"),xs(or??Y4(Et,!!i)),se("access"),S(s==="vercel_connect"?wI(H4(Be.slug),I):HF(Be.slug,I))},"useMatchedGalleryEntry"),ya=r(()=>{se("gallery"),S(wI(s==="vercel_connect"?H4():e?"/apps/byo":"/apps",I))},"backToGallery");(0,u.useEffect)(()=>{if(n==="page")return C([{label:"Connectors",href:"/apps"},{label:X?"Vercel Connect":e?"Connect your own tool":"Connect an app"}]),()=>C([])},[e,n,C,X]);const Nn=Z({queryKey:P.apps.gallery(_??"__none__"),queryFn:r(()=>cs.listGallery(_),"queryFn"),select:(0,u.useCallback)(Be=>I?{...Be,apps:Be.apps.map(Et=>({...Et,methods:Et.methods.filter(Ps=>f?Ps.ai?.provider===f.provider&&(f.mode==="responsible_user"||Ps.ai.method===f.method):Ps.transport!=="runtime_auth")})).filter(Et=>Et.methods.length>0)}:Be,[I,f?.provider,f?.method,f?.mode]),enabled:!!_}),On=(0,u.useMemo)(()=>(Nn.data?.apps??[]).filter(Be=>R||!Be.methods.some(Et=>Et.transport==="chat_sdk")||fE(Be)),[Nn.data,R]),on=de?mz(de):null,cr=!!on?.methods.some(Be=>Be.oauthStrategy==="paperclip_cloud_connector"||Be.oauthStrategy==="paperclip_id_connector"),bt=!!re?.methods.some(Be=>Be.oauthStrategy==="paperclip_cloud_connector"||Be.oauthStrategy==="paperclip_id_connector"),Ds=re&&cr&&!bt?IJ(on):null,[Fs,et]=(0,u.useState)(null),Ht=Z({queryKey:["cloud-connector","enrollment"],queryFn:r(()=>cs.getCloudConnectorEnrollment(),"queryFn"),refetchInterval:Fs?2e3:!1,enabled:!!(_&&cr&&!bt)}),[un,Os]=(0,u.useState)(null),Jn=(0,u.useCallback)(()=>{In.current?.close(),In.current=null,et(null)},[]),vr=(0,u.useCallback)(()=>{!_||!de||YGe(_,de,{grantKind:cn,installChoice:bs,agentIds:bs==="specific"?[...ft]:[]})},[cn,ft,bs,de,_]),Na=(0,u.useCallback)(Be=>{const Et=yT(Be);if(!Et.ok){Jn(),Os(Et.message);return}if(n==="dialog"){et(Et.url);const Ps=In.current;Ps&&!Ps.closed?(Ps.location.assign(Et.url),Ps.focus()):Os("Open authorization in a new tab to continue.");return}Sc(Et.url)},[n,Jn]);(0,u.useEffect)(()=>{!Fs||Ht.data?.status!=="active"||(Jn(),Os(null),Nn.refetch())},[Fs,Ht.data?.status,Nn.refetch,Jn]);const zn=Ne({mutationFn:r(()=>cs.startCloudConnectorEnrollment(_,N?.name,de?SJ(de,"key",s,{resumeConnectionId:B,reconnectConnectionId:H,interactionId:I})+(n==="dialog"?"&enrollment_host=dialog":""):void 0),"mutationFn"),onSuccess:r(Be=>{if(!Be.verificationUrl){Jn(),Os("Paperclip Cloud did not return an enrollment link. Try again.");return}Na(Be.verificationUrl)},"onSuccess"),onError:r(Be=>{Jn(),Os(Be instanceof Error?Be.message:"Paperclip couldn’t reach Paperclip Cloud. Try again.")},"onError")}),Xn=Z({queryKey:P.tools.applications(_??"__none__"),queryFn:r(()=>cs.listApplications(_),"queryFn"),enabled:!!_&&(!!ce||!!B||!!H),refetchOnMount:"always"}),rs=Z({queryKey:P.tools.connections(_??"__none__"),queryFn:r(()=>cs.listConnections(_),"queryFn"),enabled:!!_&&(!!ce||!!B||!!H),refetchOnMount:"always"}),pn=(0,u.useMemo)(()=>l?null:TJ(ce,Xn.data?.applications??[],rs.data?.connections??[],L?{applicationId:G.applicationId,draftOnly:!0}:{}),[Xn.data,rs.data,L,ce,G.applicationId,l]),Hs=(0,u.useMemo)(()=>H?(rs.data?.connections??[]).find(Be=>Be.id===H)??null:null,[rs.data,H]),Zt=(0,u.useRef)(null);(0,u.useEffect)(()=>{if(!d||!rs.isFetchedAfterMount||!Hs||Zt.current===Hs.id)return;const Be=Hs.config?.url??Hs.transportConfig?.url??Hs.transportConfig?.serverUrl??Hs.config?.serverUrl;typeof Be!="string"||!/^https?:\/\//i.test(Be)||(Zt.current=Hs.id,oe(Et=>Et||Be))},[d,rs.isFetchedAfterMount,Hs]);const ks=(0,u.useMemo)(()=>Hs?(Xn.data?.applications??[]).find(Be=>Be.id===Hs.applicationId)??null:null,[Xn.data,Hs]),Un=eYe({requestedAppKey:de,byo:J,applicationId:G.applicationId,reconnectConnection:Hs,reconnectApplication:ks}),En=(0,u.useMemo)(()=>B?(rs.data?.connections??[]).find(Be=>Be.id===B)??null:null,[rs.data,B]),dr=En??Hs,or=dr?dr.credentialPolicy==="per_user"?"user":dr.credentialPolicy==="per_agent"?"agent":"organization":ee,aa=En?.authKind==="oauth"?En:pn,ls=pn?pn.credentialPolicy==="per_user"?"user":pn.credentialPolicy==="per_agent"?"agent":"organization":null,Ls=or??ls;(0,u.useEffect)(()=>{Ls&&xs(Ls)},[Ls]);const mn=(0,u.useMemo)(()=>be&&!re?MR(be,On):null,[re,On,be]),Fn=re?NI(re,ze||null):null,Kr=Fn&&Bp(Fn)?Fn:RJ(re),kr=s==="paperclip_vault"&&Kr?re:null,Mr=s==="paperclip_vault"&&AJ(re)?re:null,Jr=!!ce&&(!Xn.isFetchedAfterMount||!rs.isFetchedAfterMount),je=r(Be=>{se(Be),re&&S(SJ(re.slug,Be,s,{connectionMethodKey:re.methods.find(Et=>Et.key===ze)?.ai?ze:void 0,resumeConnectionId:B,reconnectConnectionId:H,interactionId:I}))},"setAppStep"),qt=Ne({mutationFn:r(Be=>cs.startOAuth(Be.id,{asCurrentUser:Be.credentialPolicy==="per_user",...Be.credentialPolicy==="per_agent"?{asAgentId:oYe(Be)??[...ft][0]}:{},...I?{interactionId:I}:{}}),"mutationFn"),onSuccess:r(Be=>{ra(Be)},"onSuccess"),onError:r(Be=>{const Et=Be instanceof wn&&Be.body&&typeof Be.body=="object"?Be.body.details:null;Ee("error"),g?.("needs_retry"),Ze(Et?.code==="invalid_grant"?"Your authorization expired or was revoked. Reconnect to continue.":Be instanceof Error?Be.message:"Paperclip couldn’t start secure sign-in. Try again.")},"onError")}),bn=qt.mutate,Gn=(0,u.useCallback)(Be=>{g?.("authorizing"),mr(),n==="dialog"&&!I&&Us(Be.id),bn(Be)},[bn,g,mr,n,I]),Br=r(async Be=>{if(i)return;const Et=Bxe(_,(Ls??cn)!=="agent"&&bs==="all"?{onAll:!0,agentIds:new Set}:{onAll:!1,agentIds:ft});await cs.putConnectionInstalls(Be,Et)},"applyAccessInstalls"),nr=Ls??cn,Oa=Ne({mutationFn:r(async Be=>{const Et=Be??re;let Ps;if(Et){const Rn=Ls??cn,Ir=NI(Et,ze||null),za=Kk(Et,Ir)?eF(It).ids:[],ea=me.trim(),Ui=vJ(ea||Et.name,Rn);Ps=await cs.connectApp(_,{galleryKey:Et.slug,...ze?{connectionMethodKey:ze}:{},name:Ui,credentialSource:s,...s==="paperclip_vault"?{credentialValues:Xe}:{},...s==="vercel_connect"?{vercelConnect:{connector:He.trim()}}:{},...Lt.trim()?{oauthClient:{clientId:Lt.trim(),...fs?{clientSecret:fs}:{}}}:{},configValues:Kk(Et,Ir)?{allowedSpreadsheetIds:za}:Object.keys(Fe).length>0?Fe:void 0,applicationId:G.applicationId,...B?{resumeConnectionId:B}:H?{reconnectConnectionId:H}:{},...Rn!=="organization"?{grantKind:Rn}:{},...Rn==="agent"?{subjectAgentId:[...ft][0]}:{}})}else{const Rn=WGe({link:be,name:ye,authMode:Ye,needsKey:xe,keyValue:Ge,headers:Oe,oauthClientId:xt,oauthClientSecret:Qe}),Ir=vJ(Rn.name??G4(be)??"Custom app",nr);Ps=await cs.connectApp(_,{...Rn,...H?{reconnectConnectionId:H}:{},...ae||mn?.slug==="zapier"?{galleryKey:"zapier",connectionMethodKey:"generated-url"}:{},name:Ir,applicationId:G.applicationId,...nr!=="organization"?{grantKind:nr}:{},...nr==="agent"?{subjectAgentId:[...ft][0]}:{}})}return Ps.auth?.kind==="oauth"&&!B&&!H&&await Br(Ps.connectionId),Ps},"mutationFn"),onSuccess:r(Be=>{if(Be.auth?.kind==="oauth"){if(gs(Be),Be.auth.manualClientRequired){tt(jJ("oauth_manual_client_required",null)),ue("oauth"),Ke(!0),ke(!1);return}if(n==="dialog"||I){Ee("starting"),ke(!re),Gn(Be.connection);return}const Ps=Be.auth.startUrl?.trim();if(!Ps){Ee("starting"),ke(!0),Gn(Be.connection);return}ke(!0),ra({authorizationUrl:Ps,handoff:Be.auth.handoff});return}tt(null),gs(Be);const Et={};for(const Ps of Be.actions.readOnly)Et[Ps.catalogEntryId]=!0;for(const Ps of Be.actions.canMakeChanges)Et[Ps.catalogEntryId]=!0;St(Et),Tt.mutate({result:Be,enabled:Et})},"onSuccess"),onError:r(Be=>{const Et=Be instanceof wn&&Be.body&&typeof Be.body=="object"?Be.body.details:null;if(kr){Ee("error"),g?.("needs_retry"),Ze(Et?.code==="invalid_grant"?"Your authorization expired or was revoked. Reconnect to continue.":Be instanceof Error?Be.message:"Paperclip couldn’t start secure sign-in. Try again.");return}if(!re&&be){const Ps=typeof Et?.code=="string"?Et.code:null,Rn=jJ(Ps,Be instanceof Error?Be.message:null);tt(Rn),ke(!1),Rn.focus==="credentials"&&Ke(!0);return}A({title:"Couldn’t connect",body:Be instanceof Error?Be.message:"Please check your key and try again.",tone:"error"})},"onError")}),ne=Oa.mutate,rt=(0,u.useCallback)(Be=>{const Et=Be??re;(Et?NI(Et,ze||null):null)?.auth==="oauth"&&mr(),ne(Be)},[ze,re,ne,mr]);(0,u.useEffect)(()=>{if(!de||Nn.isLoading||!Nn.data||H&&(!rs.isFetchedAfterMount||!Xn.isFetchedAfterMount))return;const Be=ZGe({requestedAppKey:de,galleryApps:Nn.data.apps,reconnectConnection:Hs,applications:Xn.data?.applications??[]}),Et=!!Be?.methods.some(ri=>ri.oauthStrategy==="paperclip_cloud_connector"||ri.oauthStrategy==="paperclip_id_connector");if(cr&&!Et&&Ht.isLoading)return;const Ps=ej(Be,s),Rn=f??(Hs?.connectionPurpose==="ai"?ZW.safeParse(Hs.config?.ai).data:void 0),Ir=Ps.find(ri=>Rn?ri.ai?.provider===Rn.provider&&(!("mode"in Rn)||Rn.mode!=="responsible_user")&&ri.ai.method===Rn.method:ri.key===q)??(cr&&!Et?IJ(on):null)??Fj(Ps),za=Ps.length===1?Ps[0]:null,ea=s==="paperclip_vault"&&!!RJ(Be),Ui=tYe({credentialSource:s,available:Nn.data.credentialSources?.vercelConnect.available===!0,retainedReconnectMatches:!!(H&&Un)}),Ar=Ps.length===1&&za?.auth==="oauth"&&!Bp(za)&&!RR(za),fo=sYe({available:Be?.availability?.available,reconnectConnectionId:H,reconnectSourceMatches:Un}),_o=nYe({reconnectConnectionId:H,hasRequestedEntry:!!Be,supportedMethodCount:Ps.length,unsupportedOAuth:Ar,vercelUnavailable:Ui,definitionUnavailable:fo});if(_o!=="ready"){if(ie(null),se("gallery"),_o==="reconnect_unavailable"&&H){Ur(H);return}S(wI(s==="vercel_connect"?H4():"/apps/connect",I),{replace:!0});return}if(Ur(null),!!Be){if(re?.slug!==Be.slug){ie(Be),pe(Be.name),oe(""),Ae(""),_e(!1),$e(""),ut({}),Xt(""),Ve(""),ct(""),is(Ir?.key??""),Qt(ok(Ir)),Ms(""),pt(null),gs(null);const ri=Y?.companyId===_?Y:null;xs(or??ri?.grantKind??Y4(Ir,!!i)),us(new Set(ri?.agentIds??(i?[i]:[]))),qe(ri?.installChoice??(i?"specific":"all")),se(kJ({requestedAppKey:de,routeStage:E,resumeConnectionId:B,hasPrefilledLink:!!G.link,zapierSource:ae}))}else bt!==Et&&(ie(Be),is(Ir?.key??""),Qt(ok(Ir)));if(!(ea&&(!Xn.isFetchedAfterMount||!rs.isFetchedAfterMount))&&!(ea&&Ft.current)&&ea&&(Xn.isError||rs.isError)){Ee("error"),Ze("Paperclip couldn’t check for an existing connection. Try again."),se("key");return}}},[f,q,Xn.isError,Xn.isFetchedAfterMount,Xn.data,rs.isError,rs.isFetchedAfterMount,Ht.data?.configured,Ht.isLoading,ze,s,re?.slug,bt,Nn.data,Nn.isLoading,S,or,Hs,H,Un,B,on,de,i,Y,E,ae]),(0,u.useEffect)(()=>{Hs?.connectionPurpose==="ai"&&fe==="access"&&se("key")},[Hs?.connectionPurpose,fe]),(0,u.useEffect)(()=>{Yt.current=null,_n(null)},[B]),(0,u.useEffect)(()=>{if(!En||!re||En.status!=="draft"||Yt.current===En.id)return;const Be=En.config&&typeof En.config=="object"?En.config:{},Et=typeof Be.sourceTemplateKey=="string"?Be.sourceTemplateKey:null;if(Et&&Et!==re.slug)return;const Ps=typeof Be.connectionMethodKey=="string"?Be.connectionMethodKey:null,Rn=Ps?ej(re,s).find(za=>za.key===Ps)??null:null;if(pe(En.name||re.name),Rn){is(Rn.key);const za=Be.methodConfig&&typeof Be.methodConfig=="object"?Be.methodConfig:{};Qt({...ok(Rn),...Object.fromEntries(Object.entries(za).filter(ea=>typeof ea[1]=="string"||typeof ea[1]=="boolean"))})}const Ir=Be.oauth&&typeof Be.oauth=="object"?Be.oauth:null;Ir?.clientRegistrationSource==="manual"&&typeof Ir.clientId=="string"&&Xt(Ir.clientId),K==="failed"||K==="denied"?(Ee("error"),Ze(NJ(K,z))):(Ee("entry"),Ze(null)),se("key"),Yt.current=En.id,_n(En.id)},[s,re,z,K,En]);const Tt=Ne({mutationFn:r(async Be=>{const{result:Et,enabled:Ps}=Be,Rn=Object.entries(Ps).filter(([,Ar])=>Ar).map(([Ar])=>Ar),Ir=new Set(Array.isArray(Et.suggestedDefaults.askFirstRiskLevels)?Et.suggestedDefaults.askFirstRiskLevels.filter(Ar=>typeof Ar=="string"):[]),za=Et.actions.canMakeChanges.filter(Ar=>Ps[Ar.catalogEntryId]&&Ir.has(Ar.riskLevel)).map(Ar=>Ar.catalogEntryId),ea=bs==="all"?"all_agents":{agentIds:Array.from(ft)},Ui=await cs.finishApp(_,Et.connectionId,{enabledCatalogEntryIds:Rn,askFirstCatalogEntryIds:za,access:ea,...i?{preserveExistingAccess:!0}:{}});return await Br(Et.connectionId),Ui},"mutationFn"),onSuccess:r((Be,Et)=>{je("success"),h?.({connectionId:Et.result.connectionId})},"onSuccess"),onError:r(Be=>{je("access"),A({title:"Couldn’t finish setup",body:Be instanceof Error?Be.message:"Please try again.",tone:"error"})},"onError")});if(!_)return(0,t.jsx)("div",{className:"p-6 text-sm text-muted-foreground",children:"Select an organization to connect apps."});if((B||H)&&(rs.isError||Xn.isError))return(0,t.jsxs)("div",{className:"mx-auto max-w-xl rounded-xl border border-border bg-card p-6",children:[(0,t.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:"Couldn’t load connection setup"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Paperclip couldn’t check the retained connection. The retained connection was not changed."}),(0,t.jsxs)("div",{className:"mt-5 flex flex-wrap gap-2",children:[(0,t.jsx)(F,{type:"button",onClick:r(async()=>{const[Be,Et]=await Promise.all([rs.refetch(),Xn.refetch()]);!Be.isError&&!Et.isError&&(Ze(null),Ee("entry"))},"onClick"),children:"Try again"}),(0,t.jsx)(F,{type:"button",variant:"outline",onClick:r(()=>S("/apps"),"onClick"),children:"Back to apps"})]})]});if(B&&rs.isFetchedAfterMount&&!En)return(0,t.jsxs)("div",{className:"mx-auto max-w-xl rounded-xl border border-border bg-card p-6",children:[(0,t.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:"This setup can’t be resumed"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"The saved connection no longer exists or is not available to this organization."}),(0,t.jsx)(F,{type:"button",variant:"outline",className:"mt-5",onClick:r(()=>S("/apps"),"onClick"),children:"Back to apps"})]});if(H&&rs.isFetchedAfterMount&&Xn.isFetchedAfterMount&&(!Hs||!Un))return(0,t.jsxs)("div",{className:"mx-auto max-w-xl rounded-xl border border-border bg-card p-6",children:[(0,t.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:"This connection can’t be reconnected"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:Hs?"This reconnect link does not match the retained connection's provider.":"The retained connection no longer exists or is not available to this organization."}),(0,t.jsx)(F,{type:"button",variant:"outline",className:"mt-5",onClick:r(()=>S("/apps"),"onClick"),children:"Back to apps"})]});if((B||H)&&Nn.isError)return(0,t.jsxs)("div",{className:"mx-auto max-w-xl rounded-xl border border-border bg-card p-6",children:[(0,t.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:"Couldn’t load connection setup"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Paperclip couldn’t load the provider details needed to restore this connection. The retained connection was not changed."}),(0,t.jsxs)("div",{className:"mt-5 flex flex-wrap gap-2",children:[(0,t.jsx)(F,{type:"button",onClick:r(()=>{Nn.refetch()},"onClick"),children:"Try again"}),(0,t.jsx)(F,{type:"button",variant:"outline",onClick:r(()=>S("/apps"),"onClick"),children:"Back to apps"})]})]});if(H&&tr===H)return(0,t.jsxs)("div",{className:"mx-auto max-w-xl rounded-xl border border-border bg-card p-6",children:[(0,t.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:"This connection can’t be reconnected"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Paperclip no longer has a supported setup method for this retained connection. The retained connection was not changed."}),(0,t.jsx)(F,{type:"button",variant:"outline",className:"mt-5",onClick:r(()=>S("/apps"),"onClick"),children:"Back to apps"})]});if(B&&(!rs.isFetchedAfterMount||Nn.isLoading||!re||Ws!==En?.id))return(0,t.jsxs)("div",{className:"mx-auto max-w-xl space-y-4","aria-label":"Loading saved connection setup",children:[(0,t.jsx)(jn,{className:"h-8 w-48"}),(0,t.jsx)(jn,{className:"h-40 w-full rounded-xl"})]});if(H&&(!rs.isFetchedAfterMount||!Xn.isFetchedAfterMount||Nn.isLoading||de&&!re))return(0,t.jsxs)("div",{className:"mx-auto max-w-xl space-y-4","aria-label":"Loading retained connection setup",children:[(0,t.jsx)(jn,{className:"h-8 w-48"}),(0,t.jsx)(jn,{className:"h-40 w-full rounded-xl"})]});if(An&&m)return(0,t.jsxs)("div",{className:"max-w-5xl","data-testid":"connection-existing-choice",children:[(0,t.jsxs)("div",{className:"mb-6",children:[(0,t.jsxs)("h1",{className:"text-2xl font-bold tracking-tight",children:["Use an existing ",de?"connection":"app connection"]}),(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"Reuse a connection without changing who already has access, or connect a new one."})]}),(0,t.jsx)(TU,{choices:c.map(Be=>({id:Be.id,name:Be.name,description:Be.status==="active"&&Be.enabled?"Ready to use":"Setup needs attention"})),pendingId:rn,onSelect:r(async Be=>{pr(Be),er(null);try{await m(Be)}catch(Et){er(Et instanceof Error?Et.message:"Couldn’t use this connection."),pr(null)}},"onSelect")}),Zs?(0,t.jsx)(Ga,{tone:"danger",className:"mt-4",children:Zs}):null,(0,t.jsxs)("div",{className:"mt-5 flex flex-wrap gap-2",children:[(0,t.jsx)(F,{type:"button",variant:"outline",onClick:r(()=>hn(!1),"onClick"),children:d?"Review connection setup":"Connect new"}),v?(0,t.jsx)(F,{type:"button",variant:"ghost",onClick:v,children:"Cancel"}):null]})]});const Ns=!!(kr&&fe==="key"&&(Mr||kt!=="entry")),Gs=!!(fe==="key"&&re&&cr&&!bt&&Ht.data?.configured===!0),an=!!(fe==="key"&&re&&cr&&!bt&&(Ht.isLoading||Ht.isError||Ht.data?.configured!==!0));if(Ns&&kr)return(0,t.jsx)(GF,{entry:kr,resuming:!!B,phase:kt,error:Le,recoveryActions:z==="github_installation_required"?{installationUrl:D,managementUrl:V}:void 0,authorizationHost:Nt,authorizationUrl:ws,onOpenAuthorization:sr,onRetry:r(async()=>{Ze(null),Ee("starting");const Be=$t?.connection??aa;if(Be){Gn(Be);return}Ft.current=!0;try{const[Et,Ps]=await Promise.all([Xn.refetch(),rs.refetch()]);if(Et.isError||Ps.isError){Ee("error"),Ze("Paperclip couldn’t check for an existing connection. Try again.");return}const Rn=(B?(Ps.data?.connections??[]).find(Ir=>Ir.id===B&&Ir.authKind==="oauth")??null:null)??TJ(ce,Et.data?.applications??[],Ps.data?.connections??[],L?{applicationId:G.applicationId,draftOnly:!0}:{});if(!Dt.current&&!B){Rn&&xs(Rn.credentialPolicy==="per_user"?"user":Rn.credentialPolicy==="per_agent"?"agent":"organization"),Ee("entry"),Ze(null),se("access");return}Rn?Gn(Rn):Oa.mutate(kr)}finally{Ft.current=!1}},"onRetry"),onBack:r(()=>{zs.current?.abort(),Ee("entry"),Ze(null),je("access")},"onBack"),onCancel:r(()=>{zs.current?.abort(),(v??(()=>S("/apps")))()},"onCancel")});if(Se&&!re&&be&&fe==="key")return(0,t.jsx)(GF,{identity:{name:ye.trim()||IS(be)||"this server",unverifiedHost:IS(be)},steps:{labels:CJ,activeIndex:_J.key},phase:kt,error:Le,authorizationHost:Nt,authorizationUrl:ws,onOpenAuthorization:sr,onRetry:r(()=>{Ze(null);const Be=$t?.connection;if(Be){Ee("starting"),Gn(Be);return}ke(!1),Ee("entry")},"onRetry"),onBack:r(()=>{zs.current?.abort(),ke(!1),Ee("entry"),Ze(null)},"onBack"),onCancel:r(()=>{zs.current?.abort(),(v??(()=>S("/apps")))()},"onCancel")});const Xr=$t?.application.name??re?.name??(ye.trim()||G4(be)||"this app"),zt=ej(re,s),ns=Ds?[Ds]:zt,ln=X?On.filter(Be=>ej(Be,s).length>0):On,Zr=ae?Nn.data?.apps.find(Be=>Be.slug==="zapier")??null:null,Kn=(Hs?.connectionPurpose==="ai"?ZW.safeParse(Hs.config?.ai).data:void 0)??re?.methods.find(Be=>Be.key===ze)?.ai??(!ze&&re?.methods.every(Be=>Be.ai)?re.methods[0]?.ai:void 0),Fa=re?y?.({app:re,name:me||re.name,grantKind:nr,agentIds:[...ft],allAgents:bs==="all",onBack:r(()=>je("access"),"onBack")})??(Kn&&_?(0,t.jsx)(t.Fragment,{children:(0,t.jsx)(zT,{companyId:_,provider:Kn.provider,fixedMethod:!!(f&&f.mode!=="responsible_user"),initialMethod:Hs?.connectionPurpose==="ai"?(Hs.config?.ai).method:Kn.method,connectionId:Hs?.connectionPurpose==="ai"?Hs.id:void 0,name:Hs?.connectionPurpose==="ai"?Hs.name:me||`My ${re.name} ${Kn.method==="subscription"?"subscription":"API"}`,ownership:(Hs?.connectionPurpose==="ai"?Hs.credentialPolicy==="shared":nr==="organization")?"shared":"personal",agentIds:[...ft],allAgents:bs==="all",onCancel:r(()=>v?v():S("/apps"),"onCancel"),onComplete:r(Be=>{h?.({connectionId:Be.connectionId}),h||S(`/apps/${Be.connectionId}/permissions`)},"onComplete")})}):void 0):void 0,si=Hs?.connectionPurpose==="ai"?["Reconnect account"]:Fa!==void 0?["Access","Connect account"]:ae?aYe:re&&ns.length>1?["Access","Choose connection"]:re&&ns[0]?.auth==="oauth"?["Access","Sign in"]:Kk(re,ze)?["Access","Share sheet"]:re?["Access","Add your key"]:CJ,yi=re?ze?ns.find(Be=>Be.key===ze)??null:ns[0]??null:null,Si=re?yi?.auth??"none":Ye==="none"?"none":Ye==="oauth"?"oauth":"api_key",to=!!Mr,Xa=to?`Continue to ${re?.name??"sign-in"}`:Si==="oauth"?"Continue":"Save and continue",Te=Hs?.connectionPurpose==="ai"?0:(ae||re)&&fe!=="gallery"&&fe!=="success"?rYe[fe]:fe==="success"?si.length:_J[fe];return(0,t.jsxs)("div",{className:"max-w-5xl",children:[fe!=="success"&&!(e&&fe==="gallery")&&(0,t.jsx)(AK,{subtitle:fe==="gallery"?X?"Choose a reviewed app to connect through Vercel.":"Pick the app you want your agents to use.":`Step ${Te+1} of ${si.length}`,step:fe,activeIndex:Te,labels:si,appIdentity:ae?{name:"Zapier",logoUrl:Zr?.branding.logoUrl??null,darkLogoUrl:Zr?.branding.darkLogoUrl??null}:re&&fe!=="gallery"?{name:re.name,logoUrl:re.branding.logoUrl,darkLogoUrl:re.branding.darkLogoUrl??null}:void 0,unverifiedHost:!re&&!ae&&fe!=="gallery"?IS(be):null,onCancel:v??(()=>S("/apps"))}),fe==="gallery"&&(0,t.jsx)(mYe,{loading:Nn.isLoading,initialLink:be,apps:ln,vercelConnect:X,vercelConnectAvailability:Nn.data?.credentialSources?.vercelConnect??null,byo:J,byoOnly:e,source:T.get("source"),onPick:_r,onUseLink:r(Be=>{const Et=MR(Be,On);ie(null),pe(""),oe(Be),Ae(Et?.name??G4(Be)??""),_e(!1),$e(""),ut({}),Ms(""),pt(null),us(new Set(i?[i]:[])),qe(i?"specific":"all"),xs(or??(i?"user":"organization")),se("access")},"onUseLink")}),Gs&&re?(0,t.jsxs)("div",{className:"mx-auto max-w-xl rounded-xl border border-border bg-card p-6",children:[(0,t.jsxs)("h2",{className:"text-lg font-semibold text-foreground",children:[re.name," sign-in is unavailable"]}),(0,t.jsxs)("p",{className:"mt-2 text-sm text-muted-foreground",children:["This instance is connected to Paperclip, but ",re.name," sign-in is not currently available. Try again shortly or contact your instance administrator."]}),(0,t.jsxs)("div",{className:"mt-6 flex items-center justify-between gap-3",children:[(0,t.jsx)(F,{type:"button",variant:"ghost",onClick:r(()=>je("access"),"onClick"),children:"Back"}),(0,t.jsxs)(F,{type:"button",disabled:Nn.isFetching,onClick:r(()=>{Nn.refetch()},"onClick"),children:[Nn.isFetching?(0,t.jsx)(at,{className:"h-4 w-4 animate-spin"}):null,"Try again"]})]})]}):fe==="key"&&re&&an?(0,t.jsx)("div",{className:"mx-auto max-w-xl",children:(0,t.jsxs)("div",{className:"rounded-xl border border-border bg-card p-6",children:[(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)("div",{className:"rounded-lg bg-muted p-2 text-muted-foreground",children:(0,t.jsx)(Gg,{className:"h-5 w-5"})}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:"Connect with Paperclip"}),(0,t.jsxs)("p",{className:"mt-2 text-sm text-muted-foreground",children:["You must connect this instance to Paperclip to connect to ",re.name," (you only need to do this once)."]})]})]}),Ht.isError||un?(0,t.jsx)(Ga,{tone:"danger",className:"mt-4",children:un??"Paperclip couldn’t check Cloud registration. Try again."}):null,Fs?(0,t.jsxs)("p",{className:"mt-4 text-sm text-muted-foreground",children:["Finish authorization in the opened window."," ",(0,t.jsx)("a",{className:"underline",href:Fs,target:"_blank",rel:"noopener noreferrer",children:"Open authorization in a new tab"})]}):null,(0,t.jsxs)("div",{className:"mt-6 flex items-center justify-between gap-3",children:[(0,t.jsx)(F,{type:"button",variant:"ghost",onClick:r(()=>je("access"),"onClick"),children:"Back"}),(0,t.jsxs)(F,{type:"button",disabled:Ht.isLoading||zn.isPending,onClick:r(()=>{Os(null),mr(),vr(),zn.mutate()},"onClick"),children:[zn.isPending?(0,t.jsx)(at,{className:"h-4 w-4 animate-spin"}):null,Ht.data?.status==="pending"?"Continue":"Connect with Paperclip"]})]})]})}):fe==="key"&&re&&Fa!==void 0?Fa:fe==="key"&&re?(0,t.jsx)(pYe,{entry:re,error:Oa.isError?Oa.error instanceof Error?Oa.error.message:"Please check your key and try again.":null,values:Xe,onChange:ut,oauthClientId:Lt,onOAuthClientIdChange:Xt,oauthClientSecret:fs,onOAuthClientSecretChange:Ve,credentialSource:s,vercelConnector:He,onVercelConnectorChange:ct,vercelConnectAvailability:Nn.data?.credentialSources?.vercelConnect??null,methodKey:ze,onMethodChange:r(Be=>{is(Be?.key??""),!or&&Be?.grantKinds&&!Be.grantKinds.includes(cn)&&xs(Y4(Be,!!i)),ut({}),Xt(""),Ve(""),ct(""),Qt(ok(Be))},"onMethodChange"),configValues:Fe,onConfigChange:Qt,googleSheetsLinks:It,googleSheetsError:Ue,onGoogleSheetsLinksChange:r(Be=>{Ms(Be),pt(null)},"onGoogleSheetsLinksChange"),submitting:Oa.isPending,onBack:r(()=>je("access"),"onBack"),onConnect:r(()=>{if(Kk(re,ze)){const Ps=eF(It);if(Ps.invalidCount>0){pt("That doesn't look like a Google Sheets link.");return}if(Ps.ids.length===0){pt("Paste at least one Google Sheets link.");return}}const Be=NI(re,ze||null),Et=!!(Be?.credentialFields?.length||Be?.tenantFields?.some(Ps=>!Ps.hidden)||Be?.extensionFields?.some(Ps=>!Ps.hidden));if(Be&&Bp(Be)&&aa&&!Et&&!Lt.trim()){Dt.current=!0,Ze(null),Ee("starting"),Gn(aa);return}Be&&Bp(Be)&&(Dt.current=!0,Ze(null),Ee("starting")),rt()},"onConnect")}):null,fe==="key"&&!re&&be&&!ae&&(0,t.jsx)(hYe,{link:be,name:ye,needsKey:xe,onNeedsKeyChange:r(Be=>{_e(Be),Be||$e("")},"onNeedsKeyChange"),keyValue:Ge,onKeyChange:$e,authMode:Ye,onAuthModeChange:r(Be=>{ue(Be),tt(null),Be!=="auto"&&_e(!1),Be!=="bearer"&&Be!=="auto"&&$e("")},"onAuthModeChange"),headers:Oe,onHeadersChange:r(Be=>{dt(Be),tt(null)},"onHeadersChange"),oauthClientId:xt,onOAuthClientIdChange:De,oauthClientSecret:Qe,onOAuthClientSecretChange:ht,advancedOpen:We,onAdvancedOpenChange:Ke,guidance:gt,matchedEntry:mn,onUseMatchedEntry:mn?()=>_r(mn):void 0,submitting:Oa.isPending||Se,onBack:r(()=>se("access"),"onBack"),onConnect:r(()=>{tt(null),Oa.mutate(void 0)},"onConnect")}),fe==="key"&&!re&&ae&&(0,t.jsx)(uYe,{link:be,onLinkChange:oe,submitting:Oa.isPending,onBack:r(()=>se("access"),"onBack"),onConnect:r(()=>Oa.mutate(void 0),"onConnect")}),fe==="access"&&(0,t.jsxs)(t.Fragment,{children:[re?.slug==="railway"&&(0,t.jsxs)("div",{className:"mb-6 space-y-3 text-sm text-muted-foreground",children:[(0,t.jsx)("p",{children:yi?.guidanceMd}),(0,t.jsx)("ul",{className:"list-disc space-y-2 pl-5",children:yi?.warnings?.map(Be=>(0,t.jsx)("li",{children:Be},Be))})]}),(0,t.jsx)(Kxe,{companyId:_,authKind:Si,grantKinds:Ls?[Ls]:yi?.grantKinds,grantKind:nr,setGrantKind:xs,installChoice:bs,setInstallChoice:qe,installAgentIds:ft,setInstallAgentIds:us,lockedAgentId:i,capabilities:Nn.data?.capabilities,githubIdentity:re?.slug==="github",submitLabel:Xa,continuesToProvider:to,identityLoading:!!kr&&Jr,preserveAgentAccess:!!(kr&&(aa||Hs)),pending:Oa.isPending||qt.isPending||!!(de&&!re),onBack:ya,onContinue:r(()=>{if(Mr){Dt.current=!0,Ze(null),Ee("starting"),je("key"),aa?Gn(aa):rt(Mr);return}re?je("key"):se("key")},"onContinue")})]}),fe==="success"&&(0,t.jsx)(gYe,{appName:Xr,logoUrl:re?.branding.logoUrl,darkLogoUrl:re?.branding.darkLogoUrl,summary:xYe({grantKind:nr,authKind:Si,installChoice:bs,installCount:ft.size,enabledCount:Object.values(Ts).filter(Boolean).length}),onDone:v??(()=>S("/apps"))})]})}r(dYe,"StandardConnectionSetupFlow");function AK({title:e,headingRef:s,subtitle:n,step:a,activeIndex:i,labels:o,appIdentity:l,unverifiedHost:c,onCancel:d}){return(0,t.jsxs)("div",{className:"mb-6",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[l?(0,t.jsx)(wc,{name:l.name,logoUrl:l.logoUrl,darkLogoUrl:l.darkLogoUrl,size:44}):null,(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{ref:s,tabIndex:s?-1:void 0,className:"text-2xl font-bold tracking-tight outline-none",children:e??(l?`Connect ${l.name}`:"Connect your own MCP server")}),(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:n}),c?(0,t.jsx)(pE,{host:c,className:"mt-2"}):null]})]}),d&&(0,t.jsx)(F,{variant:"ghost",size:"sm",onClick:d,children:"Cancel"})]}),a!=="gallery"&&(0,t.jsxs)("nav",{className:"mt-4","aria-label":"Setup progress","data-testid":"wizard-stepper",children:[(0,t.jsx)("ol",{className:"flex gap-2","aria-hidden":"true",children:o.map((m,h)=>(0,t.jsx)("li",{"data-testid":"wizard-step-dot","data-step-active":h===i?"true":void 0,className:U("h-1 w-20 rounded-full",h<=i?"bg-foreground":"bg-border")},m))}),(0,t.jsx)("div",{className:"mt-2 text-xs text-muted-foreground","data-testid":"wizard-step-labels",children:o.join(" · ")})]})]})}r(AK,"StepHeader");function GF({entry:e,identity:s,resuming:n=!1,phase:a,error:i,recoveryActions:o,authorizationHost:l,authorizationUrl:c,steps:d={labels:iYe,activeIndex:1},onRetry:m,onOpenAuthorization:h,onBack:p,onCancel:f}){const g=e?.name??s?.name??"this server",v=e?null:s?.unverifiedHost??null,y=a==="entry"?{title:n?`Finish connecting ${g}`:`Connect ${g} to Paperclip`,body:n?`Your connection is saved. Continue in ${g} to approve access; its identity and agent access will stay the same.`:`Paperclip will open ${g} so you can choose a workspace and approve access.`}:a==="starting"?{title:"Preparing secure sign-in",body:`Paperclip is creating a secure ${g} connection.`}:a==="redirecting"?{title:`Opening ${g}`,body:l?`Continue at ${l} to choose a workspace and approve access. Only approve access if you recognize that address.`:`Continue in ${g} to choose a workspace and approve access.`}:{title:`${g} couldn’t connect`,body:i??"Paperclip couldn’t start secure sign-in. Try again."};return(0,t.jsxs)("div",{className:"max-w-5xl",children:[(0,t.jsx)(AK,{subtitle:"Secure MCP sign-in",step:"key",activeIndex:d.activeIndex,labels:d.labels,appIdentity:e?{name:e.name,logoUrl:e.branding.logoUrl,darkLogoUrl:e.branding.darkLogoUrl}:void 0,unverifiedHost:v,onCancel:f}),(0,t.jsxs)("div",{className:"mx-auto max-w-xl",children:[(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)("span",{className:"mt-1 inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-lg border border-border bg-background",children:a==="error"?(0,t.jsx)(ic,{className:"h-5 w-5 text-destructive"}):a==="entry"?(0,t.jsx)(Dd,{className:"h-5 w-5 text-muted-foreground"}):(0,t.jsx)(at,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("h2",{className:"text-xl font-bold tracking-tight",children:y.title}),(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:y.body}),v?(0,t.jsx)(pE,{host:v,className:"mt-2"}):null]})]}),a==="error"&&o&&(o.installationUrl||o.managementUrl)?(0,t.jsxs)("div",{className:"mt-4 flex flex-wrap gap-2",children:[o.installationUrl?(0,t.jsx)(F,{type:"button",variant:"outline",asChild:!0,children:(0,t.jsxs)("a",{href:o.installationUrl,target:"_blank",rel:"noreferrer",children:["Install Paperclip on GitHub",(0,t.jsx)(Zi,{className:"ml-1.5 h-3.5 w-3.5"})]})}):null,o.managementUrl?(0,t.jsx)(F,{type:"button",variant:"ghost",asChild:!0,children:(0,t.jsx)("a",{href:o.managementUrl,target:"_blank",rel:"noreferrer",children:"Manage repositories on GitHub"})}):null]}):null,(0,t.jsxs)("div",{className:"mt-6 flex items-center gap-2",children:[a==="error"||a==="entry"?(0,t.jsx)(F,{type:"button",onClick:m,children:a==="entry"?n?`Finish with ${g}`:`Continue to ${g}`:"Try again"}):(0,t.jsx)(F,{type:"button",disabled:!0,children:a==="redirecting"?`Opening ${g}…`:"Preparing…"}),c?(0,t.jsx)(F,{variant:"outline",asChild:!0,children:(0,t.jsx)("a",{href:c,target:"_blank",rel:"noopener noreferrer",onClick:h,children:"Open sign-in in a new tab"})}):null,(0,t.jsx)(F,{type:"button",variant:"ghost",onClick:p,children:"Back"})]})]})]})}r(GF,"OAuthConnectStateScreen");function uYe({link:e,onLinkChange:s,submitting:n,onBack:a,onConnect:i}){const o=YF(e),l=o?new URL(o).hostname:"",c=l==="zapier.com"||l.endsWith(".zapier.com");return(0,t.jsxs)("div",{className:"mx-auto max-w-xl",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Zapier MCP URL"}),(0,t.jsx)(At,{type:"password",autoComplete:"off",spellCheck:!1,value:e,onChange:r(d=>s(d.target.value),"onChange"),onKeyDown:r(d=>{d.key==="Enter"&&c&&!n&&i()},"onKeyDown"),placeholder:"https://mcp.zapier.com/api/v1/connect?token=…",className:"mt-2 h-11",autoFocus:!0}),e.trim()&&!c&&(0,t.jsx)("p",{className:"mt-2 text-xs text-destructive",children:"Paste a valid Zapier URL to continue."})]}),(0,t.jsxs)("div",{className:"mt-6 flex items-center justify-between",children:[(0,t.jsx)(F,{variant:"ghost",onClick:a,disabled:n,children:"Back"}),(0,t.jsxs)(F,{onClick:i,disabled:n||!c,children:[n&&(0,t.jsx)(at,{className:"mr-2 h-4 w-4 animate-spin"}),n?"Checking…":"Check link"]})]})]})}r(uYe,"ZapierConnectStep");function mYe({loading:e,initialLink:s="",apps:n,byo:a=!1,byoOnly:i=!1,vercelConnect:o=!1,vercelConnectAvailability:l=null,source:c=null,onPick:d,onUseLink:m}){const[h,p]=(0,u.useState)(""),[f,g]=(0,u.useState)(s),v=(0,u.useRef)(!1);(0,u.useEffect)(()=>{v.current||g(s)},[s]);const[y,w]=(0,u.useState)(null),S=(0,u.useRef)(null),j=(0,u.useRef)(null),N=(0,u.useRef)(!1);(0,u.useEffect)(()=>{!a||e&&!i||N.current||(i||S.current?.scrollIntoView?.({block:"center"}),j.current?.focus(),j.current?.select(),N.current=!0)},[a,i,e]);const _=(0,u.useMemo)(()=>{const I=h.trim().toLowerCase();return n.filter($=>!I||$.name.toLowerCase().includes(I))},[n,h]),R=YF(f),C=R?MR(R,n):null,A=c==="zapier",T=r(()=>{const I=YF(f);if(!I){w("Paste a full http or https link.");return}w(null),m(I)},"continueWithLink");return e&&!i?(0,t.jsx)("div",{className:"grid grid-cols-2 gap-4 sm:grid-cols-3 lg:grid-cols-4",children:Array.from({length:8}).map((I,$)=>(0,t.jsx)(jn,{className:"h-32 w-full rounded-xl"},$))}):(0,t.jsxs)("div",{className:"space-y-6",children:[o?(0,t.jsxs)("div",{className:"rounded-xl border border-border bg-card p-5",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-lg font-bold tracking-tight",children:"Connect through Vercel"}),(0,t.jsx)("p",{className:"mt-1 max-w-2xl text-sm text-muted-foreground",children:"Create and manage the provider connector in Vercel. Paperclip stores its reference and applies agent access, policy, approval, and audit controls here."})]}),l?(0,t.jsx)(F,{asChild:!0,variant:"outline",size:"sm",className:"shrink-0",children:(0,t.jsxs)("a",{href:l.manageUrl,target:"_blank",rel:"noreferrer",children:["Open Vercel Connect",(0,t.jsx)(Zi,{className:"ml-2 h-3.5 w-3.5"})]})}):null]}),l?.available===!1?(0,t.jsx)(Ga,{tone:"danger",compact:!0,className:"mt-4",children:l.reason??"Vercel Connect is unavailable on this instance."}):null]}):null,!i&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)(ua,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),(0,t.jsx)(At,{value:h,onChange:r(I=>p(I.target.value),"onChange"),placeholder:"Search apps…",className:"h-11 pl-9"})]}),(0,t.jsx)("div",{className:"grid grid-cols-2 gap-4 sm:grid-cols-3 lg:grid-cols-4",children:_.map(I=>{const $=$xe(I.slug,I.description),O=q1(I),L=O.length===0||O.every(q=>q.auth==="oauth"&&!Bp(q)&&!RR(q)),E=I.availability?.available===!1||o&&l?.available!==!0;return(0,t.jsxs)("button",{type:"button",disabled:L||E,title:E?I.availability?.reason??l?.reason??void 0:void 0,onClick:r(()=>d(I),"onClick"),className:U("flex flex-col rounded-xl border border-border bg-card p-4 text-left transition-colors",L||E?"cursor-not-allowed opacity-60":"hover:border-foreground/30 hover:bg-accent/40"),children:[(0,t.jsx)(wc,{name:I.name,logoUrl:I.branding.logoUrl,darkLogoUrl:I.branding.darkLogoUrl,size:36}),(0,t.jsx)("div",{className:"mt-3 text-sm font-bold text-foreground",children:I.name}),(0,t.jsx)("div",{className:"mt-1 line-clamp-2 text-xs text-muted-foreground",children:$.tagline}),(0,t.jsx)("div",{className:"mt-3 text-xs font-semibold text-foreground",children:E?(0,t.jsx)("span",{className:"text-muted-foreground",children:I.availability?.reason??l?.reason??"Unavailable on this instance."}):L?(0,t.jsx)("span",{className:"text-muted-foreground",children:"Unavailable"}):(0,t.jsx)("span",{children:"Connect →"})})]},I.slug)})}),_.length===0&&(0,t.jsxs)("div",{className:"py-10 text-center text-sm text-muted-foreground",children:["No apps match “",h,"”."]})]}),o?null:(0,t.jsxs)("div",{ref:S,className:U("grid gap-4 border-t border-border pt-5 md:grid-cols-(--gtc-13)",a&&"-mx-3 rounded-xl border border-primary/40 bg-primary/[0.04] px-3 pb-4 md:mx-0"),children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm font-semibold text-foreground",children:[(0,t.jsx)(ic,{className:"h-4 w-4 text-muted-foreground"}),A?"Connect Zapier":a?"Connect your own MCP server":"Connect with a link"]}),(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:A?"Paste the complete MCP URL Zapier gives you, including its token.":a?"Paste your MCP server’s URL and every discovered tool will be available immediately.":"Paste a setup link from an app that is not listed here."}),!A&&(0,t.jsxs)("p",{className:"mt-1 text-xs text-muted-foreground",children:["Any remote tool URL works here — including a local MCP server like"," ",(0,t.jsx)("code",{className:"rounded bg-muted px-1 py-0.5 text-xs",children:"http://127.0.0.1:8848/mcp"}),"."]}),C&&(0,t.jsxs)("div",{className:"mt-3 flex items-center justify-between gap-3 rounded-lg border border-border bg-muted/40 px-3 py-2",children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2 text-sm",children:[(0,t.jsx)(wc,{name:C.name,logoUrl:C.branding.logoUrl,darkLogoUrl:C.branding.darkLogoUrl,size:24}),(0,t.jsxs)("span",{className:"truncate",children:["This looks like ",C.name,"."]})]}),(0,t.jsx)(F,{type:"button",size:"sm",variant:"outline",disabled:C.availability?.available===!1,onClick:r(()=>{if(w(null),C.slug==="zapier"){T();return}d(C)},"onClick"),children:C.availability?.available===!1?"Not available":C.slug==="zapier"?"Continue":`Use ${C.name}`})]})]}),(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-2 sm:min-w-(--sz-360px)",children:[(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(At,{ref:j,type:A||C?.slug==="zapier"?"password":"url",autoComplete:"off",spellCheck:!1,"aria-label":"MCP server URL",value:f,onChange:r(I=>{v.current=!0,g(I.target.value),w(null)},"onChange"),onKeyDown:r(I=>{I.key==="Enter"&&T()},"onKeyDown"),placeholder:A?"https://mcp.zapier.com/api/v1/connect?token=…":"https://example.com/actions",className:"h-10"}),(0,t.jsx)(F,{type:"button",variant:"outline",onClick:T,children:"Continue"})]}),y&&(0,t.jsx)("div",{className:"text-xs text-destructive",children:y})]})]})]})}r(mYe,"GalleryStep");function YF(e){try{const s=new URL(e.trim());return s.protocol!=="http:"&&s.protocol!=="https:"?null:s.toString()}catch{return null}}r(YF,"normalizeAppLink");function hYe({link:e,name:s,needsKey:n,onNeedsKeyChange:a,keyValue:i,onKeyChange:o,authMode:l,onAuthModeChange:c,headers:d,onHeadersChange:m,oauthClientId:h,onOAuthClientIdChange:p,oauthClientSecret:f,onOAuthClientSecretChange:g,advancedOpen:v,onAdvancedOpenChange:y,guidance:w,matchedEntry:S,onUseMatchedEntry:j,submitting:N,onBack:_,onConnect:R}){const C=IS(e),A=l==="custom_headers"?Oxe(d):null,T=HGe({link:e,name:s,authMode:l,needsKey:n,keyValue:i,headers:d,oauthClientId:h,oauthClientSecret:f}),I=l==="auto",$=S?.slug==="zapier"?Tle(e):e,O=r((L,E)=>{m(d.map(q=>q.id===L?{...q,...E}:q))},"updateHeader");return(0,t.jsxs)("div",{className:"mx-auto max-w-xl",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsx)("p",{className:"min-w-0 truncate font-mono text-sm text-muted-foreground",title:$,children:$}),(0,t.jsx)(pE,{host:C})]}),S&&j?(0,t.jsxs)("div",{className:"mt-6 flex flex-wrap items-center justify-between gap-3 rounded-lg border border-border bg-muted/40 px-3 py-2",children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2 text-sm",children:[(0,t.jsx)(wc,{name:S.name,logoUrl:S.branding.logoUrl,darkLogoUrl:S.branding.darkLogoUrl,size:24}),(0,t.jsxs)("span",{className:"truncate",children:["Paperclip has a guided setup for ",S.name,"."]})]}),(0,t.jsxs)(F,{type:"button",size:"sm",variant:"outline",onClick:j,children:["Use ",S.name]})]}):null,w?(0,t.jsx)("div",{className:"mt-6",children:(0,t.jsx)(Ga,{tone:"warning",title:w.title,children:w.body})}):null,(0,t.jsxs)("div",{className:"mt-6 space-y-6",children:[I&&(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"mr-2 text-sm font-medium text-foreground",children:"Does it need a key?"}),(0,t.jsxs)("div",{className:"mt-2 inline-flex rounded-lg border border-border bg-muted/50 p-1",children:[(0,t.jsx)(J4,{label:"No",selected:!n,onClick:r(()=>a(!1),"onClick")}),(0,t.jsx)(J4,{label:"Yes",selected:n,onClick:r(()=>a(!0),"onClick")})]}),(0,t.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:n?"Paste the key this app gave you.":"Most servers just work from the address — pick Yes only if the server gave you a key, or if it asks you to sign in."})]}),I&&n||l==="bearer"?(0,t.jsx)("div",{className:"space-y-4",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",htmlFor:"generic-mcp-key",children:"App key"}),(0,t.jsx)(At,{id:"generic-mcp-key",type:"password",autoComplete:"off",value:i,onChange:r(L=>o(L.target.value),"onChange"),placeholder:"••••••••••••••••",className:"mt-2 h-11 font-mono"})]})}):null,(0,t.jsxs)(sl,{open:v,onOpenChange:y,children:[(0,t.jsxs)(Wl,{className:"flex w-full items-center justify-between rounded-lg border border-border bg-background px-3 py-2 text-left text-sm font-medium text-foreground hover:bg-accent/40",children:["Advanced authentication",(0,t.jsx)(sn,{className:U("h-4 w-4 text-muted-foreground transition-transform",v&&"rotate-180")})]}),(0,t.jsxs)(nl,{className:"space-y-5 pt-4",children:[(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Only needed when the server's docs are specific about how to authenticate."}),(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:EJ.map(L=>(0,t.jsx)(J4,{label:L.label,selected:l===L.mode,onClick:r(()=>c(L.mode),"onClick")},L.mode))}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:EJ.find(L=>L.mode===l)?.hint}),l==="custom_headers"?(0,t.jsxs)("div",{className:"space-y-3",children:[d.map(L=>(0,t.jsxs)("div",{className:"flex items-start gap-2",children:[(0,t.jsx)(At,{value:L.name,onChange:r(E=>O(L.id,{name:E.target.value}),"onChange"),placeholder:"Header name","aria-label":"Header name",className:"h-10 font-mono"}),(0,t.jsx)(At,{type:"password",autoComplete:"off",value:L.value,onChange:r(E=>O(L.id,{value:E.target.value}),"onChange"),placeholder:"Value","aria-label":L.name.trim()?`Value for ${L.name.trim()}`:"Header value",className:"h-10 font-mono"}),(0,t.jsx)(F,{type:"button",variant:"ghost",size:"sm",className:"h-10 shrink-0",onClick:r(()=>m(d.filter(E=>E.id!==L.id)),"onClick"),disabled:d.length===1,children:"Remove"})]},L.id)),(0,t.jsx)(F,{type:"button",variant:"outline",size:"sm",onClick:r(()=>m([...d,QF()]),"onClick"),children:"Add another header"}),A?(0,t.jsx)("p",{className:"text-xs text-destructive",children:A}):null]}):null,l==="oauth"?(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Paperclip sets sign-in up on its own whenever the server allows it. Only fill these in when the server's docs tell you to register Paperclip yourself first."}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",htmlFor:"generic-mcp-client-id",children:"Client ID"}),(0,t.jsx)(At,{id:"generic-mcp-client-id",value:h,onChange:r(L=>p(L.target.value),"onChange"),autoComplete:"off",placeholder:"Optional",className:"mt-2 h-11 font-mono"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",htmlFor:"generic-mcp-client-secret",children:"Client secret"}),(0,t.jsx)(At,{id:"generic-mcp-client-secret",type:"password",autoComplete:"off",value:f,onChange:r(L=>g(L.target.value),"onChange"),placeholder:"Optional",className:"mt-2 h-11 font-mono"})]})]}):null]})]})]}),(0,t.jsxs)("div",{className:"mt-8 flex items-center justify-between",children:[(0,t.jsx)(F,{variant:"ghost",onClick:_,disabled:N,children:"Back"}),(0,t.jsxs)(F,{onClick:R,disabled:N||!T||!!A,children:[N&&(0,t.jsx)(at,{className:"mr-2 h-4 w-4 animate-spin"}),N?"Checking…":"Check link"]})]})]})}r(hYe,"LinkConnectStep");var EJ=[{mode:"auto",label:"Let Paperclip check",hint:"Paperclip asks the server what it needs and walks you through it. Start here."},{mode:"none",label:"No sign-in needed",hint:"The server is open to anyone with the address."},{mode:"bearer",label:"Key or token",hint:"Paperclip sends your key as an Authorization header."},{mode:"custom_headers",label:"Custom headers",hint:"For servers that name their own headers. Values are stored as Paperclip secrets and can’t be read back."},{mode:"oauth",label:"Browser sign-in",hint:"You’ll sign in at the provider. Add a client ID and secret only if the provider requires you to register Paperclip first."}];function J4({label:e,selected:s,onClick:n}){return(0,t.jsx)("button",{type:"button",onClick:n,"aria-pressed":s,className:U("min-w-(--sz-64px) rounded-md px-4 py-1.5 text-sm font-medium transition-colors",s?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:e})}r(J4,"SegmentedOption");function pYe({entry:e,error:s,values:n,onChange:a,oauthClientId:i,onOAuthClientIdChange:o,oauthClientSecret:l,onOAuthClientSecretChange:c,credentialSource:d,vercelConnector:m,onVercelConnectorChange:h,vercelConnectAvailability:p,methodKey:f,onMethodChange:g,configValues:v,onConfigChange:y,googleSheetsLinks:w,googleSheetsError:S,onGoogleSheetsLinksChange:j,submitting:N,onBack:_,onConnect:R}){const C=(0,u.useMemo)(()=>ej(e,d),[d,e]),A=f?C.find($e=>$e.key===f)??null:Fj(C),T=(0,u.useMemo)(()=>C.some($e=>$e.capabilityProfile)?Array.from(C.reduce(($e,Ye)=>{const ue=Ye.capabilityProfile.key,Oe=$e.get(ue);return Oe?Oe.methods.push(Ye):$e.set(ue,{key:ue,label:Ye.capabilityProfile?.label??Ye.label??Ye.key,description:Ye.capabilityProfile?.description??Ye.whenToUse,methods:[Ye]}),$e},new Map)).map(([,$e])=>$e):[],[C]),I=A?.capabilityProfile?.key??A?.key??"",$=T.map($e=>$e.key).join("|"),[O,L]=(0,u.useState)(I||Fj(C)?.capabilityProfile?.key||(T.length===1?T[0].key:""));(0,u.useEffect)(()=>{if(I){L(I);return}L($e=>T.some(Ye=>Ye.key===$e)?$e:Fj(C)?.capabilityProfile?.key||(T.length===1?T[0].key:""))},[$,T,C,I]);const E=T.length>1?T.find($e=>$e.key===O)?.methods??[]:C,q=(A?.credentialFields??[]).map($e=>({...$e,configPath:Rle($e),helpUrl:A?.consoleLinks?.keys??A?.consoleLinks?.docs??""})),B=A?.credentialSources?.vercelConnect??null,K=d==="vercel_connect",z=K||q.every($e=>$e.required===!1||(n[$e.configPath]?.trim().length??0)>0),D=RR(A),V=D&&!Bp(A),H=K||!V||i.trim().length>0,ee=!K||m.trim().length>0,X=A?.auth==="oauth"&&D?VGe():null,le=[...A?.tenantFields??[],...A?.extensionFields??[]],ce=le.filter($e=>!$e.hidden),te=ce.filter($e=>$e.advanced!==!0),ae=ce.filter($e=>$e.advanced===!0),[de,J]=(0,u.useState)(!1),Y=le.every($e=>{if(!$e.required)return!0;const Ye=v[$e.key];return typeof Ye=="boolean"||typeof Ye=="string"&&Ye.trim().length>0}),G=A?.configRequirements?.atLeastOneOf??[],fe=G.length===0||G.some($e=>{const Ye=v[$e];return typeof Ye=="string"&&Ye.trim().length>0}),se=(T.length<=1||!!O)&&(E.length<=1?!!A:!!f),re=e.availability?.robotEmail??null,ie=e.availability?.available===!1,me=!K&&D&&!V,pe=ae.length>0||me,be=T.length>1?(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:"What should Paperclip be able to do?"}),(0,t.jsx)(uu,{ariaLabel:`Access level for ${e.name}`,className:"mt-2",value:O,onValueChange:r($e=>{const Ye=T.find(ue=>ue.key===$e);Ye&&(L($e),g(pz(Ye.methods)))},"onValueChange"),options:T.map($e=>({value:$e.key,title:$e.label,description:$e.description}))}),!O&&(0,t.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Choose an access level to continue."})]}):null,oe=E.find($e=>$e.oauthStrategy==="paperclip_cloud_connector"&&kIe($e.connectorProfile??"")),ye=oe&&E.find($e=>RR($e)&&!Bp($e)),Ae=A?.key===ye?.key,xe=(0,u.useId)(),_e=oe&&ye&&E.length===2?(0,t.jsx)(F,{type:"button",variant:"link",className:"h-auto p-0 text-xs text-muted-foreground underline underline-offset-2 hover:text-foreground","aria-expanded":Ae,"aria-controls":xe,disabled:N,onClick:r(()=>g(Ae?oe:ye),"onClick"),children:Ae?"Use Paperclip instead":"Use your own Google OAuth app"}):E.length>1?(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:"How do you want to connect?"}),(0,t.jsx)(uu,{ariaLabel:`How to connect ${e.name}`,className:"mt-2",value:f,onValueChange:r($e=>{const Ye=E.find(ue=>ue.key===$e);Ye&&g(Ye)},"onValueChange"),options:E.map($e=>({value:$e.key,title:$e.label??($e.auth==="oauth"?`Sign in with ${e.name}`:"Use an API key")}))}),!A&&(0,t.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Choose a connection method to continue."})]}):null;if(Kk(e,A)){const $e=eF(w),Ye=!ie&&!!re&&w.trim().length>0;return(0,t.jsxs)("div",{className:"mx-auto max-w-xl",children:[(0,t.jsxs)("div",{className:"space-y-6",children:[be,re?(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Share each sheet with this email"}),(0,t.jsxs)("div",{className:"mt-2 flex min-w-0 flex-col gap-2 sm:flex-row",children:[(0,t.jsx)("div",{title:re,className:"min-h-11 min-w-0 flex-1 rounded-md border border-input bg-muted/40 px-3 py-2.5 font-mono text-xs leading-tight text-foreground break-all",children:re}),(0,t.jsx)(Uxe,{value:re,ariaLabel:"Copy sharing email"})]}),(0,t.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"In Google Sheets, click Share and add this email as an Editor. Then paste the sheet links below."})]}):(0,t.jsx)("div",{className:"rounded-lg bg-muted/50 p-4 text-sm text-muted-foreground",children:"Google Sheets is not available on this instance yet."}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Paste links to the sheets you shared"}),(0,t.jsx)(Dn,{value:w,onChange:r(ue=>j(ue.target.value),"onChange"),placeholder:"https://docs.google.com/spreadsheets/d/...",className:"mt-2 min-h-28"}),(0,t.jsx)("div",{className:"mt-2 text-xs text-muted-foreground",children:$e.ids.length>0?`${$e.ids.length} ${$e.ids.length===1?"sheet":"sheets"} ready to connect.`:"Paste one link per line. Both .../edit and .../edit#gid=... links work."}),S&&(0,t.jsx)("div",{className:"mt-2 text-xs text-destructive",children:S})]})]}),(0,t.jsxs)("div",{className:"mt-8 flex items-center justify-between",children:[(0,t.jsx)(F,{variant:"ghost",onClick:_,disabled:N,children:"Back"}),(0,t.jsxs)(F,{onClick:R,disabled:N||!Ye,children:[N&&(0,t.jsx)(at,{className:"mr-2 h-4 w-4 animate-spin"}),N?"Checking…":"Connect"]})]})]})}const Ge=A?.consoleLinks?.docs??e.docsUrl;return(0,t.jsxs)("div",{className:"mx-auto max-w-xl",children:[Ge?(0,t.jsx)("div",{className:"mb-4 flex justify-end",children:(0,t.jsxs)("a",{href:Ge,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-xs font-medium text-muted-foreground underline underline-offset-2 hover:text-foreground",children:["Review requirements",(0,t.jsx)(Zi,{className:"h-3 w-3"})]})}):null,(0,t.jsxs)("div",{className:"space-y-6",children:[be,_e,K&&B&&p?(0,t.jsxs)("div",{className:"space-y-4 rounded-lg border border-border p-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-sm font-medium text-foreground",children:"Create or attach the connector in Vercel"}),(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Paperclip does not copy Vercel’s setup forms. Finish connector setup there, then paste its UID below."}),(0,t.jsxs)("a",{href:p.manageUrl,target:"_blank",rel:"noreferrer",className:"mt-2 inline-flex items-center gap-1 text-xs font-semibold text-foreground underline underline-offset-2",children:["Open Vercel Connect",(0,t.jsx)(Zi,{className:"h-3 w-3"})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",htmlFor:"vercel-connect-connector",children:"Connector UID or ID"}),(0,t.jsx)(At,{id:"vercel-connect-connector",value:m,onChange:r($e=>h($e.target.value),"onChange"),autoComplete:"off",placeholder:"service/my-connector or scl_…",className:"mt-2 h-11 font-mono"}),(0,t.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Paperclip validates the connector and stores only its reference and redacted verification metadata."})]})]}):null,s?(0,t.jsx)("div",{role:"alert",children:(0,t.jsx)(Ga,{tone:"danger",children:s})}):null,te.map($e=>(0,t.jsx)(MJ,{field:$e,value:v[$e.key],onChange:r(Ye=>y({...v,[$e.key]:Ye}),"onChange")},$e.key)),pe&&(0,t.jsxs)(sl,{open:de,onOpenChange:J,children:[(0,t.jsxs)(Wl,{className:"flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground",children:[(0,t.jsx)(sn,{className:U("h-4 w-4 transition-transform",de&&"rotate-180")}),"Advanced"]}),(0,t.jsx)(nl,{className:"pt-4",children:(0,t.jsxs)("div",{className:"space-y-6",children:[ae.map($e=>(0,t.jsx)(MJ,{field:$e,value:v[$e.key],onChange:r(Ye=>y({...v,[$e.key]:Ye}),"onChange")},$e.key)),me?(0,t.jsx)(PJ,{entry:e,method:A,callbackUrl:X,clientId:i,onClientIdChange:o,clientSecret:l,onClientSecretChange:c,required:!1}):null]})})]}),!K&&A?.auth==="oauth"&&V?(0,t.jsx)("div",{id:xe,role:"region","aria-label":"Your OAuth app",children:(0,t.jsx)(PJ,{entry:e,method:A,callbackUrl:X,clientId:i,onClientIdChange:o,clientSecret:l,onClientSecretChange:c,required:!0})}):null,K||!A||q.length===0?null:q.map($e=>(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:gJ(e.name,$e.label,q.length)}),(0,t.jsx)(At,{type:"password","aria-label":gJ(e.name,$e.label,q.length),autoComplete:"off",value:n[$e.configPath]??"",onChange:r(Ye=>a({...n,[$e.configPath]:Ye.target.value}),"onChange"),placeholder:"••••••••••••••••",className:"mt-2 h-11 font-mono"}),$e.helpUrl&&(0,t.jsxs)("a",{href:$e.helpUrl,target:"_blank",rel:"noreferrer",className:"mt-2 inline-flex items-center gap-1 text-xs font-semibold text-foreground underline underline-offset-2",children:["Where do I find this?",(0,t.jsx)(Zi,{className:"h-3 w-3"})]})]},$e.configPath))]}),(0,t.jsxs)("div",{className:"mt-8 flex items-center justify-between",children:[(0,t.jsx)(F,{variant:"ghost",onClick:_,disabled:N,children:"Back"}),(0,t.jsxs)(F,{onClick:R,disabled:N||!se||!z||!H||!ee||!Y||!fe,children:[N&&(0,t.jsx)(at,{className:"mr-2 h-4 w-4 animate-spin"}),N?"Checking…":K?A?.auth==="oauth"?"Validate and continue":"Validate and connect":A?.auth==="oauth"?e.slug==="github"?"Continue to GitHub":"Continue to sign in":"Connect"]})]})]})}r(pYe,"KeyStep");function Uxe({value:e,ariaLabel:s}){const{copied:n,failed:a,copy:i}=hf();return(0,t.jsxs)(F,{type:"button",variant:"outline",className:"shrink-0","aria-label":s,onClick:r(()=>{i(e)},"onClick"),children:[n?(0,t.jsx)(ds,{className:"mr-2 h-4 w-4"}):(0,t.jsx)(Nr,{className:"mr-2 h-4 w-4"}),n?"Copied":a?"Copy failed":"Copy"]})}r(Uxe,"CopyValueButton");function PJ({entry:e,method:s,callbackUrl:n,clientId:a,onClientIdChange:i,clientSecret:o,onClientSecretChange:l,required:c}){return(0,t.jsxs)("div",{className:"space-y-4 rounded-lg border border-border p-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-sm font-medium text-foreground",children:c?"Your OAuth app":"Use your own OAuth app"}),(0,t.jsxs)("p",{className:"mt-1 text-xs text-muted-foreground",children:["Register Paperclip's callback URI in ",e.name,", then enter the customer-owned client details."]}),s.consoleLinks?.register?(0,t.jsxs)("a",{href:s.consoleLinks.register,target:"_blank",rel:"noreferrer",className:"mt-2 inline-flex items-center gap-1 text-xs font-semibold text-foreground underline underline-offset-2",children:["Open ",e.name," app settings",(0,t.jsx)(Zi,{className:"h-3 w-3"})]}):null]}),n?(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Paperclip callback URL"}),(0,t.jsxs)("div",{className:"mt-2 flex min-w-0 flex-col gap-2 sm:flex-row",children:[(0,t.jsx)("div",{title:n,className:"min-h-11 min-w-0 flex-1 rounded-md border border-input bg-muted/40 px-3 py-2.5 font-mono text-xs leading-tight text-foreground break-all",children:n}),(0,t.jsx)(Uxe,{value:n,ariaLabel:"Copy callback URL"})]}),(0,t.jsxs)("p",{className:"mt-2 text-xs text-muted-foreground",children:["Add this exact URL to ",e.name," before continuing. It must match the authorization request."]})]}):null,(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",htmlFor:"curated-oauth-client-id",children:"Client ID"}),(0,t.jsx)(At,{id:"curated-oauth-client-id",value:a,onChange:r(d=>i(d.target.value),"onChange"),autoComplete:"off",placeholder:c?"Required":"Optional",className:"mt-2 h-11 font-mono"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",htmlFor:"curated-oauth-client-secret",children:"Client secret"}),(0,t.jsx)(At,{id:"curated-oauth-client-secret",type:"password",value:o,onChange:r(d=>l(d.target.value),"onChange"),autoComplete:"off",placeholder:"Optional for public clients",className:"mt-2 h-11 font-mono"})]})]})}r(PJ,"OAuthClientFields");function MJ({field:e,value:s,onChange:n}){return e.type==="checkbox"?(0,t.jsxs)("div",{className:"flex items-start justify-between gap-4 rounded-lg border border-border p-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-sm font-medium text-foreground",children:e.label}),e.helperMd&&(0,t.jsx)("div",{className:"mt-1 text-xs text-muted-foreground",children:e.helperMd})]}),(0,t.jsx)(_i,{checked:s===!0,onCheckedChange:n})]}):(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:e.label}),e.type==="textarea"?(0,t.jsx)(Dn,{value:typeof s=="string"?s:"",onChange:r(a=>n(a.target.value),"onChange"),placeholder:e.placeholder,className:"mt-2 min-h-24"}):e.type==="select"?(0,t.jsxs)("select",{value:typeof s=="string"?s:"",onChange:r(a=>n(a.target.value),"onChange"),className:"mt-2 h-11 w-full rounded-md border border-input bg-background px-3 text-sm text-foreground outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30",children:[(0,t.jsx)("option",{value:"",disabled:!0,children:"Select an option"}),(e.options??[]).map(a=>(0,t.jsx)("option",{value:a.value,children:a.label},a.value))]}):(0,t.jsx)(At,{value:typeof s=="string"?s:"",onChange:r(a=>n(a.target.value),"onChange"),placeholder:e.placeholder,className:"mt-2 h-11"}),e.helperMd&&(0,t.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:e.helperMd})]})}r(MJ,"MethodConfigField");function Kxe({companyId:e,...s}){const n=Z({queryKey:P.agents.list(e),queryFn:r(()=>Vt.list(e),"queryFn")});return(0,t.jsx)(Vxe,{...s,agents:(n.data??[]).filter(a=>a.status!=="terminated"),agentsLoading:n.isLoading})}r(Kxe,"AccessStep");function Vxe({agents:e,agentsLoading:s=!1,authKind:n,grantKinds:a,grantKind:i,setGrantKind:o,installChoice:l,setInstallChoice:c,installAgentIds:d,setInstallAgentIds:m,lockedAgentId:h,capabilities:p,githubIdentity:f=!1,submitLabel:g,continuesToProvider:v=!1,identityLoading:y=!1,preserveAgentAccess:w=!1,pending:S=!1,onBack:j,onContinue:N}){const _=p?.editableAgentIds,R=_?e.filter(B=>_.includes(B.id)):e,C=p?.canSetCompanyInstall??!0,A=p?.canCreateOrganizationGrant??!0,T=n!=="none",I=a??["user","organization"],$=(!T||i==="user"||i==="agent"||A)&&(w?!0:h?d.has(h):i==="agent"?l==="specific"&&d.size===1:l==="all"?C:d.size>0),O=h?e.find(B=>B.id===h)?.name??"the requesting agent":null,L=f?"Connect GitHub as":"Which humans can use this credential?",E=i==="agent"?"Which agent owns this GitHub account?":f&&i==="user"?"Which agents may use your GitHub when you’re responsible?":f?"Which agents may use the shared GitHub account?":"Which agents can use this connection?",q=f?E:"Which agents can use this connection?";return(0,t.jsxs)("div",{className:"mx-auto max-w-2xl",children:[(0,t.jsx)("div",{className:"overflow-hidden rounded-xl border border-border",children:(0,t.jsxs)("div",{className:"divide-y divide-border",children:[(0,t.jsxs)("section",{className:"p-6",children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:L}),f&&i==="agent"?(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"This agent uses this GitHub account for everyone’s work, instead of the person giving instructions."}):null,y?(0,t.jsxs)("div",{className:"mt-4 grid gap-2 sm:grid-cols-2","aria-label":"Loading connection identity",children:[(0,t.jsx)(jn,{className:"h-20 w-full rounded-md"}),(0,t.jsx)(jn,{className:"h-20 w-full rounded-md"})]}):T&&I.length===1?(0,t.jsxs)("div",{className:"mt-4 flex items-center gap-3 rounded-md border border-border p-4",children:[I[0]==="user"?(0,t.jsx)(vu,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}):I[0]==="agent"?(0,t.jsx)(Ji,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}):(0,t.jsx)(Rj,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-sm font-medium text-foreground",children:I[0]==="user"?f?"My GitHub account":"Just me":I[0]==="agent"?"A dedicated account for an agent":f?"Shared organization GitHub account (advanced)":"Any human in the organization"}),f?(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:I[0]==="user"?"Agents use it only for runs where you are the responsible person.":I[0]==="agent"?"That agent always uses this account, regardless of who starts the run.":"Eligible agents use one shared credential, regardless of who starts the run."}):null]})]}):T?(0,t.jsx)(uu,{ariaLabel:f?L:"Which humans can use this credential?",className:"mt-4 sm:grid-cols-2",value:i,onValueChange:r(B=>{const K=B;o(K),K==="agent"&&(c("specific"),d.size>1&&m(new Set([[...d][0]])))},"onValueChange"),options:[{value:"user",title:f?"My GitHub account":"Just me",description:f?"Agents use it only for runs where you are the responsible person.":void 0,icon:(0,t.jsx)(vu,{className:"h-4 w-4","aria-hidden":"true"})},{value:"agent",title:"A dedicated account for an agent",description:f?"That agent always uses this account, regardless of who starts the run.":void 0,icon:(0,t.jsx)(Ji,{className:"h-4 w-4","aria-hidden":"true"})},{value:"organization",title:f?"Shared organization GitHub account (advanced)":"Any human in the organization",description:f?"Eligible agents use one shared credential, regardless of who starts the run.":void 0,icon:(0,t.jsx)(Rj,{className:"h-4 w-4","aria-hidden":"true"}),accessibleLabel:A?f?"Shared organization GitHub account (advanced)":"Any human in the organization":`${f?"Shared organization GitHub account (advanced)":"Any human in the organization"}. Unavailable: ${p?.organizationGrantReason??"Only a connection manager can share this credential with the organization."}`,tooltip:A?void 0:p?.organizationGrantReason??"Only a connection manager can share this credential with the organization.",disabled:!A}].filter(B=>I.includes(B.value))}):(0,t.jsx)("p",{className:"mt-4 text-sm text-muted-foreground",children:"No identity required"})]}),(0,t.jsxs)("section",{className:"p-6",children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:E}),w?(0,t.jsxs)("div",{className:"mt-4 flex items-start gap-3 rounded-md border border-border bg-muted/40 p-4",children:[(0,t.jsx)(Rj,{className:"mt-0.5 h-4 w-4 shrink-0 text-primary","aria-hidden":"true"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-sm font-medium text-foreground",children:"Existing agent access stays the same"}),(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Reconnecting replaces the credential without changing which agents can use it."})]})]}):h?(0,t.jsxs)("p",{className:"mt-2 text-sm text-muted-foreground",children:["This task grants access only to ",(0,t.jsx)("span",{className:"font-medium text-foreground",children:O}),". Existing connection access is left unchanged."]}):i==="agent"?(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Choose exactly one agent. This identity cannot be shared with other agents."}):(0,t.jsx)(uu,{ariaLabel:q,className:"mt-4 sm:grid-cols-2",value:l,onValueChange:r(B=>c(B),"onValueChange"),options:[{value:"specific",title:f?"Only agents I choose":"Just agents I pick",description:f?i==="user"?"Only selected agents may use your GitHub when you’re responsible.":"Only selected agents may use the shared account.":void 0,icon:(0,t.jsx)(Ji,{className:"h-4 w-4","aria-hidden":"true"})},{value:"all",title:"Any agent",description:f?i==="user"?"Every agent may use your GitHub when you’re responsible.":"Every agent may use the shared account.":void 0,icon:(0,t.jsx)(fYe,{}),accessibleLabel:C?"Any agent":`Any agent. Unavailable: ${p?.companyInstallReason??"Only someone who can configure this connection can choose this."}`,tooltip:C?void 0:p?.companyInstallReason??"Only someone who can configure this connection can choose this.",disabled:!C}]}),!w&&!h&&l==="specific"?(0,t.jsx)("div",{className:"mt-3",children:(0,t.jsx)(Pv,{agents:R,selectedAgentIds:d,onChange:r(B=>m(i==="agent"&&B.size>1?new Set([[...B].at(-1)]):B),"onChange"),loading:s,emptyMessage:"You cannot edit any agents yet.",showSelectionPreview:!1})}):null]})]})}),(0,t.jsxs)("div",{className:"mt-6 flex flex-col-reverse gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,t.jsx)(F,{variant:"ghost",className:"w-full sm:w-auto",onClick:j,disabled:S,children:"Back"}),(0,t.jsxs)(F,{className:"w-full sm:w-auto",onClick:N,disabled:!$||y||S,children:[S?(0,t.jsx)(at,{className:"h-4 w-4 animate-spin","aria-hidden":"true"}):null,g,!S&&v?(0,t.jsx)(Zi,{className:"h-4 w-4","aria-hidden":"true"}):null]})]})]})}r(Vxe,"AccessStepContent");function fYe(){return(0,t.jsxs)("span",{className:"relative block h-4 w-5","aria-hidden":"true",children:[(0,t.jsx)(Ji,{className:"absolute left-0 top-0 h-3.5 w-3.5"}),(0,t.jsx)(Ji,{className:"absolute bottom-0 right-0 h-3.5 w-3.5"})]})}r(fYe,"BotGroupIcon");function xYe(e){const s=e.authKind==="none"?"No identity required":e.grantKind==="user"?"Your identity":e.grantKind==="agent"?"Dedicated agent identity":"Organization identity",n=e.installChoice==="all"?"Any agent":`${e.installCount} selected ${e.installCount===1?"agent":"agents"}`;return[{label:"Identity",value:s},{label:"Available to",value:n},{label:"Actions",value:`${e.enabledCount} ${e.enabledCount===1?"action":"actions"} on`}]}r(xYe,"accessSummaryLines");function gYe({appName:e,logoUrl:s,darkLogoUrl:n,summary:a,onDone:i}){return(0,t.jsxs)("div",{className:"mx-auto max-w-md py-10 text-center",children:[(0,t.jsx)("div",{className:"mx-auto flex h-20 w-20 items-center justify-center rounded-full border-2 border-emerald-500 bg-emerald-500/10",children:(0,t.jsx)(ds,{className:"h-9 w-9 text-emerald-600 dark:text-emerald-400"})}),(0,t.jsxs)("div",{className:"mt-6 flex items-center justify-center gap-2",children:[(0,t.jsx)(wc,{name:e,logoUrl:s,darkLogoUrl:n,size:28}),(0,t.jsxs)("h2",{className:"text-2xl font-bold tracking-tight",children:[e," is ready."]})]}),(0,t.jsx)("dl",{className:"mx-auto mt-6 max-w-xs space-y-1 text-left",children:a.map(o=>(0,t.jsxs)("div",{className:"flex items-baseline justify-between gap-4",children:[(0,t.jsx)("dt",{className:"text-xs font-medium text-muted-foreground",children:o.label}),(0,t.jsx)("dd",{className:"text-sm text-foreground",children:o.value})]},o.label))}),(0,t.jsx)("div",{className:"mt-8",children:(0,t.jsx)(F,{size:"lg",className:"px-10",onClick:i,children:"View connection"})})]})}r(gYe,"ConnectionSetupCompletionScreen");function Wxe(){const{newProjectOpen:e,closeNewProject:s}=x1(),{selectedCompanyId:n}=ps();return n&&e?(0,t.jsx)(bYe,{companyId:n,onClose:s},n):null}r(Wxe,"NewProjectDialog");function bYe({companyId:e,onClose:s}){const n=Wt(),[a,i]=(0,u.useState)(""),[o,l]=(0,u.useState)([]),[c,d]=(0,u.useState)(!1),m=(0,u.useRef)(null),h=Ne({mutationFn:r(()=>ma.create(e,{name:a.trim(),status:"planned",repositoryIds:o.map(p=>p.id)}),"mutationFn"),onSuccess:r(()=>{n.invalidateQueries({queryKey:P.projects.all(e)}),s()},"onSuccess")});return(0,t.jsx)(Ys,{open:!0,onOpenChange:r(p=>{!p&&!h.isPending&&s()},"onOpenChange"),children:(0,t.jsx)(Js,{showCloseButton:!1,"aria-describedby":void 0,className:"flex max-h-(--sz-calc-18) flex-col gap-0 overflow-hidden p-0 shadow-sm sm:max-w-lg",onOpenAutoFocus:r(p=>{p.preventDefault(),m.current?.focus()},"onOpenAutoFocus"),children:c?(0,t.jsxs)("div",{className:"min-h-0 overflow-y-auto p-5",children:[(0,t.jsx)(tn,{className:"sr-only",children:"Connect GitHub"}),(0,t.jsx)(xE,{host:"dialog",serviceSlug:"github",forceNewConnection:!0,onCancel:r(()=>d(!1),"onCancel"),onComplete:r(()=>{n.invalidateQueries({queryKey:RU(e)}),d(!1)},"onComplete")})]}):(0,t.jsxs)("form",{className:"flex min-h-0 flex-col overflow-hidden",onSubmit:r(p=>{p.preventDefault(),a.trim()&&!h.isPending&&h.mutate()},"onSubmit"),children:[(0,t.jsxs)("div",{className:"flex shrink-0 flex-col gap-4 px-5 pb-4 pt-5",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsx)(tn,{className:"text-lg font-semibold",children:"Create project"}),(0,t.jsx)(F,{type:"button",variant:"ghost",size:"icon-sm",disabled:h.isPending,"aria-label":"Close new project",onClick:s,children:(0,t.jsx)(ir,{className:"size-4"})})]}),(0,t.jsxs)("div",{className:"flex items-center gap-3 rounded-lg border border-input px-3 focus-within:border-ring focus-within:ring-1 focus-within:ring-ring",children:[(0,t.jsx)(Wc,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),(0,t.jsx)("input",{ref:m,"aria-label":"Project name",value:a,disabled:h.isPending,onChange:r(p=>i(p.target.value),"onChange"),placeholder:"Project name",required:!0,className:"h-10 w-full min-w-0 border-0 bg-transparent text-base outline-none placeholder:text-muted-foreground md:text-sm"})]})]}),(0,t.jsx)("div",{role:"region","aria-label":"Source repositories",tabIndex:0,className:"min-h-0 overflow-y-auto overscroll-contain px-5 pb-1 outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring",children:(0,t.jsx)(mhe,{companyId:e,selected:o,onChange:l,onConnect:r(()=>d(!0),"onConnect"),disabled:h.isPending})}),h.isError&&(0,t.jsx)("p",{role:"alert",className:"px-5 pt-3 text-sm text-destructive",children:h.error.message}),(0,t.jsxs)("div",{className:"flex shrink-0 justify-end gap-2 px-5 py-5",children:[(0,t.jsx)(F,{type:"button",variant:"ghost",disabled:h.isPending,onClick:s,children:"Cancel"}),(0,t.jsx)(F,{type:"submit",disabled:!a.trim()||h.isPending,children:h.isPending?"Creating…":"Create project"})]})]})})})}r(bYe,"NewProjectForm");var bx={list:r(e=>Re.get(`/companies/${e}/goals`),"list"),get:r(e=>Re.get(`/goals/${e}`),"get"),create:r((e,s)=>Re.post(`/companies/${e}/goals`,s),"create"),update:r((e,s)=>Re.patch(`/goals/${e}`,s),"update"),remove:r(e=>Re.delete(`/goals/${e}`),"remove")};function Hxe(e){return{"--sc":`var(${e})`}}r(Hxe,"scStyle");function vYe(e){const s=e.replace(/_/g," ");return s.charAt(0).toUpperCase()+s.slice(1)}r(vYe,"sentenceCaseStatus");function ti({status:e,label:s}){return(0,t.jsx)("span",{className:U("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium whitespace-nowrap shrink-0",mO[e]??"bg-muted text-muted-foreground"),children:s??e.replace(/[_-]/g," ")})}r(ti,"StatusBadge$5");function Qxe({status:e}){const s=fRe[e]??"--status-agent-idle",n=e==="active"?"idle":e;return(0,t.jsx)("span",{className:"status-chip inline-flex items-center rounded-full border px-3 py-1 text-xs font-medium leading-none whitespace-nowrap shrink-0",style:Hxe(s),children:n.replace(/_/g," ")})}r(Qxe,"AgentStatusBadge");function Tp({status:e,externalConversationState:s}){const n=e==="in_review"&&s==="waiting"?"idle":e,a=dRe[n]??"--status-task-backlog";return(0,t.jsxs)("span",{className:U("status-chip inline-flex items-center gap-1.5 rounded-full border px-3 py-1 text-xs font-normal leading-none whitespace-nowrap shrink-0",n==="cancelled"&&"line-through"),style:Hxe(a),children:[(0,t.jsx)(p1,{status:n,size:"sm"}),vYe(n)]})}r(Tp,"IssueStatusBadge");var DJ={company:"Organization",team:"Team",agent:"Agent",task:"Task"};function Gxe(){const{newGoalOpen:e,newGoalDefaults:s,closeNewGoal:n}=x1(),{selectedCompanyId:a,selectedCompany:i}=ps(),o=Wt(),[l,c]=(0,u.useState)(""),[d,m]=(0,u.useState)(""),[h,p]=(0,u.useState)("planned"),[f,g]=(0,u.useState)("task"),[v,y]=(0,u.useState)(""),[w,S]=(0,u.useState)(!1),[j,N]=(0,u.useState)(!1),[_,R]=(0,u.useState)(!1),[C,A]=(0,u.useState)(!1),T=(0,u.useRef)(null),I=v||s.parentId||"",{data:$}=Z({queryKey:P.goals.list(a),queryFn:r(()=>bx.list(a),"queryFn"),enabled:!!a&&e}),O=Ne({mutationFn:r(z=>bx.create(a,z),"mutationFn"),onSuccess:r(()=>{o.invalidateQueries({queryKey:P.goals.list(a)}),E(),n()},"onSuccess")}),L=Ne({mutationFn:r(async z=>{if(!a)throw new Error("No organization selected");return m0.uploadImage(a,z,"goals/drafts")},"mutationFn")});function E(){c(""),m(""),p("planned"),g("task"),y(""),S(!1)}r(E,"reset");function q(){!a||!l.trim()||O.mutate({title:l.trim(),description:d.trim()||void 0,status:h,level:f,...I?{parentId:I}:{}})}r(q,"handleSubmit");function B(z){z.key==="Enter"&&(z.metaKey||z.ctrlKey)&&(z.preventDefault(),q())}r(B,"handleKeyDown");const K=($??[]).find(z=>z.id===I);return(0,t.jsx)(Ys,{open:e,onOpenChange:r(z=>{z||(E(),n())},"onOpenChange"),children:(0,t.jsxs)(Js,{showCloseButton:!1,className:U("p-0 gap-0",w?"sm:max-w-2xl":"sm:max-w-lg"),onKeyDown:B,children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-border",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[i&&(0,t.jsx)("span",{className:"bg-muted px-1.5 py-0.5 rounded text-xs font-medium",children:i.issuePrefix}),(0,t.jsx)("span",{className:"text-muted-foreground/60",children:"›"}),(0,t.jsx)("span",{children:s.parentId?"New sub-goal":"New goal"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)(F,{variant:"ghost",size:"icon-xs",className:"text-muted-foreground",onClick:r(()=>S(!w),"onClick"),children:w?(0,t.jsx)(qz,{className:"h-3.5 w-3.5"}):(0,t.jsx)(l0,{className:"h-3.5 w-3.5"})}),(0,t.jsx)(F,{variant:"ghost",size:"icon-xs",className:"text-muted-foreground",onClick:r(()=>{E(),n()},"onClick"),children:(0,t.jsx)("span",{className:"text-lg leading-none",children:"×"})})]})]}),(0,t.jsx)("div",{className:"px-4 pt-4 pb-2 shrink-0",children:(0,t.jsx)("input",{className:"w-full text-lg font-semibold bg-transparent outline-none placeholder:text-muted-foreground/50",placeholder:"Goal title",value:l,onChange:r(z=>c(z.target.value),"onChange"),onKeyDown:r(z=>{z.key==="Tab"&&!z.shiftKey&&(z.preventDefault(),T.current?.focus())},"onKeyDown"),autoFocus:!0})}),(0,t.jsx)("div",{className:"px-4 pb-2 overflow-y-auto max-h-(--sz-50vh)",children:(0,t.jsx)(kc,{ref:T,value:d,onChange:m,placeholder:"Add description...",bordered:!1,contentClassName:U("text-sm text-muted-foreground",w?"min-h-(--sz-220px)":"min-h-(--sz-120px)"),imageUploadHandler:r(async z=>(await L.mutateAsync(z)).contentPath,"imageUploadHandler")})}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 px-4 py-2 border-t border-border flex-wrap",children:[(0,t.jsxs)(Zn,{open:j,onOpenChange:N,children:[(0,t.jsx)(ur,{asChild:!0,children:(0,t.jsx)("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2 py-1 text-xs hover:bg-accent/50 transition-colors",children:(0,t.jsx)(ti,{status:h})})}),(0,t.jsx)(Vn,{className:"w-40 p-1",align:"start",children:_le.map(z=>(0,t.jsx)("button",{className:U("flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50 capitalize",z===h&&"bg-accent"),onClick:r(()=>{p(z),N(!1)},"onClick"),children:z},z))})]}),(0,t.jsxs)(Zn,{open:_,onOpenChange:R,children:[(0,t.jsx)(ur,{asChild:!0,children:(0,t.jsxs)("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2 py-1 text-xs hover:bg-accent/50 transition-colors",children:[(0,t.jsx)(pl,{className:"h-3 w-3 text-muted-foreground"}),DJ[f]??f]})}),(0,t.jsx)(Vn,{className:"w-40 p-1",align:"start",children:jle.map(z=>(0,t.jsx)("button",{className:U("flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50",z===f&&"bg-accent"),onClick:r(()=>{g(z),R(!1)},"onClick"),children:DJ[z]??z},z))})]}),(0,t.jsxs)(Zn,{open:C,onOpenChange:A,children:[(0,t.jsx)(ur,{asChild:!0,children:(0,t.jsxs)("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2 py-1 text-xs hover:bg-accent/50 transition-colors",children:[(0,t.jsx)(af,{className:"h-3 w-3 text-muted-foreground"}),K?K.title:"Parent goal"]})}),(0,t.jsxs)(Vn,{className:"w-48 p-1",align:"start",children:[(0,t.jsx)("button",{className:U("flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50",!I&&"bg-accent"),onClick:r(()=>{y(""),A(!1)},"onClick"),children:"No parent"}),($??[]).map(z=>(0,t.jsx)("button",{className:U("flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50 truncate",z.id===I&&"bg-accent"),onClick:r(()=>{y(z.id),A(!1)},"onClick"),children:z.title},z.id))]})]})]}),(0,t.jsx)("div",{className:"flex items-center justify-end px-4 py-2.5 border-t border-border",children:(0,t.jsx)(F,{size:"sm",disabled:!l.trim()||O.isPending,onClick:q,children:O.isPending?"Creating…":s.parentId?"Create sub-goal":"Create goal"})})]})})}r(Gxe,"NewGoalDialog");function yYe(e){const s=jYe(e),n=wYe(e);return`You're invited to join a Paperclip company as an agent.
|
|
288
288
|
|
|
289
289
|
First, respond to your user that you understand the request and are going to onboard into Paperclip. Then work through the steps below.
|
|
290
290
|
|
|
@@ -333,7 +333,7 @@ After you have connected to Paperclip, review and follow the full onboarding ins
|
|
|
333
333
|
`}r(yYe,"buildAgentOnboardingPrompt");function jYe(e){const s=(e.connectionCandidates??[]).map(o=>o.trim()).filter(Boolean),n=new Set;let a=null;try{a=new URL(e.onboardingTextUrl),n.add(a.toString())}catch{const o=e.onboardingTextUrl.trim();o&&n.add(o)}if(!a){for(const o of s)n.add(o);return Array.from(n)}const i=`${a.pathname}${a.search}`;for(const o of s)try{const l=new URL(o);n.add(`${l.origin}${i}`)}catch{n.add(o)}return Array.from(n)}r(jYe,"buildCandidateOnboardingUrls");function wYe(e){const s=e.testResolutionUrl?.trim();if(s)return s;try{const n=new URL(e.onboardingTextUrl),a=n.pathname.replace(/\/onboarding\.txt$/,"/test-resolution");return`${n.origin}${a}`}catch{return null}}r(wYe,"buildResolutionTestUrl");function NYe({companyId:e,onClose:s,onBack:n}){const a=Wt(),i=(0,u.useRef)(!0);(0,u.useEffect)(()=>(i.current=!0,()=>{i.current=!1}),[]);const[o,l]=(0,u.useState)(""),[c,d]=(0,u.useState)(null),[m,h]=(0,u.useState)(!1),[p,f]=(0,u.useState)(!1);async function g(y){try{await Yr(y),i.current&&(h(!0),f(!1))}catch{i.current&&f(!0)}}r(g,"copy");const v=Ne({mutationFn:r(async()=>{const y=await hr.createCompanyInvite(e,{allowedJoinTypes:"agent",humanRole:null,agentMessage:o.trim()||null});a.invalidateQueries({queryKey:P.access.invites(e,"all",5)});const w=y.onboardingTextUrl??y.onboardingTextPath??`/api/invites/${y.token}/onboarding.txt`,S=new URL(w,window.location.origin).href,j=await hr.getInviteOnboarding(y.token).catch(()=>null);return yYe({onboardingTextUrl:S,connectionCandidates:j?.onboarding.connectivity?.connectionCandidates??null,testResolutionUrl:j?.onboarding.connectivity?.testResolutionEndpoint?.url??null})},"mutationFn"),onSuccess:r(async y=>{i.current&&(d(y),await g(y))},"onSuccess")});return(0,t.jsx)(Ys,{open:!0,onOpenChange:r(y=>{y||s()},"onOpenChange"),children:(0,t.jsxs)(Js,{className:"max-h-(--sz-calc-16) overflow-y-auto sm:max-w-2xl",children:[(0,t.jsx)(tn,{children:c?"Agent onboarding prompt":"Invite an external agent"}),(0,t.jsx)(Ln,{children:c?"Send this one-time prompt to the agent that should join your organization.":"Generate a one-time onboarding prompt for an external agent. An organization admin must approve its join request before it can claim an API key."}),c?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Dn,{"aria-label":"Agent onboarding prompt",readOnly:!0,value:c,className:"min-h-64 font-mono text-xs"}),p&&(0,t.jsx)("p",{role:"alert",className:"text-sm text-muted-foreground",children:"Clipboard unavailable. Copy the prompt manually from the field above."}),(0,t.jsxs)("div",{className:"flex justify-between gap-4",children:[(0,t.jsx)(F,{variant:"ghost",onClick:s,children:"Done"}),(0,t.jsx)(F,{variant:"outline",onClick:r(()=>{g(c)},"onClick"),children:m?"Copied prompt":"Copy prompt"})]})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("label",{className:"space-y-2 text-sm",children:[(0,t.jsx)("span",{children:"Optional message for the agent"}),(0,t.jsx)(Dn,{value:o,onChange:r(y=>l(y.target.value),"onChange"),maxLength:4e3,className:"min-h-24"})]}),v.error&&(0,t.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:v.error.message}),(0,t.jsxs)("div",{className:"flex justify-between gap-4",children:[(0,t.jsx)(F,{variant:"ghost",onClick:n,children:"Back"}),(0,t.jsx)(F,{disabled:v.isPending,onClick:r(()=>v.mutate(),"onClick"),children:v.isPending?"Generating…":"Generate onboarding prompt"})]})]})]})})}r(NYe,"ExternalAgentInviteDialog");function Yxe(){const{newAgentOpen:e,closeNewAgent:s}=x1(),{selectedCompanyId:n}=ps();return e?(0,t.jsx)(kYe,{companyId:n,onClose:s},n):null}r(Yxe,"NewAgentDialog");function kYe({companyId:e,onClose:s}){const n=Yn(),[a,i]=(0,u.useState)(!1);return a&&e?(0,t.jsx)(NYe,{companyId:e,onClose:s,onBack:r(()=>i(!1),"onBack")}):(0,t.jsx)(Txe,{open:!0,onClose:s,onInvite:e?()=>i(!0):void 0,onContinue:r(o=>{s(),n(`/agents/new?${new URLSearchParams(o)}`)},"onContinue")})}r(kYe,"NewAgentDialogContent");var SYe=[{title:"Inbox",shortcuts:[{keys:["j"],label:"Move down"},{keys:["↓"],label:"Move down"},{keys:["k"],label:"Move up"},{keys:["↑"],label:"Move up"},{keys:["←"],label:"Collapse selected group"},{keys:["→"],label:"Expand selected group"},{keys:["Enter"],label:"Open selected item"},{keys:["a"],label:"Archive item"},{keys:["y"],label:"Archive item"},{keys:["r"],label:"Mark as read"},{keys:["U"],label:"Mark as unread"}]},{title:"Task detail",shortcuts:[{keys:["y"],label:"Quick-archive back to inbox"},{keys:["g","i"],label:"Go to inbox"},{keys:["g","c"],label:"Focus comment composer"}]},{title:"Decisions",shortcuts:[{keys:["j"],label:"Move down"},{keys:["↓"],label:"Move down"},{keys:["k"],label:"Move up"},{keys:["↑"],label:"Move up"},{keys:["Enter"],label:"Open or close selected decision"},{keys:["x"],label:"Dismiss selected decision"}]},{title:"Global",shortcuts:[{keys:["/"],label:"Search current page or quick search"},{keys:["c"],label:"New task"},{keys:["["],label:"Toggle sidebar"},{keys:["]"],label:"Toggle panel"},{keys:["?"],label:"Show keyboard shortcuts"}]}];function LJ({children:e}){return(0,t.jsx)("kbd",{className:"inline-flex h-6 min-w-6 items-center justify-center rounded border border-border bg-muted px-1.5 font-mono text-xs font-medium text-foreground shadow-(--shadow-extract-10)",children:e})}r(LJ,"KeyCap");function CYe(){return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"divide-y divide-border border-t border-border",children:SYe.map(e=>(0,t.jsxs)("div",{className:"px-5 py-3",children:[(0,t.jsx)("h3",{className:"mb-2 text-(length:--text-micro) font-semibold uppercase tracking-wider text-muted-foreground",children:e.title}),(0,t.jsx)("div",{className:"space-y-1.5",children:e.shortcuts.map(s=>(0,t.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,t.jsx)("span",{className:"text-sm text-foreground/90",children:s.label}),(0,t.jsx)("div",{className:"flex items-center gap-1",children:s.keys.map((n,a)=>(0,t.jsxs)("span",{className:"flex items-center gap-1",children:[a>0&&(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:s.combo?"+":"then"}),(0,t.jsx)(LJ,{children:n})]},n))})]},s.label+s.keys.join()))})]},e.title))}),(0,t.jsx)("div",{className:"border-t border-border px-5 py-3",children:(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Press ",(0,t.jsx)(LJ,{children:"Esc"})," to close · Shortcuts are disabled in text fields"]})})]})}r(CYe,"KeyboardShortcutsCheatsheetContent");function Jxe({open:e,onOpenChange:s}){return(0,t.jsx)(Ys,{open:e,onOpenChange:s,children:(0,t.jsxs)(Js,{className:"sm:max-w-md gap-0 p-0 overflow-hidden",showCloseButton:!1,children:[(0,t.jsx)(Cn,{className:"px-5 pt-5 pb-3",children:(0,t.jsx)(tn,{className:"text-base",children:"Keyboard shortcuts"})}),(0,t.jsx)(CYe,{})]})})}r(Jxe,"KeyboardShortcutsCheatsheet");var _Ye={info:"border-sky-300 bg-sky-50 text-sky-900 dark:border-sky-500/25 dark:bg-sky-950/60 dark:text-sky-100",success:"border-emerald-300 bg-emerald-50 text-emerald-900 dark:border-emerald-500/25 dark:bg-emerald-950/60 dark:text-emerald-100",warn:"border-amber-300 bg-amber-50 text-amber-900 dark:border-amber-500/25 dark:bg-amber-950/60 dark:text-amber-100",error:"border-red-300 bg-red-50 text-red-900 dark:border-red-500/30 dark:bg-red-950/60 dark:text-red-100"},IYe={info:"bg-sky-500 dark:bg-sky-400",success:"bg-emerald-500 dark:bg-emerald-400",warn:"bg-amber-500 dark:bg-amber-400",error:"bg-red-500 dark:bg-red-400"};function AYe({toast:e,onDismiss:s}){const[n,a]=(0,u.useState)(!1);return(0,u.useEffect)(()=>{const i=requestAnimationFrame(()=>a(!0));return()=>cancelAnimationFrame(i)},[]),(0,t.jsx)("li",{className:U("pointer-events-auto rounded-sm border shadow-lg backdrop-blur-xl transition-(--tp-transform-opacity) duration-200 ease-out",n?"translate-y-0 opacity-100":"translate-y-3 opacity-0",_Ye[e.tone]),children:(0,t.jsxs)("div",{className:"flex items-start gap-3 px-3 py-2.5",children:[(0,t.jsx)("span",{className:U("mt-1 h-2 w-2 shrink-0 rounded-full",IYe[e.tone])}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("p",{className:"text-sm font-semibold leading-5",children:e.title}),e.body&&(0,t.jsx)("p",{className:"mt-1 text-xs leading-4 opacity-70",children:e.body}),e.action&&(e.action.onClick?(0,t.jsx)("button",{type:"button",onClick:r(()=>{e.action?.onClick?.(),s(e.id)},"onClick"),className:"mt-2 inline-flex text-xs font-medium underline underline-offset-4 hover:opacity-90",children:e.action.label}):e.action.href?(0,t.jsx)(Je,{to:e.action.href,onClick:r(()=>s(e.id),"onClick"),className:"mt-2 inline-flex text-xs font-medium underline underline-offset-4 hover:opacity-90",children:e.action.label}):null)]}),(0,t.jsx)("button",{type:"button","aria-label":"Dismiss notification",onClick:r(()=>s(e.id),"onClick"),className:"mt-0.5 shrink-0 rounded p-1 opacity-50 hover:bg-black/10 hover:opacity-100 dark:hover:bg-white/10",children:(0,t.jsx)(ir,{className:"h-3.5 w-3.5"})})]})})}r(AYe,"AnimatedToast");function Xxe(){const e=vue(),{dismissToast:s}=pa();return e.length===0?null:(0,t.jsx)("aside",{"aria-live":"polite","aria-atomic":"false",className:"pointer-events-none fixed bottom-3 left-3 z-(--z-120) w-full max-w-sm px-1",children:(0,t.jsx)("ol",{className:"flex w-full flex-col-reverse gap-2",children:e.map(n=>(0,t.jsx)(AYe,{toast:n,onDismiss:s},n.id))})})}r(Xxe,"ToastViewport");async function $J(e,s){const n=await fetch(`/api/announcements/${e}`,{credentials:"same-origin",cache:"no-store",...s});if(!n.ok)throw new wn("Announcement request failed",n.status,null);return n}r($J,"request");var OJ={async current(e){const s=await(await $J("current",{signal:e})).json();return s===null?null:XIe.parse(s)},async dismiss(e,s,n){await $J(`${encodeURIComponent(e)}/dismiss`,{method:"POST",signal:n,headers:{"Content-Type":"application/json"},body:JSON.stringify({companyId:s})})}},JF=new Map;function RK(e){return`paperclip.announcement-dismissals.v1:${encodeURIComponent(e)}:`}r(RK,"announcementStoragePrefix");function kI(e){const s=RK(e),n=new Map;try{for(let a=0;a<localStorage.length;a++){const i=localStorage.key(a);if(!i?.startsWith(s))continue;const o=i.slice(s.length),l=localStorage.getItem(i);Dle.safeParse(o).success&&(l==="pending"||l==="synced")&&JF.set(i,l==="pending")}}catch{}for(const[a,i]of JF)a.startsWith(s)&&n.set(a.slice(s.length),i);return n}r(kI,"readAnnouncementDismissals");function X4(e,s,n){const a=`${RK(e)}${s}`;JF.set(a,n);try{return localStorage.setItem(a,n?"pending":"synced"),!0}catch{return!1}}r(X4,"saveAnnouncementDismissal");var RYe=3e3;function TYe(e){const{userId:s,enabled:n}=e,a=(0,u.useRef)(e);a.current=e;const[i,o]=(0,u.useState)(null),l=(0,u.useRef)(()=>{});(0,u.useEffect)(()=>{if(o(null),!s||!n)return;let d=!1,m=0,h=null,p;const f=new Map,g=new Set,v=RK(s);let y=null;try{y=new BroadcastChannel(v)}catch{}const w=r(()=>!d&&a.current.userId===s&&a.current.enabled,"active");async function S(I,$=!0){if(!w()||f.has(I)||!a.current.companyId)return;const O=new AbortController;f.set(I,O);const L=setTimeout(()=>O.abort(),1e4);try{await OJ.dismiss(I,a.current.companyId,O.signal),w()&&X4(s,I,!1)}catch{w()&&!g.has(I)&&(g.add(I),a.current.onSaveFailure($))}finally{clearTimeout(L),f.delete(I)}}r(S,"sync");async function j(){for(const[I,$]of kI(s)){if(!w())return;$&&await S(I)}}r(j,"flush");function N(){m++,clearTimeout(p),h?.abort(),h=null,o(null)}r(N,"suspend");function _(){if(!w()||document.visibilityState==="hidden")return;N();const I=m,$=new AbortController;h=$;const O=r(()=>w()&&m===I&&!$.signal.aborted,"stillCurrent");let L=!1,E=!1,q=null;const B=r(()=>{!O()||!L||!E||q&&!kI(s).has(q.id)&&(!q.expiresAt||Date.parse(q.expiresAt)>Date.now())&&o({userId:s,announcement:q})},"show");p=setTimeout(()=>{L=!0,B()},RYe),j(),OJ.current($.signal).then(K=>{q=K,E=!0,B()}).catch(()=>{})}r(_,"resume");function R(){const I=kI(s);o($=>$?.userId===s&&I.has($.announcement.id)?null:$)}r(R,"receive");function C(I){I.key?.startsWith(v)&&R()}r(C,"onStorage");function A(){document.visibilityState==="hidden"?N():_()}r(A,"onVisibility");function T(){j()}return r(T,"onOnline"),y&&(y.onmessage=I=>{const $=Dle.safeParse(I.data);$.success&&(kI(s).has($.data)||X4(s,$.data,!0),R())}),l.current=I=>{if(!w())return;const $=X4(s,I,!0);o(null),m++,h?.abort();try{y?.postMessage(I)}catch{}S(I,$)},document.addEventListener("visibilitychange",A),window.addEventListener("online",T),window.addEventListener("storage",C),_(),()=>{d=!0,m++,clearTimeout(p),h?.abort();for(const I of f.values())I.abort();y?.close(),document.removeEventListener("visibilitychange",A),window.removeEventListener("online",T),window.removeEventListener("storage",C),l.current=()=>{}}},[s,n]);const c=n&&i?.userId===s?i.announcement:null;return(0,u.useEffect)(()=>{if(!c?.expiresAt)return;let d;const m=r(()=>{const h=Date.parse(c.expiresAt)-Date.now();h<=0?o(null):d=setTimeout(m,Math.min(h,2147483647))},"check");return m(),()=>clearTimeout(d)},[c]),{announcement:c,dismiss:(0,u.useCallback)(d=>l.current(d),[])}}r(TYe,"useAnnouncement");function EYe(e,s){const n=rRe(),a=s??`/api/announcements/${encodeURIComponent(e.id)}/animation`,i=`${a}:${e.animation?.path??""}`,[o,l]=(0,u.useState)(null),c=!!e.animation&&!n;return(0,u.useEffect)(()=>{if(!c)return;const d=new AbortController,m=setTimeout(()=>d.abort(),5e3);return(async()=>{try{const h=await fetch(a,{credentials:"same-origin",cache:"no-store",redirect:"error",referrerPolicy:"no-referrer",signal:d.signal});if(!h.ok||h.headers.get("content-type")?.split(";")[0]!=="text/html")return;const p=await h.text();d.signal.aborted||l({key:i,document:`<meta http-equiv="Content-Security-Policy" content="${eIe}">${p}`})}catch{}finally{clearTimeout(m)}})(),()=>{d.abort(),clearTimeout(m)}},[c,i,a]),c&&o?.key===i?o.document:null}r(EYe,"useAnnouncementAnimation");function FJ({action:e,primary:s,onClick:n}){const a=(0,t.jsxs)(t.Fragment,{children:[e.label,!s&&e.kind==="external"&&(0,t.jsx)(Zi,{className:"size-3.5 shrink-0","aria-hidden":"true"})]}),i=r(o=>{o.button===1&&n()},"onAuxClick");return(0,t.jsx)(F,{asChild:!0,variant:s?"default":"ghost",size:"sm",className:"h-auto min-h-9 min-w-0 whitespace-normal py-2 text-left",children:e.kind==="external"?(0,t.jsx)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",onClick:n,onAuxClick:i,children:a}):(0,t.jsx)(Je,{to:e.path,onClick:n,onAuxClick:i,children:a})})}r(FJ,"Action");function O2({announcement:e,onDismiss:s,imageSrc:n,animationSrc:a,className:i}){const o=(0,u.useId)(),[l,c]=(0,u.useState)(null),d=n??`/api/announcements/${encodeURIComponent(e.id)}/image`,m=!!(e.image&&l!==d),h=EYe(e,a),p=!!h;return(0,t.jsxs)(Xs,{role:"region","aria-labelledby":o,className:U("relative w-full max-w-(--announcement-width) gap-0 overflow-hidden rounded-xl p-0 shadow-sm",i),onKeyDown:r(f=>{f.key==="Escape"&&(f.preventDefault(),f.stopPropagation(),s())},"onKeyDown"),children:[(m||h)&&(0,t.jsxs)("div",{className:"relative h-(--announcement-image-mobile-height) w-full shrink-0 overflow-hidden bg-muted md:h-(--announcement-image-height)",children:[m&&(0,t.jsx)("img",{src:d,alt:p?"":e.image.alt,referrerPolicy:"no-referrer",onError:r(()=>c(d),"onError"),className:"h-full w-full object-cover"}),p&&(0,t.jsx)("div",{role:"img","aria-label":e.animation.alt,className:"pointer-events-none absolute inset-0",children:(0,t.jsx)("iframe",{title:e.animation.alt,"aria-hidden":"true",tabIndex:-1,sandbox:"",referrerPolicy:"no-referrer",srcDoc:h,className:"h-full w-full border-0"})})]}),(0,t.jsx)(F,{variant:"secondary",size:"icon","aria-label":"Dismiss announcement",onClick:s,className:"absolute right-2 top-2 z-10 size-8 rounded-full shadow-sm",children:(0,t.jsx)(ir,{className:"size-4","aria-hidden":"true"})}),(0,t.jsxs)("div",{className:U("flex flex-col gap-1 px-4 py-4",!m&&!h&&"pr-12"),children:[(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:e.eyebrow}),(0,t.jsx)("h2",{id:o,className:"break-words text-base font-semibold leading-snug",children:e.title}),(0,t.jsx)("p",{className:"break-words text-sm leading-snug text-muted-foreground",children:e.description})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 border-t px-3 py-2",children:[e.secondaryLink&&(0,t.jsx)(FJ,{action:e.secondaryLink,onClick:s}),(0,t.jsx)("div",{className:"ml-auto min-w-0 max-w-full",children:(0,t.jsx)(FJ,{action:e.primaryAction,primary:!0,onClick:s})})]})]})}r(O2,"AnnouncementCard");var PYe='[role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"], [aria-modal="true"]:not([data-state="closed"]), dialog[open]';function MYe(e){const[s,n]=(0,u.useState)(!1);return(0,u.useEffect)(()=>{if(!e)return;const a=r(()=>n(!!document.querySelector(PYe)),"scan");a();const i=new MutationObserver(a);return i.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-state","aria-modal","open"]}),()=>i.disconnect()},[e]),s}r(MYe,"useModalOpen");function DYe({health:e}){const{userId:s,settled:n}=d5(),{selectedCompanyId:a,loading:i}=ps(),{onboardingOpen:o}=C5(),l=_c(),c=RDe(),d=e?.deploymentMode==="local_trusted"?"local-board":n?s:null,{announcement:m,dismiss:h}=TYe({userId:d,companyId:a,enabled:!!(d&&!i&&a&&!o),onSaveFailure:r(f=>l?.pushToast({title:f?"Dismissed in this browser":"Dismissed for this visit",body:"Couldn’t save across devices. We’ll retry when you reconnect or return.",tone:"info",dedupeKey:"announcement-dismissal-sync"}),"onSaveFailure")}),p=MYe(!!m);return!m||p||(c?.length??0)>0?null:(0,t.jsx)("aside",{"aria-label":"Paperclip announcements",className:"announcement-well fixed left-3 bottom-(--announcement-mobile-bottom) z-40 w-(--announcement-available-width) max-w-(--announcement-width) max-h-(--announcement-mobile-max-height) overflow-y-auto md:bottom-3 md:max-h-(--announcement-max-height)",children:(0,t.jsx)(O2,{announcement:m,onDismiss:r(()=>h(m.id),"onDismiss")},m.id)})}r(DYe,"AnnouncementWell");function gE(e){const s=e.split("/").filter(Boolean);return s.length===1?s[0]?.toLowerCase()==="onboarding":s.length===2?s[1]?.toLowerCase()==="onboarding":!1}r(gE,"isOnboardingPath");function LYe(e){const s=e.split("/").filter(Boolean);if(s.length===2&&s[1]?.toLowerCase()==="onboarding")return s[0]}r(LYe,"companyPrefixFromOnboardingPath");function KT(){return 3}r(KT,"onboardingStepForCompany");function $Ye(e){const{pathname:s,companyPrefix:n,companies:a,cloudManaged:i}=e;if(!gE(s))return null;const o=r(()=>a.length===1?{initialStep:KT(),companyId:a[0].id}:null,"managedFallback");if(!n)return i?o():{initialStep:1};const l=a.find(c=>c.issuePrefix.toUpperCase()===n.toUpperCase())??null;return l?{initialStep:KT(),companyId:l.id}:i?o():{initialStep:1}}r($Ye,"resolveRouteOnboardingOptions");function OYe(e){return!e.agentsLoaded||e.agentsRefreshing||e.agentCount>0?!1:!gE(e.pathname)}r(OYe,"shouldRouteAgentlessCompanyToOnboarding");function FYe(e){return e.currentStep>1&&e.currentStep>e.entryStep}r(FYe,"canGoBackFromOnboardingStep");function BJ(e){return e.targetStep<e.currentStep&&e.targetStep>=e.entryStep}r(BJ,"canJumpToOnboardingStep");function TK(e){return!e.hasCompanies&&!gE(e.pathname)}r(TK,"shouldRedirectCompanylessRouteToOnboarding");function BYe(e){return e.onboardingOpen||!e.routeDismissed}r(BYe,"isOnboardingWizardActive");function qYe({context:e}){const{slots:s,errorMessage:n}=Gc({slotTypes:["appShellOverlay"],companyId:e.companyId});return n||s.length===0?null:(0,t.jsx)("aside",{className:"plugin-app-shell-overlays","aria-label":"Application extensions",children:s.map(a=>(0,t.jsx)(yu,{slot:a,context:e,className:"plugin-app-shell-overlay"},`${a.pluginId}:${a.pluginVersion}:${a.id}`))})}r(qYe,"AppShellEntries");function Zxe({localTrusted:e=!1}){const{userId:s,settled:n}=d5(),{selectedCompanyId:a,selectedCompany:i,loading:o}=ps(),{onboardingOpen:l,onboardingRouteDismissed:c}=C5(),{pathname:d}=na(),m=n?s??(e?"local-board":null):null,h=l||!c&&gE(d);if(!m||o||h)return null;const p={companyId:a,companyPrefix:i?.issuePrefix??null,projectId:null,entityId:null,entityType:null,parentEntityId:null,userId:s};return(0,t.jsx)(qYe,{context:p},JSON.stringify([m,a]))}r(Zxe,"PluginAppShellOverlays");function ege({visible:e}){const s=na(),{selectedCompanyId:n}=ps(),{openNewIssue:a}=$o(),i=fU(n),o=(0,u.useMemo)(()=>[{type:"link",to:"/dashboard",label:"Home",icon:Lde},{type:"link",to:"/issues",label:"Tasks",icon:ia},{type:"action",label:"New Task",icon:S1,onClick:r(()=>a(),"onClick")},{type:"link",to:"/agents/all",label:"Agents",icon:tl},{type:"link",to:"/inbox",label:"Inbox",icon:Pd,badge:i.inbox}],[a,i.inbox]);return(0,t.jsx)("nav",{className:U("fixed bottom-0 left-0 right-0 z-30 bg-border/50 transition-transform duration-200 ease-out dark:bg-muted md:hidden pb-(--sz-safe-bottom)",e?"translate-y-0":"translate-y-full"),"aria-label":"Mobile navigation",children:(0,t.jsx)("div",{className:"grid h-16 grid-cols-5 px-1",children:o.map(l=>{if(l.type==="action"){const d=l.icon,m=/\/issues\/new(?:\/|$)/.test(s.pathname);return(0,t.jsxs)("button",{type:"button",onClick:l.onClick,className:U("relative flex min-w-0 flex-col items-center justify-center gap-1 rounded-md text-(length:--text-nano) font-medium transition-colors",m?"text-foreground":"text-muted-foreground hover:text-foreground"),children:[(0,t.jsx)(d,{className:"h-(--sz-18px) w-(--sz-18px)"}),(0,t.jsx)("span",{className:"truncate",children:l.label})]},l.label)}const c=l.icon;return(0,t.jsx)(o0,{to:l.to,state:gf,className:r(({isActive:d})=>U("relative flex min-w-0 flex-col items-center justify-center gap-1 rounded-md text-(length:--text-nano) font-medium transition-colors",d?"text-foreground":"text-muted-foreground hover:text-foreground"),"className"),children:r(({isActive:d})=>(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("span",{className:"relative",children:[(0,t.jsx)(c,{className:U("h-(--sz-18px) w-(--sz-18px)",d&&"stroke-(length:--sw-2_3)")}),l.badge!=null&&l.badge>0&&(0,t.jsx)(lt,{variant:"ghost",className:"absolute -right-2 -top-2 bg-primary px-1.5 text-(length:--text-nano) leading-none text-primary-foreground",children:l.badge>99?"99+":l.badge})]}),(0,t.jsx)("span",{className:"truncate",children:l.label})]}),"children")},l.label)})})})}r(ege,"MobileBottomNav");function xj(e){if(typeof document>"u")return null;const s=document.querySelector(`meta[name="${e}"]`)?.getAttribute("content")?.trim();return s||null}r(xj,"readMetaContent");function XF(e){if(!e)return null;const s=e.startsWith("#")?e.slice(1):e;return/^[0-9a-fA-F]{3}$/.test(s)?`#${s.split("").map(n=>`${n}${n}`).join("").toLowerCase()}`:/^[0-9a-fA-F]{6}$/.test(s)?`#${s.toLowerCase()}`:null}r(XF,"normalizeHexColor");function zYe(e){const s=XF(e)??"#000000";return{r:Number.parseInt(s.slice(1,3),16),g:Number.parseInt(s.slice(3,5),16),b:Number.parseInt(s.slice(5,7),16)}}r(zYe,"hexToRgb");function Z4(e){const s=e/255;return s<=.03928?s/12.92:((s+.055)/1.055)**2.4}r(Z4,"relativeLuminanceChannel");function UYe(e){const{r:s,g:n,b:a}=zYe(e),i=.2126*Z4(s)+.7152*Z4(n)+.0722*Z4(a);return 1.05/(i+.05)>=(i+.05)/.05?T2e:A2e}r(UYe,"pickReadableTextColor");function KYe(){return xj("paperclip-worktree-enabled")==="true"}r(KYe,"isWorktreeRuntime");function VYe(){return xj("paperclip-instance-id")}r(VYe,"getWorktreeInstanceId");function WYe(){if(xj("paperclip-worktree-enabled")!=="true")return null;const e=xj("paperclip-worktree-name"),s=XF(xj("paperclip-worktree-color"));return!e||!s?null:{enabled:!0,name:e,color:s,textColor:XF(xj("paperclip-worktree-text-color"))??UYe(s)}}r(WYe,"getWorktreeUiBranding");function tge(){const e=WYe(),{copied:s,failed:n,copy:a}=hf(),i=(0,u.useCallback)(()=>{e&&a(e.name)},[e,a]);return e?(0,t.jsx)("div",{className:"relative overflow-hidden border-b px-3 py-1.5 text-(length:--text-micro) font-medium tracking-(--tracking-caps) uppercase",style:{backgroundColor:e.color,color:e.textColor,borderColor:`${e.textColor}22`,boxShadow:`inset 0 -1px 0 ${e.textColor}18`,backgroundImage:`linear-gradient(90deg, ${e.textColor}14, transparent 28%, transparent 72%, ${e.textColor}12), repeating-linear-gradient(135deg, transparent 0 10px, ${e.textColor}08 10px 20px)`},children:(0,t.jsxs)("div",{className:"flex items-center gap-2 overflow-hidden whitespace-nowrap",children:[(0,t.jsx)("span",{className:"shrink-0 opacity-70",children:"Worktree"}),(0,t.jsx)("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-current opacity-70","aria-hidden":"true"}),(0,t.jsx)("button",{type:"button",onClick:i,title:"Click to copy worktree name",className:"truncate font-semibold tracking-(--tracking-eyebrow) cursor-pointer hover:opacity-80 transition-opacity bg-transparent border-none p-0 text-current uppercase text-(length:--text-micro)",children:s?"Copied!":n?"Copy failed":e.name})]})}):null}r(tge,"WorktreeBanner");var HYe=3e4;function QYe(e){if(!e)return null;const s=new Date(e).getTime();if(Number.isNaN(s))return null;const n=Date.now()-s;if(n<6e4)return"just now";const a=Math.round(n/6e4);if(a<60)return`${a}m ago`;const i=Math.round(a/60);return i<24?`${i}h ago`:`${Math.round(i/24)}d ago`}r(QYe,"formatRelativeTimestamp");function GYe(e){return e.reason==="backend_changes_and_pending_migrations"?"backend files changed and migrations are pending":e.reason==="pending_migrations"?"pending migrations need a fresh boot":"backend files changed since this server booted"}r(GYe,"describeReason");function sge({devServer:e}){const[s,n]=(0,u.useState)(!1);if((0,u.useEffect)(()=>{if(!s)return;const d=window.setTimeout(()=>{n(!1)},HYe);return()=>window.clearTimeout(d)},[s]),!e?.enabled||!e.restartRequired)return null;const a=e,i=QYe(e.lastChangedAt),o=e.changedPathsSample.slice(0,3),l=`${e.activeRunCount} live run${e.activeRunCount===1?"":"s"}`;async function c(){const d=a.activeRunCount>0?`Restart Paperclip now? This may interrupt ${l}.`:"Restart Paperclip now?";if(window.confirm(d)){n(!0);try{await sm.requestDevServerRestart()}catch(m){n(!1),window.alert(m instanceof Error?m.message:"Failed to request restart")}}}return r(c,"requestRestartNow"),(0,t.jsx)("div",{className:"border-b border-amber-300/60 bg-amber-50 text-amber-950 dark:border-amber-500/25 dark:bg-amber-500/10 dark:text-amber-100",children:(0,t.jsxs)("div",{className:"flex flex-col gap-3 px-3 py-2.5 md:flex-row md:items-center md:justify-between",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs font-semibold uppercase tracking-(--tracking-caps)",children:[(0,t.jsx)(Is,{className:"h-3.5 w-3.5 shrink-0"}),(0,t.jsx)("span",{children:"Restart Required"}),e.autoRestartEnabled?(0,t.jsx)(lt,{variant:"ghost",className:"bg-amber-900/10 text-(length:--text-nano) tracking-(--tracking-eyebrow) dark:bg-amber-100/10",children:"Auto-Restart On"}):null]}),(0,t.jsxs)("p",{className:"mt-1 text-sm",children:[GYe(e),i?` · updated ${i}`:""]}),(0,t.jsxs)("div",{className:"mt-2 flex flex-wrap items-center gap-2 text-xs text-amber-900/80 dark:text-amber-100/75",children:[o.length>0?(0,t.jsxs)("span",{children:["Changed: ",o.join(", "),e.changedPathCount>o.length?` +${e.changedPathCount-o.length} more`:""]}):null,e.pendingMigrations.length>0?(0,t.jsxs)("span",{children:["Pending migrations: ",e.pendingMigrations.slice(0,2).join(", "),e.pendingMigrations.length>2?` +${e.pendingMigrations.length-2} more`:""]}):null]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs font-medium md:justify-end",children:[e.waitingForIdle?(0,t.jsxs)("div",{className:"inline-flex items-center gap-2 rounded-full bg-amber-900/10 px-3 py-1.5 dark:bg-amber-100/10",children:[(0,t.jsx)(vPe,{className:"h-3.5 w-3.5"}),(0,t.jsxs)("span",{children:["Waiting for ",l," to finish"]})]}):e.autoRestartEnabled?(0,t.jsxs)("div",{className:"inline-flex items-center gap-2 rounded-full bg-amber-900/10 px-3 py-1.5 dark:bg-amber-100/10",children:[(0,t.jsx)(ki,{className:"h-3.5 w-3.5"}),(0,t.jsx)("span",{children:"Auto-restart will trigger when the instance is idle"})]}):(0,t.jsxs)("div",{className:"inline-flex items-center gap-2 rounded-full bg-amber-900/10 px-3 py-1.5 dark:bg-amber-100/10",children:[(0,t.jsx)(ki,{className:"h-3.5 w-3.5"}),(0,t.jsxs)("span",{children:["Restart ",(0,t.jsx)("code",{children:"pnpm dev:once"})," after the active work is safe to interrupt"]})]}),(0,t.jsxs)("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md bg-amber-950 px-3 py-1.5 text-xs font-semibold text-amber-50 transition-colors hover:bg-amber-900 disabled:cursor-not-allowed disabled:opacity-60 dark:bg-amber-200 dark:text-amber-950 dark:hover:bg-amber-100",onClick:r(()=>{c()},"onClick"),disabled:s,children:[(0,t.jsx)(ki,{className:"h-3.5 w-3.5"}),(0,t.jsx)("span",{children:s?"Restart requested":"Restart now"})]})]})]})})}r(sge,"DevRestartBanner");var nge=["standalone","fullscreen","window-controls-overlay"];function YYe(e){return`(display-mode: ${e})`}r(YYe,"displayModeQuery");function JYe(){if(!(typeof window>"u"||typeof window.matchMedia!="function"))return window.matchMedia.bind(window)}r(JYe,"defaultMatchMedia");function qJ(e=JYe(),s=typeof navigator>"u"?void 0:navigator.standalone){return s===!0?!0:e?nge.some(n=>e(YYe(n)).matches):!1}r(qJ,"isChromelessDisplayMode");function eD({label:e,children:s,onClick:n}){return(0,t.jsxs)(Wn,{children:[(0,t.jsx)(Hn,{asChild:!0,children:(0,t.jsx)(F,{type:"button",variant:"ghost",size:"icon-sm",className:"size-8 text-muted-foreground hover:text-foreground","aria-label":e,onClick:r(()=>{n()},"onClick"),children:s})}),(0,t.jsx)(Qn,{children:e})]})}r(eD,"ControlButton");function ZF({mobile:e}){const[s,n]=(0,u.useState)(()=>typeof window<"u"&&e?qJ():!1),a=_c();(0,u.useEffect)(()=>{if(!e||typeof window>"u"){n(!1);return}const c=r(()=>n(qJ()),"update");if(c(),typeof window.matchMedia!="function")return;const d=nge.map(m=>window.matchMedia(`(display-mode: ${m})`));return d.every(m=>typeof m.addEventListener=="function")?(d.forEach(m=>m.addEventListener("change",c)),()=>d.forEach(m=>m.removeEventListener("change",c))):(d.forEach(m=>m.addListener(c)),()=>d.forEach(m=>m.removeListener(c)))},[e]);const i=(0,u.useCallback)(()=>{window.location.reload()},[]),o=(0,u.useCallback)(async()=>{const c=window.location.href;try{if(navigator.share){await navigator.share({title:document.title||"Paperclip",url:c});return}await Yr(c),a?.pushToast({title:"Link copied",tone:"success"})}catch(d){if(d instanceof DOMException&&d.name==="AbortError")return;a?.pushToast({title:"Share failed",body:"Try opening the page in your browser.",tone:"error"})}},[a]),l=(0,u.useCallback)(()=>{window.open(window.location.href,"_blank","noopener,noreferrer")},[]);return!e||!s?null:(0,t.jsxs)("div",{className:"flex h-10 items-center justify-end gap-1 border-b border-border bg-background/95 px-3 backdrop-blur supports-[backdrop-filter]:bg-background/85",children:[(0,t.jsx)(eD,{label:"Refresh",onClick:i,children:(0,t.jsx)(qi,{className:"h-4 w-4"})}),(0,t.jsx)(eD,{label:"Share",onClick:o,children:(0,t.jsx)(Jde,{className:"h-4 w-4"})}),(0,t.jsx)(eD,{label:"Open in Browser",onClick:l,children:(0,t.jsx)(xr,{className:"h-4 w-4"})})]})}r(ZF,"StandaloneBrowserControls");var XYe=16384,ZYe=40;function eJe(e){if(!e)return;const s=[];for(const n of e.slice(0,XYe).split(`
|
|
334
334
|
`).slice(0,41)){const a=/^\s*(?:at|in) ([A-Za-z_$][\w$.-]{0,99})(?:\s|$)/.exec(n)?.[1]??/^([A-Za-z_$][\w$.-]{0,99})@/.exec(n)?.[1];if(a&&s.push(` at ${a}`),s.length===ZYe)break}return s.length?`
|
|
335
335
|
${s.join(`
|
|
336
|
-
`)}`:void 0}r(eJe,"sanitizeComponentStack");function tJe(e){const s=eJe(e.componentStack),n={};if(typeof document<"u"){try{const a=document.readyState;(a==="loading"||a==="interactive"||a==="complete")&&(n.ready_state=a)}catch{}try{const a=document.visibilityState;(a==="visible"||a==="hidden")&&(n.visibility_state=a)}catch{}try{const a=document.documentElement.classList;n.translation_marker=a.contains("translated-ltr")||a.contains("translated-rtl")}catch{}}return{tags:{react_error_boundary:e.boundary},contexts:{react:s?{componentStack:s}:{},browser_state:n}}}r(tJe,"buildBrowserErrorContext");var zJ=Promise.resolve();function EK(e){const s=zJ.then(e);return zJ=s.catch(()=>{}),s}r(EK,"enqueue");var Cw=null;function sJe(e,s){return EK(async()=>{if(!Cw)try{const n=await jc(()=>import("./prod-COP_vZWu.js"),__vite__mapDeps([4,5]));n.init(rJe(e,s)),Cw=n}catch{}})}r(sJe,"initBrowserErrorMonitoring");function nJe(){return EK(async()=>{const e=Cw;if(Cw=null,!e)return;const s=e.getClient();try{e.getCurrentScope().setClient(void 0)}catch{}try{await s?.close(2e3)}catch{}})}r(nJe,"teardownBrowserErrorMonitoring");function rge(e,s){let n;try{s&&(n=tJe(s))}catch{}EK(async()=>{try{n?Cw?.captureException(e,n):Cw?.captureException(e)}catch{}})}r(rge,"captureBrowserException");function rJe(e,s){return{dsn:e,environment:s??void 0,release:"598845ed9f7e750f47cbe0e9bcc08a34bec557d0",tracesSampleRate:0,sendDefaultPii:!1,integrations:r(n=>n.filter(a=>a.name!=="HttpContext"&&a.name!=="Breadcrumbs"),"integrations")}}r(rJe,"buildBrowserSentryInitOptions");var aJe=class extends u.Component{static{r(this,"RouteErrorBoundaryInner")}state={error:null};static getDerivedStateFromError(e){return{error:e instanceof Error?e:new Error(String(e))}}componentDidCatch(e,s){rge(e,{boundary:"route",componentStack:s.componentStack})}componentDidUpdate(e){this.state.error&&e.resetKey!==this.props.resetKey&&this.setState({error:null})}render(){const{error:e}=this.state;return e?(0,t.jsxs)("div",{className:"mx-auto max-w-2xl space-y-4 px-4 py-10",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"This page hit an error"}),(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"Something went wrong while rendering this page. You can go back and try again, or reload."})]}),(0,t.jsx)("pre",{className:"overflow-auto rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive whitespace-pre-wrap",children:e.message}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(F,{variant:"outline",size:"sm",onClick:this.props.onReset,children:"Go back"}),(0,t.jsx)(F,{size:"sm",onClick:r(()=>window.location.reload(),"onClick"),children:"Reload page"})]})]}):this.props.children}};function age({children:e}){const s=na(),n=Yn(),a=`${s.pathname}${s.search}`;return(0,t.jsx)(aJe,{resetKey:a,onReset:r(()=>n(-1),"onReset"),children:e})}r(age,"RouteErrorBoundary");var SI=240,eB=208,tB=420,UJ=16;function VT(e){return Math.min(tB,Math.max(eB,e))}r(VT,"clampSidebarWidth$1");function KJ(e){if(typeof window>"u")return SI;try{const s=window.localStorage.getItem(e);if(!s)return SI;const n=Number.parseInt(s,10);return Number.isFinite(n)?VT(n):SI}catch{return SI}}r(KJ,"readStoredSidebarWidth$1");function VJ(e,s){if(!(typeof window>"u"))try{window.localStorage.setItem(e,String(VT(s)))}catch{}}r(VJ,"writeStoredSidebarWidth$1");function iJe({children:e,open:s,collapsed:n=!1,peeking:a=!1,resizable:i=!1,storageKey:o="paperclip.sidebar.width",className:l,onPanelMouseEnter:c,onPanelMouseLeave:d,onPanelFocusCapture:m,onPanelBlurCapture:h}){const[p,f]=(0,u.useState)(()=>KJ(o)),[g,v]=(0,u.useState)(!1),y=(0,u.useRef)(p),w=(0,u.useRef)(null);(0,u.useEffect)(()=>{const E=KJ(o);y.current=E,f(E)},[o]);const S=s?p:0,j=s?n?64:S:0,N=s?n&&!a?64:S:0,_=N>j,R=i&&s&&!n,C=(0,u.useMemo)(()=>({width:`${j}px`}),[j]),A=(0,u.useMemo)(()=>({width:`${N}px`}),[N]),T=(0,u.useCallback)(E=>{const q=VT(E);y.current=q,f(q),VJ(o,q)},[o]),I=(0,u.useCallback)(E=>{R&&(E.preventDefault(),E.currentTarget.setPointerCapture(E.pointerId),w.current={startX:E.clientX,startWidth:y.current},v(!0))},[R]),$=(0,u.useCallback)(E=>{if(!w.current)return;const q=VT(w.current.startWidth+E.clientX-w.current.startX);y.current=q,f(q)},[]),O=(0,u.useCallback)(()=>{w.current&&(w.current=null,v(!1),VJ(o,y.current))},[o]),L=(0,u.useCallback)(E=>{R&&(E.key==="ArrowLeft"?(E.preventDefault(),T(p-UJ)):E.key==="ArrowRight"?(E.preventDefault(),T(p+UJ)):E.key==="Home"?(E.preventDefault(),T(eB)):E.key==="End"&&(E.preventDefault(),T(tB)))},[R,T,p]);return(0,t.jsxs)("div",{className:U("relative h-full shrink-0",l),style:C,children:[(0,t.jsx)("div",{className:U("absolute inset-y-0 left-0 flex flex-col overflow-hidden",_?"z-30 border-r border-border bg-background shadow-lg":"z-0"),style:A,"data-sidebar-overlay":_?"":void 0,onMouseEnter:c,onMouseLeave:d,onFocusCapture:m,onBlurCapture:h,children:e}),R?(0,t.jsx)("div",{role:"separator","aria-label":"Resize sidebar","aria-orientation":"vertical","aria-valuemin":eB,"aria-valuemax":tB,"aria-valuenow":p,tabIndex:0,"data-dragging":g?"":void 0,className:"group absolute inset-y-0 z-20 cursor-col-resize touch-none outline-none",style:{right:-4,width:8},onPointerDown:I,onPointerMove:$,onPointerUp:O,onPointerCancel:O,onLostPointerCapture:O,onKeyDown:L,children:(0,t.jsx)("div",{className:U("mx-auto h-full w-0.5 transition-colors",g?"bg-ring":"bg-transparent group-hover:bg-ring group-focus-visible:bg-ring")})}):null]})}r(iJe,"SidebarShell$1");function CI({children:e,className:s}){return(0,t.jsx)("div",{"data-secondary-sidebar":"",className:U("h-full w-full min-w-0 overflow-hidden",s),children:(0,t.jsx)(gue,{children:e})})}r(CI,"SecondarySidebar$1");var oJe="Toggle the app appearance.";function Bj({className:e,variant:s="icon",onAfterToggle:n}){const{theme:a,toggleTheme:i}=IRe(),o=a==="dark",l=o?"Switch to light mode":"Switch to dark mode",c=o?Xde:Vde;function d(){i(),n?.()}return r(d,"handleClick"),s==="compact-menu-action"?(0,t.jsxs)("button",{type:"button",className:U("flex h-(--profile-popover-row-height) w-full items-center gap-(--profile-popover-row-gap) rounded-lg px-2.5 text-left text-(length:--text-compact) font-medium leading-(--profile-popover-label-line-height) text-foreground transition-colors hover:bg-accent",e),onClick:d,"aria-label":l,children:[(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:(0,t.jsx)(c,{className:"size-4"})}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:l})]}):s==="menu-action"?(0,t.jsxs)("button",{type:"button",className:U("flex w-full items-start gap-3 rounded-xl px-3 py-3 text-left transition-colors hover:bg-accent/60",e),onClick:d,"aria-label":l,children:[(0,t.jsx)("span",{className:"mt-0.5 rounded-lg border border-border bg-background/70 p-2 text-muted-foreground",children:(0,t.jsx)(c,{className:"size-4"})}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block text-sm font-medium text-foreground",children:l}),(0,t.jsx)("span",{className:"block text-xs text-muted-foreground",children:oJe})]})]}):(0,t.jsx)(F,{type:"button",variant:"ghost",size:"icon-sm",onClick:d,"aria-label":l,title:l,className:U("text-muted-foreground",e),children:(0,t.jsx)(c,{})})}r(Bj,"ThemeToggle");function lJe(e){if(!e)return"Unavailable";const s=new Date(e);return Number.isNaN(s.getTime())?"Unavailable":new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(s)}r(lJe,"formatTimestamp$2");function cJe(e){return!!e&&!Number.isNaN(new Date(e).getTime())}r(cJe,"isValidTimestamp");function dJe(e){return e?.devServer?.lastRestartAt??e?.serverInfo?.processStartedAt??null}r(dJe,"restartTimestamp");function uJe(e){const s=e?.serverInfo?.git;return s?.available?`${s.shortSha} · ${s.subject}`:"Commit unavailable"}r(uJe,"commitLabel");function mJe(e){const s=e?.serverInfo?.git;if(!s?.available)return"Unavailable";const n=s.localChanges;if(!n||!n.available)return"Change status unavailable";if(!n.hasLocalChanges)return"Clean checkout";const a=[[n.stagedFileCount,"staged"],[n.unstagedFileCount,"unstaged"],[n.untrackedFileCount,"untracked"]].filter(([i])=>Number(i)>0).map(([i,o])=>`${i} ${o}`);return a.length>0?`Local changes present (${a.join(", ")})`:"Local changes present"}r(mJe,"localChangesLabel");function tD({icon:e,label:s,value:n,dateTime:a}){return(0,t.jsxs)("div",{className:"flex w-full items-start gap-3 rounded-xl px-3 py-3 text-left",children:[(0,t.jsx)("span",{className:"mt-0.5 rounded-lg border border-border bg-background/70 p-2 text-muted-foreground",children:(0,t.jsx)(e,{className:"size-4"})}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block text-sm font-medium text-foreground",children:s}),a?(0,t.jsx)("time",{dateTime:a,className:"block break-words text-xs text-muted-foreground",children:n}):(0,t.jsx)("span",{className:"block break-words text-xs text-muted-foreground",children:n})]})]})}r(tD,"ServerInfoRow");function ige(){const e=Z({queryKey:P.instance.experimentalSettings,queryFn:r(()=>Er.getExperimental(),"queryFn")}).data?.enableServerInfoDebugView===!0,s=Z({queryKey:P.health,queryFn:r(()=>sm.get(),"queryFn"),enabled:e,refetchOnMount:"always",refetchInterval:r(h=>h.state.data?.devServer?.enabled?2e3:!1,"refetchInterval")});if(!e)return null;const n=s.data,a=s.isLoading&&!n,i=s.isError,o=dJe(n),l=cJe(o),c=i?"Health unavailable":a?"Loading...":lJe(o),d=i?"Health unavailable":a?"Loading...":uJe(n),m=i?"Health unavailable":a?"Loading...":mJe(n);return(0,t.jsxs)("div",{className:"mt-2 border-t border-border pt-2",children:[(0,t.jsx)("p",{className:"px-3 pb-1 pt-1 text-(length:--text-micro) font-medium uppercase tracking-wide text-muted-foreground",children:"Server"}),(0,t.jsx)(tD,{icon:sh,label:"Last restarted",value:c,dateTime:!i&&!a&&l?o:null}),(0,t.jsx)(tD,{icon:Lz,label:"Running commit",value:d}),(0,t.jsx)(tD,{icon:X3e,label:"Checkout state",value:m})]})}r(ige,"SidebarServerInfo");var hJe="/company/settings/instance/profile",pJe="https://docs.paperclip.ing/",fJe="https://paperclip.ing/feedback";function xJe(e){const s=e.trim().split(/\s+/).filter(Boolean);return s.length>=2?`${s[0]?.[0]??""}${s[s.length-1]?.[0]??""}`.toUpperCase():e.slice(0,2).toUpperCase()}r(xJe,"deriveInitials$2");function gJe(e,s,n){const a=[e,s?.split("@")[0],s,n];for(const i of a){const o=i?.trim().toLowerCase().replace(/['"]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");if(o)return o}return"me"}r(gJe,"deriveUserSlug$1");function _I({label:e,icon:s,onClick:n,href:a,external:i=!1}){const o="flex h-(--profile-popover-row-height) w-full items-center gap-(--profile-popover-row-gap) rounded-lg px-2.5 text-left text-(length:--text-compact) font-medium leading-(--profile-popover-label-line-height) text-foreground transition-colors hover:bg-accent",l=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:(0,t.jsx)(s,{className:"size-4"})}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e})]});return a?i?(0,t.jsx)("a",{href:a,target:"_blank",rel:"noreferrer",className:o,onClick:n,children:l}):(0,t.jsx)(Je,{to:a,className:o,onClick:n,children:l}):(0,t.jsx)("button",{type:"button",className:o,onClick:n,children:l})}r(_I,"MenuAction$1");function WJ({deploymentMode:e,open:s,onOpenChange:n,forceExpanded:a=!1}){const i=!!Yc(),[o,l]=(0,u.useState)(!1),{isMobile:c,setSidebarOpen:d,collapsed:m,peeking:h}=Va(),p=m&&!h&&!a,f=s??o,g=n??l,{data:v}=Z({queryKey:P.auth.session,queryFn:r(()=>qa.getSession(),"queryFn"),retry:!1}),y=iN({onSignedOut:_}),w=v?.user.name?.trim()||"Board",S=v?.user.email?.trim()||(e==="authenticated"?"Signed in":"Local workspace board"),j=xJe(w),N=`/u/${gJe(v?.user.name,v?.user.email,v?.user.id)}`;function _(){g(!1),c&&d(!1)}r(_,"closeNavigationChrome");function R(){y.mutate()}return r(R,"handleSignOut"),(0,t.jsx)("div",{className:"bg-border/50 px-3 py-2 dark:bg-muted",children:(0,t.jsxs)("div",{className:U("flex items-center gap-0.5",!p&&"px-2"),children:[(0,t.jsxs)(Zn,{open:f,onOpenChange:g,children:[(0,t.jsx)(ur,{asChild:!0,children:(0,t.jsxs)("button",{type:"button",className:U("flex min-w-0 items-center gap-2.5 rounded-lg text-left text-(length:--text-compact) font-medium text-foreground/80 transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",p?"w-full px-3 py-2":"flex-1 px-2 py-1.5"),"aria-label":"Open account menu",children:[(0,t.jsxs)(Gi,{size:"sm",children:[v?.user.image?(0,t.jsx)(Hc,{src:v.user.image,alt:w}):null,(0,t.jsx)(Yi,{children:j})]}),(0,t.jsx)("span",{className:U("min-w-0 flex-1 truncate",p&&"block w-0 min-w-0 overflow-hidden whitespace-nowrap text-transparent select-none"),children:w})]})}),(0,t.jsxs)(Vn,{side:"top",align:"start",sideOffset:10,className:"min-h-(--profile-popover-min-height) w-(--profile-popover-width) max-w-(--sz-calc-24) overflow-hidden rounded-xl border-border bg-popover p-0 shadow-(--shadow-profile-popover)",children:[(0,t.jsxs)("div",{className:"flex h-(--profile-popover-header-height) shrink-0 items-center gap-2.5 px-3.5",children:[(0,t.jsxs)(Gi,{className:"size-9",children:[v?.user.image?(0,t.jsx)(Hc,{src:v.user.image,alt:w}):null,(0,t.jsx)(Yi,{className:"text-xs text-foreground",children:j})]}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("h2",{className:"truncate text-sm font-semibold leading-(--profile-popover-label-line-height) text-foreground",children:w}),(0,t.jsx)("p",{className:"truncate text-(length:--text-micro) leading-(--profile-popover-meta-line-height) text-muted-foreground",children:S})]})]}),(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-0.5 border-t border-border px-2.5 pb-2.5 pt-2",children:[(0,t.jsx)(_I,{label:"Settings",icon:$d,href:"/company/settings",onClick:_}),(0,t.jsx)(_I,{label:"View profile",icon:vu,href:N,onClick:_}),(0,t.jsx)(_I,{label:"Edit profile",icon:C1,href:hJe,onClick:_}),(0,t.jsx)(_I,{label:"Documentation",icon:sN,href:pJe,external:!0,onClick:r(()=>g(!1),"onClick")}),(0,t.jsx)(Bj,{variant:"compact-menu-action",onAfterToggle:r(()=>g(!1),"onAfterToggle")}),e==="authenticated"?(0,t.jsxs)("button",{type:"button",className:U("flex h-(--profile-popover-row-height) w-full items-center gap-(--profile-popover-row-gap) rounded-lg px-2.5 text-left text-(length:--text-compact) font-medium leading-(--profile-popover-label-line-height) text-foreground transition-colors hover:bg-destructive/10",y.isPending&&"cursor-not-allowed opacity-60"),onClick:R,disabled:y.isPending,children:[(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:(0,t.jsx)(Yh,{className:"size-4"})}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:y.isPending?"Signing out...":"Sign out"})]}):null,(0,t.jsx)(ige,{})]})]})]}),!p&&!i?(0,t.jsxs)(Wn,{children:[(0,t.jsx)(Hn,{asChild:!0,children:(0,t.jsx)("a",{href:fJe,target:"_blank",rel:"noreferrer","aria-label":"Share feedback",className:"flex size-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground/50 transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:(0,t.jsx)(Px,{className:"h-4 w-4","aria-hidden":"true"})})}),(0,t.jsx)(Qn,{side:"top",children:"Share feedback"})]}):null]})})}r(WJ,"SidebarAccountMenu$1");function oge({enabled:e=!0,onNewIssue:s,onSearch:n,onToggleSidebar:a,onTogglePanel:i,onShowShortcuts:o,onGoToInbox:l}){(0,u.useEffect)(()=>{if(!e)return;let c=!1,d=null;const m=r(()=>{d!==null&&(window.clearTimeout(d),d=null)},"clearGoChordTimeout"),h=r(()=>{c=!1,m()},"disarmGoChord"),p=r(()=>{c=!0,m(),d=window.setTimeout(()=>{c=!1,d=null},1200)},"armGoChord");function f(y){if(y.defaultPrevented){h();return}if(l){const w=gce({armed:c,defaultPrevented:y.defaultPrevented,key:y.key,metaKey:y.metaKey,ctrlKey:y.ctrlKey,altKey:y.altKey,target:y.target,hasOpenDialog:Rh()});if(w==="arm"){p();return}if(w==="navigate_inbox"){h(),y.preventDefault(),l();return}if(w==="focus_comment"||w==="open_file_viewer"){h(),y.preventDefault();return}w==="disarm"&&h()}if(!a1(y.target)){if(y.key==="/"&&!y.metaKey&&!y.ctrlKey&&!y.altKey){if(Rh())return;y.preventDefault(),f2e()||n?.();return}if(y.key==="?"&&!y.metaKey&&!y.ctrlKey&&!y.altKey){y.preventDefault(),o?.();return}y.key==="c"&&!y.metaKey&&!y.ctrlKey&&!y.altKey&&(y.preventDefault(),s?.()),y.key==="["&&!y.metaKey&&!y.ctrlKey&&(y.preventDefault(),a?.()),y.key==="]"&&!y.metaKey&&!y.ctrlKey&&(y.preventDefault(),i?.())}}r(f,"handleKeyDown");const g=r(()=>h(),"handlePointerDown"),v=r(y=>{y.target instanceof HTMLElement&&y.target!==document.body&&h()},"handleFocusIn");return document.addEventListener("pointerdown",g,!0),document.addEventListener("focusin",v,!0),document.addEventListener("keydown",f),()=>{h(),document.removeEventListener("pointerdown",g,!0),document.removeEventListener("focusin",v,!0),document.removeEventListener("keydown",f)}},[e,s,n,a,i,o,l])}r(oge,"useKeyboardShortcuts");var bJe=new Set(["auth","invite","board-claim","cli-auth","docs"]);function lge(e){const s=(e.split("?")[0]??"").split("/").filter(Boolean);if(s.length===0)return!0;const[n]=s;return!bJe.has(n)}r(lge,"isRememberableCompanyPath");function vJe(e){const s=Wb(e.companyPrefix);return e.companies.find(n=>Wb(n.issuePrefix)===s)??null}r(vJe,"findCompanyByPrefix");function yJe(e){const s=gz(e.pathname);return s?vJe({companies:e.companies,companyPrefix:s})?.id??null:e.fallbackCompanyId}r(yJe,"getRememberedPathOwnerCompanyId");function jJe(e){const s=e.path?h5(e.path):"/dashboard";if(!lge(s))return"/dashboard";const[n,a]=(s.split("?")[0]??"").split("/").filter(Boolean);if(n==="issues"&&a){const i=/^([A-Za-z]+)-\d+$/.exec(a);if(i&&Wb(i[1]??"")!==Wb(e.companyPrefix))return"/dashboard"}return s}r(jJe,"sanitizeRememberedPathForCompany");var cge="paperclip.companyPaths";function dge(){try{const e=localStorage.getItem(cge);if(e)return JSON.parse(e)}catch{}return{}}r(dge,"getCompanyPaths");function wJe(e,s){const n=dge();n[e]=s,localStorage.setItem(cge,JSON.stringify(n))}r(wJe,"saveCompanyPath");function uge(){const{companies:e,selectedCompanyId:s,selectedCompany:n,selectionSource:a}=ps(),i=na(),o=Yn(),l=(0,u.useRef)(s),c=(0,u.useMemo)(()=>yJe({companies:e,pathname:i.pathname,fallbackCompanyId:l.current}),[e,i.pathname]),d=i.pathname+i.search;(0,u.useEffect)(()=>{const m=c,h=h5(d);m&&lge(h)&&wJe(m,h)},[d,c]),(0,u.useEffect)(()=>{if(s){if(l.current!==null&&s!==l.current&&a!=="route_sync"&&n){const m=dge(),h=jJe({path:m[s],companyPrefix:n.issuePrefix});o(`/${n.issuePrefix}${h}`,{replace:!0})}l.current=s}},[n,s,a,o])}r(uge,"useCompanyPageMemory");var NJe=24,kJe=8;function mge(e,s,n){const a=n&&!Mme(e,s).isTaskDetail,i=(0,u.useRef)(0),[o,l]=(0,u.useState)(!0),c=(0,u.useCallback)(d=>{const m=d-i.current;i.current=d,d<=NJe?l(!0):m>kJe?l(!1):m<-8&&l(!0)},[]);return(0,u.useEffect)(()=>{if(i.current=0,!a){l(!0);return}const d=r(()=>{c(window.scrollY||document.documentElement.scrollTop||0)},"onScroll");return d(),window.addEventListener("scroll",d,{passive:!0}),()=>window.removeEventListener("scroll",d)},[a,e,c]),o}r(mge,"useMobileNavAutoHide");function hge(e){const{matchedCompany:s,selectedCompanyId:n,companies:a}=e;return!s||s.status!=="archived"||n===s.id?null:a.find(i=>i.id===n&&i.status!=="archived")??a.find(i=>i.status!=="archived")??null}r(hge,"resolveArchivedCompanyBounce");function SJe(e){const{archivedCompanyId:s,companies:n,cloudPortfolioUrl:a}=e,i=n.find(o=>o.id!==s&&o.status!=="archived");return i?{kind:"company",company:i}:a?{kind:"cloud_portfolio",url:a}:{kind:"companies_list"}}r(SJe,"resolveCompanyArchiveDeparture");function pge(e){const{selectionSource:s,selectedCompanyId:n,routeCompanyId:a}=e;return!(n===a||s==="manual"&&n)}r(pge,"shouldSyncCompanySelectionFromRoute");function CJe(e,s){return e instanceof HTMLElement?!(s instanceof HTMLElement)||!document.contains(s)||s===document.body||s===document.documentElement?!0:!e.contains(s):!1}r(CJe,"shouldFocusMainContentAfterNavigation");function fge(e){if(!(e instanceof HTMLElement))return()=>{};const s=window.requestAnimationFrame(()=>{CJe(e,document.activeElement)&&e.focus({preventScroll:!0})});return()=>window.cancelAnimationFrame(s)}r(fge,"scheduleMainContentFocus");function xge(e=document,s=window){const n=r(()=>{e.documentElement.scrollTop!==0&&(e.documentElement.scrollTop=0),e.body.scrollTop!==0&&(e.body.scrollTop=0)},"onScroll");return s.addEventListener("scroll",n,{capture:!0}),()=>s.removeEventListener("scroll",n,{capture:!0})}r(xge,"pinDocumentScrollToZero");function xu({scope:e="global",requestedPrefix:s}){const n=na(),{setBreadcrumbs:a}=qn(),{companies:i,selectedCompany:o}=ps();(0,u.useEffect)(()=>{a([{label:"Not Found"}])},[a]);const l=o??i[0]??null,c=l?`/${l.issuePrefix}/dashboard`:"/",d=`${n.pathname}${n.search}${n.hash}`,m=s?.toUpperCase(),h=e==="invalid_company_prefix"?"Organization not found":"Page not found",p=e==="invalid_company_prefix"?`No organization matches prefix "${m??"unknown"}".`:"This route does not exist.";return(0,t.jsx)("div",{className:"mx-auto max-w-2xl py-10",children:(0,t.jsxs)(Xs,{className:"block p-6",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 p-2",children:(0,t.jsx)(Is,{className:"h-5 w-5 text-destructive"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{className:"text-xl font-semibold",children:h}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:p})]})]}),(0,t.jsxs)("div",{className:"mt-4 rounded-md border border-border bg-muted/20 px-3 py-2 text-xs text-muted-foreground",children:["Requested path: ",(0,t.jsx)("code",{className:"font-mono",children:d})]}),(0,t.jsxs)("div",{className:"mt-5 flex flex-wrap gap-2",children:[(0,t.jsx)(F,{asChild:!0,children:(0,t.jsxs)(Je,{to:c,children:[(0,t.jsx)(FR,{className:"mr-1.5 h-4 w-4"}),"Open dashboard"]})}),(0,t.jsx)(F,{variant:"outline",asChild:!0,children:(0,t.jsx)(Je,{to:"/",children:"Go home"})})]})]})})}r(xu,"NotFoundPage");function _Je(e,s){return Pme(e,s)[0]?.toLowerCase()??null}r(_Je,"getCompanyRouteSegment$1");var IJe=new Set(["browse","connections","connect","chat","vercel-connect","review","attention","gateways","advanced","app"]);function AJe({sidebarSections:e}){const{sidebarOpen:s,setSidebarOpen:n,toggleSidebar:a,collapsed:i,peeking:o,setPeeking:l,isMobile:c,setForceCollapsed:d}=Va(),{openNewIssue:m,openOnboarding:h}=$o(),{togglePanelVisible:p}=yf(),f=_c()?.pushToast??null,{companies:g,loading:v,selectedCompany:y,selectedCompanyId:w,selectionSource:S,setSelectedCompanyId:j}=ps(),{companyPrefix:N,pluginRoutePath:_,agentId:R,routineId:C}=Sa(),A=Yn(),T=na(),I=m5(),{enabled:$}=Cc(),O=Mme(T.pathname,N),L=O.builtInContextualSurface==="settings",E=O.companySegments,q=O.isTaskDetail,B=$&&q,K=E[0]?.toLowerCase()==="tools",z=E[0]?.toLowerCase()==="apps",D=z&&E[1]&&!IJe.has(E[1].toLowerCase())?E[1]:null,V=z&&E[1]?.toLowerCase()==="app"&&E[2]?E[2]:null,H=(0,u.useRef)(!1),ee=(0,u.useRef)(null),X=(0,u.useRef)(null),le=(0,u.useRef)(new pue),ce=(0,u.useRef)(T.key),te=mge(T.pathname,N,c),[ae,de]=(0,u.useState)(!1),J=(0,u.useMemo)(()=>{if(!N)return null;const ut=N.toUpperCase();return g.find(Lt=>Lt.issuePrefix.toUpperCase()===ut)??null},[g,N]),Y=!!N&&!v&&g.length>0&&!J,G=(0,u.useMemo)(()=>_?.toLowerCase()??_Je(T.pathname,N),[N,T.pathname,_]),fe=J?.id??null,se=J?.issuePrefix??null,{slots:re}=Gc({slotTypes:["page","routeSidebar"],companyId:fe,enabled:!!(fe&&G)}),ie=(0,u.useMemo)(()=>oU(re,G),[G,re]),me=(0,u.useMemo)(()=>({companyId:fe,companyPrefix:se}),[fe,se]),pe=L?(0,t.jsx)(KOe,{}):!$&&O.builtInContextualSurface==="skills"?(0,t.jsx)(DQ,{}):D?(0,t.jsx)(PQ,{kind:"connection",connectionId:D}):V?(0,t.jsx)(PQ,{kind:"application",applicationId:V}):z||K?(0,t.jsx)(JOe,{}):ie?$?(0,t.jsx)(T1,{surface:`plugin:${ie.id}`,title:ie.displayName,children:(0,t.jsx)(yu,{slot:ie,context:me,className:"min-h-0 flex-1",missingBehavior:"placeholder"})}):(0,t.jsx)(yu,{slot:ie,context:me,className:"h-full w-full",missingBehavior:"placeholder"}):null,be=O.builtInContextualSurface==="agent"&&R?(0,t.jsx)(mFe,{agentRef:R}):$&&O.builtInContextualSurface==="routine"&&C?(0,t.jsx)(gDe,{children:(0,t.jsx)(fFe,{routineId:C})}):$&&O.builtInContextualSurface==="skills"?(0,t.jsx)(DQ,{}):pe,oe=be!=null,ye=$&&oe&&(O.builtInContextualSurface==="skills"||O.builtInContextualSurface==="agent"||O.builtInContextualSurface==="routine"||z||K),Ae=$&&oe&&!ye,xe=oe&&(!$||ye),_e=!$||!oe?null:ie&&!O.builtInContextualSurface?`plugin:${ie.id}`:O.builtInContextualSurface,Ge=(0,u.useRef)(null),{data:$e}=Z({queryKey:P.health,queryFn:r(()=>sm.get(),"queryFn"),retry:!1,refetchInterval:r(ut=>ut.state.data?.devServer?.enabled?2e3:!1,"refetchInterval"),refetchIntervalInBackground:!1}),Ye=Z({queryKey:P.instance.generalSettings,queryFn:r(()=>Er.getGeneral(),"queryFn")}).data?.keyboardShortcuts===!0;(0,u.useLayoutEffect)(()=>(d(!$&&oe),()=>d(!1)),[oe,d,$]),(0,u.useEffect)(()=>{const ut=Ge.current;_e&&N&&ut&&ut.surface!==_e&&ut.pathname!==T.pathname&&qOe({surface:_e,companyPrefix:N,previousPathname:ut.pathname}),Ge.current={pathname:T.pathname,surface:_e}},[N,_e,T.pathname]),(0,u.useEffect)(()=>{v||H.current||$e?.deploymentMode!=="authenticated"&&($e?.cloud||g.length===0&&(H.current=!0,h()))},[g,v,h,$e?.cloud,$e?.deploymentMode]),(0,u.useEffect)(()=>{if(!N||v||g.length===0)return;if(!J){const Lt=(w?g.find(Xt=>Xt.id===w):null)??g[0]??null;Lt&&w!==Lt.id&&j(Lt.id,{source:"route_sync"});return}if(N!==J.issuePrefix){const Lt=T.pathname.replace(/^\/[^/]+/,"");A(`/${J.issuePrefix}${Lt}${T.search}`,{replace:!0});return}const ut=hge({matchedCompany:J,selectedCompanyId:w,companies:g});if(ut){f?.({title:`${J.name} is archived`,body:`Switched to ${ut.name}.`,tone:"info",dedupeKey:`archived-company-bounce:${J.id}`}),j(ut.id,{source:"route_sync"}),A(`/${ut.issuePrefix}/dashboard`,{replace:!0});return}pge({selectionSource:S,selectedCompanyId:w,routeCompanyId:J.id})&&j(J.id,{source:"route_sync"})},[N,g,v,J,T.pathname,T.search,A,f,S,w,j]);const ue=p,Oe=(0,u.useCallback)(()=>{document.dispatchEvent(new KeyboardEvent("keydown",{key:"k",metaKey:!0,bubbles:!0,cancelable:!0}))},[]),dt=(0,u.useRef)(null),xt=(0,u.useRef)(!1),De=(0,u.useRef)(!1),Qe=(0,u.useCallback)(()=>{dt.current!==null&&(window.clearTimeout(dt.current),dt.current=null)},[]),ht=(0,u.useCallback)(()=>{Qe(),dt.current=window.setTimeout(()=>l(!0),50)},[Qe,l]),We=(0,u.useCallback)(()=>{Qe(),l(!0)},[Qe,l]),Ke=(0,u.useCallback)(()=>{Qe(),dt.current=window.setTimeout(()=>l(!1),120)},[Qe,l]),gt=(0,u.useCallback)(()=>{xt.current=!0,i&&!De.current&&ht()},[i,ht]),tt=(0,u.useCallback)(()=>{xt.current=!1,De.current=!1,Ke()},[Ke]),Se=(0,u.useCallback)(()=>{De.current||We()},[We]),ke=(0,u.useCallback)(()=>{xt.current||Ke()},[Ke]);(0,u.useEffect)(()=>Qe,[Qe]);const Xe=(0,u.useRef)(i);return(0,u.useEffect)(()=>{i!==Xe.current&&(i?(Qe(),l(!1),De.current=xt.current):De.current=!1,Xe.current=i)},[i,Qe,l]),(0,u.useEffect)(()=>{if(!o)return;const ut=r(Lt=>{Lt.key==="Escape"&&(Qe(),l(!1))},"onKeyDown");return window.addEventListener("keydown",ut),()=>window.removeEventListener("keydown",ut)},[o,Qe,l]),uge(),oge({enabled:Ye,onNewIssue:r(()=>m(),"onNewIssue"),onSearch:Oe,onToggleSidebar:a,onTogglePanel:ue,onShowShortcuts:r(()=>de(!0),"onShowShortcuts"),onGoToInbox:r(()=>A("/inbox"),"onGoToInbox")}),(0,u.useEffect)(()=>{if(!c)return;const ut=30,Lt=50,Xt=75;let fs=0,Ve=0;const He=r(ze=>{const is=ze.touches[0];fs=is.clientX,Ve=is.clientY},"onTouchStart"),ct=r(ze=>{const is=ze.changedTouches[0],Fe=is.clientX-fs;if(!(Math.abs(is.clientY-Ve)>Xt)){if(!s&&fs<ut&&Fe>Lt){n(!0);return}s&&Fe<-50&&n(!1)}},"onTouchEnd");return document.addEventListener("touchstart",He,{passive:!0}),document.addEventListener("touchend",ct,{passive:!0}),()=>{document.removeEventListener("touchstart",He),document.removeEventListener("touchend",ct)}},[c,s,n]),(0,u.useEffect)(()=>{const ut=document.body.style.overflow;return document.body.style.overflow=c?"visible":"clip",()=>{document.body.style.overflow=ut}},[c]),(0,u.useEffect)(()=>{if(!c)return xge()},[c]),(0,u.useEffect)(()=>{if(typeof document>"u")return;const ut=X.current;return fge(ut)},[T.pathname]),(0,u.useEffect)(()=>{const ut=X.current;if(!ut)return;const Lt=r(()=>{le.current.remember(ce.current,ut.scrollTop)},"recordScroll");return ut.addEventListener("scroll",Lt,{passive:!0}),()=>ut.removeEventListener("scroll",Lt)},[]),(0,u.useLayoutEffect)(()=>{const ut=X.current,Lt=hue({previousPathname:ee.current,pathname:T.pathname,navigationType:I,state:T.state});ee.current=T.pathname;const Xt=I==="POP",fs=Xt?le.current.recall(T.key):0;if(ce.current=T.key,Xt){nT(ut,fs);const Ve=requestAnimationFrame(()=>nT(ut,fs));return()=>cancelAnimationFrame(Ve)}Lt&&fue(ut)},[T.key,T.pathname,T.state,I]),(0,t.jsx)(mue,{children:(0,t.jsx)(vce,{value:{keyboardShortcutsEnabled:Ye},children:(0,t.jsxs)("div",{className:U("bg-background text-foreground pt-(--sz-safe-top)",c?"min-h-dvh overflow-x-clip":"flex h-dvh flex-col overflow-clip"),children:[(0,t.jsx)("a",{href:"#main-content",className:"sr-only focus:not-sr-only focus:fixed focus:left-3 focus:top-3 focus:z-(--z-200) focus:rounded-md focus:bg-background focus:px-3 focus:py-2 focus:text-sm focus:font-medium focus:shadow-lg focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:"Skip to Main Content"}),(0,t.jsx)(tge,{}),(0,t.jsx)(sge,{devServer:$e?.devServer}),(0,t.jsxs)("div",{className:U("min-h-0 flex-1",c?"w-full":"flex overflow-clip"),children:[c&&s&&(0,t.jsx)("button",{type:"button",className:"fixed inset-0 z-40 bg-black/50",onClick:r(()=>n(!1),"onClick"),"aria-label":"Close sidebar"}),c?(0,t.jsxs)("div",{className:U("fixed inset-y-0 left-0 z-50 flex flex-col overflow-hidden pt-(--sz-safe-top) transition-transform duration-100 ease-out",s?"translate-x-0":"-translate-x-full"),children:[(0,t.jsx)("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:(0,t.jsx)("div",{className:"w-60 shrink-0 overflow-hidden",children:oe?(0,t.jsx)(CI,{children:be}):(0,t.jsx)(AQ,{children:e})})}),(0,t.jsx)(WJ,{deploymentMode:$e?.deploymentMode,forceExpanded:Ae})]}):(0,t.jsxs)(iJe,{open:s,collapsed:Ae?!1:i,peeking:Ae?!1:o,resizable:!0,onPanelMouseEnter:Ae?void 0:gt,onPanelMouseLeave:Ae?void 0:tt,onPanelFocusCapture:!Ae&&i?Se:void 0,onPanelBlurCapture:!Ae&&i?ke:void 0,children:[(0,t.jsx)("div",{className:"flex flex-1 min-h-0",children:Ae?(0,t.jsx)(CI,{children:be}):(0,t.jsx)(AQ,{children:e})}),(0,t.jsx)(WJ,{deploymentMode:$e?.deploymentMode,forceExpanded:Ae})]}),!c&&xe&&!ye?(0,t.jsx)(CI,{className:"w-60 shrink-0",children:be}):null,(0,t.jsxs)("div",{className:U("flex min-w-0 flex-col",c?"w-full":"h-full flex-1"),children:[(0,t.jsxs)("div",{className:U(!c&&B&&"hidden",c&&"sticky top-0 z-20 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/85"),children:[(0,t.jsx)(ZF,{mobile:c}),(0,t.jsx)($Q,{}),c&&L?(0,t.jsx)("div",{className:"border-b border-border px-4 pb-3",children:(0,t.jsx)($me,{})}):null]}),(0,t.jsxs)("div",{className:U(c?"block":"flex flex-1 min-h-0",!c&&B&&"streamlined-task-detail-surface"),children:[!c&&ye?(0,t.jsx)(CI,{className:"w-60 shrink-0 bg-background",children:be}):null,(0,t.jsxs)("div",{className:U(!c&&B?"flex min-w-0 flex-1 flex-col":"contents"),children:[!c&&B?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ZF,{mobile:!1}),(0,t.jsx)($Q,{taskDetailLayout:!0})]}):null,(0,t.jsx)("main",{id:"main-content",ref:X,tabIndex:-1,style:c?{"--tc-composer-bottom":"var(--sz-calc-14)"}:void 0,className:U("flex-1 p-4 outline-none md:p-6",!c&&B&&"pt-0 md:pt-0",c?"overflow-visible pb-(--sz-calc-14)":"overflow-auto [scrollbar-gutter:stable]"),children:Y?(0,t.jsx)(xu,{scope:"invalid_company_prefix",requestedPrefix:N??y?.issuePrefix}):(0,t.jsx)(age,{children:(0,t.jsx)(i0,{})})})]}),(0,t.jsx)(Gme,{taskDetailLayout:!c&&B})]})]})]}),c&&(0,t.jsx)(ege,{visible:te}),(0,t.jsx)(Xme,{}),(0,t.jsx)(uhe,{}),(0,t.jsx)(Wxe,{}),(0,t.jsx)(Gxe,{}),(0,t.jsx)(Yxe,{}),(0,t.jsx)(Jxe,{open:ae,onOpenChange:de}),(0,t.jsx)(Xxe,{}),(0,t.jsx)(DYe,{health:$e}),(0,t.jsx)(Zxe,{localTrusted:$e?.deploymentMode==="local_trusted"})]})})})}r(AJe,"Layout$1");var gge=(0,u.createContext)(!1);function RJe({children:e}){return(0,t.jsx)(gge.Provider,{value:!0,children:e})}r(RJe,"SidebarNavExpandedProvider");function TJe(){return(0,u.useContext)(gge)}r(TJe,"useSidebarNavExpanded");function Qa({to:e,label:s,icon:n,iconNode:a,end:i,className:o,labelClassName:l,badge:c,badgeTone:d="default",badgeLabel:m,textBadge:h,textBadgeTone:p="default",alert:f=!1,liveCount:g,active:v,trailing:y,trailingLabel:w,liveAccessory:S}){const{isMobile:j,setSidebarOpen:N,collapsed:_,peeking:R}=Va(),C=TJe(),A=_&&!R&&!C,T=c!=null&&c>0,I=g!=null&&g>0,$=I?`${g} live`:T?`${c}${m?` ${m}`:""}`:f?"attention needed":void 0,O=!A||!$&&!w?void 0:`${s}${$?`, ${$}`:""}${w?`, ${w}`:""}`,L=(0,t.jsxs)(o0,{to:e,state:gf,end:i,"aria-label":O,onClick:r(()=>{j&&N(!1)},"onClick"),className:r(({isActive:E})=>U("flex items-center gap-2.5 mx-2 rounded-lg px-2 py-1.5 pointer-coarse:py-1 text-(length:--text-compact) font-medium transition-colors",v??E?"bg-accent text-foreground":"text-foreground/80 hover:bg-accent/50 hover:text-foreground",o),"className"),children:[(0,t.jsxs)("span",{className:"relative shrink-0",children:[a??(n?(0,t.jsx)(n,{className:"h-4 w-4"}):null),f&&(0,t.jsx)("span",{className:"absolute -right-0.5 -top-0.5 h-2 w-2 rounded-full bg-red-500 shadow-(--shadow-extract-12)","aria-hidden":"true"}),A&&!f&&I&&(0,t.jsxs)("span",{className:"absolute -right-0.5 -top-0.5 flex h-2 w-2","aria-hidden":"true",children:[(0,t.jsx)("span",{className:"animate-pulse absolute inline-flex h-full w-full rounded-full bg-blue-600 dark:bg-blue-400 opacity-75"}),(0,t.jsx)("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-blue-600 dark:bg-blue-400 shadow-(--shadow-extract-12)"})]}),A&&!f&&!I&&T&&(0,t.jsx)("span",{className:U("absolute -right-0.5 -top-0.5 h-2 w-2 rounded-full shadow-(--shadow-extract-12)",d==="danger"?"bg-red-600":d==="warning"?"bg-amber-500":"bg-primary"),"aria-hidden":"true"})]}),(0,t.jsx)("span",{className:A?Nv:U("min-w-0 flex-1 truncate",l),children:s}),!A&&y,!A&&h&&(0,t.jsx)(lt,{variant:"ghost",className:U("ml-auto px-1.5 text-(length:--text-nano) leading-none",p==="amber"?"bg-amber-100 text-amber-800 dark:bg-amber-900/30 dark:text-amber-400":"bg-muted text-muted-foreground"),children:h}),!A&&(I||S)&&(0,t.jsxs)("span",{className:"ml-auto flex items-center gap-1.5",children:[S,I&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("span",{className:"relative flex h-2 w-2",children:[(0,t.jsx)("span",{className:"animate-pulse absolute inline-flex h-full w-full rounded-full bg-blue-600 dark:bg-blue-400 opacity-75"}),(0,t.jsx)("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-blue-600 dark:bg-blue-400"})]}),(0,t.jsxs)("span",{className:"text-(length:--text-micro) font-medium text-blue-600 dark:text-blue-400",children:[g," live"]})]})]}),!A&&T&&(0,t.jsx)(lt,{variant:"ghost",className:U("ml-auto px-1.5 leading-none",d==="danger"?"bg-red-600/90 text-red-50":d==="warning"?"bg-amber-500/90 text-amber-50":"bg-primary text-primary-foreground"),children:c})]});return A?(0,t.jsxs)(Wn,{children:[(0,t.jsx)(Hn,{asChild:!0,children:(0,t.jsx)("div",{children:L})}),(0,t.jsx)(Qn,{side:"right",children:s})]}):L}r(Qa,"SidebarNavItem");var EJe=3,HJ=12e4,PJe=[{value:"top",label:"Top"},{value:"alphabetical",label:"Alphabetical"},{value:"recent",label:"Recent"}];function Sy(e,s){const n=e[s];if(!n)return 0;const a=new Date(n).getTime();return Number.isFinite(a)?a:0}r(Sy,"agentTimestamp");function QJ(e,s){if(s==="top")return e;const n=[...e];return s==="alphabetical"?(n.sort((a,i)=>a.name.localeCompare(i.name,void 0,{sensitivity:"base"})),n):(n.sort((a,i)=>{const o=Sy(i,"lastHeartbeatAt")-Sy(a,"lastHeartbeatAt");if(o!==0)return o;const l=Sy(i,"updatedAt")-Sy(a,"updatedAt");if(l!==0)return l;const c=Sy(i,"createdAt")-Sy(a,"createdAt");return c!==0?c:a.name.localeCompare(i.name,void 0,{sensitivity:"base"})}),n)}r(QJ,"sortAgents");var MJe="opacity-0 transition-opacity group-hover/agent:opacity-100 group-focus-within/agent:opacity-100";function DJe({activeAgentId:e,activeTab:s,agent:n,disabled:a,isMobile:i,leaving:o,onLeaveAgent:l,onPauseResume:c,rail:d,runCount:m,setSidebarOpen:h,builtInStatus:p,starred:f=!1,onToggleStar:g,starPending:v=!1}){const y=Nc(n),w=s?`${Gu(n)}/${s}`:Gu(n),S=`${Gu(n)}/configuration`,j=e===y,N=n.status==="paused",_=N&&n.pauseReason==="budget",R=n.orgChainHealth?.status==="invalid_org_chain",C=N?"Resume agent":"Pause agent",A=a||n.status==="pending_approval"||_||N&&R,T=a?"Updating...":_?"Budget paused":N&&R?"Invalid org chain":C,I=p==="needs_setup"||p==="pending_approval",$=[I?`Built-in agent ${p.replace(/_/g," ")}`:null,R?"Invalid reporting chain":null].filter(Boolean).join(", ")||void 0,O=(0,t.jsx)(Qa,{to:w,label:n.name,iconNode:(0,t.jsx)(gr,{agent:n,size:16,className:"shrink-0 h-4 w-4"}),active:j,liveCount:m,labelClassName:I?"min-w-(--sz-4_5rem) flex-initial":void 0,className:U("min-w-0 flex-1",f&&!i?"pr-14":"pr-8"),trailing:I||R?(0,t.jsxs)("span",{className:"ml-1 flex shrink-0 items-center gap-1",children:[I?(0,t.jsx)(Ej,{status:p,compact:!0}):null,R?(0,t.jsx)(Is,{className:"h-3.5 w-3.5 shrink-0 text-amber-500","aria-label":"Invalid reporting chain"}):null]}):void 0,trailingLabel:$,liveAccessory:n.pauseReason==="budget"?(0,t.jsx)(I1,{title:"Agent paused by budget"}):void 0});return d?O:(0,t.jsxs)("div",{className:"group/agent relative flex items-center",children:[O,f&&!i&&g?(0,t.jsx)("span",{className:"absolute right-10 top-1/2 -translate-y-1/2",children:(0,t.jsx)(d0,{size:"row",quiet:!0,starred:!0,pending:v,resourceName:n.name,onToggle:r(()=>g(n,!1),"onToggle"),revealClassName:MJe})}):null,(0,t.jsxs)(ba,{children:[(0,t.jsx)(ga,{asChild:!0,children:(0,t.jsx)(F,{variant:"ghost",size:"icon-xs",className:U("absolute right-3 top-1/2 h-6 w-6 -translate-y-1/2 transition-opacity data-[state=open]:pointer-events-auto data-[state=open]:opacity-100",i?"opacity-100":"pointer-events-none opacity-0 group-hover/agent:pointer-events-auto group-hover/agent:opacity-100 group-focus-within/agent:pointer-events-auto group-focus-within/agent:opacity-100"),"aria-label":`Open actions for ${n.name}`,children:(0,t.jsx)(Ti,{className:"h-3.5 w-3.5"})})}),(0,t.jsxs)(va,{align:"end",className:"w-48",children:[g?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(hs,{onClick:r(()=>{v||g(n,!f)},"onClick"),disabled:v,children:[v?(0,t.jsx)(at,{className:"size-4 motion-safe:animate-spin"}):(0,t.jsx)(Th,{className:U("size-4",f&&"fill-amber-500 text-amber-500")}),(0,t.jsx)("span",{children:f?"Remove from starred":"Star agent"})]}),(0,t.jsx)(di,{})]}):null,(0,t.jsx)(hs,{asChild:!0,children:(0,t.jsxs)(Je,{to:S,onClick:r(()=>{i&&h(!1)},"onClick"),children:[(0,t.jsx)(Kl,{className:"size-4"}),(0,t.jsx)("span",{children:"Edit agent"})]})}),(0,t.jsx)(di,{}),(0,t.jsxs)(hs,{onClick:r(()=>{A||c(n,N?"resume":"pause")},"onClick"),disabled:A,title:_?"Agent was paused by budget limits":void 0,children:[N?(0,t.jsx)(w1,{className:"size-4"}):(0,t.jsx)(md,{className:"size-4"}),(0,t.jsx)("span",{children:T})]}),(0,t.jsx)(di,{}),(0,t.jsxs)(hs,{onClick:r(()=>{o||l(n)},"onClick"),disabled:o,children:[o?(0,t.jsx)(at,{className:"size-4 motion-safe:animate-spin"}):(0,t.jsx)(Yh,{className:"size-4"}),(0,t.jsx)("span",{children:o?"Leaving...":"Leave agent"})]})]})]})]})}r(DJe,"SidebarAgentItem");function LJe({streamlined:e=!1}={}){const[s,n]=(0,u.useState)(!0),[a,i]=(0,u.useState)(()=>new Set),[o,l]=(0,u.useState)(0),c=(0,u.useRef)(new Map),d=Wt(),{selectedCompanyId:m}=ps(),{openNewAgent:h}=$o(),{isMobile:p,setSidebarOpen:f,collapsed:g,peeking:v}=Va(),y=g&&!v,{pushToast:w}=pa(),S=na(),{data:j}=Z({queryKey:P.agents.list(m),queryFn:r(()=>Vt.list(m),"queryFn"),enabled:!!m}),{data:N}=Z({queryKey:P.instance.experimentalSettings,queryFn:r(()=>Er.getExperimental(),"queryFn"),enabled:!!m}),_=N?.enableBuiltInAgents===!0,{data:R}=Z({queryKey:P.builtInAgents.list(m),queryFn:r(()=>xh.list(m),"queryFn"),enabled:!!m&&_}),C=(0,u.useMemo)(()=>{const xe=new Map;if(!_)return xe;for(const _e of R??[])_e.agentId&&xe.set(_e.agentId,_e.status);return xe},[R,_]),{data:A}=Z({queryKey:P.auth.session,queryFn:r(()=>qa.getSession(),"queryFn")}),T=bf(m),I=vf(m),$=P.liveRuns(m),O=mo({companyId:m,resourceKey:"live-runs",queryKey:$,enabled:!!m,refetchInterval:!1,leaderOnly:!0}),{data:L,dataUpdatedAt:E}=Z({queryKey:$,queryFn:r(()=>sa.liveRunsForCompany(m),"queryFn"),enabled:O.enabled,refetchInterval:O.refetchInterval});ho(O,L,E);const q=(0,u.useMemo)(()=>{const xe=new Map;for(const _e of L??[])xe.set(_e.agentId,(xe.get(_e.agentId)??0)+1);return xe},[L]),B=(0,u.useMemo)(()=>{const xe=new Set;for(const[_e,Ge]of q)Ge>0&&xe.add(_e);return xe},[q]),K=(0,u.useMemo)(()=>(j??[]).filter(xe=>xe.status!=="terminated"&&(!T.isSuccess||Sx(T.data,"agent",xe.id)!=="left")),[j,T.data,T.isSuccess]),z=A?.user?.id??A?.session?.userId??null,D=(0,u.useMemo)(()=>m?kue(m,z):null,[z,m]),[V,H]=(0,u.useState)(()=>D?Pj(D):"top"),{orderedAgents:ee}=_ue({agents:K,companyId:m,userId:z}),X=(0,u.useMemo)(()=>QJ(ee,V),[ee,V]),le=(0,u.useMemo)(()=>new Set(X.map(xe=>xe.id)),[X]);(0,u.useEffect)(()=>{const xe=Date.now();for(const _e of B)c.current.set(_e,xe);for(const _e of c.current.keys())le.has(_e)||c.current.delete(_e)},[B,le]);const ce=(0,u.useMemo)(()=>{const xe=Date.now(),_e=c.current;return X.filter(Ge=>{if((q.get(Ge.id)??0)>0)return!0;const $e=_e.get(Ge.id);return $e!==void 0&&xe-$e<=HJ})},[q,o,X]),te=ce.length>0,ae=e?te?ce:X.slice(0,EJe):X,de=e&&X.length>0,J=S.pathname.match(/^\/(?:[^/]+\/)?agents\/([^/]+)(?:\/([^/]+))?/),Y=J?.[1]??null,G=J?.[2]??null;(0,u.useEffect)(()=>{if(!D){H("top");return}H(Pj(D))},[D]),(0,u.useEffect)(()=>{if(!D)return;const xe=r(Ge=>{Ge.key===D&&H(Pj(D))},"onStorage"),_e=r(Ge=>{const $e=Ge.detail;!$e||$e.storageKey!==D||H($e.sortMode)},"onCustomEvent");return window.addEventListener("storage",xe),window.addEventListener(sC,_e),()=>{window.removeEventListener("storage",xe),window.removeEventListener(sC,_e)}},[D]),(0,u.useEffect)(()=>{if(!e)return;const xe=Date.now();let _e=null;for(const $e of X){if((q.get($e.id)??0)>0)continue;const Ye=c.current.get($e.id);if(Ye===void 0)continue;const ue=Ye+HJ;ue<xe||(_e=_e===null?ue:Math.min(_e,ue))}if(_e===null)return;const Ge=window.setTimeout(()=>{l($e=>$e+1)},Math.max(0,_e-xe+1));return()=>{window.clearTimeout(Ge)}},[e,X,q,o]);const fe=(0,u.useCallback)(xe=>{const _e=xe==="alphabetical"||xe==="recent"?xe:"top";H(_e),D&&Cue(D,_e)},[D]),se=Ne({mutationFn:r(({agent:xe,action:_e})=>_e==="pause"?Vt.pause(xe.id,m??void 0):Vt.resume(xe.id,m??void 0),"mutationFn"),onMutate:r(({agent:xe})=>{i(_e=>{const Ge=new Set(_e);return Ge.add(xe.id),Ge})},"onMutate"),onSuccess:r(async(xe,{agent:_e,action:Ge})=>{m&&await Promise.all([d.invalidateQueries({queryKey:P.agents.list(m)}),d.invalidateQueries({queryKey:P.liveRuns(m)}),d.invalidateQueries({queryKey:P.dashboard(m)})]),await Promise.all([d.invalidateQueries({queryKey:P.agents.detail(_e.id)}),d.invalidateQueries({queryKey:P.agents.detail(Nc(_e))})]),w({title:Ge==="pause"?"Agent paused":"Agent resumed",body:_e.name,tone:"success"})},"onSuccess"),onError:r((xe,{agent:_e,action:Ge})=>{w({title:Ge==="pause"?"Could not pause agent":"Could not resume agent",body:xe instanceof Error?xe.message:_e.name,tone:"error"})},"onError"),onSettled:r((xe,_e,{agent:Ge})=>{i($e=>{const Ye=new Set($e);return Ye.delete(Ge.id),Ye})},"onSettled")}),re=(0,u.useCallback)(xe=>I.mutate({resourceType:"agent",resourceId:xe.id,resourceName:xe.name,state:"left"}),[I]),ie=(0,u.useCallback)(xe=>I.isPending&&I.variables?.resourceType==="agent"&&I.variables.resourceId===xe.id,[I.isPending,I.variables]),me=(0,u.useCallback)((xe,_e)=>I.mutate({resourceType:"agent",resourceId:xe.id,resourceName:xe.name,starred:_e}),[I]),pe=(0,u.useCallback)(xe=>I.isPending&&I.variables?.resourceType==="agent"&&I.variables.resourceId===xe.id&&I.variables.starred!==void 0,[I.isPending,I.variables]),be=(0,u.useMemo)(()=>new Set($5(T.data,"agent")),[T.data]),oe=(0,u.useMemo)(()=>QJ(K.filter(xe=>be.has(xe.id)),"alphabetical"),[K,be]),ye=(0,u.useMemo)(()=>ae.filter(xe=>!be.has(xe.id)),[ae,be]),Ae=r((xe,_e)=>(0,t.jsx)(DJe,{activeAgentId:Y,activeTab:G,agent:xe,disabled:a.has(xe.id),isMobile:p,leaving:ie(xe),onLeaveAgent:re,onPauseResume:r((Ge,$e)=>se.mutate({agent:Ge,action:$e}),"onPauseResume"),rail:y,runCount:q.get(xe.id)??0,setSidebarOpen:f,builtInStatus:C.get(xe.id),starred:_e||c0(T.data,"agent",xe.id),onToggleStar:me,starPending:pe(xe)},xe.id),"renderAgentRow");return(0,t.jsxs)(xx,{label:"Agents",collapsible:{open:s,onOpenChange:n},headerAction:{ariaLabel:"New agent",icon:gn,onClick:h},menu:{ariaLabel:"Agents section actions",actions:[{type:"item",label:"Browse agents",icon:tl,href:"/agents/all"},{type:"separator"}],radioLabel:"Agent sort",radioChoices:PJe,radioValue:V,onRadioValueChange:fe},children:[oe.map(xe=>Ae(xe,!0)),ye.map(xe=>Ae(xe,!1)),de&&(()=>{const xe=(0,t.jsxs)(Je,{to:"/agents/all",state:gf,"aria-label":y?"See all agents":void 0,onClick:r(()=>{p&&f(!1)},"onClick"),className:"flex items-center gap-2.5 mx-2 rounded-lg px-2 py-1.5 pointer-coarse:py-1 text-(length:--text-compact) font-medium text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",children:[(0,t.jsx)(tl,{className:"shrink-0 h-4 w-4"}),(0,t.jsx)("span",{className:y?"block w-0 min-w-0 overflow-hidden whitespace-nowrap text-transparent select-none":void 0,children:"See all agents"})]});return y?(0,t.jsxs)(Wn,{children:[(0,t.jsx)(Hn,{asChild:!0,children:xe}),(0,t.jsx)(Qn,{side:"right",children:"See all agents"})]}):xe})()]})}r(LJe,"SidebarAgents");var $Je="opacity-0 transition-opacity group-hover/starred-project:opacity-100 group-focus-within/starred-project:opacity-100";function OJe(){const{selectedCompanyId:e}=ps(),{isMobile:s,setSidebarOpen:n,collapsed:a,peeking:i}=Va(),o=a&&!i,l=na(),{data:c}=Z({queryKey:P.projects.list(e),queryFn:r(()=>ma.list(e),"queryFn"),enabled:!!e}),d=bf(e),m=vf(e),h=l.pathname.match(/^\/(?:[^/]+\/)?projects\/([^/]+)/)?.[1]??null,p=(0,u.useMemo)(()=>{if(!d.isSuccess)return[];const y=new Set($5(d.data,"project"));if(y.size===0)return[];const w=new Map((c??[]).map(S=>[S.id,S]));return Array.from(y).map(S=>w.get(S)).filter(S=>!!S).sort((S,j)=>S.name.localeCompare(j.name,void 0,{sensitivity:"base"}))},[d.data,d.isSuccess,c]),f=(0,u.useCallback)(y=>m.mutate({resourceType:"project",resourceId:y.id,resourceName:y.name,starred:!1}),[m]),g=(0,u.useCallback)(y=>m.mutate({resourceType:"project",resourceId:y.id,resourceName:y.name,state:"left"}),[m]),v=(0,u.useCallback)(y=>m.isPending&&m.variables?.resourceType==="project"&&m.variables.resourceId===y.id,[m.isPending,m.variables]);return!d.isSuccess||p.length===0?null:(0,t.jsx)("div",{className:"flex flex-col gap-0.5","aria-label":"Starred projects",children:p.map(y=>{const w=a0(y),S=h===w||h===y.id,j=v(y),N=j&&m.variables?.starred===!1,_=j&&m.variables?.state==="left",R=c0(d.data,"project",y.id),C=(0,t.jsxs)(o0,{to:`/projects/${w}/issues`,state:gf,onClick:r(()=>{s&&n(!1)},"onClick"),className:U("flex min-w-0 flex-1 items-center gap-2.5 mx-2 rounded-lg px-2 py-1.5 pointer-coarse:py-1 pr-8 text-(length:--text-compact) font-medium transition-colors",!o&&"pl-6",S?"bg-accent text-foreground":"text-foreground/80 hover:bg-accent/50 hover:text-foreground"),children:[(0,t.jsx)(Qm,{color:y.color??null,icon:y.icon??null,size:"xs"}),(0,t.jsx)("span",{className:o?Nv:"flex-1 truncate",children:y.name}),!o&&y.pauseReason==="budget"?(0,t.jsx)(I1,{title:"Project paused by budget"}):null]});return(0,t.jsxs)("div",{className:"group/starred-project relative flex items-center",children:[o?(0,t.jsxs)(Wn,{children:[(0,t.jsx)(Hn,{asChild:!0,children:(0,t.jsx)("div",{className:"min-w-0 flex-1",children:C})}),(0,t.jsx)(Qn,{side:"right",children:y.name})]}):C,!o&&!s?(0,t.jsx)("span",{className:"absolute right-3 top-1/2 -translate-y-1/2",children:(0,t.jsx)(d0,{size:"row",quiet:!0,starred:R,pending:N,resourceName:y.name,onToggle:r(()=>f(y),"onToggle"),revealClassName:$Je})}):null,!o&&s?(0,t.jsxs)(ba,{children:[(0,t.jsx)(ga,{asChild:!0,children:(0,t.jsx)(F,{variant:"ghost",size:"icon-xs",className:"absolute right-3 top-1/2 h-6 w-6 -translate-y-1/2 opacity-100","aria-label":`Open actions for ${y.name}`,children:(0,t.jsx)(Ti,{className:"h-3.5 w-3.5"})})}),(0,t.jsxs)(va,{align:"end",className:"w-48",children:[(0,t.jsxs)(hs,{onClick:r(()=>{j||f(y)},"onClick"),disabled:j,children:[N?(0,t.jsx)(at,{className:"size-4 motion-safe:animate-spin"}):(0,t.jsx)(Th,{className:"size-4 fill-amber-500 text-amber-500"}),(0,t.jsx)("span",{children:"Remove from starred"})]}),(0,t.jsx)(di,{}),(0,t.jsxs)(hs,{onClick:r(()=>{j||g(y)},"onClick"),disabled:j,children:[_?(0,t.jsx)(at,{className:"size-4 motion-safe:animate-spin"}):(0,t.jsx)(Yh,{className:"size-4"}),(0,t.jsx)("span",{children:"Leave project"})]})]})]}):null]},y.id)})})}r(OJe,"SidebarStarredProjects");var bge="size-5 shrink-0 rounded-md text-(length:--text-micro)",vge="size-(--organization-popover-avatar-size) shrink-0 rounded-lg text-(length:--text-micro)",yge="h-(--organization-popover-company-row-height) min-w-0 gap-(--organization-popover-row-gap) rounded-lg px-2.5 py-0 text-(length:--text-compact) focus:bg-accent/50 focus:text-foreground",sD="h-(--organization-popover-action-row-height) gap-(--organization-popover-row-gap) rounded-lg px-2.5 py-0 text-(length:--text-compact) font-medium leading-(--organization-popover-action-line-height) text-foreground focus:bg-accent/50 focus:text-foreground";function jge({company:e,inPopover:s=!1}){return(0,t.jsx)(Lx,{companyName:e.name,logoUrl:e.logoUrl,className:s?vge:bge})}r(jge,"WorkspaceIcon");function FJe({displayName:e}){return(0,t.jsx)(Lx,{companyName:e,className:vge})}r(FJe,"StackIcon");function BJe({displayName:e,company:s}){return(0,t.jsx)(Lx,{companyName:e,logoUrl:s?.logoUrl,className:bge})}r(BJe,"CurrentStackIcon");function qJe({stack:e,isSelected:s,onSelect:n}){return(0,t.jsxs)(hs,{onSelect:r(()=>n(e),"onSelect"),className:yge,children:[(0,t.jsx)(FJe,{displayName:e.displayName}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block truncate font-medium leading-(--organization-popover-name-line-height)",title:e.displayName,children:e.displayName}),(0,t.jsx)("span",{className:"block truncate text-(length:--text-nano) leading-(--organization-popover-prefix-line-height) text-muted-foreground",title:e.stackSlug,children:e.stackSlug})]}),(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center",children:s?(0,t.jsx)(ds,{className:"size-4 text-foreground"}):null})]})}r(qJe,"CloudStackItem");function zJe({company:e,isEditing:s,isSelected:n,onSelect:a}){const{attributes:i,listeners:o,setActivatorNodeRef:l,setNodeRef:c,transform:d,transition:m,isDragging:h}=Yw({id:e.id,disabled:!s});return(0,t.jsxs)(hs,{ref:c,style:{transform:Hw.Transform.toString(d),transition:m,zIndex:h?10:void 0},onSelect:r(p=>{if(s){p.preventDefault();return}a(e)},"onSelect"),className:U(yge,s&&"cursor-grab",h&&"opacity-80"),children:[(0,t.jsx)(jge,{company:e,inPopover:!0}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block truncate font-medium leading-(--organization-popover-name-line-height)",children:e.name}),s?null:(0,t.jsx)("span",{className:"block truncate text-(length:--text-nano) leading-(--organization-popover-prefix-line-height) text-muted-foreground",children:e.issuePrefix})]}),s?(0,t.jsx)("button",{type:"button",ref:l,"aria-label":`Reorder ${e.name}`,className:"inline-flex size-8 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-(length:--rad-2) focus-visible:ring-ring",onClick:r(p=>{p.preventDefault(),p.stopPropagation()},"onClick"),...i,...o,children:(0,t.jsx)($z,{className:"size-4","aria-hidden":"true"})}):(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center",children:n?(0,t.jsx)(ds,{className:"size-4 text-foreground"}):null})]})}r(zJe,"SortableCompanyItem");function UJe(e={}){return(0,t.jsx)(_me,{...e,children:(0,t.jsx)(KJe,{...e})})}r(UJe,"SidebarCompanyMenu");function KJe({open:e,onOpenChange:s}){const[n,a]=(0,u.useState)(!1),[i,o]=(0,u.useState)(!1),{companies:l,selectedCompany:c,setSelectedCompanyId:d,companyListUnavailable:m,retryCompanies:h}=ps(),{openOnboarding:p}=$o(),{isMobile:f,setSidebarOpen:g,collapsed:v,peeking:y}=Va(),w=v&&!y,S=na(),j=Yn(),N=e??n,_=s??a,R=Gw(rf(yz,{activationConstraint:{distance:8}}),rf(yce,{activationConstraint:{delay:180,tolerance:6}})),C=(0,u.useMemo)(()=>l.filter(G=>G.status!=="archived"),[l]),{data:A}=Z({queryKey:P.auth.session,queryFn:r(()=>qa.getSession(),"queryFn"),retry:!1}),T=A?.user?.id??A?.session?.userId??null,{orderedCompanies:I,persistOrder:$}=Sme({companies:C,userId:T}),O=Yc(),L=!!O,{hidden:E,loaded:q}=eh(),B=q&&!GS(E,"company.members")&&!GS(E,"company.invites"),K=O?.cloudBaseUrl??null,z=Z({queryKey:P.cloud.stacks,queryFn:r(()=>Nme.listStacks(),"queryFn"),enabled:L,staleTime:3e4,retry:!1}),D=z.data?.stacks??[],V=L?D.find(G=>G.isCurrent)??D.find(G=>!!O?.stackSlug&&G.stackSlug===O?.stackSlug)??null:null,H=L?U5(K):null,ee=L?"organization":"company",X=L?V?.displayName??O?.stackDisplayName??O?.stackSlug??null:c?.name??null,le=iN({onSignedOut:te});function ce(G){G||o(!1),_(G)}r(ce,"handleOpenChange");function te(){_(!1),o(!1),f&&g(!1)}r(te,"closeNavigationChrome");function ae(G){const fe=S.pathname.split("/")[1]?.toUpperCase(),se=C.some(ie=>ie.issuePrefix.toUpperCase()===fe),re=G.id!==c?.id&&(S.pathname.startsWith("/instance/")||se);d(G.id),_(!1),f&&g(!1),re&&j(`/${G.issuePrefix}/dashboard`)}r(ae,"selectCompany");function de(G){if(_(!1),f&&g(!1),G.stackSlug===V?.stackSlug)return;const fe=Cme(K,G.stackSlug);fe&&Sc(fe)}r(de,"selectStack");function J(){if(_(!1),f&&g(!1),L){H&&Sc(H);return}p({initialStep:1})}r(J,"addCompany");const Y=(0,u.useCallback)(G=>{const{active:fe,over:se}=G;if(!se||fe.id===se.id)return;const re=I.map(pe=>pe.id),ie=re.indexOf(fe.id),me=re.indexOf(se.id);ie===-1||me===-1||$(p5(re,ie,me))},[I,$]);return(0,t.jsxs)(ba,{open:N,onOpenChange:ce,children:[(0,t.jsx)(ga,{asChild:!0,children:(0,t.jsxs)(F,{variant:"ghost",className:"h-9 min-w-0 flex-1 justify-start gap-2 px-4 text-left hover:bg-accent/50 hover:text-foreground has-[>svg]:px-4 dark:hover:bg-accent/50","aria-label":X?`Open ${X} ${ee} switcher`:`Open ${ee} switcher`,children:[(0,t.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[L?X?(0,t.jsx)(BJe,{displayName:X,company:c}):null:c?(0,t.jsx)(jge,{company:c}):null,(0,t.jsx)("span",{className:U("min-w-0 truncate text-sm font-bold text-foreground",w&&"block w-0 min-w-0 overflow-hidden whitespace-nowrap text-transparent select-none"),title:X??void 0,children:X??(L?"Select organization":"Select company")})]}),!w&&(0,t.jsx)(k5,{className:"size-3.5 shrink-0 text-muted-foreground"})]})}),(0,t.jsxs)(va,{align:"start",sideOffset:8,className:"ml-2 w-(--organization-popover-width) max-w-(--sz-calc-24) overflow-hidden rounded-xl border-border bg-popover p-0 shadow-(--shadow-profile-popover)",children:[(0,t.jsxs)("div",{className:"flex h-(--organization-popover-header-height) items-center justify-between gap-2 px-3.5",children:[(0,t.jsx)(Xw,{className:"p-0 text-(length:--text-compact) font-semibold text-foreground",children:"Organizations"}),L?null:(0,t.jsx)("button",{type:"button",onClick:r(G=>{G.preventDefault(),G.stopPropagation(),o(fe=>!fe)},"onClick"),className:"rounded px-1.5 py-0.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:i?"Done":"Edit"})]}),(0,t.jsx)("div",{className:"flex max-h-96 flex-col gap-0.5 overflow-y-auto px-2.5 pb-2 pt-1",children:L?(0,t.jsxs)(t.Fragment,{children:[D.map(G=>(0,t.jsx)(qJe,{stack:G,isSelected:G.stackSlug===V?.stackSlug,onSelect:de},G.stackSlug)),D.length===0?(0,t.jsx)(hs,{disabled:!0,children:z.isLoading?"Loading organizations...":z.isError?"Could not load organizations":"No organizations"}):null]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Ww,{sensors:R,collisionDetection:i1,onDragEnd:Y,children:(0,t.jsx)(Vw,{items:I.map(G=>G.id),strategy:r1,children:I.map(G=>(0,t.jsx)(zJe,{company:G,isEditing:i,isSelected:G.id===c?.id,onSelect:ae},G.id))})}),I.length===0?m?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(hs,{disabled:!0,children:"Couldn't load companies"}),(0,t.jsxs)(hs,{onSelect:r(G=>{G.preventDefault(),h()},"onSelect"),children:[(0,t.jsx)(qi,{className:"h-4 w-4 mr-2"}),"Try again"]})]}):(0,t.jsx)(hs,{disabled:!0,children:"No companies"}):null]})}),(0,t.jsxs)("div",{className:"flex flex-col gap-0.5 border-t border-border px-2.5 pb-2.5 pt-2",children:[L&&!H?null:(0,t.jsxs)(hs,{onClick:J,className:sD,disabled:i,children:[(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:(0,t.jsx)(gn,{className:"size-4"})}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:"Create organization"})]}),B?(0,t.jsx)(hs,{asChild:!0,disabled:i,className:sD,children:(0,t.jsxs)(Je,{to:"/company/settings/invites",onClick:r(G=>{if(i){G.preventDefault();return}te()},"onClick"),children:[(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:(0,t.jsx)(Tv,{className:"size-4"})}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:X?`Invite people to ${X}`:"Invite people"})]})}):null,A?.session?(0,t.jsxs)(hs,{className:sD,onClick:r(()=>le.mutate(),"onClick"),disabled:i||le.isPending,children:[(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:(0,t.jsx)(Yh,{className:"size-4"})}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:le.isPending?"Signing out...":"Sign out"})]}):null]})]})]})}r(KJe,"BuiltinCompanyMenu");function GJ(){const{openNewIssue:e}=$o(),[s,n]=(0,u.useState)(!0),[a,i]=(0,u.useState)(!0),{selectedCompanyId:o,selectedCompany:l}=ps(),{collapsed:c,peeking:d}=Va(),m=c&&!d,h=fU(o),{data:p,isFetched:f}=Z({queryKey:P.instance.experimentalSettings,queryFn:r(()=>Er.getExperimental(),"queryFn")}),g=P.liveRuns(o),v=mo({companyId:o,resourceKey:"live-runs",queryKey:g,enabled:!!o,refetchInterval:!1,leaderOnly:!0}),{data:y,dataUpdatedAt:w}=Z({queryKey:g,queryFn:r(()=>sa.liveRunsForCompany(o),"queryFn"),enabled:v.enabled,refetchInterval:v.refetchInterval});ho(v,y,w);const S=y?.length??0,j=p?.enableIsolatedWorkspaces===!0,N=p?.enableApps===!0,_=p?.enablePipelines===!0,R=p?.enableStatusCards===!0,C=!f,A=p?.enableGoalsSidebarLink===!0,T=p?.enableDecisions===!0,{data:I}=Z({queryKey:P.attention(o),queryFn:r(()=>q5.list(o),"queryFn"),enabled:!!o&&T,refetchInterval:6e4}),$=eme(I),O=p?.enableCases===!0,L=!0,E=p?.enableConferenceRoomChat===!0,q={companyId:o,companyPrefix:l?.issuePrefix??null};return(0,t.jsxs)("aside",{className:"w-full h-full min-h-0 border-r border-border bg-background flex flex-col",children:[(0,t.jsx)("div",{className:"flex items-center gap-1 px-3 h-12 shrink-0",children:(0,t.jsx)(UJe,{})}),(0,t.jsxs)("nav",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-auto-hide flex flex-col gap-4 pointer-coarse:gap-3 px-3 py-2",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(()=>{const B=(0,t.jsxs)("button",{onClick:r(()=>e(),"onClick"),"data-slot":"icon-button","aria-label":m?"New Task":void 0,className:"flex items-center gap-2.5 mx-2 rounded-lg px-2 py-1.5 pointer-coarse:py-1 text-(length:--text-compact) font-medium text-foreground/80 hover:bg-accent/50 hover:text-foreground transition-colors",children:[(0,t.jsx)(S1,{className:"h-4 w-4 shrink-0"}),(0,t.jsx)("span",{className:m?Nv:"truncate",children:"New Task"})]});return m?(0,t.jsxs)(Wn,{children:[(0,t.jsx)(Hn,{asChild:!0,children:B}),(0,t.jsx)(Qn,{side:"right",children:"New Task"})]}):B})(),(0,t.jsx)(Qa,{to:"/search",label:"Search",icon:ua}),(0,t.jsx)(Qa,{to:"/dashboard",label:"Dashboard",icon:fx,liveCount:S}),(0,t.jsx)(Qa,{to:"/inbox",label:"Inbox",icon:Pd,badge:h.inbox,badgeLabel:"unread",badgeTone:h.failedRuns>0?"danger":"default",alert:h.failedRuns>0}),T?(0,t.jsx)(Qa,{to:"/decisions",label:"Decisions",icon:k1,badge:$,badgeLabel:"decisions"}):null,R?(0,t.jsx)(Qa,{to:"/status",label:"Status",icon:nN,textBadge:"beta"}):null,E?(0,t.jsx)(Qa,{to:"/board-chat",label:"Conference Room",icon:Ude}):null]}),(0,t.jsxs)(xx,{label:"Work",collapsible:{open:s,onOpenChange:n},children:[(0,t.jsx)(Qa,{to:"/issues",label:"Tasks",icon:ld}),O?(0,t.jsx)(Qa,{to:"/cases",label:"Cases",icon:pl,textBadge:"beta"}):null,(0,t.jsx)(Qa,{to:"/routines",label:"Routines",icon:fu}),_?(0,t.jsx)(Qa,{to:"/pipelines",label:"Pipelines",icon:Do}):null,A?(0,t.jsx)(Qa,{to:"/goals",label:"Goals",icon:af}):C?(0,t.jsx)("div",{"data-testid":"sidebar-goals-placeholder",className:"h-8 pointer-coarse:h-7","aria-hidden":"true"}):null,(0,t.jsx)(Qa,{to:"/artifacts",label:"Artifacts",icon:Eh}),(0,t.jsx)(Qa,{to:"/skills",label:"Skills",icon:Ul}),j?(0,t.jsx)(Qa,{to:"/workspaces",label:"Workspaces",icon:Do}):null,(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Qa,{to:"/projects",label:"Projects",icon:Co}),(0,t.jsx)(OJe,{})]}),(0,t.jsx)(zh,{slotTypes:["sidebar"],context:q,className:"flex flex-col gap-0.5",itemClassName:"text-(length:--text-compact) font-medium",missingBehavior:"placeholder"}),(0,t.jsx)(aN,{placementZones:["sidebar"],context:q,className:"flex flex-col gap-0.5",itemClassName:"text-(length:--text-compact) font-medium"})]}),null,(0,t.jsx)(LJe,{streamlined:L}),(0,t.jsxs)(xx,{label:"Company",collapsible:{open:a,onOpenChange:i},children:[(0,t.jsx)(Qa,{to:"/org",label:"Org",icon:Gb}),N?(0,t.jsx)(Qa,{to:"/apps",label:"Connectors",icon:tT}):null,(0,t.jsx)(Qa,{to:"/timeline",label:"Timeline",icon:jg}),(0,t.jsx)(Qa,{to:"/costs",label:"Costs",icon:_h}),(0,t.jsx)(Qa,{to:"/activity",label:"Activity",icon:Cl}),(0,t.jsx)(Qa,{to:"/company/settings",label:"Settings",icon:$d})]}),(0,t.jsx)(zh,{slotTypes:["sidebarPanel"],context:q,className:"flex flex-col gap-3",itemClassName:"rounded-lg border border-border p-3",missingBehavior:"placeholder"})]})]})}r(GJ,"Sidebar");function VJe(e){const s=e.manifestJson.environmentDrivers??[];return s.length===0?!1:s.every(n=>n.kind==="sandbox_provider")}r(VJe,"isSandboxProviderOnly");function WJe(){const{selectedCompany:e,selectedCompanyId:s}=ps(),{isMobile:n,setSidebarOpen:a}=Va(),{hidden:i}=eh(),o=r(f=>!i.has(f),"showPage"),l=o("instance.plugins"),c=!!Yc(),{slots:d}=Gc({slotTypes:["companySettingsPage"],companyId:s,enabled:!!s}),{data:m}=Z({queryKey:s?P.sidebarBadges(s):["sidebar-badges","__disabled__"],queryFn:r(async()=>{try{return await Eme.get(s)}catch(f){if(f instanceof wn&&(f.status===401||f.status===403))return null;throw f}},"queryFn"),enabled:!!s,retry:!1,refetchInterval:15e3}),{data:h}=Z({queryKey:P.plugins.all,queryFn:r(()=>el.list(),"queryFn"),enabled:l}),p=(h??[]).filter(f=>!VJe(f));return(0,t.jsxs)("aside",{className:"w-full h-full min-h-0 border-r border-border bg-background flex flex-col",children:[(0,t.jsx)("div",{className:"flex flex-col gap-1 px-3 py-3 shrink-0",children:(0,t.jsxs)(Je,{to:"/dashboard",onClick:r(()=>{n&&a(!1)},"onClick"),className:"flex items-center gap-1.5 rounded-md px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",children:[(0,t.jsx)(bu,{className:"h-3.5 w-3.5 shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:e?.name??"Company"})]})}),(0,t.jsx)("nav",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-auto-hide px-3 py-2",children:(0,t.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,t.jsx)(Qa,{to:"/company/settings",label:"General",icon:nm,end:!0}),o("instance.profile")&&(0,t.jsx)(Qa,{to:"/company/settings/instance/profile",label:"Profile",icon:C1,end:!0}),o("company.members")&&(0,t.jsx)(Qa,{to:"/company/settings/members",label:"Members",icon:tl,badge:m?.joinRequests??0,end:!0}),d.filter(f=>f.routePath).map(f=>(0,t.jsx)(Qa,{to:`/company/settings/${f.routePath}`,label:f.displayName,icon:Dg,end:!0},`${f.pluginKey}:${f.id}`)),o("company.invites")&&(0,t.jsx)(Qa,{to:"/company/settings/invites",label:"Invites",icon:Q5e,end:!0}),o("company.secrets")&&(0,t.jsx)(Qa,{to:"/company/settings/secrets",label:"Secrets",icon:bi,end:!0}),o("instance.environments")&&(0,t.jsx)(Qa,{to:"/company/settings/instance/environments",label:"Environments",icon:Kde,end:!0}),o("instance.access")&&(0,t.jsx)(Qa,{to:"/company/settings/instance/access",label:"Access",icon:v5,end:!0}),o("instance.heartbeats")&&(0,t.jsx)(Qa,{to:"/company/settings/instance/heartbeats",label:"Heartbeats",icon:sh,end:!0}),o("company.export")&&(0,t.jsx)(Qa,{to:"/company/export",label:"Export",icon:Uo}),!c&&o("company.import")&&(0,t.jsx)(Qa,{to:"/company/import",label:"Import",icon:cw,end:!0}),o("instance.experimental")&&(0,t.jsx)(Qa,{to:"/company/settings/instance/experimental",label:"Experimental",icon:em}),l&&(0,t.jsx)(Qa,{to:"/company/settings/instance/plugins",label:"Plugins",icon:Dg}),l&&p.length>0?(0,t.jsx)("div",{className:"ml-4 mt-1 flex flex-col gap-0.5 border-l border-border/70 pl-3",children:p.map(f=>(0,t.jsx)(o0,{to:`${gh}/plugins/${f.id}`,state:gf,className:r(({isActive:g})=>["rounded-md px-2 py-1.5 text-xs transition-colors",g?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"].join(" "),"className"),children:f.manifestJson.displayName??f.packageName},f.id))}):null,o("instance.adapters")&&(0,t.jsx)(Qa,{to:"/company/settings/instance/adapters",label:"Adapters",icon:$m})]})})]})}r(WJe,"CompanySettingsSidebar");function HJe(){const{pathname:e}=na(),{selectedCompany:s}=ps(),{isMobile:n,setSidebarOpen:a}=Va(),i=Bme(),{enabled:o}=K5(),l=yU.filter(d=>!Fme(d.key)||o);if(e.endsWith("/apps/chat/connect"))return(0,t.jsx)(Yz,{});const c=e.match(/\/apps\/chat\/([^/]+)(?:\/(?:settings|access|reviews|conversations|activity))?\/?$/);return c?(0,t.jsx)(Ome,{endpointId:c[1],NavItem:Qa}):(0,t.jsxs)("aside",{className:"w-full h-full min-h-0 border-r border-border bg-background flex flex-col",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 px-3 py-3 shrink-0",children:[(0,t.jsxs)(Je,{to:"/dashboard",onClick:r(()=>{n&&a(!1)},"onClick"),className:"flex items-center gap-1.5 rounded-md px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",children:[(0,t.jsx)(bu,{className:"h-3.5 w-3.5 shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:s?.name??"Company"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1",children:[(0,t.jsx)(TH,{className:"h-4 w-4 text-muted-foreground shrink-0"}),(0,t.jsx)("span",{className:"flex-1 truncate text-sm font-bold text-foreground",children:"Connectors"})]})]}),(0,t.jsxs)("nav",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-auto-hide px-3 py-2",children:[(0,t.jsx)("div",{className:"px-3 pb-1 text-(length:--text-micro) font-semibold uppercase tracking-wide text-muted-foreground",children:"Connectors"}),(0,t.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,t.jsx)(Qa,{to:"/apps",label:"Browse",icon:eC,end:!0}),(0,t.jsx)(Qa,{to:"/apps/review",label:"Review",icon:rN,badge:i>0?i:void 0,badgeTone:"warning",badgeLabel:"waiting for your OK"})]}),(0,t.jsx)("div",{className:"px-3 pb-1 pt-4 text-(length:--text-micro) font-semibold uppercase tracking-wide text-muted-foreground",children:"Developer"}),(0,t.jsx)("p",{className:"px-3 pb-1.5 text-(length:--text-micro) leading-snug text-muted-foreground/70",children:"Advanced setup for developers. Most teams never open this."}),(0,t.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,t.jsx)(Qa,{to:"/apps/connections",label:"Connections",icon:TH,end:!0}),l.map(d=>(0,t.jsx)(Qa,{to:$g(d.key),label:d.label,icon:d.icon,end:!0},d.key))]})]})]})}r(HJe,"AppsSidebar");function YJ(e){const{selectedCompanyId:s}=ps(),{isMobile:n,setSidebarOpen:a}=Va(),i=Z({queryKey:P.tools.connection(e.kind==="connection"?e.connectionId:"__none__"),queryFn:r(()=>cs.getConnection(e.kind==="connection"?e.connectionId:""),"queryFn"),enabled:e.kind==="connection"&&!!e.connectionId}),o=Z({queryKey:P.tools.applications(s??"__none__"),queryFn:r(()=>cs.listApplications(s),"queryFn"),enabled:e.kind==="application"&&!!s}),l=Z({queryKey:P.tools.connections(s??"__none__"),queryFn:r(()=>cs.listConnections(s),"queryFn"),enabled:e.kind==="application"&&!!s}),c=Z({queryKey:P.apps.gallery(s??"__none__"),queryFn:r(()=>cs.listGallery(s),"queryFn"),enabled:!!s}),d=Z({queryKey:P.apps.attention(s??"__none__"),queryFn:r(()=>cs.listAppsAttention(s),"queryFn"),enabled:!!s,refetchInterval:3e4}),m=i.data,h=e.kind==="application"?(o.data?.applications??[]).find(S=>S.id===e.applicationId):null,p=YJe(e.kind==="application"?(l.data?.connections??[]).filter(S=>S.applicationId===e.applicationId):[]),f=m?cf(m):h?.name??"App",g=GJe(c.data?.apps??[],m,h??void 0),v=m?.id??p?.id??null,y=v?d.data?.apps.find(S=>S.connection.id===v):null,w=(y?.pendingActionRequestCount??0)+((y?.quarantinedCatalogEntryCount??0)>0?1:0);return(0,t.jsxs)("aside",{className:"flex h-full min-h-0 w-full flex-col border-r border-border bg-background",children:[(0,t.jsxs)("div",{className:"flex shrink-0 flex-col gap-3 px-3 py-3",children:[(0,t.jsxs)(Je,{to:"/apps/connections",onClick:r(()=>{n&&a(!1)},"onClick"),className:"flex items-center gap-1.5 rounded-md px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",children:[(0,t.jsx)(bu,{className:"h-3.5 w-3.5 shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:"All apps"})]}),(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2 px-2 py-1",children:[(0,t.jsx)(wc,{name:f,logoUrl:E1(g),size:28}),(0,t.jsx)("span",{className:"flex-1 truncate text-sm font-bold text-foreground",children:f})]})]}),(0,t.jsx)("nav",{className:"scrollbar-auto-hide min-h-0 flex-1 overflow-y-auto px-3 py-2",children:(0,t.jsx)("div",{className:"flex flex-col gap-0.5",children:V5.map(S=>(0,t.jsx)(Qa,{to:QJe(e,S.key),label:S.label,icon:S.icon,end:!0,badge:S.key==="review"&&w>0?w:void 0,badgeTone:"danger",badgeLabel:"needing review"},S.key))})})]})}r(YJ,"AppDetailSidebar");function QJe(e,s){return e.kind==="connection"?Vu(e.connectionId,s):vS(e.applicationId,s)}r(QJe,"tabHref");function GJe(e,s,n){if(n?.applicationKey){const i=e.find(o=>zc(o)===n.applicationKey);if(i)return i}const a=(s?.name??n?.name)?.toLowerCase();return a?e.find(i=>Xg(i).toLowerCase()===a)??e.find(i=>zc(i)===a)??null:null}r(GJe,"galleryEntryFor$1");function YJe(e){const s=e.filter(n=>n.status==="archived");return s.length===0?null:s.reduce((n,a)=>{const i=new Date(n.updatedAt??n.createdAt??0).getTime();return new Date(a.updatedAt??a.createdAt??0).getTime()>i?a:n})}r(YJe,"latestArchivedConnection$1");function nD({identifier:e}){return e?(0,t.jsx)("span",{className:"shrink-0 font-mono text-muted-foreground",children:e}):null}r(nD,"CrumbIdentifier");function JJe({context:e}){const{slots:s}=Gc({slotTypes:["globalToolbarButton"],companyId:e.companyId}),{launchers:n}=xU({placementZones:["globalToolbarButton"],companyId:e.companyId,enabled:!!e.companyId});return(0,t.jsxs)("div",{className:"ml-auto flex shrink-0 items-center gap-1 pl-2 empty:hidden",children:[s.length>0?(0,t.jsx)(zh,{slotTypes:["globalToolbarButton"],context:e,className:"flex items-center gap-1"}):null,n.length>0?(0,t.jsx)(aN,{placementZones:["globalToolbarButton"],context:e,className:"flex items-center gap-1"}):null]})}r(JJe,"GlobalToolbar");function XJe(){const{breadcrumbs:e,mobileToolbar:s}=qn(),{toggleSidebar:n,isMobile:a}=Va(),{selectedCompanyId:i,selectedCompany:o}=ps(),l=(0,u.useMemo)(()=>({companyId:i??null,companyPrefix:o?.issuePrefix??null}),[i,o?.issuePrefix]),c=(0,t.jsx)(JJe,{context:l});if(a&&s)return(0,t.jsx)("div",{className:"border-b border-border px-2 h-12 shrink-0 flex items-center",children:s});if(e.length===0)return(0,t.jsx)("div",{className:"border-b border-border px-4 md:px-6 h-12 shrink-0 flex items-center justify-end",children:c});const d=a&&(0,t.jsx)(F,{variant:"ghost",size:"icon-sm",className:"mr-2 shrink-0",onClick:n,"aria-label":"Open sidebar",children:(0,t.jsx)(Bde,{className:"h-5 w-5"})});return e.length===1?(0,t.jsxs)("div",{className:"border-b border-border px-4 md:px-6 h-12 shrink-0 flex items-center",children:[d,(0,t.jsx)("div",{className:"min-w-0 overflow-hidden flex-1",children:e[0].leading||e[0].identifier?(0,t.jsxs)("h1",{className:"flex items-center gap-1.5 text-sm font-semibold uppercase tracking-wider",children:[e[0].leading&&(0,t.jsx)("span",{className:"flex shrink-0 items-center",children:e[0].leading}),(0,t.jsx)(nD,{identifier:e[0].identifier}),(0,t.jsx)("span",{className:"truncate",children:e[0].label})]}):(0,t.jsx)("h1",{className:"text-sm font-semibold uppercase tracking-wider truncate",children:e[0].label})}),c]}):(0,t.jsxs)("div",{className:"border-b border-border px-4 md:px-6 h-12 shrink-0 flex items-center",children:[d,(0,t.jsx)("div",{className:"min-w-0 overflow-hidden flex-1",children:(0,t.jsx)(jU,{className:"min-w-0 overflow-hidden",children:(0,t.jsx)(wU,{className:"flex-nowrap",children:e.map((m,h)=>{const p=h===e.length-1;return(0,t.jsxs)(u.Fragment,{children:[h>0&&(0,t.jsx)(mT,{}),(0,t.jsx)(yS,{className:p?"min-w-0":"shrink-0",children:p||!m.href?m.leading||m.identifier?(0,t.jsxs)(oC,{className:"flex min-w-0 items-center gap-1.5",children:[m.leading&&(0,t.jsx)("span",{className:"flex shrink-0 items-center",children:m.leading}),(0,t.jsx)(nD,{identifier:m.identifier}),(0,t.jsx)("span",{className:"truncate",children:m.label})]}):(0,t.jsx)(oC,{className:"truncate",children:m.label}):(0,t.jsx)(uT,{asChild:!0,children:m.leading||m.identifier?(0,t.jsxs)(Je,{to:m.href,onClick:m.onClick,className:"flex items-center gap-1.5",children:[m.leading&&(0,t.jsx)("span",{className:"flex shrink-0 items-center",children:m.leading}),(0,t.jsx)(nD,{identifier:m.identifier}),(0,t.jsx)("span",{className:"truncate",children:m.label})]}):(0,t.jsx)(Je,{to:m.href,onClick:m.onClick,children:m.label})})})]},h)})})})}),c]})}r(XJe,"BreadcrumbBar");var II=240,sB=208,nB=420,JJ=16;function WT(e){return Math.min(nB,Math.max(sB,e))}r(WT,"clampSidebarWidth");function XJ(e){if(typeof window>"u")return II;try{const s=window.localStorage.getItem(e);if(!s)return II;const n=Number.parseInt(s,10);return Number.isFinite(n)?WT(n):II}catch{return II}}r(XJ,"readStoredSidebarWidth");function ZJ(e,s){if(!(typeof window>"u"))try{window.localStorage.setItem(e,String(WT(s)))}catch{}}r(ZJ,"writeStoredSidebarWidth");function ZJe({children:e,open:s,collapsed:n=!1,peeking:a=!1,resizable:i=!1,storageKey:o="paperclip.sidebar.width",className:l,onPanelMouseEnter:c,onPanelMouseLeave:d,onPanelFocusCapture:m,onPanelBlurCapture:h}){const[p,f]=(0,u.useState)(()=>XJ(o)),[g,v]=(0,u.useState)(!1),y=(0,u.useRef)(p),w=(0,u.useRef)(null);(0,u.useEffect)(()=>{const E=XJ(o);y.current=E,f(E)},[o]);const S=s?p:0,j=s?n?64:S:0,N=s?n&&!a?64:S:0,_=N>j,R=i&&s&&!n,C=(0,u.useMemo)(()=>({width:`${j}px`}),[j]),A=(0,u.useMemo)(()=>({width:`${N}px`}),[N]),T=(0,u.useCallback)(E=>{const q=WT(E);y.current=q,f(q),ZJ(o,q)},[o]),I=(0,u.useCallback)(E=>{R&&(E.preventDefault(),E.currentTarget.setPointerCapture(E.pointerId),w.current={startX:E.clientX,startWidth:y.current},v(!0))},[R]),$=(0,u.useCallback)(E=>{if(!w.current)return;const q=WT(w.current.startWidth+E.clientX-w.current.startX);y.current=q,f(q)},[]),O=(0,u.useCallback)(()=>{w.current&&(w.current=null,v(!1),ZJ(o,y.current))},[o]),L=(0,u.useCallback)(E=>{R&&(E.key==="ArrowLeft"?(E.preventDefault(),T(p-JJ)):E.key==="ArrowRight"?(E.preventDefault(),T(p+JJ)):E.key==="Home"?(E.preventDefault(),T(sB)):E.key==="End"&&(E.preventDefault(),T(nB)))},[R,T,p]);return(0,t.jsx)("div",{className:U("relative h-full shrink-0",l),style:C,children:(0,t.jsxs)("div",{className:U("absolute inset-y-0 left-0 flex flex-col overflow-hidden",_?"z-30 border-r border-border bg-background shadow-lg":"z-0"),style:A,"data-sidebar-overlay":_?"":void 0,onMouseEnter:c,onMouseLeave:d,onFocusCapture:m,onBlurCapture:h,children:[e,R?(0,t.jsx)("div",{role:"separator","aria-label":"Resize sidebar","aria-orientation":"vertical","aria-valuemin":sB,"aria-valuemax":nB,"aria-valuenow":p,tabIndex:0,className:U("absolute inset-y-0 right-0 z-20 w-3 cursor-col-resize touch-none outline-none","before:absolute before:inset-y-0 before:left-1/2 before:w-px before:-translate-x-1/2 before:bg-transparent before:transition-colors","hover:before:bg-border focus-visible:before:bg-ring",g&&"before:bg-ring"),onPointerDown:I,onPointerMove:$,onPointerUp:O,onPointerCancel:O,onLostPointerCapture:O,onKeyDown:L}):null]})})}r(ZJe,"SidebarShell");function eXe({children:e,className:s}){return(0,t.jsx)("div",{"data-secondary-sidebar":"",className:U("h-full w-60 shrink-0 overflow-y-auto border-r border-border bg-background",s),children:(0,t.jsx)(RJe,{children:e})})}r(eXe,"SecondarySidebar");var tXe="/company/settings/instance/profile",sXe="https://docs.paperclip.ing/",nXe="https://paperclip.ing/feedback";function rXe(e){const s=e.trim().split(/\s+/).filter(Boolean);return s.length>=2?`${s[0]?.[0]??""}${s[s.length-1]?.[0]??""}`.toUpperCase():e.slice(0,2).toUpperCase()}r(rXe,"deriveInitials$1");function aXe(e,s,n){const a=[e,s?.split("@")[0],s,n];for(const i of a){const o=i?.trim().toLowerCase().replace(/['"]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");if(o)return o}return"me"}r(aXe,"deriveUserSlug");function rD({label:e,description:s,icon:n,onClick:a,href:i,external:o=!1}){const l="flex w-full items-start gap-3 rounded-xl px-3 py-3 text-left transition-colors hover:bg-accent/60",c=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"mt-0.5 rounded-lg border border-border bg-background/70 p-2 text-muted-foreground",children:(0,t.jsx)(n,{className:"size-4"})}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block text-sm font-medium text-foreground",children:e}),(0,t.jsx)("span",{className:"block text-xs text-muted-foreground",children:s})]})]});return i?o?(0,t.jsx)("a",{href:i,target:"_blank",rel:"noreferrer",className:l,onClick:a,children:c}):(0,t.jsx)(Je,{to:i,className:l,onClick:a,children:c}):(0,t.jsx)("button",{type:"button",className:l,onClick:a,children:c})}r(rD,"MenuAction");function eX({deploymentMode:e,open:s,onOpenChange:n}){const a=!!Yc(),[i,o]=(0,u.useState)(!1),{isMobile:l,setSidebarOpen:c,collapsed:d,peeking:m}=Va(),h=d&&!m,p=s??i,f=n??o,{data:g}=Z({queryKey:P.auth.session,queryFn:r(()=>qa.getSession(),"queryFn"),retry:!1}),v=iN({onSignedOut:N}),y=g?.user.name?.trim()||"Board",w=g?.user.email?.trim()||(e==="authenticated"?"Signed in":"Local workspace board"),S=rXe(y),j=`/u/${aXe(g?.user.name,g?.user.email,g?.user.id)}`;function N(){f(!1),l&&c(!1)}r(N,"closeNavigationChrome");function _(){v.mutate()}return r(_,"handleSignOut"),(0,t.jsx)("div",{className:"border-t border-r border-border bg-background px-3 py-2",children:(0,t.jsxs)("div",{className:U("flex items-center gap-0.5",!h&&"px-2"),children:[(0,t.jsxs)(Zn,{open:p,onOpenChange:f,children:[(0,t.jsx)(ur,{asChild:!0,children:(0,t.jsxs)("button",{type:"button",className:U("flex min-w-0 items-center gap-2.5 rounded-lg text-left text-(length:--text-compact) font-medium text-foreground/80 transition-colors hover:bg-accent/50 hover:text-foreground",h?"w-full px-3 py-2":"flex-1 px-2 py-1.5"),"aria-label":"Open account menu",children:[(0,t.jsxs)(Gi,{size:"sm",children:[g?.user.image?(0,t.jsx)(Hc,{src:g.user.image,alt:y}):null,(0,t.jsx)(Yi,{children:S})]}),(0,t.jsx)("span",{className:U("min-w-0 flex-1 truncate",h&&"block w-0 min-w-0 overflow-hidden whitespace-nowrap text-transparent select-none"),children:y})]})}),(0,t.jsxs)(Vn,{side:"top",align:"start",sideOffset:10,className:"w-(--sz-277px) max-w-(--sz-calc-24) overflow-hidden rounded-t-2xl rounded-b-none border-border p-0 shadow-2xl",children:[(0,t.jsx)("div",{className:"h-24 bg-(image:--gradient-extract-25)"}),(0,t.jsxs)("div",{className:"-mt-8 px-4 pb-4",children:[(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)("div",{className:"rounded-2xl border-4 border-popover bg-popover p-0.5 shadow-sm",children:(0,t.jsxs)(Gi,{size:"lg",children:[g?.user.image?(0,t.jsx)(Hc,{src:g.user.image,alt:y}):null,(0,t.jsx)(Yi,{children:S})]})}),(0,t.jsxs)("div",{className:"min-w-0 flex-1 pt-1",children:[(0,t.jsx)("h2",{className:"truncate text-base font-semibold text-foreground",children:y}),(0,t.jsx)("p",{className:"truncate text-sm text-muted-foreground",children:w})]})]}),(0,t.jsxs)("div",{className:"mt-4 space-y-1",children:[(0,t.jsx)(rD,{label:"View profile",description:"Open your activity, task, and usage ledger.",icon:vu,href:j,onClick:N}),(0,t.jsx)(rD,{label:"Edit profile",description:"Update your display name and avatar.",icon:C1,href:tXe,onClick:N}),(0,t.jsx)(rD,{label:"Documentation",description:"Open Paperclip docs in a new tab.",icon:sN,href:sXe,external:!0,onClick:r(()=>f(!1),"onClick")}),(0,t.jsx)(Bj,{variant:"menu-action",onAfterToggle:r(()=>f(!1),"onAfterToggle")}),e==="authenticated"?(0,t.jsxs)("button",{type:"button",className:U("flex w-full items-start gap-3 rounded-xl px-3 py-3 text-left transition-colors hover:bg-destructive/10",v.isPending&&"cursor-not-allowed opacity-60"),onClick:_,disabled:v.isPending,children:[(0,t.jsx)("span",{className:"mt-0.5 rounded-lg border border-border bg-background/70 p-2 text-muted-foreground",children:(0,t.jsx)(Yh,{className:"size-4"})}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block text-sm font-medium text-foreground",children:v.isPending?"Signing out...":"Sign out"}),(0,t.jsx)("span",{className:"block text-xs text-muted-foreground",children:"End this browser session."})]})]}):null,(0,t.jsx)(ige,{})]})]})]})]}),!h&&!a?(0,t.jsxs)(Wn,{children:[(0,t.jsx)(Hn,{asChild:!0,children:(0,t.jsx)("a",{href:nXe,target:"_blank",rel:"noreferrer","aria-label":"Share feedback",className:"flex size-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground/50 transition-colors hover:bg-accent/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:(0,t.jsx)(Px,{className:"h-4 w-4","aria-hidden":"true"})})}),(0,t.jsx)(Qn,{side:"top",children:"Share feedback"})]}):null]})})}r(eX,"SidebarAccountMenu");function iXe(e,s){return wge(e,s)[0]?.toLowerCase()??null}r(iXe,"getCompanyRouteSegment");function wge(e,s){if(!s)return[];const n=e.split("/").filter(Boolean);return n.length<2?[]:n[0]?.toUpperCase()!==s.toUpperCase()?[]:n.slice(1)}r(wge,"getCompanyPathSegments");var oXe=new Set(["browse","connections","connect","chat","review","attention","gateways","advanced","app"]);function lXe(e,s){const n=e.split("/").filter(Boolean);return n[0]?.toLowerCase()==="skills"?!0:s?n[0]?.toUpperCase()===s.toUpperCase()&&n[1]?.toLowerCase()==="skills":!1}r(lXe,"isSkillsStoreRoute");function cXe(){const{sidebarOpen:e,setSidebarOpen:s,toggleSidebar:n,collapsed:a,peeking:i,setPeeking:o,isMobile:l,setForceCollapsed:c}=Va(),{openNewIssue:d,openOnboarding:m}=$o(),{togglePanelVisible:h}=yf(),p=_c()?.pushToast??null,{companies:f,loading:g,selectedCompany:v,selectedCompanyId:y,selectionSource:w,setSelectedCompanyId:S}=ps(),{companyPrefix:j,pluginRoutePath:N}=Sa(),_=Yn(),R=na(),C=m5(),A=["/company/settings","/company/export","/company/import"].some(xt=>R.pathname.includes(xt)),T=wge(R.pathname,j),I=T[0]?.toLowerCase()==="tools",$=T[0]?.toLowerCase()==="apps",O=$&&T[1]&&!oXe.has(T[1].toLowerCase())?T[1]:null,L=$&&T[1]?.toLowerCase()==="app"&&T[2]?T[2]:null,E=lXe(R.pathname,j),q=(0,u.useRef)(!1),B=(0,u.useRef)(null),K=(0,u.useRef)(null),z=(0,u.useRef)(new pue),D=(0,u.useRef)(R.key),V=mge(R.pathname,j,l),[H,ee]=(0,u.useState)(!1),X=(0,u.useMemo)(()=>{if(!j)return null;const xt=j.toUpperCase();return f.find(De=>De.issuePrefix.toUpperCase()===xt)??null},[f,j]),le=!!j&&!g&&f.length>0&&!X,ce=(0,u.useMemo)(()=>N?.toLowerCase()??iXe(R.pathname,j),[j,R.pathname,N]),te=X?.id??null,ae=X?.issuePrefix??null,{slots:de}=Gc({slotTypes:["page","routeSidebar"],companyId:te,enabled:!!(te&&ce)}),J=(0,u.useMemo)(()=>oU(de,ce),[ce,de]),Y=(0,u.useMemo)(()=>({companyId:te,companyPrefix:ae}),[te,ae]),G=A?(0,t.jsx)(WJe,{}):O?(0,t.jsx)(YJ,{kind:"connection",connectionId:O}):L?(0,t.jsx)(YJ,{kind:"application",applicationId:L}):$||I?(0,t.jsx)(HJe,{}):J?(0,t.jsx)(yu,{slot:J,context:Y,className:"h-full w-full",missingBehavior:"placeholder"}):null,fe=G!=null,{data:se}=Z({queryKey:P.health,queryFn:r(()=>sm.get(),"queryFn"),retry:!1,refetchInterval:r(xt=>xt.state.data?.devServer?.enabled?2e3:!1,"refetchInterval"),refetchIntervalInBackground:!1}),re=Z({queryKey:P.instance.generalSettings,queryFn:r(()=>Er.getGeneral(),"queryFn")}).data?.keyboardShortcuts===!0,ie=fe||E;(0,u.useLayoutEffect)(()=>(c(ie),()=>c(!1)),[ie,c]),(0,u.useEffect)(()=>{g||q.current||se?.deploymentMode!=="authenticated"&&(se?.cloud||f.length===0&&(q.current=!0,m()))},[f,g,m,se?.cloud,se?.deploymentMode]),(0,u.useEffect)(()=>{if(!j||g||f.length===0)return;if(!X){const De=(y?f.find(Qe=>Qe.id===y):null)??f[0]??null;De&&y!==De.id&&S(De.id,{source:"route_sync"});return}if(j!==X.issuePrefix){const De=R.pathname.replace(/^\/[^/]+/,"");_(`/${X.issuePrefix}${De}${R.search}`,{replace:!0});return}const xt=hge({matchedCompany:X,selectedCompanyId:y,companies:f});if(xt){p?.({title:`${X.name} is archived`,body:`Switched to ${xt.name}.`,tone:"info",dedupeKey:`archived-company-bounce:${X.id}`}),S(xt.id,{source:"route_sync"}),_(`/${xt.issuePrefix}/dashboard`,{replace:!0});return}pge({selectionSource:w,selectedCompanyId:y,routeCompanyId:X.id})&&S(X.id,{source:"route_sync"})},[j,f,g,X,R.pathname,R.search,_,p,w,y,S]);const me=h,pe=(0,u.useCallback)(()=>{document.dispatchEvent(new KeyboardEvent("keydown",{key:"k",metaKey:!0,bubbles:!0,cancelable:!0}))},[]),be=(0,u.useRef)(null),oe=(0,u.useRef)(!1),ye=(0,u.useRef)(!1),Ae=(0,u.useCallback)(()=>{be.current!==null&&(window.clearTimeout(be.current),be.current=null)},[]),xe=(0,u.useCallback)(()=>{Ae(),be.current=window.setTimeout(()=>o(!0),50)},[Ae,o]),_e=(0,u.useCallback)(()=>{Ae(),o(!0)},[Ae,o]),Ge=(0,u.useCallback)(()=>{Ae(),be.current=window.setTimeout(()=>o(!1),120)},[Ae,o]),$e=(0,u.useCallback)(()=>{oe.current=!0,a&&!ye.current&&xe()},[a,xe]),Ye=(0,u.useCallback)(()=>{oe.current=!1,ye.current=!1,Ge()},[Ge]),ue=(0,u.useCallback)(()=>{ye.current||_e()},[_e]),Oe=(0,u.useCallback)(()=>{oe.current||Ge()},[Ge]);(0,u.useEffect)(()=>Ae,[Ae]);const dt=(0,u.useRef)(a);return(0,u.useEffect)(()=>{a!==dt.current&&(a?(Ae(),o(!1),ye.current=oe.current):ye.current=!1,dt.current=a)},[a,Ae,o]),(0,u.useEffect)(()=>{if(!i)return;const xt=r(De=>{De.key==="Escape"&&(Ae(),o(!1))},"onKeyDown");return window.addEventListener("keydown",xt),()=>window.removeEventListener("keydown",xt)},[i,Ae,o]),uge(),oge({enabled:re,onNewIssue:r(()=>d(),"onNewIssue"),onSearch:pe,onToggleSidebar:n,onTogglePanel:me,onShowShortcuts:r(()=>ee(!0),"onShowShortcuts"),onGoToInbox:r(()=>_("/inbox"),"onGoToInbox")}),(0,u.useEffect)(()=>{if(!l)return;const xt=30,De=50,Qe=75;let ht=0,We=0;const Ke=r(tt=>{const Se=tt.touches[0];ht=Se.clientX,We=Se.clientY},"onTouchStart"),gt=r(tt=>{const Se=tt.changedTouches[0],ke=Se.clientX-ht;if(!(Math.abs(Se.clientY-We)>Qe)){if(!e&&ht<xt&&ke>De){s(!0);return}e&&ke<-50&&s(!1)}},"onTouchEnd");return document.addEventListener("touchstart",Ke,{passive:!0}),document.addEventListener("touchend",gt,{passive:!0}),()=>{document.removeEventListener("touchstart",Ke),document.removeEventListener("touchend",gt)}},[l,e,s]),(0,u.useEffect)(()=>{const xt=document.body.style.overflow;return document.body.style.overflow=l?"visible":"clip",()=>{document.body.style.overflow=xt}},[l]),(0,u.useEffect)(()=>{if(!l)return xge()},[l]),(0,u.useEffect)(()=>{if(typeof document>"u")return;const xt=K.current;return fge(xt)},[R.pathname]),(0,u.useEffect)(()=>{const xt=K.current;if(!xt)return;const De=r(()=>{z.current.remember(D.current,xt.scrollTop)},"recordScroll");return xt.addEventListener("scroll",De,{passive:!0}),()=>xt.removeEventListener("scroll",De)},[]),(0,u.useLayoutEffect)(()=>{const xt=K.current,De=hue({previousPathname:B.current,pathname:R.pathname,navigationType:C,state:R.state});B.current=R.pathname;const Qe=C==="POP",ht=Qe?z.current.recall(R.key):0;if(D.current=R.key,Qe){nT(xt,ht);const We=requestAnimationFrame(()=>nT(xt,ht));return()=>cancelAnimationFrame(We)}De&&fue(xt)},[R.key,R.pathname,R.state,C]),(0,t.jsx)(mue,{children:(0,t.jsx)(vce,{value:{keyboardShortcutsEnabled:re},children:(0,t.jsxs)("div",{className:U("bg-background text-foreground pt-(--sz-safe-top)",l?"min-h-dvh overflow-x-clip":"flex h-dvh flex-col overflow-clip"),children:[(0,t.jsx)("a",{href:"#main-content",className:"sr-only focus:not-sr-only focus:fixed focus:left-3 focus:top-3 focus:z-(--z-200) focus:rounded-md focus:bg-background focus:px-3 focus:py-2 focus:text-sm focus:font-medium focus:shadow-lg focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:"Skip to Main Content"}),(0,t.jsx)(tge,{}),(0,t.jsx)(sge,{devServer:se?.devServer}),(0,t.jsxs)("div",{className:U("min-h-0 flex-1",l?"w-full":"flex overflow-clip"),children:[l&&e&&(0,t.jsx)("button",{type:"button",className:"fixed inset-0 z-40 bg-black/50",onClick:r(()=>s(!1),"onClick"),"aria-label":"Close sidebar"}),l?(0,t.jsxs)("div",{className:U("fixed inset-y-0 left-0 z-50 flex flex-col overflow-hidden pt-(--sz-safe-top) transition-transform duration-100 ease-out",e?"translate-x-0":"-translate-x-full"),children:[(0,t.jsx)("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:(0,t.jsx)("div",{className:"w-60 shrink-0 overflow-hidden",children:fe?G:(0,t.jsx)(GJ,{})})}),(0,t.jsx)(eX,{deploymentMode:se?.deploymentMode})]}):(0,t.jsxs)(ZJe,{open:e,collapsed:a,peeking:i,resizable:!0,onPanelMouseEnter:$e,onPanelMouseLeave:Ye,onPanelFocusCapture:a?ue:void 0,onPanelBlurCapture:a?Oe:void 0,children:[(0,t.jsx)("div",{className:"flex flex-1 min-h-0",children:(0,t.jsx)(GJ,{})}),(0,t.jsx)(eX,{deploymentMode:se?.deploymentMode})]}),!l&&fe?(0,t.jsx)(eXe,{children:G}):null,(0,t.jsxs)("div",{className:U("flex min-w-0 flex-col",l?"w-full":"h-full flex-1"),children:[(0,t.jsxs)("div",{className:U(l&&"sticky top-0 z-20 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/85"),children:[(0,t.jsx)(ZF,{mobile:l}),(0,t.jsx)(XJe,{}),l&&A?(0,t.jsx)("div",{className:"border-b border-border px-4 pb-3",children:(0,t.jsx)($me,{})}):null]}),(0,t.jsxs)("div",{className:U(l?"block":"flex flex-1 min-h-0"),children:[(0,t.jsx)("main",{id:"main-content",ref:K,tabIndex:-1,style:l?{"--tc-composer-bottom":"var(--sz-calc-14)"}:void 0,className:U("flex-1 p-4 outline-none md:p-6",l?"overflow-visible pb-(--sz-calc-14)":"overflow-auto [scrollbar-gutter:stable]"),children:le?(0,t.jsx)(xu,{scope:"invalid_company_prefix",requestedPrefix:j??v?.issuePrefix}):(0,t.jsx)(age,{children:(0,t.jsx)(i0,{})})}),(0,t.jsx)(Gme,{})]})]})]}),l&&(0,t.jsx)(ege,{visible:V}),(0,t.jsx)(Xme,{}),(0,t.jsx)(uhe,{}),(0,t.jsx)(Wxe,{}),(0,t.jsx)(Gxe,{}),(0,t.jsx)(Yxe,{}),(0,t.jsx)(Jxe,{open:H,onOpenChange:ee}),(0,t.jsx)(Xxe,{}),(0,t.jsx)(Zxe,{localTrusted:se?.deploymentMode==="local_trusted"})]})})})}r(cXe,"Layout");var tX=null;function dXe(){return tX??=new l1,tX}r(dXe,"getDetachedClient");function uXe(){const e=(0,u.useContext)(l5),{data:s,isFetched:n}=Z({queryKey:P.instance.experimentalSettings,queryFn:r(()=>Er.getExperimental(),"queryFn"),enabled:e!=null},e??dXe());return e?{enabled:s?.enableConferenceRoomChat===!0,loaded:n}:{enabled:!1,loaded:!0}}r(uXe,"useConferenceRoomChatEnabled");function mXe(){const{enabled:e,loaded:s}=uXe();return s?e?(0,t.jsx)(i0,{}):(0,t.jsx)(kn,{to:"/dashboard",replace:!0}):null}r(mXe,"ConferenceRoomChatGate");var hXe=["session-start","human-message","agent-message","thinking","responding","responding-burst","tool-call","diff","working","running","completed","activity-phases","awaiting-approval","plan-todo","interrupted","refused","truncated","live-token-cost"],pXe={"session-start":{id:"session-start",label:"Session start",tier:"live",surface:"thread",protocol:'acpx.session → TranscriptEntry kind:"init"'},"human-message":{id:"human-message",label:"Human message",tier:"live",surface:"thread",protocol:'IssueComment authorType:"user"'},"agent-message":{id:"agent-message",label:"Final response",tier:"live",surface:"thread",protocol:'PRP item.delta kind:"agentMessage" channel:"final"'},thinking:{id:"thinking",label:"Thinking",tier:"live",surface:"thread",protocol:"text_delta stream:thought (ACP agent_thought_chunk)"},responding:{id:"responding",label:"Progress update (streaming)",tier:"live",surface:"thread",protocol:'PRP item.delta kind:"agentMessage" channel:"progress"'},"responding-burst":{id:"responding-burst",label:"Progress update burst",tier:"live",surface:"thread",protocol:"text_delta stream:output ×N, tool calls between (PAP-368 dwell)"},"tool-call":{id:"tool-call",label:"Tool call",tier:"live",surface:"thread",protocol:"acpx.tool_call (ACP tool_call / tool_call_update)"},diff:{id:"diff",label:"Diff",tier:"live",surface:"thread",protocol:'ToolCallContent type:"diff" → TranscriptEntry kind:"diff"'},working:{id:"working",label:"Working",tier:"live",surface:"thread",protocol:"heartbeat.run.progress + acpx.status"},running:{id:"running",label:"Running",tier:"live",surface:"thread",protocol:'message.status.type === "running"'},completed:{id:"completed",label:"Completed (collapsed)",tier:"live",surface:"thread",protocol:"acpx.result (StopReason in subtype)"},"activity-phases":{id:"activity-phases",label:"Long-run activity phases",tier:"live",surface:"thread",protocol:"assistant boundaries + chronological tool calls"},"awaiting-approval":{id:"awaiting-approval",label:"Awaiting approval",tier:"tier-b",surface:"thread",protocol:"ACP RequestPermissionRequest + PermissionOptionKind"},"plan-todo":{id:"plan-todo",label:"Plan / todo",tier:"tier-b",surface:"plan",protocol:"ACP Plan { entries: PlanEntry[] }, PlanEntryStatus"},interrupted:{id:"interrupted",label:"Interrupted",tier:"tier-b",surface:"thread",protocol:'AcpRuntimeTurnResult.status:"cancelled" / StopReason "cancelled"'},refused:{id:"refused",label:"Refused",tier:"tier-b",surface:"thread",protocol:'StopReason "refusal"'},truncated:{id:"truncated",label:"Truncated",tier:"tier-b",surface:"thread",protocol:'StopReason "max_tokens" | "max_turn_requests"'},"live-token-cost":{id:"live-token-cost",label:"Live token / cost",tier:"tier-b",surface:"thread",protocol:"ACP UsageUpdate { used, size, cost }"}},L7t=hXe.map(e=>pXe[e]);function Nge({item:e}){return(0,t.jsx)("article",{className:"rounded-lg border border-border bg-card p-3","aria-label":`Project created: ${e.name}`,children:(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)(p5e,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),(0,t.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:[(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Project created"}),(0,t.jsx)(Je,{to:`/projects/${e.projectId}`,className:"break-words text-sm font-medium hover:underline focus-visible:underline",children:e.name}),e.description&&(0,t.jsx)("p",{className:"line-clamp-3 text-sm text-muted-foreground",children:e.description}),e.repositories.length>0&&(0,t.jsx)("ul",{className:"space-y-1 pt-1",children:e.repositories.map(s=>(0,t.jsxs)("li",{className:"flex min-w-0 items-center gap-2 text-xs text-muted-foreground",children:[(0,t.jsx)(Do,{className:"size-3 shrink-0","aria-hidden":!0}),(0,t.jsx)("a",{className:"truncate hover:underline focus-visible:underline",href:s.url,target:"_blank",rel:"noreferrer",children:s.name})]},s.id))})]})]})})}r(Nge,"TaskChatProjectCreatedCard");function fXe({item:e,onOpen:s}){return(0,t.jsx)("article",{className:"rounded-lg border border-border bg-card p-3","aria-label":`Skill created: ${e.name}`,children:(0,t.jsxs)("button",{type:"button",className:"flex w-full items-start gap-3 text-left",onClick:r(()=>s?.(e.skillId,e.name),"onClick"),children:[(0,t.jsx)(jx,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),(0,t.jsxs)("span",{className:"min-w-0 flex-1 space-y-1",children:[(0,t.jsx)("span",{className:"block text-xs text-muted-foreground",children:"Skill created"}),(0,t.jsx)("span",{className:"block break-words text-sm font-medium hover:underline focus-visible:underline",children:e.name}),e.description?(0,t.jsx)("span",{className:"block line-clamp-3 text-sm text-muted-foreground",children:e.description}):null]})]})})}r(fXe,"TaskChatSkillCreatedCard");var kge=(0,u.createContext)("streamlined");function xXe({mode:e,children:s}){return(0,t.jsx)(kge.Provider,{value:e,children:s})}r(xXe,"TaskChatPresentationProvider");function Xh(){return(0,u.useContext)(kge)==="streamlined"}r(Xh,"useStreamlinedTaskChatPresentation");function gXe(e){return(0,t.jsxs)("svg",{viewBox:"0 0 180 180",fill:"none",stroke:"currentColor",strokeWidth:14,strokeLinecap:"round",xmlns:"http://www.w3.org/2000/svg",...e,children:[(0,t.jsx)("path",{d:"M18 84.8528L85.8822 16.9706C95.2548 7.59798 110.451 7.59798 119.823 16.9706C129.196 26.3431 129.196 41.5391 119.823 50.9117L68.5581 102.177"}),(0,t.jsx)("path",{d:"M69.2652 101.47L119.823 50.9117C129.196 41.5391 144.392 41.5391 153.765 50.9117L154.118 51.2652C163.491 60.6378 163.491 75.8338 154.118 85.2063L92.7248 146.6C89.6006 149.724 89.6006 154.789 92.7248 157.913L105.331 170.52"}),(0,t.jsx)("path",{d:"M102.853 33.9411L52.6482 84.1457C43.2756 93.5183 43.2756 108.714 52.6482 118.087C62.0208 127.459 77.2167 127.459 86.5893 118.087L136.794 67.8822"})]})}r(gXe,"McpIcon");var bXe=new Set(["tool","tool call","tool_call","acp_tool"]);function Rd(e){const s=(e??"").trim().toLowerCase().replace(/\s*\((?:pending|in[_ -]?progress|completed|failed|cancelled|canceled)\)$/,"");return!s||bXe.has(s)}r(Rd,"isGenericToolName");function PK(e){const s=e.match(/^mcp__(.+?)__(.+)$/i);if(s)return{namespace:s[1],name:s[2]};const n=e.match(/^mcp\.([^.]+)\.(.+)$/i);return n?{namespace:n[1],name:n[2]}:null}r(PK,"mcpToolIdentity");function MK(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/[^A-Za-z0-9]+/g," ").trim().toLowerCase().split(/\s+/).filter(Boolean)}r(MK,"identifierWords");function Sge(e){if(e.length===0)return"";const s=e.map(n=>["api","id","lsp","mcp","pr","url"].includes(n)?n.toUpperCase():n).join(" ");return s.charAt(0).toUpperCase()+s.slice(1)}r(Sge,"sentenceCase");function qj(e){const s=(e??"").trim();return Rd(s)?"Unnamed tool":Sge(MK(PK(s)?.name??s))}r(qj,"humanizeToolName");var ad=r((e,s,n)=>({key:e,singular:s,plural:n}),"group"),vXe={bash:{action:"run"},terminal:{action:"run"},shell:{action:"run"},command:{action:"run"},run:{action:"run"},execute:{action:"run"},exec_command:{action:"run"},apply_patch:{action:"update",running:"Applying a patch",completed:"Applied a patch"},read:{action:"read",running:"Reading a file",completed:"Read a file"},write:{action:"update",running:"Writing a file",completed:"Wrote a file"},edit:{action:"update",running:"Editing a file",completed:"Edited a file"},notebook_read:{action:"read",running:"Reading a notebook",completed:"Read a notebook"},notebook_edit:{action:"update",running:"Editing a notebook",completed:"Edited a notebook"},glob:{action:"search",running:"Searching files",completed:"Searched files"},grep:{action:"search",running:"Searching file contents",completed:"Searched file contents",family:"grep"},tool_search:{action:"search",running:"Searching available tools",completed:"Searched available tools",group:ad("tool_search","tool search","tool searches")},web_search:{action:"search",running:"Searching the web",completed:"Searched the web",family:"web"},web_fetch:{action:"fetch",running:"Fetching a web page",completed:"Fetched a web page",family:"web"},todo_write:{action:"update",running:"Updating the task list",completed:"Updated the task list",family:"plan",group:ad("task_operation","task operation","task operations")},task_create:{action:"create",running:"Creating a task",completed:"Created a task",family:"plan",group:ad("task_operation","task operation","task operations")},task_update:{action:"update",running:"Updating a task",completed:"Updated a task",family:"plan",group:ad("task_operation","task operation","task operations")},task_list:{action:"list",running:"Listing tasks",completed:"Listed tasks",family:"plan",group:ad("task_operation","task operation","task operations")},task_get:{action:"read",running:"Reading a task",completed:"Read a task",family:"plan",group:ad("task_operation","task operation","task operations")},enter_plan_mode:{action:"switch",running:"Entering plan mode",completed:"Entered plan mode",family:"plan"},exit_plan_mode:{action:"switch",running:"Leaving plan mode",completed:"Left plan mode",family:"plan"},skill:{action:"read",running:"Loading a skill",completed:"Loaded a skill"},ask_user_question:{action:"request",running:"Requesting input",completed:"Requested input",family:"question"},request_human_input:{action:"request",running:"Requesting input",completed:"Requested input",family:"question",group:ad("task_operation","task operation","task operations")},agent:{action:"start",running:"Starting a subagent",completed:"Started a subagent",family:"agent"},task:{action:"start",running:"Starting a subagent",completed:"Started a subagent",family:"agent"},task_output:{action:"read",running:"Checking subagent progress",completed:"Checked subagent progress",family:"agent"},task_stop:{action:"stop",running:"Stopping a subagent",completed:"Stopped a subagent",family:"agent"},send_message:{action:"post",running:"Messaging a subagent",completed:"Messaged a subagent",family:"agent"},spawn_agent:{action:"start",running:"Starting a subagent",completed:"Started a subagent",family:"agent"},wait_agent:{action:"wait",running:"Checking subagent progress",completed:"Checked subagent progress",family:"agent"},wait_threads:{action:"wait",running:"Checking task progress",completed:"Checked task progress",family:"agent"},interrupt_agent:{action:"stop",running:"Interrupting a subagent",completed:"Interrupted a subagent",family:"agent"},report_findings:{action:"post",running:"Reporting findings",completed:"Reported findings",family:"safety"},guardian_review:{action:"think",running:"Reviewing safety",completed:"Reviewed safety",family:"safety"},lsp:{action:"read",running:"Inspecting code intelligence",completed:"Inspected code intelligence"},compact_conversation:{action:"think",running:"Compacting context",completed:"Compacted context"},image_generation:{action:"create",running:"Generating an image",completed:"Generated an image",family:"image"},view_image:{action:"read",running:"Viewing an image",completed:"Viewed an image",family:"image"},multi_tool_use_parallel:{action:"run",running:"Running tools in parallel",completed:"Ran tools in parallel"},get_task_context:{action:"read",running:"Reading task context",completed:"Read task context"},get_task_history:{action:"read",running:"Reading task history",completed:"Read task history"},list_documents:{action:"list",running:"Listing documents",completed:"Listed documents"},read_document:{action:"read",running:"Reading a document",completed:"Read a document"},list_document_revisions:{action:"list",running:"Listing document revisions",completed:"Listed document revisions"},report_progress:{action:"post",running:"Reporting progress",completed:"Reported progress"},answer_status_question:{action:"post",running:"Answering a status question",completed:"Answered a status question"},write_document:{action:"update",running:"Writing a document",completed:"Wrote a document"},register_deliverable:{action:"create",running:"Registering a deliverable",completed:"Registered a deliverable"},finish_task:{action:"finish",running:"Reporting completion",completed:"Reported completion"},paperclip_finish:{action:"finish",running:"Reporting completion",completed:"Reported completion"},block_task:{action:"block",running:"Reporting a blocker",completed:"Reported a blocker"},paperclip_block:{action:"block",running:"Reporting a blocker",completed:"Reported a blocker"},request_review:{action:"request",running:"Requesting review",completed:"Requested review"},list_agents:{action:"list",running:"Listing agents",completed:"Listed agents"},get_agent:{action:"read",running:"Reading agent details",completed:"Read agent details"},search_tasks:{action:"search",running:"Searching tasks",completed:"Searched tasks"},list_approvals:{action:"list",running:"Listing approvals",completed:"Listed approvals"},get_approval:{action:"read",running:"Reading an approval",completed:"Read an approval"},get_approval_context:{action:"read",running:"Reading approval context",completed:"Read approval context"},get_workspace_runtime:{action:"read",running:"Reading workspace status",completed:"Read workspace status"},control_workspace_service:{action:"run",running:"Controlling a workspace service",completed:"Controlled a workspace service"},set_dependencies:{action:"update",running:"Updating task dependencies",completed:"Updated task dependencies"},create_task:{action:"create",running:"Creating a task",completed:"Created a task"},request_approval:{action:"request",running:"Requesting approval",completed:"Requested approval"},decide_approval:{action:"update",running:"Deciding an approval",completed:"Decided an approval"},comment_on_approval:{action:"post",running:"Commenting on an approval",completed:"Commented on an approval"},schedule_wake:{action:"create",running:"Scheduling a wake-up",completed:"Scheduled a wake-up",family:"wait"},generic_api_request:{action:"request",running:"Calling the Paperclip API",completed:"Called the Paperclip API"}},yXe={read:["get","read","inspect","view"],list:["list","glob"],search:["find","search","grep","query","lookup"],fetch:["fetch","browse"],open:["open"],update:["write","edit","update","set","patch","upsert","sync"],create:["create","add","register","upload"],delete:["delete","remove"],move:["move","rename"],run:["run","execute","bash","shell","command"],request:["request","ask","prompt"],post:["send","message","comment","report","answer"],start:["start","spawn","delegate"],stop:["stop","cancel","interrupt"],wait:["wait","sleep","poll"],finish:["finish","complete"],block:["block"],think:["think","reason","compact","review"],switch:["switch","enter","exit"],other:[]},jXe={read:"read",edit:"update",delete:"delete",move:"move",search:"search",list:"list",execute:"run",think:"think",fetch:"fetch",switch_mode:"switch"};function wXe(e){return MK(e).join("_")}r(wXe,"normalizedKey");function NXe(e){const s=e[0];if(!s)return null;for(const[n,a]of Object.entries(yXe))if(a.includes(s))return n;return null}r(NXe,"inferredAction");function kXe(e){return e==="run"?"terminal":e==="read"||e==="list"?"read":e==="search"?"search":e==="fetch"||e==="open"?"web":["update","create","delete","move"].includes(e)?"edit":e==="request"?"question":e==="start"||e==="stop"?"agent":e==="wait"?"wait":"other"}r(kXe,"actionFamily");var SXe={terminal:Hb,grep:KEe,search:ua,read:sN,edit:I5,web:b3e,plan:k1,question:ud,agent:Gb,safety:Ii,image:R5,wait:sh,mcp:gXe,other:jx};function CXe(e,s){const n=s?` ${s}`:"";switch(e){case"read":return{running:`Reading${n||" data"}`,completed:`Read${n||" data"}`};case"list":return{running:`Listing${n||" items"}`,completed:`Listed${n||" items"}`};case"search":return{running:`Searching${n||""}`,completed:`Searched${n||""}`};case"fetch":return{running:`Fetching${n||" data"}`,completed:`Fetched${n||" data"}`};case"open":return{running:`Opening${n||" an item"}`,completed:`Opened${n||" an item"}`};case"update":return{running:`Updating${n||" data"}`,completed:`Updated${n||" data"}`};case"create":return{running:`Creating${n||" an item"}`,completed:`Created${n||" an item"}`};case"delete":return{running:`Deleting${n||" an item"}`,completed:`Deleted${n||" an item"}`};case"move":return{running:`Moving${n||" an item"}`,completed:`Moved${n||" an item"}`};case"run":return{running:"Running a command",completed:"Ran a command"};case"request":return{running:`Requesting${n||" input"}`,completed:`Requested${n||" input"}`};case"post":return{running:`Posting${n||" an update"}`,completed:`Posted${n||" an update"}`};case"start":return{running:`Starting${n||" an operation"}`,completed:`Started${n||" an operation"}`};case"stop":return{running:`Stopping${n||" an operation"}`,completed:`Stopped${n||" an operation"}`};case"wait":return{running:"Waiting",completed:"Finished waiting"};case"finish":return{running:"Reporting completion",completed:"Reported completion"};case"block":return{running:"Reporting a blocker",completed:"Reported a blocker"};case"think":return{running:"Thinking",completed:"Finished thinking"};case"switch":return{running:`Switching${n||" mode"}`,completed:`Switched${n||" mode"}`};case"other":return{running:"Running",completed:"Ran"}}}r(CXe,"actionCopy");function _Xe(e){switch(e){case"run":return ad("command","command","commands");case"read":case"list":return ad("read","read","reads");case"search":return ad("search","search","searches");case"update":case"create":case"delete":case"move":return ad("file_change","file change","file changes");case"start":case"stop":return ad("delegation","delegation","delegations");case"wait":return ad("wait","wait","waits");default:return ad("tool_action","tool action","tool actions")}}r(_Xe,"defaultSummaryGroup");function IXe(e){return e==="read"||e==="list"?ad("paperclip_read","Paperclip read","Paperclip reads"):ad("task_operation","task operation","task operations")}r(IXe,"paperclipSummaryGroup");function av(e){const s=(e.name??"").trim(),n=PK(s),a=(e.namespace??n?.namespace??"").trim(),i=(n?"mcp":e.transport??"builtin").toLowerCase(),o=(n?.name??s).trim(),l=MK(o),c=wXe(o),d=vXe[c],m=jXe[(e.operation??"").trim().toLowerCase()],h=NXe(l),p=d?.action??m??h??"other",f=d?"exact":m?"kind":h?"inferred":Rd(o)?"unnamed":"fallback",g=Rd(o)?"Unnamed tool":qj(o),v=/^[A-Za-z][A-Za-z0-9_.:-]*$/.test(o),y=h&&v&&l.length>1?l.slice(1):[],w=y.length?Sge(y).replace(/^./,C=>C.toLowerCase()):void 0,S=d?.running&&d.completed?{running:d.running,completed:d.completed}:p==="other"?Rd(o)?{running:"Running an unnamed tool",completed:"Ran an unnamed tool"}:{running:`Running ${g}`,completed:`Ran ${g}`}:CXe(p,d?void 0:w),j=d?.family??kXe(p),N=i==="mcp"?"mcp":j,_=a?qj(a):i==="mcp"?"MCP":void 0,R=a.toLowerCase()==="paperclip"?IXe(p):d?.group??_Xe(p);return{icon:SXe[N],family:N,runningLabel:S.running,completedLabel:S.completed,failedLabel:`${S.completed} · failed`,interruptedLabel:`${S.running} · stopped`,displayName:g,sourceLabel:_,technicalName:s||void 0,confidence:f,summaryGroup:R}}r(av,"toolActivityPresentation");function bE(e){const s=av({name:e});return{family:s.family,icon:s.icon,verbLabel:s.runningLabel}}r(bE,"toolTaxonomy");function AXe(e){const s=(e??"").trim().toLowerCase();return s==="thinking"?Mg:s==="responding"||s.startsWith("responding (")?nEe:null}r(AXe,"statusLabelIcon");var aD=["Clipping","Organizing","Sorting","Synthesizing","Analyzing","Filing","Collating","Stapling","Indexing","Annotating","Drafting","Proofreading","Alphabetizing","Photocopying","Laminating","Hole-punching","Bookmarking","Highlighting","Typing","Trimming","Aligning","Combining","Whiteboarding","Diagramming","Sketching","Labeling","Sticky-noting"],iD=["Brewing","Tinkering","Distilling","Deliberating"],sX=(()=>{const e=[],s=Math.max(aD.length,iD.length);for(let n=0;n<s;n++)n<aD.length&&e.push(aD[n]),n<iD.length&&e.push(iD[n]);return e})(),RXe=1e4;function TXe(e){const s=(e??"").trim().toLowerCase();return s==="running"||s==="working"}r(TXe,"isGenericStatusLabel");function EXe(e){let s=2166136261;for(let n=0;n<e.length;n++)s^=e.charCodeAt(n),s=Math.imul(s,16777619);return s>>>0}r(EXe,"fnv1a");function PXe(e,s=0){const n=Math.floor(Math.max(0,s)/RXe);return sX[(EXe(e)+n)%sX.length]}r(PXe,"whimsyWord");var MXe=[{name:"--motion-ease-out-expo",group:"Easing",kind:"easing"},{name:"--motion-ease-standard",group:"Easing",kind:"easing"},{name:"--motion-ease-out",group:"Easing",kind:"easing"},{name:"--motion-ease-scroll-pill-in",group:"Easing",kind:"easing"},{name:"--motion-ease-scroll-pill-out",group:"Easing",kind:"easing"},{name:"--motion-ease-in",group:"Easing",kind:"easing"},{name:"--motion-duration-instant",group:"Durations",kind:"time",min:0,max:1e3,step:10},{name:"--motion-duration-fast",group:"Durations",kind:"time",min:0,max:1e3,step:10},{name:"--motion-duration-base",group:"Durations",kind:"time",min:0,max:1e3,step:10},{name:"--motion-duration-slow",group:"Durations",kind:"time",min:0,max:1500,step:10},{name:"--motion-duration-deliberate",group:"Durations",kind:"time",min:0,max:2e3,step:10},{name:"--motion-duration-enter",group:"Durations",kind:"time",min:0,max:1e3,step:10},{name:"--motion-duration-exit",group:"Durations",kind:"time",min:0,max:1e3,step:10},{name:"--motion-duration-swap",group:"Durations",kind:"time",min:0,max:1e3,step:10},{name:"--motion-marker-enter",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-bubble-enter",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-cot-line-stagger",group:"States",kind:"time",min:0,max:300,step:5},{name:"--motion-cot-collapse",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-tool-enter",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-diff-reveal",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-status-enter",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-status-exit",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-approval-pulse",group:"States",kind:"time",min:0,max:3e3,step:20},{name:"--motion-plan-entry-stagger",group:"States",kind:"time",min:0,max:300,step:5},{name:"--motion-plan-check",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-question-page-enter",group:"States",kind:"time",min:0,max:1e3,step:10},{name:"--motion-count-tween",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-streaming-cursor-blink",group:"States",kind:"time",min:0,max:3e3,step:20},{name:"--motion-turn-fold",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-turn-meta",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-line-scroll",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-interstitial-dwell",group:"States",kind:"time",min:0,max:1e4,step:100},{name:"--motion-scroll-pill-enter",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-scroll-pill-exit",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-scrollbar-idle-delay",group:"States",kind:"time",min:0,max:2e3,step:10},{name:"--motion-pane-glide",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-side-panel-tab",group:"States",kind:"time",min:0,max:1500,step:10}],$7t=Array.from(new Set(MXe.map(e=>e.group)));function Cge(e){const s=e.trim();if(s.endsWith("ms"))return parseFloat(s);if(s.endsWith("s"))return parseFloat(s)*1e3;const n=parseFloat(s);return Number.isFinite(n)?n:0}r(Cge,"parseCssTimeMs");function DXe(e){if(e==null)return null;const s=Math.round(e/1e3);return s<60?`${s}s`:`${Math.floor(s/60)}m ${s%60}s`}r(DXe,"elapsedLabel");function LXe(e){if(e==null)return null;const s=Math.max(0,e)/1e3;return s<60?`${s.toFixed(1)}s`:`${Math.floor(s/60)}m ${(s%60).toFixed(1)}s`}r(LXe,"liveElapsedLabel");function $Xe(e,s){const[n,a]=(0,u.useState)(()=>Date.now());return(0,u.useEffect)(()=>{if(e==null||!s)return;const i=window.setInterval(()=>a(Date.now()),100);return()=>window.clearInterval(i)},[e,s]),e==null?void 0:Math.max(0,n-e)}r($Xe,"useLiveElapsedMs");function OXe(e,s){return!Number.isFinite(e)||!Number.isFinite(s)||s<=0?0:Math.max(0,Math.round(e/s)-1)}r(OXe,"lineScrollOffset");function F2(e){const s=getComputedStyle(document.documentElement).getPropertyValue(e),n=Cge(s);return Number.isFinite(n)?n:0}r(F2,"motionTokenMs");function FXe({text:e,streaming:s,leaving:n}){const a=(0,u.useRef)(null),[i,o]=(0,u.useState)(0),[l,c]=(0,u.useState)(!1),[d,m]=(0,u.useState)(!1);(0,u.useLayoutEffect)(()=>{const p=a.current;if(!p)return;const f=r(()=>{const v=parseFloat(window.getComputedStyle(p).lineHeight);o(OXe(p.scrollHeight,v))},"measure");if(f(),typeof ResizeObserver>"u")return;const g=new ResizeObserver(f);return g.observe(p),()=>g.disconnect()},[e,s]),(0,u.useEffect)(()=>{const p=requestAnimationFrame(()=>c(!0)),f=window.setTimeout(()=>m(!0),F2("--motion-line-scroll"));return()=>{cancelAnimationFrame(p),window.clearTimeout(f)}},[]);const h=l?n?-1:s?-i:0:1;return(0,t.jsx)("span",{className:"tc-line-scroll min-w-0 flex-1","data-testid":"task-chat-live-self-talk","data-streaming":s||void 0,"data-leaving":n||void 0,children:(0,t.jsx)("span",{ref:a,className:U("tc-line-scroll-inner block",!s&&"truncate"),style:{transform:h!==0?`translateY(calc(${h} * 1lh))`:void 0,transition:d&&!n?"none":void 0},children:e})})}r(FXe,"LiveSelfTalkLine");function BXe(e,s){const[n,a]=(0,u.useState)(null),i=(0,u.useRef)(n),o=(0,u.useRef)(null),l=(0,u.useRef)(e),c=(0,u.useRef)(0),d=(0,u.useRef)(null),m=(0,u.useRef)(null),h=(0,u.useRef)(null);return l.current=e,(0,u.useEffect)(()=>{const p=r(w=>{w.current!=null&&(window.clearTimeout(w.current),w.current=null)},"clear"),f=r(w=>{i.current=w,a(w)},"show"),g=r(()=>{p(m),p(h),m.current=window.setTimeout(()=>{if(m.current=null,o.current!=null)return;const w=i.current;w==null||w.streaming||(f({...w,leaving:!0}),h.current=window.setTimeout(()=>{h.current=null,i.current?.leaving&&f(null)},F2("--motion-line-scroll")))},F2("--motion-interstitial-dwell"))},"scheduleLeave"),v=r((w,S)=>{p(m),p(h),c.current=Date.now(),f({text:w,streaming:S,swapKey:(i.current?.swapKey??0)+1}),S||g()},"swapIn");if(!s){p(d),p(m),p(h),o.current=null,i.current&&f(null);return}const y=i.current;if(e==null){y?.streaming&&(f({...y,streaming:!1}),g());return}if(y==null){v(e,!0);return}if(y.streaming){y.text!==e&&f({...y,text:e});return}if(o.current=e,d.current==null){const w=F2("--motion-interstitial-dwell"),S=Math.max(0,c.current+w-Date.now());d.current=window.setTimeout(()=>{d.current=null;const j=o.current;o.current=null,j!=null&&v(j,l.current!=null)},S)}},[e,s]),(0,u.useEffect)(()=>()=>{d.current!=null&&window.clearTimeout(d.current),m.current!=null&&window.clearTimeout(m.current),h.current!=null&&window.clearTimeout(h.current)},[]),n}r(BXe,"useHeldSelfTalk");var qXe={running:{Icon:at,spin:!0,tone:"text-(--status-agent-running)"},working:{Icon:at,spin:!0,tone:"text-(--status-agent-running)"},awaiting_approval:{Icon:rN,spin:!1,tone:"text-primary"},interrupted:{Icon:zz,spin:!1,tone:"text-destructive"},refused:{Icon:Wu,spin:!1,tone:"text-destructive"},truncated:{Icon:BEe,spin:!1,tone:"text-(--status-agent-paused)"}};function _ge({item:e,onApprovalDecision:s,chevronOpen:n,onToggle:a}){const{Icon:i,spin:o,tone:l}=qXe[e.status],c=e.status==="awaiting_approval",d=e.status==="running"||e.status==="working",m=$Xe(e.startedAtMs,d),h=BXe(d?e.selfTalk:void 0,d),p=DXe(e.elapsedMs);if(d){const f=LXe(m??e.elapsedMs),g=e.selfTalk!=null,v=e.toolName?bE(e.toolName).icon:g?null:AXe(e.label),y=g||TXe(e.label)?PXe(e.id,m??e.elapsedMs??0):e.label,w=(0,t.jsxs)("div",{className:"tc-enter-status flex items-center gap-2 py-0.5 text-xs text-muted-foreground",children:[n!==void 0?(0,t.jsx)("span",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center","data-testid":"task-chat-status-caret-slot",children:(0,t.jsx)(Tn,{className:U("h-3 w-3 transition-transform",n?"rotate-90":null),"aria-hidden":!0})}):null,(0,t.jsx)("span",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center","data-testid":"task-chat-status-dot-slot",children:(0,t.jsx)("span",{"aria-hidden":!0,className:"h-2 w-2 animate-pulse rounded-full bg-(--status-agent-running)"})}),v?(0,t.jsx)(v,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}):null,(0,t.jsxs)("span",{className:"flex min-w-0 flex-1 items-baseline gap-2",children:[(0,t.jsxs)("span",{className:"shimmer-text shimmer-text-muted shrink-0 font-medium",children:[y,"…"]}),f?(0,t.jsx)("span",{className:"shrink-0 font-mono tabular-nums text-(length:--text-micro)",children:f}):null,e.detail?(0,t.jsx)("span",{className:"min-w-0 truncate font-mono text-(length:--text-micro)",children:e.detail}):null,e.tokens?(0,t.jsxs)("span",{className:"ml-auto shrink-0 font-mono text-(length:--text-micro)",children:[e.tokens.used.toLocaleString(),"/",e.tokens.size.toLocaleString()," ctx"]}):null]})]});return(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 py-0.5 text-xs text-muted-foreground","data-testid":"task-chat-interstitial-row",children:[(0,t.jsx)("span",{"aria-hidden":!0,className:"h-3.5 w-3.5 shrink-0"}),h?(0,t.jsx)(FXe,{text:h.text,streaming:h.streaming,leaving:h.leaving},h.swapKey):(0,t.jsx)("span",{"aria-hidden":!0,className:"tc-line-scroll min-w-0 flex-1"})]}),a?(0,t.jsx)("button",{type:"button",onClick:a,"aria-expanded":n,className:"-mx-1.5 block w-full rounded-sm px-1.5 text-left transition-colors hover:bg-muted/60","data-testid":"task-chat-live-turn",children:w}):w]})}return(0,t.jsxs)("div",{className:U("tc-enter-status flex flex-col gap-2 rounded-lg border px-3 py-2 text-sm",c?"tc-approval border-primary/40 bg-primary/5":"border-border bg-muted/40"),children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,t.jsx)(i,{className:U("h-4 w-4 shrink-0",l,o&&"animate-spin")}),(0,t.jsx)("span",{className:"min-w-0 truncate font-medium",children:e.label}),(0,t.jsxs)("span",{className:"ml-auto flex shrink-0 items-center gap-2 text-xs text-muted-foreground",children:[p?(0,t.jsx)("span",{children:p}):null,e.tokens?(0,t.jsxs)("span",{children:[e.tokens.used.toLocaleString(),"/",e.tokens.size.toLocaleString()," ctx"]}):null]})]}),e.detail?(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:e.detail}):null,c&&e.approval?(0,t.jsx)("div",{className:"flex flex-wrap justify-end gap-2 pt-1",children:e.approval.options.map(f=>{const g=f.kind.startsWith("reject");return(0,t.jsx)("button",{type:"button",onClick:r(()=>s?.(f.id),"onClick"),className:U("rounded-md border px-2.5 py-1 text-xs font-medium transition-colors",g?"border-border text-muted-foreground hover:bg-accent/50 hover:text-foreground":"border-primary bg-primary text-primary-foreground hover:bg-primary/90"),children:f.label},f.id)})}):null]})}r(_ge,"TaskChatStatusPill");function Ige(e,s){const n=URL.createObjectURL(s),a=document.createElement("a");a.href=n,a.download=e,a.rel="noreferrer",a.style.display="none",document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(n)}r(Ige,"downloadBlob$1");function zXe(e,s,n){Ige(e,new Blob([s],{type:`${n};charset=utf-8`}))}r(zXe,"downloadTextFile");var oD="flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-50";function Age({issueId:e,documentKey:s,title:n,format:a,body:i,className:o}){const[l,c]=(0,u.useState)(null),[d,m]=(0,u.useState)(null),[h,p]=(0,u.useState)(null),{copy:f,copied:g,failed:v}=hf(),y=(0,u.useRef)(void 0);(0,u.useEffect)(()=>()=>clearTimeout(y.current),[]);const w=(0,u.useCallback)(async(C,A)=>{c(C),p(null);try{await A(),m(C)}catch(T){m(null),p(T instanceof Error?T.message:"Export failed")}finally{c(null)}clearTimeout(y.current),y.current=setTimeout(()=>{m(null),p(null)},2e3)},[]),S=(0,u.useCallback)(async()=>i??(await Rt.getDocument(e,s)).body,[i,s,e]),j=(0,u.useCallback)(()=>{c("copy"),p(null),(async()=>{try{await f(await S())==="failed"&&p("Copy failed")}catch(C){p(C instanceof Error?C.message:"Copy failed")}finally{c(null)}})()},[f,S]),N=v||h==="Copy failed"?"Copy failed":g?"Copied!":"Copy full content",_=d==="download"?"Downloaded!":"Download source",R=d==="pdf"?"Downloaded!":"Export to PDF";return(0,t.jsxs)("div",{className:U("flex items-center gap-0.5",o),"data-testid":"document-export-actions",children:[(0,t.jsx)("button",{type:"button",className:oD,disabled:l!==null,"aria-label":"Copy full content",title:N,"data-testid":"document-export-copy",onClick:r(C=>{C.preventDefault(),C.stopPropagation(),j()},"onClick"),children:g?(0,t.jsx)(ds,{"aria-hidden":"true",className:"h-3.5 w-3.5"}):(0,t.jsx)(Nr,{"aria-hidden":"true",className:"h-3.5 w-3.5"})}),(0,t.jsx)("button",{type:"button",className:oD,disabled:l!==null,"aria-label":"Download source",title:_,"data-testid":"document-export-download",onClick:r(C=>{C.preventDefault(),C.stopPropagation(),w("download",async()=>{const A=BRe(a);zXe(CH(n,A),await S(),A==="md"?"text/markdown":"text/plain")})},"onClick"),children:(0,t.jsx)(Uo,{"aria-hidden":"true",className:"h-3.5 w-3.5"})}),(0,t.jsx)("button",{type:"button",className:oD,disabled:l!==null,"aria-label":"Export to PDF",title:R,"data-testid":"document-export-pdf",onClick:r(C=>{C.preventDefault(),C.stopPropagation(),w("pdf",async()=>{Ige(CH(n,"pdf"),await Rt.getDocumentPdf(e,s))})},"onClick"),children:(0,t.jsx)(e5e,{"aria-hidden":"true",className:"h-3.5 w-3.5"})}),(0,t.jsx)("span",{className:"sr-only",role:"status","aria-live":"polite",children:h??(g?"Copied!":v?"Copy failed":d?"Downloaded!":"")})]})}r(Age,"DocumentExportActions");function NC({children:e,className:s}){return(0,t.jsx)("div",{className:U("relative aspect-video w-full overflow-hidden bg-accent/20",s),children:e})}r(NC,"PreviewFrame");function HT({label:e}){return(0,t.jsx)(NC,{className:"flex items-center justify-center",children:(0,t.jsxs)("div",{className:"flex flex-col items-center gap-1.5 text-muted-foreground/50",children:[(0,t.jsx)(Vl,{className:"h-7 w-7","aria-hidden":"true"}),e?(0,t.jsx)("span",{className:"text-(length:--text-micro) font-medium uppercase tracking-wide",children:e}):null]})})}r(HT,"PlaceholderPreview");function UXe({artifact:e}){const[s,n]=(0,u.useState)(!1);return s||!e.contentPath?(0,t.jsx)(HT,{label:"Image"}):(0,t.jsx)(NC,{children:(0,t.jsx)("img",{src:e.contentPath,alt:e.title,loading:"lazy",className:"h-full w-full object-cover",onError:r(()=>n(!0),"onError")})})}r(UXe,"ImagePreview");function KXe({artifact:e}){const[s,n]=(0,u.useState)(!1),[a,i]=(0,u.useState)(!1),o=(0,u.useRef)(!1),l=(0,u.useRef)(null);if((0,u.useEffect)(()=>()=>{l.current!==null&&window.clearTimeout(l.current)},[]),s||!e.contentPath)return(0,t.jsx)(NC,{className:"flex items-center justify-center bg-black/80",children:(0,t.jsx)("div",{className:"flex h-11 w-11 items-center justify-center rounded-full bg-white/15",children:(0,t.jsx)(So,{className:"h-5 w-5 translate-x-0.5 text-white","aria-hidden":"true"})})});const c=r(()=>{l.current!==null&&(window.clearTimeout(l.current),l.current=null),i(!0)},"markFrameReady"),d=r(()=>{l.current!==null&&window.clearTimeout(l.current),l.current=window.setTimeout(c,3e3)},"scheduleFrameReadyFallback"),m=r(p=>{if(o.current)return;o.current=!0;const f=p.currentTarget,g=Number.isFinite(f.duration)&&f.duration>0?f.duration:0,v=g>0?Math.min(1,g/4):.05;try{Math.abs(f.currentTime-v)>.001?(f.currentTime=v,d()):c()}catch{c()}},"loadThumbnailFrame"),h=r(p=>{(o.current||p.currentTarget.currentTime>0)&&c()},"handleLoadedData");return(0,t.jsxs)(NC,{className:"bg-black",children:[(0,t.jsx)("video",{src:e.contentPath,preload:"metadata",muted:!0,playsInline:!0,"data-frame-ready":a?"true":"false",className:U("h-full w-full object-contain transition-opacity",a?"opacity-100":"opacity-0"),onLoadedMetadata:m,onLoadedData:h,onSeeked:c,onError:r(()=>n(!0),"onError")}),(0,t.jsx)("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:(0,t.jsx)("div",{className:"flex h-11 w-11 items-center justify-center rounded-full bg-black/55",children:(0,t.jsx)(So,{className:"h-5 w-5 translate-x-0.5 text-white","aria-hidden":"true"})})})]})}r(KXe,"VideoPreview");function VXe({artifact:e}){const s=e.previewText?.trim();return s?(0,t.jsxs)(NC,{className:"bg-card",children:[(0,t.jsx)("div",{className:"absolute inset-0 overflow-hidden p-3",children:(0,t.jsx)("p",{className:"max-h-full overflow-hidden whitespace-pre-wrap break-words text-base leading-6 text-muted-foreground/75",children:s})}),(0,t.jsx)("div",{className:"pointer-events-none absolute bottom-0 left-0 right-0 h-10 bg-gradient-to-t from-card to-transparent"})]}):(0,t.jsx)(HT,{label:e.source==="document"?"Document":"Text"})}r(VXe,"TextPreview");function z1({artifact:e}){switch(e.mediaKind){case"image":return(0,t.jsx)(UXe,{artifact:e},e.contentPath);case"video":return(0,t.jsx)(KXe,{artifact:e},e.contentPath);case"text":case"document":return(0,t.jsx)(VXe,{artifact:e});case"file":return(0,t.jsx)(HT,{label:"File"});default:return(0,t.jsx)(HT,{})}}r(z1,"ArtifactPreview");function nX({href:e,download:s,title:n,children:a}){return(0,t.jsx)("a",{href:e,...s?{download:""}:{target:"_blank",rel:"noreferrer"},title:n,"aria-label":n,onClick:r(i=>i.stopPropagation(),"onClick"),className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:a})}r(nX,"SecondaryAction");function WXe({artifact:e}){return(0,t.jsxs)(Je,{to:e.href,disableIssueQuicklook:!0,"data-testid":"artifact-card","data-media-kind":e.mediaKind,className:"group flex flex-col overflow-hidden rounded-lg border border-border bg-card cursor-pointer transition-colors hover:border-foreground/20 hover:shadow-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,t.jsx)(z1,{artifact:e}),(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1 p-3",children:[(0,t.jsxs)("div",{className:"flex h-7 items-start justify-between gap-2",children:[(0,t.jsx)("h3",{className:"min-w-0 flex-1 truncate text-sm font-medium leading-7 text-foreground/85",title:e.title,children:e.title}),(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100",children:[e.source==="document"&&e.documentKey?(0,t.jsx)(Age,{issueId:e.issue.id,documentKey:e.documentKey,title:e.title}):null,e.openPath?(0,t.jsx)(nX,{href:e.openPath,title:"Open file in new tab",children:(0,t.jsx)(xr,{className:"h-3.5 w-3.5"})}):null,e.downloadPath?(0,t.jsx)(nX,{href:e.downloadPath,download:!0,title:"Download file",children:(0,t.jsx)(Uo,{className:"h-3.5 w-3.5"})}):null]})]}),(0,t.jsxs)("div",{className:"mt-0.5 flex items-center gap-1.5 text-(length:--text-micro) text-muted-foreground/65",children:[(0,t.jsxs)("span",{children:["Last edited ",pu(e.updatedAt)]}),e.createdByAgent?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"text-muted-foreground/50",children:"·"}),(0,t.jsx)("span",{className:"truncate",children:e.createdByAgent.name})]}):null]})]})]})}r(WXe,"ArtifactCard");function mN(e){if(!Number.isFinite(e)||e<0)return"0 B";if(e<1024)return`${Math.round(e)} B`;const s=["KB","MB","GB","TB"];let n=e/1024,a=0;for(;n>=1024&&a<s.length-1;)n/=1024,a+=1;const i=n.toFixed(1);return`${i.endsWith(".0")?i.slice(0,-2):i} ${s[a]}`}r(mN,"formatBytes$4");var QT=new Set(["application/octet-stream","binary/octet-stream","application/x-binary"]),HXe=[".mp4",".m4v",".webm",".mov",".qt",".quicktime"],QXe=[".png",".jpg",".jpeg",".gif",".webp",".avif",".bmp",".svg",".ico"],GXe=new Set(["application/wasm"]),YXe=new Set(["application/zip","application/x-zip","application/x-zip-compressed"]),Rge=new Set(["text/markdown","text/x-markdown","application/markdown","application/x-markdown"]),JXe=new Set(["application/csv","application/ecmascript","application/graphql","application/html","application/javascript","application/json","application/ld+json","application/sql","application/toml","application/x-httpd-php","application/x-javascript","application/x-python","application/x-sh","application/x-yaml","application/xhtml+xml","application/xml","application/yaml"]),XXe=[".csv",".css",".graphql",".htm",".html",".js",".json",".jsx",".log",".markdown",".md",".mdx",".php",".py",".sh",".sql",".toml",".ts",".tsx",".txt",".xml",".yaml",".yml"];function U1(e){return(e??"").toLowerCase().split(";")[0]?.trim()??""}r(U1,"normalizeOutputContentType");function ZXe(e){const s=(e??"").trim().toLowerCase();return s?XXe.some(n=>s.endsWith(n)):!1}r(ZXe,"hasDocumentLikeFilename");function Tge(e){return YXe.has(e)||e.endsWith("+zip")}r(Tge,"isZipContentType");function eZe(e){return e?!!(e.startsWith("text/")||Rge.has(e)||JXe.has(e)||e.startsWith("application/")&&(e.endsWith("+json")||e.endsWith("+xml"))):!1}r(eZe,"isDocumentLikeOutputContentType");function tZe(e,s){const n=U1(e);return!n||eZe(n)||QT.has(n)&&ZXe(s)?!1:n.startsWith("video/")||n.startsWith("image/")||n==="application/pdf"||GXe.has(n)||Tge(n)||QT.has(n)}r(tZe,"isOutputEligibleContentType");function sZe(e){const s=U1(e);if(s.startsWith("video/")){const n=s.slice(6);return n==="quicktime"?{label:"MOV",tone:"video"}:{label:(n||"vid").toUpperCase().slice(0,4),tone:"video"}}return s==="application/pdf"?{label:"PDF",tone:"pdf"}:Tge(s)?{label:"ZIP",tone:"zip"}:s.startsWith("image/")?{label:"IMG",tone:"image"}:Rge.has(s)?{label:"MD",tone:"bin"}:s==="text/plain"?{label:"TXT",tone:"bin"}:s==="text/csv"||s==="application/csv"?{label:"CSV",tone:"bin"}:s==="text/html"||s==="application/html"||s==="application/xhtml+xml"?{label:"HTML",tone:"bin"}:s==="application/json"||s.endsWith("+json")?{label:"JSON",tone:"bin"}:s==="application/xml"||s==="text/xml"||s.endsWith("+xml")?{label:"XML",tone:"bin"}:s==="application/wasm"?{label:"WASM",tone:"bin"}:{label:"BIN",tone:"bin"}}r(sZe,"getOutputFileGlyph");function ju(e,s){const n=U1(e);if(n.startsWith("video/"))return!0;if(!QT.has(n))return!1;const a=(s??"").trim().toLowerCase();return HXe.some(i=>a.endsWith(i))}r(ju,"isVideoLikeOutput");function _w(e){return U1(e).startsWith("image/")}r(_w,"isImageContentType");function vE(e,s){const n=U1(e);if(_w(n))return!0;if(n&&!QT.has(n))return!1;const a=(s??"").trim().toLowerCase();return QXe.some(i=>a.endsWith(i))}r(vE,"isImageLikeOutput");function rX(e){const s=new Date(e).getTime();return Number.isNaN(s)?0:s}r(rX,"toTime");function yE(e){const s=(e??[]).filter(n=>n.type==="artifact"&&n.provider==="paperclip").flatMap(n=>{const a=aAe.safeParse(n.metadata);return a.success&&!tZe(a.data.contentType,a.data.originalFilename)?[]:[{id:n.id,title:n.title,status:typeof n.status=="string"?n.status:"active",isPrimary:!!n.isPrimary,createdAt:n.createdAt,metadata:a.success?a.data:null,degraded:!a.success,workProduct:n}]});return s.sort((n,a)=>n.isPrimary!==a.isPrimary?n.isPrimary?-1:1:rX(a.createdAt)-rX(n.createdAt)),{items:s,primary:s[0]??null,rest:s.slice(1),count:s.length}}r(yE,"getIssueOutputs");function DK(e){return e.metadata?.originalFilename||e.title||"output"}r(DK,"outputFilename");function Ege(e){return new Set(yE(e).items.flatMap(s=>{const n=s.metadata?.attachmentId;return n?[n]:[]}))}r(Ege,"getPromotedOutputAttachmentIds");var jh={connect:r((e,s)=>Re.post(`/companies/${e}/email/connections`,s),"connect"),inspectSaved:r((e,s)=>Re.post(`/companies/${e}/email/connections/${s}/inspect`,{}),"inspectSaved"),list:r(e=>Re.get(`/companies/${e}/email/inboxes`),"list"),setup:r((e,s)=>Re.post(`/companies/${e}/email/inboxes`,s),"setup"),inspect:r((e,s)=>Re.post(`/companies/${e}/email/inspect`,{apiKey:s}),"inspect"),control:r((e,s)=>Re.post(`/email/inboxes/${e}/control`,{action:s}),"control"),reconnect:r((e,s,n)=>Re.post(`/email/inboxes/${e}/reconnect`,{apiKey:s,receiveMode:n}),"reconnect"),resolve:r((e,s,n,a)=>Re.post(`/companies/${e}/email/deliveries/${s}/resolve`,{outcome:n,providerMessageId:a}),"resolve"),thread:r((e,s)=>Re.get(`/companies/${e}/email/tasks/${s}`),"thread"),send:r((e,s)=>Re.post(`/companies/${e}/email/send`,s),"send")},Pge=(0,u.createContext)(null);function nZe({companyId:e,issueId:s,children:n}){const{enabled:a}=$x(),i=Z({queryKey:["email-thread",e,s],queryFn:r(()=>jh.thread(e,s),"queryFn"),enabled:a,refetchInterval:a?3e3:!1});return(0,t.jsx)(Pge.Provider,{value:i.data??null,children:n})}r(nZe,"EmailThreadProvider");function Mge(e){const s=(0,u.useContext)(Pge),n=s?.messages.find(a=>a.commentId===e);return n&&s?(0,t.jsx)(Dge,{message:n,publication:s.publications.find(a=>a.providerMessageId===n.providerMessageId),issueId:s.issueId}):null}r(Mge,"useEmailComment");function Dge({message:e,publication:s,issueId:n}){const a=Z({queryKey:["email-attachments",n],queryFn:r(()=>Rt.listAttachments(n),"queryFn"),enabled:e.attachmentIds.length>0});return(0,t.jsxs)("article",{"aria-label":e.direction==="inbound"?"Email received":"Email sent",className:"space-y-4 rounded-xl border border-border bg-card p-5",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,t.jsxs)("span",{className:"flex items-center gap-2 text-sm font-semibold",children:[(0,t.jsx)(Bce,{className:"size-4"}),e.direction==="inbound"?"Email received":"Email sent"]}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:new Date(e.timestamp).toLocaleString()})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsxs)("p",{className:"text-sm font-medium",children:[e.from,e.direction==="inbound"&&(0,t.jsx)("span",{className:"ml-2 rounded-md bg-muted px-2 py-1 text-xs text-muted-foreground",children:"External"})]}),(0,t.jsxs)("p",{className:"break-words text-xs text-muted-foreground",children:["To: ",e.to.join(", ")]}),!!e.cc?.length&&(0,t.jsxs)("p",{className:"break-words text-xs text-muted-foreground",children:["Cc: ",e.cc.join(", ")]}),(0,t.jsx)("p",{className:"text-sm font-semibold",children:e.subject})]}),(0,t.jsx)("div",{className:"whitespace-pre-wrap break-words text-sm",children:e.text||"(No text body)"}),!!e.attachmentIds.length&&(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:e.attachmentIds.map(i=>{const o=a.data?.find(l=>l.id===i);return(0,t.jsxs)("a",{href:`/api/attachments/${i}/content`,target:"_blank",rel:"noreferrer",className:"flex items-center gap-2 rounded-md border border-border px-3 py-2 text-xs",children:[(0,t.jsx)(Vl,{className:"size-3.5"}),o?.originalFilename??"Open attachment"]},i)})}),(0,t.jsxs)("details",{className:"text-xs text-muted-foreground",children:[(0,t.jsx)("summary",{className:"cursor-pointer",children:"Email details"}),(0,t.jsxs)("div",{className:"space-y-2 pt-3",children:[!!e.bcc?.length&&(0,t.jsxs)("p",{children:["Bcc: ",e.bcc.join(", ")]}),(0,t.jsxs)("p",{className:"break-all",children:["Message ID: ",e.providerMessageId]}),e.fullText!==e.text&&(0,t.jsx)("div",{className:"whitespace-pre-wrap break-words",children:e.fullText})]})]}),s&&(0,t.jsxs)("p",{className:"border-t border-border pt-3 text-xs text-muted-foreground",children:[s.outcome==="delivered"?"Delivered":s.outcome==="failed"?"Delivery failed":s.outcome==="uncertain"?"Delivery uncertain":s.outcome==="queued"?"Queued":"Sent",s.error?` · ${s.error}`:""]}),a.error&&(0,t.jsx)("p",{role:"alert",className:"text-xs text-destructive",children:"Attachments could not be loaded."})]})}r(Dge,"EmailMessageCard");var Mb=(0,u.createContext)(null);function rZe(e){return e.contentType.toLowerCase().split(";")[0]?.trim()??""}r(rZe,"normalizedContentType$1");function K1(e){return e.originalFilename??e.id}r(K1,"attachmentFilename");function LK(e){return e.openPath??e.contentPath}r(LK,"attachmentOpenPath");function V1(e){return e.downloadPath??`${e.contentPath}?download=1`}r(V1,"attachmentDownloadPath");function Lge(e){const s=rZe(e);return vE(s,e.originalFilename)&&!/^image\/hei[cf](?:-sequence)?$/.test(s)}r(Lge,"isImageAttachment$2");function $ge(e){return ju(e.contentType,e.originalFilename)}r($ge,"isVideoAttachment");function aZe(e){return IIe(e)}r(aZe,"isMarkdownAttachment");function Mv({items:e,initialIndex:s,open:n,onOpenChange:a}){const[i,o]=(0,u.useState)(s),l=(0,u.useRef)(null),c=(0,u.useCallback)(v=>{l.current=v},[]);(0,u.useEffect)(()=>{n&&o(s)},[n,s]);const d=(0,u.useCallback)(()=>{o(v=>(v+1)%e.length)},[e.length]),m=(0,u.useCallback)(()=>{o(v=>(v-1+e.length)%e.length)},[e.length]);(0,u.useEffect)(()=>{i<e.length||o(0)},[i,e.length]),(0,u.useEffect)(()=>{if(!n)return;const v=r(y=>{y.key==="ArrowRight"?d():y.key==="ArrowLeft"?m():y.key==="Escape"&&a(!1)},"handler");return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[n,d,m,a]);const h=(0,u.useCallback)(v=>{const y=v.target;y.closest("button")||y.closest("a")||y===l.current||a(!1)},[a]);if(e.length===0)return null;const p=e[i];if(!p)return null;const f=K1(p),g=ju(p.contentType,p.originalFilename);return(0,t.jsx)(q2e,{open:n,onOpenChange:a,children:(0,t.jsxs)(F2e,{children:[(0,t.jsx)(B2e,{className:"fixed inset-0 z-50 bg-black/90 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 duration-200"}),(0,t.jsxs)(V2e,{className:"fixed inset-0 z-50 flex flex-col outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 duration-200",onClick:h,children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-5 py-3 text-white/80 text-sm shrink-0",children:[(0,t.jsx)("span",{className:"truncate max-w-(--pct-50) font-medium",title:f,children:f}),(0,t.jsxs)("div",{className:"flex items-center gap-4",children:[(0,t.jsxs)("span",{className:"text-white/40 tabular-nums text-xs",children:[i+1," / ",e.length]}),(0,t.jsx)("a",{href:V1(p),download:f,className:"text-white/50 hover:text-white transition-colors",title:"Download","aria-label":`Download ${f}`,onClick:r(v=>v.stopPropagation(),"onClick"),children:(0,t.jsx)(Uo,{className:"h-4.5 w-4.5"})}),(0,t.jsx)("button",{type:"button",onClick:r(()=>a(!1),"onClick"),className:"text-white/50 hover:text-white transition-colors",title:"Close",children:(0,t.jsx)(ir,{className:"h-5 w-5"})})]})]}),(0,t.jsxs)("div",{className:"flex-1 flex items-center min-h-0",children:[(0,t.jsx)("div",{className:"w-16 md:w-24 shrink-0 flex items-center justify-center h-full",children:e.length>1&&(0,t.jsx)("button",{type:"button",onClick:m,className:"rounded-full bg-white/10 p-3 text-white/60 hover:text-white hover:bg-white/20 transition-colors",title:"Previous",children:(0,t.jsx)(bu,{className:"h-7 w-7"})})}),(0,t.jsx)("div",{className:"flex-1 flex items-center justify-center min-w-0 min-h-0 h-full px-2",children:g?(0,t.jsx)("video",{ref:c,src:p.contentPath,className:"max-w-full max-h-full rounded-lg",controls:!0,playsInline:!0}):(0,t.jsx)("img",{ref:c,src:p.contentPath,alt:f,className:"max-w-full max-h-full object-contain select-none rounded-lg",draggable:!1})}),(0,t.jsx)("div",{className:"w-16 md:w-24 shrink-0 flex items-center justify-center h-full",children:e.length>1&&(0,t.jsx)("button",{type:"button",onClick:d,className:"rounded-full bg-white/10 p-3 text-white/60 hover:text-white hover:bg-white/20 transition-colors",title:"Next",children:(0,t.jsx)(Tn,{className:"h-7 w-7"})})})]}),(0,t.jsx)("div",{className:"h-6 shrink-0"})]})]})})}r(Mv,"ImageGalleryModal");function rB(e,s){if(e&&!s)return e;if(!e&&s)return s;if(e||s)return{...e,...s}}r(rB,"mergeObjects");var $K={};function OK(e,s,n,a,i){if(!n&&!a&&!i&&!e)return GT(s);let o=GT(e);return s&&(o=Vk(o,s)),n&&(o=Vk(o,n)),a&&(o=Vk(o,a)),i&&(o=Vk(o,i)),o}r(OK,"mergeProps");function iZe(e){if(e.length===0)return $K;if(e.length===1)return GT(e[0]);let s=GT(e[0]);for(let n=1;n<e.length;n+=1)s=Vk(s,e[n]);return s}r(iZe,"mergePropsN");function GT(e){return FK(e)?{...Fge(e,$K)}:oZe(e)}r(GT,"createInitialMergedProps");function Vk(e,s){return FK(s)?Fge(s,e):lZe(e,s)}r(Vk,"mergeInto");function oZe(e){const s={...e};for(const n in s){const a=s[n];Oge(n,a)&&(s[n]=Bge(a))}return s}r(oZe,"copyInitialProps");function lZe(e,s){if(!s)return e;for(const n in s){const a=s[n];switch(n){case"style":e[n]=rB(e.style,a);break;case"className":e[n]=zge(e.className,a);break;default:Oge(n,a)?e[n]=cZe(e[n],a):e[n]=a}}return e}r(lZe,"mutablyMergeInto");function Oge(e,s){const n=e.charCodeAt(0),a=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&a===110&&i>=65&&i<=90&&(typeof s=="function"||typeof s>"u")}r(Oge,"isEventHandler");function FK(e){return typeof e=="function"}r(FK,"isPropsGetter");function Fge(e,s){return FK(e)?e(s):e??$K}r(Fge,"resolvePropsGetter");function cZe(e,s){return s?e?(...n)=>{const a=n[0];if(Uge(a)){const o=a;qge(o);const l=s(...n);return o.baseUIHandlerPrevented||e?.(...n),l}const i=s(...n);return e?.(...n),i}:Bge(s):e}r(cZe,"mergeEventHandlers");function Bge(e){return e&&((...s)=>{const n=s[0];return Uge(n)&&qge(n),e(...s)})}r(Bge,"wrapEventHandler");function qge(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}r(qge,"makeEventPreventable");function zge(e,s){return s?e?s+" "+e:s:e}r(zge,"mergeClassNames");function Uge(e){return e!=null&&typeof e=="object"&&"nativeEvent"in e}r(Uge,"isSyntheticEvent");function dZe(e,s){return r(function(a,...i){const o=new URL(e);return o.searchParams.set("code",a.toString()),i.forEach(l=>o.searchParams.append("args[]",l)),`${s} error #${a}; visit ${o} for the full message.`},"formatErrorMessage")}r(dZe,"createFormatErrorMessage");var uZe=dZe("https://base-ui.com/production-error","Base UI"),aX={};function Kge(e,s){const n=u.useRef(aX);return n.current===aX&&(n.current=e(s)),n}r(Kge,"useRefWithInit");function iX(e,s,n,a){const i=Kge(Vge).current;return hZe(i,e,s,n,a)&&Wge(i,[e,s,n,a]),i.callback}r(iX,"useMergedRefs");function mZe(e){const s=Kge(Vge).current;return pZe(s,e)&&Wge(s,e),s.callback}r(mZe,"useMergedRefsN");function Vge(){return{callback:null,cleanup:null,refs:[]}}r(Vge,"createForkRef");function hZe(e,s,n,a,i){return e.refs[0]!==s||e.refs[1]!==n||e.refs[2]!==a||e.refs[3]!==i}r(hZe,"didChange");function pZe(e,s){return e.refs.length!==s.length||e.refs.some((n,a)=>n!==s[a])}r(pZe,"didChangeN");function Wge(e,s){if(e.refs=s,s.every(n=>n==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&(e.cleanup(),e.cleanup=null),n!=null){const a=Array(s.length).fill(null);for(let i=0;i<s.length;i+=1){const o=s[i];if(o!=null)switch(typeof o){case"function":{const l=o(n);typeof l=="function"&&(a[i]=l);break}case"object":o.current=n}}e.cleanup=()=>{for(let i=0;i<s.length;i+=1){const o=s[i];if(o!=null)switch(typeof o){case"function":{const l=a[i];typeof l=="function"?l():o(null);break}case"object":o.current=null}}}}}}r(Wge,"update");var fZe=parseInt("19.2.8",10);function xZe(e){return fZe>=e}r(xZe,"isReactVersionAtLeast");function oX(e){if(!u.isValidElement(e))return null;const s=e,n=s.props;return(xZe(19)?n?.ref:s.ref)??null}r(oX,"getReactElementRef");var O7t=Object.freeze([]),Wk=Object.freeze({});function gZe(e,s){const n={};for(const a in e){const i=e[a];if(s?.hasOwnProperty(a)){const o=s[a](i);o!=null&&Object.assign(n,o);continue}i===!0?n[`data-${a.toLowerCase()}`]="":i&&(n[`data-${a.toLowerCase()}`]=i.toString())}return n}r(gZe,"getStateAttributesProps");function bZe(e,s){return typeof e=="function"?e(s):e}r(bZe,"resolveClassName");function vZe(e,s){return typeof e=="function"?e(s):e}r(vZe,"resolveStyle");function yZe(e,s,n={}){const a=s.render,i=jZe(s,n);return n.enabled===!1?null:kZe(e,a,i,n.state??Wk)}r(yZe,"useRenderElement");function jZe(e,s={}){const{className:n,style:a,render:i}=e,{state:o=Wk,ref:l,props:c,stateAttributesMapping:d,enabled:m=!0}=s,h=m?bZe(n,o):void 0,p=m?vZe(a,o):void 0,f=m?gZe(o,d):Wk,g=m&&c?wZe(c):void 0,v=m?rB(f,g)??{}:Wk;return typeof document<"u"&&(m?Array.isArray(l)?v.ref=mZe([v.ref,oX(i),...l]):v.ref=iX(v.ref,oX(i),l):iX(null,null)),m?(h!==void 0&&(v.className=zge(v.className,h)),p!==void 0&&(v.style=rB(v.style,p)),v):Wk}r(jZe,"useRenderElementProps");function wZe(e){return Array.isArray(e)?iZe(e):OK(void 0,e)}r(wZe,"resolveRenderFunctionProps");var NZe=Symbol.for("react.lazy");function kZe(e,s,n,a){if(s){if(typeof s=="function")return s(n,a);const i=OK(n,s.props);i.ref=n.ref;let o=s;return o?.$$typeof===NZe&&(o=u.Children.toArray(s)[0]),u.cloneElement(o,i)}if(e&&typeof e=="string")return SZe(e,n);throw new Error(uZe(8))}r(kZe,"evaluateRenderProp");function SZe(e,s){return e==="button"?(0,u.createElement)("button",{type:"button",...s,key:s.key}):e==="img"?(0,u.createElement)("img",{alt:"",...s,key:s.key}):u.createElement(e,s)}r(SZe,"renderTag");function CZe(e){return yZe(e.defaultTagName??"div",e,e)}r(CZe,"useRender");var _Ze=Az("group/attachment relative flex w-fit max-w-full min-w-0 shrink-0 flex-wrap rounded-none border bg-card text-card-foreground transition-colors focus-within:ring-1 focus-within:ring-ring/50 has-[>a,>button]:hover:bg-muted/50 data-[state=error]:border-destructive/30 data-[state=idle]:border-dashed",{variants:{size:{default:"gap-2 text-xs has-data-[slot=attachment-content]:px-2 has-data-[slot=attachment-content]:py-1.5 has-data-[slot=attachment-media]:p-1.5",sm:"gap-2.5 text-xs has-data-[slot=attachment-content]:px-1.5 has-data-[slot=attachment-content]:py-1 has-data-[slot=attachment-media]:p-1",xs:"gap-1.5 rounded-none text-xs has-data-[slot=attachment-content]:px-1.5 has-data-[slot=attachment-content]:py-1 has-data-[slot=attachment-media]:p-1"},orientation:{horizontal:"min-w-40 items-center",vertical:"w-24 flex-col has-data-[slot=attachment-content]:w-30"}}});function Hge({className:e,state:s="done",size:n="default",orientation:a="horizontal",...i}){return(0,t.jsx)("div",{"data-slot":"attachment","data-state":s,"data-size":n,"data-orientation":a,className:U(_Ze({size:n,orientation:a}),e),...i})}r(Hge,"Attachment");var IZe=Az("relative flex aspect-square w-10 shrink-0 items-center justify-center overflow-hidden rounded-none bg-muted text-foreground group-data-[orientation=vertical]/attachment:w-full group-data-[size=sm]/attachment:w-8 group-data-[size=xs]/attachment:w-7 group-data-[size=xs]/attachment:rounded-none group-data-[state=error]/attachment:bg-destructive/10 group-data-[state=error]/attachment:text-destructive group-data-[orientation=vertical]/attachment:*:data-[slot=spinner]:size-6! [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 group-data-[orientation=vertical]/attachment:[&_svg:not([class*='size-'])]:size-6 group-data-[size=xs]/attachment:[&_svg:not([class*='size-'])]:size-3.5",{variants:{variant:{icon:"",image:"opacity-60 group-data-[state=done]/attachment:opacity-100 group-data-[state=idle]/attachment:opacity-100 *:[img]:aspect-square *:[img]:w-full *:[img]:object-cover"}},defaultVariants:{variant:"icon"}});function Qge({className:e,variant:s="icon",...n}){return(0,t.jsx)("div",{"data-slot":"attachment-media","data-variant":s,className:U(IZe({variant:s}),e),...n})}r(Qge,"AttachmentMedia");function Gge({className:e,...s}){return(0,t.jsx)("div",{"data-slot":"attachment-content",className:U("max-w-full min-w-0 flex-1 leading-tight group-data-[orientation=vertical]/attachment:px-1",e),...s})}r(Gge,"AttachmentContent");function Yge({className:e,...s}){return(0,t.jsx)("span",{"data-slot":"attachment-title",className:U("block max-w-full min-w-0 truncate font-medium group-data-[state=processing]/attachment:shimmer group-data-[state=uploading]/attachment:shimmer",e),...s})}r(Yge,"AttachmentTitle");function Jge({className:e,...s}){return(0,t.jsx)("span",{"data-slot":"attachment-description",className:U("mt-0.5 block min-w-0 truncate text-xs text-muted-foreground group-data-[state=error]/attachment:text-destructive/80","max-w-full",e),...s})}r(Jge,"AttachmentDescription");function AZe({className:e,...s}){return(0,t.jsx)("div",{"data-slot":"attachment-actions",className:U("relative z-20 flex shrink-0 items-center group-data-[orientation=vertical]/attachment:absolute group-data-[orientation=vertical]/attachment:top-3 group-data-[orientation=vertical]/attachment:right-3 group-data-[orientation=vertical]/attachment:gap-1",e),...s})}r(AZe,"AttachmentActions$1");function RZe({className:e,variant:s,size:n="icon-xs",...a}){return(0,t.jsx)(F,{"data-slot":"attachment-action",variant:s??"ghost",size:n,className:U(e),...a})}r(RZe,"AttachmentAction");function TZe({className:e,render:s,type:n,...a}){return CZe({defaultTagName:"button",props:OK({type:s?n:n??"button",className:U("absolute inset-0 z-10 outline-none",e)},a),render:s,state:{slot:"attachment-trigger"}})}r(TZe,"AttachmentTrigger");function Xge({className:e,...s}){return(0,t.jsx)("div",{"data-slot":"attachment-group",className:U("flex min-w-0 scroll-fade-x snap-x snap-mandatory scroll-px-1 scrollbar-none gap-3 overflow-x-auto overscroll-x-contain py-1 *:data-[slot=attachment]:flex-none *:data-[slot=attachment]:snap-start",e),...s})}r(Xge,"AttachmentGroup");var EZe=new Set(["png","jpg","jpeg","gif","webp","svg","avif","bmp","ico","heic"]),PZe={pdf:{icon:gi,label:"PDF"},doc:{icon:gi,label:"Doc"},docx:{icon:gi,label:"Doc"},txt:{icon:gi,label:"Text"},md:{icon:gi,label:"Markdown"},rtf:{icon:gi,label:"Text"},csv:{icon:Ok,label:"CSV"},tsv:{icon:Ok,label:"TSV"},xls:{icon:Ok,label:"Sheet"},xlsx:{icon:Ok,label:"Sheet"},zip:{icon:Y0,label:"ZIP"},gz:{icon:Y0,label:"Archive"},tar:{icon:Y0,label:"Archive"},tgz:{icon:Y0,label:"Archive"},rar:{icon:Y0,label:"Archive"},"7z":{icon:Y0,label:"Archive"},mp3:{icon:$k,label:"Audio"},wav:{icon:$k,label:"Audio"},m4a:{icon:$k,label:"Audio"},ogg:{icon:$k,label:"Audio"},mp4:{icon:p2,label:"Video"},mov:{icon:p2,label:"Video"},webm:{icon:p2,label:"Video"},json:{icon:jl,label:"JSON"},yaml:{icon:jl,label:"YAML"},yml:{icon:jl,label:"YAML"},xml:{icon:jl,label:"XML"},html:{icon:jl,label:"HTML"},css:{icon:jl,label:"CSS"},js:{icon:jl,label:"Code"},jsx:{icon:jl,label:"Code"},ts:{icon:jl,label:"Code"},tsx:{icon:jl,label:"Code"},py:{icon:jl,label:"Code"},rb:{icon:jl,label:"Code"},go:{icon:jl,label:"Code"},rs:{icon:jl,label:"Code"},sh:{icon:jl,label:"Code"},sql:{icon:jl,label:"SQL"},log:{icon:gi,label:"Log"},patch:{icon:jl,label:"Patch"},diff:{icon:jl,label:"Patch"}};function Zge(e){const s=/\.([a-z0-9]+)$/i.exec(e.trim());return s?s[1].toLowerCase():""}r(Zge,"extensionOf");function lX(e){return EZe.has(Zge(e))}r(lX,"isImageFilename");function e0e(e){return(e??"").toLowerCase().split(";")[0]?.trim()??""}r(e0e,"normalizedContentType");function AI(e){const s=e0e(e.contentType);return s.startsWith("image/")?!0:s&&s!=="application/octet-stream"?!1:lX(e.name)||lX(e.url.split("?")[0])}r(AI,"isImageAttachment$1");function t0e(e){return PZe[Zge(e)]??{icon:XR,label:"File"}}r(t0e,"fileKindForName");function MZe(e){const s=t0e(e.name);if(s.label!=="File")return s;const n=e0e(e.contentType);return n==="application/pdf"?{icon:gi,label:"PDF"}:n==="application/json"||n.endsWith("+json")?{icon:jl,label:"JSON"}:n==="text/csv"||n==="application/csv"?{icon:Ok,label:"CSV"}:n.startsWith("text/")?{icon:gi,label:"Text"}:n.startsWith("audio/")?{icon:$k,label:"Audio"}:n.startsWith("video/")?{icon:p2,label:"Video"}:n.includes("zip")||n.includes("archive")?{icon:Y0,label:"Archive"}:s}r(MZe,"fileKindForAttachment");function s0e(e){return e===void 0||!Number.isFinite(e)||e<=0?"":e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}r(s0e,"formatFileSize");function DZe(e){return/\/api\/(?:attachments|assets)\/([^/?]+)\/content/.exec(e)?.[1]??null}r(DZe,"attachmentIdFromUrl");function cX(e,s){const n=new Map(s.map(i=>[i.id,i])),a=new Map(s.flatMap(i=>[[i.contentPath,i],...i.openPath?[[i.openPath,i]]:[]]));return e.map(i=>{const o=i.url.split("?")[0],l=a.get(o)??n.get(DZe(i.url)??"");return l?{...i,id:l.id,name:l.originalFilename?.trim()||i.name,contentType:l.contentType,byteSize:l.byteSize,openPath:l.openPath,downloadPath:l.downloadPath}:i})}r(cX,"hydrateAttachmentRefs");var dX=/(?<!!)\[((?:\\.|[^\]\\])+)\]\((\/api\/(?:attachments|assets)\/[^()\s]+\/content(?:\?[^()\s]*)?)\)/g,n0e=/!\[((?:\\.|[^\]\\])*)\]\(([^()\s]+)\)/g;function r0e(e){return e.replace(n0e,"").trim().length===0&&e.trim().length>0}r(r0e,"isStandaloneImageEmbedLine");function LZe(e){const s=[],n=new Set;for(const a of e.split(`
|
|
336
|
+
`)}`:void 0}r(eJe,"sanitizeComponentStack");function tJe(e){const s=eJe(e.componentStack),n={};if(typeof document<"u"){try{const a=document.readyState;(a==="loading"||a==="interactive"||a==="complete")&&(n.ready_state=a)}catch{}try{const a=document.visibilityState;(a==="visible"||a==="hidden")&&(n.visibility_state=a)}catch{}try{const a=document.documentElement.classList;n.translation_marker=a.contains("translated-ltr")||a.contains("translated-rtl")}catch{}}return{tags:{react_error_boundary:e.boundary},contexts:{react:s?{componentStack:s}:{},browser_state:n}}}r(tJe,"buildBrowserErrorContext");var zJ=Promise.resolve();function EK(e){const s=zJ.then(e);return zJ=s.catch(()=>{}),s}r(EK,"enqueue");var Cw=null;function sJe(e,s){return EK(async()=>{if(!Cw)try{const n=await jc(()=>import("./prod-COP_vZWu.js"),__vite__mapDeps([4,5]));n.init(rJe(e,s)),Cw=n}catch{}})}r(sJe,"initBrowserErrorMonitoring");function nJe(){return EK(async()=>{const e=Cw;if(Cw=null,!e)return;const s=e.getClient();try{e.getCurrentScope().setClient(void 0)}catch{}try{await s?.close(2e3)}catch{}})}r(nJe,"teardownBrowserErrorMonitoring");function rge(e,s){let n;try{s&&(n=tJe(s))}catch{}EK(async()=>{try{n?Cw?.captureException(e,n):Cw?.captureException(e)}catch{}})}r(rge,"captureBrowserException");function rJe(e,s){return{dsn:e,environment:s??void 0,release:"6d94a1bd4d8c0a15b332cbca3e377eafb06a7eb2",tracesSampleRate:0,sendDefaultPii:!1,integrations:r(n=>n.filter(a=>a.name!=="HttpContext"&&a.name!=="Breadcrumbs"),"integrations")}}r(rJe,"buildBrowserSentryInitOptions");var aJe=class extends u.Component{static{r(this,"RouteErrorBoundaryInner")}state={error:null};static getDerivedStateFromError(e){return{error:e instanceof Error?e:new Error(String(e))}}componentDidCatch(e,s){rge(e,{boundary:"route",componentStack:s.componentStack})}componentDidUpdate(e){this.state.error&&e.resetKey!==this.props.resetKey&&this.setState({error:null})}render(){const{error:e}=this.state;return e?(0,t.jsxs)("div",{className:"mx-auto max-w-2xl space-y-4 px-4 py-10",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"This page hit an error"}),(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"Something went wrong while rendering this page. You can go back and try again, or reload."})]}),(0,t.jsx)("pre",{className:"overflow-auto rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive whitespace-pre-wrap",children:e.message}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(F,{variant:"outline",size:"sm",onClick:this.props.onReset,children:"Go back"}),(0,t.jsx)(F,{size:"sm",onClick:r(()=>window.location.reload(),"onClick"),children:"Reload page"})]})]}):this.props.children}};function age({children:e}){const s=na(),n=Yn(),a=`${s.pathname}${s.search}`;return(0,t.jsx)(aJe,{resetKey:a,onReset:r(()=>n(-1),"onReset"),children:e})}r(age,"RouteErrorBoundary");var SI=240,eB=208,tB=420,UJ=16;function VT(e){return Math.min(tB,Math.max(eB,e))}r(VT,"clampSidebarWidth$1");function KJ(e){if(typeof window>"u")return SI;try{const s=window.localStorage.getItem(e);if(!s)return SI;const n=Number.parseInt(s,10);return Number.isFinite(n)?VT(n):SI}catch{return SI}}r(KJ,"readStoredSidebarWidth$1");function VJ(e,s){if(!(typeof window>"u"))try{window.localStorage.setItem(e,String(VT(s)))}catch{}}r(VJ,"writeStoredSidebarWidth$1");function iJe({children:e,open:s,collapsed:n=!1,peeking:a=!1,resizable:i=!1,storageKey:o="paperclip.sidebar.width",className:l,onPanelMouseEnter:c,onPanelMouseLeave:d,onPanelFocusCapture:m,onPanelBlurCapture:h}){const[p,f]=(0,u.useState)(()=>KJ(o)),[g,v]=(0,u.useState)(!1),y=(0,u.useRef)(p),w=(0,u.useRef)(null);(0,u.useEffect)(()=>{const E=KJ(o);y.current=E,f(E)},[o]);const S=s?p:0,j=s?n?64:S:0,N=s?n&&!a?64:S:0,_=N>j,R=i&&s&&!n,C=(0,u.useMemo)(()=>({width:`${j}px`}),[j]),A=(0,u.useMemo)(()=>({width:`${N}px`}),[N]),T=(0,u.useCallback)(E=>{const q=VT(E);y.current=q,f(q),VJ(o,q)},[o]),I=(0,u.useCallback)(E=>{R&&(E.preventDefault(),E.currentTarget.setPointerCapture(E.pointerId),w.current={startX:E.clientX,startWidth:y.current},v(!0))},[R]),$=(0,u.useCallback)(E=>{if(!w.current)return;const q=VT(w.current.startWidth+E.clientX-w.current.startX);y.current=q,f(q)},[]),O=(0,u.useCallback)(()=>{w.current&&(w.current=null,v(!1),VJ(o,y.current))},[o]),L=(0,u.useCallback)(E=>{R&&(E.key==="ArrowLeft"?(E.preventDefault(),T(p-UJ)):E.key==="ArrowRight"?(E.preventDefault(),T(p+UJ)):E.key==="Home"?(E.preventDefault(),T(eB)):E.key==="End"&&(E.preventDefault(),T(tB)))},[R,T,p]);return(0,t.jsxs)("div",{className:U("relative h-full shrink-0",l),style:C,children:[(0,t.jsx)("div",{className:U("absolute inset-y-0 left-0 flex flex-col overflow-hidden",_?"z-30 border-r border-border bg-background shadow-lg":"z-0"),style:A,"data-sidebar-overlay":_?"":void 0,onMouseEnter:c,onMouseLeave:d,onFocusCapture:m,onBlurCapture:h,children:e}),R?(0,t.jsx)("div",{role:"separator","aria-label":"Resize sidebar","aria-orientation":"vertical","aria-valuemin":eB,"aria-valuemax":tB,"aria-valuenow":p,tabIndex:0,"data-dragging":g?"":void 0,className:"group absolute inset-y-0 z-20 cursor-col-resize touch-none outline-none",style:{right:-4,width:8},onPointerDown:I,onPointerMove:$,onPointerUp:O,onPointerCancel:O,onLostPointerCapture:O,onKeyDown:L,children:(0,t.jsx)("div",{className:U("mx-auto h-full w-0.5 transition-colors",g?"bg-ring":"bg-transparent group-hover:bg-ring group-focus-visible:bg-ring")})}):null]})}r(iJe,"SidebarShell$1");function CI({children:e,className:s}){return(0,t.jsx)("div",{"data-secondary-sidebar":"",className:U("h-full w-full min-w-0 overflow-hidden",s),children:(0,t.jsx)(gue,{children:e})})}r(CI,"SecondarySidebar$1");var oJe="Toggle the app appearance.";function Bj({className:e,variant:s="icon",onAfterToggle:n}){const{theme:a,toggleTheme:i}=IRe(),o=a==="dark",l=o?"Switch to light mode":"Switch to dark mode",c=o?Xde:Vde;function d(){i(),n?.()}return r(d,"handleClick"),s==="compact-menu-action"?(0,t.jsxs)("button",{type:"button",className:U("flex h-(--profile-popover-row-height) w-full items-center gap-(--profile-popover-row-gap) rounded-lg px-2.5 text-left text-(length:--text-compact) font-medium leading-(--profile-popover-label-line-height) text-foreground transition-colors hover:bg-accent",e),onClick:d,"aria-label":l,children:[(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:(0,t.jsx)(c,{className:"size-4"})}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:l})]}):s==="menu-action"?(0,t.jsxs)("button",{type:"button",className:U("flex w-full items-start gap-3 rounded-xl px-3 py-3 text-left transition-colors hover:bg-accent/60",e),onClick:d,"aria-label":l,children:[(0,t.jsx)("span",{className:"mt-0.5 rounded-lg border border-border bg-background/70 p-2 text-muted-foreground",children:(0,t.jsx)(c,{className:"size-4"})}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block text-sm font-medium text-foreground",children:l}),(0,t.jsx)("span",{className:"block text-xs text-muted-foreground",children:oJe})]})]}):(0,t.jsx)(F,{type:"button",variant:"ghost",size:"icon-sm",onClick:d,"aria-label":l,title:l,className:U("text-muted-foreground",e),children:(0,t.jsx)(c,{})})}r(Bj,"ThemeToggle");function lJe(e){if(!e)return"Unavailable";const s=new Date(e);return Number.isNaN(s.getTime())?"Unavailable":new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(s)}r(lJe,"formatTimestamp$2");function cJe(e){return!!e&&!Number.isNaN(new Date(e).getTime())}r(cJe,"isValidTimestamp");function dJe(e){return e?.devServer?.lastRestartAt??e?.serverInfo?.processStartedAt??null}r(dJe,"restartTimestamp");function uJe(e){const s=e?.serverInfo?.git;return s?.available?`${s.shortSha} · ${s.subject}`:"Commit unavailable"}r(uJe,"commitLabel");function mJe(e){const s=e?.serverInfo?.git;if(!s?.available)return"Unavailable";const n=s.localChanges;if(!n||!n.available)return"Change status unavailable";if(!n.hasLocalChanges)return"Clean checkout";const a=[[n.stagedFileCount,"staged"],[n.unstagedFileCount,"unstaged"],[n.untrackedFileCount,"untracked"]].filter(([i])=>Number(i)>0).map(([i,o])=>`${i} ${o}`);return a.length>0?`Local changes present (${a.join(", ")})`:"Local changes present"}r(mJe,"localChangesLabel");function tD({icon:e,label:s,value:n,dateTime:a}){return(0,t.jsxs)("div",{className:"flex w-full items-start gap-3 rounded-xl px-3 py-3 text-left",children:[(0,t.jsx)("span",{className:"mt-0.5 rounded-lg border border-border bg-background/70 p-2 text-muted-foreground",children:(0,t.jsx)(e,{className:"size-4"})}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block text-sm font-medium text-foreground",children:s}),a?(0,t.jsx)("time",{dateTime:a,className:"block break-words text-xs text-muted-foreground",children:n}):(0,t.jsx)("span",{className:"block break-words text-xs text-muted-foreground",children:n})]})]})}r(tD,"ServerInfoRow");function ige(){const e=Z({queryKey:P.instance.experimentalSettings,queryFn:r(()=>Er.getExperimental(),"queryFn")}).data?.enableServerInfoDebugView===!0,s=Z({queryKey:P.health,queryFn:r(()=>sm.get(),"queryFn"),enabled:e,refetchOnMount:"always",refetchInterval:r(h=>h.state.data?.devServer?.enabled?2e3:!1,"refetchInterval")});if(!e)return null;const n=s.data,a=s.isLoading&&!n,i=s.isError,o=dJe(n),l=cJe(o),c=i?"Health unavailable":a?"Loading...":lJe(o),d=i?"Health unavailable":a?"Loading...":uJe(n),m=i?"Health unavailable":a?"Loading...":mJe(n);return(0,t.jsxs)("div",{className:"mt-2 border-t border-border pt-2",children:[(0,t.jsx)("p",{className:"px-3 pb-1 pt-1 text-(length:--text-micro) font-medium uppercase tracking-wide text-muted-foreground",children:"Server"}),(0,t.jsx)(tD,{icon:sh,label:"Last restarted",value:c,dateTime:!i&&!a&&l?o:null}),(0,t.jsx)(tD,{icon:Lz,label:"Running commit",value:d}),(0,t.jsx)(tD,{icon:X3e,label:"Checkout state",value:m})]})}r(ige,"SidebarServerInfo");var hJe="/company/settings/instance/profile",pJe="https://docs.paperclip.ing/",fJe="https://paperclip.ing/feedback";function xJe(e){const s=e.trim().split(/\s+/).filter(Boolean);return s.length>=2?`${s[0]?.[0]??""}${s[s.length-1]?.[0]??""}`.toUpperCase():e.slice(0,2).toUpperCase()}r(xJe,"deriveInitials$2");function gJe(e,s,n){const a=[e,s?.split("@")[0],s,n];for(const i of a){const o=i?.trim().toLowerCase().replace(/['"]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");if(o)return o}return"me"}r(gJe,"deriveUserSlug$1");function _I({label:e,icon:s,onClick:n,href:a,external:i=!1}){const o="flex h-(--profile-popover-row-height) w-full items-center gap-(--profile-popover-row-gap) rounded-lg px-2.5 text-left text-(length:--text-compact) font-medium leading-(--profile-popover-label-line-height) text-foreground transition-colors hover:bg-accent",l=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:(0,t.jsx)(s,{className:"size-4"})}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e})]});return a?i?(0,t.jsx)("a",{href:a,target:"_blank",rel:"noreferrer",className:o,onClick:n,children:l}):(0,t.jsx)(Je,{to:a,className:o,onClick:n,children:l}):(0,t.jsx)("button",{type:"button",className:o,onClick:n,children:l})}r(_I,"MenuAction$1");function WJ({deploymentMode:e,open:s,onOpenChange:n,forceExpanded:a=!1}){const i=!!Yc(),[o,l]=(0,u.useState)(!1),{isMobile:c,setSidebarOpen:d,collapsed:m,peeking:h}=Va(),p=m&&!h&&!a,f=s??o,g=n??l,{data:v}=Z({queryKey:P.auth.session,queryFn:r(()=>qa.getSession(),"queryFn"),retry:!1}),y=iN({onSignedOut:_}),w=v?.user.name?.trim()||"Board",S=v?.user.email?.trim()||(e==="authenticated"?"Signed in":"Local workspace board"),j=xJe(w),N=`/u/${gJe(v?.user.name,v?.user.email,v?.user.id)}`;function _(){g(!1),c&&d(!1)}r(_,"closeNavigationChrome");function R(){y.mutate()}return r(R,"handleSignOut"),(0,t.jsx)("div",{className:"bg-border/50 px-3 py-2 dark:bg-muted",children:(0,t.jsxs)("div",{className:U("flex items-center gap-0.5",!p&&"px-2"),children:[(0,t.jsxs)(Zn,{open:f,onOpenChange:g,children:[(0,t.jsx)(ur,{asChild:!0,children:(0,t.jsxs)("button",{type:"button",className:U("flex min-w-0 items-center gap-2.5 rounded-lg text-left text-(length:--text-compact) font-medium text-foreground/80 transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",p?"w-full px-3 py-2":"flex-1 px-2 py-1.5"),"aria-label":"Open account menu",children:[(0,t.jsxs)(Gi,{size:"sm",children:[v?.user.image?(0,t.jsx)(Hc,{src:v.user.image,alt:w}):null,(0,t.jsx)(Yi,{children:j})]}),(0,t.jsx)("span",{className:U("min-w-0 flex-1 truncate",p&&"block w-0 min-w-0 overflow-hidden whitespace-nowrap text-transparent select-none"),children:w})]})}),(0,t.jsxs)(Vn,{side:"top",align:"start",sideOffset:10,className:"min-h-(--profile-popover-min-height) w-(--profile-popover-width) max-w-(--sz-calc-24) overflow-hidden rounded-xl border-border bg-popover p-0 shadow-(--shadow-profile-popover)",children:[(0,t.jsxs)("div",{className:"flex h-(--profile-popover-header-height) shrink-0 items-center gap-2.5 px-3.5",children:[(0,t.jsxs)(Gi,{className:"size-9",children:[v?.user.image?(0,t.jsx)(Hc,{src:v.user.image,alt:w}):null,(0,t.jsx)(Yi,{className:"text-xs text-foreground",children:j})]}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("h2",{className:"truncate text-sm font-semibold leading-(--profile-popover-label-line-height) text-foreground",children:w}),(0,t.jsx)("p",{className:"truncate text-(length:--text-micro) leading-(--profile-popover-meta-line-height) text-muted-foreground",children:S})]})]}),(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-0.5 border-t border-border px-2.5 pb-2.5 pt-2",children:[(0,t.jsx)(_I,{label:"Settings",icon:$d,href:"/company/settings",onClick:_}),(0,t.jsx)(_I,{label:"View profile",icon:vu,href:N,onClick:_}),(0,t.jsx)(_I,{label:"Edit profile",icon:C1,href:hJe,onClick:_}),(0,t.jsx)(_I,{label:"Documentation",icon:sN,href:pJe,external:!0,onClick:r(()=>g(!1),"onClick")}),(0,t.jsx)(Bj,{variant:"compact-menu-action",onAfterToggle:r(()=>g(!1),"onAfterToggle")}),e==="authenticated"?(0,t.jsxs)("button",{type:"button",className:U("flex h-(--profile-popover-row-height) w-full items-center gap-(--profile-popover-row-gap) rounded-lg px-2.5 text-left text-(length:--text-compact) font-medium leading-(--profile-popover-label-line-height) text-foreground transition-colors hover:bg-destructive/10",y.isPending&&"cursor-not-allowed opacity-60"),onClick:R,disabled:y.isPending,children:[(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:(0,t.jsx)(Yh,{className:"size-4"})}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:y.isPending?"Signing out...":"Sign out"})]}):null,(0,t.jsx)(ige,{})]})]})]}),!p&&!i?(0,t.jsxs)(Wn,{children:[(0,t.jsx)(Hn,{asChild:!0,children:(0,t.jsx)("a",{href:fJe,target:"_blank",rel:"noreferrer","aria-label":"Share feedback",className:"flex size-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground/50 transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:(0,t.jsx)(Px,{className:"h-4 w-4","aria-hidden":"true"})})}),(0,t.jsx)(Qn,{side:"top",children:"Share feedback"})]}):null]})})}r(WJ,"SidebarAccountMenu$1");function oge({enabled:e=!0,onNewIssue:s,onSearch:n,onToggleSidebar:a,onTogglePanel:i,onShowShortcuts:o,onGoToInbox:l}){(0,u.useEffect)(()=>{if(!e)return;let c=!1,d=null;const m=r(()=>{d!==null&&(window.clearTimeout(d),d=null)},"clearGoChordTimeout"),h=r(()=>{c=!1,m()},"disarmGoChord"),p=r(()=>{c=!0,m(),d=window.setTimeout(()=>{c=!1,d=null},1200)},"armGoChord");function f(y){if(y.defaultPrevented){h();return}if(l){const w=gce({armed:c,defaultPrevented:y.defaultPrevented,key:y.key,metaKey:y.metaKey,ctrlKey:y.ctrlKey,altKey:y.altKey,target:y.target,hasOpenDialog:Rh()});if(w==="arm"){p();return}if(w==="navigate_inbox"){h(),y.preventDefault(),l();return}if(w==="focus_comment"||w==="open_file_viewer"){h(),y.preventDefault();return}w==="disarm"&&h()}if(!a1(y.target)){if(y.key==="/"&&!y.metaKey&&!y.ctrlKey&&!y.altKey){if(Rh())return;y.preventDefault(),f2e()||n?.();return}if(y.key==="?"&&!y.metaKey&&!y.ctrlKey&&!y.altKey){y.preventDefault(),o?.();return}y.key==="c"&&!y.metaKey&&!y.ctrlKey&&!y.altKey&&(y.preventDefault(),s?.()),y.key==="["&&!y.metaKey&&!y.ctrlKey&&(y.preventDefault(),a?.()),y.key==="]"&&!y.metaKey&&!y.ctrlKey&&(y.preventDefault(),i?.())}}r(f,"handleKeyDown");const g=r(()=>h(),"handlePointerDown"),v=r(y=>{y.target instanceof HTMLElement&&y.target!==document.body&&h()},"handleFocusIn");return document.addEventListener("pointerdown",g,!0),document.addEventListener("focusin",v,!0),document.addEventListener("keydown",f),()=>{h(),document.removeEventListener("pointerdown",g,!0),document.removeEventListener("focusin",v,!0),document.removeEventListener("keydown",f)}},[e,s,n,a,i,o,l])}r(oge,"useKeyboardShortcuts");var bJe=new Set(["auth","invite","board-claim","cli-auth","docs"]);function lge(e){const s=(e.split("?")[0]??"").split("/").filter(Boolean);if(s.length===0)return!0;const[n]=s;return!bJe.has(n)}r(lge,"isRememberableCompanyPath");function vJe(e){const s=Wb(e.companyPrefix);return e.companies.find(n=>Wb(n.issuePrefix)===s)??null}r(vJe,"findCompanyByPrefix");function yJe(e){const s=gz(e.pathname);return s?vJe({companies:e.companies,companyPrefix:s})?.id??null:e.fallbackCompanyId}r(yJe,"getRememberedPathOwnerCompanyId");function jJe(e){const s=e.path?h5(e.path):"/dashboard";if(!lge(s))return"/dashboard";const[n,a]=(s.split("?")[0]??"").split("/").filter(Boolean);if(n==="issues"&&a){const i=/^([A-Za-z]+)-\d+$/.exec(a);if(i&&Wb(i[1]??"")!==Wb(e.companyPrefix))return"/dashboard"}return s}r(jJe,"sanitizeRememberedPathForCompany");var cge="paperclip.companyPaths";function dge(){try{const e=localStorage.getItem(cge);if(e)return JSON.parse(e)}catch{}return{}}r(dge,"getCompanyPaths");function wJe(e,s){const n=dge();n[e]=s,localStorage.setItem(cge,JSON.stringify(n))}r(wJe,"saveCompanyPath");function uge(){const{companies:e,selectedCompanyId:s,selectedCompany:n,selectionSource:a}=ps(),i=na(),o=Yn(),l=(0,u.useRef)(s),c=(0,u.useMemo)(()=>yJe({companies:e,pathname:i.pathname,fallbackCompanyId:l.current}),[e,i.pathname]),d=i.pathname+i.search;(0,u.useEffect)(()=>{const m=c,h=h5(d);m&&lge(h)&&wJe(m,h)},[d,c]),(0,u.useEffect)(()=>{if(s){if(l.current!==null&&s!==l.current&&a!=="route_sync"&&n){const m=dge(),h=jJe({path:m[s],companyPrefix:n.issuePrefix});o(`/${n.issuePrefix}${h}`,{replace:!0})}l.current=s}},[n,s,a,o])}r(uge,"useCompanyPageMemory");var NJe=24,kJe=8;function mge(e,s,n){const a=n&&!Mme(e,s).isTaskDetail,i=(0,u.useRef)(0),[o,l]=(0,u.useState)(!0),c=(0,u.useCallback)(d=>{const m=d-i.current;i.current=d,d<=NJe?l(!0):m>kJe?l(!1):m<-8&&l(!0)},[]);return(0,u.useEffect)(()=>{if(i.current=0,!a){l(!0);return}const d=r(()=>{c(window.scrollY||document.documentElement.scrollTop||0)},"onScroll");return d(),window.addEventListener("scroll",d,{passive:!0}),()=>window.removeEventListener("scroll",d)},[a,e,c]),o}r(mge,"useMobileNavAutoHide");function hge(e){const{matchedCompany:s,selectedCompanyId:n,companies:a}=e;return!s||s.status!=="archived"||n===s.id?null:a.find(i=>i.id===n&&i.status!=="archived")??a.find(i=>i.status!=="archived")??null}r(hge,"resolveArchivedCompanyBounce");function SJe(e){const{archivedCompanyId:s,companies:n,cloudPortfolioUrl:a}=e,i=n.find(o=>o.id!==s&&o.status!=="archived");return i?{kind:"company",company:i}:a?{kind:"cloud_portfolio",url:a}:{kind:"companies_list"}}r(SJe,"resolveCompanyArchiveDeparture");function pge(e){const{selectionSource:s,selectedCompanyId:n,routeCompanyId:a}=e;return!(n===a||s==="manual"&&n)}r(pge,"shouldSyncCompanySelectionFromRoute");function CJe(e,s){return e instanceof HTMLElement?!(s instanceof HTMLElement)||!document.contains(s)||s===document.body||s===document.documentElement?!0:!e.contains(s):!1}r(CJe,"shouldFocusMainContentAfterNavigation");function fge(e){if(!(e instanceof HTMLElement))return()=>{};const s=window.requestAnimationFrame(()=>{CJe(e,document.activeElement)&&e.focus({preventScroll:!0})});return()=>window.cancelAnimationFrame(s)}r(fge,"scheduleMainContentFocus");function xge(e=document,s=window){const n=r(()=>{e.documentElement.scrollTop!==0&&(e.documentElement.scrollTop=0),e.body.scrollTop!==0&&(e.body.scrollTop=0)},"onScroll");return s.addEventListener("scroll",n,{capture:!0}),()=>s.removeEventListener("scroll",n,{capture:!0})}r(xge,"pinDocumentScrollToZero");function xu({scope:e="global",requestedPrefix:s}){const n=na(),{setBreadcrumbs:a}=qn(),{companies:i,selectedCompany:o}=ps();(0,u.useEffect)(()=>{a([{label:"Not Found"}])},[a]);const l=o??i[0]??null,c=l?`/${l.issuePrefix}/dashboard`:"/",d=`${n.pathname}${n.search}${n.hash}`,m=s?.toUpperCase(),h=e==="invalid_company_prefix"?"Organization not found":"Page not found",p=e==="invalid_company_prefix"?`No organization matches prefix "${m??"unknown"}".`:"This route does not exist.";return(0,t.jsx)("div",{className:"mx-auto max-w-2xl py-10",children:(0,t.jsxs)(Xs,{className:"block p-6",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 p-2",children:(0,t.jsx)(Is,{className:"h-5 w-5 text-destructive"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{className:"text-xl font-semibold",children:h}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:p})]})]}),(0,t.jsxs)("div",{className:"mt-4 rounded-md border border-border bg-muted/20 px-3 py-2 text-xs text-muted-foreground",children:["Requested path: ",(0,t.jsx)("code",{className:"font-mono",children:d})]}),(0,t.jsxs)("div",{className:"mt-5 flex flex-wrap gap-2",children:[(0,t.jsx)(F,{asChild:!0,children:(0,t.jsxs)(Je,{to:c,children:[(0,t.jsx)(FR,{className:"mr-1.5 h-4 w-4"}),"Open dashboard"]})}),(0,t.jsx)(F,{variant:"outline",asChild:!0,children:(0,t.jsx)(Je,{to:"/",children:"Go home"})})]})]})})}r(xu,"NotFoundPage");function _Je(e,s){return Pme(e,s)[0]?.toLowerCase()??null}r(_Je,"getCompanyRouteSegment$1");var IJe=new Set(["browse","connections","connect","chat","vercel-connect","review","attention","gateways","advanced","app"]);function AJe({sidebarSections:e}){const{sidebarOpen:s,setSidebarOpen:n,toggleSidebar:a,collapsed:i,peeking:o,setPeeking:l,isMobile:c,setForceCollapsed:d}=Va(),{openNewIssue:m,openOnboarding:h}=$o(),{togglePanelVisible:p}=yf(),f=_c()?.pushToast??null,{companies:g,loading:v,selectedCompany:y,selectedCompanyId:w,selectionSource:S,setSelectedCompanyId:j}=ps(),{companyPrefix:N,pluginRoutePath:_,agentId:R,routineId:C}=Sa(),A=Yn(),T=na(),I=m5(),{enabled:$}=Cc(),O=Mme(T.pathname,N),L=O.builtInContextualSurface==="settings",E=O.companySegments,q=O.isTaskDetail,B=$&&q,K=E[0]?.toLowerCase()==="tools",z=E[0]?.toLowerCase()==="apps",D=z&&E[1]&&!IJe.has(E[1].toLowerCase())?E[1]:null,V=z&&E[1]?.toLowerCase()==="app"&&E[2]?E[2]:null,H=(0,u.useRef)(!1),ee=(0,u.useRef)(null),X=(0,u.useRef)(null),le=(0,u.useRef)(new pue),ce=(0,u.useRef)(T.key),te=mge(T.pathname,N,c),[ae,de]=(0,u.useState)(!1),J=(0,u.useMemo)(()=>{if(!N)return null;const ut=N.toUpperCase();return g.find(Lt=>Lt.issuePrefix.toUpperCase()===ut)??null},[g,N]),Y=!!N&&!v&&g.length>0&&!J,G=(0,u.useMemo)(()=>_?.toLowerCase()??_Je(T.pathname,N),[N,T.pathname,_]),fe=J?.id??null,se=J?.issuePrefix??null,{slots:re}=Gc({slotTypes:["page","routeSidebar"],companyId:fe,enabled:!!(fe&&G)}),ie=(0,u.useMemo)(()=>oU(re,G),[G,re]),me=(0,u.useMemo)(()=>({companyId:fe,companyPrefix:se}),[fe,se]),pe=L?(0,t.jsx)(KOe,{}):!$&&O.builtInContextualSurface==="skills"?(0,t.jsx)(DQ,{}):D?(0,t.jsx)(PQ,{kind:"connection",connectionId:D}):V?(0,t.jsx)(PQ,{kind:"application",applicationId:V}):z||K?(0,t.jsx)(JOe,{}):ie?$?(0,t.jsx)(T1,{surface:`plugin:${ie.id}`,title:ie.displayName,children:(0,t.jsx)(yu,{slot:ie,context:me,className:"min-h-0 flex-1",missingBehavior:"placeholder"})}):(0,t.jsx)(yu,{slot:ie,context:me,className:"h-full w-full",missingBehavior:"placeholder"}):null,be=O.builtInContextualSurface==="agent"&&R?(0,t.jsx)(mFe,{agentRef:R}):$&&O.builtInContextualSurface==="routine"&&C?(0,t.jsx)(gDe,{children:(0,t.jsx)(fFe,{routineId:C})}):$&&O.builtInContextualSurface==="skills"?(0,t.jsx)(DQ,{}):pe,oe=be!=null,ye=$&&oe&&(O.builtInContextualSurface==="skills"||O.builtInContextualSurface==="agent"||O.builtInContextualSurface==="routine"||z||K),Ae=$&&oe&&!ye,xe=oe&&(!$||ye),_e=!$||!oe?null:ie&&!O.builtInContextualSurface?`plugin:${ie.id}`:O.builtInContextualSurface,Ge=(0,u.useRef)(null),{data:$e}=Z({queryKey:P.health,queryFn:r(()=>sm.get(),"queryFn"),retry:!1,refetchInterval:r(ut=>ut.state.data?.devServer?.enabled?2e3:!1,"refetchInterval"),refetchIntervalInBackground:!1}),Ye=Z({queryKey:P.instance.generalSettings,queryFn:r(()=>Er.getGeneral(),"queryFn")}).data?.keyboardShortcuts===!0;(0,u.useLayoutEffect)(()=>(d(!$&&oe),()=>d(!1)),[oe,d,$]),(0,u.useEffect)(()=>{const ut=Ge.current;_e&&N&&ut&&ut.surface!==_e&&ut.pathname!==T.pathname&&qOe({surface:_e,companyPrefix:N,previousPathname:ut.pathname}),Ge.current={pathname:T.pathname,surface:_e}},[N,_e,T.pathname]),(0,u.useEffect)(()=>{v||H.current||$e?.deploymentMode!=="authenticated"&&($e?.cloud||g.length===0&&(H.current=!0,h()))},[g,v,h,$e?.cloud,$e?.deploymentMode]),(0,u.useEffect)(()=>{if(!N||v||g.length===0)return;if(!J){const Lt=(w?g.find(Xt=>Xt.id===w):null)??g[0]??null;Lt&&w!==Lt.id&&j(Lt.id,{source:"route_sync"});return}if(N!==J.issuePrefix){const Lt=T.pathname.replace(/^\/[^/]+/,"");A(`/${J.issuePrefix}${Lt}${T.search}`,{replace:!0});return}const ut=hge({matchedCompany:J,selectedCompanyId:w,companies:g});if(ut){f?.({title:`${J.name} is archived`,body:`Switched to ${ut.name}.`,tone:"info",dedupeKey:`archived-company-bounce:${J.id}`}),j(ut.id,{source:"route_sync"}),A(`/${ut.issuePrefix}/dashboard`,{replace:!0});return}pge({selectionSource:S,selectedCompanyId:w,routeCompanyId:J.id})&&j(J.id,{source:"route_sync"})},[N,g,v,J,T.pathname,T.search,A,f,S,w,j]);const ue=p,Oe=(0,u.useCallback)(()=>{document.dispatchEvent(new KeyboardEvent("keydown",{key:"k",metaKey:!0,bubbles:!0,cancelable:!0}))},[]),dt=(0,u.useRef)(null),xt=(0,u.useRef)(!1),De=(0,u.useRef)(!1),Qe=(0,u.useCallback)(()=>{dt.current!==null&&(window.clearTimeout(dt.current),dt.current=null)},[]),ht=(0,u.useCallback)(()=>{Qe(),dt.current=window.setTimeout(()=>l(!0),50)},[Qe,l]),We=(0,u.useCallback)(()=>{Qe(),l(!0)},[Qe,l]),Ke=(0,u.useCallback)(()=>{Qe(),dt.current=window.setTimeout(()=>l(!1),120)},[Qe,l]),gt=(0,u.useCallback)(()=>{xt.current=!0,i&&!De.current&&ht()},[i,ht]),tt=(0,u.useCallback)(()=>{xt.current=!1,De.current=!1,Ke()},[Ke]),Se=(0,u.useCallback)(()=>{De.current||We()},[We]),ke=(0,u.useCallback)(()=>{xt.current||Ke()},[Ke]);(0,u.useEffect)(()=>Qe,[Qe]);const Xe=(0,u.useRef)(i);return(0,u.useEffect)(()=>{i!==Xe.current&&(i?(Qe(),l(!1),De.current=xt.current):De.current=!1,Xe.current=i)},[i,Qe,l]),(0,u.useEffect)(()=>{if(!o)return;const ut=r(Lt=>{Lt.key==="Escape"&&(Qe(),l(!1))},"onKeyDown");return window.addEventListener("keydown",ut),()=>window.removeEventListener("keydown",ut)},[o,Qe,l]),uge(),oge({enabled:Ye,onNewIssue:r(()=>m(),"onNewIssue"),onSearch:Oe,onToggleSidebar:a,onTogglePanel:ue,onShowShortcuts:r(()=>de(!0),"onShowShortcuts"),onGoToInbox:r(()=>A("/inbox"),"onGoToInbox")}),(0,u.useEffect)(()=>{if(!c)return;const ut=30,Lt=50,Xt=75;let fs=0,Ve=0;const He=r(ze=>{const is=ze.touches[0];fs=is.clientX,Ve=is.clientY},"onTouchStart"),ct=r(ze=>{const is=ze.changedTouches[0],Fe=is.clientX-fs;if(!(Math.abs(is.clientY-Ve)>Xt)){if(!s&&fs<ut&&Fe>Lt){n(!0);return}s&&Fe<-50&&n(!1)}},"onTouchEnd");return document.addEventListener("touchstart",He,{passive:!0}),document.addEventListener("touchend",ct,{passive:!0}),()=>{document.removeEventListener("touchstart",He),document.removeEventListener("touchend",ct)}},[c,s,n]),(0,u.useEffect)(()=>{const ut=document.body.style.overflow;return document.body.style.overflow=c?"visible":"clip",()=>{document.body.style.overflow=ut}},[c]),(0,u.useEffect)(()=>{if(!c)return xge()},[c]),(0,u.useEffect)(()=>{if(typeof document>"u")return;const ut=X.current;return fge(ut)},[T.pathname]),(0,u.useEffect)(()=>{const ut=X.current;if(!ut)return;const Lt=r(()=>{le.current.remember(ce.current,ut.scrollTop)},"recordScroll");return ut.addEventListener("scroll",Lt,{passive:!0}),()=>ut.removeEventListener("scroll",Lt)},[]),(0,u.useLayoutEffect)(()=>{const ut=X.current,Lt=hue({previousPathname:ee.current,pathname:T.pathname,navigationType:I,state:T.state});ee.current=T.pathname;const Xt=I==="POP",fs=Xt?le.current.recall(T.key):0;if(ce.current=T.key,Xt){nT(ut,fs);const Ve=requestAnimationFrame(()=>nT(ut,fs));return()=>cancelAnimationFrame(Ve)}Lt&&fue(ut)},[T.key,T.pathname,T.state,I]),(0,t.jsx)(mue,{children:(0,t.jsx)(vce,{value:{keyboardShortcutsEnabled:Ye},children:(0,t.jsxs)("div",{className:U("bg-background text-foreground pt-(--sz-safe-top)",c?"min-h-dvh overflow-x-clip":"flex h-dvh flex-col overflow-clip"),children:[(0,t.jsx)("a",{href:"#main-content",className:"sr-only focus:not-sr-only focus:fixed focus:left-3 focus:top-3 focus:z-(--z-200) focus:rounded-md focus:bg-background focus:px-3 focus:py-2 focus:text-sm focus:font-medium focus:shadow-lg focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:"Skip to Main Content"}),(0,t.jsx)(tge,{}),(0,t.jsx)(sge,{devServer:$e?.devServer}),(0,t.jsxs)("div",{className:U("min-h-0 flex-1",c?"w-full":"flex overflow-clip"),children:[c&&s&&(0,t.jsx)("button",{type:"button",className:"fixed inset-0 z-40 bg-black/50",onClick:r(()=>n(!1),"onClick"),"aria-label":"Close sidebar"}),c?(0,t.jsxs)("div",{className:U("fixed inset-y-0 left-0 z-50 flex flex-col overflow-hidden pt-(--sz-safe-top) transition-transform duration-100 ease-out",s?"translate-x-0":"-translate-x-full"),children:[(0,t.jsx)("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:(0,t.jsx)("div",{className:"w-60 shrink-0 overflow-hidden",children:oe?(0,t.jsx)(CI,{children:be}):(0,t.jsx)(AQ,{children:e})})}),(0,t.jsx)(WJ,{deploymentMode:$e?.deploymentMode,forceExpanded:Ae})]}):(0,t.jsxs)(iJe,{open:s,collapsed:Ae?!1:i,peeking:Ae?!1:o,resizable:!0,onPanelMouseEnter:Ae?void 0:gt,onPanelMouseLeave:Ae?void 0:tt,onPanelFocusCapture:!Ae&&i?Se:void 0,onPanelBlurCapture:!Ae&&i?ke:void 0,children:[(0,t.jsx)("div",{className:"flex flex-1 min-h-0",children:Ae?(0,t.jsx)(CI,{children:be}):(0,t.jsx)(AQ,{children:e})}),(0,t.jsx)(WJ,{deploymentMode:$e?.deploymentMode,forceExpanded:Ae})]}),!c&&xe&&!ye?(0,t.jsx)(CI,{className:"w-60 shrink-0",children:be}):null,(0,t.jsxs)("div",{className:U("flex min-w-0 flex-col",c?"w-full":"h-full flex-1"),children:[(0,t.jsxs)("div",{className:U(!c&&B&&"hidden",c&&"sticky top-0 z-20 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/85"),children:[(0,t.jsx)(ZF,{mobile:c}),(0,t.jsx)($Q,{}),c&&L?(0,t.jsx)("div",{className:"border-b border-border px-4 pb-3",children:(0,t.jsx)($me,{})}):null]}),(0,t.jsxs)("div",{className:U(c?"block":"flex flex-1 min-h-0",!c&&B&&"streamlined-task-detail-surface"),children:[!c&&ye?(0,t.jsx)(CI,{className:"w-60 shrink-0 bg-background",children:be}):null,(0,t.jsxs)("div",{className:U(!c&&B?"flex min-w-0 flex-1 flex-col":"contents"),children:[!c&&B?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ZF,{mobile:!1}),(0,t.jsx)($Q,{taskDetailLayout:!0})]}):null,(0,t.jsx)("main",{id:"main-content",ref:X,tabIndex:-1,style:c?{"--tc-composer-bottom":"var(--sz-calc-14)"}:void 0,className:U("flex-1 p-4 outline-none md:p-6",!c&&B&&"pt-0 md:pt-0",c?"overflow-visible pb-(--sz-calc-14)":"overflow-auto [scrollbar-gutter:stable]"),children:Y?(0,t.jsx)(xu,{scope:"invalid_company_prefix",requestedPrefix:N??y?.issuePrefix}):(0,t.jsx)(age,{children:(0,t.jsx)(i0,{})})})]}),(0,t.jsx)(Gme,{taskDetailLayout:!c&&B})]})]})]}),c&&(0,t.jsx)(ege,{visible:te}),(0,t.jsx)(Xme,{}),(0,t.jsx)(uhe,{}),(0,t.jsx)(Wxe,{}),(0,t.jsx)(Gxe,{}),(0,t.jsx)(Yxe,{}),(0,t.jsx)(Jxe,{open:ae,onOpenChange:de}),(0,t.jsx)(Xxe,{}),(0,t.jsx)(DYe,{health:$e}),(0,t.jsx)(Zxe,{localTrusted:$e?.deploymentMode==="local_trusted"})]})})})}r(AJe,"Layout$1");var gge=(0,u.createContext)(!1);function RJe({children:e}){return(0,t.jsx)(gge.Provider,{value:!0,children:e})}r(RJe,"SidebarNavExpandedProvider");function TJe(){return(0,u.useContext)(gge)}r(TJe,"useSidebarNavExpanded");function Qa({to:e,label:s,icon:n,iconNode:a,end:i,className:o,labelClassName:l,badge:c,badgeTone:d="default",badgeLabel:m,textBadge:h,textBadgeTone:p="default",alert:f=!1,liveCount:g,active:v,trailing:y,trailingLabel:w,liveAccessory:S}){const{isMobile:j,setSidebarOpen:N,collapsed:_,peeking:R}=Va(),C=TJe(),A=_&&!R&&!C,T=c!=null&&c>0,I=g!=null&&g>0,$=I?`${g} live`:T?`${c}${m?` ${m}`:""}`:f?"attention needed":void 0,O=!A||!$&&!w?void 0:`${s}${$?`, ${$}`:""}${w?`, ${w}`:""}`,L=(0,t.jsxs)(o0,{to:e,state:gf,end:i,"aria-label":O,onClick:r(()=>{j&&N(!1)},"onClick"),className:r(({isActive:E})=>U("flex items-center gap-2.5 mx-2 rounded-lg px-2 py-1.5 pointer-coarse:py-1 text-(length:--text-compact) font-medium transition-colors",v??E?"bg-accent text-foreground":"text-foreground/80 hover:bg-accent/50 hover:text-foreground",o),"className"),children:[(0,t.jsxs)("span",{className:"relative shrink-0",children:[a??(n?(0,t.jsx)(n,{className:"h-4 w-4"}):null),f&&(0,t.jsx)("span",{className:"absolute -right-0.5 -top-0.5 h-2 w-2 rounded-full bg-red-500 shadow-(--shadow-extract-12)","aria-hidden":"true"}),A&&!f&&I&&(0,t.jsxs)("span",{className:"absolute -right-0.5 -top-0.5 flex h-2 w-2","aria-hidden":"true",children:[(0,t.jsx)("span",{className:"animate-pulse absolute inline-flex h-full w-full rounded-full bg-blue-600 dark:bg-blue-400 opacity-75"}),(0,t.jsx)("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-blue-600 dark:bg-blue-400 shadow-(--shadow-extract-12)"})]}),A&&!f&&!I&&T&&(0,t.jsx)("span",{className:U("absolute -right-0.5 -top-0.5 h-2 w-2 rounded-full shadow-(--shadow-extract-12)",d==="danger"?"bg-red-600":d==="warning"?"bg-amber-500":"bg-primary"),"aria-hidden":"true"})]}),(0,t.jsx)("span",{className:A?Nv:U("min-w-0 flex-1 truncate",l),children:s}),!A&&y,!A&&h&&(0,t.jsx)(lt,{variant:"ghost",className:U("ml-auto px-1.5 text-(length:--text-nano) leading-none",p==="amber"?"bg-amber-100 text-amber-800 dark:bg-amber-900/30 dark:text-amber-400":"bg-muted text-muted-foreground"),children:h}),!A&&(I||S)&&(0,t.jsxs)("span",{className:"ml-auto flex items-center gap-1.5",children:[S,I&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("span",{className:"relative flex h-2 w-2",children:[(0,t.jsx)("span",{className:"animate-pulse absolute inline-flex h-full w-full rounded-full bg-blue-600 dark:bg-blue-400 opacity-75"}),(0,t.jsx)("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-blue-600 dark:bg-blue-400"})]}),(0,t.jsxs)("span",{className:"text-(length:--text-micro) font-medium text-blue-600 dark:text-blue-400",children:[g," live"]})]})]}),!A&&T&&(0,t.jsx)(lt,{variant:"ghost",className:U("ml-auto px-1.5 leading-none",d==="danger"?"bg-red-600/90 text-red-50":d==="warning"?"bg-amber-500/90 text-amber-50":"bg-primary text-primary-foreground"),children:c})]});return A?(0,t.jsxs)(Wn,{children:[(0,t.jsx)(Hn,{asChild:!0,children:(0,t.jsx)("div",{children:L})}),(0,t.jsx)(Qn,{side:"right",children:s})]}):L}r(Qa,"SidebarNavItem");var EJe=3,HJ=12e4,PJe=[{value:"top",label:"Top"},{value:"alphabetical",label:"Alphabetical"},{value:"recent",label:"Recent"}];function Sy(e,s){const n=e[s];if(!n)return 0;const a=new Date(n).getTime();return Number.isFinite(a)?a:0}r(Sy,"agentTimestamp");function QJ(e,s){if(s==="top")return e;const n=[...e];return s==="alphabetical"?(n.sort((a,i)=>a.name.localeCompare(i.name,void 0,{sensitivity:"base"})),n):(n.sort((a,i)=>{const o=Sy(i,"lastHeartbeatAt")-Sy(a,"lastHeartbeatAt");if(o!==0)return o;const l=Sy(i,"updatedAt")-Sy(a,"updatedAt");if(l!==0)return l;const c=Sy(i,"createdAt")-Sy(a,"createdAt");return c!==0?c:a.name.localeCompare(i.name,void 0,{sensitivity:"base"})}),n)}r(QJ,"sortAgents");var MJe="opacity-0 transition-opacity group-hover/agent:opacity-100 group-focus-within/agent:opacity-100";function DJe({activeAgentId:e,activeTab:s,agent:n,disabled:a,isMobile:i,leaving:o,onLeaveAgent:l,onPauseResume:c,rail:d,runCount:m,setSidebarOpen:h,builtInStatus:p,starred:f=!1,onToggleStar:g,starPending:v=!1}){const y=Nc(n),w=s?`${Gu(n)}/${s}`:Gu(n),S=`${Gu(n)}/configuration`,j=e===y,N=n.status==="paused",_=N&&n.pauseReason==="budget",R=n.orgChainHealth?.status==="invalid_org_chain",C=N?"Resume agent":"Pause agent",A=a||n.status==="pending_approval"||_||N&&R,T=a?"Updating...":_?"Budget paused":N&&R?"Invalid org chain":C,I=p==="needs_setup"||p==="pending_approval",$=[I?`Built-in agent ${p.replace(/_/g," ")}`:null,R?"Invalid reporting chain":null].filter(Boolean).join(", ")||void 0,O=(0,t.jsx)(Qa,{to:w,label:n.name,iconNode:(0,t.jsx)(gr,{agent:n,size:16,className:"shrink-0 h-4 w-4"}),active:j,liveCount:m,labelClassName:I?"min-w-(--sz-4_5rem) flex-initial":void 0,className:U("min-w-0 flex-1",f&&!i?"pr-14":"pr-8"),trailing:I||R?(0,t.jsxs)("span",{className:"ml-1 flex shrink-0 items-center gap-1",children:[I?(0,t.jsx)(Ej,{status:p,compact:!0}):null,R?(0,t.jsx)(Is,{className:"h-3.5 w-3.5 shrink-0 text-amber-500","aria-label":"Invalid reporting chain"}):null]}):void 0,trailingLabel:$,liveAccessory:n.pauseReason==="budget"?(0,t.jsx)(I1,{title:"Agent paused by budget"}):void 0});return d?O:(0,t.jsxs)("div",{className:"group/agent relative flex items-center",children:[O,f&&!i&&g?(0,t.jsx)("span",{className:"absolute right-10 top-1/2 -translate-y-1/2",children:(0,t.jsx)(d0,{size:"row",quiet:!0,starred:!0,pending:v,resourceName:n.name,onToggle:r(()=>g(n,!1),"onToggle"),revealClassName:MJe})}):null,(0,t.jsxs)(ba,{children:[(0,t.jsx)(ga,{asChild:!0,children:(0,t.jsx)(F,{variant:"ghost",size:"icon-xs",className:U("absolute right-3 top-1/2 h-6 w-6 -translate-y-1/2 transition-opacity data-[state=open]:pointer-events-auto data-[state=open]:opacity-100",i?"opacity-100":"pointer-events-none opacity-0 group-hover/agent:pointer-events-auto group-hover/agent:opacity-100 group-focus-within/agent:pointer-events-auto group-focus-within/agent:opacity-100"),"aria-label":`Open actions for ${n.name}`,children:(0,t.jsx)(Ti,{className:"h-3.5 w-3.5"})})}),(0,t.jsxs)(va,{align:"end",className:"w-48",children:[g?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(hs,{onClick:r(()=>{v||g(n,!f)},"onClick"),disabled:v,children:[v?(0,t.jsx)(at,{className:"size-4 motion-safe:animate-spin"}):(0,t.jsx)(Th,{className:U("size-4",f&&"fill-amber-500 text-amber-500")}),(0,t.jsx)("span",{children:f?"Remove from starred":"Star agent"})]}),(0,t.jsx)(di,{})]}):null,(0,t.jsx)(hs,{asChild:!0,children:(0,t.jsxs)(Je,{to:S,onClick:r(()=>{i&&h(!1)},"onClick"),children:[(0,t.jsx)(Kl,{className:"size-4"}),(0,t.jsx)("span",{children:"Edit agent"})]})}),(0,t.jsx)(di,{}),(0,t.jsxs)(hs,{onClick:r(()=>{A||c(n,N?"resume":"pause")},"onClick"),disabled:A,title:_?"Agent was paused by budget limits":void 0,children:[N?(0,t.jsx)(w1,{className:"size-4"}):(0,t.jsx)(md,{className:"size-4"}),(0,t.jsx)("span",{children:T})]}),(0,t.jsx)(di,{}),(0,t.jsxs)(hs,{onClick:r(()=>{o||l(n)},"onClick"),disabled:o,children:[o?(0,t.jsx)(at,{className:"size-4 motion-safe:animate-spin"}):(0,t.jsx)(Yh,{className:"size-4"}),(0,t.jsx)("span",{children:o?"Leaving...":"Leave agent"})]})]})]})]})}r(DJe,"SidebarAgentItem");function LJe({streamlined:e=!1}={}){const[s,n]=(0,u.useState)(!0),[a,i]=(0,u.useState)(()=>new Set),[o,l]=(0,u.useState)(0),c=(0,u.useRef)(new Map),d=Wt(),{selectedCompanyId:m}=ps(),{openNewAgent:h}=$o(),{isMobile:p,setSidebarOpen:f,collapsed:g,peeking:v}=Va(),y=g&&!v,{pushToast:w}=pa(),S=na(),{data:j}=Z({queryKey:P.agents.list(m),queryFn:r(()=>Vt.list(m),"queryFn"),enabled:!!m}),{data:N}=Z({queryKey:P.instance.experimentalSettings,queryFn:r(()=>Er.getExperimental(),"queryFn"),enabled:!!m}),_=N?.enableBuiltInAgents===!0,{data:R}=Z({queryKey:P.builtInAgents.list(m),queryFn:r(()=>xh.list(m),"queryFn"),enabled:!!m&&_}),C=(0,u.useMemo)(()=>{const xe=new Map;if(!_)return xe;for(const _e of R??[])_e.agentId&&xe.set(_e.agentId,_e.status);return xe},[R,_]),{data:A}=Z({queryKey:P.auth.session,queryFn:r(()=>qa.getSession(),"queryFn")}),T=bf(m),I=vf(m),$=P.liveRuns(m),O=mo({companyId:m,resourceKey:"live-runs",queryKey:$,enabled:!!m,refetchInterval:!1,leaderOnly:!0}),{data:L,dataUpdatedAt:E}=Z({queryKey:$,queryFn:r(()=>sa.liveRunsForCompany(m),"queryFn"),enabled:O.enabled,refetchInterval:O.refetchInterval});ho(O,L,E);const q=(0,u.useMemo)(()=>{const xe=new Map;for(const _e of L??[])xe.set(_e.agentId,(xe.get(_e.agentId)??0)+1);return xe},[L]),B=(0,u.useMemo)(()=>{const xe=new Set;for(const[_e,Ge]of q)Ge>0&&xe.add(_e);return xe},[q]),K=(0,u.useMemo)(()=>(j??[]).filter(xe=>xe.status!=="terminated"&&(!T.isSuccess||Sx(T.data,"agent",xe.id)!=="left")),[j,T.data,T.isSuccess]),z=A?.user?.id??A?.session?.userId??null,D=(0,u.useMemo)(()=>m?kue(m,z):null,[z,m]),[V,H]=(0,u.useState)(()=>D?Pj(D):"top"),{orderedAgents:ee}=_ue({agents:K,companyId:m,userId:z}),X=(0,u.useMemo)(()=>QJ(ee,V),[ee,V]),le=(0,u.useMemo)(()=>new Set(X.map(xe=>xe.id)),[X]);(0,u.useEffect)(()=>{const xe=Date.now();for(const _e of B)c.current.set(_e,xe);for(const _e of c.current.keys())le.has(_e)||c.current.delete(_e)},[B,le]);const ce=(0,u.useMemo)(()=>{const xe=Date.now(),_e=c.current;return X.filter(Ge=>{if((q.get(Ge.id)??0)>0)return!0;const $e=_e.get(Ge.id);return $e!==void 0&&xe-$e<=HJ})},[q,o,X]),te=ce.length>0,ae=e?te?ce:X.slice(0,EJe):X,de=e&&X.length>0,J=S.pathname.match(/^\/(?:[^/]+\/)?agents\/([^/]+)(?:\/([^/]+))?/),Y=J?.[1]??null,G=J?.[2]??null;(0,u.useEffect)(()=>{if(!D){H("top");return}H(Pj(D))},[D]),(0,u.useEffect)(()=>{if(!D)return;const xe=r(Ge=>{Ge.key===D&&H(Pj(D))},"onStorage"),_e=r(Ge=>{const $e=Ge.detail;!$e||$e.storageKey!==D||H($e.sortMode)},"onCustomEvent");return window.addEventListener("storage",xe),window.addEventListener(sC,_e),()=>{window.removeEventListener("storage",xe),window.removeEventListener(sC,_e)}},[D]),(0,u.useEffect)(()=>{if(!e)return;const xe=Date.now();let _e=null;for(const $e of X){if((q.get($e.id)??0)>0)continue;const Ye=c.current.get($e.id);if(Ye===void 0)continue;const ue=Ye+HJ;ue<xe||(_e=_e===null?ue:Math.min(_e,ue))}if(_e===null)return;const Ge=window.setTimeout(()=>{l($e=>$e+1)},Math.max(0,_e-xe+1));return()=>{window.clearTimeout(Ge)}},[e,X,q,o]);const fe=(0,u.useCallback)(xe=>{const _e=xe==="alphabetical"||xe==="recent"?xe:"top";H(_e),D&&Cue(D,_e)},[D]),se=Ne({mutationFn:r(({agent:xe,action:_e})=>_e==="pause"?Vt.pause(xe.id,m??void 0):Vt.resume(xe.id,m??void 0),"mutationFn"),onMutate:r(({agent:xe})=>{i(_e=>{const Ge=new Set(_e);return Ge.add(xe.id),Ge})},"onMutate"),onSuccess:r(async(xe,{agent:_e,action:Ge})=>{m&&await Promise.all([d.invalidateQueries({queryKey:P.agents.list(m)}),d.invalidateQueries({queryKey:P.liveRuns(m)}),d.invalidateQueries({queryKey:P.dashboard(m)})]),await Promise.all([d.invalidateQueries({queryKey:P.agents.detail(_e.id)}),d.invalidateQueries({queryKey:P.agents.detail(Nc(_e))})]),w({title:Ge==="pause"?"Agent paused":"Agent resumed",body:_e.name,tone:"success"})},"onSuccess"),onError:r((xe,{agent:_e,action:Ge})=>{w({title:Ge==="pause"?"Could not pause agent":"Could not resume agent",body:xe instanceof Error?xe.message:_e.name,tone:"error"})},"onError"),onSettled:r((xe,_e,{agent:Ge})=>{i($e=>{const Ye=new Set($e);return Ye.delete(Ge.id),Ye})},"onSettled")}),re=(0,u.useCallback)(xe=>I.mutate({resourceType:"agent",resourceId:xe.id,resourceName:xe.name,state:"left"}),[I]),ie=(0,u.useCallback)(xe=>I.isPending&&I.variables?.resourceType==="agent"&&I.variables.resourceId===xe.id,[I.isPending,I.variables]),me=(0,u.useCallback)((xe,_e)=>I.mutate({resourceType:"agent",resourceId:xe.id,resourceName:xe.name,starred:_e}),[I]),pe=(0,u.useCallback)(xe=>I.isPending&&I.variables?.resourceType==="agent"&&I.variables.resourceId===xe.id&&I.variables.starred!==void 0,[I.isPending,I.variables]),be=(0,u.useMemo)(()=>new Set($5(T.data,"agent")),[T.data]),oe=(0,u.useMemo)(()=>QJ(K.filter(xe=>be.has(xe.id)),"alphabetical"),[K,be]),ye=(0,u.useMemo)(()=>ae.filter(xe=>!be.has(xe.id)),[ae,be]),Ae=r((xe,_e)=>(0,t.jsx)(DJe,{activeAgentId:Y,activeTab:G,agent:xe,disabled:a.has(xe.id),isMobile:p,leaving:ie(xe),onLeaveAgent:re,onPauseResume:r((Ge,$e)=>se.mutate({agent:Ge,action:$e}),"onPauseResume"),rail:y,runCount:q.get(xe.id)??0,setSidebarOpen:f,builtInStatus:C.get(xe.id),starred:_e||c0(T.data,"agent",xe.id),onToggleStar:me,starPending:pe(xe)},xe.id),"renderAgentRow");return(0,t.jsxs)(xx,{label:"Agents",collapsible:{open:s,onOpenChange:n},headerAction:{ariaLabel:"New agent",icon:gn,onClick:h},menu:{ariaLabel:"Agents section actions",actions:[{type:"item",label:"Browse agents",icon:tl,href:"/agents/all"},{type:"separator"}],radioLabel:"Agent sort",radioChoices:PJe,radioValue:V,onRadioValueChange:fe},children:[oe.map(xe=>Ae(xe,!0)),ye.map(xe=>Ae(xe,!1)),de&&(()=>{const xe=(0,t.jsxs)(Je,{to:"/agents/all",state:gf,"aria-label":y?"See all agents":void 0,onClick:r(()=>{p&&f(!1)},"onClick"),className:"flex items-center gap-2.5 mx-2 rounded-lg px-2 py-1.5 pointer-coarse:py-1 text-(length:--text-compact) font-medium text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",children:[(0,t.jsx)(tl,{className:"shrink-0 h-4 w-4"}),(0,t.jsx)("span",{className:y?"block w-0 min-w-0 overflow-hidden whitespace-nowrap text-transparent select-none":void 0,children:"See all agents"})]});return y?(0,t.jsxs)(Wn,{children:[(0,t.jsx)(Hn,{asChild:!0,children:xe}),(0,t.jsx)(Qn,{side:"right",children:"See all agents"})]}):xe})()]})}r(LJe,"SidebarAgents");var $Je="opacity-0 transition-opacity group-hover/starred-project:opacity-100 group-focus-within/starred-project:opacity-100";function OJe(){const{selectedCompanyId:e}=ps(),{isMobile:s,setSidebarOpen:n,collapsed:a,peeking:i}=Va(),o=a&&!i,l=na(),{data:c}=Z({queryKey:P.projects.list(e),queryFn:r(()=>ma.list(e),"queryFn"),enabled:!!e}),d=bf(e),m=vf(e),h=l.pathname.match(/^\/(?:[^/]+\/)?projects\/([^/]+)/)?.[1]??null,p=(0,u.useMemo)(()=>{if(!d.isSuccess)return[];const y=new Set($5(d.data,"project"));if(y.size===0)return[];const w=new Map((c??[]).map(S=>[S.id,S]));return Array.from(y).map(S=>w.get(S)).filter(S=>!!S).sort((S,j)=>S.name.localeCompare(j.name,void 0,{sensitivity:"base"}))},[d.data,d.isSuccess,c]),f=(0,u.useCallback)(y=>m.mutate({resourceType:"project",resourceId:y.id,resourceName:y.name,starred:!1}),[m]),g=(0,u.useCallback)(y=>m.mutate({resourceType:"project",resourceId:y.id,resourceName:y.name,state:"left"}),[m]),v=(0,u.useCallback)(y=>m.isPending&&m.variables?.resourceType==="project"&&m.variables.resourceId===y.id,[m.isPending,m.variables]);return!d.isSuccess||p.length===0?null:(0,t.jsx)("div",{className:"flex flex-col gap-0.5","aria-label":"Starred projects",children:p.map(y=>{const w=a0(y),S=h===w||h===y.id,j=v(y),N=j&&m.variables?.starred===!1,_=j&&m.variables?.state==="left",R=c0(d.data,"project",y.id),C=(0,t.jsxs)(o0,{to:`/projects/${w}/issues`,state:gf,onClick:r(()=>{s&&n(!1)},"onClick"),className:U("flex min-w-0 flex-1 items-center gap-2.5 mx-2 rounded-lg px-2 py-1.5 pointer-coarse:py-1 pr-8 text-(length:--text-compact) font-medium transition-colors",!o&&"pl-6",S?"bg-accent text-foreground":"text-foreground/80 hover:bg-accent/50 hover:text-foreground"),children:[(0,t.jsx)(Qm,{color:y.color??null,icon:y.icon??null,size:"xs"}),(0,t.jsx)("span",{className:o?Nv:"flex-1 truncate",children:y.name}),!o&&y.pauseReason==="budget"?(0,t.jsx)(I1,{title:"Project paused by budget"}):null]});return(0,t.jsxs)("div",{className:"group/starred-project relative flex items-center",children:[o?(0,t.jsxs)(Wn,{children:[(0,t.jsx)(Hn,{asChild:!0,children:(0,t.jsx)("div",{className:"min-w-0 flex-1",children:C})}),(0,t.jsx)(Qn,{side:"right",children:y.name})]}):C,!o&&!s?(0,t.jsx)("span",{className:"absolute right-3 top-1/2 -translate-y-1/2",children:(0,t.jsx)(d0,{size:"row",quiet:!0,starred:R,pending:N,resourceName:y.name,onToggle:r(()=>f(y),"onToggle"),revealClassName:$Je})}):null,!o&&s?(0,t.jsxs)(ba,{children:[(0,t.jsx)(ga,{asChild:!0,children:(0,t.jsx)(F,{variant:"ghost",size:"icon-xs",className:"absolute right-3 top-1/2 h-6 w-6 -translate-y-1/2 opacity-100","aria-label":`Open actions for ${y.name}`,children:(0,t.jsx)(Ti,{className:"h-3.5 w-3.5"})})}),(0,t.jsxs)(va,{align:"end",className:"w-48",children:[(0,t.jsxs)(hs,{onClick:r(()=>{j||f(y)},"onClick"),disabled:j,children:[N?(0,t.jsx)(at,{className:"size-4 motion-safe:animate-spin"}):(0,t.jsx)(Th,{className:"size-4 fill-amber-500 text-amber-500"}),(0,t.jsx)("span",{children:"Remove from starred"})]}),(0,t.jsx)(di,{}),(0,t.jsxs)(hs,{onClick:r(()=>{j||g(y)},"onClick"),disabled:j,children:[_?(0,t.jsx)(at,{className:"size-4 motion-safe:animate-spin"}):(0,t.jsx)(Yh,{className:"size-4"}),(0,t.jsx)("span",{children:"Leave project"})]})]})]}):null]},y.id)})})}r(OJe,"SidebarStarredProjects");var bge="size-5 shrink-0 rounded-md text-(length:--text-micro)",vge="size-(--organization-popover-avatar-size) shrink-0 rounded-lg text-(length:--text-micro)",yge="h-(--organization-popover-company-row-height) min-w-0 gap-(--organization-popover-row-gap) rounded-lg px-2.5 py-0 text-(length:--text-compact) focus:bg-accent/50 focus:text-foreground",sD="h-(--organization-popover-action-row-height) gap-(--organization-popover-row-gap) rounded-lg px-2.5 py-0 text-(length:--text-compact) font-medium leading-(--organization-popover-action-line-height) text-foreground focus:bg-accent/50 focus:text-foreground";function jge({company:e,inPopover:s=!1}){return(0,t.jsx)(Lx,{companyName:e.name,logoUrl:e.logoUrl,className:s?vge:bge})}r(jge,"WorkspaceIcon");function FJe({displayName:e}){return(0,t.jsx)(Lx,{companyName:e,className:vge})}r(FJe,"StackIcon");function BJe({displayName:e,company:s}){return(0,t.jsx)(Lx,{companyName:e,logoUrl:s?.logoUrl,className:bge})}r(BJe,"CurrentStackIcon");function qJe({stack:e,isSelected:s,onSelect:n}){return(0,t.jsxs)(hs,{onSelect:r(()=>n(e),"onSelect"),className:yge,children:[(0,t.jsx)(FJe,{displayName:e.displayName}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block truncate font-medium leading-(--organization-popover-name-line-height)",title:e.displayName,children:e.displayName}),(0,t.jsx)("span",{className:"block truncate text-(length:--text-nano) leading-(--organization-popover-prefix-line-height) text-muted-foreground",title:e.stackSlug,children:e.stackSlug})]}),(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center",children:s?(0,t.jsx)(ds,{className:"size-4 text-foreground"}):null})]})}r(qJe,"CloudStackItem");function zJe({company:e,isEditing:s,isSelected:n,onSelect:a}){const{attributes:i,listeners:o,setActivatorNodeRef:l,setNodeRef:c,transform:d,transition:m,isDragging:h}=Yw({id:e.id,disabled:!s});return(0,t.jsxs)(hs,{ref:c,style:{transform:Hw.Transform.toString(d),transition:m,zIndex:h?10:void 0},onSelect:r(p=>{if(s){p.preventDefault();return}a(e)},"onSelect"),className:U(yge,s&&"cursor-grab",h&&"opacity-80"),children:[(0,t.jsx)(jge,{company:e,inPopover:!0}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block truncate font-medium leading-(--organization-popover-name-line-height)",children:e.name}),s?null:(0,t.jsx)("span",{className:"block truncate text-(length:--text-nano) leading-(--organization-popover-prefix-line-height) text-muted-foreground",children:e.issuePrefix})]}),s?(0,t.jsx)("button",{type:"button",ref:l,"aria-label":`Reorder ${e.name}`,className:"inline-flex size-8 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-(length:--rad-2) focus-visible:ring-ring",onClick:r(p=>{p.preventDefault(),p.stopPropagation()},"onClick"),...i,...o,children:(0,t.jsx)($z,{className:"size-4","aria-hidden":"true"})}):(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center",children:n?(0,t.jsx)(ds,{className:"size-4 text-foreground"}):null})]})}r(zJe,"SortableCompanyItem");function UJe(e={}){return(0,t.jsx)(_me,{...e,children:(0,t.jsx)(KJe,{...e})})}r(UJe,"SidebarCompanyMenu");function KJe({open:e,onOpenChange:s}){const[n,a]=(0,u.useState)(!1),[i,o]=(0,u.useState)(!1),{companies:l,selectedCompany:c,setSelectedCompanyId:d,companyListUnavailable:m,retryCompanies:h}=ps(),{openOnboarding:p}=$o(),{isMobile:f,setSidebarOpen:g,collapsed:v,peeking:y}=Va(),w=v&&!y,S=na(),j=Yn(),N=e??n,_=s??a,R=Gw(rf(yz,{activationConstraint:{distance:8}}),rf(yce,{activationConstraint:{delay:180,tolerance:6}})),C=(0,u.useMemo)(()=>l.filter(G=>G.status!=="archived"),[l]),{data:A}=Z({queryKey:P.auth.session,queryFn:r(()=>qa.getSession(),"queryFn"),retry:!1}),T=A?.user?.id??A?.session?.userId??null,{orderedCompanies:I,persistOrder:$}=Sme({companies:C,userId:T}),O=Yc(),L=!!O,{hidden:E,loaded:q}=eh(),B=q&&!GS(E,"company.members")&&!GS(E,"company.invites"),K=O?.cloudBaseUrl??null,z=Z({queryKey:P.cloud.stacks,queryFn:r(()=>Nme.listStacks(),"queryFn"),enabled:L,staleTime:3e4,retry:!1}),D=z.data?.stacks??[],V=L?D.find(G=>G.isCurrent)??D.find(G=>!!O?.stackSlug&&G.stackSlug===O?.stackSlug)??null:null,H=L?U5(K):null,ee=L?"organization":"company",X=L?V?.displayName??O?.stackDisplayName??O?.stackSlug??null:c?.name??null,le=iN({onSignedOut:te});function ce(G){G||o(!1),_(G)}r(ce,"handleOpenChange");function te(){_(!1),o(!1),f&&g(!1)}r(te,"closeNavigationChrome");function ae(G){const fe=S.pathname.split("/")[1]?.toUpperCase(),se=C.some(ie=>ie.issuePrefix.toUpperCase()===fe),re=G.id!==c?.id&&(S.pathname.startsWith("/instance/")||se);d(G.id),_(!1),f&&g(!1),re&&j(`/${G.issuePrefix}/dashboard`)}r(ae,"selectCompany");function de(G){if(_(!1),f&&g(!1),G.stackSlug===V?.stackSlug)return;const fe=Cme(K,G.stackSlug);fe&&Sc(fe)}r(de,"selectStack");function J(){if(_(!1),f&&g(!1),L){H&&Sc(H);return}p({initialStep:1})}r(J,"addCompany");const Y=(0,u.useCallback)(G=>{const{active:fe,over:se}=G;if(!se||fe.id===se.id)return;const re=I.map(pe=>pe.id),ie=re.indexOf(fe.id),me=re.indexOf(se.id);ie===-1||me===-1||$(p5(re,ie,me))},[I,$]);return(0,t.jsxs)(ba,{open:N,onOpenChange:ce,children:[(0,t.jsx)(ga,{asChild:!0,children:(0,t.jsxs)(F,{variant:"ghost",className:"h-9 min-w-0 flex-1 justify-start gap-2 px-4 text-left hover:bg-accent/50 hover:text-foreground has-[>svg]:px-4 dark:hover:bg-accent/50","aria-label":X?`Open ${X} ${ee} switcher`:`Open ${ee} switcher`,children:[(0,t.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[L?X?(0,t.jsx)(BJe,{displayName:X,company:c}):null:c?(0,t.jsx)(jge,{company:c}):null,(0,t.jsx)("span",{className:U("min-w-0 truncate text-sm font-bold text-foreground",w&&"block w-0 min-w-0 overflow-hidden whitespace-nowrap text-transparent select-none"),title:X??void 0,children:X??(L?"Select organization":"Select company")})]}),!w&&(0,t.jsx)(k5,{className:"size-3.5 shrink-0 text-muted-foreground"})]})}),(0,t.jsxs)(va,{align:"start",sideOffset:8,className:"ml-2 w-(--organization-popover-width) max-w-(--sz-calc-24) overflow-hidden rounded-xl border-border bg-popover p-0 shadow-(--shadow-profile-popover)",children:[(0,t.jsxs)("div",{className:"flex h-(--organization-popover-header-height) items-center justify-between gap-2 px-3.5",children:[(0,t.jsx)(Xw,{className:"p-0 text-(length:--text-compact) font-semibold text-foreground",children:"Organizations"}),L?null:(0,t.jsx)("button",{type:"button",onClick:r(G=>{G.preventDefault(),G.stopPropagation(),o(fe=>!fe)},"onClick"),className:"rounded px-1.5 py-0.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:i?"Done":"Edit"})]}),(0,t.jsx)("div",{className:"flex max-h-96 flex-col gap-0.5 overflow-y-auto px-2.5 pb-2 pt-1",children:L?(0,t.jsxs)(t.Fragment,{children:[D.map(G=>(0,t.jsx)(qJe,{stack:G,isSelected:G.stackSlug===V?.stackSlug,onSelect:de},G.stackSlug)),D.length===0?(0,t.jsx)(hs,{disabled:!0,children:z.isLoading?"Loading organizations...":z.isError?"Could not load organizations":"No organizations"}):null]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Ww,{sensors:R,collisionDetection:i1,onDragEnd:Y,children:(0,t.jsx)(Vw,{items:I.map(G=>G.id),strategy:r1,children:I.map(G=>(0,t.jsx)(zJe,{company:G,isEditing:i,isSelected:G.id===c?.id,onSelect:ae},G.id))})}),I.length===0?m?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(hs,{disabled:!0,children:"Couldn't load companies"}),(0,t.jsxs)(hs,{onSelect:r(G=>{G.preventDefault(),h()},"onSelect"),children:[(0,t.jsx)(qi,{className:"h-4 w-4 mr-2"}),"Try again"]})]}):(0,t.jsx)(hs,{disabled:!0,children:"No companies"}):null]})}),(0,t.jsxs)("div",{className:"flex flex-col gap-0.5 border-t border-border px-2.5 pb-2.5 pt-2",children:[L&&!H?null:(0,t.jsxs)(hs,{onClick:J,className:sD,disabled:i,children:[(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:(0,t.jsx)(gn,{className:"size-4"})}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:"Create organization"})]}),B?(0,t.jsx)(hs,{asChild:!0,disabled:i,className:sD,children:(0,t.jsxs)(Je,{to:"/company/settings/invites",onClick:r(G=>{if(i){G.preventDefault();return}te()},"onClick"),children:[(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:(0,t.jsx)(Tv,{className:"size-4"})}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:X?`Invite people to ${X}`:"Invite people"})]})}):null,A?.session?(0,t.jsxs)(hs,{className:sD,onClick:r(()=>le.mutate(),"onClick"),disabled:i||le.isPending,children:[(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:(0,t.jsx)(Yh,{className:"size-4"})}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:le.isPending?"Signing out...":"Sign out"})]}):null]})]})]})}r(KJe,"BuiltinCompanyMenu");function GJ(){const{openNewIssue:e}=$o(),[s,n]=(0,u.useState)(!0),[a,i]=(0,u.useState)(!0),{selectedCompanyId:o,selectedCompany:l}=ps(),{collapsed:c,peeking:d}=Va(),m=c&&!d,h=fU(o),{data:p,isFetched:f}=Z({queryKey:P.instance.experimentalSettings,queryFn:r(()=>Er.getExperimental(),"queryFn")}),g=P.liveRuns(o),v=mo({companyId:o,resourceKey:"live-runs",queryKey:g,enabled:!!o,refetchInterval:!1,leaderOnly:!0}),{data:y,dataUpdatedAt:w}=Z({queryKey:g,queryFn:r(()=>sa.liveRunsForCompany(o),"queryFn"),enabled:v.enabled,refetchInterval:v.refetchInterval});ho(v,y,w);const S=y?.length??0,j=p?.enableIsolatedWorkspaces===!0,N=p?.enableApps===!0,_=p?.enablePipelines===!0,R=p?.enableStatusCards===!0,C=!f,A=p?.enableGoalsSidebarLink===!0,T=p?.enableDecisions===!0,{data:I}=Z({queryKey:P.attention(o),queryFn:r(()=>q5.list(o),"queryFn"),enabled:!!o&&T,refetchInterval:6e4}),$=eme(I),O=p?.enableCases===!0,L=!0,E=p?.enableConferenceRoomChat===!0,q={companyId:o,companyPrefix:l?.issuePrefix??null};return(0,t.jsxs)("aside",{className:"w-full h-full min-h-0 border-r border-border bg-background flex flex-col",children:[(0,t.jsx)("div",{className:"flex items-center gap-1 px-3 h-12 shrink-0",children:(0,t.jsx)(UJe,{})}),(0,t.jsxs)("nav",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-auto-hide flex flex-col gap-4 pointer-coarse:gap-3 px-3 py-2",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(()=>{const B=(0,t.jsxs)("button",{onClick:r(()=>e(),"onClick"),"data-slot":"icon-button","aria-label":m?"New Task":void 0,className:"flex items-center gap-2.5 mx-2 rounded-lg px-2 py-1.5 pointer-coarse:py-1 text-(length:--text-compact) font-medium text-foreground/80 hover:bg-accent/50 hover:text-foreground transition-colors",children:[(0,t.jsx)(S1,{className:"h-4 w-4 shrink-0"}),(0,t.jsx)("span",{className:m?Nv:"truncate",children:"New Task"})]});return m?(0,t.jsxs)(Wn,{children:[(0,t.jsx)(Hn,{asChild:!0,children:B}),(0,t.jsx)(Qn,{side:"right",children:"New Task"})]}):B})(),(0,t.jsx)(Qa,{to:"/search",label:"Search",icon:ua}),(0,t.jsx)(Qa,{to:"/dashboard",label:"Dashboard",icon:fx,liveCount:S}),(0,t.jsx)(Qa,{to:"/inbox",label:"Inbox",icon:Pd,badge:h.inbox,badgeLabel:"unread",badgeTone:h.failedRuns>0?"danger":"default",alert:h.failedRuns>0}),T?(0,t.jsx)(Qa,{to:"/decisions",label:"Decisions",icon:k1,badge:$,badgeLabel:"decisions"}):null,R?(0,t.jsx)(Qa,{to:"/status",label:"Status",icon:nN,textBadge:"beta"}):null,E?(0,t.jsx)(Qa,{to:"/board-chat",label:"Conference Room",icon:Ude}):null]}),(0,t.jsxs)(xx,{label:"Work",collapsible:{open:s,onOpenChange:n},children:[(0,t.jsx)(Qa,{to:"/issues",label:"Tasks",icon:ld}),O?(0,t.jsx)(Qa,{to:"/cases",label:"Cases",icon:pl,textBadge:"beta"}):null,(0,t.jsx)(Qa,{to:"/routines",label:"Routines",icon:fu}),_?(0,t.jsx)(Qa,{to:"/pipelines",label:"Pipelines",icon:Do}):null,A?(0,t.jsx)(Qa,{to:"/goals",label:"Goals",icon:af}):C?(0,t.jsx)("div",{"data-testid":"sidebar-goals-placeholder",className:"h-8 pointer-coarse:h-7","aria-hidden":"true"}):null,(0,t.jsx)(Qa,{to:"/artifacts",label:"Artifacts",icon:Eh}),(0,t.jsx)(Qa,{to:"/skills",label:"Skills",icon:Ul}),j?(0,t.jsx)(Qa,{to:"/workspaces",label:"Workspaces",icon:Do}):null,(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Qa,{to:"/projects",label:"Projects",icon:Co}),(0,t.jsx)(OJe,{})]}),(0,t.jsx)(zh,{slotTypes:["sidebar"],context:q,className:"flex flex-col gap-0.5",itemClassName:"text-(length:--text-compact) font-medium",missingBehavior:"placeholder"}),(0,t.jsx)(aN,{placementZones:["sidebar"],context:q,className:"flex flex-col gap-0.5",itemClassName:"text-(length:--text-compact) font-medium"})]}),null,(0,t.jsx)(LJe,{streamlined:L}),(0,t.jsxs)(xx,{label:"Company",collapsible:{open:a,onOpenChange:i},children:[(0,t.jsx)(Qa,{to:"/org",label:"Org",icon:Gb}),N?(0,t.jsx)(Qa,{to:"/apps",label:"Connectors",icon:tT}):null,(0,t.jsx)(Qa,{to:"/timeline",label:"Timeline",icon:jg}),(0,t.jsx)(Qa,{to:"/costs",label:"Costs",icon:_h}),(0,t.jsx)(Qa,{to:"/activity",label:"Activity",icon:Cl}),(0,t.jsx)(Qa,{to:"/company/settings",label:"Settings",icon:$d})]}),(0,t.jsx)(zh,{slotTypes:["sidebarPanel"],context:q,className:"flex flex-col gap-3",itemClassName:"rounded-lg border border-border p-3",missingBehavior:"placeholder"})]})]})}r(GJ,"Sidebar");function VJe(e){const s=e.manifestJson.environmentDrivers??[];return s.length===0?!1:s.every(n=>n.kind==="sandbox_provider")}r(VJe,"isSandboxProviderOnly");function WJe(){const{selectedCompany:e,selectedCompanyId:s}=ps(),{isMobile:n,setSidebarOpen:a}=Va(),{hidden:i}=eh(),o=r(f=>!i.has(f),"showPage"),l=o("instance.plugins"),c=!!Yc(),{slots:d}=Gc({slotTypes:["companySettingsPage"],companyId:s,enabled:!!s}),{data:m}=Z({queryKey:s?P.sidebarBadges(s):["sidebar-badges","__disabled__"],queryFn:r(async()=>{try{return await Eme.get(s)}catch(f){if(f instanceof wn&&(f.status===401||f.status===403))return null;throw f}},"queryFn"),enabled:!!s,retry:!1,refetchInterval:15e3}),{data:h}=Z({queryKey:P.plugins.all,queryFn:r(()=>el.list(),"queryFn"),enabled:l}),p=(h??[]).filter(f=>!VJe(f));return(0,t.jsxs)("aside",{className:"w-full h-full min-h-0 border-r border-border bg-background flex flex-col",children:[(0,t.jsx)("div",{className:"flex flex-col gap-1 px-3 py-3 shrink-0",children:(0,t.jsxs)(Je,{to:"/dashboard",onClick:r(()=>{n&&a(!1)},"onClick"),className:"flex items-center gap-1.5 rounded-md px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",children:[(0,t.jsx)(bu,{className:"h-3.5 w-3.5 shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:e?.name??"Company"})]})}),(0,t.jsx)("nav",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-auto-hide px-3 py-2",children:(0,t.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,t.jsx)(Qa,{to:"/company/settings",label:"General",icon:nm,end:!0}),o("instance.profile")&&(0,t.jsx)(Qa,{to:"/company/settings/instance/profile",label:"Profile",icon:C1,end:!0}),o("company.members")&&(0,t.jsx)(Qa,{to:"/company/settings/members",label:"Members",icon:tl,badge:m?.joinRequests??0,end:!0}),d.filter(f=>f.routePath).map(f=>(0,t.jsx)(Qa,{to:`/company/settings/${f.routePath}`,label:f.displayName,icon:Dg,end:!0},`${f.pluginKey}:${f.id}`)),o("company.invites")&&(0,t.jsx)(Qa,{to:"/company/settings/invites",label:"Invites",icon:Q5e,end:!0}),o("company.secrets")&&(0,t.jsx)(Qa,{to:"/company/settings/secrets",label:"Secrets",icon:bi,end:!0}),o("instance.environments")&&(0,t.jsx)(Qa,{to:"/company/settings/instance/environments",label:"Environments",icon:Kde,end:!0}),o("instance.access")&&(0,t.jsx)(Qa,{to:"/company/settings/instance/access",label:"Access",icon:v5,end:!0}),o("instance.heartbeats")&&(0,t.jsx)(Qa,{to:"/company/settings/instance/heartbeats",label:"Heartbeats",icon:sh,end:!0}),o("company.export")&&(0,t.jsx)(Qa,{to:"/company/export",label:"Export",icon:Uo}),!c&&o("company.import")&&(0,t.jsx)(Qa,{to:"/company/import",label:"Import",icon:cw,end:!0}),o("instance.experimental")&&(0,t.jsx)(Qa,{to:"/company/settings/instance/experimental",label:"Experimental",icon:em}),l&&(0,t.jsx)(Qa,{to:"/company/settings/instance/plugins",label:"Plugins",icon:Dg}),l&&p.length>0?(0,t.jsx)("div",{className:"ml-4 mt-1 flex flex-col gap-0.5 border-l border-border/70 pl-3",children:p.map(f=>(0,t.jsx)(o0,{to:`${gh}/plugins/${f.id}`,state:gf,className:r(({isActive:g})=>["rounded-md px-2 py-1.5 text-xs transition-colors",g?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"].join(" "),"className"),children:f.manifestJson.displayName??f.packageName},f.id))}):null,o("instance.adapters")&&(0,t.jsx)(Qa,{to:"/company/settings/instance/adapters",label:"Adapters",icon:$m})]})})]})}r(WJe,"CompanySettingsSidebar");function HJe(){const{pathname:e}=na(),{selectedCompany:s}=ps(),{isMobile:n,setSidebarOpen:a}=Va(),i=Bme(),{enabled:o}=K5(),l=yU.filter(d=>!Fme(d.key)||o);if(e.endsWith("/apps/chat/connect"))return(0,t.jsx)(Yz,{});const c=e.match(/\/apps\/chat\/([^/]+)(?:\/(?:settings|access|reviews|conversations|activity))?\/?$/);return c?(0,t.jsx)(Ome,{endpointId:c[1],NavItem:Qa}):(0,t.jsxs)("aside",{className:"w-full h-full min-h-0 border-r border-border bg-background flex flex-col",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 px-3 py-3 shrink-0",children:[(0,t.jsxs)(Je,{to:"/dashboard",onClick:r(()=>{n&&a(!1)},"onClick"),className:"flex items-center gap-1.5 rounded-md px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",children:[(0,t.jsx)(bu,{className:"h-3.5 w-3.5 shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:s?.name??"Company"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1",children:[(0,t.jsx)(TH,{className:"h-4 w-4 text-muted-foreground shrink-0"}),(0,t.jsx)("span",{className:"flex-1 truncate text-sm font-bold text-foreground",children:"Connectors"})]})]}),(0,t.jsxs)("nav",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-auto-hide px-3 py-2",children:[(0,t.jsx)("div",{className:"px-3 pb-1 text-(length:--text-micro) font-semibold uppercase tracking-wide text-muted-foreground",children:"Connectors"}),(0,t.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,t.jsx)(Qa,{to:"/apps",label:"Browse",icon:eC,end:!0}),(0,t.jsx)(Qa,{to:"/apps/review",label:"Review",icon:rN,badge:i>0?i:void 0,badgeTone:"warning",badgeLabel:"waiting for your OK"})]}),(0,t.jsx)("div",{className:"px-3 pb-1 pt-4 text-(length:--text-micro) font-semibold uppercase tracking-wide text-muted-foreground",children:"Developer"}),(0,t.jsx)("p",{className:"px-3 pb-1.5 text-(length:--text-micro) leading-snug text-muted-foreground/70",children:"Advanced setup for developers. Most teams never open this."}),(0,t.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,t.jsx)(Qa,{to:"/apps/connections",label:"Connections",icon:TH,end:!0}),l.map(d=>(0,t.jsx)(Qa,{to:$g(d.key),label:d.label,icon:d.icon,end:!0},d.key))]})]})]})}r(HJe,"AppsSidebar");function YJ(e){const{selectedCompanyId:s}=ps(),{isMobile:n,setSidebarOpen:a}=Va(),i=Z({queryKey:P.tools.connection(e.kind==="connection"?e.connectionId:"__none__"),queryFn:r(()=>cs.getConnection(e.kind==="connection"?e.connectionId:""),"queryFn"),enabled:e.kind==="connection"&&!!e.connectionId}),o=Z({queryKey:P.tools.applications(s??"__none__"),queryFn:r(()=>cs.listApplications(s),"queryFn"),enabled:e.kind==="application"&&!!s}),l=Z({queryKey:P.tools.connections(s??"__none__"),queryFn:r(()=>cs.listConnections(s),"queryFn"),enabled:e.kind==="application"&&!!s}),c=Z({queryKey:P.apps.gallery(s??"__none__"),queryFn:r(()=>cs.listGallery(s),"queryFn"),enabled:!!s}),d=Z({queryKey:P.apps.attention(s??"__none__"),queryFn:r(()=>cs.listAppsAttention(s),"queryFn"),enabled:!!s,refetchInterval:3e4}),m=i.data,h=e.kind==="application"?(o.data?.applications??[]).find(S=>S.id===e.applicationId):null,p=YJe(e.kind==="application"?(l.data?.connections??[]).filter(S=>S.applicationId===e.applicationId):[]),f=m?cf(m):h?.name??"App",g=GJe(c.data?.apps??[],m,h??void 0),v=m?.id??p?.id??null,y=v?d.data?.apps.find(S=>S.connection.id===v):null,w=(y?.pendingActionRequestCount??0)+((y?.quarantinedCatalogEntryCount??0)>0?1:0);return(0,t.jsxs)("aside",{className:"flex h-full min-h-0 w-full flex-col border-r border-border bg-background",children:[(0,t.jsxs)("div",{className:"flex shrink-0 flex-col gap-3 px-3 py-3",children:[(0,t.jsxs)(Je,{to:"/apps/connections",onClick:r(()=>{n&&a(!1)},"onClick"),className:"flex items-center gap-1.5 rounded-md px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",children:[(0,t.jsx)(bu,{className:"h-3.5 w-3.5 shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:"All apps"})]}),(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2 px-2 py-1",children:[(0,t.jsx)(wc,{name:f,logoUrl:E1(g),size:28}),(0,t.jsx)("span",{className:"flex-1 truncate text-sm font-bold text-foreground",children:f})]})]}),(0,t.jsx)("nav",{className:"scrollbar-auto-hide min-h-0 flex-1 overflow-y-auto px-3 py-2",children:(0,t.jsx)("div",{className:"flex flex-col gap-0.5",children:V5.map(S=>(0,t.jsx)(Qa,{to:QJe(e,S.key),label:S.label,icon:S.icon,end:!0,badge:S.key==="review"&&w>0?w:void 0,badgeTone:"danger",badgeLabel:"needing review"},S.key))})})]})}r(YJ,"AppDetailSidebar");function QJe(e,s){return e.kind==="connection"?Vu(e.connectionId,s):vS(e.applicationId,s)}r(QJe,"tabHref");function GJe(e,s,n){if(n?.applicationKey){const i=e.find(o=>zc(o)===n.applicationKey);if(i)return i}const a=(s?.name??n?.name)?.toLowerCase();return a?e.find(i=>Xg(i).toLowerCase()===a)??e.find(i=>zc(i)===a)??null:null}r(GJe,"galleryEntryFor$1");function YJe(e){const s=e.filter(n=>n.status==="archived");return s.length===0?null:s.reduce((n,a)=>{const i=new Date(n.updatedAt??n.createdAt??0).getTime();return new Date(a.updatedAt??a.createdAt??0).getTime()>i?a:n})}r(YJe,"latestArchivedConnection$1");function nD({identifier:e}){return e?(0,t.jsx)("span",{className:"shrink-0 font-mono text-muted-foreground",children:e}):null}r(nD,"CrumbIdentifier");function JJe({context:e}){const{slots:s}=Gc({slotTypes:["globalToolbarButton"],companyId:e.companyId}),{launchers:n}=xU({placementZones:["globalToolbarButton"],companyId:e.companyId,enabled:!!e.companyId});return(0,t.jsxs)("div",{className:"ml-auto flex shrink-0 items-center gap-1 pl-2 empty:hidden",children:[s.length>0?(0,t.jsx)(zh,{slotTypes:["globalToolbarButton"],context:e,className:"flex items-center gap-1"}):null,n.length>0?(0,t.jsx)(aN,{placementZones:["globalToolbarButton"],context:e,className:"flex items-center gap-1"}):null]})}r(JJe,"GlobalToolbar");function XJe(){const{breadcrumbs:e,mobileToolbar:s}=qn(),{toggleSidebar:n,isMobile:a}=Va(),{selectedCompanyId:i,selectedCompany:o}=ps(),l=(0,u.useMemo)(()=>({companyId:i??null,companyPrefix:o?.issuePrefix??null}),[i,o?.issuePrefix]),c=(0,t.jsx)(JJe,{context:l});if(a&&s)return(0,t.jsx)("div",{className:"border-b border-border px-2 h-12 shrink-0 flex items-center",children:s});if(e.length===0)return(0,t.jsx)("div",{className:"border-b border-border px-4 md:px-6 h-12 shrink-0 flex items-center justify-end",children:c});const d=a&&(0,t.jsx)(F,{variant:"ghost",size:"icon-sm",className:"mr-2 shrink-0",onClick:n,"aria-label":"Open sidebar",children:(0,t.jsx)(Bde,{className:"h-5 w-5"})});return e.length===1?(0,t.jsxs)("div",{className:"border-b border-border px-4 md:px-6 h-12 shrink-0 flex items-center",children:[d,(0,t.jsx)("div",{className:"min-w-0 overflow-hidden flex-1",children:e[0].leading||e[0].identifier?(0,t.jsxs)("h1",{className:"flex items-center gap-1.5 text-sm font-semibold uppercase tracking-wider",children:[e[0].leading&&(0,t.jsx)("span",{className:"flex shrink-0 items-center",children:e[0].leading}),(0,t.jsx)(nD,{identifier:e[0].identifier}),(0,t.jsx)("span",{className:"truncate",children:e[0].label})]}):(0,t.jsx)("h1",{className:"text-sm font-semibold uppercase tracking-wider truncate",children:e[0].label})}),c]}):(0,t.jsxs)("div",{className:"border-b border-border px-4 md:px-6 h-12 shrink-0 flex items-center",children:[d,(0,t.jsx)("div",{className:"min-w-0 overflow-hidden flex-1",children:(0,t.jsx)(jU,{className:"min-w-0 overflow-hidden",children:(0,t.jsx)(wU,{className:"flex-nowrap",children:e.map((m,h)=>{const p=h===e.length-1;return(0,t.jsxs)(u.Fragment,{children:[h>0&&(0,t.jsx)(mT,{}),(0,t.jsx)(yS,{className:p?"min-w-0":"shrink-0",children:p||!m.href?m.leading||m.identifier?(0,t.jsxs)(oC,{className:"flex min-w-0 items-center gap-1.5",children:[m.leading&&(0,t.jsx)("span",{className:"flex shrink-0 items-center",children:m.leading}),(0,t.jsx)(nD,{identifier:m.identifier}),(0,t.jsx)("span",{className:"truncate",children:m.label})]}):(0,t.jsx)(oC,{className:"truncate",children:m.label}):(0,t.jsx)(uT,{asChild:!0,children:m.leading||m.identifier?(0,t.jsxs)(Je,{to:m.href,onClick:m.onClick,className:"flex items-center gap-1.5",children:[m.leading&&(0,t.jsx)("span",{className:"flex shrink-0 items-center",children:m.leading}),(0,t.jsx)(nD,{identifier:m.identifier}),(0,t.jsx)("span",{className:"truncate",children:m.label})]}):(0,t.jsx)(Je,{to:m.href,onClick:m.onClick,children:m.label})})})]},h)})})})}),c]})}r(XJe,"BreadcrumbBar");var II=240,sB=208,nB=420,JJ=16;function WT(e){return Math.min(nB,Math.max(sB,e))}r(WT,"clampSidebarWidth");function XJ(e){if(typeof window>"u")return II;try{const s=window.localStorage.getItem(e);if(!s)return II;const n=Number.parseInt(s,10);return Number.isFinite(n)?WT(n):II}catch{return II}}r(XJ,"readStoredSidebarWidth");function ZJ(e,s){if(!(typeof window>"u"))try{window.localStorage.setItem(e,String(WT(s)))}catch{}}r(ZJ,"writeStoredSidebarWidth");function ZJe({children:e,open:s,collapsed:n=!1,peeking:a=!1,resizable:i=!1,storageKey:o="paperclip.sidebar.width",className:l,onPanelMouseEnter:c,onPanelMouseLeave:d,onPanelFocusCapture:m,onPanelBlurCapture:h}){const[p,f]=(0,u.useState)(()=>XJ(o)),[g,v]=(0,u.useState)(!1),y=(0,u.useRef)(p),w=(0,u.useRef)(null);(0,u.useEffect)(()=>{const E=XJ(o);y.current=E,f(E)},[o]);const S=s?p:0,j=s?n?64:S:0,N=s?n&&!a?64:S:0,_=N>j,R=i&&s&&!n,C=(0,u.useMemo)(()=>({width:`${j}px`}),[j]),A=(0,u.useMemo)(()=>({width:`${N}px`}),[N]),T=(0,u.useCallback)(E=>{const q=WT(E);y.current=q,f(q),ZJ(o,q)},[o]),I=(0,u.useCallback)(E=>{R&&(E.preventDefault(),E.currentTarget.setPointerCapture(E.pointerId),w.current={startX:E.clientX,startWidth:y.current},v(!0))},[R]),$=(0,u.useCallback)(E=>{if(!w.current)return;const q=WT(w.current.startWidth+E.clientX-w.current.startX);y.current=q,f(q)},[]),O=(0,u.useCallback)(()=>{w.current&&(w.current=null,v(!1),ZJ(o,y.current))},[o]),L=(0,u.useCallback)(E=>{R&&(E.key==="ArrowLeft"?(E.preventDefault(),T(p-JJ)):E.key==="ArrowRight"?(E.preventDefault(),T(p+JJ)):E.key==="Home"?(E.preventDefault(),T(sB)):E.key==="End"&&(E.preventDefault(),T(nB)))},[R,T,p]);return(0,t.jsx)("div",{className:U("relative h-full shrink-0",l),style:C,children:(0,t.jsxs)("div",{className:U("absolute inset-y-0 left-0 flex flex-col overflow-hidden",_?"z-30 border-r border-border bg-background shadow-lg":"z-0"),style:A,"data-sidebar-overlay":_?"":void 0,onMouseEnter:c,onMouseLeave:d,onFocusCapture:m,onBlurCapture:h,children:[e,R?(0,t.jsx)("div",{role:"separator","aria-label":"Resize sidebar","aria-orientation":"vertical","aria-valuemin":sB,"aria-valuemax":nB,"aria-valuenow":p,tabIndex:0,className:U("absolute inset-y-0 right-0 z-20 w-3 cursor-col-resize touch-none outline-none","before:absolute before:inset-y-0 before:left-1/2 before:w-px before:-translate-x-1/2 before:bg-transparent before:transition-colors","hover:before:bg-border focus-visible:before:bg-ring",g&&"before:bg-ring"),onPointerDown:I,onPointerMove:$,onPointerUp:O,onPointerCancel:O,onLostPointerCapture:O,onKeyDown:L}):null]})})}r(ZJe,"SidebarShell");function eXe({children:e,className:s}){return(0,t.jsx)("div",{"data-secondary-sidebar":"",className:U("h-full w-60 shrink-0 overflow-y-auto border-r border-border bg-background",s),children:(0,t.jsx)(RJe,{children:e})})}r(eXe,"SecondarySidebar");var tXe="/company/settings/instance/profile",sXe="https://docs.paperclip.ing/",nXe="https://paperclip.ing/feedback";function rXe(e){const s=e.trim().split(/\s+/).filter(Boolean);return s.length>=2?`${s[0]?.[0]??""}${s[s.length-1]?.[0]??""}`.toUpperCase():e.slice(0,2).toUpperCase()}r(rXe,"deriveInitials$1");function aXe(e,s,n){const a=[e,s?.split("@")[0],s,n];for(const i of a){const o=i?.trim().toLowerCase().replace(/['"]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");if(o)return o}return"me"}r(aXe,"deriveUserSlug");function rD({label:e,description:s,icon:n,onClick:a,href:i,external:o=!1}){const l="flex w-full items-start gap-3 rounded-xl px-3 py-3 text-left transition-colors hover:bg-accent/60",c=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"mt-0.5 rounded-lg border border-border bg-background/70 p-2 text-muted-foreground",children:(0,t.jsx)(n,{className:"size-4"})}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block text-sm font-medium text-foreground",children:e}),(0,t.jsx)("span",{className:"block text-xs text-muted-foreground",children:s})]})]});return i?o?(0,t.jsx)("a",{href:i,target:"_blank",rel:"noreferrer",className:l,onClick:a,children:c}):(0,t.jsx)(Je,{to:i,className:l,onClick:a,children:c}):(0,t.jsx)("button",{type:"button",className:l,onClick:a,children:c})}r(rD,"MenuAction");function eX({deploymentMode:e,open:s,onOpenChange:n}){const a=!!Yc(),[i,o]=(0,u.useState)(!1),{isMobile:l,setSidebarOpen:c,collapsed:d,peeking:m}=Va(),h=d&&!m,p=s??i,f=n??o,{data:g}=Z({queryKey:P.auth.session,queryFn:r(()=>qa.getSession(),"queryFn"),retry:!1}),v=iN({onSignedOut:N}),y=g?.user.name?.trim()||"Board",w=g?.user.email?.trim()||(e==="authenticated"?"Signed in":"Local workspace board"),S=rXe(y),j=`/u/${aXe(g?.user.name,g?.user.email,g?.user.id)}`;function N(){f(!1),l&&c(!1)}r(N,"closeNavigationChrome");function _(){v.mutate()}return r(_,"handleSignOut"),(0,t.jsx)("div",{className:"border-t border-r border-border bg-background px-3 py-2",children:(0,t.jsxs)("div",{className:U("flex items-center gap-0.5",!h&&"px-2"),children:[(0,t.jsxs)(Zn,{open:p,onOpenChange:f,children:[(0,t.jsx)(ur,{asChild:!0,children:(0,t.jsxs)("button",{type:"button",className:U("flex min-w-0 items-center gap-2.5 rounded-lg text-left text-(length:--text-compact) font-medium text-foreground/80 transition-colors hover:bg-accent/50 hover:text-foreground",h?"w-full px-3 py-2":"flex-1 px-2 py-1.5"),"aria-label":"Open account menu",children:[(0,t.jsxs)(Gi,{size:"sm",children:[g?.user.image?(0,t.jsx)(Hc,{src:g.user.image,alt:y}):null,(0,t.jsx)(Yi,{children:S})]}),(0,t.jsx)("span",{className:U("min-w-0 flex-1 truncate",h&&"block w-0 min-w-0 overflow-hidden whitespace-nowrap text-transparent select-none"),children:y})]})}),(0,t.jsxs)(Vn,{side:"top",align:"start",sideOffset:10,className:"w-(--sz-277px) max-w-(--sz-calc-24) overflow-hidden rounded-t-2xl rounded-b-none border-border p-0 shadow-2xl",children:[(0,t.jsx)("div",{className:"h-24 bg-(image:--gradient-extract-25)"}),(0,t.jsxs)("div",{className:"-mt-8 px-4 pb-4",children:[(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)("div",{className:"rounded-2xl border-4 border-popover bg-popover p-0.5 shadow-sm",children:(0,t.jsxs)(Gi,{size:"lg",children:[g?.user.image?(0,t.jsx)(Hc,{src:g.user.image,alt:y}):null,(0,t.jsx)(Yi,{children:S})]})}),(0,t.jsxs)("div",{className:"min-w-0 flex-1 pt-1",children:[(0,t.jsx)("h2",{className:"truncate text-base font-semibold text-foreground",children:y}),(0,t.jsx)("p",{className:"truncate text-sm text-muted-foreground",children:w})]})]}),(0,t.jsxs)("div",{className:"mt-4 space-y-1",children:[(0,t.jsx)(rD,{label:"View profile",description:"Open your activity, task, and usage ledger.",icon:vu,href:j,onClick:N}),(0,t.jsx)(rD,{label:"Edit profile",description:"Update your display name and avatar.",icon:C1,href:tXe,onClick:N}),(0,t.jsx)(rD,{label:"Documentation",description:"Open Paperclip docs in a new tab.",icon:sN,href:sXe,external:!0,onClick:r(()=>f(!1),"onClick")}),(0,t.jsx)(Bj,{variant:"menu-action",onAfterToggle:r(()=>f(!1),"onAfterToggle")}),e==="authenticated"?(0,t.jsxs)("button",{type:"button",className:U("flex w-full items-start gap-3 rounded-xl px-3 py-3 text-left transition-colors hover:bg-destructive/10",v.isPending&&"cursor-not-allowed opacity-60"),onClick:_,disabled:v.isPending,children:[(0,t.jsx)("span",{className:"mt-0.5 rounded-lg border border-border bg-background/70 p-2 text-muted-foreground",children:(0,t.jsx)(Yh,{className:"size-4"})}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block text-sm font-medium text-foreground",children:v.isPending?"Signing out...":"Sign out"}),(0,t.jsx)("span",{className:"block text-xs text-muted-foreground",children:"End this browser session."})]})]}):null,(0,t.jsx)(ige,{})]})]})]})]}),!h&&!a?(0,t.jsxs)(Wn,{children:[(0,t.jsx)(Hn,{asChild:!0,children:(0,t.jsx)("a",{href:nXe,target:"_blank",rel:"noreferrer","aria-label":"Share feedback",className:"flex size-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground/50 transition-colors hover:bg-accent/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:(0,t.jsx)(Px,{className:"h-4 w-4","aria-hidden":"true"})})}),(0,t.jsx)(Qn,{side:"top",children:"Share feedback"})]}):null]})})}r(eX,"SidebarAccountMenu");function iXe(e,s){return wge(e,s)[0]?.toLowerCase()??null}r(iXe,"getCompanyRouteSegment");function wge(e,s){if(!s)return[];const n=e.split("/").filter(Boolean);return n.length<2?[]:n[0]?.toUpperCase()!==s.toUpperCase()?[]:n.slice(1)}r(wge,"getCompanyPathSegments");var oXe=new Set(["browse","connections","connect","chat","review","attention","gateways","advanced","app"]);function lXe(e,s){const n=e.split("/").filter(Boolean);return n[0]?.toLowerCase()==="skills"?!0:s?n[0]?.toUpperCase()===s.toUpperCase()&&n[1]?.toLowerCase()==="skills":!1}r(lXe,"isSkillsStoreRoute");function cXe(){const{sidebarOpen:e,setSidebarOpen:s,toggleSidebar:n,collapsed:a,peeking:i,setPeeking:o,isMobile:l,setForceCollapsed:c}=Va(),{openNewIssue:d,openOnboarding:m}=$o(),{togglePanelVisible:h}=yf(),p=_c()?.pushToast??null,{companies:f,loading:g,selectedCompany:v,selectedCompanyId:y,selectionSource:w,setSelectedCompanyId:S}=ps(),{companyPrefix:j,pluginRoutePath:N}=Sa(),_=Yn(),R=na(),C=m5(),A=["/company/settings","/company/export","/company/import"].some(xt=>R.pathname.includes(xt)),T=wge(R.pathname,j),I=T[0]?.toLowerCase()==="tools",$=T[0]?.toLowerCase()==="apps",O=$&&T[1]&&!oXe.has(T[1].toLowerCase())?T[1]:null,L=$&&T[1]?.toLowerCase()==="app"&&T[2]?T[2]:null,E=lXe(R.pathname,j),q=(0,u.useRef)(!1),B=(0,u.useRef)(null),K=(0,u.useRef)(null),z=(0,u.useRef)(new pue),D=(0,u.useRef)(R.key),V=mge(R.pathname,j,l),[H,ee]=(0,u.useState)(!1),X=(0,u.useMemo)(()=>{if(!j)return null;const xt=j.toUpperCase();return f.find(De=>De.issuePrefix.toUpperCase()===xt)??null},[f,j]),le=!!j&&!g&&f.length>0&&!X,ce=(0,u.useMemo)(()=>N?.toLowerCase()??iXe(R.pathname,j),[j,R.pathname,N]),te=X?.id??null,ae=X?.issuePrefix??null,{slots:de}=Gc({slotTypes:["page","routeSidebar"],companyId:te,enabled:!!(te&&ce)}),J=(0,u.useMemo)(()=>oU(de,ce),[ce,de]),Y=(0,u.useMemo)(()=>({companyId:te,companyPrefix:ae}),[te,ae]),G=A?(0,t.jsx)(WJe,{}):O?(0,t.jsx)(YJ,{kind:"connection",connectionId:O}):L?(0,t.jsx)(YJ,{kind:"application",applicationId:L}):$||I?(0,t.jsx)(HJe,{}):J?(0,t.jsx)(yu,{slot:J,context:Y,className:"h-full w-full",missingBehavior:"placeholder"}):null,fe=G!=null,{data:se}=Z({queryKey:P.health,queryFn:r(()=>sm.get(),"queryFn"),retry:!1,refetchInterval:r(xt=>xt.state.data?.devServer?.enabled?2e3:!1,"refetchInterval"),refetchIntervalInBackground:!1}),re=Z({queryKey:P.instance.generalSettings,queryFn:r(()=>Er.getGeneral(),"queryFn")}).data?.keyboardShortcuts===!0,ie=fe||E;(0,u.useLayoutEffect)(()=>(c(ie),()=>c(!1)),[ie,c]),(0,u.useEffect)(()=>{g||q.current||se?.deploymentMode!=="authenticated"&&(se?.cloud||f.length===0&&(q.current=!0,m()))},[f,g,m,se?.cloud,se?.deploymentMode]),(0,u.useEffect)(()=>{if(!j||g||f.length===0)return;if(!X){const De=(y?f.find(Qe=>Qe.id===y):null)??f[0]??null;De&&y!==De.id&&S(De.id,{source:"route_sync"});return}if(j!==X.issuePrefix){const De=R.pathname.replace(/^\/[^/]+/,"");_(`/${X.issuePrefix}${De}${R.search}`,{replace:!0});return}const xt=hge({matchedCompany:X,selectedCompanyId:y,companies:f});if(xt){p?.({title:`${X.name} is archived`,body:`Switched to ${xt.name}.`,tone:"info",dedupeKey:`archived-company-bounce:${X.id}`}),S(xt.id,{source:"route_sync"}),_(`/${xt.issuePrefix}/dashboard`,{replace:!0});return}pge({selectionSource:w,selectedCompanyId:y,routeCompanyId:X.id})&&S(X.id,{source:"route_sync"})},[j,f,g,X,R.pathname,R.search,_,p,w,y,S]);const me=h,pe=(0,u.useCallback)(()=>{document.dispatchEvent(new KeyboardEvent("keydown",{key:"k",metaKey:!0,bubbles:!0,cancelable:!0}))},[]),be=(0,u.useRef)(null),oe=(0,u.useRef)(!1),ye=(0,u.useRef)(!1),Ae=(0,u.useCallback)(()=>{be.current!==null&&(window.clearTimeout(be.current),be.current=null)},[]),xe=(0,u.useCallback)(()=>{Ae(),be.current=window.setTimeout(()=>o(!0),50)},[Ae,o]),_e=(0,u.useCallback)(()=>{Ae(),o(!0)},[Ae,o]),Ge=(0,u.useCallback)(()=>{Ae(),be.current=window.setTimeout(()=>o(!1),120)},[Ae,o]),$e=(0,u.useCallback)(()=>{oe.current=!0,a&&!ye.current&&xe()},[a,xe]),Ye=(0,u.useCallback)(()=>{oe.current=!1,ye.current=!1,Ge()},[Ge]),ue=(0,u.useCallback)(()=>{ye.current||_e()},[_e]),Oe=(0,u.useCallback)(()=>{oe.current||Ge()},[Ge]);(0,u.useEffect)(()=>Ae,[Ae]);const dt=(0,u.useRef)(a);return(0,u.useEffect)(()=>{a!==dt.current&&(a?(Ae(),o(!1),ye.current=oe.current):ye.current=!1,dt.current=a)},[a,Ae,o]),(0,u.useEffect)(()=>{if(!i)return;const xt=r(De=>{De.key==="Escape"&&(Ae(),o(!1))},"onKeyDown");return window.addEventListener("keydown",xt),()=>window.removeEventListener("keydown",xt)},[i,Ae,o]),uge(),oge({enabled:re,onNewIssue:r(()=>d(),"onNewIssue"),onSearch:pe,onToggleSidebar:n,onTogglePanel:me,onShowShortcuts:r(()=>ee(!0),"onShowShortcuts"),onGoToInbox:r(()=>_("/inbox"),"onGoToInbox")}),(0,u.useEffect)(()=>{if(!l)return;const xt=30,De=50,Qe=75;let ht=0,We=0;const Ke=r(tt=>{const Se=tt.touches[0];ht=Se.clientX,We=Se.clientY},"onTouchStart"),gt=r(tt=>{const Se=tt.changedTouches[0],ke=Se.clientX-ht;if(!(Math.abs(Se.clientY-We)>Qe)){if(!e&&ht<xt&&ke>De){s(!0);return}e&&ke<-50&&s(!1)}},"onTouchEnd");return document.addEventListener("touchstart",Ke,{passive:!0}),document.addEventListener("touchend",gt,{passive:!0}),()=>{document.removeEventListener("touchstart",Ke),document.removeEventListener("touchend",gt)}},[l,e,s]),(0,u.useEffect)(()=>{const xt=document.body.style.overflow;return document.body.style.overflow=l?"visible":"clip",()=>{document.body.style.overflow=xt}},[l]),(0,u.useEffect)(()=>{if(!l)return xge()},[l]),(0,u.useEffect)(()=>{if(typeof document>"u")return;const xt=K.current;return fge(xt)},[R.pathname]),(0,u.useEffect)(()=>{const xt=K.current;if(!xt)return;const De=r(()=>{z.current.remember(D.current,xt.scrollTop)},"recordScroll");return xt.addEventListener("scroll",De,{passive:!0}),()=>xt.removeEventListener("scroll",De)},[]),(0,u.useLayoutEffect)(()=>{const xt=K.current,De=hue({previousPathname:B.current,pathname:R.pathname,navigationType:C,state:R.state});B.current=R.pathname;const Qe=C==="POP",ht=Qe?z.current.recall(R.key):0;if(D.current=R.key,Qe){nT(xt,ht);const We=requestAnimationFrame(()=>nT(xt,ht));return()=>cancelAnimationFrame(We)}De&&fue(xt)},[R.key,R.pathname,R.state,C]),(0,t.jsx)(mue,{children:(0,t.jsx)(vce,{value:{keyboardShortcutsEnabled:re},children:(0,t.jsxs)("div",{className:U("bg-background text-foreground pt-(--sz-safe-top)",l?"min-h-dvh overflow-x-clip":"flex h-dvh flex-col overflow-clip"),children:[(0,t.jsx)("a",{href:"#main-content",className:"sr-only focus:not-sr-only focus:fixed focus:left-3 focus:top-3 focus:z-(--z-200) focus:rounded-md focus:bg-background focus:px-3 focus:py-2 focus:text-sm focus:font-medium focus:shadow-lg focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:"Skip to Main Content"}),(0,t.jsx)(tge,{}),(0,t.jsx)(sge,{devServer:se?.devServer}),(0,t.jsxs)("div",{className:U("min-h-0 flex-1",l?"w-full":"flex overflow-clip"),children:[l&&e&&(0,t.jsx)("button",{type:"button",className:"fixed inset-0 z-40 bg-black/50",onClick:r(()=>s(!1),"onClick"),"aria-label":"Close sidebar"}),l?(0,t.jsxs)("div",{className:U("fixed inset-y-0 left-0 z-50 flex flex-col overflow-hidden pt-(--sz-safe-top) transition-transform duration-100 ease-out",e?"translate-x-0":"-translate-x-full"),children:[(0,t.jsx)("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:(0,t.jsx)("div",{className:"w-60 shrink-0 overflow-hidden",children:fe?G:(0,t.jsx)(GJ,{})})}),(0,t.jsx)(eX,{deploymentMode:se?.deploymentMode})]}):(0,t.jsxs)(ZJe,{open:e,collapsed:a,peeking:i,resizable:!0,onPanelMouseEnter:$e,onPanelMouseLeave:Ye,onPanelFocusCapture:a?ue:void 0,onPanelBlurCapture:a?Oe:void 0,children:[(0,t.jsx)("div",{className:"flex flex-1 min-h-0",children:(0,t.jsx)(GJ,{})}),(0,t.jsx)(eX,{deploymentMode:se?.deploymentMode})]}),!l&&fe?(0,t.jsx)(eXe,{children:G}):null,(0,t.jsxs)("div",{className:U("flex min-w-0 flex-col",l?"w-full":"h-full flex-1"),children:[(0,t.jsxs)("div",{className:U(l&&"sticky top-0 z-20 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/85"),children:[(0,t.jsx)(ZF,{mobile:l}),(0,t.jsx)(XJe,{}),l&&A?(0,t.jsx)("div",{className:"border-b border-border px-4 pb-3",children:(0,t.jsx)($me,{})}):null]}),(0,t.jsxs)("div",{className:U(l?"block":"flex flex-1 min-h-0"),children:[(0,t.jsx)("main",{id:"main-content",ref:K,tabIndex:-1,style:l?{"--tc-composer-bottom":"var(--sz-calc-14)"}:void 0,className:U("flex-1 p-4 outline-none md:p-6",l?"overflow-visible pb-(--sz-calc-14)":"overflow-auto [scrollbar-gutter:stable]"),children:le?(0,t.jsx)(xu,{scope:"invalid_company_prefix",requestedPrefix:j??v?.issuePrefix}):(0,t.jsx)(age,{children:(0,t.jsx)(i0,{})})}),(0,t.jsx)(Gme,{})]})]})]}),l&&(0,t.jsx)(ege,{visible:V}),(0,t.jsx)(Xme,{}),(0,t.jsx)(uhe,{}),(0,t.jsx)(Wxe,{}),(0,t.jsx)(Gxe,{}),(0,t.jsx)(Yxe,{}),(0,t.jsx)(Jxe,{open:H,onOpenChange:ee}),(0,t.jsx)(Xxe,{}),(0,t.jsx)(Zxe,{localTrusted:se?.deploymentMode==="local_trusted"})]})})})}r(cXe,"Layout");var tX=null;function dXe(){return tX??=new l1,tX}r(dXe,"getDetachedClient");function uXe(){const e=(0,u.useContext)(l5),{data:s,isFetched:n}=Z({queryKey:P.instance.experimentalSettings,queryFn:r(()=>Er.getExperimental(),"queryFn"),enabled:e!=null},e??dXe());return e?{enabled:s?.enableConferenceRoomChat===!0,loaded:n}:{enabled:!1,loaded:!0}}r(uXe,"useConferenceRoomChatEnabled");function mXe(){const{enabled:e,loaded:s}=uXe();return s?e?(0,t.jsx)(i0,{}):(0,t.jsx)(kn,{to:"/dashboard",replace:!0}):null}r(mXe,"ConferenceRoomChatGate");var hXe=["session-start","human-message","agent-message","thinking","responding","responding-burst","tool-call","diff","working","running","completed","activity-phases","awaiting-approval","plan-todo","interrupted","refused","truncated","live-token-cost"],pXe={"session-start":{id:"session-start",label:"Session start",tier:"live",surface:"thread",protocol:'acpx.session → TranscriptEntry kind:"init"'},"human-message":{id:"human-message",label:"Human message",tier:"live",surface:"thread",protocol:'IssueComment authorType:"user"'},"agent-message":{id:"agent-message",label:"Final response",tier:"live",surface:"thread",protocol:'PRP item.delta kind:"agentMessage" channel:"final"'},thinking:{id:"thinking",label:"Thinking",tier:"live",surface:"thread",protocol:"text_delta stream:thought (ACP agent_thought_chunk)"},responding:{id:"responding",label:"Progress update (streaming)",tier:"live",surface:"thread",protocol:'PRP item.delta kind:"agentMessage" channel:"progress"'},"responding-burst":{id:"responding-burst",label:"Progress update burst",tier:"live",surface:"thread",protocol:"text_delta stream:output ×N, tool calls between (PAP-368 dwell)"},"tool-call":{id:"tool-call",label:"Tool call",tier:"live",surface:"thread",protocol:"acpx.tool_call (ACP tool_call / tool_call_update)"},diff:{id:"diff",label:"Diff",tier:"live",surface:"thread",protocol:'ToolCallContent type:"diff" → TranscriptEntry kind:"diff"'},working:{id:"working",label:"Working",tier:"live",surface:"thread",protocol:"heartbeat.run.progress + acpx.status"},running:{id:"running",label:"Running",tier:"live",surface:"thread",protocol:'message.status.type === "running"'},completed:{id:"completed",label:"Completed (collapsed)",tier:"live",surface:"thread",protocol:"acpx.result (StopReason in subtype)"},"activity-phases":{id:"activity-phases",label:"Long-run activity phases",tier:"live",surface:"thread",protocol:"assistant boundaries + chronological tool calls"},"awaiting-approval":{id:"awaiting-approval",label:"Awaiting approval",tier:"tier-b",surface:"thread",protocol:"ACP RequestPermissionRequest + PermissionOptionKind"},"plan-todo":{id:"plan-todo",label:"Plan / todo",tier:"tier-b",surface:"plan",protocol:"ACP Plan { entries: PlanEntry[] }, PlanEntryStatus"},interrupted:{id:"interrupted",label:"Interrupted",tier:"tier-b",surface:"thread",protocol:'AcpRuntimeTurnResult.status:"cancelled" / StopReason "cancelled"'},refused:{id:"refused",label:"Refused",tier:"tier-b",surface:"thread",protocol:'StopReason "refusal"'},truncated:{id:"truncated",label:"Truncated",tier:"tier-b",surface:"thread",protocol:'StopReason "max_tokens" | "max_turn_requests"'},"live-token-cost":{id:"live-token-cost",label:"Live token / cost",tier:"tier-b",surface:"thread",protocol:"ACP UsageUpdate { used, size, cost }"}},L7t=hXe.map(e=>pXe[e]);function Nge({item:e}){return(0,t.jsx)("article",{className:"rounded-lg border border-border bg-card p-3","aria-label":`Project created: ${e.name}`,children:(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)(p5e,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),(0,t.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:[(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Project created"}),(0,t.jsx)(Je,{to:`/projects/${e.projectId}`,className:"break-words text-sm font-medium hover:underline focus-visible:underline",children:e.name}),e.description&&(0,t.jsx)("p",{className:"line-clamp-3 text-sm text-muted-foreground",children:e.description}),e.repositories.length>0&&(0,t.jsx)("ul",{className:"space-y-1 pt-1",children:e.repositories.map(s=>(0,t.jsxs)("li",{className:"flex min-w-0 items-center gap-2 text-xs text-muted-foreground",children:[(0,t.jsx)(Do,{className:"size-3 shrink-0","aria-hidden":!0}),(0,t.jsx)("a",{className:"truncate hover:underline focus-visible:underline",href:s.url,target:"_blank",rel:"noreferrer",children:s.name})]},s.id))})]})]})})}r(Nge,"TaskChatProjectCreatedCard");function fXe({item:e,onOpen:s}){return(0,t.jsx)("article",{className:"rounded-lg border border-border bg-card p-3","aria-label":`Skill created: ${e.name}`,children:(0,t.jsxs)("button",{type:"button",className:"flex w-full items-start gap-3 text-left",onClick:r(()=>s?.(e.skillId,e.name),"onClick"),children:[(0,t.jsx)(jx,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),(0,t.jsxs)("span",{className:"min-w-0 flex-1 space-y-1",children:[(0,t.jsx)("span",{className:"block text-xs text-muted-foreground",children:"Skill created"}),(0,t.jsx)("span",{className:"block break-words text-sm font-medium hover:underline focus-visible:underline",children:e.name}),e.description?(0,t.jsx)("span",{className:"block line-clamp-3 text-sm text-muted-foreground",children:e.description}):null]})]})})}r(fXe,"TaskChatSkillCreatedCard");var kge=(0,u.createContext)("streamlined");function xXe({mode:e,children:s}){return(0,t.jsx)(kge.Provider,{value:e,children:s})}r(xXe,"TaskChatPresentationProvider");function Xh(){return(0,u.useContext)(kge)==="streamlined"}r(Xh,"useStreamlinedTaskChatPresentation");function gXe(e){return(0,t.jsxs)("svg",{viewBox:"0 0 180 180",fill:"none",stroke:"currentColor",strokeWidth:14,strokeLinecap:"round",xmlns:"http://www.w3.org/2000/svg",...e,children:[(0,t.jsx)("path",{d:"M18 84.8528L85.8822 16.9706C95.2548 7.59798 110.451 7.59798 119.823 16.9706C129.196 26.3431 129.196 41.5391 119.823 50.9117L68.5581 102.177"}),(0,t.jsx)("path",{d:"M69.2652 101.47L119.823 50.9117C129.196 41.5391 144.392 41.5391 153.765 50.9117L154.118 51.2652C163.491 60.6378 163.491 75.8338 154.118 85.2063L92.7248 146.6C89.6006 149.724 89.6006 154.789 92.7248 157.913L105.331 170.52"}),(0,t.jsx)("path",{d:"M102.853 33.9411L52.6482 84.1457C43.2756 93.5183 43.2756 108.714 52.6482 118.087C62.0208 127.459 77.2167 127.459 86.5893 118.087L136.794 67.8822"})]})}r(gXe,"McpIcon");var bXe=new Set(["tool","tool call","tool_call","acp_tool"]);function Rd(e){const s=(e??"").trim().toLowerCase().replace(/\s*\((?:pending|in[_ -]?progress|completed|failed|cancelled|canceled)\)$/,"");return!s||bXe.has(s)}r(Rd,"isGenericToolName");function PK(e){const s=e.match(/^mcp__(.+?)__(.+)$/i);if(s)return{namespace:s[1],name:s[2]};const n=e.match(/^mcp\.([^.]+)\.(.+)$/i);return n?{namespace:n[1],name:n[2]}:null}r(PK,"mcpToolIdentity");function MK(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/[^A-Za-z0-9]+/g," ").trim().toLowerCase().split(/\s+/).filter(Boolean)}r(MK,"identifierWords");function Sge(e){if(e.length===0)return"";const s=e.map(n=>["api","id","lsp","mcp","pr","url"].includes(n)?n.toUpperCase():n).join(" ");return s.charAt(0).toUpperCase()+s.slice(1)}r(Sge,"sentenceCase");function qj(e){const s=(e??"").trim();return Rd(s)?"Unnamed tool":Sge(MK(PK(s)?.name??s))}r(qj,"humanizeToolName");var ad=r((e,s,n)=>({key:e,singular:s,plural:n}),"group"),vXe={bash:{action:"run"},terminal:{action:"run"},shell:{action:"run"},command:{action:"run"},run:{action:"run"},execute:{action:"run"},exec_command:{action:"run"},apply_patch:{action:"update",running:"Applying a patch",completed:"Applied a patch"},read:{action:"read",running:"Reading a file",completed:"Read a file"},write:{action:"update",running:"Writing a file",completed:"Wrote a file"},edit:{action:"update",running:"Editing a file",completed:"Edited a file"},notebook_read:{action:"read",running:"Reading a notebook",completed:"Read a notebook"},notebook_edit:{action:"update",running:"Editing a notebook",completed:"Edited a notebook"},glob:{action:"search",running:"Searching files",completed:"Searched files"},grep:{action:"search",running:"Searching file contents",completed:"Searched file contents",family:"grep"},tool_search:{action:"search",running:"Searching available tools",completed:"Searched available tools",group:ad("tool_search","tool search","tool searches")},web_search:{action:"search",running:"Searching the web",completed:"Searched the web",family:"web"},web_fetch:{action:"fetch",running:"Fetching a web page",completed:"Fetched a web page",family:"web"},todo_write:{action:"update",running:"Updating the task list",completed:"Updated the task list",family:"plan",group:ad("task_operation","task operation","task operations")},task_create:{action:"create",running:"Creating a task",completed:"Created a task",family:"plan",group:ad("task_operation","task operation","task operations")},task_update:{action:"update",running:"Updating a task",completed:"Updated a task",family:"plan",group:ad("task_operation","task operation","task operations")},task_list:{action:"list",running:"Listing tasks",completed:"Listed tasks",family:"plan",group:ad("task_operation","task operation","task operations")},task_get:{action:"read",running:"Reading a task",completed:"Read a task",family:"plan",group:ad("task_operation","task operation","task operations")},enter_plan_mode:{action:"switch",running:"Entering plan mode",completed:"Entered plan mode",family:"plan"},exit_plan_mode:{action:"switch",running:"Leaving plan mode",completed:"Left plan mode",family:"plan"},skill:{action:"read",running:"Loading a skill",completed:"Loaded a skill"},ask_user_question:{action:"request",running:"Requesting input",completed:"Requested input",family:"question"},request_human_input:{action:"request",running:"Requesting input",completed:"Requested input",family:"question",group:ad("task_operation","task operation","task operations")},agent:{action:"start",running:"Starting a subagent",completed:"Started a subagent",family:"agent"},task:{action:"start",running:"Starting a subagent",completed:"Started a subagent",family:"agent"},task_output:{action:"read",running:"Checking subagent progress",completed:"Checked subagent progress",family:"agent"},task_stop:{action:"stop",running:"Stopping a subagent",completed:"Stopped a subagent",family:"agent"},send_message:{action:"post",running:"Messaging a subagent",completed:"Messaged a subagent",family:"agent"},spawn_agent:{action:"start",running:"Starting a subagent",completed:"Started a subagent",family:"agent"},wait_agent:{action:"wait",running:"Checking subagent progress",completed:"Checked subagent progress",family:"agent"},wait_threads:{action:"wait",running:"Checking task progress",completed:"Checked task progress",family:"agent"},interrupt_agent:{action:"stop",running:"Interrupting a subagent",completed:"Interrupted a subagent",family:"agent"},report_findings:{action:"post",running:"Reporting findings",completed:"Reported findings",family:"safety"},guardian_review:{action:"think",running:"Reviewing safety",completed:"Reviewed safety",family:"safety"},lsp:{action:"read",running:"Inspecting code intelligence",completed:"Inspected code intelligence"},compact_conversation:{action:"think",running:"Compacting context",completed:"Compacted context"},image_generation:{action:"create",running:"Generating an image",completed:"Generated an image",family:"image"},view_image:{action:"read",running:"Viewing an image",completed:"Viewed an image",family:"image"},multi_tool_use_parallel:{action:"run",running:"Running tools in parallel",completed:"Ran tools in parallel"},get_task_context:{action:"read",running:"Reading task context",completed:"Read task context"},get_task_history:{action:"read",running:"Reading task history",completed:"Read task history"},list_documents:{action:"list",running:"Listing documents",completed:"Listed documents"},read_document:{action:"read",running:"Reading a document",completed:"Read a document"},list_document_revisions:{action:"list",running:"Listing document revisions",completed:"Listed document revisions"},report_progress:{action:"post",running:"Reporting progress",completed:"Reported progress"},answer_status_question:{action:"post",running:"Answering a status question",completed:"Answered a status question"},write_document:{action:"update",running:"Writing a document",completed:"Wrote a document"},register_deliverable:{action:"create",running:"Registering a deliverable",completed:"Registered a deliverable"},finish_task:{action:"finish",running:"Reporting completion",completed:"Reported completion"},paperclip_finish:{action:"finish",running:"Reporting completion",completed:"Reported completion"},block_task:{action:"block",running:"Reporting a blocker",completed:"Reported a blocker"},paperclip_block:{action:"block",running:"Reporting a blocker",completed:"Reported a blocker"},request_review:{action:"request",running:"Requesting review",completed:"Requested review"},list_agents:{action:"list",running:"Listing agents",completed:"Listed agents"},get_agent:{action:"read",running:"Reading agent details",completed:"Read agent details"},search_tasks:{action:"search",running:"Searching tasks",completed:"Searched tasks"},list_approvals:{action:"list",running:"Listing approvals",completed:"Listed approvals"},get_approval:{action:"read",running:"Reading an approval",completed:"Read an approval"},get_approval_context:{action:"read",running:"Reading approval context",completed:"Read approval context"},get_workspace_runtime:{action:"read",running:"Reading workspace status",completed:"Read workspace status"},control_workspace_service:{action:"run",running:"Controlling a workspace service",completed:"Controlled a workspace service"},set_dependencies:{action:"update",running:"Updating task dependencies",completed:"Updated task dependencies"},create_task:{action:"create",running:"Creating a task",completed:"Created a task"},request_approval:{action:"request",running:"Requesting approval",completed:"Requested approval"},decide_approval:{action:"update",running:"Deciding an approval",completed:"Decided an approval"},comment_on_approval:{action:"post",running:"Commenting on an approval",completed:"Commented on an approval"},schedule_wake:{action:"create",running:"Scheduling a wake-up",completed:"Scheduled a wake-up",family:"wait"},generic_api_request:{action:"request",running:"Calling the Paperclip API",completed:"Called the Paperclip API"}},yXe={read:["get","read","inspect","view"],list:["list","glob"],search:["find","search","grep","query","lookup"],fetch:["fetch","browse"],open:["open"],update:["write","edit","update","set","patch","upsert","sync"],create:["create","add","register","upload"],delete:["delete","remove"],move:["move","rename"],run:["run","execute","bash","shell","command"],request:["request","ask","prompt"],post:["send","message","comment","report","answer"],start:["start","spawn","delegate"],stop:["stop","cancel","interrupt"],wait:["wait","sleep","poll"],finish:["finish","complete"],block:["block"],think:["think","reason","compact","review"],switch:["switch","enter","exit"],other:[]},jXe={read:"read",edit:"update",delete:"delete",move:"move",search:"search",list:"list",execute:"run",think:"think",fetch:"fetch",switch_mode:"switch"};function wXe(e){return MK(e).join("_")}r(wXe,"normalizedKey");function NXe(e){const s=e[0];if(!s)return null;for(const[n,a]of Object.entries(yXe))if(a.includes(s))return n;return null}r(NXe,"inferredAction");function kXe(e){return e==="run"?"terminal":e==="read"||e==="list"?"read":e==="search"?"search":e==="fetch"||e==="open"?"web":["update","create","delete","move"].includes(e)?"edit":e==="request"?"question":e==="start"||e==="stop"?"agent":e==="wait"?"wait":"other"}r(kXe,"actionFamily");var SXe={terminal:Hb,grep:KEe,search:ua,read:sN,edit:I5,web:b3e,plan:k1,question:ud,agent:Gb,safety:Ii,image:R5,wait:sh,mcp:gXe,other:jx};function CXe(e,s){const n=s?` ${s}`:"";switch(e){case"read":return{running:`Reading${n||" data"}`,completed:`Read${n||" data"}`};case"list":return{running:`Listing${n||" items"}`,completed:`Listed${n||" items"}`};case"search":return{running:`Searching${n||""}`,completed:`Searched${n||""}`};case"fetch":return{running:`Fetching${n||" data"}`,completed:`Fetched${n||" data"}`};case"open":return{running:`Opening${n||" an item"}`,completed:`Opened${n||" an item"}`};case"update":return{running:`Updating${n||" data"}`,completed:`Updated${n||" data"}`};case"create":return{running:`Creating${n||" an item"}`,completed:`Created${n||" an item"}`};case"delete":return{running:`Deleting${n||" an item"}`,completed:`Deleted${n||" an item"}`};case"move":return{running:`Moving${n||" an item"}`,completed:`Moved${n||" an item"}`};case"run":return{running:"Running a command",completed:"Ran a command"};case"request":return{running:`Requesting${n||" input"}`,completed:`Requested${n||" input"}`};case"post":return{running:`Posting${n||" an update"}`,completed:`Posted${n||" an update"}`};case"start":return{running:`Starting${n||" an operation"}`,completed:`Started${n||" an operation"}`};case"stop":return{running:`Stopping${n||" an operation"}`,completed:`Stopped${n||" an operation"}`};case"wait":return{running:"Waiting",completed:"Finished waiting"};case"finish":return{running:"Reporting completion",completed:"Reported completion"};case"block":return{running:"Reporting a blocker",completed:"Reported a blocker"};case"think":return{running:"Thinking",completed:"Finished thinking"};case"switch":return{running:`Switching${n||" mode"}`,completed:`Switched${n||" mode"}`};case"other":return{running:"Running",completed:"Ran"}}}r(CXe,"actionCopy");function _Xe(e){switch(e){case"run":return ad("command","command","commands");case"read":case"list":return ad("read","read","reads");case"search":return ad("search","search","searches");case"update":case"create":case"delete":case"move":return ad("file_change","file change","file changes");case"start":case"stop":return ad("delegation","delegation","delegations");case"wait":return ad("wait","wait","waits");default:return ad("tool_action","tool action","tool actions")}}r(_Xe,"defaultSummaryGroup");function IXe(e){return e==="read"||e==="list"?ad("paperclip_read","Paperclip read","Paperclip reads"):ad("task_operation","task operation","task operations")}r(IXe,"paperclipSummaryGroup");function av(e){const s=(e.name??"").trim(),n=PK(s),a=(e.namespace??n?.namespace??"").trim(),i=(n?"mcp":e.transport??"builtin").toLowerCase(),o=(n?.name??s).trim(),l=MK(o),c=wXe(o),d=vXe[c],m=jXe[(e.operation??"").trim().toLowerCase()],h=NXe(l),p=d?.action??m??h??"other",f=d?"exact":m?"kind":h?"inferred":Rd(o)?"unnamed":"fallback",g=Rd(o)?"Unnamed tool":qj(o),v=/^[A-Za-z][A-Za-z0-9_.:-]*$/.test(o),y=h&&v&&l.length>1?l.slice(1):[],w=y.length?Sge(y).replace(/^./,C=>C.toLowerCase()):void 0,S=d?.running&&d.completed?{running:d.running,completed:d.completed}:p==="other"?Rd(o)?{running:"Running an unnamed tool",completed:"Ran an unnamed tool"}:{running:`Running ${g}`,completed:`Ran ${g}`}:CXe(p,d?void 0:w),j=d?.family??kXe(p),N=i==="mcp"?"mcp":j,_=a?qj(a):i==="mcp"?"MCP":void 0,R=a.toLowerCase()==="paperclip"?IXe(p):d?.group??_Xe(p);return{icon:SXe[N],family:N,runningLabel:S.running,completedLabel:S.completed,failedLabel:`${S.completed} · failed`,interruptedLabel:`${S.running} · stopped`,displayName:g,sourceLabel:_,technicalName:s||void 0,confidence:f,summaryGroup:R}}r(av,"toolActivityPresentation");function bE(e){const s=av({name:e});return{family:s.family,icon:s.icon,verbLabel:s.runningLabel}}r(bE,"toolTaxonomy");function AXe(e){const s=(e??"").trim().toLowerCase();return s==="thinking"?Mg:s==="responding"||s.startsWith("responding (")?nEe:null}r(AXe,"statusLabelIcon");var aD=["Clipping","Organizing","Sorting","Synthesizing","Analyzing","Filing","Collating","Stapling","Indexing","Annotating","Drafting","Proofreading","Alphabetizing","Photocopying","Laminating","Hole-punching","Bookmarking","Highlighting","Typing","Trimming","Aligning","Combining","Whiteboarding","Diagramming","Sketching","Labeling","Sticky-noting"],iD=["Brewing","Tinkering","Distilling","Deliberating"],sX=(()=>{const e=[],s=Math.max(aD.length,iD.length);for(let n=0;n<s;n++)n<aD.length&&e.push(aD[n]),n<iD.length&&e.push(iD[n]);return e})(),RXe=1e4;function TXe(e){const s=(e??"").trim().toLowerCase();return s==="running"||s==="working"}r(TXe,"isGenericStatusLabel");function EXe(e){let s=2166136261;for(let n=0;n<e.length;n++)s^=e.charCodeAt(n),s=Math.imul(s,16777619);return s>>>0}r(EXe,"fnv1a");function PXe(e,s=0){const n=Math.floor(Math.max(0,s)/RXe);return sX[(EXe(e)+n)%sX.length]}r(PXe,"whimsyWord");var MXe=[{name:"--motion-ease-out-expo",group:"Easing",kind:"easing"},{name:"--motion-ease-standard",group:"Easing",kind:"easing"},{name:"--motion-ease-out",group:"Easing",kind:"easing"},{name:"--motion-ease-scroll-pill-in",group:"Easing",kind:"easing"},{name:"--motion-ease-scroll-pill-out",group:"Easing",kind:"easing"},{name:"--motion-ease-in",group:"Easing",kind:"easing"},{name:"--motion-duration-instant",group:"Durations",kind:"time",min:0,max:1e3,step:10},{name:"--motion-duration-fast",group:"Durations",kind:"time",min:0,max:1e3,step:10},{name:"--motion-duration-base",group:"Durations",kind:"time",min:0,max:1e3,step:10},{name:"--motion-duration-slow",group:"Durations",kind:"time",min:0,max:1500,step:10},{name:"--motion-duration-deliberate",group:"Durations",kind:"time",min:0,max:2e3,step:10},{name:"--motion-duration-enter",group:"Durations",kind:"time",min:0,max:1e3,step:10},{name:"--motion-duration-exit",group:"Durations",kind:"time",min:0,max:1e3,step:10},{name:"--motion-duration-swap",group:"Durations",kind:"time",min:0,max:1e3,step:10},{name:"--motion-marker-enter",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-bubble-enter",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-cot-line-stagger",group:"States",kind:"time",min:0,max:300,step:5},{name:"--motion-cot-collapse",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-tool-enter",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-diff-reveal",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-status-enter",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-status-exit",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-approval-pulse",group:"States",kind:"time",min:0,max:3e3,step:20},{name:"--motion-plan-entry-stagger",group:"States",kind:"time",min:0,max:300,step:5},{name:"--motion-plan-check",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-question-page-enter",group:"States",kind:"time",min:0,max:1e3,step:10},{name:"--motion-count-tween",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-streaming-cursor-blink",group:"States",kind:"time",min:0,max:3e3,step:20},{name:"--motion-turn-fold",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-turn-meta",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-line-scroll",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-interstitial-dwell",group:"States",kind:"time",min:0,max:1e4,step:100},{name:"--motion-scroll-pill-enter",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-scroll-pill-exit",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-scrollbar-idle-delay",group:"States",kind:"time",min:0,max:2e3,step:10},{name:"--motion-pane-glide",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-side-panel-tab",group:"States",kind:"time",min:0,max:1500,step:10}],$7t=Array.from(new Set(MXe.map(e=>e.group)));function Cge(e){const s=e.trim();if(s.endsWith("ms"))return parseFloat(s);if(s.endsWith("s"))return parseFloat(s)*1e3;const n=parseFloat(s);return Number.isFinite(n)?n:0}r(Cge,"parseCssTimeMs");function DXe(e){if(e==null)return null;const s=Math.round(e/1e3);return s<60?`${s}s`:`${Math.floor(s/60)}m ${s%60}s`}r(DXe,"elapsedLabel");function LXe(e){if(e==null)return null;const s=Math.max(0,e)/1e3;return s<60?`${s.toFixed(1)}s`:`${Math.floor(s/60)}m ${(s%60).toFixed(1)}s`}r(LXe,"liveElapsedLabel");function $Xe(e,s){const[n,a]=(0,u.useState)(()=>Date.now());return(0,u.useEffect)(()=>{if(e==null||!s)return;const i=window.setInterval(()=>a(Date.now()),100);return()=>window.clearInterval(i)},[e,s]),e==null?void 0:Math.max(0,n-e)}r($Xe,"useLiveElapsedMs");function OXe(e,s){return!Number.isFinite(e)||!Number.isFinite(s)||s<=0?0:Math.max(0,Math.round(e/s)-1)}r(OXe,"lineScrollOffset");function F2(e){const s=getComputedStyle(document.documentElement).getPropertyValue(e),n=Cge(s);return Number.isFinite(n)?n:0}r(F2,"motionTokenMs");function FXe({text:e,streaming:s,leaving:n}){const a=(0,u.useRef)(null),[i,o]=(0,u.useState)(0),[l,c]=(0,u.useState)(!1),[d,m]=(0,u.useState)(!1);(0,u.useLayoutEffect)(()=>{const p=a.current;if(!p)return;const f=r(()=>{const v=parseFloat(window.getComputedStyle(p).lineHeight);o(OXe(p.scrollHeight,v))},"measure");if(f(),typeof ResizeObserver>"u")return;const g=new ResizeObserver(f);return g.observe(p),()=>g.disconnect()},[e,s]),(0,u.useEffect)(()=>{const p=requestAnimationFrame(()=>c(!0)),f=window.setTimeout(()=>m(!0),F2("--motion-line-scroll"));return()=>{cancelAnimationFrame(p),window.clearTimeout(f)}},[]);const h=l?n?-1:s?-i:0:1;return(0,t.jsx)("span",{className:"tc-line-scroll min-w-0 flex-1","data-testid":"task-chat-live-self-talk","data-streaming":s||void 0,"data-leaving":n||void 0,children:(0,t.jsx)("span",{ref:a,className:U("tc-line-scroll-inner block",!s&&"truncate"),style:{transform:h!==0?`translateY(calc(${h} * 1lh))`:void 0,transition:d&&!n?"none":void 0},children:e})})}r(FXe,"LiveSelfTalkLine");function BXe(e,s){const[n,a]=(0,u.useState)(null),i=(0,u.useRef)(n),o=(0,u.useRef)(null),l=(0,u.useRef)(e),c=(0,u.useRef)(0),d=(0,u.useRef)(null),m=(0,u.useRef)(null),h=(0,u.useRef)(null);return l.current=e,(0,u.useEffect)(()=>{const p=r(w=>{w.current!=null&&(window.clearTimeout(w.current),w.current=null)},"clear"),f=r(w=>{i.current=w,a(w)},"show"),g=r(()=>{p(m),p(h),m.current=window.setTimeout(()=>{if(m.current=null,o.current!=null)return;const w=i.current;w==null||w.streaming||(f({...w,leaving:!0}),h.current=window.setTimeout(()=>{h.current=null,i.current?.leaving&&f(null)},F2("--motion-line-scroll")))},F2("--motion-interstitial-dwell"))},"scheduleLeave"),v=r((w,S)=>{p(m),p(h),c.current=Date.now(),f({text:w,streaming:S,swapKey:(i.current?.swapKey??0)+1}),S||g()},"swapIn");if(!s){p(d),p(m),p(h),o.current=null,i.current&&f(null);return}const y=i.current;if(e==null){y?.streaming&&(f({...y,streaming:!1}),g());return}if(y==null){v(e,!0);return}if(y.streaming){y.text!==e&&f({...y,text:e});return}if(o.current=e,d.current==null){const w=F2("--motion-interstitial-dwell"),S=Math.max(0,c.current+w-Date.now());d.current=window.setTimeout(()=>{d.current=null;const j=o.current;o.current=null,j!=null&&v(j,l.current!=null)},S)}},[e,s]),(0,u.useEffect)(()=>()=>{d.current!=null&&window.clearTimeout(d.current),m.current!=null&&window.clearTimeout(m.current),h.current!=null&&window.clearTimeout(h.current)},[]),n}r(BXe,"useHeldSelfTalk");var qXe={running:{Icon:at,spin:!0,tone:"text-(--status-agent-running)"},working:{Icon:at,spin:!0,tone:"text-(--status-agent-running)"},awaiting_approval:{Icon:rN,spin:!1,tone:"text-primary"},interrupted:{Icon:zz,spin:!1,tone:"text-destructive"},refused:{Icon:Wu,spin:!1,tone:"text-destructive"},truncated:{Icon:BEe,spin:!1,tone:"text-(--status-agent-paused)"}};function _ge({item:e,onApprovalDecision:s,chevronOpen:n,onToggle:a}){const{Icon:i,spin:o,tone:l}=qXe[e.status],c=e.status==="awaiting_approval",d=e.status==="running"||e.status==="working",m=$Xe(e.startedAtMs,d),h=BXe(d?e.selfTalk:void 0,d),p=DXe(e.elapsedMs);if(d){const f=LXe(m??e.elapsedMs),g=e.selfTalk!=null,v=e.toolName?bE(e.toolName).icon:g?null:AXe(e.label),y=g||TXe(e.label)?PXe(e.id,m??e.elapsedMs??0):e.label,w=(0,t.jsxs)("div",{className:"tc-enter-status flex items-center gap-2 py-0.5 text-xs text-muted-foreground",children:[n!==void 0?(0,t.jsx)("span",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center","data-testid":"task-chat-status-caret-slot",children:(0,t.jsx)(Tn,{className:U("h-3 w-3 transition-transform",n?"rotate-90":null),"aria-hidden":!0})}):null,(0,t.jsx)("span",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center","data-testid":"task-chat-status-dot-slot",children:(0,t.jsx)("span",{"aria-hidden":!0,className:"h-2 w-2 animate-pulse rounded-full bg-(--status-agent-running)"})}),v?(0,t.jsx)(v,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}):null,(0,t.jsxs)("span",{className:"flex min-w-0 flex-1 items-baseline gap-2",children:[(0,t.jsxs)("span",{className:"shimmer-text shimmer-text-muted shrink-0 font-medium",children:[y,"…"]}),f?(0,t.jsx)("span",{className:"shrink-0 font-mono tabular-nums text-(length:--text-micro)",children:f}):null,e.detail?(0,t.jsx)("span",{className:"min-w-0 truncate font-mono text-(length:--text-micro)",children:e.detail}):null,e.tokens?(0,t.jsxs)("span",{className:"ml-auto shrink-0 font-mono text-(length:--text-micro)",children:[e.tokens.used.toLocaleString(),"/",e.tokens.size.toLocaleString()," ctx"]}):null]})]});return(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 py-0.5 text-xs text-muted-foreground","data-testid":"task-chat-interstitial-row",children:[(0,t.jsx)("span",{"aria-hidden":!0,className:"h-3.5 w-3.5 shrink-0"}),h?(0,t.jsx)(FXe,{text:h.text,streaming:h.streaming,leaving:h.leaving},h.swapKey):(0,t.jsx)("span",{"aria-hidden":!0,className:"tc-line-scroll min-w-0 flex-1"})]}),a?(0,t.jsx)("button",{type:"button",onClick:a,"aria-expanded":n,className:"-mx-1.5 block w-full rounded-sm px-1.5 text-left transition-colors hover:bg-muted/60","data-testid":"task-chat-live-turn",children:w}):w]})}return(0,t.jsxs)("div",{className:U("tc-enter-status flex flex-col gap-2 rounded-lg border px-3 py-2 text-sm",c?"tc-approval border-primary/40 bg-primary/5":"border-border bg-muted/40"),children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,t.jsx)(i,{className:U("h-4 w-4 shrink-0",l,o&&"animate-spin")}),(0,t.jsx)("span",{className:"min-w-0 truncate font-medium",children:e.label}),(0,t.jsxs)("span",{className:"ml-auto flex shrink-0 items-center gap-2 text-xs text-muted-foreground",children:[p?(0,t.jsx)("span",{children:p}):null,e.tokens?(0,t.jsxs)("span",{children:[e.tokens.used.toLocaleString(),"/",e.tokens.size.toLocaleString()," ctx"]}):null]})]}),e.detail?(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:e.detail}):null,c&&e.approval?(0,t.jsx)("div",{className:"flex flex-wrap justify-end gap-2 pt-1",children:e.approval.options.map(f=>{const g=f.kind.startsWith("reject");return(0,t.jsx)("button",{type:"button",onClick:r(()=>s?.(f.id),"onClick"),className:U("rounded-md border px-2.5 py-1 text-xs font-medium transition-colors",g?"border-border text-muted-foreground hover:bg-accent/50 hover:text-foreground":"border-primary bg-primary text-primary-foreground hover:bg-primary/90"),children:f.label},f.id)})}):null]})}r(_ge,"TaskChatStatusPill");function Ige(e,s){const n=URL.createObjectURL(s),a=document.createElement("a");a.href=n,a.download=e,a.rel="noreferrer",a.style.display="none",document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(n)}r(Ige,"downloadBlob$1");function zXe(e,s,n){Ige(e,new Blob([s],{type:`${n};charset=utf-8`}))}r(zXe,"downloadTextFile");var oD="flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-50";function Age({issueId:e,documentKey:s,title:n,format:a,body:i,className:o}){const[l,c]=(0,u.useState)(null),[d,m]=(0,u.useState)(null),[h,p]=(0,u.useState)(null),{copy:f,copied:g,failed:v}=hf(),y=(0,u.useRef)(void 0);(0,u.useEffect)(()=>()=>clearTimeout(y.current),[]);const w=(0,u.useCallback)(async(C,A)=>{c(C),p(null);try{await A(),m(C)}catch(T){m(null),p(T instanceof Error?T.message:"Export failed")}finally{c(null)}clearTimeout(y.current),y.current=setTimeout(()=>{m(null),p(null)},2e3)},[]),S=(0,u.useCallback)(async()=>i??(await Rt.getDocument(e,s)).body,[i,s,e]),j=(0,u.useCallback)(()=>{c("copy"),p(null),(async()=>{try{await f(await S())==="failed"&&p("Copy failed")}catch(C){p(C instanceof Error?C.message:"Copy failed")}finally{c(null)}})()},[f,S]),N=v||h==="Copy failed"?"Copy failed":g?"Copied!":"Copy full content",_=d==="download"?"Downloaded!":"Download source",R=d==="pdf"?"Downloaded!":"Export to PDF";return(0,t.jsxs)("div",{className:U("flex items-center gap-0.5",o),"data-testid":"document-export-actions",children:[(0,t.jsx)("button",{type:"button",className:oD,disabled:l!==null,"aria-label":"Copy full content",title:N,"data-testid":"document-export-copy",onClick:r(C=>{C.preventDefault(),C.stopPropagation(),j()},"onClick"),children:g?(0,t.jsx)(ds,{"aria-hidden":"true",className:"h-3.5 w-3.5"}):(0,t.jsx)(Nr,{"aria-hidden":"true",className:"h-3.5 w-3.5"})}),(0,t.jsx)("button",{type:"button",className:oD,disabled:l!==null,"aria-label":"Download source",title:_,"data-testid":"document-export-download",onClick:r(C=>{C.preventDefault(),C.stopPropagation(),w("download",async()=>{const A=BRe(a);zXe(CH(n,A),await S(),A==="md"?"text/markdown":"text/plain")})},"onClick"),children:(0,t.jsx)(Uo,{"aria-hidden":"true",className:"h-3.5 w-3.5"})}),(0,t.jsx)("button",{type:"button",className:oD,disabled:l!==null,"aria-label":"Export to PDF",title:R,"data-testid":"document-export-pdf",onClick:r(C=>{C.preventDefault(),C.stopPropagation(),w("pdf",async()=>{Ige(CH(n,"pdf"),await Rt.getDocumentPdf(e,s))})},"onClick"),children:(0,t.jsx)(e5e,{"aria-hidden":"true",className:"h-3.5 w-3.5"})}),(0,t.jsx)("span",{className:"sr-only",role:"status","aria-live":"polite",children:h??(g?"Copied!":v?"Copy failed":d?"Downloaded!":"")})]})}r(Age,"DocumentExportActions");function NC({children:e,className:s}){return(0,t.jsx)("div",{className:U("relative aspect-video w-full overflow-hidden bg-accent/20",s),children:e})}r(NC,"PreviewFrame");function HT({label:e}){return(0,t.jsx)(NC,{className:"flex items-center justify-center",children:(0,t.jsxs)("div",{className:"flex flex-col items-center gap-1.5 text-muted-foreground/50",children:[(0,t.jsx)(Vl,{className:"h-7 w-7","aria-hidden":"true"}),e?(0,t.jsx)("span",{className:"text-(length:--text-micro) font-medium uppercase tracking-wide",children:e}):null]})})}r(HT,"PlaceholderPreview");function UXe({artifact:e}){const[s,n]=(0,u.useState)(!1);return s||!e.contentPath?(0,t.jsx)(HT,{label:"Image"}):(0,t.jsx)(NC,{children:(0,t.jsx)("img",{src:e.contentPath,alt:e.title,loading:"lazy",className:"h-full w-full object-cover",onError:r(()=>n(!0),"onError")})})}r(UXe,"ImagePreview");function KXe({artifact:e}){const[s,n]=(0,u.useState)(!1),[a,i]=(0,u.useState)(!1),o=(0,u.useRef)(!1),l=(0,u.useRef)(null);if((0,u.useEffect)(()=>()=>{l.current!==null&&window.clearTimeout(l.current)},[]),s||!e.contentPath)return(0,t.jsx)(NC,{className:"flex items-center justify-center bg-black/80",children:(0,t.jsx)("div",{className:"flex h-11 w-11 items-center justify-center rounded-full bg-white/15",children:(0,t.jsx)(So,{className:"h-5 w-5 translate-x-0.5 text-white","aria-hidden":"true"})})});const c=r(()=>{l.current!==null&&(window.clearTimeout(l.current),l.current=null),i(!0)},"markFrameReady"),d=r(()=>{l.current!==null&&window.clearTimeout(l.current),l.current=window.setTimeout(c,3e3)},"scheduleFrameReadyFallback"),m=r(p=>{if(o.current)return;o.current=!0;const f=p.currentTarget,g=Number.isFinite(f.duration)&&f.duration>0?f.duration:0,v=g>0?Math.min(1,g/4):.05;try{Math.abs(f.currentTime-v)>.001?(f.currentTime=v,d()):c()}catch{c()}},"loadThumbnailFrame"),h=r(p=>{(o.current||p.currentTarget.currentTime>0)&&c()},"handleLoadedData");return(0,t.jsxs)(NC,{className:"bg-black",children:[(0,t.jsx)("video",{src:e.contentPath,preload:"metadata",muted:!0,playsInline:!0,"data-frame-ready":a?"true":"false",className:U("h-full w-full object-contain transition-opacity",a?"opacity-100":"opacity-0"),onLoadedMetadata:m,onLoadedData:h,onSeeked:c,onError:r(()=>n(!0),"onError")}),(0,t.jsx)("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:(0,t.jsx)("div",{className:"flex h-11 w-11 items-center justify-center rounded-full bg-black/55",children:(0,t.jsx)(So,{className:"h-5 w-5 translate-x-0.5 text-white","aria-hidden":"true"})})})]})}r(KXe,"VideoPreview");function VXe({artifact:e}){const s=e.previewText?.trim();return s?(0,t.jsxs)(NC,{className:"bg-card",children:[(0,t.jsx)("div",{className:"absolute inset-0 overflow-hidden p-3",children:(0,t.jsx)("p",{className:"max-h-full overflow-hidden whitespace-pre-wrap break-words text-base leading-6 text-muted-foreground/75",children:s})}),(0,t.jsx)("div",{className:"pointer-events-none absolute bottom-0 left-0 right-0 h-10 bg-gradient-to-t from-card to-transparent"})]}):(0,t.jsx)(HT,{label:e.source==="document"?"Document":"Text"})}r(VXe,"TextPreview");function z1({artifact:e}){switch(e.mediaKind){case"image":return(0,t.jsx)(UXe,{artifact:e},e.contentPath);case"video":return(0,t.jsx)(KXe,{artifact:e},e.contentPath);case"text":case"document":return(0,t.jsx)(VXe,{artifact:e});case"file":return(0,t.jsx)(HT,{label:"File"});default:return(0,t.jsx)(HT,{})}}r(z1,"ArtifactPreview");function nX({href:e,download:s,title:n,children:a}){return(0,t.jsx)("a",{href:e,...s?{download:""}:{target:"_blank",rel:"noreferrer"},title:n,"aria-label":n,onClick:r(i=>i.stopPropagation(),"onClick"),className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:a})}r(nX,"SecondaryAction");function WXe({artifact:e}){return(0,t.jsxs)(Je,{to:e.href,disableIssueQuicklook:!0,"data-testid":"artifact-card","data-media-kind":e.mediaKind,className:"group flex flex-col overflow-hidden rounded-lg border border-border bg-card cursor-pointer transition-colors hover:border-foreground/20 hover:shadow-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,t.jsx)(z1,{artifact:e}),(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1 p-3",children:[(0,t.jsxs)("div",{className:"flex h-7 items-start justify-between gap-2",children:[(0,t.jsx)("h3",{className:"min-w-0 flex-1 truncate text-sm font-medium leading-7 text-foreground/85",title:e.title,children:e.title}),(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100",children:[e.source==="document"&&e.documentKey?(0,t.jsx)(Age,{issueId:e.issue.id,documentKey:e.documentKey,title:e.title}):null,e.openPath?(0,t.jsx)(nX,{href:e.openPath,title:"Open file in new tab",children:(0,t.jsx)(xr,{className:"h-3.5 w-3.5"})}):null,e.downloadPath?(0,t.jsx)(nX,{href:e.downloadPath,download:!0,title:"Download file",children:(0,t.jsx)(Uo,{className:"h-3.5 w-3.5"})}):null]})]}),(0,t.jsxs)("div",{className:"mt-0.5 flex items-center gap-1.5 text-(length:--text-micro) text-muted-foreground/65",children:[(0,t.jsxs)("span",{children:["Last edited ",pu(e.updatedAt)]}),e.createdByAgent?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"text-muted-foreground/50",children:"·"}),(0,t.jsx)("span",{className:"truncate",children:e.createdByAgent.name})]}):null]})]})]})}r(WXe,"ArtifactCard");function mN(e){if(!Number.isFinite(e)||e<0)return"0 B";if(e<1024)return`${Math.round(e)} B`;const s=["KB","MB","GB","TB"];let n=e/1024,a=0;for(;n>=1024&&a<s.length-1;)n/=1024,a+=1;const i=n.toFixed(1);return`${i.endsWith(".0")?i.slice(0,-2):i} ${s[a]}`}r(mN,"formatBytes$4");var QT=new Set(["application/octet-stream","binary/octet-stream","application/x-binary"]),HXe=[".mp4",".m4v",".webm",".mov",".qt",".quicktime"],QXe=[".png",".jpg",".jpeg",".gif",".webp",".avif",".bmp",".svg",".ico"],GXe=new Set(["application/wasm"]),YXe=new Set(["application/zip","application/x-zip","application/x-zip-compressed"]),Rge=new Set(["text/markdown","text/x-markdown","application/markdown","application/x-markdown"]),JXe=new Set(["application/csv","application/ecmascript","application/graphql","application/html","application/javascript","application/json","application/ld+json","application/sql","application/toml","application/x-httpd-php","application/x-javascript","application/x-python","application/x-sh","application/x-yaml","application/xhtml+xml","application/xml","application/yaml"]),XXe=[".csv",".css",".graphql",".htm",".html",".js",".json",".jsx",".log",".markdown",".md",".mdx",".php",".py",".sh",".sql",".toml",".ts",".tsx",".txt",".xml",".yaml",".yml"];function U1(e){return(e??"").toLowerCase().split(";")[0]?.trim()??""}r(U1,"normalizeOutputContentType");function ZXe(e){const s=(e??"").trim().toLowerCase();return s?XXe.some(n=>s.endsWith(n)):!1}r(ZXe,"hasDocumentLikeFilename");function Tge(e){return YXe.has(e)||e.endsWith("+zip")}r(Tge,"isZipContentType");function eZe(e){return e?!!(e.startsWith("text/")||Rge.has(e)||JXe.has(e)||e.startsWith("application/")&&(e.endsWith("+json")||e.endsWith("+xml"))):!1}r(eZe,"isDocumentLikeOutputContentType");function tZe(e,s){const n=U1(e);return!n||eZe(n)||QT.has(n)&&ZXe(s)?!1:n.startsWith("video/")||n.startsWith("image/")||n==="application/pdf"||GXe.has(n)||Tge(n)||QT.has(n)}r(tZe,"isOutputEligibleContentType");function sZe(e){const s=U1(e);if(s.startsWith("video/")){const n=s.slice(6);return n==="quicktime"?{label:"MOV",tone:"video"}:{label:(n||"vid").toUpperCase().slice(0,4),tone:"video"}}return s==="application/pdf"?{label:"PDF",tone:"pdf"}:Tge(s)?{label:"ZIP",tone:"zip"}:s.startsWith("image/")?{label:"IMG",tone:"image"}:Rge.has(s)?{label:"MD",tone:"bin"}:s==="text/plain"?{label:"TXT",tone:"bin"}:s==="text/csv"||s==="application/csv"?{label:"CSV",tone:"bin"}:s==="text/html"||s==="application/html"||s==="application/xhtml+xml"?{label:"HTML",tone:"bin"}:s==="application/json"||s.endsWith("+json")?{label:"JSON",tone:"bin"}:s==="application/xml"||s==="text/xml"||s.endsWith("+xml")?{label:"XML",tone:"bin"}:s==="application/wasm"?{label:"WASM",tone:"bin"}:{label:"BIN",tone:"bin"}}r(sZe,"getOutputFileGlyph");function ju(e,s){const n=U1(e);if(n.startsWith("video/"))return!0;if(!QT.has(n))return!1;const a=(s??"").trim().toLowerCase();return HXe.some(i=>a.endsWith(i))}r(ju,"isVideoLikeOutput");function _w(e){return U1(e).startsWith("image/")}r(_w,"isImageContentType");function vE(e,s){const n=U1(e);if(_w(n))return!0;if(n&&!QT.has(n))return!1;const a=(s??"").trim().toLowerCase();return QXe.some(i=>a.endsWith(i))}r(vE,"isImageLikeOutput");function rX(e){const s=new Date(e).getTime();return Number.isNaN(s)?0:s}r(rX,"toTime");function yE(e){const s=(e??[]).filter(n=>n.type==="artifact"&&n.provider==="paperclip").flatMap(n=>{const a=aAe.safeParse(n.metadata);return a.success&&!tZe(a.data.contentType,a.data.originalFilename)?[]:[{id:n.id,title:n.title,status:typeof n.status=="string"?n.status:"active",isPrimary:!!n.isPrimary,createdAt:n.createdAt,metadata:a.success?a.data:null,degraded:!a.success,workProduct:n}]});return s.sort((n,a)=>n.isPrimary!==a.isPrimary?n.isPrimary?-1:1:rX(a.createdAt)-rX(n.createdAt)),{items:s,primary:s[0]??null,rest:s.slice(1),count:s.length}}r(yE,"getIssueOutputs");function DK(e){return e.metadata?.originalFilename||e.title||"output"}r(DK,"outputFilename");function Ege(e){return new Set(yE(e).items.flatMap(s=>{const n=s.metadata?.attachmentId;return n?[n]:[]}))}r(Ege,"getPromotedOutputAttachmentIds");var jh={connect:r((e,s)=>Re.post(`/companies/${e}/email/connections`,s),"connect"),inspectSaved:r((e,s)=>Re.post(`/companies/${e}/email/connections/${s}/inspect`,{}),"inspectSaved"),list:r(e=>Re.get(`/companies/${e}/email/inboxes`),"list"),setup:r((e,s)=>Re.post(`/companies/${e}/email/inboxes`,s),"setup"),inspect:r((e,s)=>Re.post(`/companies/${e}/email/inspect`,{apiKey:s}),"inspect"),control:r((e,s)=>Re.post(`/email/inboxes/${e}/control`,{action:s}),"control"),reconnect:r((e,s,n)=>Re.post(`/email/inboxes/${e}/reconnect`,{apiKey:s,receiveMode:n}),"reconnect"),resolve:r((e,s,n,a)=>Re.post(`/companies/${e}/email/deliveries/${s}/resolve`,{outcome:n,providerMessageId:a}),"resolve"),thread:r((e,s)=>Re.get(`/companies/${e}/email/tasks/${s}`),"thread"),send:r((e,s)=>Re.post(`/companies/${e}/email/send`,s),"send")},Pge=(0,u.createContext)(null);function nZe({companyId:e,issueId:s,children:n}){const{enabled:a}=$x(),i=Z({queryKey:["email-thread",e,s],queryFn:r(()=>jh.thread(e,s),"queryFn"),enabled:a,refetchInterval:a?3e3:!1});return(0,t.jsx)(Pge.Provider,{value:i.data??null,children:n})}r(nZe,"EmailThreadProvider");function Mge(e){const s=(0,u.useContext)(Pge),n=s?.messages.find(a=>a.commentId===e);return n&&s?(0,t.jsx)(Dge,{message:n,publication:s.publications.find(a=>a.providerMessageId===n.providerMessageId),issueId:s.issueId}):null}r(Mge,"useEmailComment");function Dge({message:e,publication:s,issueId:n}){const a=Z({queryKey:["email-attachments",n],queryFn:r(()=>Rt.listAttachments(n),"queryFn"),enabled:e.attachmentIds.length>0});return(0,t.jsxs)("article",{"aria-label":e.direction==="inbound"?"Email received":"Email sent",className:"space-y-4 rounded-xl border border-border bg-card p-5",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,t.jsxs)("span",{className:"flex items-center gap-2 text-sm font-semibold",children:[(0,t.jsx)(Bce,{className:"size-4"}),e.direction==="inbound"?"Email received":"Email sent"]}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:new Date(e.timestamp).toLocaleString()})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsxs)("p",{className:"text-sm font-medium",children:[e.from,e.direction==="inbound"&&(0,t.jsx)("span",{className:"ml-2 rounded-md bg-muted px-2 py-1 text-xs text-muted-foreground",children:"External"})]}),(0,t.jsxs)("p",{className:"break-words text-xs text-muted-foreground",children:["To: ",e.to.join(", ")]}),!!e.cc?.length&&(0,t.jsxs)("p",{className:"break-words text-xs text-muted-foreground",children:["Cc: ",e.cc.join(", ")]}),(0,t.jsx)("p",{className:"text-sm font-semibold",children:e.subject})]}),(0,t.jsx)("div",{className:"whitespace-pre-wrap break-words text-sm",children:e.text||"(No text body)"}),!!e.attachmentIds.length&&(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:e.attachmentIds.map(i=>{const o=a.data?.find(l=>l.id===i);return(0,t.jsxs)("a",{href:`/api/attachments/${i}/content`,target:"_blank",rel:"noreferrer",className:"flex items-center gap-2 rounded-md border border-border px-3 py-2 text-xs",children:[(0,t.jsx)(Vl,{className:"size-3.5"}),o?.originalFilename??"Open attachment"]},i)})}),(0,t.jsxs)("details",{className:"text-xs text-muted-foreground",children:[(0,t.jsx)("summary",{className:"cursor-pointer",children:"Email details"}),(0,t.jsxs)("div",{className:"space-y-2 pt-3",children:[!!e.bcc?.length&&(0,t.jsxs)("p",{children:["Bcc: ",e.bcc.join(", ")]}),(0,t.jsxs)("p",{className:"break-all",children:["Message ID: ",e.providerMessageId]}),e.fullText!==e.text&&(0,t.jsx)("div",{className:"whitespace-pre-wrap break-words",children:e.fullText})]})]}),s&&(0,t.jsxs)("p",{className:"border-t border-border pt-3 text-xs text-muted-foreground",children:[s.outcome==="delivered"?"Delivered":s.outcome==="failed"?"Delivery failed":s.outcome==="uncertain"?"Delivery uncertain":s.outcome==="queued"?"Queued":"Sent",s.error?` · ${s.error}`:""]}),a.error&&(0,t.jsx)("p",{role:"alert",className:"text-xs text-destructive",children:"Attachments could not be loaded."})]})}r(Dge,"EmailMessageCard");var Mb=(0,u.createContext)(null);function rZe(e){return e.contentType.toLowerCase().split(";")[0]?.trim()??""}r(rZe,"normalizedContentType$1");function K1(e){return e.originalFilename??e.id}r(K1,"attachmentFilename");function LK(e){return e.openPath??e.contentPath}r(LK,"attachmentOpenPath");function V1(e){return e.downloadPath??`${e.contentPath}?download=1`}r(V1,"attachmentDownloadPath");function Lge(e){const s=rZe(e);return vE(s,e.originalFilename)&&!/^image\/hei[cf](?:-sequence)?$/.test(s)}r(Lge,"isImageAttachment$2");function $ge(e){return ju(e.contentType,e.originalFilename)}r($ge,"isVideoAttachment");function aZe(e){return IIe(e)}r(aZe,"isMarkdownAttachment");function Mv({items:e,initialIndex:s,open:n,onOpenChange:a}){const[i,o]=(0,u.useState)(s),l=(0,u.useRef)(null),c=(0,u.useCallback)(v=>{l.current=v},[]);(0,u.useEffect)(()=>{n&&o(s)},[n,s]);const d=(0,u.useCallback)(()=>{o(v=>(v+1)%e.length)},[e.length]),m=(0,u.useCallback)(()=>{o(v=>(v-1+e.length)%e.length)},[e.length]);(0,u.useEffect)(()=>{i<e.length||o(0)},[i,e.length]),(0,u.useEffect)(()=>{if(!n)return;const v=r(y=>{y.key==="ArrowRight"?d():y.key==="ArrowLeft"?m():y.key==="Escape"&&a(!1)},"handler");return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[n,d,m,a]);const h=(0,u.useCallback)(v=>{const y=v.target;y.closest("button")||y.closest("a")||y===l.current||a(!1)},[a]);if(e.length===0)return null;const p=e[i];if(!p)return null;const f=K1(p),g=ju(p.contentType,p.originalFilename);return(0,t.jsx)(q2e,{open:n,onOpenChange:a,children:(0,t.jsxs)(F2e,{children:[(0,t.jsx)(B2e,{className:"fixed inset-0 z-50 bg-black/90 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 duration-200"}),(0,t.jsxs)(V2e,{className:"fixed inset-0 z-50 flex flex-col outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 duration-200",onClick:h,children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-5 py-3 text-white/80 text-sm shrink-0",children:[(0,t.jsx)("span",{className:"truncate max-w-(--pct-50) font-medium",title:f,children:f}),(0,t.jsxs)("div",{className:"flex items-center gap-4",children:[(0,t.jsxs)("span",{className:"text-white/40 tabular-nums text-xs",children:[i+1," / ",e.length]}),(0,t.jsx)("a",{href:V1(p),download:f,className:"text-white/50 hover:text-white transition-colors",title:"Download","aria-label":`Download ${f}`,onClick:r(v=>v.stopPropagation(),"onClick"),children:(0,t.jsx)(Uo,{className:"h-4.5 w-4.5"})}),(0,t.jsx)("button",{type:"button",onClick:r(()=>a(!1),"onClick"),className:"text-white/50 hover:text-white transition-colors",title:"Close",children:(0,t.jsx)(ir,{className:"h-5 w-5"})})]})]}),(0,t.jsxs)("div",{className:"flex-1 flex items-center min-h-0",children:[(0,t.jsx)("div",{className:"w-16 md:w-24 shrink-0 flex items-center justify-center h-full",children:e.length>1&&(0,t.jsx)("button",{type:"button",onClick:m,className:"rounded-full bg-white/10 p-3 text-white/60 hover:text-white hover:bg-white/20 transition-colors",title:"Previous",children:(0,t.jsx)(bu,{className:"h-7 w-7"})})}),(0,t.jsx)("div",{className:"flex-1 flex items-center justify-center min-w-0 min-h-0 h-full px-2",children:g?(0,t.jsx)("video",{ref:c,src:p.contentPath,className:"max-w-full max-h-full rounded-lg",controls:!0,playsInline:!0}):(0,t.jsx)("img",{ref:c,src:p.contentPath,alt:f,className:"max-w-full max-h-full object-contain select-none rounded-lg",draggable:!1})}),(0,t.jsx)("div",{className:"w-16 md:w-24 shrink-0 flex items-center justify-center h-full",children:e.length>1&&(0,t.jsx)("button",{type:"button",onClick:d,className:"rounded-full bg-white/10 p-3 text-white/60 hover:text-white hover:bg-white/20 transition-colors",title:"Next",children:(0,t.jsx)(Tn,{className:"h-7 w-7"})})})]}),(0,t.jsx)("div",{className:"h-6 shrink-0"})]})]})})}r(Mv,"ImageGalleryModal");function rB(e,s){if(e&&!s)return e;if(!e&&s)return s;if(e||s)return{...e,...s}}r(rB,"mergeObjects");var $K={};function OK(e,s,n,a,i){if(!n&&!a&&!i&&!e)return GT(s);let o=GT(e);return s&&(o=Vk(o,s)),n&&(o=Vk(o,n)),a&&(o=Vk(o,a)),i&&(o=Vk(o,i)),o}r(OK,"mergeProps");function iZe(e){if(e.length===0)return $K;if(e.length===1)return GT(e[0]);let s=GT(e[0]);for(let n=1;n<e.length;n+=1)s=Vk(s,e[n]);return s}r(iZe,"mergePropsN");function GT(e){return FK(e)?{...Fge(e,$K)}:oZe(e)}r(GT,"createInitialMergedProps");function Vk(e,s){return FK(s)?Fge(s,e):lZe(e,s)}r(Vk,"mergeInto");function oZe(e){const s={...e};for(const n in s){const a=s[n];Oge(n,a)&&(s[n]=Bge(a))}return s}r(oZe,"copyInitialProps");function lZe(e,s){if(!s)return e;for(const n in s){const a=s[n];switch(n){case"style":e[n]=rB(e.style,a);break;case"className":e[n]=zge(e.className,a);break;default:Oge(n,a)?e[n]=cZe(e[n],a):e[n]=a}}return e}r(lZe,"mutablyMergeInto");function Oge(e,s){const n=e.charCodeAt(0),a=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&a===110&&i>=65&&i<=90&&(typeof s=="function"||typeof s>"u")}r(Oge,"isEventHandler");function FK(e){return typeof e=="function"}r(FK,"isPropsGetter");function Fge(e,s){return FK(e)?e(s):e??$K}r(Fge,"resolvePropsGetter");function cZe(e,s){return s?e?(...n)=>{const a=n[0];if(Uge(a)){const o=a;qge(o);const l=s(...n);return o.baseUIHandlerPrevented||e?.(...n),l}const i=s(...n);return e?.(...n),i}:Bge(s):e}r(cZe,"mergeEventHandlers");function Bge(e){return e&&((...s)=>{const n=s[0];return Uge(n)&&qge(n),e(...s)})}r(Bge,"wrapEventHandler");function qge(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}r(qge,"makeEventPreventable");function zge(e,s){return s?e?s+" "+e:s:e}r(zge,"mergeClassNames");function Uge(e){return e!=null&&typeof e=="object"&&"nativeEvent"in e}r(Uge,"isSyntheticEvent");function dZe(e,s){return r(function(a,...i){const o=new URL(e);return o.searchParams.set("code",a.toString()),i.forEach(l=>o.searchParams.append("args[]",l)),`${s} error #${a}; visit ${o} for the full message.`},"formatErrorMessage")}r(dZe,"createFormatErrorMessage");var uZe=dZe("https://base-ui.com/production-error","Base UI"),aX={};function Kge(e,s){const n=u.useRef(aX);return n.current===aX&&(n.current=e(s)),n}r(Kge,"useRefWithInit");function iX(e,s,n,a){const i=Kge(Vge).current;return hZe(i,e,s,n,a)&&Wge(i,[e,s,n,a]),i.callback}r(iX,"useMergedRefs");function mZe(e){const s=Kge(Vge).current;return pZe(s,e)&&Wge(s,e),s.callback}r(mZe,"useMergedRefsN");function Vge(){return{callback:null,cleanup:null,refs:[]}}r(Vge,"createForkRef");function hZe(e,s,n,a,i){return e.refs[0]!==s||e.refs[1]!==n||e.refs[2]!==a||e.refs[3]!==i}r(hZe,"didChange");function pZe(e,s){return e.refs.length!==s.length||e.refs.some((n,a)=>n!==s[a])}r(pZe,"didChangeN");function Wge(e,s){if(e.refs=s,s.every(n=>n==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&(e.cleanup(),e.cleanup=null),n!=null){const a=Array(s.length).fill(null);for(let i=0;i<s.length;i+=1){const o=s[i];if(o!=null)switch(typeof o){case"function":{const l=o(n);typeof l=="function"&&(a[i]=l);break}case"object":o.current=n}}e.cleanup=()=>{for(let i=0;i<s.length;i+=1){const o=s[i];if(o!=null)switch(typeof o){case"function":{const l=a[i];typeof l=="function"?l():o(null);break}case"object":o.current=null}}}}}}r(Wge,"update");var fZe=parseInt("19.2.8",10);function xZe(e){return fZe>=e}r(xZe,"isReactVersionAtLeast");function oX(e){if(!u.isValidElement(e))return null;const s=e,n=s.props;return(xZe(19)?n?.ref:s.ref)??null}r(oX,"getReactElementRef");var O7t=Object.freeze([]),Wk=Object.freeze({});function gZe(e,s){const n={};for(const a in e){const i=e[a];if(s?.hasOwnProperty(a)){const o=s[a](i);o!=null&&Object.assign(n,o);continue}i===!0?n[`data-${a.toLowerCase()}`]="":i&&(n[`data-${a.toLowerCase()}`]=i.toString())}return n}r(gZe,"getStateAttributesProps");function bZe(e,s){return typeof e=="function"?e(s):e}r(bZe,"resolveClassName");function vZe(e,s){return typeof e=="function"?e(s):e}r(vZe,"resolveStyle");function yZe(e,s,n={}){const a=s.render,i=jZe(s,n);return n.enabled===!1?null:kZe(e,a,i,n.state??Wk)}r(yZe,"useRenderElement");function jZe(e,s={}){const{className:n,style:a,render:i}=e,{state:o=Wk,ref:l,props:c,stateAttributesMapping:d,enabled:m=!0}=s,h=m?bZe(n,o):void 0,p=m?vZe(a,o):void 0,f=m?gZe(o,d):Wk,g=m&&c?wZe(c):void 0,v=m?rB(f,g)??{}:Wk;return typeof document<"u"&&(m?Array.isArray(l)?v.ref=mZe([v.ref,oX(i),...l]):v.ref=iX(v.ref,oX(i),l):iX(null,null)),m?(h!==void 0&&(v.className=zge(v.className,h)),p!==void 0&&(v.style=rB(v.style,p)),v):Wk}r(jZe,"useRenderElementProps");function wZe(e){return Array.isArray(e)?iZe(e):OK(void 0,e)}r(wZe,"resolveRenderFunctionProps");var NZe=Symbol.for("react.lazy");function kZe(e,s,n,a){if(s){if(typeof s=="function")return s(n,a);const i=OK(n,s.props);i.ref=n.ref;let o=s;return o?.$$typeof===NZe&&(o=u.Children.toArray(s)[0]),u.cloneElement(o,i)}if(e&&typeof e=="string")return SZe(e,n);throw new Error(uZe(8))}r(kZe,"evaluateRenderProp");function SZe(e,s){return e==="button"?(0,u.createElement)("button",{type:"button",...s,key:s.key}):e==="img"?(0,u.createElement)("img",{alt:"",...s,key:s.key}):u.createElement(e,s)}r(SZe,"renderTag");function CZe(e){return yZe(e.defaultTagName??"div",e,e)}r(CZe,"useRender");var _Ze=Az("group/attachment relative flex w-fit max-w-full min-w-0 shrink-0 flex-wrap rounded-none border bg-card text-card-foreground transition-colors focus-within:ring-1 focus-within:ring-ring/50 has-[>a,>button]:hover:bg-muted/50 data-[state=error]:border-destructive/30 data-[state=idle]:border-dashed",{variants:{size:{default:"gap-2 text-xs has-data-[slot=attachment-content]:px-2 has-data-[slot=attachment-content]:py-1.5 has-data-[slot=attachment-media]:p-1.5",sm:"gap-2.5 text-xs has-data-[slot=attachment-content]:px-1.5 has-data-[slot=attachment-content]:py-1 has-data-[slot=attachment-media]:p-1",xs:"gap-1.5 rounded-none text-xs has-data-[slot=attachment-content]:px-1.5 has-data-[slot=attachment-content]:py-1 has-data-[slot=attachment-media]:p-1"},orientation:{horizontal:"min-w-40 items-center",vertical:"w-24 flex-col has-data-[slot=attachment-content]:w-30"}}});function Hge({className:e,state:s="done",size:n="default",orientation:a="horizontal",...i}){return(0,t.jsx)("div",{"data-slot":"attachment","data-state":s,"data-size":n,"data-orientation":a,className:U(_Ze({size:n,orientation:a}),e),...i})}r(Hge,"Attachment");var IZe=Az("relative flex aspect-square w-10 shrink-0 items-center justify-center overflow-hidden rounded-none bg-muted text-foreground group-data-[orientation=vertical]/attachment:w-full group-data-[size=sm]/attachment:w-8 group-data-[size=xs]/attachment:w-7 group-data-[size=xs]/attachment:rounded-none group-data-[state=error]/attachment:bg-destructive/10 group-data-[state=error]/attachment:text-destructive group-data-[orientation=vertical]/attachment:*:data-[slot=spinner]:size-6! [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 group-data-[orientation=vertical]/attachment:[&_svg:not([class*='size-'])]:size-6 group-data-[size=xs]/attachment:[&_svg:not([class*='size-'])]:size-3.5",{variants:{variant:{icon:"",image:"opacity-60 group-data-[state=done]/attachment:opacity-100 group-data-[state=idle]/attachment:opacity-100 *:[img]:aspect-square *:[img]:w-full *:[img]:object-cover"}},defaultVariants:{variant:"icon"}});function Qge({className:e,variant:s="icon",...n}){return(0,t.jsx)("div",{"data-slot":"attachment-media","data-variant":s,className:U(IZe({variant:s}),e),...n})}r(Qge,"AttachmentMedia");function Gge({className:e,...s}){return(0,t.jsx)("div",{"data-slot":"attachment-content",className:U("max-w-full min-w-0 flex-1 leading-tight group-data-[orientation=vertical]/attachment:px-1",e),...s})}r(Gge,"AttachmentContent");function Yge({className:e,...s}){return(0,t.jsx)("span",{"data-slot":"attachment-title",className:U("block max-w-full min-w-0 truncate font-medium group-data-[state=processing]/attachment:shimmer group-data-[state=uploading]/attachment:shimmer",e),...s})}r(Yge,"AttachmentTitle");function Jge({className:e,...s}){return(0,t.jsx)("span",{"data-slot":"attachment-description",className:U("mt-0.5 block min-w-0 truncate text-xs text-muted-foreground group-data-[state=error]/attachment:text-destructive/80","max-w-full",e),...s})}r(Jge,"AttachmentDescription");function AZe({className:e,...s}){return(0,t.jsx)("div",{"data-slot":"attachment-actions",className:U("relative z-20 flex shrink-0 items-center group-data-[orientation=vertical]/attachment:absolute group-data-[orientation=vertical]/attachment:top-3 group-data-[orientation=vertical]/attachment:right-3 group-data-[orientation=vertical]/attachment:gap-1",e),...s})}r(AZe,"AttachmentActions$1");function RZe({className:e,variant:s,size:n="icon-xs",...a}){return(0,t.jsx)(F,{"data-slot":"attachment-action",variant:s??"ghost",size:n,className:U(e),...a})}r(RZe,"AttachmentAction");function TZe({className:e,render:s,type:n,...a}){return CZe({defaultTagName:"button",props:OK({type:s?n:n??"button",className:U("absolute inset-0 z-10 outline-none",e)},a),render:s,state:{slot:"attachment-trigger"}})}r(TZe,"AttachmentTrigger");function Xge({className:e,...s}){return(0,t.jsx)("div",{"data-slot":"attachment-group",className:U("flex min-w-0 scroll-fade-x snap-x snap-mandatory scroll-px-1 scrollbar-none gap-3 overflow-x-auto overscroll-x-contain py-1 *:data-[slot=attachment]:flex-none *:data-[slot=attachment]:snap-start",e),...s})}r(Xge,"AttachmentGroup");var EZe=new Set(["png","jpg","jpeg","gif","webp","svg","avif","bmp","ico","heic"]),PZe={pdf:{icon:gi,label:"PDF"},doc:{icon:gi,label:"Doc"},docx:{icon:gi,label:"Doc"},txt:{icon:gi,label:"Text"},md:{icon:gi,label:"Markdown"},rtf:{icon:gi,label:"Text"},csv:{icon:Ok,label:"CSV"},tsv:{icon:Ok,label:"TSV"},xls:{icon:Ok,label:"Sheet"},xlsx:{icon:Ok,label:"Sheet"},zip:{icon:Y0,label:"ZIP"},gz:{icon:Y0,label:"Archive"},tar:{icon:Y0,label:"Archive"},tgz:{icon:Y0,label:"Archive"},rar:{icon:Y0,label:"Archive"},"7z":{icon:Y0,label:"Archive"},mp3:{icon:$k,label:"Audio"},wav:{icon:$k,label:"Audio"},m4a:{icon:$k,label:"Audio"},ogg:{icon:$k,label:"Audio"},mp4:{icon:p2,label:"Video"},mov:{icon:p2,label:"Video"},webm:{icon:p2,label:"Video"},json:{icon:jl,label:"JSON"},yaml:{icon:jl,label:"YAML"},yml:{icon:jl,label:"YAML"},xml:{icon:jl,label:"XML"},html:{icon:jl,label:"HTML"},css:{icon:jl,label:"CSS"},js:{icon:jl,label:"Code"},jsx:{icon:jl,label:"Code"},ts:{icon:jl,label:"Code"},tsx:{icon:jl,label:"Code"},py:{icon:jl,label:"Code"},rb:{icon:jl,label:"Code"},go:{icon:jl,label:"Code"},rs:{icon:jl,label:"Code"},sh:{icon:jl,label:"Code"},sql:{icon:jl,label:"SQL"},log:{icon:gi,label:"Log"},patch:{icon:jl,label:"Patch"},diff:{icon:jl,label:"Patch"}};function Zge(e){const s=/\.([a-z0-9]+)$/i.exec(e.trim());return s?s[1].toLowerCase():""}r(Zge,"extensionOf");function lX(e){return EZe.has(Zge(e))}r(lX,"isImageFilename");function e0e(e){return(e??"").toLowerCase().split(";")[0]?.trim()??""}r(e0e,"normalizedContentType");function AI(e){const s=e0e(e.contentType);return s.startsWith("image/")?!0:s&&s!=="application/octet-stream"?!1:lX(e.name)||lX(e.url.split("?")[0])}r(AI,"isImageAttachment$1");function t0e(e){return PZe[Zge(e)]??{icon:XR,label:"File"}}r(t0e,"fileKindForName");function MZe(e){const s=t0e(e.name);if(s.label!=="File")return s;const n=e0e(e.contentType);return n==="application/pdf"?{icon:gi,label:"PDF"}:n==="application/json"||n.endsWith("+json")?{icon:jl,label:"JSON"}:n==="text/csv"||n==="application/csv"?{icon:Ok,label:"CSV"}:n.startsWith("text/")?{icon:gi,label:"Text"}:n.startsWith("audio/")?{icon:$k,label:"Audio"}:n.startsWith("video/")?{icon:p2,label:"Video"}:n.includes("zip")||n.includes("archive")?{icon:Y0,label:"Archive"}:s}r(MZe,"fileKindForAttachment");function s0e(e){return e===void 0||!Number.isFinite(e)||e<=0?"":e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}r(s0e,"formatFileSize");function DZe(e){return/\/api\/(?:attachments|assets)\/([^/?]+)\/content/.exec(e)?.[1]??null}r(DZe,"attachmentIdFromUrl");function cX(e,s){const n=new Map(s.map(i=>[i.id,i])),a=new Map(s.flatMap(i=>[[i.contentPath,i],...i.openPath?[[i.openPath,i]]:[]]));return e.map(i=>{const o=i.url.split("?")[0],l=a.get(o)??n.get(DZe(i.url)??"");return l?{...i,id:l.id,name:l.originalFilename?.trim()||i.name,contentType:l.contentType,byteSize:l.byteSize,openPath:l.openPath,downloadPath:l.downloadPath}:i})}r(cX,"hydrateAttachmentRefs");var dX=/(?<!!)\[((?:\\.|[^\]\\])+)\]\((\/api\/(?:attachments|assets)\/[^()\s]+\/content(?:\?[^()\s]*)?)\)/g,n0e=/!\[((?:\\.|[^\]\\])*)\]\(([^()\s]+)\)/g;function r0e(e){return e.replace(n0e,"").trim().length===0&&e.trim().length>0}r(r0e,"isStandaloneImageEmbedLine");function LZe(e){const s=[],n=new Set;for(const a of e.split(`
|
|
337
337
|
`))if(r0e(a))for(const i of a.matchAll(n0e)){const[,o,l]=i;n.has(l)||(n.add(l),s.push({name:o.replace(/\\([[\]])/g,"$1"),url:l}))}return s}r(LZe,"extractImageRefs");function $Ze(e){return e.split(`
|
|
338
338
|
`).filter(s=>!r0e(s)).join(`
|
|
339
339
|
`).replace(/\n{3,}/g,`
|
|
@@ -725,7 +725,7 @@ Last resolved: user values resolve per member`;return(0,t.jsxs)("div",{role:"row
|
|
|
725
725
|
| Stage | Qualified |
|
|
726
726
|
| Owner | growth-bot |`,argumentsSummaryJson:JSON.stringify({spreadsheetId:"1AbC…xyz",range:"Leads!A2:D2",values:[["Priya Anand","Northwind","Qualified","growth-bot"]],apiKey:"[redacted]"},null,2),argumentsHash:"sha256:9f2c1a7be4d0c8a3",expiresAt:f9(42)};function Wv(e){const{toolAction:s,payload:n,...a}=e;return il({id:"interaction-tool-action-default",title:void 0,summary:void 0,createdByAgentId:"agent-codex",payload:{version:1,prompt:"Approve running this tool call?",acceptLabel:"Approve & run",rejectLabel:"Decline",...n,toolAction:{...Vzt,...s}},...a})}r(Wv,"createToolActionConfirmationInteraction");var _9t=Wv({id:"interaction-tool-action-pending-write"}),I9t=Wv({id:"interaction-tool-action-pending-destructive",toolAction:{actionRequestId:"aaaaaaa5-5555-4555-8555-5555555555a5",invocationId:"bbbbbbb6-6666-4666-8666-6666666666b6",toolName:"google_sheets.delete_rows",toolDisplayName:"Delete rows from spreadsheet",risk:"destructive",previewMarkdown:"**Permanently delete 12 rows** (rows 30–41) from the **Q3 Growth Leads** sheet. This cannot be undone.",argumentsSummaryJson:JSON.stringify({spreadsheetId:"1AbC…xyz",range:"Leads!A30:D41",rowCount:12},null,2),argumentsHash:"sha256:1c4e77aa90b3f2d1",expiresAt:f9(4)}}),A9t=Wv({id:"interaction-tool-action-running",status:"accepted",resolvedByUserId:zr.currentUserId,resolvedAt:new Date("2026-04-20T15:02:00.000Z"),updatedAt:new Date("2026-04-20T15:02:00.000Z"),result:{version:1,outcome:"accepted",toolAction:{version:1,status:"approved",updatedAt:"2026-04-20T15:02:00.000Z"}}}),R9t=Wv({id:"interaction-tool-action-executed",status:"accepted",resolvedByUserId:zr.currentUserId,resolvedAt:new Date("2026-04-20T15:02:00.000Z"),updatedAt:new Date("2026-04-20T15:02:12.000Z"),result:{version:1,outcome:"accepted",toolAction:{version:1,status:"executed",resultSummary:"Row 42 added to “Q3 Growth Leads”.",resultHref:"https://docs.google.com/spreadsheets/d/1AbCxyz/edit#gid=0&range=A42",updatedAt:"2026-04-20T15:02:12.000Z"}}}),T9t=Wv({id:"interaction-tool-action-failed",status:"accepted",resolvedByUserId:zr.currentUserId,resolvedAt:new Date("2026-04-20T15:02:00.000Z"),updatedAt:new Date("2026-04-20T15:02:09.000Z"),result:{version:1,outcome:"accepted",toolAction:{version:1,status:"failed",errorCode:"insufficient_permission",errorMessage:"The caller does not have permission to edit this spreadsheet (Google API 403). Ask the sheet owner to grant edit access to the connected account.",updatedAt:"2026-04-20T15:02:09.000Z"}}}),E9t=Wv({id:"interaction-tool-action-declined",status:"rejected",resolvedByUserId:zr.currentUserId,resolvedAt:new Date("2026-04-20T15:01:00.000Z"),updatedAt:new Date("2026-04-20T15:01:00.000Z"),result:{version:1,outcome:"rejected",reason:"We don't add leads to this sheet manually — use the CRM sync instead."}}),P9t=Wv({id:"interaction-tool-action-expired",status:"expired",updatedAt:new Date("2026-04-20T16:00:00.000Z"),resolvedAt:new Date("2026-04-20T16:00:00.000Z"),toolAction:{expiresAt:"2026-04-20T16:00:00.000Z"},result:{version:1,outcome:"superseded_by_comment",toolAction:{version:1,status:"expired",updatedAt:"2026-04-20T16:00:00.000Z"}}}),Wzt={version:1,proposalId:"eeeeeee5-5555-4555-8555-5555555555e5",sourceSecretLabel:"OpenAI API key",configPath:"access.evals_openai_api_key",targetAgentId:"ffffffff-6666-4666-8666-6666666666f6",targetAgentName:"EvalsEngineer",justification:"The evaluation runner needs the existing credential under its canonical config name.",expiresAt:f9(20160)};function m_(e){const{secretProposal:s,payload:n,...a}=e;return il({id:"interaction-secret-proposal-default",title:void 0,summary:"Review a proposed alias for an existing secret binding.",createdByAgentId:"agent-codex",resolverPolicy:"human_only",requestedResolverPolicy:"human_only",effectiveResolverPolicy:"human_only",payload:{version:1,prompt:"Approve this secret binding?",acceptLabel:"Approve & bind",rejectLabel:"Reject",allowDeclineReason:!0,...n,secretProposal:{...Wzt,...s}},...a})}r(m_,"createSecretProposalConfirmationInteraction");var M9t=m_({id:"interaction-secret-proposal-pending"});function C1e(e={}){const{payload:s,...n}=e;return il({id:"interaction-connection-authorization-default",title:"Connect your Gmail to continue",summary:"Outreach Agent needs your Gmail identity for work running as you.",createdByAgentId:"agent-codex",addresseeUserId:zr.currentUserId,resolverPolicy:"human_only",requestedResolverPolicy:"human_only",effectiveResolverPolicy:"human_only",payload:{version:1,prompt:"Connect your Gmail to continue",acceptLabel:"Connect Gmail",rejectLabel:"Not now",...s,connectionAuthorization:{version:1,providerName:"Gmail",connectionName:null,requestingAgentName:"Outreach Agent"},target:{type:"custom",key:"connection:gmail-abc:user:user-dotta",label:"Connect Gmail",href:"https://accounts.google.com/o/oauth2/v2/auth?client_id=paperclip"}},...n})}r(C1e,"createConnectionAuthorizationInteraction");var D9t=C1e({id:"interaction-connection-authorization-pending"}),L9t=C1e({id:"interaction-connection-authorization-resolved",status:"accepted",resolvedByUserId:zr.currentUserId,resolvedAt:new Date("2026-04-20T15:02:00.000Z"),updatedAt:new Date("2026-04-20T15:02:03.000Z"),result:{version:1,outcome:"accepted"}});function Hv(e={}){return{id:"interaction-connection-intent-default",companyId:zr.companyId,issueId:zr.issueId,kind:"connection_intent",title:"Connect Notion",summary:"Researcher needs this connection to continue.",status:"pending",continuationPolicy:"wake_assignee",createdByAgentId:"11111111-1111-4111-8111-111111111111",createdByUserId:null,resolvedByAgentId:null,resolvedByUserId:null,addresseeUserId:zr.currentUserId,createdAt:new Date("2026-04-20T15:08:00.000Z"),updatedAt:new Date("2026-04-20T15:08:00.000Z"),resolvedAt:null,payload:{version:1,serviceSlug:"notion",serviceName:"Notion",serviceLogoUrl:null,requestingAgentId:"11111111-1111-4111-8111-111111111111",requestingAgentName:"Researcher",phase:"requested"},result:null,resolverPolicy:"human_only",requestedResolverPolicy:"human_only",effectiveResolverPolicy:"human_only",resolverPolicyProvenance:"explicit",effectiveResolverPolicySource:"governed_action",legacyResolverPolicyAliases:{requested:"board_only",effective:"board_only"},...e}}r(Hv,"createConnectionIntentInteraction");var Hzt=Hv(),Qzt=Hv({id:"interaction-connection-intent-retry",payload:{version:1,serviceSlug:"notion",serviceName:"Notion",serviceLogoUrl:null,requestingAgentId:"11111111-1111-4111-8111-111111111111",requestingAgentName:"Researcher",phase:"needs_retry"}}),$9t=Hv({id:"interaction-connection-intent-authorizing",payload:{version:1,serviceSlug:"notion",serviceName:"Notion",serviceLogoUrl:null,requestingAgentId:"11111111-1111-4111-8111-111111111111",requestingAgentName:"Researcher",phase:"authorizing"}}),Gzt=Hv({id:"interaction-connection-intent-connected",status:"accepted",result:{version:1,outcome:"connected",connectionId:"22222222-2222-4222-8222-222222222222"},resolvedByUserId:zr.currentUserId,resolvedAt:new Date("2026-04-20T15:12:00.000Z")}),O9t=Hv({id:"interaction-connection-intent-declined",status:"rejected",result:{version:1,outcome:"declined",reason:"Not right now"},resolvedByUserId:zr.currentUserId,resolvedAt:new Date("2026-04-20T15:12:00.000Z")}),F9t=Hv({id:"interaction-connection-intent-superseded",status:"expired",result:{version:1,outcome:"superseded"},resolvedAt:new Date("2026-04-20T15:12:00.000Z")}),B9t=Hv({id:"interaction-connection-intent-expired",status:"expired",result:{version:1,outcome:"expired"},resolvedAt:new Date("2026-04-20T15:12:00.000Z")}),q9t=m_({id:"interaction-secret-proposal-executed",status:"accepted",resolvedByUserId:zr.currentUserId,resolvedAt:new Date("2026-04-20T15:02:00.000Z"),updatedAt:new Date("2026-04-20T15:02:03.000Z"),result:{version:1,outcome:"accepted",secretProposal:{version:1,status:"executed",updatedAt:"2026-04-20T15:02:03.000Z"}}}),z9t=m_({id:"interaction-secret-proposal-failed",status:"accepted",resolvedByUserId:zr.currentUserId,resolvedAt:new Date("2026-04-20T15:02:00.000Z"),updatedAt:new Date("2026-04-20T15:02:03.000Z"),result:{version:1,outcome:"accepted",secretProposal:{version:1,status:"failed",errorCode:"binding_snapshot_stale",updatedAt:"2026-04-20T15:02:03.000Z"}}}),U9t=m_({id:"interaction-secret-proposal-rejected",status:"rejected",resolvedByUserId:zr.currentUserId,resolvedAt:new Date("2026-04-20T15:02:00.000Z"),updatedAt:new Date("2026-04-20T15:02:00.000Z"),result:{version:1,outcome:"rejected",reason:"Use the project-scoped credential instead.",secretProposal:{version:1,status:"rejected",updatedAt:"2026-04-20T15:02:00.000Z"}}}),K9t=m_({id:"interaction-secret-proposal-expired",status:"expired",resolvedAt:new Date("2026-05-04T15:02:00.000Z"),updatedAt:new Date("2026-05-04T15:02:00.000Z"),secretProposal:{expiresAt:"2026-05-04T15:02:00.000Z"},result:{version:1,outcome:"superseded_by_newer_request",secretProposal:{version:1,status:"expired",updatedAt:"2026-05-04T15:02:00.000Z"}}}),V9t=il({id:"interaction-confirmation-expired-comment",status:"expired",resolvedByUserId:zr.currentUserId,resolvedAt:new Date("2026-04-20T14:38:00.000Z"),updatedAt:new Date("2026-04-20T14:38:00.000Z"),result:{version:1,outcome:"superseded_by_comment",commentId:"22222222-2222-4222-8222-222222222222"}}),W9t=il({id:"interaction-confirmation-expired-target",status:"expired",resolvedByAgentId:"agent-codex",resolvedAt:new Date("2026-04-20T14:40:00.000Z"),updatedAt:new Date("2026-04-20T14:40:00.000Z"),payload:{version:1,prompt:"Approve the plan and let the responsible start implementation?",acceptLabel:"Approve plan",rejectLabel:"Request revisions",rejectRequiresReason:!0,target:{type:"issue_document",issueId:zr.issueId,key:"plan",revisionId:"44444444-4444-4444-8444-444444444444",revisionNumber:4}},result:{version:1,outcome:"stale_target",staleTarget:{type:"issue_document",issueId:zr.issueId,key:"plan",revisionId:"11111111-1111-4111-8111-111111111111",revisionNumber:3}}}),H9t=il({id:"interaction-confirmation-failed",status:"failed",updatedAt:new Date("2026-04-20T14:42:00.000Z")}),Q9t=il({id:"interaction-confirmation-agent-addressed",title:"Confirm the deploy window with the release agent",summary:"Directed to the release agent, who owns this response without waiting on the board.",addresseeAgentId:"agent-codex"}),G9t=il({id:"interaction-confirmation-not-creator",title:"Independent review of the migration plan",summary:"Asked for a second pair of eyes, so the agent that wrote the plan cannot approve it.",requestedResolverPolicy:"not_creator"}),Y9t=il({id:"interaction-confirmation-human-only",title:"Approve the customer-facing announcement",summary:"Reserved for a human on the board because it commits the organization publicly.",requestedResolverPolicy:"human_only"}),J9t=il({id:"interaction-confirmation-company-capped",title:"Confirm the data retention change",summary:"Asked for an open audience; the organization caps this kind at a human decision.",requestedResolverPolicy:"anyone",effectiveResolverPolicy:"human_only",effectiveResolverPolicySource:"company_cap"}),X9t=il({id:"interaction-confirmation-legacy-restricted",title:"Confirm the archived cleanup batch",summary:"Created before Anyone became the default, so it stays restricted until re-created.",requestedResolverPolicy:"not_creator",resolverPolicyProvenance:"legacy_inherited_restriction"}),Z9t=il({id:"interaction-confirmation-agent-resolved",title:"Approved by the release agent",status:"accepted",createdByAgentId:"agent-codex",resolvedByAgentId:"agent-codex",resolvedByRunId:"run-agent-resolve-1",resolvedAt:new Date("2026-04-20T15:05:00.000Z"),updatedAt:new Date("2026-04-20T15:05:00.000Z"),result:{version:1,outcome:"accepted"}}),eVt=il({id:"interaction-confirmation-withdrawn",title:"Withdrawn: approve the plan",status:"cancelled",createdByAgentId:"agent-codex",resolvedByAgentId:"agent-codex",resolvedByRunId:"run-agent-withdraw-1",resolvedAt:new Date("2026-04-20T15:10:00.000Z"),updatedAt:new Date("2026-04-20T15:10:00.000Z"),result:{version:1,outcome:"withdrawn",reason:"Plan superseded by a newer revision; no board decision needed."}}),tVt=il({id:"interaction-confirmation-issue-closed",title:"Expired: confirm the migration cutover",status:"expired",resolvedAt:new Date(2026,3,20,15,12,0,0),updatedAt:new Date(2026,3,20,15,12,0,0),result:{version:1,outcome:"issue_closed",reason:"Issue was closed before the confirmation was resolved."}}),sVt=Vv({}),nVt=Vv({id:"interaction-checkbox-bounded",title:"Pick the regions to deploy first",summary:"Choose between two and three regions for the Phase 1 rollout.",payload:{version:1,prompt:"Which regions should we deploy to initially?",detailsMarkdown:"Select at least 2 and at most 3 regions.",options:[{id:"us-west",label:"US West (Oregon)",description:"Lowest latency for our primary user base."},{id:"us-east",label:"US East (Virginia)",description:"Redundancy and east coast coverage."},{id:"eu-west",label:"EU West (Ireland)",description:"GDPR compliance and European users."},{id:"ap-southeast",label:"AP Southeast (Singapore)",description:"Asia-Pacific expansion."}],defaultSelectedOptionIds:["us-west","us-east"],minSelected:2,maxSelected:3,acceptLabel:"Confirm regions",rejectLabel:"Reconsider",rejectRequiresReason:!0,rejectReasonLabel:"What should change about the region set?"}}),rVt=Vv({id:"interaction-checkbox-accepted",status:"accepted",resolvedByUserId:zr.currentUserId,resolvedAt:new Date("2026-04-20T14:49:00.000Z"),updatedAt:new Date("2026-04-20T14:49:00.000Z"),result:{version:1,outcome:"accepted",selectedOptionIds:["draft-march-report","draft-spec-v1"]}}),_1e=Array.from({length:100},(e,s)=>{const n=s+1;return{id:`record-${n}`,label:`Customer record #${n}`,description:n%4===0?"Flagged as a possible duplicate during the last import.":void 0}}),Yzt=Vv({id:"interaction-checkbox-many",title:"Select the customer records to archive",summary:"The cleanup job found 100 stale customer records. Confirm which ones to archive.",payload:{version:1,prompt:"Check every customer record you want archived.",detailsMarkdown:"The list scrolls. Use Select all / Clear selection to move quickly.",options:_1e,defaultSelectedOptionIds:[],minSelected:0,maxSelected:null,acceptLabel:"Archive selected",rejectLabel:"Reject",rejectRequiresReason:!1}}),aVt=Vv({id:"interaction-checkbox-many-accepted",status:"accepted",title:"Select the customer records to archive",resolvedByUserId:zr.currentUserId,resolvedAt:new Date("2026-04-20T14:52:00.000Z"),updatedAt:new Date("2026-04-20T14:52:00.000Z"),payload:Yzt.payload,result:{version:1,outcome:"accepted",selectedOptionIds:_1e.slice(0,42).map(e=>e.id)}}),iVt=Vv({id:"interaction-checkbox-rejected",status:"rejected",resolvedByUserId:zr.currentUserId,resolvedAt:new Date("2026-04-20T14:50:00.000Z"),updatedAt:new Date("2026-04-20T14:50:00.000Z"),result:{version:1,outcome:"rejected",reason:"Don't delete anything yet — let me confirm with the data owner first."}}),oVt=Vv({id:"interaction-checkbox-stale",status:"expired",resolvedByAgentId:"agent-codex",resolvedAt:new Date("2026-04-20T14:51:00.000Z"),updatedAt:new Date("2026-04-20T14:51:00.000Z"),payload:{version:1,prompt:"Check the draft documents you want me to delete.",acceptLabel:"Delete selected",rejectLabel:"Reject",options:[{id:"draft-march-report",label:"Old draft report"},{id:"draft-spec-v1",label:"Spec v1 (superseded)"}],target:{type:"issue_document",issueId:zr.issueId,key:"plan",revisionId:"44444444-4444-4444-8444-444444444444",revisionNumber:4}},result:{version:1,outcome:"stale_target",staleTarget:{type:"issue_document",issueId:zr.issueId,key:"plan",revisionId:"11111111-1111-4111-8111-111111111111",revisionNumber:3}}});function h_(e){return{id:"interaction-verdicts-default",companyId:zr.companyId,issueId:zr.issueId,kind:"request_item_verdicts",title:"Review 5 blog posts",summary:"This task drafted five blog posts. Approve the ones that are ready and reject the rest with a reason — each decision fans out on its own.",status:"pending",continuationPolicy:"wake_assignee",createdByAgentId:"agent-codex",createdByUserId:null,resolvedByAgentId:null,resolvedByUserId:null,createdAt:new Date("2026-04-20T15:02:00.000Z"),updatedAt:new Date("2026-04-20T15:02:00.000Z"),resolvedAt:null,payload:{version:1,prompt:"Review the 5 blog posts this task drafted.",detailsMarkdown:"Each approved post publishes immediately; rejected posts go back for a revision pass with your reason attached.",items:[{id:"post-spring-recap",label:"Spring launch recap",description:"820 words · product marketing",previewMarkdown:"**Spring launch recap** — a warm retrospective on the Q1 launch and what shipped.",href:"/PAP/issues/PAP-9001"},{id:"post-changelog-digest",label:"Monthly changelog digest",description:"540 words · engineering",previewMarkdown:"A tidy digest of the month's shipped changes, grouped by area.",href:"/PAP/issues/PAP-9002"},{id:"post-founder-note",label:"Founder's note on reliability",description:"1,100 words · leadership",previewMarkdown:"A candid note on the reliability push and the road ahead.",href:"/PAP/issues/PAP-9003"},{id:"post-customer-story",label:"Customer story: Northwind",description:"760 words · customer marketing",previewMarkdown:"How Northwind cut review time in half with the new workflow.",href:"/PAP/issues/PAP-9004"},{id:"post-hiring-push",label:"We're hiring: platform engineers",description:"420 words · recruiting",previewMarkdown:"An open call for platform engineers to join the team.",href:"/PAP/issues/PAP-9005"}],verdicts:["approve","reject"],requireReasonOn:["reject"],reasonLabel:"Why reject?",allowBulkApprove:!0,supersedeOnUserComment:!0},result:null,...e,...u_(e)}}r(h_,"createRequestItemVerdictsInteraction");var lVt=h_({}),cVt=h_({id:"interaction-verdicts-partial",updatedAt:new Date("2026-04-20T15:08:00.000Z"),result:{version:1,outcome:"resolved",complete:!1,items:[{id:"post-spring-recap",verdict:"approve",resolvedByUserId:zr.currentUserId,resolvedAt:new Date("2026-04-20T15:08:00.000Z")},{id:"post-changelog-digest",verdict:"reject",reason:"Tone is off-brand — too dry. Warm it up and re-submit.",resolvedByUserId:zr.currentUserId,resolvedAt:new Date("2026-04-20T15:08:00.000Z")}]}}),dVt=h_({id:"interaction-verdicts-complete",status:"answered",resolvedByUserId:zr.currentUserId,resolvedAt:new Date("2026-04-20T15:14:00.000Z"),updatedAt:new Date("2026-04-20T15:14:00.000Z"),result:{version:1,outcome:"resolved",complete:!0,items:[{id:"post-spring-recap",verdict:"approve",resolvedByUserId:zr.currentUserId,resolvedAt:new Date("2026-04-20T15:08:00.000Z")},{id:"post-changelog-digest",verdict:"reject",reason:"Tone is off-brand — too dry. Warm it up and re-submit.",resolvedByUserId:zr.currentUserId,resolvedAt:new Date("2026-04-20T15:08:00.000Z")},{id:"post-founder-note",verdict:"approve",resolvedByUserId:zr.currentUserId,resolvedAt:new Date("2026-04-20T15:14:00.000Z")},{id:"post-customer-story",verdict:"approve",resolvedByUserId:zr.currentUserId,resolvedAt:new Date("2026-04-20T15:14:00.000Z")},{id:"post-hiring-push",verdict:"reject",reason:"Hold the recruiting post until the req is approved.",resolvedByUserId:zr.currentUserId,resolvedAt:new Date("2026-04-20T15:14:00.000Z")}]}}),uVt=h_({id:"interaction-verdicts-superseded",status:"expired",resolvedByUserId:zr.currentUserId,resolvedAt:new Date("2026-04-20T15:16:00.000Z"),updatedAt:new Date("2026-04-20T15:16:00.000Z"),result:{version:1,outcome:"superseded_by_comment",complete:!1,commentId:"33333333-3333-4333-8333-333333333333",items:[{id:"post-spring-recap",verdict:"approve",resolvedByUserId:zr.currentUserId,resolvedAt:new Date("2026-04-20T15:08:00.000Z")},{id:"post-changelog-digest",verdict:"reject",reason:"Tone is off-brand — too dry. Warm it up and re-submit.",resolvedByUserId:zr.currentUserId,resolvedAt:new Date("2026-04-20T15:08:00.000Z")}]}}),Jzt=Array.from({length:24},(e,s)=>{const n=s+1;return{id:`draft-post-${n}`,label:`Draft post #${n}`,description:`${300+n*17} words · auto-generated series`}}),mVt=h_({id:"interaction-verdicts-many",title:"Review 24 generated posts",summary:"A batch-generation task produced 24 posts. Decide them in passes; the card stays until all are decided.",payload:{version:1,prompt:"Review the 24 posts this batch produced.",detailsMarkdown:"The expanded list scrolls. Approve all to accept the batch, or decide item by item.",items:Jzt,verdicts:["approve","reject"],requireReasonOn:["reject"],reasonLabel:"Why reject?",allowBulkApprove:!0,supersedeOnUserComment:!0}}),hVt=[qoe({id:"comment-thread-board",body:"Pressure-test first-class issue-thread interactions before we touch persistence. I want to see the cards in the real feed, not in a disconnected mock.",createdAt:new Date("2026-04-20T14:02:00.000Z"),updatedAt:new Date("2026-04-20T14:02:00.000Z")}),qoe({id:"comment-thread-agent",authorAgentId:"agent-codex",authorUserId:null,body:"I found the existing issue chat surface and I am adding prototype-only interaction records so the Storybook review can happen before persistence work.",createdAt:new Date("2026-04-20T14:09:00.000Z"),updatedAt:new Date("2026-04-20T14:09:00.000Z"),runId:"run-thread-interaction",runAgentId:"agent-codex"})],pVt=[{id:"event-thread-checkout",createdAt:new Date("2026-04-20T14:01:00.000Z"),actorType:"user",actorId:zr.currentUserId,statusChange:{from:"todo",to:"in_progress"}}],Xzt=new Set(["local_path","agent_package"]);function n5(e){return Xzt.has(e.type)?"unsupported_in_ui":e.pinned?"ok":"unpinned"}r(n5,"sourceWarningCode");function Zzt(e){let s="safe";for(const n of e.sourceRefs){const a=n5(n);if(a==="unsupported_in_ui")return"blocked";a==="unpinned"&&(s="has_warnings")}return s}r(Zzt,"teamRisk");function eUt(e){return e.counts.localSkills+e.counts.catalogSkills+e.counts.externalSkillSources}r(eUt,"skillCount");function zoe(e){return e.replace(/[-_/]+/g," ").replace(/\b\w/g,s=>s.toUpperCase()).trim()}r(zoe,"titleCase");var tUt={markdown_only:{label:"Markdown only",tip:"Contains only markdown and references. No executable content.",tone:"text-emerald-600 dark:text-emerald-300 border-emerald-500/30",Icon:Ii},assets:{label:"Assets",tip:"Includes static assets (images, fixtures). No executable content.",tone:"text-emerald-600 dark:text-emerald-300 border-emerald-500/30",Icon:Ii},scripts_executables:{label:"Scripts",tip:"Includes executable scripts that were security-reviewed before bundling.",tone:"text-amber-600 dark:text-amber-300 border-amber-500/30",Icon:Is},external_sources:{label:"External sources",tip:"References external sources resolved at install time.",tone:"text-amber-600 dark:text-amber-300 border-amber-500/30",Icon:Is}};function I1e({level:e,iconOnly:s=!1}){const n=tUt[e],{Icon:a}=n;return(0,t.jsxs)(Wn,{children:[(0,t.jsx)(Hn,{asChild:!0,children:(0,t.jsxs)(lt,{variant:"outline",className:U("px-1.5 text-(length:--text-micro)",n.tone),children:[(0,t.jsx)(a,{className:"h-3 w-3"}),!s&&n.label]})}),(0,t.jsx)(Qn,{children:n.tip})]})}r(I1e,"TrustChip");function A1e(e){switch(e){case"github":return _d;case"url":return ic;case"local_path":return Wc;case"agent_package":return Eh;case"skills_sh":return Ul;default:return ic}}r(A1e,"sourceKindIcon");function sUt({team:e}){const s=new Set(e.rootAgentSlugs),n=e.agentSlugs.filter(i=>!s.has(i)),a=e.rootAgentSlugs.length>0;return(0,t.jsx)("div",{className:"max-h-72 overflow-auto rounded-md border border-border",children:(0,t.jsxs)("ul",{className:"divide-y divide-border/60",children:[e.rootAgentSlugs.map(i=>(0,t.jsxs)("li",{className:U("flex items-center gap-2 px-3 py-2 text-sm",a&&"border-l-2 border-amber-500/50"),children:[(0,t.jsx)($2e,{className:"h-3.5 w-3.5 text-amber-500"}),(0,t.jsx)("span",{className:"font-medium",children:zoe(i)}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"root agent"})]},i)),n.map(i=>(0,t.jsxs)("li",{className:"flex items-center gap-2 px-3 py-2 pl-7 text-sm",children:[(0,t.jsx)(Rj,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,t.jsx)("span",{children:zoe(i)})]},i)),e.agentSlugs.length===0&&(0,t.jsx)("li",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No agents in this team."})]})})}r(sUt,"TeamHierarchyPreview");function nUt({children:e}){return(0,t.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:e})}r(nUt,"SectionHeader");function rUt({skills:e}){return e.length===0?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"No required skills."}):(0,t.jsx)("ul",{className:"space-y-1",children:e.map(s=>(0,t.jsxs)("li",{className:"flex items-center gap-2 rounded-md border border-border px-3 py-2 text-sm",children:[(0,t.jsx)(Ul,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,t.jsx)("span",{className:"font-mono text-xs",children:s.ref}),(0,t.jsx)(lt,{variant:"outline",className:"ml-auto text-(length:--text-nano)",children:s.type}),s.resolved?(0,t.jsx)(lt,{variant:"outline",className:"text-(length:--text-nano) text-emerald-600 dark:text-emerald-300 border-emerald-500/30",children:"resolved"}):(0,t.jsx)(lt,{variant:"outline",className:"text-(length:--text-nano) text-amber-600 dark:text-amber-300 border-amber-500/30",children:"external"})]},`${s.type}:${s.ref}`))})}r(rUt,"RequiredSkillsList");function aUt({inputs:e}){return e.length===0?null:(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)(nUt,{children:"Secrets & env inputs"}),(0,t.jsx)("ul",{className:"space-y-1",children:e.map(s=>(0,t.jsxs)("li",{className:"flex items-center gap-2 rounded-md border border-border px-3 py-2 text-sm",children:[(0,t.jsx)(bi,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,t.jsx)("span",{className:"font-mono text-xs uppercase tracking-wide",children:s.key}),(0,t.jsx)(lt,{variant:"outline",className:U("ml-auto text-(length:--text-nano)",s.kind==="secret"?"text-rose-600 dark:text-rose-300 border-rose-500/30":"text-muted-foreground"),children:s.kind}),s.requirement==="required"&&(0,t.jsx)(lt,{variant:"outline",className:"text-(length:--text-nano)",children:"required"})]},s.key))})]})}r(aUt,"EnvInputsList");function iUt({sources:e}){const s=e.filter(i=>i.type!=="include"),[n,a]=(0,u.useState)(!1);return s.length===0?null:(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsxs)("button",{type:"button",onClick:r(()=>a(i=>!i),"onClick"),className:"flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:[n?(0,t.jsx)(sn,{className:"h-3 w-3"}):(0,t.jsx)(Tn,{className:"h-3 w-3"}),"External sources · ",s.length]}),n&&(0,t.jsx)("ul",{className:"divide-y divide-border rounded-md border border-border",children:s.map(i=>{const o=A1e(i.type),l=n5(i);return(0,t.jsxs)("li",{className:"flex items-center gap-2 px-3 py-2 text-sm",children:[(0,t.jsx)(o,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,t.jsx)("span",{className:"font-mono text-xs truncate",children:i.ref}),(0,t.jsxs)("span",{className:"ml-auto text-(length:--text-micro)",children:[l==="ok"&&(0,t.jsx)("span",{className:"text-emerald-600 dark:text-emerald-300",children:"Pinned"}),l==="unpinned"&&(0,t.jsx)("span",{className:"text-amber-600 dark:text-amber-300",children:"Unpinned"}),l==="unsupported_in_ui"&&(0,t.jsx)("span",{className:"text-rose-600 dark:text-rose-300",children:"Unsupported in browser install"})]})]},`${i.type}:${i.ref}`)})})]})}r(iUt,"ExternalSourcesList");function oUt({team:e,allowExternalSources:s,allowUnpinnedOptionalSources:n,allowLocalPathSources:a,onChange:i}){const o=e.sourceRefs.filter(c=>c.type!=="include"),l=o.some(c=>n5(c)==="unsupported_in_ui");return(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{role:"alert",className:"rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2.5 text-sm text-amber-700 dark:text-amber-300",children:["This team references ",o.length," external source",o.length===1?"":"s",". Review each one and decide what to allow before continuing."]}),(0,t.jsx)("ul",{className:"divide-y divide-border rounded-md border border-border",children:o.map(c=>{const d=A1e(c.type),m=n5(c);return(0,t.jsxs)("li",{className:"flex items-center gap-2 px-3 py-2.5 text-sm",children:[(0,t.jsx)(d,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"font-mono text-xs truncate",children:c.ref}),(0,t.jsxs)("p",{className:"text-(length:--text-micro) text-muted-foreground",children:[m==="ok"&&"pinned",m==="unpinned"&&"unpinned reference",m==="unsupported_in_ui"&&"not installable from the browser"]})]}),(0,t.jsx)(lt,{variant:"outline",className:U("ml-auto text-(length:--text-nano)",m==="unsupported_in_ui"?"text-rose-600 dark:text-rose-300 border-rose-500/30":m==="unpinned"?"text-amber-600 dark:text-amber-300 border-amber-500/30":"text-emerald-600 dark:text-emerald-300 border-emerald-500/30"),children:c.type})]},`${c.type}:${c.ref}`)})}),(0,t.jsxs)("div",{className:"space-y-2.5 rounded-md border border-border p-3",children:[(0,t.jsx)(sO,{label:"Allow external sources",description:"Resolve github/url skill and team sources at install time.",checked:s,onChange:r(c=>i("external",c),"onChange")}),(0,t.jsx)(sO,{label:"Allow unpinned optional sources",description:"Permit optional sources that are not pinned to a ref or checksum.",checked:n,onChange:r(c=>i("unpinned",c),"onChange")}),(0,t.jsx)(sO,{label:"Allow local-path sources",description:"Required for local_path / agent_package sources. Development use only.",checked:a,onChange:r(c=>i("localPath",c),"onChange")})]}),l&&!a&&(0,t.jsx)("p",{className:"text-xs text-rose-600 dark:text-rose-300",children:"This team has local-path sources. Enable “Allow local-path sources” to continue, or install it from the CLI."})]})}r(oUt,"StepSourcePolicy");function sO({label:e,description:s,checked:n,onChange:a}){return(0,t.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:e}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:s})]}),(0,t.jsx)(_i,{checked:n,onCheckedChange:a})]})}r(sO,"PolicyToggle");var lUt={already_in_package:{label:"Bundled in package",tone:"text-emerald-600 dark:text-emerald-300 border-emerald-500/30"},catalog_install_required:{label:"Will install from catalog",tone:"text-blue-600 dark:text-blue-300 border-blue-500/30"},external_import_required:{label:"Will import from source",tone:"text-amber-600 dark:text-amber-300 border-amber-500/30"},blocked:{label:"Blocked",tone:"text-rose-600 dark:text-rose-300 border-rose-500/30"}};function cUt({team:e,preparations:s}){return(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)("div",{role:"alert",className:"rounded-md border border-blue-500/30 bg-blue-500/10 px-3 py-2.5 text-sm text-blue-700 dark:text-blue-300",children:"Before agents are imported, the catalog resolves the skills they depend on. This is the resolution plan."}),(0,t.jsx)("ul",{className:"divide-y divide-border rounded-md border border-border",children:(s??e.requiredSkills.map(dUt)).map(n=>{const a=lUt[n.action];return(0,t.jsxs)("li",{className:"flex items-center gap-2 px-3 py-2.5 text-sm",children:[(0,t.jsx)(Ul,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"font-mono text-xs truncate",children:n.ref}),n.reason&&(0,t.jsx)("p",{className:"text-(length:--text-micro) text-muted-foreground",children:n.reason})]}),(0,t.jsx)(lt,{variant:"outline",className:U("ml-auto text-(length:--text-nano)",a.tone),children:a.label})]},`${n.type}:${n.ref}`)})})]})}r(cUt,"StepSkillPlan");function dUt(e){return{type:e.type,ref:e.ref,agentSlugs:e.agentSlugs,action:e.type==="catalog"?"catalog_install_required":e.resolved?"already_in_package":"external_import_required",catalogSkillId:e.catalogSkillId??null,catalogSkillKey:e.catalogSkillKey??null,sourceLocator:e.sourceLocator??null,sourceRef:e.sourceRef??null,reason:null}}r(dUt,"toPreparation");function r2({team:e,selected:s,onSelect:n,installed:a}){const i=Zzt(e),o=!!a?.outOfDate;return(0,t.jsxs)("button",{type:"button",onClick:n,className:U("flex w-full flex-col gap-1 border-b border-border/60 px-3 py-2.5 text-left transition-colors hover:bg-accent/30",s&&"bg-accent/40"),children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Rj,{className:U("h-3.5 w-3.5 text-muted-foreground",e.kind==="optional"&&"opacity-70")}),(0,t.jsx)("span",{className:U("line-clamp-2 text-(length:--text-compact) font-medium",s&&"text-foreground"),children:e.name}),o&&(0,t.jsxs)(Wn,{children:[(0,t.jsx)(Hn,{asChild:!0,children:(0,t.jsx)("span",{"aria-label":"Update available",className:"inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border border-amber-500/40 bg-amber-500/10 text-amber-600 dark:text-amber-300",children:(0,t.jsx)(f1,{className:"h-3 w-3"})})}),(0,t.jsx)(Qn,{children:"Update available — installed team is out of date"})]}),i!=="safe"&&(0,t.jsxs)(Wn,{children:[(0,t.jsx)(Hn,{asChild:!0,children:(0,t.jsx)(Is,{className:U("ml-auto h-3.5 w-3.5",i==="blocked"?"text-rose-500":"text-amber-500")})}),(0,t.jsx)(Qn,{children:"Has external sources"})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 text-(length:--text-micro) text-muted-foreground",children:[(0,t.jsxs)("span",{children:[e.counts.agents,"a · ",e.counts.projects,"p · ",e.counts.routines,"r · ",eUt(e),"s"]}),(0,t.jsx)(I1e,{level:e.trustLevel,iconOnly:!0})]})]})}r(r2,"TeamRow");function uUt({team:e,selected:s=!1,onSelect:n}){return(0,t.jsxs)("button",{type:"button",onClick:n,"aria-pressed":s,className:U("flex aspect-square w-full flex-col gap-2 rounded-lg border border-border bg-card p-4 text-left transition-colors hover:bg-accent/30 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",s&&"ring-2 ring-ring"),children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsx)("span",{className:"flex h-8 w-8 items-center justify-center rounded-md border border-border bg-background",children:(0,t.jsx)(Rj,{className:"h-4 w-4 text-muted-foreground"})}),e.trustLevel!=="markdown_only"&&(0,t.jsx)(I1e,{level:e.trustLevel,iconOnly:!0})]}),(0,t.jsxs)("div",{className:"space-y-0.5",children:[(0,t.jsx)("h3",{className:"text-sm font-semibold leading-snug",children:e.name}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:[e.counts.agents," agent",e.counts.agents===1?"":"s"," ·"," ",e.counts.projects," project",e.counts.projects===1?"":"s"," ·"," ",e.counts.routines," routine",e.counts.routines===1?"":"s"]})]}),e.description&&(0,t.jsx)("p",{className:"line-clamp-3 text-xs text-muted-foreground",children:e.description}),e.tags.length>0&&(0,t.jsx)("div",{className:"mt-auto flex flex-wrap gap-1",children:e.tags.map(a=>(0,t.jsx)(lt,{variant:"outline",className:"text-(length:--text-nano)",children:a},a))})]})}r(uUt,"TeamCard");var vc={id:"paperclipai:bundled:company-defaults:core-exec-team",key:"paperclipai/bundled/company-defaults/core-exec-team",kind:"bundled",category:"company-defaults",slug:"core-exec-team",name:"Core Exec Team",description:"A starter executive team: a CEO who manages a CTO and a CMO, plus a launch project and a weekly standup routine. Installs ready-to-run agents you can customize.",path:"catalog/bundled/company-defaults/core-exec-team",entrypoint:"TEAM.md",schema:"agentcompanies/v1",defaultInstall:!0,recommendedForCompanyTypes:["company-root"],tags:["exec","starter"],counts:{agents:3,projects:1,tasks:1,routines:1,localSkills:1,catalogSkills:1,externalSkillSources:1},rootAgentSlugs:["ceo"],agentSlugs:["ceo","cto","cmo"],projectSlugs:["launch"],requiredSkills:[{type:"catalog",ref:"engineering/code-review",agentSlugs:["cto"],resolved:!0,catalogSkillKey:"engineering/code-review"},{type:"github",ref:"acme/growth-playbook@v1.2.0",agentSlugs:["cmo"],resolved:!1,sourceRef:"v1.2.0"}],envInputs:[{key:"OPENAI_API_KEY",agentSlug:"cto",projectSlug:null,kind:"secret",requirement:"required"},{key:"DEFAULT_TIMEZONE",agentSlug:null,projectSlug:"launch",kind:"plain",requirement:"optional"}],sourceRefs:[{type:"github",ref:"acme/growth-playbook@v1.2.0",pinned:!0},{type:"url",ref:"https://example.com/policies/brand.md",pinned:!1}],files:[{path:"TEAM.md",kind:"team",sizeBytes:2144,sha256:"a1"},{path:"README.md",kind:"readme",sizeBytes:980,sha256:"a2"},{path:"agents/ceo/AGENTS.md",kind:"agent",sizeBytes:1200,sha256:"a3"},{path:"agents/cto/AGENTS.md",kind:"agent",sizeBytes:1100,sha256:"a4"},{path:"agents/cmo/AGENTS.md",kind:"agent",sizeBytes:1050,sha256:"a5"},{path:"projects/launch/PROJECT.md",kind:"project",sizeBytes:640,sha256:"a6"}],trustLevel:"external_sources",compatibility:"compatible",contentHash:"sha256:deadbeefdeadbeefdeadbeefdeadbeef",packageName:"@tickernelz/paperclip-pro-teams-catalog",packageVersion:"0.1.0"},mUt={...vc,id:"paperclipai:optional:software-development:platform-pod",key:"paperclipai/optional/software-development/platform-pod",kind:"optional",category:"software-development",slug:"platform-pod",name:"Platform Engineering Pod",description:"An optional platform pod with a tech lead and two engineers.",recommendedForCompanyTypes:[],counts:{...vc.counts,agents:4,routines:2},rootAgentSlugs:["tech-lead"],agentSlugs:["tech-lead","eng-1","eng-2","sre"],trustLevel:"markdown_only",sourceRefs:[]},Uoe={...vc,id:"paperclipai:optional:research:lab-with-local-source",slug:"lab-with-local-source",name:"Research Lab (local source)",kind:"optional",category:"research",trustLevel:"scripts_executables",sourceRefs:[{type:"url",ref:"https://example.com/unpinned.md",pinned:!1},{type:"local_path",ref:"/Users/dev/skills/secret-sauce",pinned:!1}]},R1e={catalogId:vc.id,catalogKey:vc.key,present:!0,currentContentHash:vc.contentHash,installedOriginHashes:["sha256:0000older0000older0000older"],agentCount:3,outOfDate:!0},hUt={...R1e,installedOriginHashes:[vc.contentHash],outOfDate:!1},pUt=[{type:"catalog",ref:"engineering/code-review",agentSlugs:["cto"],action:"already_in_package",catalogSkillId:"skill-1",catalogSkillKey:"engineering/code-review",sourceLocator:null,sourceRef:null,reason:null},{type:"github",ref:"acme/growth-playbook@v1.2.0",agentSlugs:["cmo"],action:"external_import_required",catalogSkillId:null,catalogSkillKey:null,sourceLocator:"github.com/acme/growth-playbook",sourceRef:"v1.2.0",reason:"Resolved from GitHub at install time"}],Koe=[{...vc,trustLevel:"markdown_only",sourceRefs:[],requiredSkills:[],counts:{...vc.counts,localSkills:0,catalogSkills:0,externalSkillSources:0}},{...vc,id:"paperclipai:bundled:company-defaults:growth-pod",key:"paperclipai/bundled/company-defaults/growth-pod",slug:"growth-pod",name:"Growth Pod",description:"A lean growth squad: a head of growth managing a content marketer and a data analyst, wired to a launch project and a weekly metrics routine.",tags:["growth","marketing","starter"],counts:{agents:3,projects:1,tasks:0,routines:1,localSkills:0,catalogSkills:0,externalSkillSources:0},rootAgentSlugs:["head-of-growth"],agentSlugs:["head-of-growth","content-marketer","data-analyst"],trustLevel:"assets",sourceRefs:[],requiredSkills:[]},{...vc,id:"paperclipai:bundled:company-defaults:support-pod",key:"paperclipai/bundled/company-defaults/support-pod",slug:"support-pod",name:"Support Pod",description:"A two-person support desk with a lead and an agent, plus a triage routine.",tags:["support","ops"],counts:{agents:2,projects:0,tasks:0,routines:1,localSkills:0,catalogSkills:0,externalSkillSources:0},rootAgentSlugs:["support-lead"],agentSlugs:["support-lead","support-agent"],projectSlugs:[],trustLevel:"markdown_only",sourceRefs:[],requiredSkills:[]}];function az(e,s,n,a,i){const o=`/api/attachments/${s}/content`;return{id:e,companyId:"demo-company",projectId:null,issueId:"demo-issue",executionWorkspaceId:null,runtimeServiceId:null,type:"artifact",provider:"paperclip",externalId:null,title:a,url:null,status:"active",reviewState:"none",isPrimary:!!i.isPrimary,healthStatus:"unknown",summary:null,createdByRunId:null,createdAt:new Date(i.createdAt),updatedAt:new Date(i.createdAt),metadata:{attachmentId:s,contentType:n,byteSize:i.byteSize,contentPath:o,openPath:o,downloadPath:`${o}?download=1`,originalFilename:a}}}r(az,"sampleOutput");var fUt=[az("wp-vid","aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa","video/mp4","q3-summary.mp4",{byteSize:19293798,isPrimary:!0,createdAt:"2026-05-30T12:00:00Z"}),az("wp-pdf","bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb","application/pdf","talking-points.pdf",{byteSize:421888,createdAt:"2026-05-30T11:52:00Z"})],xUt=[{...az("wp-broken","cccccccc-cccc-4ccc-8ccc-cccccccccccc","video/mp4","corrupt-output.mp4",{byteSize:0,isPrimary:!0,createdAt:"2026-05-30T12:01:00Z"}),metadata:{attachmentId:"cccccccc-cccc-4ccc-8ccc-cccccccccccc",contentType:"video/mp4"}}],a2={id:"design-guide-task",identifier:"PAP-427",title:"Reconcile the navigation model across operator surfaces",status:"in_progress",priority:"medium",blockerAttention:!1};function Or({title:e,children:s}){return(0,t.jsxs)("section",{className:"space-y-4",children:[(0,t.jsx)("h3",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wide",children:e}),(0,t.jsx)(hl,{}),s]})}r(Or,"Section");function ar({title:e,children:s}){return(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)("h4",{className:"text-sm font-medium",children:e}),s]})}r(ar,"SubSection");function gUt(){const[e,s]=(0,u.useState)(Koe[0]?.id??null);return(0,t.jsx)("div",{className:"grid max-w-2xl gap-4 md:grid-cols-2 lg:grid-cols-3",children:Koe.map(n=>(0,t.jsx)(uUt,{team:n,selected:n.id===e,onSelect:r(()=>s(n.id),"onSelect")},n.id))})}r(gUt,"TeamCardShowcase");var Voe=[{id:"dg-github",companyId:"dg",scope:"company",ownerUserId:null,userSecretDefinitionId:null,key:"github_token",name:"GITHUB_TOKEN",provider:"local_encrypted",status:"active",managedMode:"paperclip_managed",externalRef:null,providerConfigId:null,providerMetadata:null,latestVersion:3,description:null,lastResolvedAt:null,lastRotatedAt:null,deletedAt:null,createdByAgentId:null,createdByUserId:null,createdAt:new Date("2026-03-01T10:00:00.000Z"),updatedAt:new Date("2026-03-01T10:00:00.000Z")},{id:"dg-db",companyId:"dg",scope:"company",ownerUserId:null,userSecretDefinitionId:null,key:"db_connection",name:"DB_CONNECTION",provider:"local_encrypted",status:"active",managedMode:"paperclip_managed",externalRef:null,providerConfigId:null,providerMetadata:null,latestVersion:3,description:null,lastResolvedAt:null,lastRotatedAt:null,deletedAt:null,createdByAgentId:null,createdByUserId:null,createdAt:new Date("2026-03-01T10:00:00.000Z"),updatedAt:new Date("2026-03-01T10:00:00.000Z")}];function bUt(){const[e,s]=(0,u.useState)({NODE_ENV:{type:"plain",value:"production"},GH_TOKEN:{type:"secret_ref",secretId:"dg-github",version:"latest"},DB_URL:{type:"secret_ref",secretId:"dg-db",version:3},STRIPE_API_KEY:{type:"plain",value:"sk-live-51H8xL0aBcDeFgHiJkLmNoPq"}});return(0,t.jsx)("div",{className:"max-w-(--sz-640px) rounded-md border border-border p-4",children:(0,t.jsx)(rv,{value:e,secrets:Voe,onChange:r(n=>s(n??{}),"onChange"),onCreateSecret:r(async n=>({...Voe[0],id:`dg-${n}`,key:n,name:n.toUpperCase(),latestVersion:1}),"onCreateSecret")})})}r(bUt,"EnvironmentVariablesEditorShowcase");function Zl({name:e,cssVar:s}){return(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"h-8 w-8 rounded-md border border-border shrink-0",style:{backgroundColor:`var(${s})`}}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-xs font-mono",children:s}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:e})]})]})}r(Zl,"Swatch");function vUt(){const[e,s]=(0,u.useState)(!0),[n,a]=(0,u.useState)(null),[i,o]=(0,u.useState)(!0);return(0,t.jsxs)("div",{className:"max-w-xl space-y-4",children:[(0,t.jsx)("div",{className:"w-52 rounded-md border border-border p-1",children:(0,t.jsx)(cNe,{scope:"subtree",canPause:e,canResume:!e,canCancel:!0,canRestore:!e,onPause:r(()=>s(!1),"onPause"),onResume:r(()=>a("resume"),"onResume"),onCancel:r(()=>a("cancel"),"onCancel"),onRestore:r(()=>a("restore"),"onRestore")})}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e?"Running: type to switch Stop to Send.":"Paused: resume from the menu."}),(0,t.jsx)(Nge,{item:{id:"design-project",kind:"project_created",projectId:"example-project",name:"Onboarding improvements",description:"Help new teams reach their first useful result.",timestamp:"2026-09-11T00:00:00Z",repositories:[{id:"1",name:"paperclipai/paperclip",url:"https://github.com/paperclipai/paperclip"}]}}),e?null:(0,t.jsx)(c0e,{item:{id:"design-cancelled",kind:"marker",variant:"interrupted",tone:"neutral",label:"Run cancelled",detail:"The run was cancelled before returning an answer.",collapsible:!0}}),(0,t.jsx)(c7,{pause:e?null:{scope:"subtree",onResume:r(()=>a("resume"),"onResume")},onAdd:r(async()=>{},"onAdd"),workMode:"standard",stopScope:"subtree",onStop:e?async()=>s(!1):void 0}),(0,t.jsx)(dNe,{open:n!==null,onOpenChange:r(l=>{l||a(null)},"onOpenChange"),mode:n??"cancel",scope:"subtree",affectedCount:3,affectedAgentCount:2,loading:!1,pending:!1,valid:!0,wakeAgents:i,onWakeAgentsChange:o,onRetry:r(()=>{},"onRetry"),onApply:r(()=>{s(n!=="cancel"&&i),a(null)},"onApply")})]})}r(vUt,"TaskExecutionControlsExample");function yUt(){const[e,s]=(0,u.useState)(!0),[n,a]=(0,u.useState)(!0);return(0,t.jsx)("div",{className:"max-w-xl",children:(0,t.jsx)(c7,{onAdd:r(async()=>{},"onAdd"),workMode:"standard",takeover:n&&e?{id:"design-question",label:"Question",pendingCount:1,content:(0,t.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,t.jsx)("p",{children:"Should the agent use the existing draft?"}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(F,{size:"sm",onClick:r(()=>a(!1),"onClick"),children:"Use draft"}),(0,t.jsx)(F,{size:"sm",variant:"outline",onClick:r(()=>a(!1),"onClick"),children:"Start fresh"})]})]}),onDismiss:r(()=>s(!1),"onDismiss"),onSkip:r(()=>a(!1),"onSkip")}:null,pendingTakeover:n?{count:1,label:"Question",onOpen:r(()=>s(!0),"onOpen")}:null})})}r(yUt,"TaskPendingInputExample");function jUt(){const[e,s]=(0,u.useState)("closed");return(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsx)(F,{variant:"outline",onClick:r(()=>s("empty"),"onClick"),children:"Empty picker"}),(0,t.jsx)(F,{variant:"outline",onClick:r(()=>s("loading"),"onClick"),children:"Loading picker"}),(0,t.jsx)(F,{variant:"outline",onClick:r(()=>s("error"),"onClick"),children:"Failed picker"}),(0,t.jsx)(Wue,{agents:[],open:e!=="closed",onOpenChange:r(n=>{n||s("closed")},"onOpenChange"),onSelect:r(()=>{},"onSelect"),loading:e==="loading",error:e==="error"?new Error("Unavailable"):null,onRetry:r(()=>s("empty"),"onRetry")})]})}r(jUt,"AgentChatPickerExample");function wUt(){const[e,s]=(0,u.useState)("standard");return(0,t.jsxs)("div",{className:"flex max-w-xl items-center gap-2 rounded-xl border border-border bg-card p-3",children:[(0,t.jsx)(zwe,{mode:e,onModeChange:s,onAttachFile:r(()=>{},"onAttachFile"),onGoal:r(()=>{},"onGoal")}),(0,t.jsx)(Uwe,{mode:e,onRemove:r(()=>s("standard"),"onRemove")}),(0,t.jsx)("span",{className:"ml-auto text-xs text-muted-foreground",children:"Plus menu · removable mode chip"})]})}r(wUt,"ComposerActionsExample");function NUt(){const[e,s]=(0,u.useState)(0),[n,a]=(0,u.useState)("todo"),[i,o]=(0,u.useState)("medium"),[l,c]=(0,u.useState)("in_progress"),[d,m]=(0,u.useState)(!0),[h,p]=(0,u.useState)(!1),[f,g]=(0,u.useState)("Click to edit this text"),[v,y]=(0,u.useState)("Editable Title"),[w,S]=(0,u.useState)("This is an editable description. Click to edit it — the textarea auto-sizes to fit the content without layout shift."),[j,N]=(0,u.useState)([{key:"status",label:"Status",value:"Active"}]),[_,R]=(0,u.useState)(!1),[C,A]=(0,u.useState)(!1),[T,I]=(0,u.useState)(!1);return(0,t.jsxs)("div",{className:"space-y-10 max-w-4xl",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-xl font-bold",children:"Design Guide"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:"Every component, style, and pattern used across Paperclip."})]}),(0,t.jsxs)(Or,{title:"Component Coverage",children:[(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"This page should be updated when new UI primitives or app-level patterns ship."}),(0,t.jsxs)("div",{className:"grid gap-6 md:grid-cols-2",children:[(0,t.jsx)(ar,{title:"UI primitives",children:(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:["avatar","badge","breadcrumb","button","card","checkbox","collapsible","command","dialog","dropdown-menu","input","label","popover","resizable-panels","scroll-area","select","separator","sheet","skeleton","tabs","textarea","tooltip"].map($=>(0,t.jsx)(lt,{variant:"outline",className:"font-mono text-(length:--text-nano)",children:$},$))})}),(0,t.jsx)(ar,{title:"App components",children:(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:["StatusBadge","StatusIcon","PriorityIcon","EntityRow","EmptyState","MetricCard","FilterBar","InlineEditor","PageSkeleton","Identity","CommentThread","MarkdownEditor","PropertiesPanel","Sidebar","CommandPalette","EnvironmentVariablesEditor","InlineBanner","BuiltInAgentGate","BuiltInLifecycleChip","CollectionToolbar","IssueRow","ContextualSidebarFrame"].map($=>(0,t.jsx)(lt,{variant:"ghost",className:"font-mono text-(length:--text-nano)",children:$},$))})})]})]}),(0,t.jsx)(Or,{title:"Announcements",children:(0,t.jsxs)("div",{className:"grid gap-4 md:grid-cols-2",children:[(0,t.jsx)(O2,{announcement:Pzt,imageSrc:"/announcement-preview.svg",animationSrc:Mzt,onDismiss:r(()=>{},"onDismiss")}),(0,t.jsx)(O2,{announcement:nz,imageSrc:"/announcement-preview.svg",onDismiss:r(()=>{},"onDismiss")}),(0,t.jsx)(O2,{announcement:{...nz,image:void 0,secondaryLink:void 0},onDismiss:r(()=>{},"onDismiss")})]})}),(0,t.jsx)(Or,{title:"Task Execution Controls",children:(0,t.jsx)(vUt,{})}),(0,t.jsx)(Or,{title:"Composer actions",children:(0,t.jsx)(wUt,{})}),(0,t.jsxs)(Or,{title:"Task Collection",children:[(0,t.jsx)("p",{className:"max-w-prose text-sm text-muted-foreground",children:"CollectionToolbar owns shared geometry while each page owns its state and behavior. The canonical task row is opt-in during migration: status leads, unread work uses title emphasis, metadata remains stable, and the task identifier trails."}),(0,t.jsx)(Dce,{context:(0,t.jsx)("span",{className:"text-sm font-medium",children:"Recent tasks"}),search:(0,t.jsx)(At,{"aria-label":"Search task collection example",placeholder:"Search tasks..."}),controls:(0,t.jsx)(F,{variant:"outline",size:"sm",children:"Filter"}),actions:(0,t.jsx)(F,{size:"sm",children:"New task"}),feedback:(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"1 task · Updated newest first"})}),(0,t.jsx)("div",{className:"overflow-hidden rounded-lg border border-border",children:(0,t.jsx)(kv,{issue:a2,presentation:"task",unreadState:"visible",metadata:(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"Updated 12m ago"}),actions:(0,t.jsx)(F,{variant:"ghost",size:"xs",children:"More"})})})]}),(0,t.jsx)(Or,{title:"Theme Toggle",children:(0,t.jsx)(ar,{title:"Variants",children:(0,t.jsxs)("div",{className:"flex max-w-sm flex-col items-start gap-3",children:[(0,t.jsx)(Bj,{}),(0,t.jsx)(Bj,{variant:"menu-action"}),(0,t.jsx)(Bj,{variant:"compact-menu-action"})]})})}),(0,t.jsxs)(Or,{title:"Colors",children:[(0,t.jsx)(ar,{title:"Core",children:(0,t.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:[(0,t.jsx)(Zl,{name:"Background",cssVar:"--background"}),(0,t.jsx)(Zl,{name:"Foreground",cssVar:"--foreground"}),(0,t.jsx)(Zl,{name:"Card",cssVar:"--card"}),(0,t.jsx)(Zl,{name:"Primary",cssVar:"--primary"}),(0,t.jsx)(Zl,{name:"Primary foreground",cssVar:"--primary-foreground"}),(0,t.jsx)(Zl,{name:"Secondary",cssVar:"--secondary"}),(0,t.jsx)(Zl,{name:"Muted",cssVar:"--muted"}),(0,t.jsx)(Zl,{name:"Muted foreground",cssVar:"--muted-foreground"}),(0,t.jsx)(Zl,{name:"Accent",cssVar:"--accent"}),(0,t.jsx)(Zl,{name:"Destructive",cssVar:"--destructive"}),(0,t.jsx)(Zl,{name:"Border",cssVar:"--border"}),(0,t.jsx)(Zl,{name:"Ring",cssVar:"--ring"})]})}),(0,t.jsx)(ar,{title:"Sidebar",children:(0,t.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:[(0,t.jsx)(Zl,{name:"Sidebar",cssVar:"--sidebar"}),(0,t.jsx)(Zl,{name:"Sidebar border",cssVar:"--sidebar-border"})]})}),(0,t.jsx)(ar,{title:"Chart",children:(0,t.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:[(0,t.jsx)(Zl,{name:"Chart 1",cssVar:"--chart-1"}),(0,t.jsx)(Zl,{name:"Chart 2",cssVar:"--chart-2"}),(0,t.jsx)(Zl,{name:"Chart 3",cssVar:"--chart-3"}),(0,t.jsx)(Zl,{name:"Chart 4",cssVar:"--chart-4"}),(0,t.jsx)(Zl,{name:"Chart 5",cssVar:"--chart-5"})]})})]}),(0,t.jsxs)(Or,{title:"Runner activity",children:[(0,t.jsx)(kC,{item:{id:"design-runner-activity",kind:"activity_phase",active:!0,summary:"",interstitial:{id:"design-runner-commentary",kind:"message",author:"agent",text:"I’ll inspect the activity feed and check the layout.",interstitial:!0},items:[{id:"design-runner-read",kind:"tool",name:"read",target:"TaskChatRunnerTurn.tsx",status:"completed",detail:"Found the activity groups."},{id:"design-runner-check",kind:"tool",name:"exec_command",target:"pnpm check:token-gates",status:"in_progress"}]}}),(0,t.jsx)(kC,{item:{id:"design-runner-completed",kind:"activity_phase",active:!1,summary:"",items:[{id:"design-completed-read",kind:"tool",name:"read",target:"TaskChatRunnerTurn.tsx",status:"completed",detail:"Read the activity groups."},{id:"design-completed-check",kind:"tool",name:"exec_command",target:"pnpm check:token-gates",status:"failed",detail:"A token check needs another pass."}]}})]}),(0,t.jsx)(Or,{title:"Typography",children:(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)("h2",{className:"text-xl font-bold",children:"Page Title — text-xl font-bold"}),(0,t.jsx)("h2",{className:"text-lg font-semibold",children:"Section Title — text-lg font-semibold"}),(0,t.jsx)("h3",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wide",children:"Section Heading — text-sm font-semibold uppercase tracking-wide"}),(0,t.jsx)("p",{className:"text-sm font-medium",children:"Card Title — text-sm font-medium"}),(0,t.jsx)("p",{className:"text-sm font-semibold",children:"Card Title Alt — text-sm font-semibold"}),(0,t.jsx)("p",{className:"text-sm",children:"Body text — text-sm"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Muted description — text-sm text-muted-foreground"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Tiny label — text-xs text-muted-foreground"}),(0,t.jsx)("p",{className:"text-sm font-mono text-muted-foreground",children:"Mono identifier — text-sm font-mono text-muted-foreground"}),(0,t.jsx)("p",{className:"text-2xl font-bold",children:"Large stat — text-2xl font-bold"}),(0,t.jsx)("p",{className:"font-mono text-xs",children:"Log/code text — font-mono text-xs"})]})}),(0,t.jsx)(Or,{title:"Radius",children:(0,t.jsx)("div",{className:"flex items-end gap-4 flex-wrap",children:[["sm","var(--radius-sm)"],["md","var(--radius-md)"],["lg","var(--radius-lg)"],["xl","var(--radius-xl)"],["full","9999px"]].map(([$,O])=>(0,t.jsxs)("div",{className:"flex flex-col items-center gap-1",children:[(0,t.jsx)("div",{className:"h-12 w-12 bg-primary",style:{borderRadius:O}}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:$})]},$))})}),(0,t.jsxs)(Or,{title:"Buttons",children:[(0,t.jsx)(ar,{title:"Variants",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,t.jsx)(F,{variant:"default",children:"Default"}),(0,t.jsx)(F,{variant:"secondary",children:"Secondary"}),(0,t.jsx)(F,{variant:"outline",children:"Outline"}),(0,t.jsx)(F,{variant:"ghost",children:"Ghost"}),(0,t.jsx)(F,{variant:"destructive",children:"Destructive"}),(0,t.jsx)(F,{variant:"link",children:"Link"})]})}),(0,t.jsx)(ar,{title:"Sizes",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,t.jsx)(F,{size:"xs",children:"Extra Small"}),(0,t.jsx)(F,{size:"sm",children:"Small"}),(0,t.jsx)(F,{size:"default",children:"Default"}),(0,t.jsx)(F,{size:"lg",children:"Large"})]})}),(0,t.jsx)(ar,{title:"Icon buttons",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,t.jsx)(F,{variant:"ghost",size:"icon-xs",children:(0,t.jsx)(ua,{})}),(0,t.jsx)(F,{variant:"ghost",size:"icon-sm",children:(0,t.jsx)(ua,{})}),(0,t.jsx)(F,{variant:"outline",size:"icon",children:(0,t.jsx)(ua,{})}),(0,t.jsx)(F,{variant:"outline",size:"icon-lg",children:(0,t.jsx)(ua,{})})]})}),(0,t.jsx)(ar,{title:"With icons",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,t.jsxs)(F,{children:[(0,t.jsx)(gn,{})," New Issue"]}),(0,t.jsxs)(F,{variant:"outline",children:[(0,t.jsx)(cw,{})," Upload"]}),(0,t.jsxs)(F,{variant:"destructive",children:[(0,t.jsx)(Ia,{})," Delete"]}),(0,t.jsxs)(F,{size:"sm",children:[(0,t.jsx)(gn,{})," Add"]})]})}),(0,t.jsx)(ar,{title:"States",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,t.jsx)(F,{disabled:!0,children:"Disabled"}),(0,t.jsx)(F,{variant:"outline",disabled:!0,children:"Disabled Outline"})]})})]}),(0,t.jsx)(Or,{title:"Badges",children:(0,t.jsx)(ar,{title:"Variants",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,t.jsx)(lt,{variant:"default",children:"Default"}),(0,t.jsx)(lt,{variant:"secondary",children:"Secondary"}),(0,t.jsx)(lt,{variant:"outline",children:"Outline"}),(0,t.jsx)(lt,{variant:"destructive",children:"Destructive"}),(0,t.jsx)(lt,{variant:"ghost",children:"Ghost"})]})})}),(0,t.jsxs)(Or,{title:"Status System",children:[(0,t.jsx)(ar,{title:"StatusBadge (all statuses)",children:(0,t.jsx)("div",{className:"flex items-center gap-2 flex-wrap",children:["active","running","paused","idle","archived","planned","achieved","completed","failed","timed_out","succeeded","error","pending_approval","backlog","todo","in_progress","in_review","blocked","done","terminated","cancelled","pending","revision_requested","approved","rejected"].map($=>(0,t.jsx)(ti,{status:$},$))})}),(0,t.jsx)(ar,{title:"IssueStatusBadge (brand chip + glyph — PAP-75)",children:(0,t.jsx)("div",{className:"flex items-center gap-2 flex-wrap",children:["backlog","todo","in_progress","in_review","done","blocked","cancelled"].map($=>(0,t.jsx)(Tp,{status:$},$))})}),(0,t.jsxs)(ar,{title:"Idle Slack conversation",children:[(0,t.jsx)(Qi,{status:"in_review",externalConversationState:"waiting",showLabel:!0}),(0,t.jsx)(Tp,{status:"in_review",externalConversationState:"waiting"})]}),(0,t.jsxs)(ar,{title:"StatusIcon (interactive)",children:[(0,t.jsx)("div",{className:"flex items-center gap-3 flex-wrap",children:["backlog","todo","in_progress","in_review","done","cancelled","blocked"].map($=>(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)(Qi,{status:$}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:$})]},$))}),(0,t.jsxs)("div",{className:"flex items-center gap-2 mt-2",children:[(0,t.jsx)(Qi,{status:n,onChange:a}),(0,t.jsxs)("span",{className:"text-sm",children:["Click the icon to change status (current: ",n,")"]})]})]}),!1,(0,t.jsx)(ar,{title:"Agent status dots",children:(0,t.jsx)("div",{className:"flex items-center gap-4 flex-wrap",children:["running","active","paused","error","archived"].map($=>(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"relative flex h-2.5 w-2.5",children:(0,t.jsx)("span",{className:`inline-flex h-full w-full rounded-full ${hRe[$]??"bg-neutral-400"}`})}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:$})]},$))})}),(0,t.jsx)(ar,{title:"Run invocation badges",children:(0,t.jsx)("div",{className:"flex items-center gap-2 flex-wrap",children:[["timer","bg-blue-100 text-blue-700 dark:bg-blue-900/50 dark:text-blue-300"],["assignment","bg-violet-100 text-violet-700 dark:bg-violet-900/50 dark:text-violet-300"],["on_demand","bg-cyan-100 text-cyan-700 dark:bg-cyan-900/50 dark:text-cyan-300"],["automation","bg-muted text-muted-foreground"]].map(([$,O])=>(0,t.jsx)(lt,{variant:"ghost",className:`px-1.5 text-(length:--text-nano) ${O}`,children:$},$))})}),(0,t.jsxs)(ar,{title:"IssueReferencePill",children:[(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Used wherever a task is referenced — in markdown, the Related Work tab, and activity summaries. Pass ",(0,t.jsx)("code",{className:"font-mono",children:"status"})," to show the target issue's state at a glance. Use ",(0,t.jsx)("code",{className:"font-mono",children:'variant="property"'})," for compact badges with direct navigation. Pass ",(0,t.jsx)("code",{className:"font-mono",children:"onRemove"})," for a separate blocker removal control with reserved space. Use ",(0,t.jsx)("code",{className:"font-mono",children:"strikethrough"}),' for "removed" contexts.']}),(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,t.jsx)(id,{issue:{id:"demo-1",identifier:"PAP-123",title:"Identifier only — no status yet"}}),(0,t.jsx)(id,{issue:{id:"demo-2",identifier:"PAP-456",title:"With in_progress status",status:"in_progress"}}),(0,t.jsx)(id,{issue:{id:"demo-3",identifier:"PAP-789",title:"Done status",status:"done"}}),(0,t.jsx)(id,{issue:{id:"demo-4",identifier:"PAP-101",title:"Blocked status",status:"blocked"}}),(0,t.jsx)(id,{onRemove:r(()=>window.alert("Blocker removed"),"onRemove"),issue:{id:"demo-blocker",identifier:"PAP-303",title:"Hover or focus to remove blocker",status:"in_review"}}),(0,t.jsx)(id,{strikethrough:!0,issue:{id:"demo-5",identifier:"PAP-202",title:"Removed (strikethrough)",status:"todo"}})]})]})]}),(0,t.jsxs)(Or,{title:"Agent Capsule",children:[(0,t.jsxs)("p",{className:"text-sm text-muted-foreground max-w-prose",children:['The brand "capsule is the agent" motif. A single agent reads as a tall pill that moves through three states as it comes to life. The online fill uses the live brand agent-gradient tokens (',(0,t.jsx)("code",{className:"font-mono",children:"--agent-Na"})," →"," ",(0,t.jsx)("code",{className:"font-mono",children:"--agent-Nb"}),"); ",(0,t.jsx)("code",{className:"font-mono",children:"prefers-reduced-motion"})," ","skips the liquid rise and pulses and renders the final state."]}),(0,t.jsx)(ar,{title:"States",children:(0,t.jsxs)("div",{className:"flex items-end gap-10",children:[(0,t.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,t.jsx)(Jf,{state:"slot"}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"slot"})]}),(0,t.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,t.jsx)(Jf,{state:"configured"}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"configured"})]}),(0,t.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,t.jsx)(Jf,{state:"online",gradient:5}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"online"})]}),(0,t.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,t.jsx)(Jf,{state:"online",gradient:5,glow:"blue"}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"online · blue glow"})]})]})}),(0,t.jsx)(ar,{title:"Sizes",children:(0,t.jsxs)("div",{className:"flex items-end gap-8",children:[(0,t.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,t.jsx)(Jf,{state:"online",size:"sm",gradient:1}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"sm"})]}),(0,t.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,t.jsx)(Jf,{state:"online",size:"md",gradient:4}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"md"})]}),(0,t.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,t.jsx)(Jf,{state:"online",size:"lg",gradient:8}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"lg"})]}),(0,t.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,t.jsx)(Jf,{state:"online",size:{width:28,height:96},gradient:6}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"custom px"})]})]})}),(0,t.jsx)(ar,{title:"Gradients",children:(0,t.jsx)("div",{className:"flex items-end gap-3 flex-wrap",children:Array.from({length:10},($,O)=>(0,t.jsxs)("div",{className:"flex flex-col items-center gap-1.5",children:[(0,t.jsx)(Jf,{state:"online",size:"sm",gradient:O+1}),(0,t.jsx)("span",{className:"text-(length:--text-nano) font-mono text-muted-foreground",children:O+1})]},O))})})]}),(0,t.jsx)(Or,{title:"Form Elements",children:(0,t.jsxs)("div",{className:"grid gap-6 md:grid-cols-2",children:[(0,t.jsxs)(ar,{title:"Input",children:[(0,t.jsx)(At,{placeholder:"Default input"}),(0,t.jsx)(At,{placeholder:"Disabled input",disabled:!0,className:"mt-2"})]}),(0,t.jsx)(ar,{title:"Textarea",children:(0,t.jsx)(Dn,{placeholder:"Write something..."})}),(0,t.jsx)(ar,{title:"Checkbox & Label",children:(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)($i,{id:"check1",defaultChecked:!0}),(0,t.jsx)(Qs,{htmlFor:"check1",children:"Checked item"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)($i,{id:"check2"}),(0,t.jsx)(Qs,{htmlFor:"check2",children:"Unchecked item"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)($i,{id:"check3",disabled:!0}),(0,t.jsx)(Qs,{htmlFor:"check3",children:"Disabled item"})]})]})}),(0,t.jsx)(ar,{title:"Inline Editor",children:(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-xs text-muted-foreground mb-1",children:"Title (single-line)"}),(0,t.jsx)(Ah,{value:v,onSave:y,as:"h2",className:"text-xl font-bold"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-xs text-muted-foreground mb-1",children:"Body text (single-line)"}),(0,t.jsx)(Ah,{value:f,onSave:g,as:"p",className:"text-sm"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-xs text-muted-foreground mb-1",children:"Description (multiline, auto-sizing)"}),(0,t.jsx)(Ah,{value:w,onSave:S,as:"p",className:"text-sm text-muted-foreground",placeholder:"Add a description...",multiline:!0})]})]})})]})}),(0,t.jsx)(Or,{title:"Select",children:(0,t.jsxs)("div",{className:"grid gap-6 md:grid-cols-2",children:[(0,t.jsxs)(ar,{title:"Default size",children:[(0,t.jsxs)($a,{value:l,onValueChange:c,children:[(0,t.jsx)(La,{className:"w-full",children:(0,t.jsx)(Ma,{placeholder:"Select status"})}),(0,t.jsxs)(Da,{children:[(0,t.jsx)(Sn,{value:"backlog",children:"Backlog"}),(0,t.jsx)(Sn,{value:"todo",children:"Todo"}),(0,t.jsx)(Sn,{value:"in_progress",children:"In Progress"}),(0,t.jsx)(Sn,{value:"in_review",children:"In Review"}),(0,t.jsx)(Sn,{value:"done",children:"Done"})]})]}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Current value: ",l]})]}),(0,t.jsx)(ar,{title:"Small trigger",children:(0,t.jsxs)($a,{defaultValue:"high",children:[(0,t.jsx)(La,{size:"sm",className:"w-full",children:(0,t.jsx)(Ma,{})}),(0,t.jsxs)(Da,{children:[(0,t.jsx)(Sn,{value:"critical",children:"Critical"}),(0,t.jsx)(Sn,{value:"high",children:"High"}),(0,t.jsx)(Sn,{value:"medium",children:"Medium"}),(0,t.jsx)(Sn,{value:"low",children:"Low"})]})]})})]})}),(0,t.jsx)(Or,{title:"Dropdown Menu",children:(0,t.jsxs)(ba,{children:[(0,t.jsx)(ga,{asChild:!0,children:(0,t.jsxs)(F,{variant:"outline",size:"sm",children:["Quick Actions",(0,t.jsx)(sn,{className:"h-4 w-4"})]})}),(0,t.jsxs)(va,{align:"start",className:"w-56",children:[(0,t.jsxs)(hs,{children:[(0,t.jsx)(ds,{className:"h-4 w-4"}),"Mark as done",(0,t.jsx)(X2e,{children:"⌘D"})]}),(0,t.jsxs)(hs,{children:[(0,t.jsx)(sN,{className:"h-4 w-4"}),"Open docs"]}),(0,t.jsx)(di,{}),(0,t.jsx)(Cz,{checked:d,onCheckedChange:r($=>m($===!0),"onCheckedChange"),children:"Watch issue"}),(0,t.jsxs)(hs,{variant:"destructive",children:[(0,t.jsx)(Ia,{className:"h-4 w-4"}),"Delete issue"]})]})]})}),(0,t.jsx)(Or,{title:"Popover",children:(0,t.jsxs)(Zn,{children:[(0,t.jsx)(ur,{asChild:!0,children:(0,t.jsx)(F,{variant:"outline",size:"sm",children:"Open Popover"})}),(0,t.jsxs)(Vn,{className:"space-y-2",children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:"Agent heartbeat"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Last run succeeded 24s ago. Next timer run in 9m."}),(0,t.jsx)(F,{size:"xs",children:"Wake now"})]})]})}),(0,t.jsx)(Or,{title:"Collapsible",children:(0,t.jsxs)(sl,{open:h,onOpenChange:p,className:"space-y-2",children:[(0,t.jsx)(Wl,{asChild:!0,children:(0,t.jsxs)(F,{variant:"outline",size:"sm",children:[h?"Hide":"Show"," advanced filters"]})}),(0,t.jsx)(nl,{className:"rounded-md border border-border p-3",children:(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(Qs,{htmlFor:"owner-filter",children:"Owner"}),(0,t.jsx)(At,{id:"owner-filter",placeholder:"Filter by agent name"})]})})]})}),(0,t.jsx)(Or,{title:"Sheet",children:(0,t.jsxs)(Gh,{children:[(0,t.jsx)(Vce,{asChild:!0,children:(0,t.jsx)(F,{variant:"outline",size:"sm",children:"Open Side Panel"})}),(0,t.jsxs)(Qh,{side:"right",children:[(0,t.jsxs)(Fh,{children:[(0,t.jsx)(Ym,{children:"Issue Properties"}),(0,t.jsx)(XS,{children:"Edit metadata without leaving the current page."})]}),(0,t.jsxs)("div",{className:"space-y-4 px-4",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(Qs,{htmlFor:"sheet-title",children:"Title"}),(0,t.jsx)(At,{id:"sheet-title",defaultValue:"Improve onboarding docs"})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(Qs,{htmlFor:"sheet-description",children:"Description"}),(0,t.jsx)(Dn,{id:"sheet-description",defaultValue:"Capture setup pitfalls and screenshots."})]})]}),(0,t.jsxs)(Kce,{children:[(0,t.jsx)(F,{variant:"outline",children:"Cancel"}),(0,t.jsx)(F,{children:"Save"})]})]})]})}),(0,t.jsx)(Or,{title:"Scroll Area",children:(0,t.jsx)(ix,{className:"h-36 rounded-md border border-border",children:(0,t.jsx)("div",{className:"space-y-2 p-3",children:Array.from({length:12}).map(($,O)=>(0,t.jsxs)("div",{className:"rounded-md border border-border p-2 text-sm",children:["Heartbeat run #",O+1,": completed successfully"]},O))})})}),(0,t.jsx)(Or,{title:"Command (CMDK)",children:(0,t.jsx)("div",{className:"rounded-md border border-border",children:(0,t.jsxs)(w5,{children:[(0,t.jsx)(u1,{placeholder:"Type a command or search..."}),(0,t.jsxs)(m1,{children:[(0,t.jsx)(h1,{children:"No results found."}),(0,t.jsxs)(Uu,{heading:"Pages",children:[(0,t.jsxs)(To,{children:[(0,t.jsx)(fx,{className:"h-4 w-4"}),"Dashboard"]}),(0,t.jsxs)(To,{children:[(0,t.jsx)(ld,{className:"h-4 w-4"}),"Issues"]})]}),(0,t.jsx)(tx,{}),(0,t.jsxs)(Uu,{heading:"Actions",children:[(0,t.jsxs)(To,{children:[(0,t.jsx)(D3e,{className:"h-4 w-4"}),"Open command palette"]}),(0,t.jsxs)(To,{children:[(0,t.jsx)(gn,{className:"h-4 w-4"}),"Create new issue"]})]})]})]})})}),(0,t.jsx)(Or,{title:"Breadcrumb",children:(0,t.jsx)(jU,{children:(0,t.jsxs)(wU,{children:[(0,t.jsx)(yS,{children:(0,t.jsx)(uT,{href:"#",children:"Projects"})}),(0,t.jsx)(mT,{}),(0,t.jsx)(yS,{children:(0,t.jsx)(uT,{href:"#",children:"Paperclip App"})}),(0,t.jsx)(mT,{}),(0,t.jsx)(yS,{children:(0,t.jsx)(oC,{children:"Issue List"})})]})})}),(0,t.jsxs)(Or,{title:"Cards",children:[(0,t.jsxs)(ar,{title:"Dashboard agent runs",children:[(0,t.jsx)("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:["running","queued","succeeded","failed","timed_out","cancelled","interrupted"].map($=>(0,t.jsx)(oje,{companyId:"design-guide",run:{id:`design-guide-${$}`,agentId:"design-guide-agent",agentName:"CodexCoder",status:$,adapterType:"codex_local",invocationSource:"on_demand",triggerDetail:"manual",startedAt:null,finishedAt:null,createdAt:"2026-09-11T12:00:00Z",issueId:"design-guide-task"},issue:{identifier:"PAP-559",title:"Recreate this wireframe on pages Paperclip",status:$==="succeeded"?"done":"in_progress"}},$))}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"The dashboard and Live runs page use the same compact cards. In-progress task icons animate across the app, including between runs, to represent task workflow status. Live indicators report active execution. Open a run to view its status and transcript."})]}),(0,t.jsx)(ar,{title:"Standard Card",children:(0,t.jsxs)(Xs,{children:[(0,t.jsxs)(Xi,{children:[(0,t.jsx)(uo,{children:"Card Title"}),(0,t.jsx)(Nl,{children:"Card description with supporting text."})]}),(0,t.jsx)(Wa,{children:(0,t.jsx)("p",{className:"text-sm",children:"Card content goes here. This is the main body area."})}),(0,t.jsxs)(ERe,{className:"gap-2",children:[(0,t.jsx)(F,{size:"sm",children:"Action"}),(0,t.jsx)(F,{variant:"outline",size:"sm",children:"Cancel"})]})]})}),(0,t.jsx)(ar,{title:"Metric Cards",children:(0,t.jsxs)("div",{className:"grid md:grid-cols-2 xl:grid-cols-4 gap-4",children:[(0,t.jsx)(Ig,{icon:Ji,value:12,label:"Active Agents",description:"+3 this week"}),(0,t.jsx)(Ig,{icon:ld,value:48,label:"Open Issues"}),(0,t.jsx)(Ig,{icon:_h,value:"$1,234",label:"Monthly Cost",description:"Under budget"}),(0,t.jsx)(Ig,{icon:kH,value:"99.9%",label:"Uptime"})]})})]}),(0,t.jsxs)(Or,{title:"Tabs",children:[(0,t.jsx)(ar,{title:"Default (pill) variant",children:(0,t.jsxs)(Ni,{defaultValue:"overview",children:[(0,t.jsxs)(Vc,{children:[(0,t.jsx)(Pa,{value:"overview",children:"Overview"}),(0,t.jsx)(Pa,{value:"runs",children:"Runs"}),(0,t.jsx)(Pa,{value:"config",children:"Config"}),(0,t.jsx)(Pa,{value:"costs",children:"Costs"})]}),(0,t.jsx)(da,{value:"overview",children:(0,t.jsx)("p",{className:"text-sm text-muted-foreground py-4",children:"Overview tab content."})}),(0,t.jsx)(da,{value:"runs",children:(0,t.jsx)("p",{className:"text-sm text-muted-foreground py-4",children:"Runs tab content."})}),(0,t.jsx)(da,{value:"config",children:(0,t.jsx)("p",{className:"text-sm text-muted-foreground py-4",children:"Config tab content."})}),(0,t.jsx)(da,{value:"costs",children:(0,t.jsx)("p",{className:"text-sm text-muted-foreground py-4",children:"Costs tab content."})})]})}),(0,t.jsx)(ar,{title:"Line variant",children:(0,t.jsxs)(Ni,{defaultValue:"summary",children:[(0,t.jsxs)(Vc,{variant:"line",children:[(0,t.jsx)(Pa,{value:"summary",children:"Summary"}),(0,t.jsx)(Pa,{value:"details",children:"Details"}),(0,t.jsx)(Pa,{value:"comments",children:"Comments"})]}),(0,t.jsx)(da,{value:"summary",children:(0,t.jsx)("p",{className:"text-sm text-muted-foreground py-4",children:"Summary content with underline tabs."})}),(0,t.jsx)(da,{value:"details",children:(0,t.jsx)("p",{className:"text-sm text-muted-foreground py-4",children:"Details content."})}),(0,t.jsx)(da,{value:"comments",children:(0,t.jsx)("p",{className:"text-sm text-muted-foreground py-4",children:"Comments content."})})]})})]}),(0,t.jsxs)(Or,{title:"Entity Rows",children:[(0,t.jsxs)("div",{className:"border border-border rounded-md",children:[(0,t.jsx)(sd,{leading:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Qi,{status:"in_progress"}),!1]}),identifier:"PAP-001",title:"Implement authentication flow",subtitle:"Responsible: Agent Alpha",trailing:(0,t.jsx)(Tp,{status:"in_progress"}),onClick:r(()=>{},"onClick")}),(0,t.jsx)(sd,{leading:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Qi,{status:"done"}),!1]}),identifier:"PAP-002",title:"Set up CI/CD pipeline",subtitle:"Completed 2 days ago",trailing:(0,t.jsx)(Tp,{status:"done"}),onClick:r(()=>{},"onClick")}),(0,t.jsx)(sd,{leading:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Qi,{status:"todo"}),!1]}),identifier:"PAP-003",title:"Write API documentation",trailing:(0,t.jsx)(Tp,{status:"todo"}),onClick:r(()=>{},"onClick")}),(0,t.jsx)(sd,{leading:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Qi,{status:"blocked"}),!1]}),identifier:"PAP-004",title:"Deploy to production",subtitle:"Blocked by PAP-001",trailing:(0,t.jsx)(Tp,{status:"blocked"}),selected:!0})]}),(0,t.jsx)(ar,{title:"Membership action",children:(0,t.jsxs)("div",{className:"border border-border rounded-md",children:[(0,t.jsx)(sd,{title:"Joined resource",subtitle:"Hover or focus the row to reveal the reserved action slot.",className:"group",trailing:(0,t.jsx)(Tg,{state:"joined",resourceName:"Joined resource",onJoin:r(()=>{},"onJoin"),onLeave:r(()=>{},"onLeave")})}),(0,t.jsx)(sd,{title:"Left resource",subtitle:"Persistent action with dimmed row content.",className:"group text-foreground/55",trailing:(0,t.jsx)(Tg,{state:"left",resourceName:"Left resource",onJoin:r(()=>{},"onJoin"),onLeave:r(()=>{},"onLeave")})}),(0,t.jsx)(sd,{title:"Leaving resource",subtitle:"Disabled while the optimistic mutation is pending.",className:"group text-foreground/55",trailing:(0,t.jsx)(Tg,{state:"left",pending:!0,pendingState:"left",resourceName:"Leaving resource",onJoin:r(()=>{},"onJoin"),onLeave:r(()=>{},"onLeave")})}),(0,t.jsx)(sd,{title:"Joining resource",subtitle:"The target state is visible immediately while the server confirms.",className:"group",trailing:(0,t.jsx)(Tg,{state:"joined",pending:!0,pendingState:"joined",resourceName:"Joining resource",onJoin:r(()=>{},"onJoin"),onLeave:r(()=>{},"onLeave")})})]})})]}),(0,t.jsxs)(Or,{title:"Filter Bar",children:[(0,t.jsx)(QK,{filters:j,onRemove:r($=>N(O=>O.filter(L=>L.key!==$)),"onRemove"),onClear:r(()=>N([]),"onClear")}),j.length===0&&(0,t.jsx)(F,{variant:"outline",size:"sm",onClick:r(()=>N([{key:"status",label:"Status",value:"Active"}]),"onClick"),children:"Reset filters"})]}),(0,t.jsxs)(Or,{title:"Avatars",children:[(0,t.jsx)(ar,{title:"Sizes",children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(Gi,{size:"sm",children:(0,t.jsx)(Yi,{children:"SM"})}),(0,t.jsx)(Gi,{children:(0,t.jsx)(Yi,{children:"DF"})}),(0,t.jsx)(Gi,{size:"lg",children:(0,t.jsx)(Yi,{children:"LG"})})]})}),(0,t.jsx)(ar,{title:"Group",children:(0,t.jsxs)(Wce,{children:[(0,t.jsx)(Gi,{children:(0,t.jsx)(Yi,{children:"A1"})}),(0,t.jsx)(Gi,{children:(0,t.jsx)(Yi,{children:"A2"})}),(0,t.jsx)(Gi,{children:(0,t.jsx)(Yi,{children:"A3"})}),(0,t.jsx)(Q2e,{children:"+5"})]})})]}),(0,t.jsx)(Or,{title:"App logos",children:(0,t.jsx)(ar,{title:"Official marks and runtime fallback",children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(wc,{name:"Notion",logoUrl:"/brands/apps/notion.svg",darkLogoUrl:"/brands/apps/notion-dark.svg",size:36}),(0,t.jsx)(wc,{name:"Jira",logoUrl:"/brands/apps/jira.svg",darkLogoUrl:"/brands/apps/jira-dark.svg",size:44}),(0,t.jsx)(wc,{name:"Fallback",logoUrl:"/brands/apps/does-not-exist.svg",size:36})]})})}),(0,t.jsxs)(Or,{title:"Agent personas",children:[(0,t.jsx)(ar,{title:"Stable palette identities",children:(0,t.jsx)("div",{className:"flex flex-wrap gap-3",children:JIe.map($=>(0,t.jsx)(gr,{appearance:ZIe($),size:48,label:$},$))})}),(0,t.jsxs)(ar,{title:"Onboarding and live character",children:[(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Place one live character beside the agent name. Onboarding uses a larger padded frame. Onboarding and agent headers follow the pointer across the page; other placements track within their region. Full-page examples are in Storybook under Agents / Personas / Full pages."}),(0,t.jsxs)("div",{className:"flex gap-4",children:[(0,t.jsx)(jC,{muted:!0,state:"sleepy",motion:"still",size:128}),(0,t.jsx)(jC,{size:128})]})]})]}),(0,t.jsxs)(Or,{title:"Human identity",children:[(0,t.jsx)(ar,{title:"Sizes",children:(0,t.jsxs)("div",{className:"flex items-center gap-6",children:[(0,t.jsx)(Bl,{name:"Alex Morgan",size:"sm"}),(0,t.jsx)(Bl,{name:"Alex Morgan"}),(0,t.jsx)(Bl,{name:"Alex Morgan",size:"lg"})]})}),(0,t.jsx)(ar,{title:"Initials derivation",children:(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsx)(Bl,{name:"Casey Jordan",size:"sm"}),(0,t.jsx)(Bl,{name:"Alpha",size:"sm"}),(0,t.jsx)(Bl,{name:"Quinn Lee",size:"sm"})]})}),(0,t.jsx)(ar,{title:"Custom initials",children:(0,t.jsx)(Bl,{name:"Backend Service",initials:"BS",size:"sm"})})]}),(0,t.jsx)(Or,{title:"Tooltips",children:(0,t.jsxs)("div",{className:"flex items-center gap-4",children:[(0,t.jsxs)(Wn,{children:[(0,t.jsx)(Hn,{asChild:!0,children:(0,t.jsx)(F,{variant:"outline",size:"sm",children:"Hover me"})}),(0,t.jsx)(Qn,{children:"This is a tooltip"})]}),(0,t.jsxs)(Wn,{children:[(0,t.jsx)(Hn,{asChild:!0,children:(0,t.jsx)(F,{variant:"ghost",size:"icon-sm",children:(0,t.jsx)($d,{})})}),(0,t.jsx)(Qn,{children:"Settings"})]})]})}),(0,t.jsx)(Or,{title:"Dialog",children:(0,t.jsxs)(Ys,{children:[(0,t.jsx)(Cv,{asChild:!0,children:(0,t.jsx)(F,{variant:"outline",children:"Open Dialog"})}),(0,t.jsxs)(Js,{children:[(0,t.jsxs)(Cn,{children:[(0,t.jsx)(tn,{children:"Dialog Title"}),(0,t.jsx)(Ln,{children:"This is a sample dialog showing the standard layout with header, content, and footer."})]}),(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)(Qs,{children:"Name"}),(0,t.jsx)(At,{placeholder:"Enter a name",className:"mt-1.5"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(Qs,{children:"Description"}),(0,t.jsx)(Dn,{placeholder:"Describe...",className:"mt-1.5"})]})]}),(0,t.jsxs)(yr,{children:[(0,t.jsx)(F,{variant:"outline",children:"Cancel"}),(0,t.jsx)(F,{children:"Save"})]})]})]})}),(0,t.jsx)(Or,{title:"Empty State",children:(0,t.jsx)("div",{className:"border border-border rounded-md",children:(0,t.jsx)(Mn,{icon:Pd,message:"No items to show. Create your first one to get started.",action:"Create Item",onAction:r(()=>{},"onAction")})})}),(0,t.jsx)(Or,{title:"Progress Bars (Budget)",children:(0,t.jsx)("div",{className:"space-y-3",children:[{label:"Under budget (40%)",pct:40,color:"bg-green-400"},{label:"Warning (75%)",pct:75,color:"bg-yellow-400"},{label:"Over budget (95%)",pct:95,color:"bg-red-400"}].map(({label:$,pct:O,color:L})=>(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:$}),(0,t.jsxs)("span",{className:"text-xs font-mono",children:[O,"%"]})]}),(0,t.jsx)("div",{className:"w-full h-2 bg-muted rounded-full overflow-hidden",children:(0,t.jsx)("div",{className:`h-full rounded-full transition-(--tp-width-background-color) duration-150 ${L}`,style:{width:`${O}%`}})})]},$))})}),(0,t.jsx)(Or,{title:"Log Viewer",children:(0,t.jsxs)("div",{className:"bg-neutral-950 rounded-lg p-3 font-mono text-xs max-h-80 overflow-y-auto",children:[(0,t.jsx)("div",{className:"text-foreground",children:"[12:00:01] INFO Agent started successfully"}),(0,t.jsx)("div",{className:"text-foreground",children:"[12:00:02] INFO Processing task PAP-001"}),(0,t.jsx)("div",{className:"text-yellow-400",children:"[12:00:05] WARN Rate limit approaching (80%)"}),(0,t.jsx)("div",{className:"text-foreground",children:"[12:00:08] INFO Task PAP-001 completed"}),(0,t.jsx)("div",{className:"text-red-400",children:"[12:00:12] ERROR Connection timeout to upstream service"}),(0,t.jsx)("div",{className:"text-blue-300",children:"[12:00:12] SYS Retrying connection in 5s..."}),(0,t.jsx)("div",{className:"text-foreground",children:"[12:00:17] INFO Reconnected successfully"}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsxs)("span",{className:"relative flex h-1.5 w-1.5",children:[(0,t.jsx)("span",{className:"absolute inline-flex h-full w-full rounded-full bg-blue-400 animate-pulse"}),(0,t.jsx)("span",{className:"inline-flex h-full w-full rounded-full bg-blue-500"})]}),(0,t.jsx)("span",{className:"text-blue-600 dark:text-blue-400",children:"Live"})]})]})}),(0,t.jsx)(Or,{title:"Property Row Pattern",children:(0,t.jsxs)("div",{className:"border border-border rounded-md p-4 space-y-1 max-w-sm",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between py-1.5",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"Status"}),(0,t.jsx)(ti,{status:"active"})]}),!1,(0,t.jsxs)("div",{className:"flex items-center justify-between py-1.5",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"Responsible"}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)(Gi,{size:"sm",children:(0,t.jsx)(Yi,{children:"A"})}),(0,t.jsx)("span",{className:"text-xs",children:"Agent Alpha"})]})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between py-1.5",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"Created"}),(0,t.jsx)("span",{className:"text-xs",children:"Jan 15, 2025"})]})]})}),(0,t.jsxs)(Or,{title:"Navigation Patterns",children:[(0,t.jsxs)(ar,{title:"Independent MCP connections",children:[(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Zapier, Arcade, Composio and Executor each own a connection. Their controlled setup views share Access → Connect. Tool discovery completes setup. Saved connections reuse the standard Permissions action list and per-action Test dialog. Storybook’s Apps / Connections groups use in-memory provider fixtures."}),(0,t.jsx)(Tzt,{})]}),(0,t.jsxs)(ar,{title:"Setup wizard",children:[(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Shared by connection setup and trigger previews. Setup navigation takes over the section sidebar; each step owns a single footer."}),(0,t.jsxs)("div",{className:"max-w-sm space-y-6",children:[(0,t.jsx)(L5,{inline:!0,labels:["Choose trigger","Configure","Review"],step:e,availableStep:2,onSelect:s}),(0,t.jsx)(Jb,{onSaveExit:r(()=>s(0),"onSaveExit"),children:(0,t.jsx)(F,{onClick:r(()=>s((e+1)%3),"onClick"),children:"Continue"})})]})]}),(0,t.jsx)(ar,{title:"Agent chat picker",children:(0,t.jsx)(jUt,{})}),(0,t.jsxs)(ar,{title:"Sidebar nav items",children:[(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Layout accepts sidebarSections to compose additional SidebarSection groups inside the shared sidebar. Use SidebarNavItem for each row, with sibling action buttons for starring or menus. The Chats section shows starred agents, the earliest-created agent when unstarred, then four recent agents without duplicates. Compose and star controls share a vertical column. Compose appears on hover or keyboard focus and remains visible on touch; starred icons remain visible. The picker searches all company agents by name or role without a subtitle, count, continuation labels, or footer. Task breadcrumbs support leading identity and trailing actions beside the label, including single-item task headers; see the Agent chat Storybook."}),(0,t.jsxs)(Xs,{className:"block w-60 p-3 space-y-0.5",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-md text-sm font-medium bg-accent text-accent-foreground",children:[(0,t.jsx)(fx,{className:"h-4 w-4"}),"Dashboard"]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-md text-sm font-medium text-muted-foreground hover:bg-accent/50 hover:text-accent-foreground cursor-pointer",children:[(0,t.jsx)(ld,{className:"h-4 w-4"}),"Issues",(0,t.jsx)(lt,{variant:"ghost",className:"ml-auto bg-primary text-primary-foreground px-1.5",children:"12"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-md text-sm font-medium text-muted-foreground hover:bg-accent/50 hover:text-accent-foreground cursor-pointer",children:[(0,t.jsx)(Ji,{className:"h-4 w-4"}),"Agents"]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-md text-sm font-medium text-muted-foreground hover:bg-accent/50 hover:text-accent-foreground cursor-pointer",children:[(0,t.jsx)(Ed,{className:"h-4 w-4"}),"Projects"]})]})]}),(0,t.jsx)(ar,{title:"View toggle",children:(0,t.jsxs)("div",{className:"flex items-center border border-border rounded-md w-fit",children:[(0,t.jsxs)("button",{className:"px-3 py-1.5 text-xs font-medium bg-accent text-foreground rounded-l-md",children:[(0,t.jsx)(MH,{className:"h-3.5 w-3.5 inline mr-1"}),"List"]}),(0,t.jsxs)("button",{className:"px-3 py-1.5 text-xs font-medium text-muted-foreground hover:bg-accent/50 rounded-r-md",children:[(0,t.jsx)(af,{className:"h-3.5 w-3.5 inline mr-1"}),"Org"]})]})})]}),(0,t.jsx)(Or,{title:"Grouped List (Issues pattern)",children:(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2 bg-muted/50 rounded-t-md",children:[(0,t.jsx)(Qi,{status:"in_progress"}),(0,t.jsx)("span",{className:"text-sm font-medium",children:"In Progress"}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground ml-1",children:"2"})]}),(0,t.jsxs)("div",{className:"border border-border rounded-b-md",children:[(0,t.jsx)(sd,{leading:void 0,identifier:"PAP-101",title:"Build agent heartbeat system",onClick:r(()=>{},"onClick")}),(0,t.jsx)(sd,{leading:void 0,identifier:"PAP-102",title:"Add cost tracking dashboard",onClick:r(()=>{},"onClick")})]})]})}),(0,t.jsx)(Or,{title:"Comment Thread Pattern",children:(0,t.jsxs)("div",{className:"space-y-3 max-w-2xl",children:[(0,t.jsx)("h3",{className:"text-sm font-semibold",children:"Comments (2)"}),(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"rounded-md border border-border p-3",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:"Agent"}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"Jan 15, 2025"})]}),(0,t.jsx)("p",{className:"text-sm",children:"Started working on the authentication module. Will need API keys configured."})]}),(0,t.jsxs)("div",{className:"rounded-md border border-border p-3",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:"Human"}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"Jan 16, 2025"})]}),(0,t.jsx)("p",{className:"text-sm",children:"API keys have been added to the vault. Please proceed."})]})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(Dn,{placeholder:"Leave a comment...",rows:3}),(0,t.jsx)(F,{size:"sm",children:"Comment"})]})]})}),(0,t.jsx)(Or,{title:"Cost Table Pattern",children:(0,t.jsx)("div",{className:"border border-border rounded-lg overflow-hidden",children:(0,t.jsxs)("table",{className:"w-full text-xs",children:[(0,t.jsx)("thead",{className:"border-b border-border bg-accent/20",children:(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{className:"text-left px-3 py-2 font-medium text-muted-foreground",children:"Model"}),(0,t.jsx)("th",{className:"text-left px-3 py-2 font-medium text-muted-foreground",children:"Tokens"}),(0,t.jsx)("th",{className:"text-left px-3 py-2 font-medium text-muted-foreground",children:"Cost"})]})}),(0,t.jsxs)("tbody",{children:[(0,t.jsxs)("tr",{className:"border-b border-border",children:[(0,t.jsx)("td",{className:"px-3 py-2",children:"claude-sonnet-4-20250514"}),(0,t.jsx)("td",{className:"px-3 py-2 font-mono",children:"1.2M"}),(0,t.jsx)("td",{className:"px-3 py-2 font-mono",children:"$18.00"})]}),(0,t.jsxs)("tr",{className:"border-b border-border",children:[(0,t.jsx)("td",{className:"px-3 py-2",children:"claude-haiku-4-20250506"}),(0,t.jsx)("td",{className:"px-3 py-2 font-mono",children:"500k"}),(0,t.jsx)("td",{className:"px-3 py-2 font-mono",children:"$1.25"})]}),(0,t.jsxs)("tr",{children:[(0,t.jsx)("td",{className:"px-3 py-2 font-medium",children:"Total"}),(0,t.jsx)("td",{className:"px-3 py-2 font-mono",children:"1.7M"}),(0,t.jsx)("td",{className:"px-3 py-2 font-mono font-medium",children:"$19.25"})]})]})]})})}),(0,t.jsxs)(Or,{title:"Skeletons",children:[(0,t.jsx)(ar,{title:"Individual",children:(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(jn,{className:"h-4 w-48"}),(0,t.jsx)(jn,{className:"h-8 w-full max-w-sm"}),(0,t.jsx)(jn,{className:"h-20 w-full"})]})}),(0,t.jsx)(ar,{title:"Page Skeleton (list)",children:(0,t.jsx)("div",{className:"border border-border rounded-md p-4",children:(0,t.jsx)(ka,{variant:"list"})})}),(0,t.jsx)(ar,{title:"Page Skeleton (detail)",children:(0,t.jsx)("div",{className:"border border-border rounded-md p-4",children:(0,t.jsx)(ka,{variant:"detail"})})})]}),(0,t.jsx)(Or,{title:"Separator",children:(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Horizontal"}),(0,t.jsx)(hl,{}),(0,t.jsxs)("div",{className:"flex items-center gap-4 h-8",children:[(0,t.jsx)("span",{className:"text-sm",children:"Left"}),(0,t.jsx)(hl,{orientation:"vertical"}),(0,t.jsx)("span",{className:"text-sm",children:"Right"})]})]})}),(0,t.jsxs)(Or,{title:"Team Catalog",children:[(0,t.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Components from the Team Catalog browse/install surface (",(0,t.jsx)("code",{className:"font-mono text-xs",children:"/teams-catalog"}),"). Fixtures are shared with the Storybook stories."]}),(0,t.jsxs)(ar,{title:"TeamRow (browse list)",children:[(0,t.jsxs)("div",{className:"w-(--sz-28rem) rounded-md border border-border",children:[(0,t.jsx)("div",{className:"px-3 py-2 text-(length:--text-micro) font-semibold uppercase tracking-wide text-muted-foreground",children:"Bundled · 1"}),(0,t.jsx)(r2,{team:vc,selected:!0,onSelect:r(()=>{},"onSelect")}),(0,t.jsx)("div",{className:"px-3 py-2 text-(length:--text-micro) font-semibold uppercase tracking-wide text-muted-foreground",children:"Optional · 2"}),(0,t.jsx)(r2,{team:mUt,selected:!1,onSelect:r(()=>{},"onSelect")}),(0,t.jsx)("div",{className:"px-3 py-2 text-(length:--text-micro) font-semibold uppercase tracking-wide text-muted-foreground",children:"Installed · 2"}),(0,t.jsx)(r2,{team:vc,selected:!1,onSelect:r(()=>{},"onSelect"),installed:R1e}),(0,t.jsx)(r2,{team:Uoe,selected:!1,onSelect:r(()=>{},"onSelect"),installed:hUt})]}),(0,t.jsxs)("p",{className:"mt-2 text-xs text-muted-foreground",children:["Installed teams collapse under ",(0,t.jsx)("code",{className:"font-mono",children:"INSTALLED · N"}),"; an out-of-date install (server ",(0,t.jsx)("code",{className:"font-mono",children:"originHash"})," ≠ catalog ",(0,t.jsx)("code",{className:"font-mono",children:"contentHash"}),") shows the amber ",(0,t.jsx)("code",{className:"font-mono",children:"↑"})," badge (PAP-10256)."]})]}),(0,t.jsxs)(ar,{title:"TeamCard (onboarding grid)",children:[(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Square tile for the onboarding “Pick a starter team” grid. Selected tile gets"," ",(0,t.jsx)("code",{className:"font-mono",children:"ring-2 ring-ring"}),". Drives the"," ",(0,t.jsx)("code",{className:"font-mono",children:"useInstallTeamCatalogEntry"})," simplified flow."]}),(0,t.jsx)(gUt,{})]}),(0,t.jsx)(ar,{title:"TeamHierarchyPreview",children:(0,t.jsx)("div",{className:"max-w-md",children:(0,t.jsx)(sUt,{team:vc})})}),(0,t.jsx)(ar,{title:"RequiredSkillsList",children:(0,t.jsx)("div",{className:"max-w-xl",children:(0,t.jsx)(rUt,{skills:vc.requiredSkills})})}),(0,t.jsx)(ar,{title:"EnvInputsList",children:(0,t.jsx)("div",{className:"max-w-xl",children:(0,t.jsx)(aUt,{inputs:vc.envInputs})})}),(0,t.jsx)(ar,{title:"ExternalSourcesList",children:(0,t.jsx)("div",{className:"max-w-xl",children:(0,t.jsx)(iUt,{sources:vc.sourceRefs})})}),(0,t.jsx)(ar,{title:"Source policy step (StepSourcePolicy)",children:(0,t.jsx)("div",{className:"max-w-xl rounded-md border border-border p-4",children:(0,t.jsx)(oUt,{team:Uoe,allowExternalSources:_,allowUnpinnedOptionalSources:C,allowLocalPathSources:T,onChange:r(($,O)=>{$==="external"&&R(O),$==="unpinned"&&A(O),$==="localPath"&&I(O)},"onChange")})})}),(0,t.jsx)(ar,{title:"Skill plan step (StepSkillPlan)",children:(0,t.jsx)("div",{className:"max-w-xl rounded-md border border-border p-4",children:(0,t.jsx)(cUt,{team:vc,preparations:pUt})})})]}),(0,t.jsx)(Or,{title:"Common Icons (Lucide)",children:(0,t.jsx)("div",{className:"grid grid-cols-4 md:grid-cols-6 gap-4",children:[["Inbox",Pd],["ListTodo",MH],["CircleDot",ld],["Hexagon",Ed],["Target",af],["LayoutDashboard",fx],["Bot",Ji],["DollarSign",_h],["History",Cl],["Search",ua],["Plus",gn],["Trash2",Ia],["Settings",$d],["User",yc],["Mail",Bce],["Upload",cw],["Zap",kH]].map(([$,O])=>(0,t.jsxs)("div",{className:"flex flex-col items-center gap-1.5 p-2",children:[(0,t.jsx)(O,{className:"h-4 w-4 text-muted-foreground"}),(0,t.jsx)("span",{className:"text-(length:--text-nano) text-muted-foreground font-mono",children:$})]},$))})}),(0,t.jsx)(Or,{title:"Keyboard Shortcuts",children:(0,t.jsx)("div",{className:"border border-border rounded-md divide-y divide-border text-sm",children:[["Cmd+K / Ctrl+K","Open Command Palette"],["C","New Issue (outside inputs)"],["[","Toggle Sidebar"],["]","Toggle Properties Panel"],["Cmd+Enter / Ctrl+Enter","Submit markdown comment"]].map(([$,O])=>(0,t.jsxs)("div",{className:"flex items-center justify-between px-4 py-2",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:O}),(0,t.jsx)("kbd",{className:"px-2 py-0.5 text-xs font-mono bg-muted rounded border border-border",children:$})]},$))})}),(0,t.jsxs)(Or,{title:"Issue Output Surface",children:[(0,t.jsx)(ar,{title:"Multiple outputs (primary video + 'Also produced')",children:(0,t.jsx)(T3,{workProducts:fUt})}),(0,t.jsx)(ar,{title:"Degraded output (invalid / failed attachment metadata)",children:(0,t.jsx)(T3,{workProducts:xUt})}),(0,t.jsx)(ar,{title:"Empty state",children:(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"When an issue has produced no artifact work products, the Output section renders nothing at all (no placeholder card)."})})]}),(0,t.jsxs)(Or,{title:"Tools & Access",children:[(0,t.jsxs)(ar,{title:"EnforcementBanner — default / denied-detected",children:[(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)(mb,{companyId:"",forceVariant:"default",recentDenialCount:0}),(0,t.jsx)(mb,{companyId:"",forceVariant:"denied-detected",recentDenialCount:3})]}),(0,t.jsxs)("p",{className:"mt-2 text-xs text-muted-foreground",children:["Persistent at the top of the Tools & Access surface. Tints to ",(0,t.jsx)("code",{children:"denied-detected"})," when governed tool calls were denied or failed in the last hour. Observability only — enforcement lives in the tool gateway."]})]}),(0,t.jsxs)(ar,{title:"EnforcementBanner — presentational tones (info / warning / error)",children:[(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)(mb,{tone:"info",title:"Effective access — server resolved.",body:"This is exactly what the tool gateway will accept. Profile and policy edits reflect within ~5s; the prompt cannot expand it."}),(0,t.jsx)(mb,{tone:"warning",title:"Local stdio is local code execution, not a security sandbox.",body:"A local-stdio slot runs with the orchestrator's privileges. Only bind trusted commands; quarantine anything you would not run yourself."}),(0,t.jsx)(mb,{tone:"error",title:"Runtime failed closed.",body:"The supervisor is restarting (attempt 2/3). The gateway returns runtime-error and the agent does not see partial output."})]}),(0,t.jsxs)("p",{className:"mt-2 text-xs text-muted-foreground",children:["Static governance copy with a tone. Used for the PAP-10400 trust-tier banner on Runtime and the effective-access banner on Agent → Tools. Pass ",(0,t.jsx)("code",{children:"title"}),"/",(0,t.jsx)("code",{children:"body"})," and an optional"," ",(0,t.jsx)("code",{children:"icon"}),"."]})]}),(0,t.jsxs)(ar,{title:"Action approval card — pending / stale (surfaces 11/12)",children:[(0,t.jsxs)("div",{className:"grid gap-4 lg:grid-cols-2",children:[(0,t.jsx)(rz,{toolName:"slack.post_message",risk:"medium",isWrite:!0,binding:{application:"Slack",manifestVersion:"2.4.1",connection:"https://slack.com/api · acme-workspace",catalogSha256:"sha256:9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",payloadSha256:"sha256:2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae"},input:{channel:"#launch",text:"Deploy v2 is live 🎉",unfurl_links:!1},reason:"This tool can write to your workspace, so a human signs off before the agent posts.",policyNumber:7,expiresInLabel:"expires in 23h 51m"}),(0,t.jsx)(rz,{variant:"stale",toolName:"slack.post_message",risk:"medium",isWrite:!0,binding:{application:"Slack",manifestVersion:"2.4.1",connection:"https://slack.com/api · acme-workspace",catalogSha256:"sha256:7d793037a0760186574b0282f2f435e7a4b1b2b0b822cd15d6c15b0f00a0e3f1",previousCatalogSha256:"sha256:9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",payloadSha256:"sha256:2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae"},input:{channel:"#launch",text:"Deploy v2 is live 🎉",unfurl_links:!1},reason:"This tool can write to your workspace, so a human signs off before the agent posts.",policyNumber:7,expiresInLabel:"expires in 18h 02m"})]}),(0,t.jsxs)("p",{className:"mt-2 text-xs text-muted-foreground",children:["Signed payload sha256 + expiry surface on every variant (PAP-10400). The"," ",(0,t.jsx)("code",{children:"stale"})," variant tints the border amber, banners the catalog-hash mismatch, strikes through the previous hash next to the current one, and renders ",(0,t.jsx)("code",{children:"Approve"})," disabled until the request is re-issued."]})]}),(0,t.jsxs)(ar,{title:"Action approval card — mobile (390×844, surface 99)",children:[(0,t.jsx)("div",{className:"w-(--sz-390px) max-w-full rounded-xl border border-border bg-background p-3",children:(0,t.jsx)(Uzt,{toolName:"slack.post_message",risk:"medium",isWrite:!0,binding:{application:"Slack",manifestVersion:"2.4.1",connection:"https://slack.com/api · acme-workspace",catalogSha256:"sha256:9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",payloadSha256:"sha256:2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae"},input:{channel:"#launch",text:"Deploy v2 is live 🎉"},reason:"This tool can write to your workspace, so a human signs off before the agent posts.",policyNumber:7,expiresInLabel:"expires in 23h 51m"})}),(0,t.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Identical content; the three buttons stack full-width in the order Approve / Deny / Edit & re-sign, and the bindings table uses a 70px label column."})]}),(0,t.jsxs)(ar,{title:"BindingsTable (reused in the audit row drilldown)",children:[(0,t.jsx)(S1e,{rows:[{label:"Application",value:"Slack · manifest v2.4.1"},{label:"Connection",value:"https://slack.com/api · acme-workspace",mono:!0},{label:"Catalog",value:"sha256:9f86d081…f00a08",mono:!0},{label:"Payload",value:"sha256:2c26b46b…66e7ae",mono:!0}]}),(0,t.jsxs)("p",{className:"mt-2 text-xs text-muted-foreground",children:["Two-column key/value block with mono values. Lives inside ",(0,t.jsx)("code",{children:"ActionCard"})," and is reused standalone in the audit row drilldown."]})]}),(0,t.jsxs)(ar,{title:"Tool-access status keys (StatusBadge)",children:[(0,t.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:["allowed","denied","block","require-approval","redacted","rate-limit","deferred","hidden","quarantined","healthy","degraded","runtime-error","unchecked"].map($=>(0,t.jsx)(ti,{status:$},$))}),(0,t.jsxs)("p",{className:"mt-2 text-xs text-muted-foreground",children:["Policy decisions, connection/runtime health, and catalog quarantine all route through the canonical"," ",(0,t.jsx)("code",{children:"StatusBadge"})," keys defined in ",(0,t.jsx)("code",{children:"lib/status-colors"}),"."]})]}),(0,t.jsx)(ar,{title:"EmptyState (canonical, with description + action)",children:(0,t.jsx)(Mn,{icon:Pd,message:"No connections yet",description:"Add a connection to an application to configure credentials and discover its tools.",action:"New connection",onAction:r(()=>{},"onAction")})})]}),(0,t.jsxs)(Or,{title:"Source Repositories",children:[(0,t.jsx)(ar,{title:"Empty and disconnected",children:(0,t.jsx)(ZO,{selected:[],onChange:r(()=>{},"onChange"),state:"disconnected",onConnect:r(()=>{},"onConnect"),onRetry:r(()=>{},"onRetry")})}),(0,t.jsx)(ar,{title:"Selected and searchable",children:(0,t.jsx)(ZO,{selected:[{id:"1",fullName:"paperclipai/paperclip",url:"https://github.com/paperclipai/paperclip",connections:["Your GitHub"]}],available:[{id:"2",fullName:"paperclipai/docs",url:"https://github.com/paperclipai/docs",connections:["Company GitHub"]}],onChange:r(()=>{},"onChange"),onConnect:r(()=>{},"onConnect"),onRetry:r(()=>{},"onRetry")})}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Loading, errors, empty search, mobile, and short viewports are covered in the Project repos Storybook stories."})]}),(0,t.jsxs)(Or,{title:"Environment Variables Editor",children:[(0,t.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Reusable env-var editor (agents, projects, environments, routines). One shared grid, an in-field Text/Secret source switch, a fuzzy secret picker with a pinned “Create secret” item, automatic sensitive-value detection, and inline secret-health warnings. See the Storybook ",(0,t.jsx)("span",{className:"font-mono",children:"Product/Environment Variables Editor"})," stories for all 10 states."]}),(0,t.jsx)(bUt,{})]}),(0,t.jsxs)(Or,{title:"Tasks created from a task",children:[(0,t.jsx)(ar,{title:"Subtasks and created work are independent",children:(0,t.jsx)("div",{className:"max-w-xl",children:(0,t.jsx)(Jk,{subtasks:[a2],createdTasks:[{...a2,projectId:"design-board",project:{id:"design-board",name:"Board UI"}},{...a2,id:"design-followup",identifier:"PAP-428",title:"Write release notes",status:"todo",projectId:null}],projects:[]})})}),(0,t.jsxs)(ar,{title:"Empty, loading and failed",children:[(0,t.jsx)(Jk,{subtasks:[],createdTasks:[],projects:[]}),(0,t.jsx)(Jk,{subtasks:[],createdTasks:[],projects:[],isLoading:!0}),(0,t.jsx)(Jk,{subtasks:[],createdTasks:[],projects:[],hasError:!0,onRetry:r(()=>{},"onRetry")})]})]}),(0,t.jsxs)(Or,{title:"Pending task input above composer",children:[(0,t.jsx)("p",{className:"mb-3 text-sm text-muted-foreground",children:"A decision card sits above the ordinary message composer. Dismiss the card to keep a reopen control, or resolve it to clear the pending state."}),(0,t.jsx)(yUt,{})]}),(0,t.jsx)(Or,{title:"Execution recovery",children:(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Recovery runs in the background. Task lists keep their ordinary status without execution badges. Active transcript headers keep saying Working during automatic recovery. Recovery decisions and attempts belong in the run log; there is no execution status card or reconciliation form."})}),(0,t.jsxs)(Or,{title:"Saved provider API keys",children:[(0,t.jsx)($j,{options:[{id:"example",label:"Claude API key (Your key)",binding:{type:"user_secret_ref",key:"ANTHROPIC_API_KEY",version:"latest"}}],value:"example",onChange:r(()=>{},"onChange"),loading:!1,error:!1}),(0,t.jsx)($j,{options:[],value:"",onChange:r(()=>{},"onChange"),loading:!0,error:!1}),(0,t.jsx)($j,{options:[],value:"",onChange:r(()=>{},"onChange"),loading:!1,error:!0})]}),(0,t.jsxs)(Or,{title:"Connection Intent",children:[(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"The task card is the dialog host for the shared connection setup flow. Provider forms, validation, OAuth, access selection, and completion come from the same feature module as the full-page Apps setup; this card owns only audience, dialog, and task refresh behavior. Pending connections stay in the timeline beside a usable composer. The independently addressable Connections/In-task connections stories cover access, OAuth recovery, narrow layouts, completion, and historical outcomes."}),(0,t.jsxs)("div",{className:"grid gap-4 xl:grid-cols-3",children:[(0,t.jsx)(tf,{interaction:Hzt,currentUserId:zr.currentUserId}),(0,t.jsx)(tf,{interaction:Qzt,currentUserId:zr.currentUserId}),(0,t.jsx)(tf,{interaction:Gzt,currentUserId:zr.currentUserId})]})]}),(0,t.jsxs)(Or,{title:"Resizable Panels",children:[(0,t.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Design-system wrapper over ",(0,t.jsx)("span",{className:"font-mono",children:"react-resizable-panels"})," ","(Skill Studio D2). Drag a handle to resize; panels accept percentage or pixel (",(0,t.jsx)("span",{className:"font-mono",children:'minSize="240px"'}),") constraints and the middle panel is collapsible. Use anywhere a split view is needed."]}),(0,t.jsx)("div",{className:"h-48 max-w-2xl overflow-hidden rounded-md border border-border",children:(0,t.jsxs)(l9,{children:[(0,t.jsx)(zb,{id:"a",minSize:"120px",className:"bg-muted/30",children:(0,t.jsx)("div",{className:"flex h-full items-center justify-center text-xs text-muted-foreground",children:"Panel A"})}),(0,t.jsx)(XC,{}),(0,t.jsx)(zb,{id:"b",minSize:"120px",collapsible:!0,collapsedSize:"40px",className:"bg-muted/10",children:(0,t.jsx)("div",{className:"flex h-full items-center justify-center text-xs text-muted-foreground",children:"Panel B (collapsible)"})}),(0,t.jsx)(XC,{}),(0,t.jsx)(zb,{id:"c",minSize:"120px",className:"bg-muted/30",children:(0,t.jsx)("div",{className:"flex h-full items-center justify-center text-xs text-muted-foreground",children:"Panel C"})})]})})]}),(0,t.jsx)(Or,{title:"Webhook URL warnings",children:(0,t.jsx)("div",{className:"space-y-3",children:["http://localhost:3100","https://paperclip.internal","https://paperclip.example-tailnet.ts.net","http://paperclip.example.com","not-a-url"].map($=>(0,t.jsx)(_7,{url:$},$))})}),(0,t.jsxs)(Or,{title:"Inline Banner",children:[(0,t.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Token-backed full-width notice (",(0,t.jsx)("span",{className:"font-mono",children:"brandBanner"})," tones). Use"," ",(0,t.jsx)("span",{className:"font-mono",children:"info"})," for provenance/context and"," ",(0,t.jsx)("span",{className:"font-mono",children:"warning"})," for paused/attention. Supports an optional bold title and a trailing actions slot. Replaces hand-rolled"," ",(0,t.jsx)("span",{className:"font-mono",children:"bg-yellow-*"}),"/",(0,t.jsx)("span",{className:"font-mono",children:"bg-blue-*"})," ","banners."]}),(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)(Ga,{tone:"info",title:"Built-in agent",actions:(0,t.jsx)(F,{variant:"outline",size:"sm",children:"Reset to defaults"}),children:["Ships with Paperclip and powers ",(0,t.jsx)("strong",{children:"Briefs"}),". It can be paused but not deleted."]}),(0,t.jsx)(Ga,{tone:"warning",title:"Briefs is paused.",actions:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(F,{variant:"ghost",size:"sm",children:"View agent"}),(0,t.jsx)(F,{size:"sm",children:"Resume agent"})]}),children:"Its built-in agent was paused 2 days ago, so new briefs aren't being generated."}),(0,t.jsx)(Ga,{tone:"danger",title:"Summary generation failed.",actions:(0,t.jsx)(F,{size:"sm",children:"Retry"}),children:"The linked issue reached a terminal state before a summary was written."}),(0,t.jsx)(Ga,{tone:"info",compact:!0,children:"Compact variant for embedding inside dialogs and modals."})]})]}),(0,t.jsxs)(Or,{title:"Media artifacts",children:[(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Images and videos use gallery tiles. The whole tile opens the task gallery; files and links keep compact, fully clickable rows. Task/Artifact Gallery in Storybook covers playable videos, mixed files, narrow panels, and unavailable previews."}),(0,t.jsxs)("div",{className:"grid max-w-2xl grid-cols-1 gap-3 sm:grid-cols-2",children:[(0,t.jsx)(uB,{id:"design-image",title:"Launch artwork",contentPath:"/announcement-preview.svg",contentType:"image/svg+xml",originalFilename:"launch.svg",detail:"Image"}),(0,t.jsx)(uB,{id:"design-video",title:"Video preview unavailable",contentPath:"",contentType:"video/mp4",originalFilename:"preview.mp4",detail:"Video"})]})]}),(0,t.jsx)(Or,{title:"AI Connections",children:(0,t.jsx)(Lzt,{})}),(0,t.jsxs)(Or,{title:"Built-in Agent Lifecycle Chips",children:[(0,t.jsxs)("p",{className:"text-sm text-muted-foreground",children:["A derived lifecycle chip (amber) for attention states. The lifecycle chip is separate from the agent status vocabulary and only shows for"," ",(0,t.jsx)("span",{className:"font-mono",children:"needs_setup"})," / ",(0,t.jsx)("span",{className:"font-mono",children:"pending_approval"}),"."]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-4",children:[(0,t.jsx)(Ej,{status:"needs_setup"}),(0,t.jsx)(Ej,{status:"pending_approval"}),(0,t.jsx)(Ej,{status:"needs_setup",compact:!0})]}),(0,t.jsxs)("p",{className:"mt-3 text-sm text-muted-foreground",children:[(0,t.jsx)("span",{className:"font-mono",children:"<BuiltInAgentGate agentKey>"})," composes"," ",(0,t.jsx)("span",{className:"font-mono",children:"PageSkeleton"})," + ",(0,t.jsx)("span",{className:"font-mono",children:"EmptyState"})," ","+ ",(0,t.jsx)("span",{className:"font-mono",children:"InlineBanner"})," to render the loading / setup / pending-approval / paused / ready states of a feature that depends on a built-in agent."]})]})]})}r(NUt,"DesignGuide");function kUt(e,s){return e?.enableWorktreeRunExecution!==!0?{kind:"off"}:e.worktreeRunExecutionActivatedAt?s?e.worktreeRunExecutionActivationInstanceId!==s?{kind:"fail_closed",reason:"instance_mismatch"}:{kind:"armed",activatedAt:e.worktreeRunExecutionActivatedAt}:{kind:"fail_closed",reason:"missing_instance_id"}:{kind:"fail_closed",reason:"missing_cutoff"}}r(kUt,"resolveWorktreeRunExecutionDisplayState");function SUt(e){const s=new Date(e);return Number.isNaN(s.getTime())?e:s.toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}r(SUt,"formatActivationTimestamp");function T1e(){return(0,t.jsxs)(lt,{variant:"outline",className:"text-muted-foreground",children:[(0,t.jsx)(Dd,{"aria-hidden":"true"}),"Managed by Paperclip Cloud"]})}r(T1e,"ManagedByCloudBadge");function ko({title:e,description:s,footnote:n,checked:a,onCheckedChange:i,disabled:o,settingKey:l,managed:c,ariaLabel:d}){const{hidden:m}=eh(),h=c?.managed===!0;return m.has($le(l))?null:(0,t.jsx)(Xs,{className:"block bg-transparent p-5",children:(0,t.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("h3",{className:"text-sm font-semibold",children:e}),h?(0,t.jsx)(T1e,{}):null]}),(0,t.jsx)("p",{className:"max-w-2xl text-sm text-muted-foreground",children:s}),n?(0,t.jsx)("p",{className:"max-w-2xl text-xs text-muted-foreground",children:n}):null]}),(0,t.jsx)(_i,{checked:a,onCheckedChange:r(p=>{h||i(p)},"onCheckedChange"),disabled:o||h,"aria-label":d})]})})}r(ko,"ExperimentalToggleCard");function CUt(){const{setBreadcrumbs:e}=qn(),s=Wt(),{hidden:n}=eh(),[a,i]=(0,u.useState)(null);(0,u.useEffect)(()=>{e([{label:"Settings",href:"/company/settings"},{label:"Experimental"}])},[e]);const o=Z({queryKey:P.instance.experimentalSettings,queryFn:r(()=>Er.getExperimental(),"queryFn")}),l=Ne({mutationFn:r(async J=>Er.updateExperimental(J),"mutationFn"),onMutate:r(async J=>{await s.cancelQueries({queryKey:P.instance.experimentalSettings});const Y=s.getQueryData(P.instance.experimentalSettings);return Y&&s.setQueryData(P.instance.experimentalSettings,{...Y,...J}),{previousSettings:Y}},"onMutate"),onSuccess:r(async J=>{i(null),s.setQueryData(P.instance.experimentalSettings,J),await Promise.all([s.invalidateQueries({queryKey:P.instance.experimentalSettings}),s.invalidateQueries({queryKey:P.adapters.all}),s.invalidateQueries({queryKey:["built-in-agents"]}),s.invalidateQueries({queryKey:P.health}),s.invalidateQueries({queryKey:["apps"]})])},"onSuccess"),onError:r((J,Y,G)=>{G?.previousSettings&&s.setQueryData(P.instance.experimentalSettings,G.previousSettings),i(J instanceof Error?J.message:"Failed to update experimental settings.")},"onError")});if(o.isLoading)return(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:"Loading experimental settings..."});if(o.error)return(0,t.jsx)("div",{className:"text-sm text-destructive",children:o.error instanceof Error?o.error.message:"Failed to load experimental settings."});const c=KYe(),d=o.data?.managedKeys??{},m=o.data?.enableWorktreeRunExecution===!0,h=d.enableWorktreeRunExecution?.managed===!0,p=kUt(o.data,VYe()),f=o.data?.enableEnvironments===!0,g=o.data?.enableNativeRunner===!0,v=o.data?.enableChatConnectors===!0,y=o.data?.enableManagedSandboxOnly===!0,w=o.data?.enableIsolatedWorkspaces===!0,S=o.data?.enableIsolatedWorkspacesByDefault===!0,j=o.data?.enableStreamlinedUi!==!1;o.data?.enableConferenceRoomChat;const N=o.data?.enableClassicTaskInterface===!0,_=o.data?.enableIssuePlanDecompositions===!0,R=o.data?.enableExperimentalFileViewer===!0,C=o.data?.enableExternalObjects===!0,A=o.data?.enableBuiltInAgents===!0,T=o.data?.enableBetaSkills===!0,I=o.data?.enableSummaries===!0,$=o.data?.enableStatusCards===!0,O=d.enableSummaries?.managed===!0,L=d.enableStatusCards?.managed===!0,E=O&&!I,q=L&&$,B=o.data?.enableDecisions===!0,K=o.data?.enableGoalsSidebarLink===!0,z=o.data?.enableCases===!0,D=o.data?.enableServerInfoDebugView===!0,V=o.data?.enablePaperclipDeveloperMode===!0,H=o.data?.enableSimplifiedEnglishInteractions===!0,ee=o.data?.enableFirstTaskPlanProposal===!0,X=o.data?.enableSmokeLab===!0,le=o.data?.autoRestartDevServerWhenIdle===!0,ce=r(J=>!n.has($le(J)),"isVisible"),te=c&&ce("enableWorktreeRunExecution"),ae=te||["autoRestartDevServerWhenIdle","enableManagedSandboxOnly","enablePaperclipDeveloperMode","enableServerInfoDebugView","enableSmokeLab","enableIssuePlanDecompositions"].some(ce),de=ce("enableClassicTaskInterface")||ce("enableGoalsSidebarLink");return(0,t.jsxs)("div",{className:"max-w-6xl space-y-6",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(em,{className:"h-5 w-5 text-muted-foreground"}),(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Experimental"})]}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Opt into features that are still being evaluated before they become default behavior."})]}),(0,t.jsx)("div",{role:"alert",className:"rounded-lg border border-amber-500/30 bg-amber-500/5 px-4 py-3",children:(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)(Is,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-700"}),(0,t.jsxs)("div",{className:"space-y-1 text-sm",children:[(0,t.jsx)("p",{className:"font-medium text-foreground",children:"Experimental features may break at any time."}),(0,t.jsx)("p",{className:"text-muted-foreground",children:"These features are opt-in and come with no compatibility guarantees. They may change, break, or be removed without notice. Avoid relying on them for critical or production workflows."})]})]})}),a&&(0,t.jsx)("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:a}),(0,t.jsxs)("section",{className:"space-y-3","aria-labelledby":"experimental-features-heading",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("h2",{id:"experimental-features-heading",className:"text-sm font-semibold",children:"Experimental features"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Optional product features that are still being evaluated."})]}),(0,t.jsx)(ko,{title:"Agent Chat",description:"Talk to each agent in one ongoing conversation. Clarify goals and create tasks for execution.",footnote:"Turning this off preserves conversations and lets active runs finish, but prevents new messages.",checked:o.data?.enableAgentChat??!1,onCheckedChange:r(J=>l.mutate({enableAgentChat:J}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableAgentChat",managed:d.enableAgentChat,ariaLabel:"Toggle agent chat experimental setting"}),(0,t.jsx)(ko,{title:"Beta skills",description:"Allow agents to pin beta releases of the Paperclip core skill. Disabling this returns every agent to the default live skill without removing saved pins.",checked:T,onCheckedChange:r(J=>l.mutate({enableBetaSkills:J}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableBetaSkills",managed:d.enableBetaSkills,ariaLabel:"Toggle beta skills experimental setting"}),(0,t.jsx)(ko,{title:"Built-in Agents",description:"Show Paperclip-managed built-in agent surfaces, including built-in roster badges, the Built-in agents tab, and built-in agent setup controls.",checked:A,onCheckedChange:r(J=>l.mutate({enableBuiltInAgents:J}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableBuiltInAgents",managed:d.enableBuiltInAgents,ariaLabel:"Toggle built-in agents experimental setting"}),(0,t.jsx)(ko,{title:"Cases",description:"Durable work products (blog posts, tweet storms…) that tasks create and iterate on. Adds the Cases tab and the agent case API.",footnote:"Turning Cases off hides the tab and blocks the case API; existing case data is kept.",checked:z,onCheckedChange:r(J=>l.mutate({enableCases:J}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableCases",managed:d.enableCases,ariaLabel:"Toggle cases experimental setting"}),(0,t.jsx)(ko,{title:"Chat connectors",description:"Connect agents to Slack, GitHub, Discord, Microsoft Teams, and Telegram conversations.",footnote:"Turning this off hides chat setup, channels, and connected-task controls. Existing chat connections keep running. GitHub and other tool connectors stay available.",checked:v,onCheckedChange:r(J=>l.mutate({enableChatConnectors:J}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableChatConnectors",managed:d.enableChatConnectors,ariaLabel:"Toggle chat connectors experimental setting"}),null,(0,t.jsx)(ko,{title:"Decisions",description:"Show the Decisions item in the main sidebar — the attention home that surfaces the tasks awaiting your input — while the surface is still being evaluated.",checked:B,onCheckedChange:r(J=>l.mutate({enableDecisions:J}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableDecisions",managed:d.enableDecisions,ariaLabel:"Toggle decisions experimental setting"}),(0,t.jsx)(ko,{title:"Enable Environments",description:"Show environment management in company settings and allow project and agent environment assignment controls.",checked:f,onCheckedChange:r(J=>l.mutate({enableEnvironments:J}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableEnvironments",managed:d.enableEnvironments,ariaLabel:"Toggle environments experimental setting"}),(0,t.jsx)(ko,{title:"Enable External Objects",description:"Detect external URLs in issues and show resolved status for pull requests, tickets, and other referenced work objects.",checked:C,onCheckedChange:r(J=>l.mutate({enableExternalObjects:J}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableExternalObjects",managed:d.enableExternalObjects,ariaLabel:"Toggle external objects experimental setting"}),(0,t.jsx)(ko,{title:"Enable Isolated Workspaces",description:"Show execution workspace controls in project configuration and allow isolated workspace behavior for new and existing task runs.",checked:w,onCheckedChange:r(J=>l.mutate({enableIsolatedWorkspaces:J}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableIsolatedWorkspaces",managed:d.enableIsolatedWorkspaces,ariaLabel:"Toggle isolated workspaces experimental setting"}),(0,t.jsx)(ko,{title:"Experimental File Viewer",description:"Show task detail controls for browsing and previewing workspace files relative to a task.",checked:R,onCheckedChange:r(J=>l.mutate({enableExperimentalFileViewer:J}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableExperimentalFileViewer",managed:d.enableExperimentalFileViewer,ariaLabel:"Toggle experimental file viewer setting"}),(0,t.jsx)(ko,{title:"First task: propose with a plan document",description:"When the user's first request is a single task, the chief of staff writes a short plan document and a checkbox card instead of a one-card confirmation. Applies to organizations created after the toggle is flipped.",checked:ee,onCheckedChange:r(J=>l.mutate({enableFirstTaskPlanProposal:J}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableFirstTaskPlanProposal",managed:d.enableFirstTaskPlanProposal,ariaLabel:"Toggle first task plan proposal experimental setting"}),(0,t.jsx)(ko,{title:"MCP aggregators",description:"Connect Zapier, Arcade, Composio Connect, and Executor through their MCP servers.",footnote:"Turning this off hides setup for these connectors. Existing MCP connections keep running.",checked:o.data?.enableMcpAggregators===!0,onCheckedChange:r(J=>l.mutate({enableMcpAggregators:J}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableMcpAggregators",managed:d.enableMcpAggregators,ariaLabel:"Toggle MCP aggregators experimental setting"}),(0,t.jsx)(ko,{title:"Paperclip Runner",description:"Allow new Codex agents to select the experimental Rust Paperclip Runner, including authenticated runner ingress when a sandbox requires it. Onboarding continues to use legacy adapters. Turning this off hides the choice without affecting existing native runs.",checked:g,onCheckedChange:r(J=>l.mutate({enableNativeRunner:J}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableNativeRunner",managed:d.enableNativeRunner,ariaLabel:"Toggle Paperclip Runner experimental setting"}),(0,t.jsx)(ko,{title:"Simplified English Interactions",description:"Instruct agents to write user interactions (plan confirmations, questions, suggested tasks, checkbox prompts) in ASD-STE100 Simplified Technical English, with brief context on what information the decision needs and what happens for each choice.",checked:H,onCheckedChange:r(J=>l.mutate({enableSimplifiedEnglishInteractions:J}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableSimplifiedEnglishInteractions",managed:d.enableSimplifiedEnglishInteractions,ariaLabel:"Toggle simplified english interactions experimental setting"}),(0,t.jsx)(ko,{title:"Status Cards",description:"Enable the experimental shared status-card board and its gated API. Existing card data is kept when this is disabled.",footnote:"Enabling Status Cards also enables Summaries.",checked:$,onCheckedChange:r(J=>l.mutate(J?{enableSummaries:!0,enableStatusCards:!0}:{enableStatusCards:!1}),"onCheckedChange"),disabled:l.isPending||E,settingKey:"enableStatusCards",managed:d.enableStatusCards,ariaLabel:"Toggle status cards experimental setting"}),(0,t.jsx)(ko,{title:"Streamlined UI",description:"Use the simplified main sidebar, shared Tasks and Inbox presentation, focused task detail layout, and contextual navigation across Agents, Routines, Skills, and Settings.",footnote:"Turning this off restores the legacy shell and navigation. Task and page data are unchanged.",checked:j,onCheckedChange:r(J=>l.mutate({enableStreamlinedUi:J}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableStreamlinedUi",managed:d.enableStreamlinedUi,ariaLabel:"Toggle Streamlined UI experimental setting"}),(0,t.jsx)(ko,{title:"Summaries",description:"Show Summarizer-generated status slots on project and workspace pages, with on-demand refresh and revision history. Existing summary data is kept when this is disabled.",footnote:"Status Cards requires Summaries. Disabling Summaries also disables Status Cards.",checked:I,onCheckedChange:r(J=>l.mutate(J||!$?{enableSummaries:J}:{enableSummaries:!1,enableStatusCards:!1}),"onCheckedChange"),disabled:l.isPending||q,settingKey:"enableSummaries",managed:d.enableSummaries,ariaLabel:"Toggle summaries experimental setting"}),w&&(0,t.jsx)(ko,{title:"Use Isolated Workspaces By Default",description:"Treat a project that has no execution workspace policy of its own as if it selected isolated workspaces, so its tasks get a per-task worktree instead of sharing the project checkout. A project that carries its own policy keeps it.",checked:S,onCheckedChange:r(J=>l.mutate({enableIsolatedWorkspacesByDefault:J}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableIsolatedWorkspacesByDefault",managed:d.enableIsolatedWorkspacesByDefault,ariaLabel:"Toggle isolated workspaces by default experimental setting"})]}),ae?(0,t.jsxs)("section",{className:"space-y-3","aria-labelledby":"developer-mode-heading",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("h2",{id:"developer-mode-heading",className:"text-sm font-semibold",children:"Paperclip Developer Mode"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Internal tools for developing, testing, and debugging Paperclip."})]}),(0,t.jsx)(ko,{title:"Auto-Restart Dev Server When Idle",description:"In `pnpm dev:once`, wait for all queued and running local agent runs to finish, then restart the server automatically when backend changes or migrations make the current boot stale.",checked:le,onCheckedChange:r(J=>l.mutate({autoRestartDevServerWhenIdle:J}),"onCheckedChange"),disabled:l.isPending,settingKey:"autoRestartDevServerWhenIdle",managed:d.autoRestartDevServerWhenIdle,ariaLabel:"Toggle guarded dev-server auto-restart"}),(0,t.jsx)(ko,{title:"Managed Environment Only",description:"Hide the local environment and run all agents in the platform-managed environment.",checked:y,onCheckedChange:r(J=>l.mutate({enableManagedSandboxOnly:J}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableManagedSandboxOnly",managed:d.enableManagedSandboxOnly,ariaLabel:"Toggle managed environment only experimental setting"}),(0,t.jsx)(ko,{title:"Paperclip Developer Mode",description:"Show internal Paperclip maintainer tools and observability links, including Honeycomb trace queries on run pages.",checked:V,onCheckedChange:r(J=>l.mutate({enablePaperclipDeveloperMode:J}),"onCheckedChange"),disabled:l.isPending,settingKey:"enablePaperclipDeveloperMode",managed:d.enablePaperclipDeveloperMode,ariaLabel:"Toggle Paperclip developer mode experimental setting"}),te?(0,t.jsx)(Xs,{className:"block bg-transparent p-5",children:(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("h3",{className:"text-sm font-semibold",children:"Run tasks in this worktree"}),h?(0,t.jsx)(T1e,{}):null]}),(0,t.jsx)("p",{className:"max-w-2xl text-sm text-muted-foreground",children:"This is an isolated git-worktree preview instance. Turn this on to let the scheduler execute runs here. Only tasks created after enabling will run automatically — copied/pre-existing tasks stay parked. Toggling off and on resets the cutoff."})]}),(0,t.jsx)(_i,{checked:m,onCheckedChange:r(J=>{h||l.mutate({enableWorktreeRunExecution:J})},"onCheckedChange"),disabled:l.isPending||h,"aria-label":"Toggle worktree run execution setting"})]}),p.kind==="armed"?(0,t.jsxs)("div",{className:"flex items-center gap-2 rounded-md border border-emerald-500/30 bg-emerald-500/5 px-3 py-2 text-sm text-foreground",children:[(0,t.jsx)(So,{className:"h-4 w-4 shrink-0 text-emerald-600"}),(0,t.jsxs)("span",{children:["Running tasks created after"," ",(0,t.jsx)("span",{className:"font-medium",children:SUt(p.activatedAt)}),"."]})]}):null,p.kind==="fail_closed"?(0,t.jsxs)("div",{className:"flex items-start gap-2 rounded-md border border-amber-500/30 bg-amber-500/5 px-3 py-2 text-sm",children:[(0,t.jsx)(Is,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-700"}),(0,t.jsxs)("div",{className:"space-y-0.5",children:[(0,t.jsx)("p",{className:"font-medium text-foreground",children:"Execution is suppressed — effectively off."}),(0,t.jsxs)("p",{className:"text-muted-foreground",children:[p.reason==="instance_mismatch"?"This setting was armed in a different instance and copied here, so no tasks run automatically.":"This setting is missing its activation cutoff, so no tasks run automatically."," ","Toggle it off and back on to arm execution for tasks created here."]})]})]}):null]})}):null,(0,t.jsx)(ko,{title:"Server Info Debug View",description:'Show a "Server" section in the account drawer with the current server restart time and running commit.',checked:D,onCheckedChange:r(J=>l.mutate({enableServerInfoDebugView:J}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableServerInfoDebugView",managed:d.enableServerInfoDebugView,ariaLabel:"Toggle server info debug view experimental setting"}),(0,t.jsx)(ko,{title:"Smoke Lab",description:'Add a "Smoke Lab" tab under Apps → Developer and an "Integration smoke" card on the dashboard for exercising every integration path against deterministic local fixtures (fake OAuth provider + loopback MCP servers). Private (non-public) deployments only.',checked:X,onCheckedChange:r(J=>l.mutate({enableSmokeLab:J}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableSmokeLab",managed:d.enableSmokeLab,ariaLabel:"Toggle smoke lab experimental setting"}),(0,t.jsx)(ko,{title:"Task Plan Decomposition",description:"Show accepted-plan decomposition history on task detail pages. Intended for debugging and validating subtask creation behavior while the presentation is still being refined.",checked:_,onCheckedChange:r(J=>l.mutate({enableIssuePlanDecompositions:J}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableIssuePlanDecompositions",managed:d.enableIssuePlanDecompositions,ariaLabel:"Toggle task plan decomposition panel experimental setting"})]}):null,de?(0,t.jsxs)("section",{className:"space-y-3","aria-labelledby":"legacy-heading",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("h2",{id:"legacy-heading",className:"text-sm font-semibold",children:"Legacy"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"These features are going to be removed."})]}),(0,t.jsx)(ko,{title:"Classic Task Interface",description:"Restores the previous task detail page: the page-level header with inline description editing, the plain comment thread, and the fixed Properties sidebar. Chat-only features — streaming activity folding, inline plan and question cards, the three-mode composer — are unavailable in the classic view.",footnote:"Switching takes effect immediately. No task data is affected.",checked:N,onCheckedChange:r(J=>l.mutate({enableClassicTaskInterface:J}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableClassicTaskInterface",managed:d.enableClassicTaskInterface,ariaLabel:"Toggle classic task interface experimental setting"}),(0,t.jsx)(ko,{title:"Goals Sidebar Link",description:"Restore the Goals item in the main sidebar while the goals surface is being evaluated.",checked:K,onCheckedChange:r(J=>l.mutate({enableGoalsSidebarLink:J}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableGoalsSidebarLink",managed:d.enableGoalsSidebarLink,ariaLabel:"Toggle goals sidebar link experimental setting"})]}):null]})}r(CUt,"InstanceExperimentalSettings");function _Ut(){const{userId:e,settled:s}=d5(),{setBreadcrumbs:n}=qn(),{pushToast:a}=Ei(),i=Wt(),[o,l]=(0,u.useState)(""),[c,d]=(0,u.useState)(null),[m,h]=(0,u.useState)(new Set);(0,u.useEffect)(()=>{n([{label:"Settings",href:"/company/settings"},{label:"Instance settings",href:"/company/settings/instance/general"},{label:"Access"}])},[n]);const p=Z({queryKey:P.access.adminUsers(o),queryFn:r(()=>hr.searchAdminUsers(o),"queryFn")}),f=Z({...cIe(e),enabled:s&&p.isSuccess}),g=f.data??[],v=(0,u.useMemo)(()=>p.data?.find(j=>j.id===c)??null,[c,p.data]),y=Z({queryKey:P.access.userCompanyAccess(c??""),queryFn:r(()=>hr.getUserCompanyAccess(c),"queryFn"),enabled:!!c});(0,u.useEffect)(()=>{!c&&p.data?.[0]&&d(p.data[0].id)},[c,p.data]),(0,u.useEffect)(()=>{y.data&&h(new Set(y.data.companyAccess.filter(j=>j.status==="active").map(j=>j.companyId)))},[y.data]);const w=Ne({mutationFn:r(()=>hr.setUserCompanyAccess(c,[...m]),"mutationFn"),onSuccess:r(async()=>{await i.invalidateQueries({queryKey:P.access.userCompanyAccess(c)}),await i.invalidateQueries({queryKey:P.access.adminUsers(o)}),await i.invalidateQueries({queryKey:P.companies.all}),a({title:"Organization access updated",tone:"success"})},"onSuccess")}),S=Ne({mutationFn:r(async j=>{if(!c)throw new Error("No user selected");return j?hr.promoteInstanceAdmin(c):hr.demoteInstanceAdmin(c)},"mutationFn"),onSuccess:r(async()=>{await i.invalidateQueries({queryKey:P.access.adminUsers(o)}),c&&await i.invalidateQueries({queryKey:P.access.userCompanyAccess(c)}),a({title:"Instance role updated",tone:"success"})},"onSuccess")});if(p.isLoading||!s||p.isSuccess&&f.isPending)return(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:"Loading instance access…"});if(p.error){const j=p.error instanceof wn&&p.error.status===403?"Instance admin access is required to manage users.":p.error instanceof Error?p.error.message:"Failed to load users.";return(0,t.jsx)("div",{className:"text-sm text-destructive",children:j})}return f.error?(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)("p",{className:"text-sm text-destructive",children:"Failed to load organizations. Try again before changing access."}),(0,t.jsx)(F,{onClick:r(()=>{f.refetch()},"onClick"),children:"Try again"})]}):(0,t.jsxs)("div",{className:"max-w-6xl space-y-6",children:[(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(v5,{className:"h-5 w-5 text-muted-foreground"}),(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Instance Access"})]}),(0,t.jsx)("p",{className:"max-w-3xl text-sm text-muted-foreground",children:"Search users, manage instance-admin status, and control which organizations they can access."})]}),(0,t.jsxs)("div",{className:"grid gap-6 lg:grid-cols-(--gtc-34)",children:[(0,t.jsxs)(Xs,{className:"block space-y-4 p-4",children:[(0,t.jsxs)("label",{className:"block space-y-2 text-sm",children:[(0,t.jsx)("span",{className:"font-medium",children:"Search users"}),(0,t.jsx)("input",{className:"w-full rounded-md border border-border bg-background px-3 py-2",value:o,onChange:r(j=>l(j.target.value),"onChange"),placeholder:"Search by name or email"})]}),(0,t.jsx)("div",{className:"space-y-2",children:(p.data??[]).map(j=>(0,t.jsxs)("button",{type:"button",onClick:r(()=>d(j.id),"onClick"),className:`w-full rounded-lg border px-3 py-3 text-left transition-colors ${j.id===c?"border-foreground bg-accent":"border-border hover:bg-accent/40"}`,children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("div",{className:"truncate font-medium",children:j.name||j.email||j.id}),(0,t.jsx)("div",{className:"truncate text-sm text-muted-foreground",children:j.email||j.id})]}),j.isInstanceAdmin?(0,t.jsx)(Ii,{className:"h-4 w-4 text-emerald-600"}):null]}),(0,t.jsxs)("div",{className:"mt-2 text-xs text-muted-foreground",children:[j.activeCompanyMembershipCount," active organization memberships"]})]},j.id))})]}),(0,t.jsx)(Xs,{className:"block space-y-4 p-5",children:c?y.isLoading?(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:"Loading user access…"}):y.error?(0,t.jsx)("div",{className:"text-sm text-destructive",children:y.error instanceof Error?y.error.message:"Failed to load user access."}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-lg font-semibold",children:v?.name||v?.email||c}),(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:v?.email||c})]}),(0,t.jsx)(F,{variant:v?.isInstanceAdmin?"outline":"default",onClick:r(()=>S.mutate(!(v?.isInstanceAdmin??!1)),"onClick"),disabled:S.isPending,children:v?.isInstanceAdmin?"Remove instance admin":"Promote to instance admin"})]}),(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-sm font-semibold",children:"Organization access"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Toggle organization membership for this user. New access defaults to an active operator membership."})]}),(0,t.jsx)("div",{className:"grid gap-3 md:grid-cols-2",children:g.map(j=>(0,t.jsxs)("label",{className:"flex items-start gap-3 rounded-lg border border-border px-3 py-3",children:[(0,t.jsx)($i,{checked:m.has(j.id),onCheckedChange:r(N=>{h(_=>{const R=new Set(_);return N?R.add(j.id):R.delete(j.id),R})},"onCheckedChange")}),(0,t.jsxs)("span",{className:"space-y-1",children:[(0,t.jsx)("span",{className:"block text-sm font-medium",children:j.name}),(0,t.jsx)("span",{className:"block text-xs text-muted-foreground",children:j.issuePrefix})]})]},j.id))}),(0,t.jsx)("div",{className:"flex justify-end",children:(0,t.jsx)(F,{onClick:r(()=>w.mutate(),"onClick"),disabled:w.isPending,children:w.isPending?"Saving…":"Save organization access"})})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("h2",{className:"text-sm font-semibold",children:"Current memberships"}),(0,t.jsx)("div",{className:"space-y-2",children:(y.data?.companyAccess??[]).map(j=>(0,t.jsxs)("div",{className:"flex items-center justify-between rounded-lg border border-border px-3 py-2 text-sm",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"font-medium",children:j.companyName||j.companyId}),(0,t.jsxs)("div",{className:"text-muted-foreground",children:[j.membershipRole||"unset"," • ",j.status]})]}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:new Date(j.updatedAt).toLocaleDateString()})]},j.id))})]})]}):(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:"Select a user to inspect instance access."})})]})]})}r(_Ut,"InstanceAccess");var Woe={getMine:r(e=>Re.get(`/companies/${e}/users/me/inbox-agent-policy`),"getMine"),updateMine:r((e,s)=>Re.put(`/companies/${e}/users/me/inbox-agent-policy`,s),"updateMine")},IUt=[{value:"open",title:"Any of my agents",description:"Let any agent you manage archive tasks out of your inbox."},{value:"allowlist",title:"Only chosen agents",description:"Restrict inbox tidying to the agents you pick below."},{value:"disabled",title:"Off",description:"Agents can never archive tasks from your inbox."}];function i2(e,s){return`${e}:${[...s].sort().join(",")}`}r(i2,"policyKey");function AUt({companyId:e}){const s=Wt(),[n,a]=(0,u.useState)(null),i=(0,u.useRef)(null),o=Z({queryKey:e?P.inboxAgentPolicy.mine(e):["inbox-agent-policy","none"],queryFn:r(()=>Woe.getMine(e),"queryFn"),enabled:!!e}),l=o.data,c=Z({queryKey:e?P.agents.list(e):["agents","none"],queryFn:r(()=>Vt.list(e),"queryFn"),enabled:!!e}),d=(0,u.useMemo)(()=>(c.data??[]).filter(lf),[c.data]),m=(0,u.useMemo)(()=>d.map(g=>({id:g.id,name:g.name,title:g.title??g.role,icon:g.icon})),[d]),h=(0,u.useMemo)(()=>new Set(n?.allowedAgentIds??[]),[n?.allowedAgentIds]);(0,u.useEffect)(()=>{if(!l)return;const g=i2(l.mode,l.allowedAgentIds);a(v=>v===null||i2(v.mode,v.allowedAgentIds)===i.current?{mode:l.mode,allowedAgentIds:l.allowedAgentIds}:v),i.current=g},[l]);const p=Ne({mutationFn:r(g=>Woe.updateMine(e,{mode:g.mode,allowedAgentIds:g.mode==="allowlist"?g.allowedAgentIds:[]}),"mutationFn"),onSuccess:r(g=>{s.setQueryData(P.inboxAgentPolicy.mine(e),g)},"onSuccess")}),f=!!(n&&l&&i2(n.mode,n.allowedAgentIds)!==i2(l.mode,l.allowedAgentIds));return o.error?(0,t.jsx)("div",{className:"text-sm text-destructive",children:o.error instanceof Error?o.error.message:"Failed to load inbox agent policy."}):o.isLoading||!n?(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:"Loading inbox agent policy…"}):(0,t.jsxs)("section",{className:"space-y-4","aria-label":"Let agents tidy my inbox",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Pd,{className:"h-5 w-5 text-muted-foreground"}),(0,t.jsx)("h2",{className:"text-base font-semibold",children:"Let agents tidy my inbox"})]}),(0,t.jsx)("p",{className:"max-w-2xl text-sm text-muted-foreground",children:"Choose whether the agents you manage may archive tasks out of your inbox on your behalf. You can undo any archive, and every agent archive is attributed in the task's properties."})]}),(0,t.jsx)(uu,{ariaLabel:"Inbox agent archiving policy",value:n.mode,onValueChange:r(g=>a(v=>v&&{...v,mode:g}),"onValueChange"),options:IUt,className:"max-w-2xl"}),n.mode==="allowlist"?(0,t.jsxs)("div",{className:"max-w-2xl space-y-2",children:[(0,t.jsx)("div",{className:"text-sm font-medium",children:"Agents allowed to tidy my inbox"}),(0,t.jsx)(Pv,{agents:m,selectedAgentIds:h,onChange:r(g=>a(v=>v&&{...v,allowedAgentIds:[...g]}),"onChange"),triggerLabel:h.size===0?"Select agents":`${h.size} ${h.size===1?"agent":"agents"} selected`,triggerFullWidth:!1,showSelectionPreview:!1,emptyMessage:"You don’t manage any agents yet."})]}):null,p.error?(0,t.jsx)("div",{className:"max-w-2xl rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:p.error instanceof Error?p.error.message:"Failed to save inbox agent policy."}):null,(0,t.jsxs)("div",{className:"flex max-w-2xl items-center justify-end gap-3",children:[p.isSuccess&&!f?(0,t.jsx)("span",{className:"text-xs text-muted-foreground",role:"status",children:"Saved"}):null,(0,t.jsxs)(F,{type:"button",disabled:!f||p.isPending,onClick:r(()=>n&&p.mutate(n),"onClick"),children:[p.isPending?(0,t.jsx)(at,{className:"size-4 animate-spin"}):(0,t.jsx)(Qp,{className:"size-4"}),p.isPending?"Saving…":"Save"]})]})]})}r(AUt,"InboxAgentPolicyControl");function RUt(e){const s=e.trim().split(/\s+/).filter(Boolean);return s.length>=2?`${s[0]?.[0]??""}${s[s.length-1]?.[0]??""}`.toUpperCase():e.slice(0,2).toUpperCase()}r(RUt,"deriveInitials");function TUt(){const{setBreadcrumbs:e}=qn(),{selectedCompanyId:s,selectedCompany:n}=ps(),a=Wt(),i=(0,u.useId)(),o=(0,u.useRef)(null),[l,c]=(0,u.useState)(""),[d,m]=(0,u.useState)(""),[h,p]=(0,u.useState)(null),f=Z({queryKey:P.auth.session,queryFn:r(()=>qa.getSession(),"queryFn"),retry:!1});(0,u.useEffect)(()=>{e([{label:"Settings",href:"/company/settings"},{label:"Profile"}])},[e]),(0,u.useEffect)(()=>{const T=f.data;T&&(c(T.user.name??""),m(T.user.image??""))},[f.data]);function g(T){a.setQueryData(P.auth.session,I=>I&&{...I,user:{...I.user,...T}})}r(g,"syncSessionProfile");async function v(T){const I=await qa.updateProfile(T);return g(I),I}r(v,"persistProfile");function y(){return l.trim()||f.data?.user.name||"Board"}r(y,"resolveProfileName");const w=Ne({mutationFn:r(T=>v(T),"mutationFn"),onSuccess:r(T=>{p(null),c(T.name??""),m(T.image??"")},"onSuccess"),onError:r(T=>{p(T instanceof Error?T.message:"Failed to update profile.")},"onError")}),S=Ne({mutationFn:r(async T=>{if(!s)throw new Error("Select an organization before uploading a profile avatar.");const I=await m0.uploadImage(s,T,`profiles/${f.data?.user.id??"board-user"}`);return v({name:y(),image:I.contentPath})},"mutationFn"),onSuccess:r(T=>{p(null),c(T.name??""),m(T.image??"")},"onSuccess"),onError:r(T=>{p(T instanceof Error?T.message:"Failed to upload avatar.")},"onError")}),j=Ne({mutationFn:r(()=>v({name:y(),image:null}),"mutationFn"),onSuccess:r(T=>{p(null),c(T.name??""),m(T.image??"")},"onSuccess"),onError:r(T=>{p(T instanceof Error?T.message:"Failed to remove avatar.")},"onError")});if(f.isLoading)return(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:"Loading profile..."});if(f.error||!f.data)return(0,t.jsx)("div",{className:"text-sm text-destructive",children:f.error instanceof Error?f.error.message:"Failed to load profile."});const N=l.trim()||f.data.user.name||"Board",_=d.trim()||null,R=RUt(N),C=w.isPending||S.isPending||j.isPending,A=n?`Stored in Paperclip file storage for ${n.name}.`:"Select an organization to upload an avatar into Paperclip storage.";return(0,t.jsxs)("div",{className:"max-w-6xl space-y-6",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(C1,{className:"h-5 w-5 text-muted-foreground"}),(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Profile"})]}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Control how your account appears in the sidebar and other board surfaces."})]}),h?(0,t.jsx)("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:h}):null,(0,t.jsxs)("section",{className:"space-y-8",children:[(0,t.jsxs)(Xs,{className:"block relative overflow-hidden rounded-(--rad-28) border-border/70",children:[(0,t.jsx)("div",{className:"absolute inset-x-0 top-0 h-32 bg-(image:--gradient-extract-26)"}),(0,t.jsx)("div",{className:"absolute inset-0 bg-(image:--gradient-extract-7)"}),(0,t.jsx)("div",{className:"relative p-6 pt-10",children:(0,t.jsxs)("div",{className:"flex flex-wrap items-end gap-5 rounded-(--rad-24) border border-border/70 bg-background/92 p-5 shadow-(--shadow-extract-18) backdrop-blur-sm",children:[(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("label",{htmlFor:i,className:"group relative block cursor-pointer rounded-full focus-within:outline-none focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 focus-within:ring-offset-background",children:[(0,t.jsx)("input",{ref:o,id:i,type:"file",accept:"image/*",className:"sr-only",disabled:!s||C,onChange:r(T=>{const I=T.target.files?.[0];I&&(S.mutate(I),T.target.value="")},"onChange")}),(0,t.jsx)("span",{className:"absolute inset-0 z-10 rounded-full bg-black/0 transition-colors group-hover:bg-black/14 group-focus-within:bg-black/14"}),(0,t.jsx)("span",{className:"absolute bottom-1 right-1 z-20 flex size-9 items-center justify-center rounded-full border border-background bg-primary text-primary-foreground shadow-sm",children:S.isPending?(0,t.jsx)(at,{className:"size-4 animate-spin"}):(0,t.jsx)(EH,{className:"size-4"})}),(0,t.jsxs)(Gi,{size:"lg",className:"data-[size=lg]:size-24 ring-4 ring-background shadow-xl",children:[_?(0,t.jsx)(Hc,{src:_,alt:N}):null,(0,t.jsx)(Yi,{children:R})]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxs)(F,{type:"button",variant:"secondary",onClick:r(()=>o.current?.click(),"onClick"),disabled:!s||C,children:[S.isPending?(0,t.jsx)(at,{className:"size-4 animate-spin"}):(0,t.jsx)(EH,{className:"size-4"}),_?"Change photo":"Upload photo"]}),_?(0,t.jsxs)(F,{type:"button",variant:"outline",onClick:r(()=>j.mutate(),"onClick"),disabled:C,children:[j.isPending?(0,t.jsx)(at,{className:"size-4 animate-spin"}):(0,t.jsx)(Ia,{className:"size-4"}),"Remove"]}):null]})]}),(0,t.jsxs)("div",{className:"min-w-0 flex-1 space-y-2 pb-1",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"truncate text-2xl font-semibold text-foreground",children:N}),(0,t.jsx)("p",{className:"truncate text-sm text-muted-foreground",children:f.data.user.email??"No email"})]}),(0,t.jsxs)("p",{className:"max-w-2xl text-sm leading-6 text-muted-foreground",children:["Click the avatar to upload a new image. ",A]})]})]})})]}),(0,t.jsxs)("form",{className:"grid gap-6 md:grid-cols-2",onSubmit:r(T=>{T.preventDefault(),w.mutate({name:y(),image:d.trim()||null})},"onSubmit"),children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(Qs,{htmlFor:"profile-name",children:"Display name"}),(0,t.jsx)(At,{id:"profile-name",value:l,onChange:r(T=>c(T.target.value),"onChange"),maxLength:120,placeholder:"Board"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Shown in the sidebar account footer and comment author surfaces."})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(Qs,{htmlFor:"profile-email",children:"Email"}),(0,t.jsx)(At,{id:"profile-email",value:f.data.user.email??"",readOnly:!0,disabled:!0}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Email is managed by your auth session and is read-only here."})]}),(0,t.jsx)("div",{className:"md:col-span-2 flex justify-end",children:(0,t.jsxs)(F,{type:"submit",disabled:C||!l.trim(),children:[w.isPending?(0,t.jsx)(at,{className:"size-4 animate-spin"}):(0,t.jsx)(Qp,{className:"size-4"}),w.isPending?"Saving...":"Save profile"]})})]}),(0,t.jsx)(AUt,{companyId:s})]})]})}r(TUt,"ProfileSettings");function EUt(e){return e?e.split(/\r?\n/).map(s=>s.trim()).find(Boolean)??null:null}r(EUt,"firstNonEmptyLine");function Hoe(e){return EUt(e.lastError)??"Plugin entered an error state without a stored error message."}r(Hoe,"getPluginErrorSummary");function Qoe(e){if(e.bundledExperimental)return!0;const s=e.packageName??"",n=e.packagePath??"";return s.includes("sandbox")||n.includes("sandbox")?!0:e.manifestJson?.environmentDrivers?.some(a=>a.kind==="sandbox_provider")===!0}r(Qoe,"isExperimentalPluginIdentity");function Goe(){return(0,t.jsx)(lt,{variant:"outline",className:"border-amber-500/30 bg-amber-500/10 text-amber-700 hover:bg-amber-500/10 dark:text-amber-200",children:"Experimental"})}r(Goe,"ExperimentalBadge");function PUt(){const{selectedCompany:e}=ps(),{setBreadcrumbs:s}=qn(),n=Wt(),{pushToast:a}=pa(),[i,o]=(0,u.useState)(""),[l,c]=(0,u.useState)(!1),[d,m]=(0,u.useState)(null),[h,p]=(0,u.useState)(""),[f,g]=(0,u.useState)(null);(0,u.useEffect)(()=>{s([{label:e?.name??"Organization",href:"/dashboard"},{label:"Settings",href:"/company/settings"},{label:"Plugins"}])},[e?.name,s]);const{data:v,isLoading:y,error:w}=Z({queryKey:P.plugins.all,queryFn:r(()=>el.list(),"queryFn")}),S=Z({queryKey:P.plugins.examples,queryFn:r(()=>el.listBundled(),"queryFn")}),j=r(()=>{n.invalidateQueries({queryKey:P.plugins.all}),n.invalidateQueries({queryKey:P.plugins.examples}),n.invalidateQueries({queryKey:P.plugins.uiContributions})},"invalidatePluginQueries"),N=Ne({mutationFn:r(E=>el.install(E),"mutationFn"),onSuccess:r(()=>{j(),c(!1),o(""),a({title:"Plugin installed successfully",tone:"success"})},"onSuccess"),onError:r(E=>{a({title:"Failed to install plugin",body:E.message,tone:"error"})},"onError")}),_=Ne({mutationFn:r(E=>el.uninstall(E),"mutationFn"),onSuccess:r(()=>{j(),a({title:"Plugin uninstalled successfully",tone:"success"})},"onSuccess"),onError:r(E=>{a({title:"Failed to uninstall plugin",body:E.message,tone:"error"})},"onError")}),R=Ne({mutationFn:r(E=>el.enable(E),"mutationFn"),onSuccess:r(()=>{j(),a({title:"Plugin enabled",tone:"success"})},"onSuccess"),onError:r(E=>{a({title:"Failed to enable plugin",body:E.message,tone:"error"})},"onError")}),C=Ne({mutationFn:r(E=>el.disable(E),"mutationFn"),onSuccess:r(()=>{j(),a({title:"Plugin disabled",tone:"info"})},"onSuccess"),onError:r(E=>{a({title:"Failed to disable plugin",body:E.message,tone:"error"})},"onError")}),A=v??[],T=S.data??[],I=new Map(A.map(E=>[E.packageName,E])),$=new Map(T.map(E=>[E.packageName,E])),O=N.variables?.isLocalPath?N.error?.message??null:null,L=(0,u.useMemo)(()=>new Map(A.map(E=>[E.id,Hoe(E)])),[A]);return y?(0,t.jsx)("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading plugins..."}):w?(0,t.jsx)("div",{className:"p-4 text-sm text-destructive",children:"Failed to load plugins."}):(0,t.jsxs)("div",{className:"max-w-6xl space-y-6",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Dg,{className:"h-6 w-6 text-muted-foreground"}),(0,t.jsx)("h1",{className:"text-xl font-semibold",children:"Plugin Manager"})]}),(0,t.jsxs)(Ys,{open:l,onOpenChange:c,children:[(0,t.jsx)(Cv,{asChild:!0,children:(0,t.jsxs)(F,{size:"sm",className:"gap-2",children:[(0,t.jsx)(gn,{className:"h-4 w-4"}),"Install Plugin"]})}),(0,t.jsxs)(Js,{children:[(0,t.jsxs)(Cn,{children:[(0,t.jsx)(tn,{children:"Install Plugin"}),(0,t.jsx)(Ln,{children:"Enter the npm package name of the plugin you wish to install."})]}),(0,t.jsx)("div",{className:"grid gap-4 py-4",children:(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)(Qs,{htmlFor:"packageName",children:"npm Package Name"}),(0,t.jsx)(At,{id:"packageName",placeholder:"@tickernelz/paperclip-pro-plugin-example",value:i,onChange:r(E=>o(E.target.value),"onChange")})]})}),(0,t.jsxs)(yr,{children:[(0,t.jsx)(F,{variant:"outline",onClick:r(()=>c(!1),"onClick"),children:"Cancel"}),(0,t.jsx)(F,{onClick:r(()=>N.mutate({packageName:i}),"onClick"),disabled:!i||N.isPending,children:N.isPending?"Installing...":"Install"})]})]})]})]}),(0,t.jsx)("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 px-4 py-3",children:(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)(Is,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-700"}),(0,t.jsxs)("div",{className:"space-y-1 text-sm",children:[(0,t.jsx)("p",{className:"font-medium text-foreground",children:"Plugins are alpha."}),(0,t.jsx)("p",{className:"text-muted-foreground",children:"The plugin runtime and API surface are still changing. Expect breaking changes while this feature settles."})]})]})}),(0,t.jsxs)("section",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(em,{className:"h-5 w-5 text-muted-foreground"}),(0,t.jsx)("h2",{className:"text-base font-semibold",children:"Available Plugins"}),(0,t.jsx)(lt,{variant:"outline",children:"Bundled"})]}),O&&(0,t.jsx)("div",{className:"rounded-md border border-destructive/25 bg-destructive/[0.06] px-4 py-3 text-sm text-destructive whitespace-pre-wrap break-words",children:O}),S.isLoading?(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:"Loading bundled plugins..."}):S.error?(0,t.jsx)("div",{className:"text-sm text-destructive",children:"Failed to load bundled plugins."}):T.length===0?(0,t.jsx)("div",{className:"rounded-md border border-dashed px-4 py-3 text-sm text-muted-foreground",children:"No bundled plugins were found in this checkout."}):(0,t.jsx)(Xs,{className:"block py-0",children:(0,t.jsx)("ul",{className:"divide-y",children:T.map(E=>{const q=I.get(E.packageName),B=N.isPending&&N.variables?.isLocalPath&&N.variables.packageName===E.localPath;return(0,t.jsx)("li",{children:(0,t.jsxs)("div",{className:"flex items-center gap-4 px-4 py-3",children:[(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("span",{className:"font-medium",children:E.displayName}),(0,t.jsx)(lt,{variant:"outline",children:E.tag==="first-party"?"First-party":"Example"}),Qoe({packageName:E.packageName,packagePath:E.localPath,bundledExperimental:E.experimental})&&(0,t.jsx)(Goe,{}),q?(0,t.jsx)(lt,{variant:q.status==="ready"?"default":"secondary",className:q.status==="ready"?"bg-green-600 hover:bg-green-700":"",children:q.status}):(0,t.jsx)(lt,{variant:"secondary",children:"Not installed"})]}),(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:E.description}),(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:E.packageName}),B&&!E.hasBuiltEntrypoints&&(0,t.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Building plugin..."})]}),(0,t.jsx)("div",{className:"flex items-center gap-2 shrink-0",children:q?(0,t.jsxs)(t.Fragment,{children:[q.status!=="ready"&&(0,t.jsx)(F,{variant:"outline",size:"sm",disabled:R.isPending,onClick:r(()=>R.mutate(q.id),"onClick"),children:"Enable"}),(0,t.jsx)(F,{variant:"outline",size:"sm",asChild:!0,children:(0,t.jsx)(Je,{to:`/company/settings/instance/plugins/${q.id}`,children:q.status==="ready"?"Open Settings":"Review"})})]}):(0,t.jsx)(F,{size:"sm",disabled:B||N.isPending,onClick:r(()=>N.mutate({packageName:E.localPath,isLocalPath:!0}),"onClick"),children:B?"Installing...":"Install"})})]})},E.packageName)})})})]}),(0,t.jsxs)("section",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Dg,{className:"h-5 w-5 text-muted-foreground"}),(0,t.jsx)("h2",{className:"text-base font-semibold",children:"Installed Plugins"})]}),A.length?(0,t.jsx)(Xs,{className:"block py-0",children:(0,t.jsx)("ul",{className:"divide-y",children:A.map(E=>(0,t.jsx)("li",{children:(0,t.jsxs)("div",{className:"flex items-start gap-4 px-4 py-3",children:[(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(Je,{to:`/company/settings/instance/plugins/${E.id}`,className:"font-medium hover:underline truncate block",title:E.manifestJson.displayName??E.packageName,children:E.manifestJson.displayName??E.packageName}),$.has(E.packageName)&&(0,t.jsx)(lt,{variant:"outline",children:$.get(E.packageName)?.tag==="first-party"?"First-party":"Example"}),Qoe({packageName:E.packageName,packagePath:E.packagePath,manifestJson:E.manifestJson,bundledExperimental:$.get(E.packageName)?.experimental})&&(0,t.jsx)(Goe,{})]}),(0,t.jsx)("div",{children:(0,t.jsxs)("p",{className:"text-xs text-muted-foreground mt-0.5 truncate",title:E.packageName,children:[E.packageName," · v",E.manifestJson.version??E.version]})}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground truncate mt-0.5",title:E.manifestJson.description,children:E.manifestJson.description||"No description provided."}),E.status==="error"&&(0,t.jsx)("div",{className:"mt-3 rounded-md border border-red-500/25 bg-red-500/[0.06] px-3 py-2",children:(0,t.jsxs)("div",{className:"flex flex-wrap items-start gap-3",children:[(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium text-red-700 dark:text-red-300",children:[(0,t.jsx)(Is,{className:"h-4 w-4 shrink-0"}),(0,t.jsx)("span",{children:"Plugin error"})]}),(0,t.jsx)("p",{className:"mt-1 text-sm text-red-700/90 dark:text-red-200/90 break-words",title:E.lastError??void 0,children:L.get(E.id)})]}),(0,t.jsx)(F,{variant:"outline",size:"sm",className:"border-red-500/30 bg-background/60 text-red-700 hover:bg-red-500/10 hover:text-red-800 dark:text-red-200 dark:hover:text-red-100",onClick:r(()=>g(E),"onClick"),children:"View full error"})]})})]}),(0,t.jsx)("div",{className:"flex shrink-0 self-center",children:(0,t.jsxs)("div",{className:"flex flex-col items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(lt,{variant:E.status==="ready"?"default":E.status==="error"?"destructive":"secondary",className:U("shrink-0",E.status==="ready"?"bg-green-600 hover:bg-green-700":""),children:E.status}),(0,t.jsx)(F,{variant:"outline",size:"icon-sm",className:"h-8 w-8",title:E.status==="ready"?"Disable":"Enable",onClick:r(()=>{E.status==="ready"?C.mutate(E.id):R.mutate(E.id)},"onClick"),disabled:R.isPending||C.isPending,children:(0,t.jsx)(Uz,{className:U("h-4 w-4",E.status==="ready"?"text-green-600":"")})}),(0,t.jsx)(F,{variant:"outline",size:"icon-sm",className:"h-8 w-8 text-destructive hover:text-destructive",title:"Uninstall",onClick:r(()=>{m(E.id),p(E.manifestJson.displayName??E.packageName)},"onClick"),disabled:_.isPending,children:(0,t.jsx)(NPe,{className:"h-4 w-4"})})]}),(0,t.jsx)(F,{variant:"outline",size:"sm",className:"mt-2 h-8",asChild:!0,children:(0,t.jsxs)(Je,{to:`/company/settings/instance/plugins/${E.id}`,children:[(0,t.jsx)($d,{className:"h-4 w-4"}),"Configure"]})})]})})]})},E.id))})}):(0,t.jsx)(Xs,{className:"bg-muted/30",children:(0,t.jsxs)(Wa,{className:"flex flex-col items-center justify-center py-10",children:[(0,t.jsx)(Dg,{className:"h-10 w-10 text-muted-foreground mb-4"}),(0,t.jsx)("p",{className:"text-sm font-medium",children:"No plugins installed"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:"Install a plugin to extend functionality."})]})})]}),(0,t.jsx)(Ys,{open:d!==null,onOpenChange:r(E=>{E||m(null)},"onOpenChange"),children:(0,t.jsxs)(Js,{children:[(0,t.jsxs)(Cn,{children:[(0,t.jsx)(tn,{children:"Uninstall Plugin"}),(0,t.jsxs)(Ln,{children:["Are you sure you want to uninstall ",(0,t.jsx)("strong",{children:h}),"? This action cannot be undone."]})]}),(0,t.jsxs)(yr,{children:[(0,t.jsx)(F,{variant:"outline",onClick:r(()=>m(null),"onClick"),children:"Cancel"}),(0,t.jsx)(F,{variant:"destructive",disabled:_.isPending,onClick:r(()=>{d&&_.mutate(d,{onSettled:r(()=>m(null),"onSettled")})},"onClick"),children:_.isPending?"Uninstalling...":"Uninstall"})]})]})}),(0,t.jsx)(Ys,{open:f!==null,onOpenChange:r(E=>{E||g(null)},"onOpenChange"),children:(0,t.jsxs)(Js,{className:"sm:max-w-2xl",children:[(0,t.jsxs)(Cn,{children:[(0,t.jsx)(tn,{children:"Error Details"}),(0,t.jsxs)(Ln,{children:[f?.manifestJson.displayName??f?.packageName??"Plugin"," hit an error state."]})]}),(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)("div",{className:"rounded-md border border-red-500/25 bg-red-500/[0.06] px-4 py-3",children:(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)(Is,{className:"mt-0.5 h-4 w-4 shrink-0 text-red-700 dark:text-red-300"}),(0,t.jsxs)("div",{className:"space-y-1 text-sm",children:[(0,t.jsx)("p",{className:"font-medium text-red-700 dark:text-red-300",children:"What errored"}),(0,t.jsx)("p",{className:"text-red-700/90 dark:text-red-200/90 break-words",children:f?Hoe(f):"No error summary available."})]})]})}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:"Full error output"}),(0,t.jsx)("pre",{className:"max-h-(--sz-50vh) overflow-auto rounded-md border bg-muted/40 p-3 text-xs leading-5 whitespace-pre-wrap break-words",children:f?.lastError??"No stored error message."})]})]}),(0,t.jsx)(yr,{children:(0,t.jsx)(F,{variant:"outline",onClick:r(()=>g(null),"onClick"),children:"Close"})})]})})]})}r(PUt,"PluginManager");function MUt(){const{selectedCompany:e,selectedCompanyId:s}=ps(),{setBreadcrumbs:n}=qn(),{companyPrefix:a,pluginId:i}=Sa(),{hideHostPaths:o}=Y1(),[l,c]=(0,u.useState)("configuration"),{data:d,isLoading:m}=Z({queryKey:P.plugins.detail(i),queryFn:r(()=>el.get(i),"queryFn"),enabled:!!i}),{data:h,isLoading:p}=Z({queryKey:P.plugins.health(i),queryFn:r(()=>el.health(i),"queryFn"),enabled:!!i&&d?.status==="ready",refetchInterval:3e4}),{data:f}=Z({queryKey:P.plugins.dashboard(i),queryFn:r(()=>el.dashboard(i),"queryFn"),enabled:!!i,refetchInterval:3e4}),{data:g}=Z({queryKey:P.plugins.logs(i),queryFn:r(()=>el.logs(i,{limit:50}),"queryFn"),enabled:!!i&&d?.status==="ready",refetchInterval:3e4}),v=d?.manifestJson?.instanceConfigSchema,y=v&&v.properties&&Object.keys(v.properties).length>0,w=i&&s?P.plugins.config(i,s):["plugins",i??"__missing_plugin__","companies","__missing_company__","config"],{data:S,isLoading:j}=Z({queryKey:w,queryFn:r(()=>el.getConfig(i,s),"queryFn"),enabled:!!i&&!!y&&!!s}),{slots:N}=Gc({slotTypes:["settingsPage"],companyId:s,enabled:!!s}),_=N.filter(q=>q.pluginId===i),R=_.length>0;if((0,u.useEffect)(()=>{n([{label:e?.name??"Organization",href:"/dashboard"},{label:"Settings",href:"/company/settings"},{label:"Plugins",href:"/company/settings/instance/plugins"},{label:d?.manifestJson?.displayName??d?.packageName??"Plugin Details"}])},[e?.name,n,a,d]),(0,u.useEffect)(()=>{c("configuration")},[i]),m)return(0,t.jsx)("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading plugin details..."});if(!d)return(0,t.jsx)(kn,{to:"/company/settings/instance/plugins",replace:!0});const C=d.status,A=d.status==="ready"?"default":d.status==="error"?"destructive":"secondary",T=d.manifestJson.description||"No description provided.",I=d.manifestJson.capabilities??[],$=d.manifestJson.environmentDrivers??[],O=d.manifestJson.localFolders??[],L=O.length>0&&!o,E=$.map(q=>q.displayName?.trim()||q.driverKey).filter((q,B,K)=>K.indexOf(q)===B).join(", ");return(0,t.jsxs)("div",{className:"max-w-6xl space-y-6",children:[(0,t.jsxs)("div",{className:"flex items-center gap-4",children:[(0,t.jsx)(Je,{to:"/company/settings/instance/plugins",children:(0,t.jsx)(F,{variant:"outline",size:"icon",className:"h-8 w-8",children:(0,t.jsx)(Sl,{className:"h-4 w-4"})})}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Dg,{className:"h-6 w-6 text-muted-foreground"}),(0,t.jsx)("h1",{className:"text-xl font-semibold",children:d.manifestJson.displayName??d.packageName}),(0,t.jsx)(lt,{variant:A,className:"ml-2",children:C}),(0,t.jsxs)(lt,{variant:"outline",className:"ml-1",children:["v",d.manifestJson.version??d.version]})]})]}),(0,t.jsxs)(Ni,{value:l,onValueChange:r(q=>c(q),"onValueChange"),className:"space-y-6",children:[(0,t.jsx)(ac,{align:"start",items:[{value:"configuration",label:"Configuration"},{value:"status",label:"Status"}],value:l,onValueChange:r(q=>c(q),"onValueChange")}),(0,t.jsx)(da,{value:"configuration",className:"space-y-6",children:(0,t.jsxs)("div",{className:"space-y-8",children:[(0,t.jsxs)("section",{className:"space-y-5",children:[(0,t.jsx)("h2",{className:"text-base font-semibold",children:"About"}),(0,t.jsxs)("div",{className:"grid gap-8 lg:grid-cols-(--gtc-52)",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"Description"}),(0,t.jsx)("p",{className:"text-sm leading-6 text-foreground/90",children:T})]}),(0,t.jsxs)("div",{className:"space-y-4 text-sm",children:[(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)("h3",{className:"font-medium text-muted-foreground",children:"Author"}),(0,t.jsx)("p",{className:"text-foreground",children:d.manifestJson.author})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("h3",{className:"font-medium text-muted-foreground",children:"Categories"}),(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:d.categories.length>0?d.categories.map(q=>(0,t.jsx)(lt,{variant:"outline",className:"capitalize",children:q},q)):(0,t.jsx)("span",{className:"text-foreground",children:"None"})})]})]})]})]}),(0,t.jsx)(hl,{}),(0,t.jsxs)("section",{className:"space-y-4",children:[(0,t.jsx)("div",{className:"space-y-1",children:(0,t.jsx)("h2",{className:"text-base font-semibold",children:"Settings"})}),L?(0,t.jsx)(DUt,{pluginId:i,companyId:s,declarations:O}):null,R?(0,t.jsx)("div",{className:"space-y-3",children:_.map(q=>(0,t.jsx)(yu,{slot:q,context:{companyId:s,companyPrefix:a??null},missingBehavior:"placeholder"},`${q.pluginKey}:${q.id}`))}):y?(0,t.jsx)(BUt,{pluginId:i,companyId:s,schema:v,initialValues:S?.configJson,isLoading:j,pluginStatus:d.status,supportsConfigTest:d.supportsConfigTest===!0}):$.length>0?(0,t.jsxs)("div",{className:"rounded-md border border-border/60 bg-muted/20 px-4 py-3 text-sm",children:[(0,t.jsx)("p",{className:"font-medium text-foreground",children:"Configure this plugin from Settings → Environments."}),(0,t.jsxs)("p",{className:"mt-1 text-muted-foreground",children:[E||"This plugin"," registers environment runtime settings there so the execution target stays instance-scoped while secret bindings still resolve through the selected organization context."]}),(0,t.jsx)("div",{className:"mt-3",children:(0,t.jsx)(Je,{to:"/company/settings/instance/environments",children:(0,t.jsx)(F,{variant:"outline",size:"sm",children:"Open Environments"})})})]}):L?null:(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"This plugin does not require any settings."})]})]})}),(0,t.jsx)(da,{value:"status",className:"space-y-6",children:(0,t.jsxs)("div",{className:"grid gap-6 xl:grid-cols-(--gtc-39)",children:[(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)(Xs,{children:[(0,t.jsxs)(Xi,{children:[(0,t.jsxs)(uo,{className:"text-base flex items-center gap-1.5",children:[(0,t.jsx)($m,{className:"h-4 w-4"}),"Runtime Dashboard"]}),(0,t.jsx)(Nl,{children:"Worker process, scheduled jobs, and webhook deliveries"})]}),(0,t.jsx)(Wa,{className:"space-y-6",children:f?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("h3",{className:"text-sm font-medium mb-3 flex items-center gap-1.5",children:[(0,t.jsx)($m,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Worker Process"]}),f.worker?(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"Status"}),(0,t.jsx)(lt,{variant:f.worker.status==="running"?"default":"secondary",children:f.worker.status})]}),(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"PID"}),(0,t.jsx)("span",{className:"font-mono text-xs",children:f.worker.pid??"—"})]}),(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"Uptime"}),(0,t.jsx)("span",{className:"text-xs",children:qUt(f.worker.uptime)})]}),(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"Pending RPCs"}),(0,t.jsx)("span",{className:"text-xs",children:f.worker.pendingRequests})]}),f.worker.totalCrashes>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex justify-between col-span-2",children:[(0,t.jsxs)("span",{className:"text-muted-foreground flex items-center gap-1",children:[(0,t.jsx)(Is,{className:"h-3 w-3 text-amber-500"}),"Crashes"]}),(0,t.jsxs)("span",{className:"text-xs",children:[f.worker.consecutiveCrashes," consecutive / ",f.worker.totalCrashes," total"]})]}),f.worker.lastCrashAt&&(0,t.jsxs)("div",{className:"flex justify-between col-span-2",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"Last Crash"}),(0,t.jsx)("span",{className:"text-xs",children:zUt(f.worker.lastCrashAt)})]})]})]}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground italic",children:"No worker process registered."})]}),(0,t.jsx)(hl,{}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("h3",{className:"text-sm font-medium mb-3 flex items-center gap-1.5",children:[(0,t.jsx)(Qg,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Recent Job Runs"]}),f.recentJobRuns.length>0?(0,t.jsx)("div",{className:"space-y-2",children:f.recentJobRuns.map(q=>(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2 rounded-md bg-muted/50 px-2 py-1.5 text-sm",children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,t.jsx)(UUt,{status:q.status}),(0,t.jsx)("span",{className:"truncate font-mono text-xs",title:q.jobKey??q.jobId,children:q.jobKey??q.jobId.slice(0,8)}),(0,t.jsx)(lt,{variant:"outline",className:"px-1 py-0 text-(length:--text-nano)",children:q.trigger})]}),(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-2 text-xs text-muted-foreground",children:[q.durationMs!=null?(0,t.jsx)("span",{children:Joe(q.durationMs)}):null,(0,t.jsx)("span",{title:q.createdAt,children:Xoe(q.createdAt)})]})]},q.id))}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground italic",children:"No job runs recorded yet."})]}),(0,t.jsx)(hl,{}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("h3",{className:"text-sm font-medium mb-3 flex items-center gap-1.5",children:[(0,t.jsx)(Hz,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Recent Webhook Deliveries"]}),f.recentWebhookDeliveries.length>0?(0,t.jsx)("div",{className:"space-y-2",children:f.recentWebhookDeliveries.map(q=>(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2 rounded-md bg-muted/50 px-2 py-1.5 text-sm",children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,t.jsx)(KUt,{status:q.status}),(0,t.jsx)("span",{className:"truncate font-mono text-xs",title:q.webhookKey,children:q.webhookKey})]}),(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-2 text-xs text-muted-foreground",children:[q.durationMs!=null?(0,t.jsx)("span",{children:Joe(q.durationMs)}):null,(0,t.jsx)("span",{title:q.createdAt,children:Xoe(q.createdAt)})]})]},q.id))}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground italic",children:"No webhook deliveries recorded yet."})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 border-t border-border/50 pt-2 text-xs text-muted-foreground",children:[(0,t.jsx)(eo,{className:"h-3 w-3"}),"Last checked: ",new Date(f.checkedAt).toLocaleTimeString()]})]}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Runtime diagnostics are unavailable right now."})})]}),g&&g.length>0?(0,t.jsxs)(Xs,{children:[(0,t.jsxs)(Xi,{children:[(0,t.jsxs)(uo,{className:"text-base flex items-center gap-1.5",children:[(0,t.jsx)(DH,{className:"h-4 w-4"}),"Recent Logs"]}),(0,t.jsxs)(Nl,{children:["Last ",g.length," log entries"]})]}),(0,t.jsx)(Wa,{children:(0,t.jsx)("div",{className:"max-h-64 space-y-1 overflow-y-auto font-mono text-xs",children:g.map(q=>(0,t.jsxs)("div",{className:`flex gap-2 py-0.5 ${q.level==="error"?"text-destructive":q.level==="warn"?"text-yellow-600 dark:text-yellow-400":q.level==="debug"?"text-muted-foreground/60":"text-muted-foreground"}`,children:[(0,t.jsx)("span",{className:"shrink-0 text-muted-foreground/50",children:new Date(q.createdAt).toLocaleTimeString()}),(0,t.jsx)(lt,{variant:"outline",className:"h-4 shrink-0 px-1 text-(length:--text-nano)",children:q.level}),(0,t.jsx)("span",{className:"truncate",title:q.message,children:q.message})]},q.id))})})]}):null]}),(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)(Xs,{children:[(0,t.jsx)(Xi,{children:(0,t.jsxs)(uo,{className:"text-base flex items-center gap-1.5",children:[(0,t.jsx)(DH,{className:"h-4 w-4"}),"Health Status"]})}),(0,t.jsx)(Wa,{children:p?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Checking health..."}):h?(0,t.jsxs)("div",{className:"space-y-4 text-sm",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"Overall"}),(0,t.jsx)(lt,{variant:h.healthy?"default":"destructive",children:h.status})]}),h.checks.length>0?(0,t.jsx)("div",{className:"space-y-2 border-t border-border/50 pt-2",children:h.checks.map((q,B)=>(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsx)("span",{className:"truncate text-muted-foreground",title:q.name,children:q.name}),q.passed?(0,t.jsx)(j3e,{className:"h-4 w-4 shrink-0 text-green-500"}):(0,t.jsx)(rc,{className:"h-4 w-4 shrink-0 text-destructive"})]},B))}):null,h.lastError?(0,t.jsx)("div",{className:"break-words rounded border border-destructive/20 bg-destructive/10 p-2 text-xs text-destructive",children:h.lastError}):null]}):(0,t.jsxs)("div",{className:"space-y-3 text-sm text-muted-foreground",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{children:"Lifecycle"}),(0,t.jsx)(lt,{variant:A,children:C})]}),(0,t.jsx)("p",{children:"Health checks run once the plugin is ready."}),d.lastError?(0,t.jsx)("div",{className:"break-words rounded border border-destructive/20 bg-destructive/10 p-2 text-xs text-destructive",children:d.lastError}):null]})})]}),(0,t.jsxs)(Xs,{children:[(0,t.jsx)(Xi,{children:(0,t.jsx)(uo,{className:"text-base",children:"Details"})}),(0,t.jsxs)(Wa,{className:"space-y-3 text-sm text-muted-foreground",children:[(0,t.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,t.jsx)("span",{children:"Plugin ID"}),(0,t.jsx)("span",{className:"font-mono text-xs text-right",children:d.id})]}),(0,t.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,t.jsx)("span",{children:"Plugin Key"}),(0,t.jsx)("span",{className:"font-mono text-xs text-right",children:d.pluginKey})]}),(0,t.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,t.jsx)("span",{children:"NPM Package"}),(0,t.jsx)("span",{className:"max-w-(--sz-170px) truncate text-right text-xs",title:d.packageName,children:d.packageName})]}),(0,t.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,t.jsx)("span",{children:"Version"}),(0,t.jsxs)("span",{className:"text-right text-foreground",children:["v",d.manifestJson.version??d.version]})]})]})]}),(0,t.jsxs)(Xs,{children:[(0,t.jsx)(Xi,{children:(0,t.jsxs)(uo,{className:"text-base flex items-center gap-1.5",children:[(0,t.jsx)(kl,{className:"h-4 w-4"}),"Permissions"]})}),(0,t.jsx)(Wa,{children:I.length>0?(0,t.jsx)("ul",{className:"space-y-2 text-sm text-muted-foreground",children:I.map(q=>(0,t.jsx)("li",{className:"rounded-md bg-muted/40 px-2.5 py-2 font-mono text-xs text-foreground/85",children:q},q))}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground italic",children:"No special permissions requested."})})]})]})]})})]})]})}r(MUt,"PluginSettings");function DUt({pluginId:e,companyId:s,declarations:n}){const{data:a,isLoading:i,error:o}=Z({queryKey:s?P.plugins.localFolders(e,s):["plugins",e,"companies","none","local-folders"],queryFn:r(()=>el.listLocalFolders(e,s),"queryFn"),enabled:!!s}),l=new Map((a?.folders??[]).map(c=>[c.folderKey,c]));return s?(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Co,{className:"h-4 w-4 text-muted-foreground"}),(0,t.jsx)("h3",{className:"text-sm font-medium",children:"Local folders"})]}),o?(0,t.jsx)("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:o.message||"Failed to load local folder settings."}):null,i?(0,t.jsxs)("div",{className:"flex items-center gap-2 py-3 text-sm text-muted-foreground",children:[(0,t.jsx)(at,{className:"h-4 w-4 animate-spin"}),"Loading local folders..."]}):(0,t.jsx)("div",{className:"space-y-3",children:n.map(c=>(0,t.jsx)(LUt,{pluginId:e,companyId:s,declaration:c,status:l.get(c.folderKey)},c.folderKey))})]}):(0,t.jsx)("div",{className:"rounded-md border border-border/60 bg-muted/20 px-4 py-3 text-sm text-muted-foreground",children:"Select an organization to configure this plugin's local folders."})}r(DUt,"PluginLocalFoldersSettings");function LUt({pluginId:e,companyId:s,declaration:n,status:a}){const i=Wt(),o=a?.path??"",[l,c]=(0,u.useState)(o),[d,m]=(0,u.useState)(null);(0,u.useEffect)(()=>{c(o),m(null)},[o,n.folderKey]);const h=Ne({mutationFn:r(y=>el.configureLocalFolder(e,s,n.folderKey,{path:y,access:n.access,requiredDirectories:n.requiredDirectories,requiredFiles:n.requiredFiles}),"mutationFn"),onSuccess:r(y=>{m({type:y.healthy?"success":"error",text:y.healthy?"Local folder saved.":"Local folder saved, but validation still needs attention."}),i.invalidateQueries({queryKey:P.plugins.localFolders(e,s)})},"onSuccess"),onError:r(y=>{m({type:"error",text:y.message||"Failed to save local folder."})},"onError")}),p=l.trim(),f=p!==o,g=a?.access??n.access??"readWrite",v=(0,u.useCallback)(()=>{if(!p){m({type:"error",text:"Local folder path is required."});return}if(!FUt(p)){m({type:"error",text:"Local folder must be a full absolute path."});return}m(null),h.mutate(p)},[h,p]);return(0,t.jsxs)("div",{className:"space-y-4 rounded-md border border-border/70 bg-background px-4 py-4",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,t.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("h4",{className:"text-sm font-medium",children:n.displayName}),(0,t.jsx)(lt,{variant:"outline",className:"font-mono text-(length:--text-nano)",children:n.folderKey}),(0,t.jsx)(lt,{variant:a?.healthy?"default":"secondary",children:a?.healthy?"Healthy":"Needs attention"})]}),n.description?(0,t.jsx)("p",{className:"max-w-3xl text-sm leading-5 text-muted-foreground",children:n.description}):null]}),(0,t.jsx)(lt,{variant:g==="readWrite"?"default":"outline",children:g==="readWrite"?"Read/write":"Read only"})]}),(0,t.jsxs)("div",{className:"grid gap-3 text-sm sm:grid-cols-3",children:[(0,t.jsx)(nO,{label:"Configured",value:a?.configured?"Yes":"No",ok:!!a?.configured}),(0,t.jsx)(nO,{label:"Readable",value:a?.readable?"Yes":"No",ok:!!a?.readable}),(0,t.jsx)(nO,{label:"Writable",value:g==="read"?"Not requested":a?.writable?"Yes":"No",ok:g==="read"||!!a?.writable})]}),a?.path?(0,t.jsxs)("div",{className:"space-y-1 text-sm",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:"Configured path"}),(0,t.jsx)("div",{className:"break-all rounded-md bg-muted/60 px-2 py-1.5 font-mono text-xs text-foreground",children:a.path})]}):null,(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)("label",{className:"text-xs font-medium text-muted-foreground",htmlFor:`local-folder-${n.folderKey}`,children:"Local folder path"}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("input",{id:`local-folder-${n.folderKey}`,className:"min-w-0 flex-1 rounded-md border border-border bg-background px-2.5 py-1.5 font-mono text-sm outline-none focus:border-foreground/40 focus:ring-2 focus:ring-ring/20",value:l,onChange:r(y=>{c(y.target.value),m(null)},"onChange"),placeholder:"/absolute/path/to/folder"}),(0,t.jsx)(fd,{className:"h-8"}),(0,t.jsxs)(F,{size:"sm",onClick:v,disabled:h.isPending||!f||!s,children:[h.isPending?(0,t.jsx)(at,{className:"h-3.5 w-3.5 animate-spin"}):(0,t.jsx)(Qp,{className:"h-3.5 w-3.5"}),"Save"]})]})]}),(0,t.jsx)($Ut,{status:a,declaration:n}),a?.problems?.length?(0,t.jsxs)("div",{className:"space-y-2 rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:[(0,t.jsx)("div",{className:"font-medium",children:"Validation problems"}),(0,t.jsx)("ul",{className:"space-y-1",children:a.problems.map((y,w)=>(0,t.jsxs)("li",{children:[y.message,y.path?(0,t.jsxs)("span",{className:"font-mono",children:[" ",y.path]}):null]},`${y.code}:${y.path??""}:${w}`))})]}):null,d?(0,t.jsx)("div",{className:`rounded-md border px-3 py-2 text-sm ${d.type==="success"?"border-green-200 bg-green-50 text-green-700 dark:border-green-900 dark:bg-green-950/30 dark:text-green-400":"border-destructive/20 bg-destructive/10 text-destructive"}`,children:d.text}):null]})}r(LUt,"PluginLocalFolderRow");function nO({label:e,value:s,ok:n}){return(0,t.jsxs)("div",{className:"flex items-center justify-between rounded-md border border-border/60 px-2.5 py-2",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:e}),(0,t.jsx)(lt,{variant:n?"default":"secondary",children:s})]})}r(nO,"FolderStatusMetric");function $Ut({status:e,declaration:s}){const n=e?.requiredDirectories??s.requiredDirectories??[],a=e?.requiredFiles??s.requiredFiles??[],i=e?.missingDirectories??n,o=e?.missingFiles??a,l=OUt(e);return n.length===0&&a.length===0?null:(0,t.jsxs)("div",{className:"grid gap-3 text-sm md:grid-cols-2",children:[(0,t.jsx)(Yoe,{title:"Required directories",items:n,missingItems:i,missingLabel:"Missing directories",inspectionUnavailable:l}),(0,t.jsx)(Yoe,{title:"Required files",items:a,missingItems:o,missingLabel:"Missing files",inspectionUnavailable:l})]})}r($Ut,"FolderRequirements");function OUt(e){return!e?.configured||e.readable?!1:e.problems.some(s=>s.code==="missing"||s.code==="not_readable"||s.code==="not_directory")}r(OUt,"isRootNotInspected");function Yoe({title:e,items:s,missingItems:n,missingLabel:a,inspectionUnavailable:i}){return(0,t.jsxs)("div",{className:"space-y-2 rounded-md border border-border/60 px-3 py-2",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:e}),i?(0,t.jsx)(lt,{variant:"secondary",className:"text-(length:--text-nano)",children:"Not inspected"}):n.length>0?(0,t.jsxs)(lt,{variant:"destructive",className:"text-(length:--text-nano)",children:[n.length," missing"]}):(0,t.jsx)(lt,{variant:"outline",className:"text-(length:--text-nano)",children:"Present"})]}),s.length>0?(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5",children:s.map(o=>{const l=n.includes(o);return(0,t.jsx)("span",{className:`rounded border px-1.5 py-0.5 font-mono text-(length:--text-micro) ${i?"border-amber-300/60 bg-amber-50 text-amber-700 dark:border-amber-800/70 dark:bg-amber-950/30 dark:text-amber-300":l?"border-destructive/30 bg-destructive/10 text-destructive":"border-border bg-muted/50 text-foreground/80"}`,children:o},o)})}):(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"None declared."}),i?(0,t.jsx)("p",{className:"text-xs text-amber-700 dark:text-amber-300",children:"Configured root was not inspected."}):n.length>0?(0,t.jsxs)("p",{className:"text-xs text-destructive",children:[a,": ",n.join(", ")]}):null]})}r(Yoe,"RequirementList");function FUt(e){return e.startsWith("/")||/^[A-Za-z]:[\\/]/.test(e)||e.startsWith("\\\\")}r(FUt,"isLikelyAbsolutePath");function BUt({pluginId:e,companyId:s,schema:n,initialValues:a,isLoading:i,pluginStatus:o,supportsConfigTest:l}){const c=Wt(),[d,m]=(0,u.useState)(()=>({...Up(n),...a??{}})),h=(0,u.useRef)(!1);(0,u.useEffect)(()=>{h.current=!1,m(Up(n))},[s,e,n]),(0,u.useEffect)(()=>{a&&!h.current&&(h.current=!0,m({...Up(n),...a}))},[a,n]);const[p,f]=(0,u.useState)({}),[g,v]=(0,u.useState)(null),[y,w]=(0,u.useState)(null),S=JSON.stringify(d)!==JSON.stringify({...Up(n),...a??{}}),j=Ne({mutationFn:r(A=>{if(!s)throw new Error("Select an organization before saving plugin configuration.");return el.saveConfig(e,s,A)},"mutationFn"),onSuccess:r(()=>{v({type:"success",text:"Configuration saved."}),w(null),s&&c.invalidateQueries({queryKey:P.plugins.config(e,s)}),setTimeout(()=>v(null),3e3)},"onSuccess"),onError:r(A=>{v({type:"error",text:A.message||"Failed to save configuration."})},"onError")}),N=Ne({mutationFn:r(A=>{if(!s)throw new Error("Select an organization before testing plugin configuration.");return el.testConfig(e,s,A)},"mutationFn"),onSuccess:r(A=>{A.valid?w({type:"success",text:"Configuration test passed."}):w({type:"error",text:A.message||"Configuration test failed."})},"onSuccess"),onError:r(A=>{w({type:"error",text:A.message||"Configuration test failed."})},"onError")}),_=(0,u.useCallback)(A=>{m(A),f({}),v(null)},[]),R=(0,u.useCallback)(()=>{const A=tv(n,d);if(Object.keys(A).length>0){f(A);return}f({}),j.mutate(d)},[n,d,j]),C=(0,u.useCallback)(()=>{const A=tv(n,d);if(Object.keys(A).length>0){f(A);return}f({}),w(null),N.mutate(d)},[n,d,N]);return i?(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-4",children:[(0,t.jsx)(at,{className:"h-4 w-4 animate-spin"}),"Loading configuration..."]}):(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)(M1,{schema:n,values:d,onChange:_,errors:p,disabled:j.isPending}),g&&(0,t.jsx)("div",{className:`text-sm p-2 rounded border ${g.type==="success"?"text-green-700 bg-green-50 border-green-200 dark:text-green-400 dark:bg-green-950/30 dark:border-green-900":"text-destructive bg-destructive/10 border-destructive/20"}`,children:g.text}),y&&(0,t.jsx)("div",{className:`text-sm p-2 rounded border ${y.type==="success"?"text-green-700 bg-green-50 border-green-200 dark:text-green-400 dark:bg-green-950/30 dark:border-green-900":"text-destructive bg-destructive/10 border-destructive/20"}`,children:y.text}),(0,t.jsxs)("div",{className:"flex items-center gap-2 pt-2",children:[(0,t.jsx)(F,{onClick:R,disabled:j.isPending||!S,size:"sm",children:j.isPending?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(at,{className:"h-3.5 w-3.5 animate-spin"}),"Saving..."]}):"Save Configuration"}),o==="ready"&&l&&(0,t.jsx)(F,{variant:"outline",onClick:C,disabled:N.isPending||!s,size:"sm",children:N.isPending?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(at,{className:"h-3.5 w-3.5 animate-spin"}),"Testing..."]}):"Test Configuration"})]})]})}r(BUt,"PluginConfigForm");function qUt(e){if(e==null)return"—";const s=Math.floor(e/1e3);if(s<60)return`${s}s`;const n=Math.floor(s/60);if(n<60)return`${n}m ${s%60}s`;const a=Math.floor(n/60);return a<24?`${a}h ${n%60}m`:`${Math.floor(a/24)}d ${a%24}h`}r(qUt,"formatUptime");function Joe(e){return e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${(e/6e4).toFixed(1)}m`}r(Joe,"formatDuration");function Xoe(e){const s=Date.now()-new Date(e).getTime();if(s<0)return"just now";const n=Math.floor(s/1e3);if(n<60)return`${n}s ago`;const a=Math.floor(n/60);if(a<60)return`${a}m ago`;const i=Math.floor(a/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}r(Xoe,"formatRelativeTime");function zUt(e){return new Date(e).toLocaleString()}r(zUt,"formatTimestamp");function UUt({status:e}){return(0,t.jsx)("span",{className:`inline-block h-2 w-2 rounded-full shrink-0 ${e==="success"||e==="succeeded"?"bg-green-500":e==="failed"?"bg-red-500":e==="running"?"bg-blue-500 animate-pulse":e==="cancelled"?"bg-gray-400":"bg-amber-500"}`,title:e})}r(UUt,"JobStatusDot");function KUt({status:e}){return(0,t.jsx)("span",{className:`inline-block h-2 w-2 rounded-full shrink-0 ${e==="processed"||e==="success"?"bg-green-500":e==="failed"?"bg-red-500":e==="received"?"bg-blue-500":"bg-amber-500"}`,title:e})}r(KUt,"DeliveryStatusDot");function rO({adapter:e,canRemove:s,onToggle:n,onRemove:a,onReload:i,onReinstall:o,isToggling:l,isReloading:c,isReinstalling:d,overriddenBy:m,toggleTitleEnabled:h,toggleTitleDisabled:p,disabledBadgeLabel:f}){return(0,t.jsx)("li",{children:(0,t.jsxs)("div",{className:"flex items-center gap-4 px-4 py-3",children:[(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("span",{className:U("font-medium",e.disabled&&"text-muted-foreground line-through"),children:e.label&&e.label!==e.type?e.label:mf(e.type)}),(0,t.jsx)(lt,{variant:"outline",children:e.source==="external"?"External":"Built-in"}),e.source==="external"&&(e.isLocalPath?(0,t.jsx)("span",{title:"Installed from local path",children:(0,t.jsx)(Co,{className:"h-4 w-4 text-amber-500"})}):(0,t.jsx)("span",{title:"Installed from npm",children:(0,t.jsx)(Eh,{className:"h-4 w-4 text-red-500"})})),e.version&&(0,t.jsxs)(lt,{variant:"secondary",className:"font-mono text-(length:--text-nano)",children:["v",e.version]}),e.overriddenBuiltin&&(0,t.jsx)(lt,{variant:"secondary",className:"text-blue-600 border-blue-400",children:"Overrides built-in"}),m&&(0,t.jsxs)(lt,{variant:"secondary",className:"text-blue-600 border-blue-400",children:["Overridden by ",m]}),e.disabled&&(0,t.jsx)(lt,{variant:"secondary",className:"text-amber-600 border-amber-400",children:f??"Hidden from menus"})]}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground mt-0.5",children:[e.type,e.packageName&&e.packageName!==e.type&&(0,t.jsxs)(t.Fragment,{children:[" · ",e.packageName]})," · ",e.modelsCount," models"]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[o&&(0,t.jsx)(F,{variant:"outline",size:"icon-sm",className:"h-8 w-8",title:"Reinstall adapter (pull latest from npm)",disabled:d,onClick:r(()=>o(e.type),"onClick"),children:(0,t.jsx)(Uo,{className:U("h-4 w-4",d&&"animate-bounce")})}),i&&(0,t.jsx)(F,{variant:"outline",size:"icon-sm",className:"h-8 w-8",title:"Reload adapter (hot-swap)",disabled:c,onClick:r(()=>i(e.type),"onClick"),children:(0,t.jsx)(qi,{className:U("h-4 w-4",c&&"animate-spin")})}),(0,t.jsx)(F,{variant:"outline",size:"icon-sm",className:"h-8 w-8",title:e.disabled?h??"Show in agent menus":p??"Hide from agent menus",disabled:l,onClick:r(()=>n(e.type,!e.disabled),"onClick"),children:(0,t.jsx)(Uz,{className:U("h-4 w-4",e.disabled?"text-muted-foreground":"text-green-600")})}),s&&(0,t.jsx)(F,{variant:"outline",size:"icon-sm",className:"h-8 w-8 text-destructive hover:text-destructive",title:"Remove adapter",onClick:r(()=>a(e.type),"onClick"),children:(0,t.jsx)(Ia,{className:"h-4 w-4"})})]})]})})}r(rO,"AdapterRow");function VUt(e){return fetch(`https://registry.npmjs.org/${encodeURIComponent(e)}/latest`,{signal:AbortSignal.timeout(5e3)}).then(s=>s.json()).then(s=>typeof s?.version=="string"?s.version:null).catch(()=>null)}r(VUt,"fetchNpmLatestVersion");function WUt({adapter:e,open:s,isReinstalling:n,onConfirm:a,onCancel:i}){const{data:o,isLoading:l}=Z({queryKey:["npm-latest-version",e?.packageName],queryFn:r(()=>e?.packageName?VUt(e.packageName):null,"queryFn"),enabled:s&&!!e?.packageName,staleTime:6e4}),c=e?.version&&o&&e.version===o;return(0,t.jsx)(Ys,{open:s,onOpenChange:r(d=>{d||i()},"onOpenChange"),children:(0,t.jsxs)(Js,{children:[(0,t.jsxs)(Cn,{children:[(0,t.jsx)(tn,{children:"Reinstall Adapter"}),(0,t.jsxs)(Ln,{children:["This will pull the latest version of"," ",(0,t.jsx)("strong",{children:e?.packageName})," from npm and hot-swap the running adapter module. Existing agents will use the new version on their next run."]})]}),(0,t.jsxs)("div",{className:"rounded-md border bg-muted/50 px-4 py-3 text-sm space-y-1",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"Package"}),(0,t.jsx)("span",{className:"font-mono",children:e?.packageName})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"Current"}),(0,t.jsx)("span",{className:"font-mono",children:e?.version?`v${e.version}`:"unknown"})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"Latest on npm"}),(0,t.jsx)("span",{className:"font-mono",children:l?"checking...":o?`v${o}`:"unavailable"})]}),c&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground pt-1",children:"Already on the latest version."})]}),(0,t.jsxs)(yr,{children:[(0,t.jsx)(F,{variant:"outline",onClick:i,disabled:n,children:"Cancel"}),(0,t.jsx)(F,{disabled:n,onClick:a,children:n?"Reinstalling...":"Reinstall"})]})]})})}r(WUt,"ReinstallDialog");function Zoe(){const{selectedCompany:e}=ps(),{setBreadcrumbs:s}=qn(),n=Wt(),{pushToast:a}=pa(),[i,o]=(0,u.useState)(""),[l,c]=(0,u.useState)(""),[d,m]=(0,u.useState)(!1),[h,p]=(0,u.useState)(!1),[f,g]=(0,u.useState)(null),[v,y]=(0,u.useState)(null);(0,u.useEffect)(()=>{s([{label:e?.name??"Organization",href:"/dashboard"},{label:"Settings",href:"/company/settings"},{label:"Adapters"}])},[e?.name,s]);const{data:w,isLoading:S}=Z({queryKey:P.adapters.all,queryFn:r(()=>Rm.list(),"queryFn")}),j=r(()=>{n.invalidateQueries({queryKey:P.adapters.all})},"invalidate"),N=Ne({mutationFn:r(E=>Rm.install(E),"mutationFn"),onSuccess:r(E=>{j(),p(!1),o(""),c(""),m(!1),a({title:"Adapter installed",body:`Type "${E.type}" registered successfully.${E.version?` (v${E.version})`:""}`,tone:"success"})},"onSuccess"),onError:r(E=>{a({title:"Install failed",body:E.message,tone:"error"})},"onError")}),_=Ne({mutationFn:r(E=>Rm.remove(E),"mutationFn"),onSuccess:r(()=>{j(),a({title:"Adapter removed",tone:"success"})},"onSuccess"),onError:r(E=>{a({title:"Removal failed",body:E.message,tone:"error"})},"onError")}),R=Ne({mutationFn:r(({type:E,disabled:q})=>Rm.setDisabled(E,q),"mutationFn"),onSuccess:r(()=>{j()},"onSuccess"),onError:r(E=>{a({title:"Toggle failed",body:E.message,tone:"error"})},"onError")}),C=Ne({mutationFn:r(({type:E,paused:q})=>Rm.setOverridePaused(E,q),"mutationFn"),onSuccess:r(()=>{j()},"onSuccess"),onError:r(E=>{a({title:"Override toggle failed",body:E.message,tone:"error"})},"onError")}),A=Ne({mutationFn:r(E=>Rm.reload(E),"mutationFn"),onSuccess:r(E=>{j(),$F(E.type),TY(E.type),a({title:"Adapter reloaded",body:`Type "${E.type}" reloaded.${E.version?` (v${E.version})`:""}`,tone:"success"})},"onSuccess"),onError:r(E=>{a({title:"Reload failed",body:E.message,tone:"error"})},"onError")}),T=Ne({mutationFn:r(E=>Rm.reinstall(E),"mutationFn"),onSuccess:r(E=>{j(),$F(E.type),TY(E.type),a({title:"Adapter reinstalled",body:`Type "${E.type}" updated from npm.${E.version?` (v${E.version})`:""}`,tone:"success"})},"onSuccess"),onError:r(E=>{a({title:"Reinstall failed",body:E.message,tone:"error"})},"onError")}),I=(w??[]).filter(E=>E.source==="builtin"),$=(w??[]).filter(E=>E.source==="external"),O=(w??[]).filter(E=>E.source==="external"&&E.overriddenBuiltin).filter(E=>!I.some(q=>q.type===E.type)).map(E=>({type:E.type,label:mf(E.type),overriddenBy:[E.packageName,E.version?`v${E.version}`:void 0].filter(Boolean).join(" "),overridePaused:!!E.overridePaused,menuDisabled:!!E.disabled}));if(S)return(0,t.jsx)("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading adapters..."});const L=N.isPending||_.isPending||R.isPending||C.isPending||A.isPending||T.isPending;return(0,t.jsxs)("div",{className:"max-w-6xl space-y-6",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)($m,{className:"h-6 w-6 text-muted-foreground"}),(0,t.jsx)("h1",{className:"text-xl font-semibold",children:"Adapters"}),(0,t.jsx)(lt,{variant:"outline",className:"text-amber-600 border-amber-400",children:"Alpha"})]}),(0,t.jsxs)(Ys,{open:h,onOpenChange:p,children:[(0,t.jsx)(Cv,{asChild:!0,children:(0,t.jsxs)(F,{size:"sm",className:"gap-2",children:[(0,t.jsx)(gn,{className:"h-4 w-4"}),"Install Adapter"]})}),(0,t.jsxs)(Js,{children:[(0,t.jsxs)(Cn,{children:[(0,t.jsx)(tn,{children:"Install External Adapter"}),(0,t.jsxs)(Ln,{children:["Add an adapter from npm or a local path. The adapter package must export ",(0,t.jsx)("code",{className:"text-xs bg-muted px-1 py-0.5 rounded",children:"createServerAdapter()"}),"."]})]}),(0,t.jsxs)("div",{className:"grid gap-4 py-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("button",{type:"button",className:U("inline-flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-xs transition-colors",d?"border-border text-muted-foreground hover:text-foreground hover:bg-accent/50":"border-foreground bg-accent text-foreground"),onClick:r(()=>m(!1),"onClick"),children:[(0,t.jsx)(Eh,{className:"h-3.5 w-3.5"}),"npm package"]}),(0,t.jsxs)("button",{type:"button",className:U("inline-flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-xs transition-colors",d?"border-foreground bg-accent text-foreground":"border-border text-muted-foreground hover:text-foreground hover:bg-accent/50"),onClick:r(()=>m(!0),"onClick"),children:[(0,t.jsx)(Co,{className:"h-3.5 w-3.5"}),"Local path"]})]}),d?(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)(Qs,{htmlFor:"adapterLocalPath",children:"Path to adapter package"}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(At,{id:"adapterLocalPath",className:"flex-1 font-mono text-xs",placeholder:"/mnt/e/Projects/my-adapter or E:\\Projects\\my-adapter",value:i,onChange:r(E=>o(E.target.value),"onChange")}),(0,t.jsx)(fd,{})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Accepts Linux, WSL, and Windows paths. Windows paths are auto-converted."})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)(Qs,{htmlFor:"adapterPackageName",children:"Package Name"}),(0,t.jsx)(At,{id:"adapterPackageName",placeholder:"my-paperclip-adapter",value:i,onChange:r(E=>o(E.target.value),"onChange")})]}),(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)(Qs,{htmlFor:"adapterVersion",children:"Version (optional)"}),(0,t.jsx)(At,{id:"adapterVersion",placeholder:"latest",value:l,onChange:r(E=>c(E.target.value),"onChange")})]})]})]}),(0,t.jsxs)(yr,{children:[(0,t.jsx)(F,{variant:"outline",onClick:r(()=>p(!1),"onClick"),children:"Cancel"}),(0,t.jsx)(F,{onClick:r(()=>N.mutate({packageName:i,version:l||void 0,isLocalPath:d}),"onClick"),disabled:!i||N.isPending,children:N.isPending?"Installing...":"Install"})]})]})]})]}),(0,t.jsx)("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 px-4 py-3",children:(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)(Is,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-700"}),(0,t.jsxs)("div",{className:"space-y-1 text-sm",children:[(0,t.jsx)("p",{className:"font-medium text-foreground",children:"External adapters are alpha."}),(0,t.jsx)("p",{className:"text-muted-foreground",children:"The adapter plugin system is under active development. APIs and storage format may change. Use the power icon to hide adapters from agent menus without removing them."})]})]})}),(0,t.jsxs)("section",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)($m,{className:"h-5 w-5 text-muted-foreground"}),(0,t.jsx)("h2",{className:"text-base font-semibold",children:"External Adapters"})]}),$.length===0?(0,t.jsx)(Xs,{className:"bg-muted/30",children:(0,t.jsxs)(Wa,{className:"flex flex-col items-center justify-center py-10",children:[(0,t.jsx)($m,{className:"h-10 w-10 text-muted-foreground mb-4"}),(0,t.jsx)("p",{className:"text-sm font-medium",children:"No external adapters installed"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:"Install an adapter package to extend model support."})]})}):(0,t.jsx)(Xs,{className:"block py-0",children:(0,t.jsx)("ul",{className:"divide-y",children:$.map(E=>{const q=E.overriddenBuiltin,B=q&&!!E.overridePaused,K=q?{...E,disabled:B??!1}:E;return(0,t.jsx)(rO,{adapter:K,canRemove:!0,onToggle:q?(z,D)=>C.mutate({type:z,paused:D}):(z,D)=>R.mutate({type:z,disabled:D}),onRemove:r(z=>g(z),"onRemove"),onReload:r(z=>A.mutate(z),"onReload"),onReinstall:E.isLocalPath?void 0:z=>y(E),isToggling:q?C.isPending:R.isPending,isReloading:A.isPending,isReinstalling:T.isPending,toggleTitleDisabled:q?"Pause external override":void 0,toggleTitleEnabled:q?"Resume external override":void 0,disabledBadgeLabel:q?"Override paused":void 0},E.type)})})})]}),(0,t.jsxs)("section",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)($m,{className:"h-5 w-5 text-muted-foreground"}),(0,t.jsx)("h2",{className:"text-base font-semibold",children:"Built-in Adapters"})]}),I.length===0&&O.length===0?(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:"No built-in adapters found."}):(0,t.jsx)(Xs,{className:"block py-0",children:(0,t.jsxs)("ul",{className:"divide-y",children:[I.map(E=>(0,t.jsx)(rO,{adapter:E,canRemove:!1,onToggle:r((q,B)=>R.mutate({type:q,disabled:B}),"onToggle"),onRemove:r(()=>{},"onRemove"),isToggling:L},E.type)),O.map(E=>(0,t.jsx)(rO,{adapter:{type:E.type,label:E.label,source:"builtin",modelsCount:0,loaded:!0,disabled:E.menuDisabled,capabilities:{supportsInstructionsBundle:!1,supportsSkills:!1,supportsLocalAgentJwt:!1,requiresMaterializedRuntimeSkills:!1,supportsAcp:!1}},canRemove:!1,onToggle:r((q,B)=>R.mutate({type:q,disabled:B}),"onToggle"),onRemove:r(()=>{},"onRemove"),isToggling:L,overriddenBy:E.overridePaused?void 0:E.overriddenBy},E.type))]})})]}),(0,t.jsx)(Ys,{open:f!==null,onOpenChange:r(E=>{E||g(null)},"onOpenChange"),children:(0,t.jsxs)(Js,{children:[(0,t.jsxs)(Cn,{children:[(0,t.jsx)(tn,{children:"Remove Adapter"}),(0,t.jsxs)(Ln,{children:["Are you sure you want to remove the ",(0,t.jsx)("strong",{children:f})," adapter? It will be unregistered and removed from the adapter store.",f&&w?.find(E=>E.type===f)?.packageName&&(0,t.jsx)(t.Fragment,{children:" npm packages will be cleaned up from disk."})," ","This action cannot be undone."]})]}),(0,t.jsxs)(yr,{children:[(0,t.jsx)(F,{variant:"outline",onClick:r(()=>g(null),"onClick"),children:"Cancel"}),(0,t.jsx)(F,{variant:"destructive",disabled:_.isPending,onClick:r(()=>{f&&_.mutate(f,{onSettled:r(()=>g(null),"onSettled")})},"onClick"),children:_.isPending?"Removing...":"Remove"})]})]})}),(0,t.jsx)(WUt,{adapter:v,open:v!==null,isReinstalling:T.isPending,onConfirm:r(()=>{v&&T.mutate(v.type,{onSettled:r(()=>y(null),"onSettled")})},"onConfirm"),onCancel:r(()=>y(null),"onCancel")})]})}r(Zoe,"AdapterManager");function ele(){const e=Sa(),{companyPrefix:s,pluginId:n,pluginRoutePath:a}=e,i=e["*"],{companies:o,selectedCompanyId:l}=ps(),{setBreadcrumbs:c}=qn(),d=(0,u.useMemo)(()=>{if(!s)return null;const w=s.toUpperCase();return o.find(S=>S.issuePrefix.toUpperCase()===w)??null},[o,s]),m=!!s&&!d,h=(0,u.useMemo)(()=>d?d.id:s?null:l??null,[d,s,l]),p=(0,u.useMemo)(()=>h?o.find(w=>w.id===h)?.issuePrefix??null:null,[o,h]),{data:f}=Z({queryKey:P.plugins.uiContributions,queryFn:r(()=>el.listUiContributions(),"queryFn"),enabled:!!h&&(!!n||!!a)}),g=(0,u.useMemo)(()=>{if(!f)return null;if(n){const S=f.find(N=>N.pluginId===n);if(!S)return null;const j=S.slots.find(N=>N.type==="page");return j?{...j,pluginId:S.pluginId,pluginKey:S.pluginKey,pluginDisplayName:S.displayName,pluginVersion:S.version}:null}if(!a)return null;const w=f.flatMap(S=>{const j=S.slots.find(N=>N.type==="page"&&N.routePath===a);return j?[{...j,pluginId:S.pluginId,pluginKey:S.pluginKey,pluginDisplayName:S.displayName,pluginVersion:S.version}]:[]});return w.length!==1?null:w[0]??null},[n,a,f]),v=(0,u.useMemo)(()=>({companyId:h??null,companyPrefix:p}),[h,p]),y=(0,u.useMemo)(()=>{if(!a||!f)return!1;const w=f.flatMap(S=>S.slots.map(j=>({...j,pluginId:S.pluginId,pluginKey:S.pluginKey,pluginDisplayName:S.displayName,pluginVersion:S.version})));return oU(w,a)!==null},[f,a]);if((0,u.useEffect)(()=>{if(g){if(y){c([{label:HUt(g,i)}]);return}c([{label:"Plugins",href:"/company/settings/instance/plugins"},{label:g.pluginDisplayName}])}},[g,i,c,y]),!h)return m?(0,t.jsx)(xu,{scope:"invalid_company_prefix",requestedPrefix:s}):(0,t.jsx)("div",{className:"space-y-4",children:(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select an organization to view this page."})});if(!f)return(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:"Loading…"});if(!n&&a&&f.filter(w=>w.slots.some(S=>S.type==="page"&&S.routePath===a)).length>1)return(0,t.jsxs)("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:["Multiple plugins declare the route ",(0,t.jsx)("code",{children:a}),". Use the plugin-id route until the conflict is resolved."]});if(!g){if(a)return(0,t.jsx)(xu,{scope:"board"});const w=n?`/company/settings/instance/plugins/${n}`:"/company/settings/instance/plugins";return(0,t.jsx)(kn,{to:w,replace:!0})}return(0,t.jsxs)("div",{className:"space-y-4",children:[!y&&(0,t.jsx)("div",{className:"flex items-center gap-2",children:(0,t.jsx)(F,{variant:"ghost",size:"sm",asChild:!0,children:(0,t.jsxs)(Je,{to:p?`/${p}/dashboard`:"/dashboard",children:[(0,t.jsx)(Sl,{className:"h-4 w-4 mr-1"}),"Back"]})})}),(0,t.jsx)(yu,{slot:g,context:v,className:"min-h-(--sz-200px)",missingBehavior:"placeholder"})]})}r(ele,"PluginPage");function HUt(e,s){return QUt(s)??e.displayName??e.pluginDisplayName}r(HUt,"resolveRouteSidebarPageTitle");function QUt(e){const s=(e??"").split("/").filter(Boolean).map(GUt);return s.length===0?null:s[0]==="page"&&s.length>1?tle(s.slice(1).join("/"),{preserveCase:!0}):tle(s[0]??null)}r(QUt,"titleFromRouteSplat");function tle(e,s={}){const n=e?.trim();if(!n)return null;const a=n.split("/").filter(Boolean).at(-1)??n,i=(a.split("::").at(-1)??a).replace(/\.[^.]+$/,"").replace(/[-_]+/g," ").trim();return i?s.preserveCase?i:i.replace(/\b\w/g,o=>o.toUpperCase()):null}r(tle,"titleFromPath");function GUt(e){try{return decodeURIComponent(e)}catch{return e}}r(GUt,"decodeRouteSegment");var o2="w-full rounded-md border border-border bg-background px-2.5 py-1.5 text-sm leading-5 outline-none focus-visible:ring-2 focus-visible:ring-ring",sle=r(e=>e.status==="fail"||e.checks.some(s=>s.code==="adapter_auth_missing"),"blocking");function YUt(){const{selectedCompanyId:e}=ps(),[s]=Ai();return e?(0,t.jsx)(JUt,{companyId:e,name:s.get("name")??"",adapterType:s.get("adapterType")??"",runnerProvider:s.get("runnerProvider")??"codex",createdAgentId:s.get("createdAgentId")},`${e}:${s.get("name")}:${s.get("adapterType")}:${s.get("runnerProvider")}`):(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select an organization to create an agent."})}r(YUt,"NewAgentSetup");function JUt({companyId:e,name:s,adapterType:n,runnerProvider:a,createdAgentId:i}){const o=Yn(),l=Wt(),{openNewIssue:c}=$o(),d=Axe(`${e}:new-agent`),m=n==="paperclip_runner",h=m?a==="claude"?"claude_local":a==="opencode"?"opencode_local":"codex_local":n,p=h==="claude_local"||h==="codex_local"||h==="grok_local"?h:null,f=h==="opencode_local"||h==="pi_local",g=k7e(h),v=f||h==="hermes_local",y=v||!!_Y[n],w=!["cursor_cloud","hermes_gateway"].includes(n),[S,j]=(0,u.useState)(""),[N,_]=(0,u.useState)(""),[R,C]=(0,u.useState)(""),[A,T]=(0,u.useState)("kimi"),[I,$]=(0,u.useState)(i?"saved":p?"connect":"runtime"),[O,L]=(0,u.useState)(""),E=m?[]:DT(n,O),[q,B]=(0,u.useState)(""),[K,z]=(0,u.useState)(!1),[D,V]=(0,u.useState)(""),[H,ee]=(0,u.useState)("openrouter"),[X,le]=(0,u.useState)(""),[ce,te]=(0,u.useState)(null),[ae,de]=(0,u.useState)(()=>h==="opencode_local"?{provider:"openrouter",method:"api_key",mode:"responsible_user"}:void 0),[J,Y]=(0,u.useState)(null),G=ae??J?.aiConnection,[fe,se]=(0,u.useState)(""),[re,ie]=(0,u.useState)(""),[me,pe]=(0,u.useState)(null),be=Z({queryKey:P.agents.detail(i??"new"),queryFn:r(()=>Vt.get(i,e),"queryFn"),enabled:!!i,retry:!1}),oe=me??(be.data?.companyId===e?be.data:null),[ye,Ae]=(0,u.useState)(!1),[xe,_e]=(0,u.useState)("idle"),[Ge,$e]=(0,u.useState)(null),[Ye,ue]=(0,u.useState)(null),Oe=(0,u.useRef)(0),dt=(0,u.useRef)(!1);(0,u.useEffect)(()=>()=>{Oe.current++},[]);const xt=r(()=>{Oe.current++,$e(null),_e("idle"),ue(null)},"resetTest"),De=Z({queryKey:P.adapters.all,queryFn:Rm.list}),Qe=Z({queryKey:P.agents.list(e),queryFn:r(()=>Vt.list(e),"queryFn")}),ht=Z({queryKey:P.environments.list(e),queryFn:r(()=>Ci.list(e),"queryFn")}),We=Z({queryKey:P.instance.settings,queryFn:Er.get}),Ke=Z({queryKey:P.instance.experimentalSettings,queryFn:Er.getExperimental}),gt=Z({queryKey:P.instance.generalSettings,queryFn:Er.getGeneral}),tt=Z({queryKey:P.environments.capabilities(e),queryFn:r(()=>Ci.capabilities(e),"queryFn")}),Se=Z({queryKey:P.agents.adapterModels(e,h,null,G?.provider),queryFn:r(()=>Vt.adapterModels(e,h,{provider:G?.provider}),"queryFn"),enabled:!!h&&w,retry:!1}),ke=Z({queryKey:P.secrets.list(e),queryFn:r(()=>fr.list(e),"queryFn"),enabled:y&&n!=="cursor_cloud"}),Xe=Z({queryKey:P.secrets.myUserSecrets(e),queryFn:r(()=>fr.listMyUserSecrets(e),"queryFn"),enabled:y&&n!=="cursor_cloud",retry:!1}),ut=NK(gt.data?.executionMode,ht.data??[]),Lt=Ke.data?.enableManagedSandboxOnly===!0;let Xt=null,fs=null;try{Xt=ut.forced?ut.kubernetesEnvironment?.id??null:vw({agentDefaultEnvironmentId:D||null,instanceDefaultEnvironmentId:We.data?.defaultEnvironmentId??null,localDefaultEnvironmentId:jw(ht.data??[]),managedSandboxOnly:Lt,managedSandboxEnvironmentId:yw(ht.data??[]),visibleEnvironmentIds:(ht.data??[]).map(qe=>qe.id)})}catch(qe){fs=qe instanceof Error?qe.message:"Could not resolve the environment."}const Ve=ht.data?.find(qe=>qe.id===Xt),He=typeof Ve?.config?.provider=="string"?Ve.config.provider:"",ct=Ve?.driver==="sandbox"&&tt.data?.sandboxProviders?.[He]?.supportsLoginPty===!0,ze=_Y[n]??g[H]??"API_KEY",is=Xe.data?.find(qe=>qe.definition.key===ze&&qe.secret),Fe=ke.data?.find(qe=>qe.key===ze&&qe.status==="active"),Qt=n==="cursor_cloud"?null:ce??(Fe?{type:"secret_ref",secretId:Fe.id,version:"latest"}:is?{type:"user_secret_ref",key:ze,version:"latest"}:null),It=n==="kimi_local"&&!!(X.trim()||Qt),Ms=!!Yc(),Ue=Rxe(n,{cloud:Ms,nativeRunnerEnabled:Ke.data?.enableNativeRunner===!0})&&De.data?.some(qe=>qe.type===n&&qe.loaded&&!qe.disabled&&!Um(n).comingSoon),pt=!!(Ue&&!fs&&!ht.isPending&&!We.isPending&&!Ke.isPending&&!gt.isPending&&!Qe.isPending&&!tt.isPending&&!ht.error&&!We.error&&!Ke.error&&!gt.error&&!Qe.error&&!tt.error&&(!(Lt||ut.forced)||Xt)),$t=xe==="running"||ye;function gs(qe=J,wt=Qt){const kt={...t0,adapterType:n,model:O||(h==="codex_local"?pw:""),thinkingEffort:q,dangerouslyBypassSandbox:n==="codex_local",envBindings:qe?.env??{},...m?{adapterSchemaValues:{provider:a==="claude"?"acpx":a,...a==="claude"?{acpxAgent:"claude"}:{}}}:{}},Ee=uN(n).buildAdapterConfig(kt);return m&&Object.assign(Ee,{provider:a==="claude"?"acpx":a,...a==="claude"?{acpxAgent:"claude"}:{},...O?{model:O}:{}}),!G&&!qe?.aiConnection&&y&&wt&&(n==="hermes_gateway"?Ee.apiKey=wt:Ee.env={...Ee.env??{},[ze]:wt}),n==="cursor_cloud"&&Object.assign(Ee,{repoUrl:fe.trim(),...re.trim()?{repoStartingRef:re.trim()}:{}}),n==="hermes_gateway"&&(Ee.apiBaseUrl=S.trim()),It&&(delete Ee.model,Ee.env={...Ee.env??{},KIMI_MODEL_NAME:{type:"plain",value:N.trim()},KIMI_MODEL_PROVIDER_TYPE:{type:"plain",value:A},...R.trim()?{KIMI_MODEL_BASE_URL:{type:"plain",value:R.trim()}}:{}}),Ee}r(gs,"buildConfig");function Ts(qe=J){if(f&&(!O.trim()||!O.includes("/")))throw new Error("Choose or enter a model in provider/model format.");if(n==="cursor_cloud"&&!/^https:\/\/github\.com\/[^/]+\/[^/]+/.test(fe.trim()))throw new Error("Enter a GitHub repository URL.");if(["cursor_cloud","hermes_gateway"].includes(n)&&!X.trim()&&!Qt)throw new Error(n==="cursor_cloud"?"Enter a Cursor API key.":`Enter ${ze} or select an organization secret.`);if(n==="hermes_gateway")try{const wt=new URL(S.trim());if(!["https:","http:"].includes(wt.protocol))throw new Error}catch{throw new Error("Enter the Hermes API base URL.")}if(It&&!N.trim())throw new Error("Enter the Kimi API model name.");return gs(qe)}r(Ts,"preparedConfig");function St(qe=J){return G||qe?.aiConnection?{}:{...qe?.credentials,...y&&X.trim()?{[ze]:X.trim()}:{}}}r(St,"pendingCredentials");async function we(qe=J){if(!pt)return!1;const wt=++Oe.current;_e("running"),$e(null),ue(null);try{const kt=await Ts(qe),Ee=await wfe({companyId:e,adapterType:n,providerAdapter:h,adapterConfig:kt,testCredentials:St(qe),aiConnection:ae??qe?.aiConnection,environmentId:Xt});return wt!==Oe.current?!1:($e(Ee),_e(sle(Ee)?"fail":Ee.status),!sle(Ee)&&(!p||Ee.checks.some(Le=>Le.code.endsWith("hello_probe_passed"))))}catch(kt){return wt===Oe.current&&(ue(kt instanceof Error?kt.message:"Could not test the agent."),_e("fail")),!1}}r(we,"runTest");async function Pe(){if(dt.current||i||oe||!pt||!s.trim()||xe==="running"||xe==="fail"||p&&!J)return;dt.current=!0,Ae(!0),ue(null);const qe=[];let wt=!1;try{const kt=Ts(),Ee=St();if(Object.keys(Ee).length&&!await we())return;for(const[Ut,Dt]of Object.entries(Ee)){const Ft=await(p?kfe:w7e)(e,Ut,Dt);qe.push(Ft),n==="hermes_gateway"&&Ut==="API_SERVER_KEY"?kt.apiKey=Ft.binding:kt.env={...kt.env??{},[Ut]:Ft.binding}}const Le=Qe.data??[],Ze=Le.find(Ut=>Ut.role==="ceo"&&Ut.status!=="terminated"),Nt=await Vt.hire(e,{name:s.trim(),appearance:d.appearance,role:Le.length?"general":"ceo",...Ze?{reportsTo:Ze.id}:{},adapterType:n,adapterConfig:kt,defaultEnvironmentId:D||(ut.forced||Lt?Xt:null),runtimeConfig:{...Abe({heartbeatEnabled:!1}),...G?{aiConnection:G}:{}},budgetMonthlyCents:0,...J?.storedSessionId?{storedSessionId:J.storedSessionId}:{},...J?.applyStoredClaudeLogin?{applyStoredClaudeLogin:!0}:{}});wt=!0,le(""),Y(null),pe(Nt.agent),d.clear(),$("saved"),o(`/agents/new?${new URLSearchParams({name:Nt.agent.name,adapterType:n,runnerProvider:a,createdAgentId:Nt.agent.id})}`,{replace:!0}),l.setQueryData(P.agents.detail(Nt.agent.id),Nt.agent),await Promise.all([l.invalidateQueries({queryKey:P.agents.list(e)}),l.invalidateQueries({queryKey:P.approvals.list(e)})])}catch(kt){ue(kt instanceof Error?kt.message:"Could not create the agent.")}finally{if(!wt)try{await Promise.all(qe.map(kt=>kt.remove()))}catch{ue(kt=>`${kt?`${kt} `:""}Could not remove an unused setup credential. Remove it from Secrets before retrying.`)}l.invalidateQueries({queryKey:P.secrets.myUserSecrets(e)}),l.invalidateQueries({queryKey:P.secrets.list(e)}),dt.current=!1,Ae(!1)}}if(r(Pe,"finish"),i&&!oe)return(0,t.jsx)("p",{role:be.error?"alert":"status",className:"text-sm text-muted-foreground",children:be.error?"Could not load the created agent. Return to Agents to view it.":"Loading your agent…"});if(!s||!n)return(0,t.jsx)(Txe,{open:!0,initialAdapter:n,onClose:r(()=>o("/agents/all"),"onClose"),onContinue:r(qe=>o(`/agents/new?${new URLSearchParams(qe)}`,{replace:!0}),"onContinue")});const it=[...p?["connect"]:[],"runtime","saved"],Ot={connect:"Connect",runtime:"Configure",saved:"Confirmation"},ft=oe?.defaultEnvironmentId?ht.data?.find(qe=>qe.id===oe.defaultEnvironmentId):Ve,us=oe?.adapterConfig?.env?.KIMI_MODEL_NAME,cn=oe?.adapterConfig?.model||(typeof us=="string"?us:us?.value)||O||"Default",xs=n==="cursor_cloud"?"Cursor Cloud":n==="hermes_gateway"?"Hermes Gateway":ft?ww(ft):"Local machine",bs=De.error??ht.error??We.error??Ke.error??gt.error??Qe.error??tt.error;return(0,t.jsx)(ofe,{reducedMotion:"user",children:(0,t.jsxs)("div",{className:"mx-auto flex max-w-5xl flex-col gap-8 py-6",children:[(0,t.jsxs)("header",{className:"flex items-center gap-4",children:[(0,t.jsx)(jC,{appearance:oe?.appearance??d.appearance,size:256,className:"size-48",trackingScope:"page",state:oe||xe==="pass"?"success":xe==="running"?"loading":"sleepy",muted:!oe&&xe!=="pass"}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("h1",{className:"text-2xl font-semibold tracking-tight",children:s}),(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,t.jsx)(CK,{type:h}),(0,t.jsx)("span",{children:Um(h).label}),m&&(0,t.jsxs)("span",{children:["·"," ",a==="codex"?"Native app server runner":"Paperclip Runner"]})]})]})]}),fs&&!ht.isPending&&(0,t.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:fs}),bs&&(0,t.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:bs.message}),De.data&&!Ue&&(0,t.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:"This adapter is unavailable. Choose an enabled adapter."}),(Lt||ut.forced)&&!ht.isPending&&!Xt&&(0,t.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:"No managed environment is available. Configure an environment before continuing."}),(0,t.jsxs)("div",{className:"flex flex-col gap-8 md:flex-row",children:[(0,t.jsx)("nav",{"aria-label":"Agent setup steps",className:"shrink-0 md:w-44",children:(0,t.jsx)("ol",{className:"flex flex-wrap gap-2 md:flex-col",children:it.map((qe,wt)=>(0,t.jsx)("li",{children:(0,t.jsxs)("button",{type:"button","aria-current":qe===I?"step":void 0,disabled:$t||!!oe||wt>it.indexOf(I),onClick:r(()=>$(qe),"onClick"),className:U("flex w-full items-center gap-3 rounded-md px-3 py-3 text-left text-sm",qe===I?"bg-accent font-medium":"text-muted-foreground"),children:[(0,t.jsx)("span",{className:U("flex size-6 shrink-0 items-center justify-center rounded-full border text-xs",qe===I?"border-foreground bg-foreground text-background":"border-border"),children:wt+1}),Ot[qe]]})},qe))})}),(0,t.jsx)("div",{className:"min-w-0 flex-1",children:(0,t.jsx)(dN,{mode:"wait",initial:!1,children:(0,t.jsx)(Zo.div,{...B7e,children:I==="connect"&&p?(0,t.jsxs)(Vrt,{className:"mx-auto",children:[(0,t.jsx)("div",{className:"mb-8",children:(0,t.jsx)(Rbe,{title:"Connect a model",lede:`Connect ${s} to ${p==="claude_local"?"Claude":p==="grok_local"?"Grok":"OpenAI"}.`,center:!0})}),(0,t.jsx)(Dxe,{companyId:e,adapterType:p,environmentId:Xt,canLogin:ct,localEnvironment:Ve?.driver==="local",onBack:r(()=>o("/agents/all"),"onBack"),testConnection:we,testError:Ye??(Ge?.checks.find(qe=>qe.level==="error")??Ge?.checks.find(qe=>qe.code.includes("hello_probe")&&qe.level==="warn"))?.message,onConnected:r(qe=>{Y(qe),xt(),$("runtime")},"onConnected")},Xt??"local")]}):I==="saved"&&oe?(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)("div",{className:"space-y-6 rounded-lg border border-border p-6",children:[(0,t.jsxs)("h2",{className:"flex items-center gap-3 text-lg font-semibold",children:[(0,t.jsx)(ds,{className:"size-5"}),oe.status==="pending_approval"?"Agent submitted for approval":"Your agent is ready"]}),(0,t.jsxs)("dl",{className:"grid grid-cols-2 gap-4 text-sm",children:[(0,t.jsx)("dt",{className:"text-muted-foreground",children:"Adapter"}),(0,t.jsx)("dd",{children:Um(n).label}),w&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("dt",{className:"text-muted-foreground",children:"Model"}),(0,t.jsx)("dd",{className:"break-all",children:String(cn)})]}),(0,t.jsx)("dt",{className:"text-muted-foreground",children:"Environment"}),(0,t.jsx)("dd",{children:xs})]}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:oe.status==="pending_approval"?"An organization administrator must approve this agent before it can work.":"Assign a task when you’re ready for this agent to work."})]}),(0,t.jsxs)("div",{className:"flex flex-wrap justify-between gap-3",children:[(0,t.jsxs)(F,{variant:"outline",onClick:r(()=>o(`${Gu(oe)}/runtime`),"onClick"),children:[(0,t.jsx)(Kz,{className:"size-4"}),"Edit configuration"]}),(0,t.jsxs)(F,{disabled:oe.status==="pending_approval",onClick:r(()=>c({assigneeAgentId:oe.id,status:"todo"}),"onClick"),children:["Assign ",oe.name," a Task",(0,t.jsx)(zo,{className:"size-4"})]})]})]}):(0,t.jsxs)("form",{className:"space-y-8",onSubmit:r(qe=>{qe.preventDefault(),Pe()},"onSubmit"),children:[(0,t.jsx)("h2",{className:"text-xl font-semibold",children:"Configure your agent"}),(0,t.jsxs)("fieldset",{disabled:$t,className:"space-y-8",children:[(0,t.jsxs)("section",{className:"space-y-5",children:[(0,t.jsx)("h3",{className:"text-sm font-semibold",children:"Runtime"}),dK(h)&&(J&&!G?(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Using the connection selected in the Connect step."}),(0,t.jsx)(F,{type:"button",variant:"outline",onClick:r(()=>$("connect"),"onClick"),children:"Change connection"})]}):(0,t.jsx)(jfe,{companyId:e,agentName:s,adapterType:h,model:O,environmentId:Xt??void 0,value:G,onChange:r(qe=>{de(qe),xt()},"onChange")})),Se.error&&(0,t.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:"Could not load models. Retry or enter a model ID manually."}),(w&&!It||E.length>0)&&(0,t.jsxs)("div",{className:"grid items-start gap-5 sm:grid-cols-2",children:[w&&!It&&(0,t.jsx)(SK,{models:Se.data??[],value:O,onChange:r(qe=>{L(qe),q&&!DT(n,qe).includes(q)&&B("");const wt=qe.split("/")[0];f&&Nfe[wt]&&wt!==H&&(ee(wt),le(""),te(null)),xt()},"onChange"),open:K,onOpenChange:z,allowDefault:!f,required:f,creatable:!0,groupByProvider:f}),E.length>0&&(0,t.jsx)(ys,{label:"Thinking effort",children:(0,t.jsxs)("select",{"aria-label":"Thinking effort",className:o2,value:q,onChange:r(qe=>{B(qe.target.value),xt()},"onChange"),children:[(0,t.jsx)("option",{value:"",children:"Auto"}),E.map(qe=>(0,t.jsx)("option",{value:qe,children:qe},qe))]})})]}),IY[n]&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:IY[n]}),w&&Se.error&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Couldn’t load models. You can enter a model ID manually."}),y&&!G&&(0,t.jsxs)("div",{className:"grid gap-5 sm:grid-cols-2",children:[v&&(0,t.jsx)(ys,{label:"API key provider",children:(0,t.jsx)("select",{"aria-label":"API key provider",className:o2,value:H,onChange:r(qe=>{ee(qe.target.value),L(""),le(""),te(null),xt()},"onChange"),children:Object.keys(g).map(qe=>(0,t.jsx)("option",{value:qe,children:qe==="openrouter"?"OpenRouter":qe==="openai"?"OpenAI":qe==="anthropic"?"Anthropic":{google:"Google",xai:"xAI",groq:"Groq",opencode:"OpenCode"}[qe]??qe},qe))})}),(0,t.jsx)("div",{className:n==="cursor_cloud"?"sm:col-span-2":void 0,children:(0,t.jsx)(ys,{label:ze,children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(At,{"aria-label":ze,type:"password",autoComplete:"off",value:X,onChange:r(qe=>{le(qe.target.value),te(null),xt()},"onChange"),placeholder:Qt?"Using saved key":["cursor_cloud","hermes_gateway"].includes(n)?"Required":"Optional if already configured"}),n==="cursor_cloud"&&(0,t.jsx)("a",{href:"https://cursor.com/dashboard/api?section=user-keys#user-api-keys",target:"_blank",rel:"noopener noreferrer",className:"shrink-0 text-xs text-muted-foreground underline underline-offset-4 hover:text-foreground",children:"get api key"})]})})}),n!=="cursor_cloud"&&(0,t.jsx)("div",{className:v?"sm:col-span-2":void 0,children:(0,t.jsx)(ys,{label:"Or use an organization secret",children:(0,t.jsx)(bK,{secretId:Qt&&typeof Qt=="object"&&Qt.type==="secret_ref"?Qt.secretId:"",secrets:ke.data??[],disabled:$t,onSelect:r(qe=>{te({type:"secret_ref",secretId:qe,version:"latest"}),le(""),xt()},"onSelect")})})}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground sm:col-span-2",children:["New keys are saved as organization secrets when you finish setup.",f&&` Use a ${H}/model ID.`]})]}),n==="hermes_gateway"&&(0,t.jsx)(ys,{label:"Hermes API base URL",children:(0,t.jsx)(At,{"aria-label":"Hermes API base URL",value:S,onChange:r(qe=>{j(qe.target.value),xt()},"onChange"),placeholder:"https://hermes.example.com"})}),It&&(0,t.jsxs)("div",{className:"grid gap-5 sm:grid-cols-2",children:[(0,t.jsx)(ys,{label:"Kimi API model name",children:(0,t.jsx)(At,{"aria-label":"Kimi API model name",value:N,onChange:r(qe=>{_(qe.target.value),xt()},"onChange"),placeholder:"kimi-for-coding"})}),(0,t.jsx)(ys,{label:"Kimi API protocol",children:(0,t.jsx)("select",{"aria-label":"Kimi API protocol",className:o2,value:A,onChange:r(qe=>{T(qe.target.value),xt()},"onChange"),children:["kimi","anthropic","openai"].map(qe=>(0,t.jsx)("option",{children:qe},qe))})}),(0,t.jsx)(ys,{label:"Kimi API base URL",hint:"Optional override for your provider endpoint.",children:(0,t.jsx)(At,{"aria-label":"Kimi API base URL",value:R,onChange:r(qe=>{C(qe.target.value),xt()},"onChange"),placeholder:"Provider default"})})]}),n==="cursor_cloud"&&(0,t.jsxs)("div",{className:"grid gap-5 sm:grid-cols-2",children:[(0,t.jsx)(ys,{label:"GitHub repository",children:(0,t.jsx)(At,{"aria-label":"GitHub repository",value:fe,onChange:r(qe=>{se(qe.target.value),xt()},"onChange"),placeholder:"https://github.com/your-org/repo"})}),(0,t.jsx)(ys,{label:"Branch",children:(0,t.jsx)(At,{"aria-label":"Branch",placeholder:"Repository default",value:re,onChange:r(qe=>{ie(qe.target.value),xt()},"onChange")})})]})]}),!["cursor_cloud","hermes_gateway"].includes(n)&&(0,t.jsxs)("section",{className:"space-y-5",children:[(0,t.jsx)("h3",{className:"text-sm font-semibold",children:"Environment"}),(0,t.jsxs)("select",{"aria-label":"Environment",className:o2,value:D,disabled:ut.forced||Lt,onChange:r(qe=>{V(qe.target.value),Y(null),xt(),p&&$("connect")},"onChange"),children:[(0,t.jsxs)("option",{value:"",children:["Default: ",xs]}),(ht.data??[]).filter(qe=>qe.status==="active").map(qe=>(0,t.jsx)("option",{value:qe.id,children:ww(qe)},qe.id))]})]})]}),(0,t.jsx)(Sfe,{state:xe,result:Ge,error:Ye,disabled:!pt||$t,onTest:r(()=>{we()},"onTest")}),Ye&&xe!=="fail"&&(0,t.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:Ye}),(0,t.jsxs)("div",{className:"flex justify-between border-t border-border py-5",children:[p?(0,t.jsxs)(F,{type:"button",variant:"ghost",disabled:$t,onClick:r(()=>$("connect"),"onClick"),children:[(0,t.jsx)(Sl,{className:"size-4"}),"Connection"]}):(0,t.jsx)("span",{}),(0,t.jsxs)(F,{type:"submit",disabled:!pt||$t||xe==="fail"||!!(p&&!J),children:[ye?"Creating…":"Finish setup",(0,t.jsx)(ds,{className:"size-4"})]})]})]})},I)})})]})]})})}r(JUt,"Setup");function XUt(){const{setBreadcrumbs:e}=qn();return(0,u.useEffect)(()=>{e([{label:"Agents",href:"/agents"},{label:"New agent"}])},[e]),(0,t.jsx)(YUt,{})}r(XUt,"NewAgent");var r5="paperclip:pending-invite-token";function x9(){return typeof window<"u"&&typeof window.localStorage<"u"}r(x9,"canUseStorage");function nle(e){const s=e.trim();if(!(!s||!x9()))try{window.localStorage.setItem(r5,s)}catch{}}r(nle,"rememberPendingInviteToken");function l2(e){if(x9())try{const s=window.localStorage.getItem(r5);if(e&&s!==e.trim())return;window.localStorage.removeItem(r5)}catch{}}r(l2,"clearPendingInviteToken");function ZUt(){if(!x9())return null;try{const e=window.localStorage.getItem(r5)?.trim();return e?`/invite/${e}`:null}catch{return null}}r(ZUt,"getRememberedInvitePath");var rle=[" ",".","·","▪","▫","○"],eKt=1e3/24,c2=[[" ╭────╮ "," ╭╯╭──╮│ "," │ │ ││ "," │ │ ││ "," │ │ ││ "," │ │ ││ "," │ ╰──╯│ "," ╰─────╯ "],[" ╭─────╮ "," │╭──╮╰╮ "," ││ │ │ "," ││ │ │ "," ││ │ │ "," ││ │ │ "," │╰──╯ │ "," ╰────╯ "]];function ale(e){const s=document.createElement("span");s.textContent="M",s.style.cssText="position:absolute;visibility:hidden;white-space:pre;font-size:11px;font-family:monospace;line-height:1;",e.appendChild(s);const n=s.getBoundingClientRect();return e.removeChild(s),{w:n.width,h:n.height}}r(ale,"measureChar");function tKt(e){let s=0;for(const n of e)s=Math.max(s,n.length);return{width:s,height:e.length}}r(tKt,"spriteSize");function sKt(){const e=(0,u.useRef)(null),s=(0,u.useRef)(null);return(0,u.useEffect)(()=>{if(!e.current)return;const n=e.current,a=window.matchMedia("(prefers-reduced-motion: reduce)");let i=document.visibilityState!=="hidden",o=!1,l=0,c=0,d=0,m=0,h=7,p=11,f=new Float32Array(0),g=new Float32Array(0),v=new Float32Array(0),y=new Uint16Array(0),w=[],S="";function j(E){const q=Math.floor(Math.max(0,Math.min(.999,E))*rle.length);return rle[q]??" "}r(j,"toGlyph");function N(){const E=Math.max(0,Math.ceil(n.clientWidth/Math.max(1,h))),q=Math.max(0,Math.ceil(n.clientHeight/Math.max(1,p)));if(E===d&&q===m)return;d=E,m=q;const B=d*m;f=new Float32Array(B),g=new Float32Array(d),v=new Float32Array(m),y=new Uint16Array(B),w=w.filter(K=>K.x>-K.width-2&&K.x<d+2&&K.y>-K.height-2&&K.y<m+2),S=""}r(N,"rebuildGrid");function _(){if(d<=0||m<=0){n.textContent="";return}const E=Array.from({length:m},()=>Array.from({length:d},()=>" "));for(let z=0;z<m;z++)for(let D=0;D<d;D++){const V=(Math.sin(D*.11+z*.04)+Math.cos(z*.08-D*.02))*.18+.22;E[z][D]=j(V)}const q=18,B=13;for(let z=1;z<m-9;z+=B){const D=Math.floor(z/B)%2===0?2:10;for(let V=D;V<d-10;V+=q){const H=c2[(V+z)%c2.length];for(let ee=0;ee<H.length;ee++){const X=H[ee];for(let le=0;le<X.length;le++){const ce=X[le]??" ";if(ce===" ")continue;const te=z+ee,ae=V+le;te<0||te>=m||ae<0||ae>=d||(E[te][ae]=ce)}}}}const K=E.map(z=>z.join("")).join(`
|
|
727
727
|
`);n.textContent=K,S=K}r(_,"drawStaticFrame");function R(){const E=c2[Math.floor(Math.random()*c2.length)],q=tKt(E),B=Math.random();let K=0,z=0,D=0,V=0;B<.68?(K=Math.random()<.5?-q.width-1:d+1,z=Math.random()*Math.max(1,m-q.height),D=K<0?.04+Math.random()*.05:-(.04+Math.random()*.05),V=(Math.random()-.5)*.014):(K=Math.random()*Math.max(1,d-q.width),z=Math.random()<.5?-q.height-1:m+1,D=(Math.random()-.5)*.014,V=z<0?.028+Math.random()*.034:-(.028+Math.random()*.034)),w.push({x:K,y:z,vx:D,vy:V,life:0,maxLife:260+Math.random()*220,drift:(Math.random()-.5)*1.2,sprite:E,width:q.width,height:q.height})}r(R,"spawnClip");function C(E,q){const B=Math.round(E.x),K=Math.round(E.y);for(let z=0;z<E.sprite.length;z++){const D=E.sprite[z],V=K+z;if(!(V<0||V>=m))for(let H=0;H<D.length;H++){const ee=D[H]??" ";if(ee===" ")continue;const X=B+H;if(X<0||X>=d)continue;const le=V*d+X,ce=ee==="│"||ee==="─"?.8:.92;f[le]=Math.max(f[le]??0,q*ce),y[le]=ee.charCodeAt(0)}}}r(C,"stampClip");function A(E){if(!o||(s.current=requestAnimationFrame(A),E-l<eKt||d<=0||m<=0))return;const q=Math.min(2,l===0?1:(E-l)/16.6667);l=E,c+=q;const B=d*m,K=Math.max(3,Math.floor(B/2200));for(;w.length<K;)R();for(let D=0;D<f.length;D++)f[D]*=.92;y.fill(0);for(let D=w.length-1;D>=0;D--){const V=w[D];V.life+=q;const H=Math.sin((V.y+V.drift+c*.12)*.09)*.0018,ee=Math.cos((V.x-V.drift-c*.09)*.08)*.0014;if(V.vx=(V.vx+H)*.998,V.vy=(V.vy+ee)*.998,V.x+=V.vx*q,V.y+=V.vy*q,V.life>=V.maxLife||V.x<-V.width-2||V.x>d+2||V.y<-V.height-2||V.y>m+2){w.splice(D,1);continue}const X=V.life/V.maxLife;C(V,X<.12?X/.12:X>.88?(1-X)/.12:1)}for(let D=0;D<d;D++)g[D]=Math.sin(D*.08+c*.06);for(let D=0;D<m;D++)v[D]=Math.cos(D*.1-c*.05);let z="";for(let D=0;D<m;D++){for(let V=0;V<d;V++){const H=D*d+V,ee=y[H];if(ee>0){z+=String.fromCharCode(ee);continue}const X=(g[V]+v[D])*.08+.1,le=Math.max(f[H]??0,X*.45);z+=j(le)}D<m-1&&(z+=`
|
|
728
|
-
`)}z!==S&&(n.textContent=z,S=z)}r(A,"step");function T(){const E=d>0&&m>0;if(a.matches){o&&(o=!1,s.current!==null&&cancelAnimationFrame(s.current),s.current=null),E&&_();return}if(!i||!E){o&&(o=!1,s.current!==null&&cancelAnimationFrame(s.current),s.current=null);return}o||(o=!0,l=0,s.current=requestAnimationFrame(A))}r(T,"syncLoop");const I=new ResizeObserver(()=>{const E=ale(n);h=E.w,p=E.h,N(),T()});I.observe(n);const $=r(()=>{i=document.visibilityState!=="hidden",T()},"onVisibilityChange");document.addEventListener("visibilitychange",$);const O=r(()=>{T()},"onMotionChange");a.addEventListener("change",O);const L=ale(n);return h=L.w,p=L.h,N(),T(),()=>{o=!1,s.current!==null&&cancelAnimationFrame(s.current),I.disconnect(),document.removeEventListener("visibilitychange",$),a.removeEventListener("change",O)}},[]),(0,t.jsx)("pre",{ref:e,className:"w-full h-full m-0 p-0 overflow-hidden text-muted-foreground/60 select-none leading-none",style:{fontSize:"var(--text-micro)",fontFamily:"monospace"},"aria-hidden":"true"})}r(sKt,"AsciiArtAnimation");function nKt({decorative:e=!1,title:s="Paperclip",className:n,...a}){return(0,t.jsxs)("svg",{...a,className:n,viewBox:"22.5 22.5 121 27",fill:"currentColor",role:e?void 0:"img","aria-hidden":e?!0:void 0,"aria-label":e?void 0:s,focusable:"false",children:[(0,t.jsx)("path",{d:"M131.15 48.4902V31.9902H133.922V33.9775H134.094C134.237 33.6911 134.441 33.3831 134.706 33.0537C134.971 32.7171 135.329 32.4307 135.78 32.1943C136.239 31.958 136.822 31.8398 137.531 31.8398C138.455 31.8398 139.289 32.0762 140.034 32.5488C140.779 33.0215 141.37 33.7161 141.807 34.6328C142.251 35.5495 142.473 36.6774 142.473 38.0166C142.473 39.3343 142.258 40.4551 141.828 41.3789C141.398 42.3027 140.808 43.0081 140.056 43.4951C139.311 43.9749 138.466 44.2148 137.521 44.2148C136.84 44.2148 136.271 44.1003 135.812 43.8711C135.361 43.6348 134.996 43.3555 134.717 43.0332C134.445 42.7038 134.237 42.3923 134.094 42.0986H133.976V48.4902H131.15ZM136.747 41.8945C137.37 41.8945 137.889 41.7262 138.305 41.3896C138.727 41.0531 139.046 40.5911 139.261 40.0039C139.476 39.4167 139.583 38.7507 139.583 38.0059C139.583 37.2611 139.476 36.5986 139.261 36.0186C139.046 35.4385 138.731 34.9837 138.315 34.6543C137.9 34.3249 137.377 34.1602 136.747 34.1602C136.138 34.1602 135.623 34.3177 135.2 34.6328C134.785 34.9479 134.466 35.3955 134.244 35.9756C134.029 36.5485 133.922 37.2253 133.922 38.0059C133.922 38.7793 134.029 39.4596 134.244 40.0469C134.466 40.627 134.788 41.0817 135.211 41.4111C135.633 41.7334 136.146 41.8945 136.747 41.8945Z"}),(0,t.jsx)("path",{d:"M126.451 44V31.9902H129.276V44H126.451ZM127.869 30.3037C127.417 30.3037 127.031 30.1533 126.708 29.8525C126.386 29.5518 126.225 29.1901 126.225 28.7676C126.225 28.3379 126.386 27.9727 126.708 27.6719C127.031 27.3711 127.417 27.2207 127.869 27.2207C128.313 27.2207 128.696 27.3711 129.018 27.6719C129.34 27.9727 129.501 28.3343 129.501 28.7568C129.501 29.1865 129.34 29.5518 129.018 29.8525C128.696 30.1533 128.313 30.3037 127.869 30.3037Z"}),(0,t.jsx)("path",{d:"M124.576 27.9941V44H121.75V27.9941H124.576Z"}),(0,t.jsx)("path",{d:"M115.3 44.2363C114.104 44.2363 113.076 43.9749 112.217 43.4521C111.357 42.9222 110.699 42.1917 110.24 41.2607C109.782 40.3298 109.553 39.2591 109.553 38.0488C109.553 36.8242 109.785 35.7464 110.251 34.8154C110.716 33.8844 111.379 33.1576 112.238 32.6348C113.098 32.1048 114.111 31.8398 115.278 31.8398C116.259 31.8398 117.126 32.0189 117.878 32.377C118.63 32.735 119.228 33.2399 119.672 33.8916C120.123 34.5361 120.381 35.2917 120.445 36.1582H117.738C117.667 35.7715 117.527 35.4242 117.319 35.1162C117.112 34.8083 116.84 34.5648 116.503 34.3857C116.174 34.2067 115.78 34.1172 115.321 34.1172C114.741 34.1172 114.233 34.2747 113.796 34.5898C113.366 34.8978 113.03 35.3418 112.786 35.9219C112.543 36.502 112.421 37.1966 112.421 38.0059C112.421 38.8223 112.539 39.5277 112.775 40.1221C113.012 40.7093 113.348 41.1641 113.785 41.4863C114.222 41.8014 114.734 41.959 115.321 41.959C115.944 41.959 116.471 41.7764 116.9 41.4111C117.337 41.0459 117.617 40.541 117.738 39.8965H120.445C120.381 40.7487 120.13 41.5007 119.693 42.1523C119.257 42.804 118.666 43.3161 117.921 43.6885C117.176 44.0537 116.302 44.2363 115.3 44.2363Z"}),(0,t.jsx)("path",{d:"M102.876 44V31.9902H105.615V34.0098H105.744C105.959 33.3079 106.335 32.7708 106.872 32.3984C107.409 32.0189 108.021 31.8291 108.709 31.8291C108.859 31.8291 109.031 31.8363 109.225 31.8506C109.425 31.8649 109.59 31.8828 109.719 31.9043V34.5039C109.597 34.4609 109.407 34.4251 109.149 34.3965C108.892 34.3678 108.645 34.3535 108.408 34.3535C107.885 34.3535 107.42 34.4645 107.012 34.6865C106.604 34.9085 106.281 35.2129 106.045 35.5996C105.816 35.9863 105.701 36.4375 105.701 36.9531V44H102.876Z"}),(0,t.jsx)("path",{d:"M96.2319 44.2363C95.0288 44.2363 93.9904 43.9857 93.1167 43.4844C92.243 42.9759 91.5698 42.2598 91.0972 41.3359C90.6317 40.4121 90.3989 39.3236 90.3989 38.0703C90.3989 36.8314 90.6317 35.7464 91.0972 34.8154C91.5627 33.8773 92.2179 33.1468 93.063 32.624C93.908 32.1012 94.9035 31.8398 96.0493 31.8398C96.7869 31.8398 97.4852 31.958 98.144 32.1943C98.8101 32.4307 99.3973 32.7959 99.9058 33.29C100.421 33.7842 100.826 34.4144 101.12 35.1807C101.413 35.9398 101.56 36.8457 101.56 37.8984V38.7793H91.7202V36.8779H100.153L98.8315 37.4365C98.8315 36.7562 98.7277 36.1654 98.52 35.6641C98.3123 35.1556 98.0044 34.7581 97.5962 34.4717C97.188 34.1852 96.6795 34.042 96.0708 34.042C95.4621 34.042 94.9429 34.1852 94.5132 34.4717C94.0835 34.7581 93.7576 35.1449 93.5356 35.6318C93.3136 36.1117 93.2026 36.6488 93.2026 37.2432V38.5645C93.2026 39.2949 93.328 39.9215 93.5786 40.4443C93.8364 40.96 94.1945 41.3538 94.6528 41.626C95.1183 41.8981 95.659 42.0342 96.2749 42.0342C96.6759 42.0342 97.0412 41.9769 97.3706 41.8623C97.7072 41.7477 97.9937 41.5758 98.23 41.3467C98.4735 41.1104 98.6597 40.8203 98.7886 40.4766L101.431 40.7881C101.259 41.4827 100.941 42.0915 100.475 42.6143C100.017 43.1299 99.4259 43.5309 98.7026 43.8174C97.9865 44.0967 97.1629 44.2363 96.2319 44.2363Z"}),(0,t.jsx)("path",{d:"M78.2437 48.4902V31.9902H81.0151V33.9775H81.187C81.3302 33.6911 81.5343 33.3831 81.7993 33.0537C82.0643 32.7171 82.4224 32.4307 82.8735 32.1943C83.3319 31.958 83.9155 31.8398 84.6245 31.8398C85.5483 31.8398 86.3826 32.0762 87.1274 32.5488C87.8722 33.0215 88.4631 33.7161 88.8999 34.6328C89.3439 35.5495 89.5659 36.6774 89.5659 38.0166C89.5659 39.3343 89.3511 40.4551 88.9214 41.3789C88.4917 42.3027 87.9009 43.0081 87.1489 43.4951C86.4041 43.9749 85.5591 44.2148 84.6138 44.2148C83.9334 44.2148 83.3641 44.1003 82.9058 43.8711C82.4546 43.6348 82.0894 43.3555 81.8101 43.0332C81.5379 42.7038 81.3302 42.3923 81.187 42.0986H81.0688V48.4902H78.2437ZM83.8403 41.8945C84.4634 41.8945 84.9826 41.7262 85.3979 41.3896C85.8205 41.0531 86.1392 40.5911 86.354 40.0039C86.5688 39.4167 86.6763 38.7507 86.6763 38.0059C86.6763 37.2611 86.5688 36.5986 86.354 36.0186C86.1392 35.4385 85.8241 34.9837 85.4087 34.6543C84.9933 34.3249 84.4705 34.1602 83.8403 34.1602C83.2316 34.1602 82.716 34.3177 82.2935 34.6328C81.8781 34.9479 81.5594 35.3955 81.3374 35.9756C81.1226 36.5485 81.0151 37.2253 81.0151 38.0059C81.0151 38.7793 81.1226 39.4596 81.3374 40.0469C81.5594 40.627 81.8817 41.0817 82.3042 41.4111C82.7267 41.7334 83.2388 41.8945 83.8403 41.8945Z"}),(0,t.jsx)("path",{d:"M70.042 44.2471C69.2757 44.2471 68.5882 44.111 67.9795 43.8389C67.3708 43.5596 66.891 43.1514 66.54 42.6143C66.1891 42.0771 66.0137 41.4147 66.0137 40.627C66.0137 39.9538 66.139 39.3952 66.3896 38.9512C66.6403 38.5072 66.9805 38.1527 67.4102 37.8877C67.847 37.6227 68.3376 37.4222 68.8818 37.2861C69.4261 37.1429 69.9883 37.0426 70.5684 36.9854C71.2773 36.9066 71.8503 36.8385 72.2871 36.7812C72.724 36.724 73.0391 36.6309 73.2324 36.502C73.4329 36.373 73.5332 36.1725 73.5332 35.9004V35.8467C73.5332 35.2666 73.3613 34.8154 73.0176 34.4932C72.6738 34.1709 72.1725 34.0098 71.5137 34.0098C70.819 34.0098 70.2676 34.1602 69.8594 34.4609C69.4583 34.7617 69.1862 35.1162 69.043 35.5244L66.4111 35.1484C66.6188 34.418 66.9626 33.8092 67.4424 33.3223C67.9222 32.8281 68.5059 32.4593 69.1934 32.2158C69.888 31.9652 70.6543 31.8398 71.4922 31.8398C72.0651 31.8398 72.638 31.9079 73.2109 32.0439C73.7839 32.1729 74.3102 32.3949 74.79 32.71C75.2699 33.0251 75.653 33.4476 75.9395 33.9775C76.2259 34.5075 76.3691 35.1699 76.3691 35.9648V44H73.6514V42.3457H73.5654C73.3936 42.6751 73.1501 42.9867 72.835 43.2803C72.527 43.5667 72.1403 43.7995 71.6748 43.9785C71.2165 44.1576 70.6722 44.2471 70.042 44.2471ZM70.7617 42.1631C71.3346 42.1631 71.8288 42.0521 72.2441 41.8301C72.6595 41.6009 72.9818 41.3001 73.2109 40.9277C73.4401 40.5482 73.5547 40.1364 73.5547 39.6924V38.2852C73.4616 38.3568 73.3112 38.4248 73.1035 38.4893C72.8958 38.5465 72.6595 38.6003 72.3945 38.6504C72.1296 38.7005 71.8682 38.7435 71.6104 38.7793C71.3597 38.8151 71.1413 38.8438 70.9551 38.8652C70.5326 38.9225 70.153 39.0192 69.8164 39.1553C69.487 39.2842 69.2256 39.4632 69.0322 39.6924C68.8389 39.9215 68.7422 40.2188 68.7422 40.584C68.7422 41.1068 68.932 41.5007 69.3115 41.7656C69.6911 42.0306 70.1745 42.1631 70.7617 42.1631Z"}),(0,t.jsx)("path",{d:"M53.7939 44V27.9941H59.7988C61.0306 27.9941 62.0618 28.2233 62.8926 28.6816C63.7305 29.14 64.3643 29.7702 64.7939 30.5723C65.2236 31.3743 65.4385 32.2839 65.4385 33.3008C65.4385 34.3249 65.2201 35.238 64.7832 36.04C64.3535 36.835 63.7161 37.4616 62.8711 37.9199C62.026 38.3711 60.9876 38.5967 59.7559 38.5967H55.7812V36.2119H59.3584C60.0817 36.2119 60.6725 36.0902 61.1309 35.8467C61.5964 35.596 61.9365 35.2523 62.1514 34.8154C62.3734 34.3714 62.4844 33.8665 62.4844 33.3008C62.4844 32.7279 62.3734 32.2266 62.1514 31.7969C61.9365 31.36 61.5964 31.0234 61.1309 30.7871C60.6725 30.5436 60.0781 30.4219 59.3477 30.4219H56.6943V44H53.7939Z"}),(0,t.jsx)("path",{d:"M46.2611 33.6556L34.7307 44.6408C32.7445 46.5331 29.5205 46.5323 27.5303 44.6361C25.5404 42.74 25.54 39.669 27.5261 37.7768L39.0565 26.7916C40.2474 25.657 42.1811 25.6567 43.3752 26.7943C44.5693 27.9319 44.5689 29.7742 43.378 30.9088L31.849 41.8954C31.4528 42.2728 30.8077 42.273 30.4092 41.8933C30.011 41.5136 30.0117 40.8996 30.4078 40.5223L41.9382 29.5371C42.336 29.1581 42.336 28.5437 41.9382 28.1647C41.5404 27.786 40.8954 27.7858 40.4977 28.1647L28.9673 39.1499C27.7742 40.2866 27.7764 42.1295 28.9687 43.2657C30.1613 44.402 32.0963 44.4046 33.2895 43.2678L44.8192 32.2805C46.8068 30.3865 46.8038 27.3159 44.8157 25.4219C42.8275 23.5277 39.6039 23.5253 37.616 25.4192L26.0856 36.4044C23.3024 39.056 23.3058 43.3558 26.0898 46.0085C28.8741 48.6612 33.388 48.6649 36.1712 46.0132L47.7017 35.028C48.0994 34.649 48.0994 34.0346 47.7017 33.6556C47.3039 33.2766 46.6589 33.2766 46.2611 33.6556Z"})]})}r(nKt,"PaperclipLockup");function rKt(){const e=Wt(),s=Yn(),[n]=Ai(),[a,i]=(0,u.useState)("sign_in"),[o,l]=(0,u.useState)(""),[c,d]=(0,u.useState)(""),[m,h]=(0,u.useState)(""),[p,f]=(0,u.useState)(null),g="auth-error",v=(0,u.useMemo)(()=>n.get("next")||ZUt()||"/",[n]),{data:y,isLoading:w}=Z({queryKey:P.auth.session,queryFn:r(()=>qa.getSession(),"queryFn"),retry:!1});(0,u.useEffect)(()=>{y&&s(v,{replace:!0})},[y,s,v]);const S=Ne({mutationFn:r(async()=>{if(a==="sign_in"){await qa.signInEmail({email:c.trim(),password:m});return}await qa.signUpEmail({name:o.trim(),email:c.trim(),password:m})},"mutationFn"),onSuccess:r(async()=>{f(null),await e.invalidateQueries({queryKey:P.auth.session}),await e.invalidateQueries({queryKey:P.health}),await e.resetQueries({queryKey:P.companies.all}),s(v,{replace:!0})},"onSuccess"),onError:r(N=>{f(N instanceof Error?N.message:"Authentication failed")},"onError")}),j=c.trim().length>0&&m.trim().length>0&&(a==="sign_in"||o.trim().length>0&&m.trim().length>=8);return w?(0,t.jsx)("div",{className:"fixed inset-0 flex items-center justify-center",children:(0,t.jsx)(Xm,{className:"min-h-0"})}):(0,t.jsxs)("div",{className:"fixed inset-0 flex bg-background",children:[(0,t.jsx)("div",{className:"absolute top-4 right-4 z-10",children:(0,t.jsx)(Bj,{})}),(0,t.jsx)("div",{className:"w-full md:w-1/2 flex flex-col overflow-y-auto",children:(0,t.jsxs)("div",{className:"w-full max-w-md mx-auto my-auto px-8 py-12",children:[(0,t.jsx)("div",{className:"mb-8",children:(0,t.jsx)(nKt,{className:"h-5 w-auto"})}),(0,t.jsx)("h1",{className:"text-xl font-semibold",children:a==="sign_in"?"Sign in to Paperclip":"Create your Paperclip account"}),(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:a==="sign_in"?"Use your email and password to access this instance.":"Create an account for this instance. Email confirmation is not required in v1."}),(0,t.jsxs)("form",{className:"mt-6 space-y-4",method:"post",action:a==="sign_up"?"/api/auth/sign-up/email":"/api/auth/sign-in/email",onSubmit:r(N=>{if(N.preventDefault(),!S.isPending){if(!j){f("Please fill in all required fields.");return}S.mutate()}},"onSubmit"),children:[a==="sign_up"&&(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{htmlFor:"name",className:"text-xs text-muted-foreground mb-1 block",children:"Name"}),(0,t.jsx)("input",{id:"name",name:"name",className:"w-full rounded-md border border-border bg-transparent px-3 py-2 text-sm outline-none focus:ring-1 focus:ring-ring placeholder:text-muted-foreground/50",value:o,onChange:r(N=>l(N.target.value),"onChange"),autoComplete:"name",required:!0,"aria-required":"true","aria-invalid":p?!0:void 0,"aria-describedby":p?g:void 0,autoFocus:!0})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{htmlFor:"email",className:"text-xs text-muted-foreground mb-1 block",children:"Email"}),(0,t.jsx)("input",{id:"email",name:"email",className:"w-full rounded-md border border-border bg-transparent px-3 py-2 text-sm outline-none focus:ring-1 focus:ring-ring placeholder:text-muted-foreground/50",type:"email",value:c,onChange:r(N=>d(N.target.value),"onChange"),autoComplete:"username",required:!0,"aria-required":"true","aria-invalid":p?!0:void 0,"aria-describedby":p?g:void 0,autoFocus:a==="sign_in"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{htmlFor:"password",className:"text-xs text-muted-foreground mb-1 block",children:"Password"}),(0,t.jsx)("input",{id:"password",name:"password",className:"w-full rounded-md border border-border bg-transparent px-3 py-2 text-sm outline-none focus:ring-1 focus:ring-ring placeholder:text-muted-foreground/50",type:"password",value:m,onChange:r(N=>h(N.target.value),"onChange"),autoComplete:a==="sign_in"?"current-password":"new-password",required:!0,"aria-required":"true","aria-invalid":p?!0:void 0,"aria-describedby":p?g:void 0})]}),p&&(0,t.jsx)("p",{id:g,role:"alert",className:"text-xs text-destructive",children:p}),(0,t.jsx)(F,{type:"submit",disabled:S.isPending,"aria-disabled":!j||S.isPending,className:`w-full ${!j&&!S.isPending?"opacity-50":""}`,children:S.isPending?"Working…":a==="sign_in"?"Sign In":"Create Account"})]}),(0,t.jsxs)("div",{className:"mt-5 text-sm text-muted-foreground",children:[a==="sign_in"?"Need an account?":"Already have an account?"," ",(0,t.jsx)("button",{type:"button",className:"font-medium text-foreground underline underline-offset-2",onClick:r(()=>{f(null),i(a==="sign_in"?"sign_up":"sign_in")},"onClick"),children:a==="sign_in"?"Create one":"Sign in"})]})]})}),(0,t.jsx)("div",{className:"hidden md:block w-1/2 overflow-hidden",children:(0,t.jsx)(sKt,{})})]})}r(rKt,"AuthPage");function aKt(){const e=Wt(),s=Sa(),[n]=Ai(),a=(s.token??"").trim(),i=(n.get("code")??"").trim(),o=(0,u.useMemo)(()=>`/board-claim/${encodeURIComponent(a)}${i?`?code=${encodeURIComponent(i)}`:""}`,[a,i]),l=Z({queryKey:P.auth.session,queryFn:r(()=>qa.getSession(),"queryFn"),retry:!1}),c=Z({queryKey:["board-claim",a,i],queryFn:r(()=>hr.getBoardClaimStatus(a,i),"queryFn"),enabled:a.length>0&&i.length>0,retry:!1}),d=Ne({mutationFn:r(()=>hr.claimBoard(a,i),"mutationFn"),onSuccess:r(async()=>{await e.invalidateQueries({queryKey:P.auth.session}),await e.invalidateQueries({queryKey:P.health}),await e.invalidateQueries({queryKey:P.companies.all}),await e.invalidateQueries({queryKey:P.companies.stats}),await c.refetch()},"onSuccess")});if(!a||!i)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-destructive",children:"Invalid board claim URL."});if(c.isLoading||l.isLoading)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-muted-foreground",children:"Loading claim challenge..."});if(c.error)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)(Xs,{className:"block p-6",children:[(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Claim challenge unavailable"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:c.error instanceof Error?c.error.message:"Challenge is invalid or expired."})]})});const m=c.data;return m?m.status==="claimed"?(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)(Xs,{className:"block p-6",children:[(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Board ownership claimed"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"This instance is now linked to your authenticated user."}),(0,t.jsx)(F,{asChild:!0,className:"mt-4",children:(0,t.jsx)(Je,{to:"/",children:"Open board"})})]})}):l.data?(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)(Xs,{className:"block p-6",children:[(0,t.jsx)("h1",{className:"text-xl font-semibold",children:"Claim Board ownership"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"This will promote your user to instance admin and migrate organization ownership access from local trusted mode."}),d.error&&(0,t.jsx)("p",{className:"mt-3 text-sm text-destructive",children:d.error instanceof Error?d.error.message:"Failed to claim board ownership"}),(0,t.jsx)(F,{className:"mt-5",onClick:r(()=>d.mutate(),"onClick"),disabled:d.isPending,children:d.isPending?"Claiming…":"Claim ownership"})]})}):(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)(Xs,{className:"block p-6",children:[(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Sign in required"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Sign in or create an account, then return to this page to claim Board ownership."}),(0,t.jsx)(F,{asChild:!0,className:"mt-4",children:(0,t.jsx)(Je,{to:`/auth?next=${encodeURIComponent(o)}`,children:"Sign in / Create account"})})]})}):(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-destructive",children:"Claim challenge unavailable."})}r(aKt,"BoardClaimPage");function iKt(){const e=Wt(),s=Sa(),[n]=Ai(),a=(s.id??"").trim(),i=(n.get("token")??"").trim(),o=(0,u.useMemo)(()=>`/cli-auth/${encodeURIComponent(a)}${i?`?token=${encodeURIComponent(i)}`:""}`,[a,i]),l=Z({queryKey:P.auth.session,queryFn:r(()=>qa.getSession(),"queryFn"),retry:!1}),c=Z({queryKey:["cli-auth-challenge",a,i],queryFn:r(()=>hr.getCliAuthChallenge(a,i),"queryFn"),enabled:a.length>0&&i.length>0,retry:!1}),d=Ne({mutationFn:r(()=>hr.approveCliAuthChallenge(a,i),"mutationFn"),onSuccess:r(async()=>{await e.invalidateQueries({queryKey:P.auth.session}),await c.refetch()},"onSuccess")}),m=Ne({mutationFn:r(()=>hr.cancelCliAuthChallenge(a,i),"mutationFn"),onSuccess:r(async()=>{await c.refetch()},"onSuccess")});if(!a||!i)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-destructive",children:"Invalid CLI auth URL."});if(l.isLoading||c.isLoading)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-muted-foreground",children:"Loading CLI auth challenge..."});if(c.error)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)(Xs,{className:"block p-6",children:[(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"CLI auth challenge unavailable"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:c.error instanceof Error?c.error.message:"Challenge is invalid or expired."})]})});const h=c.data;return h?h.status==="approved"?(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)(Xs,{className:"block p-6",children:[(0,t.jsx)("h1",{className:"text-xl font-semibold",children:"CLI access approved"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"The Paperclip CLI can now finish authentication on the requesting machine."}),(0,t.jsxs)("p",{className:"mt-4 text-sm text-muted-foreground",children:["Command: ",(0,t.jsx)("span",{className:"font-mono text-foreground",children:h.command})]})]})}):h.status==="cancelled"||h.status==="expired"?(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)(Xs,{className:"block p-6",children:[(0,t.jsx)("h1",{className:"text-xl font-semibold",children:h.status==="expired"?"CLI auth challenge expired":"CLI auth challenge cancelled"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Start the CLI auth flow again from your terminal to generate a new approval request."})]})}):h.requiresSignIn||!l.data?(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)(Xs,{className:"block p-6",children:[(0,t.jsx)("h1",{className:"text-xl font-semibold",children:"Sign in required"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Sign in or create an account, then return to this page to approve the CLI access request."}),(0,t.jsx)(F,{asChild:!0,className:"mt-4",children:(0,t.jsx)(Je,{to:`/auth?next=${encodeURIComponent(o)}`,children:"Sign in / Create account"})})]})}):(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)(Xs,{className:"block p-6",children:[(0,t.jsx)("h1",{className:"text-xl font-semibold",children:"Approve Paperclip CLI access"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"A local Paperclip CLI process is requesting board access to this instance."}),(0,t.jsxs)("div",{className:"mt-5 space-y-3 text-sm",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-muted-foreground",children:"Command"}),(0,t.jsx)("div",{className:"font-mono text-foreground",children:h.command})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-muted-foreground",children:"Client"}),(0,t.jsx)("div",{className:"text-foreground",children:h.clientName??"paperclip-pro cli"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-muted-foreground",children:"Requested access"}),(0,t.jsx)("div",{className:"text-foreground",children:h.requestedAccess==="instance_admin_required"?"Instance admin":"Board"})]}),h.requestedCompanyName&&(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-muted-foreground",children:"Requested organization"}),(0,t.jsx)("div",{className:"text-foreground",children:h.requestedCompanyName})]})]}),(d.error||m.error)&&(0,t.jsx)("p",{className:"mt-4 text-sm text-destructive",children:(d.error??m.error)instanceof Error?(d.error??m.error).message:"Failed to update CLI auth challenge"}),!h.canApprove&&(0,t.jsx)("p",{className:"mt-4 text-sm text-destructive",children:"This challenge requires instance-admin access. Sign in with an instance admin account to approve it."}),(0,t.jsxs)("div",{className:"mt-5 flex gap-3",children:[(0,t.jsx)(F,{onClick:r(()=>d.mutate(),"onClick"),disabled:!h.canApprove||d.isPending||m.isPending,children:d.isPending?"Approving...":"Approve CLI access"}),(0,t.jsx)(F,{type:"button",variant:"outline",onClick:r(()=>m.mutate(),"onClick"),disabled:d.isPending||m.isPending,children:m.isPending?"Cancelling...":"Cancel"})]})]})}):(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-destructive",children:"CLI auth challenge unavailable."})}r(iKt,"CliAuthPage");var oKt=nAe.filter(e=>e!=="paperclip_runner"),ile=new Set(["claude_local","codex_local","gemini_local","kimi_local","opencode_local","pi_local","cursor"]);function lKt(e,s){let n=e;for(const a of s){if(!n||typeof n!="object")return null;n=n[a]}return typeof n=="string"&&n.trim().length>0?n:null}r(lKt,"readNestedString");var Yy="w-full border border-zinc-800 bg-zinc-950 px-3 py-2 text-sm text-zinc-100 outline-none focus:border-zinc-500",ole="border border-zinc-800 bg-zinc-950/95 p-6",lle="flex-1 border px-3 py-2 text-sm transition-colors";function cKt(e){return e?e.charAt(0).toUpperCase()+e.slice(1):null}r(cKt,"formatHumanRole");function E1e(e){if(!e||typeof e!="object")return null;const s=e.code;return typeof s=="string"&&s.trim().length>0?s:null}r(E1e,"getAuthErrorCode");function dKt(e){if(!(e instanceof Error))return null;const s=e.message.trim();return s.length>0?s:null}r(dKt,"getAuthErrorMessage");function uKt(e,s,n){const a=E1e(e),i=dKt(e),o=n.trim().length>0?n.trim():"that email";return a==="USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL"?{tone:"info",message:`An account already exists for ${o}. Sign in below to continue with this invite.`}:a==="INVALID_EMAIL_OR_PASSWORD"?{tone:"error",message:"That email and password did not match an existing Paperclip account. Check both fields, or create an account first if you are new here."}:s==="sign_in"&&i==="Request failed: 401"?{tone:"error",message:"That email and password did not match an existing Paperclip account. Check both fields, or create an account first if you are new here."}:s==="sign_up"&&i==="Request failed: 422"?{tone:"info",message:`An account may already exist for ${o}. Try signing in instead.`}:{tone:"error",message:i??"Authentication failed"}}r(uKt,"mapInviteAuthFeedback");function cle(e){return!!(e&&typeof e=="object"&&"bootstrapAccepted"in e)}r(cle,"isBootstrapAcceptancePayload");function mKt(e,s){return!e||typeof e!="object"||s?!1:e.status==="approved"}r(mKt,"isApprovedHumanJoinPayload");function iz({companyDisplayName:e,companyLogoUrl:s,className:n}){return(0,t.jsx)(Lx,{companyName:e,logoUrl:s,logoFit:"contain",className:n})}r(iz,"InviteCompanyLogo");function dle({companyDisplayName:e,companyLogoUrl:s,invitedByUserName:n,claimSecret:a=null,claimApiKeyPath:i=null,onboardingTextUrl:o=null}){return(0,t.jsx)("div",{className:"min-h-screen bg-zinc-950 px-6 py-12 text-zinc-100",children:(0,t.jsxs)("div",{className:"mx-auto max-w-md border border-zinc-800 bg-zinc-950 p-6","data-testid":"invite-pending-approval",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(iz,{companyDisplayName:e,companyLogoUrl:s,className:"h-12 w-12 border border-zinc-800 rounded-none"}),(0,t.jsxs)("h1",{className:"text-lg font-semibold",children:["Request to join ",e]})]}),(0,t.jsxs)("div",{className:"mt-4 space-y-3",children:[(0,t.jsxs)("p",{className:"text-sm text-zinc-400",children:["Your request is still awaiting approval. ",n??"An organization admin"," must approve your request to join."]}),(0,t.jsxs)("div",{className:"border border-zinc-800 p-3",children:[(0,t.jsx)("p",{className:"text-xs text-zinc-500 mb-1",children:"Approval page"}),(0,t.jsx)("p",{className:"text-sm text-zinc-200",children:"Settings → Members"})]}),(0,t.jsxs)("p",{className:"text-sm text-zinc-400",children:["Ask them to visit ",(0,t.jsx)("span",{className:"text-zinc-200",children:"Settings → Members"})," to approve your request."]}),(0,t.jsx)("p",{className:"text-xs text-zinc-500",children:"Refresh this page after you've been approved — you'll be redirected automatically."})]}),a&&i?(0,t.jsxs)("div",{className:"mt-4 space-y-1 border border-zinc-800 p-3 text-xs text-zinc-400",children:[(0,t.jsx)("div",{className:"text-zinc-200",children:"Claim secret"}),(0,t.jsx)("div",{className:"font-mono break-all",children:a}),(0,t.jsxs)("div",{className:"font-mono break-all",children:["POST ",i]})]}):null,o?(0,t.jsxs)("div",{className:"mt-4 text-xs text-zinc-400",children:["Onboarding: ",(0,t.jsx)("span",{className:"font-mono break-all",children:o})]}):null]})})}r(dle,"AwaitingJoinApprovalPanel");function hKt(){const e=Wt(),s=Yn(),{setSelectedCompanyId:n}=ps(),a=(Sa().token??"").trim(),[i,o]=(0,u.useState)("sign_up"),[l,c]=(0,u.useState)(""),[d,m]=(0,u.useState)(""),[h,p]=(0,u.useState)(""),[f,g]=(0,u.useState)(""),[v,y]=(0,u.useState)("claude_local"),[w,S]=(0,u.useState)(""),[j,N]=(0,u.useState)(null),[_,R]=(0,u.useState)(null),[C,A]=(0,u.useState)(null),[T,I]=(0,u.useState)(!1),$="invite-auth-error",O=Z({queryKey:P.health,queryFn:r(()=>sm.get(),"queryFn"),retry:!1}),L=Z({queryKey:P.auth.session,queryFn:r(()=>qa.getSession(),"queryFn"),retry:!1}),E=Z({queryKey:P.access.invite(a),queryFn:r(()=>hr.getInvite(a),"queryFn"),enabled:a.length>0,retry:!1}),q=lz({enabled:!!L.data&&!!E.data?.companyId,staleTime:0}),B=O.data?.deploymentMode!=="local_trusted"?q.isFetchedAfterMount:!0,K=B?q.data?.companies??[]:[];(0,u.useEffect)(()=>{a&&nle(a)},[a]),(0,u.useEffect)(()=>{I(!1)},[a]),(0,u.useEffect)(()=>{if(!B)return;const pe=q.data?.companies;!pe||!E.data?.companyId||pe.some(be=>be.id===E.data.companyId)&&l2(a)},[q.data,E.data,B,a]);const z=E.data,D=!!L.data&&!!z?.companyId&&!B,V=!!z?.companyId&&K.some(pe=>pe.id===z?.companyId),H=z?.companyName?.trim()||"this Paperclip company",ee=z?.companyLogoUrl?.trim()||null,X=z?.invitedByUserName?.trim()||null,le=z?.inviteMessage?.trim()||null,ce=cKt(z?.humanRole),te=z?.joinRequestStatus??null,ae=z?.joinRequestType??null,de=ae==="human"&&(te==="pending_approval"||te==="approved"),J=O.data?.deploymentMode==="authenticated"&&!L.data&&z?.allowedJoinTypes!=="agent",Y=z?.inviteType!=="bootstrap_ceo"&&z?.allowedJoinTypes==="agent",G=!!L.data&&!Y&&z?.inviteType!=="bootstrap_ceo"&&(!te||de)&&!D&&!V&&!j&&_===null,fe=L.data?.user.name?.trim()||L.data?.user.email?.trim()||"this account",se=d.trim().length>0&&h.trim().length>0&&(i==="sign_in"||l.trim().length>0&&h.trim().length>=8),re=Ne({mutationFn:r(async()=>{if(!z)throw new Error("Invite not found");if(D)throw new Error("Checking your organization access. Try again in a moment.");if(V)throw new Error("This account already belongs to the organization.");return z.inviteType==="bootstrap_ceo"||z.allowedJoinTypes!=="agent"?hr.acceptInvite(a,{requestType:"human"}):hr.acceptInvite(a,{requestType:"agent",agentName:f.trim(),adapterType:v,capabilities:w.trim()||null})},"mutationFn"),onSuccess:r(async pe=>{R(null),l2(a);const be=cle(pe);N({kind:be?"bootstrap":"join",payload:pe}),await e.invalidateQueries({queryKey:P.auth.session}),await e.invalidateQueries({queryKey:P.access.currentBoardAccess}),await e.invalidateQueries({queryKey:P.companies.all}),z?.companyId&&mKt(pe,Y)&&(n(z.companyId,{source:"manual"}),s("/",{replace:!0}))},"onSuccess"),onError:r(pe=>{R(pe instanceof Error?pe.message:"Failed to accept invite")},"onError")});(0,u.useEffect)(()=>{!G||T||re.isPending||(I(!0),R(null),re.mutate())},[re,T,G]);const ie=Ne({mutationFn:r(async()=>{if(i==="sign_in"){await qa.signInEmail({email:d.trim(),password:h});return}await qa.signUpEmail({name:l.trim(),email:d.trim(),password:h})},"mutationFn"),onSuccess:r(async()=>{A(null),nle(a),await e.invalidateQueries({queryKey:P.auth.session}),await e.invalidateQueries({queryKey:P.health}),await e.invalidateQueries({queryKey:P.access.currentBoardAccess});const{companies:pe}=await pIe(e);if(z?.companyId&&pe.some(be=>be.id===z.companyId)){l2(a),n(z.companyId,{source:"manual"}),s("/",{replace:!0});return}if(!(!z||z.inviteType!=="bootstrap_ceo"))try{cle(await re.mutateAsync())&&s("/",{replace:!0})}catch{return}},"onSuccess"),onError:r(pe=>{const be=uKt(pe,i,d);E1e(pe)==="USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL"&&(o("sign_in"),p("")),A(be)},"onError")}),me=(0,u.useMemo)(()=>z?V?"Open organization":z.inviteType==="bootstrap_ceo"?"Accept invite":Y?"Submit request":L.data?"Accept invite":"Continue":"Continue",[z,V,L.data,Y]);if(!a)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-destructive",children:"Invalid invite token."});if(E.isLoading||O.isLoading||L.isLoading)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-muted-foreground",children:"Loading invite..."});if(D)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-muted-foreground",children:"Checking your access..."});if(E.error||!z)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)("div",{className:"border border-border bg-card p-6","data-testid":"invite-error",children:[(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Invite not available"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"This invite may be expired, revoked, or already used."})]})});if(te==="approved"&&ae==="human"&&V)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-muted-foreground",children:"Opening organization..."});if(te==="pending_approval"&&!de)return(0,t.jsx)(dle,{companyDisplayName:H,companyLogoUrl:ee,invitedByUserName:X});if(te&&!de)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)("div",{className:"border border-border bg-card p-6","data-testid":"invite-error",children:[(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Invite not available"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:te==="rejected"?"This join request was not approved.":"This invite has already been used."})]})});if(j?.kind==="bootstrap")return(0,t.jsx)("div",{className:"min-h-screen bg-zinc-950 px-6 py-12 text-zinc-100",children:(0,t.jsxs)("div",{className:"mx-auto max-w-md border border-zinc-800 bg-zinc-950 p-6",children:[(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Bootstrap complete"}),(0,t.jsx)("div",{className:"mt-4",children:(0,t.jsx)(F,{asChild:!0,className:"rounded-none",children:(0,t.jsx)(Je,{to:"/",children:"Open board"})})})]})});if(j?.kind==="join"){const pe=j.payload,be=typeof pe.claimSecret=="string"?pe.claimSecret:null,oe=typeof pe.claimApiKeyPath=="string"?pe.claimApiKeyPath:null,ye=lKt(pe.onboarding,["textInstructions","url"]);return!Y&&pe.status==="approved"?(0,t.jsx)("div",{className:"min-h-screen bg-zinc-950 px-6 py-12 text-zinc-100",children:(0,t.jsxs)("div",{className:"mx-auto max-w-md border border-zinc-800 bg-zinc-950 p-6",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(iz,{companyDisplayName:H,companyLogoUrl:ee,className:"h-12 w-12 border border-zinc-800 rounded-none"}),(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"You joined the organization"})]}),(0,t.jsx)("div",{className:"mt-4",children:(0,t.jsx)(F,{asChild:!0,className:"w-full rounded-none",children:(0,t.jsx)(Je,{to:"/",children:"Open board"})})})]})}):(0,t.jsx)(dle,{companyDisplayName:H,companyLogoUrl:ee,invitedByUserName:X,claimSecret:be,claimApiKeyPath:oe,onboardingTextUrl:ye})}return(0,t.jsx)("div",{className:"min-h-screen bg-zinc-950 px-6 py-12 text-zinc-100",children:(0,t.jsx)("div",{className:"mx-auto max-w-5xl",children:(0,t.jsxs)("div",{className:"grid gap-6 lg:grid-cols-(--gtc-36)",children:[(0,t.jsxs)("section",{className:`${ole} space-y-6`,children:[(0,t.jsxs)("div",{className:"flex items-start gap-4",children:[(0,t.jsx)(iz,{companyDisplayName:H,companyLogoUrl:ee,className:"h-16 w-16 rounded-none border border-zinc-800"}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"text-xs uppercase tracking-(--tracking-caps) text-zinc-500",children:"You've been invited to join Paperclip"}),(0,t.jsx)("h1",{className:"mt-2 text-2xl font-semibold",children:z.inviteType==="bootstrap_ceo"?"Set up Paperclip":`Join ${H}`}),(0,t.jsx)("p",{className:"mt-2 max-w-2xl text-sm leading-6 text-zinc-300",children:Y?"Review the invite details, then submit the agent information below to start the join request.":J?"Create your Paperclip account first. If you already have one, switch to sign in and continue the invite with the same email.":"Your account is ready. Review the invite details, then accept it to continue."})]})]}),(0,t.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,t.jsxs)("div",{className:"border border-zinc-800 p-3",children:[(0,t.jsx)("div",{className:"text-xs uppercase tracking-(--tracking-caps) text-zinc-500",children:"Organization"}),(0,t.jsx)("div",{className:"mt-1 text-sm text-zinc-100",children:H})]}),(0,t.jsxs)("div",{className:"border border-zinc-800 p-3",children:[(0,t.jsx)("div",{className:"text-xs uppercase tracking-(--tracking-caps) text-zinc-500",children:"Invited by"}),(0,t.jsx)("div",{className:"mt-1 text-sm text-zinc-100",children:X??"Paperclip board"})]}),(0,t.jsxs)("div",{className:"border border-zinc-800 p-3",children:[(0,t.jsx)("div",{className:"text-xs uppercase tracking-(--tracking-caps) text-zinc-500",children:"Requested access"}),(0,t.jsx)("div",{className:"mt-1 text-sm text-zinc-100",children:Y?"Agent join request":ce??"Organization access"})]}),(0,t.jsxs)("div",{className:"border border-zinc-800 p-3",children:[(0,t.jsx)("div",{className:"text-xs uppercase tracking-(--tracking-caps) text-zinc-500",children:"Invite expires"}),(0,t.jsx)("div",{className:"mt-1 text-sm text-zinc-100",children:pu(z.expiresAt)})]})]}),le?(0,t.jsxs)("div",{className:"border border-amber-500/40 bg-amber-500/10 p-4",children:[(0,t.jsx)("div",{className:"text-xs uppercase tracking-(--tracking-caps) text-amber-200/80",children:"Message from inviter"}),(0,t.jsx)("p",{className:"mt-2 text-sm leading-6 text-amber-50",children:le})]}):null,L.data?(0,t.jsxs)("div",{className:"border border-emerald-500/40 bg-emerald-500/10 p-4 text-sm text-emerald-50",children:["Signed in as ",(0,t.jsx)("span",{className:"font-medium",children:fe}),"."]}):null]}),(0,t.jsx)("section",{className:`${ole} h-fit`,children:Y?(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-lg font-semibold",children:"Submit agent details"}),(0,t.jsxs)("p",{className:"mt-1 text-sm text-zinc-400",children:["This invite will create an approval request for a new agent in ",H,"."]})]}),(0,t.jsxs)("label",{className:"block text-sm",children:[(0,t.jsx)("span",{className:"mb-1 block text-zinc-400",children:"Agent name"}),(0,t.jsx)("input",{className:Yy,value:f,onChange:r(pe=>g(pe.target.value),"onChange")})]}),(0,t.jsxs)("label",{className:"block text-sm",children:[(0,t.jsx)("span",{className:"mb-1 block text-zinc-400",children:"Adapter type"}),(0,t.jsx)("select",{className:Yy,value:v,onChange:r(pe=>y(pe.target.value),"onChange"),children:oKt.map(pe=>(0,t.jsxs)("option",{value:pe,disabled:!ile.has(pe),children:[mf(pe),ile.has(pe)?"":" (Coming soon)"]},pe))})]}),(0,t.jsxs)("label",{className:"block text-sm",children:[(0,t.jsx)("span",{className:"mb-1 block text-zinc-400",children:"Capabilities"}),(0,t.jsx)("textarea",{className:Yy,rows:4,value:w,onChange:r(pe=>S(pe.target.value),"onChange")})]}),_?(0,t.jsx)("p",{className:"text-xs text-red-400",children:_}):null,(0,t.jsx)(F,{className:"w-full rounded-none",disabled:re.isPending||f.trim().length===0,onClick:r(()=>re.mutate(),"onClick"),children:re.isPending?"Working...":me})]}):J?(0,t.jsxs)("div",{className:"space-y-5",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-lg font-semibold",children:i==="sign_up"?"Create your account":"Sign in to continue"}),(0,t.jsx)("p",{className:"mt-1 text-sm text-zinc-400",children:i==="sign_up"?`Start with a Paperclip account. After that, you'll come right back here to accept the invite for ${H}.`:"Use the Paperclip account that already matches this invite. If you do not have one yet, switch back to create account."})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("button",{type:"button",className:`${lle} ${i==="sign_up"?"border-zinc-100 bg-zinc-100 text-zinc-950":"border-zinc-800 text-zinc-300 hover:border-zinc-600"}`,onClick:r(()=>{A(null),o("sign_up")},"onClick"),children:"Create account"}),(0,t.jsx)("button",{type:"button",className:`${lle} ${i==="sign_in"?"border-zinc-100 bg-zinc-100 text-zinc-950":"border-zinc-800 text-zinc-300 hover:border-zinc-600"}`,onClick:r(()=>{A(null),o("sign_in")},"onClick"),children:"I already have an account"})]}),(0,t.jsxs)("form",{className:"space-y-4",method:"post",action:i==="sign_up"?"/api/auth/sign-up/email":"/api/auth/sign-in/email",onSubmit:r(pe=>{if(pe.preventDefault(),!ie.isPending){if(!se){A({tone:"error",message:"Please fill in all required fields."});return}ie.mutate()}},"onSubmit"),"data-testid":"invite-inline-auth",children:[i==="sign_up"?(0,t.jsxs)("label",{className:"block text-sm",htmlFor:"invite-name",children:[(0,t.jsx)("span",{className:"mb-1 block text-zinc-400",children:"Name"}),(0,t.jsx)("input",{id:"invite-name",name:"name",className:Yy,value:l,onChange:r(pe=>{c(pe.target.value),A(null)},"onChange"),autoComplete:"name",required:!0,"aria-required":"true","aria-invalid":C?.tone==="error"?!0:void 0,"aria-describedby":C?$:void 0,autoFocus:!0})]}):null,(0,t.jsxs)("label",{className:"block text-sm",htmlFor:"invite-email",children:[(0,t.jsx)("span",{className:"mb-1 block text-zinc-400",children:"Email"}),(0,t.jsx)("input",{id:"invite-email",name:"email",type:"email",className:Yy,value:d,onChange:r(pe=>{m(pe.target.value),A(null)},"onChange"),autoComplete:"username",required:!0,"aria-required":"true","aria-invalid":C?.tone==="error"?!0:void 0,"aria-describedby":C?$:void 0,autoFocus:i==="sign_in"})]}),(0,t.jsxs)("label",{className:"block text-sm",htmlFor:"invite-password",children:[(0,t.jsx)("span",{className:"mb-1 block text-zinc-400",children:"Password"}),(0,t.jsx)("input",{id:"invite-password",name:"password",type:"password",className:Yy,value:h,onChange:r(pe=>{p(pe.target.value),A(null)},"onChange"),autoComplete:i==="sign_in"?"current-password":"new-password",required:!0,"aria-required":"true","aria-invalid":C?.tone==="error"?!0:void 0,"aria-describedby":C?$:void 0})]}),C?(0,t.jsx)("p",{id:$,role:"alert",className:`text-xs ${C.tone==="info"?"text-amber-300":"text-red-400"}`,children:C.message}):null,(0,t.jsx)(F,{type:"submit",className:"w-full rounded-none",disabled:ie.isPending,"aria-disabled":!se||ie.isPending,children:ie.isPending?"Working...":i==="sign_in"?"Sign in and continue":"Create account and continue"})]}),(0,t.jsx)("p",{className:"text-xs leading-5 text-zinc-500",children:i==="sign_up"?"Already signed up before? Use the existing-account option instead so the invite lands on the right Paperclip user.":"No account yet? Switch back to create account so you can accept the invite with a new login."})]}):(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-lg font-semibold",children:V?"Already in this organization":G?"Completing organization access":z.inviteType==="bootstrap_ceo"?"Accept bootstrap invite":"Accept organization invite"}),(0,t.jsx)("p",{className:"mt-1 text-sm text-zinc-400",children:G?`Granting your access to ${H}.`:V?`This account already belongs to ${H}.`:`This will ${z.inviteType==="bootstrap_ceo"?"finish setting up Paperclip":`grant or complete your access to ${H}`}.`})]}),_?(0,t.jsx)("p",{className:"text-xs text-red-400",children:_}):null,G?(0,t.jsx)("div",{className:"text-sm text-zinc-400",children:re.isPending?"Submitting request...":"Finishing sign-in..."}):(0,t.jsx)(F,{className:"w-full rounded-none",disabled:re.isPending,onClick:r(()=>{if(V&&z.companyId){l2(a),n(z.companyId,{source:"manual"}),s("/",{replace:!0});return}re.mutate()},"onClick"),children:re.isPending?"Working...":me})]})})]})})})}r(hKt,"InviteLandingPage");function pKt(){const{selectedCompany:e,selectedCompanyId:s}=ps(),{setBreadcrumbs:n}=qn(),{pushToast:a}=Ei(),i=Wt(),[o,l]=(0,u.useState)("pending_approval"),[c,d]=(0,u.useState)("all");(0,u.useEffect)(()=>{n([{label:e?.name??"Organization",href:"/dashboard"},{label:"Inbox",href:"/inbox"},{label:"Join Requests"}])},[e?.name,n]);const m=Z({queryKey:P.access.joinRequests(s??"",`${o}:${c}`),queryFn:r(()=>hr.listJoinRequests(s,o,c==="all"?void 0:c),"queryFn"),enabled:!!s}),h=Ne({mutationFn:r(f=>hr.approveJoinRequest(s,f),"mutationFn"),onSuccess:r(async()=>{await i.invalidateQueries({queryKey:P.access.joinRequests(s,`${o}:${c}`)}),await i.invalidateQueries({queryKey:P.access.companyMembers(s)}),await i.invalidateQueries({queryKey:P.access.companyUserDirectory(s)}),a({title:"Join request approved",tone:"success"})},"onSuccess")}),p=Ne({mutationFn:r(f=>hr.rejectJoinRequest(s,f),"mutationFn"),onSuccess:r(async()=>{await i.invalidateQueries({queryKey:P.access.joinRequests(s,`${o}:${c}`)}),a({title:"Join request rejected",tone:"success"})},"onSuccess")});if(!s)return(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:"Select an organization to review join requests."});if(m.isLoading)return(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:"Loading join requests…"});if(m.error){const f=m.error instanceof wn&&m.error.status===403?"You do not have permission to review join requests for this organization.":m.error instanceof Error?m.error.message:"Failed to load join requests.";return(0,t.jsx)("div",{className:"text-sm text-destructive",children:f})}return(0,t.jsxs)("div",{className:"max-w-6xl space-y-6",children:[(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(FPe,{className:"h-5 w-5 text-muted-foreground"}),(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Join Request Queue"})]}),(0,t.jsx)("p",{className:"max-w-3xl text-sm text-muted-foreground",children:"Review human and agent join requests outside the mixed inbox feed. This queue uses the same approval mutations as the inline inbox cards."})]}),(0,t.jsxs)(Xs,{className:"flex-row flex-wrap gap-3 p-4",children:[(0,t.jsxs)("label",{className:"space-y-2 text-sm",children:[(0,t.jsx)("span",{className:"font-medium",children:"Status"}),(0,t.jsxs)("select",{className:"rounded-md border border-border bg-background px-3 py-2",value:o,onChange:r(f=>l(f.target.value),"onChange"),children:[(0,t.jsx)("option",{value:"pending_approval",children:"Pending approval"}),(0,t.jsx)("option",{value:"approved",children:"Approved"}),(0,t.jsx)("option",{value:"rejected",children:"Rejected"})]})]}),(0,t.jsxs)("label",{className:"space-y-2 text-sm",children:[(0,t.jsx)("span",{className:"font-medium",children:"Request type"}),(0,t.jsxs)("select",{className:"rounded-md border border-border bg-background px-3 py-2",value:c,onChange:r(f=>d(f.target.value),"onChange"),children:[(0,t.jsx)("option",{value:"all",children:"All"}),(0,t.jsx)("option",{value:"human",children:"Human"}),(0,t.jsx)("option",{value:"agent",children:"Agent"})]})]})]}),(0,t.jsx)("div",{className:"space-y-4",children:(m.data??[]).length===0?(0,t.jsx)("div",{className:"rounded-xl border border-dashed border-border px-4 py-8 text-sm text-muted-foreground",children:"No join requests match the current filters."}):m.data.map(f=>(0,t.jsxs)(Xs,{className:"block p-4",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(lt,{variant:f.status==="pending_approval"?"secondary":f.status==="approved"?"outline":"destructive",children:f.status.replace("_"," ")}),(0,t.jsx)(lt,{variant:"outline",children:f.requestType}),f.adapterType?(0,t.jsx)(lt,{variant:"outline",children:f.adapterType}):null]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-base font-medium",children:f.requestType==="human"?f.requesterUser?.name||f.requestEmailSnapshot||f.requestingUserId||"Unknown human requester":f.agentName||"Unknown agent requester"}),(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:f.requestType==="human"?f.requesterUser?.email||f.requestEmailSnapshot||f.requestingUserId:f.capabilities||f.requestIp})]})]}),f.status==="pending_approval"?(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(F,{variant:"outline",onClick:r(()=>p.mutate(f.id),"onClick"),disabled:p.isPending,children:"Reject"}),(0,t.jsx)(F,{onClick:r(()=>h.mutate(f.id),"onClick"),disabled:h.isPending,children:"Approve"})]}):null]}),(0,t.jsxs)("div",{className:"mt-4 grid gap-3 text-sm text-muted-foreground md:grid-cols-2",children:[(0,t.jsxs)("div",{className:"rounded-lg border border-border bg-background px-3 py-2",children:[(0,t.jsx)("div",{className:"text-xs font-medium uppercase tracking-wide",children:"Invite context"}),(0,t.jsx)("div",{className:"mt-2",children:f.invite?`${f.invite.allowedJoinTypes} join invite${f.invite.humanRole?` • default role ${f.invite.humanRole}`:""}`:"Invite metadata unavailable"}),f.invite?.inviteMessage?(0,t.jsx)("div",{className:"mt-2 text-foreground",children:f.invite.inviteMessage}):null]}),(0,t.jsxs)("div",{className:"rounded-lg border border-border bg-background px-3 py-2",children:[(0,t.jsx)("div",{className:"text-xs font-medium uppercase tracking-wide",children:"Request details"}),(0,t.jsxs)("div",{className:"mt-2",children:["Submitted ",new Date(f.createdAt).toLocaleString()]}),(0,t.jsxs)("div",{children:["Source IP ",f.requestIp]}),f.requestType==="agent"&&f.capabilities?(0,t.jsx)("div",{children:f.capabilities}):null]})]})]},f.id))})]})}r(pKt,"JoinRequestQueue");var fKt=(0,u.lazy)(()=>jc(()=>import("./CompanyExport-Y9HhGogN.js").then(e=>({default:e.CompanyExport})),__vite__mapDeps([6,5,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]))),xKt=(0,u.lazy)(()=>jc(()=>import("./Agents.production-DXpBpIOx.js").then(e=>({default:e.Agents})),__vite__mapDeps([26,5,7,9,8,10,11,12,13,27,28,29,15,30,31,32,33,24,25]))),gKt=(0,u.lazy)(()=>jc(()=>import("./Routines.production-lZoc_mDR.js").then(e=>({default:e.Routines})),__vite__mapDeps([34,5,7,8,9,10,11,12,13,35,14,15,36,37,29,27,38,39,40,21,41,42,16,17,18,19,43,44,30,45,46,23,31,47,33,48,49,50,51,24,25,28]))),ule=(0,u.lazy)(()=>jc(()=>import("./RoutineDetail.production-MnUmgi4u.js").then(e=>({default:e.RoutineDetail})),__vite__mapDeps([52,5,7,8,9,10,11,12,13,35,14,15,36,37,29,27,38,39,40,21,41,42,16,17,18,19,43,44,30,45,46,23,31,47,33,48,49,50,51,24,25,53]))),bKt=(0,u.lazy)(()=>jc(()=>import("./CompanySkills.production-bUTxjLE1.js").then(e=>({default:e.CompanySkills})),__vite__mapDeps([54,5,7,8,9,10,11,12,13,14,15,36,37,29,27,38,39,40,21,41,28,16,17,18,19,55,53,31,44,22,20,56,47,48,50,24,25]))),vKt=(0,u.lazy)(()=>jc(()=>import("./CompanyActivity.production-B-5rst1B.js").then(e=>({default:e.CompanyActivity})),__vite__mapDeps([57,5,7,8,9,10,11,12,13,27,28,29,43,37,21,44,48,49,51]))),yKt=(0,u.lazy)(()=>jc(()=>import("./Costs.production-ejn6vYm8.js").then(e=>({default:e.Costs})),__vite__mapDeps([58,5,7,28,29,13,12,44,41,50,27,51,24,25]))),jKt=(0,u.lazy)(()=>jc(()=>import("./OrgChart.production-CM87MbOq.js").then(e=>({default:e.OrgChart})),__vite__mapDeps([59,5,7,8,9,10,11,12,13,27,45,46,51,24,25])));function xg({children:e}){return(0,t.jsx)(u.Suspense,{fallback:(0,t.jsx)(Xm,{}),children:e})}r(xg,"ProductionSurface");function wKt(e){return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ot,{index:!0,element:(0,t.jsx)(kn,{to:"dashboard",replace:!0})}),(0,t.jsx)(ot,{path:"dashboard",element:(0,t.jsx)(Gpt,{})}),(0,t.jsx)(ot,{path:"dashboard/live",element:(0,t.jsx)(Ypt,{})}),(0,t.jsx)(ot,{path:"timeline",element:e?(0,t.jsx)(yp,{to:"/activity/timeline"}):(0,t.jsx)(bje,{})}),(0,t.jsx)(ot,{path:"onboarding",element:(0,t.jsx)(D1e,{})}),(0,t.jsx)(ot,{path:"companies",element:(0,t.jsx)(Lft,{})}),(0,t.jsx)(ot,{path:"company/settings",element:(0,t.jsx)(X3t,{})}),(0,t.jsx)(ot,{path:"company/settings/environments",element:(0,t.jsx)(kn,{to:"/company/settings/instance/environments",replace:!0})}),(0,t.jsx)(ot,{path:"company/settings/cloud-upstream",element:(0,t.jsx)(kn,{to:"/company/export",replace:!0})}),(0,t.jsxs)(ot,{element:(0,t.jsx)(dh,{pageKey:"company.members"}),children:[(0,t.jsx)(ot,{path:"company/settings/members",element:(0,t.jsx)(y4t,{})}),(0,t.jsx)(ot,{path:"company/settings/access",element:(0,t.jsx)(j4t,{})})]}),(0,t.jsx)(ot,{element:(0,t.jsx)(dh,{pageKey:"company.invites"}),children:(0,t.jsx)(ot,{path:"company/settings/invites",element:(0,t.jsx)(kn,{to:"/company/settings/members?tab=invites",replace:!0})})}),(0,t.jsx)(ot,{element:(0,t.jsx)(dh,{pageKey:"company.export"}),children:(0,t.jsx)(ot,{path:"company/export/*",element:(0,t.jsx)(u.Suspense,{fallback:(0,t.jsx)(Xm,{}),children:(0,t.jsx)(fKt,{})})})}),(0,t.jsx)(ot,{element:(0,t.jsx)(_tt,{}),children:(0,t.jsx)(ot,{element:(0,t.jsx)(dh,{pageKey:"company.import"}),children:(0,t.jsx)(ot,{path:"company/import",element:(0,t.jsx)(Azt,{})})})}),(0,t.jsx)(ot,{element:(0,t.jsx)(dh,{pageKey:"company.secrets"}),children:(0,t.jsx)(ot,{path:"company/settings/secrets",element:(0,t.jsx)(k6t,{})})}),(0,t.jsx)(ot,{path:"company/settings/tools",element:(0,t.jsx)(hle,{})}),(0,t.jsx)(ot,{path:"company/settings/tools/:tab",element:(0,t.jsx)(hle,{})}),(0,t.jsx)(ot,{path:"tools",element:(0,t.jsx)(ple,{})}),(0,t.jsx)(ot,{path:"tools/:tab",element:(0,t.jsx)(ple,{})}),(0,t.jsx)(ot,{path:"apps",element:(0,t.jsx)(rLt,{})}),(0,t.jsx)(ot,{path:"apps/browse",element:(0,t.jsx)(kn,{to:"/apps",replace:!0})}),(0,t.jsx)(ot,{path:"apps/connections",element:(0,t.jsx)(kn,{to:"/apps",replace:!0})}),(0,t.jsx)(ot,{path:"apps/byo",element:(0,t.jsx)(lCe,{byoOnly:!0})}),(0,t.jsx)(ot,{path:"apps/vercel-connect",element:(0,t.jsx)(mle,{credentialSource:"vercel_connect"})}),(0,t.jsx)(ot,{path:"apps/connect",element:(0,t.jsx)(mle,{})}),(0,t.jsx)(ot,{path:"apps/chat/connect",element:(0,t.jsx)(P$,{children:(0,t.jsx)(TLt,{})})}),(0,t.jsx)(ot,{path:"apps/chat/:endpointId",element:(0,t.jsx)(P$,{children:(0,t.jsx)(kn,{to:"settings",replace:!0})})}),(0,t.jsx)(ot,{path:"apps/chat/:endpointId/:tab",element:(0,t.jsx)(P$,{children:(0,t.jsx)(GLt,{})})}),(0,t.jsx)(ot,{path:"apps/connect/:appKey",element:(0,t.jsx)(kn,{to:"/apps",replace:!0})}),(0,t.jsx)(ot,{path:"apps/connect/:appKey/:stage",element:(0,t.jsx)(kn,{to:"/apps",replace:!0})}),(0,t.jsx)(ot,{path:"apps/review",element:(0,t.jsx)(s$t,{})}),(0,t.jsx)(ot,{path:"apps/attention",element:(0,t.jsx)(kn,{to:"/apps",replace:!0})}),(0,t.jsx)(ot,{path:"apps/gateways",element:(0,t.jsx)(wie,{})}),(0,t.jsx)(ot,{path:"apps/gateways/:gatewayId",element:(0,t.jsx)(kn,{to:"overview",replace:!0})}),(0,t.jsx)(ot,{path:"apps/gateways/:gatewayId/:tab",element:(0,t.jsx)(Y$t,{})}),(0,t.jsx)(ot,{path:"apps/advanced",element:(0,t.jsx)(rie,{})}),(0,t.jsx)(ot,{path:"apps/advanced/gateways",element:(0,t.jsx)(wie,{})}),(0,t.jsx)(ot,{path:"apps/advanced/profiles/new",element:(0,t.jsx)(cie,{mode:"new"})}),(0,t.jsx)(ot,{path:"apps/advanced/profiles/:profileId/edit",element:(0,t.jsx)(cie,{mode:"edit"})}),(0,t.jsx)(ot,{path:"apps/advanced/profiles/:profileId",element:(0,t.jsx)(qDt,{})}),(0,t.jsx)(ot,{path:"apps/advanced/audit",element:(0,t.jsx)(kn,{to:"/apps",replace:!0})}),(0,t.jsx)(ot,{path:"apps/advanced/run-your-own",element:(0,t.jsx)(kn,{to:"/apps",replace:!0})}),(0,t.jsx)(ot,{path:"apps/advanced/:tab",element:(0,t.jsx)(rie,{})}),(0,t.jsx)(ot,{path:"apps/app/:applicationId",element:(0,t.jsx)(vie,{})}),(0,t.jsx)(ot,{path:"apps/app/:applicationId/:tab",element:(0,t.jsx)(vie,{})}),(0,t.jsx)(ot,{path:"apps/:connectionId",element:(0,t.jsx)(kn,{to:"permissions",replace:!0})}),(0,t.jsx)(ot,{path:"apps/:connectionId/:tab",element:(0,t.jsx)(d$t,{})}),(0,t.jsx)(ot,{path:"company/settings/instance",element:(0,t.jsx)(kn,{to:"/company/settings",replace:!0})}),(0,t.jsx)(ot,{element:(0,t.jsx)(dh,{pageKey:"instance.profile"}),children:(0,t.jsx)(ot,{path:"company/settings/instance/profile",element:(0,t.jsx)(TUt,{})})}),(0,t.jsx)(ot,{path:"company/settings/instance/general",element:(0,t.jsx)(kn,{to:"/company/settings",replace:!0})}),(0,t.jsx)(ot,{path:"company/settings/instance/heartbeats",element:(0,t.jsx)(kn,{to:"/company/settings",replace:!0})}),(0,t.jsxs)(ot,{element:(0,t.jsx)(dh,{pageKey:"instance.environments"}),children:[(0,t.jsx)(ot,{path:"company/settings/instance/environments",element:(0,t.jsx)(w$,{})}),(0,t.jsx)(ot,{path:"company/settings/instance/environments/new",element:(0,t.jsx)(w$,{mode:"create"})}),(0,t.jsx)(ot,{path:"company/settings/instance/environments/:environmentId/edit",element:(0,t.jsx)(w$,{mode:"edit"})})]}),(0,t.jsx)(ot,{element:(0,t.jsx)(dh,{pageKey:"instance.access"}),children:(0,t.jsx)(ot,{path:"company/settings/instance/access",element:(0,t.jsx)(_Ut,{})})}),(0,t.jsx)(ot,{element:(0,t.jsx)(dh,{pageKey:"instance.experimental"}),children:(0,t.jsx)(ot,{path:"company/settings/instance/experimental",element:(0,t.jsx)(CUt,{})})}),(0,t.jsxs)(ot,{element:(0,t.jsx)(dh,{pageKey:"instance.plugins"}),children:[(0,t.jsx)(ot,{path:"company/settings/instance/plugins",element:(0,t.jsx)(PUt,{})}),(0,t.jsx)(ot,{path:"company/settings/instance/plugins/:pluginId",element:(0,t.jsx)(MUt,{})})]}),(0,t.jsx)(ot,{element:(0,t.jsx)(dh,{pageKey:"instance.adapters"}),children:(0,t.jsx)(ot,{path:"company/settings/instance/adapters",element:(0,t.jsx)(Zoe,{})})}),(0,t.jsx)(ot,{path:"company/settings/:settingsRoutePath/*",element:(0,t.jsx)(h4t,{})}),(0,t.jsx)(ot,{path:"skills/studio",element:(0,t.jsx)(H$,{})}),(0,t.jsx)(ot,{path:"skills/studio/new",element:(0,t.jsx)(H$,{})}),(0,t.jsx)(ot,{path:"skills/studio/:skillId",element:(0,t.jsx)(H$,{})}),(0,t.jsx)(ot,{path:"skills/:skillId/studio",element:(0,t.jsx)(P1e,{})}),(0,t.jsx)(ot,{path:"skills/*",element:e?(0,t.jsx)(uFt,{}):(0,t.jsx)(xg,{children:(0,t.jsx)(bKt,{})})}),(0,t.jsx)(ot,{path:"settings",element:(0,t.jsx)(xb,{})}),(0,t.jsx)(ot,{path:"settings/*",element:(0,t.jsx)(xb,{})}),(0,t.jsx)(ot,{path:"plugins/:pluginId",element:(0,t.jsx)(ele,{})}),(0,t.jsx)(ot,{path:"org",element:e?(0,t.jsx)(kn,{to:"/agents/all",replace:!0}):(0,t.jsx)(xg,{children:(0,t.jsx)(jKt,{})})}),(0,t.jsx)(ot,{path:"agents",element:(0,t.jsx)(kn,{to:"/agents/all",replace:!0})}),K8.map(s=>(0,t.jsx)(ot,{path:`agents/${s}`,element:e?(0,t.jsx)(cxt,{}):(0,t.jsx)(xg,{children:(0,t.jsx)(xKt,{})})},s)),(0,t.jsx)(ot,{path:"agents/new",element:(0,t.jsx)(XUt,{})}),(0,t.jsx)(ot,{path:"agents/:agentId",element:(0,t.jsx)(lL,{})}),(0,t.jsx)(ot,{path:"agents/:agentId/:tab",element:(0,t.jsx)(lL,{})}),(0,t.jsx)(ot,{path:"agents/:agentId/runs/:runId",element:(0,t.jsx)(lL,{})}),(0,t.jsx)(ot,{path:"projects",element:(0,t.jsx)(jbt,{})}),(0,t.jsx)(ot,{path:"projects/:projectId",element:(0,t.jsx)(q0,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/overview",element:(0,t.jsx)(q0,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/issues",element:(0,t.jsx)(q0,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/issues/:filter",element:(0,t.jsx)(q0,{})}),(0,t.jsx)(ot,{element:(0,t.jsx)(mD,{}),children:(0,t.jsx)(ot,{path:"projects/:projectId/workspaces/:workspaceId",element:(0,t.jsx)(xyt,{})})}),(0,t.jsx)(ot,{path:"projects/:projectId/workspaces",element:(0,t.jsx)(q0,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/configuration",element:(0,t.jsx)(q0,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/budget",element:(0,t.jsx)(q0,{})}),(0,t.jsx)(ot,{element:(0,t.jsx)(mD,{}),children:(0,t.jsx)(ot,{path:"workspaces",element:(0,t.jsx)(vyt,{})})}),(0,t.jsx)(ot,{path:"issues",element:(0,t.jsx)(_yt,{})}),(0,t.jsx)(ot,{path:"tasks",element:(0,t.jsx)(kn,{to:"/issues",replace:!0})}),(0,t.jsx)(ot,{path:"search",element:(0,t.jsx)(Zyt,{})}),(0,t.jsx)(ot,{path:"issues/all",element:(0,t.jsx)(kn,{to:"/issues",replace:!0})}),(0,t.jsx)(ot,{path:"issues/active",element:(0,t.jsx)(kn,{to:"/issues",replace:!0})}),(0,t.jsx)(ot,{path:"issues/backlog",element:(0,t.jsx)(kn,{to:"/issues",replace:!0})}),(0,t.jsx)(ot,{path:"issues/done",element:(0,t.jsx)(kn,{to:"/issues",replace:!0})}),(0,t.jsx)(ot,{path:"issues/recent",element:(0,t.jsx)(kn,{to:"/issues",replace:!0})}),(0,t.jsx)(ot,{path:"chats/:agentRef",element:(0,t.jsx)(jSt,{})}),(0,t.jsx)(ot,{path:"issues/:issueId",element:(0,t.jsx)(vSt,{})}),null,(0,t.jsx)(ot,{path:"routines",element:e?(0,t.jsx)(eCt,{}):(0,t.jsx)(xg,{children:(0,t.jsx)(gKt,{})})}),(0,t.jsx)(ot,{path:"cases",element:(0,t.jsx)(kX,{children:(0,t.jsx)(Htt,{})})}),(0,t.jsx)(ot,{path:"cases/:caseIdentifier",element:(0,t.jsx)(kX,{children:(0,t.jsx)(Rrt,{})})}),(0,t.jsx)(ot,{path:"status",element:(0,t.jsx)(SX,{children:(0,t.jsx)(Dne,{})})}),(0,t.jsx)(ot,{path:"status/:cardId",element:(0,t.jsx)(SX,{children:(0,t.jsx)(Dne,{})})}),(0,t.jsx)(ot,{path:"status-cards",element:(0,t.jsx)(fle,{})}),(0,t.jsx)(ot,{path:"status-cards/:cardId",element:(0,t.jsx)(fle,{})}),(0,t.jsx)(ot,{path:"review-queue",element:(0,t.jsx)(ag,{children:(0,t.jsx)(b_t,{})})}),(0,t.jsx)(ot,{path:"learnings",element:(0,t.jsx)(ag,{children:(0,t.jsx)(y_t,{})})}),(0,t.jsx)(ot,{path:"pipelines",element:(0,t.jsx)(ag,{children:(0,t.jsx)(UL,{})})}),(0,t.jsx)(ot,{path:"pipelines/:pipelineId",element:(0,t.jsx)(ag,{children:(0,t.jsx)(UL,{})})}),(0,t.jsx)(ot,{path:"pipelines/:pipelineId/add",element:(0,t.jsx)(ag,{children:(0,t.jsx)(UL,{})})}),(0,t.jsx)(ot,{path:"pipelines/:pipelineId/settings",element:(0,t.jsx)(ag,{children:(0,t.jsx)(hIt,{})})}),(0,t.jsx)(ot,{path:"pipelines/:pipelineId/items/:caseId",element:(0,t.jsx)(ag,{children:(0,t.jsx)(O1t,{})})}),(0,t.jsx)(ot,{path:"pipelines/:pipelineId/cases/:caseId",element:(0,t.jsx)(ag,{children:(0,t.jsx)(D1t,{})})}),(0,t.jsx)(ot,{path:"routines/:routineId",element:e?(0,t.jsx)(Gne,{}):(0,t.jsx)(xg,{children:(0,t.jsx)(ule,{})})}),(0,t.jsx)(ot,{path:"routines/:routineId/:section",element:e?(0,t.jsx)(Gne,{}):(0,t.jsx)(xg,{children:(0,t.jsx)(ule,{})})}),(0,t.jsx)(ot,{element:(0,t.jsx)(mD,{}),children:(0,t.jsxs)(ot,{element:(0,t.jsx)(Att,{}),children:[(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId",element:(0,t.jsx)(Ky,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId/services",element:(0,t.jsx)(Ky,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId/configuration",element:(0,t.jsx)(Ky,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId/runtime-logs",element:(0,t.jsx)(Ky,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId/issues",element:(0,t.jsx)(Ky,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId/routines",element:(0,t.jsx)(Ky,{})})]})}),(0,t.jsx)(ot,{path:"goals",element:(0,t.jsx)(T2t,{})}),(0,t.jsx)(ot,{path:"goals/:goalId",element:(0,t.jsx)(V2t,{})}),(0,t.jsx)(ot,{path:"artifacts",element:(0,t.jsx)(Zne,{})}),(0,t.jsx)(ot,{path:"approvals",element:(0,t.jsx)(kn,{to:"/approvals/pending",replace:!0})}),(0,t.jsx)(ot,{path:"approvals/pending",element:(0,t.jsx)(tre,{})}),(0,t.jsx)(ot,{path:"approvals/all",element:(0,t.jsx)(tre,{})}),(0,t.jsx)(ot,{path:"approvals/:approvalId",element:(0,t.jsx)(W2t,{})}),(0,t.jsx)(ot,{path:"activity",element:e?(0,t.jsx)(PRt,{}):(0,t.jsx)(xg,{children:(0,t.jsx)(vKt,{})})}),e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ot,{path:"activity/runs",element:(0,t.jsx)(tS,{section:"runs"})}),(0,t.jsx)(ot,{path:"activity/costs",element:(0,t.jsx)(tS,{section:"costs"})}),(0,t.jsx)(ot,{path:"activity/budgets",element:(0,t.jsx)(tS,{section:"budgets"})}),(0,t.jsx)(ot,{path:"activity/timeline",element:(0,t.jsx)(tS,{section:"timeline"})}),(0,t.jsx)(ot,{path:"audit",element:(0,t.jsx)(yp,{to:"/activity",forceAgentMode:!0})}),(0,t.jsx)(ot,{path:"audit/activity",element:(0,t.jsx)(yp,{to:"/activity"})}),(0,t.jsx)(ot,{path:"audit/runs",element:(0,t.jsx)(yp,{to:"/activity/runs"})}),(0,t.jsx)(ot,{path:"audit/costs",element:(0,t.jsx)(yp,{to:"/activity/costs"})}),(0,t.jsx)(ot,{path:"audit/budgets",element:(0,t.jsx)(yp,{to:"/activity/budgets"})}),(0,t.jsx)(ot,{path:"audit/timeline",element:(0,t.jsx)(yp,{to:"/activity/timeline"})}),(0,t.jsx)(ot,{path:"runs",element:(0,t.jsx)(yp,{to:"/activity/runs"})}),(0,t.jsx)(ot,{path:"costs",element:(0,t.jsx)(yp,{to:"/activity/costs"})}),(0,t.jsx)(ot,{path:"budgets",element:(0,t.jsx)(yp,{to:"/activity/budgets"})})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ot,{path:"costs",element:(0,t.jsx)(xg,{children:(0,t.jsx)(yKt,{})})}),(0,t.jsx)(ot,{path:"audit",element:(0,t.jsx)(kn,{to:"/activity?mode=agents",replace:!0})})]}),(0,t.jsxs)(ot,{element:(0,t.jsx)(mXe,{}),children:[(0,t.jsx)(ot,{path:"board-chat",element:(0,t.jsx)(B3t,{})}),(0,t.jsx)(ot,{path:"artifacts",element:(0,t.jsx)(Zne,{})})]}),null,(0,t.jsx)(ot,{path:"decisions",element:(0,t.jsx)(u3t,{})}),(0,t.jsx)(ot,{path:"decisions/queues/:key",element:(0,t.jsx)(f3t,{})}),(0,t.jsx)(ot,{path:"inbox",element:(0,t.jsx)(NKt,{})}),(0,t.jsx)(ot,{path:"inbox/mine",element:(0,t.jsx)(kk,{})}),(0,t.jsx)(ot,{path:"inbox/recent",element:(0,t.jsx)(kk,{})}),(0,t.jsx)(ot,{path:"inbox/unread",element:(0,t.jsx)(kk,{})}),(0,t.jsx)(ot,{path:"inbox/blocked",element:(0,t.jsx)(kk,{})}),(0,t.jsx)(ot,{path:"inbox/all",element:(0,t.jsx)(kk,{})}),(0,t.jsx)(ot,{path:"inbox/requests",element:(0,t.jsx)(pKt,{})}),(0,t.jsx)(ot,{path:"inbox/new",element:(0,t.jsx)(kn,{to:"/inbox/mine",replace:!0})}),(0,t.jsx)(ot,{path:"u/:userSlug",element:(0,t.jsx)(a2t,{})}),(0,t.jsx)(ot,{path:"design-guide",element:(0,t.jsx)(NUt,{})}),(0,t.jsx)(ot,{path:"instance/settings/adapters",element:(0,t.jsx)(Zoe,{})}),(0,t.jsx)(ot,{path:":pluginRoutePath/*",element:(0,t.jsx)(ele,{})}),(0,t.jsx)(ot,{path:"*",element:(0,t.jsx)(xu,{scope:"board"})})]})}r(wKt,"boardRoutes");function mle({credentialSource:e="paperclip_vault"}={}){const s=na(),n=new URLSearchParams(s.search),{enabled:a}=$x();return LGe(n,{chatConnectorsEnabled:a})?(0,t.jsx)(lCe,{credentialSource:e}):(0,t.jsx)(kn,{to:"/apps",replace:!0})}r(mle,"AppsConnectEntryRoute");function NKt(){return(0,t.jsx)(kn,{to:`/inbox/${d2e()}`,replace:!0})}r(NKt,"InboxRootRedirect");function P1e(){const e=na(),{companies:s,selectedCompany:n,loading:a}=ps(),{companyPrefix:i,skillId:o}=Sa();if(a)return null;const l=(i?s.find(c=>c.issuePrefix.toUpperCase()===i.toUpperCase()):null)??n??s[0]??null;return!l||!o?(0,t.jsx)(kn,{to:"/skills/studio",replace:!0}):(0,t.jsx)(kn,{to:`/${l.issuePrefix}/skills/studio/${encodeURIComponent(o)}${e.search}${e.hash}`,replace:!0})}r(P1e,"LegacySkillStudioRedirect");function xb(){const e=na(),{companies:s,selectedCompany:n,loading:a}=ps(),{companyPrefix:i}=Sa(),{hidden:o}=eh();if(a)return(0,t.jsx)(Xm,{});const l=(i?s.find(d=>d.issuePrefix.toUpperCase()===i.toUpperCase()):null)??n??s[0]??null;if(!l)return TK({pathname:e.pathname,hasCompanies:!1})?(0,t.jsx)(kn,{to:"/onboarding",replace:!0}):(0,t.jsx)(g9,{});const c=wLe(Lue(`${e.pathname}${e.search}${e.hash}`),o);return(0,t.jsx)(kn,{to:`/${l.issuePrefix}${c}`,replace:!0})}r(xb,"LegacySettingsRedirect");function hle(){const{tab:e}=Sa();return(0,t.jsx)(kn,{to:M1e(e),replace:!0})}r(hle,"LegacyToolsSettingsRedirect");function ple(){const{tab:e}=Sa();return(0,t.jsx)(kn,{to:M1e(e),replace:!0})}r(ple,"LegacyToolsRedirect");function M1e(e){return e?e==="applications"||e==="connections"||e==="overview"||e==="examples"||e==="runtime"||e==="audit"?"/apps":e==="policies"?"/apps/advanced/profiles":`/apps/advanced/${e}`:"/apps/advanced/profiles"}r(M1e,"legacyToolsRedirectTarget");function D1e(){const{companies:e}=ps(),{openOnboarding:s}=$o(),{t:n}=due(),a=Yc(),i=U5(a?.cloudBaseUrl??null),{onboardingOpen:o,onboardingRouteDismissed:l}=C5(),{companyPrefix:c}=Sa(),d=c?e.find(p=>p.issuePrefix.toUpperCase()===c.toUpperCase())??null:null;if(BYe({onboardingOpen:o,routeDismissed:l}))return null;const m=d?`Add another agent to ${d.name}`:e.length>0?"Create another organization":"Create your first organization",h=d?"Run onboarding again to add an agent and a starter task for this organization.":e.length>0?"Run onboarding again to create another organization and seed its first agent.":"Get started by creating an organization and your first agent.";return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)("div",{className:"rounded-lg border border-border bg-card p-6",children:[(0,t.jsx)("h1",{className:"text-xl font-semibold",children:m}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:h}),(0,t.jsx)("div",{className:"mt-4",children:!d&&a&&!i?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:n("app.cloudCreateUnavailable",{defaultValue:"Organizations are created in Paperclip Cloud. This instance can't reach it right now — try again from your Cloud portfolio."})}):(0,t.jsx)(F,{onClick:r(()=>d?s({initialStep:KT(),companyId:d.id}):a&&i?Sc(i):s(),"onClick"),children:d?"Add Agent":"Start Onboarding"})})]})})}r(D1e,"OnboardingRoutePage");function kKt(){const{companies:e,selectedCompany:s,loading:n}=ps(),a=na();if(n)return(0,t.jsx)(Xm,{});const i=s??e[0]??null;return i?(0,t.jsx)(kn,{to:`/${i.issuePrefix}/dashboard`,replace:!0}):TK({pathname:a.pathname,hasCompanies:!1})?(0,t.jsx)(kn,{to:"/onboarding",replace:!0}):(0,t.jsx)(g9,{})}r(kKt,"CompanyRootRedirect");function fle(){const{cardId:e}=Sa(),s=vAe(),n=s?`/${s}`:"";return(0,t.jsx)(kn,{to:`${n}/status${e?`/${e}`:""}`,replace:!0})}r(fle,"StatusCardsLegacyRedirect");function yp({to:e,forceAgentMode:s=!1}){const n=na(),a=new URLSearchParams(n.search);s&&a.set("mode","agents");const i=a.toString();return(0,t.jsx)(kn,{to:`${e}${i?`?${i}`:""}${n.hash}`,replace:!0})}r(yp,"AuditCompatibilityRedirect");function ja(){const e=na(),{companies:s,selectedCompany:n,loading:a}=ps();if(a)return(0,t.jsx)(Xm,{});const i=n??s[0]??null;return i?(0,t.jsx)(kn,{to:`/${i.issuePrefix}${e.pathname}${e.search}${e.hash}`,replace:!0}):TK({pathname:e.pathname,hasCompanies:!1})?(0,t.jsx)(kn,{to:"/onboarding",replace:!0}):(0,t.jsx)(g9,{})}r(ja,"UnprefixedBoardRedirect");function g9(){const{openOnboarding:e}=$o(),{t:s}=due(),n=Yc(),a=U5(n?.cloudBaseUrl??null);return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)("div",{className:"rounded-lg border border-border bg-card p-6",children:[(0,t.jsx)("h1",{className:"text-xl font-semibold",children:s("app.noCompanies.title",{defaultValue:"Create your first organization"})}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:s("app.noCompanies.description",{defaultValue:"Get started by creating an organization."})}),(0,t.jsx)("div",{className:"mt-4",children:n&&!a?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:s("app.cloudCreateUnavailable",{defaultValue:"Organizations are created in Paperclip Cloud. This instance can't reach it right now — try again from your Cloud portfolio."})}):(0,t.jsx)(F,{onClick:r(()=>n&&a?Sc(a):e(),"onClick"),children:s("app.noCompanies.newCompany",{defaultValue:"New Organization"})})})]})})}r(g9,"NoCompaniesStartPage");function SKt(){const{enabled:e,loaded:s}=Cc();return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(wAe,{children:[(0,t.jsx)(ot,{path:"oauth-handoff",element:(0,t.jsx)(I$t,{})}),(0,t.jsx)(ot,{path:"auth",element:(0,t.jsx)(rKt,{})}),(0,t.jsx)(ot,{path:"board-claim/:token",element:(0,t.jsx)(aKt,{})}),(0,t.jsx)(ot,{path:"cli-auth/:id",element:(0,t.jsx)(iKt,{})}),(0,t.jsx)(ot,{path:"invite/:token",element:(0,t.jsx)(hKt,{})}),(0,t.jsx)(ot,{element:s?(0,t.jsx)(bZ,{allowMembershipRequest:!0}):(0,t.jsx)(Xm,{}),children:(0,t.jsx)(ot,{path:"chat-identity/confirm",element:(0,t.jsx)(e$t,{})})}),(0,t.jsx)(ot,{path:"tests/perf/long-thread",element:(0,t.jsx)(ESt,{})}),(0,t.jsx)(ot,{path:"ux-lab/bootstrap-setup",element:(0,t.jsx)(c4t,{})}),(0,t.jsx)(ot,{path:"ux-lab/responsible-user-denial",element:(0,t.jsx)(d4t,{})}),(0,t.jsx)(ot,{path:"ux-lab/cross-issue-collaboration",element:(0,t.jsx)(m4t,{})}),(0,t.jsxs)(ot,{element:s?(0,t.jsx)(bZ,{}):(0,t.jsx)(Xm,{}),children:[(0,t.jsx)(ot,{index:!0,element:(0,t.jsx)(kKt,{})}),(0,t.jsx)(ot,{path:"onboarding",element:(0,t.jsx)(D1e,{})}),(0,t.jsx)(ot,{path:"instance",element:(0,t.jsx)(xb,{})}),(0,t.jsx)(ot,{path:"instance/settings",element:(0,t.jsx)(xb,{})}),(0,t.jsx)(ot,{path:"instance/settings/*",element:(0,t.jsx)(xb,{})}),(0,t.jsx)(ot,{path:"companies",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"issues",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"tasks",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"issues/:issueId",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"routines",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"routines/:routineId",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"review-queue",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"learnings",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"cases",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"cases/:caseIdentifier",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"status",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"status/:cardId",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"status-cards",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"status-cards/:cardId",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"pipelines",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"pipelines/:pipelineId",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"pipelines/:pipelineId/add",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"pipelines/:pipelineId/settings",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"pipelines/:pipelineId/items/:caseId",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"pipelines/:pipelineId/cases/:caseId",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"artifacts",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"audit",element:(0,t.jsx)(ja,{})}),e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ot,{path:"audit/*",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"activity",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"activity/*",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"runs",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"costs",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"budgets",element:(0,t.jsx)(ja,{})})]}):null,(0,t.jsx)(ot,{path:"decisions",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"u/:userSlug",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"skills/studio",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"skills/studio/new",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"skills/studio/:skillId",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"skills/:skillId/studio",element:(0,t.jsx)(P1e,{})}),(0,t.jsx)(ot,{path:"skills/*",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"settings",element:(0,t.jsx)(xb,{})}),(0,t.jsx)(ot,{path:"settings/*",element:(0,t.jsx)(xb,{})}),(0,t.jsx)(ot,{path:"agents",element:(0,t.jsx)(ja,{})}),K8.map(n=>(0,t.jsx)(ot,{path:`agents/${n}`,element:(0,t.jsx)(ja,{})},n)),(0,t.jsx)(ot,{path:"agents/new",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"agents/:agentId",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"agents/:agentId/:tab",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"agents/:agentId/runs/:runId",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"projects",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"projects/:projectId",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/overview",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/issues",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/issues/:filter",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/workspaces",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/workspaces/:workspaceId",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/configuration",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"workspaces",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId",element:(0,t.jsx)(Iy,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId/services",element:(0,t.jsx)(Iy,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId/configuration",element:(0,t.jsx)(Iy,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId/runtime-logs",element:(0,t.jsx)(Iy,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId/issues",element:(0,t.jsx)(Iy,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId/routines",element:(0,t.jsx)(Iy,{})}),(0,t.jsx)(ot,{path:":companyPrefix",element:e?(0,t.jsx)(AJe,{}):(0,t.jsx)(cXe,{}),children:wKt(e)}),(0,t.jsx)(ot,{path:"*",element:(0,t.jsx)(xu,{scope:"global"})})]})]}),(0,t.jsx)(aat,{})]})}r(SKt,"App");var CKt=class extends u.Component{static{r(this,"AppErrorBoundary")}state={error:null};static getDerivedStateFromError(e){return{error:e instanceof Error?e:new Error(String(e))}}componentDidCatch(e,s){rge(e,{boundary:"app",componentStack:s.componentStack})}render(){const{error:e}=this.state;return e?(0,t.jsxs)("div",{className:"mx-auto flex min-h-screen max-w-2xl flex-col justify-center space-y-4 px-4 py-10",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Paperclip hit an error"}),(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"Something went wrong while running the app. Reloading usually fixes this."})]}),(0,t.jsx)("pre",{className:"overflow-auto rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive whitespace-pre-wrap",children:e.message}),(0,t.jsx)("div",{children:(0,t.jsx)("button",{type:"button",className:"inline-flex items-center rounded-md border border-input bg-background px-3 py-1.5 text-sm font-medium shadow-sm hover:bg-accent hover:text-accent-foreground",onClick:r(()=>window.location.reload(),"onClick"),children:"Reload page"})})]}):this.props.children}};function _Kt(){const{data:e}=Z({queryKey:P.auth.session,queryFn:r(()=>qa.getSession(),"queryFn"),retry:!1}),s=e?.sentryDsn,n=e?.sentryEnvironment??void 0;return(0,u.useEffect)(()=>{if(s)return sJe(s,n),()=>{nJe()}},[s,n]),null}r(_Kt,"SentryGate");function IKt(e){return{id:e.key,title:e.title,status:e.status,projectId:e.projectId??null,assigneeAgentId:e.assigneeAgentId??null,lastRun:e.lastRunAt||e.lastRunStatus?{triggeredAt:e.lastRunAt??null,status:e.lastRunStatus??null}:null}}r(IKt,"managedRoutineToRow");function AKt({routines:e,agents:s=[],projects:n=[],pluginDisplayName:a=null,emptyMessage:i="No managed routines.",runningRoutineKey:o=null,statusMutationRoutineKey:l=null,reconcilingRoutineKey:c=null,resettingRoutineKey:d=null,onRunNow:m,onToggleEnabled:h,onReconcile:p,onReset:f}){const g=new Map(s.map(y=>[y.id,y])),v=new Map(n.map(y=>[y.id,{name:y.name,color:y.color}]));return e.length===0?(0,t.jsx)("div",{className:"rounded-lg border border-border px-3 py-8 text-center text-sm text-muted-foreground",children:i}):(0,t.jsx)("div",{className:"rounded-lg border border-border",children:e.map(y=>{const w=IKt(y),S=y.href??(y.routineId?`/routines/${y.routineId}`:"/routines"),j=y.missingRefs??[],N=!!(y.routineId&&y.resourceKey&&j.length===0),_=y.managedByPluginDisplayName??a,R=!!(p||f);return(0,t.jsxs)("div",{className:"last:[&_a]:border-b-0",children:[(0,t.jsx)(bNe,{routine:w,projectById:v,agentById:g,runningRoutineId:o,statusMutationRoutineId:l,href:S,configureLabel:"Configure",managedByLabel:_?`Managed by ${_}`:null,runNowButton:!0,hideArchiveAction:!0,disableRunNow:!N,disableToggle:!N,secondaryDetails:(0,t.jsxs)("span",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[y.resourceKey?(0,t.jsx)("span",{children:y.resourceKey}):null,y.cronExpression?(0,t.jsxs)("span",{children:["Schedule ",y.cronExpression]}):null]}),onRunNow:r(()=>m?.(y),"onRunNow"),onToggleEnabled:r(()=>h?.(y,w.status==="active"),"onToggleEnabled")}),R?(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 border-b border-border px-3 pb-3 text-xs text-muted-foreground last:border-b-0",onClick:r(C=>{C.preventDefault(),C.stopPropagation()},"onClick"),children:[(0,t.jsx)("span",{children:j.length?`Missing ${j.map(C=>`${C.resourceKind}:${C.resourceKey}`).join(", ")}`:"Routine defaults can be repaired."}),(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[p?(0,t.jsx)(F,{size:"sm",variant:"ghost",disabled:c===y.key,onClick:r(()=>p(y),"onClick"),children:c===y.key?"Reconciling...":"Reconcile"}):null,f?(0,t.jsx)(F,{size:"sm",variant:"ghost",disabled:d===y.key,onClick:r(()=>f(y),"onClick"),children:d===y.key?"Resetting...":"Reset"}):null]})]}):null]},y.key)})})}r(AKt,"ManagedRoutinesList");function xle(e){return new Set(e??[])}r(xle,"toPathSet");function RKt({expandedPaths:e,checkedPaths:s,selectedFile:n=null,showCheckboxes:a=!1,onToggleDir:i,onSelectFile:o,...l}){return(0,u.createElement)(t_,{...l,selectedFile:n,expandedDirs:xle(e),checkedFiles:s?xle(s):void 0,showCheckboxes:a,onToggleDir:i??(()=>{}),onSelectFile:o??(()=>{})})}r(RKt,"PluginSdkFileTree");function TKt(e){const[s,n]=(0,u.useState)(null);return(0,u.useEffect)(()=>{let a=!1;return jc(()=>import("./MarkdownEditor-DfrwLv1M.js").then(i=>i.n).then(i=>{a||n(()=>i.MarkdownEditor)}),__vite__mapDeps([36,5,7,9,14,10,15,37,29,27,38])),()=>{a=!0}},[]),s?(0,u.createElement)(s,e):(0,u.createElement)("textarea",{className:e.className,value:e.value,placeholder:e.placeholder,readOnly:e.readOnly,onBlur:e.onBlur,onChange:r(a=>e.onChange(a.currentTarget.value),"onChange")})}r(TKt,"PluginSdkMarkdownEditor");function EKt(e){return Object.fromEntries(Object.entries(e).filter(([,s])=>s!=null&&s!==""&&s!==!1))}r(EKt,"compactIssueFilters");function PKt({companyId:e,projectId:s=null,filters:n,viewStateKey:a="paperclip:plugin-issues-view",initialSearch:i,createIssueLabel:o,searchWithinLoadedIssues:l=!0}){const c=Wt(),d=(0,u.useMemo)(()=>EKt({...n??{},projectId:n?.projectId??s??void 0}),[n,s]),m=d.originKindPrefix??null,h=d.projectId??s??null,p=(0,u.useMemo)(()=>["plugins","sdk-ui","issues-list",e??"__no-company__",d],[e,d]),{data:f}=Z({queryKey:P.agents.list(e??"__no-company__"),queryFn:r(()=>Vt.list(e),"queryFn"),enabled:!!e}),{data:g}=Z({queryKey:P.projects.list(e??"__no-company__",{includeArchived:!0}),queryFn:r(()=>ma.list(e,{includeArchived:!0}),"queryFn"),enabled:!!e}),v=P.liveRuns(e??"__no-company__"),y=mo({companyId:e,resourceKey:"live-runs",queryKey:v,enabled:!!e,refetchInterval:!1,leaderOnly:!0}),{data:w,dataUpdatedAt:S}=Z({queryKey:v,queryFn:r(()=>sa.liveRunsForCompany(e),"queryFn"),enabled:y.enabled,refetchInterval:y.refetchInterval});ho(y,w,S);const{data:j,isLoading:N,error:_}=Z({queryKey:p,queryFn:r(()=>Rt.list(e,d),"queryFn"),enabled:!!e}),R=(0,u.useMemo)(()=>Tx(w,j),[j,w]),C=Ne({mutationFn:r(({id:A,data:T})=>Rt.update(A,T),"mutationFn"),onSuccess:r(()=>{e&&(c.invalidateQueries({queryKey:["plugins","sdk-ui","issues-list",e]}),c.invalidateQueries({queryKey:P.issues.list(e)}),h&&(c.invalidateQueries({queryKey:P.issues.listByProject(e,h)}),m&&c.invalidateQueries({queryKey:P.issues.listPluginOperationsByProject(e,h,m)})))},"onSuccess")});return e?(0,u.createElement)(yx,{issues:j??[],isLoading:N,error:_,agents:f,projects:g,liveIssueIds:R,projectId:h??void 0,viewStateKey:a,initialSearch:i,createIssueLabel:o,searchWithinLoadedIssues:l,onUpdateIssue:r((A,T)=>C.mutate({id:A,data:T}),"onUpdateIssue")}):(0,u.createElement)("div",{className:"text-sm text-muted-foreground"},"Select an organization to view tasks.")}r(PKt,"PluginSdkIssuesList");function MKt({companyId:e,value:s,onChange:n,placeholder:a="Responsible",noneLabel:i="No responsible",searchPlaceholder:o="Search responsible...",emptyMessage:l="No responsible found.",includeUsers:c=!0,includeTerminatedAgents:d=!1,className:m,onConfirm:h}){const p=iU(),f=e??p.companyId??null,{data:g}=Z({queryKey:P.auth.session,queryFn:r(()=>qa.getSession(),"queryFn"),enabled:c}),v=g?.user?.id??g?.session?.userId??null,{data:y}=Z({queryKey:P.agents.list(f??"__no-company__"),queryFn:r(()=>Vt.list(f),"queryFn"),enabled:!!f}),{data:w}=Z({queryKey:P.access.companyUserDirectory(f??"__no-company__"),queryFn:r(()=>hr.listUserDirectory(f),"queryFn"),enabled:!!f&&c}),S=(0,u.useMemo)(()=>VAe(),[]),j=(0,u.useMemo)(()=>S.map(A=>A.startsWith("agent:")?A.slice(6):null).filter(A=>!!A),[S]),N=(0,u.useMemo)(()=>Wg((y??[]).filter(A=>d||A.status!=="terminated"),j),[y,d,j]),_=(0,u.useMemo)(()=>[...c?Ice(v):[],...c?tN(w?.users,{excludeUserIds:[v]}):[],...N.map(A=>({id:Mm({assigneeAgentId:A.id}),label:A.name,searchText:`${A.name} ${A.role} ${A.title??""}`}))],[w?.users,v,c,N]),R=Oc(s),C=R.assigneeAgentId?N.find(A=>A.id===R.assigneeAgentId):null;return(0,u.createElement)(nc,{value:s,options:_,recentOptionIds:S,placeholder:a,noneLabel:i,searchPlaceholder:o,emptyMessage:l,className:m,onConfirm:h,onChange:r(A=>{const T=Oc(A);T.assigneeAgentId&&o1(T.assigneeAgentId),T.assigneeUserId&&lce(T.assigneeUserId),n(A,T)},"onChange"),renderTriggerValue:r(A=>A?C?(0,u.createElement)(a5,null,(0,u.createElement)(hw,{icon:C.icon,className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,u.createElement)("span",{className:"truncate"},A.label)):(0,u.createElement)("span",{className:"truncate"},A.label):(0,u.createElement)("span",{className:"text-muted-foreground"},a),"renderTriggerValue"),renderOption:r(A=>{if(!A.id)return(0,u.createElement)("span",{className:"truncate"},A.label);const T=Oc(A.id),I=T.assigneeAgentId?N.find($=>$.id===T.assigneeAgentId):null;return(0,u.createElement)(a5,null,I?(0,u.createElement)(hw,{icon:I.icon,className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):(0,u.createElement)(yc,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,u.createElement)("span",{className:"truncate"},A.label))},"renderOption")})}r(MKt,"PluginSdkAssigneePicker");function DKt({companyId:e,value:s,onChange:n,placeholder:a="Project",noneLabel:i="No project",searchPlaceholder:o="Search projects...",emptyMessage:l="No projects found.",includeArchived:c=!1,className:d,onConfirm:m}){const h=iU(),p=e??h.companyId??null,{data:f}=Z({queryKey:P.auth.session,queryFn:r(()=>qa.getSession(),"queryFn")}),g=f?.user?.id??f?.session?.userId??null,{data:v}=Z({queryKey:P.projects.list(p??"__no-company__",{includeArchived:c}),queryFn:r(()=>ma.list(p,{includeArchived:c}),"queryFn"),enabled:!!p}),y=(0,u.useMemo)(()=>(v??[]).filter(_=>c||!_.archivedAt),[c,v]),{orderedProjects:w}=Ev({projects:y,companyId:p,userId:g}),S=(0,u.useMemo)(()=>Jw(),[]),j=(0,u.useMemo)(()=>w.map(_=>({id:_.id,label:_.name,searchText:_.description??""})),[w]),N=w.find(_=>_.id===s)??null;return(0,u.createElement)(nc,{value:s,options:j,recentOptionIds:S,placeholder:a,noneLabel:i,searchPlaceholder:o,emptyMessage:l,className:d,onConfirm:m,onChange:r(_=>{_&&Qw(_),n(_)},"onChange"),renderTriggerValue:r(_=>!_||!N?(0,u.createElement)("span",{className:"text-muted-foreground"},a):(0,u.createElement)(a5,null,(0,u.createElement)("span",{className:"h-3.5 w-3.5 shrink-0 rounded-sm",style:{backgroundColor:N.color??"#6366f1"}}),(0,u.createElement)("span",{className:"truncate"},_.label)),"renderTriggerValue"),renderOption:r(_=>{if(!_.id)return(0,u.createElement)("span",{className:"truncate"},_.label);const R=w.find(C=>C.id===_.id);return(0,u.createElement)(a5,null,(0,u.createElement)("span",{className:"h-3.5 w-3.5 shrink-0 rounded-sm",style:{backgroundColor:R?.color??"#6366f1"}}),(0,u.createElement)("span",{className:"truncate"},_.label))},"renderOption")})}r(DKt,"PluginSdkProjectPicker");function a5({children:e}){return(0,u.createElement)("span",{className:"contents"},e)}r(a5,"FragmentSafe");function LKt({label:e,status:s}){const n={ok:"border-emerald-300 bg-emerald-50 text-emerald-700",warning:"border-amber-300 bg-amber-50 text-amber-800",error:"border-red-300 bg-red-50 text-red-700",info:"border-slate-300 bg-slate-50 text-slate-700",pending:"border-slate-300 bg-slate-50 text-slate-600"}[s];return(0,u.createElement)("span",{className:`inline-flex w-fit items-center rounded-full border px-2 py-0.5 text-xs font-medium ${n}`},e)}r(LKt,"PluginSdkStatusBadge");function $Kt({columns:e,rows:s,loading:n,emptyMessage:a="No rows."}){if(n)return(0,u.createElement)("div",{className:"text-sm text-muted-foreground"},"Loading...");if(!s.length)return(0,u.createElement)("div",{className:"text-sm text-muted-foreground"},a);const i=e.map(o=>o.width??"minmax(0, 1fr)").join(" ");return(0,u.createElement)("div",{className:"overflow-hidden rounded-md border"},(0,u.createElement)("div",{className:"hidden border-b bg-muted/35 px-3 py-2 text-xs font-medium uppercase tracking-wide text-muted-foreground md:grid md:[grid-template-columns:var(--plugin-grid-cols)]",style:{"--plugin-grid-cols":i}},e.map(o=>(0,u.createElement)("div",{key:o.key},o.header))),(0,u.createElement)("div",{className:"divide-y"},s.map((o,l)=>(0,u.createElement)("div",{key:String(o.id??l),className:"grid gap-2 px-3 py-3 md:items-center md:[grid-template-columns:var(--plugin-grid-cols)]",style:{"--plugin-grid-cols":i}},e.map(c=>(0,u.createElement)("div",{key:c.key,className:"min-w-0 text-sm"},(0,u.createElement)("div",{className:"mb-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground md:hidden"},c.header),c.render?c.render(o[c.key],o):String(o[c.key]??"")))))))}r($Kt,"PluginSdkDataTable");function OKt({pairs:e}){return(0,u.createElement)("dl",{className:"grid gap-x-4 gap-y-1 text-sm sm:grid-cols-[max-content_minmax(0,1fr)]"},e.flatMap(s=>[(0,u.createElement)("dt",{key:`${s.label}:label`,className:"text-muted-foreground"},s.label),(0,u.createElement)("dd",{key:`${s.label}:value`,className:"min-w-0"},s.value)]))}r(OKt,"PluginSdkKeyValueList");function FKt({label:e,value:s,unit:n}){return(0,u.createElement)("div",{className:"rounded-md border bg-card p-3"},(0,u.createElement)("div",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground"},e),(0,u.createElement)("div",{className:"mt-1 text-lg font-semibold"},`${s}${n??""}`))}r(FKt,"PluginSdkMetricCard");function BKt({data:e}){return(0,u.createElement)("pre",{className:"max-h-80 overflow-auto rounded-md border bg-muted/30 p-2 text-xs"},JSON.stringify(e,null,2))}r(BKt,"PluginSdkJsonTree");function qKt({label:e="Loading"}){return(0,u.createElement)("span",{className:"inline-block h-3.5 w-3.5 animate-spin rounded-full border-2 border-muted-foreground/30 border-t-foreground align-middle",role:"status","aria-label":e})}r(qKt,"PluginSdkSpinner");var zKt=class extends u.Component{static{r(this,"PluginSdkErrorBoundary")}state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback??(0,u.createElement)("div",{className:"rounded-md border border-destructive/30 p-3 text-sm text-destructive"},"Plugin UI failed to render."):this.props.children}};function UKt(e,s){globalThis.__paperclipPluginBridge__={react:e,reactJsxRuntime:t,reactDom:s,sdkUi:{usePluginData:TLe,usePluginAction:ELe,useHostContext:iU,useHostLocation:MLe,useHostNavigation:PLe,usePluginStream:LLe,usePluginToast:DLe,copyTextToClipboard:Yr,MarkdownBlock:r(({content:n,className:a,enableWikiLinks:i,wikiLinkRoot:o,resolveWikiLinkHref:l})=>(0,u.createElement)($n,{className:a,softBreaks:!1,enableWikiLinks:i,wikiLinkRoot:o,resolveWikiLinkHref:l,children:n}),"MarkdownBlock"),MetricCard:FKt,StatusBadge:LKt,DataTable:$Kt,KeyValueList:OKt,JsonTree:BKt,Spinner:qKt,ErrorBoundary:zKt,MarkdownEditor:TKt,FileTree:RKt,IssuesList:PKt,AssigneePicker:MKt,ProjectPicker:DKt,ManagedRoutinesList:AKt}}}r(UKt,"initPluginBridge");var KKt=1e4;function VKt(e=KKt){if(typeof performance>"u"||typeof performance.clearMeasures!="function")return()=>{};const n=setInterval(r(()=>{globalThis.__paperclipKeepPerfMeasures||performance.clearMeasures()},"reap"),e);return()=>clearInterval(n)}r(VKt,"startPerfMeasureReaper");var WKt=wv((e=>{function s(K,z){var D=K.length;K.push(z);e:for(;0<D;){var V=D-1>>>1,H=K[V];if(0<i(H,z))K[V]=z,K[D]=H,D=V;else break e}}r(s,"push");function n(K){return K.length===0?null:K[0]}r(n,"peek");function a(K){if(K.length===0)return null;var z=K[0],D=K.pop();if(D!==z){K[0]=D;e:for(var V=0,H=K.length,ee=H>>>1;V<ee;){var X=2*(V+1)-1,le=K[X],ce=X+1,te=K[ce];if(0>i(le,D))ce<H&&0>i(te,le)?(K[V]=te,K[ce]=D,V=ce):(K[V]=le,K[X]=D,V=X);else if(ce<H&&0>i(te,D))K[V]=te,K[ce]=D,V=ce;else break e}}return z}r(a,"pop");function i(K,z){var D=K.sortIndex-z.sortIndex;return D!==0?D:K.id-z.id}if(r(i,"compare"),e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var l=Date,c=l.now();e.unstable_now=function(){return l.now()-c}}var d=[],m=[],h=1,p=null,f=3,g=!1,v=!1,y=!1,w=!1,S=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate<"u"?setImmediate:null;function _(K){for(var z=n(m);z!==null;){if(z.callback===null)a(m);else if(z.startTime<=K)a(m),z.sortIndex=z.expirationTime,s(d,z);else break;z=n(m)}}r(_,"advanceTimers");function R(K){if(y=!1,_(K),!v)if(n(d)!==null)v=!0,C||(C=!0,L());else{var z=n(m);z!==null&&B(R,z.startTime-K)}}r(R,"handleTimeout");var C=!1,A=-1,T=5,I=-1;function $(){return w?!0:!(e.unstable_now()-I<T)}r($,"shouldYieldToHost");function O(){if(w=!1,C){var K=e.unstable_now();I=K;var z=!0;try{e:{v=!1,y&&(y=!1,j(A),A=-1),g=!0;var D=f;try{t:{for(_(K),p=n(d);p!==null&&!(p.expirationTime>K&&$());){var V=p.callback;if(typeof V=="function"){p.callback=null,f=p.priorityLevel;var H=V(p.expirationTime<=K);if(K=e.unstable_now(),typeof H=="function"){p.callback=H,_(K),z=!0;break t}p===n(d)&&a(d),_(K)}else a(d);p=n(d)}if(p!==null)z=!0;else{var ee=n(m);ee!==null&&B(R,ee.startTime-K),z=!1}}break e}finally{p=null,f=D,g=!1}z=void 0}}finally{z?L():C=!1}}}r(O,"performWorkUntilDeadline");var L;if(typeof N=="function")L=r(function(){N(O)},"schedulePerformWorkUntilDeadline");else if(typeof MessageChannel<"u"){var E=new MessageChannel,q=E.port2;E.port1.onmessage=O,L=r(function(){q.postMessage(null)},"schedulePerformWorkUntilDeadline")}else L=r(function(){S(O,0)},"schedulePerformWorkUntilDeadline");function B(K,z){A=S(function(){K(e.unstable_now())},z)}r(B,"requestHostTimeout"),e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(K){K.callback=null},e.unstable_forceFrameRate=function(K){0>K||125<K||(T=0<K?Math.floor(1e3/K):5)},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(K){switch(f){case 1:case 2:case 3:var z=3;break;default:z=f}var D=f;f=z;try{return K()}finally{f=D}},e.unstable_requestPaint=function(){w=!0},e.unstable_runWithPriority=function(K,z){switch(K){case 1:case 2:case 3:case 4:case 5:break;default:K=3}var D=f;f=K;try{return z()}finally{f=D}},e.unstable_scheduleCallback=function(K,z,D){var V=e.unstable_now();switch(typeof D=="object"&&D!==null?(D=D.delay,D=typeof D=="number"&&0<D?V+D:V):D=V,K){case 1:var H=-1;break;case 2:H=250;break;case 5:H=1073741823;break;case 4:H=1e4;break;default:H=5e3}return H=D+H,K={id:h++,callback:z,priorityLevel:K,startTime:D,expirationTime:H,sortIndex:-1},D>V?(K.sortIndex=D,s(m,K),n(d)===null&&K===n(m)&&(y?(j(A),A=-1):y=!0,B(R,D-V))):(K.sortIndex=H,s(d,K),v||g||(v=!0,C||(C=!0,L()))),K},e.unstable_shouldYield=$,e.unstable_wrapCallback=function(K){var z=f;return function(){var D=f;f=z;try{return K.apply(this,arguments)}finally{f=D}}}})),HKt=wv(((e,s)=>{s.exports=WKt()})),QKt=wv((e=>{var s=HKt(),n=cz(),a=Cle();function i(x){var b="https://react.dev/errors/"+x;if(1<arguments.length){b+="?args[]="+encodeURIComponent(arguments[1]);for(var k=2;k<arguments.length;k++)b+="&args[]="+encodeURIComponent(arguments[k])}return"Minified React error #"+x+"; visit "+b+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}r(i,"formatProdErrorMessage");function o(x){return!(!x||x.nodeType!==1&&x.nodeType!==9&&x.nodeType!==11)}r(o,"isValidContainer");function l(x){var b=x,k=x;if(x.alternate)for(;b.return;)b=b.return;else{x=b;do b=x,(b.flags&4098)!==0&&(k=b.return),x=b.return;while(x)}return b.tag===3?k:null}r(l,"getNearestMountedFiber");function c(x){if(x.tag===13){var b=x.memoizedState;if(b===null&&(x=x.alternate,x!==null&&(b=x.memoizedState)),b!==null)return b.dehydrated}return null}r(c,"getSuspenseInstanceFromFiber");function d(x){if(x.tag===31){var b=x.memoizedState;if(b===null&&(x=x.alternate,x!==null&&(b=x.memoizedState)),b!==null)return b.dehydrated}return null}r(d,"getActivityInstanceFromFiber");function m(x){if(l(x)!==x)throw Error(i(188))}r(m,"assertIsMounted");function h(x){var b=x.alternate;if(!b){if(b=l(x),b===null)throw Error(i(188));return b!==x?null:x}for(var k=x,M=b;;){var W=k.return;if(W===null)break;var Q=W.alternate;if(Q===null){if(M=W.return,M!==null){k=M;continue}break}if(W.child===Q.child){for(Q=W.child;Q;){if(Q===k)return m(W),x;if(Q===M)return m(W),b;Q=Q.sibling}throw Error(i(188))}if(k.return!==M.return)k=W,M=Q;else{for(var ge=!1,Me=W.child;Me;){if(Me===k){ge=!0,k=W,M=Q;break}if(Me===M){ge=!0,M=W,k=Q;break}Me=Me.sibling}if(!ge){for(Me=Q.child;Me;){if(Me===k){ge=!0,k=Q,M=W;break}if(Me===M){ge=!0,M=Q,k=W;break}Me=Me.sibling}if(!ge)throw Error(i(189))}}if(k.alternate!==M)throw Error(i(190))}if(k.tag!==3)throw Error(i(188));return k.stateNode.current===k?x:b}r(h,"findCurrentFiberUsingSlowPath");function p(x){var b=x.tag;if(b===5||b===26||b===27||b===6)return x;for(x=x.child;x!==null;){if(b=p(x),b!==null)return b;x=x.sibling}return null}r(p,"findCurrentHostFiberImpl");var f=Object.assign,g=Symbol.for("react.element"),v=Symbol.for("react.transitional.element"),y=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),S=Symbol.for("react.strict_mode"),j=Symbol.for("react.profiler"),N=Symbol.for("react.consumer"),_=Symbol.for("react.context"),R=Symbol.for("react.forward_ref"),C=Symbol.for("react.suspense"),A=Symbol.for("react.suspense_list"),T=Symbol.for("react.memo"),I=Symbol.for("react.lazy"),$=Symbol.for("react.activity"),O=Symbol.for("react.memo_cache_sentinel"),L=Symbol.iterator;function E(x){return x===null||typeof x!="object"?null:(x=L&&x[L]||x["@@iterator"],typeof x=="function"?x:null)}r(E,"getIteratorFn");var q=Symbol.for("react.client.reference");function B(x){if(x==null)return null;if(typeof x=="function")return x.$$typeof===q?null:x.displayName||x.name||null;if(typeof x=="string")return x;switch(x){case w:return"Fragment";case j:return"Profiler";case S:return"StrictMode";case C:return"Suspense";case A:return"SuspenseList";case $:return"Activity"}if(typeof x=="object")switch(x.$$typeof){case y:return"Portal";case _:return x.displayName||"Context";case N:return(x._context.displayName||"Context")+".Consumer";case R:var b=x.render;return x=x.displayName,x||(x=b.displayName||b.name||"",x=x!==""?"ForwardRef("+x+")":"ForwardRef"),x;case T:return b=x.displayName||null,b!==null?b:B(x.type)||"Memo";case I:b=x._payload,x=x._init;try{return B(x(b))}catch{}}return null}r(B,"getComponentNameFromType");var K=Array.isArray,z=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D=a.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,V={pending:!1,data:null,method:null,action:null},H=[],ee=-1;function X(x){return{current:x}}r(X,"createCursor");function le(x){0>ee||(x.current=H[ee],H[ee]=null,ee--)}r(le,"pop");function ce(x,b){ee++,H[ee]=x.current,x.current=b}r(ce,"push");var te=X(null),ae=X(null),de=X(null),J=X(null);function Y(x,b){switch(ce(de,b),ce(ae,x),ce(te,null),b.nodeType){case 9:case 11:x=(x=b.documentElement)&&(x=x.namespaceURI)?NW(x):0;break;default:if(x=b.tagName,b=b.namespaceURI)b=NW(b),x=kW(b,x);else switch(x){case"svg":x=1;break;case"math":x=2;break;default:x=0}}le(te),ce(te,x)}r(Y,"pushHostContainer");function G(){le(te),le(ae),le(de)}r(G,"popHostContainer");function fe(x){x.memoizedState!==null&&ce(J,x);var b=te.current,k=kW(b,x.type);b!==k&&(ce(ae,x),ce(te,k))}r(fe,"pushHostContext");function se(x){ae.current===x&&(le(te),le(ae)),J.current===x&&(le(J),WN._currentValue=V)}r(se,"popHostContext");var re,ie;function me(x){if(re===void 0)try{throw Error()}catch(k){var b=k.stack.trim().match(/\n( *(at )?)/);re=b&&b[1]||"",ie=-1<k.stack.indexOf(`
|
|
728
|
+
`)}z!==S&&(n.textContent=z,S=z)}r(A,"step");function T(){const E=d>0&&m>0;if(a.matches){o&&(o=!1,s.current!==null&&cancelAnimationFrame(s.current),s.current=null),E&&_();return}if(!i||!E){o&&(o=!1,s.current!==null&&cancelAnimationFrame(s.current),s.current=null);return}o||(o=!0,l=0,s.current=requestAnimationFrame(A))}r(T,"syncLoop");const I=new ResizeObserver(()=>{const E=ale(n);h=E.w,p=E.h,N(),T()});I.observe(n);const $=r(()=>{i=document.visibilityState!=="hidden",T()},"onVisibilityChange");document.addEventListener("visibilitychange",$);const O=r(()=>{T()},"onMotionChange");a.addEventListener("change",O);const L=ale(n);return h=L.w,p=L.h,N(),T(),()=>{o=!1,s.current!==null&&cancelAnimationFrame(s.current),I.disconnect(),document.removeEventListener("visibilitychange",$),a.removeEventListener("change",O)}},[]),(0,t.jsx)("pre",{ref:e,className:"w-full h-full m-0 p-0 overflow-hidden text-muted-foreground/60 select-none leading-none",style:{fontSize:"var(--text-micro)",fontFamily:"monospace"},"aria-hidden":"true"})}r(sKt,"AsciiArtAnimation");function nKt({decorative:e=!1,title:s="Paperclip",className:n,...a}){return(0,t.jsxs)("svg",{...a,className:n,viewBox:"22.5 22.5 121 27",fill:"currentColor",role:e?void 0:"img","aria-hidden":e?!0:void 0,"aria-label":e?void 0:s,focusable:"false",children:[(0,t.jsx)("path",{d:"M131.15 48.4902V31.9902H133.922V33.9775H134.094C134.237 33.6911 134.441 33.3831 134.706 33.0537C134.971 32.7171 135.329 32.4307 135.78 32.1943C136.239 31.958 136.822 31.8398 137.531 31.8398C138.455 31.8398 139.289 32.0762 140.034 32.5488C140.779 33.0215 141.37 33.7161 141.807 34.6328C142.251 35.5495 142.473 36.6774 142.473 38.0166C142.473 39.3343 142.258 40.4551 141.828 41.3789C141.398 42.3027 140.808 43.0081 140.056 43.4951C139.311 43.9749 138.466 44.2148 137.521 44.2148C136.84 44.2148 136.271 44.1003 135.812 43.8711C135.361 43.6348 134.996 43.3555 134.717 43.0332C134.445 42.7038 134.237 42.3923 134.094 42.0986H133.976V48.4902H131.15ZM136.747 41.8945C137.37 41.8945 137.889 41.7262 138.305 41.3896C138.727 41.0531 139.046 40.5911 139.261 40.0039C139.476 39.4167 139.583 38.7507 139.583 38.0059C139.583 37.2611 139.476 36.5986 139.261 36.0186C139.046 35.4385 138.731 34.9837 138.315 34.6543C137.9 34.3249 137.377 34.1602 136.747 34.1602C136.138 34.1602 135.623 34.3177 135.2 34.6328C134.785 34.9479 134.466 35.3955 134.244 35.9756C134.029 36.5485 133.922 37.2253 133.922 38.0059C133.922 38.7793 134.029 39.4596 134.244 40.0469C134.466 40.627 134.788 41.0817 135.211 41.4111C135.633 41.7334 136.146 41.8945 136.747 41.8945Z"}),(0,t.jsx)("path",{d:"M126.451 44V31.9902H129.276V44H126.451ZM127.869 30.3037C127.417 30.3037 127.031 30.1533 126.708 29.8525C126.386 29.5518 126.225 29.1901 126.225 28.7676C126.225 28.3379 126.386 27.9727 126.708 27.6719C127.031 27.3711 127.417 27.2207 127.869 27.2207C128.313 27.2207 128.696 27.3711 129.018 27.6719C129.34 27.9727 129.501 28.3343 129.501 28.7568C129.501 29.1865 129.34 29.5518 129.018 29.8525C128.696 30.1533 128.313 30.3037 127.869 30.3037Z"}),(0,t.jsx)("path",{d:"M124.576 27.9941V44H121.75V27.9941H124.576Z"}),(0,t.jsx)("path",{d:"M115.3 44.2363C114.104 44.2363 113.076 43.9749 112.217 43.4521C111.357 42.9222 110.699 42.1917 110.24 41.2607C109.782 40.3298 109.553 39.2591 109.553 38.0488C109.553 36.8242 109.785 35.7464 110.251 34.8154C110.716 33.8844 111.379 33.1576 112.238 32.6348C113.098 32.1048 114.111 31.8398 115.278 31.8398C116.259 31.8398 117.126 32.0189 117.878 32.377C118.63 32.735 119.228 33.2399 119.672 33.8916C120.123 34.5361 120.381 35.2917 120.445 36.1582H117.738C117.667 35.7715 117.527 35.4242 117.319 35.1162C117.112 34.8083 116.84 34.5648 116.503 34.3857C116.174 34.2067 115.78 34.1172 115.321 34.1172C114.741 34.1172 114.233 34.2747 113.796 34.5898C113.366 34.8978 113.03 35.3418 112.786 35.9219C112.543 36.502 112.421 37.1966 112.421 38.0059C112.421 38.8223 112.539 39.5277 112.775 40.1221C113.012 40.7093 113.348 41.1641 113.785 41.4863C114.222 41.8014 114.734 41.959 115.321 41.959C115.944 41.959 116.471 41.7764 116.9 41.4111C117.337 41.0459 117.617 40.541 117.738 39.8965H120.445C120.381 40.7487 120.13 41.5007 119.693 42.1523C119.257 42.804 118.666 43.3161 117.921 43.6885C117.176 44.0537 116.302 44.2363 115.3 44.2363Z"}),(0,t.jsx)("path",{d:"M102.876 44V31.9902H105.615V34.0098H105.744C105.959 33.3079 106.335 32.7708 106.872 32.3984C107.409 32.0189 108.021 31.8291 108.709 31.8291C108.859 31.8291 109.031 31.8363 109.225 31.8506C109.425 31.8649 109.59 31.8828 109.719 31.9043V34.5039C109.597 34.4609 109.407 34.4251 109.149 34.3965C108.892 34.3678 108.645 34.3535 108.408 34.3535C107.885 34.3535 107.42 34.4645 107.012 34.6865C106.604 34.9085 106.281 35.2129 106.045 35.5996C105.816 35.9863 105.701 36.4375 105.701 36.9531V44H102.876Z"}),(0,t.jsx)("path",{d:"M96.2319 44.2363C95.0288 44.2363 93.9904 43.9857 93.1167 43.4844C92.243 42.9759 91.5698 42.2598 91.0972 41.3359C90.6317 40.4121 90.3989 39.3236 90.3989 38.0703C90.3989 36.8314 90.6317 35.7464 91.0972 34.8154C91.5627 33.8773 92.2179 33.1468 93.063 32.624C93.908 32.1012 94.9035 31.8398 96.0493 31.8398C96.7869 31.8398 97.4852 31.958 98.144 32.1943C98.8101 32.4307 99.3973 32.7959 99.9058 33.29C100.421 33.7842 100.826 34.4144 101.12 35.1807C101.413 35.9398 101.56 36.8457 101.56 37.8984V38.7793H91.7202V36.8779H100.153L98.8315 37.4365C98.8315 36.7562 98.7277 36.1654 98.52 35.6641C98.3123 35.1556 98.0044 34.7581 97.5962 34.4717C97.188 34.1852 96.6795 34.042 96.0708 34.042C95.4621 34.042 94.9429 34.1852 94.5132 34.4717C94.0835 34.7581 93.7576 35.1449 93.5356 35.6318C93.3136 36.1117 93.2026 36.6488 93.2026 37.2432V38.5645C93.2026 39.2949 93.328 39.9215 93.5786 40.4443C93.8364 40.96 94.1945 41.3538 94.6528 41.626C95.1183 41.8981 95.659 42.0342 96.2749 42.0342C96.6759 42.0342 97.0412 41.9769 97.3706 41.8623C97.7072 41.7477 97.9937 41.5758 98.23 41.3467C98.4735 41.1104 98.6597 40.8203 98.7886 40.4766L101.431 40.7881C101.259 41.4827 100.941 42.0915 100.475 42.6143C100.017 43.1299 99.4259 43.5309 98.7026 43.8174C97.9865 44.0967 97.1629 44.2363 96.2319 44.2363Z"}),(0,t.jsx)("path",{d:"M78.2437 48.4902V31.9902H81.0151V33.9775H81.187C81.3302 33.6911 81.5343 33.3831 81.7993 33.0537C82.0643 32.7171 82.4224 32.4307 82.8735 32.1943C83.3319 31.958 83.9155 31.8398 84.6245 31.8398C85.5483 31.8398 86.3826 32.0762 87.1274 32.5488C87.8722 33.0215 88.4631 33.7161 88.8999 34.6328C89.3439 35.5495 89.5659 36.6774 89.5659 38.0166C89.5659 39.3343 89.3511 40.4551 88.9214 41.3789C88.4917 42.3027 87.9009 43.0081 87.1489 43.4951C86.4041 43.9749 85.5591 44.2148 84.6138 44.2148C83.9334 44.2148 83.3641 44.1003 82.9058 43.8711C82.4546 43.6348 82.0894 43.3555 81.8101 43.0332C81.5379 42.7038 81.3302 42.3923 81.187 42.0986H81.0688V48.4902H78.2437ZM83.8403 41.8945C84.4634 41.8945 84.9826 41.7262 85.3979 41.3896C85.8205 41.0531 86.1392 40.5911 86.354 40.0039C86.5688 39.4167 86.6763 38.7507 86.6763 38.0059C86.6763 37.2611 86.5688 36.5986 86.354 36.0186C86.1392 35.4385 85.8241 34.9837 85.4087 34.6543C84.9933 34.3249 84.4705 34.1602 83.8403 34.1602C83.2316 34.1602 82.716 34.3177 82.2935 34.6328C81.8781 34.9479 81.5594 35.3955 81.3374 35.9756C81.1226 36.5485 81.0151 37.2253 81.0151 38.0059C81.0151 38.7793 81.1226 39.4596 81.3374 40.0469C81.5594 40.627 81.8817 41.0817 82.3042 41.4111C82.7267 41.7334 83.2388 41.8945 83.8403 41.8945Z"}),(0,t.jsx)("path",{d:"M70.042 44.2471C69.2757 44.2471 68.5882 44.111 67.9795 43.8389C67.3708 43.5596 66.891 43.1514 66.54 42.6143C66.1891 42.0771 66.0137 41.4147 66.0137 40.627C66.0137 39.9538 66.139 39.3952 66.3896 38.9512C66.6403 38.5072 66.9805 38.1527 67.4102 37.8877C67.847 37.6227 68.3376 37.4222 68.8818 37.2861C69.4261 37.1429 69.9883 37.0426 70.5684 36.9854C71.2773 36.9066 71.8503 36.8385 72.2871 36.7812C72.724 36.724 73.0391 36.6309 73.2324 36.502C73.4329 36.373 73.5332 36.1725 73.5332 35.9004V35.8467C73.5332 35.2666 73.3613 34.8154 73.0176 34.4932C72.6738 34.1709 72.1725 34.0098 71.5137 34.0098C70.819 34.0098 70.2676 34.1602 69.8594 34.4609C69.4583 34.7617 69.1862 35.1162 69.043 35.5244L66.4111 35.1484C66.6188 34.418 66.9626 33.8092 67.4424 33.3223C67.9222 32.8281 68.5059 32.4593 69.1934 32.2158C69.888 31.9652 70.6543 31.8398 71.4922 31.8398C72.0651 31.8398 72.638 31.9079 73.2109 32.0439C73.7839 32.1729 74.3102 32.3949 74.79 32.71C75.2699 33.0251 75.653 33.4476 75.9395 33.9775C76.2259 34.5075 76.3691 35.1699 76.3691 35.9648V44H73.6514V42.3457H73.5654C73.3936 42.6751 73.1501 42.9867 72.835 43.2803C72.527 43.5667 72.1403 43.7995 71.6748 43.9785C71.2165 44.1576 70.6722 44.2471 70.042 44.2471ZM70.7617 42.1631C71.3346 42.1631 71.8288 42.0521 72.2441 41.8301C72.6595 41.6009 72.9818 41.3001 73.2109 40.9277C73.4401 40.5482 73.5547 40.1364 73.5547 39.6924V38.2852C73.4616 38.3568 73.3112 38.4248 73.1035 38.4893C72.8958 38.5465 72.6595 38.6003 72.3945 38.6504C72.1296 38.7005 71.8682 38.7435 71.6104 38.7793C71.3597 38.8151 71.1413 38.8438 70.9551 38.8652C70.5326 38.9225 70.153 39.0192 69.8164 39.1553C69.487 39.2842 69.2256 39.4632 69.0322 39.6924C68.8389 39.9215 68.7422 40.2188 68.7422 40.584C68.7422 41.1068 68.932 41.5007 69.3115 41.7656C69.6911 42.0306 70.1745 42.1631 70.7617 42.1631Z"}),(0,t.jsx)("path",{d:"M53.7939 44V27.9941H59.7988C61.0306 27.9941 62.0618 28.2233 62.8926 28.6816C63.7305 29.14 64.3643 29.7702 64.7939 30.5723C65.2236 31.3743 65.4385 32.2839 65.4385 33.3008C65.4385 34.3249 65.2201 35.238 64.7832 36.04C64.3535 36.835 63.7161 37.4616 62.8711 37.9199C62.026 38.3711 60.9876 38.5967 59.7559 38.5967H55.7812V36.2119H59.3584C60.0817 36.2119 60.6725 36.0902 61.1309 35.8467C61.5964 35.596 61.9365 35.2523 62.1514 34.8154C62.3734 34.3714 62.4844 33.8665 62.4844 33.3008C62.4844 32.7279 62.3734 32.2266 62.1514 31.7969C61.9365 31.36 61.5964 31.0234 61.1309 30.7871C60.6725 30.5436 60.0781 30.4219 59.3477 30.4219H56.6943V44H53.7939Z"}),(0,t.jsx)("path",{d:"M46.2611 33.6556L34.7307 44.6408C32.7445 46.5331 29.5205 46.5323 27.5303 44.6361C25.5404 42.74 25.54 39.669 27.5261 37.7768L39.0565 26.7916C40.2474 25.657 42.1811 25.6567 43.3752 26.7943C44.5693 27.9319 44.5689 29.7742 43.378 30.9088L31.849 41.8954C31.4528 42.2728 30.8077 42.273 30.4092 41.8933C30.011 41.5136 30.0117 40.8996 30.4078 40.5223L41.9382 29.5371C42.336 29.1581 42.336 28.5437 41.9382 28.1647C41.5404 27.786 40.8954 27.7858 40.4977 28.1647L28.9673 39.1499C27.7742 40.2866 27.7764 42.1295 28.9687 43.2657C30.1613 44.402 32.0963 44.4046 33.2895 43.2678L44.8192 32.2805C46.8068 30.3865 46.8038 27.3159 44.8157 25.4219C42.8275 23.5277 39.6039 23.5253 37.616 25.4192L26.0856 36.4044C23.3024 39.056 23.3058 43.3558 26.0898 46.0085C28.8741 48.6612 33.388 48.6649 36.1712 46.0132L47.7017 35.028C48.0994 34.649 48.0994 34.0346 47.7017 33.6556C47.3039 33.2766 46.6589 33.2766 46.2611 33.6556Z"})]})}r(nKt,"PaperclipLockup");function rKt(){const e=Wt(),s=Yn(),[n]=Ai(),[a,i]=(0,u.useState)("sign_in"),[o,l]=(0,u.useState)(""),[c,d]=(0,u.useState)(""),[m,h]=(0,u.useState)(""),[p,f]=(0,u.useState)(null),g="auth-error",v=(0,u.useMemo)(()=>n.get("next")||ZUt()||"/",[n]),{data:y,isLoading:w}=Z({queryKey:P.auth.session,queryFn:r(()=>qa.getSession(),"queryFn"),retry:!1});(0,u.useEffect)(()=>{y&&s(v,{replace:!0})},[y,s,v]);const S=Ne({mutationFn:r(async()=>{if(a==="sign_in"){await qa.signInEmail({email:c.trim(),password:m});return}await qa.signUpEmail({name:o.trim(),email:c.trim(),password:m})},"mutationFn"),onSuccess:r(async()=>{f(null),await e.invalidateQueries({queryKey:P.auth.session}),await e.invalidateQueries({queryKey:P.health}),await e.resetQueries({queryKey:P.companies.all}),s(v,{replace:!0})},"onSuccess"),onError:r(N=>{f(N instanceof Error?N.message:"Authentication failed")},"onError")}),j=c.trim().length>0&&m.trim().length>0&&(a==="sign_in"||o.trim().length>0&&m.trim().length>=8);return w?(0,t.jsx)("div",{className:"fixed inset-0 flex items-center justify-center",children:(0,t.jsx)(Xm,{className:"min-h-0"})}):(0,t.jsxs)("div",{className:"fixed inset-0 flex bg-background",children:[(0,t.jsx)("div",{className:"absolute top-4 right-4 z-10",children:(0,t.jsx)(Bj,{})}),(0,t.jsx)("div",{className:"w-full md:w-1/2 flex flex-col overflow-y-auto",children:(0,t.jsxs)("div",{className:"w-full max-w-md mx-auto my-auto px-8 py-12",children:[(0,t.jsx)("div",{className:"mb-8",children:(0,t.jsx)(nKt,{className:"h-5 w-auto"})}),(0,t.jsx)("h1",{className:"text-xl font-semibold",children:a==="sign_in"?"Sign in to Paperclip":"Create your Paperclip account"}),(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:a==="sign_in"?"Use your email and password to access this instance.":"Create an account for this instance. Email confirmation is not required in v1."}),(0,t.jsxs)("form",{className:"mt-6 space-y-4",method:"post",action:a==="sign_up"?"/api/auth/sign-up/email":"/api/auth/sign-in/email",onSubmit:r(N=>{if(N.preventDefault(),!S.isPending){if(!j){f("Please fill in all required fields.");return}S.mutate()}},"onSubmit"),children:[a==="sign_up"&&(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{htmlFor:"name",className:"text-xs text-muted-foreground mb-1 block",children:"Name"}),(0,t.jsx)("input",{id:"name",name:"name",className:"w-full rounded-md border border-border bg-transparent px-3 py-2 text-sm outline-none focus:ring-1 focus:ring-ring placeholder:text-muted-foreground/50",value:o,onChange:r(N=>l(N.target.value),"onChange"),autoComplete:"name",required:!0,"aria-required":"true","aria-invalid":p?!0:void 0,"aria-describedby":p?g:void 0,autoFocus:!0})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{htmlFor:"email",className:"text-xs text-muted-foreground mb-1 block",children:"Email"}),(0,t.jsx)("input",{id:"email",name:"email",className:"w-full rounded-md border border-border bg-transparent px-3 py-2 text-sm outline-none focus:ring-1 focus:ring-ring placeholder:text-muted-foreground/50",type:"email",value:c,onChange:r(N=>d(N.target.value),"onChange"),autoComplete:"username",required:!0,"aria-required":"true","aria-invalid":p?!0:void 0,"aria-describedby":p?g:void 0,autoFocus:a==="sign_in"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{htmlFor:"password",className:"text-xs text-muted-foreground mb-1 block",children:"Password"}),(0,t.jsx)("input",{id:"password",name:"password",className:"w-full rounded-md border border-border bg-transparent px-3 py-2 text-sm outline-none focus:ring-1 focus:ring-ring placeholder:text-muted-foreground/50",type:"password",value:m,onChange:r(N=>h(N.target.value),"onChange"),autoComplete:a==="sign_in"?"current-password":"new-password",required:!0,"aria-required":"true","aria-invalid":p?!0:void 0,"aria-describedby":p?g:void 0})]}),p&&(0,t.jsx)("p",{id:g,role:"alert",className:"text-xs text-destructive",children:p}),(0,t.jsx)(F,{type:"submit",disabled:S.isPending,"aria-disabled":!j||S.isPending,className:`w-full ${!j&&!S.isPending?"opacity-50":""}`,children:S.isPending?"Working…":a==="sign_in"?"Sign In":"Create Account"})]}),(0,t.jsxs)("div",{className:"mt-5 text-sm text-muted-foreground",children:[a==="sign_in"?"Need an account?":"Already have an account?"," ",(0,t.jsx)("button",{type:"button",className:"font-medium text-foreground underline underline-offset-2",onClick:r(()=>{f(null),i(a==="sign_in"?"sign_up":"sign_in")},"onClick"),children:a==="sign_in"?"Create one":"Sign in"})]})]})}),(0,t.jsx)("div",{className:"hidden md:block w-1/2 overflow-hidden",children:(0,t.jsx)(sKt,{})})]})}r(rKt,"AuthPage");function aKt(){const e=Wt(),s=Sa(),[n]=Ai(),a=(s.token??"").trim(),i=(n.get("code")??"").trim(),o=(0,u.useMemo)(()=>`/board-claim/${encodeURIComponent(a)}${i?`?code=${encodeURIComponent(i)}`:""}`,[a,i]),l=Z({queryKey:P.auth.session,queryFn:r(()=>qa.getSession(),"queryFn"),retry:!1}),c=Z({queryKey:["board-claim",a,i],queryFn:r(()=>hr.getBoardClaimStatus(a,i),"queryFn"),enabled:a.length>0&&i.length>0,retry:!1}),d=Ne({mutationFn:r(()=>hr.claimBoard(a,i),"mutationFn"),onSuccess:r(async()=>{await e.invalidateQueries({queryKey:P.auth.session}),await e.invalidateQueries({queryKey:P.health}),await e.invalidateQueries({queryKey:P.companies.all}),await e.invalidateQueries({queryKey:P.companies.stats}),await c.refetch()},"onSuccess")});if(!a||!i)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-destructive",children:"Invalid board claim URL."});if(c.isLoading||l.isLoading)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-muted-foreground",children:"Loading claim challenge..."});if(c.error)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)(Xs,{className:"block p-6",children:[(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Claim challenge unavailable"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:c.error instanceof Error?c.error.message:"Challenge is invalid or expired."})]})});const m=c.data;return m?m.status==="claimed"?(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)(Xs,{className:"block p-6",children:[(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Board ownership claimed"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"This instance is now linked to your authenticated user."}),(0,t.jsx)(F,{asChild:!0,className:"mt-4",children:(0,t.jsx)(Je,{to:"/",children:"Open board"})})]})}):l.data?(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)(Xs,{className:"block p-6",children:[(0,t.jsx)("h1",{className:"text-xl font-semibold",children:"Claim Board ownership"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"This will promote your user to instance admin and migrate organization ownership access from local trusted mode."}),d.error&&(0,t.jsx)("p",{className:"mt-3 text-sm text-destructive",children:d.error instanceof Error?d.error.message:"Failed to claim board ownership"}),(0,t.jsx)(F,{className:"mt-5",onClick:r(()=>d.mutate(),"onClick"),disabled:d.isPending,children:d.isPending?"Claiming…":"Claim ownership"})]})}):(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)(Xs,{className:"block p-6",children:[(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Sign in required"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Sign in or create an account, then return to this page to claim Board ownership."}),(0,t.jsx)(F,{asChild:!0,className:"mt-4",children:(0,t.jsx)(Je,{to:`/auth?next=${encodeURIComponent(o)}`,children:"Sign in / Create account"})})]})}):(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-destructive",children:"Claim challenge unavailable."})}r(aKt,"BoardClaimPage");function iKt(){const e=Wt(),s=Sa(),[n]=Ai(),a=(s.id??"").trim(),i=(n.get("token")??"").trim(),o=(0,u.useMemo)(()=>`/cli-auth/${encodeURIComponent(a)}${i?`?token=${encodeURIComponent(i)}`:""}`,[a,i]),l=Z({queryKey:P.auth.session,queryFn:r(()=>qa.getSession(),"queryFn"),retry:!1}),c=Z({queryKey:["cli-auth-challenge",a,i],queryFn:r(()=>hr.getCliAuthChallenge(a,i),"queryFn"),enabled:a.length>0&&i.length>0,retry:!1}),d=Ne({mutationFn:r(()=>hr.approveCliAuthChallenge(a,i),"mutationFn"),onSuccess:r(async()=>{await e.invalidateQueries({queryKey:P.auth.session}),await c.refetch()},"onSuccess")}),m=Ne({mutationFn:r(()=>hr.cancelCliAuthChallenge(a,i),"mutationFn"),onSuccess:r(async()=>{await c.refetch()},"onSuccess")});if(!a||!i)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-destructive",children:"Invalid CLI auth URL."});if(l.isLoading||c.isLoading)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-muted-foreground",children:"Loading CLI auth challenge..."});if(c.error)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)(Xs,{className:"block p-6",children:[(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"CLI auth challenge unavailable"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:c.error instanceof Error?c.error.message:"Challenge is invalid or expired."})]})});const h=c.data;return h?h.status==="approved"?(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)(Xs,{className:"block p-6",children:[(0,t.jsx)("h1",{className:"text-xl font-semibold",children:"CLI access approved"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"The Paperclip CLI can now finish authentication on the requesting machine."}),(0,t.jsxs)("p",{className:"mt-4 text-sm text-muted-foreground",children:["Command: ",(0,t.jsx)("span",{className:"font-mono text-foreground",children:h.command})]})]})}):h.status==="cancelled"||h.status==="expired"?(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)(Xs,{className:"block p-6",children:[(0,t.jsx)("h1",{className:"text-xl font-semibold",children:h.status==="expired"?"CLI auth challenge expired":"CLI auth challenge cancelled"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Start the CLI auth flow again from your terminal to generate a new approval request."})]})}):h.requiresSignIn||!l.data?(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)(Xs,{className:"block p-6",children:[(0,t.jsx)("h1",{className:"text-xl font-semibold",children:"Sign in required"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Sign in or create an account, then return to this page to approve the CLI access request."}),(0,t.jsx)(F,{asChild:!0,className:"mt-4",children:(0,t.jsx)(Je,{to:`/auth?next=${encodeURIComponent(o)}`,children:"Sign in / Create account"})})]})}):(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)(Xs,{className:"block p-6",children:[(0,t.jsx)("h1",{className:"text-xl font-semibold",children:"Approve Paperclip CLI access"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"A local Paperclip CLI process is requesting board access to this instance."}),(0,t.jsxs)("div",{className:"mt-5 space-y-3 text-sm",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-muted-foreground",children:"Command"}),(0,t.jsx)("div",{className:"font-mono text-foreground",children:h.command})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-muted-foreground",children:"Client"}),(0,t.jsx)("div",{className:"text-foreground",children:h.clientName??"paperclip-pro cli"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-muted-foreground",children:"Requested access"}),(0,t.jsx)("div",{className:"text-foreground",children:h.requestedAccess==="instance_admin_required"?"Instance admin":"Board"})]}),h.requestedCompanyName&&(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-muted-foreground",children:"Requested organization"}),(0,t.jsx)("div",{className:"text-foreground",children:h.requestedCompanyName})]})]}),(d.error||m.error)&&(0,t.jsx)("p",{className:"mt-4 text-sm text-destructive",children:(d.error??m.error)instanceof Error?(d.error??m.error).message:"Failed to update CLI auth challenge"}),!h.canApprove&&(0,t.jsx)("p",{className:"mt-4 text-sm text-destructive",children:"This challenge requires instance-admin access. Sign in with an instance admin account to approve it."}),(0,t.jsxs)("div",{className:"mt-5 flex gap-3",children:[(0,t.jsx)(F,{onClick:r(()=>d.mutate(),"onClick"),disabled:!h.canApprove||d.isPending||m.isPending,children:d.isPending?"Approving...":"Approve CLI access"}),(0,t.jsx)(F,{type:"button",variant:"outline",onClick:r(()=>m.mutate(),"onClick"),disabled:d.isPending||m.isPending,children:m.isPending?"Cancelling...":"Cancel"})]})]})}):(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-destructive",children:"CLI auth challenge unavailable."})}r(iKt,"CliAuthPage");var oKt=nAe.filter(e=>e!=="paperclip_runner"),ile=new Set(["claude_local","codex_local","gemini_local","kimi_local","opencode_local","pi_local","cursor"]);function lKt(e,s){let n=e;for(const a of s){if(!n||typeof n!="object")return null;n=n[a]}return typeof n=="string"&&n.trim().length>0?n:null}r(lKt,"readNestedString");var Yy="w-full border border-zinc-800 bg-zinc-950 px-3 py-2 text-sm text-zinc-100 outline-none focus:border-zinc-500",ole="border border-zinc-800 bg-zinc-950/95 p-6",lle="flex-1 border px-3 py-2 text-sm transition-colors";function cKt(e){return e?e.charAt(0).toUpperCase()+e.slice(1):null}r(cKt,"formatHumanRole");function E1e(e){if(!e||typeof e!="object")return null;const s=e.code;return typeof s=="string"&&s.trim().length>0?s:null}r(E1e,"getAuthErrorCode");function dKt(e){if(!(e instanceof Error))return null;const s=e.message.trim();return s.length>0?s:null}r(dKt,"getAuthErrorMessage");function uKt(e,s,n){const a=E1e(e),i=dKt(e),o=n.trim().length>0?n.trim():"that email";return a==="USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL"?{tone:"info",message:`An account already exists for ${o}. Sign in below to continue with this invite.`}:a==="INVALID_EMAIL_OR_PASSWORD"?{tone:"error",message:"That email and password did not match an existing Paperclip account. Check both fields, or create an account first if you are new here."}:s==="sign_in"&&i==="Request failed: 401"?{tone:"error",message:"That email and password did not match an existing Paperclip account. Check both fields, or create an account first if you are new here."}:s==="sign_up"&&i==="Request failed: 422"?{tone:"info",message:`An account may already exist for ${o}. Try signing in instead.`}:{tone:"error",message:i??"Authentication failed"}}r(uKt,"mapInviteAuthFeedback");function cle(e){return!!(e&&typeof e=="object"&&"bootstrapAccepted"in e)}r(cle,"isBootstrapAcceptancePayload");function mKt(e,s){return!e||typeof e!="object"||s?!1:e.status==="approved"}r(mKt,"isApprovedHumanJoinPayload");function iz({companyDisplayName:e,companyLogoUrl:s,className:n}){return(0,t.jsx)(Lx,{companyName:e,logoUrl:s,logoFit:"contain",className:n})}r(iz,"InviteCompanyLogo");function dle({companyDisplayName:e,companyLogoUrl:s,invitedByUserName:n,claimSecret:a=null,claimApiKeyPath:i=null,onboardingTextUrl:o=null}){return(0,t.jsx)("div",{className:"min-h-screen bg-zinc-950 px-6 py-12 text-zinc-100",children:(0,t.jsxs)("div",{className:"mx-auto max-w-md border border-zinc-800 bg-zinc-950 p-6","data-testid":"invite-pending-approval",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(iz,{companyDisplayName:e,companyLogoUrl:s,className:"h-12 w-12 border border-zinc-800 rounded-none"}),(0,t.jsxs)("h1",{className:"text-lg font-semibold",children:["Request to join ",e]})]}),(0,t.jsxs)("div",{className:"mt-4 space-y-3",children:[(0,t.jsxs)("p",{className:"text-sm text-zinc-400",children:["Your request is still awaiting approval. ",n??"An organization admin"," must approve your request to join."]}),(0,t.jsxs)("div",{className:"border border-zinc-800 p-3",children:[(0,t.jsx)("p",{className:"text-xs text-zinc-500 mb-1",children:"Approval page"}),(0,t.jsx)("p",{className:"text-sm text-zinc-200",children:"Settings → Members"})]}),(0,t.jsxs)("p",{className:"text-sm text-zinc-400",children:["Ask them to visit ",(0,t.jsx)("span",{className:"text-zinc-200",children:"Settings → Members"})," to approve your request."]}),(0,t.jsx)("p",{className:"text-xs text-zinc-500",children:"Refresh this page after you've been approved — you'll be redirected automatically."})]}),a&&i?(0,t.jsxs)("div",{className:"mt-4 space-y-1 border border-zinc-800 p-3 text-xs text-zinc-400",children:[(0,t.jsx)("div",{className:"text-zinc-200",children:"Claim secret"}),(0,t.jsx)("div",{className:"font-mono break-all",children:a}),(0,t.jsxs)("div",{className:"font-mono break-all",children:["POST ",i]})]}):null,o?(0,t.jsxs)("div",{className:"mt-4 text-xs text-zinc-400",children:["Onboarding: ",(0,t.jsx)("span",{className:"font-mono break-all",children:o})]}):null]})})}r(dle,"AwaitingJoinApprovalPanel");function hKt(){const e=Wt(),s=Yn(),{setSelectedCompanyId:n}=ps(),a=(Sa().token??"").trim(),[i,o]=(0,u.useState)("sign_up"),[l,c]=(0,u.useState)(""),[d,m]=(0,u.useState)(""),[h,p]=(0,u.useState)(""),[f,g]=(0,u.useState)(""),[v,y]=(0,u.useState)("claude_local"),[w,S]=(0,u.useState)(""),[j,N]=(0,u.useState)(null),[_,R]=(0,u.useState)(null),[C,A]=(0,u.useState)(null),[T,I]=(0,u.useState)(!1),$="invite-auth-error",O=Z({queryKey:P.health,queryFn:r(()=>sm.get(),"queryFn"),retry:!1}),L=Z({queryKey:P.auth.session,queryFn:r(()=>qa.getSession(),"queryFn"),retry:!1}),E=Z({queryKey:P.access.invite(a),queryFn:r(()=>hr.getInvite(a),"queryFn"),enabled:a.length>0,retry:!1}),q=lz({enabled:!!L.data&&!!E.data?.companyId,staleTime:0}),B=O.data?.deploymentMode!=="local_trusted"?q.isFetchedAfterMount:!0,K=B?q.data?.companies??[]:[];(0,u.useEffect)(()=>{a&&nle(a)},[a]),(0,u.useEffect)(()=>{I(!1)},[a]),(0,u.useEffect)(()=>{if(!B)return;const pe=q.data?.companies;!pe||!E.data?.companyId||pe.some(be=>be.id===E.data.companyId)&&l2(a)},[q.data,E.data,B,a]);const z=E.data,D=!!L.data&&!!z?.companyId&&!B,V=!!z?.companyId&&K.some(pe=>pe.id===z?.companyId),H=z?.companyName?.trim()||"this Paperclip company",ee=z?.companyLogoUrl?.trim()||null,X=z?.invitedByUserName?.trim()||null,le=z?.inviteMessage?.trim()||null,ce=cKt(z?.humanRole),te=z?.joinRequestStatus??null,ae=z?.joinRequestType??null,de=ae==="human"&&(te==="pending_approval"||te==="approved"),J=O.data?.deploymentMode==="authenticated"&&!L.data&&z?.allowedJoinTypes!=="agent",Y=z?.inviteType!=="bootstrap_ceo"&&z?.allowedJoinTypes==="agent",G=!!L.data&&!Y&&z?.inviteType!=="bootstrap_ceo"&&(!te||de)&&!D&&!V&&!j&&_===null,fe=L.data?.user.name?.trim()||L.data?.user.email?.trim()||"this account",se=d.trim().length>0&&h.trim().length>0&&(i==="sign_in"||l.trim().length>0&&h.trim().length>=8),re=Ne({mutationFn:r(async()=>{if(!z)throw new Error("Invite not found");if(D)throw new Error("Checking your organization access. Try again in a moment.");if(V)throw new Error("This account already belongs to the organization.");return z.inviteType==="bootstrap_ceo"||z.allowedJoinTypes!=="agent"?hr.acceptInvite(a,{requestType:"human"}):hr.acceptInvite(a,{requestType:"agent",agentName:f.trim(),adapterType:v,capabilities:w.trim()||null})},"mutationFn"),onSuccess:r(async pe=>{R(null),l2(a);const be=cle(pe);N({kind:be?"bootstrap":"join",payload:pe}),await e.invalidateQueries({queryKey:P.auth.session}),await e.invalidateQueries({queryKey:P.access.currentBoardAccess}),await e.invalidateQueries({queryKey:P.companies.all}),z?.companyId&&mKt(pe,Y)&&(n(z.companyId,{source:"manual"}),s("/",{replace:!0}))},"onSuccess"),onError:r(pe=>{R(pe instanceof Error?pe.message:"Failed to accept invite")},"onError")});(0,u.useEffect)(()=>{!G||T||re.isPending||(I(!0),R(null),re.mutate())},[re,T,G]);const ie=Ne({mutationFn:r(async()=>{if(i==="sign_in"){await qa.signInEmail({email:d.trim(),password:h});return}await qa.signUpEmail({name:l.trim(),email:d.trim(),password:h})},"mutationFn"),onSuccess:r(async()=>{A(null),nle(a),await e.invalidateQueries({queryKey:P.auth.session}),await e.invalidateQueries({queryKey:P.health}),await e.invalidateQueries({queryKey:P.access.currentBoardAccess});const{companies:pe}=await pIe(e);if(z?.companyId&&pe.some(be=>be.id===z.companyId)){l2(a),n(z.companyId,{source:"manual"}),s("/",{replace:!0});return}if(!(!z||z.inviteType!=="bootstrap_ceo"))try{cle(await re.mutateAsync())&&s("/",{replace:!0})}catch{return}},"onSuccess"),onError:r(pe=>{const be=uKt(pe,i,d);E1e(pe)==="USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL"&&(o("sign_in"),p("")),A(be)},"onError")}),me=(0,u.useMemo)(()=>z?V?"Open organization":z.inviteType==="bootstrap_ceo"?"Accept invite":Y?"Submit request":L.data?"Accept invite":"Continue":"Continue",[z,V,L.data,Y]);if(!a)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-destructive",children:"Invalid invite token."});if(E.isLoading||O.isLoading||L.isLoading)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-muted-foreground",children:"Loading invite..."});if(D)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-muted-foreground",children:"Checking your access..."});if(E.error||!z)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)("div",{className:"border border-border bg-card p-6","data-testid":"invite-error",children:[(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Invite not available"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"This invite may be expired, revoked, or already used."})]})});if(te==="approved"&&ae==="human"&&V)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-muted-foreground",children:"Opening organization..."});if(te==="pending_approval"&&!de)return(0,t.jsx)(dle,{companyDisplayName:H,companyLogoUrl:ee,invitedByUserName:X});if(te&&!de)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)("div",{className:"border border-border bg-card p-6","data-testid":"invite-error",children:[(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Invite not available"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:te==="rejected"?"This join request was not approved.":"This invite has already been used."})]})});if(j?.kind==="bootstrap")return(0,t.jsx)("div",{className:"min-h-screen bg-zinc-950 px-6 py-12 text-zinc-100",children:(0,t.jsxs)("div",{className:"mx-auto max-w-md border border-zinc-800 bg-zinc-950 p-6",children:[(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Bootstrap complete"}),(0,t.jsx)("div",{className:"mt-4",children:(0,t.jsx)(F,{asChild:!0,className:"rounded-none",children:(0,t.jsx)(Je,{to:"/",children:"Open board"})})})]})});if(j?.kind==="join"){const pe=j.payload,be=typeof pe.claimSecret=="string"?pe.claimSecret:null,oe=typeof pe.claimApiKeyPath=="string"?pe.claimApiKeyPath:null,ye=lKt(pe.onboarding,["textInstructions","url"]);return!Y&&pe.status==="approved"?(0,t.jsx)("div",{className:"min-h-screen bg-zinc-950 px-6 py-12 text-zinc-100",children:(0,t.jsxs)("div",{className:"mx-auto max-w-md border border-zinc-800 bg-zinc-950 p-6",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(iz,{companyDisplayName:H,companyLogoUrl:ee,className:"h-12 w-12 border border-zinc-800 rounded-none"}),(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"You joined the organization"})]}),(0,t.jsx)("div",{className:"mt-4",children:(0,t.jsx)(F,{asChild:!0,className:"w-full rounded-none",children:(0,t.jsx)(Je,{to:"/",children:"Open board"})})})]})}):(0,t.jsx)(dle,{companyDisplayName:H,companyLogoUrl:ee,invitedByUserName:X,claimSecret:be,claimApiKeyPath:oe,onboardingTextUrl:ye})}return(0,t.jsx)("div",{className:"min-h-screen bg-zinc-950 px-6 py-12 text-zinc-100",children:(0,t.jsx)("div",{className:"mx-auto max-w-5xl",children:(0,t.jsxs)("div",{className:"grid gap-6 lg:grid-cols-(--gtc-36)",children:[(0,t.jsxs)("section",{className:`${ole} space-y-6`,children:[(0,t.jsxs)("div",{className:"flex items-start gap-4",children:[(0,t.jsx)(iz,{companyDisplayName:H,companyLogoUrl:ee,className:"h-16 w-16 rounded-none border border-zinc-800"}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"text-xs uppercase tracking-(--tracking-caps) text-zinc-500",children:"You've been invited to join Paperclip"}),(0,t.jsx)("h1",{className:"mt-2 text-2xl font-semibold",children:z.inviteType==="bootstrap_ceo"?"Set up Paperclip":`Join ${H}`}),(0,t.jsx)("p",{className:"mt-2 max-w-2xl text-sm leading-6 text-zinc-300",children:Y?"Review the invite details, then submit the agent information below to start the join request.":J?"Create your Paperclip account first. If you already have one, switch to sign in and continue the invite with the same email.":"Your account is ready. Review the invite details, then accept it to continue."})]})]}),(0,t.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,t.jsxs)("div",{className:"border border-zinc-800 p-3",children:[(0,t.jsx)("div",{className:"text-xs uppercase tracking-(--tracking-caps) text-zinc-500",children:"Organization"}),(0,t.jsx)("div",{className:"mt-1 text-sm text-zinc-100",children:H})]}),(0,t.jsxs)("div",{className:"border border-zinc-800 p-3",children:[(0,t.jsx)("div",{className:"text-xs uppercase tracking-(--tracking-caps) text-zinc-500",children:"Invited by"}),(0,t.jsx)("div",{className:"mt-1 text-sm text-zinc-100",children:X??"Paperclip board"})]}),(0,t.jsxs)("div",{className:"border border-zinc-800 p-3",children:[(0,t.jsx)("div",{className:"text-xs uppercase tracking-(--tracking-caps) text-zinc-500",children:"Requested access"}),(0,t.jsx)("div",{className:"mt-1 text-sm text-zinc-100",children:Y?"Agent join request":ce??"Organization access"})]}),(0,t.jsxs)("div",{className:"border border-zinc-800 p-3",children:[(0,t.jsx)("div",{className:"text-xs uppercase tracking-(--tracking-caps) text-zinc-500",children:"Invite expires"}),(0,t.jsx)("div",{className:"mt-1 text-sm text-zinc-100",children:pu(z.expiresAt)})]})]}),le?(0,t.jsxs)("div",{className:"border border-amber-500/40 bg-amber-500/10 p-4",children:[(0,t.jsx)("div",{className:"text-xs uppercase tracking-(--tracking-caps) text-amber-200/80",children:"Message from inviter"}),(0,t.jsx)("p",{className:"mt-2 text-sm leading-6 text-amber-50",children:le})]}):null,L.data?(0,t.jsxs)("div",{className:"border border-emerald-500/40 bg-emerald-500/10 p-4 text-sm text-emerald-50",children:["Signed in as ",(0,t.jsx)("span",{className:"font-medium",children:fe}),"."]}):null]}),(0,t.jsx)("section",{className:`${ole} h-fit`,children:Y?(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-lg font-semibold",children:"Submit agent details"}),(0,t.jsxs)("p",{className:"mt-1 text-sm text-zinc-400",children:["This invite will create an approval request for a new agent in ",H,"."]})]}),(0,t.jsxs)("label",{className:"block text-sm",children:[(0,t.jsx)("span",{className:"mb-1 block text-zinc-400",children:"Agent name"}),(0,t.jsx)("input",{className:Yy,value:f,onChange:r(pe=>g(pe.target.value),"onChange")})]}),(0,t.jsxs)("label",{className:"block text-sm",children:[(0,t.jsx)("span",{className:"mb-1 block text-zinc-400",children:"Adapter type"}),(0,t.jsx)("select",{className:Yy,value:v,onChange:r(pe=>y(pe.target.value),"onChange"),children:oKt.map(pe=>(0,t.jsxs)("option",{value:pe,disabled:!ile.has(pe),children:[mf(pe),ile.has(pe)?"":" (Coming soon)"]},pe))})]}),(0,t.jsxs)("label",{className:"block text-sm",children:[(0,t.jsx)("span",{className:"mb-1 block text-zinc-400",children:"Capabilities"}),(0,t.jsx)("textarea",{className:Yy,rows:4,value:w,onChange:r(pe=>S(pe.target.value),"onChange")})]}),_?(0,t.jsx)("p",{className:"text-xs text-red-400",children:_}):null,(0,t.jsx)(F,{className:"w-full rounded-none",disabled:re.isPending||f.trim().length===0,onClick:r(()=>re.mutate(),"onClick"),children:re.isPending?"Working...":me})]}):J?(0,t.jsxs)("div",{className:"space-y-5",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-lg font-semibold",children:i==="sign_up"?"Create your account":"Sign in to continue"}),(0,t.jsx)("p",{className:"mt-1 text-sm text-zinc-400",children:i==="sign_up"?`Start with a Paperclip account. After that, you'll come right back here to accept the invite for ${H}.`:"Use the Paperclip account that already matches this invite. If you do not have one yet, switch back to create account."})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("button",{type:"button",className:`${lle} ${i==="sign_up"?"border-zinc-100 bg-zinc-100 text-zinc-950":"border-zinc-800 text-zinc-300 hover:border-zinc-600"}`,onClick:r(()=>{A(null),o("sign_up")},"onClick"),children:"Create account"}),(0,t.jsx)("button",{type:"button",className:`${lle} ${i==="sign_in"?"border-zinc-100 bg-zinc-100 text-zinc-950":"border-zinc-800 text-zinc-300 hover:border-zinc-600"}`,onClick:r(()=>{A(null),o("sign_in")},"onClick"),children:"I already have an account"})]}),(0,t.jsxs)("form",{className:"space-y-4",method:"post",action:i==="sign_up"?"/api/auth/sign-up/email":"/api/auth/sign-in/email",onSubmit:r(pe=>{if(pe.preventDefault(),!ie.isPending){if(!se){A({tone:"error",message:"Please fill in all required fields."});return}ie.mutate()}},"onSubmit"),"data-testid":"invite-inline-auth",children:[i==="sign_up"?(0,t.jsxs)("label",{className:"block text-sm",htmlFor:"invite-name",children:[(0,t.jsx)("span",{className:"mb-1 block text-zinc-400",children:"Name"}),(0,t.jsx)("input",{id:"invite-name",name:"name",className:Yy,value:l,onChange:r(pe=>{c(pe.target.value),A(null)},"onChange"),autoComplete:"name",required:!0,"aria-required":"true","aria-invalid":C?.tone==="error"?!0:void 0,"aria-describedby":C?$:void 0,autoFocus:!0})]}):null,(0,t.jsxs)("label",{className:"block text-sm",htmlFor:"invite-email",children:[(0,t.jsx)("span",{className:"mb-1 block text-zinc-400",children:"Email"}),(0,t.jsx)("input",{id:"invite-email",name:"email",type:"email",className:Yy,value:d,onChange:r(pe=>{m(pe.target.value),A(null)},"onChange"),autoComplete:"username",required:!0,"aria-required":"true","aria-invalid":C?.tone==="error"?!0:void 0,"aria-describedby":C?$:void 0,autoFocus:i==="sign_in"})]}),(0,t.jsxs)("label",{className:"block text-sm",htmlFor:"invite-password",children:[(0,t.jsx)("span",{className:"mb-1 block text-zinc-400",children:"Password"}),(0,t.jsx)("input",{id:"invite-password",name:"password",type:"password",className:Yy,value:h,onChange:r(pe=>{p(pe.target.value),A(null)},"onChange"),autoComplete:i==="sign_in"?"current-password":"new-password",required:!0,"aria-required":"true","aria-invalid":C?.tone==="error"?!0:void 0,"aria-describedby":C?$:void 0})]}),C?(0,t.jsx)("p",{id:$,role:"alert",className:`text-xs ${C.tone==="info"?"text-amber-300":"text-red-400"}`,children:C.message}):null,(0,t.jsx)(F,{type:"submit",className:"w-full rounded-none",disabled:ie.isPending,"aria-disabled":!se||ie.isPending,children:ie.isPending?"Working...":i==="sign_in"?"Sign in and continue":"Create account and continue"})]}),(0,t.jsx)("p",{className:"text-xs leading-5 text-zinc-500",children:i==="sign_up"?"Already signed up before? Use the existing-account option instead so the invite lands on the right Paperclip user.":"No account yet? Switch back to create account so you can accept the invite with a new login."})]}):(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-lg font-semibold",children:V?"Already in this organization":G?"Completing organization access":z.inviteType==="bootstrap_ceo"?"Accept bootstrap invite":"Accept organization invite"}),(0,t.jsx)("p",{className:"mt-1 text-sm text-zinc-400",children:G?`Granting your access to ${H}.`:V?`This account already belongs to ${H}.`:`This will ${z.inviteType==="bootstrap_ceo"?"finish setting up Paperclip":`grant or complete your access to ${H}`}.`})]}),_?(0,t.jsx)("p",{className:"text-xs text-red-400",children:_}):null,G?(0,t.jsx)("div",{className:"text-sm text-zinc-400",children:re.isPending?"Submitting request...":"Finishing sign-in..."}):(0,t.jsx)(F,{className:"w-full rounded-none",disabled:re.isPending,onClick:r(()=>{if(V&&z.companyId){l2(a),n(z.companyId,{source:"manual"}),s("/",{replace:!0});return}re.mutate()},"onClick"),children:re.isPending?"Working...":me})]})})]})})})}r(hKt,"InviteLandingPage");function pKt(){const{selectedCompany:e,selectedCompanyId:s}=ps(),{setBreadcrumbs:n}=qn(),{pushToast:a}=Ei(),i=Wt(),[o,l]=(0,u.useState)("pending_approval"),[c,d]=(0,u.useState)("all");(0,u.useEffect)(()=>{n([{label:e?.name??"Organization",href:"/dashboard"},{label:"Inbox",href:"/inbox"},{label:"Join Requests"}])},[e?.name,n]);const m=Z({queryKey:P.access.joinRequests(s??"",`${o}:${c}`),queryFn:r(()=>hr.listJoinRequests(s,o,c==="all"?void 0:c),"queryFn"),enabled:!!s}),h=Ne({mutationFn:r(f=>hr.approveJoinRequest(s,f),"mutationFn"),onSuccess:r(async()=>{await i.invalidateQueries({queryKey:P.access.joinRequests(s,`${o}:${c}`)}),await i.invalidateQueries({queryKey:P.access.companyMembers(s)}),await i.invalidateQueries({queryKey:P.access.companyUserDirectory(s)}),a({title:"Join request approved",tone:"success"})},"onSuccess")}),p=Ne({mutationFn:r(f=>hr.rejectJoinRequest(s,f),"mutationFn"),onSuccess:r(async()=>{await i.invalidateQueries({queryKey:P.access.joinRequests(s,`${o}:${c}`)}),a({title:"Join request rejected",tone:"success"})},"onSuccess")});if(!s)return(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:"Select an organization to review join requests."});if(m.isLoading)return(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:"Loading join requests…"});if(m.error){const f=m.error instanceof wn&&m.error.status===403?"You do not have permission to review join requests for this organization.":m.error instanceof Error?m.error.message:"Failed to load join requests.";return(0,t.jsx)("div",{className:"text-sm text-destructive",children:f})}return(0,t.jsxs)("div",{className:"max-w-6xl space-y-6",children:[(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(FPe,{className:"h-5 w-5 text-muted-foreground"}),(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Join Request Queue"})]}),(0,t.jsx)("p",{className:"max-w-3xl text-sm text-muted-foreground",children:"Review human and agent join requests outside the mixed inbox feed. This queue uses the same approval mutations as the inline inbox cards."})]}),(0,t.jsxs)(Xs,{className:"flex-row flex-wrap gap-3 p-4",children:[(0,t.jsxs)("label",{className:"space-y-2 text-sm",children:[(0,t.jsx)("span",{className:"font-medium",children:"Status"}),(0,t.jsxs)("select",{className:"rounded-md border border-border bg-background px-3 py-2",value:o,onChange:r(f=>l(f.target.value),"onChange"),children:[(0,t.jsx)("option",{value:"pending_approval",children:"Pending approval"}),(0,t.jsx)("option",{value:"approved",children:"Approved"}),(0,t.jsx)("option",{value:"rejected",children:"Rejected"})]})]}),(0,t.jsxs)("label",{className:"space-y-2 text-sm",children:[(0,t.jsx)("span",{className:"font-medium",children:"Request type"}),(0,t.jsxs)("select",{className:"rounded-md border border-border bg-background px-3 py-2",value:c,onChange:r(f=>d(f.target.value),"onChange"),children:[(0,t.jsx)("option",{value:"all",children:"All"}),(0,t.jsx)("option",{value:"human",children:"Human"}),(0,t.jsx)("option",{value:"agent",children:"Agent"})]})]})]}),(0,t.jsx)("div",{className:"space-y-4",children:(m.data??[]).length===0?(0,t.jsx)("div",{className:"rounded-xl border border-dashed border-border px-4 py-8 text-sm text-muted-foreground",children:"No join requests match the current filters."}):m.data.map(f=>(0,t.jsxs)(Xs,{className:"block p-4",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(lt,{variant:f.status==="pending_approval"?"secondary":f.status==="approved"?"outline":"destructive",children:f.status.replace("_"," ")}),(0,t.jsx)(lt,{variant:"outline",children:f.requestType}),f.adapterType?(0,t.jsx)(lt,{variant:"outline",children:f.adapterType}):null]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-base font-medium",children:f.requestType==="human"?f.requesterUser?.name||f.requestEmailSnapshot||f.requestingUserId||"Unknown human requester":f.agentName||"Unknown agent requester"}),(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:f.requestType==="human"?f.requesterUser?.email||f.requestEmailSnapshot||f.requestingUserId:f.capabilities||f.requestIp})]})]}),f.status==="pending_approval"?(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(F,{variant:"outline",onClick:r(()=>p.mutate(f.id),"onClick"),disabled:p.isPending,children:"Reject"}),(0,t.jsx)(F,{onClick:r(()=>h.mutate(f.id),"onClick"),disabled:h.isPending,children:"Approve"})]}):null]}),(0,t.jsxs)("div",{className:"mt-4 grid gap-3 text-sm text-muted-foreground md:grid-cols-2",children:[(0,t.jsxs)("div",{className:"rounded-lg border border-border bg-background px-3 py-2",children:[(0,t.jsx)("div",{className:"text-xs font-medium uppercase tracking-wide",children:"Invite context"}),(0,t.jsx)("div",{className:"mt-2",children:f.invite?`${f.invite.allowedJoinTypes} join invite${f.invite.humanRole?` • default role ${f.invite.humanRole}`:""}`:"Invite metadata unavailable"}),f.invite?.inviteMessage?(0,t.jsx)("div",{className:"mt-2 text-foreground",children:f.invite.inviteMessage}):null]}),(0,t.jsxs)("div",{className:"rounded-lg border border-border bg-background px-3 py-2",children:[(0,t.jsx)("div",{className:"text-xs font-medium uppercase tracking-wide",children:"Request details"}),(0,t.jsxs)("div",{className:"mt-2",children:["Submitted ",new Date(f.createdAt).toLocaleString()]}),(0,t.jsxs)("div",{children:["Source IP ",f.requestIp]}),f.requestType==="agent"&&f.capabilities?(0,t.jsx)("div",{children:f.capabilities}):null]})]})]},f.id))})]})}r(pKt,"JoinRequestQueue");var fKt=(0,u.lazy)(()=>jc(()=>import("./CompanyExport-DjCKz1zk.js").then(e=>({default:e.CompanyExport})),__vite__mapDeps([6,5,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]))),xKt=(0,u.lazy)(()=>jc(()=>import("./Agents.production-B1rYmw_F.js").then(e=>({default:e.Agents})),__vite__mapDeps([26,5,7,9,8,10,11,12,13,27,28,29,15,30,31,32,33,24,25]))),gKt=(0,u.lazy)(()=>jc(()=>import("./Routines.production-BO7eZ9iR.js").then(e=>({default:e.Routines})),__vite__mapDeps([34,5,7,8,9,10,11,12,13,35,14,15,36,37,29,27,38,39,40,21,41,42,16,17,18,19,43,44,30,45,46,23,31,47,33,48,49,50,51,24,25,28]))),ule=(0,u.lazy)(()=>jc(()=>import("./RoutineDetail.production-Bl23zT09.js").then(e=>({default:e.RoutineDetail})),__vite__mapDeps([52,5,7,8,9,10,11,12,13,35,14,15,36,37,29,27,38,39,40,21,41,42,16,17,18,19,43,44,30,45,46,23,31,47,33,48,49,50,51,24,25,53]))),bKt=(0,u.lazy)(()=>jc(()=>import("./CompanySkills.production-BHl_qJmr.js").then(e=>({default:e.CompanySkills})),__vite__mapDeps([54,5,7,8,9,10,11,12,13,14,15,36,37,29,27,38,39,40,21,41,28,16,17,18,19,55,53,31,44,22,20,56,47,48,50,24,25]))),vKt=(0,u.lazy)(()=>jc(()=>import("./CompanyActivity.production-8_P9Hbf6.js").then(e=>({default:e.CompanyActivity})),__vite__mapDeps([57,5,7,8,9,10,11,12,13,27,28,29,43,37,21,44,48,49,51]))),yKt=(0,u.lazy)(()=>jc(()=>import("./Costs.production-UXGZUFPU.js").then(e=>({default:e.Costs})),__vite__mapDeps([58,5,7,28,29,13,12,44,41,50,27,51,24,25]))),jKt=(0,u.lazy)(()=>jc(()=>import("./OrgChart.production-CDnUnIIE.js").then(e=>({default:e.OrgChart})),__vite__mapDeps([59,5,7,8,9,10,11,12,13,27,45,46,51,24,25])));function xg({children:e}){return(0,t.jsx)(u.Suspense,{fallback:(0,t.jsx)(Xm,{}),children:e})}r(xg,"ProductionSurface");function wKt(e){return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ot,{index:!0,element:(0,t.jsx)(kn,{to:"dashboard",replace:!0})}),(0,t.jsx)(ot,{path:"dashboard",element:(0,t.jsx)(Gpt,{})}),(0,t.jsx)(ot,{path:"dashboard/live",element:(0,t.jsx)(Ypt,{})}),(0,t.jsx)(ot,{path:"timeline",element:e?(0,t.jsx)(yp,{to:"/activity/timeline"}):(0,t.jsx)(bje,{})}),(0,t.jsx)(ot,{path:"onboarding",element:(0,t.jsx)(D1e,{})}),(0,t.jsx)(ot,{path:"companies",element:(0,t.jsx)(Lft,{})}),(0,t.jsx)(ot,{path:"company/settings",element:(0,t.jsx)(X3t,{})}),(0,t.jsx)(ot,{path:"company/settings/environments",element:(0,t.jsx)(kn,{to:"/company/settings/instance/environments",replace:!0})}),(0,t.jsx)(ot,{path:"company/settings/cloud-upstream",element:(0,t.jsx)(kn,{to:"/company/export",replace:!0})}),(0,t.jsxs)(ot,{element:(0,t.jsx)(dh,{pageKey:"company.members"}),children:[(0,t.jsx)(ot,{path:"company/settings/members",element:(0,t.jsx)(y4t,{})}),(0,t.jsx)(ot,{path:"company/settings/access",element:(0,t.jsx)(j4t,{})})]}),(0,t.jsx)(ot,{element:(0,t.jsx)(dh,{pageKey:"company.invites"}),children:(0,t.jsx)(ot,{path:"company/settings/invites",element:(0,t.jsx)(kn,{to:"/company/settings/members?tab=invites",replace:!0})})}),(0,t.jsx)(ot,{element:(0,t.jsx)(dh,{pageKey:"company.export"}),children:(0,t.jsx)(ot,{path:"company/export/*",element:(0,t.jsx)(u.Suspense,{fallback:(0,t.jsx)(Xm,{}),children:(0,t.jsx)(fKt,{})})})}),(0,t.jsx)(ot,{element:(0,t.jsx)(_tt,{}),children:(0,t.jsx)(ot,{element:(0,t.jsx)(dh,{pageKey:"company.import"}),children:(0,t.jsx)(ot,{path:"company/import",element:(0,t.jsx)(Azt,{})})})}),(0,t.jsx)(ot,{element:(0,t.jsx)(dh,{pageKey:"company.secrets"}),children:(0,t.jsx)(ot,{path:"company/settings/secrets",element:(0,t.jsx)(k6t,{})})}),(0,t.jsx)(ot,{path:"company/settings/tools",element:(0,t.jsx)(hle,{})}),(0,t.jsx)(ot,{path:"company/settings/tools/:tab",element:(0,t.jsx)(hle,{})}),(0,t.jsx)(ot,{path:"tools",element:(0,t.jsx)(ple,{})}),(0,t.jsx)(ot,{path:"tools/:tab",element:(0,t.jsx)(ple,{})}),(0,t.jsx)(ot,{path:"apps",element:(0,t.jsx)(rLt,{})}),(0,t.jsx)(ot,{path:"apps/browse",element:(0,t.jsx)(kn,{to:"/apps",replace:!0})}),(0,t.jsx)(ot,{path:"apps/connections",element:(0,t.jsx)(kn,{to:"/apps",replace:!0})}),(0,t.jsx)(ot,{path:"apps/byo",element:(0,t.jsx)(lCe,{byoOnly:!0})}),(0,t.jsx)(ot,{path:"apps/vercel-connect",element:(0,t.jsx)(mle,{credentialSource:"vercel_connect"})}),(0,t.jsx)(ot,{path:"apps/connect",element:(0,t.jsx)(mle,{})}),(0,t.jsx)(ot,{path:"apps/chat/connect",element:(0,t.jsx)(P$,{children:(0,t.jsx)(TLt,{})})}),(0,t.jsx)(ot,{path:"apps/chat/:endpointId",element:(0,t.jsx)(P$,{children:(0,t.jsx)(kn,{to:"settings",replace:!0})})}),(0,t.jsx)(ot,{path:"apps/chat/:endpointId/:tab",element:(0,t.jsx)(P$,{children:(0,t.jsx)(GLt,{})})}),(0,t.jsx)(ot,{path:"apps/connect/:appKey",element:(0,t.jsx)(kn,{to:"/apps",replace:!0})}),(0,t.jsx)(ot,{path:"apps/connect/:appKey/:stage",element:(0,t.jsx)(kn,{to:"/apps",replace:!0})}),(0,t.jsx)(ot,{path:"apps/review",element:(0,t.jsx)(s$t,{})}),(0,t.jsx)(ot,{path:"apps/attention",element:(0,t.jsx)(kn,{to:"/apps",replace:!0})}),(0,t.jsx)(ot,{path:"apps/gateways",element:(0,t.jsx)(wie,{})}),(0,t.jsx)(ot,{path:"apps/gateways/:gatewayId",element:(0,t.jsx)(kn,{to:"overview",replace:!0})}),(0,t.jsx)(ot,{path:"apps/gateways/:gatewayId/:tab",element:(0,t.jsx)(Y$t,{})}),(0,t.jsx)(ot,{path:"apps/advanced",element:(0,t.jsx)(rie,{})}),(0,t.jsx)(ot,{path:"apps/advanced/gateways",element:(0,t.jsx)(wie,{})}),(0,t.jsx)(ot,{path:"apps/advanced/profiles/new",element:(0,t.jsx)(cie,{mode:"new"})}),(0,t.jsx)(ot,{path:"apps/advanced/profiles/:profileId/edit",element:(0,t.jsx)(cie,{mode:"edit"})}),(0,t.jsx)(ot,{path:"apps/advanced/profiles/:profileId",element:(0,t.jsx)(qDt,{})}),(0,t.jsx)(ot,{path:"apps/advanced/audit",element:(0,t.jsx)(kn,{to:"/apps",replace:!0})}),(0,t.jsx)(ot,{path:"apps/advanced/run-your-own",element:(0,t.jsx)(kn,{to:"/apps",replace:!0})}),(0,t.jsx)(ot,{path:"apps/advanced/:tab",element:(0,t.jsx)(rie,{})}),(0,t.jsx)(ot,{path:"apps/app/:applicationId",element:(0,t.jsx)(vie,{})}),(0,t.jsx)(ot,{path:"apps/app/:applicationId/:tab",element:(0,t.jsx)(vie,{})}),(0,t.jsx)(ot,{path:"apps/:connectionId",element:(0,t.jsx)(kn,{to:"permissions",replace:!0})}),(0,t.jsx)(ot,{path:"apps/:connectionId/:tab",element:(0,t.jsx)(d$t,{})}),(0,t.jsx)(ot,{path:"company/settings/instance",element:(0,t.jsx)(kn,{to:"/company/settings",replace:!0})}),(0,t.jsx)(ot,{element:(0,t.jsx)(dh,{pageKey:"instance.profile"}),children:(0,t.jsx)(ot,{path:"company/settings/instance/profile",element:(0,t.jsx)(TUt,{})})}),(0,t.jsx)(ot,{path:"company/settings/instance/general",element:(0,t.jsx)(kn,{to:"/company/settings",replace:!0})}),(0,t.jsx)(ot,{path:"company/settings/instance/heartbeats",element:(0,t.jsx)(kn,{to:"/company/settings",replace:!0})}),(0,t.jsxs)(ot,{element:(0,t.jsx)(dh,{pageKey:"instance.environments"}),children:[(0,t.jsx)(ot,{path:"company/settings/instance/environments",element:(0,t.jsx)(w$,{})}),(0,t.jsx)(ot,{path:"company/settings/instance/environments/new",element:(0,t.jsx)(w$,{mode:"create"})}),(0,t.jsx)(ot,{path:"company/settings/instance/environments/:environmentId/edit",element:(0,t.jsx)(w$,{mode:"edit"})})]}),(0,t.jsx)(ot,{element:(0,t.jsx)(dh,{pageKey:"instance.access"}),children:(0,t.jsx)(ot,{path:"company/settings/instance/access",element:(0,t.jsx)(_Ut,{})})}),(0,t.jsx)(ot,{element:(0,t.jsx)(dh,{pageKey:"instance.experimental"}),children:(0,t.jsx)(ot,{path:"company/settings/instance/experimental",element:(0,t.jsx)(CUt,{})})}),(0,t.jsxs)(ot,{element:(0,t.jsx)(dh,{pageKey:"instance.plugins"}),children:[(0,t.jsx)(ot,{path:"company/settings/instance/plugins",element:(0,t.jsx)(PUt,{})}),(0,t.jsx)(ot,{path:"company/settings/instance/plugins/:pluginId",element:(0,t.jsx)(MUt,{})})]}),(0,t.jsx)(ot,{element:(0,t.jsx)(dh,{pageKey:"instance.adapters"}),children:(0,t.jsx)(ot,{path:"company/settings/instance/adapters",element:(0,t.jsx)(Zoe,{})})}),(0,t.jsx)(ot,{path:"company/settings/:settingsRoutePath/*",element:(0,t.jsx)(h4t,{})}),(0,t.jsx)(ot,{path:"skills/studio",element:(0,t.jsx)(H$,{})}),(0,t.jsx)(ot,{path:"skills/studio/new",element:(0,t.jsx)(H$,{})}),(0,t.jsx)(ot,{path:"skills/studio/:skillId",element:(0,t.jsx)(H$,{})}),(0,t.jsx)(ot,{path:"skills/:skillId/studio",element:(0,t.jsx)(P1e,{})}),(0,t.jsx)(ot,{path:"skills/*",element:e?(0,t.jsx)(uFt,{}):(0,t.jsx)(xg,{children:(0,t.jsx)(bKt,{})})}),(0,t.jsx)(ot,{path:"settings",element:(0,t.jsx)(xb,{})}),(0,t.jsx)(ot,{path:"settings/*",element:(0,t.jsx)(xb,{})}),(0,t.jsx)(ot,{path:"plugins/:pluginId",element:(0,t.jsx)(ele,{})}),(0,t.jsx)(ot,{path:"org",element:e?(0,t.jsx)(kn,{to:"/agents/all",replace:!0}):(0,t.jsx)(xg,{children:(0,t.jsx)(jKt,{})})}),(0,t.jsx)(ot,{path:"agents",element:(0,t.jsx)(kn,{to:"/agents/all",replace:!0})}),K8.map(s=>(0,t.jsx)(ot,{path:`agents/${s}`,element:e?(0,t.jsx)(cxt,{}):(0,t.jsx)(xg,{children:(0,t.jsx)(xKt,{})})},s)),(0,t.jsx)(ot,{path:"agents/new",element:(0,t.jsx)(XUt,{})}),(0,t.jsx)(ot,{path:"agents/:agentId",element:(0,t.jsx)(lL,{})}),(0,t.jsx)(ot,{path:"agents/:agentId/:tab",element:(0,t.jsx)(lL,{})}),(0,t.jsx)(ot,{path:"agents/:agentId/runs/:runId",element:(0,t.jsx)(lL,{})}),(0,t.jsx)(ot,{path:"projects",element:(0,t.jsx)(jbt,{})}),(0,t.jsx)(ot,{path:"projects/:projectId",element:(0,t.jsx)(q0,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/overview",element:(0,t.jsx)(q0,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/issues",element:(0,t.jsx)(q0,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/issues/:filter",element:(0,t.jsx)(q0,{})}),(0,t.jsx)(ot,{element:(0,t.jsx)(mD,{}),children:(0,t.jsx)(ot,{path:"projects/:projectId/workspaces/:workspaceId",element:(0,t.jsx)(xyt,{})})}),(0,t.jsx)(ot,{path:"projects/:projectId/workspaces",element:(0,t.jsx)(q0,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/configuration",element:(0,t.jsx)(q0,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/budget",element:(0,t.jsx)(q0,{})}),(0,t.jsx)(ot,{element:(0,t.jsx)(mD,{}),children:(0,t.jsx)(ot,{path:"workspaces",element:(0,t.jsx)(vyt,{})})}),(0,t.jsx)(ot,{path:"issues",element:(0,t.jsx)(_yt,{})}),(0,t.jsx)(ot,{path:"tasks",element:(0,t.jsx)(kn,{to:"/issues",replace:!0})}),(0,t.jsx)(ot,{path:"search",element:(0,t.jsx)(Zyt,{})}),(0,t.jsx)(ot,{path:"issues/all",element:(0,t.jsx)(kn,{to:"/issues",replace:!0})}),(0,t.jsx)(ot,{path:"issues/active",element:(0,t.jsx)(kn,{to:"/issues",replace:!0})}),(0,t.jsx)(ot,{path:"issues/backlog",element:(0,t.jsx)(kn,{to:"/issues",replace:!0})}),(0,t.jsx)(ot,{path:"issues/done",element:(0,t.jsx)(kn,{to:"/issues",replace:!0})}),(0,t.jsx)(ot,{path:"issues/recent",element:(0,t.jsx)(kn,{to:"/issues",replace:!0})}),(0,t.jsx)(ot,{path:"chats/:agentRef",element:(0,t.jsx)(jSt,{})}),(0,t.jsx)(ot,{path:"issues/:issueId",element:(0,t.jsx)(vSt,{})}),null,(0,t.jsx)(ot,{path:"routines",element:e?(0,t.jsx)(eCt,{}):(0,t.jsx)(xg,{children:(0,t.jsx)(gKt,{})})}),(0,t.jsx)(ot,{path:"cases",element:(0,t.jsx)(kX,{children:(0,t.jsx)(Htt,{})})}),(0,t.jsx)(ot,{path:"cases/:caseIdentifier",element:(0,t.jsx)(kX,{children:(0,t.jsx)(Rrt,{})})}),(0,t.jsx)(ot,{path:"status",element:(0,t.jsx)(SX,{children:(0,t.jsx)(Dne,{})})}),(0,t.jsx)(ot,{path:"status/:cardId",element:(0,t.jsx)(SX,{children:(0,t.jsx)(Dne,{})})}),(0,t.jsx)(ot,{path:"status-cards",element:(0,t.jsx)(fle,{})}),(0,t.jsx)(ot,{path:"status-cards/:cardId",element:(0,t.jsx)(fle,{})}),(0,t.jsx)(ot,{path:"review-queue",element:(0,t.jsx)(ag,{children:(0,t.jsx)(b_t,{})})}),(0,t.jsx)(ot,{path:"learnings",element:(0,t.jsx)(ag,{children:(0,t.jsx)(y_t,{})})}),(0,t.jsx)(ot,{path:"pipelines",element:(0,t.jsx)(ag,{children:(0,t.jsx)(UL,{})})}),(0,t.jsx)(ot,{path:"pipelines/:pipelineId",element:(0,t.jsx)(ag,{children:(0,t.jsx)(UL,{})})}),(0,t.jsx)(ot,{path:"pipelines/:pipelineId/add",element:(0,t.jsx)(ag,{children:(0,t.jsx)(UL,{})})}),(0,t.jsx)(ot,{path:"pipelines/:pipelineId/settings",element:(0,t.jsx)(ag,{children:(0,t.jsx)(hIt,{})})}),(0,t.jsx)(ot,{path:"pipelines/:pipelineId/items/:caseId",element:(0,t.jsx)(ag,{children:(0,t.jsx)(O1t,{})})}),(0,t.jsx)(ot,{path:"pipelines/:pipelineId/cases/:caseId",element:(0,t.jsx)(ag,{children:(0,t.jsx)(D1t,{})})}),(0,t.jsx)(ot,{path:"routines/:routineId",element:e?(0,t.jsx)(Gne,{}):(0,t.jsx)(xg,{children:(0,t.jsx)(ule,{})})}),(0,t.jsx)(ot,{path:"routines/:routineId/:section",element:e?(0,t.jsx)(Gne,{}):(0,t.jsx)(xg,{children:(0,t.jsx)(ule,{})})}),(0,t.jsx)(ot,{element:(0,t.jsx)(mD,{}),children:(0,t.jsxs)(ot,{element:(0,t.jsx)(Att,{}),children:[(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId",element:(0,t.jsx)(Ky,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId/services",element:(0,t.jsx)(Ky,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId/configuration",element:(0,t.jsx)(Ky,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId/runtime-logs",element:(0,t.jsx)(Ky,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId/issues",element:(0,t.jsx)(Ky,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId/routines",element:(0,t.jsx)(Ky,{})})]})}),(0,t.jsx)(ot,{path:"goals",element:(0,t.jsx)(T2t,{})}),(0,t.jsx)(ot,{path:"goals/:goalId",element:(0,t.jsx)(V2t,{})}),(0,t.jsx)(ot,{path:"artifacts",element:(0,t.jsx)(Zne,{})}),(0,t.jsx)(ot,{path:"approvals",element:(0,t.jsx)(kn,{to:"/approvals/pending",replace:!0})}),(0,t.jsx)(ot,{path:"approvals/pending",element:(0,t.jsx)(tre,{})}),(0,t.jsx)(ot,{path:"approvals/all",element:(0,t.jsx)(tre,{})}),(0,t.jsx)(ot,{path:"approvals/:approvalId",element:(0,t.jsx)(W2t,{})}),(0,t.jsx)(ot,{path:"activity",element:e?(0,t.jsx)(PRt,{}):(0,t.jsx)(xg,{children:(0,t.jsx)(vKt,{})})}),e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ot,{path:"activity/runs",element:(0,t.jsx)(tS,{section:"runs"})}),(0,t.jsx)(ot,{path:"activity/costs",element:(0,t.jsx)(tS,{section:"costs"})}),(0,t.jsx)(ot,{path:"activity/budgets",element:(0,t.jsx)(tS,{section:"budgets"})}),(0,t.jsx)(ot,{path:"activity/timeline",element:(0,t.jsx)(tS,{section:"timeline"})}),(0,t.jsx)(ot,{path:"audit",element:(0,t.jsx)(yp,{to:"/activity",forceAgentMode:!0})}),(0,t.jsx)(ot,{path:"audit/activity",element:(0,t.jsx)(yp,{to:"/activity"})}),(0,t.jsx)(ot,{path:"audit/runs",element:(0,t.jsx)(yp,{to:"/activity/runs"})}),(0,t.jsx)(ot,{path:"audit/costs",element:(0,t.jsx)(yp,{to:"/activity/costs"})}),(0,t.jsx)(ot,{path:"audit/budgets",element:(0,t.jsx)(yp,{to:"/activity/budgets"})}),(0,t.jsx)(ot,{path:"audit/timeline",element:(0,t.jsx)(yp,{to:"/activity/timeline"})}),(0,t.jsx)(ot,{path:"runs",element:(0,t.jsx)(yp,{to:"/activity/runs"})}),(0,t.jsx)(ot,{path:"costs",element:(0,t.jsx)(yp,{to:"/activity/costs"})}),(0,t.jsx)(ot,{path:"budgets",element:(0,t.jsx)(yp,{to:"/activity/budgets"})})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ot,{path:"costs",element:(0,t.jsx)(xg,{children:(0,t.jsx)(yKt,{})})}),(0,t.jsx)(ot,{path:"audit",element:(0,t.jsx)(kn,{to:"/activity?mode=agents",replace:!0})})]}),(0,t.jsxs)(ot,{element:(0,t.jsx)(mXe,{}),children:[(0,t.jsx)(ot,{path:"board-chat",element:(0,t.jsx)(B3t,{})}),(0,t.jsx)(ot,{path:"artifacts",element:(0,t.jsx)(Zne,{})})]}),null,(0,t.jsx)(ot,{path:"decisions",element:(0,t.jsx)(u3t,{})}),(0,t.jsx)(ot,{path:"decisions/queues/:key",element:(0,t.jsx)(f3t,{})}),(0,t.jsx)(ot,{path:"inbox",element:(0,t.jsx)(NKt,{})}),(0,t.jsx)(ot,{path:"inbox/mine",element:(0,t.jsx)(kk,{})}),(0,t.jsx)(ot,{path:"inbox/recent",element:(0,t.jsx)(kk,{})}),(0,t.jsx)(ot,{path:"inbox/unread",element:(0,t.jsx)(kk,{})}),(0,t.jsx)(ot,{path:"inbox/blocked",element:(0,t.jsx)(kk,{})}),(0,t.jsx)(ot,{path:"inbox/all",element:(0,t.jsx)(kk,{})}),(0,t.jsx)(ot,{path:"inbox/requests",element:(0,t.jsx)(pKt,{})}),(0,t.jsx)(ot,{path:"inbox/new",element:(0,t.jsx)(kn,{to:"/inbox/mine",replace:!0})}),(0,t.jsx)(ot,{path:"u/:userSlug",element:(0,t.jsx)(a2t,{})}),(0,t.jsx)(ot,{path:"design-guide",element:(0,t.jsx)(NUt,{})}),(0,t.jsx)(ot,{path:"instance/settings/adapters",element:(0,t.jsx)(Zoe,{})}),(0,t.jsx)(ot,{path:":pluginRoutePath/*",element:(0,t.jsx)(ele,{})}),(0,t.jsx)(ot,{path:"*",element:(0,t.jsx)(xu,{scope:"board"})})]})}r(wKt,"boardRoutes");function mle({credentialSource:e="paperclip_vault"}={}){const s=na(),n=new URLSearchParams(s.search),{enabled:a}=$x();return LGe(n,{chatConnectorsEnabled:a})?(0,t.jsx)(lCe,{credentialSource:e}):(0,t.jsx)(kn,{to:"/apps",replace:!0})}r(mle,"AppsConnectEntryRoute");function NKt(){return(0,t.jsx)(kn,{to:`/inbox/${d2e()}`,replace:!0})}r(NKt,"InboxRootRedirect");function P1e(){const e=na(),{companies:s,selectedCompany:n,loading:a}=ps(),{companyPrefix:i,skillId:o}=Sa();if(a)return null;const l=(i?s.find(c=>c.issuePrefix.toUpperCase()===i.toUpperCase()):null)??n??s[0]??null;return!l||!o?(0,t.jsx)(kn,{to:"/skills/studio",replace:!0}):(0,t.jsx)(kn,{to:`/${l.issuePrefix}/skills/studio/${encodeURIComponent(o)}${e.search}${e.hash}`,replace:!0})}r(P1e,"LegacySkillStudioRedirect");function xb(){const e=na(),{companies:s,selectedCompany:n,loading:a}=ps(),{companyPrefix:i}=Sa(),{hidden:o}=eh();if(a)return(0,t.jsx)(Xm,{});const l=(i?s.find(d=>d.issuePrefix.toUpperCase()===i.toUpperCase()):null)??n??s[0]??null;if(!l)return TK({pathname:e.pathname,hasCompanies:!1})?(0,t.jsx)(kn,{to:"/onboarding",replace:!0}):(0,t.jsx)(g9,{});const c=wLe(Lue(`${e.pathname}${e.search}${e.hash}`),o);return(0,t.jsx)(kn,{to:`/${l.issuePrefix}${c}`,replace:!0})}r(xb,"LegacySettingsRedirect");function hle(){const{tab:e}=Sa();return(0,t.jsx)(kn,{to:M1e(e),replace:!0})}r(hle,"LegacyToolsSettingsRedirect");function ple(){const{tab:e}=Sa();return(0,t.jsx)(kn,{to:M1e(e),replace:!0})}r(ple,"LegacyToolsRedirect");function M1e(e){return e?e==="applications"||e==="connections"||e==="overview"||e==="examples"||e==="runtime"||e==="audit"?"/apps":e==="policies"?"/apps/advanced/profiles":`/apps/advanced/${e}`:"/apps/advanced/profiles"}r(M1e,"legacyToolsRedirectTarget");function D1e(){const{companies:e}=ps(),{openOnboarding:s}=$o(),{t:n}=due(),a=Yc(),i=U5(a?.cloudBaseUrl??null),{onboardingOpen:o,onboardingRouteDismissed:l}=C5(),{companyPrefix:c}=Sa(),d=c?e.find(p=>p.issuePrefix.toUpperCase()===c.toUpperCase())??null:null;if(BYe({onboardingOpen:o,routeDismissed:l}))return null;const m=d?`Add another agent to ${d.name}`:e.length>0?"Create another organization":"Create your first organization",h=d?"Run onboarding again to add an agent and a starter task for this organization.":e.length>0?"Run onboarding again to create another organization and seed its first agent.":"Get started by creating an organization and your first agent.";return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)("div",{className:"rounded-lg border border-border bg-card p-6",children:[(0,t.jsx)("h1",{className:"text-xl font-semibold",children:m}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:h}),(0,t.jsx)("div",{className:"mt-4",children:!d&&a&&!i?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:n("app.cloudCreateUnavailable",{defaultValue:"Organizations are created in Paperclip Cloud. This instance can't reach it right now — try again from your Cloud portfolio."})}):(0,t.jsx)(F,{onClick:r(()=>d?s({initialStep:KT(),companyId:d.id}):a&&i?Sc(i):s(),"onClick"),children:d?"Add Agent":"Start Onboarding"})})]})})}r(D1e,"OnboardingRoutePage");function kKt(){const{companies:e,selectedCompany:s,loading:n}=ps(),a=na();if(n)return(0,t.jsx)(Xm,{});const i=s??e[0]??null;return i?(0,t.jsx)(kn,{to:`/${i.issuePrefix}/dashboard`,replace:!0}):TK({pathname:a.pathname,hasCompanies:!1})?(0,t.jsx)(kn,{to:"/onboarding",replace:!0}):(0,t.jsx)(g9,{})}r(kKt,"CompanyRootRedirect");function fle(){const{cardId:e}=Sa(),s=vAe(),n=s?`/${s}`:"";return(0,t.jsx)(kn,{to:`${n}/status${e?`/${e}`:""}`,replace:!0})}r(fle,"StatusCardsLegacyRedirect");function yp({to:e,forceAgentMode:s=!1}){const n=na(),a=new URLSearchParams(n.search);s&&a.set("mode","agents");const i=a.toString();return(0,t.jsx)(kn,{to:`${e}${i?`?${i}`:""}${n.hash}`,replace:!0})}r(yp,"AuditCompatibilityRedirect");function ja(){const e=na(),{companies:s,selectedCompany:n,loading:a}=ps();if(a)return(0,t.jsx)(Xm,{});const i=n??s[0]??null;return i?(0,t.jsx)(kn,{to:`/${i.issuePrefix}${e.pathname}${e.search}${e.hash}`,replace:!0}):TK({pathname:e.pathname,hasCompanies:!1})?(0,t.jsx)(kn,{to:"/onboarding",replace:!0}):(0,t.jsx)(g9,{})}r(ja,"UnprefixedBoardRedirect");function g9(){const{openOnboarding:e}=$o(),{t:s}=due(),n=Yc(),a=U5(n?.cloudBaseUrl??null);return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)("div",{className:"rounded-lg border border-border bg-card p-6",children:[(0,t.jsx)("h1",{className:"text-xl font-semibold",children:s("app.noCompanies.title",{defaultValue:"Create your first organization"})}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:s("app.noCompanies.description",{defaultValue:"Get started by creating an organization."})}),(0,t.jsx)("div",{className:"mt-4",children:n&&!a?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:s("app.cloudCreateUnavailable",{defaultValue:"Organizations are created in Paperclip Cloud. This instance can't reach it right now — try again from your Cloud portfolio."})}):(0,t.jsx)(F,{onClick:r(()=>n&&a?Sc(a):e(),"onClick"),children:s("app.noCompanies.newCompany",{defaultValue:"New Organization"})})})]})})}r(g9,"NoCompaniesStartPage");function SKt(){const{enabled:e,loaded:s}=Cc();return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(wAe,{children:[(0,t.jsx)(ot,{path:"oauth-handoff",element:(0,t.jsx)(I$t,{})}),(0,t.jsx)(ot,{path:"auth",element:(0,t.jsx)(rKt,{})}),(0,t.jsx)(ot,{path:"board-claim/:token",element:(0,t.jsx)(aKt,{})}),(0,t.jsx)(ot,{path:"cli-auth/:id",element:(0,t.jsx)(iKt,{})}),(0,t.jsx)(ot,{path:"invite/:token",element:(0,t.jsx)(hKt,{})}),(0,t.jsx)(ot,{element:s?(0,t.jsx)(bZ,{allowMembershipRequest:!0}):(0,t.jsx)(Xm,{}),children:(0,t.jsx)(ot,{path:"chat-identity/confirm",element:(0,t.jsx)(e$t,{})})}),(0,t.jsx)(ot,{path:"tests/perf/long-thread",element:(0,t.jsx)(ESt,{})}),(0,t.jsx)(ot,{path:"ux-lab/bootstrap-setup",element:(0,t.jsx)(c4t,{})}),(0,t.jsx)(ot,{path:"ux-lab/responsible-user-denial",element:(0,t.jsx)(d4t,{})}),(0,t.jsx)(ot,{path:"ux-lab/cross-issue-collaboration",element:(0,t.jsx)(m4t,{})}),(0,t.jsxs)(ot,{element:s?(0,t.jsx)(bZ,{}):(0,t.jsx)(Xm,{}),children:[(0,t.jsx)(ot,{index:!0,element:(0,t.jsx)(kKt,{})}),(0,t.jsx)(ot,{path:"onboarding",element:(0,t.jsx)(D1e,{})}),(0,t.jsx)(ot,{path:"instance",element:(0,t.jsx)(xb,{})}),(0,t.jsx)(ot,{path:"instance/settings",element:(0,t.jsx)(xb,{})}),(0,t.jsx)(ot,{path:"instance/settings/*",element:(0,t.jsx)(xb,{})}),(0,t.jsx)(ot,{path:"companies",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"issues",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"tasks",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"issues/:issueId",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"routines",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"routines/:routineId",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"review-queue",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"learnings",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"cases",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"cases/:caseIdentifier",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"status",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"status/:cardId",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"status-cards",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"status-cards/:cardId",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"pipelines",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"pipelines/:pipelineId",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"pipelines/:pipelineId/add",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"pipelines/:pipelineId/settings",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"pipelines/:pipelineId/items/:caseId",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"pipelines/:pipelineId/cases/:caseId",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"artifacts",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"audit",element:(0,t.jsx)(ja,{})}),e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ot,{path:"audit/*",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"activity",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"activity/*",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"runs",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"costs",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"budgets",element:(0,t.jsx)(ja,{})})]}):null,(0,t.jsx)(ot,{path:"decisions",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"u/:userSlug",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"skills/studio",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"skills/studio/new",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"skills/studio/:skillId",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"skills/:skillId/studio",element:(0,t.jsx)(P1e,{})}),(0,t.jsx)(ot,{path:"skills/*",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"settings",element:(0,t.jsx)(xb,{})}),(0,t.jsx)(ot,{path:"settings/*",element:(0,t.jsx)(xb,{})}),(0,t.jsx)(ot,{path:"agents",element:(0,t.jsx)(ja,{})}),K8.map(n=>(0,t.jsx)(ot,{path:`agents/${n}`,element:(0,t.jsx)(ja,{})},n)),(0,t.jsx)(ot,{path:"agents/new",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"agents/:agentId",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"agents/:agentId/:tab",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"agents/:agentId/runs/:runId",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"projects",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"projects/:projectId",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/overview",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/issues",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/issues/:filter",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/workspaces",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/workspaces/:workspaceId",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/configuration",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"workspaces",element:(0,t.jsx)(ja,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId",element:(0,t.jsx)(Iy,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId/services",element:(0,t.jsx)(Iy,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId/configuration",element:(0,t.jsx)(Iy,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId/runtime-logs",element:(0,t.jsx)(Iy,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId/issues",element:(0,t.jsx)(Iy,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId/routines",element:(0,t.jsx)(Iy,{})}),(0,t.jsx)(ot,{path:":companyPrefix",element:e?(0,t.jsx)(AJe,{}):(0,t.jsx)(cXe,{}),children:wKt(e)}),(0,t.jsx)(ot,{path:"*",element:(0,t.jsx)(xu,{scope:"global"})})]})]}),(0,t.jsx)(aat,{})]})}r(SKt,"App");var CKt=class extends u.Component{static{r(this,"AppErrorBoundary")}state={error:null};static getDerivedStateFromError(e){return{error:e instanceof Error?e:new Error(String(e))}}componentDidCatch(e,s){rge(e,{boundary:"app",componentStack:s.componentStack})}render(){const{error:e}=this.state;return e?(0,t.jsxs)("div",{className:"mx-auto flex min-h-screen max-w-2xl flex-col justify-center space-y-4 px-4 py-10",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Paperclip hit an error"}),(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"Something went wrong while running the app. Reloading usually fixes this."})]}),(0,t.jsx)("pre",{className:"overflow-auto rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive whitespace-pre-wrap",children:e.message}),(0,t.jsx)("div",{children:(0,t.jsx)("button",{type:"button",className:"inline-flex items-center rounded-md border border-input bg-background px-3 py-1.5 text-sm font-medium shadow-sm hover:bg-accent hover:text-accent-foreground",onClick:r(()=>window.location.reload(),"onClick"),children:"Reload page"})})]}):this.props.children}};function _Kt(){const{data:e}=Z({queryKey:P.auth.session,queryFn:r(()=>qa.getSession(),"queryFn"),retry:!1}),s=e?.sentryDsn,n=e?.sentryEnvironment??void 0;return(0,u.useEffect)(()=>{if(s)return sJe(s,n),()=>{nJe()}},[s,n]),null}r(_Kt,"SentryGate");function IKt(e){return{id:e.key,title:e.title,status:e.status,projectId:e.projectId??null,assigneeAgentId:e.assigneeAgentId??null,lastRun:e.lastRunAt||e.lastRunStatus?{triggeredAt:e.lastRunAt??null,status:e.lastRunStatus??null}:null}}r(IKt,"managedRoutineToRow");function AKt({routines:e,agents:s=[],projects:n=[],pluginDisplayName:a=null,emptyMessage:i="No managed routines.",runningRoutineKey:o=null,statusMutationRoutineKey:l=null,reconcilingRoutineKey:c=null,resettingRoutineKey:d=null,onRunNow:m,onToggleEnabled:h,onReconcile:p,onReset:f}){const g=new Map(s.map(y=>[y.id,y])),v=new Map(n.map(y=>[y.id,{name:y.name,color:y.color}]));return e.length===0?(0,t.jsx)("div",{className:"rounded-lg border border-border px-3 py-8 text-center text-sm text-muted-foreground",children:i}):(0,t.jsx)("div",{className:"rounded-lg border border-border",children:e.map(y=>{const w=IKt(y),S=y.href??(y.routineId?`/routines/${y.routineId}`:"/routines"),j=y.missingRefs??[],N=!!(y.routineId&&y.resourceKey&&j.length===0),_=y.managedByPluginDisplayName??a,R=!!(p||f);return(0,t.jsxs)("div",{className:"last:[&_a]:border-b-0",children:[(0,t.jsx)(bNe,{routine:w,projectById:v,agentById:g,runningRoutineId:o,statusMutationRoutineId:l,href:S,configureLabel:"Configure",managedByLabel:_?`Managed by ${_}`:null,runNowButton:!0,hideArchiveAction:!0,disableRunNow:!N,disableToggle:!N,secondaryDetails:(0,t.jsxs)("span",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[y.resourceKey?(0,t.jsx)("span",{children:y.resourceKey}):null,y.cronExpression?(0,t.jsxs)("span",{children:["Schedule ",y.cronExpression]}):null]}),onRunNow:r(()=>m?.(y),"onRunNow"),onToggleEnabled:r(()=>h?.(y,w.status==="active"),"onToggleEnabled")}),R?(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 border-b border-border px-3 pb-3 text-xs text-muted-foreground last:border-b-0",onClick:r(C=>{C.preventDefault(),C.stopPropagation()},"onClick"),children:[(0,t.jsx)("span",{children:j.length?`Missing ${j.map(C=>`${C.resourceKind}:${C.resourceKey}`).join(", ")}`:"Routine defaults can be repaired."}),(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[p?(0,t.jsx)(F,{size:"sm",variant:"ghost",disabled:c===y.key,onClick:r(()=>p(y),"onClick"),children:c===y.key?"Reconciling...":"Reconcile"}):null,f?(0,t.jsx)(F,{size:"sm",variant:"ghost",disabled:d===y.key,onClick:r(()=>f(y),"onClick"),children:d===y.key?"Resetting...":"Reset"}):null]})]}):null]},y.key)})})}r(AKt,"ManagedRoutinesList");function xle(e){return new Set(e??[])}r(xle,"toPathSet");function RKt({expandedPaths:e,checkedPaths:s,selectedFile:n=null,showCheckboxes:a=!1,onToggleDir:i,onSelectFile:o,...l}){return(0,u.createElement)(t_,{...l,selectedFile:n,expandedDirs:xle(e),checkedFiles:s?xle(s):void 0,showCheckboxes:a,onToggleDir:i??(()=>{}),onSelectFile:o??(()=>{})})}r(RKt,"PluginSdkFileTree");function TKt(e){const[s,n]=(0,u.useState)(null);return(0,u.useEffect)(()=>{let a=!1;return jc(()=>import("./MarkdownEditor-DfrwLv1M.js").then(i=>i.n).then(i=>{a||n(()=>i.MarkdownEditor)}),__vite__mapDeps([36,5,7,9,14,10,15,37,29,27,38])),()=>{a=!0}},[]),s?(0,u.createElement)(s,e):(0,u.createElement)("textarea",{className:e.className,value:e.value,placeholder:e.placeholder,readOnly:e.readOnly,onBlur:e.onBlur,onChange:r(a=>e.onChange(a.currentTarget.value),"onChange")})}r(TKt,"PluginSdkMarkdownEditor");function EKt(e){return Object.fromEntries(Object.entries(e).filter(([,s])=>s!=null&&s!==""&&s!==!1))}r(EKt,"compactIssueFilters");function PKt({companyId:e,projectId:s=null,filters:n,viewStateKey:a="paperclip:plugin-issues-view",initialSearch:i,createIssueLabel:o,searchWithinLoadedIssues:l=!0}){const c=Wt(),d=(0,u.useMemo)(()=>EKt({...n??{},projectId:n?.projectId??s??void 0}),[n,s]),m=d.originKindPrefix??null,h=d.projectId??s??null,p=(0,u.useMemo)(()=>["plugins","sdk-ui","issues-list",e??"__no-company__",d],[e,d]),{data:f}=Z({queryKey:P.agents.list(e??"__no-company__"),queryFn:r(()=>Vt.list(e),"queryFn"),enabled:!!e}),{data:g}=Z({queryKey:P.projects.list(e??"__no-company__",{includeArchived:!0}),queryFn:r(()=>ma.list(e,{includeArchived:!0}),"queryFn"),enabled:!!e}),v=P.liveRuns(e??"__no-company__"),y=mo({companyId:e,resourceKey:"live-runs",queryKey:v,enabled:!!e,refetchInterval:!1,leaderOnly:!0}),{data:w,dataUpdatedAt:S}=Z({queryKey:v,queryFn:r(()=>sa.liveRunsForCompany(e),"queryFn"),enabled:y.enabled,refetchInterval:y.refetchInterval});ho(y,w,S);const{data:j,isLoading:N,error:_}=Z({queryKey:p,queryFn:r(()=>Rt.list(e,d),"queryFn"),enabled:!!e}),R=(0,u.useMemo)(()=>Tx(w,j),[j,w]),C=Ne({mutationFn:r(({id:A,data:T})=>Rt.update(A,T),"mutationFn"),onSuccess:r(()=>{e&&(c.invalidateQueries({queryKey:["plugins","sdk-ui","issues-list",e]}),c.invalidateQueries({queryKey:P.issues.list(e)}),h&&(c.invalidateQueries({queryKey:P.issues.listByProject(e,h)}),m&&c.invalidateQueries({queryKey:P.issues.listPluginOperationsByProject(e,h,m)})))},"onSuccess")});return e?(0,u.createElement)(yx,{issues:j??[],isLoading:N,error:_,agents:f,projects:g,liveIssueIds:R,projectId:h??void 0,viewStateKey:a,initialSearch:i,createIssueLabel:o,searchWithinLoadedIssues:l,onUpdateIssue:r((A,T)=>C.mutate({id:A,data:T}),"onUpdateIssue")}):(0,u.createElement)("div",{className:"text-sm text-muted-foreground"},"Select an organization to view tasks.")}r(PKt,"PluginSdkIssuesList");function MKt({companyId:e,value:s,onChange:n,placeholder:a="Responsible",noneLabel:i="No responsible",searchPlaceholder:o="Search responsible...",emptyMessage:l="No responsible found.",includeUsers:c=!0,includeTerminatedAgents:d=!1,className:m,onConfirm:h}){const p=iU(),f=e??p.companyId??null,{data:g}=Z({queryKey:P.auth.session,queryFn:r(()=>qa.getSession(),"queryFn"),enabled:c}),v=g?.user?.id??g?.session?.userId??null,{data:y}=Z({queryKey:P.agents.list(f??"__no-company__"),queryFn:r(()=>Vt.list(f),"queryFn"),enabled:!!f}),{data:w}=Z({queryKey:P.access.companyUserDirectory(f??"__no-company__"),queryFn:r(()=>hr.listUserDirectory(f),"queryFn"),enabled:!!f&&c}),S=(0,u.useMemo)(()=>VAe(),[]),j=(0,u.useMemo)(()=>S.map(A=>A.startsWith("agent:")?A.slice(6):null).filter(A=>!!A),[S]),N=(0,u.useMemo)(()=>Wg((y??[]).filter(A=>d||A.status!=="terminated"),j),[y,d,j]),_=(0,u.useMemo)(()=>[...c?Ice(v):[],...c?tN(w?.users,{excludeUserIds:[v]}):[],...N.map(A=>({id:Mm({assigneeAgentId:A.id}),label:A.name,searchText:`${A.name} ${A.role} ${A.title??""}`}))],[w?.users,v,c,N]),R=Oc(s),C=R.assigneeAgentId?N.find(A=>A.id===R.assigneeAgentId):null;return(0,u.createElement)(nc,{value:s,options:_,recentOptionIds:S,placeholder:a,noneLabel:i,searchPlaceholder:o,emptyMessage:l,className:m,onConfirm:h,onChange:r(A=>{const T=Oc(A);T.assigneeAgentId&&o1(T.assigneeAgentId),T.assigneeUserId&&lce(T.assigneeUserId),n(A,T)},"onChange"),renderTriggerValue:r(A=>A?C?(0,u.createElement)(a5,null,(0,u.createElement)(hw,{icon:C.icon,className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,u.createElement)("span",{className:"truncate"},A.label)):(0,u.createElement)("span",{className:"truncate"},A.label):(0,u.createElement)("span",{className:"text-muted-foreground"},a),"renderTriggerValue"),renderOption:r(A=>{if(!A.id)return(0,u.createElement)("span",{className:"truncate"},A.label);const T=Oc(A.id),I=T.assigneeAgentId?N.find($=>$.id===T.assigneeAgentId):null;return(0,u.createElement)(a5,null,I?(0,u.createElement)(hw,{icon:I.icon,className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):(0,u.createElement)(yc,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,u.createElement)("span",{className:"truncate"},A.label))},"renderOption")})}r(MKt,"PluginSdkAssigneePicker");function DKt({companyId:e,value:s,onChange:n,placeholder:a="Project",noneLabel:i="No project",searchPlaceholder:o="Search projects...",emptyMessage:l="No projects found.",includeArchived:c=!1,className:d,onConfirm:m}){const h=iU(),p=e??h.companyId??null,{data:f}=Z({queryKey:P.auth.session,queryFn:r(()=>qa.getSession(),"queryFn")}),g=f?.user?.id??f?.session?.userId??null,{data:v}=Z({queryKey:P.projects.list(p??"__no-company__",{includeArchived:c}),queryFn:r(()=>ma.list(p,{includeArchived:c}),"queryFn"),enabled:!!p}),y=(0,u.useMemo)(()=>(v??[]).filter(_=>c||!_.archivedAt),[c,v]),{orderedProjects:w}=Ev({projects:y,companyId:p,userId:g}),S=(0,u.useMemo)(()=>Jw(),[]),j=(0,u.useMemo)(()=>w.map(_=>({id:_.id,label:_.name,searchText:_.description??""})),[w]),N=w.find(_=>_.id===s)??null;return(0,u.createElement)(nc,{value:s,options:j,recentOptionIds:S,placeholder:a,noneLabel:i,searchPlaceholder:o,emptyMessage:l,className:d,onConfirm:m,onChange:r(_=>{_&&Qw(_),n(_)},"onChange"),renderTriggerValue:r(_=>!_||!N?(0,u.createElement)("span",{className:"text-muted-foreground"},a):(0,u.createElement)(a5,null,(0,u.createElement)("span",{className:"h-3.5 w-3.5 shrink-0 rounded-sm",style:{backgroundColor:N.color??"#6366f1"}}),(0,u.createElement)("span",{className:"truncate"},_.label)),"renderTriggerValue"),renderOption:r(_=>{if(!_.id)return(0,u.createElement)("span",{className:"truncate"},_.label);const R=w.find(C=>C.id===_.id);return(0,u.createElement)(a5,null,(0,u.createElement)("span",{className:"h-3.5 w-3.5 shrink-0 rounded-sm",style:{backgroundColor:R?.color??"#6366f1"}}),(0,u.createElement)("span",{className:"truncate"},_.label))},"renderOption")})}r(DKt,"PluginSdkProjectPicker");function a5({children:e}){return(0,u.createElement)("span",{className:"contents"},e)}r(a5,"FragmentSafe");function LKt({label:e,status:s}){const n={ok:"border-emerald-300 bg-emerald-50 text-emerald-700",warning:"border-amber-300 bg-amber-50 text-amber-800",error:"border-red-300 bg-red-50 text-red-700",info:"border-slate-300 bg-slate-50 text-slate-700",pending:"border-slate-300 bg-slate-50 text-slate-600"}[s];return(0,u.createElement)("span",{className:`inline-flex w-fit items-center rounded-full border px-2 py-0.5 text-xs font-medium ${n}`},e)}r(LKt,"PluginSdkStatusBadge");function $Kt({columns:e,rows:s,loading:n,emptyMessage:a="No rows."}){if(n)return(0,u.createElement)("div",{className:"text-sm text-muted-foreground"},"Loading...");if(!s.length)return(0,u.createElement)("div",{className:"text-sm text-muted-foreground"},a);const i=e.map(o=>o.width??"minmax(0, 1fr)").join(" ");return(0,u.createElement)("div",{className:"overflow-hidden rounded-md border"},(0,u.createElement)("div",{className:"hidden border-b bg-muted/35 px-3 py-2 text-xs font-medium uppercase tracking-wide text-muted-foreground md:grid md:[grid-template-columns:var(--plugin-grid-cols)]",style:{"--plugin-grid-cols":i}},e.map(o=>(0,u.createElement)("div",{key:o.key},o.header))),(0,u.createElement)("div",{className:"divide-y"},s.map((o,l)=>(0,u.createElement)("div",{key:String(o.id??l),className:"grid gap-2 px-3 py-3 md:items-center md:[grid-template-columns:var(--plugin-grid-cols)]",style:{"--plugin-grid-cols":i}},e.map(c=>(0,u.createElement)("div",{key:c.key,className:"min-w-0 text-sm"},(0,u.createElement)("div",{className:"mb-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground md:hidden"},c.header),c.render?c.render(o[c.key],o):String(o[c.key]??"")))))))}r($Kt,"PluginSdkDataTable");function OKt({pairs:e}){return(0,u.createElement)("dl",{className:"grid gap-x-4 gap-y-1 text-sm sm:grid-cols-[max-content_minmax(0,1fr)]"},e.flatMap(s=>[(0,u.createElement)("dt",{key:`${s.label}:label`,className:"text-muted-foreground"},s.label),(0,u.createElement)("dd",{key:`${s.label}:value`,className:"min-w-0"},s.value)]))}r(OKt,"PluginSdkKeyValueList");function FKt({label:e,value:s,unit:n}){return(0,u.createElement)("div",{className:"rounded-md border bg-card p-3"},(0,u.createElement)("div",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground"},e),(0,u.createElement)("div",{className:"mt-1 text-lg font-semibold"},`${s}${n??""}`))}r(FKt,"PluginSdkMetricCard");function BKt({data:e}){return(0,u.createElement)("pre",{className:"max-h-80 overflow-auto rounded-md border bg-muted/30 p-2 text-xs"},JSON.stringify(e,null,2))}r(BKt,"PluginSdkJsonTree");function qKt({label:e="Loading"}){return(0,u.createElement)("span",{className:"inline-block h-3.5 w-3.5 animate-spin rounded-full border-2 border-muted-foreground/30 border-t-foreground align-middle",role:"status","aria-label":e})}r(qKt,"PluginSdkSpinner");var zKt=class extends u.Component{static{r(this,"PluginSdkErrorBoundary")}state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback??(0,u.createElement)("div",{className:"rounded-md border border-destructive/30 p-3 text-sm text-destructive"},"Plugin UI failed to render."):this.props.children}};function UKt(e,s){globalThis.__paperclipPluginBridge__={react:e,reactJsxRuntime:t,reactDom:s,sdkUi:{usePluginData:TLe,usePluginAction:ELe,useHostContext:iU,useHostLocation:MLe,useHostNavigation:PLe,usePluginStream:LLe,usePluginToast:DLe,copyTextToClipboard:Yr,MarkdownBlock:r(({content:n,className:a,enableWikiLinks:i,wikiLinkRoot:o,resolveWikiLinkHref:l})=>(0,u.createElement)($n,{className:a,softBreaks:!1,enableWikiLinks:i,wikiLinkRoot:o,resolveWikiLinkHref:l,children:n}),"MarkdownBlock"),MetricCard:FKt,StatusBadge:LKt,DataTable:$Kt,KeyValueList:OKt,JsonTree:BKt,Spinner:qKt,ErrorBoundary:zKt,MarkdownEditor:TKt,FileTree:RKt,IssuesList:PKt,AssigneePicker:MKt,ProjectPicker:DKt,ManagedRoutinesList:AKt}}}r(UKt,"initPluginBridge");var KKt=1e4;function VKt(e=KKt){if(typeof performance>"u"||typeof performance.clearMeasures!="function")return()=>{};const n=setInterval(r(()=>{globalThis.__paperclipKeepPerfMeasures||performance.clearMeasures()},"reap"),e);return()=>clearInterval(n)}r(VKt,"startPerfMeasureReaper");var WKt=wv((e=>{function s(K,z){var D=K.length;K.push(z);e:for(;0<D;){var V=D-1>>>1,H=K[V];if(0<i(H,z))K[V]=z,K[D]=H,D=V;else break e}}r(s,"push");function n(K){return K.length===0?null:K[0]}r(n,"peek");function a(K){if(K.length===0)return null;var z=K[0],D=K.pop();if(D!==z){K[0]=D;e:for(var V=0,H=K.length,ee=H>>>1;V<ee;){var X=2*(V+1)-1,le=K[X],ce=X+1,te=K[ce];if(0>i(le,D))ce<H&&0>i(te,le)?(K[V]=te,K[ce]=D,V=ce):(K[V]=le,K[X]=D,V=X);else if(ce<H&&0>i(te,D))K[V]=te,K[ce]=D,V=ce;else break e}}return z}r(a,"pop");function i(K,z){var D=K.sortIndex-z.sortIndex;return D!==0?D:K.id-z.id}if(r(i,"compare"),e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var l=Date,c=l.now();e.unstable_now=function(){return l.now()-c}}var d=[],m=[],h=1,p=null,f=3,g=!1,v=!1,y=!1,w=!1,S=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate<"u"?setImmediate:null;function _(K){for(var z=n(m);z!==null;){if(z.callback===null)a(m);else if(z.startTime<=K)a(m),z.sortIndex=z.expirationTime,s(d,z);else break;z=n(m)}}r(_,"advanceTimers");function R(K){if(y=!1,_(K),!v)if(n(d)!==null)v=!0,C||(C=!0,L());else{var z=n(m);z!==null&&B(R,z.startTime-K)}}r(R,"handleTimeout");var C=!1,A=-1,T=5,I=-1;function $(){return w?!0:!(e.unstable_now()-I<T)}r($,"shouldYieldToHost");function O(){if(w=!1,C){var K=e.unstable_now();I=K;var z=!0;try{e:{v=!1,y&&(y=!1,j(A),A=-1),g=!0;var D=f;try{t:{for(_(K),p=n(d);p!==null&&!(p.expirationTime>K&&$());){var V=p.callback;if(typeof V=="function"){p.callback=null,f=p.priorityLevel;var H=V(p.expirationTime<=K);if(K=e.unstable_now(),typeof H=="function"){p.callback=H,_(K),z=!0;break t}p===n(d)&&a(d),_(K)}else a(d);p=n(d)}if(p!==null)z=!0;else{var ee=n(m);ee!==null&&B(R,ee.startTime-K),z=!1}}break e}finally{p=null,f=D,g=!1}z=void 0}}finally{z?L():C=!1}}}r(O,"performWorkUntilDeadline");var L;if(typeof N=="function")L=r(function(){N(O)},"schedulePerformWorkUntilDeadline");else if(typeof MessageChannel<"u"){var E=new MessageChannel,q=E.port2;E.port1.onmessage=O,L=r(function(){q.postMessage(null)},"schedulePerformWorkUntilDeadline")}else L=r(function(){S(O,0)},"schedulePerformWorkUntilDeadline");function B(K,z){A=S(function(){K(e.unstable_now())},z)}r(B,"requestHostTimeout"),e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(K){K.callback=null},e.unstable_forceFrameRate=function(K){0>K||125<K||(T=0<K?Math.floor(1e3/K):5)},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(K){switch(f){case 1:case 2:case 3:var z=3;break;default:z=f}var D=f;f=z;try{return K()}finally{f=D}},e.unstable_requestPaint=function(){w=!0},e.unstable_runWithPriority=function(K,z){switch(K){case 1:case 2:case 3:case 4:case 5:break;default:K=3}var D=f;f=K;try{return z()}finally{f=D}},e.unstable_scheduleCallback=function(K,z,D){var V=e.unstable_now();switch(typeof D=="object"&&D!==null?(D=D.delay,D=typeof D=="number"&&0<D?V+D:V):D=V,K){case 1:var H=-1;break;case 2:H=250;break;case 5:H=1073741823;break;case 4:H=1e4;break;default:H=5e3}return H=D+H,K={id:h++,callback:z,priorityLevel:K,startTime:D,expirationTime:H,sortIndex:-1},D>V?(K.sortIndex=D,s(m,K),n(d)===null&&K===n(m)&&(y?(j(A),A=-1):y=!0,B(R,D-V))):(K.sortIndex=H,s(d,K),v||g||(v=!0,C||(C=!0,L()))),K},e.unstable_shouldYield=$,e.unstable_wrapCallback=function(K){var z=f;return function(){var D=f;f=z;try{return K.apply(this,arguments)}finally{f=D}}}})),HKt=wv(((e,s)=>{s.exports=WKt()})),QKt=wv((e=>{var s=HKt(),n=cz(),a=Cle();function i(x){var b="https://react.dev/errors/"+x;if(1<arguments.length){b+="?args[]="+encodeURIComponent(arguments[1]);for(var k=2;k<arguments.length;k++)b+="&args[]="+encodeURIComponent(arguments[k])}return"Minified React error #"+x+"; visit "+b+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}r(i,"formatProdErrorMessage");function o(x){return!(!x||x.nodeType!==1&&x.nodeType!==9&&x.nodeType!==11)}r(o,"isValidContainer");function l(x){var b=x,k=x;if(x.alternate)for(;b.return;)b=b.return;else{x=b;do b=x,(b.flags&4098)!==0&&(k=b.return),x=b.return;while(x)}return b.tag===3?k:null}r(l,"getNearestMountedFiber");function c(x){if(x.tag===13){var b=x.memoizedState;if(b===null&&(x=x.alternate,x!==null&&(b=x.memoizedState)),b!==null)return b.dehydrated}return null}r(c,"getSuspenseInstanceFromFiber");function d(x){if(x.tag===31){var b=x.memoizedState;if(b===null&&(x=x.alternate,x!==null&&(b=x.memoizedState)),b!==null)return b.dehydrated}return null}r(d,"getActivityInstanceFromFiber");function m(x){if(l(x)!==x)throw Error(i(188))}r(m,"assertIsMounted");function h(x){var b=x.alternate;if(!b){if(b=l(x),b===null)throw Error(i(188));return b!==x?null:x}for(var k=x,M=b;;){var W=k.return;if(W===null)break;var Q=W.alternate;if(Q===null){if(M=W.return,M!==null){k=M;continue}break}if(W.child===Q.child){for(Q=W.child;Q;){if(Q===k)return m(W),x;if(Q===M)return m(W),b;Q=Q.sibling}throw Error(i(188))}if(k.return!==M.return)k=W,M=Q;else{for(var ge=!1,Me=W.child;Me;){if(Me===k){ge=!0,k=W,M=Q;break}if(Me===M){ge=!0,M=W,k=Q;break}Me=Me.sibling}if(!ge){for(Me=Q.child;Me;){if(Me===k){ge=!0,k=Q,M=W;break}if(Me===M){ge=!0,M=Q,k=W;break}Me=Me.sibling}if(!ge)throw Error(i(189))}}if(k.alternate!==M)throw Error(i(190))}if(k.tag!==3)throw Error(i(188));return k.stateNode.current===k?x:b}r(h,"findCurrentFiberUsingSlowPath");function p(x){var b=x.tag;if(b===5||b===26||b===27||b===6)return x;for(x=x.child;x!==null;){if(b=p(x),b!==null)return b;x=x.sibling}return null}r(p,"findCurrentHostFiberImpl");var f=Object.assign,g=Symbol.for("react.element"),v=Symbol.for("react.transitional.element"),y=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),S=Symbol.for("react.strict_mode"),j=Symbol.for("react.profiler"),N=Symbol.for("react.consumer"),_=Symbol.for("react.context"),R=Symbol.for("react.forward_ref"),C=Symbol.for("react.suspense"),A=Symbol.for("react.suspense_list"),T=Symbol.for("react.memo"),I=Symbol.for("react.lazy"),$=Symbol.for("react.activity"),O=Symbol.for("react.memo_cache_sentinel"),L=Symbol.iterator;function E(x){return x===null||typeof x!="object"?null:(x=L&&x[L]||x["@@iterator"],typeof x=="function"?x:null)}r(E,"getIteratorFn");var q=Symbol.for("react.client.reference");function B(x){if(x==null)return null;if(typeof x=="function")return x.$$typeof===q?null:x.displayName||x.name||null;if(typeof x=="string")return x;switch(x){case w:return"Fragment";case j:return"Profiler";case S:return"StrictMode";case C:return"Suspense";case A:return"SuspenseList";case $:return"Activity"}if(typeof x=="object")switch(x.$$typeof){case y:return"Portal";case _:return x.displayName||"Context";case N:return(x._context.displayName||"Context")+".Consumer";case R:var b=x.render;return x=x.displayName,x||(x=b.displayName||b.name||"",x=x!==""?"ForwardRef("+x+")":"ForwardRef"),x;case T:return b=x.displayName||null,b!==null?b:B(x.type)||"Memo";case I:b=x._payload,x=x._init;try{return B(x(b))}catch{}}return null}r(B,"getComponentNameFromType");var K=Array.isArray,z=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D=a.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,V={pending:!1,data:null,method:null,action:null},H=[],ee=-1;function X(x){return{current:x}}r(X,"createCursor");function le(x){0>ee||(x.current=H[ee],H[ee]=null,ee--)}r(le,"pop");function ce(x,b){ee++,H[ee]=x.current,x.current=b}r(ce,"push");var te=X(null),ae=X(null),de=X(null),J=X(null);function Y(x,b){switch(ce(de,b),ce(ae,x),ce(te,null),b.nodeType){case 9:case 11:x=(x=b.documentElement)&&(x=x.namespaceURI)?NW(x):0;break;default:if(x=b.tagName,b=b.namespaceURI)b=NW(b),x=kW(b,x);else switch(x){case"svg":x=1;break;case"math":x=2;break;default:x=0}}le(te),ce(te,x)}r(Y,"pushHostContainer");function G(){le(te),le(ae),le(de)}r(G,"popHostContainer");function fe(x){x.memoizedState!==null&&ce(J,x);var b=te.current,k=kW(b,x.type);b!==k&&(ce(ae,x),ce(te,k))}r(fe,"pushHostContext");function se(x){ae.current===x&&(le(te),le(ae)),J.current===x&&(le(J),WN._currentValue=V)}r(se,"popHostContext");var re,ie;function me(x){if(re===void 0)try{throw Error()}catch(k){var b=k.stack.trim().match(/\n( *(at )?)/);re=b&&b[1]||"",ie=-1<k.stack.indexOf(`
|
|
729
729
|
at`)?" (<anonymous>)":-1<k.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
730
730
|
`+re+x+ie}r(me,"describeBuiltInComponentFrame");var pe=!1;function be(x,b){if(!x||pe)return"";pe=!0;var k=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var M={DetermineComponentFrameRoot:r(function(){try{if(b){var Rs=r(function(){throw Error()},"Fake");if(Object.defineProperty(Rs.prototype,"props",{set:r(function(){throw Error()},"set")}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Rs,[])}catch(os){var ss=os}Reflect.construct(x,[],Rs)}else{try{Rs.call()}catch(os){ss=os}x.call(Rs.prototype)}}else{try{throw Error()}catch(os){ss=os}(Rs=x())&&typeof Rs.catch=="function"&&Rs.catch(function(){})}}catch(os){if(os&&ss&&typeof os.stack=="string")return[os.stack,ss.stack]}return[null,null]},"DetermineComponentFrameRoot")};M.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var W=Object.getOwnPropertyDescriptor(M.DetermineComponentFrameRoot,"name");W&&W.configurable&&Object.defineProperty(M.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var Q=M.DetermineComponentFrameRoot(),ge=Q[0],Me=Q[1];if(ge&&Me){var yt=ge.split(`
|
|
731
731
|
`),ts=Me.split(`
|