cogpit 2.7.4 → 3.0.1
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/cli.js +5657 -3925
- package/dist/web/assets/CommandPaletteHost-B-n0sXM6.js +1 -0
- package/dist/web/assets/ConfigBrowser-DOdqaQra.js +1 -0
- package/dist/web/assets/HighlightedEditor-D75svkum.js +2 -0
- package/dist/web/assets/{KeyboardShortcutsDialog-DQuepxQo.js → KeyboardShortcutsDialog-DeIXxXmj.js} +1 -1
- package/dist/web/assets/{MobileFileChanges-B6rggNR6.js → MobileFileChanges-Dze0jsvc.js} +1 -1
- package/dist/web/assets/PluginsDialog-qcJTbfeg.js +1 -0
- package/dist/web/assets/PreviewPanel-DChL85Uq.js +1 -0
- package/dist/web/assets/ProjectFilesPanel-DJ-_Lb_R.js +4 -0
- package/dist/web/assets/ProjectSwitcherModal-BUV_fZ5V.js +1 -0
- package/dist/web/assets/{TerminalOutput-CUmbXM9h.js → TerminalOutput-BCG6Ppu3.js} +13 -13
- package/dist/web/assets/ThemeSelectorModal-t2P0tZVJ.js +1 -0
- package/dist/web/assets/WorkflowsPanel-Bv2RwtYI.js +1 -0
- package/dist/web/assets/WorktreePanel-F9QlbnAH.js +1 -0
- package/dist/web/assets/edition-ui-C0x29noh.js +2 -0
- package/dist/web/assets/index-BO-Nd-ib.css +1 -0
- package/dist/web/assets/{index-BA1eUNuR.js → index-BtmLHL6v.js} +4 -4
- package/dist/web/assets/index-C4W7tiDS.js +1 -0
- package/dist/web/assets/index-CRUYvx2l.js +1 -0
- package/dist/web/assets/index-CW9tjG1S.js +472 -0
- package/dist/web/assets/index-bXbR7jwp.js +1 -0
- package/dist/web/assets/password-BV9mqUzz.js +1 -0
- package/dist/web/assets/{session-parser.worker-CnA52U1J.js → session-parser.worker-CkTPpg3t.js} +24 -24
- package/dist/web/assets/{vendor-ui-ZKZkD5k3.js → vendor-ui-Br3ZTAXZ.js} +237 -167
- package/dist/web/index.html +6 -6
- package/dist/web/theme-bootstrap.js +1 -25
- package/package.json +1 -1
- package/dist/web/assets/CommandPaletteHost-ByD_7YRK.js +0 -1
- package/dist/web/assets/ConfigBrowser-vXK8JNMg.js +0 -1
- package/dist/web/assets/HighlightedEditor-BwET41dr.js +0 -2
- package/dist/web/assets/PluginsDialog-DTF9NnK7.js +0 -1
- package/dist/web/assets/PreviewPanel-BaXxki5D.js +0 -1
- package/dist/web/assets/ProjectFilesPanel-CO6Znhgi.js +0 -4
- package/dist/web/assets/ProjectSwitcherModal-Chi-U3vv.js +0 -1
- package/dist/web/assets/TerminalOutput-6GBZ9nXN.css +0 -32
- package/dist/web/assets/ThemeSelectorModal-B2m42_1f.js +0 -1
- package/dist/web/assets/WorkflowsPanel-CiYzHaQg.js +0 -1
- package/dist/web/assets/WorktreePanel-CldMZY3n.js +0 -1
- package/dist/web/assets/index-C-0I_ZqI.js +0 -1
- package/dist/web/assets/index-C6wvrmo0.js +0 -221
- package/dist/web/assets/index-CYN2JttE.js +0 -1
- package/dist/web/assets/index-DYWsIgvZ.css +0 -1
- package/dist/web/assets/index-QH_v3Ygj.js +0 -1
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalOutput-BCG6Ppu3.js","assets/vendor-react-gGw_S5I_.js","assets/vendor-ui-Br3ZTAXZ.js","assets/vendor-shiki-DOn6sF-i.js","assets/vendor-markdown-BE1gYnO9.js","assets/html-GMplVEZG.js","assets/javascript-wDzz0qaB.js","assets/css-DPfMkruS.js","assets/cpp-BRuaLJcg.js","assets/c-BIGW1oBm.js","assets/sql-BLtJtn59.js","assets/ruby-B0Tyh1qT.js","assets/xml-D2mA2LmW.js","assets/java-CylS5w8V.js","assets/typescript-BPQ3VLAy.js","assets/jsx-g9-lgVsj.js","assets/tsx-COt5Ahok.js","assets/bash-Yzrsuije.js","assets/yaml-Buea-lGh.js","assets/php-aq0itWAE.js","assets/json-Cp-IABpG.js","assets/vue-DVfSmUF7.js","assets/svelte-DZMnMd3x.js","assets/scss-OYdSNvt2.js","assets/ProjectSwitcherModal-BUV_fZ5V.js","assets/CommandPaletteHost-B-n0sXM6.js","assets/index-bXbR7jwp.js","assets/password-BV9mqUzz.js","assets/KeyboardShortcutsDialog-DeIXxXmj.js","assets/ThemeSelectorModal-t2P0tZVJ.js","assets/ProjectFilesPanel-DJ-_Lb_R.js","assets/HighlightedEditor-D75svkum.js","assets/WorktreePanel-F9QlbnAH.js","assets/index-CRUYvx2l.js","assets/index-C4W7tiDS.js","assets/ConfigBrowser-DOdqaQra.js","assets/PreviewPanel-DChL85Uq.js","assets/PluginsDialog-qcJTbfeg.js","assets/MobileFileChanges-Dze0jsvc.js","assets/edition-ui-C0x29noh.js","assets/index-BtmLHL6v.js","assets/WorkflowsPanel-Bv2RwtYI.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var wA=Object.defineProperty;var SA=(n,e,t)=>e in n?wA(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Wt=(n,e,t)=>SA(n,typeof e!="symbol"?e+"":e,t);import{j as a,d as Te,e as kA,c as q,r as w,a as jA,f as NA}from"./vendor-react-gGw_S5I_.js";import{aT as CA,aU as _A,aV as EA,aW as Lr,ae as vt,aX as TA,J as lr,aY as Pd,au as Mr,aZ as AA,a_ as PA,a$ as IA,b0 as $A,b1 as RA,b2 as OA,a2 as Ot,b3 as LA,I as Ft,b4 as MA,am as i3,a as On,b5 as zA,b6 as a3,b7 as DA,b8 as FA,b9 as UA,ba as BA,bb as WA,bc as l3,bd as Bu,g as ll,be as c3,G as _r,bf as Kg,bg as qA,bh as VA,bi as HA,bj as KA,bk as GA,bl as ZA,bm as YA,bn as XA,bo as JA,bp as QA,bq as e7,br as t7,bs as n7,bt as s7,bu as Id,bv as Gg,bw as Zg,bx as Yg,by as u3,bz as Xg,bA as Ol,X as Ut,bB as Jg,bC as r7,D as Qg,af as Bs,bD as o7,bE as d3,bF as f3,bG as ki,bH as bo,bI as i7,bJ as a7,bK as l7,bL as c7,bM as cl,S as Yn,y as Ai,bN as Er,bO as m3,bP as u7,bQ as d7,bR as p3,bS as h3,bT as g3,bU as x3,bV as b3,bW as v3,bX as f7,bY as m7,bZ as p7,ah as $d,b_ as h7,$ as Rd,n as Pi,aa as Zi,b$ as yh,c0 as g7,c1 as x7,c2 as b7,c3 as v7,c4 as y7,c5 as w7,c6 as S7,c7 as e1,c8 as k7,aF as Ds,z as ys,c9 as j7,ca as N7,cb as C7,cc as _7,cd as E7,ce as T7,cf as ul,cg as Yi,ch as A7,i as Od,ci as P7,cj as I7,ck as $7,cl as R7,cm as O7,cn as L7,co as M7,cp as z7,cq as D7,cr as F7,C as ot,P as tr,x as Xi,c as y3,cs as U7,ct as B7,cu as W7,cv as q7,l as Tr,ai as vo,cw as V7,cx as w3,W as t1,e as Ld,cy as wh,a9 as n1,cz as H7,cA as s1,cB as Sh,cC as K7,R as r1,cD as G7,cE as Z7,a0 as oo,b as S3,cF as Y7,s as Ji,cG as X7,a1 as Va,cH as J7,cI as Wu,cJ as o1,k as io,cK as Q7,cL as eP,cM as tP,cN as k3,cO as nP,cP as Ac,cQ as _o,ak as Bb,F as Ll,B as i1,cR as sP,a5 as qu,cS as rP,av as oP,t as Md,N as Ii,V as a1,cT as iP,cU as aP,a4 as $i,cV as lP,cW as cP,cX as uP,cY as dP,cZ as fP,c_ as j3,c$ as mP,aG as pP,as as N3,m as kh,d0 as hP,aO as gP,d1 as xP,d2 as C3,h as _3,A as Ml,d3 as bP,aB as zd,aA as gs,a6 as E3,r as vP,d4 as yP,aK as T3,p as wP,aw as jh,v as SP,d5 as kP,d6 as jP,d7 as NP,d8 as CP,d9 as _P,o as EP,da as TP,db as AP,dc as PP,dd as IP,aj as l1,O as A3,H as $P,de as P3,df as RP,dg as Wb,ad as OP,L as I3,w as $3,ag as LP,aq as MP,aN as zP,dh as DP,di as FP,dj as UP,ac as BP,dk as WP}from"./vendor-ui-Br3ZTAXZ.js";import{c as qP,a as VP}from"./vendor-shiki-DOn6sF-i.js";import{r as HP,M as cr}from"./vendor-markdown-BE1gYnO9.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const o of r)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&s(i)}).observe(document,{childList:!0,subtree:!0});function t(r){const o={};return r.integrity&&(o.integrity=r.integrity),r.referrerPolicy&&(o.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?o.credentials="include":r.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function s(r){if(r.ep)return;r.ep=!0;const o=t(r);fetch(r.href,o)}})();const KP="modulepreload",GP=function(n){return"/"+n},qb={},et=function(e,t,s){let r=Promise.resolve();if(t&&t.length>0){let i=function(u){return Promise.all(u.map(d=>Promise.resolve(d).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),c=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));r=i(t.map(u=>{if(u=GP(u),u in qb)return;qb[u]=!0;const d=u.endsWith(".css"),f=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${f}`))return;const m=document.createElement("link");if(m.rel=d?"stylesheet":KP,d||(m.as="script"),m.crossOrigin="",m.href=u,c&&m.setAttribute("nonce",c),document.head.appendChild(m),d)return new Promise((p,h)=>{m.addEventListener("load",p),m.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${u}`)))})}))}function o(i){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=i,window.dispatchEvent(l),!l.defaultPrevented)throw i}return r.then(i=>{for(const l of i||[])l.status==="rejected"&&o(l.reason);return e().catch(o)})};function G(...n){return CA(_A(n))}const ZP=Lr("inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium outline-none transition-[color,background-color,border-color,box-shadow,transform,scale] duration-100 ease-out active:scale-[0.98] disabled:pointer-events-none disabled:opacity-50 motion-reduce:transition-none motion-reduce:active:scale-100 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/20 aria-invalid:border-destructive aria-invalid:ring-[3px] aria-invalid:ring-destructive/20",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20",outline:"border border-input bg-background shadow-xs hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",xs:"h-7 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-xs":"size-7 rounded-md [&_svg:not([class*='size-'])]:size-3.5","icon-sm":"size-7","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function ee({className:n,variant:e,size:t,...s}){return a.jsx(EA,{"data-slot":"button",className:G(ZP({variant:e,size:t,className:n})),...s})}function kn({className:n,...e}){return a.jsx("div",{"data-slot":"empty",className:G("flex w-full min-w-0 flex-1 flex-col items-center justify-center gap-4 rounded-xl border-dashed p-6 text-center text-balance motion-safe:animate-in motion-safe:fade-in-0 motion-safe:slide-in-from-bottom-1 motion-safe:duration-200 motion-safe:ease-out motion-reduce:animate-none",n),...e})}function jn({className:n,...e}){return a.jsx("div",{"data-slot":"empty-header",className:G("flex max-w-sm flex-col items-center gap-2",n),...e})}const YP=Lr("mb-2 flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0",{variants:{variant:{default:"bg-transparent",icon:"flex size-8 shrink-0 items-center justify-center rounded-lg bg-muted text-foreground [&_svg:not([class*='size-'])]:size-4"}},defaultVariants:{variant:"default"}});function Rn({className:n,variant:e="default",...t}){return a.jsx("div",{"data-slot":"empty-icon","data-variant":e,className:G(YP({variant:e,className:n})),...t})}function Nn({className:n,...e}){return a.jsx("div",{"data-slot":"empty-title",className:G("text-sm font-medium tracking-tight",n),...e})}function Cn({className:n,...e}){return a.jsx("div",{"data-slot":"empty-description",className:G("text-sm/relaxed text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",n),...e})}function zl({className:n,...e}){return a.jsx("div",{"data-slot":"empty-content",className:G("flex w-full max-w-sm min-w-0 flex-col items-center gap-2.5 text-sm text-balance",n),...e})}function XP(n){if(typeof document>"u")return;let e=document.head||document.getElementsByTagName("head")[0],t=document.createElement("style");t.type="text/css",e.appendChild(t),t.styleSheet?t.styleSheet.cssText=n:t.appendChild(document.createTextNode(n))}const JP=n=>{switch(n){case"success":return tI;case"info":return sI;case"warning":return nI;case"error":return rI;default:return null}},QP=Array(12).fill(0),eI=({visible:n,className:e})=>Te.createElement("div",{className:["sonner-loading-wrapper",e].filter(Boolean).join(" "),"data-visible":n},Te.createElement("div",{className:"sonner-spinner"},QP.map((t,s)=>Te.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${s}`})))),tI=Te.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},Te.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),nI=Te.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},Te.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),sI=Te.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},Te.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),rI=Te.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},Te.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),oI=Te.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true"},Te.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),Te.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),iI=()=>{const[n,e]=Te.useState(document.hidden);return Te.useEffect(()=>{const t=()=>{e(document.hidden)};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[]),n};let aI=1;const lI=100,Vb=n=>{var e;return typeof(n==null?void 0:n.id)=="number"||(n==null||(e=n.id)==null?void 0:e.length)>0?n.id:aI++};class cI{constructor(){this.subscribe=e=>(this.subscribers.push(e),this.getActiveToasts().forEach(t=>e(t)),()=>{const t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e],this.trimHistory()},this.trimHistory=()=>{let e=this.toasts.length-lI;e<=0||(this.toasts=this.toasts.filter(t=>e>0&&this.dismissedToasts.has(t.id)?(this.dismissedToasts.delete(t.id),e--,!1):!0))},this.create=e=>{const{message:t,...s}=e,r=Vb(e),o=this.pendingDismissals.get(r);o!==void 0&&(cancelAnimationFrame(o),this.pendingDismissals.delete(r),this.dismissedToasts.delete(r));const i=this.dismissedToasts.has(r),l=e.dismissible===void 0?!0:e.dismissible;return i&&(this.dismissedToasts.delete(r),this.toasts=this.toasts.filter(u=>u.id!==r)),(i?void 0:this.toasts.find(u=>u.id===r))?this.toasts=this.toasts.map(u=>u.id===r?(this.publish({...u,...e,id:r,title:t}),{...u,...e,id:r,dismissible:l,title:t}):u):this.addToast({title:t,...s,dismissible:l,id:r}),r},this.dismiss=e=>{if(e==null)return this.getActiveToasts().forEach(s=>{this.dismissedToasts.add(s.id),this.subscribers.forEach(r=>r({id:s.id,dismiss:!0}))}),e;this.dismissedToasts.add(e);const t=this.pendingDismissals.get(e);return t!==void 0&&cancelAnimationFrame(t),this.pendingDismissals.set(e,requestAnimationFrame(()=>{this.pendingDismissals.delete(e),this.subscribers.forEach(s=>s({id:e,dismiss:!0}))})),e},this.message=(e,t)=>this.create({...t,message:e,type:void 0}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let s;t.loading!==void 0&&(s=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));const r=Promise.resolve(e instanceof Function?e():e);let o=s!==void 0,i;const l=r.then(async u=>{if(i=["resolve",u],Te.isValidElement(u))o=!1,this.create({id:s,type:"default",message:u});else if(dI(u)&&!u.ok){o=!1;const f=typeof t.error=="function"?await t.error(`HTTP error! status: ${u.status}`):t.error,m=typeof t.description=="function"?await t.description(`HTTP error! status: ${u.status}`):t.description,h=typeof f=="object"&&!Te.isValidElement(f)?f:{message:f};this.create({id:s,type:"error",description:m,...h})}else if(u instanceof Error){o=!1;const f=typeof t.error=="function"?await t.error(u):t.error,m=typeof t.description=="function"?await t.description(u):t.description,h=typeof f=="object"&&!Te.isValidElement(f)?f:{message:f};this.create({id:s,type:"error",description:m,...h})}else if(t.success!==void 0){o=!1;const f=typeof t.success=="function"?await t.success(u):t.success,m=typeof t.description=="function"?await t.description(u):t.description,h=typeof f=="object"&&!Te.isValidElement(f)?f:{message:f};this.create({id:s,type:"success",description:m,...h})}}).catch(async u=>{if(i=["reject",u],t.error!==void 0){o=!1;const d=typeof t.error=="function"?await t.error(u):t.error,f=typeof t.description=="function"?await t.description(u):t.description,p=typeof d=="object"&&!Te.isValidElement(d)?d:{message:d};this.create({id:s,type:"error",description:f,...p})}}).finally(()=>{o&&(this.dismiss(s),s=void 0),t.finally==null||t.finally.call(t)}),c=()=>new Promise((u,d)=>l.then(()=>i[0]==="reject"?d(i[1]):u(i[1])).catch(d));return typeof s!="string"&&typeof s!="number"?{unwrap:c}:Object.assign(s,{unwrap:c})},this.custom=(e,t)=>{const s=Vb(t);return this.create({...t,jsx:e(s),id:s,type:void 0}),s},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set,this.pendingDismissals=new Map}}const Hn=new cI,uI=(n,e)=>Hn.message(n,e),dI=n=>n&&typeof n=="object"&&"ok"in n&&typeof n.ok=="boolean"&&"status"in n&&typeof n.status=="number",fI=uI,mI=()=>Hn.toasts,pI=()=>Hn.getActiveToasts(),Bn=Object.assign(fI,{success:Hn.success,info:Hn.info,warning:Hn.warning,error:Hn.error,custom:Hn.custom,message:Hn.message,promise:Hn.promise,dismiss:Hn.dismiss,loading:Hn.loading},{getHistory:mI,getToasts:pI});XP("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px;flex:1;min-width:0}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--normal-text);background:var(--normal-bg);border:1px solid var(--normal-border);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{-webkit-user-select:none;user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function Pc(n){return n.label!==void 0}const hI=3,gI="24px",xI="16px",Hb=4e3,bI=356,vI=14,yI=45,wI=200;function Hs(...n){return n.filter(Boolean).join(" ")}function SI(n){const[e,t]=n.split("-"),s=[];return e&&s.push(e),t&&s.push(t),s}const kI=n=>{var e,t,s,r,o,i,l,c,u;const{invert:d,toast:f,unstyled:m,interacting:p,setHeights:h,visibleToasts:g,heights:x,index:b,toasts:y,expanded:v,removeToast:k,defaultRichColors:j,closeButton:_,style:N,cancelButtonStyle:S,actionButtonStyle:C,className:E="",descriptionClassName:T="",duration:A,position:P,gap:I,expandByDefault:$,classNames:O,icons:M,closeButtonAriaLabel:R="Close toast"}=n,[z,W]=Te.useState(null),[D,L]=Te.useState(null),[U,F]=Te.useState(!1),[B,V]=Te.useState(!1),[H,K]=Te.useState(!1),[Z,Y]=Te.useState(!1),[X,se]=Te.useState(!1),[Q,te]=Te.useState(0),[J,ne]=Te.useState(0),re=Te.useRef(f.duration||A||Hb),le=Te.useRef(null),ae=Te.useRef(null),ue=b===0,oe=b+1<=g,ie=f.type,fe=ie??"default",de=f.dismissible!==!1,ce=f.className||"",xe=f.descriptionClassName||"",pe=Te.useMemo(()=>x.findIndex(Ce=>Ce.toastId===f.id)||0,[x,f.id]),he=Te.useMemo(()=>{var Ce;return(Ce=f.closeButton)!=null?Ce:_},[f.closeButton,_]),ye=Te.useMemo(()=>f.duration||A||Hb,[f.duration,A]),ve=Te.useRef(0),ke=Te.useRef(0),je=Te.useRef(0),Me=Te.useRef(null),[_e,Fe]=P.split("-"),ze=Te.useMemo(()=>x.reduce((Ce,Be,Ye)=>Ye>=pe?Ce:Ce+Be.height,0),[x,pe]),We=iI(),Pe=Te.useMemo(()=>{var Ce;return(Ce=n.swipeDirections)!=null?Ce:SI(P)},[n.swipeDirections,P]),qe=f.invert||d,be=ie==="loading";ke.current=Te.useMemo(()=>pe*I+ze,[pe,ze]),Te.useEffect(()=>{re.current=ye},[ye]),Te.useEffect(()=>{F(!0)},[]),Te.useEffect(()=>{const Ce=ae.current;if(Ce){const Be=Ce.getBoundingClientRect().height;return ne(Be),h(Ye=>[{toastId:f.id,height:Be,position:f.position},...Ye]),()=>h(Ye=>Ye.filter(Xe=>Xe.toastId!==f.id))}},[h,f.id]),Te.useLayoutEffect(()=>{if(!U)return;const Ce=ae.current,Be=Ce.style.height;Ce.style.height="auto";const Ye=Ce.getBoundingClientRect().height;Ce.style.height=Be,ne(Ye),h(Xe=>Xe.find(Qe=>Qe.toastId===f.id)?Xe.map(Qe=>Qe.toastId===f.id?{...Qe,height:Ye}:Qe):[{toastId:f.id,height:Ye,position:f.position},...Xe])},[U,f.title,f.description,h,f.id,f.jsx,f.action,f.cancel]);const Ie=Te.useCallback(()=>{V(!0),te(ke.current),h(Ce=>Ce.filter(Be=>Be.toastId!==f.id)),setTimeout(()=>{k(f)},wI)},[f,k,h,ke]);Te.useEffect(()=>{if(f.promise&&ie==="loading"||f.duration===1/0||f.type==="loading")return;let Ce;return v||p||We?(()=>{if(je.current<ve.current){const Xe=new Date().getTime()-ve.current;re.current=re.current-Xe}je.current=new Date().getTime()})():(()=>{re.current!==1/0&&(ve.current=new Date().getTime(),Ce=setTimeout(()=>{f.onAutoClose==null||f.onAutoClose.call(f,f),Ie()},re.current))})(),()=>clearTimeout(Ce)},[v,p,f,ie,We,Ie]),Te.useEffect(()=>{f.delete&&(Ie(),f.onDismiss==null||f.onDismiss.call(f,f))},[Ie,f.delete]);function Se(){var Ce;if(M!=null&&M.loading){var Be;return Te.createElement("div",{className:Hs(O==null?void 0:O.loader,f==null||(Be=f.classNames)==null?void 0:Be.loader,"sonner-loader"),"data-visible":ie==="loading"},M.loading)}return Te.createElement(eI,{className:Hs(O==null?void 0:O.loader,f==null||(Ce=f.classNames)==null?void 0:Ce.loader),visible:ie==="loading"})}const Ne=f.icon||(M==null?void 0:M[ie])||JP(ie);var He,Ke;return Te.createElement("li",{tabIndex:0,ref:ae,className:Hs(E,ce,O==null?void 0:O.toast,f==null||(e=f.classNames)==null?void 0:e.toast,O==null?void 0:O[fe],f==null||(t=f.classNames)==null?void 0:t[fe]),"data-sonner-toast":"","data-rich-colors":(He=f.richColors)!=null?He:j,"data-styled":!(f.jsx||f.unstyled||m),"data-mounted":U,"data-promise":!!f.promise,"data-swiped":X,"data-removed":B,"data-visible":oe,"data-y-position":_e,"data-x-position":Fe,"data-index":b,"data-front":ue,"data-swiping":H,"data-dismissible":de,"data-type":ie,"data-invert":qe,"data-swipe-out":Z,"data-swipe-direction":D,"data-expanded":!!(v||$&&U),"data-testid":f.testId,style:{"--index":b,"--toasts-before":b,"--z-index":y.length-b,"--offset":`${B?Q:ke.current}px`,"--initial-height":$?"auto":`${J}px`,...N,...f.style},onDragEnd:()=>{K(!1),W(null),Me.current=null},onPointerDown:Ce=>{Ce.button!==2&&(be||!de||(le.current=new Date,te(ke.current),Ce.target.setPointerCapture(Ce.pointerId),Ce.target.tagName!=="BUTTON"&&(K(!0),Me.current={x:Ce.clientX,y:Ce.clientY})))},onPointerUp:()=>{var Ce,Be,Ye;if(Z||!de)return;Me.current=null;const Xe=Number(((Ce=ae.current)==null?void 0:Ce.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),nt=Number(((Be=ae.current)==null?void 0:Be.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Qe=new Date().getTime()-((Ye=le.current)==null?void 0:Ye.getTime()),Ee=z==="x"?Xe:nt,me=Math.abs(Ee)/Qe;if((z==="x"?Pe.includes(Xe>0?"right":"left"):Pe.includes(nt>0?"bottom":"top"))&&(Math.abs(Ee)>=yI||me>.11)){te(ke.current),f.onDismiss==null||f.onDismiss.call(f,f),L(z==="x"?Xe>0?"right":"left":nt>0?"down":"up"),Ie(),Y(!0);return}else{var Ge,rt;(Ge=ae.current)==null||Ge.style.setProperty("--swipe-amount-x","0px"),(rt=ae.current)==null||rt.style.setProperty("--swipe-amount-y","0px")}se(!1),K(!1),W(null)},onPointerMove:Ce=>{var Be,Ye,Xe;if(!Me.current||!de||((Be=window.getSelection())==null?void 0:Be.toString().length)>0)return;const Qe=Ce.clientY-Me.current.y,Ee=Ce.clientX-Me.current.x;!z&&(Math.abs(Ee)>1||Math.abs(Qe)>1)&&W(Math.abs(Ee)>Math.abs(Qe)?"x":"y");let me={x:0,y:0};const Oe=Ge=>1/(1.5+Math.abs(Ge)/20);if(z==="y"){if(Pe.includes("top")||Pe.includes("bottom"))if(Pe.includes("top")&&Qe<0||Pe.includes("bottom")&&Qe>0)me.y=Qe;else{const Ge=Qe*Oe(Qe);me.y=Math.abs(Ge)<Math.abs(Qe)?Ge:Qe}}else if(z==="x"&&(Pe.includes("left")||Pe.includes("right")))if(Pe.includes("left")&&Ee<0||Pe.includes("right")&&Ee>0)me.x=Ee;else{const Ge=Ee*Oe(Ee);me.x=Math.abs(Ge)<Math.abs(Ee)?Ge:Ee}(Math.abs(me.x)>0||Math.abs(me.y)>0)&&se(!0),(Ye=ae.current)==null||Ye.style.setProperty("--swipe-amount-x",`${me.x}px`),(Xe=ae.current)==null||Xe.style.setProperty("--swipe-amount-y",`${me.y}px`)}},he&&!f.jsx&&ie!=="loading"?Te.createElement("button",{"aria-label":R,"data-disabled":be,"data-close-button":!0,onClick:be||!de?()=>{}:()=>{Ie(),f.onDismiss==null||f.onDismiss.call(f,f)},className:Hs(O==null?void 0:O.closeButton,f==null||(s=f.classNames)==null?void 0:s.closeButton)},(Ke=M==null?void 0:M.close)!=null?Ke:oI):null,(ie||f.icon||f.promise)&&f.icon!==null&&((M==null?void 0:M[ie])!==null||f.icon)?Te.createElement("div",{"data-icon":"",className:Hs(O==null?void 0:O.icon,f==null||(r=f.classNames)==null?void 0:r.icon)},ie==="loading"?f.icon||Se():f.promise?Se():null,ie!=="loading"?Ne:null):null,Te.createElement("div",{"data-content":"",className:Hs(O==null?void 0:O.content,f==null||(o=f.classNames)==null?void 0:o.content)},Te.createElement("div",{"data-title":"",className:Hs(O==null?void 0:O.title,f==null||(i=f.classNames)==null?void 0:i.title)},f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title),f.description?Te.createElement("div",{"data-description":"",className:Hs(T,xe,O==null?void 0:O.description,f==null||(l=f.classNames)==null?void 0:l.description)},typeof f.description=="function"?f.description():f.description):null),Te.isValidElement(f.cancel)?f.cancel:f.cancel&&Pc(f.cancel)?Te.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||S,onClick:Ce=>{Pc(f.cancel)&&de&&(f.cancel.onClick==null||f.cancel.onClick.call(f.cancel,Ce),Ie())},className:Hs(O==null?void 0:O.cancelButton,f==null||(c=f.classNames)==null?void 0:c.cancelButton)},f.cancel.label):null,Te.isValidElement(f.action)?f.action:f.action&&Pc(f.action)?Te.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||C,onClick:Ce=>{Pc(f.action)&&(f.action.onClick==null||f.action.onClick.call(f.action,Ce),!Ce.defaultPrevented&&Ie())},className:Hs(O==null?void 0:O.actionButton,f==null||(u=f.classNames)==null?void 0:u.actionButton)},f.action.label):null)};function Kb(){if(typeof window>"u"||typeof document>"u")return"ltr";const n=document.documentElement.getAttribute("dir");return n==="auto"||!n?window.getComputedStyle(document.documentElement).direction:n}function jI(n,e){const t={};return[n,e].forEach((s,r)=>{const o=r===1,i=o?"--mobile-offset":"--offset",l=o?xI:gI;function c(u){["top","right","bottom","left"].forEach(d=>{t[`${i}-${d}`]=typeof u=="number"?`${u}px`:u})}typeof s=="number"||typeof s=="string"?c(s):typeof s=="object"?["top","right","bottom","left"].forEach(u=>{s[u]===void 0?t[`${i}-${u}`]=l:t[`${i}-${u}`]=typeof s[u]=="number"?`${s[u]}px`:s[u]}):c(l)}),t}const NI=Te.forwardRef(function(e,t){const{id:s,invert:r,position:o="bottom-right",hotkey:i=["altKey","KeyT"],expand:l,closeButton:c,className:u,offset:d,mobileOffset:f,theme:m="light",richColors:p,duration:h,style:g,visibleToasts:x=hI,toastOptions:b,dir:y=Kb(),gap:v=vI,icons:k,customAriaLabel:j,containerAriaLabel:_="Notifications"}=e,[N,S]=Te.useState([]),C=Te.useMemo(()=>s?N.filter(F=>F.toasterId===s):N.filter(F=>!F.toasterId),[N,s]),E=Te.useMemo(()=>Array.from(new Set([o].concat(C.filter(F=>F.position).map(F=>F.position)))),[C,o]),[T,A]=Te.useState([]),[P,I]=Te.useState(!1),[$,O]=Te.useState(!1),[M,R]=Te.useState(m!=="system"?m:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),z=Te.useRef(null),W=i.join("+").replace(/Key/g,"").replace(/Digit/g,""),D=Te.useRef(null),L=Te.useRef(!1),U=Te.useCallback(F=>{S(B=>{var V;return(V=B.find(H=>H.id===F.id))!=null&&V.delete||Hn.dismiss(F.id),B.filter(({id:H})=>H!==F.id)})},[]);return Te.useEffect(()=>Hn.subscribe(F=>{if(F.dismiss){requestAnimationFrame(()=>{S(B=>B.map(V=>V.id===F.id?{...V,delete:!0}:V))});return}setTimeout(()=>{kA.flushSync(()=>{S(B=>{const V=B.findIndex(H=>H.id===F.id);return V!==-1?[...B.slice(0,V),{...B[V],...F},...B.slice(V+1)]:[F,...B]})})})}),[]),Te.useEffect(()=>{if(m!=="system"){R(m);return}if(m==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?R("dark"):R("light")),typeof window>"u")return;const F=window.matchMedia("(prefers-color-scheme: dark)");try{F.addEventListener("change",({matches:B})=>{R(B?"dark":"light")})}catch{F.addListener(({matches:V})=>{try{R(V?"dark":"light")}catch(H){console.error(H)}})}},[m]),Te.useEffect(()=>{N.length<=1&&I(!1)},[N]),Te.useEffect(()=>{const F=B=>{var V;if(i.length>0&&i.every(Z=>B[Z]||B.code===Z)){var K;I(!0),(K=z.current)==null||K.focus()}B.code==="Escape"&&(document.activeElement===z.current||(V=z.current)!=null&&V.contains(document.activeElement))&&I(!1)};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[i]),Te.useEffect(()=>{if(z.current)return()=>{D.current&&(D.current.focus({preventScroll:!0}),D.current=null,L.current=!1)}},[z.current]),Te.createElement("section",{ref:t,"aria-label":j??`${_} ${W}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0,"data-react-aria-top-layer":!0},E.map((F,B)=>{var V;const[H,K]=F.split("-");return C.length?Te.createElement("ol",{key:F,dir:y==="auto"?Kb():y,tabIndex:-1,ref:z,className:u,"data-sonner-toaster":!0,"data-sonner-theme":M,"data-y-position":H,"data-x-position":K,style:{"--front-toast-height":`${((V=T[0])==null?void 0:V.height)||0}px`,"--width":`${bI}px`,"--gap":`${v}px`,...g,...jI(d,f)},onBlur:Z=>{L.current&&!Z.currentTarget.contains(Z.relatedTarget)&&(L.current=!1,D.current&&(D.current.focus({preventScroll:!0}),D.current=null))},onFocus:Z=>{Z.target instanceof HTMLElement&&Z.target.dataset.dismissible==="false"||L.current||(L.current=!0,D.current=Z.relatedTarget)},onMouseEnter:()=>I(!0),onMouseMove:()=>I(!0),onMouseLeave:()=>{$||I(!1)},onDragEnd:()=>I(!1),onPointerDown:Z=>{Z.target instanceof HTMLElement&&Z.target.dataset.dismissible==="false"||O(!0)},onPointerUp:()=>O(!1)},C.filter(Z=>!Z.position&&B===0||Z.position===F).map((Z,Y)=>{var X,se;return Te.createElement(kI,{key:Z.id,icons:k,index:Y,toast:Z,defaultRichColors:p,duration:(X=b==null?void 0:b.duration)!=null?X:h,className:b==null?void 0:b.className,descriptionClassName:b==null?void 0:b.descriptionClassName,invert:r,visibleToasts:x,closeButton:(se=b==null?void 0:b.closeButton)!=null?se:c,interacting:$,position:F,style:b==null?void 0:b.style,unstyled:b==null?void 0:b.unstyled,classNames:b==null?void 0:b.classNames,cancelButtonStyle:b==null?void 0:b.cancelButtonStyle,actionButtonStyle:b==null?void 0:b.actionButtonStyle,closeButtonAriaLabel:b==null?void 0:b.closeButtonAriaLabel,removeToast:U,toasts:C.filter(Q=>Q.position==Z.position),heights:T.filter(Q=>Q.position==Z.position),setHeights:A,expandByDefault:l,gap:v,expanded:P,swipeDirections:e.swipeDirections})})):null}))}),CI=n=>{const e=q.c(6);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s,r;e[2]===Symbol.for("react.memo_cache_sentinel")?(s={success:a.jsx(Mr,{className:"size-4"}),info:a.jsx(Pd,{className:"size-4"}),warning:a.jsx(lr,{className:"size-4"}),error:a.jsx(TA,{className:"size-4"}),loading:a.jsx(vt,{className:"size-4 animate-spin"})},r={"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)","--border-radius":"var(--radius)"},e[2]=s,e[3]=r):(s=e[2],r=e[3]);let o;return e[4]!==t?(o=a.jsx(NI,{className:"toaster group",icons:s,style:r,...t}),e[4]=t,e[5]=o):o=e[5],o},Et="local",R3="cogpit-last-path::",Nh=new Map;function Dt(){var t;const n=typeof window<"u"?(t=window.location)==null?void 0:t.pathname:void 0;if(!n)return Et;const e=/^\/d\/([^/]+)/.exec(n);return e?e[1]:Et}function yo(){return Dt()!==Et}function Dd(){const n=Dt();return n===Et?"":`/d/${n}`}function O3(){const n=Dt();return n===Et?"":`/hub/${n}`}function c1(n){const e=O3();return!e||n.startsWith("/api/hub/")||n.startsWith("/api/auth/")?n:n.startsWith("/api")||n.startsWith("/__pty")||n.startsWith("/__browser")?`${e}${n}`:n}let dl=null;function _I(n){n!==dl&&(dl=n,window.dispatchEvent(new Event("cogpit-identity-changed")))}function xs(){return dl}function vu(n){return n===Et?0:Nh.get(n)??0}function EI(n,e){if(n===Et||!Number.isSafeInteger(e)||e<0)return!1;const t=Nh.get(n);return t!==void 0&&e<=t?!1:(Nh.set(n,e),window.dispatchEvent(new CustomEvent("cogpit-device-scope-changed",{detail:{deviceId:n,connectionRevision:e}})),!0)}function fn(){const n=Dt(),e=vu(n);return e===0?n:`${n}@${e}`}function gn(n){const e=Dt(),t=fn();return dl!==null?`${n}::${t}::${dl}`:e===Et?n:`${n}::${t}`}function ha(n,e){sessionStorage.setItem(`${R3}${n}`,e)}function Fs(n){const t=sessionStorage.getItem(`${R3}${n}`)??(n===Et?"/":`/d/${n}/`);window.history.pushState(null,"",t),window.dispatchEvent(new Event("cogpit-device-changed"))}const TI=["personal","team"];function L3(n){return TI.includes(n)}const AI="X-Cogpit-Gate",u1={terminal:!0,configWrite:!0,hostFiles:!0,manageDevices:!0,killAny:!0,viewUsage:!0,share:!0,browser:!0},Qi={terminal:!1,configWrite:!1,hostFiles:!1,manageDevices:!1,killAny:!1,viewUsage:!1,share:!1,browser:!1},PI={capabilities:u1,user:{edition:"personal",user:null,hubUser:null,enforcesSessionAccess:!1},gate:null},M3={capabilities:Qi,user:{edition:null,user:null,hubUser:null,enforcesSessionAccess:null},gate:null};let z3=PI,Ch=null;const _h=new Set;function Ha(n,e=(n==null?void 0:n.user)??null){z3=n?{capabilities:n.capabilities,user:{edition:n.edition,user:n.user,hubUser:e,enforcesSessionAccess:n.enforcesSessionAccess===!0},gate:n.gate??null}:M3,Ch=fn();for(const t of _h)t()}function d1(){return Ch===null||Ch===fn()?z3:M3}function pt(n){const{capabilities:e}=d1();return Object.hasOwn(e,n)&&e[n]===!0}function fl(){return d1().user}function Gb(){return d1().gate}function Fd(n){return _h.add(n),()=>_h.delete(n)}const II=Object.freeze({});let Dl=II,ea="idle";const Eh=new Set;function Ud(n,e){Dl=n,ea=e;for(const t of Eh)t()}function Th(){return Dl}function ml(){return ea}function f1(n){return Eh.add(n),()=>Eh.delete(n)}function $I(n){if(ea==="installed")throw new Error(`An edition UI is already installed; ${n.edition} cannot replace it`);Ud(n.ui,"installed")}function RI(){ea!=="installed"&&Ud(Dl,"loading")}function OI(){ea!=="installed"&&Ud(Dl,"unavailable")}function LI(){ea!=="installed"&&Ud(Dl,"failed")}const MI=[],Zb=new WeakMap;function Yb(){const n=fl();let e=Zb.get(n);return e||(e={...n,can:pt},Zb.set(n,e)),e}function ur(){return w.useSyncExternalStore(f1,Th,Th)}function Xb(){return ml()==="unavailable"}function zI(){return w.useSyncExternalStore(f1,Xb,Xb)}function DI(){return w.useSyncExternalStore(Fd,Yb,Yb)}function m1(){const n=q.c(5),{mainViews:e}=ur(),t=e===void 0?MI:e,s=DI();let r;if(n[0]!==s||n[1]!==t){let o;n[3]!==s?(o=i=>i.isAvailable(s),n[3]=s,n[4]=o):o=n[4],r=t.filter(o),n[0]=s,n[1]=t,n[2]=r}else r=n[2];return r}function D3(n){const e=q.c(3),t=m1();let s;return e[0]!==n||e[1]!==t?(s=n===null?null:t.find(r=>r.id===n)??null,e[0]=n,e[1]=t,e[2]=s):s=e[2],s}const Bd=[{id:"layered",className:"dark theme-layered",name:"Layered Black",swatches:["#000000","#080808","#0f0f0f","#161616","#1d1d1d"]},{id:"layered-light",className:"theme-layered",name:"Layered Light",swatches:["#ffffff","#f7f7f7","#f0f0f0","#e9e9e9","#e2e2e2"]},{id:"dark",className:"dark",name:"Default Dark",swatches:["oklch(0.105 0 0)","oklch(0.13 0 0)","oklch(0.16 0 0)","oklch(0.2 0 0)","oklch(0.24 0 0)"]},{id:"oled",className:"dark theme-oled",name:"Deep OLED",swatches:["oklch(0 0 0)","oklch(0.08 0 0)","oklch(0.10 0 0)","oklch(0.10 0 0)","oklch(0.18 0 0)"]},{id:"light",className:"",name:"Light",swatches:["oklch(1 0 0)","oklch(1 0 0)","oklch(1 0 0)","oklch(0.96 0 0)","oklch(0.922 0 0)"]}],F3="cogpit-theme",FI=[...new Set(Bd.flatMap(n=>n.className.split(" ").filter(Boolean)))];function UI(){var n;try{const e=localStorage.getItem(F3);return((n=Bd.find(t=>t.id===e))==null?void 0:n.id)??"dark"}catch{return"dark"}}function BI(n){try{localStorage.setItem(F3,n)}catch{}}function U3(n){return Bd.find(e=>e.id===n).className.split(" ").includes("dark")?"dark":"light"}function WI(n){var s;const e=Bd.find(r=>r.id===n),t=document.documentElement;t.classList.remove(...FI),t.classList.add(...e.className.split(" ").filter(Boolean)),t.style.colorScheme=U3(n),(s=document.querySelector('meta[name="theme-color"]'))==null||s.setAttribute("content",e.swatches[0])}function Jb(n){const e=q.c(18),{activeError:t,clearActiveError:s,modelFallbackNotice:r,dismissModelFallbackNotice:o,connectionLost:i,theme:l}=n;let c,u;e[0]!==t||e[1]!==s?(c=()=>{if(!t){Bn.dismiss("app-error");return}Bn.error(t,{id:"app-error",duration:8e3,onDismiss:s,onAutoClose:s})},u=[t,s],e[0]=t,e[1]=s,e[2]=c,e[3]=u):(c=e[2],u=e[3]),w.useEffect(c,u);let d,f;e[4]!==o||e[5]!==r?(d=()=>{if(!r){Bn.dismiss("model-fallback");return}Bn.warning(r,{id:"model-fallback",duration:1/0,onDismiss:o})},f=[o,r],e[4]=o,e[5]=r,e[6]=d,e[7]=f):(d=e[6],f=e[7]),w.useEffect(d,f);let m,p;e[8]!==i?(m=()=>{if(!i){Bn.dismiss("session-connection");return}Bn.warning("Connection lost",{id:"session-connection",description:"Reconnecting to the live session…",duration:1/0})},p=[i],e[8]=i,e[9]=m,e[10]=p):(m=e[9],p=e[10]),w.useEffect(m,p);const h=zI();let g,x;e[11]!==h?(g=()=>{h&&Bn.info("This server offers features this build of Cogpit doesn’t include.",{id:"edition-ui-unavailable"})},x=[h],e[11]=h,e[12]=g,e[13]=x):(g=e[12],x=e[13]),w.useEffect(g,x);let b;e[14]!==l?(b=U3(l),e[14]=l,e[15]=b):b=e[15];let y;return e[16]!==b?(y=a.jsx(CI,{theme:b,position:"bottom-center",closeButton:!0,visibleToasts:3}),e[16]=b,e[17]=y):y=e[17],y}const Ah="cogpit-gate";function qI(n){n.status===403&&n.headers.has(AI)&&window.dispatchEvent(new Event(Ah))}function VI(n){return window.addEventListener(Ah,n),()=>window.removeEventListener(Ah,n)}const HI="/api/session-access/",p1="X-Cogpit-Session-Access",KI="X-Cogpit-Session-Id",Qb="access",ev="session-config",B3="cogpit-session-access-lost",W3="cogpit-session-access-changed",q3="cogpit-session-deleted",GI=6e4,yu=new Map,ZI=["none","view","interact","own"];function V3(n){return typeof n=="string"&&ZI.includes(n)}function H3(n,e,t=!1){window.dispatchEvent(new CustomEvent(n,{detail:{sessionId:e,background:t}}))}function K3(n,e,t=!1){H3(e==="none"?B3:W3,n,t)}function YI(n){return n.headers.has(p1)}function G3(n){return n.headers.get(p1)==="none"}function XI(n,e=!1){const t=n.headers.get(p1),s=n.headers.get(KI);V3(t)&&s&&K3(s,t,e)}function JI(n){function e(t){let s;try{s=JSON.parse(t.data)}catch{return}V3(s.level)&&typeof s.sessionId=="string"&&K3(s.sessionId,s.level)}return n.addEventListener(Qb,e),()=>n.removeEventListener(Qb,e)}function h1(n,e,t){function s(r){const o=r.detail,i=o==null?void 0:o.sessionId;typeof i!="string"||t!==void 0&&i!==t||e(i,(o==null?void 0:o.background)===!0)}return window.addEventListener(n,s),()=>window.removeEventListener(n,s)}function QI(n){return h1(B3,n)}function e$(n,e){const t=e.catch(()=>!1);yu.set(n,t);const s=()=>{yu.get(n)===t&&yu.delete(n)};return t.then(r=>(r?(H3(q3,n),setTimeout(s,GI)):s(),r))}function t$(n){return yu.get(n)??Promise.resolve(!1)}function n$(n){return h1(q3,n)}function Z3(n,e){return h1(W3,n,e)}let Y3=null;function Vu(){return Y3}function s$(n){Y3=n}const r$=["DEVICE_AUTH_FAILED","DEVICE_UNREACHABLE","DEVICE_REFUSED"],tv="cogpit-network-token",o$=new Set(["localhost","127.0.0.1","::1","0:0:0:0:0:0:0:1"]);function Wd(){const n=window.location.hostname.toLowerCase(),e=n.startsWith("[")&&n.endsWith("]")?n.slice(1,-1):n;return!o$.has(e)}function qd(){try{localStorage.removeItem(tv),sessionStorage.removeItem(tv)}catch{}}typeof window<"u"&&qd();const i$={edition:"personal",signIn:"password",setupRequired:!1};let pl=null;function X3(){return fetch("/api/hello",{method:"GET",credentials:"same-origin",cache:"no-store",headers:{"X-Cogpit-Client":"1"}}).then(async n=>{if(!n.ok)throw new Error(`Hello handshake failed (${n.status})`);const e=await n.json(),t=e.signIn==="account"?"account":"password";return s$(t),{edition:L3(e.edition)?e.edition:"personal",signIn:t,setupRequired:t==="account"&&e.setupRequired===!0}}).catch(()=>(pl=null,i$))}function J3(){return pl??(pl=X3()),pl}function nv(){return pl=X3(),pl}function Q3(){return J3().then(n=>n.signIn)}async function a$(){if(!Wd()&&Vu()!=="account")return!0;try{return(await fetch("/api/auth/session",{method:"GET",credentials:"same-origin",cache:"no-store",headers:{"X-Cogpit-Client":"1"}})).ok}catch{return!1}}async function l$(){try{await fetch("/api/auth/logout",{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"X-Cogpit-Client":"1"}})}finally{qd()}}const c$=new Set(r$);function sv(){return qd(),window.dispatchEvent(new Event("cogpit-auth-required")),Promise.reject(new Error("Authentication required"))}function ej(n,e,t){t&&typeof n=="string"&&n.startsWith("/api")&&(n=c1(n));const{background:s=!1,...r}=e??{},o=new Headers(r.headers);return o.delete("Authorization"),o.set("X-Cogpit-Client","1"),fetch(n,{...r,headers:o,credentials:"same-origin"}).then(i=>{if(XI(i,s),qI(i),i.status===401){if(Wd()||Vu()==="account")return sv();if(Vu()===null)return Q3().then(l=>l==="account"?sv():i)}if(i.status===502){const l=i.headers.get("X-Cogpit-Hub-Error"),c=i.headers.get("X-Cogpit-Device");c&&l&&c$.has(l)&&window.dispatchEvent(new CustomEvent("cogpit-device-unreachable",{detail:{deviceId:c,reason:l}}))}return i})}function Re(n,e){return ej(n,e,!0)}function ws(n,e,t={}){return Re(n,{method:"POST",...t,headers:{"Content-Type":"application/json",...t.headers},body:JSON.stringify(e)})}function Kr(n,e){return ej(n,e,!1)}function g1(n){return c1(n)}const ao=["codex","copilot","claude"],x1="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}",u$=new RegExp(`^${x1}$`,"i");function rv(n,e){const t=new TextEncoder().encode(e);let s="";for(const o of t)s+=String.fromCharCode(o);const r=btoa(s).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return`${n}${r}`}function ov(n,e){if(!e.startsWith(n))return null;try{const t=e.slice(n.length).replace(/-/g,"+").replace(/_/g,"/"),s=atob(t),r=Uint8Array.from(s,o=>o.charCodeAt(0));return new TextDecoder().decode(r)}catch{return null}}function tj(n){return{lossy:!1,owns:e=>typeof e=="string"&&e.startsWith(n),recognizes:e=>{const t=ov(n,e);return t!==null&&t!==""&&rv(n,t)===e},encode:e=>rv(n,e),decode:e=>ov(n,e)}}function Ph(n){const e=new RegExp(`(${x1})\\.jsonl$`,"i").exec(n);return e?e[1]:null}function b1(n){return n?{rootSessionId:n.toLowerCase(),isRootTranscript:!0}:null}function nj(n){const e=n.split("/");return e.every(s=>s!==""&&s!=="."&&s!==".."&&!s.includes("\\"))?e:null}const sj={urlId:n=>n.replace(/\.jsonl$/,""),fileNameFromUrlId:n=>n.endsWith(".jsonl")?n:`${n}.jsonl`};function rj(n){return`'${n.replace(/'/g,"'\\''")}'`}function hl(n,e){return e?[n,e]:[]}function Hu(n,e){var t;return((t=e.exec(n))==null?void 0:t[1])??null}const Ku="[0-9a-f-]{36}",oj="codex__",ij="copilot__",d$=new Set(["default","plan","acceptEdits","dontAsk","auto"]),f$=new Set(["subagents","workflows"]);function m$(n){const e=nj(n);if(!e)return null;const[t,s]=e;if(e.length===1){const r=t.replace(/\.jsonl$/,"");return r!==t&&av(r)?b1(r):null}return e.length>2&&f$.has(s)&&av(t)?{rootSessionId:t.toLowerCase(),isRootTranscript:!1}:null}const aj={kind:"claude",displayName:"Claude Code",binName:"claude",dirName:{lossy:!0,owns:n=>typeof n=="string"&&!n.startsWith(oj)&&!n.startsWith(ij),recognizes:n=>/^(?:(?:-|[A-Za-z]--)[A-Za-z0-9-]*|[A-Za-z]-)$/.test(n),encode:n=>(n.replace(/[\\/]+$/,"")||n).replace(/[^a-zA-Z0-9]/g,"-"),decode:n=>{const e=/^([A-Za-z])--(.*)$/.exec(n);return e?`${e[1]}:\\${e[2].replace(/-/g,"\\")}`:"/"+n.replace(/^-/,"").replace(/-/g,"/")}},projectWorktreeDir:".claude/worktrees",sessionFile:{name:n=>`${n}.jsonl`,sessionId:Ph,...sj,transcriptRoot:m$},metadataFromHead:!0,resume:{command:n=>`claude --resume ${n}`,args:n=>["--resume",n]},launchArgs:{permissions:n=>n!=null&&n.mode?n.mode==="bypassPermissions"?["--dangerously-skip-permissions"]:[...d$.has(n.mode)?["--permission-mode",n.mode]:[],...(n.allowedTools??[]).flatMap(e=>["--allowedTools",e]),...(n.disallowedTools??[]).flatMap(e=>["--disallowedTools",e])]:["--permission-mode","default"],model:n=>hl("--model",n),effort:n=>hl("--effort",n),fastTier:()=>[]},serviceTier:null,cli:{packageName:"@anthropic-ai/claude-code",homebrew:{name:"claude-code",cask:!1},wingetId:null,versionArgs:["--version"],selfUpdate:{args:["update"],matches:n=>n.endsWith("/.local/bin/claude")||n.endsWith("/.local/bin/claude.exe")||n.includes("/.local/share/claude/")},bundledBySdk:!0,homeDirName:".claude",homeEnvVar:null,installMarker:"projects",homeIsDiscoverable:!1,process:{by:"command",sessionIdFromCommand:n=>Hu(n,new RegExp(`--resume(?:=|\\s+)(${Ku})`))??Hu(n,new RegExp(`--session-id(?:=|\\s+)(${Ku})`))}},config:{rootDirName:".claude",instructions:[{in:"scope",path:"CLAUDE.md",scopes:["global","project"]},{in:"root",path:"CLAUDE.md",label:".claude/CLAUDE.md",scopes:["project"]}],settings:[{in:"root",path:"settings.json",scopes:["global"]},{in:"root",path:"settings.local.json",scopes:["project"]}],skillsDir:"skills",agentsDir:"agents",commandsDir:"commands",themesDir:"themes",pluginsDir:"plugins",pluginManifestDir:".claude-plugin"},contextWindow:{defaultLimit:1e6,limits:[{match:"claude-haiku-4-5",limit:2e5},{match:"claude-haiku-4-1",limit:2e5},{match:"claude-sonnet-4-5",limit:2e5},{match:"claude-opus-4-5",limit:2e5},{match:"claude-opus-4-1",limit:2e5}],compactBuffer:33e3,extendedContext:{marker:"[1m]",limit:1e6}},capabilities:{worktrees:!0,mcp:!0,slashCommands:!0,workflows:!0,agentTeams:!0,subagentTranscripts:!0,nestedSubagents:!1,sharing:!0,goals:"transcript",undo:!0,redo:!0,nativeRewind:!1,fileCheckpoints:!0,reasoningEffort:!0,configurableContextWindow:!1,fastTier:!0,lowPriorityInTerminal:!0,imageInput:!0,midTurnSteering:!1,stopSession:!0,ultracode:!0,contextWindow:!0,externalProcesses:!1,accountSwitching:!0,modelFallbackNotices:!0,autoPermissionMode:"per-model",settingsApply:"live",turnLiveness:"transcript",tokenStreaming:!0,nativeFork:!1,namedSessions:!0}},iv={appServerValue:"priority",cliConfigValue:"fast"},p$={kind:"codex",displayName:"Codex",binName:"codex",dirName:tj(oj),projectWorktreeDir:null,sessionFile:{name:(n,e=new Date)=>{const t=String(e.getFullYear()),s=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0"),o=String(e.getHours()).padStart(2,"0"),i=String(e.getMinutes()).padStart(2,"0"),l=String(e.getSeconds()).padStart(2,"0");return`${t}/${s}/${r}/rollout-${t}-${s}-${r}T${o}-${i}-${l}-${n}.jsonl`},sessionId:Ph,...sj,transcriptRoot:n=>nj(n)?b1(Ph(n)):null},metadataFromHead:!1,resume:{command:(n,e)=>e?`codex -C ${rj(e)} resume ${n}`:`codex resume ${n}`,args:n=>["resume",n]},launchArgs:{permissions:n=>{const e=(n==null?void 0:n.mode)||"default";return e==="bypassPermissions"?["--dangerously-bypass-approvals-and-sandbox"]:e==="auto"?["--approve-for-me"]:["--sandbox",e==="plan"?"read-only":"workspace-write","-c",'approval_policy="never"']},model:n=>hl("-m",n),effort:n=>n?["-c",`model_reasoning_effort=${JSON.stringify(n)}`]:[],fastTier:n=>n?["-c",`service_tier=${JSON.stringify(iv.cliConfigValue)}`,"--enable","fast_mode"]:[]},serviceTier:iv,cli:{packageName:"@openai/codex",homebrew:{name:"codex",cask:!1},wingetId:null,versionArgs:["--version"],selfUpdate:null,bundledBySdk:!1,homeDirName:".codex",homeEnvVar:"CODEX_HOME",installMarker:"",homeIsDiscoverable:!0,process:{by:"command",sessionIdFromCommand:n=>Hu(n,new RegExp(`codex(?:\\s+\\S+)*\\s+exec\\s+resume\\s+(${Ku})`))}},config:{rootDirName:".codex",instructions:[{in:"scope",path:"AGENTS.md",scopes:["global","project"]}],settings:[{in:"root",path:"config.toml",scopes:["global","project"]}],skillsDir:"skills",agentsDir:"agents",commandsDir:"prompts",themesDir:null,pluginsDir:null,pluginManifestDir:null},contextWindow:{defaultLimit:272e3,limits:[],compactBuffer:0,extendedContext:null},capabilities:{worktrees:!0,mcp:!1,slashCommands:!1,workflows:!1,agentTeams:!1,subagentTranscripts:!0,nestedSubagents:!0,sharing:!1,goals:"thread-api",undo:!0,redo:!0,nativeRewind:!1,fileCheckpoints:!1,reasoningEffort:!0,configurableContextWindow:!0,fastTier:!0,lowPriorityInTerminal:!1,imageInput:!0,midTurnSteering:!0,stopSession:!1,ultracode:!1,contextWindow:!1,externalProcesses:!1,accountSwitching:!1,modelFallbackNotices:!1,autoPermissionMode:"always",settingsApply:"next-turn",turnLiveness:"runtime",tokenStreaming:!0,nativeFork:!1,namedSessions:!1}};function nm(n){const e=new RegExp(`^(${x1})/events\\.jsonl$`,"i").exec(n);return e?e[1]:null}const h$={kind:"copilot",displayName:"GitHub Copilot CLI",binName:"copilot",dirName:tj(ij),projectWorktreeDir:null,sessionFile:{name:n=>`${n}/events.jsonl`,sessionId:nm,urlId:n=>nm(n)??n.replace(/\.jsonl$/,""),fileNameFromUrlId:n=>n.endsWith(".jsonl")?n:`${n}/events.jsonl`,transcriptRoot:n=>b1(nm(n))},metadataFromHead:!0,resume:{command:(n,e)=>e?`copilot -C ${rj(e)} --resume ${n}`:`copilot --resume ${n}`,args:n=>[`--resume=${n}`]},launchArgs:{permissions:n=>(n==null?void 0:n.mode)==="bypassPermissions"||(n==null?void 0:n.mode)==="auto"?["--allow-all"]:[],model:n=>hl("--model",n),effort:n=>hl("--reasoning-effort",n),fastTier:()=>[]},serviceTier:null,cli:{packageName:"@github/copilot",homebrew:{name:"copilot-cli",cask:!0},wingetId:"GitHub.Copilot",versionArgs:["--version"],selfUpdate:{args:["update"],matches:n=>n.endsWith("/.local/bin/copilot")||n==="/usr/local/bin/copilot"},bundledBySdk:!1,homeDirName:".copilot",homeEnvVar:"COPILOT_HOME",installMarker:"session-state",homeIsDiscoverable:!0,process:{by:"executable",sessionIdFromCommand:n=>Hu(n,new RegExp(`--resume(?:=|\\s+)(${Ku})`))}},config:{rootDirName:".copilot",instructions:[{in:"scope",path:"AGENTS.md",scopes:["global","project"]}],settings:[{in:"root",path:"config.json",scopes:["global"]}],skillsDir:"skills",agentsDir:null,commandsDir:null,themesDir:null,pluginsDir:null,pluginManifestDir:null},contextWindow:{defaultLimit:2e5,limits:[],compactBuffer:0,extendedContext:null},capabilities:{worktrees:!1,mcp:!1,slashCommands:!1,workflows:!1,agentTeams:!1,subagentTranscripts:!1,nestedSubagents:!1,sharing:!1,goals:!1,undo:!0,redo:!1,nativeRewind:!0,fileCheckpoints:!1,reasoningEffort:!1,configurableContextWindow:!1,fastTier:!1,lowPriorityInTerminal:!1,imageInput:!1,midTurnSteering:!0,stopSession:!0,ultracode:!1,contextWindow:!1,externalProcesses:!0,accountSwitching:!1,modelFallbackNotices:!1,autoPermissionMode:"always",settingsApply:"next-turn",turnLiveness:"runtime",tokenStreaming:!1,nativeFork:!0,namedSessions:!0}},gl=Object.freeze({claude:aj,codex:p$,copilot:h$});function us(n){return gl[n]}function Fl(){return ao.map(n=>gl[n])}function g$(n,e){const t=Fl().filter(n);if(t.length!==1)throw new Error(`Expected exactly one agent with ${e}, found ${t.length}`);return t[0]}function Ss(n){for(const e of ao)if(e!=="claude"&&gl[e].dirName.owns(n))return gl[e];return aj}function nn(n){return Ss(n).kind}function sm(n,e,t){const s=gl[n].dirName;return t&&s.lossy?t:s.encode(e)}function av(n){return u$.test(n)}const Go=Ss(null).kind;var r3;const Ic=((r3=Fl().find(n=>n.dirName.lossy))==null?void 0:r3.kind)??null;function Ri(n){return Ss(n).capabilities}function xn(n){return us(n).capabilities}function x$(n,e){return ao.find(t=>t===n)??e}function Gu(n){for(const e of Fl()){const t=e.sessionFile.sessionId(n);if(t)return t}return n.replace(/\.jsonl$/,"")}function v1(n,e){var t;return((t=Ss(n).sessionFile.transcriptRoot(e))==null?void 0:t.rootSessionId)??null}function b$(n,e){const t=Ss(n).sessionFile.transcriptRoot(e);return t!=null&&t.isRootTranscript?t.rootSessionId:null}function v$(n,e){return Ss(n).sessionFile.urlId(e)}function y$(n,e){return Ss(n).sessionFile.fileNameFromUrlId(e)}function y1(n,e,t){return us(n).resume.command(e,t)}function w$(n,e){const t=us(n);return{command:t.binName,args:[...t.resume.args(e)]}}function lv(n){return n.replace(/\/+$/,"")||"/"}function S$(n,e,t){var r;const s=lv(e);return((r=n.find(o=>Ss(o.dirName).kind===t&&lv(o.path)===s))==null?void 0:r.dirName)??null}const k$=[{value:"",label:"Default"},{value:"fable",label:"Fable"},{value:"fable[1m]",label:"Fable 1M"},{value:"opus",label:"Opus"},{value:"opus[1m]",label:"Opus 1M"},{value:"sonnet",label:"Sonnet"},{value:"sonnet[1m]",label:"Sonnet 1M"},{value:"haiku",label:"Haiku"}],w1=[{value:"low",label:"Light",description:"Fast responses with lighter reasoning"},{value:"medium",label:"Medium",description:"Balanced for everyday tasks"},{value:"high",label:"High",description:"Deeper reasoning for complex work"},{value:"xhigh",label:"Extra High",description:"Extra depth for difficult problems"},{value:"max",label:"Max",description:"Maximum reasoning depth"}],lj=[...w1,{value:"ultra",label:"Ultra",description:"Maximum reasoning with automatic task delegation"}],$c=w1.slice(0,4);var o3;const _a=[{value:((o3=us("codex").serviceTier)==null?void 0:o3.appServerValue)??"priority",label:"Fast",description:"1.5× speed with increased usage"}],cv={defaultReasoningEffort:"medium",supportedReasoningEfforts:lj,inputModalities:["text","image"],supportsPersonality:!1,serviceTiers:_a},j$=[{value:"",label:"Default",description:"Use the model configured in Codex"},{value:"gpt-6-astra",label:"GPT-6 Astra",description:"For complex, demanding work",...cv,serviceTiers:[{value:"priority",label:"Fast",description:"2× speed with increased usage"}]},{value:"gpt-5.6-sol",label:"GPT-5.6 Sol",description:"Flagship model for the most ambitious work",...cv},{value:"gpt-5.6-terra",label:"GPT-5.6 Terra",description:"Balanced model for everyday work",defaultReasoningEffort:"medium",supportedReasoningEfforts:lj,inputModalities:["text","image"],supportsPersonality:!1,serviceTiers:_a},{value:"gpt-5.6-luna",label:"GPT-5.6 Luna",description:"Fastest, most cost-efficient model",defaultReasoningEffort:"medium",supportedReasoningEfforts:w1,inputModalities:["text","image"],supportsPersonality:!1,serviceTiers:_a},{value:"gpt-5.5",label:"GPT-5.5",description:"Frontier model for complex real-world work",defaultReasoningEffort:"medium",supportedReasoningEfforts:$c,inputModalities:["text","image"],supportsPersonality:!0,serviceTiers:_a},{value:"gpt-5.4",label:"GPT-5.4",description:"Strong model for everyday coding",defaultReasoningEffort:"medium",supportedReasoningEfforts:$c,inputModalities:["text","image"],supportsPersonality:!0,serviceTiers:_a},{value:"gpt-5.4-mini",label:"GPT-5.4 Mini",description:"Small, fast model for simpler tasks",defaultReasoningEffort:"medium",supportedReasoningEfforts:$c,inputModalities:["text","image"],supportsPersonality:!0},{value:"gpt-5.3-codex-spark",label:"GPT-5.3 Codex Spark",description:"Ultra-fast text-only coding model",defaultReasoningEffort:"high",supportedReasoningEfforts:$c,inputModalities:["text"],supportsPersonality:!0}],N$=[{value:"",label:"Default",supportsEffort:!1,inputModalities:["text"]},{value:"auto",label:"Auto",description:"Let Copilot choose the best available model",supportsEffort:!1,inputModalities:["text"]}],C$={claude:k$,codex:j$,copilot:N$};function _$(n){return C$[n]}const cj=new Map,Ih=new Set;function E$(n,e){!Array.isArray(e)||e.length===0||(cj.set(n,e),Ih.forEach(t=>t()))}function T$(n){return Ih.add(n),()=>Ih.delete(n)}const uv="high",A$=[{value:"low",label:"Light"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"xhigh",label:"Extra High"},{value:"max",label:"Max"}];function P$(n){return cj.get(n)??_$(n)}function Ul(n,e){return e?n.find(t=>t.value===e):n.find(t=>t.value!==""&&t.isDefault)??n.find(t=>t.value==="")??n.find(t=>t.value!=="")}function uj(n,e,t){const s=Ul(e,t),r=s==null?void 0:s.supportedReasoningEfforts;return r&&r.length>0?r:(s==null?void 0:s.supportsEffort)===!1||!xn(n).reasoningEffort?[]:A$}function I$(n,e){var t,s;return(s=(t=Ul(n,e))==null?void 0:t.serviceTiers)==null?void 0:s.find(r=>r.value==="fast"||r.value==="priority"||r.label.toLowerCase()==="fast")}function $$(n,e,t){var r;const s=(r=Ul(e,t))==null?void 0:r.inputModalities;return s?s.includes("image"):xn(n).imageInput}function R$(n,e,t){var r;const s=xn(n).autoPermissionMode;return s==="always"?!0:s==="never"?!1:((r=Ul(e,t))==null?void 0:r.supportsAutoMode)===!0}function O$(n,e){return xn(n).ultracode?!(e??"").toLowerCase().startsWith("haiku"):!1}function L$(n,e,t,s){var l;const r=uj(n,e,s);if(r.length===0)return"";const o=c=>!!c&&r.some(u=>u.value===c);if(o(t))return t;const i=(l=Ul(e,s))==null?void 0:l.defaultReasoningEffort;return o(i)?i:o(uv)?uv:r[0].value}function M$(n){return n.toLowerCase().replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-").slice(0,40).replace(/-$/,"")}async function Vd(n){try{return await navigator.clipboard.writeText(n),!0}catch{const e=document.activeElement,t=document.createElement("textarea");t.value=n,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();const s=document.execCommand("copy");return document.body.removeChild(t),e instanceof HTMLElement&&e.focus(),s}}const z$=300*1e3,D$=30*1e3;let $h=0,ga=null;function F$(n){return Array.isArray(n)&&n.length>0&&n.every(e=>e&&typeof e=="object"&&typeof e.value=="string"&&typeof e.label=="string")}async function U$(){try{const n=await Re("/api/models");if(!n.ok)throw new Error(`GET /api/models → ${n.status}`);const e=await n.json();for(const t of ao){const s=e==null?void 0:e[t];F$(s)&&E$(t,s)}$h=Date.now()+z$}catch{$h=Date.now()+D$}}function S1(){return ga||(Date.now()<$h?Promise.resolve():(ga=U$().finally(()=>{ga=null}),ga))}function B$(){const n=()=>{document.visibilityState==="visible"&&S1()};return window.addEventListener("focus",n),document.addEventListener("visibilitychange",n),()=>{window.removeEventListener("focus",n),document.removeEventListener("visibilitychange",n)}}function W$(n){const e=q.c(3);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0],w.useEffect(q$,t);let s;return e[1]!==n?(s=()=>P$(n),e[1]=n,e[2]=s):s=e[2],w.useSyncExternalStore(T$,s)}function q$(){return S1(),B$()}function dj(n,e){const t=q.c(26),s=W$(n);let r;t[0]!==n||t[1]!==e||t[2]!==s?(r=uj(n,s,e),t[0]=n,t[1]=e,t[2]=s,t[3]=r):r=t[3];let o;t[4]!==e||t[5]!==s?(o=I$(s,e),t[4]=e,t[5]=s,t[6]=o):o=t[6];let i;t[7]!==n||t[8]!==e||t[9]!==s?(i=$$(n,s,e),t[7]=n,t[8]=e,t[9]=s,t[10]=i):i=t[10];let l;t[11]!==n||t[12]!==e||t[13]!==s?(l=R$(n,s,e),t[11]=n,t[12]=e,t[13]=s,t[14]=l):l=t[14];let c;t[15]!==n||t[16]!==e||t[17]!==s?(c=d=>L$(n,s,d,e),t[15]=n,t[16]=e,t[17]=s,t[18]=c):c=t[18];let u;return t[19]!==s||t[20]!==r||t[21]!==o||t[22]!==i||t[23]!==l||t[24]!==c?(u={options:s,effortOptions:r,fastTier:o,imageInput:i,autoPermissionMode:l,normalizeEffort:c},t[19]=s,t[20]=r,t[21]=o,t[22]=i,t[23]=l,t[24]=c,t[25]=u):u=t[25],u}function Bl(n){const e=q.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(AA,{"data-slot":"popover",...t}),e[2]=t,e[3]=s):s=e[3],s}function Wl(n){const e=q.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(PA,{"data-slot":"popover-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function k1(n){const e=q.c(22);let t,s,r,o,i,l,c,u;e[0]!==n?({align:o,alignOffset:i,side:l,sideOffset:c,collisionPadding:u,collisionAvoidance:s,className:t,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i,e[6]=l,e[7]=c,e[8]=u):(t=e[1],s=e[2],r=e[3],o=e[4],i=e[5],l=e[6],c=e[7],u=e[8]);const d=o===void 0?"start":o,f=i===void 0?0:i,m=l===void 0?"bottom":l,p=c===void 0?6:c,h=u===void 0?8:u;let g;e[9]!==t?(g=G("z-50 max-h-(--available-height) origin-(--transform-origin) rounded-xl bg-popover text-popover-foreground shadow-lg ring-1 ring-foreground/10 outline-none duration-100 ease-out data-[side=bottom]:slide-in-from-top-1 data-[side=top]:slide-in-from-bottom-1 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-75 data-closed:ease-in motion-reduce:animate-none",t),e[9]=t,e[10]=g):g=e[10];let x;e[11]!==r||e[12]!==g?(x=a.jsx(IA,{"data-slot":"popover-content",className:g,...r}),e[11]=r,e[12]=g,e[13]=x):x=e[13];let b;return e[14]!==d||e[15]!==f||e[16]!==s||e[17]!==h||e[18]!==m||e[19]!==p||e[20]!==x?(b=a.jsx($A,{children:a.jsx(RA,{className:"isolate z-50 outline-none",align:d,alignOffset:f,side:m,sideOffset:p,collisionPadding:h,collisionAvoidance:s,children:x})}),e[14]=d,e[15]=f,e[16]=s,e[17]=h,e[18]=m,e[19]=p,e[20]=x,e[21]=b):b=e[21],b}const V$=new Set(["mcp","server","servers","api","app","the","and"]),H$=/^([\w-]+\.[a-z]{2,})\s+(.+)$/i;function fj(n){const e=H$.exec(n.trim());return e?{short:e[2],namespace:e[1]}:{short:n.trim()}}function K$(n){const{short:e}=fj(n),t=e.split(/[^a-z0-9]+/i).filter(o=>o&&!V$.has(o.toLowerCase())),s=t.length>0?t:[e];return(s.length>=2?s[0][0]+s[1][0]:s[0].slice(0,2)).toUpperCase()}function j1(n){return n?"bottom":"top"}function N1(n){const e=q.c(11);let t,s,r;e[0]!==n?({className:s,children:t,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);let o;e[4]!==s?(o=G("max-w-72 data-popup-open:bg-accent data-popup-open:text-accent-foreground",s),e[4]=s,e[5]=o):o=e[5];let i;e[6]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsx(Ot,{"data-icon":"inline-end",className:"opacity-60"}),e[6]=i):i=e[6];let l;return e[7]!==t||e[8]!==r||e[9]!==o?(l=a.jsxs(ee,{type:"button",variant:"ghost",size:"xs",className:o,...r,children:[t,i]}),e[7]=t,e[8]=r,e[9]=o,e[10]=l):l=e[10],l}function C1(n){const e=q.c(13);let t,s,r,o;e[0]!==n?({side:r,align:o,className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o):(t=e[1],s=e[2],r=e[3],o=e[4]);const i=o===void 0?"start":o;let l;e[5]===Symbol.for("react.memo_cache_sentinel")?(l={side:"none",align:"shift",fallbackAxisSide:"none"},e[5]=l):l=e[5];let c;e[6]!==t?(c=G("flex flex-col overflow-hidden p-0",t),e[6]=t,e[7]=c):c=e[7];let u;return e[8]!==i||e[9]!==s||e[10]!==r||e[11]!==c?(u=a.jsx(k1,{side:r,align:i,collisionAvoidance:l,className:c,...s}),e[8]=i,e[9]=s,e[10]=r,e[11]=c,e[12]=u):u=e[12],u}function ji(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("px-2 pb-1 pt-1.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Rh(n){const e=q.c(16);let t,s,r,o,i;e[0]!==n?({value:i,onValueChange:o,className:r,children:s,...t}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i):(t=e[1],s=e[2],r=e[3],o=e[4],i=e[5]);let l;e[6]!==o?(l=d=>o(d),e[6]=o,e[7]=l):l=e[7];let c;e[8]!==r?(c=G("flex flex-col gap-px",r),e[8]=r,e[9]=c):c=e[9];let u;return e[10]!==t||e[11]!==s||e[12]!==l||e[13]!==c||e[14]!==i?(u=a.jsx(OA,{value:i,onValueChange:l,className:c,...t,children:s}),e[10]=t,e[11]=s,e[12]=l,e[13]=c,e[14]=i,e[15]=u):u=e[15],u}const G$="flex w-full cursor-pointer select-none items-center gap-2.5 rounded-lg px-2 py-1.5 text-left text-sm outline-none transition-colors duration-100 hover:bg-accent/70 focus-visible:ring-2 focus-visible:ring-ring/40";function _1(n){const e=q.c(16),{value:t,title:s,description:r,icon:o,disabled:i}=n;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=G(G$,"group/option data-checked:bg-accent data-checked:text-accent-foreground data-disabled:cursor-not-allowed data-disabled:opacity-40 data-disabled:hover:bg-transparent"),e[0]=l):l=e[0];let c;e[1]!==o?(c=o&&a.jsx(o,{className:"size-4 shrink-0 text-muted-foreground group-data-checked/option:text-foreground"}),e[1]=o,e[2]=c):c=e[2];let u;e[3]!==s?(u=a.jsx("span",{className:"truncate leading-5 group-data-checked/option:font-medium",children:s}),e[3]=s,e[4]=u):u=e[4];let d;e[5]!==r?(d=r&&a.jsx("span",{className:"truncate text-xs leading-4 text-muted-foreground",title:r,children:r}),e[5]=r,e[6]=d):d=e[6];let f;e[7]!==u||e[8]!==d?(f=a.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[u,d]}),e[7]=u,e[8]=d,e[9]=f):f=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=a.jsx(LA,{keepMounted:!0,className:"shrink-0 text-foreground opacity-0 transition-opacity duration-100 data-checked:opacity-100",children:a.jsx(Ft,{className:"size-4"})}),e[10]=m):m=e[10];let p;return e[11]!==i||e[12]!==c||e[13]!==f||e[14]!==t?(p=a.jsxs(MA,{value:t,disabled:i,className:l,children:[c,f,m]}),e[11]=i,e[12]=c,e[13]=f,e[14]=t,e[15]=p):p=e[15],p}const Z$=8;function Y$(n){const e=q.c(89),{servers:t,selected:s,onToggle:r,onSetSelection:o,onRefresh:i,loading:l,onAuth:c,isNewSession:u}=n,[d,f]=w.useState(""),m=w.useId();let p,h,g,x,b,y,v,k,j,_,N,S,C,E,T,A,P;if(e[0]!==d||e[1]!==u||e[2]!==m||e[3]!==l||e[4]!==c||e[5]!==i||e[6]!==o||e[7]!==r||e[8]!==s||e[9]!==t){const M=t.filter(Q$),R=t.filter(J$);let z;e[27]!==s?(z=new Set(s),e[27]=s,e[28]=z):z=e[28];const W=z;let D;e[29]!==W?(D=oe=>W.has(oe.name),e[29]=W,e[30]=D):D=e[30];const L=M.filter(D).length,U=l&&t.length===0,F=U?"MCPs":`MCPs ${L}/${M.length}`,B=d.trim().toLowerCase(),V=oe=>!B||oe.name.toLowerCase().includes(B),H=M.filter(V),K=R.filter(V);h=Bl,v=!1,e[31]===Symbol.for("react.memo_cache_sentinel")?(k=oe=>{oe||f("")},e[31]=k):k=e[31];let Z;e[32]!==F?(Z=a.jsx(N1,{"aria-label":F}),e[32]=F,e[33]=Z):Z=e[33];let Y;e[34]===Symbol.for("react.memo_cache_sentinel")?(Y=a.jsx(i3,{"data-icon":"inline-start"}),e[34]=Y):Y=e[34];let X;e[35]!==F?(X=a.jsx("span",{className:"truncate",children:F}),e[35]=F,e[36]=X):X=e[36];let se;e[37]!==U?(se=U&&a.jsx(On,{className:"size-3 animate-spin","aria-hidden":!0}),e[37]=U,e[38]=se):se=e[38],e[39]!==Z||e[40]!==X||e[41]!==se?(j=a.jsxs(Wl,{render:Z,children:[Y,X,se]}),e[39]=Z,e[40]=X,e[41]=se,e[42]=j):j=e[42],p=C1,e[43]!==u?(A=j1(u),e[43]=u,e[44]=A):A=e[44],P="MCP servers",x="w-[23rem]";const Q=M.length>0&&a.jsxs("span",{"aria-hidden":!0,className:"ml-1.5 font-normal normal-case tracking-normal",children:[L," on"]});let te;e[45]!==m||e[46]!==Q?(te=a.jsxs(ji,{id:m,className:"pt-1",children:["MCP servers",Q]}),e[45]=m,e[46]=Q,e[47]=te):te=e[47];const J=o&&M.length>1&&a.jsxs(a.Fragment,{children:[a.jsx(dv,{label:"Turn every server on",disabled:L===M.length,onClick:()=>o(M.map(X$)),children:"All"}),a.jsx(dv,{label:"Turn every server off",disabled:L===0,onClick:()=>o([]),children:"None"})]}),ne=l&&"animate-spin";let re;e[48]!==ne?(re=G(ne),e[48]=ne,e[49]=re):re=e[49];let le;e[50]!==re?(le=a.jsx(On,{className:re}),e[50]=re,e[51]=le):le=e[51];let ae;e[52]!==i||e[53]!==le?(ae=a.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:i,"aria-label":"Refresh status",title:"Refresh status",className:"text-muted-foreground",children:le}),e[52]=i,e[53]=le,e[54]=ae):ae=e[54];let ue;e[55]!==J||e[56]!==ae?(ue=a.jsxs("div",{className:"flex items-center gap-0.5",children:[J,ae]}),e[55]=J,e[56]=ae,e[57]=ue):ue=e[57],e[58]!==te||e[59]!==ue?(b=a.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 px-1.5 pt-1.5",children:[te,ue]}),e[58]=te,e[59]=ue,e[60]=b):b=e[60],e[61]!==d||e[62]!==t.length?(y=t.length>Z$&&a.jsx("div",{className:"shrink-0 px-1.5 pt-1",children:a.jsx("input",{type:"search",value:d,onChange:oe=>f(oe.target.value),placeholder:"Filter servers…","aria-label":"Filter servers",className:"h-7 w-full rounded-md bg-muted/60 px-2 text-xs text-foreground outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring/40 [&::-webkit-search-cancel-button]:hidden"})}),e[61]=d,e[62]=t.length,e[63]=y):y=e[63],g="group",_=m,N="flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto p-1.5",e[64]!==l||e[65]!==t.length?(S=t.length===0&&a.jsx("p",{className:"px-0.5 py-1 text-xs text-muted-foreground",children:l?"Loading…":"No MCP servers configured"}),e[64]=l,e[65]=t.length,e[66]=S):S=e[66],C=t.length>0&&H.length===0&&K.length===0&&a.jsx("p",{className:"px-0.5 py-1 text-xs text-muted-foreground",children:"No servers match."}),E=H.length>0&&a.jsx("div",{className:"grid grid-cols-2 gap-1",children:H.map(oe=>a.jsx(fv,{server:oe,on:W.has(oe.name),onClick:()=>r(oe.name)},oe.name))}),T=K.length>0&&a.jsxs(a.Fragment,{children:[a.jsx(ji,{className:"px-0.5 pt-2 text-warning/80",children:"Needs sign-in"}),a.jsx("div",{className:"grid grid-cols-2 gap-1",children:K.map(oe=>a.jsx(fv,{server:oe,onClick:()=>c(oe.name)},oe.name))})]}),e[0]=d,e[1]=u,e[2]=m,e[3]=l,e[4]=c,e[5]=i,e[6]=o,e[7]=r,e[8]=s,e[9]=t,e[10]=p,e[11]=h,e[12]=g,e[13]=x,e[14]=b,e[15]=y,e[16]=v,e[17]=k,e[18]=j,e[19]=_,e[20]=N,e[21]=S,e[22]=C,e[23]=E,e[24]=T,e[25]=A,e[26]=P}else p=e[10],h=e[11],g=e[12],x=e[13],b=e[14],y=e[15],v=e[16],k=e[17],j=e[18],_=e[19],N=e[20],S=e[21],C=e[22],E=e[23],T=e[24],A=e[25],P=e[26];let I;e[67]!==g||e[68]!==_||e[69]!==N||e[70]!==S||e[71]!==C||e[72]!==E||e[73]!==T?(I=a.jsxs("div",{role:g,"aria-labelledby":_,className:N,children:[S,C,E,T]}),e[67]=g,e[68]=_,e[69]=N,e[70]=S,e[71]=C,e[72]=E,e[73]=T,e[74]=I):I=e[74];let $;e[75]!==p||e[76]!==x||e[77]!==b||e[78]!==y||e[79]!==I||e[80]!==A||e[81]!==P?($=a.jsxs(p,{side:A,"aria-label":P,className:x,children:[b,y,I]}),e[75]=p,e[76]=x,e[77]=b,e[78]=y,e[79]=I,e[80]=A,e[81]=P,e[82]=$):$=e[82];let O;return e[83]!==h||e[84]!==v||e[85]!==k||e[86]!==j||e[87]!==$?(O=a.jsxs(h,{modal:v,onOpenChange:k,children:[j,$]}),e[83]=h,e[84]=v,e[85]=k,e[86]=j,e[87]=$,e[88]=O):O=e[88],O}function X$(n){return n.name}function J$(n){return n.status!=="connected"}function Q$(n){return n.status==="connected"}function dv(n){const e=q.c(5),{label:t,disabled:s,onClick:r,children:o}=n;let i;return e[0]!==o||e[1]!==s||e[2]!==t||e[3]!==r?(i=a.jsx(ee,{type:"button",variant:"ghost",size:"xs","aria-label":t,title:t,disabled:s,onClick:r,className:"h-6 px-1.5 text-[11px] text-muted-foreground",children:o}),e[0]=o,e[1]=s,e[2]=t,e[3]=r,e[4]=i):i=e[4],i}function fv(n){const e=q.c(34),{server:t,on:s,onClick:r}=n;let o;e[0]!==t.name?(o=fj(t.name),e[0]=t.name,e[1]=o):o=e[1];const{short:i,namespace:l}=o,c=s===void 0,u=c?void 0:"checkbox",d=c?void 0:s,f=c?`${t.name}, needs sign-in`:t.name,m=c?`${t.name} · Sign in to connect`:t.name,p=c&&"bg-warning/5 ring-warning/25 hover:bg-warning/10",h=s===!0&&"bg-accent text-accent-foreground ring-foreground/10",g=s===!1&&"text-muted-foreground ring-transparent hover:bg-accent/60 hover:text-foreground";let x;e[2]!==p||e[3]!==h||e[4]!==g?(x=G("flex min-w-0 items-center gap-2 rounded-lg px-2 py-1.5 text-left text-sm outline-none ring-1 ring-inset transition-[background-color,box-shadow,color] duration-100 focus-visible:ring-2 focus-visible:ring-ring/40",p,h,g),e[2]=p,e[3]=h,e[4]=g,e[5]=x):x=e[5];const b=c&&"bg-warning/15 text-warning",y=s===!0&&"bg-primary text-primary-foreground",v=s===!1&&"bg-muted text-muted-foreground";let k;e[6]!==b||e[7]!==y||e[8]!==v?(k=G("flex size-6 shrink-0 items-center justify-center rounded-md text-[10px] font-semibold tracking-wide transition-colors duration-100",b,y,v),e[6]=b,e[7]=y,e[8]=v,e[9]=k):k=e[9];let j;e[10]!==t.name?(j=K$(t.name),e[10]=t.name,e[11]=j):j=e[11];let _;e[12]!==k||e[13]!==j?(_=a.jsx("span",{"aria-hidden":!0,className:k,children:j}),e[12]=k,e[13]=j,e[14]=_):_=e[14];let N;e[15]!==i?(N=a.jsx("span",{className:"truncate leading-4",children:i}),e[15]=i,e[16]=N):N=e[16];let S;e[17]!==l?(S=l&&a.jsx("span",{className:"truncate text-[10px] leading-3 text-muted-foreground",children:l}),e[17]=l,e[18]=S):S=e[18];let C;e[19]!==N||e[20]!==S?(C=a.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[N,S]}),e[19]=N,e[20]=S,e[21]=C):C=e[21];let E;e[22]!==c?(E=c&&a.jsx(zA,{className:"size-3.5 shrink-0 text-warning","aria-hidden":!0}),e[22]=c,e[23]=E):E=e[23];let T;return e[24]!==r||e[25]!==_||e[26]!==C||e[27]!==E||e[28]!==u||e[29]!==d||e[30]!==f||e[31]!==m||e[32]!==x?(T=a.jsxs("button",{type:"button",role:u,"aria-checked":d,"aria-label":f,title:m,onClick:r,className:x,children:[_,C,E]}),e[24]=r,e[25]=_,e[26]=C,e[27]=E,e[28]=u,e[29]=d,e[30]=f,e[31]=m,e[32]=x,e[33]=T):T=e[33],T}function eR(n,e){var i;const{defaultLimit:t,limits:s,extendedContext:r}=us(e).contextWindow,o=n.trim().toLowerCase();return r&&o.includes(r.marker)?r.limit:((i=s.find(l=>o.includes(l.match)))==null?void 0:i.limit)??t}function tR(n,e,t){const s=typeof n.input_tokens=="number"?n.input_tokens:0,r=typeof n.cache_creation_input_tokens=="number"?n.cache_creation_input_tokens:0,o=typeof n.cache_read_input_tokens=="number"?n.cache_read_input_tokens:0,i=s+r+o,l=eR(e,t),c=l-us(t).contextWindow.compactBuffer;return{used:i,limit:l,compactAt:c,percent:Math.min(100,i/c*100),percentAbsolute:Math.min(100,i/l*100)}}const nR=["fable","mythos","opus","sonnet","haiku"];function mv(n){return n.charAt(0).toUpperCase()+n.slice(1)}function Zo(n){if(!n)return"unknown";const e=n.toLowerCase(),t=/\[1m\]$/.test(e)?" 1M":"",s=e.replace(/\[[^\]]*\]$/,"");for(const r of nR){const o=s.match(new RegExp(`${r}(?:-(\\d+)(?:-(\\d{1,2}))?(?!\\d))?`));if(!o)continue;const i=o[1]?` ${o[1]}${o[2]?`.${o[2]}`:""}`:"";return`${mv(r)}${i}${t}`}if(s.startsWith("gpt-")){const[r,...o]=s.slice(4).split("-"),i=o.map(mv).join(" ");return`GPT-${r}${i?` ${i}`:""}${t}`}return n.length>20?n.slice(0,20)+"...":n}function sR(n){return n.split("/").map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("[\\\\/]")}const rR=new RegExp(`[\\\\/](?:${[...Fl().map(n=>n.projectWorktreeDir),".worktrees"].filter(n=>n!==null).map(sR).join("|")})[\\\\/]([^\\\\/]+)`);function nr(n){const e=rR.exec(n);return e?{parentPath:n.slice(0,e.index),worktreeName:e[1]}:null}function Ige(n,e){return e===`worktree-${n}`}function ms(n){return Number.isFinite(n)?n<.01?`$${n.toFixed(4)}`:n<1?`$${n.toFixed(3)}`:`$${n.toFixed(2)}`:"—"}function Nt(n){return n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}k`:String(n)}function sr(n){if(n<1e3)return`${n}ms`;const e=Math.round(n/1e3);if(e<60)return`${e}s`;const t=Math.floor(e/60),s=e%60;return t>=60?`${Math.floor(t/60)}h ${t%60}m`:`${t}m ${s}s`}function oR(n){if(n<60)return`${n}s`;const e=Math.floor(n/60),t=n%60;return`${e}m ${t}s`}function mj(n){return n>=1e6?`${(n/1e6).toFixed(1)}MB`:n>=1e3?`${(n/1e3).toFixed(0)}KB`:`${n}B`}function Yo(n){const e=Date.now()-new Date(n).getTime(),t=Math.floor(e/6e4);if(t<1)return"now";if(t<60)return`${t}m`;const s=Math.floor(t/60);if(s<24)return`${s}h`;const r=Math.floor(s/24);return r<7?`${r}d`:new Date(n).toLocaleDateString()}function E1(n){return n>=86400?`${Math.floor(n/86400)}d ${Math.floor(n%86400/3600)}h`:n>=3600?`${Math.floor(n/3600)}h ${Math.floor(n%3600/60)}m`:`${Math.max(1,Math.floor(n/60))}m`}function T1(n){if(n.durationMs!==null)return n.durationMs;if(!n.timestamp)return null;let e=0,t=n.timestamp,s="";const r=i=>{i&&i>s&&(s=i)},o=()=>{if(!s)return;const i=new Date(s).getTime()-new Date(t).getTime();i>0&&(e+=i),s=""};for(const i of n.contentBlocks){if(i.kind==="task_notification"){o(),i.timestamp&&(t=i.timestamp);continue}if(r(i.timestamp),i.kind==="tool_calls"||i.kind==="plan_mode")for(const l of i.toolCalls)r(l.timestamp)}return o(),e>0?e:null}function Is(n,e){return n.length<=e?n:n.slice(0,e)+"..."}function ls(n){return Ss(n).dirName.decode(n)??n}function ql(n,e=2){const t=n.replace(/\/+$/,"").split("/").filter(Boolean);return t.length<=e?n:t.slice(-e).join("/")}function rr(n){return n.replace(/\/+$/,"").split("/").at(-1)??n}function lo(n){const e=n.match(/^([^/]+)\/subagents\/agent-([^.]+)\.jsonl$/);return e?{parentSessionId:e[1],agentId:e[2],parentFileName:`${e[1]}.jsonl`}:null}function pj(n){for(let e=n.length-1;e>=0;e--){const t=n[e];if(t.type==="assistant")return tR(t.message.usage,t.message.model??"","claude")}return null}const wu=[27e4,5e5,1e6];function pv(n){return wu.includes(n)?Nt(n).replace(/\.0(?=[kM]$)/,""):n.toLocaleString("en-US")}function hj(n){const e=q.c(12),{value:t,onChange:s}=n;let r;e[0]!==t?(r=t===null?"Default":pv(t),e[0]=t,e[1]=r):r=e[1];const o=r,i=wu[(wu.indexOf(t??0)+1)%wu.length],l=`Context window: ${o}`;let c;e[2]!==i?(c=pv(i),e[2]=i,e[3]=c):c=e[3];const u=`Context window: ${o}. Click to use ${c} next turn. Models with long-context pricing charge higher rates above 272k input tokens. This is not a hard billing cap.`;let d;e[4]!==i||e[5]!==s?(d=()=>s(i),e[4]=i,e[5]=s,e[6]=d):d=e[6];let f;return e[7]!==o||e[8]!==l||e[9]!==u||e[10]!==d?(f=a.jsx(ee,{type:"button",variant:"ghost",size:"xs",className:"h-6 shrink-0 tabular-nums","aria-label":l,title:u,onClick:d,children:o}),e[7]=o,e[8]=l,e[9]=u,e[10]=d,e[11]=f):f=e[11],f}const gj=Lr("group/toggle inline-flex items-center justify-center gap-1 rounded-lg text-sm font-medium whitespace-nowrap outline-none transition-[color,background-color,border-color,box-shadow,transform,scale] duration-100 ease-out hover:bg-muted hover:text-foreground active:scale-[0.96] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-pressed:bg-muted motion-reduce:transition-none motion-reduce:active:scale-100 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-muted"},size:{default:"h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",sm:"h-7 min-w-7 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2"}},defaultVariants:{variant:"default",size:"default"}});function iR(n){const e=q.c(12);let t,s,r,o;e[0]!==n?({className:t,variant:r,size:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o):(t=e[1],s=e[2],r=e[3],o=e[4]);const i=r===void 0?"default":r,l=o===void 0?"default":o;let c;e[5]!==t||e[6]!==l||e[7]!==i?(c=G(gj({variant:i,size:l,className:t})),e[5]=t,e[6]=l,e[7]=i,e[8]=c):c=e[8];let u;return e[9]!==s||e[10]!==c?(u=a.jsx(a3,{"data-slot":"toggle",className:c,...s}),e[9]=s,e[10]=c,e[11]=u):u=e[11],u}function aR(n){const e=q.c(34),{options:t,value:s,onChange:r,disabled:o,labelId:i}=n,l=t.length-1;let c;if(e[0]!==t||e[1]!==s){let v;e[3]!==s?(v=k=>k.value===s,e[3]=s,e[4]=v):v=e[4],c=t.findIndex(v),e[0]=t,e[1]=s,e[2]=c}else c=e[2];const u=Math.max(0,c);let d;e[5]!==r||e[6]!==t||e[7]!==s?(d=v=>{const k=t[v];k&&k.value!==s&&r(k.value)},e[5]=r,e[6]=t,e[7]=s,e[8]=d):d=e[8];const f=o&&"opacity-50";let m;e[9]!==f?(m=G("w-full",f),e[9]=f,e[10]=m):m=e[10];let p;e[11]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsx(DA,{className:"rounded-full bg-primary"}),e[11]=p):p=e[11];let h;if(e[12]!==u||e[13]!==l||e[14]!==t){let v;e[16]!==u||e[17]!==l?(v=(k,j)=>a.jsx("span",{"aria-hidden":!0,className:G("pointer-events-none absolute top-1/2 size-1.5 -translate-x-1/2 -translate-y-1/2 rounded-full transition-colors duration-150",j<=u?"bg-primary":"bg-muted-foreground/40"),style:{left:l===0?"50%":`${j/l*100}%`}},k.value),e[16]=u,e[17]=l,e[18]=v):v=e[18],h=t.map(v),e[12]=u,e[13]=l,e[14]=t,e[15]=h}else h=e[15];let g;e[19]!==t?(g=(v,k)=>{var j;return((j=t[k])==null?void 0:j.label)??""},e[19]=t,e[20]=g):g=e[20];let x;e[21]!==i||e[22]!==g?(x=a.jsx(FA,{"aria-labelledby":i,getAriaValueText:g,className:"size-3.5 rounded-full bg-primary shadow-[0_0_0_3px_var(--popover)] outline-none transition-transform duration-100 has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-ring/50 has-[:focus-visible]:ring-offset-2 has-[:focus-visible]:ring-offset-popover data-dragging:scale-125 motion-reduce:transition-none"}),e[21]=i,e[22]=g,e[23]=x):x=e[23];let b;e[24]!==h||e[25]!==x?(b=a.jsx(UA,{className:"flex h-6 w-full touch-none select-none items-center px-1.5",children:a.jsxs(BA,{className:"relative h-1 w-full rounded-full bg-muted-foreground/20",children:[p,h,x]})}),e[24]=h,e[25]=x,e[26]=b):b=e[26];let y;return e[27]!==o||e[28]!==u||e[29]!==l||e[30]!==d||e[31]!==m||e[32]!==b?(y=a.jsx(WA,{value:u,min:0,max:l,step:1,disabled:o,onValueChange:d,className:m,children:b}),e[27]=o,e[28]=u,e[29]=l,e[30]=d,e[31]=m,e[32]=b,e[33]=y):y=e[33],y}function xj(n,e){const t=w.forwardRef(function(r,o){const i=q.c(4);let l;i[0]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx("path",{d:e}),i[0]=l):l=i[0];let c;return i[1]!==r||i[2]!==o?(c=a.jsx("svg",{ref:o,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:24,height:24,fill:"currentColor","aria-hidden":!0,...r,children:l}),i[1]=r,i[2]=o,i[3]=c):c=i[3],c});return t.displayName=n,t}const lR=xj("AnthropicIcon","M17.3041 3.541h-3.6718l6.696 16.918H24Zm-10.6082 0L0 20.459h3.7442l1.3693-3.5527h7.0052l1.3693 3.5528h3.7442L10.1256 3.5409Zm-.3712 10.2232 2.2914-5.9456 2.2914 5.9456Z"),cR=xj("OpenAIIcon","M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z"),bj={claude:lR,codex:cR,copilot:l3},A1={claude:"Claude",codex:"Codex",copilot:"Copilot"},uR={claude:"Claude",codex:"Codex",copilot:"GitHub Copilot"},dR={claude:null,codex:"Codex",copilot:"Copilot"},fR={claude:{letter:"C",label:"Loaded by Claude Code"},codex:{letter:"X",label:"Loaded by Codex CLI"},copilot:{letter:"G",label:"Loaded by GitHub Copilot CLI"}},mR={claude:"var(--chart-1)",codex:"var(--chart-2)",copilot:"var(--chart-3)"},pR={claude:"Interrupt agent",codex:"Stop active turn",copilot:"Stop Copilot turn"},hR={claude:[{value:"default",label:"Ask",description:"Ask before sensitive actions"},{value:"plan",label:"Plan",description:"Read and plan without changing files"},{value:"acceptEdits",label:"Accept Edits",description:"Allow file edits; ask for other actions"},{value:"auto",label:"Auto",description:"Run autonomously with classifier safeguards"},{value:"dontAsk",label:"Don't Ask",description:"Deny actions that need approval"},{value:"bypassPermissions",label:"Full access",description:"Skip permission checks"}],codex:[{value:"default",label:"Workspace",description:"Write inside the project sandbox"},{value:"plan",label:"Read only",description:"Inspect and plan without writing"},{value:"auto",label:"Auto review",description:"Review approval requests automatically, with the workspace sandbox"},{value:"bypassPermissions",label:"Full access",description:"No sandbox or approval checks"}],copilot:[{value:"default",label:"Ask",description:"Ask before running tools or changing files"},{value:"plan",label:"Plan",description:"Explore and plan without changing project files"},{value:"auto",label:"Autopilot",description:"Implement autonomously until the task is complete"},{value:"bypassPermissions",label:"Full access",description:"Allow tools, paths, and URLs without asking"}]};function gR(n){return hR[n]}function xR(n){return bj[n]}function Hd(n){return A1[n]}function bR(n){return uR[n]}function vR(n){return dR[n]}function $ge(n){return fR[n]}function yR(n){return pR[n]}function wR(n){return mR[n]}const hv=Ss(null).kind,vj=[hv,...ao.filter(n=>n!==hv)];function SR(n){return`This ${A1[n]} session is controlled by another process. Cogpit can only view it.`}const Oh=vj.map(n=>({value:n,label:A1[n],Icon:bj[n]}));function kR(n,e){const t=e==null?void 0:e.filter(s=>s.value!=="");return(t==null?void 0:t.find(s=>s.value===n))??(t==null?void 0:t.find(s=>s.resolvedModel===n))}function jR(n){var t;const e=(t=n.find(s=>s.value===""))==null?void 0:t.resolvedModel;return e?P1(e,n):"Default"}function P1(n,e){var t;return((t=kR(n,e))==null?void 0:t.label)??Zo(n)}function NR(n){var Se;const e=q.c(112),{agentKind:t,onAgentKindChange:s,selectedModel:r,resolvedDefaultName:o,modelOptions:i,onModelChange:l,selectedEffort:c,effortOptions:u,onEffortChange:d,contextWindowTokens:f,onContextWindowTokensChange:m,fastTier:p,fastModeEnabled:h,onFastModeEnabledChange:g,ultracodeEnabled:x,onUltracodeEnabledChange:b,isNewSession:y}=n,v=h===void 0?!1:h,k=x===void 0?!1:x;let j;e[0]!==t?(j=xn(t),e[0]=t,e[1]=j):j=e[1];const _=j;let N;e[2]!==t?(N=Oh.find(Ne=>Ne.value===t),e[2]=t,e[3]=N):N=e[3];const S=N,C=S==null?void 0:S.Icon,E=(S==null?void 0:S.label)??t;let T;e[4]!==i||e[5]!==o||e[6]!==r?(T=((Se=i.find(Ne=>Ne.value===r))==null?void 0:Se.label)??o,e[4]=i,e[5]=o,e[6]=r,e[7]=T):T=e[7];const A=T;let P;if(e[8]!==u||e[9]!==c){let Ne;e[11]!==c?(Ne=He=>He.value===c,e[11]=c,e[12]=Ne):Ne=e[12],P=u.find(Ne),e[8]=u,e[9]=c,e[10]=P}else P=e[10];const I=P,$=!s,O=_.reasoningEffort,M=_.configurableContextWindow&&!!m,R=_.fastTier,z=_.ultracode,W=!!p&&!!g,D=!!b,L=v&&W,U=k&&D,F=U?"Pinned by Ultracode":I==null?void 0:I.description,B=I==null?void 0:I.label;let V;e[13]!==A||e[14]!==E||e[15]!==B?(V=[E,A,B].filter(Boolean),e[13]=A,e[14]=E,e[15]=B,e[16]=V):V=e[16];const H=V.join(" · "),K=L?"Fast mode on":null,Z=U?"Ultracode on":null;let Y;e[17]!==Z||e[18]!==K?(Y=[K,Z].filter(Boolean),e[17]=Z,e[18]=K,e[19]=Y):Y=e[19];const X=Y.join(", "),se=w.useId(),Q=w.useId(),te=w.useId(),J=X?`${H} (${X})`:H,ne=X?`${H} · ${X}`:void 0;let re;e[20]!==J||e[21]!==ne?(re=a.jsx(N1,{"aria-label":J,title:ne}),e[20]=J,e[21]=ne,e[22]=re):re=e[22];let le;e[23]!==C?(le=C&&a.jsx(C,{"data-icon":"inline-start"}),e[23]=C,e[24]=le):le=e[24];let ae;e[25]!==A?(ae=a.jsx("span",{className:"truncate",children:A}),e[25]=A,e[26]=ae):ae=e[26];let ue;e[27]!==I?(ue=I&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-muted-foreground/60","aria-hidden":!0,children:"·"}),a.jsx("span",{className:"shrink-0 text-muted-foreground",children:I.label})]}),e[27]=I,e[28]=ue):ue=e[28];let oe;e[29]!==ae||e[30]!==ue?(oe=a.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[ae,ue]}),e[29]=ae,e[30]=ue,e[31]=oe):oe=e[31];let ie;e[32]!==L?(ie=L&&a.jsx(Bu,{className:"size-3 shrink-0 fill-current","aria-hidden":!0}),e[32]=L,e[33]=ie):ie=e[33];let fe;e[34]!==U?(fe=U&&a.jsx(ll,{className:"size-3 shrink-0 fill-current","aria-hidden":!0}),e[34]=U,e[35]=fe):fe=e[35];let de;e[36]!==re||e[37]!==le||e[38]!==oe||e[39]!==ie||e[40]!==fe?(de=a.jsxs(Wl,{render:re,children:[le,oe,ie,fe]}),e[36]=re,e[37]=le,e[38]=oe,e[39]=ie,e[40]=fe,e[41]=de):de=e[41];let ce;e[42]!==y?(ce=j1(y),e[42]=y,e[43]=ce):ce=e[43];let xe;e[44]!==se?(xe=a.jsx(ji,{id:se,children:"Provider"}),e[44]=se,e[45]=xe):xe=e[45];let pe;e[46]!==s?(pe=Ne=>s==null?void 0:s(Ne),e[46]=s,e[47]=pe):pe=e[47];let he;e[48]!==t||e[49]!==$?(he=Oh.map(Ne=>a.jsx(_1,{value:Ne.value,title:Ne.label,icon:Ne.Icon,disabled:$&&Ne.value!==t},Ne.value)),e[48]=t,e[49]=$,e[50]=he):he=e[50];let ye;e[51]!==t||e[52]!==se||e[53]!==pe||e[54]!==he?(ye=a.jsx(Rh,{value:t,onValueChange:pe,"aria-labelledby":se,children:he}),e[51]=t,e[52]=se,e[53]=pe,e[54]=he,e[55]=ye):ye=e[55];let ve;e[56]!==y||e[57]!==$?(ve=$&&!y&&a.jsx("p",{className:"mt-auto px-2 pb-1 pt-3 text-[11px] leading-4 text-muted-foreground",children:"Fixed for this session. Start a new one to switch."}),e[56]=y,e[57]=$,e[58]=ve):ve=e[58];let ke;e[59]!==xe||e[60]!==ye||e[61]!==ve?(ke=a.jsxs("div",{className:"flex min-h-0 flex-col overflow-y-auto border-r bg-muted/30 p-1.5",children:[xe,ye,ve]}),e[59]=xe,e[60]=ye,e[61]=ve,e[62]=ke):ke=e[62];let je;e[63]!==Q?(je=a.jsx(ji,{id:Q,children:"Model"}),e[63]=Q,e[64]=je):je=e[64];let Me;e[65]!==f||e[66]!==W||e[67]!==L||e[68]!==(p==null?void 0:p.description)||e[69]!==A||e[70]!==m||e[71]!==g||e[72]!==b||e[73]!==M||e[74]!==R||e[75]!==z||e[76]!==D||e[77]!==U?(Me=(M||R||z)&&a.jsxs("div",{className:"flex items-center gap-1",children:[M&&a.jsx(hj,{value:f??null,onChange:m}),R&&a.jsx(gv,{label:"Fast mode",pressed:L,onPressedChange:Ne=>g==null?void 0:g(Ne),disabled:!W,title:W?`Fast mode · ${(p==null?void 0:p.description)??"Lower latency with increased usage"}`:`Fast mode isn't offered for ${A}`,children:a.jsx(Bu,{className:G(L&&"fill-current")})}),z&&a.jsxs(gv,{label:"Ultracode",pressed:U,onPressedChange:Ne=>b==null?void 0:b(Ne),disabled:!D,title:D?"Ultracode · Extra High effort with standing multi-agent orchestration":`Ultracode isn't available for ${A}`,children:[a.jsx(ll,{className:G(U&&"fill-current")}),"Ultracode"]})]}),e[65]=f,e[66]=W,e[67]=L,e[68]=p==null?void 0:p.description,e[69]=A,e[70]=m,e[71]=g,e[72]=b,e[73]=M,e[74]=R,e[75]=z,e[76]=D,e[77]=U,e[78]=Me):Me=e[78];let _e;e[79]!==je||e[80]!==Me?(_e=a.jsxs("div",{className:"flex items-center justify-between gap-2 pr-0.5",children:[je,Me]}),e[79]=je,e[80]=Me,e[81]=_e):_e=e[81];let Fe;e[82]!==i?(Fe=i.map(CR),e[82]=i,e[83]=Fe):Fe=e[83];let ze;e[84]!==Q||e[85]!==l||e[86]!==r||e[87]!==Fe?(ze=a.jsx(Rh,{value:r,onValueChange:l,"aria-labelledby":Q,className:"max-h-56 min-h-0 flex-1 overflow-y-auto",children:Fe}),e[84]=Q,e[85]=l,e[86]=r,e[87]=Fe,e[88]=ze):ze=e[88];let We;e[89]!==_e||e[90]!==ze?(We=a.jsxs("div",{className:"flex min-h-0 flex-col p-1.5",children:[_e,ze]}),e[89]=_e,e[90]=ze,e[91]=We):We=e[91];let Pe;e[92]!==ke||e[93]!==We?(Pe=a.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-[10.5rem_minmax(0,1fr)] overflow-hidden",children:[ke,We]}),e[92]=ke,e[93]=We,e[94]=Pe):Pe=e[94];let qe;e[95]!==F||e[96]!==te||e[97]!==u||e[98]!==A||e[99]!==d||e[100]!==c||e[101]!==I||e[102]!==O||e[103]!==U?(qe=O&&a.jsxs("div",{className:"shrink-0 border-t px-2 pb-1.5 pt-2",children:[a.jsxs("div",{className:"flex items-baseline justify-between gap-3 px-1.5",children:[a.jsxs(ji,{id:te,className:"flex items-baseline gap-1.5 p-0",children:["Reasoning",I&&a.jsx("span",{className:"text-xs font-medium normal-case tracking-normal text-foreground motion-safe:animate-in motion-safe:fade-in-0 motion-safe:duration-200",children:I.label},I.value)]}),F&&a.jsx("span",{className:"truncate text-[11px] leading-4 text-muted-foreground",children:F})]}),u.length>0?a.jsx(aR,{options:u,value:c,onChange:d,disabled:U,labelId:te}):a.jsxs("p",{className:"px-1.5 pb-1 text-xs leading-5 text-muted-foreground",children:["Not adjustable for ",A,"."]})]}),e[95]=F,e[96]=te,e[97]=u,e[98]=A,e[99]=d,e[100]=c,e[101]=I,e[102]=O,e[103]=U,e[104]=qe):qe=e[104];let be;e[105]!==ce||e[106]!==Pe||e[107]!==qe?(be=a.jsxs(C1,{side:ce,align:"end","aria-label":"Model settings",className:"w-[34rem] max-w-[calc(100vw-1.5rem)]",children:[Pe,qe]}),e[105]=ce,e[106]=Pe,e[107]=qe,e[108]=be):be=e[108];let Ie;return e[109]!==de||e[110]!==be?(Ie=a.jsxs(Bl,{modal:!1,onOpenChange:_R,children:[de,be]}),e[109]=de,e[110]=be,e[111]=Ie):Ie=e[111],Ie}function CR(n){return a.jsx(_1,{value:n.value,title:n.menuLabel??n.label,description:n.description},n.value)}function _R(n){n&&S1()}function gv(n){const e=q.c(7),{label:t,pressed:s,onPressedChange:r,disabled:o,title:i,children:l}=n;let c;return e[0]!==l||e[1]!==o||e[2]!==t||e[3]!==r||e[4]!==s||e[5]!==i?(c=a.jsx(iR,{variant:"outline",size:"sm",pressed:s,onPressedChange:r,disabled:o,"aria-label":t,title:i,className:"h-6 gap-1 px-1.5 text-xs text-muted-foreground data-pressed:bg-primary data-pressed:text-primary-foreground data-pressed:hover:bg-primary/90 [&_svg:not([class*='size-'])]:size-3.5",children:l}),e[0]=l,e[1]=o,e[2]=t,e[3]=r,e[4]=s,e[5]=i,e[6]=c):c=e[6],c}function yj(n,e){return gR(n).filter(t=>t.value!=="auto"||e)}function ER(n){const e=q.c(22),{agentKind:t,mode:s,onChange:r,autoAvailable:o,isNewSession:i}=n,l=o===void 0?!1:o,[c,u]=w.useState(!1),d=yj(t,l),f=d.find(A=>A.value===s)??d[0],m=w.useId(),p=`Permissions: ${f.label}`;let h;e[0]!==p?(h=a.jsx(N1,{"aria-label":p}),e[0]=p,e[1]=h):h=e[1];let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=a.jsx(c3,{"data-icon":"inline-start"}),e[2]=g):g=e[2];const x=C1;let b;e[3]!==i?(b=j1(i),e[3]=i,e[4]=b):b=e[4];const y="Permissions",v="w-80",k="p-1.5";let j;e[5]!==m?(j=a.jsx(ji,{id:m,children:"Permissions"}),e[5]=m,e[6]=j):j=e[6];const _=Rh;let N;e[7]!==r?(N=A=>{r(A),u(!1)},e[7]=r,e[8]=N):N=e[8];const S=d.map(TR);let C;e[9]!==_||e[10]!==m||e[11]!==s||e[12]!==N||e[13]!==S?(C=a.jsx(_,{value:s,onValueChange:N,"aria-labelledby":m,children:S}),e[9]=_,e[10]=m,e[11]=s,e[12]=N,e[13]=S,e[14]=C):C=e[14];let E;e[15]!==C||e[16]!==j?(E=a.jsxs("div",{className:k,children:[j,C]}),e[15]=C,e[16]=j,e[17]=E):E=e[17];let T;return e[18]!==x||e[19]!==E||e[20]!==b?(T=a.jsx(x,{side:b,"aria-label":y,className:v,children:E}),e[18]=x,e[19]=E,e[20]=b,e[21]=T):T=e[21],a.jsxs(Bl,{modal:!1,open:c,onOpenChange:u,children:[a.jsxs(Wl,{render:h,children:[g,a.jsx("span",{className:"truncate",children:f.label})]}),T]})}function TR(n){return a.jsx(_1,{value:n.value,title:n.label,description:n.description},n.value)}function AR(n){const e=q.c(56),{agentKind:t,onAgentKindChange:s,selectedModel:r,resolvedDefaultName:o,modelOptions:i,onModelChange:l,selectedEffort:c,effortOptions:u,onEffortChange:d,contextWindowTokens:f,onContextWindowTokensChange:m,fastTier:p,fastModeEnabled:h,onFastModeEnabledChange:g,isNewSession:x,worktreeEnabled:b,onWorktreeEnabledChange:y,ultracodeEnabled:v,onUltracodeEnabledChange:k,autoModeAvailable:j,permissionMode:_,onPermissionModeChange:N,mcpServers:S,selectedMcpServers:C,onToggleMcpServer:E,onSetMcpServers:T,onRefreshMcpServers:A,mcpLoading:P,onMcpAuth:I,changeAndApply:$,trailingExtra:O}=n;let M;e[0]!==t?(M=xn(t),e[0]=t,e[1]=M):M=e[1];const{worktrees:R}=M;let z;e[2]!==t||e[3]!==j||e[4]!==$||e[5]!==x||e[6]!==N||e[7]!==_?(z=N&&_&&a.jsx(ER,{agentKind:t,mode:_,onChange:H=>$(()=>N(H)),autoAvailable:j,isNewSession:x}),e[2]=t,e[3]=j,e[4]=$,e[5]=x,e[6]=N,e[7]=_,e[8]=z):z=e[8];let W;e[9]!==x||e[10]!==y||e[11]!==R||e[12]!==b?(W=R&&x&&y&&a.jsxs(ee,{type:"button",variant:b?"secondary":"ghost",size:"xs","aria-pressed":!!b,onClick:()=>y(!b),children:[a.jsx(_r,{"data-icon":"inline-start"}),"Worktree"]}),e[9]=x,e[10]=y,e[11]=R,e[12]=b,e[13]=W):W=e[13];let D;e[14]!==$||e[15]!==x||e[16]!==P||e[17]!==S||e[18]!==I||e[19]!==A||e[20]!==T||e[21]!==E||e[22]!==C?(D=E&&A&&I&&(P||S&&S.length>0)&&a.jsx(Y$,{servers:S??[],selected:C??[],onToggle:H=>$(()=>E(H)),onSetSelection:T?H=>$(()=>T(H)):void 0,onRefresh:A,loading:P??!1,onAuth:I,isNewSession:x}),e[14]=$,e[15]=x,e[16]=P,e[17]=S,e[18]=I,e[19]=A,e[20]=T,e[21]=E,e[22]=C,e[23]=D):D=e[23];let L;e[24]!==z||e[25]!==W||e[26]!==D||e[27]!==O?(L=a.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1",children:[z,W,D,O]}),e[24]=z,e[25]=W,e[26]=D,e[27]=O,e[28]=L):L=e[28];let U;e[29]!==$||e[30]!==g?(U=g?H=>$(()=>g(H)):void 0,e[29]=$,e[30]=g,e[31]=U):U=e[31];let F;e[32]!==$||e[33]!==k?(F=k?H=>$(()=>k(H)):void 0,e[32]=$,e[33]=k,e[34]=F):F=e[34];let B;e[35]!==t||e[36]!==f||e[37]!==u||e[38]!==h||e[39]!==p||e[40]!==x||e[41]!==i||e[42]!==s||e[43]!==m||e[44]!==d||e[45]!==l||e[46]!==o||e[47]!==c||e[48]!==r||e[49]!==U||e[50]!==F||e[51]!==v?(B=a.jsx(NR,{agentKind:t,onAgentKindChange:s,selectedModel:r,resolvedDefaultName:o,modelOptions:i,onModelChange:l,selectedEffort:c,effortOptions:u,onEffortChange:d,contextWindowTokens:f,onContextWindowTokensChange:m,fastTier:p,fastModeEnabled:h,onFastModeEnabledChange:U,ultracodeEnabled:v,onUltracodeEnabledChange:F,isNewSession:x}),e[35]=t,e[36]=f,e[37]=u,e[38]=h,e[39]=p,e[40]=x,e[41]=i,e[42]=s,e[43]=m,e[44]=d,e[45]=l,e[46]=o,e[47]=c,e[48]=r,e[49]=U,e[50]=F,e[51]=v,e[52]=B):B=e[52];let V;return e[53]!==L||e[54]!==B?(V=a.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1",role:"group","aria-label":"Session settings",children:[L,B]}),e[53]=L,e[54]=B,e[55]=V):V=e[55],V}function Gt(n){const e=q.c(10);let t,s,r;e[0]!==n?({className:t,orientation:r,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);const o=r===void 0?"horizontal":r;let i;e[4]!==t?(i=G("shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-px data-[orientation=vertical]:self-stretch",t),e[4]=t,e[5]=i):i=e[5];let l;return e[6]!==o||e[7]!==s||e[8]!==i?(l=a.jsx(Kg,{"data-slot":"separator",orientation:o,className:i,...s}),e[6]=o,e[7]=s,e[8]=i,e[9]=l):l=e[9],l}function PR(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("label",{"data-slot":"label",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function IR(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex flex-col gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("fieldset",{"data-slot":"field-set",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function $R(n){const e=q.c(10);let t,s,r;e[0]!==n?({className:t,variant:r,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);const o=r===void 0?"legend":r;let i;e[4]!==t?(i=G("mb-1.5 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base",t),e[4]=t,e[5]=i):i=e[5];let l;return e[6]!==s||e[7]!==i||e[8]!==o?(l=a.jsx("legend",{"data-slot":"field-legend","data-variant":o,className:i,...s}),e[6]=s,e[7]=i,e[8]=o,e[9]=l):l=e[9],l}function Vl(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("group/field-group @container/field-group flex w-full flex-col gap-5 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"field-group",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}const RR=Lr("group/field flex w-full gap-2 data-[invalid=true]:text-destructive",{variants:{orientation:{vertical:"flex-col *:w-full [&>.sr-only]:w-auto",horizontal:"flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",responsive:"flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"}},defaultVariants:{orientation:"vertical"}});function un(n){const e=q.c(11);let t,s,r;e[0]!==n?({className:t,orientation:r,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);const o=r===void 0?"vertical":r;let i;e[4]!==t||e[5]!==o?(i=G(RR({orientation:o}),t),e[4]=t,e[5]=o,e[6]=i):i=e[6];let l;return e[7]!==o||e[8]!==s||e[9]!==i?(l=a.jsx("div",{role:"group","data-slot":"field","data-orientation":o,className:i,...s}),e[7]=o,e[8]=s,e[9]=i,e[10]=l):l=e[10],l}function Rge(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("group/field-content flex flex-1 flex-col gap-0.5 leading-snug",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"field-content",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function dn(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border has-[>[data-slot=field]]:not-has-[:disabled,[data-disabled]]:hover:bg-muted/50 has-[>[data-slot=field]]:has-[:focus-visible]:border-ring has-[>[data-slot=field]]:has-[:focus-visible]:ring-3 has-[>[data-slot=field]]:has-[:focus-visible]:ring-ring/50 *:data-[slot=field]:p-2.5 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10","has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(PR,{"data-slot":"field-label",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Zu(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-left text-sm leading-normal font-normal text-muted-foreground group-data-[orientation=horizontal]/field:text-balance [[data-variant=legend]+&]:-mt-1.5","last:mt-0 nth-last-2:-mt-1","[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("p",{"data-slot":"field-description",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function to(n){var d;const e=q.c(15);let t,s,r,o;e[0]!==n?({className:s,children:t,errors:r,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o):(t=e[1],s=e[2],r=e[3],o=e[4]);let i;e:{if(t){i=t;break e}if(!(r!=null&&r.length)){i=null;break e}let f;e[5]!==r?(f=[...new Map(r.map(LR)).values()],e[5]=r,e[6]=f):f=e[6];const m=f;if((m==null?void 0:m.length)==1){i=(d=m[0])==null?void 0:d.message;break e}let p;e[7]!==m?(p=a.jsx("ul",{className:"ml-4 flex list-disc flex-col gap-1",children:m.map(OR)}),e[7]=m,e[8]=p):p=e[8],i=p}const l=i;if(!l)return null;let c;e[9]!==s?(c=G("text-sm font-normal text-destructive",s),e[9]=s,e[10]=c):c=e[10];let u;return e[11]!==l||e[12]!==o||e[13]!==c?(u=a.jsx("div",{role:"alert","data-slot":"field-error",className:c,...o,children:l}),e[11]=l,e[12]=o,e[13]=c,e[14]=u):u=e[14],u}function OR(n,e){return(n==null?void 0:n.message)&&a.jsx("li",{children:n.message},e)}function LR(n){return[n==null?void 0:n.message,n]}const MR=KA;function zR(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("scroll-my-1 p-1",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(VA,{"data-slot":"select-group",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function DR(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex flex-1 text-left",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(GA,{"data-slot":"select-value",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function FR(n){const e=q.c(13);let t,s,r,o;e[0]!==n?({className:s,size:o,children:t,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o):(t=e[1],s=e[2],r=e[3],o=e[4]);const i=o===void 0?"default":o;let l;e[5]!==s?(l=G("group/select-trigger flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input py-2 pr-2 pl-2.5 text-sm whitespace-nowrap outline-none transition-[color,background-color,border-color,box-shadow,transform,scale] duration-100 ease-out select-none data-pressed:scale-[0.98] focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 motion-reduce:transition-none motion-reduce:data-pressed:scale-100 bg-background hover:bg-accent dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",s),e[5]=s,e[6]=l):l=e[6];let c;e[7]===Symbol.for("react.memo_cache_sentinel")?(c=a.jsx(YA,{render:a.jsx(Ot,{className:"pointer-events-none size-4 text-muted-foreground transition-transform duration-150 ease-out group-data-popup-open/select-trigger:rotate-180 motion-reduce:transition-none"})}),e[7]=c):c=e[7];let u;return e[8]!==t||e[9]!==r||e[10]!==i||e[11]!==l?(u=a.jsxs(ZA,{"data-slot":"select-trigger","data-size":i,className:l,...r,children:[t,c]}),e[8]=t,e[9]=r,e[10]=i,e[11]=l,e[12]=u):u=e[12],u}function UR(n){const e=q.c(26);let t,s,r,o,i,l,c,u;e[0]!==n?({className:s,children:t,side:o,sideOffset:i,align:l,alignOffset:c,alignItemWithTrigger:u,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i,e[6]=l,e[7]=c,e[8]=u):(t=e[1],s=e[2],r=e[3],o=e[4],i=e[5],l=e[6],c=e[7],u=e[8]);const d=o===void 0?"bottom":o,f=i===void 0?4:i,m=l===void 0?"center":l,p=c===void 0?0:c,h=u===void 0?!0:u;let g;e[9]!==s?(g=G("relative isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 ease-out data-[side=none]:animate-none data-[side=bottom]:slide-in-from-top-1 data-[side=inline-end]:slide-in-from-left-1 data-[side=inline-start]:slide-in-from-right-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-75 data-closed:ease-in motion-reduce:animate-none",s),e[9]=s,e[10]=g):g=e[10];let x;e[11]===Symbol.for("react.memo_cache_sentinel")?(x=a.jsx(WR,{}),e[11]=x):x=e[11];let b;e[12]!==t?(b=a.jsx(XA,{children:t}),e[12]=t,e[13]=b):b=e[13];let y;e[14]===Symbol.for("react.memo_cache_sentinel")?(y=a.jsx(qR,{}),e[14]=y):y=e[14];let v;e[15]!==r||e[16]!==g||e[17]!==b?(v=a.jsxs(qA,{"data-slot":"select-content",className:g,...r,children:[x,b,y]}),e[15]=r,e[16]=g,e[17]=b,e[18]=v):v=e[18];let k;return e[19]!==m||e[20]!==h||e[21]!==p||e[22]!==d||e[23]!==f||e[24]!==v?(k=a.jsx(JA,{children:a.jsx(QA,{side:d,sideOffset:f,align:m,alignOffset:p,alignItemWithTrigger:h,className:"isolate z-50",children:v})}),e[19]=m,e[20]=h,e[21]=p,e[22]=d,e[23]=f,e[24]=v,e[25]=k):k=e[25],k}function BR(n){const e=q.c(13);let t,s,r;e[0]!==n?({className:s,children:t,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);let o;e[4]!==s?(o=G("relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none transition-colors duration-75 focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",s),e[4]=s,e[5]=o):o=e[5];let i;e[6]!==t?(i=a.jsx(e7,{className:"flex flex-1 shrink-0 gap-2 whitespace-nowrap",children:t}),e[6]=t,e[7]=i):i=e[7];let l;e[8]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(t7,{className:"transition-[opacity,transform,scale] duration-100 ease-out motion-safe:data-starting-style:scale-75 motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:scale-75 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none",render:a.jsx("span",{className:"pointer-events-none absolute right-2 flex size-4 items-center justify-center"}),children:a.jsx(Ft,{className:"pointer-events-none"})}),e[8]=l):l=e[8];let c;return e[9]!==r||e[10]!==o||e[11]!==i?(c=a.jsxs(HA,{"data-slot":"select-item",className:o,...r,children:[i,l]}),e[9]=r,e[10]=o,e[11]=i,e[12]=c):c=e[12],c}function WR(n){const e=q.c(9);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("top-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 transition-opacity duration-100 motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none [&_svg:not([class*='size-'])]:size-4",t),e[3]=t,e[4]=r):r=e[4];let o;e[5]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx(Id,{}),e[5]=o):o=e[5];let i;return e[6]!==s||e[7]!==r?(i=a.jsx(n7,{"data-slot":"select-scroll-up-button",className:r,...s,children:o}),e[6]=s,e[7]=r,e[8]=i):i=e[8],i}function qR(n){const e=q.c(9);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("bottom-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 transition-opacity duration-100 motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none [&_svg:not([class*='size-'])]:size-4",t),e[3]=t,e[4]=r):r=e[4];let o;e[5]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx(Ot,{}),e[5]=o):o=e[5];let i;return e[6]!==s||e[7]!==r?(i=a.jsx(s7,{"data-slot":"select-scroll-down-button",className:r,...s,children:o}),e[6]=s,e[7]=r,e[8]=i):i=e[8],i}function VR(n){const e=q.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(u3,{"data-slot":"sheet",...t}),e[2]=t,e[3]=s):s=e[3],s}function HR(n){const e=q.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(r7,{"data-slot":"sheet-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function KR(n){const e=q.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(Ol,{"data-slot":"sheet-close",...t}),e[2]=t,e[3]=s):s=e[3],s}function GR(n){const e=q.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(Xg,{"data-slot":"sheet-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}function ZR(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("fixed inset-0 z-50 bg-black/55 duration-200 ease-out data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0 data-closed:duration-150 data-closed:ease-in motion-reduce:animate-none",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(Jg,{"data-slot":"sheet-overlay",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function YR(n){const e=q.c(17);let t,s,r,o,i;e[0]!==n?({className:s,children:t,side:o,showCloseButton:i,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i):(t=e[1],s=e[2],r=e[3],o=e[4],i=e[5]);const l=o===void 0?"right":o,c=i===void 0?!0:i;let u;e[6]===Symbol.for("react.memo_cache_sentinel")?(u=a.jsx(ZR,{}),e[6]=u):u=e[6];let d;e[7]!==s?(d=G("fixed z-50 flex flex-col border-border bg-popover text-popover-foreground shadow-lg duration-200 ease-out data-closed:duration-150 data-closed:ease-in motion-reduce:animate-none","data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-full data-[side=right]:max-w-[560px] data-[side=right]:border-l","data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-full data-[side=left]:max-w-[560px] data-[side=left]:border-r","data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t","data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b","data-open:animate-in data-open:fade-in-0 data-[side=right]:data-open:slide-in-from-right data-[side=left]:data-open:slide-in-from-left data-[side=bottom]:data-open:slide-in-from-bottom data-[side=top]:data-open:slide-in-from-top","data-closed:animate-out data-closed:fade-out-0 data-[side=right]:data-closed:slide-out-to-right data-[side=left]:data-closed:slide-out-to-left data-[side=bottom]:data-closed:slide-out-to-bottom data-[side=top]:data-closed:slide-out-to-top",s),e[7]=s,e[8]=d):d=e[8];let f;e[9]!==c?(f=c&&a.jsxs(Ol,{className:"absolute top-4 right-4 inline-flex size-7 items-center justify-center rounded-md text-muted-foreground outline-none transition-[color,background-color,transform,scale] duration-100 ease-out hover:bg-accent hover:text-foreground active:scale-90 focus-visible:ring-[3px] focus-visible:ring-ring/20 disabled:pointer-events-none motion-reduce:transition-none motion-reduce:active:scale-100",children:[a.jsx(Ut,{"data-icon":"inline-start",className:"size-4"}),a.jsx("span",{className:"sr-only",children:"Close"})]}),e[9]=c,e[10]=f):f=e[10];let m;return e[11]!==t||e[12]!==r||e[13]!==l||e[14]!==d||e[15]!==f?(m=a.jsxs(GR,{children:[u,a.jsxs(Yg,{"data-slot":"sheet-content","data-side":l,className:d,...r,children:[t,f]})]}),e[11]=t,e[12]=r,e[13]=l,e[14]=d,e[15]=f,e[16]=m):m=e[16],m}function XR(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex flex-col gap-1.5 border-b p-4",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"sheet-header",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function JR(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-sm font-medium",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(Gg,{"data-slot":"sheet-title",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function QR(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-sm text-muted-foreground",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(Zg,{"data-slot":"sheet-description",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Ka(n){const e=q.c(10),{label:t,children:s,wide:r}=n,i=(r===void 0?!1:r)&&"col-span-2";let l;e[0]!==i?(l=G("min-w-0 gap-1 py-1",i),e[0]=i,e[1]=l):l=e[1];let c;e[2]!==t?(c=a.jsx(dn,{className:"text-xs text-muted-foreground",children:t}),e[2]=t,e[3]=c):c=e[3];let u;e[4]!==s?(u=a.jsx("div",{className:"min-w-0 [&>button]:w-full [&>button]:justify-between",children:s}),e[4]=s,e[5]=u):u=e[5];let d;return e[6]!==l||e[7]!==c||e[8]!==u?(d=a.jsxs(un,{className:l,children:[c,u]}),e[6]=l,e[7]=c,e[8]=u,e[9]=d):d=e[9],d}function Rc(n){const e=q.c(20),{label:t,ariaLabel:s,value:r,options:o,onChange:i,disabled:l,title:c}=n;let u;e[0]!==i?(u=x=>{x!==null&&i(x)},e[0]=i,e[1]=u):u=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=a.jsx(DR,{}),e[2]=d):d=e[2];let f;e[3]!==s||e[4]!==c?(f=a.jsx(FR,{"aria-label":s,title:c,className:"h-10 w-full",children:d}),e[3]=s,e[4]=c,e[5]=f):f=e[5];let m;e[6]!==o?(m=o.map(e8),e[6]=o,e[7]=m):m=e[7];let p;e[8]!==m?(p=a.jsx(UR,{children:a.jsx(zR,{children:m})}),e[8]=m,e[9]=p):p=e[9];let h;e[10]!==l||e[11]!==o||e[12]!==u||e[13]!==f||e[14]!==p||e[15]!==r?(h=a.jsxs(MR,{items:o,value:r,onValueChange:u,disabled:l,children:[f,p]}),e[10]=l,e[11]=o,e[12]=u,e[13]=f,e[14]=p,e[15]=r,e[16]=h):h=e[16];let g;return e[17]!==t||e[18]!==h?(g=a.jsx(Ka,{label:t,children:h}),e[17]=t,e[18]=h,e[19]=g):g=e[19],g}function e8(n){return a.jsx(BR,{value:n.value,children:n.menuLabel??n.label},n.value||"default")}function t8(n){const e=q.c(37),{contextWindowTokens:t,onContextWindowTokensChange:s,agentKind:r,onAgentKindChange:o,selectedModel:i,onModelChange:l,modelOptions:c,selectedEffort:u,onEffortChange:d,effortOptions:f,ultracodeEnabled:m,fastTier:p,fastModeEnabled:h,onFastModeEnabledChange:g,permissionMode:x,permissionOptions:b,onPermissionModeChange:y,changeAndApply:v}=n;let k;e[0]===Symbol.for("react.memo_cache_sentinel")?(k=a.jsx("h3",{id:"mobile-model-controls",className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Model and behavior"}),e[0]=k):k=e[0];let j;e[1]!==r||e[2]!==t||e[3]!==s?(j=xn(r).configurableContextWindow&&s&&a.jsx(hj,{value:t??null,onChange:s}),e[1]=r,e[2]=t,e[3]=s,e[4]=j):j=e[4];let _;e[5]!==j?(_=a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[k,j]}),e[5]=j,e[6]=_):_=e[6];let N;e[7]!==r||e[8]!==o?(N=o&&a.jsx(Rc,{label:"Agent",ariaLabel:"Agent",value:r,options:Oh,onChange:I=>o(I)}),e[7]=r,e[8]=o,e[9]=N):N=e[9];let S;e[10]!==c||e[11]!==l||e[12]!==i?(S=a.jsx(Rc,{label:"Model",ariaLabel:"Model",value:i,options:c,onChange:l}),e[10]=c,e[11]=l,e[12]=i,e[13]=S):S=e[13];let C;e[14]!==f||e[15]!==d||e[16]!==u||e[17]!==m?(C=f.length>0&&a.jsx(Rc,{label:"Reasoning",ariaLabel:"Reasoning effort",value:u,options:f,onChange:d,disabled:m,title:m?"Effort is pinned to XHigh while Ultracode is on":void 0}),e[14]=f,e[15]=d,e[16]=u,e[17]=m,e[18]=C):C=e[18];let E;e[19]!==v||e[20]!==h||e[21]!==p||e[22]!==g?(E=p&&g&&a.jsx(Ka,{label:"Speed",children:a.jsxs(ee,{type:"button",variant:h?"secondary":"ghost","aria-pressed":!!h,onClick:()=>v(()=>g(!h)),title:p.description,className:"h-10 justify-start",children:[a.jsx(Bu,{"data-icon":"inline-start",className:G(h&&"fill-current")}),h?"Fast":"Standard"]})}),e[19]=v,e[20]=h,e[21]=p,e[22]=g,e[23]=E):E=e[23];let T;e[24]!==y||e[25]!==x||e[26]!==b?(T=y&&x&&a.jsx(Rc,{label:"Access",ariaLabel:"Access policy",value:x,options:b,onChange:I=>y(I)}),e[24]=y,e[25]=x,e[26]=b,e[27]=T):T=e[27];let A;e[28]!==N||e[29]!==S||e[30]!==C||e[31]!==E||e[32]!==T?(A=a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[N,S,C,E,T]}),e[28]=N,e[29]=S,e[30]=C,e[31]=E,e[32]=T,e[33]=A):A=e[33];let P;return e[34]!==_||e[35]!==A?(P=a.jsxs("section",{"aria-labelledby":"mobile-model-controls",className:"flex flex-col gap-2",children:[_,A]}),e[34]=_,e[35]=A,e[36]=P):P=e[36],P}function n8(n){const e=q.c(30),{agentKind:t,isNewSession:s,worktreeEnabled:r,onWorktreeEnabledChange:o,ultracodeEnabled:i,onUltracodeEnabledChange:l,mcpServers:c,selectedMcpServers:u,onToggleMcpServer:d,onRefreshMcpServers:f,mcpLoading:m,onMcpAuth:p,changeAndApply:h}=n;let g;e[0]!==t?(g=xn(t),e[0]=t,e[1]=g):g=e[1];const{worktrees:x,ultracode:b}=g,y=!!(d&&f&&p&&(m||c&&c.length>0)),v=!!(x&&s&&o||b&&l||y);let k;e[2]!==u?(k=u??[],e[2]=u,e[3]=k):k=e[3];let j;e[4]!==k?(j=new Set(k),e[4]=k,e[5]=j):j=e[5];const _=j;if(!v)return null;let N;e[6]===Symbol.for("react.memo_cache_sentinel")?(N=a.jsx("h3",{id:"mobile-advanced-controls",className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Advanced"}),e[6]=N):N=e[6];let S;e[7]!==s||e[8]!==o||e[9]!==x||e[10]!==r?(S=x&&s&&o&&a.jsx(Ka,{label:"Isolation",children:a.jsxs(ee,{type:"button",variant:r?"secondary":"ghost","aria-pressed":!!r,onClick:()=>o(!r),className:"h-10 justify-start",children:[a.jsx(_r,{"data-icon":"inline-start"}),"Worktree"]})}),e[7]=s,e[8]=o,e[9]=x,e[10]=r,e[11]=S):S=e[11];let C;e[12]!==h||e[13]!==l||e[14]!==b||e[15]!==i?(C=b&&l&&a.jsx(Ka,{label:"Workflow",children:a.jsxs(ee,{type:"button",variant:i?"secondary":"ghost","aria-pressed":!!i,onClick:()=>h(()=>l(!i)),className:"h-10 justify-start",children:[a.jsx(Bu,{"data-icon":"inline-start",className:G(i&&"fill-current")}),"Ultracode"]})}),e[12]=h,e[13]=l,e[14]=b,e[15]=i,e[16]=C):C=e[16];let E;e[17]!==h||e[18]!==m||e[19]!==c||e[20]!==p||e[21]!==f||e[22]!==d||e[23]!==_||e[24]!==y?(E=y&&d&&f&&p&&a.jsx(Ka,{label:"Connections",wide:!0,children:a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsxs(ee,{type:"button",variant:"ghost",onClick:f,className:"min-h-10 justify-start",children:[a.jsx(On,{"data-icon":"inline-start",className:G(m&&"animate-spin")}),"Refresh MCP status"]}),(c??[]).map(A=>{const P=_.has(A.name),I=A.status==="connected";return a.jsxs(ee,{type:"button",variant:"ghost","aria-pressed":I?P:void 0,onClick:()=>I?h(()=>d(A.name)):p(A.name),className:"min-h-10 justify-start text-left",children:[a.jsx("span",{className:G("size-2 shrink-0 rounded-full",I&&P?"bg-success":I?"bg-muted-foreground":"bg-warning")}),a.jsx("span",{className:"min-w-0 flex-1 truncate",children:A.name}),a.jsx("span",{className:"text-xs text-muted-foreground",children:I?P?"On":"Off":"Connect"})]},A.name)})]})}),e[17]=h,e[18]=m,e[19]=c,e[20]=p,e[21]=f,e[22]=d,e[23]=_,e[24]=y,e[25]=E):E=e[25];let T;return e[26]!==S||e[27]!==C||e[28]!==E?(T=a.jsxs("section",{"aria-labelledby":"mobile-advanced-controls",className:"flex flex-col gap-2",children:[N,a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[S,C,E]})]}),e[26]=S,e[27]=C,e[28]=E,e[29]=T):T=e[29],T}function s8(n){var ue,oe;const e=q.c(76),{open:t,onOpenChange:s,agentKind:r,onAgentKindChange:o,selectedModel:i,resolvedDefaultName:l,catalogOptions:c,modelOptions:u,onModelChange:d,selectedEffort:f,effortOptions:m,onEffortChange:p,contextWindowTokens:h,onContextWindowTokensChange:g,fastTier:x,fastModeEnabled:b,onFastModeEnabledChange:y,isNewSession:v,worktreeEnabled:k,onWorktreeEnabledChange:j,ultracodeEnabled:_,onUltracodeEnabledChange:N,autoModeAvailable:S,permissionMode:C,onPermissionModeChange:E,mcpServers:T,selectedMcpServers:A,onToggleMcpServer:P,onRefreshMcpServers:I,mcpLoading:$,onMcpAuth:O,mobileExtra:M,changeAndApply:R}=n;let z,W;e[0]!==r||e[1]!==S||e[2]!==C?(z=yj(r,S),W=(ue=z.find(ie=>ie.value===C))==null?void 0:ue.label,e[0]=r,e[1]=S,e[2]=C,e[3]=z,e[4]=W):(z=e[3],W=e[4]);const D=W;let L;e[5]!==c||e[6]!==l||e[7]!==i?(L=i?P1(i,c):l,e[5]=c,e[6]=l,e[7]=i,e[8]=L):L=e[8];let U;e[9]!==m||e[10]!==f?(U=(oe=m.find(ie=>ie.value===f))==null?void 0:oe.label,e[9]=m,e[10]=f,e[11]=U):U=e[11];let F;e[12]!==D||e[13]!==L||e[14]!==U?(F=[L,U,D].filter(Boolean),e[12]=D,e[13]=L,e[14]=U,e[15]=F):F=e[15];const B=F.join(" · ");let V;e[16]!==R||e[17]!==E?(V=ie=>{E&&R(()=>E(ie))},e[16]=R,e[17]=E,e[18]=V):V=e[18];const H=V;let K;e[19]===Symbol.for("react.memo_cache_sentinel")?(K=a.jsx(HR,{render:a.jsx(ee,{type:"button",variant:"ghost",size:"icon",className:"ml-0.5 shrink-0 rounded-full text-muted-foreground","aria-label":"Session controls",title:"Session controls"}),children:a.jsx(Qg,{})}),e[19]=K):K=e[19];let Z;e[20]===Symbol.for("react.memo_cache_sentinel")?(Z=a.jsx(JR,{children:"Session controls"}),e[20]=Z):Z=e[20];let Y;e[21]!==B?(Y=a.jsx(QR,{className:"truncate text-xs",children:B}),e[21]=B,e[22]=Y):Y=e[22];let X;e[23]===Symbol.for("react.memo_cache_sentinel")?(X=a.jsx(KR,{render:a.jsx(ee,{type:"button",variant:"ghost",size:"icon-lg",className:"absolute right-2 top-2","aria-label":"Close session controls"}),children:a.jsx(Ut,{})}),e[23]=X):X=e[23];let se;e[24]!==Y?(se=a.jsxs(XR,{className:"gap-1 px-4 pb-3 pt-4",children:[Z,Y,X]}),e[24]=Y,e[25]=se):se=e[25];let Q;e[26]!==r||e[27]!==R||e[28]!==H||e[29]!==h||e[30]!==m||e[31]!==b||e[32]!==x||e[33]!==u||e[34]!==o||e[35]!==g||e[36]!==p||e[37]!==y||e[38]!==d||e[39]!==C||e[40]!==z||e[41]!==f||e[42]!==i||e[43]!==_?(Q=a.jsx(t8,{contextWindowTokens:h,onContextWindowTokensChange:g,agentKind:r,onAgentKindChange:o,selectedModel:i,onModelChange:d,modelOptions:u,selectedEffort:f,onEffortChange:p,effortOptions:m,ultracodeEnabled:_,fastTier:x,fastModeEnabled:b,onFastModeEnabledChange:y,permissionMode:C,permissionOptions:z,onPermissionModeChange:H,changeAndApply:R}),e[26]=r,e[27]=R,e[28]=H,e[29]=h,e[30]=m,e[31]=b,e[32]=x,e[33]=u,e[34]=o,e[35]=g,e[36]=p,e[37]=y,e[38]=d,e[39]=C,e[40]=z,e[41]=f,e[42]=i,e[43]=_,e[44]=Q):Q=e[44];let te;e[45]!==r||e[46]!==R||e[47]!==v||e[48]!==$||e[49]!==T||e[50]!==O||e[51]!==I||e[52]!==P||e[53]!==N||e[54]!==j||e[55]!==A||e[56]!==_||e[57]!==k?(te=a.jsx(n8,{agentKind:r,isNewSession:v,worktreeEnabled:k,onWorktreeEnabledChange:j,ultracodeEnabled:_,onUltracodeEnabledChange:N,mcpServers:T,selectedMcpServers:A,onToggleMcpServer:P,onRefreshMcpServers:I,mcpLoading:$,onMcpAuth:O,changeAndApply:R}),e[45]=r,e[46]=R,e[47]=v,e[48]=$,e[49]=T,e[50]=O,e[51]=I,e[52]=P,e[53]=N,e[54]=j,e[55]=A,e[56]=_,e[57]=k,e[58]=te):te=e[58];let J;e[59]!==M?(J=M&&a.jsxs("section",{"aria-labelledby":"mobile-goal-controls",className:"flex flex-col gap-2 pt-1",children:[a.jsx(Gt,{className:"mb-3"}),a.jsx("h3",{id:"mobile-goal-controls",className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Long-running goal"}),a.jsx("div",{className:"[&>*]:mx-0 [&>*]:mb-0 [&_button]:min-h-10",children:M})]}),e[59]=M,e[60]=J):J=e[60];let ne;e[61]!==r||e[62]!==v?(ne=!v&&a.jsx("p",{className:"text-xs text-muted-foreground",children:xn(r).settingsApply==="live"?"Changes apply live.":"Changes apply on the next turn."}),e[61]=r,e[62]=v,e[63]=ne):ne=e[63];let re;e[64]!==Q||e[65]!==te||e[66]!==J||e[67]!==ne?(re=a.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-4 py-4",children:[Q,te,J,ne]}),e[64]=Q,e[65]=te,e[66]=J,e[67]=ne,e[68]=re):re=e[68];let le;e[69]!==se||e[70]!==re?(le=a.jsxs(YR,{side:"bottom",className:"max-h-[82dvh] overflow-hidden rounded-t-2xl pb-[env(safe-area-inset-bottom)]",showCloseButton:!1,children:[se,re]}),e[69]=se,e[70]=re,e[71]=le):le=e[71];let ae;return e[72]!==s||e[73]!==t||e[74]!==le?(ae=a.jsx(a.Fragment,{children:a.jsxs(VR,{open:t,onOpenChange:s,children:[K,le]})}),e[72]=s,e[73]=t,e[74]=le,e[75]=ae):ae=e[75],ae}const r8=w.memo(function(e){const t=q.c(55),{agentKind:s,onAgentKindChange:r,selectedModel:o,onModelChange:i,selectedEffort:l,onEffortChange:c,contextWindowTokens:u,onContextWindowTokensChange:d,fastModeEnabled:f,onFastModeEnabledChange:m,isNewSession:p,worktreeEnabled:h,onWorktreeEnabledChange:g,ultracodeEnabled:x,onUltracodeEnabledChange:b,onApplySettings:y,activeModelId:v,mcpServers:k,selectedMcpServers:j,onToggleMcpServer:_,onSetMcpServers:N,onRefreshMcpServers:S,mcpLoading:C,onMcpAuth:E,permissionMode:T,onPermissionModeChange:A,mobileExtra:P,trailingExtra:I,mobile:$}=e,O=s===void 0?Go:s,M=$===void 0?!1:$,[R,z]=w.useState(!1);let W;t[0]!==p||t[1]!==y?(W=oe=>{oe(),!p&&y&&setTimeout(()=>y(),0)},t[0]=p,t[1]=y,t[2]=W):W=t[2];const D=W;let L;t[3]!==D||t[4]!==i?(L=oe=>D(()=>i(oe)),t[3]=D,t[4]=i,t[5]=L):L=t[5];const U=L;let F;t[6]!==D||t[7]!==c?(F=oe=>D(()=>c(oe)),t[6]=D,t[7]=c,t[8]=F):F=t[8];const B=F,{options:V,effortOptions:H,fastTier:K,autoPermissionMode:Z,normalizeEffort:Y}=dj(O,o),X=(v==null?void 0:v.toLowerCase().startsWith("gpt-"))??!1,Q=v&&(O==="copilot"||X===(O==="codex"))?v:void 0;let te,J;t[9]!==V||t[10]!==Q?(te=Q?P1(Q,V):jR(V),J=V.map(oe=>{const ie=[oe.description,oe.availabilityMessage].filter(Boolean).join(" · ")||void 0;return oe.value===""?{...oe,description:ie,label:te,menuLabel:oe.label}:{...oe,description:ie}}),t[9]=V,t[10]=Q,t[11]=te,t[12]=J):(te=t[11],J=t[12]);const ne=J;let re;t[13]!==Y||t[14]!==l?(re=Y(l),t[13]=Y,t[14]=l,t[15]=re):re=t[15];let le;t[16]!==O||t[17]!==Z||t[18]!==D||t[19]!==u||t[20]!==H||t[21]!==f||t[22]!==K||t[23]!==B||t[24]!==U||t[25]!==p||t[26]!==C||t[27]!==k||t[28]!==ne||t[29]!==r||t[30]!==d||t[31]!==m||t[32]!==E||t[33]!==A||t[34]!==S||t[35]!==N||t[36]!==_||t[37]!==b||t[38]!==g||t[39]!==T||t[40]!==te||t[41]!==j||t[42]!==o||t[43]!==re||t[44]!==x||t[45]!==h?(le={agentKind:O,onAgentKindChange:r,selectedModel:o,resolvedDefaultName:te,modelOptions:ne,onModelChange:U,selectedEffort:re,effortOptions:H,onEffortChange:B,contextWindowTokens:u,onContextWindowTokensChange:d,fastTier:K,fastModeEnabled:f,onFastModeEnabledChange:m,isNewSession:p,worktreeEnabled:h,onWorktreeEnabledChange:g,ultracodeEnabled:x,onUltracodeEnabledChange:b,autoModeAvailable:Z,permissionMode:T,onPermissionModeChange:A,mcpServers:k,selectedMcpServers:j,onToggleMcpServer:_,onSetMcpServers:N,onRefreshMcpServers:S,mcpLoading:C,onMcpAuth:E,changeAndApply:D},t[16]=O,t[17]=Z,t[18]=D,t[19]=u,t[20]=H,t[21]=f,t[22]=K,t[23]=B,t[24]=U,t[25]=p,t[26]=C,t[27]=k,t[28]=ne,t[29]=r,t[30]=d,t[31]=m,t[32]=E,t[33]=A,t[34]=S,t[35]=N,t[36]=_,t[37]=b,t[38]=g,t[39]=T,t[40]=te,t[41]=j,t[42]=o,t[43]=re,t[44]=x,t[45]=h,t[46]=le):le=t[46];const ae=le;if(M){let oe;return t[47]!==V||t[48]!==ae||t[49]!==P||t[50]!==R?(oe=a.jsx(s8,{...ae,open:R,onOpenChange:z,catalogOptions:V,mobileExtra:P}),t[47]=V,t[48]=ae,t[49]=P,t[50]=R,t[51]=oe):oe=t[51],oe}let ue;return t[52]!==ae||t[53]!==I?(ue=a.jsx(AR,{...ae,trailingExtra:I}),t[52]=ae,t[53]=I,t[54]=ue):ue=t[54],ue});function wj(n){return n.agentType==="team-lead"}function o8(n){return wj(n)?void 0:n.color}const i8={blue:"bg-blue-500",green:"bg-green-500",yellow:"bg-yellow-500",purple:"bg-purple-500",orange:"bg-orange-500"};function a8(n){return n?i8[n]??"bg-zinc-400":"bg-zinc-400"}const l8=w.memo(function(e){const t=q.c(18),{teamName:s,members:r,currentMemberName:o,loadingMember:i,onMemberClick:l}=e;let c;t[0]===Symbol.for("react.memo_cache_sentinel")?(c=a.jsx(Bs,{className:"size-3"}),t[0]=c):c=t[0];let u;t[1]!==s?(u=a.jsxs("div",{className:"flex shrink-0 items-center gap-1.5 text-xs font-medium text-muted-foreground",children:[c,a.jsx("span",{className:"max-w-[120px] truncate",children:s})]}),t[1]=s,t[2]=u):u=t[2];let d;t[3]===Symbol.for("react.memo_cache_sentinel")?(d=a.jsx(Gt,{orientation:"vertical",className:"h-3.5"}),t[3]=d):d=t[3];let f;if(t[4]!==o||t[5]!==i||t[6]!==r||t[7]!==l){let h;t[9]!==o||t[10]!==i||t[11]!==l?(h=g=>{const x=g.name===o,b=g.name===i,y=a8(o8(g));return a.jsxs(ee,{variant:"ghost",size:"xs",onClick:()=>l(g),disabled:b,className:G("whitespace-nowrap",x?"bg-accent text-accent-foreground":"text-muted-foreground"),children:[b?a.jsx(vt,{"data-icon":"inline-start",className:"animate-spin"}):a.jsx("span",{className:G("inline-flex size-1.5 shrink-0 rounded-full",y)}),a.jsx("span",{children:g.name}),wj(g)&&a.jsx(o7,{"data-icon":"inline-end",className:"text-warning"})]},g.agentId)},t[9]=o,t[10]=i,t[11]=l,t[12]=h):h=t[12],f=r.map(h),t[4]=o,t[5]=i,t[6]=r,t[7]=l,t[8]=f}else f=t[8];let m;t[13]!==f?(m=a.jsx("div",{className:"flex items-center gap-1",children:f}),t[13]=f,t[14]=m):m=t[14];let p;return t[15]!==u||t[16]!==m?(p=a.jsxs("div",{className:"flex shrink-0 items-center gap-2 overflow-x-auto border-b bg-background px-3 py-2",children:[u,d,m]}),t[15]=u,t[16]=m,t[17]=p):p=t[17],p});function Sj(n){const e=q.c(3),t=w.useRef(null),[s,r]=w.useState(0);let o,i;return e[0]!==n?(o=()=>{if(!n){t.current=null,r(0);return}t.current=Date.now(),r(0);const l=setInterval(()=>{t.current!==null&&r(Math.floor((Date.now()-t.current)/1e3))},1e3);return()=>clearInterval(l)},i=[n],e[0]=n,e[1]=o,e[2]=i):(o=e[1],i=e[2]),w.useEffect(o,i),s}const kj=w.createContext(null),jj=w.createContext(null);function Su(n){const e=q.c(6),{value:t,chatValue:s,children:r}=n;let o;e[0]!==s||e[1]!==r?(o=a.jsx(jj.Provider,{value:s,children:r}),e[0]=s,e[1]=r,e[2]=o):o=e[2];let i;return e[3]!==o||e[4]!==t?(i=a.jsx(kj.Provider,{value:t,children:o}),e[3]=o,e[4]=t,e[5]=i):i=e[5],i}function xt(){const n=w.useContext(kj);if(!n)throw new Error("useSessionContext must be used within a SessionProvider");return n}function Hl(){const n=w.useContext(jj);if(!n)throw new Error("useSessionChatContext must be used within a SessionProvider");return n}const c8=Lr("group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!",{variants:{variant:{default:"bg-primary text-primary-foreground [a]:hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",destructive:"bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20",outline:"border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",ghost:"hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",link:"text-primary underline-offset-4 hover:underline"}},defaultVariants:{variant:"default"}});function Ue(n){const e=q.c(13);let t,s,r,o,i;if(e[0]!==n){const{className:u,variant:d,render:f,...m}=n;t=f,i=d===void 0?"default":d,o=f3,s="span",r=d3({className:G(c8({variant:i}),u)},m),e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i}else t=e[1],s=e[2],r=e[3],o=e[4],i=e[5];let l;e[6]!==i?(l={slot:"badge",variant:i},e[6]=i,e[7]=l):l=e[7];let c;return e[8]!==t||e[9]!==s||e[10]!==r||e[11]!==l?(c={defaultTagName:s,props:r,render:t,state:l},e[8]=t,e[9]=s,e[10]=r,e[11]=l,e[12]=c):c=e[12],o(c)}var xv=1,u8=.9,d8=.8,f8=.17,rm=.1,om=.999,m8=.9999,p8=.99,h8=/[\\\/_+.#"@\[\(\{&]/,g8=/[\\\/_+.#"@\[\(\{&]/g,x8=/[\s-]/,Nj=/[\s-]/g;function Lh(n,e,t,s,r,o,i){if(o===e.length)return r===n.length?xv:p8;var l=`${r},${o}`;if(i[l]!==void 0)return i[l];for(var c=s.charAt(o),u=t.indexOf(c,r),d=0,f,m,p,h;u>=0;)f=Lh(n,e,t,s,u+1,o+1,i),f>d&&(u===r?f*=xv:h8.test(n.charAt(u-1))?(f*=d8,p=n.slice(r,u-1).match(g8),p&&r>0&&(f*=Math.pow(om,p.length))):x8.test(n.charAt(u-1))?(f*=u8,h=n.slice(r,u-1).match(Nj),h&&r>0&&(f*=Math.pow(om,h.length))):(f*=f8,r>0&&(f*=Math.pow(om,u-r))),n.charAt(u)!==e.charAt(o)&&(f*=m8)),(f<rm&&t.charAt(u-1)===s.charAt(o+1)||s.charAt(o+1)===s.charAt(o)&&t.charAt(u-1)!==s.charAt(o))&&(m=Lh(n,e,t,s,u+1,o+2,i),m*rm>f&&(f=m*rm)),f>d&&(d=f),u=t.indexOf(c,u+1);return i[l]=d,d}function bv(n){return n.toLowerCase().replace(Nj," ")}function b8(n,e,t){return n=t&&t.length>0?`${n+" "+t.join(" ")}`:n,Lh(n,e,bv(n),bv(e),0,0,{})}var xa='[cmdk-group=""]',im='[cmdk-group-items=""]',v8='[cmdk-group-heading=""]',Cj='[cmdk-item=""]',vv=`${Cj}:not([aria-disabled="true"])`,Mh="cmdk-item-select",di="data-value",y8=(n,e,t)=>b8(n,e,t),_j=w.createContext(void 0),Kl=()=>w.useContext(_j),Ej=w.createContext(void 0),I1=()=>w.useContext(Ej),Tj=w.createContext(void 0),Aj=w.forwardRef((n,e)=>{let t=fi(()=>{var L,U;return{search:"",value:(U=(L=n.value)!=null?L:n.defaultValue)!=null?U:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),s=fi(()=>new Set),r=fi(()=>new Map),o=fi(()=>new Map),i=fi(()=>new Set),l=Pj(n),{label:c,children:u,value:d,onValueChange:f,filter:m,shouldFilter:p,loop:h,disablePointerSelection:g=!1,vimBindings:x=!0,...b}=n,y=ki(),v=ki(),k=ki(),j=w.useRef(null),_=P8();Fo(()=>{if(d!==void 0){let L=d.trim();t.current.value=L,N.emit()}},[d]),Fo(()=>{_(6,P)},[]);let N=w.useMemo(()=>({subscribe:L=>(i.current.add(L),()=>i.current.delete(L)),snapshot:()=>t.current,setState:(L,U,F)=>{var B,V,H,K;if(!Object.is(t.current[L],U)){if(t.current[L]=U,L==="search")A(),E(),_(1,T);else if(L==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let Z=document.getElementById(k);Z?Z.focus():(B=document.getElementById(y))==null||B.focus()}if(_(7,()=>{var Z;t.current.selectedItemId=(Z=I())==null?void 0:Z.id,N.emit()}),F||_(5,P),((V=l.current)==null?void 0:V.value)!==void 0){let Z=U??"";(K=(H=l.current).onValueChange)==null||K.call(H,Z);return}}N.emit()}},emit:()=>{i.current.forEach(L=>L())}}),[]),S=w.useMemo(()=>({value:(L,U,F)=>{var B;U!==((B=o.current.get(L))==null?void 0:B.value)&&(o.current.set(L,{value:U,keywords:F}),t.current.filtered.items.set(L,C(U,F)),_(2,()=>{E(),N.emit()}))},item:(L,U)=>(s.current.add(L),U&&(r.current.has(U)?r.current.get(U).add(L):r.current.set(U,new Set([L]))),_(3,()=>{A(),E(),t.current.value||T(),N.emit()}),()=>{o.current.delete(L),s.current.delete(L),t.current.filtered.items.delete(L);let F=I();_(4,()=>{A(),(F==null?void 0:F.getAttribute("id"))===L&&T(),N.emit()})}),group:L=>(r.current.has(L)||r.current.set(L,new Set),()=>{o.current.delete(L),r.current.delete(L)}),filter:()=>l.current.shouldFilter,label:c||n["aria-label"],getDisablePointerSelection:()=>l.current.disablePointerSelection,listId:y,inputId:k,labelId:v,listInnerRef:j}),[]);function C(L,U){var F,B;let V=(B=(F=l.current)==null?void 0:F.filter)!=null?B:y8;return L?V(L,t.current.search,U):0}function E(){if(!t.current.search||l.current.shouldFilter===!1)return;let L=t.current.filtered.items,U=[];t.current.filtered.groups.forEach(B=>{let V=r.current.get(B),H=0;V.forEach(K=>{let Z=L.get(K);H=Math.max(Z,H)}),U.push([B,H])});let F=j.current;$().sort((B,V)=>{var H,K;let Z=B.getAttribute("id"),Y=V.getAttribute("id");return((H=L.get(Y))!=null?H:0)-((K=L.get(Z))!=null?K:0)}).forEach(B=>{let V=B.closest(im);V?V.appendChild(B.parentElement===V?B:B.closest(`${im} > *`)):F.appendChild(B.parentElement===F?B:B.closest(`${im} > *`))}),U.sort((B,V)=>V[1]-B[1]).forEach(B=>{var V;let H=(V=j.current)==null?void 0:V.querySelector(`${xa}[${di}="${encodeURIComponent(B[0])}"]`);H==null||H.parentElement.appendChild(H)})}function T(){let L=$().find(F=>F.getAttribute("aria-disabled")!=="true"),U=L==null?void 0:L.getAttribute(di);N.setState("value",U||void 0)}function A(){var L,U,F,B;if(!t.current.search||l.current.shouldFilter===!1){t.current.filtered.count=s.current.size;return}t.current.filtered.groups=new Set;let V=0;for(let H of s.current){let K=(U=(L=o.current.get(H))==null?void 0:L.value)!=null?U:"",Z=(B=(F=o.current.get(H))==null?void 0:F.keywords)!=null?B:[],Y=C(K,Z);t.current.filtered.items.set(H,Y),Y>0&&V++}for(let[H,K]of r.current)for(let Z of K)if(t.current.filtered.items.get(Z)>0){t.current.filtered.groups.add(H);break}t.current.filtered.count=V}function P(){var L,U,F;let B=I();B&&(((L=B.parentElement)==null?void 0:L.firstChild)===B&&((F=(U=B.closest(xa))==null?void 0:U.querySelector(v8))==null||F.scrollIntoView({block:"nearest"})),B.scrollIntoView({block:"nearest"}))}function I(){var L;return(L=j.current)==null?void 0:L.querySelector(`${Cj}[aria-selected="true"]`)}function $(){var L;return Array.from(((L=j.current)==null?void 0:L.querySelectorAll(vv))||[])}function O(L){let U=$()[L];U&&N.setState("value",U.getAttribute(di))}function M(L){var U;let F=I(),B=$(),V=B.findIndex(K=>K===F),H=B[V+L];(U=l.current)!=null&&U.loop&&(H=V+L<0?B[B.length-1]:V+L===B.length?B[0]:B[V+L]),H&&N.setState("value",H.getAttribute(di))}function R(L){let U=I(),F=U==null?void 0:U.closest(xa),B;for(;F&&!B;)F=L>0?T8(F,xa):A8(F,xa),B=F==null?void 0:F.querySelector(vv);B?N.setState("value",B.getAttribute(di)):M(L)}let z=()=>O($().length-1),W=L=>{L.preventDefault(),L.metaKey?z():L.altKey?R(1):M(1)},D=L=>{L.preventDefault(),L.metaKey?O(0):L.altKey?R(-1):M(-1)};return w.createElement(bo.div,{ref:e,tabIndex:-1,...b,"cmdk-root":"",onKeyDown:L=>{var U;(U=b.onKeyDown)==null||U.call(b,L);let F=L.nativeEvent.isComposing||L.keyCode===229;if(!(L.defaultPrevented||F))switch(L.key){case"n":case"j":{x&&L.ctrlKey&&W(L);break}case"ArrowDown":{W(L);break}case"p":case"k":{x&&L.ctrlKey&&D(L);break}case"ArrowUp":{D(L);break}case"Home":{L.preventDefault(),O(0);break}case"End":{L.preventDefault(),z();break}case"Enter":{L.preventDefault();let B=I();if(B){let V=new Event(Mh);B.dispatchEvent(V)}}}}},w.createElement("label",{"cmdk-label":"",htmlFor:S.inputId,id:S.labelId,style:$8},c),Kd(n,L=>w.createElement(Ej.Provider,{value:N},w.createElement(_j.Provider,{value:S},L))))}),w8=w.forwardRef((n,e)=>{var t,s;let r=ki(),o=w.useRef(null),i=w.useContext(Tj),l=Kl(),c=Pj(n),u=(s=(t=c.current)==null?void 0:t.forceMount)!=null?s:i==null?void 0:i.forceMount;Fo(()=>{if(!u)return l.item(r,i==null?void 0:i.id)},[u]);let d=Ij(r,o,[n.value,n.children,o],n.keywords),f=I1(),m=co(_=>_.value&&_.value===d.current),p=co(_=>u||l.filter()===!1?!0:_.search?_.filtered.items.get(r)>0:!0);w.useEffect(()=>{let _=o.current;if(!(!_||n.disabled))return _.addEventListener(Mh,h),()=>_.removeEventListener(Mh,h)},[p,n.onSelect,n.disabled]);function h(){var _,N;g(),(N=(_=c.current).onSelect)==null||N.call(_,d.current)}function g(){f.setState("value",d.current,!0)}if(!p)return null;let{disabled:x,value:b,onSelect:y,forceMount:v,keywords:k,...j}=n;return w.createElement(bo.div,{ref:cl(o,e),...j,id:r,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!m,"data-disabled":!!x,"data-selected":!!m,onPointerMove:x||l.getDisablePointerSelection()?void 0:g,onClick:x?void 0:h},n.children)}),S8=w.forwardRef((n,e)=>{let{heading:t,children:s,forceMount:r,...o}=n,i=ki(),l=w.useRef(null),c=w.useRef(null),u=ki(),d=Kl(),f=co(p=>r||d.filter()===!1?!0:p.search?p.filtered.groups.has(i):!0);Fo(()=>d.group(i),[]),Ij(i,l,[n.value,n.heading,c]);let m=w.useMemo(()=>({id:i,forceMount:r}),[r]);return w.createElement(bo.div,{ref:cl(l,e),...o,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},t&&w.createElement("div",{ref:c,"cmdk-group-heading":"","aria-hidden":!0,id:u},t),Kd(n,p=>w.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":t?u:void 0},w.createElement(Tj.Provider,{value:m},p))))}),k8=w.forwardRef((n,e)=>{let{alwaysRender:t,...s}=n,r=w.useRef(null),o=co(i=>!i.search);return!t&&!o?null:w.createElement(bo.div,{ref:cl(r,e),...s,"cmdk-separator":"",role:"separator"})}),j8=w.forwardRef((n,e)=>{let{onValueChange:t,...s}=n,r=n.value!=null,o=I1(),i=co(u=>u.search),l=co(u=>u.selectedItemId),c=Kl();return w.useEffect(()=>{n.value!=null&&o.setState("search",n.value)},[n.value]),w.createElement(bo.input,{ref:e,...s,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":l,id:c.inputId,type:"text",value:r?n.value:i,onChange:u=>{r||o.setState("search",u.target.value),t==null||t(u.target.value)}})}),N8=w.forwardRef((n,e)=>{let{children:t,label:s="Suggestions",...r}=n,o=w.useRef(null),i=w.useRef(null),l=co(u=>u.selectedItemId),c=Kl();return w.useEffect(()=>{if(i.current&&o.current){let u=i.current,d=o.current,f,m=new ResizeObserver(()=>{f=requestAnimationFrame(()=>{let p=u.offsetHeight;d.style.setProperty("--cmdk-list-height",p.toFixed(1)+"px")})});return m.observe(u),()=>{cancelAnimationFrame(f),m.unobserve(u)}}},[]),w.createElement(bo.div,{ref:cl(o,e),...r,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":l,"aria-label":s,id:c.listId},Kd(n,u=>w.createElement("div",{ref:cl(i,c.listInnerRef),"cmdk-list-sizer":""},u)))}),C8=w.forwardRef((n,e)=>{let{open:t,onOpenChange:s,overlayClassName:r,contentClassName:o,container:i,...l}=n;return w.createElement(i7,{open:t,onOpenChange:s},w.createElement(a7,{container:i},w.createElement(l7,{"cmdk-overlay":"",className:r}),w.createElement(c7,{"aria-label":n.label,"cmdk-dialog":"",className:o},w.createElement(Aj,{ref:e,...l}))))}),_8=w.forwardRef((n,e)=>co(t=>t.filtered.count===0)?w.createElement(bo.div,{ref:e,...n,"cmdk-empty":"",role:"presentation"}):null),E8=w.forwardRef((n,e)=>{let{progress:t,children:s,label:r="Loading...",...o}=n;return w.createElement(bo.div,{ref:e,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,"aria-label":r},Kd(n,i=>w.createElement("div",{"aria-hidden":!0},i)))}),ta=Object.assign(Aj,{List:N8,Item:w8,Input:j8,Group:S8,Separator:k8,Dialog:C8,Empty:_8,Loading:E8});function T8(n,e){let t=n.nextElementSibling;for(;t;){if(t.matches(e))return t;t=t.nextElementSibling}}function A8(n,e){let t=n.previousElementSibling;for(;t;){if(t.matches(e))return t;t=t.previousElementSibling}}function Pj(n){let e=w.useRef(n);return Fo(()=>{e.current=n}),e}var Fo=typeof window>"u"?w.useEffect:w.useLayoutEffect;function fi(n){let e=w.useRef();return e.current===void 0&&(e.current=n()),e}function co(n){let e=I1(),t=()=>n(e.snapshot());return w.useSyncExternalStore(e.subscribe,t,t)}function Ij(n,e,t,s=[]){let r=w.useRef(),o=Kl();return Fo(()=>{var i;let l=(()=>{var u;for(let d of t){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?(u=d.current.textContent)==null?void 0:u.trim():r.current}})(),c=s.map(u=>u.trim());o.value(n,l,c),(i=e.current)==null||i.setAttribute(di,l),r.current=l}),r}var P8=()=>{let[n,e]=w.useState(),t=fi(()=>new Map);return Fo(()=>{t.current.forEach(s=>s()),t.current=new Map},[n]),(s,r)=>{t.current.set(s,r),e({})}};function I8(n){let e=n.type;return typeof e=="function"?e(n.props):"render"in e?e.render(n.props):n}function Kd({asChild:n,children:e},t){return n&&w.isValidElement(e)?w.cloneElement(I8(e),{ref:e.ref},t(e.props.children)):t(e)}var $8={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function dr(n){const e=q.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(u3,{"data-slot":"dialog",...t}),e[2]=t,e[3]=s):s=e[3],s}function R8(n){const e=q.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(Xg,{"data-slot":"dialog-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}function Oge(n){const e=q.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(Ol,{"data-slot":"dialog-close",...t}),e[2]=t,e[3]=s):s=e[3],s}function O8(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("fixed inset-0 z-50 bg-black/55 duration-150 ease-out data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0 data-closed:duration-100 data-closed:ease-in motion-reduce:animate-none",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(Jg,{"data-slot":"dialog-overlay",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function fr(n){const e=q.c(15);let t,s,r,o;e[0]!==n?({className:s,children:t,showCloseButton:o,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o):(t=e[1],s=e[2],r=e[3],o=e[4]);const i=o===void 0?!0:o;let l;e[5]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(O8,{}),e[5]=l):l=e[5];let c;e[6]!==s?(c=G("fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl border bg-popover p-6 text-popover-foreground shadow-lg duration-150 ease-out sm:max-w-lg data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-100 data-closed:ease-in motion-reduce:animate-none",s),e[6]=s,e[7]=c):c=e[7];let u;e[8]!==i?(u=i&&a.jsxs(Ol,{className:"absolute top-4 right-4 inline-flex size-7 items-center justify-center rounded-md text-muted-foreground outline-none transition-[color,background-color,transform,scale] duration-100 ease-out hover:bg-accent hover:text-foreground active:scale-90 focus-visible:ring-[3px] focus-visible:ring-ring/20 disabled:pointer-events-none motion-reduce:transition-none motion-reduce:active:scale-100",children:[a.jsx(Ut,{"data-icon":"inline-start",className:"size-4"}),a.jsx("span",{className:"sr-only",children:"Close"})]}),e[8]=i,e[9]=u):u=e[9];let d;return e[10]!==t||e[11]!==r||e[12]!==c||e[13]!==u?(d=a.jsxs(R8,{children:[l,a.jsxs(Yg,{"data-slot":"dialog-content",className:c,...r,children:[t,u]})]}),e[10]=t,e[11]=r,e[12]=c,e[13]=u,e[14]=d):d=e[14],d}function wo(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex flex-col gap-2 text-center sm:text-left",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"dialog-header",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function $1(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"dialog-footer",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function mr(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-lg leading-none font-semibold",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(Gg,{"data-slot":"dialog-title",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function pr(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-muted-foreground text-sm",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(Zg,{"data-slot":"dialog-description",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Gl(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex size-full flex-col overflow-hidden rounded-xl! bg-popover p-1 text-popover-foreground",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(ta,{"data-slot":"command",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Lge(n){const e=q.c(24);let t,s,r,o,i,l;e[0]!==n?({title:o,description:i,children:t,className:s,showCloseButton:l,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i,e[6]=l):(t=e[1],s=e[2],r=e[3],o=e[4],i=e[5],l=e[6]);const c=o===void 0?"Command Palette":o,u=i===void 0?"Search for a command to run...":i,d=l===void 0?!1:l;let f;e[7]!==s?(f=G("top-1/3 translate-y-0 overflow-hidden rounded-xl! p-0",s),e[7]=s,e[8]=f):f=e[8];let m;e[9]!==c?(m=a.jsx(mr,{children:c}),e[9]=c,e[10]=m):m=e[10];let p;e[11]!==u?(p=a.jsx(pr,{children:u}),e[11]=u,e[12]=p):p=e[12];let h;e[13]!==m||e[14]!==p?(h=a.jsxs(wo,{className:"sr-only",children:[m,p]}),e[13]=m,e[14]=p,e[15]=h):h=e[15];let g;e[16]!==t||e[17]!==d||e[18]!==f||e[19]!==h?(g=a.jsxs(fr,{className:f,showCloseButton:d,children:[h,t]}),e[16]=t,e[17]=d,e[18]=f,e[19]=h,e[20]=g):g=e[20];let x;return e[21]!==r||e[22]!==g?(x=a.jsx(dr,{...r,children:g}),e[21]=r,e[22]=g,e[23]=x):x=e[23],x}function R1(n){const e=q.c(9);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(Yn,{className:"size-4 shrink-0 text-muted-foreground"}),e[3]=r):r=e[3];let o;e[4]!==t?(o=G("min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),e[4]=t,e[5]=o):o=e[5];let i;return e[6]!==s||e[7]!==o?(i=a.jsxs("div",{"data-slot":"command-input-wrapper",className:"flex h-11 items-center gap-2 border-b px-3",children:[r,a.jsx(ta.Input,{"data-slot":"command-input",className:o,...s})]}),e[6]=s,e[7]=o,e[8]=i):i=e[8],i}function Zl(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("no-scrollbar h-(--cmdk-list-height) max-h-72 scroll-py-1 overflow-x-hidden overflow-y-auto outline-none transition-[height] duration-100 ease-out motion-reduce:transition-none",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(ta.List,{"data-slot":"command-list",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function L8(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("py-6 text-center text-sm motion-safe:animate-in motion-safe:fade-in-0 motion-safe:duration-100 motion-reduce:animate-none",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(ta.Empty,{"data-slot":"command-empty",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Uo(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("overflow-hidden p-1 text-foreground **:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:py-1.5 **:[[cmdk-group-heading]]:text-xs **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group-heading]]:text-muted-foreground",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(ta.Group,{"data-slot":"command-group",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function no(n){const e=q.c(11);let t,s,r;e[0]!==n?({className:s,children:t,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);let o;e[4]!==s?(o=G("group/command-item relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none transition-colors duration-75 in-data-[slot=dialog-content]:rounded-lg! data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-muted data-[selected=true]:text-foreground motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[selected=true]:*:[svg]:text-foreground",s),e[4]=s,e[5]=o):o=e[5];let i;e[6]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsx(Ft,{className:"ml-auto scale-75 opacity-0 transition-[opacity,transform,scale] duration-100 ease-out group-has-data-[slot=command-shortcut]/command-item:hidden group-data-[checked=true]/command-item:scale-100 group-data-[checked=true]/command-item:opacity-100 motion-reduce:transition-none"}),e[6]=i):i=e[6];let l;return e[7]!==t||e[8]!==r||e[9]!==o?(l=a.jsxs(ta.Item,{"data-slot":"command-item",className:o,...r,children:[t,i]}),e[7]=t,e[8]=r,e[9]=o,e[10]=l):l=e[10],l}function M8(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("ml-auto text-xs tracking-widest text-muted-foreground group-data-[selected=true]/command-item:text-foreground",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("span",{"data-slot":"command-shortcut",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function z8(n){return a.jsx(Ue,{variant:n.source==="built-in"?"secondary":"outline",children:n.source})}const D8=w.memo(function(e){const t=q.c(38),{suggestions:s,filter:r,loading:o,selectedIndex:i,onSelect:l,onHover:c,onEdit:u}=e;let d;t[0]===Symbol.for("react.memo_cache_sentinel")?(d=new Map,t[0]=d):d=t[0];const f=w.useRef(d);let m,p;if(t[1]!==i?(m=()=>{var T;const E=f.current.get(i);E&&((T=E.scrollIntoView)==null||T.call(E,{block:"nearest"}))},p=[i],t[1]=i,t[2]=m,t[3]=p):(m=t[2],p=t[3]),w.useEffect(m,p),o){let E;return t[4]===Symbol.for("react.memo_cache_sentinel")?(E=a.jsx("div",{className:"motion-popover-in absolute bottom-full left-0 right-0 z-50 mx-auto mb-2 max-w-[var(--chat-width)]",children:a.jsxs("div",{className:"flex items-center gap-2 rounded-lg border bg-popover p-3 text-popover-foreground shadow-sm",children:[a.jsx(vt,{className:"size-3.5 animate-spin text-muted-foreground"}),a.jsx("span",{className:"text-xs text-muted-foreground",children:"Loading suggestions..."})]})}),t[4]=E):E=t[4],E}if(s.length===0){const E=r?`No commands or skills matching "${r}"`:"No commands or skills found";let T;return t[5]!==E?(T=a.jsx("div",{className:"motion-popover-in absolute bottom-full left-0 right-0 z-50 mx-auto mb-2 max-w-[var(--chat-width)]",children:a.jsx("div",{className:"rounded-lg border bg-popover p-3 text-popover-foreground shadow-sm",children:a.jsx("span",{className:"text-xs text-muted-foreground",children:E})})}),t[5]=E,t[6]=T):T=t[6],T}let h,g,x,b,y,v,k,j,_;if(t[7]!==u||t[8]!==c||t[9]!==l||t[10]!==i||t[11]!==s){const E=s.filter(U8),T=[{heading:"Commands",suggestions:E,offset:0},{heading:"Skills",suggestions:s.filter(B8),offset:E.length}];x="motion-popover-in absolute bottom-full left-0 right-0 z-50 mx-auto mb-2 max-w-[var(--chat-width)]",g=Gl,y="slash-suggestions",v=s[i]?`${s[i].type}-${s[i].name}`:void 0,t[21]!==c||t[22]!==s?(k=A=>{const P=s.findIndex(I=>`${I.type}-${I.name}`===A);P>=0&&c(P)},t[21]=c,t[22]=s,t[23]=k):k=t[23],j=!1,_="border shadow-sm",h=Zl,b=T.map(A=>A.suggestions.length>0&&a.jsx(Uo,{heading:A.heading,children:A.suggestions.map((P,I)=>{const $=A.offset+I;return a.jsx(F8,{suggestion:P,index:$,isSelected:$===i,onSelect:l,onHover:c,onEdit:u,itemRefs:f},`${P.type}-${P.name}`)})},A.heading)),t[7]=u,t[8]=c,t[9]=l,t[10]=i,t[11]=s,t[12]=h,t[13]=g,t[14]=x,t[15]=b,t[16]=y,t[17]=v,t[18]=k,t[19]=j,t[20]=_}else h=t[12],g=t[13],x=t[14],b=t[15],y=t[16],v=t[17],k=t[18],j=t[19],_=t[20];let N;t[24]!==h||t[25]!==b?(N=a.jsx(h,{children:b}),t[24]=h,t[25]=b,t[26]=N):N=t[26];let S;t[27]!==g||t[28]!==N||t[29]!==y||t[30]!==v||t[31]!==k||t[32]!==j||t[33]!==_?(S=a.jsx(g,{id:y,value:v,onValueChange:k,shouldFilter:j,className:_,children:N}),t[27]=g,t[28]=N,t[29]=y,t[30]=v,t[31]=k,t[32]=j,t[33]=_,t[34]=S):S=t[34];let C;return t[35]!==x||t[36]!==S?(C=a.jsx("div",{className:x,children:S}),t[35]=x,t[36]=S,t[37]=C):C=t[37],C});function F8({suggestion:n,index:e,isSelected:t,onSelect:s,onHover:r,onEdit:o,itemRefs:i}){const l=w.useCallback(c=>{c?(c.id=`slash-suggestion-${e}`,i.current.set(e,c)):i.current.delete(e)},[e,i]);return a.jsxs("div",{className:"group/suggestion relative",children:[a.jsxs(no,{ref:l,value:`${n.type}-${n.name}`,className:"items-start gap-2.5 px-2 py-2 pr-10",onMouseEnter:()=>r(e),onSelect:()=>s(n),onMouseDown:c=>{c.preventDefault()},children:[a.jsx("div",{className:"mt-0.5 shrink-0",children:n.type==="command"?a.jsx(Ai,{className:"size-4 text-muted-foreground"}):a.jsx(ll,{className:"size-4 text-muted-foreground"})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("span",{className:"font-mono text-sm font-medium text-foreground",children:["/",n.name]}),z8(n)]}),n.description&&a.jsx("p",{className:"mt-0.5 line-clamp-1 text-xs text-muted-foreground",children:n.description})]}),t&&a.jsx(M8,{className:o&&n.filePath?"mr-6":void 0,children:"Enter"})]}),o&&n.filePath&&a.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",className:"absolute right-1.5 top-1/2 -translate-y-1/2 opacity-0 transition-opacity group-hover/suggestion:opacity-100 focus-visible:opacity-100",onMouseDown:c=>{c.preventDefault(),c.stopPropagation()},onClick:c=>{c.preventDefault(),c.stopPropagation(),o(n.filePath)},"aria-label":`Edit ${n.name}`,children:a.jsx(Er,{"data-icon":"inline-start"})})]})}function U8(n){return n.type==="command"}function B8(n){return n.type==="skill"}function W8(n){const e=q.c(25),{files:t,query:s,loading:r,selectedIndex:o,onSelect:i,onHover:l}=n;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=new Map,e[0]=c):c=e[0];const u=w.useRef(c);let d,f;e[1]!==o?(d=()=>{var v,k;(k=(v=u.current.get(o))==null?void 0:v.scrollIntoView)==null||k.call(v,{block:"nearest"})},f=[o],e[1]=o,e[2]=d,e[3]=f):(d=e[2],f=e[3]),w.useEffect(d,f);const m=t[o];let p;e[4]!==t||e[5]!==l?(p=v=>{const k=t.indexOf(v);k>=0&&l(k)},e[4]=t,e[5]=l,e[6]=p):p=e[6];let h;e[7]!==r?(h=r&&a.jsx(vt,{"data-icon":"inline-end","aria-label":"Loading project files",className:"size-3.5 animate-spin"}),e[7]=r,e[8]=h):h=e[8];let g;e[9]!==h?(g=a.jsxs("span",{className:"flex items-center justify-between",children:["Project files",h]}),e[9]=h,e[10]=g):g=e[10];let x;e[11]!==t||e[12]!==r||e[13]!==l||e[14]!==i||e[15]!==s||e[16]!==o?(x=!r&&t.length===0?a.jsx("p",{className:"px-2 py-3 text-xs text-muted-foreground",children:s?`No files matching “${s}”`:"No project files found"}):t.map((v,k)=>a.jsxs(no,{ref:j=>{j?(j.id=`file-suggestion-${k}`,u.current.set(k,j)):u.current.delete(k)},value:v,onMouseEnter:()=>l(k),onSelect:()=>i(v),onMouseDown:q8,children:[a.jsx(m3,{"data-icon":"inline-start","aria-hidden":"true",className:"size-3.5 shrink-0 text-muted-foreground"}),a.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs",children:v}),k===o&&a.jsx("span",{className:"text-xs text-muted-foreground",children:"↵"})]},v)),e[11]=t,e[12]=r,e[13]=l,e[14]=i,e[15]=s,e[16]=o,e[17]=x):x=e[17];let b;e[18]!==g||e[19]!==x?(b=a.jsx(Zl,{className:"max-h-70",children:a.jsx(Uo,{heading:g,children:x})}),e[18]=g,e[19]=x,e[20]=b):b=e[20];let y;return e[21]!==m||e[22]!==p||e[23]!==b?(y=a.jsx("div",{className:"motion-popover-in absolute bottom-full left-0 right-0 z-50 mx-auto mb-1.5 max-w-[var(--chat-width)]",children:a.jsx(Gl,{id:"file-suggestions",value:m,onValueChange:p,shouldFilter:!1,className:"border shadow-sm",children:b})}),e[21]=m,e[22]=p,e[23]=b,e[24]=y):y=e[24],y}function q8(n){return n.preventDefault()}const V8=Lr("group/alert relative grid w-full gap-0.5 rounded-lg border px-2.5 py-2 text-left text-sm has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pr-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2 motion-safe:animate-in motion-safe:fade-in-0 motion-safe:slide-in-from-top-1 motion-safe:duration-150 motion-safe:ease-out motion-reduce:animate-none *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 *:[svg]:text-current"}},defaultVariants:{variant:"default"}});function Jt({className:n,variant:e,...t}){return a.jsx("div",{"data-slot":"alert",role:"alert",className:G(V8({variant:e}),n),...t})}function _n({className:n,...e}){return a.jsx("div",{"data-slot":"alert-title",className:G("font-medium group-has-[>svg]/alert:col-start-2 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground",n),...e})}function Qt({className:n,...e}){return a.jsx("div",{"data-slot":"alert-description",className:G("text-sm text-balance text-muted-foreground md:text-pretty [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground [&_p:not(:last-child)]:mb-4",n),...e})}function uo({className:n,...e}){return a.jsx("div",{"data-slot":"alert-action",className:G("absolute top-2 right-2",n),...e})}function na(n){const e=q.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(u7,{"data-slot":"dropdown-menu",...t}),e[2]=t,e[3]=s):s=e[3],s}function sa(n){const e=q.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(d7,{"data-slot":"dropdown-menu-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function ra(n){const e=q.c(18);let t,s,r,o,i,l;e[0]!==n?({align:r,alignOffset:o,side:i,sideOffset:l,className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i,e[6]=l):(t=e[1],s=e[2],r=e[3],o=e[4],i=e[5],l=e[6]);const c=r===void 0?"start":r,u=o===void 0?0:o,d=i===void 0?"bottom":i,f=l===void 0?4:l;let m;e[7]!==t?(m=G("z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 ease-out outline-none data-[side=bottom]:slide-in-from-top-1 data-[side=inline-end]:slide-in-from-left-1 data-[side=inline-start]:slide-in-from-right-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-75 data-closed:ease-in motion-reduce:animate-none",t),e[7]=t,e[8]=m):m=e[8];let p;e[9]!==s||e[10]!==m?(p=a.jsx(p3,{"data-slot":"dropdown-menu-content",className:m,...s}),e[9]=s,e[10]=m,e[11]=p):p=e[11];let h;return e[12]!==c||e[13]!==u||e[14]!==d||e[15]!==f||e[16]!==p?(h=a.jsx(x3,{children:a.jsx(b3,{className:"isolate z-50 outline-none",align:c,alignOffset:u,side:d,sideOffset:f,children:p})}),e[12]=c,e[13]=u,e[14]=d,e[15]=f,e[16]=p,e[17]=h):h=e[17],h}function Nr(n){const e=q.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(h3,{"data-slot":"dropdown-menu-group",...t}),e[2]=t,e[3]=s):s=e[3],s}function $j(n){const e=q.c(10);let t,s,r;e[0]!==n?({className:t,inset:s,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);let o;e[4]!==t?(o=G("px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7",t),e[4]=t,e[5]=o):o=e[5];let i;return e[6]!==s||e[7]!==r||e[8]!==o?(i=a.jsx(v3,{"data-slot":"dropdown-menu-label","data-inset":s,className:o,...r}),e[6]=s,e[7]=r,e[8]=o,e[9]=i):i=e[9],i}function cn(n){const e=q.c(12);let t,s,r,o;e[0]!==n?({className:t,inset:s,variant:o,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o):(t=e[1],s=e[2],r=e[3],o=e[4]);const i=o===void 0?"default":o;let l;e[5]!==t?(l=G("group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none transition-colors duration-75 focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive",t),e[5]=t,e[6]=l):l=e[6];let c;return e[7]!==s||e[8]!==r||e[9]!==l||e[10]!==i?(c=a.jsx(g3,{"data-slot":"dropdown-menu-item","data-inset":s,"data-variant":i,className:l,...r}),e[7]=s,e[8]=r,e[9]=l,e[10]=i,e[11]=c):c=e[11],c}function Yu(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("-mx-1 my-1 h-px bg-border",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(Kg,{"data-slot":"dropdown-menu-separator",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function En({...n}){return a.jsx(m7,{"data-slot":"collapsible",...n})}function vs({...n}){return a.jsx(p7,{"data-slot":"collapsible-trigger",...n})}function Tn({className:n,...e}){return a.jsx(f7,{"data-slot":"collapsible-content",className:G("h-[var(--collapsible-panel-height)] overflow-hidden opacity-100 transition-[height,opacity] duration-150 ease-out [&[hidden]:not([hidden='until-found'])]:hidden motion-safe:data-starting-style:h-0 motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:h-0 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none",n),...e})}const H8={exit_only:"Exit plan mode",interactive:"Implement interactively",autopilot:"Implement with Autopilot",autopilot_fleet:"Implement with Fleet"};function yv(n){return H8[n]??n.replaceAll("_"," ")}function Rj(n){const e=q.c(34),{allowedPrompts:t,summary:s,planContent:r,actions:o,recommendedAction:i,responding:l,responseError:c,onApprove:u,onReject:d}=n;let f,m,p,h,g,x;if(e[0]!==u||e[1]!==d||e[2]!==i||e[3]!==s||e[4]!==o||e[5]!==l){const j=o===void 0?[]:o,_=l===void 0?!1:l,N=i??j[0],S=j.filter(T=>T!==N);f=Jt;const C=u&&"pr-44";e[12]!==C?(m=G("mb-3",C),e[12]=C,e[13]=m):m=e[13],e[14]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsx($d,{}),h=a.jsx(_n,{children:"Plan ready for review"}),e[14]=p,e[15]=h):(p=e[14],h=e[15]);const E=s||(u?"Approve the plan or ask the agent to revise it.":"The agent is waiting for this plan to be reviewed.");e[16]!==E?(g=a.jsx(Qt,{children:E}),e[16]=E,e[17]=g):g=e[17],x=u&&d&&a.jsxs(uo,{className:"flex gap-2",children:[a.jsxs(ee,{size:"sm",disabled:_,onClick:()=>u(N),children:[_&&a.jsx(vt,{className:"animate-spin","data-icon":"inline-start"}),_?"Sending...":N?yv(N):"Approve"]}),S.length>0&&a.jsxs(na,{children:[a.jsx(sa,{render:a.jsx(ee,{type:"button",variant:"outline",size:"icon-sm","aria-label":"Other plan actions",disabled:_}),children:a.jsx(Ot,{"data-icon":"icon"})}),a.jsx(ra,{align:"end",children:a.jsx(Nr,{children:S.map(T=>a.jsx(cn,{onClick:()=>u(T),children:yv(T)},T))})})]}),a.jsx(ee,{variant:"ghost",size:"sm",disabled:_,onClick:d,children:"Reject"})]}),e[0]=u,e[1]=d,e[2]=i,e[3]=s,e[4]=o,e[5]=l,e[6]=f,e[7]=m,e[8]=p,e[9]=h,e[10]=g,e[11]=x}else f=e[6],m=e[7],p=e[8],h=e[9],g=e[10],x=e[11];let b;e[18]!==c?(b=c&&a.jsx("div",{role:"alert",className:"col-span-full mt-2 text-xs text-destructive",children:c}),e[18]=c,e[19]=b):b=e[19];let y;e[20]!==r?(y=r&&a.jsxs(En,{className:"col-span-full mt-2",children:[a.jsx(vs,{render:a.jsx(ee,{type:"button",variant:"ghost",size:"xs"}),children:"Review full plan"}),a.jsx(Tn,{children:a.jsx("pre",{className:"mt-2 max-h-64 overflow-auto whitespace-pre-wrap rounded-md bg-muted p-3 text-xs text-foreground",children:r})})]}),e[20]=r,e[21]=y):y=e[21];let v;e[22]!==t?(v=t&&t.length>0&&a.jsxs("div",{className:"col-span-full mt-2 flex flex-wrap gap-1",children:[a.jsx("span",{className:"mr-1 self-center text-xs text-muted-foreground",children:"Permissions requested:"}),t.map(K8)]}),e[22]=t,e[23]=v):v=e[23];let k;return e[24]!==f||e[25]!==v||e[26]!==m||e[27]!==p||e[28]!==h||e[29]!==g||e[30]!==x||e[31]!==b||e[32]!==y?(k=a.jsxs(f,{className:m,children:[p,h,g,x,b,y,v]}),e[24]=f,e[25]=v,e[26]=m,e[27]=p,e[28]=h,e[29]=g,e[30]=x,e[31]=b,e[32]=y,e[33]=k):k=e[33],k}function K8(n,e){return a.jsx(Ue,{variant:"outline",children:n.prompt},e)}const G8=["allow","allow_always","deny"];function Oc(n,e){return(n.availableDecisions??G8).includes(e)}function Z8(n){switch(n){case"Bash":return{label:"Run command",icon:Ai,tone:"cmd"};case"Edit":return{label:"Edit file",icon:yh,tone:"write"};case"Write":return{label:"Write file",icon:yh,tone:"write"};case"Read":return{label:"Read file",icon:Zi,tone:"read"};case"Glob":return{label:"File search",icon:Yn,tone:"search"};case"Grep":return{label:"Content search",icon:Yn,tone:"search"};case"WebFetch":return{label:"Fetch URL",icon:Pi,tone:"net"};case"WebSearch":return{label:"Web search",icon:Pi,tone:"net"};default:return{label:n,icon:Rd,tone:"other"}}}function Y8(n,e){if(n==="Bash"&&typeof e.command=="string")return e.command;if((n==="Edit"||n==="Write"||n==="Read")&&typeof e.file_path=="string")return e.file_path;if((n==="Glob"||n==="Grep")&&typeof e.pattern=="string")return e.pattern;if(n==="WebFetch"&&typeof e.url=="string")return e.url;if(n==="WebSearch"&&typeof e.query=="string")return e.query;const t=Object.keys(e).slice(0,2);return t.length===0?null:t.flatMap(s=>{const r=e[s],o=typeof r=="string"?r:JSON.stringify(r);return o?[o.length>160?o.slice(0,157)+"…":o]:[]}).join(" · ")}function Oj({requests:n,responding:e,onRespond:t,onRespondAll:s}){var k;const r=n[0],o=n.length,i=r!==void 0&&t!==void 0,l=i&&Oc(r,"allow"),c=i&&Oc(r,"allow_always"),u=i&&Oc(r,"deny"),d=!!s&&o>1&&n.every(j=>!j.defaultToNo&&Oc(j,"allow")),f=!(r!=null&&r.defaultToNo),m=w.useEffectEvent(j=>{if(!r)return;const _=j.target;if(_&&(_.tagName==="INPUT"||_.tagName==="TEXTAREA"||_.isContentEditable)||j.metaKey||j.ctrlKey||j.altKey)return;const N=j.key.toLowerCase();N==="a"&&j.shiftKey&&d?(j.preventDefault(),s==null||s("allow")):N==="a"&&l&&f?(j.preventDefault(),t==null||t(r.requestId,"allow")):N==="s"&&c&&f?(j.preventDefault(),t==null||t(r.requestId,"allow_always")):N==="d"&&u&&(j.preventDefault(),t==null||t(r.requestId,"deny"))});w.useEffect(()=>{const j=_=>m(_);return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[]);const p=r?Z8(r.toolName):null,h=r?Y8(r.toolName,r.input):null,g=(r==null?void 0:r.decisionReason)||(r==null?void 0:r.description)||(r==null?void 0:r.blockedPath),x=(((k=r==null?void 0:r.suggestions)==null?void 0:k.length)??0)>0;if(!r||!p)return null;const b=p.icon,y=(e==null?void 0:e.has(r.requestId))??!1,v=o>1;return a.jsx("div",{className:"motion-slide-down-in border-b border-warning/20 bg-warning/5",children:a.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5",children:[a.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[a.jsx("div",{className:"flex size-7 items-center justify-center rounded-md bg-warning/10 text-warning",children:a.jsx(c3,{className:"size-4"})}),a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(b,{className:"size-4 text-muted-foreground"}),a.jsx("span",{className:"text-sm font-medium text-foreground",children:p.label})]})]}),h&&a.jsx("div",{className:"min-w-0 flex-1",children:a.jsx("code",{className:"block truncate rounded-md border bg-muted/40 px-2 py-1 font-mono text-xs text-muted-foreground",children:h})}),g&&g!==h&&a.jsx("p",{className:"hidden max-w-64 truncate text-xs text-muted-foreground xl:block",title:g,children:g}),v&&a.jsxs(Ue,{variant:"outline",className:"shrink-0 tabular-nums",children:["+",o-1," more"]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[u&&a.jsxs(ee,{autoFocus:r.defaultToNo,variant:"ghost",size:"sm",className:"text-destructive",disabled:y,onClick:()=>t==null?void 0:t(r.requestId,"deny"),title:"Deny (D)",children:[a.jsx(Ut,{"data-icon":"inline-start"}),"Deny",a.jsx("kbd",{className:"ml-0.5 font-mono text-xs text-muted-foreground",children:"D"})]},r.requestId),c&&a.jsxs(ee,{variant:"outline",size:"sm",disabled:y,onClick:()=>t==null?void 0:t(r.requestId,"allow_always"),title:x?`Apply the suggested scoped permission rule${f?" (S)":""}`:`Allow ${r.toolName} for this session${f?" (S)":""}`,children:[a.jsx(h7,{"data-icon":"inline-start"}),x?"Remember rule":"Session",f&&a.jsx("kbd",{className:"ml-0.5 font-mono text-xs text-muted-foreground",children:"S"})]}),d&&a.jsxs(ee,{variant:"secondary",size:"sm",disabled:y,onClick:()=>s==null?void 0:s("allow"),title:"Allow all pending (⇧A)",children:["Allow all",a.jsx("kbd",{className:"ml-0.5 font-mono text-xs text-muted-foreground",children:"⇧A"})]}),l&&a.jsxs(ee,{size:"sm",disabled:y,onClick:()=>t==null?void 0:t(r.requestId,"allow"),title:f?"Allow once (A)":"Allow once",children:[a.jsx(Ft,{"data-icon":"inline-start"}),"Allow",f&&a.jsx("kbd",{className:"ml-0.5 font-mono text-xs opacity-70",children:"A"})]}),i&&!l&&!c&&!u&&a.jsx("span",{className:"text-xs text-muted-foreground",children:"Resolve this approval in Codex"})]})]})})}const X8=1568,J8=.85,wv=35e5;function Q8(n,e){let{width:t,height:s}=n;const r=Math.min(1,X8/Math.max(t,s));t=Math.round(t*r),s=Math.round(s*r);const o=document.createElement("canvas");o.width=t,o.height=s,o.getContext("2d").drawImage(n,0,0,t,s);const l=e==="image/jpeg"||e==="image/webp",c=l?"image/jpeg":"image/png";let u=o.toDataURL(c,l?J8:void 0),d=u.split(",")[1];if(d.length>wv){let f=l?.7:.8;for(;d.length>wv&&f>.3;)u=o.toDataURL("image/jpeg",f),d=u.split(",")[1],f-=.1;return{dataUrl:u,base64:d,mediaType:"image/jpeg"}}return{dataUrl:u,base64:d,mediaType:c}}function e9(n){const e=q.c(25),t=n===void 0?!0:n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=[],e[0]=s):s=e[0];const[r,o]=w.useState(s),[i,l]=w.useState(!1),[c,u]=w.useState(!1),d=w.useRef(t);let f,m;e[1]!==t?(f=()=>{d.current=t},m=[t],e[1]=t,e[2]=f,e[3]=m):(f=e[2],m=e[3]),w.useEffect(f,m);let p;e[4]!==t?(p=R=>{const z=Array.from(R).filter(s9);if(!t){z.length>0&&u(!0);return}u(!1);for(const W of z){const D=new FileReader;D.onload=()=>{if(!d.current){u(!0);return}const L=D.result,U=new Image;U.onload=()=>{if(!d.current){u(!0);return}const F=Q8(U,W.type);o(B=>[...B,{id:crypto.randomUUID(),file:W,preview:F.dataUrl,data:F.base64,mediaType:F.mediaType}])},U.src=L},D.onerror=()=>{console.warn(`Failed to read image file: ${W.name}`)},D.readAsDataURL(W)}},e[4]=t,e[5]=p):p=e[5];const h=p;let g;e[6]===Symbol.for("react.memo_cache_sentinel")?(g=R=>{o(z=>z.filter((W,D)=>D!==R)),u(!1)},e[6]=g):g=e[6];const x=g;let b;e[7]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{o([]),u(!1)},e[7]=b):b=e[7];const y=b;let v;e[8]===Symbol.for("react.memo_cache_sentinel")?(v=R=>{o(z=>z.length>0?z:R)},e[8]=v):v=e[8];const k=v;let j;e[9]===Symbol.for("react.memo_cache_sentinel")?(j=()=>u(!1),e[9]=j):j=e[9];const _=j;let N;e[10]!==t?(N=R=>{R.preventDefault(),t&&l(!0)},e[10]=t,e[11]=N):N=e[11];const S=N;let C;e[12]===Symbol.for("react.memo_cache_sentinel")?(C=R=>{R.preventDefault(),R.currentTarget.contains(R.relatedTarget)||l(!1)},e[12]=C):C=e[12];const E=C;let T;e[13]!==h?(T=R=>{R.preventDefault(),l(!1),R.dataTransfer.files.length>0&&h(R.dataTransfer.files)},e[13]=h,e[14]=T):T=e[14];const A=T;let P;e[15]!==h?(P=R=>{var L;const z=(L=R.clipboardData)==null?void 0:L.items;if(!z)return;const W=Array.from(z).filter(n9);if(W.length===0)return;R.preventDefault();const D=W.map(t9).filter(Boolean);h(D)},e[15]=h,e[16]=P):P=e[16];const I=P,$=!t&&r.length>0?"The selected model does not accept images. Switch models or remove the attachments.":!t&&c?"The selected model does not accept the image you tried to add.":null,O=!t&&r.length>0;let M;return e[17]!==S||e[18]!==A||e[19]!==I||e[20]!==r||e[21]!==i||e[22]!==$||e[23]!==O?(M={images:r,isDragOver:i,imageError:$,hasUnsupportedAttachments:O,dismissImageError:_,removeImage:x,clearImages:y,restoreImages:k,handleDragOver:S,handleDragLeave:E,handleDrop:A,handlePaste:I},e[17]=S,e[18]=A,e[19]=I,e[20]=r,e[21]=i,e[22]=$,e[23]=O,e[24]=M):M=e[24],M}function t9(n){return n.getAsFile()}function n9(n){return n.type.startsWith("image/")}function s9(n){return n.type.startsWith("image/")}const zh=new Map;function Lj(n){return`${gn("refused-draft")}::${n}`}function Sv(n,e){zh.set(Lj(n),e)}function r9(n){const e=Lj(n),t=zh.get(e);return zh.delete(e),t}function o9(n){const e=q.c(6);let t,s;e[0]!==n?({delay:s,...t}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);const r=s===void 0?0:s;let o;return e[3]!==r||e[4]!==t?(o=a.jsx(v7,{"data-slot":"tooltip-provider",delay:r,...t}),e[3]=r,e[4]=t,e[5]=o):o=e[5],o}function Zt(n){const e=q.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(o9,{children:a.jsx(b7,{"data-slot":"tooltip",...t})}),e[2]=t,e[3]=s):s=e[3],s}function Yt(n){const e=q.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(g7,{"data-slot":"tooltip-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function Xt(n){const e=q.c(20);let t,s,r,o,i,l,c;e[0]!==n?({className:s,side:o,sideOffset:i,align:l,alignOffset:c,children:t,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i,e[6]=l,e[7]=c):(t=e[1],s=e[2],r=e[3],o=e[4],i=e[5],l=e[6],c=e[7]);const u=o===void 0?"top":o,d=i===void 0?4:i,f=l===void 0?"center":l,m=c===void 0?0:c;let p;e[8]!==s?(p=G("z-50 w-fit origin-(--transform-origin) overflow-hidden rounded-md bg-popover px-2.5 py-1.5 text-xs text-popover-foreground shadow-md ring-1 ring-foreground/10 text-balance duration-100 ease-out data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-75 data-closed:ease-in motion-reduce:animate-none",s),e[8]=s,e[9]=p):p=e[9];let h;e[10]!==t||e[11]!==r||e[12]!==p?(h=a.jsx(x7,{"data-slot":"tooltip-content",className:p,...r,children:t}),e[10]=t,e[11]=r,e[12]=p,e[13]=h):h=e[13];let g;return e[14]!==f||e[15]!==m||e[16]!==u||e[17]!==d||e[18]!==h?(g=a.jsx(y7,{children:a.jsx(w7,{align:f,alignOffset:m,side:u,sideOffset:d,className:"isolate z-50",children:h})}),e[14]=f,e[15]=m,e[16]=u,e[17]=d,e[18]=h,e[19]=g):g=e[19],g}const rs="rounded-full border bg-popover shadow-sm",Gd=w.memo(function(e){const t=q.c(8);let s,r;t[0]!==e?({className:s,...r}=e,t[0]=e,t[1]=s,t[2]=r):(s=t[1],r=t[2]);let o;t[3]!==s?(o=G("inline-block size-2 shrink-0 rounded-full bg-success",s),t[3]=s,t[4]=o):o=t[4];let i;return t[5]!==r||t[6]!==o?(i=a.jsx("span",{className:o,...r}),t[5]=r,t[6]=o,t[7]=i):i=t[7],i}),am=w.memo(function(e){const t=q.c(17),{icon:s,label:r,onClick:o,disabled:i,className:l,iconClassName:c,size:u}=e,f=(u===void 0?"sm":u)==="sm"?"icon-xs":"icon-sm";let m;t[0]!==l||t[1]!==i||t[2]!==r||t[3]!==o||t[4]!==f?(m=a.jsx(ee,{variant:"ghost",size:f,className:l,onClick:o,disabled:i,"aria-label":r}),t[0]=l,t[1]=i,t[2]=r,t[3]=o,t[4]=f,t[5]=m):m=t[5];let p;t[6]!==s||t[7]!==c?(p=a.jsx(s,{"data-icon":"inline-start",className:c}),t[6]=s,t[7]=c,t[8]=p):p=t[8];let h;t[9]!==m||t[10]!==p?(h=a.jsx(Yt,{render:m,children:p}),t[9]=m,t[10]=p,t[11]=h):h=t[11];let g;t[12]!==r?(g=a.jsx(Xt,{children:r}),t[12]=r,t[13]=g):g=t[13];let x;return t[14]!==h||t[15]!==g?(x=a.jsxs(Zt,{children:[h,g]}),t[14]=h,t[15]=g,t[16]=x):x=t[16],x});function i9(n){return n<10?"critical":n<30?"warning":"healthy"}const a9={critical:"border-destructive/30 bg-destructive/10 text-destructive",warning:"border-warning/30 bg-warning/10 text-warning",healthy:"text-muted-foreground"},Mj=w.memo(function(e){const t=q.c(54),{rawMessages:s,showRemaining:r,showTooltip:o,warnOnly:i}=e,l=r===void 0?!1:r,c=o===void 0?!1:o,u=i===void 0?!1:i;let d,f,m,p,h,g,x,b,y,v,k,j,_;if(t[0]!==s||t[1]!==l||t[2]!==c||t[3]!==u){x=Symbol.for("react.early_return_sentinel");e:{const E=pj(s);if(!E){x=null;break e}const T=Math.max(0,100-E.percent),A=i9(T);if(u&&A==="healthy"){x=null;break e}const P=Math.max(0,E.compactAt-E.used);let I;t[17]!==T||t[18]!==P||t[19]!==l?(I=l?`${T.toFixed(0)}% · ${Nt(P)}`:`${T.toFixed(0)}%`,t[17]=T,t[18]=P,t[19]=l,t[20]=I):I=t[20];const $=I,O=a9[A],M=l&&"gap-1";let R;t[21]!==O||t[22]!==M?(R=G("shrink-0 tabular-nums",O,M),t[21]=O,t[22]=M,t[23]=R):R=t[23];let z;t[24]!==$||t[25]!==R?(z=a.jsx(Ue,{variant:"outline",className:R,children:$}),t[24]=$,t[25]=R,t[26]=z):z=t[26];const W=z;if(!c){x=W;break e}f=Zt,t[27]!==W?(g=a.jsx(Yt,{render:W}),t[27]=W,t[28]=g):g=t[28],d=Xt,m="flex flex-col gap-1 text-xs",t[29]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsx("div",{className:"font-medium",children:"Context before auto-compact"}),t[29]=p):p=t[29];let D;t[30]!==P?(D=Nt(P),t[30]=P,t[31]=D):D=t[31];let L;t[32]!==T?(L=T.toFixed(1),t[32]=T,t[33]=L):L=t[33],t[34]!==D||t[35]!==L?(h=a.jsxs("div",{children:[D," remaining (",L,"%)"]}),t[34]=D,t[35]=L,t[36]=h):h=t[36],b="text-muted-foreground",y=Nt(E.used),v=" / ",k=Nt(E.limit),j=" tokens used (",_=E.percentAbsolute.toFixed(1)}t[0]=s,t[1]=l,t[2]=c,t[3]=u,t[4]=d,t[5]=f,t[6]=m,t[7]=p,t[8]=h,t[9]=g,t[10]=x,t[11]=b,t[12]=y,t[13]=v,t[14]=k,t[15]=j,t[16]=_}else d=t[4],f=t[5],m=t[6],p=t[7],h=t[8],g=t[9],x=t[10],b=t[11],y=t[12],v=t[13],k=t[14],j=t[15],_=t[16];if(x!==Symbol.for("react.early_return_sentinel"))return x;let N;t[37]!==b||t[38]!==y||t[39]!==v||t[40]!==k||t[41]!==j||t[42]!==_?(N=a.jsxs("div",{className:b,children:[y,v,k,j,_,"%)"]}),t[37]=b,t[38]=y,t[39]=v,t[40]=k,t[41]=j,t[42]=_,t[43]=N):N=t[43];let S;t[44]!==d||t[45]!==m||t[46]!==p||t[47]!==h||t[48]!==N?(S=a.jsxs(d,{className:m,children:[p,h,N]}),t[44]=d,t[45]=m,t[46]=p,t[47]=h,t[48]=N,t[49]=S):S=t[49];let C;return t[50]!==f||t[51]!==g||t[52]!==S?(C=a.jsxs(f,{children:[g,S]}),t[50]=f,t[51]=g,t[52]=S,t[53]=C):C=t[53],C});function l9(n){const e=q.c(7),{isPlanApproval:t,isUserQuestion:s,elapsedSec:r}=n,{isLive:o}=xt(),{chat:i}=Hl(),{isConnected:l}=i,c=l||o;let u;e[0]!==r||e[1]!==t||e[2]!==s||e[3]!==c?(u=c&&!t&&!s&&a.jsxs("div",{className:"motion-enter mr-1 flex items-center gap-1.5",children:[r>0&&a.jsx("span",{className:"font-mono text-xs tabular-nums text-muted-foreground",children:oR(r)}),a.jsx(Gd,{})]}),e[0]=r,e[1]=t,e[2]=s,e[3]=c,e[4]=u):u=e[4];let d;return e[5]!==u?(d=a.jsx(a.Fragment,{children:u}),e[5]=u,e[6]=d):d=e[6],d}function c9(n){const e=q.c(26),{hasContent:t,onSubmit:s,submitLabel:r}=n,o=r===void 0?"Send message":r,{isLive:i,sessionSource:l,actions:c}=xt(),{handleStopSession:u}=c,{chat:d}=Hl(),{isConnected:f,interrupt:m}=d,p=f||i;let h;e[0]!==(l==null?void 0:l.agentKind)||e[1]!==(l==null?void 0:l.dirName)?(h=(l==null?void 0:l.agentKind)??nn((l==null?void 0:l.dirName)??null),e[0]=l==null?void 0:l.agentKind,e[1]=l==null?void 0:l.dirName,e[2]=h):h=e[2];const g=h;let x;e[3]!==g?(x=yR(g),e[3]=g,e[4]=x):x=e[4];const b=x;let y;e[5]!==b||e[6]!==m||e[7]!==p?(y=p&&a.jsxs(Zt,{children:[a.jsx(Yt,{render:a.jsx(ee,{variant:"outline",size:"icon-sm",className:"motion-enter shrink-0 rounded-full text-warning",onClick:m,"aria-label":b,title:b}),children:a.jsx(e1,{"data-icon":"inline-start",className:"fill-current"})}),a.jsxs(Xt,{children:[b," (Esc)"]})]}),e[5]=b,e[6]=m,e[7]=p,e[8]=y):y=e[8];let v;e[9]!==g||e[10]!==u||e[11]!==p?(v=p&&xn(g).stopSession&&a.jsxs(Zt,{children:[a.jsx(Yt,{render:a.jsx(ee,{variant:"ghost",size:"icon-sm",className:"motion-enter shrink-0 rounded-full text-destructive hover:bg-destructive/10 hover:text-destructive",onClick:u,"aria-label":"Stop session",title:"Stop session"}),children:a.jsx(S7,{"data-icon":"inline-start"})}),a.jsx(Xt,{children:"Stop session"})]}),e[9]=g,e[10]=u,e[11]=p,e[12]=v):v=e[12];const k=t?"default":"secondary",j=!t&&"text-muted-foreground";let _;e[13]!==j?(_=G("shrink-0 rounded-full",j),e[13]=j,e[14]=_):_=e[14];const N=!t;let S;e[15]===Symbol.for("react.memo_cache_sentinel")?(S=a.jsx(k7,{"data-icon":"inline-start"}),e[15]=S):S=e[15];let C;e[16]!==s||e[17]!==o||e[18]!==_||e[19]!==N||e[20]!==k?(C=a.jsx(ee,{variant:k,size:"icon-sm",className:_,disabled:N,onClick:s,"aria-label":o,title:o,children:S}),e[16]=s,e[17]=o,e[18]=_,e[19]=N,e[20]=k,e[21]=C):C=e[21];let E;return e[22]!==C||e[23]!==y||e[24]!==v?(E=a.jsxs("div",{className:"flex items-center gap-1",children:[y,v,C]}),e[22]=C,e[23]=y,e[24]=v,e[25]=E):E=e[25],E}function kv(n){const e=q.c(34),{error:t}=n,[s,r]=w.useState(!1),[o,i]=w.useState(!1);let l;e[0]!==t?(l=t.split(`
|
|
3
|
+
`),e[0]=t,e[1]=l):l=e[1];const c=l[0];let u;e[2]!==t||e[3]!==c?(u=t.includes(`
|
|
4
|
+
`)||t.length>c.length,e[2]=t,e[3]=c,e[4]=u):u=e[4];const d=u;let f;e[5]!==t?(f=async()=>{try{await navigator.clipboard.writeText(t),i(!0),setTimeout(()=>i(!1),1500)}catch{}},e[5]=t,e[6]=f):f=e[6];const m=f;let p;e[7]===Symbol.for("react.memo_cache_sentinel")?(p=()=>r(!0),e[7]=p):p=e[7];let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=a.jsx(Ds,{"data-icon":"inline-start"}),e[8]=h):h=e[8];let g;e[9]!==c?(g=a.jsx("span",{className:"truncate",children:c}),e[9]=c,e[10]=g):g=e[10];let x;e[11]!==d?(x=d&&a.jsx("span",{className:"shrink-0 opacity-60",children:"(details)"}),e[11]=d,e[12]=x):x=e[12];let b;e[13]!==g||e[14]!==x?(b=a.jsxs(ee,{type:"button",variant:"ghost",size:"sm",onClick:p,title:"Click to view the full error",className:"motion-enter mt-1 w-full justify-start text-destructive",children:[h,g,x]}),e[13]=g,e[14]=x,e[15]=b):b=e[15];let y;e[16]===Symbol.for("react.memo_cache_sentinel")?(y=a.jsxs(wo,{children:[a.jsxs(mr,{className:"flex items-center gap-2 text-destructive",children:[a.jsx(Ds,{className:"size-4"}),"Error details"]}),a.jsx(pr,{children:"The full output from the failed request, including the underlying process stderr."})]}),e[16]=y):y=e[16];let v;e[17]!==t?(v=a.jsx("pre",{className:"max-h-[50vh] select-text overflow-auto whitespace-pre-wrap break-words rounded-md border bg-muted/30 p-3 font-mono text-xs text-destructive",children:t}),e[17]=t,e[18]=v):v=e[18];let k;e[19]!==o?(k=o?a.jsx(Ft,{"data-icon":"inline-start"}):a.jsx(ys,{"data-icon":"inline-start"}),e[19]=o,e[20]=k):k=e[20];const j=o?"Copied":"Copy";let _;e[21]!==m||e[22]!==k||e[23]!==j?(_=a.jsx("div",{className:"flex justify-end",children:a.jsxs(ee,{type:"button",variant:"outline",size:"sm",onClick:m,children:[k,j]})}),e[21]=m,e[22]=k,e[23]=j,e[24]=_):_=e[24];let N;e[25]!==v||e[26]!==_?(N=a.jsxs(fr,{className:"max-w-2xl",children:[y,v,_]}),e[25]=v,e[26]=_,e[27]=N):N=e[27];let S;e[28]!==s||e[29]!==N?(S=a.jsx(dr,{open:s,onOpenChange:r,children:N}),e[28]=s,e[29]=N,e[30]=S):S=e[30];let C;return e[31]!==S||e[32]!==b?(C=a.jsxs(a.Fragment,{children:[b,S]}),e[31]=S,e[32]=b,e[33]=C):C=e[33],C}function u9(n){const e=q.c(17),{suggestion:t,onAccept:s}=n,[r,o]=w.useState(null);if(!t||t===r)return null;let i;e[0]!==s||e[1]!==t?(i=()=>{o(t),s(t)},e[0]=s,e[1]=t,e[2]=i):i=e[2];let l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(ll,{"data-icon":"inline-start"}),e[3]=l):l=e[3];let c;e[4]!==t?(c=a.jsx("span",{className:"truncate",children:t}),e[4]=t,e[5]=c):c=e[5];let u;e[6]!==i||e[7]!==c?(u=a.jsxs(ee,{type:"button",variant:"ghost",size:"sm",title:"Put this in the composer",onClick:i,className:"min-w-0 flex-1 justify-start text-muted-foreground",children:[l,c]}),e[6]=i,e[7]=c,e[8]=u):u=e[8];let d;e[9]!==t?(d=()=>o(t),e[9]=t,e[10]=d):d=e[10];let f;e[11]===Symbol.for("react.memo_cache_sentinel")?(f=a.jsx(Ut,{}),e[11]=f):f=e[11];let m;e[12]!==d?(m=a.jsx(ee,{type:"button",variant:"ghost",size:"icon","aria-label":"Dismiss suggestion",onClick:d,className:"shrink-0 text-muted-foreground",children:f}),e[12]=d,e[13]=m):m=e[13];let p;return e[14]!==u||e[15]!==m?(p=a.jsxs("div",{className:"motion-enter mb-1 flex items-center gap-1",children:[u,m]}),e[14]=u,e[15]=m,e[16]=p):p=e[16],p}function d9(n){const e=/(?:^|\s)@([^\s]*)$/.exec(n);if(!e||e.index===void 0)return null;const t=e[0].lastIndexOf("@");return{start:e.index+t,query:e[1]??""}}function f9(n,e,t){return`${n.slice(0,e.start)}@${t} `}function mn(n){const e=q.c(3);let t,s;return e[0]!==n?(t=()=>pt(n),s=()=>pt(n),e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]),w.useSyncExternalStore(Fd,t,s)}function m9(n){const e=n.files;return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function p9(n,e,t){const s=mn("hostFiles"),[r,o]=w.useState([]),[i,l]=w.useState(!1);return w.useEffect(()=>{if(!s||!t||!n){o([]),l(!1);return}const c=new AbortController,u=window.setTimeout(async()=>{l(!0);try{const d=await Re(`/api/project-files?cwd=${encodeURIComponent(n)}&q=${encodeURIComponent(e)}&limit=30`,{signal:c.signal});if(!d.ok)throw new Error(`Request failed (${d.status})`);const f=await d.json();c.signal.aborted||o(m9(f))}catch{c.signal.aborted||o([])}finally{c.signal.aborted||l(!1)}},120);return()=>{window.clearTimeout(u),c.abort()}},[s,n,t,e]),{files:r,loading:i}}const Dh="cogpit-share-revoked";function h9(){window.dispatchEvent(new Event(Dh))}async function zj(n,e){const t=new Headers(e==null?void 0:e.headers);t.set("X-Cogpit-Client","1");const s=await fetch(n,{...e,headers:t,credentials:"same-origin",cache:"no-store"});return s.status===401&&h9(),s}function Yl(n,e){return zj(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e??{})})}async function g9(){let n;try{n=await fetch("/api/share/session",{credentials:"same-origin",cache:"no-store",headers:{"X-Cogpit-Client":"1"}})}catch{return{status:"error",message:"Could not reach the server."}}if(n.status===401)return{status:"unauthenticated"};if(!n.ok)return{status:"error",message:`The server refused the request (${n.status}).`};try{return{status:"ok",info:await n.json()}}catch{return{status:"error",message:"The server sent an unreadable response."}}}function x9(n,e){return Yl("/api/share/send-message",e!=null&&e.length?{message:n,images:e}:{message:n})}function b9(){return Yl("/api/share/interrupt")}function v9(){return Yl("/api/share/stop")}async function y9(n,e){return(await Yl("/api/share/permission",{requestId:n,behavior:e})).ok}async function w9(n,e){try{const t=await Yl("/api/share/answer",{toolUseId:n,answers:e});return{ok:t.ok,gone:t.status===404}}catch{return{ok:!1,gone:!1}}}async function S9(){try{const n=await zj("/api/share/pending");if(!n.ok)return null;const e=await n.json();return Array.isArray(e.permissions)?e.permissions:[]}catch{return null}}const k9=/^\/shared\/([^/]+)\/?$/;function Dj(n){const e=k9.exec(n);if(!e)return null;try{return decodeURIComponent(e[1])||null}catch{return null}}function Zd(n){return Dj(n)!==null}function j9(n){return`/shared/${encodeURIComponent(n)}`}function Mge(n){return[...n].join(", ")}async function O1(n,e){try{const t=await ws(n,e);return{ok:t.ok,gone:t.status===404}}catch{return{ok:!1,gone:!1}}}function L1(n,e,t){return Zd(window.location.pathname)?w9(e,t):O1("/api/ask-user-answer",{sessionId:n,toolUseId:e,answers:t})}async function N9(n,e,t){try{return(await ws(`/api/permissions/${encodeURIComponent(n)}/plan`,{requestId:e,...t})).ok}catch{return!1}}function Yd(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-background px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("textarea",{"data-slot":"textarea",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Lc(n,e){if(!n)return!1;const t=n.offsetHeight;n.style.transition="none",n.style.height="auto";const s=Math.min(n.scrollHeight,200);let r;if(e){const i=n.style.width;n.style.width=`${Math.max(100,n.offsetWidth-140)}px`,r=n.scrollHeight>48,n.style.width=i}else r=s>44;return t!==s&&(n.style.height=t+"px",n.offsetHeight,n.style.transition="height 150ms ease"),n.style.height=s+"px",r}function C9(n,e,t,s,r,o){return s?"Resolve approval to continue...":n?"Provide feedback to request changes...":e?"Type a custom response...":o?r?"Steer…":"Message…":r?"Steer the active turn… (Enter to send)":t?"Message... (Enter to send)":"Send a message... (Enter to send)"}function _9(n,e,t){return t?"border-warning/40 focus-within:border-warning/60 focus-within:ring-warning/15":n||e?"border-info/40 focus-within:border-info/60 focus-within:ring-info/15":"border-input focus-within:border-ring focus-within:ring-ring/20"}function E9(n,e,t){return n?"px-4 pb-1.5 pt-3.5":e?G("col-span-2 row-start-1",t?"py-2.5 pr-3 pl-2":"py-3 pr-4 pl-4"):G("col-start-2 row-start-1",t?"py-2 pr-1 pl-2":"py-2.5 pr-2 pl-4")}function T9(n,e){return n?"gap-1 px-2 pb-2 pt-0.5":e?"col-start-2 row-start-2 px-1.5 pb-1.5":"col-start-3 row-start-1 pr-1.5 pb-1.5"}const Fh=w.memo(w.forwardRef(function({allowImages:e=!0,agentKind:t,projectCwd:s,leadingAccessory:r,footer:o,compact:i=!1},l){var Ee;const c=mn("hostFiles"),{session:u,isLive:d,actions:{handleEditConfig:f},pendingInteraction:m,permissionRequests:p,permissionResponding:h,respondPermission:g,respondAllPermissions:x,slashSuggestions:b,slashSuggestionsLoading:y,turnError:v,promptSuggestion:k}=xt(),{chat:{status:j,error:_,isConnected:N,sendMessage:S,interrupt:C}}=Hl(),E=N||d,[T,A]=w.useState(""),[P,I]=w.useState(!1),[$,O]=w.useState(!1),[M,R]=w.useState(null),z=w.useRef(null),W=w.useRef(null),D=w.useRef(!1),L=w.useRef(""),U=w.useRef(null);w.useEffect(()=>{L.current=T},[T]);const F=w.useCallback(me=>{D.current=me,I(me)},[]),{images:B,isDragOver:V,imageError:H,hasUnsupportedAttachments:K,dismissImageError:Z,removeImage:Y,clearImages:X,restoreImages:se,handleDragOver:Q,handleDragLeave:te,handleDrop:J,handlePaste:ne}=e9(e),re=w.useRef(B);w.useEffect(()=>{re.current=B},[B]);const le=(u==null?void 0:u.sessionId)??null,ae=w.useRef(null),ue=w.useRef(null);w.useEffect(()=>{const me=()=>L.current.trim()!==""||re.current.length>0;ae.current={sessionId:le};const Oe=le&&!me()?r9(le):void 0;return Oe&&(ue.current=le,L.current=Oe.text,re.current=Oe.images,A(Oe.text),se(Oe.images)),()=>{ae.current=null,le&&ue.current===le&&me()&&(Sv(le,{text:L.current,images:re.current}),L.current="",re.current=[],A(""),X()),ue.current=null}},[le,se,X]);const[oe,ie]=w.useState(0),[fe,de]=w.useState(0),[ce,xe]=w.useState(!1),pe=T.startsWith("/")&&!T.includes(" "),he=pe?T.slice(1):"",ye=w.useMemo(()=>{if(!pe)return[];const me=he.toLowerCase(),Oe=b.filter(wt=>me?wt.name.toLowerCase().includes(me)||wt.description.toLowerCase().includes(me):!0),Ge=Oe.filter(wt=>wt.type==="command"),rt=Oe.filter(wt=>wt.type==="skill");return[...Ge,...rt]},[pe,he,b]),ve=w.useMemo(()=>d9(T),[T]),ke=!!(c&&ve&&s&&!ce),je=p9(s,(ve==null?void 0:ve.query)??"",ke);w.useEffect(()=>{ie(0)},[he]),w.useEffect(()=>{de(0)},[ve==null?void 0:ve.query]);const Me=Sj(N),_e=(m==null?void 0:m.type)==="plan"?m.requestId??null:null;w.useEffect(()=>{W.current=_e,z.current=null,O(!1),R(null)},[_e]);const Fe=w.useCallback(async me=>{const Oe=m;if(!(u!=null&&u.sessionId)||(Oe==null?void 0:Oe.type)!=="question")return;const Ge=Oe.questions[0];if(!Ge||!me.trim())return;(await L1(u.sessionId,Oe.toolUseId,{[Ge.question]:me})).ok||S(me)},[m,u==null?void 0:u.sessionId,S]),ze=w.useCallback(async(me,Oe,Ge)=>{const rt=m;if((rt==null?void 0:rt.type)==="plan"&&rt.provider==="copilot"&&rt.requestId&&(u!=null&&u.sessionId)){const wt=rt.requestId;if(z.current)return!1;z.current=wt,O(!0),R(null);try{const Ct=await N9(u.sessionId,wt,{approved:me,...Oe?{selectedAction:Oe}:{},...Ge?{feedback:Ge}:{}});return!Ct&&W.current===wt&&R("Couldn't send the plan response. Try again."),Ct}finally{z.current===wt&&(z.current=null,O(!1))}}return S(me?"yes":Ge||"no"),!0},[m,u==null?void 0:u.sessionId,S]),We=w.useCallback(()=>{requestAnimationFrame(()=>{const me=U.current;me&&(me.focus(),me.selectionStart=me.selectionEnd=me.value.length,F(Lc(me,D.current)))})},[F]),Pe=w.useCallback(me=>{A(`/${me.name} `),ie(0),We()},[We]),qe=w.useCallback(me=>{A(me),We()},[We]),be=w.useCallback(me=>{if(!ve)return;const Oe=f9(T,ve,me);A(Oe),xe(!0),de(0),requestAnimationFrame(()=>{const Ge=U.current;Ge&&(Ge.focus(),Ge.selectionStart=Ge.selectionEnd=Ge.value.length,F(Lc(Ge,D.current)))})},[ve,T,F]),Ie=w.useCallback(async()=>{const me=T.trim();if(!me&&B.length===0||!e&&B.length>0)return;if((m==null?void 0:m.type)==="question"){Fe(me),A(""),F(!1),U.current&&(U.current.style.height="auto");return}if((m==null?void 0:m.type)==="plan"&&m.provider==="copilot"){if(!me||!await ze(!1,void 0,me))return;A(""),F(!1),U.current&&(U.current.style.height="auto");return}const Oe=e&&B.length>0?B.map(rt=>({data:rt.data,mediaType:rt.mediaType})):void 0,Ge={text:T,images:B};ue.current=null,S(me,Oe).then(rt=>{var wt;if(!rt){if(((wt=ae.current)==null?void 0:wt.sessionId)!==le){le&&Sv(le,Ge);return}ue.current=le,A(Ct=>Ct||Ge.text),se(Ge.images)}}),A(""),X(),F(!1),U.current&&(U.current.style.height="auto")},[T,B,e,S,X,se,F,m,Fe,ze,le]),Se=w.useCallback(me=>{if(ke&&me.key==="Escape"){me.preventDefault(),xe(!0);return}if(ke&&je.files.length>0){if(me.key==="ArrowDown"){me.preventDefault(),de(Oe=>Oe<je.files.length-1?Oe+1:0);return}if(me.key==="ArrowUp"){me.preventDefault(),de(Oe=>Oe>0?Oe-1:je.files.length-1);return}if(me.key==="Tab"||me.key==="Enter"&&!me.shiftKey){me.preventDefault();const Oe=je.files[fe];Oe&&be(Oe);return}}if(pe&&ye.length>0){if(me.key==="ArrowDown"){me.preventDefault(),ie(Oe=>Oe<ye.length-1?Oe+1:0);return}if(me.key==="ArrowUp"){me.preventDefault(),ie(Oe=>Oe>0?Oe-1:ye.length-1);return}if(me.key==="Tab"||me.key==="Enter"&&!me.shiftKey){me.preventDefault();const Oe=ye[oe];Oe&&Pe(Oe);return}if(me.key==="Escape"){me.preventDefault(),A("");return}}if(me.key==="Escape"&&E&&C){me.preventDefault(),C();return}me.key==="Enter"&&!me.shiftKey&&(me.preventDefault(),Ie())},[Ie,E,C,ke,je.files,fe,be,pe,ye,oe,Pe]),Ne=w.useCallback(me=>{A(me.target.value),xe(!1),F(Lc(me.target,D.current))},[F]);w.useImperativeHandle(l,()=>({focus:()=>{var me;return(me=U.current)==null?void 0:me.focus()},getText:()=>L.current,setText:me=>{A(me),xe(!1),requestAnimationFrame(()=>F(Lc(U.current,D.current)))}}),[F]);const He=(m==null?void 0:m.type)==="plan",Ke=(m==null?void 0:m.type)==="question",Ce=p.length>0,Be=!!o,Ye=(T.trim().length>0||B.length>0)&&!K,Xe=xn(t??Go).midTurnSteering&&E,nt=ke?"file-suggestions":pe?"slash-suggestions":void 0,Qe=ke&&je.files[fe]?`file-suggestion-${fe}`:pe&&ye[oe]?`slash-suggestion-${oe}`:void 0;return a.jsxs("div",{className:G("relative pb-0",i?"px-2 pt-2":"px-3 pt-2",V&&"ring-2 ring-info/40 ring-inset"),onDragOver:Q,onDragLeave:te,onDrop:J,children:[V&&a.jsx("div",{className:"motion-enter pointer-events-none absolute inset-0 flex items-center justify-center rounded-lg border-2 border-dashed border-info/40 bg-info/10",children:a.jsx("span",{className:"text-sm font-medium text-info",children:"Drop images here"})}),pe&&a.jsx(D8,{suggestions:ye,filter:he,loading:y,selectedIndex:oe,onSelect:Pe,onHover:ie,onEdit:f}),ke&&a.jsx(W8,{files:je.files,query:(ve==null?void 0:ve.query)??"",loading:je.loading,selectedIndex:fe,onSelect:be,onHover:de}),a.jsxs("div",{children:[He&&a.jsx(Rj,{allowedPrompts:m.allowedPrompts,summary:m.summary,planContent:m.planContent,actions:m.actions,recommendedAction:m.recommendedAction,responding:$,responseError:M,onApprove:me=>{ze(!0,me)},onReject:()=>{ze(!1)}}),a.jsx(u9,{suggestion:k,onAccept:qe}),B.length>0&&a.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:B.map((me,Oe)=>a.jsxs("div",{className:"motion-list-item relative group/thumb",children:[a.jsx("img",{src:me.preview,alt:`Upload ${Oe+1}`,className:"h-16 w-auto rounded-md border bg-muted object-contain"}),a.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>Y(Oe),className:"absolute -right-1.5 -top-1.5 size-5 rounded-full border bg-popover p-0 text-muted-foreground opacity-100 hover:bg-destructive hover:text-destructive-foreground sm:opacity-0 sm:group-hover/thumb:opacity-100 sm:focus-visible:opacity-100","aria-label":`Remove image ${Oe+1}`,children:a.jsx(Ut,{className:"size-3","data-icon":"icon"})})]},me.id))}),H&&a.jsxs("div",{role:"status","aria-live":"polite",className:"motion-enter mb-2 flex items-center gap-2 text-xs text-warning",children:[a.jsx("span",{className:"flex-1",children:H}),!K&&a.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:Z,className:"text-muted-foreground","aria-label":"Dismiss image notice",children:a.jsx(Ut,{"data-icon":"icon"})})]}),a.jsxs("div",{className:G("relative overflow-hidden border bg-popover shadow-lg shadow-black/5 transition-[border-color,box-shadow] duration-150",Be?"rounded-3xl":"rounded-xl",_9(He,Ke,Ce),"focus-within:ring-3"),children:[Ce&&a.jsx(Oj,{requests:p,responding:h,onRespond:g,onRespondAll:x},(Ee=p[0])==null?void 0:Ee.requestId),a.jsxs("div",{className:G("min-w-0",Be?"flex flex-col":"grid items-end",!Be&&(P?"grid-cols-[1fr_auto]":"grid-cols-[auto_minmax(0,1fr)_auto]")),children:[r&&a.jsx("div",{className:G("flex shrink-0 items-center",P?"col-start-1 row-start-2 pl-0.5 pb-0.5":"col-start-1 row-start-1"),children:r}),a.jsx(Yd,{ref:U,value:T,onChange:Ne,onKeyDown:Se,onPaste:ne,onFocus:()=>{setTimeout(()=>{var me;return(me=U.current)==null?void 0:me.scrollIntoView({behavior:"smooth",block:"center"})},300)},placeholder:C9(He,Ke,N,Ce,Xe,i),"aria-label":"Message",role:"combobox","aria-autocomplete":"list","aria-expanded":!!nt,"aria-controls":nt,"aria-activedescendant":Qe,rows:1,className:G("min-h-0 w-full resize-none rounded-none border-0 bg-transparent text-sm text-foreground shadow-none placeholder:text-muted-foreground focus-visible:border-transparent focus-visible:ring-0",E9(Be,P,i))}),a.jsxs("div",{className:G("flex shrink-0 items-center justify-end",T9(Be,P)),children:[o,a.jsx(l9,{isPlanApproval:He,isUserQuestion:Ke,elapsedSec:Me}),a.jsx(c9,{hasContent:Ye,onSubmit:Ie,submitLabel:Xe?"Steer active turn":"Send message"})]})]})]}),j==="error"&&_&&a.jsx(kv,{error:_},_),v&&a.jsx(kv,{error:v},v)]})]})}));function M1(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function A9(n){return M1(n)?n:null}function P9(n){for(let e=n.length-1;e>=0;e-=1){const t=n[e];if(t.type!=="attachment")continue;const s=A9(t.attachment);if((s==null?void 0:s.type)!=="goal_status")continue;const r=typeof s.condition=="string"?s.condition:"",o=s.met===!0,i=s.failed===!0;return s.sentinel===!0&&o||!r?null:{condition:r,status:i?"failed":o?"achieved":"active",reason:typeof s.reason=="string"?s.reason:void 0,iterations:typeof s.iterations=="number"?s.iterations:0,durationMs:typeof s.durationMs=="number"?s.durationMs:0,tokens:typeof s.tokens=="number"?s.tokens:0}}return null}function Mc(n){return`/api/codex/goals/${encodeURIComponent(n)}`}function Zn({className:n,...e}){return a.jsx(j7,{"data-slot":"input",className:G("h-8 w-full min-w-0 rounded-lg border border-input bg-background px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",n),...e})}function Xl(n){const e=q.c(13);let t,s,r,o;e[0]!==n?({className:s,children:t,value:o,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o):(t=e[1],s=e[2],r=e[3],o=e[4]);let i;e[5]!==s?(i=G("flex flex-wrap gap-3",s),e[5]=s,e[6]=i):i=e[6];let l;e[7]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(I9,{children:a.jsx($9,{})}),e[7]=l):l=e[7];let c;return e[8]!==t||e[9]!==r||e[10]!==i||e[11]!==o?(c=a.jsxs(N7,{value:o,"data-slot":"progress",className:i,...r,children:[t,l]}),e[8]=t,e[9]=r,e[10]=i,e[11]=o,e[12]=c):c=e[12],c}function I9(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("relative flex h-1 w-full items-center overflow-x-hidden rounded-full bg-muted",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(C7,{className:r,"data-slot":"progress-track",...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function $9(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("h-full bg-primary transition-[width] duration-150 ease-out motion-reduce:transition-none",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(_7,{"data-slot":"progress-indicator",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Fj(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-sm font-medium",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(E7,{className:r,"data-slot":"progress-label",...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Uj(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("ml-auto text-sm text-muted-foreground tabular-nums",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(T7,{className:r,"data-slot":"progress-value",...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}const R9={section:null,canCreate:!1,beginEditing:()=>{}},z1=w.createContext(R9);function Bj(){return w.useContext(z1)}const Wj="mx-3 mb-1.5 rounded-lg border border-border bg-muted/30 px-2.5 py-1",qj="mx-3 mb-1.5 rounded-lg border border-border bg-muted/30 px-2.5 py-2";function O9(n){return n==="usageLimited"?"Usage limited":n==="budgetLimited"?"Budget limited":n.charAt(0).toUpperCase()+n.slice(1)}function L9(n){return n==="complete"?"secondary":n==="blocked"||n.endsWith("Limited")?"destructive":n==="paused"?"outline":"default"}function M9({agentKind:n,threadId:e,children:t}){const s=Hd(n),[r,o]=w.useState(null),[i,l]=w.useState(!0),[c,u]=w.useState(!1),[d,f]=w.useState(""),[m,p]=w.useState(""),[h,g]=w.useState(!1),[x,b]=w.useState(null),y=w.useCallback(async E=>{try{const T=await Re(Mc(e),{signal:E});if(T.status===404||T.status===501){l(!1);return}if(!T.ok)return;const A=await T.json();o(A.goal),l(!0)}catch{}},[e]);w.useEffect(()=>{const E=new AbortController;y(E.signal);const T=i?setInterval(()=>void y(),1e4):void 0;return()=>{E.abort(),T!==void 0&&clearInterval(T)}},[y,i]);const v=w.useCallback(()=>{var E;f((r==null?void 0:r.objective)??""),p(((E=r==null?void 0:r.tokenBudget)==null?void 0:E.toString())??""),b(null),u(!0)},[r]),k=async()=>{const E=d.trim();if(!E)return;const T=m.trim()?Number(m):null;if(T!==null&&(!Number.isSafeInteger(T)||T<=0)){b("Token budget must be a positive whole number");return}g(!0),b(null);try{const A=await Re(Mc(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({objective:E,status:(r==null?void 0:r.status)==="complete"?"active":(r==null?void 0:r.status)??"active",tokenBudget:T})}),P=await A.json();if(!A.ok)throw new Error(P.error||"Could not save goal");o(P.goal),u(!1)}catch(A){b(A instanceof Error?A.message:"Could not save goal")}finally{g(!1)}},j=async E=>{if(r){g(!0);try{const T=await Re(Mc(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:E})});T.ok&&o((await T.json()).goal)}finally{g(!1)}}},_=async()=>{g(!0);try{(await Re(Mc(e),{method:"DELETE"})).ok&&(o(null),u(!1))}finally{g(!1)}},N=r!=null&&r.tokenBudget?Math.min(100,r.tokensUsed/r.tokenBudget*100):null;let S=null;if(i&&c)S=a.jsxs("form",{className:qj,onSubmit:E=>{E.preventDefault(),k()},children:[a.jsxs("div",{className:"mb-2 flex items-center gap-1.5 text-xs font-medium text-foreground",children:[a.jsx(ul,{className:"size-3.5","data-icon":"inline-start"}),r?"Edit long-running goal":"Set a long-running goal"]}),a.jsxs(Vl,{className:"gap-2",children:[a.jsxs(un,{children:[a.jsx(dn,{className:"sr-only",htmlFor:"goal-objective",children:"Goal objective"}),a.jsx(Yd,{id:"goal-objective",value:d,onChange:E=>f(E.target.value),placeholder:`What should ${s} keep working toward?`,rows:2,autoFocus:!0})]}),a.jsxs(un,{orientation:"horizontal","data-invalid":!!x,children:[a.jsx(dn,{className:"text-xs text-muted-foreground",htmlFor:"goal-budget",children:"Token budget"}),a.jsx(Zn,{id:"goal-budget",type:"number",min:1,step:1,value:m,onChange:E=>p(E.target.value),placeholder:"Optional",className:"ml-auto h-8 w-28","aria-invalid":!!x})]})]}),a.jsx(to,{className:"mt-1.5",children:x}),a.jsxs("div",{className:"mt-2 flex items-center justify-end gap-1",children:[a.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>u(!1),children:[a.jsx(Ut,{"data-icon":"inline-start"}),"Cancel"]}),a.jsxs(ee,{type:"submit",size:"xs",disabled:h||!d.trim(),children:[a.jsx(Ft,{"data-icon":"inline-start"}),"Save goal"]})]})]});else if(i&&r){const E=r.status==="paused",T=r.status==="complete";S=a.jsxs("section",{className:Wj,"aria-label":`${s} goal`,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ul,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground",title:r.objective,children:r.objective}),a.jsx(Ue,{variant:L9(r.status),children:O9(r.status)}),a.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[Nt(r.tokensUsed),r.tokenBudget?` / ${Nt(r.tokenBudget)}`:""," · ",Math.max(0,Math.round(r.timeUsedSeconds/60)),"m"]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[E&&a.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void j("active"),disabled:h,"aria-label":"Resume goal",children:a.jsx(Yi,{"data-icon":"icon"})}),!E&&!T&&a.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void j("paused"),disabled:h,"aria-label":"Pause goal",children:a.jsx(A7,{"data-icon":"icon"})}),!T&&a.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void j("complete"),disabled:h,"aria-label":"Mark goal complete",children:a.jsx(Ft,{"data-icon":"icon"})}),a.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:v,"aria-label":"Edit goal",children:a.jsx(Er,{"data-icon":"icon"})}),a.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void _(),disabled:h,className:"text-destructive","aria-label":"Clear goal",children:a.jsx(Od,{"data-icon":"icon"})})]})]}),N!==null&&a.jsx(Xl,{className:"mt-1 mb-0.5",value:N,"aria-label":`${N.toFixed(0)}% of goal token budget used`})]})}const C=w.useMemo(()=>({section:S,canCreate:i&&!r&&!c,beginEditing:v}),[S,i,r,c,v]);return a.jsx(z1.Provider,{value:C,children:t})}function z9(n){switch(n){case"active":return"Goal active";case"achieved":return"Achieved";default:return"Needs attention"}}function D9(n){switch(n){case"failed":return"destructive";case"achieved":return"secondary";default:return"outline"}}function F9(n){const e=q.c(89),{agentKind:t,session:s,onSendCommand:r,children:o}=n;let i;e[0]!==t?(i=Hd(t),e[0]=t,e[1]=i):i=e[1];const l=i;let c;e[2]!==s.rawMessages?(c=P9(s.rawMessages),e[2]=s.rawMessages,e[3]=c):c=e[3];const u=c,[d,f]=w.useState(),[m,p]=w.useState(!1),[h,g]=w.useState(""),[x,b]=w.useState(null),y=u?`${u.status}\0${u.condition}`:"",[v,k]=w.useState(y);v!==y&&(k(y),f(void 0));const j=d!==void 0?d:u;let _;e[4]!==(j==null?void 0:j.condition)?(_=()=>{g((j==null?void 0:j.condition)??""),b(null),p(!0)},e[4]=j==null?void 0:j.condition,e[5]=_):_=e[5];const N=_;let S;e[6]!==r||e[7]!==d?(S=async(z,W)=>{const D=d;f(W),p(!1);const L=await r(z);return L||f(D),L},e[6]=r,e[7]=d,e[8]=S):S=e[8];const C=S;let E;e[9]!==h||e[10]!==C?(E=async()=>{const z=h.trim();if(!z)return;if(z.length>4e3){b("Goal conditions can be at most 4,000 characters");return}await C(`/goal ${z}`,{condition:z,status:"active",iterations:0,durationMs:0,tokens:0})||(g(z),p(!0))},e[9]=h,e[10]=C,e[11]=E):E=e[11];const T=E;let A;e[12]!==C?(A=()=>void C("/goal clear",null),e[12]=C,e[13]=A):A=e[13];const P=A;let I;if(e[14]!==l||e[15]!==N||e[16]!==P||e[17]!==h||e[18]!==m||e[19]!==x||e[20]!==j||e[21]!==T){if(I=null,m){let z;e[23]===Symbol.for("react.memo_cache_sentinel")?(z=a.jsx(ul,{className:"size-3.5","data-icon":"inline-start"}),e[23]=z):z=e[23];const W=j?"Replace goal":"Set a long-running goal";let D;e[24]!==W?(D=a.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5 text-xs font-medium text-foreground",children:[z,W]}),e[24]=W,e[25]=D):D=e[25];const L=!!x;let U;e[26]===Symbol.for("react.memo_cache_sentinel")?(U=a.jsx(dn,{className:"sr-only",htmlFor:"goal-condition",children:"Goal condition"}),e[26]=U):U=e[26];let F;e[27]===Symbol.for("react.memo_cache_sentinel")?(F=ne=>g(ne.target.value),e[27]=F):F=e[27];const B=`A measurable condition ${l} should keep working toward…`,V=!!x;let H;e[28]!==h||e[29]!==B||e[30]!==V?(H=a.jsx(Yd,{id:"goal-condition",value:h,onChange:F,placeholder:B,rows:2,maxLength:4e3,"aria-invalid":V,autoFocus:!0}),e[28]=h,e[29]=B,e[30]=V,e[31]=H):H=e[31];let K;e[32]!==x?(K=a.jsx(to,{children:x}),e[32]=x,e[33]=K):K=e[33];let Z;e[34]!==L||e[35]!==H||e[36]!==K?(Z=a.jsxs(un,{"data-invalid":L,children:[U,H,K]}),e[34]=L,e[35]=H,e[36]=K,e[37]=Z):Z=e[37];let Y;e[38]===Symbol.for("react.memo_cache_sentinel")?(Y=a.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>p(!1),children:[a.jsx(Ut,{"data-icon":"inline-start"}),"Cancel"]}),e[38]=Y):Y=e[38];let X;e[39]!==T?(X=()=>void T(),e[39]=T,e[40]=X):X=e[40];let se;e[41]!==h?(se=h.trim(),e[41]=h,e[42]=se):se=e[42];const Q=!se;let te;e[43]===Symbol.for("react.memo_cache_sentinel")?(te=a.jsx(Ft,{"data-icon":"inline-start"}),e[43]=te):te=e[43];let J;e[44]!==X||e[45]!==Q?(J=a.jsxs("div",{className:"mt-2 flex items-center justify-end gap-1",children:[Y,a.jsxs(ee,{type:"button",size:"xs",onClick:X,disabled:Q,children:[te,"Start goal"]})]}),e[44]=X,e[45]=Q,e[46]=J):J=e[46],I=a.jsxs("section",{className:qj,"aria-label":`${l} goal editor`,children:[D,Z,J]})}else if(j){let z;e[47]===Symbol.for("react.memo_cache_sentinel")?(z=a.jsx(ul,{className:"size-3.5 shrink-0 text-primary","data-icon":"inline-start"}),e[47]=z):z=e[47];let W;e[48]!==j.condition?(W=a.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground",title:j.condition,children:j.condition}),e[48]=j.condition,e[49]=W):W=e[49];let D;e[50]!==j.status?(D=D9(j.status),e[50]=j.status,e[51]=D):D=e[51];let L;e[52]!==j.status?(L=z9(j.status),e[52]=j.status,e[53]=L):L=e[53];let U;e[54]!==L||e[55]!==D?(U=a.jsx(Ue,{variant:D,children:L}),e[54]=L,e[55]=D,e[56]=U):U=e[56];const F=j.iterations,B=j.iterations===1?"":"s";let V;e[57]!==j.tokens?(V=Nt(j.tokens),e[57]=j.tokens,e[58]=V):V=e[58];let H;e[59]!==j.durationMs?(H=Math.round(j.durationMs/6e4),e[59]=j.durationMs,e[60]=H):H=e[60];const K=Math.max(0,H);let Z;e[61]!==j.iterations||e[62]!==B||e[63]!==V||e[64]!==K?(Z=a.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[F," turn",B," · ",V," · ",K,"m"]}),e[61]=j.iterations,e[62]=B,e[63]=V,e[64]=K,e[65]=Z):Z=e[65];let Y;e[66]===Symbol.for("react.memo_cache_sentinel")?(Y=a.jsx(Er,{"data-icon":"icon"}),e[66]=Y):Y=e[66];let X;e[67]!==N?(X=a.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:N,"aria-label":"Replace goal",children:Y}),e[67]=N,e[68]=X):X=e[68];let se;e[69]===Symbol.for("react.memo_cache_sentinel")?(se=a.jsx(Od,{"data-icon":"icon"}),e[69]=se):se=e[69];let Q;e[70]!==P?(Q=a.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:P,"aria-label":"Clear goal",children:se}),e[70]=P,e[71]=Q):Q=e[71];let te;e[72]!==X||e[73]!==Q?(te=a.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[X,Q]}),e[72]=X,e[73]=Q,e[74]=te):te=e[74];let J;e[75]!==U||e[76]!==Z||e[77]!==te||e[78]!==W?(J=a.jsxs("div",{className:"flex items-center gap-2",children:[z,W,U,Z,te]}),e[75]=U,e[76]=Z,e[77]=te,e[78]=W,e[79]=J):J=e[79];let ne;e[80]!==j.reason?(ne=j.reason&&a.jsx("p",{className:"line-clamp-2 pb-0.5 pl-5 text-xs text-muted-foreground",children:j.reason}),e[80]=j.reason,e[81]=ne):ne=e[81],I=a.jsxs("section",{className:Wj,"aria-label":`${l} goal`,children:[J,ne]})}e[14]=l,e[15]=N,e[16]=P,e[17]=h,e[18]=m,e[19]=x,e[20]=j,e[21]=T,e[22]=I}else I=e[22];const $=!j&&!m;let O;e[82]!==N||e[83]!==I||e[84]!==$?(O={section:I,canCreate:$,beginEditing:N},e[82]=N,e[83]=I,e[84]=$,e[85]=O):O=e[85];const M=O;let R;return e[86]!==o||e[87]!==M?(R=a.jsx(z1.Provider,{value:M,children:o}),e[86]=o,e[87]=M,e[88]=R):R=e[88],R}function U9(n){const e=q.c(9),{agentKind:t,session:s,onSendCommand:r,children:o}=n,i=xn(t).goals;if(i==="thread-api"){let l;return e[0]!==t||e[1]!==o||e[2]!==s.sessionId?(l=a.jsx(M9,{agentKind:t,threadId:s.sessionId,children:o}),e[0]=t,e[1]=o,e[2]=s.sessionId,e[3]=l):l=e[3],l}if(i==="transcript"){let l;return e[4]!==t||e[5]!==o||e[6]!==r||e[7]!==s?(l=a.jsx(F9,{agentKind:t,session:s,onSendCommand:r,children:o}),e[4]=t,e[5]=o,e[6]=r,e[7]=s,e[8]=l):l=e[8],l}return o}function B9(){return Bj().section}function jv(){const n=q.c(3),{canCreate:e,beginEditing:t}=Bj();if(!e)return null;let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(ul,{"data-icon":"inline-start"}),n[0]=s):s=n[0];let r;return n[1]!==t?(r=a.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:t,title:"Set a long-running goal for this session",children:[s,"Set goal"]}),n[1]=t,n[2]=r):r=n[2],r}const W9=/\x1b\].*?(?:\x07|\x1b\\)/g,q9=/\x1b\[[0-9;]*[A-Za-z]/g,V9=/\x1b[()][AB012]/g,H9=/\[2K\[1G/g;function Vj(n){return n.replace(W9,"").replace(q9,"").replace(V9,"").replace(H9,`
|
|
5
|
+
`).replace(/\r/g,"")}const Uh="cogpit-session-config-changed";function K9(n){if(typeof n!="string")return null;let e;try{e=JSON.parse(n)}catch{e=n.trim()}if(typeof e=="string")return e||null;const t=e==null?void 0:e.sessionId;return typeof t=="string"?t:null}function G9(n){function e(t){const s=K9(t.data);s&&window.dispatchEvent(new CustomEvent(Uh,{detail:{sessionId:s}}))}return n.addEventListener(ev,e),()=>n.removeEventListener(ev,e)}function Z9(n,e){function t(s){var r;((r=s.detail)==null?void 0:r.sessionId)===n&&e()}return window.addEventListener(Uh,t),()=>window.removeEventListener(Uh,t)}function D1(n,{onLost:e}={}){const t=new EventSource(g1(n)),s=JI(t),r=G9(t),o=new AbortController;return t.addEventListener("error",()=>{t.readyState!==EventSource.CLOSED||fl().enforcesSessionAccess!==!0||Re(n,{signal:o.signal}).then(i=>{var l;return!o.signal.aborted&&G3(i)&&(e==null||e()),(l=i.body)==null?void 0:l.cancel()},()=>{})}),{source:t,close:()=>{o.abort(),s(),r(),t.close()}}}function Jl({className:n,children:e,...t}){return a.jsxs(P7,{"data-slot":"scroll-area",className:G("relative overflow-hidden",n),...t,children:[a.jsx(I7,{"data-slot":"scroll-area-viewport",className:"size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",children:e}),a.jsx(Y9,{}),a.jsx($7,{})]})}function Y9({className:n,orientation:e="vertical",...t}){return a.jsx(R7,{"data-slot":"scroll-area-scrollbar","data-orientation":e,orientation:e,className:G("flex touch-none p-px transition-colors select-none data-[orientation=horizontal]:h-2.5 data-[orientation=horizontal]:flex-col data-[orientation=horizontal]:border-t data-[orientation=horizontal]:border-t-transparent data-[orientation=vertical]:h-full data-[orientation=vertical]:w-2.5 data-[orientation=vertical]:border-l data-[orientation=vertical]:border-l-transparent",n),...t,children:a.jsx(O7,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"})})}function Hj({className:n,...e}){return a.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",className:G("status-icon-spin size-5",n),...e,children:[a.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.2"}),a.jsx("path",{d:"M12 2A10 10 0 0 1 22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function X9({className:n,...e}){return a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:G("size-5",n),...e,children:a.jsx("path",{className:"status-icon-complete",d:"M20 6L9 17L4 12"})})}function J9({className:n,...e}){return a.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:G("size-5",n),...e,children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function Q9({className:n,...e}){return a.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",className:G("status-icon-spin size-5",n),...e,children:[a.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.1"}),a.jsx("path",{d:"M12 2A10 10 0 0 1 22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),a.jsx("path",{d:"M12 22A10 10 0 0 1 2 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function An({className:n,...e}){const t=n==null?void 0:n.replace(/\banimate-spin\b/g,"").trim();return a.jsx(Hj,{className:G(t),...e})}function eO(n){const e=mn("hostFiles"),[t,s]=w.useState([]),[r,o]=w.useState(!1),i=w.useCallback(async()=>{if(!e||!n){s([]);return}o(!0);try{const l=await Re(`/api/scripts?dir=${encodeURIComponent(n)}`);if(l.ok){const c=await l.json();s(c)}}catch{}finally{o(!1)}},[e,n]);return w.useEffect(()=>{i()},[i]),{scripts:t,loading:r,refresh:i}}const Nv=500,tO=5e3;function nO(n){const e=q.c(29),t=n===void 0?!0:n,[s,r]=w.useState("disconnected");let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=[],e[0]=o):o=e[0];const[i,l]=w.useState(o),c=w.useRef(null);let u;e[1]===Symbol.for("react.memo_cache_sentinel")?(u=new Map,e[1]=u):u=e[1];const d=w.useRef(u),f=w.useRef(Nv),m=w.useRef(null),p=w.useRef(!1),h=w.useRef(sO);let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=W=>{var U;const D=W.type,L=W.id;if(D==="sessions"){l(W.sessions??[]);return}L&&((U=d.current.get(L))==null||U(D,W))},e[2]=g):g=e[2];const x=g;let b,y;e[3]!==t?(b=()=>{if(p.current=!1,!t)return()=>{p.current=!0};const W=function(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}${O3()}/__pty`},D=function(){if(p.current||c.current&&c.current.readyState!==WebSocket.CLOSED)return;r("connecting");const U=new WebSocket(W());c.current=U,U.onopen=()=>{if(p.current){U.close();return}f.current=Nv,r("connected"),U.send(JSON.stringify({type:"list"}))},U.onmessage=F=>{try{const B=JSON.parse(F.data);x(B)}catch{}},U.onclose=()=>{if(p.current)return;r("disconnected"),c.current=null;const F=f.current;f.current=Math.min(F*2,tO),m.current=setTimeout(()=>h.current(),F)}};return h.current=D,D(),()=>{p.current=!0,m.current&&(clearTimeout(m.current),m.current=null),c.current&&(c.current.onclose=null,c.current.close(),c.current=null)}},y=[t,x],e[3]=t,e[4]=b,e[5]=y):(b=e[4],y=e[5]),w.useEffect(b,y);let v;e[6]!==t?(v=W=>{if(!t)return;const D=c.current;D&&D.readyState===WebSocket.OPEN&&D.send(JSON.stringify(W))},e[6]=t,e[7]=v):v=e[7];const k=v;let j;e[8]===Symbol.for("react.memo_cache_sentinel")?(j=(W,D)=>{d.current.set(W,D)},e[8]=j):j=e[8];const _=j;let N;e[9]===Symbol.for("react.memo_cache_sentinel")?(N=W=>{d.current.delete(W)},e[9]=N):N=e[9];const S=N;let C;e[10]!==k?(C=W=>{const D=W===void 0?{}:W,L=`pty_${crypto.randomUUID().slice(0,8)}`;return k({type:"spawn",id:L,name:D.name??"Terminal",cwd:D.cwd,metadata:{type:"terminal"}}),L},e[10]=k,e[11]=C):C=e[11];const E=C;let T;e[12]!==k?(T=W=>{const D=`script_${crypto.randomUUID().slice(0,8)}`;return k({type:"spawn",id:D,name:W.name,cwd:W.cwd,args:["run",W.scriptName],command:"bun",metadata:{type:"script",source:W.source,scriptName:W.scriptName}}),D},e[12]=k,e[13]=T):T=e[13];const A=T;let P;e[14]!==k?(P=W=>{k({type:"kill",id:W})},e[14]=k,e[15]=P):P=e[15];const I=P;let $;e[16]!==k?($=(W,D)=>{k({type:"input",id:W,data:D})},e[16]=k,e[17]=$):$=e[17];const O=$;let M;e[18]!==k?(M=(W,D,L)=>{k({type:"resize",id:W,cols:D,rows:L})},e[18]=k,e[19]=M):M=e[19];const R=M;let z;return e[20]!==I||e[21]!==R||e[22]!==k||e[23]!==i||e[24]!==A||e[25]!==E||e[26]!==s||e[27]!==O?(z={status:s,send:k,subscribe:_,unsubscribe:S,sessions:i,spawnTerminal:E,spawnScript:A,killSession:I,writeInput:O,resize:R},e[20]=I,e[21]=R,e[22]=k,e[23]=i,e[24]=A,e[25]=E,e[26]=s,e[27]=O,e[28]=z):z=e[28],z}function sO(){}const Kj=w.createContext(null);function lm(n){const e=q.c(3),{children:t,enabled:s}=n,o=nO(s===void 0?!0:s);let i;return e[0]!==t||e[1]!==o?(i=a.jsx(Kj.Provider,{value:o,children:t}),e[0]=t,e[1]=o,e[2]=i):i=e[2],i}function F1(){const n=w.useContext(Kj);if(!n)throw new Error("usePty must be used within a PtyProvider");return n}function rO(n){var d;const e=q.c(11),t=F1();let s;if(e[0]!==t.sessions){s=new Map;for(const f of t.sessions)((d=f.metadata)==null?void 0:d.type)==="script"&&s.set(f.id,{id:f.id,name:f.name,cwd:f.cwd,status:f.status==="running"?"running":"stopped",source:f.metadata.source??"root/"});e[0]=t.sessions,e[1]=s}else s=e[1];const r=s;let o;e[2]!==n||e[3]!==t?(o=(f,m,p)=>{const h=t.spawnScript({name:f,cwd:m,source:p,scriptName:f}),g=p==="root/"?f:`${p.replace(/\/$/,"")}:${f}`;n==null||n({id:h,name:g,type:"script",status:"running",source:p})},e[2]=n,e[3]=t,e[4]=o):o=e[4];const i=o;let l;e[5]!==t?(l=f=>{t.killSession(f)},e[5]=t,e[6]=l):l=e[6];const c=l;let u;return e[7]!==i||e[8]!==r||e[9]!==c?(u={runningProcesses:r,runScript:i,stopScript:c},e[7]=i,e[8]=r,e[9]=c,e[10]=u):u=e[10],u}function oO(n){const e=q.c(14),{script:t,status:s,onRun:r,onStop:o}=n,i=s==="running";let l="bg-transparent";i?l="bg-primary":s==="errored"&&(l="bg-destructive");const c=i?o:r,u=i?`Stop ${t.name}`:`Run: ${t.command}`;let d;e[0]!==l?(d=G("size-1.5 shrink-0 rounded-full",l),e[0]=l,e[1]=d):d=e[1];let f;e[2]!==d?(f=a.jsx("span",{className:d}),e[2]=d,e[3]=f):f=e[3];let m;e[4]!==t.name?(m=a.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:t.name}),e[4]=t.name,e[5]=m):m=e[5];let p;e[6]!==i?(p=i?a.jsx(e1,{"data-icon":"inline-end",className:"fill-current text-destructive"}):a.jsx(Yi,{"data-icon":"inline-end",className:"opacity-0 text-muted-foreground transition-opacity group-hover:opacity-100"}),e[6]=i,e[7]=p):p=e[7];let h;return e[8]!==c||e[9]!==u||e[10]!==f||e[11]!==m||e[12]!==p?(h=a.jsxs(ee,{type:"button",variant:"ghost",size:"sm",className:"motion-list-item group w-full justify-start px-2",onClick:c,title:u,children:[f,m,p]}),e[8]=c,e[9]=u,e[10]=f,e[11]=m,e[12]=p,e[13]=h):h=e[13],h}const iO=w.memo(function(e){const t=q.c(42),{projectDir:s,onProcessStarted:r}=e,[o,i]=w.useState(!1),[l,c]=w.useState("");let u;t[0]===Symbol.for("react.memo_cache_sentinel")?(u=new Set,t[0]=u):u=t[0];const[d,f]=w.useState(u),{scripts:m,loading:p}=eO(s),{runningProcesses:h,runScript:g,stopScript:x}=rO(r);let b;if(t[1]!==m||t[2]!==l){const D=l.trim().toLowerCase(),L=D?m.filter(U=>U.name.toLowerCase().includes(D)||U.dirLabel.toLowerCase().includes(D)):m;b=new Map;for(const U of L){const F=b.get(U.dirLabel)??[];F.push(U),b.set(U.dirLabel,F)}t[1]=m,t[2]=l,t[3]=b}else b=t[3];const y=b;let v;if(t[4]!==h){v=new Map;for(const[D,L]of h)v.set(`${L.name}:${L.cwd}`,{id:D,status:L.status});t[4]=h,t[5]=v}else v=t[5];const k=v;if(!s||!p&&m.length===0)return null;let j;t[6]===Symbol.for("react.memo_cache_sentinel")?(j=function(L){f(U=>{const F=new Set(U);return F.has(L)?F.delete(L):F.add(L),F})},t[6]=j):j=t[6];const _=j;let N;t[7]===Symbol.for("react.memo_cache_sentinel")?(N=a.jsx("span",{className:"flex-1 text-xs font-medium text-muted-foreground",children:"Scripts"}),t[7]=N):N=t[7];let S;t[8]!==p?(S=p&&a.jsx(An,{className:"size-3 text-muted-foreground","aria-label":"Loading scripts"}),t[8]=p,t[9]=S):S=t[9];const C=o?"Close script search":"Search scripts";let E,T;t[10]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{i(aO),c("")},T=a.jsx(Yn,{}),t[10]=E,t[11]=T):(E=t[10],T=t[11]);let A;t[12]!==o||t[13]!==C?(A=a.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm","aria-label":C,"aria-expanded":o,onClick:E,children:T}),t[12]=o,t[13]=C,t[14]=A):A=t[14];let P;t[15]!==S||t[16]!==A?(P=a.jsxs("div",{className:"flex h-8 shrink-0 items-center gap-2 px-2",children:[N,S,A]}),t[15]=S,t[16]=A,t[17]=P):P=t[17];let I;t[18]!==o||t[19]!==l?(I=o&&a.jsx("div",{className:"motion-slide-down-in px-2 pb-2",children:a.jsx(Zn,{type:"search",value:l,onChange:D=>c(D.target.value),placeholder:"Filter scripts...","aria-label":"Filter scripts",className:"h-7",autoFocus:!0})}),t[18]=o,t[19]=l,t[20]=I):I=t[20];let $;t[21]!==d||t[22]!==y||t[23]!==g||t[24]!==k||t[25]!==l||t[26]!==x?($=[...y.entries()].map(D=>{const[L,U]=D,F=d.has(L)||!!l,B=U.filter(lO),V=U.filter(cO),H=F?U:B.length>0?B:U.slice(0,1);return a.jsxs("div",{className:"flex flex-col gap-0.5 pb-1",children:[y.size>1&&a.jsx("div",{className:"truncate px-2 pt-1 text-xs text-muted-foreground",children:L}),H.map(K=>{const Z=k.get(`${K.name}:${K.dir}`);return a.jsx(oO,{script:K,status:(Z==null?void 0:Z.status)??null,onRun:()=>g(K.name,K.dir,K.dirLabel),onStop:()=>{Z&&x(Z.id)}},`${L}:${K.name}`)}),!l&&V.length>0&&a.jsx(ee,{type:"button",variant:"link",size:"sm",className:"h-auto justify-start px-2 py-1",onClick:()=>_(L),children:F?"Show less":`Show ${V.length} more`})]},L)}),t[21]=d,t[22]=y,t[23]=g,t[24]=k,t[25]=l,t[26]=x,t[27]=$):$=t[27];let O;t[28]!==y.size||t[29]!==p||t[30]!==l?(O=!p&&y.size===0&&l&&a.jsx(kn,{className:"gap-1 p-3",children:a.jsxs(jn,{className:"gap-1",children:[a.jsx(Nn,{children:"No matching scripts"}),a.jsx(Cn,{children:"Try another name."})]})}),t[28]=y.size,t[29]=p,t[30]=l,t[31]=O):O=t[31];let M;t[32]!==$||t[33]!==O?(M=a.jsxs(Jl,{className:"min-h-0 flex-1 px-1 pb-1",children:[$,O]}),t[32]=$,t[33]=O,t[34]=M):M=t[34];let R;t[35]!==I||t[36]!==M||t[37]!==P?(R=a.jsxs("section",{className:"flex w-56 shrink-0 flex-col","aria-label":"Scripts",children:[P,I,M]}),t[35]=I,t[36]=M,t[37]=P,t[38]=R):R=t[38];let z;t[39]===Symbol.for("react.memo_cache_sentinel")?(z=a.jsx(Gt,{orientation:"vertical"}),t[39]=z):z=t[39];let W;return t[40]!==R?(W=a.jsxs(a.Fragment,{children:[R,z]}),t[40]=R,t[41]=W):W=t[41],W});function aO(n){return!n}function lO(n){return n.isCommon}function cO(n){return!n.isCommon}function Gj({className:n,orientation:e="horizontal",...t}){return a.jsx(D7,{"data-slot":"tabs","data-orientation":e,className:G("group/tabs relative flex gap-2 data-[orientation=horizontal]:flex-col","has-[>[data-slot=tabs-content]]:grid has-[>[data-slot=tabs-content]]:grid-cols-1 [&>[data-slot=tabs-list]]:col-start-1 [&>[data-slot=tabs-list]]:row-start-1 [&>[data-slot=tabs-content]]:col-start-1 [&>[data-slot=tabs-content]]:row-start-2","data-[orientation=vertical]:has-[>[data-slot=tabs-content]]:grid-cols-[auto_minmax(0,1fr)] data-[orientation=vertical]:[&>[data-slot=tabs-content]]:col-start-2 data-[orientation=vertical]:[&>[data-slot=tabs-content]]:row-start-1",n),...t})}const uO=Lr("group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-[orientation=horizontal]/tabs:h-8 group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col data-[variant=line]:rounded-none",{variants:{variant:{default:"bg-muted",line:"gap-1 bg-transparent"}},defaultVariants:{variant:"default"}});function Zj({className:n,children:e,variant:t="default",...s}){return a.jsxs(M7,{"data-slot":"tabs-list","data-variant":t,className:G(uO({variant:t}),"relative isolate",n),...s,children:[e,a.jsx(z7,{"data-slot":"tabs-indicator","data-variant":t,className:G("pointer-events-none absolute top-0 left-0 z-0 h-(--active-tab-height) w-(--active-tab-width) translate-x-(--active-tab-left) translate-y-(--active-tab-top) transition-[translate,width,height] duration-150 ease-out motion-reduce:transition-none after:absolute after:content-['']","data-[variant=default]:after:inset-0 data-[variant=default]:after:rounded-md data-[variant=default]:after:bg-background data-[variant=default]:after:shadow-sm","data-[variant=line]:after:bg-foreground data-[variant=line]:data-[orientation=horizontal]:after:inset-x-0 data-[variant=line]:data-[orientation=horizontal]:after:-bottom-[5px] data-[variant=line]:data-[orientation=horizontal]:after:h-0.5 data-[variant=line]:data-[orientation=vertical]:after:inset-y-0 data-[variant=line]:data-[orientation=vertical]:after:-right-1 data-[variant=line]:data-[orientation=vertical]:after:w-0.5")})]})}function Ea({className:n,...e}){return a.jsx(F7,{"data-slot":"tabs-trigger",className:G("relative z-10 inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 outline-none transition-[color,border-color,box-shadow,transform,scale] duration-100 ease-out group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start hover:text-foreground active:scale-[0.98] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-active:text-foreground dark:text-muted-foreground dark:hover:text-foreground dark:data-active:text-foreground motion-reduce:transition-none motion-reduce:active:scale-100 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",n),...e})}function Ta({className:n,...e}){return a.jsx(L7,{"data-slot":"tabs-content",className:G("flex-1 text-sm outline-none transition-[opacity,translate] duration-150 ease-out motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none","motion-safe:data-starting-style:data-[activation-direction=left]:translate-x-[-0.25rem] motion-safe:data-starting-style:data-[activation-direction=right]:translate-x-[0.25rem] motion-safe:data-ending-style:data-[activation-direction=left]:translate-x-[0.25rem] motion-safe:data-ending-style:data-[activation-direction=right]:translate-x-[-0.25rem]","motion-safe:data-starting-style:data-[activation-direction=up]:translate-y-[-0.25rem] motion-safe:data-starting-style:data-[activation-direction=down]:translate-y-[0.25rem] motion-safe:data-ending-style:data-[activation-direction=up]:translate-y-[0.25rem] motion-safe:data-ending-style:data-[activation-direction=down]:translate-y-[-0.25rem]",n),...e})}const dO=w.lazy(()=>et(()=>import("./TerminalOutput-BCG6Ppu3.js"),__vite__mapDeps([0,1,2,3,4])).then(n=>({default:n.TerminalOutput})));function fO({process:n}){const[e,t]=w.useState(""),[s,r]=w.useState(!1),o=w.useRef(null);return w.useEffect(()=>{if(n.type!=="task"||!n.outputPath)return;t(""),r(!1);const i=D1(`/api/task-output?path=${encodeURIComponent(n.outputPath)}`),l=i.source;return l.onopen=()=>r(!0),l.onmessage=c=>{try{const u=JSON.parse(c.data);if(u.type==="output"&&u.text){const d=Vj(u.text);d&&t(f=>{const m=f+d;return m.length>1e5?m.slice(-1e5):m})}}catch{}},i.close},[n.id,n.type,n.outputPath]),w.useEffect(()=>{o.current&&(o.current.scrollTop=o.current.scrollHeight)},[e]),a.jsx("pre",{ref:o,className:"flex-1 overflow-auto bg-background px-3 py-2 font-mono text-xs leading-relaxed text-foreground whitespace-pre-wrap break-words",children:e||a.jsx("span",{className:"text-muted-foreground",children:s?"Waiting for output...":"Connecting..."})})}function mO(n){const e=q.c(34),{process:t,isActive:s,onSelectActive:r,onClose:o,mobile:i}=n,l=t.source??t.name,c=t.id,u=t.name;let d;e[0]!==s||e[1]!==r?(d=()=>{s&&r()},e[0]=s,e[1]=r,e[2]=d):d=e[2];const f=i?"gap-1 px-1.5":"gap-1.5 px-2";let m;e[3]!==f?(m=G("h-6 min-w-0 justify-start py-0 text-xs",f),e[3]=f,e[4]=m):m=e[4];let p;e[5]!==t.status?(p=t.status==="running"&&a.jsx("span",{className:"inline-block size-1.5 shrink-0 rounded-full bg-success"}),e[5]=t.status,e[6]=p):p=e[6];let h;e[7]!==t.status?(h=t.status==="errored"&&a.jsx("span",{className:"inline-block size-1.5 shrink-0 rounded-full bg-destructive"}),e[7]=t.status,e[8]=h):h=e[8];let g;e[9]!==t.name?(g=a.jsx("span",{className:"truncate max-w-[100px]",children:t.name}),e[9]=t.name,e[10]=g):g=e[10];const x=i&&"hidden";let b;e[11]!==x?(b=G("px-1 py-0 font-normal",x),e[11]=x,e[12]=b):b=e[12];let y;e[13]!==t.type||e[14]!==b?(y=a.jsx(Ue,{variant:"secondary",className:b,children:t.type}),e[13]=t.type,e[14]=b,e[15]=y):y=e[15];let v;e[16]!==t.id||e[17]!==t.name||e[18]!==y||e[19]!==d||e[20]!==m||e[21]!==p||e[22]!==h||e[23]!==g?(v=a.jsxs(Ea,{value:c,"aria-label":u,onClick:d,className:m,children:[p,h,g,y]}),e[16]=t.id,e[17]=t.name,e[18]=y,e[19]=d,e[20]=m,e[21]=p,e[22]=h,e[23]=g,e[24]=v):v=e[24];const k=`Close ${t.name}`,j=`Close ${t.name}`;let _;e[25]===Symbol.for("react.memo_cache_sentinel")?(_=a.jsx(Ut,{"data-icon":"inline-start"}),e[25]=_):_=e[25];let N;e[26]!==o||e[27]!==k||e[28]!==j?(N=a.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs","aria-label":k,title:j,onClick:o,className:"mr-0.5 text-muted-foreground",children:_}),e[26]=o,e[27]=k,e[28]=j,e[29]=N):N=e[29];let S;return e[30]!==l||e[31]!==v||e[32]!==N?(S=a.jsxs("div",{title:l,className:"inline-flex h-6 shrink-0 items-center",children:[v,N]}),e[30]=l,e[31]=v,e[32]=N,e[33]=S):S=e[33],S}const Yj=100,Xj=600,pO=200,Jj="process-panel-height";function hO(){try{const n=localStorage.getItem(Jj);if(n)return Math.min(Xj,Math.max(Yj,Number(n)))}catch{}return pO}const gO=w.memo(function(e){const t=q.c(89),{processes:s,activeProcessId:r,collapsed:o,onSetActive:i,onRemove:l,onToggleCollapse:c,onRequestTerminal:u,onAddTerminalContext:d,onUpdateStatus:f,projectDir:m,onProcessStarted:p,mobile:h}=e,g=h===void 0?!1:h,x=F1(),[b,y]=w.useState(hO),v=w.useRef(null);let k,j;t[0]!==f||t[1]!==x.sessions?(k=()=>{for(const ce of x.sessions)ce.status==="exited"&&(f==null||f(ce.id,"stopped"))},j=[x.sessions,f],t[0]=f,t[1]=x.sessions,t[2]=k,t[3]=j):(k=t[2],j=t[3]),w.useEffect(k,j);let _;t[4]!==l||t[5]!==x?(_=ce=>{ce.type!=="task"&&x.killSession(ce.id),l(ce.id)},t[4]=l,t[5]=x,t[6]=_):_=t[6];const N=_;let S;t[7]!==b?(S=ce=>{ce.preventDefault(),v.current={startY:ce.clientY,startH:b},ce.target.setPointerCapture(ce.pointerId)},t[7]=b,t[8]=S):S=t[8];const C=S;let E;t[9]===Symbol.for("react.memo_cache_sentinel")?(E=ce=>{if(!v.current)return;const xe=v.current.startY-ce.clientY,pe=Math.min(Xj,Math.max(Yj,v.current.startH+xe));y(pe)},t[9]=E):E=t[9];const T=E;let A;t[10]!==b?(A=()=>{if(v.current){v.current=null;try{localStorage.setItem(Jj,String(b))}catch{}}},t[10]=b,t[11]=A):A=t[11];const P=A;let I;t[12]!==r||t[13]!==s?(I=r?s.get(r):null,t[12]=r,t[13]=s,t[14]=I):I=t[14];const $=I;let O;t[15]!==s?(O=[...s.values()],t[15]=s,t[16]=O):O=t[16];const M=O;let R;t[17]!==i?(R=ce=>{typeof ce=="string"&&i(ce)},t[17]=i,t[18]=R):R=t[18];let z;t[19]!==$||t[20]!==o||t[21]!==g||t[22]!==C||t[23]!==P?(z=!g&&!o&&$&&a.jsx("div",{className:"h-1 cursor-row-resize transition-colors hover:bg-accent active:bg-muted-foreground/30",onPointerDown:C,onPointerMove:T,onPointerUp:P,onPointerCancel:P}),t[19]=$,t[20]=o,t[21]=g,t[22]=C,t[23]=P,t[24]=z):z=t[24];const W=g?"h-7 gap-1 px-2":"h-8 gap-2 px-3";let D;t[25]!==W?(D=G("flex shrink-0 items-center border-b bg-card",W),t[25]=W,t[26]=D):D=t[26];const L=o?"Expand terminal panel":"Collapse terminal panel",U=!o;let F;t[27]!==o?(F=o?a.jsx(ot,{"data-icon":"inline-start"}):a.jsx(Ot,{"data-icon":"inline-start"}),t[27]=o,t[28]=F):F=t[28];const B=g&&"sr-only";let V;t[29]!==B?(V=G(B),t[29]=B,t[30]=V):V=t[30];let H;t[31]!==V?(H=a.jsx("span",{className:V,children:"Terminal"}),t[31]=V,t[32]=H):H=t[32];let K;t[33]!==c||t[34]!==L||t[35]!==U||t[36]!==F||t[37]!==H?(K=a.jsxs(ee,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2",onClick:c,"aria-label":L,"aria-expanded":U,children:[F,H]}),t[33]=c,t[34]=L,t[35]=U,t[36]=F,t[37]=H,t[38]=K):K=t[38];const Z=!g&&"ml-2";let Y;t[39]!==Z?(Y=G("min-w-0 flex-1 justify-start overflow-x-auto no-scrollbar",Z),t[39]=Z,t[40]=Y):Y=t[40];let X;t[41]!==r||t[42]!==N||t[43]!==g||t[44]!==i||t[45]!==M?(X=M.map(ce=>a.jsx(mO,{process:ce,isActive:ce.id===r,onSelectActive:()=>i(ce.id),onClose:()=>N(ce),mobile:g},ce.id)),t[41]=r,t[42]=N,t[43]=g,t[44]=i,t[45]=M,t[46]=X):X=t[46];let se;t[47]!==Y||t[48]!==X?(se=a.jsx(Zj,{variant:"default","aria-label":"Open processes",className:Y,children:X}),t[47]=Y,t[48]=X,t[49]=se):se=t[49];let Q;t[50]!==u||t[51]!==m?(Q=u&&a.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",disabled:!m,onClick:u,"aria-label":"New terminal",title:m?"New terminal":"Open a project to start a terminal",children:a.jsx(tr,{})}),t[50]=u,t[51]=m,t[52]=Q):Q=t[52];let te;t[53]!==D||t[54]!==K||t[55]!==se||t[56]!==Q?(te=a.jsxs("div",{className:D,children:[K,se,Q]}),t[53]=D,t[54]=K,t[55]=se,t[56]=Q,t[57]=te):te=t[57];const J=!o,ne=g?"min(36dvh, 260px)":b;let re;t[58]!==ne?(re={height:ne},t[58]=ne,t[59]=re):re=t[59];let le;t[60]!==g||t[61]!==p||t[62]!==m?(le=!g&&a.jsx(iO,{projectDir:m,onProcessStarted:p}),t[60]=g,t[61]=p,t[62]=m,t[63]=le):le=t[63];let ae;t[64]!==N||t[65]!==d||t[66]!==u||t[67]!==M?(ae=M.map(ce=>a.jsx(Ta,{value:ce.id,className:"col-start-1 row-start-1 flex min-h-0 flex-col",children:ce.type==="task"?a.jsx(fO,{process:ce}):a.jsx(w.Suspense,{fallback:a.jsx("div",{className:"flex size-full items-center justify-center text-xs text-muted-foreground",children:"Loading terminal…"}),children:a.jsx(dO,{processId:ce.id,autoFocus:!0,onRequestNew:u,onRequestClose:()=>N(ce),onAddContext:d})})},ce.id)),t[64]=N,t[65]=d,t[66]=u,t[67]=M,t[68]=ae):ae=t[68];let ue;t[69]!==$||t[70]!==u||t[71]!==m?(ue=!$&&a.jsxs(kn,{className:"col-start-1 row-start-1 rounded-none",children:[a.jsxs(jn,{children:[a.jsx(Rn,{variant:"icon",children:a.jsx(Xi,{})}),a.jsx(Nn,{children:"No terminal open"}),a.jsx(Cn,{children:"Start a terminal here or run a project script from the left."})]}),u&&m&&a.jsx(zl,{children:a.jsxs(ee,{type:"button",size:"sm",onClick:u,children:[a.jsx(tr,{"data-icon":"inline-start"}),"New terminal"]})})]}),t[69]=$,t[70]=u,t[71]=m,t[72]=ue):ue=t[72];let oe;t[73]!==ae||t[74]!==ue?(oe=a.jsxs("div",{className:"grid min-h-0 min-w-0 flex-1 grid-cols-1",children:[ae,ue]}),t[73]=ae,t[74]=ue,t[75]=oe):oe=t[75];let ie;t[76]!==re||t[77]!==le||t[78]!==oe?(ie=a.jsx(Tn,{children:a.jsxs("div",{className:"flex min-h-0",style:re,children:[le,oe]})}),t[76]=re,t[77]=le,t[78]=oe,t[79]=ie):ie=t[79];let fe;t[80]!==J||t[81]!==ie?(fe=a.jsx(En,{open:J,className:"min-h-0",children:ie}),t[80]=J,t[81]=ie,t[82]=fe):fe=t[82];let de;return t[83]!==r||t[84]!==R||t[85]!==z||t[86]!==te||t[87]!==fe?(de=a.jsxs(Gj,{value:r,onValueChange:R,className:"shrink-0 gap-0 border-t bg-background",children:[z,te,fe]}),t[83]=r,t[84]=R,t[85]=z,t[86]=te,t[87]=fe,t[88]=de):de=t[88],de});function Ql(n){const e=q.c(2),{children:t}=n;let s;return e[0]!==t?(s=a.jsx("h3",{className:"mb-3 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:t}),e[0]=t,e[1]=s):s=e[1],s}const xO=/(?::(\d{4,5}))|(?:port\s+(\d{4,5}))|(?:localhost:(\d{4,5}))/gi;function bO(n){const e=new Set;for(const t of n.matchAll(xO)){const s=parseInt(t[1]||t[2]||t[3],10);s>0&&s<65536&&e.add(s)}return[...e]}function vO(n){var s;const e=q.c(2);let t;if(e[0]!==n){t=new Map;for(let r=0;r<n.length;r++)for(const o of n[r].toolCalls){if(o.name!=="Bash"||!o.input.run_in_background)continue;const i=o.input.command||"",l=o.input.description||"",c=((s=n[r].assistantText)==null?void 0:s.join(" "))||"",u=[i,l,o.result||"",c].join(" "),d=bO(u);if(d.length===0){const p=i.toLowerCase();(p.includes("run dev")||p.includes("next dev")||p.includes("vite"))&&d.push(3e3)}const f=(o.result||"").match(/Output is being written to:\s*(\S+)/),m=f?f[1]:null;for(const p of d)t.set(p,{description:l||i.replace(/^cd\s+"[^"]*"\s*&&\s*/,"").slice(0,60),outputPath:m})}e[0]=n,e[1]=t}else t=e[1];return t}function Cv(n){var e;return((e=n.preview.split(`
|
|
6
|
+
`).find(t=>t.trim()))==null?void 0:e.trim())||`Task ${n.id}`}function yO(n){const e=q.c(10),{port:t,isActive:s}=n,r=s?"bg-success":"bg-muted-foreground/40";let o;e[0]!==r?(o=G("inline-block size-1.5 rounded-full",r),e[0]=r,e[1]=o):o=e[1];let i;e[2]!==o?(i=a.jsx("span",{className:o}),e[2]=o,e[3]=i):i=e[3];const l=s?"text-success":"text-muted-foreground";let c;e[4]!==t||e[5]!==l?(c=a.jsxs("span",{className:l,children:[":",t]}),e[4]=t,e[5]=l,e[6]=c):c=e[6];let u;return e[7]!==i||e[8]!==c?(u=a.jsxs(Ue,{variant:"secondary",className:"font-mono",children:[i,c]}),e[7]=i,e[8]=c,e[9]=u):u=e[9],u}function Qj({cwd:n,turns:e,canStop:t=!1,onToggleServer:s,onServersChanged:r}){const[o,i]=w.useState([]),l=vO(e);w.useEffect(()=>{if(!n)return;let u=!1;async function d(){try{const m=await Re(`/api/background-tasks?cwd=${encodeURIComponent(n)}`);if(u)return;if(m.ok){const g=await m.json();if(u)return;if(g.length>0){i(g);return}}if(l.size===0){i([]);return}const p=[...l.keys()],h=await Re(`/api/check-ports?ports=${p.join(",")}`);if(u)return;if(h.ok){const g=await h.json();if(u)return;const x=[],b=new Set;for(const[y,v]of l)!g[y]||b.has(y)||(b.add(y),x.push({id:`port-${y}`,outputPath:v.outputPath,ports:[y],portStatus:{[y]:!0},preview:v.description}));i(x)}}catch{}}d();const f=setInterval(d,1e4);return()=>{u=!0,clearInterval(f)}},[n,l]);const c=w.useCallback(async u=>{try{await Re("/api/kill-port",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({port:u})}),setTimeout(()=>{i(d=>d.filter(f=>!f.ports.includes(u)))},1500)}catch{}},[]);return w.useEffect(()=>{if(!r)return;const u=o.filter(d=>d.outputPath).map(d=>({id:d.id,outputPath:d.outputPath,title:Cv(d)}));r(u)},[o,r]),o.length===0?null:a.jsxs("section",{children:[a.jsxs(Ql,{children:["Active Servers (",o.length,")"]}),a.jsx("div",{className:"flex flex-col gap-1.5",children:o.map(u=>{const d=u.ports.filter(m=>u.portStatus[m]),f=Cv(u);return a.jsxs("div",{className:"border-b border-border px-2 py-2 last:border-b-0",children:[a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(y3,{className:"size-3 shrink-0 text-success","data-icon":"inline-start"}),a.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:f})]}),a.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5",children:[u.ports.map(m=>a.jsx(yO,{port:m,isActive:u.portStatus[m]},m)),a.jsx("div",{className:"flex-1"}),u.outputPath&&a.jsx(ee,{variant:"ghost",size:"icon-xs",onClick:()=>s==null?void 0:s(u.id,u.outputPath,f),title:"View server output","aria-label":"View server output",children:a.jsx(Xi,{"data-icon":"inline-start"})}),t&&d.length>0&&a.jsxs(ee,{variant:"ghost",size:"xs",className:"text-destructive",onClick:()=>d.forEach(m=>c(m)),title:"Stop server","aria-label":"Stop server",children:[a.jsx(e1,{"data-icon":"inline-start",className:"fill-current"}),a.jsx("span",{children:"Stop"})]})]})]},u.id)})})]})}function U1(n){const e=q.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(U7,{"data-slot":"alert-dialog",...t}),e[2]=t,e[3]=s):s=e[3],s}function wO(n){const e=q.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(B7,{"data-slot":"alert-dialog-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function SO(n){const e=q.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(Xg,{"data-slot":"alert-dialog-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}function kO(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("fixed inset-0 isolate z-50 bg-black/55 duration-150 ease-out data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0 data-closed:duration-100 data-closed:ease-in motion-reduce:animate-none",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(Jg,{"data-slot":"alert-dialog-overlay",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function B1(n){const e=q.c(11);let t,s,r;e[0]!==n?({className:t,size:r,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);const o=r===void 0?"default":r;let i;e[4]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsx(kO,{}),e[4]=i):i=e[4];let l;e[5]!==t?(l=G("group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl border bg-popover p-4 text-popover-foreground shadow-lg duration-150 ease-out outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-100 data-closed:ease-in motion-reduce:animate-none",t),e[5]=t,e[6]=l):l=e[6];let c;return e[7]!==s||e[8]!==o||e[9]!==l?(c=a.jsxs(SO,{children:[i,a.jsx(Yg,{"data-slot":"alert-dialog-content","data-size":o,className:l,...s})]}),e[7]=s,e[8]=o,e[9]=l,e[10]=c):c=e[10],c}function W1(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"alert-dialog-header",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function q1(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"alert-dialog-footer",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function jO(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("mb-2 inline-flex size-10 items-center justify-center rounded-md bg-muted sm:group-data-[size=default]/alert-dialog-content:row-span-2 *:[svg:not([class*='size-'])]:size-6",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"alert-dialog-media",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function V1(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-base font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(Gg,{"data-slot":"alert-dialog-title",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function H1(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(Zg,{"data-slot":"alert-dialog-description",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function K1(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G(t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(ee,{"data-slot":"alert-dialog-action",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function G1(n){const e=q.c(14);let t,s,r,o;e[0]!==n?({className:t,variant:r,size:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o):(t=e[1],s=e[2],r=e[3],o=e[4]);const i=r===void 0?"outline":r,l=o===void 0?"default":o;let c;e[5]!==t?(c=G(t),e[5]=t,e[6]=c):c=e[6];let u;e[7]!==l||e[8]!==i?(u=a.jsx(ee,{variant:i,size:l}),e[7]=l,e[8]=i,e[9]=u):u=e[9];let d;return e[10]!==s||e[11]!==c||e[12]!==u?(d=a.jsx(Ol,{"data-slot":"alert-dialog-cancel",className:c,render:u,...s}),e[10]=s,e[11]=c,e[12]=u,e[13]=d):d=e[13],d}function e4(n){const e=q.c(9);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input outline-none transition-[color,background-color,border-color,box-shadow,transform,scale] duration-100 ease-out active:scale-90 group-has-disabled/field:opacity-50 group-has-[:focus-visible]/field-label:ring-0 group-has-[:focus-visible]/field-label:not-data-checked:border-input after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary bg-background dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground group-has-[:focus-visible]/field-label:data-checked:border-primary motion-reduce:transition-none motion-reduce:active:scale-100",t),e[3]=t,e[4]=r):r=e[4];let o;e[5]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx(q7,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-[opacity,transform,scale] duration-100 ease-out motion-safe:data-starting-style:scale-75 motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:scale-75 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none [&>svg]:size-3.5",children:a.jsx(Ft,{})}),e[5]=o):o=e[5];let i;return e[6]!==s||e[7]!==r?(i=a.jsx(W7,{"data-slot":"checkbox",className:r,...s,children:o}),e[6]=s,e[7]=r,e[8]=i):i=e[8],i}const NO={undo:"Undo turns?",redo:"Redo turns?","branch-switch":"Switch branch?"},CO={undo:"This will revert file changes from the following turns.",redo:"This will re-apply file changes from the following turns.","branch-switch":"This will switch to a different branch, undoing current changes and applying the branch's changes."};function _O({state:n,isApplying:e,applyError:t,onConfirm:s,onCancel:r}){var f,m;const o=w.useRef(n),[i,l]=w.useState({key:"",selected:!1});w.useEffect(()=>{n&&(o.current=n)},[n]);const c=n??o.current;if(!c)return null;const u=((f=c.nativeRewind)==null?void 0:f.eventId)??`${c.type}:${c.targetTurnIndex}:${c.branchId??""}`,d=i.key===u&&i.selected;return a.jsx(U1,{open:n!==null,onOpenChange:p=>{p||r()},onOpenChangeComplete:p=>{p||(o.current=null,l({key:"",selected:!1}))},children:a.jsxs(B1,{children:[a.jsxs(W1,{children:[a.jsx(jO,{children:a.jsx(lr,{className:"text-warning"})}),a.jsx(V1,{children:NO[c.type]}),a.jsx(H1,{children:c.nativeRewind?d?"This removes the selected turn and everything after it, restoring captured files.":"This removes the selected turn and everything after it. Files stay unchanged.":CO[c.type]})]}),a.jsxs("div",{className:"flex flex-col gap-2 py-2",children:[a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("span",{className:"text-muted-foreground",children:"Turns affected"}),a.jsx("span",{className:"text-foreground font-mono",children:c.summary.turnCount})]}),a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("span",{className:"text-muted-foreground",children:"Files affected"}),a.jsx("span",{className:"text-foreground font-mono",children:c.summary.fileCount})]}),a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("span",{className:"text-muted-foreground",children:"Operations"}),a.jsx("span",{className:"text-foreground font-mono",children:c.summary.operationCount})]}),c.summary.filePaths.length>0&&a.jsx("div",{className:"mt-2 max-h-32 overflow-y-auto rounded-md border bg-muted/30 p-2",children:c.summary.filePaths.map(p=>a.jsx("div",{className:"truncate font-mono text-xs text-muted-foreground",children:p},p))}),((m=c.nativeRewind)==null?void 0:m.filesAvailable)&&a.jsxs("label",{className:"mt-2 flex items-center gap-2 text-sm text-foreground",children:[a.jsx(e4,{checked:d,disabled:e,onCheckedChange:p=>l({key:u,selected:p===!0})}),"Restore captured file changes"]})]}),t&&a.jsx(Jt,{variant:"destructive",children:a.jsx(Qt,{children:t})}),a.jsxs(q1,{children:[a.jsx(G1,{onClick:r,disabled:e,children:"Cancel"}),a.jsx(K1,{onClick:()=>s(d),disabled:e,children:e?a.jsxs(a.Fragment,{children:[a.jsx(vt,{"data-icon":"inline-start",className:"animate-spin"}),"Applying..."]}):c.type==="undo"?"Undo":c.type==="redo"?"Redo":"Switch"})]})]})})}function Ts(n){const e=q.c(10);let t,s,r;e[0]!==n?({className:t,size:r,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);const o=r===void 0?"default":r;let i;e[4]!==t?(i=G("group/card flex flex-col gap-4 overflow-hidden rounded-xl bg-card py-4 text-sm text-card-foreground ring-1 ring-foreground/10 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",t),e[4]=t,e[5]=i):i=e[5];let l;return e[6]!==s||e[7]!==o||e[8]!==i?(l=a.jsx("div",{"data-slot":"card","data-size":o,className:i,...s}),e[6]=s,e[7]=o,e[8]=i,e[9]=l):l=e[9],l}function Ys(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-4 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"card-header",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Xs(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-base leading-snug font-medium group-data-[size=sm]/card:text-sm",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"card-title",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Js(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-sm text-muted-foreground",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"card-description",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function EO(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("col-start-2 row-span-2 row-start-1 self-start justify-self-end",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"card-action",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function As(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("px-4 group-data-[size=sm]/card:px-3",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"card-content",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Xd(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex items-center rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/card:p-3",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"card-footer",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function So(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("group/input-group relative flex h-8 w-full min-w-0 items-center rounded-lg border border-input transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto bg-background dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"input-group",role:"group",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}const TO=Lr("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4",{variants:{align:{"inline-start":"order-first pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem]","inline-end":"order-last pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem]","block-start":"order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2","block-end":"order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2"}},defaultVariants:{align:"inline-start"}});function or(n){const e=q.c(11);let t,s,r;e[0]!==n?({className:t,align:r,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);const o=r===void 0?"inline-start":r;let i;e[4]!==o||e[5]!==t?(i=G(TO({align:o}),t),e[4]=o,e[5]=t,e[6]=i):i=e[6];let l;return e[7]!==o||e[8]!==s||e[9]!==i?(l=a.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":o,className:i,onClick:AO,...s}),e[7]=o,e[8]=s,e[9]=i,e[10]=l):l=e[10],l}function AO(n){var e,t;n.target.closest("button")||(t=(e=n.currentTarget.parentElement)==null?void 0:e.querySelector("input"))==null||t.focus()}const PO=Lr("flex items-center gap-2 text-sm shadow-none",{variants:{size:{xs:"h-6 gap-1 rounded-[calc(var(--radius)-3px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5",sm:"","icon-xs":"size-6 rounded-[calc(var(--radius)-3px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function Jd(n){const e=q.c(15);let t,s,r,o,i;e[0]!==n?({className:t,type:r,variant:o,size:i,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i):(t=e[1],s=e[2],r=e[3],o=e[4],i=e[5]);const l=r===void 0?"button":r,c=o===void 0?"ghost":o,u=i===void 0?"xs":i;let d;e[6]!==t||e[7]!==u?(d=G(PO({size:u}),t),e[6]=t,e[7]=u,e[8]=d):d=e[8];let f;return e[9]!==s||e[10]!==u||e[11]!==d||e[12]!==l||e[13]!==c?(f=a.jsx(ee,{type:l,"data-size":u,variant:c,className:d,...s}),e[9]=s,e[10]=u,e[11]=d,e[12]=l,e[13]=c,e[14]=f):f=e[14],f}function ko(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(Zn,{"data-slot":"input-group-control",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function IO(){const[n,e]=w.useState("idle"),[t,s]=w.useState(null),r=w.useRef(void 0),o=w.useCallback(async u=>{if(!u.trim()){e("idle"),s(null);return}e("validating"),s(null);try{const f=await(await Re(`/api/config/validate?path=${encodeURIComponent(u)}`)).json();f.valid?(e("valid"),s(null)):(e("invalid"),s(f.error||"Invalid path"))}catch{e("invalid"),s("Failed to validate path")}},[]),i=w.useCallback(u=>{clearTimeout(r.current),r.current=setTimeout(()=>o(u),400)},[o]),l=w.useCallback(()=>{e("idle"),s(null),clearTimeout(r.current)},[]),c=w.useCallback(async(u,d)=>{try{const f=await Re("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({claudeDir:u,...d})}),m=await f.json();return f.ok&&m.success?{success:!0,claudeDir:m.claudeDir}:(s(m.error||"Failed to save"),e("invalid"),{success:!1,error:m.error})}catch{return s("Failed to save configuration"),{success:!1,error:"Network error"}}},[]);return w.useEffect(()=>()=>clearTimeout(r.current),[]),{status:n,error:t,debouncedValidate:i,validate:o,reset:l,save:c}}const mi=g$(n=>!n.cli.homeIsDiscoverable,"a home Cogpit has to be told about"),t4=Fl().filter(n=>n.cli.homeIsDiscoverable);function n4(n){return n.flatMap((e,t)=>t===0?[e]:[t===n.length-1?" and ":", ",e])}function s4(n){const e=q.c(2),{children:t}=n;let s;return e[0]!==t?(s=a.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-xs text-foreground",children:t}),e[0]=t,e[1]=s):s=e[1],s}const $O=n4(t4.map(n=>n.displayName)),RO=n4(t4.map(n=>a.jsx(s4,{children:["~",n.cli.homeDirName,n.cli.installMarker].filter(Boolean).join("/")},n.kind))),OO=`~/${mi.cli.homeDirName}`;function LO(n){const e=q.c(46),{onConfigured:t}=n,[s,r]=w.useState(""),[o,i]=w.useState(!1),{status:l,error:c,debouncedValidate:u,save:d}=IO();let f;e[0]!==u?(f=z=>{const W=z.target.value;r(W),u(W)},e[0]=u,e[1]=f):f=e[1];const m=f;let p;e[2]!==t||e[3]!==s||e[4]!==d?(p=async()=>{i(!0);const z=await d(s);z.success&&z.claudeDir&&t(z.claudeDir),i(!1)},e[2]=t,e[3]=s,e[4]=d,e[5]=p):p=e[5];const h=p;let g;e[6]!==h||e[7]!==o||e[8]!==l?(g=z=>{z.preventDefault(),l==="valid"&&!o&&h()},e[6]=h,e[7]=o,e[8]=l,e[9]=g):g=e[9];let x,b;e[10]===Symbol.for("react.memo_cache_sentinel")?(x=a.jsx("div",{className:"mb-2 flex size-9 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:a.jsx(Qg,{className:"size-4"})}),b=a.jsx(Xs,{children:"Connect your coding agent"}),e[10]=x,e[11]=b):(x=e[10],b=e[11]);let y;e[12]===Symbol.for("react.memo_cache_sentinel")?(y=a.jsxs(Ys,{children:[x,b,a.jsxs(Js,{children:["Cogpit detects ",$O," automatically. Existing histories live in"," ",RO,"."," ","For ",mi.displayName,", enter its data directory, usually"," ",a.jsx(s4,{children:OO}),"."]})]}),e[12]=y):y=e[12];const v=l==="invalid";let k;e[13]===Symbol.for("react.memo_cache_sentinel")?(k=a.jsxs(dn,{htmlFor:"agent-data-directory",children:[mi.displayName," data directory"]}),e[13]=k):k=e[13];let j;e[14]===Symbol.for("react.memo_cache_sentinel")?(j=a.jsx(or,{children:a.jsx(Tr,{"aria-hidden":"true"})}),e[14]=j):j=e[14];const _=l==="invalid";let N;e[15]!==m||e[16]!==s||e[17]!==_?(N=a.jsxs(So,{children:[j,a.jsx(ko,{id:"agent-data-directory",value:s,onChange:m,placeholder:`/Users/you/${mi.cli.homeDirName}`,autoFocus:!0,"aria-invalid":_,"aria-describedby":"agent-directory-status"})]}),e[15]=m,e[16]=s,e[17]=_,e[18]=N):N=e[18];let S;e[19]!==l?(S=l==="validating"&&a.jsxs(Zu,{className:"flex items-center gap-2",children:[a.jsx(An,{className:"size-4"}),"Checking path..."]}),e[19]=l,e[20]=S):S=e[20];let C;e[21]!==l?(C=l==="valid"&&a.jsxs(Zu,{className:"flex items-center gap-2 text-success",children:[a.jsx($d,{className:"size-4"}),mi.displayName," history found"]}),e[21]=l,e[22]=C):C=e[22];let E;e[23]!==c||e[24]!==l?(E=l==="invalid"&&c&&a.jsxs(to,{className:"flex items-center gap-2",children:[a.jsx(vo,{className:"size-4"}),c]}),e[23]=c,e[24]=l,e[25]=E):E=e[25];let T;e[26]!==S||e[27]!==C||e[28]!==E?(T=a.jsxs("div",{id:"agent-directory-status",className:"min-h-5",role:"status","aria-live":"polite",children:[S,C,E]}),e[26]=S,e[27]=C,e[28]=E,e[29]=T):T=e[29];let A;e[30]!==N||e[31]!==T||e[32]!==v?(A=a.jsx(As,{children:a.jsx(Vl,{children:a.jsxs(un,{"data-invalid":v,children:[k,N,T]})})}),e[30]=N,e[31]=T,e[32]=v,e[33]=A):A=e[33];const P=l!=="valid"||o;let I;e[34]!==o?(I=o&&a.jsx(An,{"data-icon":"inline-start"}),e[34]=o,e[35]=I):I=e[35];const $=o?"Saving...":`Connect ${mi.displayName}`;let O;e[36]!==P||e[37]!==I||e[38]!==$?(O=a.jsx(Xd,{children:a.jsxs(ee,{type:"submit",className:"w-full",disabled:P,children:[I,$]})}),e[36]=P,e[37]=I,e[38]=$,e[39]=O):O=e[39];let M;e[40]!==A||e[41]!==O?(M=a.jsxs(Ts,{children:[y,A,O]}),e[40]=A,e[41]=O,e[42]=M):M=e[42];let R;return e[43]!==M||e[44]!==g?(R=a.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-canvas px-4 py-8 text-foreground",children:a.jsx("form",{className:"w-full max-w-lg",onSubmit:g,children:M})}),e[43]=M,e[44]=g,e[45]=R):R=e[45],R}const r4=/^[a-z]:[\\/]/i;function Z1(n){return(r4.test(n)?n.replace(/\\/g,"/"):n).replace(/\/+$/,"")||"/"}function _v(n){const e=Z1(n);return r4.test(n)?e.toLowerCase():e}function MO(n){const e=Z1(n),t=e.lastIndexOf("/");return t<0?e:t===0?"/":e.slice(0,t)}function Ev(n,e){const t=_v(n),s=_v(e);if(t===s)return"";const r=t==="/"?"/":`${t}/`;return s.startsWith(r)?Z1(e).slice(r.length):null}let Y1=!1;function zO(n){Y1=n}function X1(){return Y1}let Ga=null;function DO(n){return Ga=n,()=>{Ga===n&&(Ga=null)}}function FO(n,e){if(!n.path)return null;if(n.kind==="project")return{root:n.path,file:null,mode:"edit"};if(e){const r=Ev(e,n.path);if(r)return{root:e,file:r,mode:Tv(n),line:n.line}}const t=MO(n.path),s=Ev(t,n.path);return s?{root:t,file:s,mode:Tv(n),line:n.line}:null}function Tv(n){return n.mode==="diff"?"diff":"edit"}function o4(n){return Y1&&Ga!==null&&Ga(n)}function i4(n,e){ws(n,e).catch(()=>{})}function xl(n,e={}){if(pt("hostFiles")&&!o4({kind:"file",path:n,...e})){if(yo()){Vd(n);return}i4("/api/open-in-editor",{path:n,mode:e.mode??"file",line:e.line,column:e.column})}}function a4(n){pt("hostFiles")&&(n.path&&o4({kind:"project",path:n.path})||c4("/api/open-in-editor",n))}function l4(n){pt("hostFiles")&&c4("/api/reveal-in-folder",n)}function c4(n,e){!e.path&&!e.dirName||i4(n,{path:e.path||void 0,dirName:e.dirName||void 0})}const UO=1500;function Ar(){const n=q.c(5),[e,t]=w.useState(!1),s=w.useRef(null),r=w.useRef(!0);let o,i;n[0]===Symbol.for("react.memo_cache_sentinel")?(o=()=>(r.current=!0,()=>{r.current=!1,s.current&&clearTimeout(s.current)}),i=[],n[0]=o,n[1]=i):(o=n[0],i=n[1]),w.useEffect(o,i);let l;n[2]===Symbol.for("react.memo_cache_sentinel")?(l=async d=>{!await Vd(d)||!r.current||(t(!0),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>t(!1),UO))},n[2]=l):l=n[2];const c=l;let u;return n[3]!==e?(u=[e,c],n[3]=e,n[4]=u):u=n[4],u}function ec(){const n=q.c(2),[e,t]=w.useState(BO);let s,r;return n[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>{const o=document.documentElement,i=()=>t(o.classList.contains("dark")),l=new MutationObserver(i);return l.observe(o,{attributes:!0,attributeFilter:["class"]}),()=>l.disconnect()},r=[],n[0]=s,n[1]=r):(s=n[0],r=n[1]),w.useEffect(s,r),e}function BO(){return typeof document<"u"&&document.documentElement.classList.contains("dark")}let cm=null;const Bh=new Set,zc=new Map,Av=["typescript","tsx","javascript","jsx","json","css","html","python","bash","yaml","markdown"],u4={typescript:()=>et(()=>import("./typescript-BPQ3VLAy.js"),[]),tsx:()=>et(()=>import("./tsx-COt5Ahok.js"),[]),javascript:()=>et(()=>import("./javascript-wDzz0qaB.js"),[]),jsx:()=>et(()=>import("./jsx-g9-lgVsj.js"),[]),json:()=>et(()=>import("./json-Cp-IABpG.js"),[]),css:()=>et(()=>import("./css-DPfMkruS.js"),[]),html:()=>et(()=>import("./html-GMplVEZG.js"),__vite__mapDeps([5,6,7])),python:()=>et(()=>import("./python-B6aJPvgy.js"),[]),bash:()=>et(()=>import("./bash-Yzrsuije.js"),[]),yaml:()=>et(()=>import("./yaml-Buea-lGh.js"),[]),markdown:()=>et(()=>import("./markdown-Cvjx9yec.js"),[]),rust:()=>et(()=>import("./rust-B1yitclQ.js"),[]),go:()=>et(()=>import("./go-CxLEBnE3.js"),[]),toml:()=>et(()=>import("./toml-vGWfd6FD.js"),[]),sql:()=>et(()=>import("./sql-BLtJtn59.js"),[]),c:()=>et(()=>import("./c-BIGW1oBm.js"),[]),cpp:()=>et(()=>import("./cpp-BRuaLJcg.js"),__vite__mapDeps([8,9,10])),java:()=>et(()=>import("./java-CylS5w8V.js"),[]),ruby:()=>et(()=>import("./ruby-B0Tyh1qT.js"),__vite__mapDeps([11,5,6,7,12,13,10,14,15,16,8,9,17,18])),swift:()=>et(()=>import("./swift-D82vCrfD.js"),[]),kotlin:()=>et(()=>import("./kotlin-BdnUsdx6.js"),[]),php:()=>et(()=>import("./php-aq0itWAE.js"),__vite__mapDeps([19,5,6,7,12,13,10,20])),vue:()=>et(()=>import("./vue-DVfSmUF7.js"),__vite__mapDeps([21,7,6,14,20,5])),svelte:()=>et(()=>import("./svelte-DZMnMd3x.js"),__vite__mapDeps([22,6,14,7])),scss:()=>et(()=>import("./scss-OYdSNvt2.js"),__vite__mapDeps([23,7]))};function d4(){return cm||(cm=(async()=>{const[n,e,...t]=await Promise.all([et(()=>import("./github-dark-DHJKELXO.js"),[]).then(r=>r.default),et(()=>import("./github-light-DAi9KRSo.js"),[]).then(r=>r.default),...Av.map(r=>u4[r]().then(o=>o.default))]),s=await qP({themes:[n,e],langs:t,engine:VP()});for(const r of Av)Bh.add(r);return s})()),cm}async function f4(n,e){if(Bh.has(e))return;if(zc.has(e))return zc.get(e);const t=u4[e];if(!t)return;const s=t().then(async r=>{await n.loadLanguage(r.default),Bh.add(e)}).finally(()=>zc.delete(e));zc.set(e,s),await s}const WO={ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",mjs:"javascript",cjs:"javascript",mts:"typescript",cts:"typescript",py:"python",rs:"rust",go:"go",json:"json",css:"css",scss:"scss",html:"html",htm:"html",md:"markdown",mdx:"markdown",yml:"yaml",yaml:"yaml",toml:"toml",sh:"bash",bash:"bash",zsh:"bash",sql:"sql",c:"c",h:"c",cpp:"cpp",cc:"cpp",hpp:"cpp",java:"java",rb:"ruby",swift:"swift",kt:"kotlin",kts:"kotlin",php:"php",vue:"vue",svelte:"svelte"};function m4(n){var t;const e=((t=n.split(".").pop())==null?void 0:t.toLowerCase())??"";return WO[e]??null}async function qO(n,e,t){try{const s=await d4();await f4(s,e);const r=t?"github-dark":"github-light";return s.codeToTokens(n,{lang:e,theme:r}).tokens}catch{return null}}const VO="min-w-0 max-h-96 overflow-y-auto whitespace-pre-wrap break-words [overflow-wrap:anywhere] rounded-md border bg-muted p-3 font-mono text-xs leading-relaxed text-foreground/85",J1="min-w-0 max-h-96 overflow-auto whitespace-pre-wrap break-words [overflow-wrap:anywhere] rounded-md bg-muted p-3 font-mono text-xs leading-relaxed text-foreground/85";function Qd(n,e,t){const s=q.c(5),[r,o]=w.useState(null);let i,l;return s[0]!==n||s[1]!==t||s[2]!==e?(i=()=>{if(!e)return;let c=!1;return qO(n,e,t).then(u=>{c||o({code:n,lang:e,isDark:t,tokens:u})}).catch(HO),()=>{c=!0}},l=[n,e,t],s[0]=n,s[1]=t,s[2]=e,s[3]=i,s[4]=l):(i=s[3],l=s[4]),w.useEffect(i,l),(r==null?void 0:r.code)===n&&r.lang===e&&r.isDark===t?r.tokens:null}function HO(){}function Q1(n){const e=q.c(13),{lines:t,tokens:s,lineNums:r,variant:o,label:i}=n,l=o==="boxed"?VO:J1;let c;if(e[0]!==r||e[1]!==t||e[2]!==s){let f;e[4]!==r||e[5]!==s?(f=(m,p)=>{const h=s==null?void 0:s[p];return a.jsxs("span",{className:"block",children:[(r==null?void 0:r[p])&&a.jsx("span",{className:"inline-block w-10 text-right mr-2 text-muted-foreground select-none",children:r[p]}),h?h.map(KO):m||" "]},p)},e[4]=r,e[5]=s,e[6]=f):f=e[6],c=t.map(f),e[0]=r,e[1]=t,e[2]=s,e[3]=c}else c=e[3];let u;e[7]!==i||e[8]!==c?(u=a.jsx("code",{className:"block","aria-label":i,children:c}),e[7]=i,e[8]=c,e[9]=u):u=e[9];let d;return e[10]!==l||e[11]!==u?(d=a.jsx("pre",{tabIndex:0,className:l,children:u}),e[10]=l,e[11]=u,e[12]=d):d=e[12],d}function KO(n,e){return a.jsx("span",{style:{color:n.color},children:n.content},e)}function p4(n){const e=q.c(6),{code:t,language:s,label:r}=n,o=ec(),i=Qd(t,s,o);let l;e[0]!==t?(l=bl(t),e[0]=t,e[1]=l):l=e[1];const c=l;let u;return e[2]!==r||e[3]!==c||e[4]!==i?(u=a.jsx(Q1,{lines:c,tokens:i,variant:"unboxed",label:r}),e[2]=r,e[3]=c,e[4]=i,e[5]=u):u=e[5],u}const GO=/^(\s*\d+)→(.*)$/;function bl(n){return n.split(/\r\n|\r|\n/)}function ZO(n){const e=[],t=[];for(const s of bl(n)){const r=s.match(GO);r?(e.push(r[1]),t.push(r[2])):(e.push(""),t.push(s))}return{lineNums:e,codeLines:t}}function YO(n){const e=q.c(11),{result:t,filePath:s,variant:r}=n,o=r===void 0?"boxed":r,i=ec();let l;e[0]!==s?(l=m4(s),e[0]=s,e[1]=l):l=e[1];const c=l;let u;e[2]!==t?(u=ZO(t),e[2]=t,e[3]=u):u=e[3];const{lineNums:d,codeLines:f}=u;let m;e[4]!==f?(m=f.join(`
|
|
7
|
+
`),e[4]=f,e[5]=m):m=e[5];const h=Qd(m,c,i);let g;return e[6]!==f||e[7]!==d||e[8]!==h||e[9]!==o?(g=a.jsx(Q1,{lines:f,tokens:h,lineNums:d,variant:o}),e[6]=f,e[7]=d,e[8]=h,e[9]=o,e[10]=g):g=e[10],g}function h4(n){const e=n.trim();if(e[0]!=="{"&&e[0]!=="[")return null;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return null}}function g4(n){const e=q.c(9),{result:t,alreadyPretty:s,variant:r}=n,o=r===void 0?"boxed":r,i=ec();let l;e[0]!==s||e[1]!==t?(l=s?t:h4(t)??t,e[0]=s,e[1]=t,e[2]=l):l=e[2];const c=l;let u;e[3]!==c?(u=bl(c),e[3]=c,e[4]=u):u=e[4];const d=u,f=Qd(c,"json",i);let m;return e[5]!==d||e[6]!==f||e[7]!==o?(m=a.jsx(Q1,{lines:d,tokens:f,variant:o}),e[5]=d,e[6]=f,e[7]=o,e[8]=m):m=e[8],m}function XO(n){const e=bl(n),t=e.slice(0,8).join(`
|
|
8
|
+
`),s=t.slice(0,1e3);return{text:s,hiddenLines:Math.max(0,e.length-bl(s).length),truncated:e.length>8||t.length>1e3}}function x4(n){const e=q.c(37),{result:t,isError:s,filePath:r,renderResult:o}=n,i=s===void 0?!1:s,[l,c]=w.useState(!1),[u,d]=Ar(),f=w.useId();let m;e[0]!==r||e[1]!==i||e[2]!==t?(m=!i&&!r?h4(t):null,e[0]=r,e[1]=i,e[2]=t,e[3]=m):m=e[3];const p=m,h=p??t;let g;e[4]!==h?(g=XO(h),e[4]=h,e[5]=g):g=e[5];const x=g,b=l?h:x.text,y=i&&"text-destructive";let v;e[6]!==y?(v=G("text-xs text-muted-foreground",y),e[6]=y,e[7]=v):v=e[7];const k=i?"Error":"Result";let j;e[8]!==v||e[9]!==k?(j=a.jsx("span",{className:v,children:k}),e[8]=v,e[9]=k,e[10]=j):j=e[10];let _;e[11]!==u||e[12]!==d||e[13]!==t?(_=t.trim()&&a.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>d(t),"aria-label":u?"Result copied":"Copy result",children:u?a.jsx(Ft,{"data-icon":"icon"}):a.jsx(ys,{"data-icon":"icon"})}),e[11]=u,e[12]=d,e[13]=t,e[14]=_):_=e[14];let N;e[15]!==j||e[16]!==_?(N=a.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[j,_]}),e[15]=j,e[16]=_,e[17]=N):N=e[17];let S;e[18]!==r||e[19]!==i||e[20]!==p||e[21]!==o||e[22]!==t||e[23]!==b?(S=t.trim()?o?o(b):r&&!i?a.jsx(YO,{result:b,filePath:r,variant:"unboxed"}):p!==null?a.jsx(g4,{result:b,alreadyPretty:!0,variant:"unboxed"}):a.jsx("pre",{tabIndex:0,className:G(J1,i&&"border-destructive/30 text-destructive"),children:b}):a.jsx("p",{className:"text-xs text-muted-foreground",children:"No output"}),e[18]=r,e[19]=i,e[20]=p,e[21]=o,e[22]=t,e[23]=b,e[24]=S):S=e[24];let C;e[25]!==f||e[26]!==S?(C=a.jsx("div",{id:f,children:S}),e[25]=f,e[26]=S,e[27]=C):C=e[27];let E;e[28]!==l||e[29]!==x.hiddenLines||e[30]!==x.truncated||e[31]!==f?(E=x.truncated&&a.jsx(ee,{type:"button",variant:"ghost",size:"xs",className:"mt-1",onClick:()=>c(JO),"aria-expanded":l,"aria-controls":f,children:l?"Show less":x.hiddenLines>0?`+${x.hiddenLines} ${x.hiddenLines===1?"line":"lines"}`:"Show more"}),e[28]=l,e[29]=x.hiddenLines,e[30]=x.truncated,e[31]=f,e[32]=E):E=e[32];let T;return e[33]!==C||e[34]!==E||e[35]!==N?(T=a.jsxs("section",{className:"mt-3 min-w-0","aria-label":"Result",children:[N,C,E]}),e[33]=C,e[34]=E,e[35]=N,e[36]=T):T=e[36],T}function JO(n){return!n}const QO={js:"JavaScript",jsx:"JSX",ts:"TypeScript",tsx:"TSX",py:"Python",rb:"Ruby",rs:"Rust",go:"Go",java:"Java",kt:"Kotlin",swift:"Swift",cs:"C#",cpp:"C++",c:"C",sh:"Shell",bash:"Bash",zsh:"Zsh",fish:"Fish",ps1:"PowerShell",powershell:"PowerShell",sql:"SQL",graphql:"GraphQL",html:"HTML",css:"CSS",scss:"SCSS",less:"LESS",json:"JSON",yaml:"YAML",yml:"YAML",toml:"TOML",xml:"XML",md:"Markdown",markdown:"Markdown",dockerfile:"Dockerfile",docker:"Docker",makefile:"Makefile",cmake:"CMake",lua:"Lua",vim:"Vim",diff:"Diff",plaintext:"Text",text:"Text",txt:"Text",php:"PHP",perl:"Perl",r:"R",scala:"Scala",elixir:"Elixir",clojure:"Clojure",haskell:"Haskell",ocaml:"OCaml",zig:"Zig",nim:"Nim",dart:"Dart",vue:"Vue",svelte:"Svelte",astro:"Astro",prisma:"Prisma",terraform:"Terraform",tf:"Terraform",proto:"Protobuf",protobuf:"Protobuf"};function eL(n){return QO[n.toLowerCase()]??n}function tL(n){if(!n)return null;const e=n.match(/language-(\S+)/);return(e==null?void 0:e[1])??null}function nL(n){const e=q.c(9),{text:t}=n,[s,r]=Ar();let o;e[0]!==r||e[1]!==t?(o=()=>r(t),e[0]=r,e[1]=t,e[2]=o):o=e[2];const i=s?"Copied":"Copy code";let l;e[3]!==s?(l=s?a.jsxs(a.Fragment,{children:[a.jsx(Ft,{className:"text-success","data-icon":"inline-start"}),a.jsx("span",{className:"text-success",children:"Copied"})]}):a.jsx(ys,{"data-icon":"icon"}),e[3]=s,e[4]=l):l=e[4];let c;return e[5]!==o||e[6]!==i||e[7]!==l?(c=a.jsx(ee,{type:"button",variant:"ghost",size:"xs",onClick:o,className:"text-muted-foreground",title:"Copy code","aria-label":i,children:l}),e[5]=o,e[6]=i,e[7]=l,e[8]=c):c=e[8],c}function sL(n){const e=q.c(2),{num:t}=n;let s;return e[0]!==t?(s=a.jsx("span",{className:"mr-3 inline-block w-8 select-none text-right text-xs text-muted-foreground/60",children:t}),e[0]=t,e[1]=s):s=e[1],s}function b4(n){const e=q.c(16);let t,s,r;if(e[0]!==n){const{children:m,className:p,node:h,...g}=n;t=m,s=p,r=g,e[0]=n,e[1]=t,e[2]=s,e[3]=r}else t=e[1],s=e[2],r=e[3];const o=!s&&typeof t=="string"&&!t.includes(`
|
|
9
|
+
`);let i;e[4]!==s?(i=tL(s),e[4]=s,e[5]=i):i=e[5];const l=i,c=String(t);let u;if(e[6]!==c){let m;e[8]===Symbol.for("react.memo_cache_sentinel")?(m=/\n$/,e[8]=m):m=e[8],u=c.replace(m,""),e[6]=c,e[7]=u}else u=e[7];const d=u;if(o){let m;return e[9]!==t||e[10]!==r?(m=a.jsx("code",{className:"rounded-md border border-border bg-muted px-1.5 py-0.5 font-mono text-[0.9em] text-foreground",...r,children:t}),e[9]=t,e[10]=r,e[11]=m):m=e[11],m}let f;return e[12]!==d||e[13]!==l||e[14]!==r?(f=a.jsx(rL,{code:d,lang:l,...r}),e[12]=d,e[13]=l,e[14]=r,e[15]=f):f=e[15],f}function rL(n){const e=q.c(39);let t,s,r;e[0]!==n?({code:t,lang:s,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);const o=ec(),i=Qd(t,s,o),[l,c]=w.useState(!1);let u,d,f,m;if(e[4]!==t||e[5]!==l||e[6]!==s||e[7]!==r||e[8]!==i){const g=t.split(`
|
|
10
|
+
`);u=g.length;const x=u>30,b=l?ot:Ot;d="my-3 overflow-hidden rounded-lg border border-border bg-muted";let y;e[13]!==b||e[14]!==l||e[15]!==x?(y=x&&a.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>c(!l),className:"text-muted-foreground","aria-label":l?"Expand code":"Collapse code",children:a.jsx(b,{"data-icon":"icon"})}),e[13]=b,e[14]=l,e[15]=x,e[16]=y):y=e[16];let v;e[17]!==s?(v=s&&a.jsx(Ue,{variant:"ghost",className:"px-0 uppercase tracking-wide text-muted-foreground",children:eL(s)}),e[17]=s,e[18]=v):v=e[18];let k;e[19]!==x||e[20]!==u?(k=x&&a.jsxs("span",{className:"text-xs text-muted-foreground",children:[u," lines"]}),e[19]=x,e[20]=u,e[21]=k):k=e[21];let j;e[22]!==y||e[23]!==v||e[24]!==k?(j=a.jsxs("div",{className:"flex items-center gap-2",children:[y,v,k]}),e[22]=y,e[23]=v,e[24]=k,e[25]=j):j=e[25];let _;e[26]!==t?(_=a.jsx(nL,{text:t}),e[26]=t,e[27]=_):_=e[27],e[28]!==j||e[29]!==_?(f=a.jsxs("div",{className:"flex items-center justify-between border-b border-border bg-muted px-3 py-1.5",children:[j,_]}),e[28]=j,e[29]=_,e[30]=f):f=e[30],m=!l&&a.jsx("div",{className:"overflow-x-auto",children:a.jsx("pre",{className:"m-0 p-3 font-mono text-xs leading-relaxed",children:a.jsx("code",{className:G("block",!i&&"text-foreground/90"),...r,children:g.map((N,S)=>{const C=i==null?void 0:i[S];return a.jsxs("span",{className:"block",children:[a.jsx(sL,{num:S+1}),C?C.map(oL):N||" "]},S)})})})}),e[4]=t,e[5]=l,e[6]=s,e[7]=r,e[8]=i,e[9]=u,e[10]=d,e[11]=f,e[12]=m}else u=e[9],d=e[10],f=e[11],m=e[12];let p;e[31]!==l||e[32]!==u?(p=l&&a.jsxs(ee,{type:"button",variant:"ghost",size:"sm",onClick:()=>c(!1),className:"h-auto w-full justify-start rounded-none px-3 py-2 text-xs text-muted-foreground","aria-label":`Expand ${u} lines of code`,children:["Show ",u," lines..."]}),e[31]=l,e[32]=u,e[33]=p):p=e[33];let h;return e[34]!==d||e[35]!==f||e[36]!==m||e[37]!==p?(h=a.jsxs("div",{className:d,children:[f,m,p]}),e[34]=d,e[35]=f,e[36]=m,e[37]=p,e[38]=h):h=e[38],h}function oL(n,e){return a.jsx("span",{style:{color:n.color},children:n.content},e)}var Lo=function(n,e){return Number(n.toFixed(e))},iL=function(n,e){return e},mt=function(n,e,t){t&&typeof t=="function"&&t(n,e)},aL=function(n){return-Math.cos(n*Math.PI)/2+.5},lL=function(n){return n},cL=function(n){return n*n},uL=function(n){return n*(2-n)},dL=function(n){return n<.5?2*n*n:-1+(4-2*n)*n},fL=function(n){return n*n*n},mL=function(n){return--n*n*n+1},pL=function(n){return n<.5?4*n*n*n:(n-1)*(2*n-2)*(2*n-2)+1},hL=function(n){return n*n*n*n},gL=function(n){return 1- --n*n*n*n},xL=function(n){return n<.5?8*n*n*n*n:1-8*--n*n*n*n},bL=function(n){return n*n*n*n*n},vL=function(n){return 1+--n*n*n*n*n},yL=function(n){return n<.5?16*n*n*n*n*n:1+16*--n*n*n*n*n},v4={easeOut:aL,linear:lL,easeInQuad:cL,easeOutQuad:uL,easeInOutQuad:dL,easeInCubic:fL,easeOutCubic:mL,easeInOutCubic:pL,easeInQuart:hL,easeOutQuart:gL,easeInOutQuart:xL,easeInQuint:bL,easeOutQuint:vL,easeInOutQuint:yL},y4=function(n){typeof n=="number"&&cancelAnimationFrame(n)},Ps=function(n){n.mounted&&(y4(n.animation),n.isAnimating=!1,n.animation=null,n.velocity=null)};function w4(n,e,t,s){if(n.mounted){var r=new Date().getTime(),o=1;Ps(n),n.animation=function(){if(!n.mounted)return y4(n.animation);var i=new Date().getTime()-r,l=i/t,c=v4[e],u=c(l);i>=t?(s(o),n.animation=null):n.animation&&(s(u),requestAnimationFrame(n.animation))},requestAnimationFrame(n.animation)}}function wL(n){var e=n.scale,t=n.positionX,s=n.positionY;return!(Number.isNaN(e)||Number.isNaN(t)||Number.isNaN(s))}function jo(n,e,t,s){var r=wL(e);if(!(!n.mounted||!r)){var o=n.setState,i=n.state,l=i.scale,c=i.positionX,u=i.positionY,d=e.scale-l,f=e.positionX-c,m=e.positionY-u;t===0?o(e.scale,e.positionX,e.positionY):w4(n,s,t,function(p){p!==1?n.isAnimating=!0:n.isAnimating=!1;var h=l+d*p,g=c+f*p,x=u+m*p;o(h,g,x)})}}function SL(n,e,t){var s=n.offsetWidth,r=n.offsetHeight,o=e.offsetWidth,i=e.offsetHeight,l=o*t,c=i*t,u=s-l,d=r-c;return{wrapperWidth:s,wrapperHeight:r,newContentWidth:l,newDiffWidth:u,newContentHeight:c,newDiffHeight:d}}var kL=function(n,e,t,s,r,o,i){var l=n>e?t*(i?.5:1):0,c=s>r?o*(i?.5:1):0,u=n-e-l,d=l,f=s-r-c,m=c;return{minPositionX:u,maxPositionX:d,minPositionY:f,maxPositionY:m,scaleWidthFactor:l,scaleHeightFactor:c}},ex=function(n,e){var t=n.wrapperComponent,s=n.contentComponent,r=n.setup,o=r.centerZoomedOut,i=r.disablePadding;if(!t||!s)throw new Error("Components are not mounted");var l=SL(t,s,e),c=l.wrapperWidth,u=l.wrapperHeight,d=l.newContentWidth,f=l.newContentHeight,m=l.newDiffWidth,p=l.newDiffHeight,h=kL(c,d,m,u,f,p,!!o),g=c>=d&&u>=f;i&&g&&!o&&(h.minPositionX=0,h.maxPositionX=0,h.minPositionY=0,h.maxPositionY=0);var x=n.setup,b=x.minPositionX,y=x.maxPositionX,v=x.minPositionY,k=x.maxPositionY;return b!=null&&(h.minPositionX=c*(1-e)+b*e),y!=null&&(h.maxPositionX=y*e),v!=null&&(h.minPositionY=u*(1-e)+v*e),k!=null&&(h.maxPositionY=k*e),h},vl=function(n,e,t,s){return s?n<e?Lo(e,2):n>t?Lo(t,2):Lo(n,2):Lo(n,2)},Oi=function(n,e){var t=ex(n,e);return n.bounds=t,t};function tc(n,e,t,s,r,o,i){var l=t.minPositionX,c=t.minPositionY,u=t.maxPositionX,d=t.maxPositionY,f=0,m=0;i&&(f=r,m=o);var p=vl(n,l-f,u+f,s),h=vl(e,c-m,d+m,s);return{x:p,y:h}}function ef(n,e,t,s,r,o){var i=n.state,l=i.scale,c=i.positionX,u=i.positionY,d=s-l;if(!Number.isFinite(e)||!Number.isFinite(t))return console.error("Mouse X and Y position were not provided!"),{x:c,y:u};var f=c-e*d,m=u-t*d,p=tc(f,m,r,o,0,0,null);return p}var Pv=1e-7;function nc(n,e,t,s,r){var o=r?s:0,i=Math.max(e-o,Pv),l=t+o;return!Number.isNaN(t)&&n>=l?l:!Number.isNaN(e)&&n<=i?i:Math.max(n,Pv)}var Iv=function(n,e){var t=n.setup.panning.excluded,s=n.isInitialized,r=n.wrapperComponent,o=e.target,i="shadowRoot"in o&&"composedPath"in e,l=i?e.composedPath().some(function(d){return d instanceof Element?r==null?void 0:r.contains(d):!1}):r==null?void 0:r.contains(o),c=s&&o&&l;if(!c)return!1;var u=sc(o,t);return!(u||o.getAttribute("draggable")==="true"||o.getAttribute("contenteditable")==="true"||o.isContentEditable)},$v=function(n){var e=n.isInitialized,t=n.isPanning,s=n.setup,r=s.panning.disabled,o=e&&t&&!r;return!!o},jL=function(n,e){var t=n.state,s=t.positionX,r=t.positionY;n.isPanning=!0;var o=e.clientX,i=e.clientY;n.startCoords={x:o-s,y:i-r}},NL=function(n,e){var t=e.touches,s=n.state,r=s.positionX,o=s.positionY;n.isPanning=!0;var i=t.length===1;if(i){var l=t[0].clientX,c=t[0].clientY;n.startCoords={x:l-r,y:c-o}}};function CL(n){var e=n.state,t=e.positionX,s=e.positionY,r=e.scale,o=n.setup,i=o.disabled,l=o.limitToBounds,c=o.centerZoomedOut,u=n.wrapperComponent;if(!(i||!u||!n.bounds)){var d=n.bounds,f=d.maxPositionX,m=d.minPositionX,p=d.maxPositionY,h=d.minPositionY,g=t>f||t<m,x=s>p||s<h,b=t>f?u.offsetWidth:n.setup.minPositionX||0,y=s>p?u.offsetHeight:n.setup.minPositionY||0,v=ef(n,b,y,r,n.bounds,l||c),k=v.x,j=v.y;return{scale:r,positionX:g?k:t,positionY:x?j:s}}}function S4(n,e,t,s,r){var o=n.setup.limitToBounds,i=n.wrapperComponent,l=n.bounds,c=n.state,u=c.scale,d=c.positionX,f=c.positionY;if(!(i===null||l===null||e===d&&t===f)){var m=tc(e,t,l,o,s,r,i),p=m.x,h=m.y;n.setState(u,p,h)}}var _L=function(n,e,t){var s=n.startCoords,r=n.state,o=n.setup.panning,i=o.lockAxisX,l=o.lockAxisY,c=r.positionX,u=r.positionY;if(!s)return{x:c,y:u};var d=e-s.x,f=t-s.y,m=i?c:d,p=l?u:f;return{x:m,y:p}},fo=function(n,e,t){var s=n.setup,r=n.state,o=s.minScale,i=s.disablePadding,l=s.centerZoomedOut,c=t??r.scale;return e>0&&c>=o&&!i&&!l?e:0},Zr;(function(n){n.TRACK_PAD="track_pad",n.MOUSE="mouse",n.TOUCH="touch"})(Zr||(Zr={}));var EL=function(n){var e=n.mounted,t=n.wrapperComponent,s=n.contentComponent,r=n.setup,o=r.disabled,i=r.velocityAnimation,l=r.limitToBounds,c=n.state.scale,u=i.disabled;if(u||o||!e||!t||!s)return!1;if(!l)return!0;var d=t.offsetWidth<s.offsetWidth*c||t.offsetHeight<s.offsetHeight*c;return d},TL=function(n){var e=n.mounted,t=n.velocity,s=n.bounds,r=n.setup,o=r.disabled,i=r.velocityAnimation,l=i.disabled,c=!l&&!o&&e;return!(!c||!t||!s)};function AL(n,e){var t=n.setup.velocityAnimation,s=t.animationTime,r=t.maxAnimationTime,o=t.inertia;return Math.min(s*Math.max(1,Math.abs(e/o)),r)}function Rv(n,e,t,s,r,o,i,l,c,u){if(r){if(e>i&&t>i){var d=i+(n-i)*u;return d>c?c:d<i?i:d}if(e<o&&t<o){var d=o+(n-o)*u;return d<l?l:d>o?o:d}}return s?e:vl(n,o,i,r)}function PL(n){var e=1,t=n.offsetWidth/window.innerWidth;return Number.isNaN(t)?e:Math.min(e,t)}var um=function(n,e,t){var s=0,r=n*t;return Number.isNaN(r)?s:n<0?Math.max(r,-e):Math.min(r,e)};function IL(n,e,t){var s,r,o=EL(n);if(o){var i=n.lastMousePosition,l=n.velocityTime,c=n.setup,u=n.wrapperComponent,d=c.velocityAnimation,f=d.maxStrengthMouse,m=d.maxStrengthTouch,p=d.sensitivityTouch,h=d.sensitivityMouse,g=Date.now();if(i&&l&&u){var x=PL(u),b=(s={},s[Zr.TOUCH]=p,s[Zr.MOUSE]=h,s)[t],y=(r={},r[Zr.TOUCH]=m,r[Zr.MOUSE]=f,r)[t],v=e.x-i.x,k=e.y-i.y,j=um(v/x,y,b),_=um(k/x,y,b),N=g-l,S=v*v+k*k,C=um(Math.sqrt(S)/N,y,b);n.velocity={velocityX:j,velocityY:_,total:C}}n.lastMousePosition=e,n.velocityTime=g}}function $L(n){var e=n.velocity,t=n.bounds,s=n.setup,r=n.wrapperComponent,o=TL(n);if(!(!o||!e||!t||!r)){var i=e.velocityX,l=e.velocityY,c=e.total,u=t.maxPositionX,d=t.minPositionX,f=t.maxPositionY,m=t.minPositionY,p=s.limitToBounds,h=s.autoAlignment,g=s.zoomAnimation,x=s.panning,b=x.lockAxisY,y=x.lockAxisX,v=g.animationType,k=h.sizeX,j=h.sizeY,_=h.velocityAlignmentTime,N=_,S=AL(n,c),C=Math.max(S,N),E=fo(n,k),T=fo(n,j),A=E*r.offsetWidth/100,P=T*r.offsetHeight/100,I=u+A,$=d-A,O=f+P,M=m-P,R=n.state,z=new Date().getTime();w4(n,v,C,function(W){var D=n.state,L=D.scale,U=D.positionX,F=D.positionY,B=new Date().getTime()-z,V=B/N,H=v4[h.animationType],K=1-H(Math.min(1,V)),Z=1-W,Y=U+i*Z,X=F+l*Z,se=Rv(Y,R.positionX,U,y,p,d,u,$,I,K),Q=Rv(X,R.positionY,F,b,p,m,f,M,O,K);if(U!==Y||F!==X){n.setState(L,se,Q);var te=n.props.onPanning;te&&te(ut(n),{})}})}}function Ov(n,e){var t=n.state,s=t.scale,r=t.positionX,o=t.positionY;n.panStartPosition={x:r,y:o},Ps(n),Oi(n,s),window.TouchEvent!==void 0&&e instanceof TouchEvent?NL(n,e):jL(n,e)}function k4(n,e){var t=n.state.scale,s=n.setup,r=s.minScale,o=s.autoAlignment,i=o.disabled,l=o.sizeX,c=o.sizeY,u=o.animationTime,d=o.animationType,f=i||t<r||!l&&!c;if(!f){var m=CL(n);m&&jo(n,m,u,d)}}function Lv(n,e,t,s){var r=n.startCoords,o=n.setup,i=o.autoAlignment,l=i.sizeX,c=i.sizeY;if(r){var u=_L(n,e,t),d=u.x,f=u.y,m=fo(n,l),p=fo(n,c);IL(n,{x:d,y:f},s),S4(n,d,f,m,p)}}function RL(n,e){if(n.isPanning){var t=n.velocity,s=n.wrapperComponent,r=n.contentComponent;n.isPanning=!1;var o=n.state,i=o.positionX,l=o.positionY,c=o.scale,u=n.panStartPosition;if(n.panStartPosition=null,u){var d=i-u.x,f=l-u.y;if(d*d+f*f<=25)return}n.isAnimating=!1,n.animation=null;var m=(s==null?void 0:s.offsetWidth)||0,p=(s==null?void 0:s.offsetHeight)||0,h=((r==null?void 0:r.offsetWidth)||0)*c,g=((r==null?void 0:r.offsetHeight)||0)*c,x=!n.setup.limitToBounds||m<h||p<g,b=!e&&t&&t.total>.1&&x;b?$L(n):k4(n)}}function tx(n,e,t,s){var r=n.setup,o=r.minScale,i=r.maxScale,l=r.limitToBounds,c=nc(Lo(e,2),o,i,0,!1),u=Oi(n,c),d=ef(n,t,s,c,u,l),f=d.x,m=d.y;return{scale:c,positionX:f,positionY:m}}function nx(n,e,t){var s=n.state.scale,r=n.wrapperComponent,o=n.setup,i=o.minScale,l=o.maxScale,c=o.limitToBounds,u=o.zoomAnimation,d=u.disabled,f=u.animationTime,m=u.animationType,p=s>=i&&s<=l,h=d||p;if((s>=1||c)&&k4(n),!(h||!r||!n.mounted)){var g=e||r.offsetWidth/2,x=t||r.offsetHeight/2,b=s<i?i:l,y=tx(n,b,g,x);y&&jo(n,y,f,m)}}var ps=function(){return ps=Object.assign||function(e){for(var t,s=1,r=arguments.length;s<r;s++){t=arguments[s];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},ps.apply(this,arguments)};function Mv(n,e,t){for(var s=0,r=e.length,o;s<r;s++)(o||!(s in e))&&(o||(o=Array.prototype.slice.call(e,0,s)),o[s]=e[s]);return n.concat(o||Array.prototype.slice.call(e))}var dm={scale:1,positionX:0,positionY:0},Ro={disabled:!1,minPositionX:null,maxPositionX:null,minPositionY:null,maxPositionY:null,minScale:1,maxScale:8,limitToBounds:!0,centerZoomedOut:!1,centerOnInit:!1,disablePadding:!1,smooth:!0,detached:!1,wheel:{step:.015,disabled:!1,wheelDisabled:!1,touchPadDisabled:!1,activationKeys:[],excluded:[]},trackPadPanning:{disabled:!0,velocityDisabled:!1,lockAxisX:!1,lockAxisY:!1,activationKeys:[],excluded:[]},panning:{disabled:!1,velocityDisabled:!1,lockAxisX:!1,lockAxisY:!1,allowLeftClickPan:!0,allowMiddleClickPan:!0,allowRightClickPan:!0,activationKeys:[],excluded:[]},pinch:{step:5,disabled:!1,allowPanning:!0,excluded:[]},doubleClick:{disabled:!1,step:.7,mode:"zoomIn",animationType:"easeOut",animationTime:200,excluded:[]},zoomAnimation:{disabled:!1,size:.4,animationTime:200,animationType:"easeOut"},autoAlignment:{disabled:!1,sizeX:100,sizeY:100,animationTime:200,velocityAlignmentTime:400,animationType:"easeOut"},velocityAnimation:{disabled:!1,sensitivityMouse:1,sensitivityTouch:1.2,maxStrengthMouse:20,maxStrengthTouch:40,inertia:1,animationTime:300,maxAnimationTime:800,animationType:"easeOut"}},Wh={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},j4=function(n){var e,t,s,r,o,i,l,c,u,d=Math.max((e=n.minScale)!==null&&e!==void 0?e:Ro.minScale,1e-7),f=(t=n.maxScale)!==null&&t!==void 0?t:Ro.maxScale,m=(s=n.initialScale)!==null&&s!==void 0?s:dm.scale,p=Math.min(Math.max(m,d),f),h=vl((r=n.initialPositionX)!==null&&r!==void 0?r:dm.positionX,(o=n.minPositionX)!==null&&o!==void 0?o:-1/0,(i=n.maxPositionX)!==null&&i!==void 0?i:1/0,n.minPositionX!=null||n.maxPositionX!=null),g=vl((l=n.initialPositionY)!==null&&l!==void 0?l:dm.positionY,(c=n.minPositionY)!==null&&c!==void 0?c:-1/0,(u=n.maxPositionY)!==null&&u!==void 0?u:1/0,n.minPositionY!=null||n.maxPositionY!=null);return{previousScale:p,scale:p,positionX:h,positionY:g}},zv=function(n){var e=ps({},Ro);return Object.keys(n).forEach(function(t){var s=t,r=typeof n[s]<"u",o=typeof Ro[s]<"u";if(o&&r){var i=Object.prototype.toString.call(Ro[s]),l=i==="[object Object]",c=i==="[object Array]";l?e[s]=ps(ps({},Ro[s]),n[s]):c?e[s]=Mv(Mv([],Ro[s],!0),n[s]):e[s]=n[s]}}),e.minScale<=0&&(e.minScale=1e-7),e},N4=function(n,e,t){var s=n.state.scale,r=n.wrapperComponent,o=n.setup,i=o.maxScale,l=o.minScale,c=o.zoomAnimation,u=o.smooth,d=c.size;if(!r)throw new Error("Wrapper is not mounted");var f=u?s*Math.exp(e*t):s+e*t,m=nc(Lo(f,3),l,i,d,!1);return m};function C4(n,e,t,s,r){var o,i,l=n.wrapperComponent,c=n.state,u=c.scale,d=c.positionX,f=c.positionY,m=n.setup.zoomAnimation;if(!l)return console.error("No WrapperComponent found");var p=m.disabled?0:s,h=l.offsetWidth,g=l.offsetHeight,x=(h/2-d)/u,b=(g/2-f)/u,y=N4(n,e,t),v=tx(n,y,x,b);if(!v)return console.error("Error during zoom event. New transformation state was not calculated.");var k=n.props,j=k.onZoomStart,_=k.onZoom,N=k.onZoomStop,S=new MouseEvent("mousemove",{bubbles:!0}),C=ut(n);mt(C,S,j),mt(C,S,_),jo(n,v,p,r);var E=(i=(o=l.ownerDocument)===null||o===void 0?void 0:o.defaultView)!==null&&i!==void 0?i:typeof window<"u"?window:null;E&&E.setTimeout(function(){n.mounted&&mt(ut(n),S,N)},p)}function _4(n,e,t,s){var r,o,i=n.setup,l=n.wrapperComponent,c=n.contentComponent,u=i.limitToBounds,d=i.centerOnInit,f=j4(n.props),m=n.state,p=m.scale,h=m.positionX,g=m.positionY;if(l){var x=f.positionX,b=f.positionY;if(d&&c){var y=sx(f.scale,l,c);x=y.positionX,b=y.positionY}var v=ex(n,f.scale),k=tc(x,b,v,u,0,0,l),j={scale:f.scale,positionX:k.x,positionY:k.y};if(!(p===f.scale&&h===f.positionX&&g===f.positionY)){s==null||s();var _=n.props,N=_.onZoomStart,S=_.onZoom,C=_.onZoomStop,E=new MouseEvent("mousemove",{bubbles:!0}),T=ut(n);mt(T,E,N),mt(T,E,S),jo(n,j,e,t);var A=(o=(r=l.ownerDocument)===null||r===void 0?void 0:r.defaultView)!==null&&o!==void 0?o:typeof window<"u"?window:null;A&&A.setTimeout(function(){n.mounted&&mt(ut(n),E,C)},e)}}}function OL(n,e,t,s){var r=n.getBoundingClientRect(),o=e.getBoundingClientRect(),i=t.getBoundingClientRect(),l=o.x*s.scale,c=o.y*s.scale;return{x:(r.x-i.x+l)/s.scale,y:(r.y-i.y+c)/s.scale}}function LL(n,e,t,s,r){s===void 0&&(s=0),r===void 0&&(r=0);var o=n.wrapperComponent,i=n.contentComponent,l=n.state,c=n.setup,u=c.limitToBounds,d=c.minScale,f=c.maxScale;if(!o||!i)return l;var m=o.getBoundingClientRect(),p=e.getBoundingClientRect(),h=OL(e,o,i,l),g=h.x,x=h.y,b=p.width/l.scale,y=p.height/l.scale,v=o.offsetWidth/b,k=o.offsetHeight/y,j=nc(t||Math.min(v,k),d,f,0,!1),_=(m.width-b*j)/2,N=(m.height-y*j)/2,S=(m.left-g)*j+_+s,C=(m.top-x)*j+N+r,E=ex(n,j),T=tc(S,C,E,u,0,0,o),A=T.x,P=T.y;return{positionX:A,positionY:P,scale:j}}var ML=function(n){return function(e,t,s){e===void 0&&(e=.5),t===void 0&&(t=300),s===void 0&&(s="easeOut"),C4(n,1,e,t,s)}},zL=function(n){return function(e,t,s){e===void 0&&(e=.5),t===void 0&&(t=300),s===void 0&&(s="easeOut"),C4(n,-1,e,t,s)}},DL=function(n){return function(e,t,s,r,o){r===void 0&&(r=300),o===void 0&&(o="easeOut");var i=n.state,l=i.positionX,c=i.positionY,u=i.scale,d=n.wrapperComponent,f=n.contentComponent,m=n.setup.disabled;if(!(m||!d||!f)){var p={positionX:Number.isNaN(e)?l:e,positionY:Number.isNaN(t)?c:t,scale:Number.isNaN(s)?u:s};jo(n,p,r,o)}}},FL=function(n){return function(e,t){e===void 0&&(e=200),t===void 0&&(t="easeOut"),_4(n,e,t)}},UL=function(n){return function(e,t,s){t===void 0&&(t=200),s===void 0&&(s="easeOut");var r=n.state,o=n.wrapperComponent,i=n.contentComponent;if(o&&i){var l=sx(e||r.scale,o,i);jo(n,l,t,s)}}},BL=function(n){return function(e,t,s,r,o,i){s===void 0&&(s=600),r===void 0&&(r="easeOut"),o===void 0&&(o=0),i===void 0&&(i=0),Ps(n);var l=n.wrapperComponent,c=typeof e=="string"?document.getElementById(e):e;if(l&&c&&l.contains(c)){var u=LL(n,c,t,o,i);jo(n,u,s,r)}}},qh=function(n){return{instance:n,state:n.state,zoomIn:ML(n),zoomOut:zL(n),setTransform:DL(n),resetTransform:FL(n),centerView:UL(n),zoomToElement:BL(n)}},WL=function(n){return{instance:n,state:n.state}},ut=function(n){var e={};return Object.assign(e,WL(n)),Object.assign(e,qh(n)),e},fm=!1;function mm(){try{var n={get passive(){return fm=!0,!1}};return n}catch{return fm=!1,fm}}var Dc=".".concat(Wh.wrapperClass),sc=function(n,e){return e.some(function(t){return n.matches("".concat(Dc," ").concat(t,", ").concat(Dc," .").concat(t,", ").concat(Dc," ").concat(t," *, ").concat(Dc," .").concat(t," *"))})},yl=function(n){n&&clearTimeout(n)},qL=function(n){return Number.parseFloat(n.toFixed(8))},E4=function(n,e,t){var s=qL(t);return"translate(".concat(n,"px, ").concat(e,"px) scale(").concat(s,")")},sx=function(n,e,t){var s=t.offsetWidth*n,r=t.offsetHeight*n,o=(e.offsetWidth-s)/2,i=(e.offsetHeight-r)/2;return{scale:n,positionX:o,positionY:i}};function VL(n,e){n!=null&&(typeof n=="function"?n(e):n.current=e)}function HL(n){return function(e){n.forEach(function(t){typeof t=="function"?t(e):t!=null&&(t.current=e)})}}var T4=function(n,e){var t=n.setup.wheel,s=t.disabled,r=t.wheelDisabled,o=t.touchPadDisabled,i=t.excluded,l=n.isInitialized,c=n.isPanning,u=e.target,d=l&&!c&&!s&&u;if(!d||r&&!e.ctrlKey||o&&e.ctrlKey)return!1;var f=sc(u,i);if(f)return!1;var m=n.isPressingKeys(n.setup.wheel.activationKeys);return!!m},KL=function(n,e){var t=n.setup,s=t.disabled,r=t.trackPadPanning,o=r.activationKeys,i=r.excluded;if(!n.wrapperComponent||!n.contentComponent||s||r.disabled||e.ctrlKey)return!1;var l=T4(n,e);if(l)return!1;var c=e.target,u=sc(c,i);if(u)return!1;var d=n.isPressingKeys(o);return!!d},GL=function(n){return n?n.deltaY<0?1:-1:0};function ZL(n,e){var t=GL(n),s=iL(e,t);return s}function A4(n,e,t){var s=e.getBoundingClientRect(),r=0,o=0;if("clientX"in n)r=(n.clientX-s.left)/t,o=(n.clientY-s.top)/t;else{var i=n.touches[0];r=(i.clientX-s.left)/t,o=(i.clientY-s.top)/t}return Number.isNaN(r)||Number.isNaN(o)?(console.error("No mouse or touch offset found"),{x:0,y:0}):{x:r,y:o}}var YL=function(n,e,t,s,r){var o=n.state.scale,i=n.wrapperComponent,l=n.setup,c=l.maxScale,u=l.minScale,d=l.zoomAnimation,f=l.disablePadding,m=d.size,p=d.disabled;if(!i)throw new Error("Wrapper is not mounted");var h=o+e*t,g=s?!1:!p,x=nc(h,u,c,m,g&&!f);return x},P4=function(n,e){var t=n.previousWheelEvent,s=n.state.scale,r=n.setup,o=r.maxScale,i=r.minScale;return t?s<o||s>i||Math.sign(t.deltaY)!==Math.sign(e.deltaY)||t.deltaY>0&&t.deltaY<e.deltaY||t.deltaY<0&&t.deltaY>e.deltaY||Math.sign(t.deltaY)!==Math.sign(e.deltaY):!1},XL=function(n,e){var t=n.setup.pinch,s=t.disabled,r=t.excluded,o=n.isInitialized,i=e.target,l=o&&!s&&i;if(!l)return!1;var c=sc(i,r);return!c},JL=function(n){var e=n.setup.pinch.disabled,t=n.isInitialized,s=n.pinchStartDistance,r=t&&!e&&s!==null;return!!r},QL=function(n,e,t){var s=t.getBoundingClientRect(),r=n.touches,o=r[0].clientX-s.left,i=r[0].clientY-s.top,l=r[1].clientX-s.left,c=r[1].clientY-s.top;return{x:(o+l)/2/e,y:(i+c)/2/e}},I4=function(n){return Math.sqrt(Math.pow(n.touches[0].pageX-n.touches[1].pageX,2)+Math.pow(n.touches[0].pageY-n.touches[1].pageY,2))},eM=5,tM=function(n,e){var t=n.pinchStartScale,s=n.pinchStartDistance,r=n.setup,o=r.maxScale,i=r.minScale,l=r.zoomAnimation,c=r.disablePadding,u=r.pinch,d=l.size,f=l.disabled,m=u.step;if(!t||s===null)throw new Error("Pinch touches distance was not provided");if(e<0)return n.state.scale;var p=e/s,h=p*t,g=(h-t)*(m/eM),x=t+g,b=x===1/0?0:Lo(x,10);return nc(b,i,o,d,!f&&!c)},$4=160,R4=100,nM=function(n,e){var t=n.props,s=t.onWheelStart,r=t.onZoomStart;n.wheelStopEventTimer||(Ps(n),mt(ut(n),e,s),mt(ut(n),e,r))},sM=function(n,e){var t=n.props,s=t.onWheel,r=t.onZoom,o=n.contentComponent,i=n.setup,l=n.state,c=l.scale,u=i.limitToBounds,d=i.centerZoomedOut,f=i.zoomAnimation,m=i.wheel,p=i.disablePadding,h=i.smooth,g=f.size,x=f.disabled,b=m.step;if(!o)throw new Error("Component not mounted");e.cancelable&&e.preventDefault(),e.stopPropagation();var y=ZL(e,null),v=h?b*Math.abs(e.deltaY):b,k=YL(n,y,v,!e.ctrlKey);if(c!==k){var j=Oi(n,k),_=A4(e,o,c),N=x||g===0||d||p,S=u&&N,C=ef(n,_.x,_.y,k,j,S),E=C.x,T=C.y;n.previousWheelEvent=e,n.setState(k,E,T),mt(ut(n),e,s),mt(ut(n),e,r)}},rM=function(n,e){var t=n.props,s=t.onWheelStop,r=t.onZoomStop;yl(n.wheelAnimationTimer),n.wheelAnimationTimer=setTimeout(function(){n.mounted&&(nx(n,e.x,e.y),n.wheelAnimationTimer=null)},R4);var o=P4(n,e);o&&(yl(n.wheelStopEventTimer),n.wheelStopEventTimer=setTimeout(function(){n.mounted&&(n.wheelStopEventTimer=null,mt(ut(n),e,s),mt(ut(n),e,r))},$4))},oM=function(n,e){var t=n.props,s=t.onWheelStart,r=t.onPanningStart;n.wheelStopEventTimer||(Ps(n),mt(ut(n),e,s),mt(ut(n),e,r))},iM=function(n,e){var t=n.props,s=t.onWheelStop,r=t.onPanningStop;yl(n.wheelAnimationTimer),n.wheelAnimationTimer=setTimeout(function(){n.mounted&&(nx(n,e.x,e.y),n.wheelAnimationTimer=null)},R4);var o=P4(n,e);o&&(yl(n.wheelStopEventTimer),n.wheelStopEventTimer=setTimeout(function(){n.mounted&&(n.wheelStopEventTimer=null,mt(ut(n),e,s),mt(ut(n),e,r))},$4))},O4=function(n){for(var e=0,t=0,s=0;s<2;s+=1)e+=n.touches[s].clientX,t+=n.touches[s].clientY;var r=e/2,o=t/2;return{x:r,y:o}},aM=function(n,e){var t=I4(e);n.pinchStartDistance=t,n.lastDistance=t,n.pinchStartScale=n.state.scale,n.isPanning=!1,n.isPinching=!0,n.pinchPreviousCenter=O4(e),Ps(n)},lM=function(n,e){var t=n.contentComponent,s=n.pinchStartDistance,r=n.wrapperComponent,o=n.pinchPreviousCenter,i=n.state.scale,l=n.setup,c=l.limitToBounds,u=l.centerZoomedOut,d=l.zoomAnimation,f=l.autoAlignment,m=l.pinch,p=l.panning,h=d.disabled,g=d.size,x=m.allowPanning;if(!(s===null||!t)){var b=QL(e,i,t);if(!(!Number.isFinite(b.x)||!Number.isFinite(b.y))){var y=I4(e),v=tM(n,y),k=O4(e),j=i/v,_=(k.x-((o==null?void 0:o.x)||0))*j,N=(k.y-((o==null?void 0:o.y)||0))*j;if(!(v===i&&_===0&&N===0)){n.pinchPreviousCenter=k;var S=Oi(n,v),C=h||g===0||u,E=c&&C,T=ef(n,b.x,b.y,v,S,E),A=T.x,P=T.y;if(n.pinchMidpoint=b,n.lastDistance=y,p.disabled||!x)n.setState(v,A,P);else{var I=f.sizeX,$=f.sizeY,O=fo(n,I,v),M=fo(n,$,v),R=A+_,z=P+N,W=tc(R,z,S,c,O,M,r),D=W.x,L=W.y;n.setState(v,D,L)}}}}},cM=function(n){var e=n.pinchMidpoint;n.velocity=null,n.lastDistance=null,n.pinchMidpoint=null,n.pinchStartScale=null,n.pinchStartDistance=null,n.isPinching=!1,nx(n,e==null?void 0:e.x,e==null?void 0:e.y)},L4=function(n,e){var t=n.props.onZoomStop,s=n.setup.doubleClick.animationTime;yl(n.doubleClickStopEventTimer),n.doubleClickStopEventTimer=setTimeout(function(){n.doubleClickStopEventTimer=null,mt(ut(n),e,t)},s)},uM=function(n,e){var t=n.props,s=t.onZoomStart,r=t.onZoom,o=n.setup.doubleClick,i=o.animationTime,l=o.animationType;mt(ut(n),e,s),_4(n,i,l,function(){return mt(ut(n),e,r)}),L4(n,e)};function dM(n,e){return n==="toggle"?e===1?1:-1:n==="zoomOut"?-1:1}function fM(n,e){var t=n.setup,s=n.doubleClickStopEventTimer,r=n.state,o=n.contentComponent,i=r.scale,l=n.props,c=l.onZoomStart,u=l.onZoom,d=t.doubleClick,f=d.disabled,m=d.mode,p=d.step,h=d.animationTime,g=d.animationType;if(!f&&!s){if(m==="reset")return uM(n,e);if(!o)return console.error("No ContentComponent found");var x=dM(m,n.state.scale),b=N4(n,x,p);if(i!==b){mt(ut(n),e,c);var y=A4(e,o,i),v=tx(n,b,y.x,y.y);if(!v)return console.error("Error during zoom event. New transformation state was not calculated.");mt(ut(n),e,u),jo(n,v,h,g),L4(n,e)}}}var mM=function(n,e){var t=n.isInitialized,s=n.setup,r=n.wrapperComponent,o=s.doubleClick,i=o.disabled,l=o.excluded,c=e.target,u=r==null?void 0:r.contains(c),d=t&&c&&u&&!i;if(!d)return!1;var f=sc(c,l);return!f},pM=(function(){function n(e){var t=this;this.mounted=!0,this.onChangeCallbacks=new Set,this.onInitCallbacks=new Set,this.onTransformCallbacks=new Set,this.wrapperComponent=null,this.contentComponent=null,this.isInitialized=!1,this.bounds=null,this.previousWheelEvent=null,this.wheelStopEventTimer=null,this.wheelAnimationTimer=null,this.isPanning=!1,this.isWheelPanning=!1,this.startCoords=null,this.panStartPosition=null,this.lastTouch=null,this.isPinching=!1,this.distance=null,this.lastDistance=null,this.pinchStartDistance=null,this.pinchStartScale=null,this.pinchMidpoint=null,this.pinchPreviousCenter=null,this.doubleClickStopEventTimer=null,this.velocity=null,this.velocityTime=null,this.lastMousePosition=null,this.isAnimating=!1,this.animation=null,this.pressedKeys={},this.mount=function(){t.initializeWindowEvents()},this.unmount=function(){t.cleanupWindowEvents()},this.update=function(s){t.props=s,t.wrapperComponent&&t.contentComponent&&Oi(t,t.state.scale),t.setup=zv(s)},this.initializeWindowEvents=function(){var s,r,o,i,l=mm(),c=(s=t.wrapperComponent)===null||s===void 0?void 0:s.ownerDocument,u=c==null?void 0:c.defaultView;(r=t.wrapperComponent)===null||r===void 0||r.addEventListener("wheel",t.onWheelPanning,l),(o=t.wrapperComponent)===null||o===void 0||o.addEventListener("keyup",t.setKeyUnPressed,l),(i=t.wrapperComponent)===null||i===void 0||i.addEventListener("keydown",t.setKeyPressed,l),u==null||u.addEventListener("mousedown",t.onPanningStart,l),u==null||u.addEventListener("mousemove",t.onPanning,l),u==null||u.addEventListener("mouseup",t.onPanningStop,l),c==null||c.addEventListener("mouseleave",t.clearPanning,l),u==null||u.addEventListener("keyup",t.setKeyUnPressed,l),u==null||u.addEventListener("keydown",t.setKeyPressed,l),u==null||u.addEventListener("blur",t.handleWindowBlur)},this.cleanupWindowEvents=function(){var s,r,o,i,l,c=mm(),u=(s=t.wrapperComponent)===null||s===void 0?void 0:s.ownerDocument,d=u==null?void 0:u.defaultView;d==null||d.removeEventListener("mousedown",t.onPanningStart,c),d==null||d.removeEventListener("mousemove",t.onPanning,c),d==null||d.removeEventListener("mouseup",t.onPanningStop,c),u==null||u.removeEventListener("mouseleave",t.clearPanning,c),d==null||d.removeEventListener("keyup",t.setKeyUnPressed,c),d==null||d.removeEventListener("keydown",t.setKeyPressed,c),d==null||d.removeEventListener("blur",t.handleWindowBlur),document.removeEventListener("mouseleave",t.clearPanning,c),(r=t.wrapperComponent)===null||r===void 0||r.removeEventListener("wheel",t.onWheelPanning,c),(o=t.wrapperComponent)===null||o===void 0||o.removeEventListener("keyup",t.setKeyUnPressed,c),(i=t.wrapperComponent)===null||i===void 0||i.removeEventListener("keydown",t.setKeyPressed,c),Ps(t),(l=t.observer)===null||l===void 0||l.disconnect()},this.handleInitializeWrapperEvents=function(s){var r=mm();s.addEventListener("wheel",t.onWheelZoom,r),s.addEventListener("dblclick",t.onDoubleClick,r),s.addEventListener("touchstart",t.onTouchPanningStart,r),s.addEventListener("touchmove",t.onTouchPanning,r),s.addEventListener("touchend",t.onTouchPanningStop,r)},this.handleInitialize=function(s){var r=t.setup.centerOnInit;t.applyTransformation(),t.onInitCallbacks.forEach(function(o){return o(ut(t))}),r&&(t.setCenter(),t.observer=new ResizeObserver(function(){var o,i=s.offsetWidth,l=s.offsetHeight;(i>0||l>0)&&(t.onInitCallbacks.forEach(function(c){return c(ut(t))}),t.setCenter(),(o=t.observer)===null||o===void 0||o.disconnect())}),setTimeout(function(){var o;(o=t.observer)===null||o===void 0||o.disconnect()},5e3),t.observer.observe(s))},this.onWheelZoom=function(s){var r=t.setup.disabled;if(!r){t.syncModifierKeys(s);var o=T4(t,s);o&&(nM(t,s),sM(t,s),rM(t,s))}},this.onWheelPanning=function(s){var r=t.props.onPanning,o=t.setup.trackPadPanning,i=o.lockAxisX,l=o.lockAxisY;t.syncModifierKeys(s);var c=KL(t,s);if(c){s.cancelable&&s.preventDefault(),s.stopPropagation();var u=t.state,d=u.positionX,f=u.positionY,m=d-s.deltaX,p=f-s.deltaY,h=i?d:m,g=l?f:p,x=t.setup.autoAlignment,b=x.sizeX,y=x.sizeY,v=fo(t,b),k=fo(t,y);h===d&&g===f||(oM(t,s),S4(t,h,g,v,k),mt(ut(t),s,r),iM(t,s))}},this.onPanningStart=function(s){var r=t.setup.disabled,o=t.props.onPanningStart;if(!r){t.syncModifierKeys(s);var i=Iv(t,s);if(i){var l=t.isPressingKeys(t.setup.panning.activationKeys);l&&(s.button===0&&!t.setup.panning.allowLeftClickPan||s.button===1&&!t.setup.panning.allowMiddleClickPan||s.button===2&&!t.setup.panning.allowRightClickPan||(s.cancelable&&s.preventDefault(),s.stopPropagation(),Ps(t),Ov(t,s),mt(ut(t),s,o)))}}},this.onPanning=function(s){var r=t.setup.disabled,o=t.props.onPanning;if(!r){if(t.syncModifierKeys(s),t.isPanning&&s.buttons===0){t.clearPanning(s);return}var i=$v(t);if(i){var l=t.isPressingKeys(t.setup.panning.activationKeys);l&&(s.cancelable&&s.preventDefault(),s.stopPropagation(),Lv(t,s.clientX,s.clientY,Zr.MOUSE),mt(ut(t),s,o))}}},this.onPanningStop=function(s){var r=t.setup.panning.velocityDisabled,o=t.props.onPanningStop;t.isPanning&&(RL(t,r),mt(ut(t),s,o))},this.onPinchStart=function(s){var r=t.setup.disabled,o=t.props.onPinchStart;if(!r){var i=XL(t,s);i&&(aM(t,s),Ps(t),mt(ut(t),s,o))}},this.onPinch=function(s){var r=t.setup.disabled,o=t.props.onPinch;if(!r){var i=JL(t);i&&(s.cancelable&&s.preventDefault(),s.stopPropagation(),lM(t,s),mt(ut(t),s,o))}},this.onPinchStop=function(s){var r=t.props.onPinchStop;t.pinchStartScale&&(cM(t),mt(ut(t),s,r))},this.onTouchPanningStart=function(s){var r=t.setup,o=r.disabled,i=r.doubleClick,l=t.props.onPanningStart;if(!o){var c=!(i!=null&&i.disabled),u=t.lastTouch&&+new Date-t.lastTouch<200;if(c&&u&&s.touches.length===1)t.onDoubleClick(s);else{t.lastTouch=+new Date,Ps(t);var d=s.touches,f=d.length===1,m=d.length===2,p=Iv(t,s);if(f){if(!p)return;Ps(t),Ov(t,s),mt(ut(t),s,l)}m&&t.onPinchStart(s)}}},this.onTouchPanning=function(s){var r=t.setup.disabled,o=t.props.onPanning;if(t.isPanning&&s.touches.length===1){if(r)return;var i=$v(t);if(!i)return;s.cancelable&&s.preventDefault(),s.stopPropagation();var l=s.touches[0];Lv(t,l.clientX,l.clientY,Zr.TOUCH),mt(ut(t),s,o)}else s.touches.length>1&&t.onPinch(s)},this.onTouchPanningStop=function(s){t.onPanningStop(s),t.onPinchStop(s)},this.onDoubleClick=function(s){var r=t.setup.disabled;if(!r){var o=mM(t,s);o&&fM(t,s)}},this.clearPanning=function(s){t.isPanning&&t.onPanningStop(s)},this.handleWindowBlur=function(){t.pressedKeys={},t.isPanning&&(t.isPanning=!1,t.startCoords=null)},this.syncModifierKeys=function(s){var r=s.ctrlKey,o=s.metaKey,i=s.shiftKey,l=s.altKey;typeof r=="boolean"&&(t.pressedKeys.Control=r),typeof o=="boolean"&&(t.pressedKeys.Meta=o),typeof i=="boolean"&&(t.pressedKeys.Shift=i),typeof l=="boolean"&&(t.pressedKeys.Alt=l)},this.setKeyPressed=function(s){t.pressedKeys[s.key]=!0},this.setKeyUnPressed=function(s){t.pressedKeys[s.key]=!1},this.isPressingKeys=function(s){return typeof s=="function"?s(Object.entries(t.pressedKeys).filter(function(r){var o=r[1];return o}).map(function(r){var o=r[0];return o})):s.length?!!s.every(function(r){return t.pressedKeys[r]}):!0},this.setCenter=function(){if(t.wrapperComponent&&t.contentComponent){var s=sx(t.state.scale,t.wrapperComponent,t.contentComponent);t.setState(s.scale,s.positionX,s.positionY)}},this.handleTransformStyles=function(s,r,o){return t.props.customTransform?t.props.customTransform(s,r,o):E4(s,r,o)},this.getContext=function(){return ut(t)},this.applyTransformation=function(){if(!(!t.mounted||!t.contentComponent)){var s=t.state,r=s.scale,o=s.positionX,i=s.positionY,l=t.handleTransformStyles(o,i,r);t.props.detached||(t.contentComponent.style.transform=l),t.onTransformCallbacks.forEach(function(c){return c({scale:r,positionX:o,positionY:i,previousScale:t.state.previousScale,ref:ut(t)})})}},this.setState=function(s,r,o){var i=t.props.onTransform;if(!Number.isNaN(s)&&!Number.isNaN(r)&&!Number.isNaN(o)){var l=Math.max(s,1e-7);l!==t.state.scale&&(t.state.previousScale=t.state.scale,t.state.scale=l),t.state.positionX=r,t.state.positionY=o,t.applyTransformation();var c=ut(t);t.onChangeCallbacks.forEach(function(u){return u(c)}),mt(c,{scale:t.state.scale,positionX:r,positionY:o},i)}else console.error("Detected NaN set state values")},this.onTransform=function(s){return t.onTransformCallbacks.has(s)||t.onTransformCallbacks.add(s),function(){t.onTransformCallbacks.delete(s)}},this.onChange=function(s){return t.onChangeCallbacks.has(s)||t.onChangeCallbacks.add(s),function(){t.onChangeCallbacks.delete(s)}},this.onInit=function(s){return t.onInitCallbacks.has(s)||t.onInitCallbacks.add(s),function(){t.onInitCallbacks.delete(s)}},this.init=function(s,r){t.cleanupWindowEvents(),t.wrapperComponent=s,t.contentComponent=r,Oi(t,t.state.scale),t.handleInitializeWrapperEvents(s),t.handleInitialize(r),t.initializeWindowEvents(),t.isInitialized=!0;var o=ut(t);mt(o,void 0,t.props.onInit),VL(t.props.ref,o)},this.props=e,this.setup=zv(this.props),this.state=j4(this.props)}return n})(),tf=Te.createContext(null),hM=function(n,e){return typeof n=="function"?n(e):n},gM=Te.forwardRef(function(n,e){var t=w.useRef(new pM(n)).current,s=hM(n.children,qh(t));return w.useImperativeHandle(e,function(){return qh(t)},[t]),w.useEffect(function(){t.update(n)},[t,n]),a.jsx(tf.Provider,ps({value:t},{children:s}))});Te.forwardRef(function(n,e){var t=w.useRef(null),s=w.useContext(tf);return w.useEffect(function(){return s.onChange(function(r){if(t.current){var o=0,i=0;t.current.style.transform=s.handleTransformStyles(o,i,1/r.instance.state.scale)}})},[s]),a.jsx("div",ps({},n,{ref:HL([t,e])}))});function xM(n,e){e===void 0&&(e={});var t=e.insertAt;if(!(typeof document>"u")){var s=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&s.firstChild?s.insertBefore(r,s.firstChild):s.appendChild(r),r.styleSheet?r.styleSheet.cssText=n:r.appendChild(document.createTextNode(n))}}var bM=`.transform-component-module_wrapper__SPB86 {
|
|
11
|
+
position: relative;
|
|
12
|
+
width: -moz-fit-content;
|
|
13
|
+
width: fit-content;
|
|
14
|
+
height: -moz-fit-content;
|
|
15
|
+
height: fit-content;
|
|
16
|
+
overflow: hidden;
|
|
17
|
+
-webkit-touch-callout: none; /* iOS Safari */
|
|
18
|
+
-webkit-user-select: none; /* Safari */
|
|
19
|
+
-khtml-user-select: none; /* Konqueror HTML */
|
|
20
|
+
-moz-user-select: none; /* Firefox */
|
|
21
|
+
-ms-user-select: none; /* Internet Explorer/Edge */
|
|
22
|
+
user-select: none;
|
|
23
|
+
margin: 0;
|
|
24
|
+
padding: 0;
|
|
25
|
+
transform: translate3d(0, 0, 0);
|
|
26
|
+
}
|
|
27
|
+
.transform-component-module_content__FBWxo {
|
|
28
|
+
display: flex;
|
|
29
|
+
flex-wrap: wrap;
|
|
30
|
+
width: -moz-fit-content;
|
|
31
|
+
width: fit-content;
|
|
32
|
+
height: -moz-fit-content;
|
|
33
|
+
height: fit-content;
|
|
34
|
+
margin: 0;
|
|
35
|
+
padding: 0;
|
|
36
|
+
transform-origin: 0% 0%;
|
|
37
|
+
}
|
|
38
|
+
.transform-component-module_content__FBWxo img {
|
|
39
|
+
pointer-events: none;
|
|
40
|
+
}
|
|
41
|
+
.transform-component-module_infiniteGrid__Z-aP3 {
|
|
42
|
+
position: absolute;
|
|
43
|
+
inset: 0;
|
|
44
|
+
pointer-events: none;
|
|
45
|
+
background-image: radial-gradient(
|
|
46
|
+
circle,
|
|
47
|
+
rgba(0, 0, 0, 0.12) 1px,
|
|
48
|
+
transparent 1px
|
|
49
|
+
);
|
|
50
|
+
background-size: 20px 20px;
|
|
51
|
+
background-position: 0 0;
|
|
52
|
+
}
|
|
53
|
+
`,pm={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo",infiniteGrid:"transform-component-module_infiniteGrid__Z-aP3"};xM(bM);var vM=function(n){var e=n.children,t=n.wrapperClass,s=t===void 0?"":t,r=n.contentClass,o=r===void 0?"":r,i=n.wrapperStyle,l=n.contentStyle,c=n.wrapperProps,u=c===void 0?{}:c,d=n.contentProps,f=d===void 0?{}:d,m=n.infinite,p=m===void 0?!1:m,h=w.useContext(tf),g=h.init,x=h.cleanupWindowEvents,b=w.useRef(null),y=w.useRef(null),v=w.useRef(null);return w.useEffect(function(){var k=b.current,j=y.current;return k!==null&&j!==null&&g&&(g==null||g(k,j)),function(){x==null||x()}},[]),w.useEffect(function(){if(p){var k=v.current;if(k){var j=function(){var _=h.state,N=_.positionX,S=_.positionY;k.style.backgroundPosition="".concat(N,"px ").concat(S,"px")};return j(),h.onChange(j)}}},[p,h]),a.jsxs("div",ps({},u,{ref:b,className:"".concat(Wh.wrapperClass," ").concat(pm.wrapper," ").concat(s),style:i},{children:[p&&a.jsx("div",{ref:v,className:pm.infiniteGrid,"aria-hidden":!0}),a.jsx("div",ps({},f,{ref:y,className:"".concat(Wh.contentClass," ").concat(pm.content," ").concat(o),style:ps(ps({},l),{transform:E4(h.state.positionX,h.state.positionY,h.state.scale)})},{children:e}))]}))};function yM(n,e){var t=Math.max(0,Math.min(n.x+n.width,e.x+e.width)-Math.max(n.x,e.x)),s=Math.max(0,Math.min(n.y+n.height,e.y+e.height)-Math.max(n.y,e.y));return t*s}function wM(n){var e=n.elementX,t=n.elementY,s=n.elementWidth,r=n.elementHeight,o=n.scale,i=n.positionX,l=n.positionY,c=n.viewportWidth,u=n.viewportHeight,d=n.margin,f=d===void 0?0:d,m=n.threshold,p=m===void 0?0:m,h={x:-f,y:-f,width:c+2*f,height:u+2*f},g={x:e*o+i,y:t*o+l,width:s*o,height:r*o};if(p<=0){var x=g.x<h.x+h.width&&g.x+g.width>h.x,b=g.y<h.y+h.height&&g.y+g.height>h.y;return x&&b}var y=g.width*g.height;if(y<=0)return!1;var v=yM(h,g);return v/y>=p}Te.forwardRef(function(n,e){var t=n.x,s=n.y,r=n.width,o=n.height,i=n.margin,l=i===void 0?0:i,c=n.threshold,u=c===void 0?0:c,d=n.placeholder,f=d===void 0?null:d,m=n.onShow,p=n.onHide,h=n.children,g=n.className,x=n.style,b=w.useContext(tf),y=w.useState(!1),v=y[0],k=y[1],j=w.useRef(!1),_=w.useRef(m),N=w.useRef(p);return _.current=m,N.current=p,w.useEffect(function(){var S=function(){var T,A,P=b.wrapperComponent;if(P){var I=wM({elementX:t,elementY:s,elementWidth:r,elementHeight:o,scale:b.state.scale,positionX:b.state.positionX,positionY:b.state.positionY,viewportWidth:P.offsetWidth,viewportHeight:P.offsetHeight,margin:l,threshold:u});I!==j.current&&(j.current=I,k(I),I?(T=_.current)===null||T===void 0||T.call(_):(A=N.current)===null||A===void 0||A.call(N))}};S();var C=b.onChange(S),E;return b.wrapperComponent||(E=b.onInit(function(){return S()})),function(){C(),E==null||E()}},[b,t,s,r,o,l,u]),v?a.jsx("div",ps({ref:e,className:g,style:x},{children:h})):f?a.jsx(a.Fragment,{children:f}):null});const Dv=8,SM=56;function ba(n){const e=q.c(8),{label:t,disabled:s,onClick:r,children:o,className:i}=n;let l;e[0]!==i?(l=G("size-8 border border-border bg-background text-foreground/75","hover:bg-accent hover:text-foreground focus-visible:ring-ring/40","disabled:pointer-events-none disabled:opacity-30",i),e[0]=i,e[1]=l):l=e[1];let c;return e[2]!==o||e[3]!==s||e[4]!==t||e[5]!==r||e[6]!==l?(c=a.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:r,disabled:s,"aria-label":t,title:t,className:l,children:o}),e[2]=o,e[3]=s,e[4]=t,e[5]=r,e[6]=l,e[7]=c):c=e[7],c}function rx(n){const e=q.c(101),{open:t,images:s,initialIndex:r,onClose:o,onCloseComplete:i}=n,l=t===void 0?!0:t,c=Math.min(Math.max(r,0),Math.max(s.length-1,0)),[u,d]=w.useState(c),[f,m]=w.useState(100),p=w.useRef(null),h=w.useRef(null),g=s[u];let x;e[0]!==s.length?(x=Se=>{d(Math.min(Math.max(Se,0),s.length-1)),m(100)},e[0]=s.length,e[1]=x):x=e[1];const b=x;let y;e[2]!==b||e[3]!==u?(y=()=>b(u-1),e[2]=b,e[3]=u,e[4]=y):y=e[4];const v=y;let k;e[5]!==b||e[6]!==u?(k=()=>b(u+1),e[5]=b,e[6]=u,e[7]=k):k=e[7];const j=k;if(!g)return null;const _=s.length>1,N=u>0,S=u<s.length-1,C=f>100;let E;e[8]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{var Se;return(Se=p.current)==null?void 0:Se.zoomIn()},e[8]=E):E=e[8];const T=E;let A;e[9]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{var Se;return(Se=p.current)==null?void 0:Se.zoomOut()},e[9]=A):A=e[9];const P=A;let I;e[10]===Symbol.for("react.memo_cache_sentinel")?(I=()=>{var Se;return(Se=p.current)==null?void 0:Se.resetTransform()},e[10]=I):I=e[10];const $=I;let O;e[11]!==S||e[12]!==N||e[13]!==j||e[14]!==v?(O=Se=>{Se.key==="ArrowLeft"&&N?(Se.preventDefault(),v()):Se.key==="ArrowRight"&&S?(Se.preventDefault(),j()):Se.key==="+"||Se.key==="="?(Se.preventDefault(),T()):Se.key==="-"?(Se.preventDefault(),P()):Se.key==="0"&&(Se.preventDefault(),$())},e[11]=S,e[12]=N,e[13]=j,e[14]=v,e[15]=O):O=e[15];const M=O;let R;e[16]===Symbol.for("react.memo_cache_sentinel")?(R=Se=>{if(Se.pointerType==="mouse"||Se.isPrimary===!1){h.current=null;return}h.current={x:Se.clientX,y:Se.clientY}},e[16]=R):R=e[16];const z=R;let W;e[17]!==S||e[18]!==N||e[19]!==j||e[20]!==v?(W=Se=>{var Be;const Ne=h.current;h.current=null;const He=((Be=p.current)==null?void 0:Be.instance.state.scale)??1;if(!Ne||He>1.01)return;const Ke=Se.clientX-Ne.x,Ce=Se.clientY-Ne.y;Math.abs(Ke)<SM||Math.abs(Ke)<Math.abs(Ce)||(Ke>0&&N&&v(),Ke<0&&S&&j())},e[17]=S,e[18]=N,e[19]=j,e[20]=v,e[21]=W):W=e[21];const D=W;let L;e[22]!==o?(L=Se=>{Se||o()},e[22]=o,e[23]=L):L=e[23];let U;e[24]!==i?(U=Se=>{Se||i==null||i()},e[24]=i,e[25]=U):U=e[25];let F,B,V;e[26]===Symbol.for("react.memo_cache_sentinel")?(F=G("flex h-[calc(100dvh-1rem)] w-[calc(100vw-1rem)] max-w-none flex-col gap-0 overflow-hidden rounded-xl border-border bg-popover p-0 text-foreground","sm:h-[min(820px,calc(100dvh-2rem))] sm:w-[min(1120px,calc(100vw-2rem))] sm:max-w-none"),B=a.jsx(mr,{className:"sr-only",children:"Image viewer"}),V=a.jsx(pr,{className:"sr-only",children:"View and navigate images from this session."}),e[26]=F,e[27]=B,e[28]=V):(F=e[26],B=e[27],V=e[28]);let H;e[29]===Symbol.for("react.memo_cache_sentinel")?(H=a.jsx("span",{className:"flex size-7 shrink-0 items-center justify-center rounded-md bg-background",children:a.jsx(V7,{className:"size-3.5 text-foreground/65","data-icon":"icon"})}),e[29]=H):H=e[29];const K=g.label||g.alt||"Session image";let Z;e[30]!==K?(Z=a.jsx("div",{className:"truncate text-xs font-medium text-foreground/90",children:K}),e[30]=K,e[31]=Z):Z=e[31];let Y;e[32]!==_||e[33]!==s.length||e[34]!==u?(Y=_&&a.jsxs("div",{className:"text-xs tabular-nums text-foreground/50",children:[u+1," of ",s.length]}),e[32]=_,e[33]=s.length,e[34]=u,e[35]=Y):Y=e[35];let X;e[36]!==Z||e[37]!==Y?(X=a.jsxs("div",{className:"min-w-0 flex-1",children:[Z,Y]}),e[36]=Z,e[37]=Y,e[38]=X):X=e[38];const se=f<=100;let Q;e[39]===Symbol.for("react.memo_cache_sentinel")?(Q=a.jsx(w3,{className:"size-3.5","data-icon":"icon"}),e[39]=Q):Q=e[39];let te;e[40]!==se?(te=a.jsx(ba,{label:"Zoom out",disabled:se,onClick:P,children:Q}),e[40]=se,e[41]=te):te=e[41];let J;e[42]!==f?(J=a.jsxs(ee,{type:"button",variant:"ghost",size:"sm",onClick:$,className:"min-w-12 px-1.5 font-mono text-xs tabular-nums text-foreground/60 hover:bg-background hover:text-foreground","aria-label":"Reset zoom",title:"Reset zoom",children:[f,"%"]}),e[42]=f,e[43]=J):J=e[43];const ne=f>=Dv*100;let re;e[44]===Symbol.for("react.memo_cache_sentinel")?(re=a.jsx(tr,{className:"size-3.5","data-icon":"icon"}),e[44]=re):re=e[44];let le;e[45]!==ne?(le=a.jsx(ba,{label:"Zoom in",disabled:ne,onClick:T,children:re}),e[45]=ne,e[46]=le):le=e[46];let ae;e[47]===Symbol.for("react.memo_cache_sentinel")?(ae=a.jsx("div",{className:"mx-1 h-5 w-px bg-border"}),e[47]=ae):ae=e[47];let ue;e[48]===Symbol.for("react.memo_cache_sentinel")?(ue=a.jsx(Ut,{className:"size-4","data-icon":"icon"}),e[48]=ue):ue=e[48];let oe;e[49]!==o?(oe=a.jsx(ba,{label:"Close image viewer",onClick:o,children:ue}),e[49]=o,e[50]=oe):oe=e[50];let ie;e[51]!==te||e[52]!==J||e[53]!==le||e[54]!==oe?(ie=a.jsxs("div",{className:"flex items-center gap-1",children:[te,J,le,ae,oe]}),e[51]=te,e[52]=J,e[53]=le,e[54]=oe,e[55]=ie):ie=e[55];let fe;e[56]!==X||e[57]!==ie?(fe=a.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-2 border-b border-border bg-background px-2.5 sm:px-3",children:[H,X,ie]}),e[56]=X,e[57]=ie,e[58]=fe):fe=e[58];const de=g.id;let ce,xe,pe;e[59]===Symbol.for("react.memo_cache_sentinel")?(ce={mode:"toggle"},xe={step:.005},pe=(Se,Ne)=>m(Math.round(Ne.scale*100)),e[59]=ce,e[60]=xe,e[61]=pe):(ce=e[59],xe=e[60],pe=e[61]);let he,ye;e[62]===Symbol.for("react.memo_cache_sentinel")?(he={width:"100%",height:"100%"},ye={width:"100%",height:"100%"},e[62]=he,e[63]=ye):(he=e[62],ye=e[63]);const ve=g.src,ke=g.alt,je=C?"cursor-grab active:cursor-grabbing":"cursor-zoom-in";let Me;e[64]!==je?(Me=G("max-h-full max-w-full select-none object-contain",je),e[64]=je,e[65]=Me):Me=e[65];let _e;e[66]!==g.alt||e[67]!==g.src||e[68]!==Me?(_e=a.jsx(vM,{wrapperStyle:he,contentStyle:ye,contentClass:"flex items-center justify-center p-3 sm:p-6",children:a.jsx("img",{src:ve,alt:ke,draggable:!1,className:Me})}),e[66]=g.alt,e[67]=g.src,e[68]=Me,e[69]=_e):_e=e[69];let Fe;e[70]!==g.id||e[71]!==_e?(Fe=a.jsx(gM,{ref:p,minScale:1,maxScale:Dv,centerOnInit:!0,centerZoomedOut:!0,doubleClick:ce,wheel:xe,onTransform:pe,children:_e},de),e[70]=g.id,e[71]=_e,e[72]=Fe):Fe=e[72];let ze;e[73]!==S||e[74]!==N||e[75]!==j||e[76]!==v||e[77]!==_?(ze=_&&a.jsxs(a.Fragment,{children:[a.jsx(ba,{label:"Previous image",disabled:!N,onClick:v,className:"absolute left-2 top-1/2 size-10 -translate-y-1/2 rounded-full bg-popover backdrop-blur sm:left-3",children:a.jsx(t1,{className:"size-5","data-icon":"icon"})}),a.jsx(ba,{label:"Next image",disabled:!S,onClick:j,className:"absolute right-2 top-1/2 size-10 -translate-y-1/2 rounded-full bg-popover backdrop-blur sm:right-3",children:a.jsx(ot,{className:"size-5","data-icon":"icon"})})]}),e[73]=S,e[74]=N,e[75]=j,e[76]=v,e[77]=_,e[78]=ze):ze=e[78];let We;e[79]!==f?(We=f===100&&a.jsxs("div",{className:"pointer-events-none absolute bottom-2 left-1/2 hidden -translate-x-1/2 items-center gap-1.5 rounded-full bg-popover px-2.5 py-1 text-xs text-foreground/60 sm:flex",children:[a.jsx(Ld,{className:"size-3","data-icon":"inline-start"}),"Scroll or double-click to zoom · drag to pan"]}),e[79]=f,e[80]=We):We=e[80];let Pe;e[81]!==D||e[82]!==Fe||e[83]!==ze||e[84]!==We?(Pe=a.jsxs("div",{className:"relative min-h-0 flex-1 overflow-hidden bg-black",onPointerDown:z,onPointerUp:D,children:[Fe,ze,We]}),e[81]=D,e[82]=Fe,e[83]=ze,e[84]=We,e[85]=Pe):Pe=e[85];let qe;e[86]!==b||e[87]!==_||e[88]!==s||e[89]!==u?(qe=_&&a.jsx("footer",{className:"shrink-0 border-t border-border bg-background px-2 py-2",children:a.jsx("div",{className:"flex gap-1.5 overflow-x-auto overscroll-x-contain pb-0.5",children:s.map((Se,Ne)=>a.jsxs(ee,{type:"button",variant:"ghost",onClick:()=>b(Ne),"aria-label":`View image ${Ne+1}`,"aria-current":Ne===u?"true":void 0,className:G("relative size-12 shrink-0 overflow-hidden rounded-md border bg-background p-0.5 sm:h-14 sm:w-[4.5rem]",Ne===u?"border-foreground ring-1 ring-ring/40":"border-border opacity-55 hover:border-foreground/25 hover:opacity-90"),children:[a.jsx("img",{src:Se.src,alt:"",draggable:!1,className:"size-full rounded-[3px] object-cover"}),a.jsx("span",{className:"absolute bottom-0.5 right-0.5 rounded bg-popover px-1 font-mono text-xs text-foreground/80",children:Ne+1})]},`${Se.id}-${Ne}`))})}),e[86]=b,e[87]=_,e[88]=s,e[89]=u,e[90]=qe):qe=e[90];let be;e[91]!==M||e[92]!==fe||e[93]!==Pe||e[94]!==qe?(be=a.jsxs(fr,{showCloseButton:!1,onKeyDown:M,className:F,children:[B,V,fe,Pe,qe]}),e[91]=M,e[92]=fe,e[93]=Pe,e[94]=qe,e[95]=be):be=e[95];let Ie;return e[96]!==l||e[97]!==L||e[98]!==U||e[99]!==be?(Ie=a.jsx(dr,{open:l,onOpenChange:L,onOpenChangeComplete:U,children:be}),e[96]=l,e[97]=L,e[98]=U,e[99]=be,e[100]=Ie):Ie=e[100],Ie}const Fv={0:"\0",b:"\b",f:"\f",n:`
|
|
54
|
+
`,r:"\r",t:" ",v:"\v"};function kM(n){return!!(n&&/[A-Za-z_$]/.test(n))}function Xu(n){return!!(n&&/[\w$]/.test(n))}function ir(n,e){const t=n[e];if(t!=='"'&&t!=="'"&&t!=="`")return null;let s="",r=e+1;for(;r<n.length;){const o=n[r];if(o===t)return{endIndex:r+1,value:s};if(o!=="\\"){s+=o,r++;continue}if(r++,r>=n.length)return null;const i=n[r];if(i in Fv){s+=Fv[i],r++;continue}if(i===`
|
|
55
|
+
`){r++;continue}if(i==="\r"){r+=n[r+1]===`
|
|
56
|
+
`?2:1;continue}if(i==="x"&&/^[0-9a-fA-F]{2}$/.test(n.slice(r+1,r+3))){s+=String.fromCharCode(Number.parseInt(n.slice(r+1,r+3),16)),r+=3;continue}if(i==="u"){const l=n.slice(r+1).match(/^\{([0-9a-fA-F]+)\}/);if(l){const u=Number.parseInt(l[1],16);if(Number.isFinite(u)&&u<=1114111){s+=String.fromCodePoint(u),r+=l[0].length+1;continue}}const c=n.slice(r+1,r+5);if(/^[0-9a-fA-F]{4}$/.test(c)){s+=String.fromCharCode(Number.parseInt(c,16)),r+=5;continue}}s+=i,r++}return null}const Yr={"(":")","[":"]","{":"}"};function ox(n,e){if(n[e]!=="/")return null;if(n[e+1]==="/"){const t=n.indexOf(`
|
|
57
|
+
`,e+2);return t===-1?n.length:t+1}if(n[e+1]==="*"){const t=n.indexOf("*/",e+2);return t===-1?n.length:t+2}return null}function rc(n,e){const t=ir(n,e);if(t)return{endIndex:t.endIndex,isString:!0};const s=ox(n,e);return s===null?null:{endIndex:s,isString:!1}}function Gn(n,e){let t=e;for(;t<n.length;){if(/\s/.test(n[t])){t++;continue}const s=ox(n,t);if(s===null)break;t=s}return t}function nf(n,e){const t=n[e];if(!Yr[t])return null;const s=[Yr[t]];for(let r=e+1;r<n.length;r++){const o=rc(n,r);if(o){r=o.endIndex-1;continue}const i=n[r];if(Yr[i]){s.push(Yr[i]);continue}if(i===s.at(-1)&&(s.pop(),s.length===0))return r}return null}function M4(n,e){if(!kM(n[e]))return null;let t=e+1;for(;Xu(n[t]);)t++;return{value:n.slice(e,t),endIndex:t}}function jM(n,e,t){var d;const s=(d=t.trim().match(/^([A-Za-z_$][\w$]*)$/))==null?void 0:d[1];if(!s)return t;const r=n.slice(0,e),o=new RegExp(`\\b(?:const|let|var)\\s+${s.replace(/[$]/g,"\\$")}\\s*=`,"y");let i=null;for(let f=0;f<r.length;f++){const m=rc(r,f);if(m){f=m.endIndex-1;continue}o.lastIndex=f;const p=o.exec(r);p&&(i=p,f+=p[0].length-1)}if(!i||i.index===void 0)return t;const l=Gn(r,i.index+i[0].length),c=r[l];if(c==="{"||c==="["||c==="("){const f=nf(r,l);if(f!==null)return r.slice(l,f+1).trim()}const u=ir(r,l);return u?r.slice(l,u.endIndex).trim():t}function z4(n){const e=[];let t="";for(let s=0;s<n.length;s++){const r=rc(n,s);if(r){r.isString&&(t="literal"),s=r.endIndex-1;continue}const o=t===".";if(/\s/.test(n[s])||(t=n[s]),o||!n.startsWith("tools",s)||Xu(n[s-1])||Xu(n[s+5]))continue;let i=Gn(n,s+5),l="";if(n[i]==="."){i=Gn(n,i+1);const d=M4(n,i);if(!d)continue;l=d.value,i=d.endIndex}else if(n[i]==="["){i=Gn(n,i+1);const d=ir(n,i);if(!d||(i=Gn(n,d.endIndex),n[i]!=="]"))continue;l=d.value,i++}else continue;if(i=Gn(n,i),n[i]!=="(")continue;const c=nf(n,i);if(c===null){e.push({name:l,argumentSource:n.slice(i+1).trim(),startIndex:s});break}const u=n.slice(i+1,c).trim();e.push({name:l,argumentSource:jM(n,s,u),startIndex:s})}return e}function D4(n,e){return ir(n,e)??M4(n,e)}function NM(n,e,t){const s=[];for(let r=e;r<t;r++){const o=rc(n,r);if(o){r=o.endIndex-1;continue}const i=n[r];if(Yr[i]){s.push(Yr[i]);continue}if(s.length>0&&i===s.at(-1)){s.pop();continue}if(s.length===0&&i===",")return r}return t}function sf(n,e){let t=Gn(n,0);for(;n[t]==="(";)t=Gn(n,t+1);if(n[t]!=="{")return null;const s=nf(n,t);if(s===null)return null;let r=t+1;for(;r<s;){if(r=Gn(n,r),n[r]===","){r++;continue}const o=D4(n,r);if(!o){r++;continue}if(r=Gn(n,o.endIndex),n[r]!==":"){r++;continue}const i=Gn(n,r+1),l=NM(n,i,s);if(o.value===e)return n.slice(i,l).trim();r=l+1}return null}function F4(n,e,t){const s=[];for(let r=0;r<n.length;r++){const o=ox(n,r);if(o!==null){r=o-1;continue}const i=D4(n,r);if(i){if(i.value===e&&!Xu(n[r-1])){const l=Gn(n,i.endIndex);if(n[l]===":"){const c=t(Gn(n,l+1));c!==null&&s.push(c)}}r=i.endIndex-1}}return s}function ix(n,e){return F4(n,e,t=>{var s;return((s=ir(n,t))==null?void 0:s.value)??null})}function U4(n,e){return F4(n,e,t=>{const s=n.slice(t).match(/^-?[\d_]+(?:\.\d+)?/);if(!s)return null;const r=Number(s[0].replaceAll("_",""));return Number.isFinite(r)?r:null})}function B4(n){const e=Gn(n,0);if(!n.slice(e).trim())return 0;if(n[e]!=="[")return 1;const t=nf(n,e);if(t===null)return 1;let s=0,r=!1;const o=[];for(let i=e+1;i<t;i++){const l=rc(n,i);if(l){r||(r=l.isString),i=l.endIndex-1;continue}const c=n[i];Yr[c]?(r=!0,o.push(Yr[c])):o.length>0&&c===o.at(-1)?o.pop():o.length===0&&c===","?(r&&s++,r=!1):/\s/.test(c)||(r=!0)}return s+(r?1:0)}const CM=["cmd","command","workdir","description","timeout","yield_time_ms","max_output_tokens","session_id","chars","tty","login","shell","path","file_path","pattern","query","url","prompt","message","target","task_name","agent_id","agent_ids","model","agent_type","fork_turns","reasoning_effort","questions","plan","explanation","search_query","image_query","open","click","find","screenshot","finance","weather","sports","time","response_length","server","uri","cursor","name","code","old_string","new_string","content","replace_all","patch","input"];function Uv(n){try{return{value:JSON.parse(n)}}catch{}if(n.startsWith("`")&&n.includes("${"))return null;const e=ir(n,0);return e&&e.endIndex===n.length?{value:e.value}:null}function ax(n){return typeof n.input.raw=="string"&&/(?:^|__|[.:/])exec$/.test(n.name)}function W4(n){return typeof n.raw!="string"?[]:z4(n.raw).map(({name:e,argumentSource:t})=>{const s=t.trim(),r=Uv(s);if(r){const i=r.value;return i&&typeof i=="object"&&!Array.isArray(i)?{name:e,input:i}:{name:e,input:typeof i=="string"?{raw:i}:{value:i}}}const o={raw:t};for(const i of CM){const l=sf(s,i);if(l===null)continue;const c=Uv(l);c&&(o[i]=c.value)}return{name:e,input:o}})}function Vh(n){return n.type==="user"}function lx(n){return n.type==="assistant"}function Bv(n){return n.type==="progress"}function Wv(n){return n.type==="system"}function q4(n){return n.type==="summary"}function _M(n){return n.type==="queue-operation"}function V4(n){return n.type==="attachment"}function EM(n){return n.type==="user"&&n.isCompactSummary===!0}function H4(n){return n.type==="system"&&n.subtype==="compact_boundary"}function qv(n,e){let t=0;for(const s of n)e[s.name]=(e[s.name]??0)+1,s.isError&&t++;return t}function Vv(n,e){n.totalInputTokens+=e.input_tokens,n.totalOutputTokens+=e.output_tokens,n.totalCacheCreationTokens+=e.cache_creation_input_tokens??0,n.totalCacheReadTokens+=e.cache_read_input_tokens??0}function rf(n){return{totalInputTokens:0,totalOutputTokens:0,totalCacheCreationTokens:0,totalCacheReadTokens:0,toolCallCounts:{},errorCount:0,totalDurationMs:0,turnCount:n}}function of(n){const e=rf(n.length);for(const t of n){t.tokenUsage&&Vv(e,t.tokenUsage),t.durationMs&&(e.totalDurationMs+=t.durationMs),e.errorCount+=qv(t.toolCalls,e.toolCallCounts);for(const s of t.subAgentActivity)e.errorCount+=qv(s.toolCalls,e.toolCallCounts),s.tokenUsage&&Vv(e,s.tokenUsage)}return e}function Ni(n,e){var s,r;if(!n)return{...e};const t=(((s=n.output_tokens_details)==null?void 0:s.thinking_tokens)??0)+(((r=e.output_tokens_details)==null?void 0:r.thinking_tokens)??0);return{input_tokens:n.input_tokens+e.input_tokens,output_tokens:n.output_tokens+e.output_tokens,cache_creation_input_tokens:(n.cache_creation_input_tokens??0)+(e.cache_creation_input_tokens??0),cache_read_input_tokens:(n.cache_read_input_tokens??0)+(e.cache_read_input_tokens??0),speed:e.speed??n.speed,...n.output_tokens_details||e.output_tokens_details?{output_tokens_details:{thinking_tokens:t}}:{}}}const TM=/<(agent-message|teammate-message)([^>]*)>([\s\S]*?)<\/\1>/g,AM=[/\bteammate_id=(?:"([^"]*)"|'([^']*)')/,/\bfrom=(?:"([^"]*)"|'([^']*)')/];function PM(n){for(const e of AM){const t=n.match(e),s=(t==null?void 0:t[1])??(t==null?void 0:t[2]);if(s)return s}return null}function IM(n){return n.replace(/^\s*<(?:agent-message|teammate-message)\b[^>]*>/,"").replace(/<\/(?:agent-message|teammate-message)>\s*$/,"").trim()}function wl(n){let e=null,t=!1;const s=n.replace(TM,(r,o,i,l)=>(t=!0,e===null&&(e=PM(i)),l.trim()));return{sender:e,matched:t,body:t?s.trim():n}}const $M=[/\bblocking question\b/,/\bbefore i touch\b/,/\bshould i\b/,/\btell me one of\b/,/\byour call\b/,/\bwho owns\b/,/\bconfirm whether\b/],RM=[/(?:^|[,;:.!?—–-]\s*)tell me\b/,/(?:^|[,;:.!?—–-]\s*)say so\b/],OM=200,LM=/\bhttps?:\/\/\S+/g;function MM(n){const e=n.trim();if(!e)return!1;const t=e.slice(0,OM).toLowerCase();if($M.some(o=>o.test(t)))return!0;const r=e.slice(e.lastIndexOf(`
|
|
58
|
+
`)+1).slice(-200).replace(LM,"").toLowerCase();return r.includes("?")||RM.some(o=>o.test(r))}function Fc(n){return n&&typeof n=="object"?n:{}}function zM(n,e){const t=Fc(e);if(n==="Edit"||n==="Write")return t.staged===!0?{awaitingReview:!0}:{};if(n!=="Bash")return{};const s=Fc(t.bashEditDiff);if(!Array.isArray(s.files))return{};const r=[];for(const i of s.files){const l=Fc(i);if(typeof l.filePath!="string"||!l.filePath||!Array.isArray(l.hunks))continue;const c=[];for(const u of l.hunks){const d=Fc(u),{oldStart:f,oldLines:m,newStart:p,newLines:h,lines:g}=d;[f,m,p,h].every(x=>typeof x=="number"&&Number.isInteger(x)&&x>=0)&&(!Array.isArray(g)||!g.every(x=>typeof x=="string"&&/^[ +\\-]/.test(x))||c.push({oldStart:f,oldLines:m,newStart:p,newLines:h,lines:g}))}c.length&&r.push({filePath:l.filePath,hunks:c})}const o=typeof s.moreFiles=="number"&&Number.isInteger(s.moreFiles)&&s.moreFiles>0?s.moreFiles:0;return{fileDiffs:r,...o?{additionalFileDiffs:o}:{}}}function DM(n){return n.hunks.map(e=>[`@@ -${e.oldStart},${e.oldLines} +${e.newStart},${e.newLines} @@`,...e.lines].join(`
|
|
59
|
+
`)).join(`
|
|
60
|
+
`)}function FM(n){return n.map(e=>{let t="",s="";const r={add:0,del:0};for(const o of e.hunks){let i="";for(const l of o.lines){const c=l[0];if(l==="\")(i===" "||i==="-")&&(t=t.slice(0,-1)),(i===" "||i==="+")&&(s=s.slice(0,-1));else{const u=l.slice(1)+`
|
|
61
|
+
`;(c===" "||c==="-")&&(t+=u),(c===" "||c==="+")&&(s+=u),c==="+"&&r.add++,c==="-"&&r.del++}i=c}}return{filePath:e.filePath,oldString:t,newString:s,diffLineCounts:r}})}function af(n){return typeof n=="string"?n:n.filter(e=>e.type==="text").map(e=>e.text).join(`
|
|
62
|
+
`)}function Hv(n){return n?typeof n=="string"?n:n.map(e=>e.type==="text"?e.text:"").filter(Boolean).join(`
|
|
63
|
+
`):""}function K4(n){if(!(n!=null&&n.trim()))return!1;const e=n.trimStart();return e.startsWith("<")?!e.includes("<task-notification>")&&!e.startsWith("<system-reminder>")&&!e.startsWith("<local-command-"):!0}const UM=/<task-notification>[\s\S]*?<\/task-notification>/g,BM=/<[^>]*>/g;function WM(n){var t;if(((t=n.origin)==null?void 0:t.kind)==="task-notification")return!0;const e=af(n.message.content);return e.includes("<task-notification>")?e.replace(UM,"").replace(BM,"").trim()==="":!1}function qM(n){if(!V4(n))return null;const e=n.attachment;if(!e||e.type!=="queued_command"||e.commandMode!=="prompt")return null;const t=e.prompt;if(t==null)return null;const s=typeof t=="string"?t:af(t);if(!K4(s))return null;const r=e.origin;if((r==null?void 0:r.kind)==="peer"){const i=r.name??r.from??null;if(i)return{raw:s,sender:i,body:r.body??wl(s).body}}if((r==null?void 0:r.kind)==="human")return{raw:s,sender:null,body:s};const o=wl(s);return{raw:s,sender:o.sender,body:o.body}}const VM=[["attributionAgent","agent"],["attributionSkill","skill"],["attributionPlugin","plugin"],["attributionMcpServer","mcpServer"],["attributionMcpTool","mcpTool"]];function HM(n,e){let t=n;for(const[s,r]of VM){const o=e[s];typeof o!="string"||!o||(t={...t,[r]:o})}return t}const KM=/^This session is being continued from a previous conversation[\s\S]*?\n\nSummary:\s*\n/,GM=/\n+(?:If you need specific details from before compaction|(?:Please c|C)ontinue the conversation from where it left off)[\s\S]*$/;function ZM(n){return af(n).trim().replace(KM,"").replace(GM,"").trim()}function YM(n){if(n)return{trigger:n.trigger,preTokens:n.preTokens,postTokens:n.postTokens}}function Uc(n,e){return{id:n.uuid??crypto.randomUUID(),userMessage:e,contentBlocks:[],thinking:[],assistantText:[],toolCalls:[],subAgentActivity:[],timestamp:n.timestamp??"",durationMs:null,tokenUsage:null,model:null}}function XM(n){const e=[];let t=0;for(;t<n.length;){const s=n[t];if(s.kind==="tool_calls"){const r=s.toolCalls.findIndex(o=>o.name==="EnterPlanMode");if(r!==-1){const o=s.toolCalls[r],i=String(o.input.plan??""),l=s.timestamp,c=s.toolCalls.slice(0,r);c.length>0&&e.push({kind:"tool_calls",toolCalls:c,timestamp:s.timestamp});const u=[],d=s.toolCalls.slice(r+1),f=d.findIndex(m=>m.name==="ExitPlanMode");if(f!==-1){u.push(...d.slice(0,f));const m=d[f],p=m.input.path?String(m.input.path):void 0;let h="pending";m.result!==null&&(h=m.isError?"rejected":"approved"),e.push({kind:"plan_mode",plan:i,planFilePath:p,status:h,toolCalls:u,timestamp:l});const g=d.slice(f+1);g.length>0&&e.push({kind:"tool_calls",toolCalls:g,timestamp:s.timestamp}),t++;continue}else{u.push(...d);let m,p,h="pending",g=t+1;const x=[];for(;g<n.length;){const b=n[g];if(b.kind==="tool_calls"){const y=b.toolCalls.findIndex(v=>v.name==="ExitPlanMode");if(y!==-1){u.push(...b.toolCalls.slice(0,y)),m=b.toolCalls[y],p=m.input.path?String(m.input.path):void 0,m.result!==null&&(h=m.isError?"rejected":"approved");const v=b.toolCalls.slice(y+1);e.push({kind:"plan_mode",plan:i,planFilePath:p,status:h,toolCalls:u,timestamp:l}),e.push(...x),v.length>0&&e.push({kind:"tool_calls",toolCalls:v,timestamp:b.timestamp}),t=g+1;break}else u.push(...b.toolCalls),g++}else if(b.kind==="hook_event"||b.kind==="text"||b.kind==="queued_prompt"||b.kind==="agent_message")x.push(b),g++;else break}m||(e.push({kind:"plan_mode",plan:i,planFilePath:void 0,status:"pending",toolCalls:u,timestamp:l}),e.push(...x),t=g);continue}}}e.push(s),t++}return e}function JM(n){return n.contentBlocks.some(e=>e.kind==="agent_message")?{...n,contentBlocks:n.contentBlocks.map(e=>{if(e.kind!=="agent_message")return e;const{reply:t,...s}=e;return s})}:n}function cx(n){var s;const e=n.map(JM),t=new Map;for(const r of e)for(const o of r.contentBlocks){if(o.kind==="agent_message"){const i=t.get(o.sender);i?i.push(o):t.set(o.sender,[o]);continue}if(o.kind==="tool_calls")for(const i of o.toolCalls){if(i.name!=="SendMessage")continue;const l=i.input.to;if(typeof l!="string"||!l)continue;const c=(s=t.get(l))==null?void 0:s.shift();if(!c)continue;const u=i.input.summary;c.reply={summary:typeof u=="string"?u:"",timestamp:i.timestamp||o.timestamp||""}}}return e}function QM(n){const e=[];let t=!1;for(let s=0;s<n.length;s++){const r=n[s];if(q4(r)||H4(r)){t=!1;continue}if(Vh(r)&&!r.isMeta){const o=r.message.content;if(t&&Array.isArray(o)&&o.some(l=>l.type==="tool_result"))continue;e.push(s),t=!0;continue}lx(r)&&!t&&(e.push(s),t=!0)}return e}function G4(n){var _,N;const e=[],t=[];let s=null,r=0,o=null,i=null;function l(S){i&&(S.compactionSummary=i.summary,S.compactionMeta=i.meta,i=null)}let c=null;const u=new Map,d=new Set,f=new Map,m=new Map,p=new Set,h=new Map,g=[],x=new Map;function b(S,C){let E=x.get(S);E||(E=new Map,x.set(S,E)),E.set(C,(E.get(C)??0)+1)}function y(S,C){const E=x.get(S),T=E==null?void 0:E.get(C);return!E||!T?!1:(T===1?E.delete(C):E.set(C,T-1),!0)}function v(){for(const S of g)S.turn.contentBlocks.push(S.sender?{kind:"agent_message",sender:S.sender,body:S.body,timestamp:S.timestamp}:{kind:"queued_prompt",content:S.content,timestamp:S.timestamp});g.length=0}function k(S){if(!o)return;const C=f.get(S);if(!C||C.length===0)return;o.subAgentActivity.push(...C),f.delete(S);const E=p.has(S)?"background_agent":"sub_agent",T=m.get(S);if(T)T.messages.push(...C);else{const A={kind:E,messages:[...C]};o.contentBlocks.push(A),m.set(S,A)}}function j(){if(o){for(const S of o.toolCalls)k(S.id);for(const[S]of f)k(S);for(const S of o.contentBlocks)if(S.kind==="hook_event")for(const C of S.events){if(!(C.eventName==="PostToolUse"||C.eventName.startsWith("PostToolUse:"))||!C.toolUseId)continue;const T=o.toolCalls.find(A=>A.id===C.toolUseId);T&&(C.updatedToolOutput&&(T.outputReplacedByHook=!0),C.durationMs!==void 0&&(T.hookDurationMs=(T.hookDurationMs??0)+C.durationMs))}o.contentBlocks=XM(o.contentBlocks),e.push(o),s!==null&&t.push(s),s=null,o=null,m.clear()}}for(r=0;r<n.length;r++){const S=n[r];if(q4(S)){j(),i={summary:S.summary};continue}if(H4(S)){j(),i={meta:YM(S.compactMetadata)};continue}if(EM(S)){j(),s=r,o=Uc(S,null),o.compactionSummary=ZM(S.message.content),o.compactionMeta=i==null?void 0:i.meta,i=null;continue}if(Wv(S)&&S.subtype==="away_summary"&&S.content){c={content:S.content,timestamp:S.timestamp};continue}if(_M(S)){if(o&&S.operation==="enqueue"&&K4(S.content)){const C=wl(S.content);g.push({turn:o,content:S.content,timestamp:S.timestamp,sender:C.sender,body:C.body}),b(o,S.content)}continue}if(V4(S)){const C=qM(S);o&&C!==null&&!y(o,C.raw)&&g.push({turn:o,content:C.raw,timestamp:((_=S.attachment)==null?void 0:_.timestamp)??S.timestamp,sender:C.sender,body:C.body});continue}if(g.length>0){const C=Vh(S)&&!S.isMeta?S.message.content:null;if(typeof C=="string"){const E=g.findIndex(T=>T.content===C);if(E>=0){const[T]=g.splice(E,1);y(T.turn,T.content)}}v()}if(Vh(S)&&!S.isMeta){const C=S.message.content;if(typeof C!="string"&&Array.isArray(C)&&C.some(T=>T.type==="tool_result")&&o){for(const A of C)if(A.type==="tool_result"){const P=u.get(A.tool_use_id);if(P){P.turn.toolCalls[P.index].result=Hv(A.content),P.turn.toolCalls[P.index].isError=A.is_error===!0;const I=P.turn.toolCalls[P.index];Object.assign(I,zM(I.name,S.toolUseResult)),u.delete(A.tool_use_id)}}const T=S.toolUseResult;if(T!=null&&T.agentId){const A=((N=C.find(R=>R.type==="tool_result"))==null?void 0:N.tool_use_id)??"",P=h.get(A),I=p.has(A),$=[];if(Array.isArray(T.content))for(const R of T.content)R.type==="text"&&$.push(R.text);const O={agentId:T.agentId,parentToolUseId:A||void 0,agentName:(P==null?void 0:P.name)??null,subagentType:(P==null?void 0:P.subagentType)??null,type:"assistant",content:T.content,toolCalls:[],thinking:[],text:$,timestamp:S.timestamp??"",tokenUsage:T.usage?{input_tokens:T.usage.input_tokens??0,output_tokens:T.usage.output_tokens??0,cache_creation_input_tokens:T.usage.cache_creation_input_tokens??0,cache_read_input_tokens:T.usage.cache_read_input_tokens??0}:null,model:null,isBackground:I,prompt:T.prompt,status:T.status,durationMs:T.totalDurationMs,toolUseCount:T.totalToolUseCount};if(!m.get(A)){o.subAgentActivity.push(O);const z={kind:I?"background_agent":"sub_agent",messages:[O]};o.contentBlocks.push(z),m.set(A,z)}}continue}if(WM(S)){const E={kind:"task_notification",content:af(C),timestamp:S.timestamp};if(o){o.contentBlocks.push(E);continue}s=r,o=Uc(S,null),o.contentBlocks.push(E),l(o);continue}j(),s=r,o=Uc(S,S.message.content),l(o),c&&(o.contentBlocks.push({kind:"recap",content:c.content,timestamp:c.timestamp}),c=null);continue}if(lx(S)){let C=function(){I.length>0&&($.contentBlocks.push({kind:"tool_calls",toolCalls:[...I],timestamp:A}),I.length=0)},E=function(){if(P.length>0){const O=$.contentBlocks[$.contentBlocks.length-1];O&&O.kind==="thinking"?O.blocks.push(...P):$.contentBlocks.push({kind:"thinking",blocks:[...P],timestamp:A}),P.length=0}};o||(s=r,o=Uc(S,null),l(o)),o.model=S.message.model,S.effort&&(o.effort=S.effort),o.attribution=HM(o.attribution,S);const T=S.message.id;d.has(T)||(d.add(T),o.tokenUsage=Ni(o.tokenUsage,S.message.usage));const A=S.timestamp??"",P=[],I=[],$=o;for(const O of S.message.content)if(O.type==="thinking"){C();const M=O;if(!M.thinking)continue;o.thinking.push(M),P.push(M)}else if(O.type==="text"){C(),E();const M=/<thinking>([\s\S]*?)<\/thinking>/g;let R=O.text,z;for(;(z=M.exec(O.text))!==null;){const W=z[1].trim();if(W){const D={type:"thinking",thinking:W,signature:""};o.thinking.push(D),o.contentBlocks.push({kind:"thinking",blocks:[D],timestamp:A})}R=R.replace(z[0],"")}if(R=R.trim(),R){o.assistantText.push(R);const W=o.contentBlocks[o.contentBlocks.length-1];W&&W.kind==="text"?W.text.push(R):o.contentBlocks.push({kind:"text",text:[R],timestamp:A})}}else if(O.type==="tool_use"){E();const M={id:O.id,name:O.name,input:O.input,result:null,isError:!1,timestamp:S.timestamp??""},R=o.toolCalls.length;if(o.toolCalls.push(M),I.push(M),u.set(O.id,{turn:o,index:R}),O.name==="Task"||O.name==="Agent"){const z=O.input;z.run_in_background===!0&&p.add(O.id),h.set(O.id,{name:z.name??null,subagentType:z.subagent_type??null})}}E(),C();continue}if(Bv(S)&&S.data.type==="agent_progress"){const C=S.data,E=S.parentToolUseID??"";let T=null;if(C.message.type==="assistant"){const O=C.message.message,M=O.id,R=O.usage;R&&M&&!d.has(M)&&(d.add(M),T={input_tokens:R.input_tokens??0,output_tokens:R.output_tokens??0,cache_creation_input_tokens:R.cache_creation_input_tokens??0,cache_read_input_tokens:R.cache_read_input_tokens??0})}const A=C.message.type==="assistant"?C.message.message.model??null:null,P=h.get(E),I={agentId:C.agentId,parentToolUseId:E||void 0,agentName:(P==null?void 0:P.name)??null,subagentType:(P==null?void 0:P.subagentType)??null,type:C.message.type,content:C.message.message.content,toolCalls:[],thinking:[],text:[],timestamp:C.message.timestamp??S.timestamp??"",tokenUsage:T,model:A,isBackground:p.has(E)};if(C.message.type==="assistant"){const O=C.message.message.content;if(Array.isArray(O))for(const M of O)M.type==="thinking"?I.thinking.push(M.thinking):M.type==="text"?I.text.push(M.text):M.type==="tool_use"&&I.toolCalls.push({id:M.id,name:M.name,input:M.input,result:null,isError:!1,timestamp:C.message.timestamp??S.timestamp??""})}else if(C.message.type==="user"){const O=C.message.message.content;if(Array.isArray(O)){for(const M of O)if(M.type==="tool_result"){const R=f.get(E);if(R)for(const z of R){const W=z.toolCalls.find(D=>D.id===M.tool_use_id);W&&(W.result=Hv(M.content),W.isError=M.is_error===!0)}}}}let $=f.get(E);$||($=[],f.set(E,$)),$.push(I),o&&k(E);continue}if(Bv(S)&&S.data.type==="hook_progress"){const C=S.data,E=String(C.hook_event_name??C.hookEvent??"unknown"),T=C.hookSpecificOutput,A={eventName:E,source:C.source!==void 0?String(C.source):void 0,toolName:C.tool_name!==void 0?String(C.tool_name):void 0,toolUseId:C.tool_use_id!==void 0?String(C.tool_use_id):void 0,command:C.command!==void 0?String(C.command):void 0,output:C.output!==void 0?String(C.output):void 0,stderr:C.stderr!==void 0?String(C.stderr):void 0,exitCode:C.exit_code!==void 0?Number(C.exit_code):void 0,decision:C.decision!==void 0?String(C.decision):void 0,durationMs:C.duration_ms!==void 0?Number(C.duration_ms):void 0,updatedToolOutput:(T==null?void 0:T.updatedToolOutput)!==void 0?String(T.updatedToolOutput):void 0,sessionTitle:(T==null?void 0:T.sessionTitle)!==void 0?String(T.sessionTitle):void 0,worktreePath:(T==null?void 0:T.worktreePath)!==void 0?String(T.worktreePath):void 0,timestamp:S.timestamp??""};if(o){const P=o.contentBlocks[o.contentBlocks.length-1];P&&P.kind==="hook_event"?P.events.push(A):o.contentBlocks.push({kind:"hook_event",events:[A],timestamp:S.timestamp})}continue}if(Wv(S)&&S.subtype==="turn_duration"&&o){S.durationMs!==void 0&&S.durationMs!==null&&(o.durationMs=(o.durationMs??0)+S.durationMs);continue}}return v(),j(),{turns:cx(e),turnStartIndices:t}}function Z4(n){return G4(n).turns}function Kv(){return!0}function Y4(n){const e=[];for(const t of n){const s=t.trim();if(s)try{e.push(JSON.parse(s))}catch{}}return e}function X4(n){return Y4(n.split(`
|
|
64
|
+
`))}function J4(n){const e={sessionId:"",version:"",gitBranch:"",cwd:"",slug:"",name:"",model:"",branchedFrom:void 0};for(const t of n)if(t.sessionId&&!e.sessionId&&(e.sessionId=t.sessionId),t.version&&!e.version&&(e.version=t.version),t.gitBranch&&!e.gitBranch&&(e.gitBranch=t.gitBranch),t.cwd&&!e.cwd&&(e.cwd=t.cwd),t.slug&&!e.slug&&(e.slug=t.slug),t.name&&!e.name&&(e.name=t.name),t.branchedFrom&&!e.branchedFrom&&(e.branchedFrom=t.branchedFrom),lx(t)&&t.message.model&&!e.model&&(e.model=t.message.model),e.sessionId&&e.version&&e.gitBranch&&e.cwd&&e.model)break;return e}function ez(n){return J4(Y4(n))}function tz(n,e){const t=X4(n),s=J4(t),r=Z4(t),o=e!=null&&e.skipStats?rf(r.length):of(r);return{...s,turns:r,stats:o,rawMessages:e!=null&&e.skipStats?[]:t,agentKind:"claude"}}function nz(n,e){const t=X4(e);if(t.length===0)return n;const s=n.rawMessages,r=[...s,...t],o=QM(s),i=Math.max(0,n.turns.length-o.length);let l=Math.max(0,o.length-1);const c=new Set;for(const h of t)if(h.type==="progress"){const g=h.parentToolUseID;g&&c.add(g)}if(c.size>0)for(let h=l-1;h>=0;h--){const g=n.turns[i+h];if(g!=null&&g.toolCalls.some(x=>c.has(x.id))){l=h;break}}const u=o[l]??s.length,d=n.turns.slice(0,i+l),f=Z4(r.slice(u)),m=cx([...d,...f]),p=of(m);return{sessionId:n.sessionId,version:n.version,gitBranch:n.gitBranch,cwd:n.cwd,slug:n.slug,name:n.name,model:n.model||m.length>0&&m[m.length-1].model||"",turns:m,stats:p,rawMessages:r,branchedFrom:n.branchedFrom,agentKind:n.agentKind}}const Q4="<task-notification>",sz=/<task-id>([^<]+)<\/task-id>/g,rz=/<tool-use-id>([^<]+)<\/tool-use-id>/g;function Ks(n){return typeof n=="object"&&n!==null}function oz(n){const e=Ks(n.message)?n.message:null,t=e==null?void 0:e.content;return typeof t=="string"?[t]:Array.isArray(t)?t.filter(s=>Ks(s)&&typeof s.text=="string").map(s=>s.text):[]}function iz(n){const e=[],t=new Set,s=new Set,r=new Set;function o(i,l){if(i.includes(Q4)){for(const c of i.matchAll(sz))t.add(c[1]),l==null||l.add(c[1]);for(const c of i.matchAll(rz))t.add(c[1]),l==null||l.add(c[1])}}for(const i of n){if(i.type==="user"){const l=Ks(i.toolUseResult)?i.toolUseResult:null;if((l==null?void 0:l.status)==="async_launched"){const c=Ks(i.message)?i.message:null,d=(Array.isArray(c==null?void 0:c.content)?c.content:[]).filter(p=>Ks(p)&&p.type==="tool_result").map(p=>p.tool_use_id),f=[l.agentId,l.taskId,...d].filter(p=>typeof p=="string"&&p.length>0),m=[l.description,l.workflowName,l.summary].find(p=>typeof p=="string"&&p.length>0)??"";f.length>0&&e.push({ids:f,description:m})}for(const c of oz(i))o(c,r);continue}if(i.type==="assistant"){const l=Ks(i.message)?i.message:null,c=Array.isArray(l==null?void 0:l.content)?l.content:[];for(const u of c){if(!Ks(u)||u.type!=="tool_use"||u.name!=="TaskStop")continue;const d=Ks(u.input)?u.input:null,f=(d==null?void 0:d.task_id)??(d==null?void 0:d.shell_id);typeof f=="string"&&t.add(f)}continue}if(i.type==="attachment"){const l=Ks(i.attachment)?i.attachment:null;typeof(l==null?void 0:l.prompt)=="string"&&o(l.prompt,r);continue}if(i.type==="queue-operation"&&typeof i.content=="string"){const l=i.operation;o(i.content,l==="enqueue"?s:r)}}return{pendingDescriptions:e.filter(i=>!i.ids.some(l=>t.has(l))).map(i=>i.description),undeliveredNotifications:[...s].filter(i=>!r.has(i)).length}}function az(n,e){return{status:"awaiting_agents",pendingQueue:e,pendingAgents:n.length,pendingAgentDescriptions:n.filter(t=>t.length>0)}}function lz(n){var i,l;let e=0,t=null,s=!1;function r(c,u){const d={status:c,pendingQueue:Math.max(0,e)};return u&&(d.toolName=u),d}function o(){return t??(t=iz(n))}for(let c=n.length-1;c>=0;c--){const u=n[c];if(u.type!=="queue-operation"){if(u.type==="progress"){const d=u.data;if((d==null?void 0:d.type)==="hook_progress"&&(d.decision??((i=d.hookSpecificOutput)==null?void 0:i.permissionDecision))==="defer")return r("deferred");break}break}}for(let c=n.length-1;c>=0;c--){const u=n[c];if(u.type==="queue-operation"){if(typeof u.content=="string"&&u.content.includes(Q4))continue;const d=u.operation;d==="enqueue"?e++:(d==="dequeue"||d==="remove")&&e--;continue}if(u.type==="attachment"){const d=Ks(u.attachment)?u.attachment:null;(d==null?void 0:d.commandMode)==="task-notification"&&(s=!0);continue}if(u.type==="assistant"){const d=u.message,f=d==null?void 0:d.stop_reason;if(f==="end_turn"){const m=o();if(s||m.undeliveredNotifications>0)return r("processing");if(m.pendingDescriptions.length>0)return az(m.pendingDescriptions,Math.max(0,e));let p=!1;for(let h=c-1;h>=0;h--){const g=n[h];if(g.type==="user"&&!g.isMeta){p=!0;break}}return r(p?"completed":"idle")}if(f==="tool_use"){const m=d==null?void 0:d.content,p=(l=m==null?void 0:m.findLast)==null?void 0:l.call(m,h=>h.type==="tool_use");return r("tool_use",p==null?void 0:p.name)}return r("thinking")}if(u.type==="user"){if(u.isMeta)continue;return r("processing")}if(u.type==="system"&&u.subtype==="terminal_reason"){const d=u.reason;if(d)return{status:"completed",terminalReason:d,pendingQueue:Math.max(0,e)};continue}u.type!=="summary"&&u.type==="system"&&u.subtype}return{status:"idle"}}function cz(n,e,t){const s=typeof n.sessionId=="string"?n.sessionId:"";return{record:{...n,sessionId:e,branchedFrom:{sessionId:s,turnIndex:t}},originalId:s}}function uz(n){return G4(n).turnStartIndices}function eN(n,e,t){if(!e)return;n.assistantText.push(e);const s=n.contentBlocks[n.contentBlocks.length-1];if((s==null?void 0:s.kind)==="text"){s.text.push(e);return}n.contentBlocks.push({kind:"text",text:[e],timestamp:t})}function Gv(n){return n.includes("*** Begin Patch")&&n.includes("*** End Patch")}function dz(n){if(!n.includes("apply_patch")||!n.includes("*** Begin Patch"))return[];const e=new Map;for(let i=0;i<n.length;i++){const l=ir(n,i);if(l){if(Gv(l.value)){const c=n.slice(0,i).match(/(?:^|[;\n])\s*(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*$/);c&&e.set(c[1],l.value)}i=l.endIndex-1}}const t=[],s=new Set,r=/\btools\s*\.\s*apply_patch\s*\(/g;let o;for(;(o=r.exec(n))!==null;){let i=o.index+o[0].length;for(;/\s/.test(n[i]??"");)i++;const l=ir(n,i),c=l?null:n.slice(i).match(/^([A-Za-z_$][\w$]*)/),u=(l==null?void 0:l.value)??(c?e.get(c[1]):void 0);!u||!Gv(u)||s.has(u)||(s.add(u),t.push(u))}return t}function Zv(n,e){if(!e||n.startsWith("/")||/^[A-Za-z]:[\\/]/.test(n))return n;const t=e.replace(/[\\/]+$/,""),s=n.replace(/^\.[\\/]/,"");return/^[A-Za-z]:[\\/]/.test(e)?`${t}\\${s.replace(/\//g,"\\")}`:`${t}/${s}`}function Yv(n,e,t,s=""){var c,u;const r=[],o=/^\*\*\*\s+(Update File|Add File|Delete File):\s*(.+)$/gm,i=[];let l;for(;(l=o.exec(n))!==null;)i.push({action:l[1],filePath:l[2].trim(),headerIdx:l.index,startIdx:l.index+l[0].length});for(let d=0;d<i.length;d++){const f=i[d],m=d+1<i.length?i[d+1].headerIdx:n.length,p=n.slice(f.startIdx,m),h=(u=(c=p.match(/^\*\*\*\s+Move to:\s*(.+)$/m))==null?void 0:c[1])==null?void 0:u.trim(),g=Zv(f.filePath,s),x=Zv(h||f.filePath,s),b=p.split(/^@@.*$/m).filter(j=>j.trim()),y=[],v=[];for(const j of b)for(const _ of j.split(`
|
|
65
|
+
`))_.startsWith("-")?y.push(_.slice(1)):_.startsWith("+")?v.push(_.slice(1)):_.startsWith(" ")&&(y.push(_.slice(1)),v.push(_.slice(1)));const k=i.length>1?`${e}:file-${d}`:e;f.action==="Add File"?r.push({id:k,name:"Write",input:{file_path:x,content:v.join(`
|
|
66
|
+
`)},result:null,isError:!1,timestamp:t}):f.action==="Delete File"?r.push({id:k,name:"Edit",input:{file_path:x,old_string:y.join(`
|
|
67
|
+
`),new_string:""},result:null,isError:!1,timestamp:t}):r.push({id:k,name:"Edit",input:{file_path:x,...h?{old_path:g}:{},old_string:y.join(`
|
|
68
|
+
`),new_string:v.join(`
|
|
69
|
+
`)},result:null,isError:!1,timestamp:t})}return r}function tN(n,e,t,s,r=""){return n==="apply_patch"?Yv(e,t,s,r):dz(e).flatMap((o,i)=>Yv(o,`${t}:patch-${i}`,s,r))}function fz(n,e,t){var l;if(!e||!/(?:apply[_ ]patch|invalid patch|invalid context|failed to (?:apply|find)|could not apply)/i.test(n))return new Set;const s=new Map;for(const c of t){const u=(l=c.id.match(/:patch-(\d+)(?::file-\d+)?$/))==null?void 0:l[1];if(u===void 0)continue;const d=Number(u),f=s.get(d)??[];f.push(c),s.set(d,f)}if(s.size===0)return new Set(t.map(c=>c.id));const r=n.toLowerCase().replaceAll("\\","/"),o=new Set;for(const[c,u]of s)u.some(d=>{const f=String(d.input.file_path??"").toLowerCase().replaceAll("\\","/");if(!f)return!1;const p=f.split("/").filter(Boolean).slice(-2).join("/");return r.includes(f)||p.includes("/")&&r.includes(p)})&&o.add(c);for(const c of r.matchAll(/\bpatch\s*(?:#|-)?\s*(\d+)\b/g)){const u=Number(c[1]);s.has(u)&&o.add(u)}o.size===0&&o.add(Math.max(...s.keys()));const i=Math.min(...o);for(const c of s.keys())c>=i&&o.add(c);return new Set([...o].flatMap(c=>{var u;return((u=s.get(c))==null?void 0:u.map(d=>d.id))??[]}))}function er(n){return typeof n=="object"&&n!==null}const mz=new Map([["spawn_agent","spawn_agent"],["spawnAgent","spawn_agent"],["wait_agent","wait_agent"],["waitAgent","wait_agent"],["send_message","send_message"],["sendMessage","send_message"],["followup_task","followup_task"],["followupTask","followup_task"],["list_agents","list_agents"],["listAgents","list_agents"],["interrupt_agent","interrupt_agent"],["interruptAgent","interrupt_agent"]]),pz=new Set(["exec","exec_command","write_stdin","apply_patch","update_plan","view_image","request_user_input","request_user_input_async","tool_search","list_mcp_resources","list_mcp_resource_templates","read_mcp_resource","request_plugin_install","create_goal","get_goal","update_goal","wait"]);function Ls(n){if(n.startsWith("mcp__"))return n;const e=n.split(/(?:__|[.:/])+/).filter(Boolean).at(-1)??n;return mz.get(e)??(pz.has(e)?e:n)}function hz(n){const e=n==null?void 0:n.match(/Process exited with code (\d+)/);return e?e[1]!=="0":!1}function gz(n){return n==="request_user_input"||n==="request_user_input_async"}function xz(n){const t=(Array.isArray(n.questions)?n.questions:[n]).filter(s=>er(s)).map(s=>{const r=typeof s.question=="string"?s.question:typeof s.title=="string"?s.title:"",o=Array.isArray(s.options)?s.options:[];return{question:r,...typeof s.header=="string"&&s.header?{header:s.header}:{},options:o.map(i=>typeof i=="string"?{label:i}:!er(i)||typeof i.label!="string"?null:{label:i.label,...typeof i.description=="string"&&i.description?{description:i.description}:{}}).filter(i=>i!==null)}}).filter(s=>s.question);return t.length>0?{...n,questions:t}:n}function bz(n){return{todos:(Array.isArray(n.plan)?n.plan:[]).filter(s=>er(s)).map(s=>({content:typeof s.step=="string"?s.step:"",status:typeof s.status=="string"?s.status:"pending",activeForm:typeof s.step=="string"?s.step:""}))}}function vz(n){if(n.type!=="image"&&n.type!=="input_image"&&n.type!=="image_url")return null;const e=er(n.source)?n.source:n,t=e.media_type??e.mimeType;if(typeof t=="string"&&t.startsWith("image/")&&typeof e.data=="string"&&e.data)return{type:"image",source:{type:"base64",media_type:t,data:e.data}};const s=er(n.image_url)?n.image_url.url:n.image_url,r=typeof s=="string"?/^data:(image\/[^;,]+);base64,(.+)$/is.exec(s):null;return r?{type:"image",source:{type:"base64",media_type:r[1].toLowerCase(),data:r[2]}}:null}function Xv(n){if(typeof n=="string")return{parts:[n],text:n,images:[]};if(!Array.isArray(n)){const s=n==null?"":JSON.stringify(n);return{parts:[s],text:s,images:[]}}const e=[],t=[];for(const s of n){if(!er(s))continue;typeof s.text=="string"&&e.push(s.text);const r=vz(s);r&&t.push(r)}return{parts:e,text:e.join(""),images:t}}const yz=/^Script (?:completed|failed|running)\b/;function nN(n,e){er(n)&&(n.status==="rejected"?e.push(1):n.status==="fulfilled"?nN(n.value,e):typeof n.exit_code=="number"&&e.push(n.exit_code))}function wz(n){const e=n[0]??"";if(!yz.test(e))return;if(e.startsWith("Script failed"))return!0;const t=[];for(const s of n.slice(1)){let r;try{r=JSON.parse(s)}catch{continue}for(const o of Array.isArray(r)?r:[r])nN(o,t)}return t.length>0?t.some(s=>s!==0):void 0}function Hh(n){const e=Xv(n);let t=er(n)&&!Array.isArray(n)?n:null;try{const u=t??JSON.parse(e.text);er(u)&&!Array.isArray(u)&&(t=u)}catch{}const s=t&&("output"in t||"content"in t)?Xv(t.output??t.content):e,r=s===e?e.images:[...e.images,...s.images],o=er(t==null?void 0:t.metadata)?t.metadata:null,i=(o==null?void 0:o.exit_code)??(t==null?void 0:t.exit_code),l=typeof(t==null?void 0:t.isError)=="boolean"?t.isError:typeof(t==null?void 0:t.is_error)=="boolean"?t.is_error:void 0,c=l===!0||(typeof i=="number"?i!==0:l??wz(e.parts)??hz(s.text));return{text:s.text,isError:c,...r.length>0?{images:r}:{}}}const Sz=["# AGENTS.md instructions for ","<recommended_plugins>","<environment_context>","<permissions instructions>","<collaboration_mode>","<skills_instructions>"];function kz(n){var e,t;return((t=(e=globalThis.crypto)==null?void 0:e.randomUUID)==null?void 0:t.call(e))??`${n}-${Math.random().toString(36).slice(2,10)}`}function ux(n){try{return JSON.parse(n)}catch{return null}}function dt(n){return typeof n=="object"&&n!==null}function jz(n){const e=dt(n.source)?n.source:null,t=e&&dt(e.subagent)?e.subagent:null,s=t&&dt(t.thread_spawn)?t.thread_spawn:null;for(const r of[n.forked_from_id,n.parent_thread_id,s==null?void 0:s.parent_thread_id])if(typeof r=="string"&&r)return r;return null}function Li(n){return!n||typeof n.type!="string"?!1:n.type==="session_meta"||n.type==="turn_context"||n.type==="event_msg"||n.type==="response_item"||n.type==="inter_agent_communication_metadata"||n.type==="compacted"||n.type==="world_state"}function Ju(n,e){const t=n==null?void 0:n.content;return Array.isArray(t)?t.filter(s=>dt(s)&&s.type===e&&typeof s.text=="string").map(s=>s.text).join(`
|
|
70
|
+
`).trim():""}const Nz=/^data:(image\/(?:png|jpeg|gif|webp));base64,(.+)$/is,Cz=/^data:(audio\/(?:wav|x-wav|mpeg|mp4|webm|ogg));base64,(.+)$/is;function sN(n){if(typeof n!="string")return null;const e=Nz.exec(n);return!(e!=null&&e[1])||!e[2]?null:{type:"image",source:{type:"base64",media_type:e[1].toLowerCase(),data:e[2]}}}function rN(n){if(typeof n!="string")return null;const e=Cz.exec(n);return!(e!=null&&e[1])||!e[2]?null:{type:"audio",source:{type:"base64",media_type:e[1].toLowerCase(),data:e[2]}}}function _z(n){return Array.isArray(n.images)?n.images.map(sN).filter(e=>e!==null):[]}function Ez(n){return Array.isArray(n.audio)?n.audio.map(rN).filter(e=>e!==null):[]}function oN(n){return Array.isArray(n.content)?n.content.filter(e=>dt(e)&&e.type==="input_image").map(e=>sN(e.image_url)).filter(e=>e!==null):[]}function iN(n){return Array.isArray(n.content)?n.content.filter(e=>dt(e)&&e.type==="input_audio").map(e=>rN(e.audio_url)).filter(e=>e!==null):[]}function Jv(n,e,t=[],s=[],r=[]){const o=[...s.map(l=>`
|
|
71
|
+
`),...r.map(l=>`
|
|
72
|
+
[audio attachment](<${l}>)`)].join(""),i=n+o;return e.length===0&&t.length===0?i:[...e,...t,...i?[{type:"text",text:i}]:[]]}function Tz(n){var i,l;const e=Ju(n,"input_text");if(!e)return{messageType:null,text:""};const t=e.match(/\r?\nPayload:\s*(?:\r?\n|$)/);if(!e.startsWith("Message Type:")||!t||t.index===void 0)return{messageType:null,text:e.trim()};const r=((l=(i=e.slice(0,t.index).match(/^Message Type:\s*([^\r\n]+)/))==null?void 0:i[1])==null?void 0:l.trim().toUpperCase())??null,o=e.slice(t.index+t[0].length).trim();return{messageType:r,text:o}}function va(n){return n.split(/[\\/]/).filter(Boolean).at(-1)??null}function Az(n){if(typeof n!="string")return"";const e=n.trim();return/^gAAAAA[A-Za-z0-9_-]+$/.test(e)?"":e}function Kh(n){const e=n.trim();return!e||Sz.some(t=>e.startsWith(t))?"":e}function Pz(n){if(!dt(n))return null;const e=typeof n.input_tokens=="number"?n.input_tokens:0,t=typeof n.output_tokens=="number"?n.output_tokens:0,s=typeof n.cache_write_input_tokens=="number"?n.cache_write_input_tokens:typeof n.cache_creation_input_tokens=="number"?n.cache_creation_input_tokens:0,r=typeof n.cached_input_tokens=="number"?Math.max(0,n.cached_input_tokens):null,o=r??(typeof n.cache_read_input_tokens=="number"?n.cache_read_input_tokens:0),i=r===null?e:Math.max(0,e-r);return i===0&&t===0&&s===0&&o===0?null:{input_tokens:i,output_tokens:t,cache_creation_input_tokens:s,cache_read_input_tokens:o}}function Iz(n,e,t){if(!e)return;const s={type:"thinking",thinking:e,signature:""};n.thinking.push(s);const r=n.contentBlocks[n.contentBlocks.length-1];if(r&&r.kind==="thinking"){r.blocks.push(s);return}n.contentBlocks.push({kind:"thinking",blocks:[s],timestamp:t})}function ei(n,e,t){n.toolCalls.push(e);const s=n.contentBlocks[n.contentBlocks.length-1];if(s&&s.kind==="tool_calls"&&s.timestamp===t){s.toolCalls.push(e);return}n.contentBlocks.push({kind:"tool_calls",toolCalls:[e],timestamp:t})}function $z(n,e,t){if(!e||!(e.userMessage!==null||e.assistantText.length>0||e.toolCalls.length>0||e.thinking.length>0||e.subAgentActivity.length>0))return null;if(e.timestamp&&t){const r=new Date(e.timestamp).getTime(),o=new Date(t).getTime();Number.isFinite(r)&&Number.isFinite(o)&&o>=r&&(e.durationMs=o-r)}return n.push(e),null}function Qv(n){if(typeof n!="string"||!n.trim())return{};try{const e=JSON.parse(n);return dt(e)?e:{value:e}}catch{return{raw:n}}}function ya(n){if(typeof n=="string")return n;try{return JSON.stringify(n)}catch{return String(n??"")}}function ey(...n){return n.find(e=>typeof e=="string")}function Rz(n){return n.startsWith("exec-")}function Oz(n){var r;if(!dt(n))return{text:ya(n),isError:!1};if("Err"in n)return{text:ya(n.Err),isError:!0};const e=dt(n.Ok)?n.Ok:null;if(!e)return{text:ya(n),isError:!1};const t=Hh({...e,content:e.content}),s=t.text||((r=t.images)!=null&&r.length?"":e.structuredContent!==void 0?ya(e.structuredContent):ya(e));return{...t,text:s,isError:t.isError}}function Lz(n,e,t){return{id:n?`${n}@${e}`:kz("codex-turn"),userMessage:null,contentBlocks:[],thinking:[],assistantText:[],toolCalls:[],subAgentActivity:[],timestamp:e,durationMs:null,tokenUsage:null,model:t}}function aN(n){return n.type==="event_msg"&&dt(n.payload)&&n.payload.type==="user_message"&&typeof n.payload.message=="string"?Kh(n.payload.message):n.type==="response_item"&&dt(n.payload)&&n.payload.type==="message"&&n.payload.role==="user"?Kh(Ju(n.payload,"input_text")):""}function Mz(n,e){if(n.type==="session_meta"||n.type==="event_msg"&&(e==null?void 0:e.type)==="task_started")return!1;if(n.type==="response_item"&&(e==null?void 0:e.type)==="message"){if(e.role==="developer"||e.role==="system")return!1;if(e.role==="user")return aN(n)!==""||oN(e).length>0||iN(e).length>0}return!0}function lN(n){let e="",t="",s="",r="",o="",i,l="",c="",u="",d="",f=0,m=!1,p=null,h="/root",g="";for(const x of n){if(!dt(x.payload))continue;if(x.type==="session_meta"){if(e||(e=typeof x.payload.id=="string"?x.payload.id:""),t||(t=typeof x.payload.cli_version=="string"?x.payload.cli_version:""),r||(r=typeof x.payload.cwd=="string"?x.payload.cwd:""),!i&&dt(x.payload.branchedFrom)){const k=typeof x.payload.branchedFrom.sessionId=="string"?x.payload.branchedFrom.sessionId:"";k&&(i={sessionId:k,turnIndex:typeof x.payload.branchedFrom.turnIndex=="number"?x.payload.branchedFrom.turnIndex:null})}const y=dt(x.payload.source)?x.payload.source:null;if(y&&dt(y.subagent)){m=!0;const k=dt(y.subagent.thread_spawn)?y.subagent.thread_spawn:null;k&&typeof k.agent_path=="string"&&(h=k.agent_path)}p=jz(x.payload)??p;const v=dt(x.payload.git)?x.payload.git:null;s||(s=v&&typeof v.branch=="string"?v.branch:"")}x.type==="turn_context"&&(o||(o=typeof x.payload.model=="string"?x.payload.model:""),r||(r=typeof x.payload.cwd=="string"?x.payload.cwd:""));const b=aN(x);b&&b!==g&&(l||(l=b),c=b,g=b,f++,u||(u=x.timestamp??""),d=x.timestamp??d)}return d===""&&(d=u),{sessionId:e,version:t,gitBranch:s,cwd:r,model:o,slug:"",name:"",branchedFrom:i,firstUserMessage:l,lastUserMessage:c,timestamp:u,lastTimestamp:d,turnCount:f,isSubagent:m,parentSessionId:p,agentPath:h}}function cN(n){for(const e of n.split(`
|
|
73
|
+
`)){const t=e.trim();if(t)return Li(ux(t))}return!1}function zz(n){return Li(n[0]??null)}function Dz(n){const e=n.map(ux).filter(Li);return lN(e)}function uN(n,e){const t=lN(n.filter(Li)),s=[],r=new Map,o=new Map,i=new Map,l=new Map,c=new Map,u=new Map,d=new Map,f=new Map;function m(E,T,A,P={}){const I=c.get(E);let $=f.get(E);if(!$){const M={agentId:E,parentToolUseId:(I==null?void 0:I.parentToolCallId)||void 0,agentName:(I==null?void 0:I.nickname)??(I!=null&&I.agentPath?va(I.agentPath):null),subagentType:(I==null?void 0:I.agentType)??null,type:"assistant",content:null,toolCalls:[],thinking:[],text:[],timestamp:(I==null?void 0:I.timestamp)??A,tokenUsage:null,model:(I==null?void 0:I.model)??null,isBackground:!1,prompt:(I==null?void 0:I.message)||void 0,status:P.status??"running"};T.subAgentActivity.push(M);const R=T.contentBlocks[T.contentBlocks.length-1];(R==null?void 0:R.kind)==="sub_agent"?R.messages.push(M):T.contentBlocks.push({kind:"sub_agent",messages:[M],timestamp:A}),$={message:M,turn:T},f.set(E,$)}const O=$.message;if(I&&(O.parentToolUseId=I.parentToolCallId||O.parentToolUseId,O.agentName=I.nickname??(I.agentPath?va(I.agentPath):O.agentName),O.subagentType=I.agentType,O.model=I.model,O.prompt=I.message||O.prompt),P.text&&!O.text.includes(P.text)&&(O.text.push(P.text),O.content=O.text.join(`
|
|
74
|
+
|
|
75
|
+
`)),P.status){const M=new Set(["completed","failed","interrupted"]);if(P.status==="running"&&O.status&&M.has(O.status)||(O.status=P.status),M.has(P.status)&&O.timestamp&&A){const R=new Date(O.timestamp).getTime(),z=new Date(A).getTime();Number.isFinite(R)&&Number.isFinite(z)&&z>=R&&(O.durationMs=z-R)}}return O}let p=null,h=null,g=t.model||null,x="",b=null,y=!1;const v=[];let k=0,j=null,_=null;function N(E){const T=s.length,A=$z(s,E,x);return s.length>T&&_!==null&&v.push(_),_=null,A}function S(E,T,A){const P=Lz(E,T,A);return _=j??k,j=null,y||(P.isFragment=!0),b&&(P.compactionSummary=b,b=null),P}function C(E,T,A,P,I){const $=o.get(T);if($){$.input={...$.input,...A},$.result=P,$.isError=P==="failed";return}const O={id:T,name:"WebSearch",input:A,result:P,isError:P==="failed",timestamp:I};o.set(T,O),ei(E,O,I)}for(let E=0;E<n.length;E++){const T=n[E];if(!Li(T))continue;k=E;const A=dt(T.payload)?T.payload:void 0,P=T.timestamp??"";if(T.type==="compacted"){p=N(p),b="Conversation compacted",x=P;continue}if(T.type!=="world_state"){if(T.type==="turn_context"){p=N(p),j=E,h=typeof(A==null?void 0:A.turn_id)=="string"?A.turn_id:null,g=typeof(A==null?void 0:A.model)=="string"?A.model:g,x=P,y=!0;continue}if(T.type==="event_msg"&&(A==null?void 0:A.type)==="user_message"&&typeof A.message=="string"){p&&(p.assistantText.length>0||p.toolCalls.length>0||p.thinking.length>0)&&(p=N(p)),y=!0,p??(p=S(h,P,g));const I=(Array.isArray(A.local_images)?A.local_images:[]).filter(O=>typeof O=="string"&&O.length>0),$=(Array.isArray(A.local_audio)?A.local_audio:[]).filter(O=>typeof O=="string"&&O.length>0);p.userMessage=Jv(A.message,_z(A),Ez(A),I,$),p.isFragment=!1,p.timestamp=p.timestamp||P,x=P;continue}if(!(!p&&!Mz(T,A))){if(p??(p=S(h,P,g)),!p.model&&g&&(p.model=g),p.timestamp||(p.timestamp=P),P&&(x=P),T.type==="event_msg"&&(A==null?void 0:A.type)==="token_count"){const I=dt(A.info)?A.info:null,$=I?Pz(I.last_token_usage):null;$&&(p.tokenUsage=Ni(p.tokenUsage,$));continue}if(T.type==="event_msg"&&(A==null?void 0:A.type)==="web_search_end"&&typeof A.call_id=="string"){const I={};typeof A.query=="string"&&A.query&&(I.query=A.query),dt(A.action)&&(I.action=A.action),C(p,A.call_id,I,"completed",P);continue}if(T.type==="event_msg"&&(A==null?void 0:A.type)==="mcp_tool_call_end"&&typeof A.call_id=="string"&&dt(A.invocation)){const I=A.invocation,$=typeof I.server=="string"?I.server:"mcp",O=typeof I.tool=="string"?I.tool:"tool",M=dt(I.arguments)?I.arguments:{},R=Oz(A.result),z=r.get(A.call_id);z?(z.result=R.text,z.isError=R.isError,R.images&&(z.resultImages=R.images),r.delete(A.call_id)):Rz(A.call_id)||ei(p,{id:A.call_id,name:`mcp__${$}__${O}`,input:M,result:R.text,isError:R.isError,...R.images?{resultImages:R.images}:{},timestamp:P},P);continue}if(T.type==="event_msg"&&(A==null?void 0:A.type)==="sub_agent_activity"&&typeof A.agent_thread_id=="string"&&typeof A.agent_path=="string"){const I=A.agent_thread_id,$=typeof A.event_id=="string"?A.event_id:"",O=typeof A.kind=="string"?A.kind:"started",M=$?l.get($):void 0,R=u.get(A.agent_path),z=c.get(I)??(R?c.get(R):void 0);if(O!=="started"&&!z&&!M)continue;if(R&&R!==I&&!f.has(I)){const L=f.get(R);L&&(L.message.agentId=I,f.delete(R),f.set(I,L)),c.delete(R)}const W={agentId:I,nickname:(z==null?void 0:z.nickname)??va(A.agent_path)??(M==null?void 0:M.taskName)??null,agentPath:A.agent_path,message:(z==null?void 0:z.message)??(M==null?void 0:M.message)??"",model:(z==null?void 0:z.model)??(M==null?void 0:M.model)??null,agentType:(z==null?void 0:z.agentType)??(M==null?void 0:M.agentType)??null,timestamp:(z==null?void 0:z.timestamp)??(P||(M==null?void 0:M.timestamp)||""),parentToolCallId:(z==null?void 0:z.parentToolCallId)??$};c.set(I,W),u.set(A.agent_path,I),$&&(O==="started"||M)&&d.set($,I),m(I,p,P,{status:O==="interrupted"?"interrupted":"running"});continue}if(!(T.type!=="response_item"||!A)){if(A.type==="reasoning"){const I=Array.isArray(A.summary)?A.summary.filter($=>typeof $=="string").join(`
|
|
76
|
+
`):"";Iz(p,I.trim(),P);continue}if(A.type==="message"&&A.role==="assistant"){eN(p,Ju(A,"output_text"),P);continue}if(A.type==="message"&&A.role==="user"&&p.userMessage===null){const I=Kh(Ju(A,"input_text")),$=oN(A),O=iN(A);(I||$.length>0||O.length>0)&&(p.userMessage=Jv(I,$,O),p.isFragment=!1,y=!0);continue}if(A.type==="web_search_call"&&typeof A.id=="string"){const I={};dt(A.action)&&(I.action=A.action);const $=typeof A.status=="string"?A.status:"completed";C(p,A.id,I,$,P);continue}if(A.type==="tool_search_call"){const I=ey(A.call_id,A.id)??"";if(I){const $={id:I,name:"ToolSearch",input:dt(A.arguments)?A.arguments:{},result:null,isError:!1,timestamp:P};r.set(I,$),ei(p,$,P)}continue}if(A.type==="tool_search_output"&&typeof A.call_id=="string"){const I=r.get(A.call_id);if(I){const $=Array.isArray(A.tools)?A.tools:[],O=$.filter(dt).map(z=>ey(z.name)??"").filter(Boolean),M=O.length>0?O.length:$.length,R=`Found ${M} tool${M===1?"":"s"}`;I.result=O.length>0?`${R}: ${O.join(", ")}`:R,I.isError=A.status==="failed",r.delete(A.call_id)}continue}if(A.type==="agent_message"&&typeof A.author=="string"){const I=A.author,$=typeof A.recipient=="string"?A.recipient:null,O=Tz(A);if(O.messageType==="NEW_TASK")continue;const M=u.get(I),R=I.startsWith(`${t.agentPath}/`)&&($===null||$===t.agentPath);if(!M&&!R)continue;const z=M??I;M||(c.set(z,{agentId:z,nickname:va(I),agentPath:I,message:"",model:null,agentType:null,timestamp:P,parentToolCallId:""}),u.set(I,z));let W;O.messageType==="FINAL_ANSWER"?W="completed":O.messageType==="ERROR"||O.messageType==="FAILED"?W="failed":O.messageType==="INTERRUPTED"?W="interrupted":O.messageType==="MESSAGE"&&(W="running"),m(z,p,P,{status:W,text:O.text||void 0});continue}if(A.type==="function_call"&&typeof A.call_id=="string"){const I=typeof A.name=="string"?A.name:"tool",$=Ls(I),O=Qv(A.arguments);let M=$,R=O;$==="exec_command"?M="Bash":$==="update_plan"?(M="TodoWrite",R=bz(O)):gz($)&&(M="AskUserQuestion",R=xz(O)),$==="spawn_agent"&&l.set(A.call_id,{callId:A.call_id,message:Az(O.message),taskName:typeof O.task_name=="string"?O.task_name:null,model:typeof O.model=="string"?O.model:null,agentType:typeof O.agent_type=="string"?O.agent_type:null,timestamp:P});const z={id:A.call_id,name:M,input:R,result:null,isError:!1,timestamp:P,...$==="request_user_input_async"?{asyncQuestion:!0}:{}};r.set(z.id,z),ei(p,z,P);continue}if(A.type==="function_call_output"&&typeof A.call_id=="string"){const I=r.get(A.call_id);if(!I)continue;const $=Hh(A.output),O=$.text;if(I.result=O,I.isError=$.isError,$.images&&(I.resultImages=$.images),r.delete(A.call_id),I.name==="spawn_agent"&&O)try{const M=JSON.parse(O),R=typeof M.agent_id=="string"?M.agent_id:d.get(I.id)??"",z=typeof M.task_name=="string"?M.task_name:null,W=typeof M.nickname=="string"?M.nickname:z?va(z):null;if(R){const D=l.get(I.id),L=c.get(R),U={agentId:R,nickname:W??(L==null?void 0:L.nickname)??(D==null?void 0:D.taskName)??null,agentPath:z??(L==null?void 0:L.agentPath)??null,message:(L==null?void 0:L.message)??(D==null?void 0:D.message)??"",model:(L==null?void 0:L.model)??(D==null?void 0:D.model)??null,agentType:(L==null?void 0:L.agentType)??(D==null?void 0:D.agentType)??null,timestamp:(L==null?void 0:L.timestamp)??(D==null?void 0:D.timestamp)??P,parentToolCallId:(L==null?void 0:L.parentToolCallId)??I.id};c.set(R,U),d.set(I.id,R),U.agentPath&&u.set(U.agentPath,R),m(R,p,P,{status:"running"})}}catch{}if(I.name==="wait_agent"&&O&&p)try{const M=JSON.parse(O),R=dt(M.status)?M.status:{};for(const[z,W]of Object.entries(R)){const D=dt(W)?W:{},L=typeof D.completed=="string"?D.completed:"",U=typeof D.failed=="string"?D.failed:typeof D.error=="string"?D.error:"",F=typeof D.interrupted=="string"?D.interrupted:"",B=L?"completed":U?"failed":F?"interrupted":typeof D.status=="string"?D.status:"running";c.has(z)||c.set(z,{agentId:z,nickname:null,agentPath:null,message:"",model:null,agentType:null,timestamp:P,parentToolCallId:""}),m(z,p,P,{status:B,text:L||U||F||void 0})}}catch{}continue}if(A.type==="custom_tool_call"&&typeof A.call_id=="string"){const I=Ls(typeof A.name=="string"?A.name:"tool"),$=typeof A.input=="string"?A.input:"",O=A.call_id,M=$?tN(I,$,O,P,t.cwd):[];if(I!=="apply_patch"){const R={id:O,name:I==="exec_command"?"Bash":I,input:Qv($),result:null,isError:!1,timestamp:P};r.set(R.id,R),ei(p,R,P)}for(const R of M)r.set(R.id,R),ei(p,R,P);M.length>0&&i.set(O,{calls:M,direct:I==="apply_patch"});continue}if(A.type==="custom_tool_call_output"&&typeof A.call_id=="string"){const I=A.call_id,{text:$,isError:O,images:M}=Hh(A.output),R=i.get(I);if(R){const W=R.direct&&O?new Set(R.calls.map(D=>D.id)):fz($,O,R.calls);for(const D of R.calls){const L=r.get(D.id);L&&(L.result=$,L.isError=W.has(L.id),r.delete(L.id))}i.delete(I)}const z=r.get(I);z&&(z.result=$,z.isError=O,M&&(z.resultImages=M),r.delete(I));continue}}}}}return N(p),{turnStartIndices:v,sessionId:t.sessionId,version:t.version,gitBranch:t.gitBranch,cwd:t.cwd,slug:t.slug,name:"",model:t.model,turns:s,stats:e!=null&&e.skipStats?rf(s.length):of(s),rawMessages:e!=null&&e.skipStats?[]:n,branchedFrom:t.branchedFrom,agentKind:"codex"}}function dx(n,e){const t=n.split(`
|
|
77
|
+
`).map(o=>o.trim()).filter(Boolean).map(ux).filter(Li),{turnStartIndices:s,...r}=uN(t,e);return r}function Fz(n,e){const t=n.rawMessages.map(s=>JSON.stringify(s)).join(`
|
|
78
|
+
`);return dx(t?`${t}
|
|
79
|
+
${e}`:e)}const Uz=new Set(["FINAL_ANSWER","ERROR","FAILED","INTERRUPTED"]);function Bz(n){const e=n.content;return Array.isArray(e)?e.filter(t=>dt(t)&&t.type==="input_text"&&typeof t.text=="string").map(t=>t.text).join(`
|
|
80
|
+
`):""}function Bc(n){if(typeof n!="string")return null;try{const e=JSON.parse(n);return dt(e)?e:null}catch{return null}}function Wz(n){var c,u;const e=new Map,t=new Set,s=new Map,r=new Map,o=new Set,i=new Map;function l(d,f){t.has(d)||e.set(d,e.get(d)||f)}for(const d of n){const f=dt(d.payload)?d.payload:null;if(f){if(d.type==="event_msg"&&f.type==="sub_agent_activity"&&typeof f.agent_thread_id=="string"&&typeof f.agent_path=="string"){const m=f.agent_thread_id,p=typeof f.kind=="string"?f.kind:"started",h=typeof f.event_id=="string"?f.event_id:"",g=s.get(f.agent_path),x=e.has(m)||t.has(m)||g!==void 0||r.has(h);if(p!=="started"&&!x)continue;g&&g!==m&&(e.has(g)&&(l(m,e.get(g)??""),e.delete(g)),t.has(g)&&t.add(m)),s.set(f.agent_path,m),p==="interrupted"?(t.add(m),e.delete(m)):l(m,r.get(h)??"");continue}if(d.type==="response_item"){if(f.type==="function_call"&&typeof f.call_id=="string"){const m=Ls(typeof f.name=="string"?f.name:"");if(m==="spawn_agent"){const p=Bc(f.arguments);r.set(f.call_id,typeof(p==null?void 0:p.task_name)=="string"?p.task_name:"")}else if(m==="wait_agent")o.add(f.call_id);else if(m==="interrupt_agent"){const p=Bc(f.arguments),h=[p==null?void 0:p.agent_id,...Array.isArray(p==null?void 0:p.agent_ids)?p.agent_ids:[]].filter(g=>typeof g=="string");i.set(f.call_id,h)}continue}if(f.type==="function_call_output"&&typeof f.call_id=="string"){const m=f.call_id;if(r.has(m)){const p=Bc(f.output),h=typeof(p==null?void 0:p.agent_id)=="string"?p.agent_id:"";if(h){l(h,r.get(m)??"");const g=typeof(p==null?void 0:p.task_name)=="string"?p.task_name:"";g&&!s.has(g)&&s.set(g,h)}}else if(o.has(m)){const p=Bc(f.output),h=dt(p==null?void 0:p.status)?p.status:{};for(const[g,x]of Object.entries(h)){const b=dt(x)?x:{},y=typeof b.status=="string"?b.status:"";(typeof b.completed=="string"||typeof b.failed=="string"||typeof b.error=="string"||typeof b.interrupted=="string"||y==="completed"||y==="failed"||y==="interrupted")&&(t.add(g),e.delete(g))}}else if(i.has(m))for(const p of i.get(m)??[])t.add(p),e.delete(p);continue}if(f.type==="agent_message"&&typeof f.author=="string"){const p=((u=(c=Bz(f).match(/^Message Type:\s*([^\r\n]+)/))==null?void 0:c[1])==null?void 0:u.trim().toUpperCase())??"";if(!Uz.has(p))continue;const h=s.get(f.author)??f.author;t.add(h),e.delete(h)}}}}return[...e.entries()].filter(([d])=>!t.has(d)).map(([,d])=>d)}function qz(n){for(let e=n.length-1;e>=0;e--){const t=n[e];if(t.type==="event_msg"){const s=t.payload;switch(s==null?void 0:s.type){case"task_complete":{const r=Wz(n);return r.length>0?{status:"awaiting_agents",pendingQueue:0,pendingAgents:r.length,pendingAgentDescriptions:r.filter(o=>o.length>0)}:{status:"completed"}}case"task_started":return{status:"processing"};case"agent_message":return{status:"thinking"};case"token_count":continue}}if(t.type==="response_item"){const s=t.payload;if(!s)continue;if(s.type==="function_call")return{status:"tool_use",toolName:s.name?Ls(s.name):s.name};if(s.type==="message"){if(s.role==="assistant")return{status:"thinking"};if(s.role==="user")return{status:"processing"}}}}return{status:"idle"}}function Vz(n,e,t,s){const r=dt(n.payload)?{...n.payload}:{},o=typeof r.id=="string"?r.id:"";return r.id=e,r.branchedFrom={sessionId:o,turnIndex:t,at:new Date(s).toISOString()},{record:{...n,payload:r},originalId:o}}function Hz(n){return uN(n,{skipStats:!0}).turnStartIndices}const Kz=/^(?:assistant|auto_mode|auto_mode_switch|background_tasks|canvas|command|custom|elicitation|exit_plan_mode|extensions|external_tool|factory|hook|managed_settings|mcp|model|pending_messages|permission|sampling|session|skill|subagent|system|tool|ui|user_input)\./;function rn(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function dN(n){return typeof n.agentId!="string"||n.agentId.length===0}function fN(n){return!rn(n)||typeof n.type!="string"||!rn(n.data)?!1:n.type==="abort"||n.type==="binary_asset"||n.type==="user.message"||Kz.test(n.type)}function mN(n){try{const e=JSON.parse(n);return fN(e)?e:null}catch{return null}}function Gz(n){return n.split(`
|
|
81
|
+
`).map(e=>e.trim()).filter(Boolean).map(mN).filter(e=>e!==null)}function $e(...n){return n.find(e=>typeof e=="string")??""}function kr(n){return typeof n=="number"&&Number.isFinite(n)?n:0}function Aa(n){return typeof n.timestamp=="string"?n.timestamp:""}function qr(n,e){var t,s;return typeof n.id=="string"&&n.id?n.id:((s=(t=globalThis.crypto)==null?void 0:t.randomUUID)==null?void 0:s.call(t))??`${e}-${Math.random().toString(36).slice(2,10)}`}function ty(n){const e=qr(n,"copilot-turn"),t=$e(n.data.turnId);return t?`${t}@${e}`:e}function hm(n,e){if(!rn(n))return;const t=$e(n.cwd),s=$e(n.branch);t&&(e.cwd=t),s&&(e.gitBranch=s)}function pN(n){const e={sessionId:"",version:"",gitBranch:"",cwd:"",model:"",slug:"",name:"",firstUserMessage:"",lastUserMessage:"",timestamp:"",lastTimestamp:"",turnCount:0,isSubagent:!1,parentSessionId:null};for(const t of n){if(!dN(t))continue;const{data:s}=t,r=Aa(t);if(r&&(e.lastTimestamp=r),t.type==="session.start"){e.sessionId||(e.sessionId=$e(s.sessionId)),e.version||(e.version=$e(s.copilotVersion)||(typeof s.version=="number"?String(s.version):$e(s.version))),hm(s.context,e),e.model=$e(s.selectedModel)||e.model;continue}if(t.type==="session.resume"){hm(s.context,e),e.model=$e(s.selectedModel)||e.model;continue}if(t.type==="session.context_changed"){hm(s,e);continue}if(t.type==="session.auto_mode_resolved"){e.model=$e(s.chosenModel)||e.model;continue}if(t.type==="session.model_change"){e.model=$e(s.newModel)||e.model;continue}if(t.type==="session.title_changed"){e.name=$e(s.title)||e.name;continue}if(t.type==="session.shutdown"){e.model=$e(s.currentModel)||e.model;continue}if((t.type==="assistant.turn_start"||t.type==="assistant.turn_end"||t.type==="assistant.message"||t.type==="assistant.usage"||t.type==="tool.execution_start"||t.type==="tool.execution_complete")&&(e.model=$e(s.model)||e.model),t.type!=="user.message")continue;e.turnCount++,e.timestamp||(e.timestamp=r);const o=$e(s.content).trim();o&&(e.firstUserMessage||(e.firstUserMessage=o),e.lastUserMessage=o)}return e.lastTimestamp||(e.lastTimestamp=e.timestamp),e}function Zz(n){for(const e of n.split(`
|
|
82
|
+
`)){const t=e.trim();if(t)try{const s=JSON.parse(t);if(fN(s))return!0}catch{}}return!1}function Yz(n){var e;return uD((e=n[0])==null?void 0:e.type)}function Xz(n){const e=n.map(t=>mN(t.trim())).filter(t=>t!==null);return pN(e)}function gm(n){if(typeof n=="string")return n;if(n===void 0)return"";try{return JSON.stringify(n)}catch{return String(n)}}function ny(n){return typeof n=="string"?n:Array.isArray(n)?n.flatMap(e=>{const t=typeof e=="string"?e:rn(e)?$e(e.text,e.content):"";return t?[t]:[]}).join(`
|
|
83
|
+
`):""}function Jz(n){const e=new Map;for(const t of n){if(t.type!=="session.binary_asset"&&t.type!=="binary_asset")continue;const s=$e(t.data.assetId),r=$e(t.data.data),o=$e(t.data.mimeType);s&&r&&o&&e.set(s,{data:r,mimeType:o})}return e}function Qz(n,e){if(!rn(n))return null;const t=e.get($e(n.assetId)),s=$e(n.mimeType,t==null?void 0:t.mimeType).toLowerCase(),r=$e(n.data,t==null?void 0:t.data);return!s.startsWith("image/")||!r?null:{type:"image",source:{type:"base64",media_type:s,data:r}}}function hN(n,e){if(!Array.isArray(n))return[];const t=[],s=new Set;for(const r of n){const o=Qz(r,e);if(!o)continue;const i=`${o.source.media_type}:${o.source.data}`;s.has(i)||(s.add(i),t.push(o))}return t}function eD(n,e){const t=$e(n.content),s=hN(n.attachments,e);return s.length===0?t:[...s,...t?[{type:"text",text:t}]:[]]}function tD(n,e){return rn(n.result)?hN([...Array.isArray(n.result.contents)?n.result.contents:[],...Array.isArray(n.result.binaryResultsForLlm)?n.result.binaryResultsForLlm:[]],e):[]}function Gh(n,e=!1){const t=kr(n.cacheWriteTokens),s=kr(n.cacheReadTokens),r=kr(n.inputTokens),o={input_tokens:e?Math.max(0,r-t-s):r,output_tokens:kr(n.outputTokens),cache_creation_input_tokens:t,cache_read_input_tokens:s},i=kr(n.reasoningTokens);return i&&(o.output_tokens_details={thinking_tokens:i}),o.input_tokens===0&&o.output_tokens===0&&o.cache_creation_input_tokens===0&&o.cache_read_input_tokens===0&&i===0?null:o}function nD(n){if(!rn(n.modelMetrics))return null;let e=null;for(const t of Object.values(n.modelMetrics)){if(!rn(t)||!rn(t.usage))continue;const s=Gh(t.usage,!0);s&&(e=Ni(e,s))}return e}function sD(n){if(typeof n=="string")return{label:n};if(!rn(n))return null;const e=$e(n.label,n.title,n.value,n.name);if(!e)return null;const t=$e(n.description);return t?{label:e,description:t}:{label:e}}function rD(n){return Array.isArray(n)?n.map(sD).filter(e=>e!==null):[]}function oD(n){if(!rn(n))return null;const e=$e(n.question,n.prompt,n.text,n.message);if(!e)return null;const t=$e(n.header,n.title),s=typeof n.multiSelect=="boolean"?n.multiSelect:typeof n.multi_select=="boolean"?n.multi_select:void 0;return{question:e,...t?{header:t}:{},options:rD(n.options??n.choices),...s===void 0?{}:{multiSelect:s}}}function iD(n){const t=(Array.isArray(n.questions)?n.questions:[n]).map(oD).filter(s=>s!==null);return t.length>0?{...n,questions:t}:n}function Pa(n){switch(n.toLowerCase().replace(/-/g,"_")){case"ask_user":return"AskUserQuestion";case"bash":case"powershell":case"shell":return"Bash";case"create":return"Write";case"edit":return"Edit";default:return n}}function Qu(n,e){const t=rn(e)?e:e===void 0?{}:{value:e};return n==="AskUserQuestion"?iD(t):n==="Edit"?{...t,file_path:$e(t.file_path,t.path),old_string:$e(t.old_string,t.old_str),new_string:$e(t.new_string,t.new_str)}:n==="Write"?{...t,file_path:$e(t.file_path,t.path),content:$e(t.content,t.file_text)}:n==="Bash"&&typeof t.command!="string"&&typeof t.cmd=="string"?{...t,command:t.cmd}:t}function aD(n){const e=n.error;if(typeof e=="string")return e;if(rn(e)){const s=$e(e.message,e.code);if(s)return s}const t=n.result;if(typeof t=="string")return t;if(!rn(t))return t===void 0?"":gm(t);if(typeof t.detailedContent=="string")return t.detailedContent;if(typeof t.content=="string")return t.content;if(Array.isArray(t.contents)){const s=t.contents.flatMap(r=>{const o=typeof r=="string"?r:rn(r)?$e(r.text,r.content,r.output):"";return o?[o]:[]}).join(`
|
|
84
|
+
`);if(s)return s}return t.structuredContent!==void 0?gm(t.structuredContent):gm(t)}function sy(n,e,t,s){if(!e||n.thinking.some(i=>i.thinking===e))return;const r={type:"thinking",thinking:e,signature:s};n.thinking.push(r);const o=n.contentBlocks[n.contentBlocks.length-1];if((o==null?void 0:o.kind)==="thinking"){o.blocks.push(r);return}n.contentBlocks.push({kind:"thinking",blocks:[r],timestamp:t})}function Wc(n,e,t){n.toolCalls.push(e);const s=n.contentBlocks[n.contentBlocks.length-1];if((s==null?void 0:s.kind)==="tool_calls"){s.toolCalls.push(e);return}n.contentBlocks.push({kind:"tool_calls",toolCalls:[e],timestamp:t})}function Ia(n,e,t,s){return{id:n,name:e,input:t,result:null,isError:!1,timestamp:s}}function ry(n,e,t){if(!Array.isArray(n))return[];const s=[];for(const r of n){if(!rn(r))continue;const o=$e(r.toolCallId),i=$e(r.name);if(!o||!i||t(o))continue;const l=Pa(i);s.push(Ia(o,l,Qu(l,r.arguments),e))}return s}function oy(n,e,t,s){n.name=e,n.input=Qu(e,t),n.timestamp=s||n.timestamp}function iy(n,e,t){n.result=aD(e);const s=tD(e,t);s.length>0&&(n.resultImages=s),n.isError=e.success===!1||e.error!==void 0&&e.error!==null}function ay(n,e,t,s,r,o){return{id:n,userMessage:t,contentBlocks:[],thinking:[],assistantText:[],toolCalls:[],subAgentActivity:[],timestamp:e,durationMs:null,tokenUsage:null,model:s,...r?{effort:r}:{},...o?{isFragment:!0}:{}}}function lD(n){return n.userMessage!==null||n.assistantText.length>0||n.thinking.length>0||n.toolCalls.length>0||n.subAgentActivity.length>0}function gN(n,e){const t=Gz(n),s=pN(t),r=Jz(t),o=[],i=new Map,l=new Map,c=new Map,u=new WeakMap,d=new WeakMap;let f=null,m=null,p,h=!1,g=!1,x=null;function b(N,S){S&&u.set(N,S)}function y(N){return f||(f=ay(ty(N),Aa(N),null,m,p,!0)),f}function v(){f&&(lD(f)&&o.push(f),f=null)}function k(N){var $;const S=typeof N.agentId=="string"?N.agentId:"";if(!S)return null;const C=l.get(S);if(C)return C.message;const E=N.data,T=$e(E.toolCallId),A=T?(($=i.get(T))==null?void 0:$.turn)??f:f;if(!A)return null;const P=$e(E.executionMode),I={agentId:S,...T?{parentToolUseId:T}:{},agentName:$e(E.agentDisplayName,E.agentName)||null,subagentType:$e(E.agentType,E.agentName)||null,type:"assistant",content:null,toolCalls:[],thinking:[],text:[],timestamp:Aa(N),tokenUsage:null,model:$e(E.model)||null,isBackground:P==="background",...$e(E.description)?{prompt:$e(E.description)}:{},status:"running"};return A.subAgentActivity.push(I),A.contentBlocks.push({kind:I.isBackground?"background_agent":"sub_agent",messages:[I],timestamp:I.timestamp}),l.set(S,{message:I,turn:A}),I}function j(N){if(dN(N))return!1;const S=k(N);if(!S)return!0;const{data:C}=N,E=Aa(N);if(N.type==="subagent.started"||N.type==="subagent.configured")return S.parentToolUseId||(S.parentToolUseId=$e(C.toolCallId)||void 0),S.agentName=$e(C.agentDisplayName,C.agentName)||S.agentName,S.subagentType=$e(C.agentType,C.agentName)||S.subagentType,S.model=$e(C.model)||S.model,S.prompt||(S.prompt=$e(C.description)||void 0),S.isBackground||(S.isBackground=$e(C.executionMode)==="background"),S.status="running",!0;if(N.type==="subagent.completed"||N.type==="subagent.failed"){S.agentName=$e(C.agentDisplayName,C.agentName)||S.agentName,S.subagentType=$e(C.agentType,C.agentName)||S.subagentType,S.model=$e(C.model)||S.model,S.durationMs=kr(C.durationMs)||S.durationMs,S.toolUseCount=kr(C.totalToolCalls)||S.toolUseCount,S.status=N.type==="subagent.completed"?"completed":"failed";const T=$e(C.error,C.message);return T&&!S.text.includes(T)&&S.text.push(T),!0}if(N.type==="user.message")return S.prompt||(S.prompt=$e(C.content)||void 0),!0;if(N.type==="assistant.reasoning"){const T=$e(C.content);return T&&!S.thinking.includes(T)&&S.thinking.push(T),!0}if(N.type==="assistant.message"){S.model=$e(C.model)||S.model;const T=$e(C.reasoningText);T&&!S.thinking.includes(T)&&S.thinking.push(T);const A=ny(C.content);A&&!S.text.includes(A)&&S.text.push(A);for(const P of ry(C.toolRequests,E,I=>c.has(I)))S.toolCalls.push(P),c.set(P.id,{call:P,message:S});return!0}if(N.type==="assistant.usage"){S.model=$e(C.model)||S.model;const T=Gh(C);return T&&(S.tokenUsage=Ni(S.tokenUsage,T)),!0}if(N.type==="tool.execution_start"){const T=$e(C.toolCallId)||qr(N,"copilot-agent-tool"),A=$e(C.toolName)||"Tool",P=Pa(A),I=c.get(T);if(I)oy(I.call,P,C.arguments,E);else{const $=Ia(T,P,Qu(P,C.arguments),E);S.toolCalls.push($),c.set(T,{call:$,message:S})}return!0}if(N.type==="tool.execution_complete"){const T=$e(C.toolCallId)||qr(N,"copilot-agent-tool");let A=c.get(T);if(!A){const P=$e(C.toolName)||"Tool",I=Pa(P),$=Ia(T,I,{},E);S.toolCalls.push($),A={call:$,message:S}}return iy(A.call,C,r),c.delete(T),!0}return!0}for(const N of t){if(j(N))continue;const{data:S}=N,C=Aa(N);if(N.type==="session.start"||N.type==="session.resume"){m=$e(S.selectedModel)||m,p=$e(S.reasoningEffort)||p;continue}if(N.type==="session.auto_mode_resolved"){m=$e(S.chosenModel)||m,f&&(f.model=m);continue}if(N.type==="session.model_change"){m=$e(S.newModel)||m;const E=S.reasoningEffort;typeof E=="string"&&(p=E),f&&(f.model=m,p&&(f.effort=p));continue}if(N.type==="session.shutdown"){m=$e(S.currentModel)||m,f&&!f.model&&(f.model=m),x=nD(S)??x;const E=kr(S.totalApiDurationMs);f&&!g&&E&&d.set(f,E);continue}if(N.type==="user.message"){v(),f=ay(ty(N),C,eD(S,r),m,p,!1),b(f,C);continue}if(N.type==="assistant.turn_start"){m=$e(S.model)||m;const E=y(N);E.model=m,p&&(E.effort=p),b(E,C);continue}if(N.type==="assistant.reasoning"){const E=y(N);sy(E,$e(S.content),C,$e(S.reasoningId)||qr(N,"copilot-thinking")),b(E,C);continue}if(N.type==="assistant.message"){m=$e(S.model)||m;const E=y(N);E.model=m,p&&(E.effort=p),sy(E,$e(S.reasoningText),C,qr(N,"copilot-thinking")),eN(E,ny(S.content),C);for(const T of ry(S.toolRequests,C,A=>i.has(A)))Wc(E,T,C),i.set(T.id,{call:T,turn:E});b(E,C);continue}if(N.type==="assistant.usage"){m=$e(S.model)||m,p=$e(S.reasoningEffort)||p;const E=Gh(S),T=kr(S.duration);E&&(h=!0),T&&(g=!0);const A=y(N);A.model=m,p&&(A.effort=p),E&&(A.tokenUsage=Ni(A.tokenUsage,E)),T&&d.set(A,(d.get(A)??0)+T),b(A,C);continue}if(N.type==="tool.execution_start"){m=$e(S.model)||m;const E=y(N);E.model=m;const T=$e(S.toolCallId)||qr(N,"copilot-tool"),A=$e(S.toolName)||"Tool",P=Pa(A),I=i.get(T);if(I)oy(I.call,P,S.arguments,C);else{const $=Ia(T,P,Qu(P,S.arguments),C);Wc(E,$,C),i.set(T,{call:$,turn:E})}b(E,C);continue}if(N.type==="tool.execution_complete"){m=$e(S.model)||m;const E=$e(S.toolCallId)||qr(N,"copilot-tool");let T=i.get(E);if(!T){const A=y(N),P=$e(S.toolName)||"Tool",I=Pa(P),$=Ia(E,I,{},C);Wc(A,$,C),T={call:$,turn:A}}iy(T.call,S,r),i.delete(E),b(T.turn,C);continue}if(N.type==="session.error"){const E=y(N),A={errorType:$e(S.errorType)||"unknown"};typeof S.statusCode=="number"&&(A.statusCode=S.statusCode),typeof S.errorCode=="string"&&(A.errorCode=S.errorCode),Wc(E,{id:qr(N,"copilot-error"),name:"Error",input:A,result:$e(S.message)||"Copilot session error",isError:!0,timestamp:C},C),b(E,C);continue}(N.type==="assistant.turn_end"||N.type==="assistant.idle"||N.type==="session.idle")&&f&&b(f,C)}if(v(),!h&&x&&o.length===1&&(o[0].tokenUsage=Ni(o[0].tokenUsage,x)),s.model)for(const N of o)N.model||(N.model=s.model);for(const N of o){const S=u.get(N),C=Date.parse(N.timestamp),E=S?Date.parse(S):Number.NaN;if(Number.isFinite(C)&&Number.isFinite(E)&&E>=C)N.durationMs=E-C;else{const T=d.get(N)??0;T&&(N.durationMs=T)}}const _=e!=null&&e.skipStats?rf(o.length):of(o);return!(e!=null&&e.skipStats)&&!h&&x&&o.length>1&&(_.totalInputTokens=x.input_tokens,_.totalOutputTokens=x.output_tokens,_.totalCacheCreationTokens=x.cache_creation_input_tokens??0,_.totalCacheReadTokens=x.cache_read_input_tokens??0),{sessionId:s.sessionId,version:s.version,gitBranch:s.gitBranch,cwd:s.cwd,slug:s.slug,name:s.name,model:s.model,turns:o,stats:_,rawMessages:e!=null&&e.skipStats?[]:t,agentKind:"copilot"}}function cD(n,e){const t=n.rawMessages.map(s=>JSON.stringify(s)).join(`
|
|
85
|
+
`);return gN(t?`${t}
|
|
86
|
+
${e}`:e)}function uD(n){return typeof n=="string"&&(n==="abort"||n==="binary_asset"||n==="user.message"||n.startsWith("assistant.")||n.startsWith("permission.")||n.startsWith("session.")||n.startsWith("subagent.")||n.startsWith("tool.")||n.startsWith("user_input."))}function dD(n){const e=new Map;for(const r of n){const o=typeof r.agentId=="string"?r.agentId:"";if(!o&&(r.type==="abort"||r.type==="session.shutdown"||r.type==="session.error")){e.clear();continue}if(!o||!r.type.startsWith("subagent."))continue;const i=rn(r.data)?r.data:{};if(r.type==="subagent.completed"||r.type==="subagent.failed"){e.delete(o);continue}if(r.type==="subagent.started"||r.type==="subagent.configured"){const l=[i.agentDisplayName,i.description,i.agentName].find(c=>typeof c=="string")??"";e.set(o,l||e.get(o)||"")}}if(e.size>0){const r=[...e.values()];return{status:"awaiting_agents",pendingQueue:0,pendingAgents:r.length,pendingAgentDescriptions:r.filter(o=>o.length>0)}}let t=!1;const s=new Set;for(let r=n.length-1;r>=0;r--){const o=n[r];if(typeof o.agentId=="string"&&o.agentId)continue;const i=rn(o.data)?o.data:{};switch(o.type){case"abort":case"session.shutdown":return{status:"completed"};case"assistant.turn_end":{for(let l=r-1;l>=0;l--){const c=n[l];if(typeof c.agentId=="string"&&c.agentId)continue;if(c.type==="user.message")break;if(c.type==="abort")return{status:"completed"};if(c.type!=="assistant.message")continue;const u=rn(c.data)?c.data:{};return Array.isArray(u.toolRequests)&&u.toolRequests.length>0?{status:"processing"}:{status:"completed"}}return{status:"processing"}}case"session.error":return{status:"completed",terminalReason:typeof i.message=="string"?i.message:"Copilot session error"};case"assistant.idle":case"session.idle":return{status:t?"completed":"idle"};case"permission.completed":{const l=typeof i.requestId=="string"?i.requestId:"";l&&s.add(l);continue}case"permission.requested":{const l=typeof i.requestId=="string"?i.requestId:"";if(l&&s.has(l))continue;return{status:"deferred"}}case"user_input.requested":return{status:"tool_use",toolName:"AskUserQuestion"};case"tool.execution_start":return s.size>0?{status:"thinking"}:{status:"tool_use",toolName:typeof i.toolName=="string"?Ls(i.toolName):typeof i.name=="string"?Ls(i.name):void 0};case"tool.execution_complete":return{status:"thinking"};case"assistant.turn_start":return{status:"processing"};case"assistant.message":case"assistant.message_delta":case"assistant.reasoning":case"assistant.reasoning_delta":return{status:"thinking"};case"user.message":return t=!0,{status:"processing"};case"session.start":case"session.resume":return{status:t?"processing":"idle"}}}return{status:"idle"}}function fD(){throw new Error("Copilot sessions branch through the CLI's fork API, not by copying the transcript")}function mD(n){const e=[];for(let t=0;t<n.length;t++){const s=n[t];if(s.type!=="user.message"||typeof s.agentId=="string")continue;const r=s.data;!r||typeof r!="object"||Array.isArray(r)||typeof s.id!="string"||!s.id||e.push(t)}return e}const xN=ao[ao.length-1],pD={kind:"codex",descriptor:us("codex"),detectsText:cN,detectsRecords:zz,parse:dx,append:Fz,metadataFromLines:Dz,status:qz,brandBranch:Vz,turnBoundaries:Hz},hD={kind:"copilot",descriptor:us("copilot"),detectsText:Zz,detectsRecords:Yz,parse:gN,append:cD,metadataFromLines:Xz,status:dD,brandBranch:fD,turnBoundaries:mD},gD={kind:"claude",descriptor:us("claude"),detectsText:Kv,detectsRecords:Kv,parse:tz,append:nz,metadataFromLines:ez,status:lz,brandBranch:cz,turnBoundaries:uz},ku=Object.freeze({claude:gD,codex:pD,copilot:hD});function bN(n){for(const e of ao)if(n(ku[e]))return ku[e];return ku[xN]}function vN(n){return ku[n]}function yN(n){return bN(e=>e.detectsText(n))}function wN(n){return bN(e=>e.detectsRecords(n))}function fx(n,e){return n.turnBoundaries(e.map(xD))}function xD(n){try{const e=JSON.parse(n);return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function SN(n,e,t){return fx(n,e)[t]??e.length}function bD(n,e){const t=fx(n,e),s=n.parse(e.join(`
|
|
87
|
+
`),{skipStats:!0}).turns;return s.length!==t.length?null:t.map((r,o)=>({line:r,id:s[o].id}))}function vD(n){return ax(n)?W4(n.input):[n]}function yD(n,e){if(n.length<2)return!1;const t=n[n.length-2],s=t.toolCalls[t.toolCalls.length-1];return(s==null?void 0:s.name)===e&&s.isError}function wD(n,e){const t=n.contentBlocks,s=t.findIndex(r=>r.kind==="tool_calls"&&r.toolCalls.some(o=>o.id===e));return s===-1?!1:t.slice(s+1).some(r=>r.kind==="text"||r.kind==="thinking"||r.kind==="tool_calls")}function SD(n,e){const t=n.contentBlocks,s=t.findIndex(r=>r.kind==="tool_calls"&&r.toolCalls.some(o=>o.id===e));return s===-1?!1:t.slice(s+1).some(r=>r.kind==="queued_prompt")}function kD(n){for(let e=n.toolCalls.length-1;e>=0;e--){const t=n.toolCalls[e];if(!t.asyncQuestion||t.isError)continue;if(SD(n,t.id))return null;const s=t.input.questions;if(s&&s.length>0)return{type:"question",toolUseId:t.id,questions:s}}return null}function jD(n,e){const t=e.toolCalls[e.toolCalls.length-1];if(!t||t.asyncQuestion)return null;const{name:s}=t;if(s!=="ExitPlanMode"&&s!=="AskUserQuestion"||t.result!==null&&!t.isError||yD(n,s)||t.isError&&wD(e,t.id))return null;const r=t.input;if(s==="ExitPlanMode")return{type:"plan",allowedPrompts:r.allowedPrompts};const o=r.questions;return o&&o.length>0?{type:"question",toolUseId:t.id,questions:o}:null}function kN(n){const{turns:e}=n;if(e.length===0)return null;const t=e[e.length-1];return!t||t.toolCalls.length===0?null:jD(e,t)??kD(t)}function ND(n){return typeof n=="string"?n:n.filter(e=>e.type==="text").map(e=>e.text).join(`
|
|
88
|
+
`)}function lf(n,e){return yN(n).parse(n,e)}function CD(n,e){const t=wN(n.rawMessages);return(t.kind===xN?yN(e):t).append(n,e)}function cf(n){return n===null?"":typeof n=="string"?n:ND(n)}function jN(n){return n===null||typeof n=="string"?[]:n.filter(e=>e.type==="image")}const NN=w.createContext(null);function _D(n){const e=[];for(let t=0;t<n.length;t+=1){const s=n[t],r=jN(s.userMessage);for(let o=0;o<r.length;o+=1){const i=r[o];e.push({id:`${s.id}:attachment:${o}`,src:`data:${i.source.media_type};base64,${i.source.data}`,alt:`Attachment ${o+1} from turn ${t+1}`,label:`Turn ${t+1} · Image ${o+1}`})}}return e}function ED(n){const e=q.c(10),{images:t,children:s}=n,[r,o]=w.useState(null);let i;e[0]!==t?(i=m=>{const p=t.findIndex(g=>g.src===m.src),h=p>=0?t:[...t,{...m,id:m.id??`supplemental-image-${t.length}`}];o(g=>({key:((g==null?void 0:g.key)??0)+1,open:!0,images:h,index:p>=0?p:h.length-1}))},e[0]=t,e[1]=i):i=e[1];const l=i;let c;e[2]!==l?(c={openImage:l},e[2]=l,e[3]=c):c=e[3];const u=c;let d;e[4]!==r?(d=r&&a.jsx(rx,{open:r.open,images:r.images,initialIndex:r.index,onClose:()=>o(TD),onCloseComplete:()=>o(null)},r.key),e[4]=r,e[5]=d):d=e[5];let f;return e[6]!==s||e[7]!==d||e[8]!==u?(f=a.jsxs(NN.Provider,{value:u,children:[s,d]}),e[6]=s,e[7]=d,e[8]=u,e[9]=f):f=e[9],f}function TD(n){return n?{...n,open:!1}:null}function AD(n){const e=q.c(7),{children:t}=n,{session:s}=xt();s==null||s.turns;let r;e[0]!==(s==null?void 0:s.turns)?(r=(s==null?void 0:s.turns)??[],e[0]=s==null?void 0:s.turns,e[1]=r):r=e[1];let o;e[2]!==r?(o=_D(r),e[2]=r,e[3]=o):o=e[3];const i=o;let l;return e[4]!==t||e[5]!==i?(l=a.jsx(ED,{images:i,children:t}),e[4]=t,e[5]=i,e[6]=l):l=e[6],l}function CN(){return w.useContext(NN)}const PD={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".svg":"image/svg+xml",".bmp":"image/bmp",".ico":"image/x-icon",".avif":"image/avif"},ID={".mp4":"video/mp4",".m4v":"video/x-m4v",".webm":"video/webm",".mov":"video/quicktime"},_N=new Set(Object.keys(PD)),EN=new Set(Object.keys(ID));function TN(n,e){if(!n)return!1;const t=n.lastIndexOf(".");return t!==-1&&e.has(n.slice(t).toLowerCase())}function $D(n){return TN(n,_N)}function AN(n){return TN(n,EN)}function PN(n){return!n||n.startsWith("http://")||n.startsWith("https://")||n.startsWith("data:")?!1:n.startsWith("/")}function mx(n){return PN(n)&&$D(n)}function IN(n){return PN(n)&&AN(n)}function $N(n){return mx(n)||IN(n)?g1(`/api/local-file?path=${encodeURIComponent(n)}`):n}function Zh(n){const e=q.c(41),{src:t,alt:s,id:r,className:o,thumbnailClassName:i}=n,l=r===void 0?"markdown-image":r,c=mn("hostFiles"),[u,d]=w.useState(!1),[f,m]=w.useState(!1),[p,h]=w.useState(),g=CN();let x;e[0]!==c||e[1]!==t?(x=mx(t)&&!c,e[0]=c,e[1]=t,e[2]=x):x=e[2];const b=x;let y;e[3]!==b||e[4]!==t?(y=b?void 0:$N(t),e[3]=b,e[4]=t,e[5]=y):y=e[5];const v=y;let k;e[6]!==s||e[7]!==l||e[8]!==v?(k=v?{id:l,src:v,alt:s??"Rendered image",label:s||"Rendered image"}:null,e[6]=s,e[7]=l,e[8]=v,e[9]=k):k=e[9];const j=k;let _;e[10]!==g||e[11]!==j?(_=()=>{j&&(g?g.openImage(j):(m(!0),d(!0)))},e[10]=g,e[11]=j,e[12]=_):_=e[12];const N=_;if(b){let R;return e[13]!==s?(R=s?a.jsx("span",{className:"text-muted-foreground",children:s}):null,e[13]=s,e[14]=R):R=e[14],R}if(v&&p===v){const R=s?`: ${s}`:"";let z;return e[15]!==R?(z=a.jsxs("span",{role:"status",className:"my-3 block text-xs text-muted-foreground",children:["Image unavailable",R]}),e[15]=R,e[16]=z):z=e[16],z}const S=`Open ${s||"rendered image"}`;let C;e[17]!==o?(C=G("group/image relative my-3 block h-auto max-w-full overflow-hidden rounded-lg border border-border bg-background p-1 transition-colors hover:bg-muted focus-visible:ring-ring/40",o),e[17]=o,e[18]=C):C=e[18];const E=s??"";let T;e[19]!==v?(T=()=>h(v),e[19]=v,e[20]=T):T=e[20];let A;e[21]!==i?(A=G("max-h-96 max-w-full rounded-lg object-contain",i),e[21]=i,e[22]=A):A=e[22];let P;e[23]!==v||e[24]!==A||e[25]!==E||e[26]!==T?(P=a.jsx("img",{src:v,alt:E,loading:"lazy",decoding:"async",onError:T,className:A}),e[23]=v,e[24]=A,e[25]=E,e[26]=T,e[27]=P):P=e[27];let I;e[28]===Symbol.for("react.memo_cache_sentinel")?(I=a.jsx("span",{className:"absolute right-2 top-2 flex size-7 items-center justify-center rounded-md border border-border bg-popover text-foreground/70 opacity-80 backdrop-blur transition-[color,opacity] group-hover/image:text-foreground sm:opacity-0 sm:group-hover/image:opacity-100 sm:group-focus-visible/image:opacity-100",children:a.jsx(Ld,{className:"size-3.5","data-icon":"icon"})}),e[28]=I):I=e[28];let $;e[29]!==N||e[30]!==P||e[31]!==S||e[32]!==C?($=a.jsxs(ee,{type:"button",variant:"ghost",onClick:N,"aria-label":S,className:C,children:[P,I]}),e[29]=N,e[30]=P,e[31]=S,e[32]=C,e[33]=$):$=e[33];let O;e[34]!==u||e[35]!==f||e[36]!==j?(O=f&&j&&a.jsx(rx,{open:u,images:[j],initialIndex:0,onClose:()=>d(!1),onCloseComplete:()=>m(!1)}),e[34]=u,e[35]=f,e[36]=j,e[37]=O):O=e[37];let M;return e[38]!==$||e[39]!==O?(M=a.jsxs(a.Fragment,{children:[$,O]}),e[38]=$,e[39]=O,e[40]=M):M=e[40],M}function RD(n){const e=q.c(21),{src:t,alt:s,className:r}=n,o=mn("hostFiles"),[i,l]=w.useState();let c;e[0]!==o||e[1]!==t?(c=IN(t)&&!o,e[0]=o,e[1]=t,e[2]=c):c=e[2];const u=c;let d;e[3]!==u||e[4]!==t?(d=u?void 0:$N(t),e[3]=u,e[4]=t,e[5]=d):d=e[5];const f=d;if(!f){let b;return e[6]!==s?(b=s?a.jsx("span",{className:"text-muted-foreground",children:s}):null,e[6]=s,e[7]=b):b=e[7],b}if(i===f){const b=s?`: ${s}`:"";let y;return e[8]!==b?(y=a.jsxs("span",{role:"status",className:"my-3 block text-xs text-muted-foreground",children:["Video unavailable",b]}),e[8]=b,e[9]=y):y=e[9],y}let m;e[10]!==r?(m=G("my-3 block w-fit max-w-full overflow-hidden rounded-lg border border-border bg-background p-1",r),e[10]=r,e[11]=m):m=e[11];const p=s||"Rendered video";let h;e[12]!==f?(h=()=>l(f),e[12]=f,e[13]=h):h=e[13];let g;e[14]!==f||e[15]!==p||e[16]!==h?(g=a.jsx("video",{src:f,controls:!0,playsInline:!0,preload:"metadata","aria-label":p,onError:h,className:"block max-h-96 max-w-full rounded-lg bg-black"}),e[14]=f,e[15]=p,e[16]=h,e[17]=g):g=e[17];let x;return e[18]!==m||e[19]!==g?(x=a.jsx("span",{className:m,children:g}),e[18]=m,e[19]=g,e[20]=x):x=e[20],x}function OD(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("w-full caption-bottom text-sm",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:a.jsx("table",{"data-slot":"table",className:r,...s})}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function LD(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("[&_tr]:border-b",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("thead",{"data-slot":"table-header",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function MD(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("[&_tr:last-child]:border-0",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("tbody",{"data-slot":"table-body",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function zD(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("tr",{"data-slot":"table-row",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function DD(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("th",{"data-slot":"table-head",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function FD(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("td",{"data-slot":"table-cell",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function UD(n){if(!n)return null;let e=n;if(e.toLowerCase().startsWith("file://"))try{const l=new URL(e);e=`${l.pathname}${l.hash}`}catch{return null}const t=e.startsWith("/")&&!e.startsWith("//"),s=/^\/?[a-z]:[\\/]/i.test(e);if(!t&&!s)return null;let r,o;const i=e.match(/#L(\d+)(?:C(\d+))?$/i);if(i)r=Number(i[1]),o=i[2]?Number(i[2]):void 0,e=e.slice(0,-i[0].length);else{const l=e.match(/:(\d+)(?::(\d+))?$/);l&&(r=Number(l[1]),o=l[2]?Number(l[2]):void 0,e=e.slice(0,-l[0].length))}try{e=decodeURIComponent(e)}catch{return null}return/^\/[a-z]:[\\/]/i.test(e)&&(e=e.slice(1)),{path:e,line:r,column:o}}function BD(n){const e=q.c(17);let t,s,r;e[0]!==n?({href:s,children:t,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);const o=mn("hostFiles");let i;e[4]!==s?(i=UD(s),e[4]=s,e[5]=i):i=e[5];const l=i;if(l&&!o){let f;return e[6]!==t||e[7]!==s?(f=a.jsx("span",{className:"text-muted-foreground",title:s,children:t}),e[6]=t,e[7]=s,e[8]=f):f=e[8],f}let c;e[9]!==l||e[10]!==s?(c=f=>{s&&(f.preventDefault(),l?xl(l.path,{line:l.line,column:l.column}):window.open(s,"_blank","noopener,noreferrer"))},e[9]=l,e[10]=s,e[11]=c):c=e[11];const u=c;let d;return e[12]!==t||e[13]!==u||e[14]!==s||e[15]!==r?(d=a.jsx("a",{href:s,onClick:u,className:"text-primary underline decoration-primary/30 hover:decoration-primary/60 cursor-pointer transition-colors",title:s,...r,children:t}),e[12]=t,e[13]=u,e[14]=s,e[15]=r,e[16]=d):d=e[16],d}const WD=[..._N,...EN].map(n=>n.slice(1)).join("|"),qD=new RegExp(`^([ \\t]*)(\\/[^\\s]+\\.(?:${WD}))[ \\t]*$`,"gim");function RN(n){return n.replace(qD,(e,t,s)=>`${t}`)}function VD(n){const e=q.c(3),{src:t,alt:s}=n;let r;return e[0]!==s||e[1]!==t?(r=AN(t)?a.jsx(RD,{src:t,alt:s}):a.jsx(Zh,{src:t,alt:s}),e[0]=s,e[1]=t,e[2]=r):r=e[2],r}const hr={code:b4,pre({children:n}){return a.jsx(a.Fragment,{children:n})},a:BD,h1({children:n}){return a.jsx("h1",{className:"text-xl font-semibold mt-6 mb-3 pb-2 border-b border-border/40 text-foreground first:mt-0",children:n})},h2({children:n}){return a.jsx("h2",{className:"text-lg font-semibold mt-5 mb-2 pb-1.5 border-b border-border/30 text-foreground first:mt-0",children:n})},h3({children:n}){return a.jsx("h3",{className:"text-base font-semibold mt-4 mb-2 text-foreground first:mt-0",children:n})},h4({children:n}){return a.jsx("h4",{className:"text-sm font-semibold mt-3 mb-1.5 text-foreground first:mt-0",children:n})},h5({children:n}){return a.jsx("h5",{className:"text-sm font-medium mt-3 mb-1 text-foreground first:mt-0",children:n})},h6({children:n}){return a.jsx("h6",{className:"text-xs font-medium mt-3 mb-1 text-muted-foreground first:mt-0",children:n})},p({children:n}){return a.jsx("p",{className:"my-1.5 leading-[1.55] text-foreground/90 first:mt-0 last:mb-0 md:my-2 md:leading-relaxed",children:n})},blockquote({children:n}){return a.jsx("blockquote",{className:"my-2 rounded-r-md border-l-2 border-border bg-muted/30 py-1.5 pl-3 pr-2.5 text-foreground/80 [&>p]:my-1 md:my-3 md:py-2 md:pl-4 md:pr-3",children:n})},ul({children:n}){return a.jsx("ul",{className:"my-1.5 flex list-disc flex-col gap-0.5 pl-5 marker:text-muted-foreground/50 [&_ol]:my-1 [&_ul]:my-1 md:my-2 md:gap-1 md:pl-6",children:n})},ol({children:n}){return a.jsx("ol",{className:"my-1.5 flex list-decimal flex-col gap-0.5 pl-5 marker:text-muted-foreground/50 [&_ol]:my-1 [&_ul]:my-1 md:my-2 md:gap-1 md:pl-6",children:n})},li({children:n}){return a.jsx("li",{className:"pl-1 leading-[1.55] text-foreground/90 md:leading-relaxed",children:n})},hr(){return a.jsx(Gt,{className:"my-4"})},table({children:n}){return a.jsx("div",{className:"my-3 overflow-x-auto rounded-lg border border-border/40",children:a.jsx(OD,{className:"border-collapse text-sm",children:n})})},thead({children:n}){return a.jsx(LD,{className:"bg-muted/50",children:n})},tbody({children:n}){return a.jsx(MD,{children:n})},tr({children:n}){return a.jsx(zD,{className:"even:bg-muted/20",children:n})},th({children:n}){return a.jsx(DD,{className:"h-9 px-3 py-2 text-xs font-medium text-muted-foreground",children:n})},td({children:n}){return a.jsx(FD,{className:"px-3 py-2 text-foreground/90",children:n})},strong({children:n}){return a.jsx("strong",{className:"font-semibold text-foreground",children:n})},em({children:n}){return a.jsx("em",{className:"italic text-foreground/90",children:n})},del({children:n}){return a.jsx("del",{className:"line-through text-muted-foreground",children:n})},img:VD,input({checked:n,...e}){return a.jsx("input",{type:"checkbox",checked:n,readOnly:!0,className:"mr-2 rounded border-border accent-primary",...e})}},gr=[HP],HD=["system-reminder","local-command-caveat","command-name","command-message","command-args","env","claude_background_info","fast_mode_info","gitStatus","user-prompt-submit-hook"],KD=HD.join("|");function ON(){return new RegExp(`<(${KD})[^>]*>[\\s\\S]*?<\\/\\1>`,"g")}function LN(n){return n.replace(ON(),"").trim()}function GD(n){return ON().test(n)}const ZD=/<command-message>([^<]+)<\/command-message>/,YD=/<command-name>([\s\S]*?)<\/command-name>/,XD=/<command-args>([\s\S]*?)<\/command-args>/;function MN(n){const e=n.match(ZD);if(e)return e[1];const t=n.match(YD);return t?t[1].trim().replace(/^\//,""):null}function zN(n){const e=n.match(XD);if(!e)return null;const t=e[1].trim();return t.length>0?t:null}const DN={"local-command-stdout":"stdout","local-command-stderr":"stderr","bash-input":"input","bash-stdout":"stdout","bash-stderr":"stderr"},JD=new RegExp(`<(${Object.keys(DN).join("|")})>([\\s\\S]*?)<\\/\\1>`,"g");function QD(n){const e=[],t=n.replace(JD,(s,r,o)=>(e.push({text:Vj(o).trim(),stream:DN[r]}),"")).trim();return{outputs:e,remainingText:t}}const eF=/<task-notification>([\s\S]*?)<\/task-notification>/g;function Eo(n,e){const t=n.match(new RegExp(`<${e}>([\\s\\S]*?)<\\/${e}>`));return t?t[1].trim():""}function px(n){const e=[],t=n.replace(eF,(s,r)=>(e.push({taskId:Eo(r,"task-id"),toolUseId:Eo(r,"tool-use-id"),outputFile:Eo(r,"output-file"),status:Eo(r,"status"),summary:Eo(r,"summary"),result:Eo(r,"result"),event:Eo(r,"event")}),"")).trim();return{notifications:e,remainingText:t}}const tF=/\[Request interrupted by user[^\]]*\]/g;function nF(n){const e=[],t=n.replace(tF,s=>(e.push(s),"")).trim();return{interrupts:e,remainingText:t}}const ly="[SYSTEM NOTIFICATION - NOT USER INPUT]";function sF(n){const e=n.indexOf(ly);if(e===-1)return{text:n,isSystemNotification:!1};const t=e+ly.length,s=n.indexOf(`
|
|
89
|
+
|
|
90
|
+
`,t),r=s===-1?t:s+2;return{text:(n.slice(0,e)+n.slice(r)).trim(),isSystemNotification:!0}}const cy={Icon:J9,color:"text-destructive",bg:"border-destructive/20 bg-destructive/5",badgeVariant:"destructive"},rF={completed:{Icon:X9,color:"text-success",bg:"border-success/20 bg-success/5",badgeVariant:"secondary",label:"Completed"},failed:{...cy,label:"Failed"},error:{...cy,label:"Error"},running:{Icon:Q9,color:"text-warning",bg:"border-warning/20 bg-warning/5",badgeVariant:"outline",label:"Running"}},oF={Icon:wh,color:"text-muted-foreground",bg:"border-border/40 bg-muted/30",badgeVariant:"outline"};function FN(n){const e=q.c(47),{notification:t}=n,[s,r]=w.useState(!1);let o,i,l,c,u,d,f,m,p,h;if(e[0]!==s||e[1]!==t.event||e[2]!==t.outputFile||e[3]!==t.result.length||e[4]!==t.status){u=rF[t.status]??{...oF,label:t.status||"Event"};const{Icon:N}=u;c=t.result.length>0||t.event.length>0||t.outputFile.length>0,o=s?Ot:ot,l=En,m=s,p=r,h=G("my-1 rounded-lg border p-3",u.bg),f="flex items-start gap-2",i=N,d=G("mt-0.5 size-4 shrink-0",u.color),e[0]=s,e[1]=t.event,e[2]=t.outputFile,e[3]=t.result.length,e[4]=t.status,e[5]=o,e[6]=i,e[7]=l,e[8]=c,e[9]=u,e[10]=d,e[11]=f,e[12]=m,e[13]=p,e[14]=h}else o=e[5],i=e[6],l=e[7],c=e[8],u=e[9],d=e[10],f=e[11],m=e[12],p=e[13],h=e[14];let g;e[15]!==i||e[16]!==d?(g=a.jsx(i,{className:d}),e[15]=i,e[16]=d,e[17]=g):g=e[17];let x;e[18]!==t.summary?(x=a.jsx("span",{className:"text-sm font-medium text-foreground",children:t.summary}),e[18]=t.summary,e[19]=x):x=e[19];let b;e[20]!==u.badgeVariant||e[21]!==u.color||e[22]!==u.label?(b=a.jsx(Ue,{variant:u.badgeVariant,className:u.color,children:u.label}),e[20]=u.badgeVariant,e[21]=u.color,e[22]=u.label,e[23]=b):b=e[23];let y;e[24]!==x||e[25]!==b?(y=a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[x,b]}),e[24]=x,e[25]=b,e[26]=y):y=e[26];let v;e[27]!==o||e[28]!==s||e[29]!==c||e[30]!==t.event||e[31]!==t.outputFile||e[32]!==t.result?(v=c&&a.jsxs(a.Fragment,{children:[a.jsxs(vs,{render:a.jsx(ee,{type:"button",variant:"ghost",size:"xs",className:"mt-1.5 -ml-2 text-muted-foreground"}),children:[a.jsx(o,{"data-icon":"inline-start"}),s?"Hide detail":"Show detail"]}),a.jsx(Tn,{children:a.jsxs("div",{className:"mt-2 border-t border-border/30 pt-2 text-sm text-foreground/90",children:[t.result&&a.jsx(cr,{components:hr,remarkPlugins:gr,children:t.result}),t.event&&a.jsx("div",{className:"whitespace-pre-wrap break-words font-mono text-xs",children:t.event}),t.outputFile&&a.jsxs("div",{className:"mt-2",children:[a.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Output file"}),a.jsx("div",{className:"mt-1 select-all break-all rounded bg-muted px-2 py-1 font-mono text-xs text-muted-foreground",children:t.outputFile})]})]})})]}),e[27]=o,e[28]=s,e[29]=c,e[30]=t.event,e[31]=t.outputFile,e[32]=t.result,e[33]=v):v=e[33];let k;e[34]!==v||e[35]!==y?(k=a.jsxs("div",{className:"min-w-0 flex-1",children:[y,v]}),e[34]=v,e[35]=y,e[36]=k):k=e[36];let j;e[37]!==k||e[38]!==f||e[39]!==g?(j=a.jsxs("div",{className:f,children:[g,k]}),e[37]=k,e[38]=f,e[39]=g,e[40]=j):j=e[40];let _;return e[41]!==l||e[42]!==j||e[43]!==m||e[44]!==p||e[45]!==h?(_=a.jsx(l,{open:m,onOpenChange:p,className:h,children:j}),e[41]=l,e[42]=j,e[43]=m,e[44]=p,e[45]=h,e[46]=_):_=e[46],_}function iF(n){const e=q.c(7),{content:t}=n;let s,r,o;if(e[0]!==t){o=Symbol.for("react.early_return_sentinel");e:{const{notifications:l}=px(t);if(l.length===0){o=null;break e}s="flex flex-col",r=l.map(aF)}e[0]=t,e[1]=s,e[2]=r,e[3]=o}else s=e[1],r=e[2],o=e[3];if(o!==Symbol.for("react.early_return_sentinel"))return o;let i;return e[4]!==s||e[5]!==r?(i=a.jsx("div",{className:s,children:r}),e[4]=s,e[5]=r,e[6]=i):i=e[6],i}function aF(n,e){return a.jsx(FN,{notification:n},n.taskId||`notification-${e}`)}function lF(n){const e=q.c(15),{output:t}=n,s=t.stream==="stderr",r=t.stream==="input",o=s&&"border-destructive/20 bg-destructive/5 text-destructive",i=r&&"border-border bg-muted/50 text-foreground",l=!s&&!r&&"border-border bg-muted/40 text-muted-foreground";let c;e[0]!==o||e[1]!==i||e[2]!==l?(c=G("rounded-md border px-3 py-2 my-1 font-mono text-xs",o,i,l),e[0]=o,e[1]=i,e[2]=l,e[3]=c):c=e[3];let u;e[4]!==s||e[5]!==r?(u=r?a.jsx(ot,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}):a.jsx(Ai,{className:G("size-3 shrink-0",s?"text-destructive":"text-muted-foreground"),"data-icon":"inline-start"}),e[4]=s,e[5]=r,e[6]=u):u=e[6];let d;e[7]!==t.text?(d=a.jsx("span",{className:"whitespace-pre-wrap break-words",children:t.text}),e[7]=t.text,e[8]=d):d=e[8];let f;e[9]!==u||e[10]!==d?(f=a.jsxs("div",{className:"flex items-center gap-1.5",children:[u,d]}),e[9]=u,e[10]=d,e[11]=f):f=e[11];let m;return e[12]!==c||e[13]!==f?(m=a.jsx("div",{className:c,children:f}),e[12]=c,e[13]=f,e[14]=m):m=e[14],m}function cF(n){const e=q.c(6),{loading:t,content:s}=n;let r;if(t){let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground/60 font-mono",children:[a.jsx(Hj,{className:"w-3 h-3 text-muted-foreground/60"})," Loading..."]}),e[0]=i):i=e[0],r=i}else if(s){let i;e[1]!==s?(i=a.jsx(cr,{components:hr,remarkPlugins:gr,children:s}),e[1]=s,e[2]=i):i=e[2],r=i}else{let i;e[3]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsx("span",{className:"text-muted-foreground/60 font-mono",children:"Could not load command content"}),e[3]=i):i=e[3],r=i}let o;return e[4]!==r?(o=a.jsx("div",{className:"mt-2 max-h-80 overflow-auto rounded-md border border-border bg-muted/40 p-3 text-xs text-muted-foreground",children:r}),e[4]=r,e[5]=o):o=e[5],o}const hx=w.memo(function({content:e,timestamp:t,onEditCommand:s,onExpandCommand:r,compact:o=!1}){const i=CN(),[l,c]=w.useState(!1),[u,d]=w.useState(!1),[f,m]=w.useState(!1),[p,h]=w.useState(null),[g,x]=w.useState(!1),[b,y]=w.useState(null),v=w.useMemo(()=>cf(e),[e]),k=w.useMemo(()=>MN(v),[v]),j=w.useMemo(()=>zN(v),[v]),{sender:_,body:N,matched:S}=w.useMemo(()=>wl(v),[v]),C=w.useMemo(()=>LN(N),[N]),{text:E,isSystemNotification:T}=w.useMemo(()=>sF(C),[C]),{notifications:A,remainingText:P}=w.useMemo(()=>px(E),[E]),{outputs:I,remainingText:$}=w.useMemo(()=>QD(P),[P]),{interrupts:O,remainingText:M}=w.useMemo(()=>nF($),[$]),R=w.useCallback(async H=>{if(!H){m(!1);return}if(p!==null){m(!0);return}if(!(!r||!k)){x(!0),m(!0);try{const K=await r(k,j??void 0);h(K)}finally{x(!1)}}},[p,r,k,j]),z=w.useMemo(()=>jN(e),[e]),W=w.useMemo(()=>z.map(H=>`data:${H.source.media_type};base64,${H.source.data}`),[z]),D=w.useMemo(()=>W.map((H,K)=>({id:`message-attachment-${K}`,src:H,alt:`Attachment ${K+1}`,label:W.length>1?`Attachment ${K+1}`:"Attached image"})),[W]),L=w.useMemo(()=>GD(v)||T||S,[v,T,S]),U=u?v:M,B=U.length>500&&!l?U.slice(0,500)+"...":U,V=H=>{const K=D[H];K&&(i?i.openImage(K):y({index:H,open:!0}))};return a.jsxs("div",{className:"group",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:"flex items-center gap-2 mb-1",children:L&&a.jsx(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>d(!u),className:"-ml-2 text-muted-foreground",children:u?a.jsxs(a.Fragment,{children:[a.jsx(n1,{"data-icon":"inline-start"})," Hide raw"]}):a.jsxs(a.Fragment,{children:[a.jsx(Zi,{"data-icon":"inline-start"})," Show raw"]})})}),!u&&T&&a.jsx("div",{className:"mb-2",children:a.jsxs(Ue,{variant:"outline",className:"text-muted-foreground",children:[a.jsx(Ai,{"data-icon":"inline-start"}),"System event"]})}),!u&&S&&a.jsx("div",{className:"mb-2",children:a.jsxs(Ue,{variant:"outline",className:"text-muted-foreground",children:[a.jsx(Bs,{"data-icon":"inline-start"}),_?`From ${_}`:"Teammate message"]})}),k&&a.jsxs(En,{open:f,onOpenChange:H=>void R(H),className:"mb-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(Ue,{variant:"outline",className:"font-mono text-foreground",children:[a.jsx(Ai,{"data-icon":"inline-start"}),"/",k,j&&a.jsx("span",{className:"text-muted-foreground",children:j})]}),r&&a.jsxs(vs,{render:a.jsx(ee,{type:"button",variant:"ghost",size:"xs",className:"text-muted-foreground"}),children:[f?a.jsx(Ot,{"data-icon":"inline-start"}):a.jsx(ot,{"data-icon":"inline-start"}),f?"Collapse":"Expand"]}),f&&s&&a.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>s(k),className:"text-muted-foreground",children:[a.jsx(Er,{"data-icon":"inline-start"}),"Edit"]})]}),a.jsx(Tn,{children:a.jsx(cF,{loading:g,content:p})})]}),W.length>0&&a.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:W.map((H,K)=>a.jsxs(ee,{type:"button",variant:"ghost",onClick:()=>V(K),"aria-label":`Open attached image ${K+1}`,className:G("group/image relative h-auto max-w-full overflow-hidden rounded-lg border border-border bg-background p-1 text-left","transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40"),children:[a.jsx("img",{src:H,alt:`Attachment ${K+1}`,loading:"lazy",decoding:"async",className:"max-h-64 max-w-full rounded-lg object-contain sm:max-w-md"}),a.jsx("span",{className:"absolute right-2 top-2 flex size-7 items-center justify-center rounded-md border border-border bg-popover text-foreground/70 opacity-80 backdrop-blur transition-[color,opacity] group-hover/image:text-foreground sm:opacity-0 sm:group-hover/image:opacity-100 sm:group-focus-visible/image:opacity-100",children:a.jsx(Ld,{className:"size-3.5","data-icon":"icon"})}),W.length>1&&a.jsxs("span",{className:"absolute bottom-2 right-2 rounded-md bg-popover px-1.5 py-0.5 font-mono text-xs text-foreground/80",children:[K+1," / ",W.length]})]},`${z[K].source.media_type}-${z[K].source.data.slice(0,24)}-${K}`))}),!u&&A.length>0&&a.jsx("div",{className:"mb-2 flex flex-col gap-2",children:A.map(H=>a.jsx(FN,{notification:H},H.taskId))}),!u&&I.length>0&&a.jsx("div",{className:"mb-2 flex flex-col gap-1",children:I.map((H,K)=>a.jsx(lF,{output:H},K))}),!u&&O.length>0&&a.jsx("div",{className:"mb-2 flex flex-col gap-1",children:O.map((H,K)=>a.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium text-destructive",children:[a.jsx(H7,{className:"size-3 shrink-0","data-icon":"inline-start"}),a.jsx("span",{children:H})]},K))}),B&&a.jsx("div",{className:"max-w-none overflow-hidden break-words text-sm leading-relaxed",children:a.jsx(cr,{components:hr,remarkPlugins:gr,children:B})}),U.length>500&&a.jsx(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>c(!l),className:"mt-1 -ml-2 text-muted-foreground",children:l?a.jsxs(a.Fragment,{children:[a.jsx(Ot,{"data-icon":"inline-start"})," Show less"]}):a.jsxs(a.Fragment,{children:[a.jsx(ot,{"data-icon":"inline-start"})," Show more"]})}),!o&&t&&a.jsx("div",{className:"flex items-center mt-1.5 ml-auto",children:a.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(t).toLocaleTimeString()})})]}),b!==null&&a.jsx(rx,{open:b.open,images:D,initialIndex:b.index,onClose:()=>y(H=>H?{...H,open:!1}:null),onCloseComplete:()=>y(null)},b.index)]})}),UN=w.memo(function(e){const t=q.c(10),{message:s,turnNumber:r}=e;let o;t[0]!==r?(o=a.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:["Turn ",r]}),t[0]=r,t[1]=o):o=t[1];let i;t[2]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsx(Ue,{variant:"outline",children:"Queued"}),t[2]=i):i=t[2];let l;t[3]!==o?(l=a.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[o,i]}),t[3]=o,t[4]=l):l=t[4];let c;t[5]!==s?(c=a.jsx("div",{className:"rounded-lg border border-dashed bg-prompt-surface p-3",children:a.jsx(hx,{content:s,timestamp:""})}),t[5]=s,t[6]=c):c=t[6];let u;return t[7]!==l||t[8]!==c?(u=a.jsxs("div",{className:"motion-enter group relative px-4 py-5",children:[l,c]}),t[7]=l,t[8]=c,t[9]=u):u=t[9],u}),BN=w.memo(function(e){const t=q.c(30),{progress:s,expanded:r,onExpandedChange:o}=e,[i,l]=w.useState(!1),c=r??i,{todos:u,completed:d,total:f}=s,m=f>0?d/f*100:0;let p;t[0]!==o?(p=E=>{o==null||o(E),l(E)},t[0]=o,t[1]=p):p=t[1];let h;t[2]===Symbol.for("react.memo_cache_sentinel")?(h=a.jsx(ee,{type:"button",variant:"ghost",className:"h-auto w-full justify-start rounded-none px-3 py-2"}),t[2]=h):h=t[2];let g;t[3]!==c?(g=c?a.jsx(Ot,{"data-icon":"inline-start"}):a.jsx(Id,{"data-icon":"inline-start"}),t[3]=c,t[4]=g):g=t[4];let x;t[5]===Symbol.for("react.memo_cache_sentinel")?(x=a.jsx("span",{className:"text-sm font-medium",children:"Tasks"}),t[5]=x):x=t[5];let b;t[6]!==d||t[7]!==f?(b=a.jsxs("span",{className:"font-mono text-xs tabular-nums text-muted-foreground",children:[d,"/",f]}),t[6]=d,t[7]=f,t[8]=b):b=t[8];let y;t[9]!==m?(y=m.toFixed(0),t[9]=m,t[10]=y):y=t[10];const v=`${y}% of tasks complete`;let k;t[11]!==m||t[12]!==v?(k=a.jsx(Xl,{value:m,className:"max-w-[200px] flex-1","aria-label":v}),t[11]=m,t[12]=v,t[13]=k):k=t[13];let j;t[14]!==s.inProgress?(j=s.inProgress&&a.jsxs("span",{className:"flex min-w-0 items-center gap-1 truncate text-xs text-info",children:[a.jsx(vt,{className:"size-3 shrink-0 animate-spin"}),a.jsx("span",{className:"truncate",children:s.inProgress.activeForm})]}),t[14]=s.inProgress,t[15]=j):j=t[15];let _;t[16]!==g||t[17]!==b||t[18]!==k||t[19]!==j?(_=a.jsxs(vs,{render:h,children:[g,x,b,k,j]}),t[16]=g,t[17]=b,t[18]=k,t[19]=j,t[20]=_):_=t[20];let N;t[21]!==u?(N=u.map(uF),t[21]=u,t[22]=N):N=t[22];let S;t[23]!==N?(S=a.jsx(Tn,{children:a.jsx("div",{className:"px-3 pb-3 pt-1",children:a.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:N})})}),t[23]=N,t[24]=S):S=t[24];let C;return t[25]!==c||t[26]!==p||t[27]!==_||t[28]!==S?(C=a.jsxs(En,{open:c,onOpenChange:p,className:"shrink-0 border-t bg-background",children:[_,S]}),t[25]=c,t[26]=p,t[27]=_,t[28]=S,t[29]=C):C=t[29],C});function uF(n,e){return a.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[n.status==="completed"?a.jsx(Mr,{className:"size-3 shrink-0 text-success"}):n.status==="in_progress"?a.jsx(vt,{className:"size-3 shrink-0 animate-spin text-info"}):a.jsx(s1,{className:"size-3 shrink-0 text-muted-foreground"}),a.jsx("span",{className:G("truncate text-xs",n.status==="in_progress"?"text-foreground":"text-muted-foreground",n.status==="completed"&&"line-through"),children:n.content}),n.owner&&a.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:n.owner})]},n.id??e)}function oa(n,e){const t=q.c(8);let s;t[0]!==e||t[1]!==n?(s=()=>{if(typeof window>"u")return e;try{const u=localStorage.getItem(n);return u===null?e:JSON.parse(u)}catch{return e}},t[0]=e,t[1]=n,t[2]=s):s=t[2];const[r,o]=w.useState(s);let i;t[3]!==n?(i=u=>{o(d=>{const f=typeof u=="function"?u(d):u;try{localStorage.setItem(n,JSON.stringify(f))}catch(m){const p=m;console.warn(`useLocalStorage: failed to serialize value for key "${n}"`,p)}return f})},t[3]=n,t[4]=i):i=t[4];const l=i;let c;return t[5]!==l||t[6]!==r?(c=[r,l],t[5]=l,t[6]=r,t[7]=c):c=t[7],c}function WN(n){return`${n.provider}:${n.latestVersion??"unknown"}`}function dF(n,e){const t=e.split(":")[0];return[...n.filter(s=>s.split(":")[0]!==t),e]}const fF="cogpit:provider-update-dismissals:v1";function mF(n,e){return n.filter(t=>t.status==="behind"&&!e.includes(WN(t)))}async function pF(n){const e=await Re("/api/provider-updates",{signal:n});if(!e.ok)throw new Error(`Provider update check failed (${e.status})`);return(await e.json()).providers??[]}async function hF(n){const e=await ws("/api/provider-updates/run",{provider:n}),t=await e.json();if(!t.status)throw new Error(t.error??`Update failed (${e.status})`);return t}const gF=360*60*1e3;function xF(){const[n,e]=w.useState([]),[t,s]=oa(fF,[]),[r,o]=w.useState(null),[i,l]=w.useState(null);w.useEffect(()=>{const d=new AbortController,f=()=>{pF(d.signal).then(e).catch(()=>{})};f();const m=setInterval(f,gF);return()=>{d.abort(),clearInterval(m)}},[]);const c=w.useCallback(async d=>{o(d),l(null);try{const f=await hF(d);l(f),e(m=>m.map(p=>p.provider===d?f.info:p))}catch(f){l({provider:d,status:"failed",message:f instanceof Error?f.message:"Update failed.",output:null})}finally{o(null)}},[]),u=w.useCallback(d=>{s(f=>dF(f,WN(d)))},[s]);return{pending:mF(n,t),updating:r,outcome:i,update:c,dismiss:u,clearOutcome:w.useCallback(()=>l(null),[])}}const bF=5e3,vF={warning:"border-warning/30 bg-warning/10 text-warning",destructive:"border-destructive/30 bg-destructive/10 text-destructive",success:"border-success/30 bg-success/10 text-success"};function xm(n){return`grid-cols-[auto_minmax(0,1fr)_auto] rounded-none border-x-0 border-t-0 px-4 py-2 ${vF[n]}`}function uy(n){const e=n.currentVersion?`v${n.currentVersion}`:"an older build";return`${n.displayName} ${e} → v${n.latestVersion}`}function qN(){const n=q.c(55),{pending:e,updating:t,outcome:s,update:r,dismiss:o,clearOutcome:i}=xF(),l=pt("configWrite"),c=(s==null?void 0:s.status)==="succeeded";let u,d;if(n[0]!==i||n[1]!==c?(u=()=>{if(!c)return;const C=setTimeout(i,bF);return()=>clearTimeout(C)},d=[c,i],n[0]=i,n[1]=c,n[2]=u,n[3]=d):(u=n[2],d=n[3]),w.useEffect(u,d),s){let C;return n[4]!==i||n[5]!==s.message||n[6]!==c?(C=c?a.jsxs(Jt,{className:xm("success"),children:[a.jsx($d,{}),a.jsx(_n,{children:s.message}),a.jsx(Qt,{className:"text-success/80",children:"New sessions will use the updated CLI."})]}):a.jsxs(Jt,{className:xm("destructive"),children:[a.jsx(vo,{}),a.jsx(_n,{children:"Update did not complete"}),a.jsx(Qt,{className:"text-destructive/80",children:s.message}),a.jsx(uo,{className:"static col-start-3 row-span-2 row-start-1 self-center",children:a.jsx(ee,{variant:"ghost",size:"xs",onClick:i,children:"Dismiss"})})]}),n[4]=i,n[5]=s.message,n[6]=c,n[7]=C):C=n[7],C}if(e.length===0||!l)return null;const f=e[0];let m,p,h,g,x,b,y,v;if(n[8]!==f||n[9]!==e||n[10]!==r||n[11]!==t){const C=e.filter(wF);p=Jt,n[20]===Symbol.for("react.memo_cache_sentinel")?(x=xm("warning"),n[20]=x):x=n[20],n[21]!==t?(b=t?a.jsx(vt,{className:"animate-spin"}):a.jsx(lr,{}),n[21]=t,n[22]=b):b=n[22];let E;n[23]!==f||n[24]!==e?(E=e.length===1?uy(f):`${e.map(yF).join(" and ")} are out of date`,n[23]=f,n[24]=e,n[25]=E):E=n[25],n[26]!==E?(y=a.jsx(_n,{children:E}),n[26]=E,n[27]=y):y=n[27];let T;n[28]!==f||n[29]!==e?(T=e.length>1?e.map(uy).join(" · "):f.updateCommand?`Cogpit can run \`${f.updateCommand}\` for you.`:"Update it with whatever installed it — Cogpit could not tell.",n[28]=f,n[29]=e,n[30]=T):T=n[30],n[31]!==T?(v=a.jsx(Qt,{className:"text-warning/80",children:T}),n[31]=T,n[32]=v):v=n[32],m=uo,h="static col-start-3 row-span-2 row-start-1 flex items-center gap-2 self-center";let A;n[33]!==e.length||n[34]!==r||n[35]!==t?(A=P=>a.jsxs(ee,{variant:"outline",size:"xs",disabled:t!==null,onClick:()=>void r(P.provider),children:[a.jsx(Sh,{"data-icon":"inline-start"}),t===P.provider?"Updating…":e.length===1?"Update":`Update ${P.displayName}`]},P.provider),n[33]=e.length,n[34]=r,n[35]=t,n[36]=A):A=n[36],g=C.map(A),n[8]=f,n[9]=e,n[10]=r,n[11]=t,n[12]=m,n[13]=p,n[14]=h,n[15]=g,n[16]=x,n[17]=b,n[18]=y,n[19]=v}else m=n[12],p=n[13],h=n[14],g=n[15],x=n[16],b=n[17],y=n[18],v=n[19];const k=t!==null;let j;n[37]!==o||n[38]!==e?(j=()=>e.forEach(o),n[37]=o,n[38]=e,n[39]=j):j=n[39];let _;n[40]!==k||n[41]!==j?(_=a.jsx(ee,{variant:"ghost",size:"xs",disabled:k,onClick:j,className:"whitespace-nowrap text-muted-foreground",children:"Don't show again"}),n[40]=k,n[41]=j,n[42]=_):_=n[42];let N;n[43]!==m||n[44]!==_||n[45]!==h||n[46]!==g?(N=a.jsxs(m,{className:h,children:[g,_]}),n[43]=m,n[44]=_,n[45]=h,n[46]=g,n[47]=N):N=n[47];let S;return n[48]!==p||n[49]!==N||n[50]!==x||n[51]!==b||n[52]!==y||n[53]!==v?(S=a.jsxs(p,{className:x,children:[b,y,v,N]}),n[48]=p,n[49]=N,n[50]=x,n[51]=b,n[52]=y,n[53]=v,n[54]=S):S=n[54],S}function yF(n){return n.displayName}function wF(n){return n.updateCommand!==null}function VN(){const n=q.c(27),[e,t]=w.useState(null),[s,r]=w.useState(null),[o,i]=w.useState(!1);let l,c;if(n[0]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{const u=window.electronUpdater;u&&(u.onUpdateAvailable(d=>{t(d)}),u.onUpdateDownloaded(d=>{r(d)}))},c=[],n[0]=l,n[1]=c):(l=n[0],c=n[1]),w.useEffect(l,c),s&&!o){let u;n[2]===Symbol.for("react.memo_cache_sentinel")?(u=a.jsx(Sh,{}),n[2]=u):u=n[2];let d;n[3]!==s.version?(d=a.jsxs(_n,{children:["Cogpit v",s.version," is ready"]}),n[3]=s.version,n[4]=d):d=n[4];let f;n[5]===Symbol.for("react.memo_cache_sentinel")?(f=a.jsx(Qt,{className:"text-success/80",children:"Restart to apply the update."}),n[5]=f):f=n[5];let m;n[6]===Symbol.for("react.memo_cache_sentinel")?(m=()=>i(!0),n[6]=m):m=n[6];let p;n[7]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsx(uo,{className:"static col-start-3 row-span-2 row-start-1 self-center",children:a.jsx(ee,{variant:"ghost",size:"icon-xs",onClick:m,"aria-label":"Dismiss update",children:a.jsx(Ut,{"data-icon":"inline-start"})})}),n[7]=p):p=n[7];let h;return n[8]!==d?(h=a.jsxs(Jt,{className:"grid-cols-[auto_minmax(0,1fr)_auto] rounded-none border-x-0 border-t-0 border-success/30 bg-success/10 px-4 py-2 pr-4 text-success has-data-[slot=alert-action]:pr-4",children:[u,d,f,p]}),n[8]=d,n[9]=h):h=n[9],h}if(e&&!o){let u;n[10]===Symbol.for("react.memo_cache_sentinel")?(u=a.jsx(Sh,{}),n[10]=u):u=n[10];let d;n[11]!==e.version?(d=a.jsxs(_n,{children:["Cogpit v",e.version," is available"]}),n[11]=e.version,n[12]=d):d=n[12];let f;n[13]!==e.platform?(f=e.platform!=="mac"&&a.jsx(Qt,{children:"Update through your package manager."}),n[13]=e.platform,n[14]=f):f=n[14];let m;n[15]!==e.platform||n[16]!==e.url?(m=e.platform==="mac"&&a.jsxs(ee,{variant:"outline",size:"xs",render:a.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer"}),nativeButton:!1,children:[a.jsx(K7,{"data-icon":"inline-start"}),"Download"]}),n[15]=e.platform,n[16]=e.url,n[17]=m):m=n[17];let p;n[18]!==e.version?(p=a.jsx(ee,{variant:"ghost",size:"xs",onClick:()=>{var x;i(!0),(x=window.electronUpdater)==null||x.dismissVersion(e.version)},className:"whitespace-nowrap text-muted-foreground",children:"Don't show again"}),n[18]=e.version,n[19]=p):p=n[19];let h;n[20]!==m||n[21]!==p?(h=a.jsxs(uo,{className:"static col-start-3 row-span-2 row-start-1 flex items-center gap-2 self-center",children:[m,p]}),n[20]=m,n[21]=p,n[22]=h):h=n[22];let g;return n[23]!==d||n[24]!==f||n[25]!==h?(g=a.jsxs(Jt,{className:"grid-cols-[auto_minmax(0,1fr)_auto] rounded-none border-x-0 border-t-0 border-info/30 bg-info/10 px-4 py-2 pr-4 text-info has-data-[slot=alert-action]:pr-4",children:[u,d,f,h]}),n[23]=d,n[24]=f,n[25]=h,n[26]=g):g=n[26],g}return null}const Sl=null,{min:Mo,max:_s,abs:dy,floor:SF}=Math,HN=(n,e,t)=>Mo(t,_s(e,n)),KN=n=>[...n].sort((e,t)=>e-t),GN=typeof queueMicrotask=="function"?queueMicrotask:n=>{Promise.resolve().then(n)},Yh=()=>{let n;return[new Promise(e=>{n=e}),n]},ZN=n=>{let e;return()=>(n&&(e=n(),n=void 0),e)},Za=(n,e,t)=>{const s=t?"unshift":"push";for(let r=0;r<e;r++)n[s](-1);return n},YN=(n,e)=>{const t=n.t[e];return t===-1?n.o:t},kF=(n,e,t)=>{const s=n.t[e]===-1;return n.t[e]=t,n.i=Mo(e,n.i),s},ju=(n,e)=>{if(!n.l)return 0;if(n.i>=e)return n.u[e];n.i<0&&(n.u[0]=0,n.i=0);let t=n.i,s=n.u[t];for(;t<e;)s+=YN(n,t),n.u[++t]=s;return n.i=e,s},ti=(n,e,t=0,s=n.l-1)=>{let r=t;for(;t<=s;){const o=SF((t+s)/2);ju(n,o)<=e?(r=o,t=o+1):s=o-1}return HN(r,0,n.l-1)},fy=(n,e,t)=>{const s=e-n.l;return n.i=t?-1:Mo(e-1,n.i),n.l=e,s>0?(Za(n.u,s),Za(n.t,s,t),n.o*s):(n.u.splice(s),(t?n.t.splice(0,-s):n.t.splice(s)).reduce((r,o)=>r-(o===-1?n.o:o),0))},jF=typeof window<"u",NF=n=>n.documentElement,CF=n=>n.ownerDocument,_F=n=>n.defaultView,XN=ZN(()=>!!/iP(hone|od|ad)/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>0),EF=ZN(()=>"scrollBehavior"in NF(document).style),TF=n=>_s(n.h(),n.p()),AF=(n,e=40,t=0,s,r=!1)=>{let o=!!t,i=1,l=0,c=0,u=0,d=0,f=0,m=0,p=0,h=0,g=Sl,x=[0,o?_s(t-1,0):-1],b=0,y=!1;const v=((P,I,$)=>({o:I,t:$?Za($.slice(0,Mo(P,$.length)),_s(0,P-$.length)):Za([],P),l:P,i:-1,u:Za([],P+1)}))(n,s?s[1]:e,s&&s[0]),k=new Set,j=()=>u-c,_=()=>j()+f+d,N=(P,I)=>(($,O,M,R)=>{if(R=Mo(R,$.l-1),ju($,R)<=O){const z=ti($,M,R);return[ti($,O,R,z),z]}{const z=ti($,O,void 0,R);return[z,ti($,M,z)]}})(v,P,I,x[0]),S=()=>ju(v,v.l),C=(P,I)=>{const $=ju(v,P)-f;return I?S()-$-E(P):$},E=P=>YN(v,P),T=(P,I=-1)=>v.t[P]===I,A=P=>{P&&(XN()&&p!==0||g&&h===1?f+=P:d+=P)};return{v:()=>{k.clear()},m:()=>i,_:()=>(P=>[P.t.slice(),P.o])(v),S:(P=200)=>{if(!y||o)return x;let I,$;if(m)[I,$]=x;else{let O=_s(0,_()),M=O+l;r||(P=_s(0,P),p!==1&&(O-=P),p!==2&&(M+=P)),[I,$]=x=N(_s(0,O),_s(0,M)),g&&(I=Mo(I,g[0]),$=_s($,g[1]))}return[_s(I,0),Mo($,v.l-1)]},$:P=>ti(v,P-c),I:T,k:C,R:E,T:()=>v.l,C:()=>u,M:()=>p!==0,p:()=>l,O:()=>c,h:S,H:()=>(m=d,d=0,[m,h===2]),W:(P,I)=>{const $=[P,I];return k.add($),()=>{k.delete($)}},B:(P,I)=>{let $,O,M=0;switch(P){case 1:{if(I===u&&h===0)break;const R=m;m=0;const z=I-u,W=dy(z);R&&W<dy(R)+1||h!==0||(p=z<0?2:1),o&&(o=!1),u=I,M=4;const D=j();D>=-l&&D<=S()&&(M+=1,O=W>l);break}case 2:M=8,p!==0&&($=!0,M+=1),p=0,h=0,g=Sl;break;case 3:{const R=I.filter(([z,W])=>!T(z,W));if(!R.length)break;A(R.reduce((z,[W,D])=>{let L;if(h===2)L=!0;else if(g&&h===1)L=W<g[0];else{const U=j(),F=C(W),B=E(W);L=p!==1&&h===0?F+B<=U:F<U&&F+B<U+l}return L&&(z+=D-E(W)),z},0));for(const[z,W]of R){const D=E(z),L=kF(v,z,W);r&&(b+=L?W:W-D)}r&&l&&b>l&&(A(((z,W)=>{let D=0;const L=[];z.t.forEach((K,Z)=>{K!==-1&&(L.push(K),Z<W&&D++)}),z.i=-1;const U=KN(L),F=U.length,B=F/2|0,V=F%2==0?(U[B-1]+U[B])/2:U[B],H=z.o;return((z.o=V)-H)*_s(W-D,0)})(v,ti(v,_()))),r=!1),M=3,O=!0;break}case 4:l!==I&&(l||(y=O=!0),l=I,M=3);break;case 5:I[1]?(A(fy(v,I[0],!0)),h=2,M=1):(fy(v,I[0]),M=1);break;case 6:c=I;break;case 7:h=1;break;case 8:g=N(I,I+l),M=1}M&&(i=1+(2147483647&i),$&&f&&(d+=f,f=0),k.forEach(([R,z])=>{M&R&&z(O)}))}}},gx=setTimeout,bm=(n,e)=>e?-n:n,PF=(n,e,t,s,r,o)=>{const i=Date.now;let l=0,c=!1,u=!1,d=!1,f=!1;const m=(()=>{let b;const y=()=>{b!=Sl&&clearTimeout(b)},v=()=>{y(),b=gx(()=>{b=Sl,(()=>{if(c||u)return c=!1,void m();d=!1,n.B(2)})()},150)};return v.J=y,v})(),p=()=>{l=i(),d&&(f=!0),n.B(1,s()),m()},h=b=>{if(c||!n.M()||b.ctrlKey)return;const y=i()-l;150>y&&50<y&&(t?b.deltaX:b.deltaY)&&(c=!0)},g=()=>{u=!0,d=f=!1},x=()=>{u=!1,XN()&&(d=!0)};return e.addEventListener("scroll",p),e.addEventListener("wheel",h,{passive:!0}),e.addEventListener("touchstart",g,{passive:!0}),e.addEventListener("touchend",x,{passive:!0}),{A:()=>{e.removeEventListener("scroll",p),e.removeEventListener("wheel",h),e.removeEventListener("touchstart",g),e.removeEventListener("touchend",x),m.J()},L:()=>{const[b,y]=n.H();b&&(r(b,y,f),f=!1,y&&n.p()>n.h()&&n.B(1,s()))}}},IF=(n,e,t)=>{let s;return[async(r,o)=>{if(!await e())return;s&&s();const i=()=>{const[l,c]=Yh();return s=()=>{c(!1)},n.p()&&gx(s,150),[l,n.W(2,()=>{c(!0)})]};if(o&&EF())n.B(8,r()),GN(async()=>{for(;;){let l=!0;for(let[d,f]=n.S();d<=f;d++)if(n.I(d)){l=!1;break}if(l)break;const[c,u]=i();try{if(!await c)return}finally{u()}}n.B(7),t(r(),o)});else for(;;){const[l,c]=i();try{if(n.B(7),t(r()),!await l)return}finally{c()}}},()=>{s&&s()}]},$F=(n,e)=>{let t,s,r=Yh(),o=!1;const i=e?"scrollLeft":"scrollTop",l=e?"overflowX":"overflowY",[c,u]=IF(n,()=>r[0],(d,f)=>{d=bm(d,o),f?t.scrollTo({[e?"left":"top"]:d,behavior:"smooth"}):t[i]=d});return{N(d,f){t=f,e&&(o=getComputedStyle(f).direction==="rtl"),s=PF(n,f,e,()=>bm(f[i],o),(m,p,h)=>{if(h){const g=f.style,x=g[l];g[l]="hidden",gx(()=>{g[l]=x})}f[i]=bm(n.C()+m,o),p&&u()}),r[1](!0)},v(){s&&s.A(),r[1](!1),r=Yh()},P:()=>o,V(d){c(()=>d)},X(d){d+=n.C(),c(()=>d)},Y(d,{align:f,smooth:m,offset:p=0}={}){if(d=HN(d,0,n.T()-1),f==="nearest"){const h=n.k(d),g=n.C();if(h<g)f="start";else{if(!(h+n.R(d)>g+n.p()))return;f="end"}}c(()=>p+n.O()+n.k(d)+(f==="end"?n.R(d)-n.p():f==="center"?(n.R(d)-n.p())/2:0),m)},q:()=>{s&&s.L()}}},RF=n=>{let e;return{j(t){(e||(e=new(_F(CF(t))).ResizeObserver(n))).observe(t)},D(t){e.unobserve(t)},A(){e&&e.disconnect()}}},OF=(n,e)=>{let t;const s=e?"width":"height",r=new WeakMap,o=RF(i=>{const l=[];for(const{target:c,contentRect:u}of i)if(c.offsetParent)if(c===t)n.B(4,u[s]);else{const d=r.get(c);d!=Sl&&l.push([d,u[s]])}l.length&&n.B(3,l)});return{G(i){o.j(t=i)},U:(i,l)=>(r.set(i,l),o.j(i),()=>{r.delete(i),o.D(i)}),v:o.A}},ed=jF?w.useLayoutEffect:w.useEffect,os="current",JN=(n,e)=>{if(Array.isArray(n))for(const t of n)JN(t,e);else n==null||typeof n=="boolean"||e.push(n)},LF=(n,e)=>{const t=n.key;return t??"_"+e},MF=n=>{const e=w.useRef(null);return e[os]||(e[os]=n())},my=n=>{const e=w.useRef(n);return ed(()=>{e[os]=n},[n]),e},zF=w.memo(({Z:n,ee:e,te:t,oe:s,ne:r,re:o,se:i,ie:l})=>{const c=w.useRef(null);ed(()=>e(c[os],t),[t]);const u=w.useMemo(()=>{const d={contain:"layout style",position:r&&l?void 0:"absolute",[i?"height":"width"]:"100%",[i?"top":"left"]:0,[i?"left":"top"]:s,visibility:!r||l?void 0:"hidden"};return i&&(d.display="inline-flex"),d},[s,r,l,i]);return a.jsx(o,typeof o=="string"?{ref:c,style:u,children:n}:{ref:c,style:u,index:t,children:n})}),DF=(n,e)=>w.useMemo(()=>{if(typeof n=="function")return[s=>n(e[s],s),e.length];const t=(s=>{const r=[];return JN(s,r),r})(n);return[s=>t[s],t.length]},[n,e]),FF=w.forwardRef(({children:n,data:e,bufferSize:t,itemSize:s,shift:r,horizontal:o,keepMounted:i,cache:l,startMargin:c=0,ssrCount:u,as:d="div",item:f="div",scrollRef:m,onScroll:p,onScrollEnd:h},g)=>{const[x,b]=DF(n,e),y=w.useRef(null),v=w.useRef(!!u),k=my(p),j=my(h),[_,N,S,C]=MF(()=>{const M=!!o,R=AF(b,s,u,l,!s);return[R,OF(R,M),$F(R,M),M]});b!==_.T()&&_.B(5,[b,r]),c!==_.O()&&_.B(6,c);const[E,T]=w.useReducer(_.m,void 0,_.m),A=_.M(),P=_.h(),I=S.P(),$=[],O=M=>{const R=x(M);return a.jsx(zF,{ee:N.U,te:M,oe:_.k(M,I),ne:_.I(M),re:f,Z:R,se:C,ie:v[os]},LF(R,M))};if(ed(()=>{v[os]=!1,_.W(1,z=>{z?jA.flushSync(T):T()}),_.W(4,()=>{k[os]&&k[os](_.C())}),_.W(8,()=>{j[os]&&j[os]()});const M=y[os],R=z=>{N.G(z),S.N(M,z)};return m?GN(()=>{m[os]&&R(m[os])}):R(M.parentElement),()=>{_.v(),N.v(),S.v()}},[]),ed(()=>{S.q()},[E]),w.useImperativeHandle(g,()=>({get cache(){return _._()},get scrollOffset(){return _.C()},get scrollSize(){return TF(_)},get viewportSize(){return _.p()},findItemIndex:_.$,getItemOffset:_.k,getItemSize:_.R,scrollToIndex:S.Y,scrollTo:S.V,scrollBy:S.X}),[]),i){const M=new Set(i);for(let[R,z]=_.S(t);R<=z;R++)M.add(R);KN([...M]).forEach(R=>{$.push(O(R))})}else for(let[M,R]=_.S(t);M<=R;M++)$.push(O(M));return a.jsx(d,{ref:y,style:{contain:"size style",overflowAnchor:"none",flex:"none",position:"relative",width:C?P:"100%",height:C?"100%":P,pointerEvents:A?"none":void 0},children:$})});function UF(n){const e=q.c(15),{redoTurnCount:t,onRedoAll:s}=n;if(t<=0)return null;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(r1,{className:"size-4","data-icon":"inline-start"}),e[0]=r):r=e[0];let o;e[1]!==t?(o=a.jsx("span",{className:"font-mono",children:t}),e[1]=t,e[2]=o):o=e[2];const i=t!==1?"s":"";let l;e[3]!==i?(l=a.jsxs("span",{children:["turn",i," archived"]}),e[3]=i,e[4]=l):l=e[4];let c;e[5]!==o||e[6]!==l?(c=a.jsxs("div",{className:"flex items-center gap-1.5 text-sm text-muted-foreground",children:[r,o,l]}),e[5]=o,e[6]=l,e[7]=c):c=e[7];let u;e[8]===Symbol.for("react.memo_cache_sentinel")?(u=a.jsx(Gt,{orientation:"vertical",className:"h-4"}),e[8]=u):u=e[8];let d;e[9]===Symbol.for("react.memo_cache_sentinel")?(d=a.jsx(G7,{"data-icon":"inline-start"}),e[9]=d):d=e[9];let f;e[10]!==s?(f=a.jsxs(ee,{variant:"default",size:"sm",onClick:s,children:[d,"Redo all"]}),e[10]=s,e[11]=f):f=e[11];let m;return e[12]!==c||e[13]!==f?(m=a.jsxs("div",{className:"sticky bottom-0 flex items-center justify-center gap-3 border-t border-border bg-popover px-4 py-2",role:"status",children:[c,u,f]}),e[12]=c,e[13]=f,e[14]=m):m=e[14],m}const py=new Map;function BF(n){let e=py.get(n);if(!e){const t=new Map;e={observer:new IntersectionObserver(r=>{var o;for(const i of r)(o=t.get(i.target))==null||o(i.isIntersecting)},{rootMargin:n}),callbacks:t},py.set(n,e)}return e}function QN(n){const e=q.c(5),t="100%",s=w.useRef(null),[r,o]=w.useState(!0);let i,l;e[0]!==t?(i=()=>{const u=s.current;if(!u)return;const{observer:d,callbacks:f}=BF(t);return f.set(u,o),d.observe(u),()=>{d.unobserve(u),f.delete(u)}},l=[t],e[0]=t,e[1]=i,e[2]=l):(i=e[1],l=e[2]),w.useEffect(i,l);let c;return e[3]!==r?(c={ref:s,isNear:r},e[3]=r,e[4]=c):c=e[4],c}function eC(){return w.useSyncExternalStore(Fd,fl,fl)}function tC(){return w.useSyncExternalStore(Fd,Gb,Gb)}function td(n){if(typeof n!="string"||n.length===0)return Number.NEGATIVE_INFINITY;const e=Date.parse(n);return Number.isFinite(e)?e:Number.NEGATIVE_INFINITY}function hy(n){const e=td(n.lastActivityAt);return e!==Number.NEGATIVE_INFINITY?e:td(n.lastModified)}function gy(n,e){return n===e?0:e-n}function xy(n){return[n.dirName??"",n.fileName??"",n.sessionId??""].join("/")}function WF(n,e){const t=gy(hy(n),hy(e));if(t!==0)return t;const s=gy(td(n.lastModified),td(e.lastModified));return s!==0?s:xy(n).localeCompare(xy(e))}function oc(n){return[...n].sort(WF)}function nd(n,e){return e||Is(sC(n),50)}const qF="Untitled session";function nC(n,e){const t=n.teamName&&n.agentName?n.agentName:"";return e||n.aiTitle||t||n.lastUserMessage||n.firstUserMessage||n.slug||void 0}function sC(n,e){return nC(n,e)??qF}function VF(n,e){return nC(n,e)===void 0}function HF(n){const e=new Set(n.map(r=>r.sessionId)),t=new Map,s=[];for(const r of n){const o=r.teamLeadSessionId;if(o&&o!==r.sessionId&&e.has(o)){const i=t.get(o);i?i.push(r):t.set(o,[r])}else s.push(r)}return{topLevelSessions:s,teammatesByLead:t}}function KF(n){return n.find(e=>!nr(e.cwd??ls(e.dirName)))??n[0]}const GF="Unknown project";function xx(n){const e=nr(n);return ql(e?e.parentPath:n,2)||GF}function bx(n){return xx(n.cwd||ls(n.dirName))}function vx(n){return n==="inactive"?"Archived after two weeks without activity":"Archived"}function ZF(n,e){return e?n:n.filter(t=>!t.archived)}function YF(n){const e=oc(n),t=new Map;for(const s of e){const r=bx(s),o=t.get(r);o?o.push(s):t.set(r,[s])}return t}function yx(n,e){return n.isActive?!0:e?n.agentStatus!=="completed":!1}const wx=new Set(["thinking","tool_use","processing","compacting","awaiting_agents"]),XF=12e4;function JF(n,e=Date.now()){const t=Date.parse(n.lastActivityAt||n.lastModified);return Number.isFinite(t)&&e-t<XF}function rC(n,e,t=Date.now()){return yx(n,e.get(n.sessionId))?!0:n.agentStatus==="completed"||!n.agentStatus?!1:JF(n,t)}function QF(n,e,t=Date.now()){return n.some(s=>rC(s,e,t))}const eU="cogpit:session-list-cache",tU=10080*60*1e3,nU=24,kl={projects:"projects",activeSessions:"active-sessions",runningProcesses:"running-processes"};function oC(n,e){return e===null?n:`${n}:${e}`}function Nu(n){return oC(kl.activeSessions,n)}const sd=new Map;function sU(){return{version:1,entries:{}}}function uf(){return Vu()==="account"&&xs()===null?null:gn(eU)}function Sx(n){const e=sd.get(n);if(e)return e;let t=sU();try{const s=localStorage.getItem(n);if(s){const r=JSON.parse(s);r.version===1&&r.entries&&typeof r.entries=="object"&&(t=r)}}catch{}return sd.set(n,t),t}function iC(n,e){sd.set(n,e);try{localStorage.setItem(n,JSON.stringify(e))}catch{}}function aC(n){const e=uf(),t=e===null?void 0:Sx(e).entries[n];if(!(!t||Date.now()-t.savedAt>tU))return t.value}function lC(n,e){const t=uf();if(t===null)return;const s={...Sx(t).entries,[n]:{savedAt:Date.now(),value:e}},r=Object.entries(s).sort(([,o],[,i])=>i.savedAt-o.savedAt);iC(t,{version:1,entries:Object.fromEntries(r.slice(0,nU))})}function cC(n){return M1(n)&&Array.isArray(n.sessions)&&typeof n.total=="number"}function by(n,e){return n.filter(t=>!(M1(t)&&t.sessionId===e))}function rU(n,e){if(Array.isArray(n)){const r=by(n,e);return r.length===n.length?n:r}if(!cC(n))return n;const t=by(n.sessions,e),s=n.sessions.length-t.length;return s===0?n:{sessions:t,total:n.total-s}}function Ci(n){const e=aC(n);return Array.isArray(e)?e:void 0}function Ya(n,e){lC(n,e)}function uC(n,e){return oC(`sessions:${n}`,e)}function oU(n,e){const t=aC(uC(n,e));return cC(t)?t:void 0}function iU(n,e,t){lC(uC(n,e),t)}function aU(n){const e=uf();if(e===null)return;const t=Sx(e);let s=!1;const r={};for(const[o,i]of Object.entries(t.entries)){const l=rU(i.value,n);s||(s=l!==i.value),r[o]=l===i.value?i:{...i,value:l}}s&&iC(e,{version:1,entries:r})}function lU(){const n=uf();if(n!==null){sd.delete(n);try{localStorage.removeItem(n)}catch{}}}const cU=Object.freeze({key:null,query:Object.freeze({})});function uU(){return()=>{}}function dU(){return null}function df(){const n=q.c(7),{sessionListFilter:e}=ur();let t;n[0]!==e?(t=c=>(e==null?void 0:e.subscribe(c))??uU(),n[0]=e,n[1]=t):t=n[1];const s=t;let r;n[2]!==e?(r=e?()=>e.getKey():dU,n[2]=e,n[3]=r):r=n[3];const o=r,i=w.useSyncExternalStore(s,o,o);let l;return n[4]!==i||n[5]!==e?(l=e&&i!==null?{key:i,query:e.getQuery()}:cU,n[4]=i,n[5]=e,n[6]=l):l=n[6],l}function Xa(n,e,t={}){const s=new URLSearchParams(t);for(const[o,i]of Object.entries(e.query))s.set(o,i);const r=s.toString();return r?`${n}?${r}`:n}function ff(n,e){return Xa("/api/active-sessions",e,n)}async function Zs(n){try{const e=await(n==null?void 0:n.json());return e&&typeof e=="object"?e:null}catch{return null}}async function Ja(n,e){const t=await Zs(n);return typeof(t==null?void 0:t.error)=="string"&&t.error?t.error:e}const fU=["view","interact","own"],mU=1e3,pU=3e4,rd=new Map,dC=new Set,Cu=new Map,Bo=new Set,Xh=new Set;let vy=0;function No(n){return`${gn("session-access")}::${n}`}function ia(n){for(const e of n)e()}function ic(n,e,t){e!=="none"&&dC.add(n);const s=rd.get(n);return s&&s.ticket>t?!1:(rd.set(n,{level:e,ticket:t}),(s==null?void 0:s.level)!==e)}function hU(n){return fU.includes(n==null?void 0:n.level)}function gU(n){var e;return(e=rd.get(No(n)))==null?void 0:e.level}function xU(n){return dC.has(No(n))}function bU(n){return Bo.add(n),()=>Bo.delete(n)}function Pr(){return vy+=1,vy}function Mi(n,e){let t=!1;for(const{sessionId:s,access:r}of n)r&&(t=ic(No(s),r.level,e)||t);t&&ia(Bo)}async function vU(n){let e;try{e=await Re(`${HI}${encodeURIComponent(n)}`)}catch{return null}if(e.status===404&&G3(e))return"none";if(!e.ok)return null;const t=await Zs(e);return hU(t)?t.level:null}async function yU(n,e){var r;const t=Pr(),s=await vU(n);return s===null?null:(ic(e,s,t)&&ia(Bo),((r=rd.get(e))==null?void 0:r.level)??null)}function fC(n){const e=No(n),t=yU(n,e).finally(()=>{Cu.get(e)===t&&Cu.delete(e)});return Cu.set(e,t),t}function yy(n){return Cu.get(No(n))??fC(n)}function zge(n,e,t){ic(No(n),e,t)&&ia(Bo)}function wU(n){ic(No(n),"none",Pr())&&ia(Bo)}function mC(n){const{enforcesSessionAccess:e,user:t}=fl();!e||!t||ic(No(n),"own",Pr())&&ia(Bo)}function pC(){ia(Xh)}function mf(n){return Xh.add(n),()=>Xh.delete(n)}function SU(n){let e=!1,t=0,s=0,r;async function o(l){const c=++s;clearTimeout(r);const u=await l();if(e||c!==s)return;if(u){t=0;return}const d=Math.min(mU*2**t,pU);t+=1,r=setTimeout(()=>void o(()=>yy(n)),d)}o(()=>yy(n));const i=Z3(()=>{t=0,o(()=>fC(n))},n);return()=>{e=!0,clearTimeout(r),i()}}const kU=2e4;function jU(n){const e=new Map;for(const t of n){if(!t.sessionId)continue;const s=e.get(t.sessionId);(!s||t.memMB>s.memMB)&&e.set(t.sessionId,t)}return e}function wy(n,e){let t=null;for(const s of e){const r=!!s.archived;n.has(s.sessionId)!==r&&(t??(t=new Set(n)),r?t.add(s.sessionId):t.delete(s.sessionId))}return t??n}const hC=w.createContext(null);function NU({children:n}){const[e]=w.useState(fn),t=df(),s=tC()!==null,r=Nu(t.key),[o,i]=w.useState(()=>Ci(r)??[]),[l,c]=w.useState(()=>Ci(kl.runningProcesses)??[]),[u,d]=w.useState(!1),[f,m]=w.useState(null),[p,h]=w.useState(new Set),[g,x]=oa(gn("live-sessions-show-archived"),!1),b=g===!0,[y,v]=w.useState(!1),k=b||y,[j,_]=w.useState(0),N=w.useRef(wy(new Set,o)),[S,C]=w.useState(N.current),E=w.useCallback(H=>{N.current=H,C(H)},[]),T=w.useRef(null),A=w.useRef(!1),P=w.useRef(o),I=w.useRef(r),$=w.useRef(null),O=w.useRef(!1);w.useEffect(()=>(O.current=!0,()=>{var H;O.current=!1,(H=$.current)==null||H.abort(),$.current=null}),[]);const M=w.useCallback(async()=>{var Y;if(s||!O.current||fn()!==e)return;(Y=$.current)==null||Y.abort();const H=new AbortController;$.current=H;const K=()=>O.current&&!H.signal.aborted&&$.current===H&&fn()===e;d(!0);const Z=Pr();try{const[X,se]=await Promise.all([Re(ff(k?{archived:"include"}:{},t),{signal:H.signal}),Re("/api/running-processes",{signal:H.signal})]);if(!K())return;if(!X.ok||!se.ok)throw new Error("Failed to fetch live data");const[Q,te]=await Promise.all([X.json(),se.json()]);if(!K())return;const J=Array.isArray(Q)?Q:[],ne=Array.isArray(te)?te:[];Mi(J,Z),A.current&&(A.current=!1,T.current=null),P.current=J,i(J),c(ne),E(wy(N.current,J)),_(Number(X.headers.get("X-Cogpit-Archived-Count"))||0),Ya(r,J),Ya(kl.runningProcesses,ne),m(null)}catch(X){if(!K())return;m(X instanceof Error?X.message:"Failed to load data")}finally{K()&&d(!1),$.current===H&&($.current=null)}},[s,e,k,t,r,E]),R=w.useCallback(()=>{M()},[M]);w.useEffect(()=>{if(I.current===r)return;I.current=r,A.current=!0;const H=Ci(r)??[];P.current=H,i(H)},[r]),w.useEffect(()=>{R()},[R]),w.useEffect(()=>mf(()=>{A.current=!0,R()}),[R]);const z=w.useMemo(()=>jU(l),[l]),W=w.useMemo(()=>QF(o,z),[o,z]);w.useEffect(()=>(window.addEventListener("focus",R),()=>window.removeEventListener("focus",R)),[R]),w.useEffect(()=>{if(!W)return;const H=setInterval(()=>{document.visibilityState==="visible"&&R()},kU);return()=>clearInterval(H)},[W,R]),w.useEffect(()=>{if(o.length===0||A.current)return;const H=T.current,K=new Map;for(const Z of o)Z.agentStatus&&z.has(Z.sessionId)&&K.set(Z.sessionId,Z.agentStatus);H!==null&&h(Z=>{let Y=null;for(const[X,se]of K)se==="completed"&&H.has(X)&&H.get(X)!=="completed"&&(Y??(Y=new Set(Z)),Y.add(X));for(const X of Z)K.get(X)!=="completed"&&(Y??(Y=new Set(Z)),Y.delete(X));return Y??Z}),T.current=K},[o,z]);const D=w.useCallback(H=>{h(K=>{if(!K.has(H))return K;const Z=new Set(K);return Z.delete(H),Z})},[]),L=w.useCallback(H=>{P.current=H,i(H),fn()===e&&Ya(r,H)},[e,r]),U=w.useCallback(H=>{L(P.current.filter(K=>K.sessionId!==H))},[L]),F=w.useCallback((H,K)=>{const Z=N.current,Y=new Set(H.filter(Q=>Z.has(Q)!==K));if(Y.size===0)return;const X=new Set(Z);for(const Q of Y)K?X.add(Q):X.delete(Q);E(X),L(P.current.map(Q=>{if(!Y.has(Q.sessionId))return Q;if(K)return{...Q,archived:!0,archivedReason:"manual"};const{archived:te,archivedReason:J,...ne}=Q;return ne}));const se=K?Y.size:-Y.size;_(Q=>Math.max(0,Q+se))},[E,L]),B=w.useCallback(H=>S.has(H),[S]),V=w.useMemo(()=>({sessions:o,processes:l,procBySession:z,newlyCompleted:p,loading:u,error:f,refresh:R,removeSession:U,acknowledgeCompleted:D,showArchived:b,setShowArchived:x,setSearchActive:v,archivedCount:j,isArchived:B,setArchived:F}),[o,l,z,p,u,f,R,U,D,b,x,j,B,F]);return a.jsx(hC.Provider,{value:V,children:n})}function kx(){const n=ac();if(!n)throw new Error("useSessionInventory must be used within a SessionInventoryProvider");return n}function ac(){return w.useContext(hC)}const Sy=[20,50,80,110,140,170,200,230,260,290,320,350];function CU(n){let e=2166136261;for(let t=0;t<n.length;t++)e^=n.charCodeAt(t),e=Math.imul(e,16777619);return Sy[(e>>>0)%Sy.length]}function vm(n){const e=[];let t=!1;for(const s of n.split(`
|
|
91
|
+
`)){if(/^\s*(```|~~~)/.test(s)){t=!t;continue}let r=s;if(!t){if(r=r.replace(/^\s{0,3}#{1,6}\s+/,"").replace(/^\s*>\s?/,"").replace(/^\s*(?:[-*+]|\d+[.)])\s+/,""),/^\s*(?:[-*_]\s*){3,}$/.test(r))continue;r=r.replace(/!\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[([^\]]*)\]\[[^\]]*\]/g,"$1").replace(/(\*\*|__|~~)(.*?)\1/g,"$2").replace(new RegExp("(?<![\\w*])[*_](?=\\S)([^*_]+?)(?<=\\S)[*_](?![\\w*])","g"),"$1").replace(/`+/g,"")}const o=r.trim();o&&e.push(o)}return e.join(" ")}function _U(n){const e=n.split(`
|
|
92
|
+
`);let t=0;for(;t<e.length&&e[t].trim()==="";)t++;const s=vm(e[t]??"");return s?{subject:s,preview:vm(e.slice(t+1).join(`
|
|
93
|
+
`))}:{subject:vm(n),preview:""}}function Jh(n){if(!n)return null;const e=new Date(n).getTime();return Number.isNaN(e)?null:e}function EU(n,e){return n===null||e===null||e<n?null:e-n}function TU(n){const e=Jh(n);return e===null?null:new Date(e).toLocaleTimeString()}function AU(n){var s;const e=(s=ac())==null?void 0:s.sessions;let t;e:{if(!n||!e){t=null;break e}const r=e.filter(i=>i.agentName===n);if(r.length!==1){t=null;break e}const o=r[0].agentStatus;if(!o){t=null;break e}t=wx.has(o)?"working":"idle"}return t}const PU=w.memo(function(e){const t=q.c(48),{sender:s,body:r,timestamp:o,reply:i,isLive:l}=e,[c,u]=w.useState(!1);let d;t[0]!==r?(d=IM(r),t[0]=r,t[1]=d):d=t[1];const f=d;let m;t[2]!==f?(m=_U(f),t[2]=f,t[3]=m):m=t[3];const{subject:p,preview:h}=m;let g;t[4]!==o?(g=TU(o),t[4]=o,t[5]=g):g=t[5];const x=g,b=AU(s);let y;t[6]!==f?(y=MM(f),t[6]=f,t[7]=y):y=t[7];const v=y,k=v&&!i,j=Jh(o),_=i?EU(j,Jh(i.timestamp)):null,N=!i&&l===!0,S=!!i||v;Sj(N&&S);const C=!0;let E;t[8]!==s?(E=CU(s),t[8]=s,t[9]=E):E=t[9];const T=String(E);let A;t[10]!==T?(A={"--agent-hue":T},t[10]=T,t[11]=A):A=t[11];const P=A,I="my-2 rounded-lg border border-l-[3px] border-border bg-card px-3 py-2 [border-left-color:oklch(0.52_0.16_var(--agent-hue))] dark:[border-left-color:oklch(0.74_0.14_var(--agent-hue))]";let $;t[12]===Symbol.for("react.memo_cache_sentinel")?($=a.jsx(Z7,{className:"size-3.5 shrink-0 text-[oklch(0.52_0.16_var(--agent-hue))] dark:text-[oklch(0.74_0.14_var(--agent-hue))]","data-icon":"inline-start"}),t[12]=$):$=t[12];let O;t[13]!==s?(O=a.jsx("span",{className:"truncate font-mono text-xs font-medium text-[oklch(0.52_0.16_var(--agent-hue))] dark:text-[oklch(0.74_0.14_var(--agent-hue))]",children:s}),t[13]=s,t[14]=O):O=t[14];let M;t[15]!==b||t[16]!==s?(M=b&&a.jsx("span",{"data-testid":"agent-liveness","data-live":b,title:b==="working"?`${s} is working now`:`${s} is idle`,className:`inline-flex size-1.5 shrink-0 rounded-full ${b==="working"?"animate-pulse bg-warning":"bg-success"}`}),t[15]=b,t[16]=s,t[17]=M):M=t[17];let R;t[18]!==O||t[19]!==M?(R=a.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[$,O,M]}),t[18]=O,t[19]=M,t[20]=R):R=t[20];let z;t[21]!==k?(z=k&&a.jsx(Ue,{variant:"outline",className:"h-4 border-warning/30 bg-warning/10 px-1.5 text-[10px] tracking-wide text-warning uppercase",children:"Needs you"}),t[21]=k,t[22]=z):z=t[22];let W;t[23]!==x?(W=x&&a.jsx("span",{className:"text-xs text-muted-foreground",children:x}),t[23]=x,t[24]=W):W=t[24];let D;t[25]!==z||t[26]!==W?(D=a.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:[z,W]}),t[25]=z,t[26]=W,t[27]=D):D=t[27];let L;t[28]!==R||t[29]!==D?(L=a.jsxs("div",{className:"flex items-center gap-2",children:[R,D]}),t[28]=R,t[29]=D,t[30]=L):L=t[30];let U;t[31]!==f||t[32]!==c||t[33]!==h||t[34]!==p?(U=c?a.jsx("div",{"data-testid":"agent-message-body",className:"mt-1.5 max-w-none overflow-hidden break-words text-sm leading-relaxed",children:a.jsx(cr,{components:hr,remarkPlugins:gr,children:f})}):a.jsxs(a.Fragment,{children:[a.jsx("p",{"data-testid":"agent-message-subject",className:"mt-1 line-clamp-2 break-words text-sm font-medium text-foreground",children:p}),h&&a.jsx("p",{"data-testid":"agent-message-preview",className:"mt-0.5 line-clamp-2 break-words text-xs leading-relaxed text-muted-foreground",children:h})]}),t[31]=f,t[32]=c,t[33]=h,t[34]=p,t[35]=U):U=t[35];const F="mt-1.5 flex items-center justify-end gap-2",B=S&&a.jsx("p",{"data-testid":"agent-message-state",className:`min-w-0 flex-1 truncate text-xs ${N?"text-warning":"text-muted-foreground"}`,children:i?a.jsxs(a.Fragment,{children:[_===null?"You replied":`You replied ${sr(_)} later`,i.summary&&` · "${i.summary}"`]}):N?j===null?"Awaiting your reply":`Awaiting your reply · ${sr(Math.max(0,Date.now()-j))}`:"Never answered"});let V;t[36]===Symbol.for("react.memo_cache_sentinel")?(V=()=>u(IU),t[36]=V):V=t[36];let H;t[37]!==f||t[38]!==c?(H=a.jsx(ee,{type:"button",variant:"ghost",size:"xs",onClick:V,className:"-mr-2 text-muted-foreground",children:c?a.jsxs(a.Fragment,{children:[a.jsx(Ot,{"data-icon":"inline-start"})," Collapse"]}):a.jsxs(a.Fragment,{children:[a.jsx(ot,{"data-icon":"inline-start"})," Expand ·"," ",f.length.toLocaleString("en-US")," ",f.length===1?"char":"chars"]})}),t[37]=f,t[38]=c,t[39]=H):H=t[39];let K;t[40]!==B||t[41]!==H?(K=a.jsxs("div",{className:F,children:[B,H]}),t[40]=B,t[41]=H,t[42]=K):K=t[42];let Z;return t[43]!==L||t[44]!==U||t[45]!==K||t[46]!==P?(Z=a.jsxs("div",{"data-agent-rail":C,style:P,className:I,children:[L,U,K]}),t[43]=L,t[44]=U,t[45]=K,t[46]=P,t[47]=Z):Z=t[47],Z});function IU(n){return!n}const $U=w.memo(function(e){const t=q.c(20),{text:s,model:r,effort:o,timestamp:i,compact:l}=e,c=l===void 0?!1:l;let u;t[0]!==s?(u=RN(s),t[0]=s,t[1]=u):u=t[1];const d=u,[f,m]=Ar();if(!s)return null;let p;t[2]!==c||t[3]!==f||t[4]!==m||t[5]!==o||t[6]!==r||t[7]!==s||t[8]!==i?(p=!c&&a.jsxs("div",{className:"mb-1 flex min-h-6 items-center justify-end gap-1.5",children:[r&&a.jsx("span",{className:"text-xs text-muted-foreground",children:Zo(r)}),o&&a.jsx("span",{className:"text-xs text-muted-foreground",title:`Reasoning effort: ${o}`,children:o}),(r||o)&&i&&a.jsx("span",{className:"text-xs text-muted-foreground",children:"·"}),i&&a.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(i).toLocaleTimeString()}),a.jsx(ee,{variant:"ghost",size:"icon-sm",className:"opacity-60 transition-opacity hover:opacity-100 focus-visible:opacity-100 sm:opacity-0 sm:group-hover:opacity-100",onClick:()=>m(s),"aria-label":f?"Response copied":"Copy response",title:f?"Copied":"Copy response",children:f?a.jsx(Ft,{"data-icon":"inline-start"}):a.jsx(ys,{"data-icon":"inline-start"})})]}),t[2]=c,t[3]=f,t[4]=m,t[5]=o,t[6]=r,t[7]=s,t[8]=i,t[9]=p):p=t[9];const h=c&&"leading-relaxed";let g;t[10]!==h?(g=G("overflow-hidden break-words text-sm",h),t[10]=h,t[11]=g):g=t[11];let x;t[12]!==d?(x=a.jsx(cr,{components:hr,remarkPlugins:gr,children:d}),t[12]=d,t[13]=x):x=t[13];let b;t[14]!==g||t[15]!==x?(b=a.jsx("div",{className:g,children:x}),t[14]=g,t[15]=x,t[16]=b):b=t[16];let y;return t[17]!==p||t[18]!==b?(y=a.jsxs("div",{className:"group",children:[p,b]}),t[17]=p,t[18]=b,t[19]=y):y=t[19],y}),pi=[];function RU(n){return n.map(e=>({messageId:e.messageId,parentToolUseId:e.parentToolUseId,stopped:e.stopped,...e.stopped?{stoppedAt:Date.now()}:{},blocks:e.blocks.map(t=>({...t}))}))}function OU(n,e){if(e.length===0)return n;const t=n.slice(),s=new Map,r=o=>{let i=s.get(o.messageId);if(i)return i;const l=t.findIndex(c=>c.messageId===o.messageId);return l>=0?(i={...t[l],blocks:t[l].blocks.map(c=>({...c}))},t[l]=i):(i={messageId:o.messageId,parentToolUseId:o.parentToolUseId,stopped:!1,blocks:[]},t.push(i)),s.set(o.messageId,i),i};for(const o of e){const i=r(o);if(o.event==="message_stop"){i.stopped=!0,i.stoppedAt=Date.now();continue}let l=i.blocks.find(c=>c.index===o.blockIndex);l||(l={index:o.blockIndex,blockType:o.blockType,...o.toolName?{toolName:o.toolName}:{},text:""},i.blocks.push(l)),o.delta&&(l.text+=o.delta)}return t}const ky=/"id"\s*:\s*"(msg_[A-Za-z0-9]+)"/g;function LU(n,e){if(n.length===0||e.length===0)return n;const t=new Set;for(const r of e){ky.lastIndex=0;let o;for(;(o=ky.exec(r))!==null;)t.add(o[1])}if(t.size===0)return n;const s=n.filter(r=>r.parentToolUseId!==null||!t.has(r.messageId));return s.length===n.length?n:s}function MU(n,e=1e4,t=Date.now()){if(n.length===0)return n;const s=n.filter(r=>r.parentToolUseId!==null||!(r.stopped&&r.stoppedAt!==void 0&&t-r.stoppedAt>e));return s.length===n.length?n:s}function zU(n){return n.filter(e=>e.parentToolUseId===null)}function DU(n,e){return n.filter(t=>t.parentToolUseId===e)}const gC={},xC=w.createContext(pi),bC=w.createContext(gC);function ym(n){const e=q.c(6),{value:t,agentProgress:s,children:r}=n,o=s===void 0?gC:s;let i;e[0]!==o||e[1]!==r?(i=a.jsx(bC.Provider,{value:o,children:r}),e[0]=o,e[1]=r,e[2]=i):i=e[2];let l;return e[3]!==i||e[4]!==t?(l=a.jsx(xC.Provider,{value:t,children:i}),e[3]=i,e[4]=t,e[5]=l):l=e[5],l}function jx(){return w.useContext(xC)}function FU(n){return w.useContext(bC)[n]??null}function ni(n){return function({children:t}){return a.jsx(n,{className:"mt-2 mb-1 text-xs font-semibold text-foreground first:mt-0",children:t})}}const vC={...hr,code({className:n,children:e}){return!n&&typeof e=="string"&&!e.includes(`
|
|
94
|
+
`)?a.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[0.9em] text-foreground",children:e}):a.jsx("pre",{className:"my-1.5 overflow-x-auto rounded-md border bg-muted p-2 font-mono text-xs leading-relaxed",children:a.jsx("code",{children:String(e).replace(/\n$/,"")})})},img:()=>null},UU={...vC,h1:ni("h1"),h2:ni("h2"),h3:ni("h3"),h4:ni("h4"),h5:ni("h5"),h6:ni("h6")},yC=w.memo(function(e){const t=q.c(3),{text:s,compactHeadings:r}=e,i=(r===void 0?!1:r)?UU:vC;let l;return t[0]!==i||t[1]!==s?(l=a.jsx(cr,{components:i,remarkPlugins:gr,children:s}),t[0]=i,t[1]=s,t[2]=l):l=t[2],l}),jy=400,BU=24,Nx=w.memo(function(e){const t=q.c(24),{toolUseId:s}=e,r=jx(),o=FU(s),i=w.useRef(null),[l,c]=w.useState(!0);let u,d,f;if(t[0]!==l||t[1]!==r||t[2]!==s){f=DU(r,s).flatMap(WU).filter(qU).map(VU).join(`
|
|
95
|
+
`);const _=f.split(`
|
|
96
|
+
`);u=l&&_.length>jy,d=u?_.slice(-jy).join(`
|
|
97
|
+
`):f,t[0]=l,t[1]=r,t[2]=s,t[3]=u,t[4]=d,t[5]=f}else u=t[3],d=t[4],f=t[5];const m=d;let p;t[6]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{const _=i.current;if(!_)return;const N=_.scrollHeight-_.scrollTop-_.clientHeight<BU;c(S=>S===N?S:N)},t[6]=p):p=t[6];const h=p;let g;t[7]!==l?(g=()=>{const _=i.current;if(!_||!l)return;const N=_.scrollHeight-_.clientHeight;_.scrollTop!==N&&(_.scrollTop=N)},t[7]=l,t[8]=g):g=t[8];let x;if(t[9]!==l||t[10]!==m?(x=[m,l],t[9]=l,t[10]=m,t[11]=x):x=t[11],w.useLayoutEffect(g,x),!f&&!o)return null;const b=o?"live-subagent-summary":void 0;let y;t[12]!==o?(y=o??a.jsx("span",{className:"uppercase tracking-wide",children:"Live"}),t[12]=o,t[13]=y):y=t[13];let v;t[14]!==b||t[15]!==y?(v=a.jsx("div",{"data-testid":b,className:"mb-1 text-xs font-medium text-muted-foreground",children:y}),t[14]=b,t[15]=y,t[16]=v):v=t[16];let k;t[17]!==u||t[18]!==m||t[19]!==f?(k=f&&a.jsxs("div",{ref:i,onScroll:h,"data-testid":"live-subagent-scroll",role:"region","aria-label":"Live sub-agent output",tabIndex:0,className:"text-xs break-words max-h-64 overflow-y-auto overscroll-contain pr-1",children:[u&&a.jsx("div",{className:"text-muted-foreground/50",children:"…"}),a.jsx(yC,{text:m,compactHeadings:!0})]}),t[17]=u,t[18]=m,t[19]=f,t[20]=k):k=t[20];let j;return t[21]!==v||t[22]!==k?(j=a.jsxs("div",{className:"mt-2 rounded-md border bg-muted/30 px-3 py-2","data-testid":"live-subagent-transcript",children:[v,k]}),t[21]=v,t[22]=k,t[23]=j):j=t[23],j});function WU(n){return n.blocks}function qU(n){return n.blockType!=="tool_use"&&n.text}function VU(n){return n.text}function Ny(n){return n.length>8?n.slice(0,8):n}function Cx(n,e,t){const s=e??t;return s?`${s} - ${Ny(n)}`:Ny(n)}function HU(n){const e=new Map;for(const t of n)e.has(t.agentId)||e.set(t.agentId,Cx(t.agentId,t.subagentType,t.agentName));return e}function KU(n){const e=new Map;for(const s of n)s.parentToolUseId&&!e.has(s.agentId)&&e.set(s.agentId,s.parentToolUseId);const t=new Map;for(const s of e.values())t.set(s,(t.get(s)??0)+1);for(const[s,r]of e)(t.get(r)??0)>1&&e.delete(s);return e}function GU(n){return n?typeof n=="string"?n:n.map(e=>e.type==="text"?e.text:"").filter(Boolean).join(`
|
|
98
|
+
`):""}function wC(n,e){if(cN(n))return dx(n).turns.filter(o=>o.assistantText.length>0||o.thinking.length>0||o.toolCalls.length>0).map(o=>({agentId:e,agentName:null,subagentType:null,type:"assistant",content:o.assistantText.join(`
|
|
99
|
+
|
|
100
|
+
`),toolCalls:o.toolCalls,thinking:o.thinking.map(i=>i.thinking),text:[...o.assistantText],timestamp:o.timestamp,tokenUsage:o.tokenUsage,model:o.model,isBackground:!0}));const t=[],s=new Map;for(const r of n.split(`
|
|
101
|
+
`)){const o=r.trim();if(!o)continue;let i;try{i=JSON.parse(o)}catch{continue}const l=i.type;if(l!=="user"&&l!=="assistant")continue;const c=i.message;if(!c)continue;const u=c.content,d=i.timestamp??"";if(l==="assistant"){const f={agentId:e,agentName:null,subagentType:null,type:"assistant",content:u,toolCalls:[],thinking:[],text:[],timestamp:d,tokenUsage:c.usage?{input_tokens:c.usage.input_tokens??0,output_tokens:c.usage.output_tokens??0,cache_creation_input_tokens:c.usage.cache_creation_input_tokens??0,cache_read_input_tokens:c.usage.cache_read_input_tokens??0}:null,model:c.model??null,isBackground:!0};if(Array.isArray(u)){for(const m of u)if(m.type==="thinking")f.thinking.push(m.thinking);else if(m.type==="text")f.text.push(m.text);else if(m.type==="tool_use"){const p={id:m.id,name:m.name,input:m.input,result:null,isError:!1,timestamp:d};f.toolCalls.push(p),s.set(m.id,p)}}t.push(f)}else if(l==="user"&&Array.isArray(u)){for(const f of u)if(f.type==="tool_result"){const m=s.get(f.tool_use_id);m&&(m.result=GU(f.content),m.isError=f.is_error??!1)}}}return t}const wm=new Map;function ZU(n,e){const t=q.c(21),{session:s,sessionSource:r,isLive:o}=xt();let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=new Map,t[0]=i):i=t[0];const[l,c]=w.useState(i),[u,d]=w.useState(!1);let f;t[1]===Symbol.for("react.memo_cache_sentinel")?(f=new Set,t[1]=f):f=t[1];const m=w.useRef(f);let p;if(t[2]!==o||t[3]!==n){let C;t[5]!==o?(C=E=>E.text.length>0||E.thinking.length>0||E.toolCalls.length>0?!1:o?E.durationMs!=null:E.status==="async_launched",t[5]=o,t[6]=C):C=t[6],p=n.filter(C),t[2]=o,t[3]=n,t[4]=p}else p=t[4];const h=p,g=r==null?void 0:r.dirName,x=s==null?void 0:s.sessionId;let b;t[7]===Symbol.for("react.memo_cache_sentinel")?(b=Zd(window.location.pathname),t[7]=b):b=t[7];const y=b;let v,k;t[8]!==h||t[9]!==g||t[10]!==e||t[11]!==x?(v=()=>{if(y||!e||!g||!x||h.length===0)return;const C=[];for(const A of h){const P=gn(`${g}/${x}/${A.agentId}`);if(!m.current.has(P)){if(wm.has(P)){c(I=>{const $=new Map(I);return $.set(A.agentId,wm.get(P)),$}),m.current.add(P);continue}C.push({agentId:A.agentId,cacheKey:P})}}if(C.length===0)return;let E=!1;return d(!0),async function(){const P=new Map;await Promise.all(C.map(async I=>{const{agentId:$,cacheKey:O}=I;try{const M=`/api/sessions/${encodeURIComponent(g)}/${encodeURIComponent(x)}/subagents/agent-${encodeURIComponent($)}.jsonl`,R=await Re(M);if(!R.ok)return;const z=await R.text(),W=wC(z,$);wm.set(O,W),m.current.add(O),P.set($,W)}catch{}})),!E&&P.size>0&&c(I=>{const $=new Map(I);for(const[O,M]of P)$.set(O,M);return $}),E||d(!1)}(),()=>{E=!0}},k=[y,e,g,x,h],t[8]=h,t[9]=g,t[10]=e,t[11]=x,t[12]=v,t[13]=k):(v=t[12],k=t[13]),w.useEffect(v,k);let j;e:{if(l.size===0&&h.length===0){j=n;break e}let C;if(t[14]!==l||t[15]!==n){C=[];for(const E of n){const T=l.get(E.agentId);if(T&&T.length>0&&(E.status==="async_launched"||E.durationMs!=null)){const A={...T[0],durationMs:E.durationMs,toolUseCount:E.toolUseCount,status:E.status,prompt:E.prompt,agentName:E.agentName,subagentType:E.subagentType};C.push(A,...T.slice(1))}else C.push(E)}t[14]=l,t[15]=n,t[16]=C}else C=t[16];j=C}const _=j,N=y&&e&&h.length>0;let S;return t[17]!==_||t[18]!==u||t[19]!==N?(S={enrichedMessages:_,isLoading:u,unavailable:N},t[17]=_,t[18]=u,t[19]=N,t[20]=S):S=t[20],S}const Cy=w.memo(function(e){const t=q.c(74),{messages:s,expandAll:r,label:o,countLabel:i}=e,[l,c]=w.useState(!1),u=r||l,{sessionSource:d,actions:f}=xt(),m=d==null?void 0:d.dirName;let p;t[0]!==m?(p=Ri(m),t[0]=m,t[1]=p):p=t[1];const h=p.subagentTranscripts,{enrichedMessages:g,isLoading:x,unavailable:b}=ZU(s,u&&h);let y;e:{if(!(d!=null&&d.fileName)){y=null;break e}let Y;t[2]!==d.fileName?(Y=lo(d.fileName),t[2]=d.fileName,t[3]=Y):Y=t[3];const X=Y;if(X){y=X.parentSessionId;break e}let se;if(t[4]!==d.fileName){let te;t[6]===Symbol.for("react.memo_cache_sentinel")?(te=/^([^/]+)\.jsonl$/,t[6]=te):te=t[6],se=d.fileName.match(te),t[4]=d.fileName,t[5]=se}else se=t[5];const Q=se;y=(Q==null?void 0:Q[1])??null}const v=y;let k;t[7]!==g?(k=new Set(g.map(XU)),t[7]=g,t[8]=k):k=t[8];let j;t[9]!==k?(j=[...k],t[9]=k,t[10]=j):j=t[10];const _=j;let N;t[11]!==g?(N=HU(g),t[11]=g,t[12]=N):N=t[12];const S=N;let C;if(t[13]!==g||t[14]!==s){C=new Map;for(const Y of[...s,...g]){const X=C.get(Y.agentId)??{};Y.durationMs!=null&&(X.durationMs=Y.durationMs),Y.toolUseCount!=null&&(X.toolUseCount=Y.toolUseCount),Y.status&&(X.status=Y.status),C.set(Y.agentId,X)}t[13]=g,t[14]=s,t[15]=C}else C=t[15];const E=C;let T;t[16]!==g||t[17]!==s?(T=KU([...s,...g]),t[16]=g,t[17]=s,t[18]=T):T=t[18];const A=T;let P,I;if(t[19]!==g){I=new Map,P=new Map;for(const Y of g)P.set(Y.agentId,Y),Y.text.length>0&&I.set(Y.agentId,Y);t[19]=g,t[20]=P,t[21]=I}else P=t[20],I=t[21];let $;if(t[22]!==_||t[23]!==P||t[24]!==I){$=new Map;for(const Y of _){const X=I.get(Y)??P.get(Y);X&&$.set(Y,X)}t[22]=_,t[23]=P,t[24]=I,t[25]=$}else $=t[25];const O=$;let M;e:{let Y=0,X=0,se=!1,Q=!0;for(const J of s)J.durationMs!=null&&(Y=Y+J.durationMs,se=!0),J.toolUseCount!=null&&(X=X+J.toolUseCount),J.status&&J.status!=="completed"&&(Q=!1);if(!se){M=null;break e}let te;t[26]!==Q||t[27]!==Y||t[28]!==X?(te={totalDuration:Y,totalToolUses:X,allCompleted:Q},t[26]=Q,t[27]=Y,t[28]=X,t[29]=te):te=t[29],M=te}const R=M;if(s.length===0)return null;let z;t[30]!==l?(z=()=>c(!l),t[30]=l,t[31]=z):z=t[31];let W;t[32]!==u?(W=u?a.jsx(Ot,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}):a.jsx(ot,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),t[32]=u,t[33]=W):W=t[33];let D;t[34]===Symbol.for("react.memo_cache_sentinel")?(D=a.jsx(Bs,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),t[34]=D):D=t[34];let L;t[35]!==o?(L=a.jsx("span",{className:"text-xs font-medium text-foreground",children:o}),t[35]=o,t[36]=L):L=t[36];let U;t[37]!==_.length||t[38]!==i?(U=_.length>1&&a.jsxs(Ue,{variant:"secondary",children:[_.length," ",i]}),t[37]=_.length,t[38]=i,t[39]=U):U=t[39];let F;t[40]!==_||t[41]!==S?(F=_.map(Y=>a.jsx(Ue,{variant:"outline",children:S.get(Y)},Y)),t[40]=_,t[41]=S,t[42]=F):F=t[42];let B;t[43]!==_.length||t[44]!==R?(B=R?a.jsxs("span",{className:"inline-flex items-center gap-2 text-xs text-muted-foreground",children:[R.allCompleted?a.jsx(Mr,{className:"size-3 text-success","data-icon":"inline-start"}):a.jsx(vo,{className:"size-3 text-destructive","data-icon":"inline-start"}),a.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[a.jsx(oo,{className:"size-3","data-icon":"inline-start"}),sr(R.totalDuration)]}),R.totalToolUses>0&&a.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[a.jsx(Rd,{className:"size-3","data-icon":"inline-start"}),R.totalToolUses]})]}):a.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",_.length," agent",_.length!==1?"s":"",")"]}),t[43]=_.length,t[44]=R,t[45]=B):B=t[45];let V;t[46]!==W||t[47]!==L||t[48]!==U||t[49]!==F||t[50]!==B||t[51]!==z?(V=a.jsxs(ee,{type:"button",variant:"ghost",onClick:z,className:"h-auto w-full min-w-0 flex-wrap justify-start gap-2 px-0 py-1 text-left whitespace-normal",children:[W,D,L,U,F,B]}),t[46]=W,t[47]=L,t[48]=U,t[49]=F,t[50]=B,t[51]=z,t[52]=V):V=t[52];let H;t[53]!==_||t[54]!==u||t[55]!==A?(H=!u&&_.map(Y=>{const X=A.get(Y);return X?a.jsx(Nx,{toolUseId:X},Y):null}),t[53]=_,t[54]=u,t[55]=A,t[56]=H):H=t[56];let K;t[57]!==f||t[58]!==_||t[59]!==S||t[60]!==O||t[61]!==h||t[62]!==x||t[63]!==u||t[64]!==v||t[65]!==A||t[66]!==d||t[67]!==E||t[68]!==b?(K=u&&a.jsxs("div",{className:"motion-enter mt-2 flex flex-col gap-2",children:[b?a.jsx("div",{className:"py-1 text-xs italic text-muted-foreground",children:"Sub-agent transcripts aren't available in a shared session."}):x&&a.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground py-1",children:[a.jsx(vt,{className:"size-3 animate-spin"}),"Loading agent output..."]}),_.map(Y=>{const X=O.get(Y),se=E.get(Y),Q=h&&!!d&&!!v&&!b;return a.jsx(YU,{agentLabel:S.get(Y)??Y,message:X,stats:se,parentToolUseId:A.get(Y),canNavigate:Q,onOpen:()=>{Q&&f.handleLoadSession(d.dirName,`${v}/subagents/agent-${Y}.jsonl`)}},Y)})]}),t[57]=f,t[58]=_,t[59]=S,t[60]=O,t[61]=h,t[62]=x,t[63]=u,t[64]=v,t[65]=A,t[66]=d,t[67]=E,t[68]=b,t[69]=K):K=t[69];let Z;return t[70]!==V||t[71]!==H||t[72]!==K?(Z=a.jsxs("div",{children:[V,H,K]}),t[70]=V,t[71]=H,t[72]=K,t[73]=Z):Z=t[73],Z});function YU(n){const e=q.c(22),{agentLabel:t,message:s,stats:r,parentToolUseId:o,canNavigate:i,onOpen:l}=n,c=s==null?void 0:s.text;let u;e[0]!==c?(u=RN((c??[]).join(`
|
|
102
|
+
|
|
103
|
+
`)),e[0]=c,e[1]=u):u=e[1];const d=u,f=((c==null?void 0:c.length)??0)>0,m=(r==null?void 0:r.status)!=null&&r.status!=="completed"&&r.status!=="async_launched",p=(r==null?void 0:r.status)==="completed";let h;e[2]!==t?(h=a.jsx(Ue,{variant:"outline",children:t}),e[2]=t,e[3]=h):h=e[3];let g;e[4]!==p||e[5]!==r?(g=r&&a.jsxs("span",{className:"inline-flex items-center gap-2 text-xs text-muted-foreground",children:[p&&a.jsx(Mr,{className:"size-3 text-success"}),r.durationMs!=null&&a.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[a.jsx(oo,{className:"size-3"}),sr(r.durationMs)]}),r.toolUseCount!=null&&r.toolUseCount>0&&a.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[a.jsx(Rd,{className:"size-3"}),r.toolUseCount]})]}),e[4]=p,e[5]=r,e[6]=g):g=e[6];let x;e[7]!==i||e[8]!==l?(x=i&&a.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:l,className:"ml-auto",title:"Open this sub-agent's full chat session",children:[a.jsx(S3,{"data-icon":"inline-start"}),"Open chat"]}),e[7]=i,e[8]=l,e[9]=x):x=e[9];let b;e[10]!==h||e[11]!==g||e[12]!==x?(b=a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[h,g,x]}),e[10]=h,e[11]=g,e[12]=x,e[13]=b):b=e[13];let y;e[14]!==f||e[15]!==m||e[16]!==d||e[17]!==o?(y=f?a.jsx("div",{className:"text-xs break-words overflow-hidden",children:a.jsx(cr,{components:hr,remarkPlugins:gr,children:d})}):a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsx("div",{className:"inline-flex items-center gap-1.5 text-xs italic text-muted-foreground",children:m?a.jsxs(a.Fragment,{children:[a.jsx(vt,{className:"size-3 animate-spin"}),"Working — no return yet"]}):a.jsx(a.Fragment,{children:"No return message from this agent"})}),o&&a.jsx(Nx,{toolUseId:o})]}),e[14]=f,e[15]=m,e[16]=d,e[17]=o,e[18]=y):y=e[18];let v;return e[19]!==b||e[20]!==y?(v=a.jsx("div",{className:"border-l pl-3",children:a.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[b,y]})}),e[19]=b,e[20]=y,e[21]=v):v=e[21],v}function XU(n){return n.agentId}const JU=new Set(["StopFailure","PermissionDenied","PostToolUseFailure"]),QU=w.memo(function(e){const t=q.c(30),{events:s}=e,[r,o]=w.useState(!1);if(s.length===0)return null;let i;t[0]!==s?(i=s.some(eB),t[0]=s,t[1]=i):i=t[1];const l=i,c=r?Ot:ot,u=l?"border-destructive/20 bg-destructive/5":"bg-muted/30";let d;t[2]!==u?(d=G("my-1 rounded-md border px-2 py-1 text-xs",u),t[2]=u,t[3]=d):d=t[3];let f;t[4]===Symbol.for("react.memo_cache_sentinel")?(f=a.jsx(ee,{type:"button",variant:"ghost",size:"sm",className:"h-auto w-full justify-start px-0 py-0 text-left font-normal text-muted-foreground"}),t[4]=f):f=t[4];let m;t[5]!==c?(m=a.jsx(c,{className:"size-3 shrink-0","data-icon":"inline-start"}),t[5]=c,t[6]=m):m=t[6];let p;t[7]!==l?(p=l?a.jsx(Ds,{className:"size-3 text-destructive","data-icon":"inline-start"}):a.jsx(Y7,{className:"size-3","data-icon":"inline-start"}),t[7]=l,t[8]=p):p=t[8];const h=s.length===1?"":"s";let g;t[9]!==s.length||t[10]!==h?(g=a.jsxs("span",{className:"font-mono",children:[s.length," hook event",h]}),t[9]=s.length,t[10]=h,t[11]=g):g=t[11];let x;t[12]!==s?(x=s.map(tB).join(", "),t[12]=s,t[13]=x):x=t[13];let b;t[14]!==x?(b=a.jsx("span",{className:"truncate text-muted-foreground/60",children:x}),t[14]=x,t[15]=b):b=t[15];let y;t[16]!==b||t[17]!==m||t[18]!==p||t[19]!==g?(y=a.jsxs(vs,{render:f,children:[m,p,g,b]}),t[16]=b,t[17]=m,t[18]=p,t[19]=g,t[20]=y):y=t[20];let v;t[21]!==s?(v=s.map(nB),t[21]=s,t[22]=v):v=t[22];let k;t[23]!==v?(k=a.jsx(Tn,{children:a.jsx("ul",{className:"ml-5 mt-1 flex flex-col gap-0.5 font-mono",children:v})}),t[23]=v,t[24]=k):k=t[24];let j;return t[25]!==r||t[26]!==y||t[27]!==k||t[28]!==d?(j=a.jsxs(En,{open:r,onOpenChange:o,className:d,children:[y,k]}),t[25]=r,t[26]=y,t[27]=k,t[28]=d,t[29]=j):j=t[29],j});function eB(n){return JU.has(n.eventName)||n.exitCode!==void 0&&n.exitCode!==0}function tB(n){return n.eventName}function nB(n,e){return a.jsxs("li",{className:"text-muted-foreground/80",children:[a.jsx("span",{className:"text-foreground",children:n.eventName}),n.toolName&&a.jsxs("span",{children:[" · ",n.toolName]}),n.source&&a.jsxs("span",{className:"text-muted-foreground/50",children:[" (",n.source,")"]}),n.decision&&a.jsxs("span",{className:"text-warning",children:[" → ",n.decision]}),n.durationMs!==void 0&&a.jsxs("span",{className:"text-muted-foreground/50",children:[" ",n.durationMs,"ms"]}),n.exitCode!==void 0&&n.exitCode!==0&&a.jsxs("span",{className:"text-destructive",children:[" exit ",n.exitCode]}),n.stderr&&a.jsx("pre",{className:"ml-2 mt-0.5 whitespace-pre-wrap text-destructive",children:n.stderr.slice(0,500)}),n.updatedToolOutput&&a.jsx("span",{className:"text-info",children:" · output replaced by hook"}),n.sessionTitle&&a.jsxs("span",{className:"text-foreground",children:[" · title: ",n.sessionTitle]}),n.worktreePath&&a.jsxs("span",{className:"text-success",children:[" · path: ",n.worktreePath]})]},e)}function od(n){if(!n)return[];const e=n.split(`
|
|
104
|
+
`);return n.endsWith(`
|
|
105
|
+
`)&&e.pop(),e}function Qh(n,e){if(!n&&!e)return{add:0,del:0};const t=od(n),s=od(e);if(t.length===0)return{add:s.length,del:0};if(s.length===0)return{add:0,del:t.length};const r=t.length,o=s.length;let i=0;for(;i<r&&i<o&&t[i]===s[i];)i++;let l=0;for(;l<r-i&&l<o-i&&t[r-1-l]===s[o-1-l];)l++;const c=r-i-l,u=o-i-l;if(c===0)return{add:u,del:0};if(u===0)return{add:0,del:c};let d=new Array(u+1).fill(0),f=new Array(u+1).fill(0);for(let p=1;p<=c;p++){f[0]=0;const h=t[i+p-1];for(let g=1;g<=u;g++)h===s[i+g-1]?f[g]=d[g-1]+1:f[g]=d[g]>f[g-1]?d[g]:f[g-1];[d,f]=[f,d]}const m=d[u];return{add:u-m,del:c-m}}function Sm(n){return n.filter(Boolean).reduce((e,t)=>e+(e&&!e.endsWith(`
|
|
106
|
+
`)?`
|
|
107
|
+
`:"")+t,"")}function sB(n){let e=[];for(const i of n){if(i.isWrite){e=[{original:i.newString,current:i.newString}];continue}if(!i.oldString){e.push({original:i.oldString,current:i.newString,diffLineCounts:i.diffLineCounts});continue}let l=!1;for(const c of e){const u=c.current.indexOf(i.oldString);if(u!==-1){c.current=c.current.slice(0,u)+i.newString+c.current.slice(u+i.oldString.length),delete c.diffLineCounts,l=!0;break}}l||e.some(u=>u.original.includes(i.oldString)&&!u.current.includes(i.oldString))||e.push({original:i.oldString,current:i.newString,diffLineCounts:i.diffLineCounts})}const t=e.filter(i=>{var l,c;return i.original!==i.current||((l=i.diffLineCounts)==null?void 0:l.add)||((c=i.diffLineCounts)==null?void 0:c.del)});if(t.length===0){if(n.some(l=>l.isWrite)&&e.length>0){const l=Sm(e.map(c=>c.current));if(l){const c=Qh("",l);return{originalStr:"",currentStr:l,addCount:c.add,delCount:c.del}}}return{originalStr:"",currentStr:"",addCount:0,delCount:0}}const s=Sm(t.map(i=>i.original)),r=Sm(t.map(i=>i.current)),o={add:0,del:0};for(const i of t){const l=i.diffLineCounts??Qh(i.original,i.current);o.add+=l.add,o.del+=l.del}return{originalStr:s,currentStr:r,addCount:o.add,delCount:o.del}}const rB=24,wa=[];function oB(n,e){for(let s=0;s<wa.length;s++){const r=wa[s];if(r.oldStr===n&&r.newStr===e)return r.result}const t=aB(n,e);return wa.length>=rB&&wa.shift(),wa.push({oldStr:n,newStr:e,result:t}),t}const iB=25e4;function aB(n,e){const t=od(n),s=od(e),r=t.length,o=s.length;let i=0;for(;i<r&&i<o&&t[i]===s[i];)i++;let l=0;for(;l<r-i&&l<o-i&&t[r-1-l]===s[o-1-l];)l++;const c=r-i-l,u=o-i-l,d=[];for(let f=0;f<i;f++)d.push({type:"unchanged",text:t[f],oldIdx:f,newIdx:f});if(!(c===0&&u===0))if(c===0)for(let f=0;f<u;f++)d.push({type:"added",text:s[i+f],newIdx:i+f});else if(u===0)for(let f=0;f<c;f++)d.push({type:"removed",text:t[i+f],oldIdx:i+f});else if(c*u>iB){for(let f=0;f<c;f++)d.push({type:"removed",text:t[i+f],oldIdx:i+f});for(let f=0;f<u;f++)d.push({type:"added",text:s[i+f],newIdx:i+f})}else{const f=u+1,m=new Int32Array((c+1)*f);for(let x=1;x<=c;x++){const b=t[i+x-1],y=x*f,v=y-f;for(let k=1;k<=u;k++)if(b===s[i+k-1])m[y+k]=m[v+k-1]+1;else{const j=m[v+k],_=m[y+k-1];m[y+k]=j>_?j:_}}const p=[];let h=c,g=u;for(;h>0||g>0;)h>0&&g>0&&t[i+h-1]===s[i+g-1]?(p.push({type:"unchanged",text:t[i+h-1],oldIdx:i+h-1,newIdx:i+g-1}),h--,g--):g>0&&(h===0||m[h*f+g-1]>=m[(h-1)*f+g])?(p.push({type:"added",text:s[i+g-1],newIdx:i+g-1}),g--):(p.push({type:"removed",text:t[i+h-1],oldIdx:i+h-1}),h--);p.reverse(),d.push(...p)}for(let f=0;f<l;f++){const m=r-l+f,p=o-l+f;d.push({type:"unchanged",text:t[m],oldIdx:m,newIdx:p})}return d}function lB(n,e,t,s){const r=q.c(9),[o,i]=w.useState(null),[l,c]=w.useState(null);let u,d;r[0]!==t||r[1]!==s||r[2]!==e||r[3]!==n?(u=()=>{const m=m4(t);if(!m){i(null),c(null);return}const p=s?"github-dark":"github-light";let h=!1;const g=requestAnimationFrame(()=>{h||d4().then(async x=>{if(h||(await f4(x,m),h))return;const b=x.codeToTokens(n,{lang:m,theme:p});if(h)return;i(b.tokens);const y=x.codeToTokens(e,{lang:m,theme:p});h||c(y.tokens)}).catch(x=>{console.warn("[EditDiffView] highlight failed:",x),h||(i(null),c(null))})});return()=>{h=!0,cancelAnimationFrame(g)}},d=[n,e,t,s],r[0]=t,r[1]=s,r[2]=e,r[3]=n,r[4]=u,r[5]=d):(u=r[4],d=r[5]),w.useEffect(u,d);let f;return r[6]!==l||r[7]!==o?(f={oldTokens:o,newTokens:l},r[6]=l,r[7]=o,r[8]=f):f=r[8],f}const cB={removed:"bg-destructive/10",added:"bg-success/10",unchanged:""},_y={removed:"border-destructive/20 text-destructive/70",added:"border-success/20 text-success/70",unchanged:"border-border text-muted-foreground"},uB={removed:"text-destructive",added:"text-success",unchanged:"text-muted-foreground"};function dB(n,e){return n.map((t,s)=>a.jsx("span",{style:{color:t.color},className:G(e&&"opacity-50"),children:t.content},s))}function fB(n,e,t){switch(n.type){case"removed":return e==null?void 0:e[n.oldIdx??-1];case"added":return t==null?void 0:t[n.newIdx??-1];case"unchanged":return(t==null?void 0:t[n.newIdx??-1])??(e==null?void 0:e[n.oldIdx??-1])}}function mB(n){const e=q.c(3),{type:t}=n;switch(t){case"removed":{let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(w3,{className:"inline size-3","data-icon":"icon"}),e[0]=s):s=e[0],s}case"added":{let s;return e[1]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(tr,{className:"inline size-3","data-icon":"icon"}),e[1]=s):s=e[1],s}default:{let s;return e[2]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx("span",{className:"inline-block size-3","aria-hidden":"true"}),e[2]=s):s=e[2],s}}}const km=3;function pB(n){if(n.length===0)return[];const e=new Set;for(let o=0;o<n.length;o++)n[o].type!=="unchanged"&&e.add(o);if(e.size===0||n.length<=km*2+3)return n.map((o,i)=>({kind:"line",line:o,originalIdx:i}));const t=new Set;for(const o of e)for(let i=Math.max(0,o-km);i<=Math.min(n.length-1,o+km);i++)t.add(i);const s=[];let r=0;for(;r<n.length;)if(t.has(r))s.push({kind:"line",line:n[r],originalIdx:r}),r++;else{const o=r;let i=0;for(;r<n.length&&!t.has(r);)i++,r++;s.push({kind:"separator",count:i,fromIdx:o,toIdx:r-1})}return s}function hB(n){const e=q.c(7),{count:t,onExpand:s}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(Ji,{className:"shrink-0","data-icon":"inline-start"}),e[0]=r):r=e[0];let o;e[1]!==t?(o=a.jsxs("span",{className:"font-mono",children:[t," unchanged lines"]}),e[1]=t,e[2]=o):o=e[2];let i;e[3]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsx("span",{className:"flex-1 border-b border-border"}),e[3]=i):i=e[3];let l;return e[4]!==s||e[5]!==o?(l=a.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:s,className:"h-auto w-full justify-start rounded-none px-2 py-1 text-xs text-muted-foreground",children:[r,o,i]}),e[4]=s,e[5]=o,e[6]=l):l=e[6],l}const Ey=w.memo(function(e){const t=q.c(33),{line:s,lineNum:r,oldTokens:o,newTokens:i}=e;let l,c,u,d,f,m;if(t[0]!==s||t[1]!==r||t[2]!==i||t[3]!==o){m=fB(s,o,i);const x=cB[s.type];t[10]!==x?(u=G("flex",x),t[10]=x,t[11]=u):u=t[11];const b=_y[s.type];let y;t[12]!==b?(y=G("w-8 shrink-0 select-none border-r pr-1 text-right text-xs leading-relaxed tabular-nums",b),t[12]=b,t[13]=y):y=t[13],t[14]!==r||t[15]!==y?(d=a.jsx("span",{className:y,children:r}),t[14]=r,t[15]=y,t[16]=d):d=t[16];const v=_y[s.type];let k;t[17]!==v?(k=G("select-none shrink-0 w-5 text-right pr-1 border-r",v),t[17]=v,t[18]=k):k=t[18];let j;t[19]!==s.type?(j=a.jsx(mB,{type:s.type}),t[19]=s.type,t[20]=j):j=t[20],t[21]!==k||t[22]!==j?(f=a.jsx("span",{className:k,children:j}),t[21]=k,t[22]=j,t[23]=f):f=t[23],l="pl-2 whitespace-pre",c=m?dB(m,s.type==="unchanged"):a.jsx("span",{className:uB[s.type],children:s.text||" "}),t[0]=s,t[1]=r,t[2]=i,t[3]=o,t[4]=l,t[5]=c,t[6]=u,t[7]=d,t[8]=f,t[9]=m}else l=t[4],c=t[5],u=t[6],d=t[7],f=t[8],m=t[9];const p=m&&m.length===0&&" ";let h;t[24]!==l||t[25]!==c||t[26]!==p?(h=a.jsxs("span",{className:l,children:[c,p]}),t[24]=l,t[25]=c,t[26]=p,t[27]=h):h=t[27];let g;return t[28]!==u||t[29]!==d||t[30]!==f||t[31]!==h?(g=a.jsxs("div",{className:u,children:[d,f,h]}),t[28]=u,t[29]=d,t[30]=f,t[31]=h,t[32]=g):g=t[32],g}),Ty=120,Ay=60,gB=120;function Py(n){const e=q.c(34),{lines:t,oldTokens:s,newTokens:r,compact:o,startLine:i}=n,l=i===void 0?1:i;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=new Set,e[0]=c):c=e[0];const[u,d]=w.useState(c);let f;e[1]!==t?(f=pB(t),e[1]=t,e[2]=f):f=e[2];const m=f,p=m.length>Ty,[h,g]=w.useState(p?Ay:m.length);let x;e[3]!==m.length?(x=()=>{g(m.length>Ty?Ay:m.length)},e[3]=m.length,e[4]=x):x=e[4];let b;e[5]!==m?(b=[m],e[5]=m,e[6]=b):b=e[6],w.useEffect(x,b);let y,v;e[7]!==m.length||e[8]!==h?(y=()=>{if(h>=m.length)return;const A=requestAnimationFrame(()=>{g(P=>Math.min(P+gB,m.length))});return()=>cancelAnimationFrame(A)},v=[h,m.length],e[7]=m.length,e[8]=h,e[9]=y,e[10]=v):(y=e[9],v=e[10]),w.useEffect(y,v);let k;e[11]===Symbol.for("react.memo_cache_sentinel")?(k=A=>{d(P=>new Set(P).add(A))},e[11]=k):k=e[11];const j=k;let _;e[12]!==m||e[13]!==p||e[14]!==h?(_=p?m.slice(0,h):m,e[12]=m,e[13]=p,e[14]=h,e[15]=_):_=e[15];const N=_,S=o&&"max-h-64 overflow-y-auto";let C;e[16]!==S?(C=G("overflow-x-auto font-mono text-xs leading-relaxed",S),e[16]=S,e[17]=C):C=e[17];let E;if(e[18]!==u||e[19]!==N||e[20]!==t||e[21]!==r||e[22]!==s||e[23]!==l){let A;e[25]!==u||e[26]!==t||e[27]!==r||e[28]!==s||e[29]!==l?(A=(P,I)=>{if(P.kind==="separator")return u.has(P.fromIdx)?t.slice(P.fromIdx,P.toIdx+1).map((M,R)=>{const z=P.fromIdx+R;return a.jsx(Ey,{line:M,lineNum:M.type==="removed"?(M.oldIdx??0)+l:(M.newIdx??0)+l,oldTokens:s,newTokens:r},`exp-${z}`)}):a.jsx(hB,{count:P.count,onExpand:()=>j(P.fromIdx)},`sep-${I}`);const{line:$}=P,O=$.type==="removed"?($.oldIdx??0)+l:($.newIdx??0)+l;return a.jsx(Ey,{line:$,lineNum:O,oldTokens:s,newTokens:r},I)},e[25]=u,e[26]=t,e[27]=r,e[28]=s,e[29]=l,e[30]=A):A=e[30],E=N.map(A),e[18]=u,e[19]=N,e[20]=t,e[21]=r,e[22]=s,e[23]=l,e[24]=E}else E=e[24];let T;return e[31]!==C||e[32]!==E?(T=a.jsx("div",{className:C,children:E}),e[31]=C,e[32]=E,e[33]=T):T=e[33],T}function Iy(n){const e=q.c(11),{lines:t}=n;let s=0,r=0;for(const m of t)m.type==="added"?s++:m.type==="removed"&&r++;let o;e[0]!==s||e[1]!==r?(o={added:s,removed:r},e[0]=s,e[1]=r,e[2]=o):o=e[2];const{added:i,removed:l}=o;let c;e[3]!==l?(c=l>0&&a.jsxs("span",{className:"text-destructive",children:["-",l]}),e[3]=l,e[4]=c):c=e[4];const u=l>0&&i>0&&" ";let d;e[5]!==i?(d=i>0&&a.jsxs("span",{className:"text-success",children:["+",i]}),e[5]=i,e[6]=d):d=e[6];let f;return e[7]!==c||e[8]!==u||e[9]!==d?(f=a.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:[c,u,d]}),e[7]=c,e[8]=u,e[9]=d,e[10]=f):f=e[10],f}function _x(n){const e=q.c(34),{oldString:t,newString:s,filePath:r,compact:o,startLine:i,hideHeader:l}=n,c=o===void 0?!0:o,u=i===void 0?1:i,d=l===void 0?!1:l,[f,m]=w.useState(!1),p=ec();let h;e[0]!==s||e[1]!==t?(h=oB(t,s),e[0]=s,e[1]=t,e[2]=h):h=e[2];const g=h,{oldTokens:x,newTokens:b}=lB(t,s,r,p);let y;e[3]!==r?(y=r.split("/").slice(-3).join("/"),e[3]=r,e[4]=y):y=e[4];const v=y,k=c&&"mt-1.5",j=d&&"border-0 rounded-none";let _;e[5]!==k||e[6]!==j?(_=G("overflow-hidden rounded border border-border bg-muted",k,j),e[5]=k,e[6]=j,e[7]=_):_=e[7];let N;e[8]!==d||e[9]!==c||e[10]!==g||e[11]!==v?(N=!d&&a.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2 border-b border-border bg-muted px-2 py-1",children:[a.jsx("span",{className:"truncate font-mono text-xs text-muted-foreground",children:v}),a.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[a.jsx(Iy,{lines:g}),c&&a.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>m(!0),className:"text-muted-foreground",title:"Expand diff","aria-label":"Expand diff",children:a.jsx(Ld,{"data-icon":"icon"})})]})]}),e[8]=d,e[9]=c,e[10]=g,e[11]=v,e[12]=N):N=e[12];let S;e[13]!==c||e[14]!==g||e[15]!==b||e[16]!==x||e[17]!==u?(S=a.jsx(Py,{lines:g,oldTokens:x,newTokens:b,compact:c,startLine:u}),e[13]=c,e[14]=g,e[15]=b,e[16]=x,e[17]=u,e[18]=S):S=e[18];let C;e[19]!==S||e[20]!==_||e[21]!==N?(C=a.jsxs("div",{className:_,children:[N,S]}),e[19]=S,e[20]=_,e[21]=N,e[22]=C):C=e[22];let E;e[23]!==r||e[24]!==c||e[25]!==g||e[26]!==f||e[27]!==b||e[28]!==x||e[29]!==u?(E=c&&a.jsx(dr,{open:f,onOpenChange:m,children:a.jsxs(fr,{className:"flex max-h-[85vh] flex-col border-border bg-popover sm:max-w-4xl",children:[a.jsxs(wo,{children:[a.jsxs(mr,{className:"font-mono text-sm text-foreground flex min-w-0 flex-wrap items-center gap-3 [overflow-wrap:anywhere]",children:[r,a.jsx(Iy,{lines:g})]}),a.jsx(pr,{className:"sr-only",children:"Diff view for edit operation"})]}),a.jsx("div",{className:"flex-1 overflow-auto rounded border border-border bg-background",children:a.jsx(Py,{lines:g,oldTokens:x,newTokens:b,startLine:u})})]})}),e[23]=r,e[24]=c,e[25]=g,e[26]=f,e[27]=b,e[28]=x,e[29]=u,e[30]=E):E=e[30];let T;return e[31]!==C||e[32]!==E?(T=a.jsxs(a.Fragment,{children:[C,E]}),e[31]=C,e[32]=E,e[33]=T):T=e[33],T}const id={Read:{label:"Read file",styleName:"Read"},Write:{label:"Write file",styleName:"Write"},Edit:{label:"Edit file",styleName:"Edit"},Bash:{label:"Run command",styleName:"Bash"},Grep:{label:"Search files",styleName:"Grep"},Glob:{label:"Find files",styleName:"Glob"},Task:{label:"Spawn agent",styleName:"Task"},Agent:{label:"Spawn agent",styleName:"Task"},WebFetch:{label:"Open page",styleName:"WebFetch"},TodoWrite:{label:"Update plan",styleName:"TodoWrite"},AskUserQuestion:{label:"Ask question",styleName:"AskUserQuestion"},Skill:{label:"Use skill",styleName:"Skill"},ToolSearch:{label:"Find tools",styleName:"ToolSearch"},SendMessage:{label:"Message agent",styleName:"SendMessage"},ListAgents:{label:"List agents",styleName:"ListAgents"},TaskCreate:{label:"Create task",styleName:"TaskCreate"},TaskUpdate:{label:"Update task",styleName:"TaskUpdate"},TaskList:{label:"List tasks",styleName:"TaskList"},TaskOutput:{label:"Read task output",styleName:"TaskOutput"},TaskStop:{label:"Stop task",styleName:"TaskStop"},NotebookEdit:{label:"Edit notebook",styleName:"Edit"},EnterPlanMode:{label:"Enter plan mode",styleName:"EnterPlanMode"},ExitPlanMode:{label:"Exit plan mode",styleName:"ExitPlanMode"},EnterWorktree:{label:"Enter worktree",styleName:"EnterWorktree"},ExitWorktree:{label:"Exit worktree",styleName:"ExitWorktree"},Workflow:{label:"Run workflow",styleName:"Workflow"},SendFeedback:{label:"Draft feedback",styleName:"Mcp"},Artifact:{label:"Artifact",styleName:"Mcp"},exec_command:{label:"Run command",styleName:"Bash"},write_stdin:{label:"Continue command",styleName:"Bash"},apply_patch:{label:"Apply patch",styleName:"Edit"},update_plan:{label:"Update plan",styleName:"TodoWrite"},request_user_input:{label:"Ask question",styleName:"AskUserQuestion"},request_user_input_async:{label:"Ask question",styleName:"AskUserQuestion"},wait:{label:"Wait for tools",styleName:"Mcp"},spawn_agent:{label:"Spawn agent",styleName:"Task"},wait_agent:{label:"Wait for agents",styleName:"TaskOutput"},send_message:{label:"Message agent",styleName:"SendMessage"},followup_task:{label:"Follow up",styleName:"Task"},list_agents:{label:"List agents",styleName:"ListAgents"},interrupt_agent:{label:"Interrupt agent",styleName:"Task"},tool_search:{label:"Find tools",styleName:"ToolSearch"},list_mcp_resources:{label:"List MCP resources",styleName:"Mcp"},list_mcp_resource_templates:{label:"List MCP templates",styleName:"Mcp"},read_mcp_resource:{label:"Read MCP resource",styleName:"Mcp"},request_plugin_install:{label:"Install plugin",styleName:"Mcp"},create_goal:{label:"Create goal",styleName:"TodoWrite"},get_goal:{label:"Check goal",styleName:"TaskList"},update_goal:{label:"Update goal",styleName:"TodoWrite"},view_image:{label:"View image",styleName:"Read"}},xB=new Set(["Write","Edit","Bash","exec","Task","Agent","Skill","TodoWrite","Image","AskUserQuestion","CronCreate","CronDelete","ScheduleWakeup","RemoteTrigger","PushNotification","EnterWorktree","ExitWorktree","SendMessage","EndConversation","TaskCreate","TaskUpdate","TaskStop","Workflow"]);function bB(n){var t;const e=Ls(n);return xB.has(((t=id[e])==null?void 0:t.styleName)??e)?"mutating":"readOnly"}function SC(n){return typeof n=="object"&&n!==null}function Vt(...n){return n.find(e=>typeof e=="string")??""}function Xr(n){return typeof n!="string"?"":/^gAAAAA[A-Za-z0-9_-]+={0,2}$/.test(n.trim())?"Encrypted message":n}function Xo(n){const e=n.command??n.cmd;return typeof e=="string"?e:!Array.isArray(e)||!e.every(t=>typeof t=="string")?"":e.map(t=>/^[A-Za-z0-9_./:@%+=,-]+$/.test(t)?t:`'${t.replace(/'/g,`'"'"'`)}'`).join(" ")}function Ir(n,e=140){const t=n.replace(/\s+/g," ").trim();return t.length>e?`${t.slice(0,e-1)}…`:t}function Ex(n){const e=[],t=new Set;for(const s of n){const r=s.trim();!r||t.has(r)||(t.add(r),e.push(r))}return e}function lc(n,e=""){const t=Ex(n);if(t.length===0)return e;const s=Ir(t[0]);return t.length===1?s:`${s} · +${t.length-1} more`}function pf(n,e){return n===1?`1 ${e}`:`${n} ${e}${/(?:ch|sh|s|x|z)$/.test(e)?"es":"s"}`}const $y={mcp:"MCP",api:"API",url:"URL",openai:"OpenAI",figma:"Figma",clickup:"ClickUp"};function jl(n,e=!1){const t=n.replace(/^mcp__/,"").replace(/__/g," ").replace(/[_./:-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").trim().split(/\s+/).filter(Boolean).map(r=>{const o=r.toLowerCase();return $y[o]?$y[o]:e?o[0].toUpperCase()+o.slice(1):o});if(t.length===0)return"Tool";const s=t.join(" ");return s[0].toUpperCase()+s.slice(1)}function vB(n){if(!n)return null;const e=n.trim(),t=ir(e,0);return(t==null?void 0:t.endIndex)===e.length?t.value:null}function yn(n,...e){for(const t of e){const s=vB(sf(n,t));if(s)return s;const r=ix(n,t)[0];if(r)return r}return""}function yB(n,...e){for(const t of e){const s=U4(n,t)[0];if(s!==void 0)return s}return null}function ad(n){return yn(n,"description","query","q","cmd","command","file_path","path","uri","url","pattern","prompt","objective","message","location","ticker","target","task_name","plugin_id","server","status","id")}const wB=[{key:"search_query",label:"Search web",noun:"search",summaryGroups:[["q","query"]]},{key:"image_query",label:"Search images",noun:"image search",summaryGroups:[["q","query"]]},{key:"open",label:"Open page",noun:"page",summaryGroups:[["ref_id","url"]],detail:{property:"lineno",format:n=>`line ${n}`}},{key:"click",label:"Open link",noun:"link",summaryGroups:[["ref_id"]],detail:{property:"id",format:n=>`link ${n}`}},{key:"find",label:"Find on page",noun:"find",summaryGroups:[["pattern"],["ref_id","url"]]},{key:"screenshot",label:"Capture page",noun:"capture",summaryGroups:[["ref_id"]],detail:{property:"pageno",format:n=>`page ${n+1}`}},{key:"finance",label:"Check markets",noun:"quote",summaryGroups:[["ticker"]]},{key:"weather",label:"Check weather",noun:"forecast",summaryGroups:[["location"]]},{key:"sports",label:"Check sports",noun:"sports lookup",summaryGroups:[["league","team"]],countProperties:["league"]},{key:"time",label:"Check time",noun:"time lookup",summaryGroups:[["utc_offset"]]}];function Ry(n,e){return e.flatMap(t=>ix(n,t))}function SB(n,e){const t=e.summaryGroups.map(o=>Ry(n,o)),s=e.detail?U4(n,e.detail.property):[],r=e.countProperties?Ry(n,e.countProperties):t[0];return{label:e.label,noun:e.noun,summary:[...t.map(o=>lc(o)),e.detail&&s.length>0?e.detail.format(s[0]):""].filter(Boolean).join(" · "),count:Math.max(B4(n),Ex(r).length,s.length,1)}}function kB(n){const e=[];for(const t of wB){const s=sf(n,t.key);s&&e.push(SB(s,t))}return e}function kC(n){const e=kB(n);return e.length===0?{label:"Browse web",summary:ad(n),styleName:"WebSearch"}:e.length===1?{label:e[0].label,summary:e[0].summary,styleName:"WebSearch"}:{label:"Browse web",summary:e.map(t=>pf(t.count,t.noun)).join(" · "),styleName:"WebSearch"}}function jC(n){if(!n.startsWith("mcp__"))return null;const[,e,...t]=n.split("__");return!e||t.length===0?null:{server:jl(e,!0),action:jl(t.join(" "))}}function jB(n,e){const t=jC(n);if(!t)return{label:jl(n),summary:ad(e),styleName:"Mcp"};const s=ad(e);return{label:t.server,summary:[t.action,s].filter(Boolean).join(" · "),styleName:"Mcp"}}function NC(n){const e=ir(n.trim(),0),t=(e==null?void 0:e.value)??n,s=Ex(Array.from(t.matchAll(/^\*\*\*\s+(?:Update|Add|Delete) File:\s*(.+)$/gm),r=>r[1]));return lc(s,s.length>0?pf(s.length,"file"):"")}function NB(n){const e=n.argumentSource;switch(Ls(n.name)){case"exec_command":return{label:"Run command",summary:yn(e,"cmd","command"),styleName:"Bash"};case"write_stdin":{const t=yB(e,"session_id"),s=yn(e,"chars");return{label:"Continue command",summary:[t!==null?`session ${t}`:"",s?Ir(s,60):""].filter(Boolean).join(" · "),styleName:"Bash"}}case"apply_patch":return{label:"Apply patch",summary:NC(e),styleName:"Edit"};case"web__run":case"web_search":return kC(e);case"view_image":return{label:"View image",summary:yn(e,"path"),styleName:"Read"};case"update_plan":{const t=sf(e,"plan"),s=t?B4(t):0;return{label:"Update plan",summary:s>0?pf(s,"step"):yn(e,"explanation"),styleName:"TodoWrite"}}case"create_goal":return{label:"Create goal",summary:yn(e,"objective"),styleName:"TodoWrite"};case"get_goal":return{label:"Check goal",summary:"",styleName:"TaskList"};case"update_goal":return{label:"Update goal",summary:yn(e,"status"),styleName:"TodoWrite"};case"list_mcp_resources":return{label:"List MCP resources",summary:yn(e,"server"),styleName:"Mcp"};case"list_mcp_resource_templates":return{label:"List MCP templates",summary:yn(e,"server"),styleName:"Mcp"};case"read_mcp_resource":return{label:"Read MCP resource",summary:[yn(e,"server"),yn(e,"uri")].filter(Boolean).join(" · "),styleName:"Mcp"};case"request_plugin_install":return{label:"Install plugin",summary:yn(e,"plugin_id"),styleName:"Mcp"};case"tool_search":return{label:"Find tools",summary:yn(e,"query"),styleName:"ToolSearch"};case"image_gen__imagegen":return{label:"Generate image",summary:yn(e,"prompt"),styleName:"Image"};case"spawn_agent":return{label:"Spawn agent",summary:Xr(yn(e,"task_name","message")),styleName:"Task"};case"send_message":case"followup_task":return{...id[Ls(n.name)],summary:[yn(e,"target"),Xr(yn(e,"message"))].filter(Boolean).join(" · ")};default:{const t=Ls(n.name),s=id[t];return t.startsWith("mcp__")?jB(t,e):{label:(s==null?void 0:s.label)??jl(t),summary:Xr(ad(e)),styleName:(s==null?void 0:s.styleName)??t}}}}function CB(n){const e=z4(n);if(e.length===0)return{label:"Run tool script",summary:"",styleName:"exec"};const t=e.map(NB),s=t[0];if(t.every(o=>o.label===s.label)){const o=lc(t.map(i=>i.summary));return{label:s.label,summary:e.length===1?o:[`×${e.length}`,o].filter(Boolean).join(" · "),styleName:s.styleName}}const r=new Map;for(const o of t)r.set(o.label,(r.get(o.label)??0)+1);return{label:"Run tools",summary:[...r].map(([o,i])=>i>1?`${o} ×${i}`:o).join(" · "),styleName:"exec"}}function _B(n){const e=SC(n.action)?n.action:null,t=typeof(e==null?void 0:e.type)=="string"?e.type:"search";if(t==="open_page"||t==="openPage")return{label:"Open page",summary:Vt(e==null?void 0:e.url,n.query),styleName:"WebSearch"};if(t==="find_in_page"||t==="findInPage")return{label:"Find on page",summary:[Vt(e==null?void 0:e.pattern),Vt(e==null?void 0:e.url)].filter(Boolean).join(" · "),styleName:"WebSearch"};const s=Array.isArray(e==null?void 0:e.queries)?e.queries.filter(o=>typeof o=="string"):[],r=Vt(e==null?void 0:e.query,n.query);return{label:"Search web",summary:lc([r,...s]),styleName:"WebSearch"}}const EB=["summary","headline","verdict","title"];function TB(n){const e=Vt(...EB.map(t=>n[t]));if(e)return Ir(e);for(const[t,s]of Object.entries(n)){if(!Array.isArray(s))continue;const r=s.length===1&&t.endsWith("s")?t.slice(0,-1):t;return`${s.length} ${r}`}return""}function AB(n){const e=Vt(n.description);if(e)return Ir(e);const t=Vt(n.script);return(t?ix(t,"name")[0]??"":"")||Vt(n.scriptPath)}function Oy(n){const e=Vt(...["description","summary","query","q","command","cmd","file_path","path","url","uri","pattern","prompt","objective","message","title","name"].map(s=>n[s]));if(e)return Ir(e);const t=Object.entries(n).find(([s,r])=>s!=="raw"&&s!=="script"&&typeof r=="string");return t?Ir(t[1]):""}function Ly(n){const e=n.input;switch(n.name){case"Read":case"Write":case"Edit":return String(e.file_path??e.path??"");case"Bash":case"exec_command":return Xo(e);case"write_stdin":return[e.session_id!==void 0?`session ${e.session_id}`:"",Vt(e.chars)].filter(Boolean).join(" · ");case"apply_patch":return NC(Vt(e.patch,e.raw,e.input));case"TodoWrite":case"update_plan":{const t=Array.isArray(e.todos)?e.todos:Array.isArray(e.plan)?e.plan:[];return t.length>0?pf(t.length,"step"):Vt(e.explanation)}case"Grep":case"Glob":return String(e.pattern??"");case"Task":case"Agent":return Xr(e.description??e.prompt);case"WebFetch":return String(e.url??"");case"NotebookEdit":return String(e.notebook_path??"");case"EnterPlanMode":return"Entered plan mode";case"ExitPlanMode":return"Waiting for plan approval";case"AskUserQuestion":case"request_user_input":case"request_user_input_async":{const t=Array.isArray(e.questions)?e.questions.find(SC):null;return Vt(t==null?void 0:t.question,t==null?void 0:t.title)}case"Monitor":{const t=String(e.bash_id??""),s=e.filter?` · filter=${e.filter}`:"";return`${t}${s}`}case"CronCreate":{const t=String(e.schedule??e.cron??""),s=String(e.prompt??""),r=s.length>60?s.slice(0,60)+"...":s;return t&&r?`${t} → ${r}`:t||r}case"CronList":return"";case"CronDelete":return String(e.id??e.cron_id??"");case"ScheduleWakeup":{const t=Number(e.delaySeconds??0),s=Math.round(t/60),r=t>=3600?`${Math.round(t/3600)}h`:t>=60?`${s}m`:`${t}s`,o=e.reason?` · ${e.reason}`:"";return`in ${r}${o}`}case"RemoteTrigger":{const t=String(e.action??""),s=String(e.id??e.trigger_id??"");return[t,s].filter(Boolean).join(" ")}case"PushNotification":return String(e.title??e.body??"");case"EnterWorktree":{const t=String(e.name??e.branch??""),s=e.path?` (${e.path})`:"";return`${t}${s}`}case"ExitWorktree":return String(e.name??e.branch??"");case"Skill":return String(e.skill??e.name??"");case"ToolSearch":return String(e.query??"");case"SendMessage":{const t=Vt(e.to,e.recipient),s=Ir(Xr(Vt(e.summary,e.message,e.content)));return[t,s].filter(Boolean).join(" · ")}case"ListAgents":case"TaskList":return"";case"TaskCreate":return Ir(Vt(e.subject,e.description));case"TaskUpdate":{const t=String(e.taskId??""),s=Array.isArray(e.addBlockedBy)?e.addBlockedBy.filter(o=>typeof o=="string"):[],r=Vt(e.status)||(s.length>0?`blocked by ${s.join(", ")}`:"");return r?`${t} → ${r}`:t}case"TaskOutput":case"TaskStop":return String(e.task_id??"");case"Workflow":return AB(e);case"SendFeedback":return Vt(e.title,e.details);case"Artifact":return[Vt(e.action),Vt(e.title,e.file_path,e.url),Vt(e.asset_id)].filter(Boolean).join(" · ");case"StructuredOutput":case"ReportFindings":case"DesignSync":case"LSP":return TB(e)||Oy(e);case"spawn_agent":return Xr(e.task_name??e.message);case"wait_agent":{const t=Array.isArray(e.ids)?e.ids.filter(s=>typeof s=="string"):[];return lc(t)}case"send_message":case"followup_task":return[e.target,Xr(e.message)].filter(t=>typeof t=="string"&&t.length>0).join(" · ");case"list_agents":return String(e.path_prefix??"");case"interrupt_agent":return String(e.target??"");case"list_mcp_resources":case"list_mcp_resource_templates":return String(e.server??"");case"read_mcp_resource":return[e.server,e.uri].filter(t=>typeof t=="string").join(" · ");case"request_plugin_install":return String(e.plugin_id??"");case"create_goal":return String(e.objective??"");case"update_goal":return String(e.status??"");case"view_image":return String(e.path??"");default:return Oy(e)}}function aa(n){if(ax(n))return CB(n.input.raw);const e=Ls(n.name);if(e==="WebSearch"||e==="web_search")return _B(n.input);if(e==="web__run"||e==="web.run")return kC(JSON.stringify(n.input));const t=jC(n.name);if(t)return{label:t.server,summary:[t.action,Ly(n)].filter(Boolean).join(" · "),styleName:"Mcp"};const s=id[e];return{label:(s==null?void 0:s.label)??jl(e),summary:Ir(Ly({name:e,input:n.input})),styleName:(s==null?void 0:s.styleName)??e}}function PB(n){return aa(n).summary}const IB={file_path:"File",path:"Path",target:"Recipient",recipient:"Recipient",recipient_agent_id:"Recipient",agent_id:"Agent",agent_type:"Agent type",subagent_type:"Agent type",task_name:"Task",description:"Description",message:"Message",prompt:"Task",content:"Content",query:"Query",pattern:"Pattern",url:"URL",workdir:"Working directory",cwd:"Working directory",max_output_tokens:"Output limit",yield_time_ms:"Yield",timeout_ms:"Timeout"};function $B(n){return IB[n]??n.replace(/_/g," ").replace(/^./,e=>e.toUpperCase())}function RB(n,e){if(typeof e=="number"){if(n==="max_output_tokens")return`${e.toLocaleString()} tokens`;if(n.endsWith("_ms"))return e<1e3?`${e} ms`:`${e/1e3} sec`}return String(e)}function Nl(n){const e=q.c(20),{value:t}=n,[s,r]=w.useState(!1),o=w.useId();let i,l,c,u;if(e[0]!==s||e[1]!==o||e[2]!==t){const p=Xr(t);i=p.length>800,l=o;const h=s&&"max-h-96 overflow-auto";e[7]!==h?(c=G("whitespace-pre-wrap break-words [overflow-wrap:anywhere]",h),e[7]=h,e[8]=c):c=e[8],u=i&&!s?`${p.slice(0,800)}…`:p,e[0]=s,e[1]=o,e[2]=t,e[3]=i,e[4]=l,e[5]=c,e[6]=u}else i=e[3],l=e[4],c=e[5],u=e[6];let d;e[9]!==l||e[10]!==c||e[11]!==u?(d=a.jsx("div",{id:l,className:c,children:u}),e[9]=l,e[10]=c,e[11]=u,e[12]=d):d=e[12];let f;e[13]!==s||e[14]!==o||e[15]!==i?(f=i&&a.jsx(ee,{type:"button",variant:"ghost",size:"xs","aria-expanded":s,"aria-controls":o,onClick:()=>r(OB),children:s?"Show less":"Show more"}),e[13]=s,e[14]=o,e[15]=i,e[16]=f):f=e[16];let m;return e[17]!==d||e[18]!==f?(m=a.jsxs(a.Fragment,{children:[d,f]}),e[17]=d,e[18]=f,e[19]=m):m=e[19],m}function OB(n){return!n}function LB(n){const e=n.todos??n.plan;return Array.isArray(e)?e.flatMap(t=>{if(!t||typeof t!="object")return[];const s=t,r=s.content??s.step??s.description;return typeof r=="string"?[{text:r,status:typeof s.status=="string"?s.status:"pending"}]:[]}):[]}function MB(n){const e=q.c(4),{steps:t}=n;let s;e[0]!==t?(s=t.map(zB),e[0]=t,e[1]=s):s=e[1];let r;return e[2]!==s?(r=a.jsx("section",{className:"mt-2 min-w-0","aria-label":"Plan",children:a.jsx("ol",{className:"flex flex-col gap-2",children:s})}),e[2]=s,e[3]=r):r=e[3],r}function zB(n,e){const t=n.status==="completed",s=n.status==="in_progress",r=t?Ft:s?X7:s1,o=t?"Completed":s?"In progress":"Pending";return a.jsxs("li",{className:"flex min-w-0 items-start gap-2 text-xs",children:[a.jsx(r,{role:"img","aria-label":o,className:G("mt-0.5 size-3 shrink-0 text-muted-foreground",s&&"text-info")}),a.jsx("div",{className:"min-w-0 flex-1",children:a.jsx(Nl,{value:n.text})}),a.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:o})]},e)}function DB(n){const e=q.c(4),{questions:t}=n;let s;e[0]!==t?(s=t.map(FB),e[0]=t,e[1]=s):s=e[1];let r;return e[2]!==s?(r=a.jsx("section",{className:"mt-2 flex min-w-0 flex-col gap-3","aria-label":"Questions",children:s}),e[2]=s,e[3]=r):r=e[3],r}function FB(n,e){return a.jsxs("div",{className:"min-w-0 text-xs",children:[a.jsx(Nl,{value:String(n.question??n.title)}),Array.isArray(n.options)&&a.jsx("ul",{className:"mt-2 flex min-w-0 flex-col gap-1.5 border-l border-border pl-3",children:n.options.map(UB)})]},e)}function UB(n,e){const t=typeof n=="string"?{label:n}:n;return!t||typeof t.label!="string"?null:a.jsxs("li",{className:"min-w-0",children:[a.jsx(Nl,{value:t.label}),typeof t.description=="string"&&a.jsx("div",{className:"mt-0.5 text-muted-foreground",children:a.jsx(Nl,{value:t.description})})]},e)}function CC(n){const e=q.c(21),{input:t}=n;let s;e[0]!==t?(s=LB(t),e[0]=t,e[1]=s):s=e[1];const r=s;let o;e[2]!==t.questions?(o=Array.isArray(t.questions)?t.questions.filter(qB):[],e[2]=t.questions,e[3]=o):o=e[3];const i=o;let l,c,u,d,f;if(e[4]!==t||e[5]!==i||e[6]!==r){f=Symbol.for("react.early_return_sentinel");e:{const p=Object.entries(t).filter(WB);if(r.length===0&&p.length===0&&i.length===0){f=null;break e}l="min-w-0",e[12]!==r?(c=r.length>0&&a.jsx(MB,{steps:r}),e[12]=r,e[13]=c):c=e[13],e[14]!==i?(u=i.length>0&&a.jsx(DB,{questions:i}),e[14]=i,e[15]=u):u=e[15],d=p.length>0&&a.jsx("dl",{className:"mt-2 flex min-w-0 flex-col gap-2","aria-label":"Call details",children:p.map(BB)})}e[4]=t,e[5]=i,e[6]=r,e[7]=l,e[8]=c,e[9]=u,e[10]=d,e[11]=f}else l=e[7],c=e[8],u=e[9],d=e[10],f=e[11];if(f!==Symbol.for("react.early_return_sentinel"))return f;let m;return e[16]!==l||e[17]!==c||e[18]!==u||e[19]!==d?(m=a.jsxs("div",{className:l,children:[c,u,d]}),e[16]=l,e[17]=c,e[18]=u,e[19]=d,e[20]=m):m=e[20],m}function BB(n){const[e,t]=n;return a.jsxs("div",{className:"grid min-w-0 grid-cols-[6.5rem_minmax(0,1fr)] items-start gap-x-3 text-xs",children:[a.jsx("dt",{className:"max-w-32 break-words text-muted-foreground",children:$B(e)}),a.jsx("dd",{className:"min-w-0 leading-relaxed",children:a.jsx(Nl,{value:RB(e,t)})})]},e)}function WB(n){const[e,t]=n;return e!=="raw"&&e!=="type"&&(typeof t=="string"?t.length>0:typeof t=="number"||typeof t=="boolean")}function qB(n){return n!==null&&typeof n=="object"&&typeof(n.question??n.title)=="string"}function VB(n){const e=q.c(25),{name:t,input:s}=n;let r;e[0]!==s||e[1]!==t?(r=aa(typeof s.raw=="string"&&s.raw.startsWith("{")?{name:"exec",input:{raw:`tools.${t}(${s.raw})`}}:{name:t,input:s}),e[0]=s,e[1]=t,e[2]=r):r=e[2];const o=r;let i;e[3]!==s?(i=Xo(s),e[3]=s,e[4]=i):i=e[4];const l=i;let c;e[5]!==l||e[6]!==s?(c=l?Object.fromEntries(Object.entries(s).filter(HB)):s,e[5]=l,e[6]=s,e[7]=c):c=e[7];const u=c;let d;e[8]!==o.label?(d=a.jsx("span",{className:"font-medium",children:o.label}),e[8]=o.label,e[9]=d):d=e[9];let f;e[10]!==l||e[11]!==o.summary?(f=o.summary&&!l&&a.jsx("span",{className:"truncate text-muted-foreground",children:o.summary}),e[10]=l,e[11]=o.summary,e[12]=f):f=e[12];let m;e[13]!==d||e[14]!==f?(m=a.jsxs("div",{className:"mb-1 flex min-w-0 flex-wrap items-center gap-x-2 text-xs",children:[d,f]}),e[13]=d,e[14]=f,e[15]=m):m=e[15];let p;e[16]!==l?(p=l&&a.jsx(p4,{code:l,language:"bash",label:"Command"}),e[16]=l,e[17]=p):p=e[17];let h;e[18]!==u?(h=a.jsx(CC,{input:u}),e[18]=u,e[19]=h):h=e[19];let g;return e[20]!==o.label||e[21]!==m||e[22]!==p||e[23]!==h?(g=a.jsxs("section",{className:"min-w-0","aria-label":o.label,children:[m,p,h]}),e[20]=o.label,e[21]=m,e[22]=p,e[23]=h,e[24]=g):g=e[24],g}function HB(n){const[e]=n;return e!=="command"&&e!=="cmd"}function KB(n){const e=q.c(32),{input:t}=n,s=String(t.raw??"");let r;e[0]!==t?(r=W4(t),e[0]=t,e[1]=r):r=e[1];const o=r,[i,l]=w.useState(!1),[c,u]=Ar(),d=w.useId(),f=o.length===0||i;let m;e[2]!==o?(m=o.length>0&&a.jsx("div",{className:"flex min-w-0 flex-col gap-3",children:o.map(ZB)}),e[2]=o,e[3]=m):m=e[3];let p;e[4]!==o.length||e[5]!==f||e[6]!==d?(p=o.length>0?a.jsxs(ee,{type:"button",variant:"ghost",size:"xs","aria-expanded":f,"aria-controls":d,onClick:()=>l(GB),children:[a.jsx(ot,{"data-icon":"inline-start",className:G(f&&"rotate-90")}),"Source"]}):a.jsx("span",{className:"text-xs text-muted-foreground",children:"Script"}),e[4]=o.length,e[5]=f,e[6]=d,e[7]=p):p=e[7];let h;e[8]!==u||e[9]!==s?(h=()=>u(s),e[8]=u,e[9]=s,e[10]=h):h=e[10];const g=c?"Tool script copied":"Copy script";let x;e[11]!==c?(x=c?a.jsx(Ft,{"data-icon":"icon"}):a.jsx(ys,{"data-icon":"icon"}),e[11]=c,e[12]=x):x=e[12];let b;e[13]!==h||e[14]!==g||e[15]!==x?(b=a.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:h,"aria-label":g,children:x}),e[13]=h,e[14]=g,e[15]=x,e[16]=b):b=e[16];let y;e[17]!==p||e[18]!==b?(y=a.jsxs("div",{className:"mb-1 mt-1 flex items-center justify-between gap-2",children:[p,b]}),e[17]=p,e[18]=b,e[19]=y):y=e[19];let v;e[20]!==s?(v=a.jsx(p4,{code:s,language:"typescript",label:"Codex exec script"}),e[20]=s,e[21]=v):v=e[21];let k;e[22]!==d||e[23]!==v?(k=a.jsx(Tn,{id:d,children:v}),e[22]=d,e[23]=v,e[24]=k):k=e[24];let j;e[25]!==f||e[26]!==k?(j=a.jsx(En,{open:f,children:k}),e[25]=f,e[26]=k,e[27]=j):j=e[27];let _;return e[28]!==j||e[29]!==m||e[30]!==y?(_=a.jsxs("section",{className:"mt-2 min-w-0","aria-label":"Tool script",children:[m,y,j]}),e[28]=j,e[29]=m,e[30]=y,e[31]=_):_=e[31],_}function GB(n){return!n}function ZB(n,e){return a.jsx(VB,{...n},e)}const YB=/(?:^|;|&&)\s*echo\s+(["']?)---([\w.-]*)\1\s*(?=;|&&|$)/g;function My(n){return n.replace(/^\s*(?:;|&&)/,"").trim()}function _C(n,e){const t=[],s=[];let r=0;for(const l of n.matchAll(YB)){const c=My(n.slice(r,l.index));c&&t.push({label:s.at(-1)??"",command:c,chunk:s.length}),s.push(l[2]),r=l.index+l[0].length}if(s.length===0)return null;const o=My(n.slice(r));if(o&&t.push({label:s.at(-1)??"",command:o,chunk:s.length}),t.length<2)return null;const i=e===null?null:XB(e,s);return i!==null&&i.length<2?null:t.map(({chunk:l,...c})=>({...c,output:i!==null&&l<i.length?i[l]:null}))}function XB(n,e){const t=[[]];let s=0;for(const r of n.split(/\r\n|\r|\n/))s<e.length&&r===`---${e[s]}`?(t.push([]),s++):t[t.length-1].push(r);return t.map(r=>r.join(`
|
|
108
|
+
`).trim())}const JB=new Set(["mv","cp","rm","mkdir","touch","tee","ln","chmod","chown","install","rsync"]),QB=/(?:^|[^\d&])>{1,2}(?!\s*&|\s*\/dev\/null)/,eW=/\|\||&&|[|;\n]/,tW=new Set(["echo","printf","true","false",":"]),nW=new Set(["find","grep","rg","ag","ack","locate","which","whereis"]),sW=new Set(["cat","head","tail","less","more","wc","stat","file","strings","jq","awk","cut","sort","uniq","tr","sed","diff","xxd","od"]),rW=new Set(["ls","tree","du"]),oW=new Set(["xargs","sudo","env","time","nohup","command"]);function iW(n){const e=n.split(/\s+/);for(;e.length>1&&(oW.has(e[0])||/^-/.test(e[0]));)e.shift();const[t,...s]=e;return JB.has(t)||t==="sed"&&s.some(r=>/^-[a-zA-Z]*i/.test(r))||/^python3?$/.test(t)&&s[0]==="-"||t==="git"&&/^(add|commit|checkout|reset|push|stash|rebase|merge|rm|mv)$/.test(s[0]??"")?!0:QB.test(n)}const EC=/<<-?\s*['"]?\w+['"]?/,aW=/'[^']*'|"(?:[^"\\]|\\.)*"/g;function lW(n){return n.split(EC)[0].replace(aW,'""').split(eW).map(e=>e.trim()).filter(Boolean)}function cW(n){const e=lW(n);if(e.some(iW))return"write";let t=!1,s=!1,r=!1;for(const o of e){const i=o.split(/\s+/)[0];if(!(!i||tW.has(i)))if(nW.has(i))t=!0;else if(sW.has(i))s=!0;else if(rW.has(i))r=!0;else return"run"}return r?"list":t?"search":s?"read":"run"}const uW=/^["']?((?:~|\.{1,2})?\/?[\w.@+-]+(?:\/[\w.@+*{}-]+)+\/?|[\w@+-]+\.(?:[cm]?[jt]sx?|json|md|mdx|py|rb|go|rs|sh|zsh|ya?ml|toml|css|scss|html|txt|sql|swift|kt|java|plist|lock))["']?[,:;]?$/;function TC(n){const e=new Set;for(const t of n.split(EC)[0].split(/\s+/)){const s=t.match(uW);if(!s)continue;const r=s[1];r.includes("*")||r.includes("{")||r.startsWith("-")||e.add(r)}return[...e]}const dW=/^(?:cat|head(?:\s+-n?\s*\d+)?|tail(?:\s+-n?\s*\d+)?|sed\s+-n\s+(\d+),(\d+)p)\s+(["']?)(\S+)\3(?:\s*\|\s*(?:head|tail)(?:\s+-n?\s*\d+)?)?$/;function fW(n){const e=n.trim().match(dW);if(!e)return null;const[,t,s,,r]=e;return TC(r).length?t?{path:r,from:Number(t),to:Number(s)}:{path:r}:null}const mW=/(?:No such file or directory|command not found|no matches found|Permission denied|is not recognized as an internal|Traceback \(most recent call last\)|^fatal: |^npm ERR!|^error: |^ERROR: |exited with code [1-9]\d*|^FAIL\b)/m;function pW(n,e){return!e||n==="read"&&e.split(`
|
|
109
|
+
`).length>3?!1:mW.test(e)}function AC(n){const e=cW(n.command);return{kind:e,paths:TC(n.command),readFile:e==="read"?fW(n.command):null,failed:pW(e,n.output)}}function hW(n){var e;return n.label||((e=n.command.match(/^[\w.-]+/))==null?void 0:e[0])||"…"}const gW={read:{icon:Va,label:"Read file"},search:{icon:Yn,label:"Search"},list:{icon:Tr,label:"List files"},run:{icon:Yi,label:"Run command"},write:{icon:yh,label:"Update files"}},xW=new Set(["command","cmd","description","timeout","run_in_background"]);function PC(n){const e=Xo(n.input);return _C(e,n.result)??[{label:"",command:e,output:n.result}]}function bW(n,e,t){if(!n.isError||t.some(r=>r.failed))return-1;const s=e.findLastIndex(r=>r.output!==null);return s>=0?s:e.length-1}function vW(n){return typeof n!="number"||!Number.isFinite(n)?String(n):n<1e3?`${n} ms timeout`:n%6e4===0?`${n/6e4} min timeout`:n%1e3===0?`${n/1e3} sec timeout`:`${(n/1e3).toFixed(1)} sec timeout`}function yW(n){return n.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase())}function wW(n){if(typeof n=="string")return n;if(n===null)return"null";if(n===void 0)return"undefined";try{return JSON.stringify(n)}catch{return String(n)}}function SW(n){const e=[];n.timeout!==void 0&&e.push(vW(n.timeout)),typeof n.run_in_background=="boolean"&&e.push(n.run_in_background?"Background":"Foreground");for(const[t,s]of Object.entries(n))xW.has(t)||s===void 0||e.push(`${yW(t)} ${wW(s)}`);return e}function kW(n,e){const t=PC(n),s=t.map(AC),r=bW(n,t,s);return{command:Xo(n.input),rows:t.map((o,i)=>({section:o,analysis:s[i],failed:s[i].failed||i===r,pending:e&&n.result===null&&!n.isError})),options:SW(n.input)}}function jW(n){return n?n.split(/\r\n|\r|\n/).length:0}function NW(n){if(n.failed)return"Failed";if(n.pending)return"Output pending";if(n.section.output===null)return"Not run";if(n.section.output==="")return"No output";const e=jW(n.section.output);return e===1?"1 line":`${e} lines`}function CW(n,e){return n.startsWith("/")?n:n.startsWith("~")||!e?null:`${e.replace(/\/$/,"")}/${n.replace(/^\.\//,"")}`}function IC(n){const e=q.c(12),{path:t,line:s,cwd:r,children:o}=n;let i;e[0]!==r||e[1]!==t?(i=CW(t,r),e[0]=r,e[1]=t,e[2]=i):i=e[2];const l=i;if(!l||!pt("hostFiles")){let f;return e[3]!==o?(f=a.jsx(a.Fragment,{children:o}),e[3]=o,e[4]=f):f=e[4],f}const c=`Open ${l}${s?`:${s}`:""}`;let u;e[5]!==s||e[6]!==l?(u=f=>{f.stopPropagation(),xl(l,s?{line:s}:{})},e[5]=s,e[6]=l,e[7]=u):u=e[7];let d;return e[8]!==o||e[9]!==c||e[10]!==u?(d=a.jsx("button",{type:"button",className:"rounded-sm underline decoration-dotted decoration-muted-foreground/60 underline-offset-2 hover:bg-muted hover:text-foreground hover:decoration-solid",title:c,onClick:u,children:o}),e[8]=o,e[9]=c,e[10]=u,e[11]=d):d=e[11],d}function $C(n){const e=q.c(13),{command:t,paths:s,cwd:r}=n;if(s.length===0){let u;return e[0]!==t?(u=a.jsx(a.Fragment,{children:t}),e[0]=t,e[1]=u):u=e[1],u}let o;e[2]!==s?(o=new Set(s),e[2]=s,e[3]=o):o=e[3];const i=o;let l;if(e[4]!==t||e[5]!==r||e[6]!==i){let u;e[8]!==r||e[9]!==i?(u=(d,f)=>{const m=d.replace(/^["']|["']?[,:;]?$/g,"");return i.has(m)?a.jsx(IC,{path:m,cwd:r,children:d},f):d},e[8]=r,e[9]=i,e[10]=u):u=e[10],l=t.split(/(\s+)/).map(u),e[4]=t,e[5]=r,e[6]=i,e[7]=l}else l=e[7];let c;return e[11]!==l?(c=a.jsx(a.Fragment,{children:l}),e[11]=l,e[12]=c):c=e[12],c}const _W=/^([^\s:]+):(\d+)([:-])/;function EW(n){const e=q.c(7),{output:t,cwd:s}=n;let r;if(e[0]!==s||e[1]!==t){let i;e[3]!==s?(i=(l,c)=>{const u=l.match(_W);return a.jsx("span",{className:"block",children:u?a.jsxs(a.Fragment,{children:[a.jsxs(IC,{path:u[1],line:Number(u[2]),cwd:s,children:[u[1],":",u[2]]}),l.slice(u[1].length+u[2].length+1)]}):l||" "},c)},e[3]=s,e[4]=i):i=e[4],r=t.split(/\r\n|\r|\n/).map(i),e[0]=s,e[1]=t,e[2]=r}else r=e[2];let o;return e[5]!==r?(o=a.jsx("pre",{tabIndex:0,className:J1,children:r}),e[5]=r,e[6]=o):o=e[6],o}function RC(n){var l;const e=q.c(14),{row:t,cwd:s}=n;if(t.section.output===null){let c;e[0]!==t.pending?(c=t.pending&&a.jsx(vt,{className:"size-3.5 motion-safe:animate-spin","aria-hidden":"true"}),e[0]=t.pending,e[1]=c):c=e[1];const u=t.pending?"Command is running. Waiting for output…":"Output unavailable";let d;return e[2]!==c||e[3]!==u?(d=a.jsxs("p",{className:"flex items-center gap-2 py-2 text-xs text-muted-foreground",role:"status",children:[c,u]}),e[2]=c,e[3]=u,e[4]=d):d=e[4],d}const r=(l=t.analysis.readFile)==null?void 0:l.path;let o;e[5]!==s||e[6]!==t.analysis.kind||e[7]!==t.failed?(o=t.analysis.kind==="search"&&!t.failed?c=>a.jsx(EW,{output:c,cwd:s}):void 0,e[5]=s,e[6]=t.analysis.kind,e[7]=t.failed,e[8]=o):o=e[8];let i;return e[9]!==t.failed||e[10]!==t.section.output||e[11]!==r||e[12]!==o?(i=a.jsx(x4,{result:t.section.output,isError:t.failed,filePath:r,renderResult:o}),e[9]=t.failed,e[10]=t.section.output,e[11]=r,e[12]=o,e[13]=i):i=e[13],i}function TW(n){var M;const e=q.c(52),{row:t,expandAll:s,cwd:r}=n,[o,i]=w.useState(!1),l=s||o,c=t.section.output!==null&&t.section.output!=="";let u;e[0]!==t.section?(u=hW(t.section),e[0]=t.section,e[1]=u):u=e[1];const d=`${u} section: ${t.section.command}`,{icon:f,label:m}=gW[t.analysis.kind];let p;e[2]!==f?(p=a.jsx(f,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),e[2]=f,e[3]=p):p=e[3];const h=t.section.label||m;let g;e[4]!==h?(g=a.jsx("span",{className:"min-w-0 flex-1 break-words text-[13px] font-medium text-foreground",children:h}),e[4]=h,e[5]=g):g=e[5];const x=t.failed&&"text-destructive";let b;e[6]!==x?(b=G("shrink-0 text-xs tabular-nums text-muted-foreground",x),e[6]=x,e[7]=b):b=e[7];let y;e[8]!==t?(y=NW(t),e[8]=t,e[9]=y):y=e[9];let v;e[10]!==b||e[11]!==y?(v=a.jsx("span",{className:b,children:y}),e[10]=b,e[11]=y,e[12]=v):v=e[12];let k;e[13]!==c||e[14]!==l?(k=c&&a.jsx(ot,{className:G("size-3.5 shrink-0 text-muted-foreground transition-transform motion-reduce:transition-none",l&&"rotate-90"),"aria-hidden":"true"}),e[13]=c,e[14]=l,e[15]=k):k=e[15];let j;e[16]!==p||e[17]!==g||e[18]!==v||e[19]!==k?(j=a.jsxs(a.Fragment,{children:[p,g,v,k]}),e[16]=p,e[17]=g,e[18]=v,e[19]=k,e[20]=j):j=e[20];const _=j;let N;e[21]!==s?(N=R=>{s||i(R)},e[21]=s,e[22]=N):N=e[22];let S;e[23]!==_||e[24]!==s||e[25]!==c||e[26]!==d?(S=c?a.jsx(vs,{className:G("flex min-h-9 w-full min-w-0 items-center gap-2 text-left","cursor-pointer rounded-md hover:bg-muted/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),"aria-label":d,disabled:s,children:_}):a.jsx("div",{className:"flex min-h-9 w-full min-w-0 items-center gap-2 text-left","aria-label":d,children:_}),e[23]=_,e[24]=s,e[25]=c,e[26]=d,e[27]=S):S=e[27];const C=l||!c?"whitespace-pre-wrap break-words [overflow-wrap:anywhere]":"truncate";let E;e[28]!==C?(E=G("min-w-0 flex-1 font-mono text-xs leading-relaxed text-foreground/85",C),e[28]=C,e[29]=E):E=e[29];let T;e[30]!==r||e[31]!==t.analysis.paths||e[32]!==t.section.command?(T=a.jsx($C,{command:t.section.command,paths:t.analysis.paths,cwd:r}),e[30]=r,e[31]=t.analysis.paths,e[32]=t.section.command,e[33]=T):T=e[33];let A;e[34]!==E||e[35]!==T?(A=a.jsx("code",{className:E,children:T}),e[34]=E,e[35]=T,e[36]=A):A=e[36];let P;e[37]!==t.analysis.readFile?(P=((M=t.analysis.readFile)==null?void 0:M.from)&&a.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:["L",t.analysis.readFile.from,"–",t.analysis.readFile.to]}),e[37]=t.analysis.readFile,e[38]=P):P=e[38];let I;e[39]!==A||e[40]!==P?(I=a.jsxs("div",{className:"flex min-w-0 items-start gap-2 pl-5.5",children:[A,P]}),e[39]=A,e[40]=P,e[41]=I):I=e[41];let $;e[42]!==r||e[43]!==c||e[44]!==t?($=c&&a.jsx(Tn,{children:a.jsx("div",{className:"pb-1 pl-5.5",children:a.jsx(RC,{row:t,cwd:r})})}),e[42]=r,e[43]=c,e[44]=t,e[45]=$):$=e[45];let O;return e[46]!==l||e[47]!==N||e[48]!==S||e[49]!==I||e[50]!==$?(O=a.jsxs(En,{open:l,onOpenChange:N,className:"min-w-0 py-2",children:[S,I,$]}),e[46]=l,e[47]=N,e[48]=S,e[49]=I,e[50]=$,e[51]=O):O=e[51],O}function AW(n){const e=q.c(33),{toolCall:t,cwd:s,expandAll:r,isAgentActive:o}=n,i=r===void 0?!1:r,l=o===void 0?!1:o;let c;e[0]!==l||e[1]!==t?(c=kW(t,l),e[0]=l,e[1]=t,e[2]=c):c=e[2];const u=c,d=u.rows.length,[f,m]=Ar(),p=d===1?"Bash command":"Bash commands",h=d===1?"Command":`${d} commands`;let g;e[3]!==h?(g=a.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:h}),e[3]=h,e[4]=g):g=e[4];let x;e[5]!==u.command||e[6]!==m?(x=()=>m(u.command),e[5]=u.command,e[6]=m,e[7]=x):x=e[7];const b=f?"Commands copied":d===1?"Copy command":"Copy commands",y=f?"Copied":d===1?"Copy command":"Copy commands";let v;e[8]!==f?(v=f?a.jsx(Ft,{"data-icon":"inline-start","aria-hidden":"true"}):a.jsx(ys,{"data-icon":"inline-start","aria-hidden":"true"}),e[8]=f,e[9]=v):v=e[9];let k;e[10]!==v||e[11]!==x||e[12]!==b||e[13]!==y?(k=a.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:x,"aria-label":b,title:y,children:v}),e[10]=v,e[11]=x,e[12]=b,e[13]=y,e[14]=k):k=e[14];let j;e[15]!==k||e[16]!==g?(j=a.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2",children:[g,k]}),e[15]=k,e[16]=g,e[17]=j):j=e[17];let _;e[18]!==u.options?(_=u.options.length>0&&a.jsx("div",{className:"flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 py-1 text-xs text-muted-foreground [overflow-wrap:anywhere]",children:u.options.map(PW)}),e[18]=u.options,e[19]=_):_=e[19];let N;e[20]!==u.command||e[21]!==u.rows||e[22]!==d||e[23]!==s||e[24]!==i?(N=d===1?a.jsxs(a.Fragment,{children:[a.jsx("pre",{className:"min-w-0 whitespace-pre-wrap break-words rounded-md bg-muted p-3 font-mono text-xs leading-relaxed text-foreground [overflow-wrap:anywhere]",children:a.jsx($C,{command:u.command,paths:u.rows[0].analysis.paths,cwd:s})}),a.jsx(RC,{row:u.rows[0],cwd:s})]}):a.jsx("div",{className:"min-w-0",children:u.rows.map((E,T)=>a.jsxs("div",{className:"min-w-0",children:[T>0&&a.jsx(Gt,{}),a.jsx(TW,{row:E,expandAll:i,cwd:s})]},T))}),e[20]=u.command,e[21]=u.rows,e[22]=d,e[23]=s,e[24]=i,e[25]=N):N=e[25];let S;e[26]!==_||e[27]!==N?(S=a.jsxs("div",{className:"flex min-w-0 flex-col gap-2","aria-label":"Command sections",children:[_,N]}),e[26]=_,e[27]=N,e[28]=S):S=e[28];let C;return e[29]!==j||e[30]!==S||e[31]!==p?(C=a.jsxs("section",{className:"min-w-0","aria-label":p,children:[j,S]}),e[29]=j,e[30]=S,e[31]=p,e[32]=C):C=e[32],C}function PW(n){return a.jsx("span",{children:n},n)}const OC=w.createContext({size:"default",variant:"default",spacing:2,orientation:"horizontal"});function IW(n){const e=q.c(29);let t,s,r,o,i,l,c;e[0]!==n?({className:s,variant:c,size:o,spacing:i,orientation:l,children:t,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i,e[6]=l,e[7]=c):(t=e[1],s=e[2],r=e[3],o=e[4],i=e[5],l=e[6],c=e[7]);const u=i===void 0?2:i,d=l===void 0?"horizontal":l;let f;e[8]!==u?(f={"--gap":u},e[8]=u,e[9]=f):f=e[9];const m=f;let p;e[10]!==s?(p=G("group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-lg data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-[orientation=vertical]:flex-col data-[orientation=vertical]:items-stretch",s),e[10]=s,e[11]=p):p=e[11];let h;e[12]!==d||e[13]!==o||e[14]!==u||e[15]!==c?(h={variant:c,size:o,spacing:u,orientation:d},e[12]=d,e[13]=o,e[14]=u,e[15]=c,e[16]=h):h=e[16];let g;e[17]!==t||e[18]!==h?(g=a.jsx(OC.Provider,{value:h,children:t}),e[17]=t,e[18]=h,e[19]=g):g=e[19];let x;return e[20]!==d||e[21]!==r||e[22]!==o||e[23]!==u||e[24]!==m||e[25]!==p||e[26]!==g||e[27]!==c?(x=a.jsx(J7,{"data-slot":"toggle-group","data-variant":c,"data-size":o,"data-spacing":u,"data-orientation":d,orientation:d,style:m,className:p,...r,children:g}),e[20]=d,e[21]=r,e[22]=o,e[23]=u,e[24]=m,e[25]=p,e[26]=g,e[27]=c,e[28]=x):x=e[28],x}function $W(n){const e=q.c(19);let t,s,r,o,i;e[0]!==n?({className:s,children:t,variant:o,size:i,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i):(t=e[1],s=e[2],r=e[3],o=e[4],i=e[5]);const l=o===void 0?"default":o,c=i===void 0?"default":i,u=w.useContext(OC),d=u.variant||l,f=u.size||c,m=u.spacing;let p;e[6]!==s||e[7]!==u.size||e[8]!==u.variant||e[9]!==c||e[10]!==l?(p=G("shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-1.5 group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:first:rounded-l-lg group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:first:rounded-t-lg group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:last:rounded-r-lg group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:last:rounded-b-lg group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t",gj({variant:u.variant||l,size:u.size||c}),s),e[6]=s,e[7]=u.size,e[8]=u.variant,e[9]=c,e[10]=l,e[11]=p):p=e[11];let h;return e[12]!==t||e[13]!==u.spacing||e[14]!==r||e[15]!==d||e[16]!==f||e[17]!==p?(h=a.jsx(a3,{"data-slot":"toggle-group-item","data-variant":d,"data-size":f,"data-spacing":m,className:p,...r,children:t}),e[12]=t,e[13]=u.spacing,e[14]=r,e[15]=d,e[16]=f,e[17]=p,e[18]=h):h=e[18],h}function LC(n){const e=q.c(22),{option:t,multiSelect:s,selected:r,showSelectedBadge:o}=n,i=o===void 0?!1:o,l=s?"rounded":"rounded-full",c=r?"border-primary bg-primary text-primary-foreground":"border-muted-foreground/30";let u;e[0]!==l||e[1]!==c?(u=G("mt-0.5 flex size-4 shrink-0 items-center justify-center border",l,c),e[0]=l,e[1]=c,e[2]=u):u=e[2];let d;e[3]!==r?(d=r&&a.jsx(Ft,{className:"size-3",strokeWidth:3,"data-icon":"icon"}),e[3]=r,e[4]=d):d=e[4];let f;e[5]!==u||e[6]!==d?(f=a.jsx("span",{className:u,"aria-hidden":"true",children:d}),e[5]=u,e[6]=d,e[7]=f):f=e[7];let m;e[8]!==r||e[9]!==i?(m=i&&r&&a.jsx(Ue,{variant:"secondary",className:"ml-2",children:"Selected"}),e[8]=r,e[9]=i,e[10]=m):m=e[10];let p;e[11]!==t.label||e[12]!==m?(p=a.jsxs("span",{className:"block text-xs font-medium",children:[t.label,m]}),e[11]=t.label,e[12]=m,e[13]=p):p=e[13];let h;e[14]!==t.description?(h=t.description&&a.jsx("span",{className:"mt-0.5 block text-xs leading-relaxed text-muted-foreground",children:t.description}),e[14]=t.description,e[15]=h):h=e[15];let g;e[16]!==p||e[17]!==h?(g=a.jsxs("span",{className:"min-w-0 flex-1",children:[p,h]}),e[16]=p,e[17]=h,e[18]=g):g=e[18];let x;return e[19]!==g||e[20]!==f?(x=a.jsxs(a.Fragment,{children:[f,g]}),e[19]=g,e[20]=f,e[21]=x):x=e[21],x}function RW(n){const e=q.c(30),{toolCall:t,sessionId:s}=n;let r;e[0]!==t.input.questions?(r=t.input.questions??[],e[0]=t.input.questions,e[1]=r):r=e[1];const o=r;let i;e[2]!==o?(i=()=>Object.fromEntries(o.map(OW)),e[2]=o,e[3]=i):i=e[3];const[l,c]=w.useState(i),[u,d]=w.useState(!1),[f,m]=w.useState(!1),{chat:p}=Hl(),{sendMessage:h}=p;if(o.length===0)return null;let g;e[4]!==l||e[5]!==o||e[6]!==h?(g=()=>{const C=o.map(E=>{var A;const T=(A=l[E.question])==null?void 0:A.trim();return T?o.length>1?`${E.question}
|
|
110
|
+
${T}`:T:null}).filter(Boolean).join(`
|
|
111
|
+
|
|
112
|
+
`);C&&h(C),m(!0)},e[4]=l,e[5]=o,e[6]=h,e[7]=g):g=e[7];const x=g;let b;if(e[8]!==l||e[9]!==x||e[10]!==s||e[11]!==t.id){const C=async E=>{E.preventDefault(),d(!0);try{(await L1(s,t.id,l)).ok?m(!0):x()}catch{x()}d(!1)};b=E=>{C(E)},e[8]=l,e[9]=x,e[10]=s,e[11]=t.id,e[12]=b}else b=e[12];const y=f&&"pointer-events-none opacity-50";let v;e[13]!==y?(v=G("flex flex-col gap-3",y),e[13]=y,e[14]=v):v=e[14];let k;if(e[15]!==l||e[16]!==o||e[17]!==t.id){let C;e[19]!==l||e[20]!==t.id?(C=(E,T)=>{const A=E.options&&E.options.length>0,P=new Set(E.multiSelect?(l[E.question]??"").split(", ").filter(Boolean):[]),I=`ask-user-answer-${t.id}-${T}`;return a.jsxs(IR,{className:"gap-2 border-b border-border pb-3 last:border-b-0 last:pb-0",children:[(E.header||E.question)&&a.jsxs($R,{variant:"label",className:"flex flex-col items-start gap-1",children:[E.header&&a.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:E.header}),a.jsx("span",{className:"text-sm leading-relaxed text-foreground",children:E.question})]}),A?a.jsx(IW,{multiple:E.multiSelect,orientation:"vertical",variant:"outline",value:E.multiSelect?Array.from(P):l[E.question]?[l[E.question]]:[],onValueChange:$=>{if(!E.multiSelect&&$.length===0)return;const O=E.multiSelect?$.join(", "):$[0];c({...l,[E.question]:O})},className:"grid w-full gap-1.5",children:E.options.map(($,O)=>{const M=E.multiSelect?P.has($.label):l[E.question]===$.label;return a.jsx($W,{value:$.label,"aria-label":$.label,className:"h-auto w-full justify-start whitespace-normal px-3 py-2.5 text-left",children:a.jsx(LC,{option:$,multiSelect:E.multiSelect,selected:M})},O)})}):a.jsxs(un,{children:[a.jsx(dn,{htmlFor:I,children:"Answer"}),a.jsx(Yd,{id:I,value:l[E.question]??"",onChange:$=>{c({...l,[E.question]:$.target.value})},rows:2,placeholder:"Type your answer..."})]})]},T)},e[19]=l,e[20]=t.id,e[21]=C):C=e[21],k=o.map(C),e[15]=l,e[16]=o,e[17]=t.id,e[18]=k}else k=e[18];const j=u||f,_=f?"Sent":u?"Sending...":"Send answer";let N;e[22]!==_||e[23]!==j?(N=a.jsx(ee,{type:"submit",size:"sm",disabled:j,children:_}),e[22]=_,e[23]=j,e[24]=N):N=e[24];let S;return e[25]!==N||e[26]!==b||e[27]!==v||e[28]!==k?(S=a.jsxs("form",{onSubmit:b,className:v,children:[k,N]}),e[25]=N,e[26]=b,e[27]=v,e[28]=k,e[29]=S):S=e[29],S}function OW(n){return[n.question,""]}function LW(n){return Array.isArray(n.input.questions)?n.input.questions.filter(e=>typeof e=="object"&&e!==null&&typeof e.question=="string"):[]}function zy(n){try{return JSON.parse(`"${n}"`)}catch{return n.replace(/\\"/g,'"').replace(/\\\\/g,"\\")}}function MW(n){const e={},t=/"((?:\\.|[^"\\])*)"\s*=\s*"((?:\\.|[^"\\])*)"/g;let s;for(;(s=t.exec(n))!==null;)e[zy(s[1])]=zy(s[2]);return e}function zW(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function DW(n,e){const t=(n.options??[]).filter(s=>{const r=s.label.trim();return r?new RegExp(`(^|[^\\p{L}\\p{N}])${zW(r)}(?=$|[^\\p{L}\\p{N}])`,"iu").test(e):!1});return t.length===1?t[0].label:void 0}function FW(n,e){if(n.asyncQuestion)return{};const t=n.input.answers;if(typeof t=="object"&&t!==null&&!Array.isArray(t)){const r=Object.entries(t).filter(o=>typeof o[1]=="string");if(r.length>0)return Object.fromEntries(r)}if(!n.result)return{};const s=MW(n.result);for(const r of e)if(s[r.question]===void 0){const o=DW(r,n.result);o!==void 0&&(s[r.question]=o)}return s}function Dy(n,e,t){return e===void 0?!1:n.multiSelect?e.split(/,\s*/).includes(t):e===t}function UW(n){const e=q.c(30),{question:t,answer:s,index:r,completed:o}=n;let i;e[0]!==t.options?(i=t.options??[],e[0]=t.options,e[1]=i):i=e[1];const l=i;let c;if(e[2]!==s||e[3]!==l||e[4]!==t){let v;e[6]!==s||e[7]!==t?(v=k=>Dy(t,s,k.label),e[6]=s,e[7]=t,e[8]=v):v=e[8],c=l.filter(v),e[2]=s,e[3]=l,e[4]=t,e[5]=c}else c=e[5];const u=c.length,d=o&&s!==void 0&&u===0,f=r+1;let m;e[9]!==f?(m=a.jsx(Ue,{variant:"outline",className:"size-5 rounded-full p-0 font-mono text-muted-foreground",children:f}),e[9]=f,e[10]=m):m=e[10];let p;e[11]!==t.header?(p=t.header&&a.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:t.header}),e[11]=t.header,e[12]=p):p=e[12];let h;e[13]!==m||e[14]!==p?(h=a.jsxs("div",{className:"mb-1.5 flex items-center gap-2",children:[m,p]}),e[13]=m,e[14]=p,e[15]=h):h=e[15];let g;e[16]!==t.question?(g=a.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:t.question}),e[16]=t.question,e[17]=g):g=e[17];let x;e[18]!==s||e[19]!==l||e[20]!==t?(x=l.length>0&&a.jsx("div",{className:"mt-2 flex flex-col divide-y divide-border",children:l.map((v,k)=>{const j=Dy(t,s,v.label);return a.jsx("div",{className:G("flex items-start gap-2.5 py-2",j?"text-foreground":"text-muted-foreground"),children:a.jsx(LC,{option:v,multiSelect:t.multiSelect,selected:j,showSelectedBadge:!0})},`${v.label}-${k}`)})}),e[18]=s,e[19]=l,e[20]=t,e[21]=x):x=e[21];let b;e[22]!==s||e[23]!==d?(b=d&&a.jsxs("div",{className:"mt-2 border-l-2 border-border pl-3",children:[a.jsx("div",{className:"mb-0.5 text-xs font-medium text-muted-foreground",children:"Answer"}),a.jsx("p",{className:"whitespace-pre-wrap break-words text-sm leading-relaxed text-foreground/90",children:s.trim()||"No answer provided"})]}),e[22]=s,e[23]=d,e[24]=b):b=e[24];let y;return e[25]!==h||e[26]!==g||e[27]!==x||e[28]!==b?(y=a.jsxs("div",{className:"border-b border-border py-3 last:border-b-0",children:[h,g,x,b]}),e[25]=h,e[26]=g,e[27]=x,e[28]=b,e[29]=y):y=e[29],y}function BW(n){const e=q.c(63),{toolCall:t,expandToolPayloads:s,isAwaitingAnswer:r,sessionId:o,canAnswer:i}=n,[l,c]=w.useState(!1);let u;e[0]!==t?(u=LW(t),e[0]=t,e[1]=u):u=e[1];const d=u;let f;e[2]!==d||e[3]!==t?(f=FW(t,d),e[2]=d,e[3]=t,e[4]=f):f=e[4];const m=f,p=s||l,h=t.result!==null&&!t.isError&&!t.asyncQuestion,g=!h&&!t.isError&&r&&!!o&&d.length>0;let x;e[5]!==m?(x=Object.keys(m),e[5]=m,e[6]=x):x=e[6];const b=x.length>0,y=t.isError?Ds:h?Mr:Wu,v=t.isError?"Not answered":h?"Answered":g?"Waiting for answer":"No answer recorded",k=t.isError&&"border-destructive/30";let j;e[7]!==k?(j=G("my-1 overflow-hidden rounded-lg border bg-card",k),e[7]=k,e[8]=j):j=e[8];let _;e[9]===Symbol.for("react.memo_cache_sentinel")?(_=a.jsx(o1,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground","data-icon":"inline-start"}),e[9]=_):_=e[9];let N;e[10]===Symbol.for("react.memo_cache_sentinel")?(N=a.jsx("h3",{className:"text-sm font-medium text-foreground",children:"Decision requested"}),e[10]=N):N=e[10];const S=d.length===1?"question":"questions";let C;e[11]!==d.length||e[12]!==S?(C=a.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[N,a.jsxs("span",{className:"text-xs text-muted-foreground",children:[d.length," ",S]})]}),e[11]=d.length,e[12]=S,e[13]=C):C=e[13];const E=t.isError?"destructive":h?"secondary":"outline";let T;e[14]!==y?(T=a.jsx(y,{"data-icon":"inline-start"}),e[14]=y,e[15]=T):T=e[15];let A;e[16]!==v||e[17]!==E||e[18]!==T?(A=a.jsxs(Ue,{variant:E,children:[T,v]}),e[16]=v,e[17]=E,e[18]=T,e[19]=A):A=e[19];let P;e[20]!==A||e[21]!==C?(P=a.jsxs("div",{className:"min-w-0 flex-1",children:[C,A]}),e[20]=A,e[21]=C,e[22]=P):P=e[22];let I;e[23]!==t.timestamp?(I=t.timestamp&&a.jsx("time",{className:"hidden shrink-0 pt-0.5 font-mono text-xs tabular-nums text-muted-foreground sm:block",children:new Date(t.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}),e[23]=t.timestamp,e[24]=I):I=e[24];let $;e[25]!==P||e[26]!==I?($=a.jsxs("header",{className:"flex items-start gap-2.5 border-b px-3 py-2.5",children:[_,P,I]}),e[25]=P,e[26]=I,e[27]=$):$=e[27];let O;e[28]!==m||e[29]!==i||e[30]!==g||e[31]!==d||e[32]!==o||e[33]!==t?(O=g&&o&&i?a.jsx(RW,{toolCall:t,sessionId:o}):d.length>0?d.map((B,V)=>a.jsx(UW,{question:B,answer:m[B.question],index:V,completed:t.result!==null&&!t.asyncQuestion},`${B.question}-${V}`)):a.jsx("p",{className:"py-3 text-sm text-muted-foreground",children:"Question details are unavailable."}),e[28]=m,e[29]=i,e[30]=g,e[31]=d,e[32]=o,e[33]=t,e[34]=O):O=e[34];let M;e[35]!==b||e[36]!==t.asyncQuestion||e[37]!==t.isError||e[38]!==t.result?(M=t.result!==null&&!t.asyncQuestion&&!b&&a.jsxs("div",{className:G("border-t border-border py-3",t.isError?"text-destructive":"text-muted-foreground"),children:[a.jsx("div",{className:"mb-0.5 text-xs font-semibold uppercase tracking-wide opacity-70",children:"Recorded response"}),a.jsx("p",{className:"whitespace-pre-wrap break-words text-sm leading-relaxed",children:t.result})]}),e[35]=b,e[36]=t.asyncQuestion,e[37]=t.isError,e[38]=t.result,e[39]=M):M=e[39];let R;e[40]!==O||e[41]!==M?(R=a.jsxs("div",{className:"px-3",children:[O,M]}),e[40]=O,e[41]=M,e[42]=R):R=e[42];let z;e[43]!==s?(z=()=>{s||c(WW)},e[43]=s,e[44]=z):z=e[44];let W;e[45]!==p?(W=p?a.jsx(Ot,{"data-icon":"inline-start"}):a.jsx(ot,{"data-icon":"inline-start"}),e[45]=p,e[46]=W):W=e[46];let D;e[47]!==p||e[48]!==z||e[49]!==W?(D=a.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:z,className:"-ml-2 text-muted-foreground","aria-expanded":p,children:[W,"Raw details"]}),e[47]=p,e[48]=z,e[49]=W,e[50]=D):D=e[50];let L;e[51]!==p||e[52]!==t.input||e[53]!==t.result?(L=p&&a.jsxs("div",{className:"mt-1.5 grid gap-2 pb-1.5 lg:grid-cols-2",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Input"}),a.jsx("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap break-words rounded-md border bg-muted/30 p-2 font-mono text-xs leading-relaxed text-muted-foreground",children:JSON.stringify(t.input,null,2)})]}),t.result!==null&&a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Result"}),a.jsx("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap break-words rounded-md border bg-muted/30 p-2 font-mono text-xs leading-relaxed text-muted-foreground",children:t.result})]})]}),e[51]=p,e[52]=t.input,e[53]=t.result,e[54]=L):L=e[54];let U;e[55]!==D||e[56]!==L?(U=a.jsxs("div",{className:"border-t px-3 py-1.5",children:[D,L]}),e[55]=D,e[56]=L,e[57]=U):U=e[57];let F;return e[58]!==$||e[59]!==R||e[60]!==U||e[61]!==j?(F=a.jsxs("section",{className:j,"aria-label":"Question history",children:[$,R,U]}),e[58]=$,e[59]=R,e[60]=U,e[61]=j,e[62]=F):F=e[62],F}function WW(n){return!n}function qW(n){const e=q.c(4),{styleName:t}=n;let s;e[0]!==t?(s={Read:Va,Write:Er,Edit:Er,Bash:Ai,Grep:Yn,Glob:eP,WebFetch:Pi,WebSearch:Pi,TodoWrite:Q7,Task:Bs,SendMessage:io,AskUserQuestion:o1,Skill:ll}[t]??i3,e[0]=t,e[1]=s):s=e[1];const r=s;let o;return e[2]!==r?(o=a.jsx(r,{className:"size-4 shrink-0","aria-hidden":"true"}),e[2]=r,e[3]=o):o=e[3],o}const VW={failed:{Icon:vo,label:"Failed",description:"failed"},awaitingReview:{Icon:Wu,label:"Awaiting review",description:"awaiting review"},running:{Icon:vt,label:"Running",description:"running"},unavailable:{Icon:Wu,label:"No result",description:"has no result"},completed:{Icon:Ft,label:"Completed",description:"completed"}};function HW(n,e,t){return e?"failed":n.awaitingReview?"awaitingReview":n.result!==null?"completed":t?"running":"unavailable"}function KW({toolCall:n,failed:e=!!n.isError,isAgentActive:t}){const s=HW(n,e,t),{Icon:r,label:o,description:i}=VW[s],l=s==="running";return a.jsxs("span",{className:G("flex shrink-0 items-center gap-1.5 text-xs text-muted-foreground",e&&"text-destructive",l&&"text-info"),title:o,children:[a.jsx(r,{role:"img","aria-label":`Tool call ${i}`,className:G("size-3.5",l&&"motion-safe:animate-spin")}),a.jsx("span",{className:G(s==="completed"&&"sr-only"),children:o})]})}function GW(n){const e=q.c(7),{fileDiffs:t,additionalFileDiffs:s}=n;let r;e[0]!==t?(r=t==null?void 0:t.map(ZW),e[0]=t,e[1]=r):r=e[1];let o;e[2]!==s?(o=!!s&&a.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:[s," additional file diffs omitted by the agent."]}),e[2]=s,e[3]=o):o=e[3];let i;return e[4]!==r||e[5]!==o?(i=a.jsxs(a.Fragment,{children:[r,o]}),e[4]=r,e[5]=o,e[6]=i):i=e[6],i}function ZW(n){return a.jsxs("section",{"aria-label":`File diff: ${n.filePath}`,className:"mt-3 min-w-0",children:[a.jsx("div",{className:"break-all font-mono text-xs text-muted-foreground",children:n.filePath}),a.jsx(b4,{className:"language-diff",children:DM(n)})]},n.filePath)}const YW={"Read file":["read","reads"],"Write file":["write","writes"],"Edit file":["edit","edits"],"Apply patch":["edit","edits"],"Edit notebook":["edit","edits"],"Run command":["command","commands"],"Continue command":["command","commands"],"Search files":["search","searches"],"Find files":["search","searches"],"Search web":["search","searches"],"Search images":["image search","image searches"],"Open page":["page","pages"],"Open link":["page","pages"],"View image":["image","images"],"Spawn agent":["agent","agents"],"Message agent":["message","messages"],"Ask question":["question","questions"],"Use skill":["skill","skills"],"Update plan":["plan update","plan updates"],"Run tools":["tool batch","tool batches"],"Run tool script":["tool script","tool scripts"]};function Tx(n){var t;if(n.isError)return!0;const e=Xo(n.input);return!e||n.result===null||aa(n).styleName!=="Bash"?!1:((t=_C(e,n.result))==null?void 0:t.some(s=>AC(s).failed))??!1}function XW(n,e=!1){const t=new Map,s={total:n.length,completed:0,awaitingReview:0,failed:0,running:0,unavailable:0,groups:[],text:""};for(const r of n){Tx(r)?s.failed++:r.awaitingReview?s.awaitingReview++:r.result!==null?s.completed++:e?s.running++:s.unavailable++;const{label:o}=aa(r),i=YW[o],l=(i==null?void 0:i[0])??o,c=t.get(l);c?c.count++:t.set(l,{count:1,nouns:i})}return s.groups=[...t].map(([r,{count:o,nouns:i}])=>({label:r,count:o,text:i?`${o} ${i[o===1?0:1]}`:`${r} ×${o}`})),s.text=s.groups.map(r=>r.text).join(" · "),s}function JW(n,e){return e?e.flatMap(t=>t.kind==="thinking"?t.blocks.map(s=>({kind:"thinking",blocks:[s]})):t.toolCalls.map(s=>({kind:"tool_call",toolCall:s}))):n.map(t=>({kind:"tool_call",toolCall:t}))}const QW=3;function eq(n,e,t=!1){if(!e)return{visible:[...n],hidden:0};const s=n.length-QW,r=n.filter((o,i)=>i>=s||o.kind==="tool_call"&&(Tx(o.toolCall)||o.toolCall.awaitingReview||t&&o.toolCall.result===null));return{visible:r,hidden:n.length-r.length}}function tq(n,e=!1){return e?"text-destructive":bB(n)==="mutating"?"text-foreground":"text-muted-foreground"}function nq(n){if(n.isError)return null;const e=n.name==="Read"?n.input.file_path:/(?:^|[._])view_image$/.test(n.name)?n.input.path:null;return typeof e=="string"&&mx(e)?e:null}function sq(n){const e=q.c(27),{summary:t,filePath:s,monospace:r,className:o}=n;let i;e[0]!==t?(i=t.lastIndexOf("/"),e[0]=t,e[1]=i):i=e[1];let l;e[2]!==t?(l=t.lastIndexOf("\\"),e[2]=t,e[3]=l):l=e[3];const c=Math.max(i,l);if(s&&t.length>30&&c>=0){let m;e[4]!==o?(m=G("flex min-w-0 font-mono leading-5",o),e[4]=o,e[5]=m):m=e[5];let p;e[6]!==c||e[7]!==t?(p=t.slice(0,c+1),e[6]=c,e[7]=t,e[8]=p):p=e[8];let h;e[9]!==p?(h=a.jsx("span",{className:"truncate",children:p}),e[9]=p,e[10]=h):h=e[10];let g;e[11]!==c||e[12]!==t?(g=t.slice(c+1),e[11]=c,e[12]=t,e[13]=g):g=e[13];let x;e[14]!==g?(x=a.jsx("span",{className:"max-w-full shrink-0 truncate",children:g}),e[14]=g,e[15]=x):x=e[15];let b;return e[16]!==t||e[17]!==m||e[18]!==h||e[19]!==x?(b=a.jsxs("span",{className:m,title:t,children:[h,x]}),e[16]=t,e[17]=m,e[18]=h,e[19]=x,e[20]=b):b=e[20],b}const u=r&&"font-mono";let d;e[21]!==o||e[22]!==u?(d=G("line-clamp-2 min-w-0 leading-5 [overflow-wrap:anywhere]",u,o),e[21]=o,e[22]=u,e[23]=d):d=e[23];let f;return e[24]!==t||e[25]!==d?(f=a.jsx("span",{className:d,title:t,children:t}),e[24]=t,e[25]=d,e[26]=f):f=e[26],f}function rq(n){const e=q.c(4),{toolCall:t}=n,s=t.input.old_string,r=t.input.new_string,o=t.input.file_path;let i;return e[0]!==s||e[1]!==r||e[2]!==o?(i=a.jsx(_x,{oldString:s,newString:r,filePath:o}),e[0]=s,e[1]=r,e[2]=o,e[3]=i):i=e[3],i}const MC=w.memo(function(e){var de,ce,xe,pe;const t=q.c(189),{toolCall:s,expandToolPayloads:r,isAgentActive:o,skillMetadata:i}=e,l=r===void 0?!1:r,{session:c,pendingInteraction:u,permissions:d}=xt(),[f,m]=w.useState(!1),[p,h]=w.useState(!1),g=w.useId(),x=w.useId(),b=w.useId();let y;t[0]!==s?(y=ax(s),t[0]=s,t[1]=y):y=t[1];const v=y;let k;t[2]!==v||t[3]!==s.input||t[4]!==s.name?(k=!v&&(s.name==="Bash"||/(?:^|[._])exec_command$/.test(s.name))&&!!Xo(s.input),t[2]=v,t[3]=s.input,t[4]=s.name,t[5]=k):k=t[5];const j=k;let _;t[6]!==s?(_=aa(s),t[6]=s,t[7]=_):_=t[7];const N=_;let S;t[8]!==j||t[9]!==s?(S=j?PC(s):null,t[8]=j,t[9]=s,t[10]=S):S=t[10];const C=S;let E;t[11]!==s?(E=Tx(s),t[11]=s,t[12]=E):E=t[12];const T=E,A=N.label,P=N.label===s.name?s.name:`${N.label} (${s.name})`;let I,$,O,M,R,z,W,D,L,U;if(t[13]!==A||t[14]!==l||t[15]!==T||t[16]!==j||t[17]!==o||t[18]!==P||t[19]!==g||t[20]!==f||t[21]!==u||t[22]!==d||t[23]!==N.styleName||t[24]!==N.summary||t[25]!==C||t[26]!==(c==null?void 0:c.sessionId)||t[27]!==i||t[28]!==b||t[29]!==s){W=Symbol.for("react.early_return_sentinel");e:{const he=tq(N.styleName,T);let ye;t[40]!==s.timestamp?(ye=s.timestamp?new Date(s.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}):void 0,t[40]=s.timestamp,t[41]=ye):ye=t[41];const ve=ye;let ke;t[42]!==s.timestamp?(ke=s.timestamp?new Date(s.timestamp).toISOString():void 0,t[42]=s.timestamp,t[43]=ke):ke=t[43];const je=ke;$=l||f;let Me;t[44]!==j||t[45]!==N.summary||t[46]!==C||t[47]!==s.input?(Me=j&&typeof s.input.description=="string"&&s.input.description.trim()?s.input.description:C&&C.length>1?`${C.length} commands · ${C.map(oq).join(", ")}`:N.summary,t[44]=j,t[45]=N.summary,t[46]=C,t[47]=s.input,t[48]=Me):Me=t[48];const _e=Me;let Fe;t[49]!==i||t[50]!==_e||t[51]!==s.name?(Fe=s.name==="Skill"&&i?i.get(_e)??null:null,t[49]=i,t[50]=_e,t[51]=s.name,t[52]=Fe):Fe=t[52],R=Fe,M=R==null?void 0:R.filePath,I=s.name==="Edit"&&typeof s.input.old_string=="string"&&typeof s.input.new_string=="string"&&typeof s.input.file_path=="string";const ze=nq(s),We=!!((de=s.resultImages)!=null&&de.length),Pe=ze!==null&&((ce=s.result)==null?void 0:ce.trim())===""&&!We;let qe;if(t[53]!==j||t[54]!==I||t[55]!==Pe||t[56]!==We||t[57]!==s.awaitingReview||t[58]!==s.isError||t[59]!==s.result?(qe=s.result!==null&&!Pe&&!j&&(!We||!!((xe=s.result)!=null&&xe.trim()))&&(!I||s.isError||s.awaitingReview),t[53]=j,t[54]=I,t[55]=Pe,t[56]=We,t[57]=s.awaitingReview,t[58]=s.isError,t[59]=s.result,t[60]=qe):qe=t[60],O=qe,s.name==="AskUserQuestion"){const ts=(u==null?void 0:u.type)==="question"&&u.toolUseId===s.id,ns=c==null?void 0:c.sessionId;let Bt;t[61]!==l||t[62]!==d.answer||t[63]!==ts||t[64]!==ns||t[65]!==s?(Bt=a.jsx(BW,{toolCall:s,expandToolPayloads:l,isAwaitingAnswer:ts,sessionId:ns,canAnswer:d.answer}),t[61]=l,t[62]=d.answer,t[63]=ts,t[64]=ns,t[65]=s,t[66]=Bt):Bt=t[66],W=Bt;break e}const be=$&&"bg-muted",Ie=T&&"bg-destructive/5";t[67]!==be||t[68]!==Ie?(D=G("min-w-0 rounded-lg",be,Ie),t[67]=be,t[68]=Ie,t[69]=D):D=t[69],L=s.id;const Se=`Toggle ${A} details${_e?`: ${_e}`:""}`;let Ne;t[70]!==l?(Ne=()=>{l||m(iq)},t[70]=l,t[71]=Ne):Ne=t[71];const He=T&&"text-destructive";let Ke;t[72]!==He?(Ke=G("flex size-8 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground",He),t[72]=He,t[73]=Ke):Ke=t[73];let Ce;t[74]!==N.styleName?(Ce=a.jsx(qW,{styleName:N.styleName}),t[74]=N.styleName,t[75]=Ce):Ce=t[75];let Be;t[76]!==Ke||t[77]!==Ce?(Be=a.jsx("span",{className:Ke,children:Ce}),t[76]=Ke,t[77]=Ce,t[78]=Be):Be=t[78];const Ye=_e&&a.jsx(sq,{summary:_e,filePath:[s.input.file_path,s.input.path,s.input.notebook_path].includes(_e),monospace:!j||!s.input.description,className:G("text-[13px] font-medium",he)}),Xe=G(_e?"text-xs text-muted-foreground":G("text-[13px] font-medium",he),"leading-5");let nt;t[79]!==A||t[80]!==P||t[81]!==Xe?(nt=a.jsx("span",{className:Xe,title:P,children:A}),t[79]=A,t[80]=P,t[81]=Xe,t[82]=nt):nt=t[82];let Qe;t[83]!==Ye||t[84]!==nt?(Qe=a.jsxs("span",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[Ye,nt]}),t[83]=Ye,t[84]=nt,t[85]=Qe):Qe=t[85];let Ee;t[86]!==T||t[87]!==o||t[88]!==s?(Ee=a.jsx(KW,{toolCall:s,failed:T,isAgentActive:o}),t[86]=T,t[87]=o,t[88]=s,t[89]=Ee):Ee=t[89];let me;t[90]!==s.hookDurationMs?(me=!!(s.hookDurationMs&&s.hookDurationMs>0)&&a.jsxs("span",{className:"text-xs tabular-nums text-muted-foreground",title:"PostToolUse hook duration",children:[s.hookDurationMs,"ms"]}),t[90]=s.hookDurationMs,t[91]=me):me=t[91];let Oe;t[92]!==s.outputReplacedByHook?(Oe=s.outputReplacedByHook&&a.jsx("span",{className:"text-xs text-info",title:"Output replaced by hook",children:"hook"}),t[92]=s.outputReplacedByHook,t[93]=Oe):Oe=t[93];let Ge;t[94]!==b||t[95]!==Ee||t[96]!==me||t[97]!==Oe?(Ge=a.jsxs("span",{id:b,className:"flex shrink-0 flex-col items-end gap-1",children:[Ee,me,Oe]}),t[94]=b,t[95]=Ee,t[96]=me,t[97]=Oe,t[98]=Ge):Ge=t[98];const rt=$&&"rotate-90";let wt;t[99]!==rt?(wt=G("size-3.5 shrink-0 text-muted-foreground transition-transform",rt),t[99]=rt,t[100]=wt):wt=t[100];let Ct;t[101]!==wt?(Ct=a.jsx(ot,{className:wt,"aria-hidden":"true"}),t[101]=wt,t[102]=Ct):Ct=t[102];let Pn;t[103]!==je||t[104]!==ve?(Pn=ve&&a.jsx("time",{className:"sr-only",dateTime:je,children:ve}),t[103]=je,t[104]=ve,t[105]=Pn):Pn=t[105],t[106]!==g||t[107]!==$||t[108]!==b||t[109]!==Se||t[110]!==Ne||t[111]!==Be||t[112]!==Qe||t[113]!==Ge||t[114]!==Ct||t[115]!==Pn||t[116]!==ve?(U=a.jsxs("button",{type:"button",className:"group/tool flex min-h-14 w-full min-w-0 items-center gap-3 rounded-lg px-3 py-2.5 text-left transition-colors hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",title:ve,"aria-label":Se,"aria-expanded":$,"aria-controls":g,"aria-describedby":b,onClick:Ne,children:[Be,Qe,Ge,Ct,Pn]}),t[106]=g,t[107]=$,t[108]=b,t[109]=Se,t[110]=Ne,t[111]=Be,t[112]=Qe,t[113]=Ge,t[114]=Ct,t[115]=Pn,t[116]=ve,t[117]=U):U=t[117],z=Pe&&a.jsx(Zh,{src:ze,alt:ze.slice(ze.lastIndexOf("/")+1),id:`tool-image:${s.id}`,className:"my-1.5",thumbnailClassName:"max-h-40"})}t[13]=A,t[14]=l,t[15]=T,t[16]=j,t[17]=o,t[18]=P,t[19]=g,t[20]=f,t[21]=u,t[22]=d,t[23]=N.styleName,t[24]=N.summary,t[25]=C,t[26]=c==null?void 0:c.sessionId,t[27]=i,t[28]=b,t[29]=s,t[30]=I,t[31]=$,t[32]=O,t[33]=M,t[34]=R,t[35]=z,t[36]=W,t[37]=D,t[38]=L,t[39]=U}else I=t[30],$=t[31],O=t[32],M=t[33],R=t[34],z=t[35],W=t[36],D=t[37],L=t[38],U=t[39];if(W!==Symbol.for("react.early_return_sentinel"))return W;let F;t[118]!==s.id||t[119]!==s.resultImages?(F=(pe=s.resultImages)==null?void 0:pe.map((he,ye)=>a.jsx(Zh,{src:`data:${he.source.media_type};base64,${he.source.data}`,alt:`Tool result image ${ye+1}`,id:`tool-result-image:${s.id}:${ye}`,className:"my-1.5",thumbnailClassName:"max-h-40"},`${he.source.media_type}-${he.source.data.length}-${he.source.data.slice(0,32)}-${he.source.data.slice(-32)}`)),t[118]=s.id,t[119]=s.resultImages,t[120]=F):F=t[120];let B;t[121]!==M||t[122]!==R?(B=R&&a.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-2 font-mono text-xs text-muted-foreground",children:[a.jsxs("span",{children:["source: ",R.source]}),M&&(!yo()||X1())&&a.jsxs(ee,{type:"button",variant:"link",size:"xs",onClick:()=>xl(M),title:M,children:[a.jsx(S3,{"data-icon":"inline-start"}),"Open SKILL.md"]})]}),t[121]=M,t[122]=R,t[123]=B):B=t[123];let V;t[124]!==I||t[125]!==s?(V=I&&a.jsx(rq,{toolCall:s}),t[124]=I,t[125]=s,t[126]=V):V=t[126];let H;t[127]!==l||t[128]!==j||t[129]!==I||t[130]!==o||t[131]!==v||t[132]!==(c==null?void 0:c.cwd)||t[133]!==s?(H=j?a.jsx(AW,{toolCall:s,cwd:c==null?void 0:c.cwd,expandAll:l,isAgentActive:!!o}):v?a.jsx(KB,{input:s.input}):I?null:a.jsx(CC,{input:s.input}),t[127]=l,t[128]=j,t[129]=I,t[130]=o,t[131]=v,t[132]=c==null?void 0:c.cwd,t[133]=s,t[134]=H):H=t[134];let K;t[135]!==s.additionalFileDiffs||t[136]!==s.fileDiffs?(K=a.jsx(GW,{fileDiffs:s.fileDiffs,additionalFileDiffs:s.additionalFileDiffs}),t[135]=s.additionalFileDiffs,t[136]=s.fileDiffs,t[137]=K):K=t[137];let Z;t[138]!==O||t[139]!==s.input||t[140]!==s.isError||t[141]!==s.name||t[142]!==s.result?(Z=O&&a.jsx(x4,{result:s.result??"",isError:s.isError,filePath:s.name==="Read"&&typeof s.input.file_path=="string"?s.input.file_path:void 0}),t[138]=O,t[139]=s.input,t[140]=s.isError,t[141]=s.name,t[142]=s.result,t[143]=Z):Z=t[143];let Y;t[144]===Symbol.for("react.memo_cache_sentinel")?(Y=()=>h(aq),t[144]=Y):Y=t[144];const X=p&&"rotate-90";let se;t[145]!==X?(se=G(X),t[145]=X,t[146]=se):se=t[146];let Q;t[147]!==se?(Q=a.jsx(ot,{"data-icon":"inline-start",className:se}),t[147]=se,t[148]=Q):Q=t[148];let te;t[149]!==x||t[150]!==p||t[151]!==Q?(te=a.jsxs(ee,{type:"button",variant:"ghost",size:"xs",className:"mt-1","aria-expanded":p,"aria-controls":x,onClick:Y,children:[Q,"Raw input"]}),t[149]=x,t[150]=p,t[151]=Q,t[152]=te):te=t[152];let J;t[153]!==s.input?(J=JSON.stringify(s.input),t[153]=s.input,t[154]=J):J=t[154];let ne;t[155]!==J?(ne=a.jsx(g4,{result:J}),t[155]=J,t[156]=ne):ne=t[156];let re;t[157]!==x||t[158]!==ne?(re=a.jsx(Tn,{id:x,children:ne}),t[157]=x,t[158]=ne,t[159]=re):re=t[159];let le;t[160]!==p||t[161]!==te||t[162]!==re?(le=a.jsxs(En,{open:p,children:[te,re]}),t[160]=p,t[161]=te,t[162]=re,t[163]=le):le=t[163];let ae;t[164]!==V||t[165]!==H||t[166]!==K||t[167]!==Z||t[168]!==le?(ae=a.jsxs("div",{className:"min-w-0 px-3 pb-3 pt-1 sm:pl-14",children:[V,H,K,Z,le]}),t[164]=V,t[165]=H,t[166]=K,t[167]=Z,t[168]=le,t[169]=ae):ae=t[169];let ue;t[170]!==g||t[171]!==ae?(ue=a.jsx(Tn,{id:g,children:ae}),t[170]=g,t[171]=ae,t[172]=ue):ue=t[172];let oe;t[173]!==$||t[174]!==ue?(oe=a.jsx(En,{open:$,children:ue}),t[173]=$,t[174]=ue,t[175]=oe):oe=t[175];let ie;t[176]!==s.id||t[177]!==s.name||t[178]!==s.result?(ie=(s.name==="Task"||s.name==="Agent")&&s.result===null&&a.jsx(Nx,{toolUseId:s.id}),t[176]=s.id,t[177]=s.name,t[178]=s.result,t[179]=ie):ie=t[179];let fe;return t[180]!==z||t[181]!==F||t[182]!==B||t[183]!==oe||t[184]!==ie||t[185]!==D||t[186]!==L||t[187]!==U?(fe=a.jsxs("div",{className:D,"data-tool-call-id":L,children:[U,z,F,B,oe,ie]}),t[180]=z,t[181]=F,t[182]=B,t[183]=oe,t[184]=ie,t[185]=D,t[186]=L,t[187]=U,t[188]=fe):fe=t[188],fe});function oq(n){return n.label||n.command.split(/\s+/)[0]}function iq(n){return!n}function aq(n){return!n}const lq=w.memo(function({plan:e,planFilePath:t,status:s,toolCalls:r,expandAll:o=!1,expandToolPayloads:i=!1,isAgentActive:l,skillMetadata:c}){const[u,d]=w.useState(!0),f=r.some(k=>k.name==="AskUserQuestion"&&k.result===null),[m,p]=w.useState(null),h=w.useRef(f);w.useEffect(()=>{f&&(h.current=!0)},[f]);const g=o||u,x=o||(m??(f||h.current)),b=s==="approved"?$d:s==="rejected"?vo:oo,y=g?Ot:ot,v=x?Ot:ot;return a.jsxs(En,{open:g,onOpenChange:d,className:G("my-2 rounded-lg border",s==="approved"?"border-success/20 bg-success/5":s==="rejected"?"border-destructive/20 bg-destructive/5":"border-warning/20 bg-warning/5"),children:[a.jsxs(vs,{render:a.jsx(ee,{type:"button",variant:"ghost",className:"h-auto w-full justify-start rounded-b-none p-2 text-left"}),children:[a.jsx(y,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),a.jsx(tP,{className:"size-4 text-muted-foreground","data-icon":"inline-start"}),a.jsx("span",{className:"text-sm font-medium",children:"Plan Mode"}),a.jsx(b,{className:G("size-4",s==="approved"?"text-success":s==="rejected"?"text-destructive":"text-warning")}),a.jsx("span",{className:"text-xs text-muted-foreground capitalize",children:s}),t&&a.jsx("span",{className:"ml-auto truncate font-mono text-xs text-muted-foreground",children:t})]}),a.jsx(Tn,{children:a.jsxs("div",{className:"px-3 pb-2",children:[a.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none border-t pt-2",children:a.jsx(cr,{remarkPlugins:gr,components:hr,children:e})}),r.length>0&&a.jsxs(En,{open:x,onOpenChange:p,className:"mt-2",children:[a.jsxs(vs,{render:a.jsx(ee,{type:"button",variant:"ghost",size:"xs",className:"-ml-2 text-muted-foreground"}),children:[a.jsx(v,{"data-icon":"inline-start"}),r.length," call",r.length===1?"":"s"," during planning"]}),a.jsx(Tn,{children:a.jsx("div",{className:"ml-4 mt-1 flex flex-col gap-1",children:r.map(k=>a.jsx(MC,{toolCall:k,expandToolPayloads:i,isAgentActive:l,skillMetadata:c},k.id))})})]})]})})]})}),cq=w.memo(function(e){const t=q.c(13),{content:s}=e,[r,o]=w.useState(!0),i=r?Ot:ot;let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(ee,{type:"button",variant:"ghost",className:"h-auto w-full justify-start rounded-b-none p-2 text-left"}),t[0]=l):l=t[0];let c;t[1]!==i?(c=a.jsx(i,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),t[1]=i,t[2]=c):c=t[2];let u,d;t[3]===Symbol.for("react.memo_cache_sentinel")?(u=a.jsx(k3,{className:"size-4 text-muted-foreground","data-icon":"inline-start"}),d=a.jsx("span",{className:"text-sm font-medium",children:"Session recap"}),t[3]=u,t[4]=d):(u=t[3],d=t[4]);let f;t[5]!==c?(f=a.jsxs(vs,{render:l,children:[c,u,d]}),t[5]=c,t[6]=f):f=t[6];let m;t[7]!==s?(m=a.jsx(Tn,{children:a.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none border-t px-3 pb-2 pt-2",children:a.jsx(cr,{remarkPlugins:gr,components:hr,children:s})})}),t[7]=s,t[8]=m):m=t[8];let p;return t[9]!==r||t[10]!==f||t[11]!==m?(p=a.jsxs(En,{open:r,onOpenChange:o,className:"my-2 rounded-lg border bg-card",children:[f,m]}),t[9]=r,t[10]=f,t[11]=m,t[12]=p):p=t[12],p}),uq=w.memo(function(e){const t=q.c(4),{blocks:s}=e;if(s.length===0)return null;let r;t[0]!==s?(r=s.map(dq),t[0]=s,t[1]=r):r=t[1];let o;return t[2]!==r?(o=a.jsx("div",{className:"flex flex-col gap-2",children:r}),t[2]=r,t[3]=o):o=t[3],o});function dq(n,e){return a.jsx("pre",{className:"text-xs text-muted-foreground/70 font-mono whitespace-pre-wrap break-words max-h-96 overflow-y-auto",children:n.thinking},e)}const Fy=w.memo(function(e){const t=q.c(115),{toolCalls:s,expandAll:r,expandToolPayloads:o,activeToolCallId:i,isAgentActive:l,activityItems:c,thinkingCount:u,thoughtForMs:d,skillMetadata:f}=e,m=l===void 0?!1:l,p=u===void 0?0:u,h=d===void 0?0:d,[g,x]=w.useState(null),b=w.useRef(null),y=w.useId(),v=w.useId();let k;t[0]!==m||t[1]!==s?(k=XW(s,m),t[0]=m,t[1]=s,t[2]=k):k=t[2];const j=k,_=j.running>0;let N;t[3]!==s?(N=s.some(fq),t[3]=s,t[4]=N):N=t[4];const S=N,C=r||S||(g??_),E=g===null&&_&&!r&&!S;let T;t[5]!==c||t[6]!==s?(T=JW(s,c),t[5]=c,t[6]=s,t[7]=T):T=t[7];const A=T;let P;t[8]!==A||t[9]!==m||t[10]!==E?(P=eq(A,E,m),t[8]=A,t[9]=m,t[10]=E,t[11]=P):P=t[11];const I=P,$=w.useRef(null),O=w.useRef(null);let M,R;t[12]!==i||t[13]!==s?(M=()=>{if(!i){$.current=null;return}i!==$.current&&s.some(ne=>ne.id===i)&&($.current=i,x(!0),O.current=requestAnimationFrame(()=>{O.current=requestAnimationFrame(()=>{var ne;O.current=null,(ne=b.current)==null||ne.scrollIntoView({behavior:"smooth",block:"nearest"})})}))},R=[i,s],t[12]=i,t[13]=s,t[14]=M,t[15]=R):(M=t[14],R=t[15]),w.useEffect(M,R);let z,W;t[16]===Symbol.for("react.memo_cache_sentinel")?(z=()=>()=>{O.current!==null&&cancelAnimationFrame(O.current)},W=[],t[16]=z,t[17]=W):(z=t[16],W=t[17]),w.useEffect(z,W);let D,L,U,F,B,V,H,K,Z,Y,X;if(t[18]!==i||t[19]!==c||t[20]!==A||t[21]!==r||t[22]!==o||t[23]!==S||t[24]!==m||t[25]!==C||t[26]!==y||t[27]!==f||t[28]!==v||t[29]!==j.awaitingReview||t[30]!==j.failed||t[31]!==j.running||t[32]!==j.text||t[33]!==j.unavailable||t[34]!==I||t[35]!==p||t[36]!==h||t[37]!==s[0]||t[38]!==s.length){X=Symbol.for("react.early_return_sentinel");e:{const ne=function(Pe){const qe=i===Pe.id;return a.jsx("div",{ref:qe?b:void 0,className:G("min-w-0",qe&&"rounded-lg ring-2 ring-ring"),children:a.jsx(MC,{toolCall:Pe,expandToolPayloads:o,isAgentActive:m&&Pe.result===null,skillMetadata:f})},Pe.id)};if(s.length===1&&p===0&&!c){X=ne(s[0]);break e}const re=s.length>0?`${s.length} tool ${s.length===1?"call":"calls"}`:"Thinking";let le;t[50]!==p||t[51]!==h?(le=h>0?`Thought for ${Math.max(1,Math.round(h/1e3))}s`:p>0?"Includes thinking":"",t[50]=p,t[51]=h,t[52]=le):le=t[52];const ae=le;let ue;t[53]!==j.text||t[54]!==ae?(ue=[j.text,ae].filter(Boolean),t[53]=j.text,t[54]=ae,t[55]=ue):ue=t[55];const oe=ue.join(" · ");K="min-w-0 rounded-xl border border-border/80 bg-card",Z="";const ie=`${C?"Collapse":"Expand"} ${re}${oe?`: ${oe}`:""}`,fe=r||S||void 0;let de;t[56]!==r||t[57]!==S||t[58]!==C?(de=()=>{!r&&!S&&x(!C)},t[56]=r,t[57]=S,t[58]=C,t[59]=de):de=t[59];let ce;t[60]===Symbol.for("react.memo_cache_sentinel")?(ce=a.jsx(nP,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),t[60]=ce):ce=t[60];let xe;t[61]!==re?(xe=a.jsx("span",{className:"text-[13px] font-medium text-foreground",children:re}),t[61]=re,t[62]=xe):xe=t[62];let pe;t[63]!==oe?(pe=oe&&a.jsx("span",{className:"text-xs leading-5 text-muted-foreground [overflow-wrap:anywhere]",children:oe}),t[63]=oe,t[64]=pe):pe=t[64];let he;t[65]!==xe||t[66]!==pe?(he=a.jsxs("span",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[xe,pe]}),t[65]=xe,t[66]=pe,t[67]=he):he=t[67];let ye;t[68]!==j.running?(ye=j.running>0&&a.jsxs("span",{className:"flex items-center gap-1.5 text-info",children:[a.jsx(vt,{className:"size-3.5 motion-safe:animate-spin","aria-hidden":"true"}),j.running," running"]}),t[68]=j.running,t[69]=ye):ye=t[69];let ve;t[70]!==j.failed?(ve=j.failed>0&&a.jsxs("span",{className:"flex items-center gap-1.5 text-destructive",children:[a.jsx(vo,{className:"size-3.5","aria-hidden":"true"}),j.failed," failed"]}),t[70]=j.failed,t[71]=ve):ve=t[71];let ke;t[72]!==j.awaitingReview?(ke=j.awaitingReview>0&&a.jsxs("span",{className:"text-muted-foreground",children:[j.awaitingReview," awaiting review"]}),t[72]=j.awaitingReview,t[73]=ke):ke=t[73];let je;t[74]!==j.unavailable?(je=j.unavailable>0&&a.jsxs("span",{className:"text-muted-foreground",children:[j.unavailable," no result"]}),t[74]=j.unavailable,t[75]=je):je=t[75];let Me;t[76]!==v||t[77]!==ye||t[78]!==ve||t[79]!==ke||t[80]!==je?(Me=a.jsxs("span",{id:v,className:"flex shrink-0 flex-col items-end gap-1 text-xs",children:[ye,ve,ke,je]}),t[76]=v,t[77]=ye,t[78]=ve,t[79]=ke,t[80]=je,t[81]=Me):Me=t[81];const _e=C&&"rotate-90";let Fe;t[82]!==_e?(Fe=G("size-3.5 shrink-0 text-muted-foreground transition-transform",_e),t[82]=_e,t[83]=Fe):Fe=t[83];let ze;t[84]!==Fe?(ze=a.jsx(ot,{className:Fe,"aria-hidden":"true"}),t[84]=Fe,t[85]=ze):ze=t[85],t[86]!==C||t[87]!==y||t[88]!==v||t[89]!==ie||t[90]!==fe||t[91]!==de||t[92]!==he||t[93]!==Me||t[94]!==ze?(Y=a.jsxs("button",{type:"button",className:"flex min-h-14 w-full min-w-0 items-center gap-3 rounded-xl px-3 py-3 text-left transition-colors hover:bg-muted/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":ie,"aria-expanded":C,"aria-controls":y,"aria-describedby":v,"aria-disabled":fe,onClick:de,children:[ce,he,Me,ze]}),t[86]=C,t[87]=y,t[88]=v,t[89]=ie,t[90]=fe,t[91]=de,t[92]=he,t[93]=Me,t[94]=ze,t[95]=Y):Y=t[95],L=En,H=C,D=Tn,V=y,U="min-w-0 border-t border-border/70 px-1 py-1",t[96]!==I.hidden?(F=I.hidden>0&&a.jsxs(ee,{type:"button",variant:"ghost",size:"sm",className:"mb-1 ml-2",onClick:()=>x(!0),children:["Show ",I.hidden," earlier ",I.hidden===1?"step":"steps"]}),t[96]=I.hidden,t[97]=F):F=t[97],B=I.visible.map(We=>We.kind==="tool_call"?ne(We.toolCall):a.jsx("div",{className:"px-3 py-1",children:a.jsx(uq,{blocks:We.blocks})},`thinking-${A.filter(mq).indexOf(We)}`))}t[18]=i,t[19]=c,t[20]=A,t[21]=r,t[22]=o,t[23]=S,t[24]=m,t[25]=C,t[26]=y,t[27]=f,t[28]=v,t[29]=j.awaitingReview,t[30]=j.failed,t[31]=j.running,t[32]=j.text,t[33]=j.unavailable,t[34]=I,t[35]=p,t[36]=h,t[37]=s[0],t[38]=s.length,t[39]=D,t[40]=L,t[41]=U,t[42]=F,t[43]=B,t[44]=V,t[45]=H,t[46]=K,t[47]=Z,t[48]=Y,t[49]=X}else D=t[39],L=t[40],U=t[41],F=t[42],B=t[43],V=t[44],H=t[45],K=t[46],Z=t[47],Y=t[48],X=t[49];if(X!==Symbol.for("react.early_return_sentinel"))return X;let se;t[98]!==U||t[99]!==F||t[100]!==B?(se=a.jsxs("div",{className:U,children:[F,B]}),t[98]=U,t[99]=F,t[100]=B,t[101]=se):se=t[101];let Q;t[102]!==D||t[103]!==V||t[104]!==se?(Q=a.jsx(D,{id:V,children:se}),t[102]=D,t[103]=V,t[104]=se,t[105]=Q):Q=t[105];let te;t[106]!==L||t[107]!==H||t[108]!==Q?(te=a.jsx(L,{open:H,children:Q}),t[106]=L,t[107]=H,t[108]=Q,t[109]=te):te=t[109];let J;return t[110]!==K||t[111]!==Z||t[112]!==Y||t[113]!==te?(J=a.jsxs("div",{className:K,"data-tool-activity":Z,children:[Y,te]}),t[110]=K,t[111]=Z,t[112]=Y,t[113]=te,t[114]=J):J=t[114],J});function fq(n){return n.name==="AskUserQuestion"}function mq(n){return n.kind==="thinking"}function pq(n){const e=q.c(15),{label:t,expanded:s,onToggle:r,compact:o}=n,l=(o===void 0?!1:o)&&"min-h-9";let c;e[0]!==l?(c=G("group/fold h-auto min-h-8 w-full cursor-pointer justify-start gap-1.5 px-1 text-left text-xs font-normal text-muted-foreground",l),e[0]=l,e[1]=c):c=e[1];const u=s&&"rotate-90";let d;e[2]!==u?(d=G("size-3 shrink-0 transition-transform duration-150 motion-reduce:transition-none",u),e[2]=u,e[3]=d):d=e[3];let f;e[4]!==d?(f=a.jsx(ot,{"data-icon":"inline-start",className:d}),e[4]=d,e[5]=f):f=e[5];let m;e[6]!==t?(m=a.jsx("span",{className:"tabular-nums",children:t}),e[6]=t,e[7]=m):m=e[7];let p;e[8]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsx("span",{"aria-hidden":!0,className:"pointer-events-none ml-1 h-px flex-1 bg-border/40 transition-colors group-hover/fold:bg-border/70"}),e[8]=p):p=e[8];let h;return e[9]!==s||e[10]!==r||e[11]!==c||e[12]!==f||e[13]!==m?(h=a.jsxs(ee,{type:"button",variant:"ghost",onClick:r,"aria-expanded":s,className:c,children:[f,m,p]}),e[9]=s,e[10]=r,e[11]=c,e[12]=f,e[13]=m,e[14]=h):h=e[14],h}const zC="synthesizedFrom",Uy=/[.*+?[\]{}()^$|]/,hq=/[$*?`~]|\\\s/,DC=/<<(-?)\s*(?:'([^']+)'|"([^"]+)")/,gq=new RegExp(DC,"g");function ld(n,e,t,s){return{id:e,name:t,input:{...s,[zC]:n.name},result:null,isError:!1,timestamp:n.timestamp}}function xq(n){return typeof n.input[zC]=="string"}function bq(n){const e=n[0];return(e==='"'||e==="'")&&n.at(-1)===e?n.slice(1,-1):n}function By(n){const e=[];for(const t of n.split("/"))!t||t==="."||(t===".."?e.pop():e.push(t));return`/${e.join("/")}`}function hf(n,e){const t=bq(n.trim());return!t||hq.test(t)?null:t.startsWith("/")?By(t):e?By(`${e}/${t}`):null}function vq(n){const e=[];let t="",s=null;function r(o){t.trim()&&e.push({text:t.trim(),piped:o}),t=""}for(let o=0;o<n.length;o++){const i=n[o];if(s){t+=i,i===s&&(s=null);continue}if(i==='"'||i==="'"){s=i,t+=i;continue}if(i==="|"){r(!0),n[o+1]==="|"&&o++;continue}if(i===";"||i==="&"&&n[o+1]==="&"){r(!1),i==="&"&&o++;continue}t+=i}return r(!1),e}function yq(n){const e=n.split(`
|
|
113
|
+
`),t=[];let s=0;for(;s<e.length;){const r=e[s];s++;const o=new Map;for(const i of r.matchAll(gq)){const[,l,c,u]=i,d=c??u,f=[];for(;s<e.length&&e[s].trim()!==d;)f.push(l?e[s].replace(/^\t+/,""):e[s]),s++;s>=e.length||(s++,o.set(d,f.join(`
|
|
114
|
+
`)))}for(const i of vq(r))t.push({text:i.text,bodies:o,piped:i.piped})}return t}function wq(n,e){const t=n.match(/^cd\s+(?:"([^"]*)"|'([^']*)'|([^\s;&|]+))\s*$/);return t?hf(t[1]??t[2]??t[3]??"",e):null}function Sq(n){const e=n.match(/^tee\s+(?:(-a)\s+)?(?:"([^"]+)"|'([^']+)'|([^\s<>|;&]+))/);if(e)return e[1]?null:e[2]??e[3]??e[4]??null;if(!/^cat\b/.test(n))return null;const t=n.match(/(>>?)\s*(?:"([^"]+)"|'([^']+)'|([^\s<>|;&]+))/);return!t||t[1]===">>"?null:t[2]??t[3]??t[4]??null}function kq(n,e){if(n.piped||n.bodies.size===0)return null;const t=n.text.match(DC);if(!t)return null;const s=n.bodies.get(t[2]??t[3]??"");if(s===void 0)return null;const r=Sq(n.text);if(!r)return null;const o=hf(r,e);return o?{name:"Write",input:{file_path:o,content:s}}:null}function Wy(n,e){const t=e==="replacement";let s="";for(let r=0;r<n.length;r++){const o=n[r];if(o==="\\"){const i=n[r+1];if(i===void 0||i==="|"||!Uy.test(i)&&!"\\/&#".includes(i))return null;s+=i,r++;continue}if(o==="&"&&t||!t&&Uy.test(o))return null;s+=o}return s}const jq=/^sed\s+-i(?:\.\S+)?\s+(?:''\s+|""\s+)?(?<quote>['"])s(?<sep>.)(?<pattern>(?:(?!\k<sep>).)*)\k<sep>(?<replacement>(?:(?!\k<sep>).)*)\k<sep>(?<flags>[a-zA-Z]*)\k<quote>\s+(?:"(?<dquoted>[^"]+)"|'(?<squoted>[^']+)'|(?<bare>[^\s<>|;&]+))$/;function Nq(n,e){var m;const t=(m=n.text.match(jq))==null?void 0:m.groups;if(!t)return null;const{pattern:s,replacement:r,flags:o,dquoted:i,squoted:l,bare:c}=t;if(/[^g]/.test(o))return null;const u=Wy(s,"pattern"),d=Wy(r,"replacement");if(!u||d===null)return null;const f=hf(i??l??c??"",e);return f?{name:"Edit",input:{file_path:f,old_string:u,new_string:d,replace_all:o.includes("g")}}:null}function FC(n,e=null){if(n.fileDiffs)return FM(n.fileDiffs).map((o,i)=>({...ld(n,`${n.id}:bash-${i}`,"Edit",{file_path:o.filePath,old_string:o.oldString,new_string:o.newString}),diffLineCounts:o.diffLineCounts}));const t=n.input.command;if(typeof t!="string"||!t)return[];const s=[];let r=e;for(const o of yq(t)){const i=wq(o.text,r);if(i){r=i;continue}const l=kq(o,r)??Nq(o,r);l&&s.push(ld(n,`${n.id}:bash-${s.length}`,l.name,l.input))}return s}function UC(n,e){const t=n.input.edits,s=n.input.file_path??n.input.path;if(!Array.isArray(t)||typeof s!="string")return[];const r=hf(s,e)??s,o=[];for(const[i,l]of t.entries()){if(typeof l!="object"||l===null)continue;const{old_string:c,new_string:u,replace_all:d}=l;typeof c!="string"||typeof u!="string"||o.push(ld(n,`${n.id}:edit-${i}`,"Edit",{file_path:r,old_string:c,new_string:u,replace_all:d===!0}))}return o}function BC(n,e){const t=[n.input.patch,n.input.value,n.input.input].find(s=>typeof s=="string");return t?tN("apply_patch",t,n.id,n.timestamp,e??"").map(s=>ld(n,s.id,s.name,s.input)):[]}function Qa(n,e=null){const t=[];for(const s of n)s.isError||s.awaitingReview||(s.name==="Edit"||s.name==="Write"?t.push(s):s.name==="MultiEdit"?t.push(...UC(s,e)):s.name==="Bash"?t.push(...FC(s,e)):s.name==="apply_patch"&&t.push(...BC(s,e)));return t}function cd(n,e=null){for(const t of n)if(!(t.isError||t.awaitingReview)&&(t.name==="Edit"||t.name==="Write"||t.name==="MultiEdit"&&UC(t,e).length>0||t.name==="Bash"&&FC(t,e).length>0||t.name==="apply_patch"&&BC(t,e).length>0))return!0;return!1}const Cq=new Set(["tsx","jsx","ts","js","mjs","cjs","css","scss","sass","less","yaml","yml","toml","py","rs","go","html","htm","vue","svelte","sql","rb","java","kt","swift","php","c","h","cpp","cc","hpp","cs"]),_q={json:Bb,jsonc:Bb,md:Va,mdx:Va,txt:Va,png:_o,jpg:_o,jpeg:_o,gif:_o,webp:_o,svg:_o,ico:_o,sh:Ac,bash:Ac,zsh:Ac,fish:Ac};function WC(n){const e=n.split("/").at(-1)??n,t=e.lastIndexOf(".");return t===-1?"":e.slice(t+1).toLowerCase()}function Eq(n){const e=WC(n);return _q[e]??(Cq.has(e)?Ll:m3)}function zi(n){const e=q.c(11),{add:t,del:s,dimmed:r,className:o}=n,i=r&&"opacity-40";let l;e[0]!==o||e[1]!==i?(l=G("flex shrink-0 items-center gap-1 font-mono text-xs tabular-nums",i,o),e[0]=o,e[1]=i,e[2]=l):l=e[2];let c;e[3]!==t?(c=t>0&&a.jsxs("span",{className:"text-success",children:["+",t]}),e[3]=t,e[4]=c):c=e[4];let u;e[5]!==s?(u=s>0&&a.jsxs("span",{className:"text-destructive",children:["-",s]}),e[5]=s,e[6]=u):u=e[6];let d;return e[7]!==l||e[8]!==c||e[9]!==u?(d=a.jsxs("span",{className:l,children:[c,u]}),e[7]=l,e[8]=c,e[9]=u,e[10]=d):d=e[10],d}const qy=5;function Ax(n){const e=q.c(11),{add:t,del:s}=n,r=t+s;if(r===0)return null;let o,i,l;if(e[0]!==t||e[1]!==r){const d=Math.round(t/r*qy);o=qy-d,i="flex items-center gap-[1px] shrink-0 ml-1",l=Array.from({length:d},Aq),e[0]=t,e[1]=r,e[2]=o,e[3]=i,e[4]=l}else o=e[2],i=e[3],l=e[4];let c;e[5]!==o?(c=Array.from({length:o},Tq),e[5]=o,e[6]=c):c=e[6];let u;return e[7]!==i||e[8]!==l||e[9]!==c?(u=a.jsxs("span",{className:i,children:[l,c]}),e[7]=i,e[8]=l,e[9]=c,e[10]=u):u=e[10],u}function Tq(n,e){return a.jsx("span",{className:"inline-block size-1.5 rounded-xs bg-destructive/70"},`d${e}`)}function Aq(n,e){return a.jsx("span",{className:"inline-block size-1.5 rounded-xs bg-success/70"},`a${e}`)}const ud="cogpit:open-subagent";function qC(n){const e=q.c(3),{hasEdit:t,hasWrite:s}=n;if(t&&s){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx("span",{className:"shrink-0 text-xs font-bold text-warning",children:"E+W"}),e[0]=o):o=e[0],o}if(s){let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx("span",{className:"shrink-0 text-xs font-bold text-success",children:"W"}),e[1]=o):o=e[1],o}let r;return e[2]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx("span",{className:"shrink-0 text-xs font-bold text-warning",children:"E"}),e[2]=r):r=e[2],r}function Px(n){const e=q.c(2),{agentId:t}=n;let s;return e[0]!==t?(s=a.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",className:"size-5 shrink-0 font-mono text-xs font-bold text-muted-foreground","aria-label":"Open sub-agent view",title:"Open sub-agent view",onClick:r=>{r.stopPropagation(),window.dispatchEvent(new CustomEvent(ud,{detail:{agentId:t}}))},children:"S"}),e[0]=t,e[1]=s):s=e[1],s}const VC=w.memo(function(e){const t=q.c(92),{file:s,defaultOpen:r,isHighlighted:o,diffMode:i}=e,{ref:l,isNear:c}=QN(),[u,d]=w.useState(r),[f,m]=w.useState(r),p=w.useRef(r);let h;t[0]===Symbol.for("react.memo_cache_sentinel")?(h=ye=>{d(ye),ye?w.startTransition(()=>m(!0)):m(!1)},t[0]=h):h=t[0];const g=h;let x,b;t[1]!==r?(x=()=>{p.current!==r&&(p.current=r,g(r))},b=[r,g],t[1]=r,t[2]=x,t[3]=b):(x=t[2],b=t[3]),w.useEffect(x,b);let y,v;t[4]!==o?(y=()=>{o&&g(!0)},v=[o,g],t[4]=o,t[5]=y,t[6]=v):(y=t[5],v=t[6]),w.useEffect(y,v);let k;t[7]!==s.filePath?(k=WC(s.filePath),t[7]=s.filePath,t[8]=k):k=t[8];const j=k,_=s.netOriginal,N=s.netCurrent,S=!!(_||N);let C;t[9]!==s.edits?(C=s.edits.some(Rq),t[9]=s.edits,t[10]=C):C=t[10];const T=i==="per-edit"?C:S,A=f&&c&&T,[P,I]=w.useState(0);let $;t[11]===Symbol.for("react.memo_cache_sentinel")?($=ye=>{if(!ye)return;const ve=ye.offsetHeight;I(ke=>ke===ve?ke:ve)},t[11]=$):$=t[11];const O=$,M=s.turnRange[0]===s.turnRange[1]?`T${s.turnRange[0]+1}`:`T${s.turnRange[0]+1}–T${s.turnRange[1]+1}`,R=s.filePath,z=o?"border-ring ring-2 ring-ring/20":"border-border";let W;t[12]!==z?(W=G("rounded-lg border bg-card transition-colors",z),t[12]=z,t[13]=W):W=t[13];let D;t[14]!==u?(D=()=>g(!u),t[14]=u,t[15]=D):D=t[15];let L;t[16]!==u?(L=u?a.jsx(Ot,{"data-icon":"inline-start",className:"size-3 shrink-0 text-muted-foreground"}):a.jsx(ot,{"data-icon":"inline-start",className:"size-3 shrink-0 text-muted-foreground"}),t[16]=u,t[17]=L):L=t[17];let U;t[18]!==j?(U=a.jsx("span",{className:"shrink-0 font-mono text-xs font-bold text-muted-foreground",children:j}),t[18]=j,t[19]=U):U=t[19];let F;t[20]!==s.opTypes?(F=s.opTypes.includes("Edit"),t[20]=s.opTypes,t[21]=F):F=t[21];let B;t[22]!==s.opTypes?(B=s.opTypes.includes("Write"),t[22]=s.opTypes,t[23]=B):B=t[23];let V;t[24]!==F||t[25]!==B?(V=a.jsx(qC,{hasEdit:F,hasWrite:B}),t[24]=F,t[25]=B,t[26]=V):V=t[26];let H;t[27]!==s.shortPath?(H=a.jsx("span",{className:"truncate font-mono text-xs text-muted-foreground",children:s.shortPath}),t[27]=s.shortPath,t[28]=H):H=t[28];let K;t[29]!==M?(K=a.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:M}),t[29]=M,t[30]=K):K=t[30];let Z;t[31]!==s.editCount?(Z=s.editCount>1&&a.jsxs(Ue,{variant:"outline",className:"h-5 shrink-0 px-1 font-mono text-xs text-muted-foreground",children:[s.editCount,"x"]}),t[31]=s.editCount,t[32]=Z):Z=t[32];let Y;t[33]!==u||t[34]!==D||t[35]!==L||t[36]!==U||t[37]!==V||t[38]!==H||t[39]!==K||t[40]!==Z?(Y=a.jsxs(ee,{type:"button",variant:"ghost",onClick:D,className:"h-auto min-w-0 flex-1 justify-start gap-1.5 rounded-r-none px-2 py-1 font-normal","aria-expanded":u,children:[L,U,V,H,K,Z]}),t[33]=u,t[34]=D,t[35]=L,t[36]=U,t[37]=V,t[38]=H,t[39]=K,t[40]=Z,t[41]=Y):Y=t[41];let X;t[42]!==s.subAgentId?(X=s.subAgentId&&a.jsx(Px,{agentId:s.subAgentId}),t[42]=s.subAgentId,t[43]=X):X=t[43];let se;t[44]!==s.filePath?(se=a.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>xl(s.filePath),"aria-label":"Open file in editor"}),t[44]=s.filePath,t[45]=se):se=t[45];let Q;t[46]===Symbol.for("react.memo_cache_sentinel")?(Q=a.jsx(i1,{"data-icon":"inline-start"}),t[46]=Q):Q=t[46];let te;t[47]!==se?(te=a.jsx(Yt,{render:se,children:Q}),t[47]=se,t[48]=te):te=t[48];let J;t[49]===Symbol.for("react.memo_cache_sentinel")?(J=a.jsx(Xt,{children:"Open in editor"}),t[49]=J):J=t[49];let ne;t[50]!==te?(ne=a.jsxs(Zt,{children:[te,J]}),t[50]=te,t[51]=ne):ne=t[51];let re;t[52]!==s.filePath?(re=a.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>xl(s.filePath,{mode:"diff"}),"aria-label":"View git diff"}),t[52]=s.filePath,t[53]=re):re=t[53];let le;t[54]===Symbol.for("react.memo_cache_sentinel")?(le=a.jsx(sP,{"data-icon":"inline-start"}),t[54]=le):le=t[54];let ae;t[55]!==re?(ae=a.jsx(Yt,{render:re,children:le}),t[55]=re,t[56]=ae):ae=t[56];let ue;t[57]===Symbol.for("react.memo_cache_sentinel")?(ue=a.jsx(Xt,{children:"View git diff"}),t[57]=ue):ue=t[57];let oe;t[58]!==ae?(oe=a.jsxs(Zt,{children:[ae,ue]}),t[58]=ae,t[59]=oe):oe=t[59];let ie;t[60]!==ne||t[61]!==oe?(ie=a.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[ne,oe]}),t[60]=ne,t[61]=oe,t[62]=ie):ie=t[62];let fe,de;t[63]!==s.addCount||t[64]!==s.delCount?(fe=a.jsx(zi,{add:s.addCount,del:s.delCount}),de=a.jsx(Ax,{add:s.addCount,del:s.delCount}),t[63]=s.addCount,t[64]=s.delCount,t[65]=fe,t[66]=de):(fe=t[65],de=t[66]);let ce;t[67]!==X||t[68]!==ie||t[69]!==fe||t[70]!==de?(ce=a.jsxs("div",{className:"flex items-center gap-1.5 pr-2 shrink-0",children:[X,ie,fe,de]}),t[67]=X,t[68]=ie,t[69]=fe,t[70]=de,t[71]=ce):ce=t[71];let xe;t[72]!==Y||t[73]!==ce?(xe=a.jsxs("div",{className:"group sticky top-0 z-10 flex w-full items-center rounded-t-lg bg-popover",children:[Y,ce]}),t[72]=Y,t[73]=ce,t[74]=xe):xe=t[74];let pe;t[75]!==i||t[76]!==s.edits||t[77]!==s.filePath||t[78]!==s.netStartLine||t[79]!==T||t[80]!==P||t[81]!==N||t[82]!==_||t[83]!==u||t[84]!==A?(pe=a.jsx(Pq,{showDiff:A,open:u,hasDiff:T,diffRef:O,lastDiffHeight:P,oldString:_,newString:N,filePath:s.filePath,diffMode:i,edits:s.edits,netStartLine:s.netStartLine}),t[75]=i,t[76]=s.edits,t[77]=s.filePath,t[78]=s.netStartLine,t[79]=T,t[80]=P,t[81]=N,t[82]=_,t[83]=u,t[84]=A,t[85]=pe):pe=t[85];let he;return t[86]!==s.filePath||t[87]!==l||t[88]!==W||t[89]!==xe||t[90]!==pe?(he=a.jsxs("div",{ref:l,"data-file-path":R,className:W,children:[xe,pe]}),t[86]=s.filePath,t[87]=l,t[88]=W,t[89]=xe,t[90]=pe,t[91]=he):he=t[91],he}),Pq=w.memo(function(e){const t=q.c(15),{showDiff:s,open:r,hasDiff:o,diffRef:i,lastDiffHeight:l,oldString:c,newString:u,filePath:d,diffMode:f,edits:m,netStartLine:p}=e;if(s){let h;t[0]!==f||t[1]!==m||t[2]!==d||t[3]!==p||t[4]!==u||t[5]!==c?(h=f==="per-edit"?a.jsx($q,{edits:m,filePath:d}):a.jsx(_x,{oldString:c,newString:u,filePath:d,compact:!1,startLine:p,hideHeader:!0}),t[0]=f,t[1]=m,t[2]=d,t[3]=p,t[4]=u,t[5]=c,t[6]=h):h=t[6];let g;return t[7]!==f||t[8]!==i||t[9]!==h?(g=a.jsx("div",{ref:i,className:"motion-enter overflow-hidden rounded-b",children:h},f),t[7]=f,t[8]=i,t[9]=h,t[10]=g):g=t[10],g}if(r&&l>0){let h;return t[11]!==l?(h=a.jsx("div",{style:{height:l}}),t[11]=l,t[12]=h):h=t[12],h}if(r&&!o){const h=f==="per-edit"?"No edits":"No net changes (all edits cancelled out)";let g;return t[13]!==h?(g=a.jsx("div",{className:"motion-enter px-3 py-2 text-xs italic text-muted-foreground",children:h}),t[13]=h,t[14]=g):g=t[14],g}return null}),Vy=3,Iq=5,$q=w.memo(function(e){const t=q.c(9),{edits:s,filePath:r}=e,o=s.length,i=s.filter(Oq),l=i.length>Vy,[c,u]=w.useState(l?Vy:i.length);w.useEffect(()=>{if(c>=i.length)return;const x=requestAnimationFrame(()=>{u(b=>Math.min(b+Iq,i.length))});return()=>cancelAnimationFrame(x)},[c,i.length]);const d=l?i.slice(0,c):i,f="divide-y divide-border/30";let m;t[0]!==r||t[1]!==o?(m=(x,b)=>a.jsxs("div",{children:[o>1&&a.jsxs("div",{className:"flex items-center gap-2 bg-muted/30 px-2.5 py-1",children:[a.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:[x.toolName," ",b+1,"/",o]}),a.jsxs("span",{className:"text-xs text-muted-foreground",children:["T",x.turnIndex+1]}),x.agentId&&a.jsx(Px,{agentId:x.agentId})]}),a.jsx(_x,{oldString:x.oldString,newString:x.newString,filePath:r,compact:!1,startLine:x.startLine,hideHeader:!0})]},x.id),t[0]=r,t[1]=o,t[2]=m):m=t[2];const p=d.map(m);let h;t[3]!==i.length||t[4]!==c?(h=c<i.length&&a.jsxs("div",{className:"py-1.5 text-center text-xs text-muted-foreground",children:["Loading ",i.length-c," more edits…"]}),t[3]=i.length,t[4]=c,t[5]=h):h=t[5];let g;return t[6]!==p||t[7]!==h?(g=a.jsxs("div",{className:f,children:[p,h]}),t[6]=p,t[7]=h,t[8]=g):g=t[8],g});function Rq(n){return!!(n.oldString||n.newString)}function Oq(n){return!!(n.oldString||n.newString)}const jm=new Map;function Lq(n){var y;const e=mn("hostFiles"),{sessionSource:t}=xt(),s=t==null?void 0:t.dirName,r=nn(s)==="codex",o=n.turns.length,i=((y=n.turns.at(-1))==null?void 0:y.toolCalls.length)??0,l=w.useMemo(()=>{let v=0;for(const k of n.turns){v+=k.toolCalls.length;for(const j of k.subAgentActivity)v+=j.toolCalls.length}return v},[o,i]),c=w.useMemo(()=>{const v=[];for(let k=0;k<n.turns.length;k++)for(const j of n.turns[k].subAgentActivity){const _=r&&(j.status==="completed"||j.status==="failed"||j.status==="interrupted");(j.isBackground||_)&&j.toolCalls.length===0&&v.push({agentId:j.agentId,turnIndex:k})}return v},[n.turns,l,r]),[u,d]=w.useState(new Map),f=w.useRef(new Set);w.useEffect(()=>{if(!s||!n.sessionId||c.length===0)return;const v=[];for(const{agentId:_}of c){const N=gn(`${s}/${n.sessionId}/${_}`);if(!f.current.has(N)){if(jm.has(N)){d(S=>{const C=new Map(S);return C.set(_,jm.get(N)),C}),f.current.add(N);continue}v.push({agentId:_,cacheKey:N})}}if(v.length===0)return;let k=!1;async function j(){const _=new Map;await Promise.all(v.map(async({agentId:N,cacheKey:S})=>{try{const C=`/api/sessions/${encodeURIComponent(s)}/${encodeURIComponent(n.sessionId)}/subagents/agent-${encodeURIComponent(N)}.jsonl`,E=await Re(C);if(!E.ok)return;const T=await E.text(),P=wC(T,N).flatMap(I=>Qa(I.toolCalls,n.cwd));jm.set(S,P),f.current.add(S),_.set(N,P)}catch{}})),!k&&_.size>0&&d(N=>{const S=new Map(N);for(const[C,E]of _)S.set(C,E);return S})}return j(),()=>{k=!0}},[s,n.sessionId,n.cwd,c]);const m=w.useMemo(()=>{const v=[],k=new Set;for(let j=0;j<n.turns.length;j++){const _=n.turns[j];for(const N of Qa(_.toolCalls,n.cwd))v.push({turnIndex:j,toolCall:N});for(const N of _.subAgentActivity){for(const S of Qa(N.toolCalls,n.cwd))v.push({turnIndex:j,toolCall:S,agentId:N.agentId});if((N.isBackground||r)&&N.toolCalls.length===0&&!k.has(N.agentId)){k.add(N.agentId);const S=u.get(N.agentId);if(S)for(const C of S)v.push({turnIndex:j,toolCall:C,agentId:N.agentId})}}}return v},[l,n.turns,u,r]),p=w.useMemo(()=>{const v=new Set;for(const k of m){const j=HC(k.toolCall);j&&v.add(j)}return[...v]},[m]),[h,g]=w.useState(new Map);w.useEffect(()=>{if(!e||p.length===0){g(new Map);return}let v=!1;return Promise.all(p.map(k=>Re(`/api/file-content?path=${encodeURIComponent(k)}`).then(j=>j.ok?j.text():null).then(j=>j?[k,j]:null).catch(()=>null))).then(k=>{if(v)return;const j=new Map;for(const _ of k)_&&j.set(_[0],_[1]);g(j)}),()=>{v=!0}},[e,p]);const x=n.turns.length-1,b=w.useMemo(()=>{const v=new Map;for(const k of n.turns)for(const j of k.subAgentActivity)v.has(j.agentId)||v.set(j.agentId,{name:j.agentName,type:j.subagentType});return v},[n.turns]);return{fileChanges:m,fileContents:h,lastTurnIndex:x,agentMap:b}}function Hy(n,e){if(!n||!e)return 1;const t=n.indexOf(e);if(t===-1)return 1;let s=1;for(let r=0;r<t;r++)n[r]===`
|
|
115
|
+
`&&s++;return s}function HC(n){return String(n.input.file_path??n.input.path??"")}function Mq(n){const e=n.name==="Edit";return{oldString:e?String(n.input.old_string??""):"",newString:String(e?n.input.new_string??"":n.input.content??""),isWrite:!e,diffLineCounts:n.diffLineCounts}}function KC(n,e,t){const s=new Map;for(const o of n){if(e!=="all"&&o.turnIndex!==e)continue;const i=HC(o.toolCall);if(!i)continue;let l=s.get(i);l||(l=[],s.set(i,l)),l.push(o)}const r=[];for(const[o,i]of s){const l=[],c=[];let u=1/0,d=-1/0,f=!1,m=!1,p;const h=t==null?void 0:t.get(o);for(let b=0;b<i.length;b++){const y=i[b],v=Mq(y.toolCall);l.push(v),y.turnIndex<u&&(u=y.turnIndex),y.turnIndex>d&&(d=y.turnIndex),y.toolCall.name==="Edit"?f=!0:m=!0,y.agentId&&(p=y.agentId),c.push({id:y.toolCall.id,oldString:v.oldString,newString:v.newString,toolName:y.toolCall.name,turnIndex:y.turnIndex,agentId:y.agentId,startLine:y.toolCall.name==="Write"?1:Hy(h,v.newString||v.oldString)})}const g=sB(l),x=[];f&&x.push("Edit"),m&&x.push("Write"),r.push({filePath:o,shortPath:o.split("/").slice(-3).join("/"),editCount:i.length,turnRange:[u,d],opTypes:x,netOriginal:g.originalStr,netCurrent:g.currentStr,addCount:g.addCount,delCount:g.delCount,subAgentId:p??null,edits:c,netStartLine:g.currentStr?Hy(h,g.currentStr):c.length>0?c[0].startLine:1})}return r.sort((o,i)=>o.turnRange[1]-i.turnRange[1]||o.turnRange[0]-i.turnRange[0]||o.filePath.localeCompare(i.filePath)),r}function zq(n,e,t,s){const r=new Map;for(const i of n){if(!i.agentId||e!=="all"&&i.turnIndex!==e)continue;let l=r.get(i.agentId);l||(l=[],r.set(i.agentId,l)),l.push(i)}const o=[];for(const[i,l]of r){const c=KC(l,"all",s);if(c.length===0)continue;let u=0,d=0;for(const m of c)u+=m.addCount,d+=m.delCount;const f=t.get(i);o.push({agentId:i,agentName:(f==null?void 0:f.name)??null,subagentType:(f==null?void 0:f.type)??null,files:c,totalAdd:u,totalDel:d})}return o.sort((i,l)=>{var d,f;const c=((d=i.files[0])==null?void 0:d.turnRange[0])??0,u=((f=l.files[0])==null?void 0:f.turnRange[0])??0;return c-u}),o}const Cl="cogpit:focus-file",Dq="cogpit:file-changes-prefs",Fq={expanded:!0,diffMode:"net",scope:"last",groupByAgent:!1};function Uq(n){const e=q.c(34),{group:t,allExpanded:s,highlightPath:r,diffMode:o}=n;let i;e[0]!==t.agentId||e[1]!==t.agentName?(i=t.agentName||t.agentId.slice(0,8),e[0]=t.agentId,e[1]=t.agentName,e[2]=i):i=e[2];const l=i,c=t.subagentType,u=`Open subagent ${t.agentId}`;let d;e[3]!==t.agentId?(d=()=>{window.dispatchEvent(new CustomEvent(ud,{detail:{agentId:t.agentId}}))},e[3]=t.agentId,e[4]=d):d=e[4];let f;e[5]!==l||e[6]!==u||e[7]!==d?(f=a.jsx(ee,{type:"button",variant:"ghost",size:"xs",className:"h-auto min-w-0 truncate px-1 text-xs font-semibold",title:u,onClick:d,children:l}),e[5]=l,e[6]=u,e[7]=d,e[8]=f):f=e[8];let m;e[9]!==c?(m=c&&a.jsx("span",{className:"truncate text-xs text-muted-foreground",children:c}),e[9]=c,e[10]=m):m=e[10];let p;e[11]!==t.files.length?(p=a.jsx(Ue,{variant:"outline",className:"h-5 px-1.5 text-xs text-muted-foreground",children:t.files.length}),e[11]=t.files.length,e[12]=p):p=e[12];let h;e[13]===Symbol.for("react.memo_cache_sentinel")?(h=a.jsx("div",{className:"flex-1"}),e[13]=h):h=e[13];let g;e[14]!==t.totalAdd||e[15]!==t.totalDel?(g=a.jsx(zi,{add:t.totalAdd,del:t.totalDel}),e[14]=t.totalAdd,e[15]=t.totalDel,e[16]=g):g=e[16];let x;e[17]!==f||e[18]!==m||e[19]!==p||e[20]!==g?(x=a.jsxs("div",{className:"flex items-center gap-2 px-1.5 pt-1.5 pb-0.5",children:[f,m,p,h,g]}),e[17]=f,e[18]=m,e[19]=p,e[20]=g,e[21]=x):x=e[21];let b;if(e[22]!==s||e[23]!==o||e[24]!==t.files||e[25]!==r){let v;e[27]!==s||e[28]!==o||e[29]!==r?(v=k=>a.jsx(VC,{file:k,defaultOpen:s,isHighlighted:r===k.filePath,diffMode:o},k.filePath),e[27]=s,e[28]=o,e[29]=r,e[30]=v):v=e[30],b=t.files.map(v),e[22]=s,e[23]=o,e[24]=t.files,e[25]=r,e[26]=b}else b=e[26];let y;return e[31]!==b||e[32]!==x?(y=a.jsxs("div",{className:"flex flex-col gap-1",children:[x,b]}),e[31]=b,e[32]=x,e[33]=y):y=e[33],y}const Bq=w.memo(function({session:e,sessionChangeKey:t}){const s=w.useRef(null),r=w.useRef(null),o=w.useRef(!0),i=w.useRef(!1),l=w.useRef(0),c=w.useRef(e.turns.length),[u,d]=w.useState(!1),[f,m]=w.useState(!1),[p,h]=oa(Dq,{}),g={...Fq,...p},x=g.expanded,b=g.diffMode,y=g.groupByAgent,[v,k]=w.useState(g.scope),j=w.useCallback(B=>{h(V=>({...V,expanded:B}))},[h]),_=w.useCallback(B=>{h(V=>({...V,diffMode:B}))},[h]),N=w.useCallback(B=>{h(V=>({...V,groupByAgent:B}))},[h]);w.useEffect(()=>{typeof v!="number"&&h(B=>({...B,scope:v}))},[v,h]);const[S,C]=w.useState(null),E=w.useRef(null),{fileChanges:T,fileContents:A,lastTurnIndex:P,agentMap:I}=Lq(e),$=w.useMemo(()=>KC(T,typeof v=="number"?v:v==="all"?"all":P,A),[T,v,P,A]),O=w.useMemo(()=>y?zq(T,typeof v=="number"?v:v==="all"?"all":P,I,A):[],[y,T,v,P,I,A]);w.useEffect(()=>{const B=V=>{const H=V.detail;H!=null&&H.filePath&&(k(H.turnIndex),C(H.filePath),E.current&&clearTimeout(E.current),E.current=setTimeout(()=>C(null),3e3),requestAnimationFrame(()=>{var Z;const K=(Z=s.current)==null?void 0:Z.querySelector(`[data-file-path="${CSS.escape(H.filePath)}"]`);K==null||K.scrollIntoView({behavior:"smooth",block:"nearest"})}))};return window.addEventListener(Cl,B),()=>{window.removeEventListener(Cl,B),E.current&&clearTimeout(E.current)}},[]);const M=w.useCallback(()=>{const B=s.current;B&&(d(B.scrollTop>10),m(B.scrollHeight-B.scrollTop-B.clientHeight>10))},[]),R=w.useCallback(()=>{const B=s.current;B&&(o.current=B.scrollHeight-B.scrollTop-B.clientHeight<50,M())},[M]);if(w.useEffect(()=>{M()},[T.length,$.length,M]),w.useEffect(()=>{const B=s.current;B&&(B.scrollTop=B.scrollHeight),o.current=!0,i.current=!1,l.current=T.length,c.current=e.turns.length,k(g.scope),C(null),M()},[t]),w.useEffect(()=>{const B=e.turns.length;B>c.current&&(i.current=!0),c.current=B},[e.turns.length]),w.useEffect(()=>{if(T.length<=l.current){l.current=T.length;return}l.current=T.length,(i.current||o.current)&&(requestAnimationFrame(()=>{var B;(B=r.current)==null||B.scrollIntoView({behavior:"smooth"})}),i.current=!1)},[T.length]),T.length===0)return null;let z=0,W=0,D=0;if(y)for(const B of O)z+=B.totalAdd,W+=B.totalDel,D+=B.files.length;else{for(const B of $)z+=B.addCount,W+=B.delCount;D=$.length}function L(){k(v==="last"?"all":"last")}function U(){return typeof v=="number"?`Turn ${v+1}`:v==="all"?"All turns":`Last turn (T${P+1})`}const F=U();return a.jsxs("div",{className:"view-transition-file-panel panel-enter-bottom flex h-full min-w-0 flex-col overflow-hidden bg-canvas",children:[a.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-2 border-b px-3",children:[a.jsx(Ll,{"data-icon":"inline-start",className:"size-3.5 text-muted-foreground"}),a.jsx("span",{className:"text-xs font-medium text-foreground",children:"File Changes"}),a.jsxs(Ue,{variant:"outline",className:"h-5 px-1.5 text-xs text-muted-foreground",children:[D," file",D!==1?"s":""]}),a.jsx("div",{className:"flex-1"}),a.jsx(zi,{add:z,del:W}),a.jsxs(Zt,{children:[a.jsx(Yt,{render:a.jsx(ee,{variant:y?"secondary":"ghost",size:"icon-xs",onClick:()=>N(!y),"aria-label":y?"Show all changes":"Group by subagent"}),children:a.jsx(Bs,{"data-icon":"inline-start"})}),a.jsx(Xt,{children:y?"Show all changes":"Group by subagent"})]}),a.jsxs(Zt,{children:[a.jsx(Yt,{render:a.jsx(ee,{variant:v==="all"?"secondary":"ghost",size:"icon-xs",onClick:L,"aria-label":v==="last"?"Show all turns":"Show last turn only"}),children:v==="all"?a.jsx(qu,{"data-icon":"inline-start"}):a.jsx(oo,{"data-icon":"inline-start"})}),a.jsx(Xt,{children:v==="last"?"Click for all turns":"Click for last turn only"})]}),a.jsxs(Zt,{children:[a.jsx(Yt,{render:a.jsx(ee,{variant:b==="per-edit"?"secondary":"ghost",size:"icon-xs",onClick:()=>_(b==="net"?"per-edit":"net"),"aria-label":b==="net"?"Show per-edit diffs":"Show net diff"}),children:b==="net"?a.jsx(rP,{"data-icon":"inline-start"}):a.jsx(oP,{"data-icon":"inline-start"})}),a.jsx(Xt,{children:b==="net"?"Switch to per-edit diffs":"Switch to net diff"})]}),a.jsxs(Zt,{children:[a.jsx(Yt,{render:a.jsx(ee,{variant:"ghost",size:"icon-xs",onClick:()=>j(!x),"aria-label":x?"Collapse all":"Expand all"}),children:x?a.jsx(Md,{"data-icon":"inline-start"}):a.jsx(Ji,{"data-icon":"inline-start"})}),a.jsx(Xt,{children:x?"Collapse all":"Expand all"})]})]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b bg-muted/30 px-3 py-1",children:[a.jsx("span",{className:"text-xs text-muted-foreground",children:"Showing:"}),v!=="all"&&P>0&&a.jsx(ee,{variant:"ghost",size:"icon-xs",onClick:()=>{const B=typeof v=="number"?v:P;B>0&&k(B-1)},disabled:(typeof v=="number"?v:P)<=0,"aria-label":"Previous turn",children:a.jsx(t1,{"data-icon":"inline-start"})}),a.jsx("span",{className:G("text-xs font-medium",typeof v=="number"?"text-foreground":"text-muted-foreground"),children:F}),v!=="all"&&P>0&&a.jsx(ee,{variant:"ghost",size:"icon-xs",onClick:()=>{k(B=>typeof B!="number"?B:B+1>=P?"last":B+1)},disabled:v==="last","aria-label":"Next turn",children:a.jsx(ot,{"data-icon":"inline-start"})}),typeof v=="number"&&a.jsx(ee,{variant:"ghost",size:"icon-xs",onClick:()=>k("last"),"aria-label":"Back to last turn",children:a.jsx(Ut,{"data-icon":"inline-start"})})]}),a.jsxs("div",{className:"relative flex-1 min-h-0",children:[a.jsx("div",{className:G("pointer-events-none absolute inset-x-0 top-0 z-10 h-6 bg-gradient-to-b from-canvas to-transparent transition-opacity duration-200",u?"opacity-100":"opacity-0")}),a.jsxs("div",{ref:s,onScroll:R,className:"h-full overflow-y-auto",children:[a.jsx("div",{className:"flex flex-col gap-1 p-1.5",children:y?O.length>0?O.map(B=>a.jsx(Uq,{group:B,allExpanded:x,highlightPath:S,diffMode:b},B.agentId)):a.jsxs("div",{className:"py-4 text-center text-xs text-muted-foreground",children:["No subagent changes in ",F.toLowerCase()]}):$.length>0?$.map(B=>a.jsx(VC,{file:B,defaultOpen:x,isHighlighted:S===B.filePath,diffMode:b},B.filePath)):a.jsxs("div",{className:"py-4 text-center text-xs text-muted-foreground",children:["No file changes in ",F.toLowerCase()]})}),a.jsx("div",{ref:r})]}),a.jsx("div",{className:G("pointer-events-none absolute inset-x-0 bottom-0 z-10 h-6 bg-gradient-to-t from-canvas to-transparent transition-opacity duration-200",f?"opacity-100":"opacity-0")})]})]})});function Wq(n,e){const t=new Map;function s(r,o){const i=String(r.input.file_path??r.input.path??"");if(!i)return;const l=r.name==="Edit",c=l?String(r.input.old_string??""):"",u=String(l?r.input.new_string??"":r.input.content??""),d=r.diffLineCounts??Qh(c,u),f=t.get(i)??{add:0,del:0,hasEdit:!1,hasWrite:!1,subAgentId:null};f.add+=d.add,f.del+=d.del,l?f.hasEdit=!0:f.hasWrite=!0,o&&(f.subAgentId=o),t.set(i,f)}return Qa(n.toolCalls,e).forEach(r=>s(r)),n.subAgentActivity.forEach(r=>Qa(r.toolCalls,e).forEach(o=>s(o,r.agentId))),[...t.entries()].map(([r,{add:o,del:i,hasEdit:l,hasWrite:c,subAgentId:u}])=>({filePath:r,additions:o,deletions:i,hasEdit:l,hasWrite:c,subAgentId:u}))}function Ky(){return{children:new Map,isFile:!1,absPath:"",additions:0,deletions:0,hasEdit:!1,hasWrite:!1,subAgentId:null}}function qq(n,e){if(n.length===0)return[];const t=e.endsWith("/")?e.slice(0,-1):e,s=Ky();for(const o of n){let i=o.filePath;t&&i.startsWith(t+"/")?i=i.slice(t.length+1):i.startsWith("/")&&(i=i.slice(1));const l=i.split("/");let c=s;for(let u=0;u<l.length;u++){let d=c.children.get(l[u]);d||(d=Ky(),c.children.set(l[u],d)),u===l.length-1&&(d.isFile=!0,d.absPath=o.filePath,d.additions+=o.additions,d.deletions+=o.deletions,o.hasEdit&&(d.hasEdit=!0),o.hasWrite&&(d.hasWrite=!0),o.subAgentId&&(d.subAgentId=o.subAgentId)),c=d}}function r(o,i){return[...o.children.entries()].sort(([c,u],[d,f])=>{const m=u.isFile&&u.children.size===0,p=f.isFile&&f.children.size===0;return m!==p?m?1:-1:c.localeCompare(d)}).map(([c,u])=>{const d=i?`${i}/${c}`:c;if(u.isFile&&u.children.size===0)return{name:c,fullPath:d,absPath:u.absPath,isFile:!0,additions:u.additions,deletions:u.deletions,hasEdit:u.hasEdit,hasWrite:u.hasWrite,subAgentId:u.subAgentId,children:[]};let f=u,m=c,p=d;for(;!f.isFile&&f.children.size===1;){const[k,j]=[...f.children.entries()][0];if(j.isFile&&j.children.size===0)break;m+="/"+k,p+="/"+k,f=j}const h=r(f,p);let g=0,x=0,b=f.isFile?f.hasEdit:!1,y=f.isFile?f.hasWrite:!1,v=f.isFile?f.subAgentId:null;for(const k of h)g+=k.additions,x+=k.deletions,k.hasEdit&&(b=!0),k.hasWrite&&(y=!0),k.subAgentId&&(v=k.subAgentId);return f.isFile&&(g+=f.additions,x+=f.deletions),{name:m,fullPath:p,absPath:f.absPath,isFile:!1,additions:g,deletions:x,hasEdit:b,hasWrite:y,subAgentId:v,children:h}})}return r(s,"")}const Vq=w.memo(function(e){const t=q.c(45),{turn:s,turnIndex:r,cwd:o}=e,i=mn("hostFiles");let l;t[0]!==o||t[1]!==s?(l=Wq(s,o),t[0]=o,t[1]=s,t[2]=l):l=t[2];const c=l;let u;t[3]!==o||t[4]!==c?(u=qq(c,o),t[3]=o,t[4]=c,t[5]=u):u=t[5];const d=u,[f,m]=w.useState(!1);let p=0,h=0;if(t[6]!==p||t[7]!==h||t[8]!==c){for(const I of c)p=p+I.additions,h=h+I.deletions;t[6]=p,t[7]=h,t[8]=c,t[9]=p,t[10]=h}else p=t[9],h=t[10];let g;t[11]!==p||t[12]!==h?(g={add:p,del:h},t[11]=p,t[12]=h,t[13]=g):g=t[13];const x=g;if(c.length===0)return null;const b=f&&"rotate-90";let y;t[14]!==b?(y=G("size-3 shrink-0 transition-transform duration-150 motion-reduce:transition-none",b),t[14]=b,t[15]=y):y=t[15];let v;t[16]!==y?(v=a.jsx(ot,{"data-icon":"inline-start",className:y}),t[16]=y,t[17]=v):v=t[17];let k;t[18]===Symbol.for("react.memo_cache_sentinel")?(k=a.jsx(Ll,{className:"size-3.5 shrink-0","data-icon":"inline-start"}),t[18]=k):k=t[18];const j=c.length!==1?"s":"";let _;t[19]!==c.length||t[20]!==j?(_=a.jsxs("span",{className:"font-medium tabular-nums",children:[c.length," file",j]}),t[19]=c.length,t[20]=j,t[21]=_):_=t[21];let N,S;t[22]!==x.add||t[23]!==x.del?(N=a.jsx(zi,{add:x.add,del:x.del,className:"opacity-80"}),S=a.jsx(Ax,{add:x.add,del:x.del}),t[22]=x.add,t[23]=x.del,t[24]=N,t[25]=S):(N=t[24],S=t[25]);let C;t[26]===Symbol.for("react.memo_cache_sentinel")?(C=a.jsx("span",{"aria-hidden":!0,className:"pointer-events-none ml-1 h-px flex-1 bg-border/40 transition-colors group-hover/files:bg-border/70"}),t[26]=C):C=t[26];let E;t[27]!==N||t[28]!==S||t[29]!==v||t[30]!==_?(E=a.jsxs(vs,{className:"group/files flex min-h-7 w-full cursor-pointer items-center gap-1.5 rounded-md px-1 text-left text-xs text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[v,k,_,N,S,C]}),t[27]=N,t[28]=S,t[29]=v,t[30]=_,t[31]=E):E=t[31];let T;if(t[32]!==i||t[33]!==d||t[34]!==r){let I;t[36]!==i||t[37]!==r?(I=$=>a.jsx(Hq,{node:$,depth:0,turnIndex:r,canFocusFiles:i},$.fullPath),t[36]=i,t[37]=r,t[38]=I):I=t[38],T=d.map(I),t[32]=i,t[33]=d,t[34]=r,t[35]=T}else T=t[35];let A;t[39]!==T?(A=a.jsx(Tn,{className:"ml-1 border-l border-border/40 pl-3",children:a.jsx("div",{className:"py-0.5",children:T})}),t[39]=T,t[40]=A):A=t[40];let P;return t[41]!==f||t[42]!==E||t[43]!==A?(P=a.jsxs(En,{open:f,onOpenChange:m,children:[E,A]}),t[41]=f,t[42]=E,t[43]=A,t[44]=P):P=t[44],P}),Hq=w.memo(function n({node:e,depth:t,turnIndex:s,canFocusFiles:r}){const[o,i]=w.useState(!0),l=t*16+8;if(e.isFile){const c=Eq(e.name),u=()=>{r&&e.absPath&&window.dispatchEvent(new CustomEvent(Cl,{detail:{filePath:e.absPath,turnIndex:s}}))};return a.jsxs("div",{className:"flex h-7 w-full items-center gap-1.5 font-mono text-xs",style:{paddingLeft:l},children:[a.jsxs(ee,{type:"button",variant:"ghost",size:"xs",disabled:!r,className:G("h-7 min-w-0 flex-1 justify-start gap-1.5 rounded-sm px-0 font-mono text-xs font-normal disabled:opacity-100",r&&"cursor-pointer"),onClick:u,title:r?"Click to focus in sidebar":void 0,children:[a.jsx(c,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}),a.jsx(qC,{hasEdit:e.hasEdit,hasWrite:e.hasWrite}),a.jsx("span",{className:"truncate text-foreground/75",children:e.name})]}),e.subAgentId&&a.jsx(Px,{agentId:e.subAgentId}),a.jsx(zi,{add:e.additions,del:e.deletions}),a.jsx(Ax,{add:e.additions,del:e.deletions})]})}return a.jsxs(a.Fragment,{children:[a.jsxs(ee,{type:"button",variant:"ghost",size:"xs",className:"h-7 w-full justify-start gap-1 rounded-sm font-mono text-xs font-normal",style:{paddingLeft:l},onClick:()=>i(!o),"aria-expanded":o,children:[o?a.jsx(Ot,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}):a.jsx(ot,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}),a.jsx(Ii,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}),a.jsx("span",{className:"truncate text-foreground/70",children:e.name}),a.jsx("div",{className:"flex-1 min-w-2"}),!o&&a.jsx(zi,{add:e.additions,del:e.deletions,dimmed:!0})]}),o&&e.children.map(c=>a.jsx(n,{node:c,depth:t+1,turnIndex:s,canFocusFiles:r},c.fullPath))]})});function Kq(n){const e=q.c(14),{branchCount:t,onClick:s}=n;if(t===0)return null;let r;e[0]!==s?(r=a.jsx(ee,{variant:"ghost",size:"xs",onClick:f=>{f.stopPropagation(),s()},className:"h-6 text-muted-foreground"}),e[0]=s,e[1]=r):r=e[1];let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx(a1,{"data-icon":"inline-start"}),e[2]=o):o=e[2];let i;e[3]!==t?(i=a.jsx("span",{className:"font-mono text-xs",children:t}),e[3]=t,e[4]=i):i=e[4];let l;e[5]!==r||e[6]!==i?(l=a.jsxs(Yt,{render:r,children:[o,i]}),e[5]=r,e[6]=i,e[7]=l):l=e[7];const c=t!==1?"es":"";let u;e[8]!==t||e[9]!==c?(u=a.jsxs(Xt,{children:[t," branch",c," from this turn"]}),e[8]=t,e[9]=c,e[10]=u):u=e[10];let d;return e[11]!==l||e[12]!==u?(d=a.jsxs(Zt,{children:[l,u]}),e[11]=l,e[12]=u,e[13]=d):d=e[13],d}function gf(n){const e=q.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(aP,{"data-slot":"context-menu",...t}),e[2]=t,e[3]=s):s=e[3],s}function xf(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("select-none",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(iP,{"data-slot":"context-menu-trigger",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function bf(n){const e=q.c(18);let t,s,r,o,i,l;e[0]!==n?({className:t,align:r,alignOffset:o,side:i,sideOffset:l,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i,e[6]=l):(t=e[1],s=e[2],r=e[3],o=e[4],i=e[5],l=e[6]);const c=r===void 0?"start":r,u=o===void 0?4:o,d=i===void 0?"right":i,f=l===void 0?0:l;let m;e[7]!==t?(m=G("z-50 max-h-(--available-height) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 ease-out outline-none data-[side=bottom]:slide-in-from-top-1 data-[side=inline-end]:slide-in-from-left-1 data-[side=inline-start]:slide-in-from-right-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-75 data-closed:ease-in motion-reduce:animate-none",t),e[7]=t,e[8]=m):m=e[8];let p;e[9]!==s||e[10]!==m?(p=a.jsx(p3,{"data-slot":"context-menu-content",className:m,...s}),e[9]=s,e[10]=m,e[11]=p):p=e[11];let h;return e[12]!==c||e[13]!==u||e[14]!==d||e[15]!==f||e[16]!==p?(h=a.jsx(x3,{children:a.jsx(b3,{className:"isolate z-50 outline-none",align:c,alignOffset:u,side:d,sideOffset:f,children:p})}),e[12]=c,e[13]=u,e[14]=d,e[15]=f,e[16]=p,e[17]=h):h=e[17],h}function zo(n){const e=q.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(h3,{"data-slot":"context-menu-group",...t}),e[2]=t,e[3]=s):s=e[3],s}function Dge(n){const e=q.c(10);let t,s,r;e[0]!==n?({className:t,inset:s,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);let o;e[4]!==t?(o=G("px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7",t),e[4]=t,e[5]=o):o=e[5];let i;return e[6]!==s||e[7]!==r||e[8]!==o?(i=a.jsx(v3,{"data-slot":"context-menu-label","data-inset":s,className:o,...r}),e[6]=s,e[7]=r,e[8]=o,e[9]=i):i=e[9],i}function $n(n){const e=q.c(12);let t,s,r,o;e[0]!==n?({className:t,inset:s,variant:o,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o):(t=e[1],s=e[2],r=e[3],o=e[4]);const i=o===void 0?"default":o;let l;e[5]!==t?(l=G("group/context-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none transition-colors duration-75 focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus:*:[svg]:text-accent-foreground data-[variant=destructive]:*:[svg]:text-destructive",t),e[5]=t,e[6]=l):l=e[6];let c;return e[7]!==s||e[8]!==r||e[9]!==l||e[10]!==i?(c=a.jsx(g3,{"data-slot":"context-menu-item","data-inset":s,"data-variant":i,className:l,...r}),e[7]=s,e[8]=r,e[9]=l,e[10]=i,e[11]=c):c=e[11],c}function Di(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("-mx-1 my-1 h-px bg-border",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(Kg,{"data-slot":"context-menu-separator",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Gq(n){const e=q.c(22),{children:t,turnIndex:s,branches:r,onRestoreToHere:o,onOpenBranches:i,onBranchFromHere:l}=n;let c;e[0]!==t?(c=a.jsx(xf,{className:"select-text",children:t}),e[0]=t,e[1]=c):c=e[1];let u;e[2]!==o||e[3]!==s?(u=()=>o(s),e[2]=o,e[3]=s,e[4]=u):u=e[4];let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=a.jsx(r1,{"data-icon":"inline-start"}),e[5]=d):d=e[5];let f;e[6]!==u?(f=a.jsx(zo,{children:a.jsxs($n,{onClick:u,children:[d,"Restore to this point"]})}),e[6]=u,e[7]=f):f=e[7];let m;e[8]!==r.length||e[9]!==i||e[10]!==s?(m=r.length>0&&a.jsxs(a.Fragment,{children:[a.jsx(Di,{}),a.jsx(zo,{children:a.jsxs($n,{onClick:()=>i(s),children:[a.jsx(a1,{"data-icon":"inline-start"}),"View branches (",r.length,")"]})})]}),e[8]=r.length,e[9]=i,e[10]=s,e[11]=m):m=e[11];let p;e[12]!==l||e[13]!==s?(p=l&&a.jsxs(a.Fragment,{children:[a.jsx(Di,{}),a.jsx(zo,{children:a.jsxs($n,{onClick:()=>l(s),children:[a.jsx(ys,{"data-icon":"inline-start"}),"Duplicate from here"]})})]}),e[12]=l,e[13]=s,e[14]=p):p=e[14];let h;e[15]!==f||e[16]!==m||e[17]!==p?(h=a.jsxs(bf,{className:"min-w-44",children:[f,m,p]}),e[15]=f,e[16]=m,e[17]=p,e[18]=h):h=e[18];let g;return e[19]!==c||e[20]!==h?(g=a.jsxs(gf,{children:[c,h]}),e[19]=c,e[20]=h,e[21]=g):g=e[21],g}function GC(n){return wN(n).status(n)}const Zq=new Set(["Agent","TaskOutput","spawn_agent","wait_agent"]);function Ix(n){switch(n){case"max_turns":return"Stopped — turn limit reached";case"aborted_tools":return"Stopped — tools aborted";case"blocking_limit":return"Stopped — blocked";default:return`Stopped — ${n.replace(/_/g," ")}`}}function cc(n,e,t,s){switch(n){case"thinking":return"Thinking...";case"tool_use":return e&&Zq.has(e)?"Running agents...":e?`Using ${e}`:"Using tool...";case"processing":return"Processing...";case"compacting":return"Compressing context...";case"deferred":return"Awaiting permission review";case"awaiting_agents":return s&&s>0?`Waiting on ${s} agent${s===1?"":"s"}...`:"Waiting on agents...";case"completed":return t?Ix(t):"Done";default:return null}}function Yq(n){const e=q.c(6),{status:t}=n;switch(t){case"thinking":{let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(cP,{className:"size-5 text-warning"}),e[0]=s):s=e[0],s}case"tool_use":{let s;return e[1]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(Xi,{className:"size-5 text-info"}),e[1]=s):s=e[1],s}case"processing":{let s;return e[2]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(lP,{className:"size-5 text-warning"}),e[2]=s):s=e[2],s}case"compacting":{let s;return e[3]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(Md,{className:"size-5 text-warning"}),e[3]=s):s=e[3],s}case"awaiting_agents":{let s;return e[4]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx($i,{className:"size-5 text-info"}),e[4]=s):s=e[4],s}case"completed":{let s;return e[5]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(Mr,{className:"size-5 text-success"}),e[5]=s):s=e[5],s}default:return null}}const Gy=2e3,ZC=600;function YC(n){const e=q.c(28),{status:t,label:s,fading:r,startTimestamp:o}=n,i=r===void 0?!1:r,l=t.status==="completed";let c;e[0]!==t.pendingAgentDescriptions?(c=t.pendingAgentDescriptions??[],e[0]=t.pendingAgentDescriptions,e[1]=c):c=e[1];const u=c,d=i?"opacity-0":"opacity-100";let f;e[2]!==d?(f=G("flex items-center gap-2.5 min-w-0 transition-opacity",d),e[2]=d,e[3]=f):f=e[3];let m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m={transitionDuration:`${ZC}ms`},e[4]=m):m=e[4];let p;e[5]!==t.status?(p=a.jsx(Yq,{status:t.status}),e[5]=t.status,e[6]=p):p=e[6];const h=!l&&"text-muted-foreground",g=l&&t.terminalReason&&"text-warning",x=l&&!t.terminalReason&&"text-success";let b;e[7]!==h||e[8]!==g||e[9]!==x?(b=G("text-xs font-medium shrink-0",h,g,x),e[7]=h,e[8]=g,e[9]=x,e[10]=b):b=e[10];let y;e[11]!==s||e[12]!==b?(y=a.jsx("span",{className:b,children:s}),e[11]=s,e[12]=b,e[13]=y):y=e[13];let v;e[14]!==l||e[15]!==o?(v=!l&&o&&a.jsx($x,{startTimestamp:o}),e[14]=l,e[15]=o,e[16]=v):v=e[16];let k;e[17]!==u?(k=u.length>0&&a.jsx("span",{className:"truncate text-xs text-muted-foreground",title:u.join(`
|
|
116
|
+
`),children:u.join(" · ")}),e[17]=u,e[18]=k):k=e[18];let j;e[19]!==t.pendingQueue?(j=(t.pendingQueue??0)>0&&a.jsxs("span",{className:"ml-1 shrink-0 text-xs text-muted-foreground",children:["+",t.pendingQueue," queued"]}),e[19]=t.pendingQueue,e[20]=j):j=e[20];let _;return e[21]!==y||e[22]!==v||e[23]!==k||e[24]!==j||e[25]!==f||e[26]!==p?(_=a.jsxs("div",{className:f,style:m,children:[p,y,v,k,j]}),e[21]=y,e[22]=v,e[23]=k,e[24]=j,e[25]=f,e[26]=p,e[27]=_):_=e[27],_}function Xq(n){const e=q.c(28),{status:t,durationLabel:s}=n,[r,o]=w.useState("visible");let i,l;if(e[0]===Symbol.for("react.memo_cache_sentinel")?(i=()=>{const h=setTimeout(()=>o("fading"),Gy),g=setTimeout(()=>o("ready"),Gy+ZC);return()=>{clearTimeout(h),clearTimeout(g)}},l=[],e[0]=i,e[1]=l):(i=e[0],l=e[1]),w.useEffect(i,l),r==="ready"){let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=a.jsx(Mr,{className:"size-4 shrink-0 text-success"}),e[2]=h):h=e[2];const g=t.terminalReason?"text-warning":"text-muted-foreground";let x;e[3]!==g?(x=G("text-xs font-medium",g),e[3]=g,e[4]=x):x=e[4];let b;e[5]!==t.terminalReason?(b=t.terminalReason?Ix(t.terminalReason):"Waiting for your input",e[5]=t.terminalReason,e[6]=b):b=e[6];let y;e[7]!==x||e[8]!==b?(y=a.jsx("span",{className:x,children:b}),e[7]=x,e[8]=b,e[9]=y):y=e[9];let v;e[10]!==s?(v=s&&a.jsx("span",{className:"font-mono text-xs tabular-nums text-muted-foreground",children:s}),e[10]=s,e[11]=v):v=e[11];let k;return e[12]!==y||e[13]!==v?(k=a.jsxs("div",{className:"flex items-center gap-2.5 py-3 px-4","data-agent-ready":!0,children:[h,y,v]}),e[12]=y,e[13]=v,e[14]=k):k=e[14],k}let c;e[15]!==t.status||e[16]!==t.terminalReason||e[17]!==t.toolName?(c=cc(t.status,t.toolName,t.terminalReason)??"Done",e[15]=t.status,e[16]=t.terminalReason,e[17]=t.toolName,e[18]=c):c=e[18];const u=c,d=r==="fading";let f;e[19]!==u||e[20]!==t||e[21]!==d?(f=a.jsx(YC,{status:t,label:u,fading:d}),e[19]=u,e[20]=t,e[21]=d,e[22]=f):f=e[22];let m;e[23]!==s?(m=s&&a.jsxs("span",{className:"font-mono text-xs tabular-nums text-muted-foreground",children:["in ",s]}),e[23]=s,e[24]=m):m=e[24];let p;return e[25]!==f||e[26]!==m?(p=a.jsxs("div",{className:"flex items-center gap-2.5 py-3 px-4",children:[f,m]}),e[25]=f,e[26]=m,e[27]=p):p=e[27],p}const Jq=w.memo(function(){const e=q.c(25),{session:t,isLive:s,sseState:r,isCompacting:o,pendingInteraction:i}=xt(),[l,c]=w.useState(!1),[u,d]=w.useState(!1),f=t==null?void 0:t.sessionId,[m,p]=w.useState(f);f!==m&&(p(f),c(!1),d(!1));let h;e:{if(!t||r!=="connected"){h=null;break e}if(o){let I;e[0]===Symbol.for("react.memo_cache_sentinel")?(I={status:"compacting"},e[0]=I):I=e[0],h=I;break e}const A=t.rawMessages;let P;e[1]!==A?(P=GC(A),e[1]=A,e[2]=P):P=e[2],h=P}const g=h;let x,b;e[3]!==g||e[4]!==s||e[5]!==u?(x=()=>{if(!(!g||g.status==="compacting"||g.status==="idle")){if(!s){g.status==="completed"&&!u&&c(!0);return}if(g.status==="completed"){d(!0);return}c(!1),d(!1)}},b=[g,s,u],e[3]=g,e[4]=s,e[5]=u,e[6]=x,e[7]=b):(x=e[6],b=e[7]),w.useEffect(x,b);let y;e:{if(!g){y=null;break e}if(g.status==="compacting"){y=g;break e}if(g.status==="completed"){if(l){y=null;break e}if(!s&&!u){y=null;break e}y=g;break e}if(!s||g.status==="idle"){y=null;break e}y=g}const v=y,k=(v==null?void 0:v.status)==="completed",j=(t==null?void 0:t.turns[t.turns.length-1])??null;let _;e:{if(!k||!j){_=null;break e}let A;if(e[8]!==j){const P=T1(j);A=P!==null?sr(P):null,e[8]=j,e[9]=A}else A=e[9];_=A}const N=_;if(i&&r==="connected"){let A;e[10]===Symbol.for("react.memo_cache_sentinel")?(A=a.jsx(o1,{className:"size-5 shrink-0 text-info"}),e[10]=A):A=e[10];const P=i.type==="plan"?"Waiting for plan approval":"Waiting for your answer";let I;return e[11]!==P?(I=a.jsxs("div",{className:"flex items-center gap-2.5 py-3 px-4",children:[A,a.jsx("span",{className:"text-xs font-medium text-info",children:P})]}),e[11]=P,e[12]=I):I=e[12],I}if(!v)return null;if(k){let A;return e[13]!==v||e[14]!==N?(A=a.jsx(Xq,{status:v,durationLabel:N}),e[13]=v,e[14]=N,e[15]=A):A=e[15],A}let S;e[16]!==v.pendingAgents||e[17]!==v.status||e[18]!==v.terminalReason||e[19]!==v.toolName?(S=cc(v.status,v.toolName,v.terminalReason,v.pendingAgents),e[16]=v.pendingAgents,e[17]=v.status,e[18]=v.terminalReason,e[19]=v.toolName,e[20]=S):S=e[20];const C=S;if(!C)return null;const E=j==null?void 0:j.timestamp;let T;return e[21]!==v||e[22]!==C||e[23]!==E?(T=a.jsx("div",{className:"flex items-center gap-2.5 py-3 px-4",children:a.jsx(YC,{status:v,label:C,startTimestamp:E})}),e[21]=v,e[22]=C,e[23]=E,e[24]=T):T=e[24],T});function $x(n){const e=q.c(3),{startTimestamp:t,className:s}=n;let r;return e[0]!==s||e[1]!==t?(r=a.jsx(Qq,{startTimestamp:t,className:s},t),e[0]=s,e[1]=t,e[2]=r):r=e[2],r}function Qq(n){const e=q.c(12),{startTimestamp:t,className:s}=n;let r;e[0]!==t?(r=new Date(t).getTime(),e[0]=t,e[1]=r):r=e[1];const o=r,i=w.useRef(null);let l,c;e[2]!==o?(l=()=>{const h=setInterval(()=>{const g=i.current;g&&(g.textContent=sr(Math.max(0,Date.now()-o)))},1e3);return()=>clearInterval(h)},c=[o],e[2]=o,e[3]=l,e[4]=c):(l=e[3],c=e[4]),w.useEffect(l,c);let u;e[5]!==s?(u=G("font-mono text-xs tabular-nums text-muted-foreground",s),e[5]=s,e[6]=u):u=e[6];const d=Math.max(0,Date.now()-o);let f;e[7]!==d?(f=sr(d),e[7]=d,e[8]=f):f=e[8];let m;return e[9]!==u||e[10]!==f?(m=a.jsx("span",{ref:i,className:u,children:f}),e[9]=u,e[10]=f,e[11]=m):m=e[11],m}function eV(n,e){var s;if(!e)return!0;const t=e.toLowerCase();if(n.userMessage&&(typeof n.userMessage=="string"?n.userMessage:JSON.stringify(n.userMessage)).toLowerCase().includes(t))return!0;for(const r of n.assistantText)if(r.toLowerCase().includes(t))return!0;for(const r of n.contentBlocks)if(r.kind==="queued_prompt"&&r.content.toLowerCase().includes(t)||r.kind==="agent_message"&&(r.sender.toLowerCase().includes(t)||r.body.toLowerCase().includes(t)))return!0;for(const r of n.thinking)if(r.thinking.toLowerCase().includes(t))return!0;for(const r of n.toolCalls)if(r.name.toLowerCase().includes(t)||JSON.stringify(r.input).toLowerCase().includes(t)||(s=r.result)!=null&&s.toLowerCase().includes(t))return!0;return!1}const tV=6e5;function nV(n,e){const t=n[e].timestamp,s=e>0?n[e-1].timestamp:void 0;if(!t||!s)return 0;const r=Date.parse(t)-Date.parse(s);return!Number.isFinite(r)||r<=0?0:Math.min(r,tV)}function Zy(n,e){const t=[],s=[];let r=0,o=0,i=e;for(;i<n.length;){const l=n[i];if(l.kind==="thinking")t.push({kind:"thinking",blocks:l.blocks}),r+=l.blocks.length,o+=nV(n,i),i++;else if(l.kind==="tool_calls")t.push({kind:"tool_calls",toolCalls:l.toolCalls}),s.push(...l.toolCalls),i++;else break}return{items:t,toolCalls:s,thinkingCount:r,thoughtForMs:o,nextIndex:i}}const XC=w.createContext(null);function _u(n){const e=q.c(3),{value:t,children:s}=n;let r;return e[0]!==s||e[1]!==t?(r=a.jsx(XC.Provider,{value:t,children:s}),e[0]=s,e[1]=t,e[2]=r):r=e[2],r}function bn(){const n=w.useContext(XC);if(!n)throw new Error("useAppContext must be used within an AppProvider");return n}const eg=new Map,sV=300*1e3;function Yy(n){const e=eg.get(n);return e?Date.now()>e.expiresAt?(eg.delete(n),null):e.data:null}function rV(n,e){eg.set(n,{data:e,expiresAt:Date.now()+sV})}function oV(n){const e=q.c(5);let t;e[0]!==n?(t=()=>n?Yy(gn(n))??new Map:new Map,e[0]=n,e[1]=t):t=e[1];const[s,r]=w.useState(t),o=w.useRef("");let i,l;return e[2]!==n?(i=()=>{if(!n||Zd(window.location.pathname))return;const c=gn(n),u=Yy(c);if(u){r(u);return}o.current=n;const d=new AbortController;return Re(`/api/slash-suggestions?cwd=${encodeURIComponent(n)}`,{signal:d.signal}).then(async f=>{if(d.signal.aborted||o.current!==n||!f.ok)return;const m=await f.json();if(d.signal.aborted||o.current!==n)return;const p=new Map;for(const h of m.suggestions??[])h.type==="skill"&&p.set(h.name,{source:h.source,description:h.description,filePath:h.filePath});rV(c,p),r(p)}).catch(iV),()=>d.abort()},l=[n],e[2]=n,e[3]=i,e[4]=l):(i=e[3],l=e[4]),w.useEffect(i,l),s}function iV(){}const aV=new Set(["queued_prompt","agent_message","plan_mode","recap","task_notification"]),lV=new Set(["thinking","tool_calls","sub_agent","background_agent","hook_event"]),cV=new Set(["AskUserQuestion","ExitPlanMode"]),uV=new Set(["text","thinking","tool_calls"]);function dV(n){return n.kind==="tool_calls"&&n.toolCalls.some(e=>cV.has(e.name)&&e.result==null)}function fV(n,e){for(let t=n.length-1;t>=0;t--){if(dV(n[t]))return t;if(uV.has(n[t].kind))break}return e?n.findIndex(t=>t.kind==="tool_calls"&&t.toolCalls.some(s=>s.id===e&&s.asyncQuestion)):-1}const qc={foldedIndices:[],foldAnchorIndex:-1,foldable:!1,hiddenToolCalls:0};function mV(n,e="settled",t){if(n.length===0||!n.some(l=>lV.has(l.kind)))return qc;let s=-1;if(e==="settled"){for(let l=n.length-1;l>=0;l--)if(n[l].kind==="text"){s=l;break}if(s===-1)return qc}const r=fV(n,t),o=[];let i=0;for(let l=0;l<n.length;l++){if(l===s||l===r)continue;const c=n[l];aV.has(c.kind)||(o.push(l),c.kind==="tool_calls"&&(i+=c.toolCalls.length))}return o.length===0?qc:{foldedIndices:o,foldAnchorIndex:o[0],foldable:!0,hiddenToolCalls:i}}function pV(n,e){return n!==null&&n>0?`Worked for ${sr(n)}`:e>0?`Worked through ${e} step${e===1?"":"s"}`:"Show work"}const JC="border border-border bg-prompt-surface",Xy="border-l border-border/40",Jy="border-l border-border";function QC(n){const e=q.c(21),{turn:t,index:s,branchCount:r}=n,o=r===void 0?0:r,{state:i,isMobile:l}=bn(),{activeTurnIndex:c,activeToolCallId:u,expandAll:d,expandToolPayloads:f}=i,{session:m,isLive:p,isSubAgentView:h,undoRedo:g,actions:x,pendingInteraction:b}=xt(),y=p&&m!==null,v=y&&s===((m==null?void 0:m.turns.length)??0)-1;let k=!v;if(v&&m){let T;if(e[0]!==m.rawMessages){const{status:A}=GC(m.rawMessages);T=wx.has(A),e[0]=m.rawMessages,e[1]=T}else T=e[1];k=!T}const j=(m==null?void 0:m.cwd)??"",_=oV(j),N=(b==null?void 0:b.type)==="question"?b.toolUseId:void 0,S=c===s,C=!g.enabled||h?void 0:g.requestUndo;let E;return e[2]!==x.handleEditCommand||e[3]!==x.handleExpandCommand||e[4]!==x.handleOpenBranches||e[5]!==u||e[6]!==o||e[7]!==j||e[8]!==d||e[9]!==f||e[10]!==s||e[11]!==v||e[12]!==l||e[13]!==y||e[14]!==k||e[15]!==N||e[16]!==_||e[17]!==S||e[18]!==C||e[19]!==t?(E=a.jsx(xV,{turn:t,openQuestionId:N,index:s,branchCount:o,isActive:S,activeToolCallId:u,expandAll:d,expandToolPayloads:f,isAgentActive:v,isSessionLive:y,isTurnDone:k,isMobile:l,cwd:j,skillMetadata:_,onRestoreToHere:C,onOpenBranches:x.handleOpenBranches,onEditCommand:x.handleEditCommand,onExpandCommand:x.handleExpandCommand}),e[2]=x.handleEditCommand,e[3]=x.handleExpandCommand,e[4]=x.handleOpenBranches,e[5]=u,e[6]=o,e[7]=j,e[8]=d,e[9]=f,e[10]=s,e[11]=v,e[12]=l,e[13]=y,e[14]=k,e[15]=N,e[16]=_,e[17]=S,e[18]=C,e[19]=t,e[20]=E):E=e[20],E}function hV(n){const e=q.c(12),{index:t,children:s}=n,{session:r,isSubAgentView:o,undoRedo:i,actions:l}=xt(),{requestUndo:c,branchesAtTurn:u}=i,{handleOpenBranches:d,handleBranchFromHere:f}=l,m=t>=((r==null?void 0:r.turns.length)??0);if(!i.enabled||o||m||!c||!d){let g;return e[0]!==s?(g=a.jsx(a.Fragment,{children:s}),e[0]=s,e[1]=g):g=e[1],g}let p;e[2]!==u||e[3]!==t?(p=u(t),e[2]=u,e[3]=t,e[4]=p):p=e[4];let h;return e[5]!==s||e[6]!==f||e[7]!==d||e[8]!==t||e[9]!==c||e[10]!==p?(h=a.jsx(Gq,{turnIndex:t,branches:p,onRestoreToHere:c,onOpenBranches:d,onBranchFromHere:f,children:s}),e[5]=s,e[6]=f,e[7]=d,e[8]=t,e[9]=c,e[10]=p,e[11]=h):h=e[11],h}function gV(n){const e=q.c(5),{turn:t,isTurnDone:s,hiddenToolCalls:r}=n;if(s){let i;return e[0]!==r||e[1]!==t?(i=pV(T1(t),r),e[0]=r,e[1]=t,e[2]=i):i=e[2],i}if(!t.timestamp)return"Working";let o;return e[3]!==t.timestamp?(o=a.jsxs("span",{className:"inline-flex items-baseline gap-1",children:["Working for",a.jsx($x,{startTimestamp:t.timestamp,className:"text-xs text-inherit"})]}),e[3]=t.timestamp,e[4]=o):o=e[4],o}const xV=w.memo(function({turn:e,index:t,branchCount:s,isActive:r,activeToolCallId:o,expandAll:i,expandToolPayloads:l,isAgentActive:c,isSessionLive:u,isTurnDone:d,isMobile:f,cwd:m,skillMetadata:p,onRestoreToHere:h,onOpenBranches:g,onEditCommand:x,onExpandCommand:b,openQuestionId:y}){const{ref:v,isNear:k}=QN(),j=w.useRef(null),_=w.useRef(0);w.useLayoutEffect(()=>{k&&j.current&&(_.current=j.current.offsetHeight)},[k]);const N=cd(e.toolCalls,m)||e.subAgentActivity.some(O=>cd(O.toolCalls,m)),S=d?"settled":"working",C=w.useMemo(()=>mV(e.contentBlocks,S,y),[S,y,e.contentBlocks]),[E,T]=w.useState(()=>d?void 0:!0),A=E??(i||!d),{leadingBlocks:P,trailingBlocks:I}=w.useMemo(()=>{if(!C.foldable)return{leadingBlocks:[],trailingBlocks:[]};const O=C.foldAnchorIndex,M=new Set(C.foldedIndices);return{leadingBlocks:e.contentBlocks.slice(0,O),trailingBlocks:e.contentBlocks.slice(O).filter((R,z)=>A||!M.has(O+z))}},[C,e.contentBlocks,A]),$={model:e.model,effort:e.effort,expandAll:i,expandToolPayloads:l,activeToolCallId:o,isAgentActive:c,isSessionLive:u,isMobile:f,skillMetadata:p};return a.jsxs("div",{ref:v,"data-turn-index":t,className:G("group relative",f?"px-0 py-5":"px-4 py-5",r&&"rounded-lg ring-1 ring-ring/40"),children:[a.jsx(vV,{index:t,turn:e,branchCount:s,isTurnDone:d,isMobile:f,onRestoreToHere:h,onOpenBranches:g}),k?a.jsxs("div",{ref:j,className:"flex flex-col gap-3",children:[e.userMessage&&a.jsx(hV,{index:t,children:a.jsx("div",{"data-turn-prompt":!0,className:G("rounded-lg p-3",JC),children:a.jsx(hx,{content:e.userMessage,timestamp:e.timestamp,onEditCommand:x,onExpandCommand:b})})}),C.foldable?a.jsxs(a.Fragment,{children:[P.length>0&&a.jsx(Nm,{blocks:P,...$}),a.jsx(pq,{label:a.jsx(gV,{turn:e,isTurnDone:d,hiddenToolCalls:C.hiddenToolCalls}),expanded:A,onToggle:()=>T(!A)}),I.length>0&&a.jsx(Nm,{blocks:I,...$})]}):a.jsx(Nm,{blocks:e.contentBlocks,...$}),d&&N&&a.jsx(Vq,{turn:e,turnIndex:t,cwd:m})]}):a.jsx("div",{style:{minHeight:_.current||bV(e)}})]})});function bV(n){return Math.max(60,(n.userMessage?40:0)+n.contentBlocks.length*60)}function vV(n){const e=q.c(26),{index:t,turn:s,branchCount:r,isTurnDone:o,isMobile:i,onRestoreToHere:l,onOpenBranches:c}=n,u=!o&&!!s.timestamp;let d;e[0]!==o||e[1]!==s?(d=o?T1(s):null,e[0]=o,e[1]=s,e[2]=d):d=e[2];const f=d,m=i?"mb-2 gap-1.5":"mb-4 gap-2";let p;e[3]!==m?(p=G("flex items-center",m),e[3]=m,e[4]=p):p=e[4];const h=t+1;let g;e[5]!==h?(g=a.jsx("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:h}),e[5]=h,e[6]=g):g=e[6];let x;e[7]!==f||e[8]!==u||e[9]!==s.timestamp?(x=a.jsx(yV,{durationMs:f,showLiveTimer:u,timestamp:s.timestamp}),e[7]=f,e[8]=u,e[9]=s.timestamp,e[10]=x):x=e[10];let b;e[11]!==t||e[12]!==i||e[13]!==l?(b=l&&a.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>l(t),className:G("ml-auto text-muted-foreground transition-opacity hover:text-foreground",i?"opacity-70":"opacity-0 group-hover:opacity-100"),title:"Undo this turn and all after it",children:[a.jsx(r1,{"data-icon":"inline-start"}),a.jsx("span",{className:"hidden sm:inline",children:"Restore"})]}),e[11]=t,e[12]=i,e[13]=l,e[14]=b):b=e[14];let y;e[15]!==r||e[16]!==t||e[17]!==c||e[18]!==l?(y=r>0&&c&&a.jsx("div",{className:G(!l&&"ml-auto"),children:a.jsx(Kq,{branchCount:r,onClick:()=>c(t)})}),e[15]=r,e[16]=t,e[17]=c,e[18]=l,e[19]=y):y=e[19];let v;return e[20]!==p||e[21]!==g||e[22]!==x||e[23]!==b||e[24]!==y?(v=a.jsxs("div",{className:p,children:[g,x,b,y]}),e[20]=p,e[21]=g,e[22]=x,e[23]=b,e[24]=y,e[25]=v):v=e[25],v}function yV(n){const e=q.c(8),{durationMs:t,showLiveTimer:s,timestamp:r}=n;if(t!==null){let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx(oo,{className:"size-3","data-icon":"inline-start"}),e[0]=o):o=e[0];let i;e[1]!==t?(i=sr(t),e[1]=t,e[2]=i):i=e[2];let l;return e[3]!==i?(l=a.jsxs("span",{className:"flex items-center gap-1 font-mono text-xs tabular-nums text-muted-foreground",children:[o,i]}),e[3]=i,e[4]=l):l=e[4],l}if(s){let o;e[5]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx(oo,{className:"size-3","data-icon":"inline-start"}),e[5]=o):o=e[5];let i;return e[6]!==r?(i=a.jsxs("span",{className:"flex items-center gap-1 font-mono text-xs tabular-nums text-info",children:[o,a.jsx($x,{startTimestamp:r,className:"tabular-nums"})]}),e[6]=r,e[7]=i):i=e[7],i}return null}function wV(n){var e,t,s;switch(n.kind){case"tool_calls":return((e=n.toolCalls[0])==null?void 0:e.id)??null;case"sub_agent":case"background_agent":return((t=n.messages[0])==null?void 0:t.parentToolUseId)??((s=n.messages[0])==null?void 0:s.agentId)??null;default:return n.timestamp??null}}function Nm(n){const e=q.c(11),{blocks:t,model:s,effort:r,expandAll:o,expandToolPayloads:i,activeToolCallId:l,isAgentActive:c,isSessionLive:u,isMobile:d,skillMetadata:f}=n;let m;if(e[0]!==l||e[1]!==t||e[2]!==r||e[3]!==o||e[4]!==i||e[5]!==c||e[6]!==d||e[7]!==u||e[8]!==s||e[9]!==f){const p=[],h=d?"ml-0 pl-2":"ml-1 pl-3",g=new Map,x=(y,v)=>{const k=wV(y)??`at-${v}`,j=g.get(k)??0;return g.set(k,j+1),j===0?k:`${k}#${j}`};let b=0;for(;b<t.length;){const y=t[b];if(y.kind==="thinking"||y.kind==="tool_calls"){const{items:v,toolCalls:k,thinkingCount:j,thoughtForMs:_,nextIndex:N}=Zy(t,b),S=v.length===1&&v[0].kind==="tool_calls";p.push(a.jsx("div",{className:G(Xy,h),children:a.jsx(Fy,{toolCalls:k,expandAll:o,expandToolPayloads:i,activeToolCallId:l,isAgentActive:c,activityItems:S?void 0:v,thinkingCount:j,thoughtForMs:_,skillMetadata:f})},x(y,b))),b=N;continue}if(y.kind==="text"){const{items:v,toolCalls:k,thinkingCount:j,thoughtForMs:_,nextIndex:N}=Zy(t,b+1);p.push(a.jsxs("div",{children:[a.jsx("div",{className:G("flex flex-col","gap-3"),children:y.text.map((S,C)=>a.jsx($U,{text:S,model:s,effort:r,timestamp:y.timestamp},C))}),(k.length>0||j>0)&&a.jsx("div",{className:G("mt-1.5",Xy,h),children:a.jsx(Fy,{toolCalls:k,expandAll:o,expandToolPayloads:i,activeToolCallId:l,isAgentActive:c,activityItems:j>0?v:void 0,thinkingCount:j,thoughtForMs:_,skillMetadata:f})})]},x(y,b))),b=N;continue}if(y.kind==="queued_prompt"){p.push(a.jsxs("div",{className:G("rounded-lg p-3",JC),children:[a.jsx(Ue,{variant:"outline",className:"mb-2",children:"Queued while working"}),a.jsx(hx,{content:y.content,timestamp:y.timestamp??""})]},x(y,b))),b++;continue}if(y.kind==="agent_message"){p.push(a.jsx(PU,{sender:y.sender,body:y.body,reply:y.reply,timestamp:y.timestamp,isLive:u},x(y,b))),b++;continue}if(y.kind==="sub_agent"){p.push(a.jsx("div",{className:G(Jy,h),children:a.jsx(Cy,{messages:y.messages,expandAll:o,label:"Sub-agent activity",countLabel:"subagents active"})},x(y,b))),b++;continue}if(y.kind==="background_agent"){p.push(a.jsx("div",{className:G(Jy,h),children:a.jsx(Cy,{messages:y.messages,expandAll:o,label:"Background agent activity",countLabel:"agents active"})},x(y,b))),b++;continue}if(y.kind==="hook_event"){p.push(a.jsx(QU,{events:y.events},x(y,b))),b++;continue}if(y.kind==="plan_mode"){p.push(a.jsx(lq,{plan:y.plan,planFilePath:y.planFilePath,status:y.status,toolCalls:y.toolCalls,expandAll:o,expandToolPayloads:i,isAgentActive:c,skillMetadata:f},x(y,b))),b++;continue}if(y.kind==="recap"){p.push(a.jsx(cq,{content:y.content},x(y,b))),b++;continue}if(y.kind==="task_notification"){p.push(a.jsx(iF,{content:y.content},x(y,b))),b++;continue}b++}m=a.jsx(a.Fragment,{children:p}),e[0]=l,e[1]=t,e[2]=r,e[3]=o,e[4]=i,e[5]=c,e[6]=d,e[7]=u,e[8]=s,e[9]=f,e[10]=m}else m=e[10];return m}function SV(n){if(!n)return null;const e=n.trigger==="manual"?"manual":"auto";return n.postTokens!=null?`${e} · ${Nt(n.preTokens)} → ${Nt(n.postTokens)}`:`${e} · ${Nt(n.preTokens)}`}const kV=w.memo(function(e){const t=q.c(29),{summary:s,meta:r}=e,[o,i]=w.useState(!1);let l;t[0]!==r?(l=SV(r),t[0]=r,t[1]=l):l=t[1];const c=l;let u;t[2]!==s?(u=s==null?void 0:s.trim(),t[2]=s,t[3]=u):u=t[3];const d=u;let f;t[4]!==d||t[5]!==o?(f=d&&(o?a.jsx(Ot,{className:"size-3","data-icon":"inline-start"}):a.jsx(ot,{className:"size-3","data-icon":"inline-start"})),t[4]=d,t[5]=o,t[6]=f):f=t[6];let m,p;t[7]===Symbol.for("react.memo_cache_sentinel")?(m=a.jsx(uP,{className:"size-3","data-icon":"inline-start"}),p=a.jsx("span",{className:"font-medium",children:"Compacted"}),t[7]=m,t[8]=p):(m=t[7],p=t[8]);let h;t[9]!==c?(h=c&&a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"·"}),a.jsx("span",{children:c})]}),t[9]=c,t[10]=h):h=t[10];let g;t[11]!==f||t[12]!==h?(g=a.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground transition-colors group-hover:text-foreground",children:[f,m,p,h]}),t[11]=f,t[12]=h,t[13]=g):g=t[13];const x=g;if(!d){let N;t[14]===Symbol.for("react.memo_cache_sentinel")?(N=a.jsx("div",{className:"h-px flex-1 bg-border"}),t[14]=N):N=t[14];let S;t[15]===Symbol.for("react.memo_cache_sentinel")?(S=a.jsx("div",{className:"h-px flex-1 bg-border"}),t[15]=S):S=t[15];let C;return t[16]!==x?(C=a.jsxs("div",{className:"flex items-center gap-3 px-4 py-2",children:[N,x,S]}),t[16]=x,t[17]=C):C=t[17],C}let b,y;t[18]===Symbol.for("react.memo_cache_sentinel")?(b=a.jsx(ee,{type:"button",variant:"ghost",className:"group h-auto w-full gap-3 px-0"}),y=a.jsx("div",{className:"h-px flex-1 bg-border"}),t[18]=b,t[19]=y):(b=t[18],y=t[19]);let v;t[20]===Symbol.for("react.memo_cache_sentinel")?(v=a.jsx("div",{className:"h-px flex-1 bg-border"}),t[20]=v):v=t[20];let k;t[21]!==x?(k=a.jsxs(vs,{render:b,children:[y,x,v]}),t[21]=x,t[22]=k):k=t[22];let j;t[23]!==d?(j=a.jsx(Tn,{children:a.jsx("div",{className:"prose prose-sm dark:prose-invert mx-8 mt-2 max-w-none rounded-md border bg-muted/30 px-3 py-2",children:a.jsx(cr,{remarkPlugins:gr,components:hr,children:d})})}),t[23]=d,t[24]=j):j=t[24];let _;return t[25]!==o||t[26]!==k||t[27]!==j?(_=a.jsxs(En,{open:o,onOpenChange:i,className:"px-4 py-2",children:[k,j]}),t[25]=o,t[26]=k,t[27]=j,t[28]=_):_=t[28],_}),jV=1.5;function NV(n,e){return e<=0?!1:n<e*jV}function CV(n,e){return n===0&&!e}function _V(n,e){return!n||!n.firstKey||e.length<=n.length||e[0]===n.firstKey?!1:e.includes(n.firstKey)}function EV(n,e){return e&&e!=="claude"?n.isFragment===!0:n.userMessage===null}const TV=1e3;function AV(n){const e=new Map;return n.map(t=>{if(!t.contentBlocks.some(r=>r.kind==="agent_message"))return t;const s=t.contentBlocks.filter(r=>{if(r.kind!=="agent_message")return!0;const o=Date.parse(r.timestamp??"");if(Number.isNaN(o))return!0;const i=`${r.sender}\0${r.body}`,l=e.get(i);return l!==void 0&&Math.abs(o-l)<=TV?!1:(e.set(i,o),!0)});return s.length===t.contentBlocks.length?t:{...t,contentBlocks:s}})}function e5(n,e,t){const s=new Set(n.map(c=>c.id)),r=e.filter(c=>!s.has(c.id));if(r.length===0)return n;const o=n[0],i=r[r.length-1],l=o&&i&&EV(o,t)?[...r.slice(0,-1),IV(i,o),...n.slice(1)]:[...r,...n];return cx(AV(l))}function PV(n,e){if(n.durationMs!==null&&e.durationMs!==null)return n.durationMs+e.durationMs;const t=Date.parse(n.timestamp),s=Date.parse(e.timestamp)+(e.durationMs??0);return!Number.isFinite(t)||!Number.isFinite(s)||s<t?e.durationMs??n.durationMs:s-t}function IV(n,e){return{...n,id:e.id,contentBlocks:[...n.contentBlocks,...e.contentBlocks],thinking:[...n.thinking,...e.thinking],assistantText:[...n.assistantText,...e.assistantText],toolCalls:[...n.toolCalls,...e.toolCalls],subAgentActivity:[...n.subAgentActivity,...e.subAgentActivity],durationMs:PV(n,e),tokenUsage:e.tokenUsage??n.tokenUsage,model:e.model??n.model,compactionSummary:n.compactionSummary??e.compactionSummary,compactionMeta:n.compactionMeta??e.compactionMeta}}function $V(){const n=q.c(10),{session:e,isSubAgentView:t,undoRedo:s}=xt(),{canRedo:r,redoTurnCount:o,redoGhostTurns:i,requestRedoAll:l,requestRedoUpTo:c}=s,u=(e==null?void 0:e.turns.length)??0;if(!s.enabled||t||!r||!l)return null;let d;n[0]!==o||n[1]!==l?(d=a.jsx(UF,{redoTurnCount:o,onRedoAll:l}),n[0]=o,n[1]=l,n[2]=d):d=n[2];let f;n[3]!==i||n[4]!==c||n[5]!==u?(f=i.length>0&&a.jsx("div",{className:"select-none",children:i.map((p,h)=>a.jsxs("div",{className:"group/ghost relative opacity-25 hover:opacity-40 transition-opacity",children:[a.jsx(QC,{turn:p,index:u+h}),c&&a.jsxs(ee,{type:"button",variant:"outline",size:"xs",onClick:()=>c(h),className:"absolute right-4 top-4 text-success opacity-0 transition-opacity group-hover/ghost:opacity-100",children:[a.jsx(dP,{"data-icon":"inline-start"}),"Redo to here"]})]},`ghost-${p.id}`))}),n[3]=i,n[4]=c,n[5]=u,n[6]=f):f=n[6];let m;return n[7]!==d||n[8]!==f?(m=a.jsxs(a.Fragment,{children:[d,f]}),n[7]=d,n[8]=f,n[9]=m):m=n[9],m}function RV(n){const e=q.c(5),{hasMore:t,isLoadingOlder:s}=n;let r;e[0]!==t||e[1]!==s?(r=s?a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx(vt,{className:"size-3 animate-spin","data-icon":"inline-start"}),"Loading older turns…"]}):t?null:a.jsx("span",{children:"Beginning of session"}),e[0]=t,e[1]=s,e[2]=r):r=e[2];let o;return e[3]!==r?(o=a.jsx("div",{className:"flex h-8 select-none items-center justify-center text-xs text-muted-foreground","data-testid":"history-status",children:r}),e[3]=r,e[4]=o):o=e[4],o}function OV(n){return(n.compactionSummary!=null||n.compactionMeta!=null)&&n.userMessage==null&&n.contentBlocks.length===0}function LV({filteredTurns:n,scrollContainerRef:e,hasMore:t=!1,isLoadingOlder:s=!1,pagingEnabled:r=!1,onLoadMore:o}){const{state:{activeTurnIndex:i}}=bn(),{undoRedo:l}=xt(),c=w.useRef(null),u=w.useRef(null),[d,f]=w.useState(0),m=w.useMemo(()=>{const v=new Map;return n.map(k=>{const j=v.get(k.turn.id)??0;return v.set(k.turn.id,j+1),{...k,key:j===0?k.turn.id:`${k.turn.id}#${j}`}})},[n]),p=w.useRef(null),h=w.useMemo(()=>_V(p.current,m.map(v=>v.key)),[m]);w.useLayoutEffect(()=>{var v;p.current={firstKey:(v=m[0])==null?void 0:v.key,length:m.length}},[m]);const g=w.useRef(t);w.useEffect(()=>{t&&(g.current=!0)},[t]);const x=t||g.current;w.useLayoutEffect(()=>{const v=e.current,k=u.current;if(!v||!k)return;const j=k.getBoundingClientRect().top-v.getBoundingClientRect().top+v.scrollTop;f(_=>Math.abs(_-j)<1?_:j)},[e,x]),w.useEffect(()=>{if(!t||!o||!r||s)return;const v=e.current;if(!v)return;const k=()=>{NV(v.scrollTop,v.clientHeight)&&o()};return k(),v.addEventListener("scroll",k,{passive:!0}),()=>v.removeEventListener("scroll",k)},[t,s,r,o,m.length,e]);const b=w.useMemo(()=>{const v=new Map;for(let k=0;k<m.length;k++)v.set(m[k].index,k);return v},[m]),y=w.useRef(null);return w.useEffect(()=>{var k;if(i===null){y.current=null;return}if(i===y.current)return;y.current=i;const v=b.get(i);v!==void 0&&((k=c.current)==null||k.scrollToIndex(v,{align:"start",smooth:!0}))},[i,b]),a.jsxs(a.Fragment,{children:[x&&a.jsx(RV,{hasMore:t,isLoadingOlder:s}),a.jsx("div",{ref:u,className:"motion-session-enter",children:a.jsx(FF,{ref:c,scrollRef:e,startMargin:d,shift:h,children:m.map(({turn:v,index:k,key:j})=>a.jsxs("div",{"data-turn-index":k,children:[(v.compactionSummary||v.compactionMeta)&&a.jsx(kV,{summary:v.compactionSummary,meta:v.compactionMeta}),!OV(v)&&a.jsx(QC,{turn:v,index:k,branchCount:l.branchesAtTurn?l.branchesAtTurn(k).length:0})]},j))})}),a.jsx($V,{})]})}const MV=w.memo(function(e){const t=q.c(19),{chatScrollRef:s,hasMore:r,isLoadingOlder:o,pagingEnabled:i,onLoadMore:l}=e,{state:c}=bn(),{searchQuery:u,sessionChangeKey:d}=c,{session:f}=xt(),m=f==null?void 0:f.turns;let p;t[0]!==m?(p=m?m.map(zV):[],t[0]=m,t[1]=p):p=t[1];const h=p;let g;t[2]!==h||t[3]!==u?(g=u?h.filter(k=>{const{turn:j}=k;return eV(j,u)}):h,t[2]=h,t[3]=u,t[4]=g):g=t[4];const x=g;let b;t[5]!==x.length||t[6]!==r||t[7]!==u?(b=u?x.length===0:CV(x.length,r??!1),t[5]=x.length,t[6]=r,t[7]=u,t[8]=b):b=t[8];const y=b;let v;return t[9]!==s||t[10]!==x||t[11]!==r||t[12]!==o||t[13]!==l||t[14]!==i||t[15]!==u||t[16]!==d||t[17]!==y?(v=a.jsx(AD,{children:y?a.jsx(kn,{className:"min-h-64 border-0",children:a.jsxs(jn,{children:[a.jsx(Rn,{variant:"icon",children:u?a.jsx(fP,{}):a.jsx(j3,{})}),a.jsx(Nn,{children:u?"No matching turns":"No conversation yet"}),a.jsx(Cn,{children:u?"Try a different search term.":"Messages and tool activity will appear here."})]})}):a.jsx(LV,{filteredTurns:x,scrollContainerRef:s,hasMore:r,isLoadingOlder:o,pagingEnabled:i,onLoadMore:l},d)}),t[9]=s,t[10]=x,t[11]=r,t[12]=o,t[13]=l,t[14]=i,t[15]=u,t[16]=d,t[17]=y,t[18]=v):v=t[18],v});function zV(n,e){return{turn:n,index:e}}const DV="[data-turn-index]",t5="[data-turn-prompt]",Qy=1,FV=120,e2=180;function UV(n){if(!n.userMessage)return null;const e=cf(n.userMessage),{body:t}=wl(e),{remainingText:s}=px(t),r=LN(s);if(!r){const i=MN(e);if(!i)return null;const l=zN(e);return l?`/${i} ${l}`:`/${i}`}const o=r.split(`
|
|
117
|
+
`)[0];return o.length>e2?`${o.slice(0,e2)}...`:o}function BV(n,e){for(let t=e;t>=0;t--){const s=n[t];if(!s)continue;const r=UV(s);if(r)return{index:t,text:r}}return null}function WV(n){const e=n.getBoundingClientRect().top;let t=null,s=0;for(const l of n.querySelectorAll(DV)){const c=l.getBoundingClientRect().top;if(c>e+Qy)break;t=l,s=c}if(!t)return null;const r=Number(t.dataset.turnIndex);if(!Number.isInteger(r))return null;const o=t.querySelector(t5);return(o?o.getBoundingClientRect().bottom>e+Qy:s+FV>e)?null:r}const qV=w.memo(function(e){const t=q.c(22),{session:s,scrollContainerRef:r}=e,[o,i]=w.useState(null);let l,c;t[0]!==r||t[1]!==s.sessionId?(l=()=>{const k=r.current;if(!k)return;let j=null;const _=()=>{j=null;const E=WV(k);i(T=>E===null?null:(T==null?void 0:T.sessionId)===s.sessionId&&T.index===E?T:{sessionId:s.sessionId,index:E})},N=()=>{j===null&&(j=requestAnimationFrame(_))};i(null),k.addEventListener("scroll",N,{passive:!0});const S=new MutationObserver(N);S.observe(k,{childList:!0,subtree:!0});const C=new ResizeObserver(N);return C.observe(k),k.firstElementChild&&C.observe(k.firstElementChild),N(),()=>{k.removeEventListener("scroll",N),S.disconnect(),C.disconnect(),j!==null&&cancelAnimationFrame(j)}},c=[r,s.sessionId],t[0]=r,t[1]=s.sessionId,t[2]=l,t[3]=c):(l=t[2],c=t[3]),w.useEffect(l,c);let u;e:{if(!o||o.sessionId!==s.sessionId){u=null;break e}let k;t[4]!==s.turns||t[5]!==o.index?(k=BV(s.turns,o.index),t[4]=s.turns,t[5]=o.index,t[6]=k):k=t[6],u=k}const d=u;if(!d)return null;let f;t[7]!==d.index||t[8]!==r?(f=()=>{const k=r.current;if(!k)return;const j=k.querySelector(`[data-turn-index="${d.index}"]`),_=(j==null?void 0:j.querySelector(t5))??j;if(!_)return;const N=k.scrollTop+_.getBoundingClientRect().top-k.getBoundingClientRect().top;k.scrollTo({top:Math.max(0,N),behavior:"smooth"})},t[7]=d.index,t[8]=r,t[9]=f):f=t[9];const m=f,p=`Scroll to turn ${d.index+1} prompt`;let h;t[10]===Symbol.for("react.memo_cache_sentinel")?(h=a.jsx(j3,{"data-icon":"inline-start"}),t[10]=h):h=t[10];const g=d.index+1;let x;t[11]!==g?(x=a.jsxs("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:["Turn ",g]}),t[11]=g,t[12]=x):x=t[12];let b;t[13]!==d.text?(b=a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-normal text-foreground/80",children:d.text}),t[13]=d.text,t[14]=b):b=t[14];let y;t[15]===Symbol.for("react.memo_cache_sentinel")?(y=a.jsx(Id,{"data-icon":"inline-end",className:"ml-auto"}),t[15]=y):y=t[15];let v;return t[16]!==d.text||t[17]!==m||t[18]!==p||t[19]!==x||t[20]!==b?(v=a.jsxs(ee,{type:"button",variant:"outline",size:"sm","aria-label":p,title:d.text,className:"motion-slide-down-in absolute left-1/2 top-12 z-20 h-9 max-w-[calc(100%-5rem)] -translate-x-1/2 justify-start gap-2 rounded-full bg-popover px-3 text-left shadow-sm",onClick:m,children:[h,x,b,y]}),t[16]=d.text,t[17]=m,t[18]=p,t[19]=x,t[20]=b,t[21]=v):v=t[21],v});function tg({path:n,dirName:e,command:t}){return yo()?(console.warn("[open-terminal] unavailable for remote devices"),!1):!n&&!e?(console.warn("[open-terminal] no project path available"),!1):(Re("/api/open-terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n,dirName:e,...t?{command:t}:{}})}).then(s=>{s.ok||s.json().then(r=>console.error("[open-terminal]",r.error)).catch(()=>{})}).catch(s=>console.error("[open-terminal] fetch failed:",s)),!0)}const VV={five_hour:"5-hour",seven_day:"weekly",seven_day_opus:"weekly Opus",seven_day_sonnet:"weekly Sonnet",seven_day_overage_included:"weekly",overage:"spend"},HV=1440*60*1e3;function KV(n){return(n&&VV[n])??"usage"}function GV(n){if(n===null)return null;const e=new Date(n*1e3);if(Number.isNaN(e.getTime()))return null;const t=e.getTime()-Date.now()>HV;return e.toLocaleString(void 0,{...t?{weekday:"short"}:{},hour:"numeric",minute:"2-digit"})}function ZV(n){const e=q.c(33),{block:t,dirName:s,fileName:r,cwd:o,terminal:i}=n;let l,c;e[0]!==o||e[1]!==s||e[2]!==r?(l=Ss(s),c=y1(l.kind,Gu(r),o??void 0),e[0]=o,e[1]=s,e[2]=r,e[3]=l,e[4]=c):(l=e[3],c=e[4]);const u=c;let d;e[5]!==t.resetsAt?(d=GV(t.resetsAt),e[5]=t.resetsAt,e[6]=d):d=e[6];const f=d,m=t.lowPriority&&l.capabilities.lowPriorityInTerminal;let p;e[7]!==m||e[8]!==i?(p=m&&i&&!yo(),e[7]=m,e[8]=i,e[9]=p):p=e[9];const h=p;let g;e[10]===Symbol.for("react.memo_cache_sentinel")?(g=a.jsx(oo,{}),e[10]=g):g=e[10];const x=l.displayName;let b;e[11]!==t.limit?(b=KV(t.limit),e[11]=t.limit,e[12]=b):b=e[12];let y;e[13]!==l.displayName||e[14]!==b?(y=a.jsxs(_n,{children:[x," hit its ",b," limit"]}),e[13]=l.displayName,e[14]=b,e[15]=y):y=e[15];const v=f?`Resets at ${f}. `:"";let k;e[16]!==u||e[17]!==m?(k=m?a.jsxs(a.Fragment,{children:["It can keep this session going before then at lower priority, spending your weekly allowance to do it — a mode that exists only in its own terminal. Resume there with ",a.jsx("code",{className:"font-mono",children:u}),"."]}):a.jsx(a.Fragment,{children:"Nothing here can lift this one; the session continues once the allowance refills."}),e[16]=u,e[17]=m,e[18]=k):k=e[18];let j;e[19]!==v||e[20]!==k?(j=a.jsxs("span",{children:[v,k]}),e[19]=v,e[20]=k,e[21]=j):j=e[21];let _;e[22]!==h||e[23]!==u||e[24]!==o||e[25]!==s?(_=h&&a.jsx(ee,{size:"sm",variant:"outline",onClick:()=>tg({path:o??void 0,dirName:s,command:u}),children:"Open in terminal"}),e[22]=h,e[23]=u,e[24]=o,e[25]=s,e[26]=_):_=e[26];let N;e[27]!==j||e[28]!==_?(N=a.jsxs(Qt,{className:"flex flex-col items-start gap-2",children:[j,_]}),e[27]=j,e[28]=_,e[29]=N):N=e[29];let S;return e[30]!==N||e[31]!==y?(S=a.jsxs(Jt,{role:"status",className:"rounded-none border-x-0 border-t-0 px-4 py-2",children:[g,y,N]}),e[30]=N,e[31]=y,e[32]=S):S=e[32],S}function YV(n){const e=q.c(14),{block:t,showCursor:s}=n;if(t.blockType==="tool_use"){const l=t.toolName??"tool";let c;return e[0]!==l?(c=a.jsxs("div",{className:"text-xs text-muted-foreground italic py-1",children:["Preparing ",l,"…"]}),e[0]=l,e[1]=c):c=e[1],c}if(t.blockType==="thinking"){if(!t.text)return null;let l;e[2]!==s?(l=s&&a.jsx(t2,{}),e[2]=s,e[3]=l):l=e[3];let c;return e[4]!==t.text||e[5]!==l?(c=a.jsxs("div",{className:"my-2 whitespace-pre-wrap break-words border-l pl-3 text-sm italic leading-relaxed text-muted-foreground",children:[t.text,l]}),e[4]=t.text,e[5]=l,e[6]=c):c=e[6],c}if(!t.text)return null;let r;e[7]!==t.text?(r=a.jsx(yC,{text:t.text}),e[7]=t.text,e[8]=r):r=e[8];let o;e[9]!==s?(o=s&&a.jsx(t2,{}),e[9]=s,e[10]=o):o=e[10];let i;return e[11]!==r||e[12]!==o?(i=a.jsxs("div",{className:"text-sm leading-relaxed break-words my-2",children:[r,o]}),e[11]=r,e[12]=o,e[13]=i):i=e[13],i}function t2(){const n=q.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=a.jsx("span",{className:"ml-0.5 inline-block h-[15px] w-[7px] rounded-[1px] bg-foreground/70 align-text-bottom"}),n[0]=e):e=n[0],e}const XV=w.memo(function(){const e=q.c(9),t=jx();let s,r,o,i;if(e[0]!==t){i=Symbol.for("react.early_return_sentinel");e:{const c=zU(t);if(c.length===0){i=null;break e}const u=new Map;s="px-4",r="streaming-turn-overlay",o=c.map(d=>{const f=u.get(d.messageId)??0;u.set(d.messageId,f+1);const m=d.blocks.reduce(JV,-1);return a.jsx("div",{children:d.blocks.map((p,h)=>a.jsx(YV,{block:p,showCursor:!d.stopped&&h===m},p.index))},`${d.messageId}:${f}`)})}e[0]=t,e[1]=s,e[2]=r,e[3]=o,e[4]=i}else s=e[1],r=e[2],o=e[3],i=e[4];if(i!==Symbol.for("react.early_return_sentinel"))return i;let l;return e[5]!==s||e[6]!==r||e[7]!==o?(l=a.jsx("div",{className:s,"data-testid":r,children:o}),e[5]=s,e[6]=r,e[7]=o,e[8]=l):l=e[8],l});function JV(n,e,t){return e.blockType!=="tool_use"&&e.text?t:n}class n5 extends w.Component{constructor(t){super(t);Wt(this,"handleRetry",()=>{this.setState({hasError:!1,error:null})});this.state={hasError:!1,error:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,s){console.error("ErrorBoundary caught:",t,s.componentStack)}render(){return this.state.hasError?a.jsx("div",{className:"flex justify-center p-8",children:a.jsxs(Jt,{variant:"destructive",className:"max-w-md has-data-[slot=alert-action]:pr-2.5",children:[a.jsx(lr,{}),a.jsx(_n,{children:a.jsx("h3",{children:this.props.fallbackMessage||"Something went wrong"})}),this.state.error&&a.jsx(Qt,{className:"font-mono text-xs",children:this.state.error.message}),a.jsx(uo,{className:"static col-start-2 mt-2",children:a.jsxs(ee,{variant:"outline",size:"sm",onClick:this.handleRetry,children:[a.jsx(On,{"data-icon":"inline-start"}),"Try again"]})})]})}):this.props.children}}const n2="find-in-session-highlight",Cm="find-in-session-active";function QV(n){const e=[],t=document.createTreeWalker(n,NodeFilter.SHOW_TEXT,null);let s;for(;s=t.nextNode();)s.nodeValue&&s.nodeValue.trim().length>0&&e.push(s);return e}const eH=w.forwardRef(function(e,t){const s=q.c(63),{scrollContainerRef:r}=e,[o,i]=w.useState(!1),[l,c]=w.useState("");let u;s[0]===Symbol.for("react.memo_cache_sentinel")?(u=[],s[0]=u):u=s[0];const[d,f]=w.useState(u),[m,p]=w.useState(-1),h=w.useRef(null);let g;s[1]!==r?(g=()=>{const J=r.current;if(!J)return;J.querySelectorAll(`mark.${n2}`).forEach(tH)},s[1]=r,s[2]=g):g=s[2];const x=g;let b;s[3]!==x||s[4]!==r?(b=J=>{if(x(),!J||!r.current){f([]),p(-1);return}const ne=r.current,re=QV(ne),le=J.toLowerCase(),ae=[];for(const ue of re){const oe=ue.nodeValue||"",ie=oe.toLowerCase();let fe=0;const de=[];for(;;){const he=ie.indexOf(le,fe);if(he===-1)break;de.push(he),fe=he+1}if(de.length===0)continue;const ce=ue.parentNode;if(!ce)continue;const xe=document.createDocumentFragment();let pe=0;for(const he of de){he>pe&&xe.appendChild(document.createTextNode(oe.slice(pe,he)));const ye=document.createElement("mark");ye.className=n2,ye.textContent=oe.slice(he,he+J.length),xe.appendChild(ye),ae.push(ye),pe=he+J.length}pe<oe.length&&xe.appendChild(document.createTextNode(oe.slice(pe))),ce.replaceChild(xe,ue)}f(ae),ae.length>0?(p(0),ae[0].classList.add(Cm),ae[0].scrollIntoView({block:"center",behavior:"smooth"})):p(-1)},s[3]=x,s[4]=r,s[5]=b):b=s[5];const y=b;let v;s[6]!==m||s[7]!==d?(v=J=>{if(d.length===0)return;m>=0&&m<d.length&&d[m].classList.remove(Cm);const ne=(J%d.length+d.length)%d.length;d[ne].classList.add(Cm),d[ne].scrollIntoView({block:"center",behavior:"smooth"}),p(ne)},s[6]=m,s[7]=d,s[8]=v):v=s[8];const k=v;let j;s[9]!==x?(j=()=>{i(!1),c(""),x(),f([]),p(-1)},s[9]=x,s[10]=j):j=s[10];const _=j;let N,S;s[11]!==_||s[12]!==o?(N=()=>({open:()=>{i(!0),requestAnimationFrame(()=>{var J;return(J=h.current)==null?void 0:J.focus()})},close:_,isOpen:o}),S=[_,o],s[11]=_,s[12]=o,s[13]=N,s[14]=S):(N=s[13],S=s[14]),w.useImperativeHandle(t,N,S);let C,E;s[15]!==y||s[16]!==l?(C=()=>{const J=setTimeout(()=>y(l),150);return()=>clearTimeout(J)},E=[l,y],s[15]=y,s[16]=l,s[17]=C,s[18]=E):(C=s[17],E=s[18]),w.useEffect(C,E);let T,A;s[19]!==x?(T=()=>()=>x(),A=[x],s[19]=x,s[20]=T,s[21]=A):(T=s[20],A=s[21]),w.useEffect(T,A);let P;s[22]!==m||s[23]!==k||s[24]!==_?(P=J=>{J.key==="Escape"?(J.preventDefault(),J.stopPropagation(),_()):J.key==="Enter"&&(J.preventDefault(),J.shiftKey?k(m-1):k(m+1))},s[22]=m,s[23]=k,s[24]=_,s[25]=P):P=s[25];const I=P;if(!o)return null;let $;s[26]===Symbol.for("react.memo_cache_sentinel")?($=J=>c(J.target.value),s[26]=$):$=s[26];let O;s[27]!==I||s[28]!==l?(O=a.jsx(ko,{ref:h,value:l,onChange:$,onKeyDown:I,placeholder:"Find in conversation","aria-label":"Find in conversation",autoFocus:!0}),s[27]=I,s[28]=l,s[29]=O):O=s[29];const M=l?d.length>0?`${m+1}/${d.length}`:"0/0":"";let R;s[30]!==M?(R=a.jsx(or,{align:"inline-end",children:a.jsx("span",{className:"min-w-12 text-center text-xs tabular-nums",children:M})}),s[30]=M,s[31]=R):R=s[31];let z;s[32]!==O||s[33]!==R?(z=a.jsxs(So,{className:"w-64",children:[O,R]}),s[32]=O,s[33]=R,s[34]=z):z=s[34];let W;s[35]!==m||s[36]!==k?(W=()=>k(m-1),s[35]=m,s[36]=k,s[37]=W):W=s[37];const D=d.length===0,L=d.length>0?"hover:text-foreground":"cursor-default opacity-40";let U;s[38]!==L?(U=G("text-muted-foreground",L),s[38]=L,s[39]=U):U=s[39];let F;s[40]===Symbol.for("react.memo_cache_sentinel")?(F=a.jsx(Id,{"data-icon":"inline-start"}),s[40]=F):F=s[40];let B;s[41]!==W||s[42]!==D||s[43]!==U?(B=a.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:W,disabled:D,className:U,"aria-label":"Previous match",children:F}),s[41]=W,s[42]=D,s[43]=U,s[44]=B):B=s[44];let V;s[45]!==m||s[46]!==k?(V=()=>k(m+1),s[45]=m,s[46]=k,s[47]=V):V=s[47];const H=d.length===0,K=d.length>0?"hover:text-foreground":"cursor-default opacity-40";let Z;s[48]!==K?(Z=G("text-muted-foreground",K),s[48]=K,s[49]=Z):Z=s[49];let Y;s[50]===Symbol.for("react.memo_cache_sentinel")?(Y=a.jsx(Ot,{"data-icon":"inline-start"}),s[50]=Y):Y=s[50];let X;s[51]!==V||s[52]!==H||s[53]!==Z?(X=a.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:V,disabled:H,className:Z,"aria-label":"Next match",children:Y}),s[51]=V,s[52]=H,s[53]=Z,s[54]=X):X=s[54];let se;s[55]===Symbol.for("react.memo_cache_sentinel")?(se=a.jsx(Ut,{"data-icon":"inline-start"}),s[55]=se):se=s[55];let Q;s[56]!==_?(Q=a.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:_,className:"text-muted-foreground hover:text-foreground","aria-label":"Close search",children:se}),s[56]=_,s[57]=Q):Q=s[57];let te;return s[58]!==z||s[59]!==B||s[60]!==X||s[61]!==Q?(te=a.jsxs("div",{className:"motion-slide-down-in absolute right-4 top-12 z-30 flex items-center gap-1 rounded-lg border bg-popover p-2 text-popover-foreground shadow-sm",children:[z,B,X,Q]}),s[58]=z,s[59]=B,s[60]=X,s[61]=Q,s[62]=te):te=s[62],te});function tH(n){const e=n.parentNode;e&&(e.replaceChild(document.createTextNode(n.textContent||""),n),e.normalize())}const s5=[1,2,3,4,5,6,7,8,9],Fge=["General","View","Tools"],vf=[{command:"commandPalette",label:"Open command palette",description:"Search actions, projects, and recent sessions",group:"General",defaultShortcut:{key:"k",modKey:!0}},{command:"keyboardShortcuts",label:"Show keyboard shortcuts",description:"Open this reference — only while no text field is focused",group:"General",defaultShortcut:{key:"?",shiftKey:!0}},{command:"newSession",label:"Start a new session",description:"Open the project picker for a new agent session",group:"General",defaultShortcut:{key:"n",platformChord:!0}},{command:"focusComposer",label:"Focus message composer",description:"Jump to the chat composer — only while no text field is focused",group:"General",defaultShortcut:{key:" "}},{command:"prevLiveSession",label:"Focus previous live session",description:"Move focus up the live session list; press Enter to open",group:"General",defaultShortcut:{key:"arrowup",modKey:!0,shiftKey:!0}},{command:"nextLiveSession",label:"Focus next live session",description:"Move focus down the live session list; press Enter to open",group:"General",defaultShortcut:{key:"arrowdown",modKey:!0,shiftKey:!0}},{command:"recentSessionBack",label:"Previous recent session",description:"Step back through recently opened sessions",group:"General",defaultShortcut:{key:"tab",ctrlKey:!0}},{command:"recentSessionForward",label:"Next recent session",description:"Step forward through recently opened sessions",group:"General",defaultShortcut:{key:"tab",ctrlKey:!0,shiftKey:!0}},{command:"toggleSidebar",label:"Toggle session sidebar",description:"Show or hide projects and sessions",group:"View",defaultShortcut:{key:"b",modKey:!0}},{command:"missionControl",label:"Toggle Mission Control",description:"Show every live session at once and answer whatever is blocked",group:"View",defaultShortcut:{doubleTapModifier:"mod"}},{command:"toggleStats",label:"Toggle session analytics",description:"Show or hide the right analytics panel",group:"View",defaultShortcut:{key:"b",modKey:!0,shiftKey:!0}},{command:"expandAll",label:"Expand all groups",description:"Expand conversation and tool groups without opening raw payloads",group:"View",defaultShortcut:{key:"e",modKey:!0}},{command:"expandToolPayloads",label:"Expand all tool payloads",description:"Expand tool inputs, results, and diffs with their containing groups",group:"View",defaultShortcut:{key:"e",modKey:!0,shiftKey:!0}},{command:"findInConversation",label:"Find in conversation",description:"Search the open conversation and step through matches",group:"View",defaultShortcut:{key:"f",modKey:!0}},{command:"integratedTerminal",label:"Toggle integrated terminal",description:"Open or collapse the in-app project terminal",group:"Tools",defaultShortcut:{key:"j",modKey:!0}},{command:"newIntegratedTerminal",label:"New integrated terminal",description:"Create another terminal while the integrated terminal is focused",group:"Tools",defaultShortcut:{key:"n",modKey:!0}},{command:"closeIntegratedTerminal",label:"Close integrated terminal",description:"Close the active terminal while the integrated terminal is focused",group:"Tools",defaultShortcut:{key:"w",modKey:!0}},{command:"preview",label:"Toggle development preview",description:"Show or hide the in-app local server preview",group:"Tools",defaultShortcut:{key:"j",modKey:!0,shiftKey:!0}},{command:"previewRefresh",label:"Refresh development preview",description:"Reload the page while the preview toolbar is focused",group:"Tools",defaultShortcut:{key:"r",modKey:!0}},{command:"previewFocusUrl",label:"Focus preview URL",description:"Select the URL while the preview toolbar is focused",group:"Tools",defaultShortcut:{key:"l",modKey:!0}},{command:"previewZoomIn",label:"Zoom preview in",description:"Increase the preview scale while its toolbar is focused",group:"Tools",defaultShortcut:{key:"=",modKey:!0}},{command:"previewZoomOut",label:"Zoom preview out",description:"Decrease the preview scale while its toolbar is focused",group:"Tools",defaultShortcut:{key:"-",modKey:!0}},{command:"previewResetZoom",label:"Reset preview zoom",description:"Return the preview to 100% while its toolbar is focused",group:"Tools",defaultShortcut:{key:"0",modKey:!0}},{command:"projectFiles",label:"Toggle project files",description:"Browse and edit files in the active project",group:"Tools",defaultShortcut:{key:"f",modKey:!0,shiftKey:!0}},{command:"projectFileSave",label:"Save project file",description:"Save the open file while the project file workspace is focused",group:"Tools",defaultShortcut:{key:"s",modKey:!0}},{command:"systemTerminal",label:"Open system terminal",description:"Open the project in your preferred terminal app",group:"Tools",defaultShortcut:{key:"t",platformChord:!0}},{command:"themeSelector",label:"Change theme",description:"Open the theme selector",group:"Tools",defaultShortcut:{key:"s",platformChord:!0}},...s5.map(n=>({command:`device.switch.${n}`,label:`Switch to device ${n}`,description:n===1?"Jump to this machine (the local device)":`Jump to the ${n}${n===2?"nd":n===3?"rd":"th"} device in the switcher`,group:"General",defaultShortcut:{key:String(n),platformChord:!0}})),{command:"device.cycle",label:"Cycle devices",description:"Switch to the next device in the switcher",group:"General",defaultShortcut:{key:"0",platformChord:!0}}],r5="cogpit-keybindings";let Io=null;function o5(n=typeof navigator>"u"?"":navigator.platform){return/Mac|iPhone|iPad/i.test(n)}function _l(n){const e=n.toLowerCase();return e==="esc"?"escape":e}function nH(n){if(!n||typeof n!="object")return!1;const e=n;return e.doubleTapModifier==="mod"||typeof e.key=="string"&&e.key.length>0}function Rx(){if(Io)return Io;try{const n=localStorage.getItem(r5);if(!n)return Io={};const e=JSON.parse(n);if(!e||typeof e!="object")return Io={};const t={};for(const s of vf){const r=e[s.command];nH(r)&&(t[s.command]=r)}return Io=t}catch{return Io={}}}function Ox(n){Io=n;try{localStorage.setItem(r5,JSON.stringify(n))}catch{}typeof window<"u"&&window.dispatchEvent(new Event("cogpit-keybindings-changed"))}function uc(n){const e=vf.find(t=>t.command===n);if(!e)throw new Error(`Unknown keybinding command: ${n}`);return Rx()[n]??e.defaultShortcut}function Uge(){return Object.fromEntries(vf.map(n=>[n.command,uc(n.command)]))}function Bge(n,e){const t="doubleTapModifier"in e?{...e}:{...e,key:_l(e.key)};Ox({...Rx(),[n]:t})}function Wge(n){const e={...Rx()};delete e[n],Ox(e)}function qge(){Ox({})}function Vge(n){return{key:_l(n.key),metaKey:n.metaKey||void 0,ctrlKey:n.ctrlKey||void 0,shiftKey:n.shiftKey||void 0,altKey:n.altKey||void 0}}function i5(n){const e=n;if(!e)return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||e.isContentEditable===!0}function qt(n,e){const t=uc(n);return"doubleTapModifier"in t||_l(e.key)!==_l(t.key)?!1:t.modKey?e.metaKey===e.ctrlKey?!1:e.shiftKey===!!t.shiftKey&&e.altKey===!!t.altKey:t.platformChord?e.ctrlKey&&e.metaKey!==e.altKey&&e.shiftKey===!!t.shiftKey:e.metaKey===!!t.metaKey&&e.ctrlKey===!!t.ctrlKey&&e.shiftKey===!!t.shiftKey&&e.altKey===!!t.altKey}function si(n){return n===" "?"Space":n==="escape"?"Esc":n==="tab"?"Tab":n==="arrowup"?"↑":n==="arrowdown"?"↓":n==="arrowleft"?"←":n==="arrowright"?"→":n.length===1?n.toUpperCase():n}function sH(n){const e=o5();return"doubleTapModifier"in n?e?"Double ⌘":"Double Ctrl":n.modKey?e?`${n.shiftKey?"⇧":""}⌘${si(n.key)}`:`Ctrl+${n.shiftKey?"Shift+":""}${si(n.key)}`:n.platformChord?e?`⌃⌘${n.shiftKey?"⇧":""}${si(n.key)}`:`Ctrl+Alt+${n.shiftKey?"Shift+":""}${si(n.key)}`:e?`${n.ctrlKey?"⌃":""}${n.altKey?"⌥":""}${n.shiftKey?"⇧":""}${n.metaKey?"⌘":""}${si(n.key)}`:[n.ctrlKey?"Ctrl":null,n.altKey?"Alt":null,n.shiftKey?"Shift":null,n.metaKey?"Meta":null,si(n.key)].filter(Boolean).join("+")}function Eu(n){return sH(uc(n))}function s2(n){if("doubleTapModifier"in n)return[`double-tap:${n.doubleTapModifier}`];const e=(t,s,r,o)=>`${_l(n.key)}|${t}|${s}|${r}|${o}`;return n.modKey?[e(!0,!1,!!n.shiftKey,!!n.altKey),e(!1,!0,!!n.shiftKey,!!n.altKey)]:n.platformChord?[e(!0,!0,!!n.shiftKey,!1),e(!1,!0,!!n.shiftKey,!0)]:[e(!!n.metaKey,!!n.ctrlKey,!!n.shiftKey,!!n.altKey)]}function Hge(n,e){const t=new Set(s2(n));return vf.find(s=>s.command!==e&&s2(uc(s.command)).some(r=>t.has(r)))??null}function r2(n){return"doubleTapModifier"in uc(n)?o5()?"Meta":"Control":null}const rH=s5.map(n=>`device.switch.${n}`),oH="device.cycle";function iH(n){const e=rH.findIndex(t=>qt(t,n));return e===-1?null:e+1}function aH(n){return qt(oH,n)}const ng="cogpit:find-in-conversation",yf=w.memo(function(e){const t=q.c(82),{searchInputRef:s,hasTodos:r,hasMore:o,isLoadingOlder:i,onLoadMore:l,mobileSearchOpen:c,onMobileSearchClose:u}=e,d=c===void 0?!1:c,{state:f,dispatch:m,isMobile:p}=bn(),{session:h,sessionSource:g,rateLimit:x,permissions:b}=xt(),y=mn("terminal"),{chat:v,scroll:k}=Hl(),{searchQuery:j}=f,{pendingMessages:_}=v,{chatScrollRef:N,scrollEndRef:S,handleScroll:C,canScrollDown:E,scrollToBottomInstant:T,initialScrollDone:A}=k,P=w.useRef(null);let I;t[0]===Symbol.for("react.memo_cache_sentinel")?(I=()=>{var he;return(he=P.current)==null?void 0:he.open()},t[0]=I):I=t[0];const $=I;let O,M;t[1]===Symbol.for("react.memo_cache_sentinel")?(O=()=>{const he=function(ve){qt("findInConversation",ve)&&(ve.preventDefault(),$())};return window.addEventListener("keydown",he),window.addEventListener(ng,$),()=>{window.removeEventListener("keydown",he),window.removeEventListener(ng,$)}},M=[$],t[1]=O,t[2]=M):(O=t[1],M=t[2]),w.useEffect(O,M);let R,z;t[3]!==p||t[4]!==d||t[5]!==s?(R=()=>{!p||!d||requestAnimationFrame(()=>{var he;return(he=s.current)==null?void 0:he.focus()})},z=[p,d,s],t[3]=p,t[4]=d,t[5]=s,t[6]=R,t[7]=z):(R=t[6],z=t[7]),w.useEffect(R,z);let W;t[8]!==m||t[9]!==u?(W=()=>{m({type:"SET_SEARCH_QUERY",value:""}),u==null||u()},t[8]=m,t[9]=u,t[10]=W):W=t[10];const D=W,L=h;let U;t[11]!==x||t[12]!==g?(U=x&&g?{block:x,dirName:g.dirName,fileName:g.fileName}:null,t[11]=x,t[12]=g,t[13]=U):U=t[13];const F=U,B=L.turns.length>0||_.length===0;let V;t[14]!==D||t[15]!==m||t[16]!==p||t[17]!==d||t[18]!==s||t[19]!==j?(V=p&&d&&a.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b bg-background px-3 py-2",children:[a.jsxs(So,{className:"h-9 flex-1",children:[a.jsx(ko,{ref:s,value:j,onChange:he=>m({type:"SET_SEARCH_QUERY",value:he.target.value}),placeholder:"Search conversation...","aria-label":"Search conversation"}),a.jsx(or,{align:"inline-start",children:a.jsx(Yn,{})})]}),a.jsx(ee,{variant:"ghost",size:"icon-sm",onClick:D,"aria-label":"Close conversation search",children:a.jsx(Ut,{"data-icon":"inline-start"})})]}),t[14]=D,t[15]=m,t[16]=p,t[17]=d,t[18]=s,t[19]=j,t[20]=V):V=t[20];let H;t[21]!==y||t[22]!==L.cwd||t[23]!==p||t[24]!==b||t[25]!==F?(H=F&&a.jsx("div",{className:G("shrink-0",!p&&"pt-10"),children:a.jsx(ZV,{...F,cwd:L.cwd,terminal:y&&b.send})}),t[21]=y,t[22]=L.cwd,t[23]=p,t[24]=b,t[25]=F,t[26]=H):H=t[26];let K;t[27]!==N?(K=a.jsx(eH,{ref:P,scrollContainerRef:N}),t[27]=N,t[28]=K):K=t[28];let Z;t[29]!==N||t[30]!==L?(Z=a.jsx(qV,{session:L,scrollContainerRef:N}),t[29]=N,t[30]=L,t[31]=Z):Z=t[31];const Y=p&&"mobile-scroll";let X;t[32]!==Y?(X=G("h-full overflow-x-hidden overflow-y-auto",Y),t[32]=Y,t[33]=X):X=t[33];let se;t[34]!==r||t[35]!==p||t[36]!==F?(se=p?"px-3 py-3 pb-5":G("mx-auto w-full max-w-[var(--chat-width)] px-6",F?"pt-4":"pt-14",r?"pb-48":"pb-32"),t[34]=r,t[35]=p,t[36]=F,t[37]=se):se=t[37];let Q;t[38]!==N||t[39]!==o||t[40]!==A||t[41]!==i||t[42]!==l||t[43]!==B?(Q=B&&a.jsx(MV,{chatScrollRef:N,hasMore:o,isLoadingOlder:i,pagingEnabled:A,onLoadMore:l}),t[38]=N,t[39]=o,t[40]=A,t[41]=i,t[42]=l,t[43]=B,t[44]=Q):Q=t[44];let te;t[45]===Symbol.for("react.memo_cache_sentinel")?(te=a.jsx(XV,{}),t[45]=te):te=t[45];let J;if(t[46]!==L.turns.length||t[47]!==_){let he;t[49]!==L.turns.length?(he=(ye,ve)=>a.jsx(UN,{message:ye,turnNumber:L.turns.length+1+ve},ve),t[49]=L.turns.length,t[50]=he):he=t[50],J=_.map(he),t[46]=L.turns.length,t[47]=_,t[48]=J}else J=t[48];let ne;t[51]===Symbol.for("react.memo_cache_sentinel")?(ne=a.jsx(Jq,{}),t[51]=ne):ne=t[51];let re;t[52]!==S?(re=a.jsx("div",{ref:S}),t[52]=S,t[53]=re):re=t[53];let le;t[54]!==Q||t[55]!==J||t[56]!==re?(le=a.jsxs(n5,{fallbackMessage:"Failed to render conversation timeline",children:[Q,te,J,ne,re]}),t[54]=Q,t[55]=J,t[56]=re,t[57]=le):le=t[57];let ae;t[58]!==se||t[59]!==le?(ae=a.jsx("div",{className:se,children:le}),t[58]=se,t[59]=le,t[60]=ae):ae=t[60];let ue;t[61]!==N||t[62]!==C||t[63]!==X||t[64]!==ae?(ue=a.jsx("div",{ref:N,onScroll:C,className:X,children:ae}),t[61]=N,t[62]=C,t[63]=X,t[64]=ae,t[65]=ue):ue=t[65];const oe=E?"opacity-100 scale-100":"opacity-0 scale-75 pointer-events-none",ie=p?"right-3 bottom-3":"right-5 bottom-5";let fe;t[66]!==oe||t[67]!==ie?(fe=G("absolute rounded-full shadow-sm transition-[opacity,transform] duration-200 ease-out active:scale-95",oe,ie),t[66]=oe,t[67]=ie,t[68]=fe):fe=t[68];let de;t[69]===Symbol.for("react.memo_cache_sentinel")?(de=a.jsx(mP,{"data-icon":"inline-start"}),t[69]=de):de=t[69];let ce;t[70]!==T||t[71]!==fe?(ce=a.jsx(ee,{size:"icon",className:fe,onClick:T,"aria-label":"Scroll to bottom",children:de}),t[70]=T,t[71]=fe,t[72]=ce):ce=t[72];let xe;t[73]!==K||t[74]!==Z||t[75]!==ue||t[76]!==ce?(xe=a.jsxs("div",{className:"relative min-h-0 flex-1",children:[K,Z,ue,ce]}),t[73]=K,t[74]=Z,t[75]=ue,t[76]=ce,t[77]=xe):xe=t[77];let pe;return t[78]!==H||t[79]!==xe||t[80]!==V?(pe=a.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col",children:[V,H,xe]}),t[78]=H,t[79]=xe,t[80]=V,t[81]=pe):pe=t[81],pe});function lH({open:n,onOpenChange:e,trigger:t,title:s,description:r,confirmLabel:o,destructive:i=!1,onConfirm:l}){const[c,u]=w.useState(!1),[d,f]=w.useState(null);function m(h){c||(f(null),e(h))}async function p(){u(!0),f(null);try{f(await l())}finally{u(!1)}}return a.jsxs(U1,{open:n,onOpenChange:m,children:[t&&a.jsx(wO,{render:t}),a.jsxs(B1,{size:"sm",children:[a.jsxs(W1,{children:[a.jsx(V1,{children:s}),a.jsx(H1,{children:r})]}),d&&a.jsx(to,{className:"text-center",children:d}),a.jsxs(q1,{children:[a.jsx(G1,{disabled:c,children:"Cancel"}),a.jsxs(K1,{variant:i?"destructive":"default",disabled:c,onClick:()=>void p(),children:[c&&a.jsx(vt,{"data-icon":"inline-start",className:"animate-spin"}),o]})]})]})]})}function cH(n){const e=q.c(21),{children:t,error:s,busy:r,saveLabel:o,onCancel:i,onSave:l,className:c}=n;let u;e[0]!==c?(u=G("flex flex-col gap-3 border-t px-3 py-3",c),e[0]=c,e[1]=u):u=e[1];let d;e[2]!==s?(d=s&&a.jsx(to,{children:s}),e[2]=s,e[3]=d):d=e[3];let f;e[4]!==i?(f=a.jsx(ee,{variant:"outline",size:"sm",onClick:i,children:"Cancel"}),e[4]=i,e[5]=f):f=e[5];let m;e[6]!==r||e[7]!==o?(m=r?a.jsx(vt,{"data-icon":"inline-start",className:"animate-spin"}):o,e[6]=r,e[7]=o,e[8]=m):m=e[8];let p;e[9]!==r||e[10]!==l||e[11]!==m?(p=a.jsx(ee,{size:"sm",disabled:r,onClick:l,children:m}),e[9]=r,e[10]=l,e[11]=m,e[12]=p):p=e[12];let h;e[13]!==f||e[14]!==p?(h=a.jsxs("div",{className:"flex justify-end gap-1.5",children:[f,p]}),e[13]=f,e[14]=p,e[15]=h):h=e[15];let g;return e[16]!==t||e[17]!==u||e[18]!==d||e[19]!==h?(g=a.jsxs("div",{className:u,children:[t,d,h]}),e[16]=t,e[17]=u,e[18]=d,e[19]=h,e[20]=g):g=e[20],g}const sg="cogpit-devices-changed",a5="cogpit:devices-changed";function l5(n){typeof n.connectionRevision=="number"&&EI(n.id,n.connectionRevision)}function c5(n,e,t=!1){window.dispatchEvent(new CustomEvent(sg,{detail:{deviceId:n,connectionRevision:e,removed:t}}));try{localStorage.setItem(a5,JSON.stringify({deviceId:n,connectionRevision:e,removed:t,nonce:`${Date.now()}:${Math.random()}`}))}catch{}}function o2(n){l5(n),c5(n.id,n.connectionRevision)}function i2(n){const e=Dt();e!==Et&&!n.some(t=>t.id===e)&&Fs(Et)}function _m(n,e=""){return`/api/hub/devices/${encodeURIComponent(n)}${e}`}function u5(n){const e=n.runtime.lastHello;if(e&&typeof e=="object"){const t=e.version;if(typeof t=="string")return t}}function uH(n){const e=n.runtime.lastHello;if(e&&typeof e=="object"){const t=e.signIn;if(t==="account"||t==="password")return t}}function la({enabled:n=!0}={}){const[e,t]=w.useState([]),[s,r]=w.useState(!0),[o,i]=w.useState(()=>Dt()),l=w.useRef(0),c=w.useCallback(async()=>{const g=++l.current;if(!n){t([]),r(!1);return}try{const x=await Kr("/api/hub/devices");if(x.status===403&&g===l.current&&i2([]),!x.ok)return;const b=await Zs(x);if(g!==l.current)return;const y=Array.isArray(b==null?void 0:b.devices)?b.devices:[];for(const v of y)l5(v);t(y),i2(y)}catch{}finally{g===l.current&&r(!1)}},[n]);w.useEffect(()=>{c()},[c]),w.useEffect(()=>{const g=()=>i(Dt()),x=()=>void c(),b=k=>{if(k.key===a5){try{const j=JSON.parse(k.newValue??"null");(j==null?void 0:j.removed)===!0&&typeof j.deviceId=="string"&&Dt()===j.deviceId&&Fs(Et)}catch{}c()}},y=()=>{l.current+=1,t([]),r(!0),c()},v=()=>{l.current+=1,t([]),r(!1)};return window.addEventListener("cogpit-device-changed",g),window.addEventListener("popstate",g),window.addEventListener(sg,x),window.addEventListener("storage",b),window.addEventListener("cogpit-auth-changed",y),window.addEventListener("cogpit-identity-changed",y),window.addEventListener("cogpit-auth-required",v),()=>{window.removeEventListener("cogpit-device-changed",g),window.removeEventListener("popstate",g),window.removeEventListener(sg,x),window.removeEventListener("storage",b),window.removeEventListener("cogpit-auth-changed",y),window.removeEventListener("cogpit-identity-changed",y),window.removeEventListener("cogpit-auth-required",v)}},[c]);const u=w.useMemo(()=>o===Et?void 0:e.find(g=>g.id===o),[e,o]),d=w.useCallback(async(g,x,b,y)=>{try{const v=await Kr("/api/hub/devices/probe",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({host:g,port:x,allowLocalTunnel:b,tls:y})}),k=await Zs(v);return(k==null?void 0:k.ok)===!0&&k.hello?{ok:!0,hello:k.hello}:{ok:!1,code:(k==null?void 0:k.code)??"UNREACHABLE",error:typeof(k==null?void 0:k.error)=="string"?k.error:void 0}}catch{return{ok:!1,code:"UNREACHABLE",error:"Could not reach the device."}}},[]),f=w.useCallback(async g=>{try{const x=await Kr("/api/hub/devices",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(g)}),b=await Zs(x);if(x.ok&&(b!=null&&b.device)){const y=b.device;return o2(y),{ok:!0,device:y}}return{ok:!1,code:(b==null?void 0:b.code)??"ERROR",error:typeof(b==null?void 0:b.error)=="string"?b.error:"Could not add the device."}}catch{return{ok:!1,code:"ERROR",error:"Could not add the device."}}},[]),m=w.useCallback(async(g,x)=>{try{const b=await Kr(_m(g),{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(x)}),y=await Zs(b);if(b.ok&&(y!=null&&y.device)){const v=y.device;return o2(v),{ok:!0,device:v}}return{ok:!1,code:(y==null?void 0:y.code)??"ERROR",error:typeof(y==null?void 0:y.error)=="string"?y.error:"Could not update the device."}}catch{return{ok:!1,code:"ERROR",error:"Could not update the device."}}},[]),p=w.useCallback(async g=>{try{const x=await Kr(_m(g),{method:"DELETE"});if(x.ok)return Dt()===g&&Fs(Et),c5(g,void 0,!0),{ok:!0};const b=await Zs(x);return{ok:!1,error:typeof(b==null?void 0:b.error)=="string"?b.error:"Could not remove the device."}}catch{return{ok:!1,error:"Could not remove the device."}}},[]),h=w.useCallback(async g=>{try{const x=await Kr(_m(g,"/test"),{method:"POST"});return await Zs(x)??{ok:!1,reachable:!1,code:"UNREACHABLE"}}catch{return{ok:!1,reachable:!1,code:"UNREACHABLE"}}},[]);return{devices:e,activeDeviceId:o,activeDevice:u,loading:s,refresh:c,probe:d,addDevice:f,updateDevice:m,removeDevice:p,testDevice:h}}const d5="3.0.1",f5={version:d5},a2=f5.version,dH=19384,fH=443,mH=450,pH=typeof navigator<"u"&&/Mac|iPhone|iPad/i.test(navigator.platform||""),hH=`${pH?"⌘⇧":"Ctrl+Shift+"}1–9`,gH=new Set(["BAD_PASSWORD","PASSWORD_REQUIRED","USERNAME_REQUIRES_PASSWORD"]),xH=new Set(["ACCOUNT_REFUSED"]);function Vc(n){const e=n.trim(),t=/^https:\/\//i.test(e),s=e.replace(/^https?:\/\//i,"").replace(/\/.*$/,""),r=/^(.+):(\d+)$/.exec(s),o=r?r[1]:s,i=r?Number(r[2]):void 0;return t?{host:o,port:i,tls:!0}:{host:o,port:i}}function bH(n,e,t){if(n.ok){if(n.hello.signIn==="account"&&n.hello.setupRequired===!0)return{tone:"info",text:"Reachable server — finish its setup before adding it here."};if(n.hello.signIn!=="account"&&n.hello.networkAccess===!1)return{tone:"warn",text:"Cogpit is running but network access is disabled — enable it in that device's settings."};if(n.hello.configured===!1)return{tone:"info",text:"Reachable — this device hasn't finished setup yet and will show its setup screen."};const s=n.hello.name?` "${n.hello.name}"`:"",r=n.hello.version?` (v${n.hello.version})`:"";return{tone:"ok",text:`Found Cogpit${s}${r}.`}}switch(n.code){case"UNREACHABLE":return{tone:"error",text:`Can't reach ${e}:${t}. Is Cogpit running with network access enabled?`};case"LEGACY_NO_HELLO":return{tone:"error",text:"That Cogpit is too old for multi-device — update it."};case"NOT_COGPIT":return{tone:"error",text:"Something responded, but it isn't Cogpit."};case"SELF_ADD":return{tone:"error",text:"That's this machine."};default:return{tone:"error",text:n.error??"Could not reach the device."}}}const m5={ok:"text-success",warn:"text-warning",info:"text-info",error:"text-destructive"};function vH(n){const e=q.c(10),{tone:t}=n,s=m5[t];let r;e[0]!==s?(r=G("size-3.5 shrink-0",s),e[0]=s,e[1]=r):r=e[1];const o=r;if(t==="ok"){let l;return e[2]!==o?(l=a.jsx(Mr,{"data-icon":"inline-start",className:o}),e[2]=o,e[3]=l):l=e[3],l}if(t==="warn"){let l;return e[4]!==o?(l=a.jsx(lr,{"data-icon":"inline-start",className:o}),e[4]=o,e[5]=l):l=e[5],l}if(t==="info"){let l;return e[6]!==o?(l=a.jsx(On,{"data-icon":"inline-start",className:o}),e[6]=o,e[7]=l):l=e[7],l}let i;return e[8]!==o?(i=a.jsx(vo,{"data-icon":"inline-start",className:o}),e[8]=o,e[9]=i):i=e[9],i}const yH={ok:"bg-success",unknown:"bg-warning","bad-password":"bg-destructive"};function wH(n){const e=q.c(103),{device:t,onRename:s,onCredentials:r,onRemove:o,onTest:i}=n,[l,c]=w.useState(!1),[u,d]=w.useState(t.name),[f,m]=w.useState(!1),[p,h]=w.useState(t.username??""),[g,x]=w.useState(""),[b,y]=w.useState(null),[v,k]=w.useState(!1),[j,_]=w.useState(null);let N,S;e[0]!==t.name?(N=()=>{d(t.name)},S=[t.name],e[0]=t.name,e[1]=N,e[2]=S):(N=e[1],S=e[2]),w.useEffect(N,S);let C,E;e[3]!==t.username?(C=()=>{h(t.username??"")},E=[t.username],e[3]=t.username,e[4]=C,e[5]=E):(C=e[4],E=e[5]),w.useEffect(C,E);let T;e[6]!==t?(T=u5(t),e[6]=t,e[7]=T):T=e[7];const A=T,P=A!==void 0&&A!==a2;let I;e[8]!==t?(I=uH(t),e[8]=t,e[9]=I):I=e[9];const $=I==="account";let O;e[10]!==t.id||e[11]!==t.name||e[12]!==u||e[13]!==s?(O=async function(){const Fe=u.trim();if(!Fe||Fe===t.name){c(!1),d(t.name);return}_("rename"),await s(t.id,Fe),_(null),c(!1)},e[10]=t.id,e[11]=t.name,e[12]=u,e[13]=s,e[14]=O):O=e[14];const M=O;let R;e[15]!==g||e[16]!==p||e[17]!==t.auth||e[18]!==t.id||e[19]!==t.username||e[20]!==r?(R=async function(){const Fe=p.trim(),ze=t.username??"",We=Fe!==ze,Pe=g.length>0;if(!We&&!Pe){m(!1),x(""),y(null);return}if(t.auth==="none"&&!Pe){y("Enter a password when adding an account to an unauthenticated device.");return}const qe={};We&&(qe.username=Fe||null),Pe&&(qe.password=g),_("credentials"),y(null);const be=await r(t.id,qe);if(_(null),!be.ok){y(be.error);return}m(!1),x("")},e[15]=g,e[16]=p,e[17]=t.auth,e[18]=t.id,e[19]=t.username,e[20]=r,e[21]=R):R=e[21];const z=R,W=`Status: ${t.runtime.authState}`,D=yH[t.runtime.authState];let L;e[22]!==D?(L=G("size-2 shrink-0 rounded-full",D),e[22]=D,e[23]=L):L=e[23];let U;e[24]!==L||e[25]!==W?(U=a.jsx("span",{"aria-label":W,className:L}),e[24]=L,e[25]=W,e[26]=U):U=e[26];let F;e[27]!==t.auth||e[28]!==t.name||e[29]!==l||e[30]!==u||e[31]!==M||e[32]!==P||e[33]!==A?(F=l?a.jsx(Zn,{value:u,autoFocus:!0,"aria-label":`Rename ${t.name}`,onChange:_e=>d(_e.target.value),onKeyDown:_e=>{_e.key==="Enter"&&M(),_e.key==="Escape"&&(c(!1),d(t.name))},onBlur:()=>void M(),className:"h-6 text-sm"}):a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("span",{className:"truncate text-sm text-foreground",children:t.name}),A&&a.jsxs("span",{className:G("shrink-0 font-mono text-xs",P?"text-warning":"text-muted-foreground"),title:P?`Device runs v${A}; hub runs v${a2}`:void 0,children:["v",A,P&&" ≠ hub"]}),t.auth==="none"&&a.jsx(Ue,{variant:"secondary",children:"Unauthenticated"})]}),e[27]=t.auth,e[28]=t.name,e[29]=l,e[30]=u,e[31]=M,e[32]=P,e[33]=A,e[34]=F):F=e[34];const B=t.tls?"https://":"";let V;e[35]!==t.host||e[36]!==t.port||e[37]!==B?(V=a.jsxs("span",{className:"truncate font-mono text-xs text-muted-foreground",children:[B,t.host,":",t.port]}),e[35]=t.host,e[36]=t.port,e[37]=B,e[38]=V):V=e[38];let H;e[39]!==$||e[40]!==t.username?(H=t.username?a.jsxs("span",{className:"truncate text-xs text-muted-foreground",title:t.username,children:["Account: ",t.username]}):$?a.jsx("span",{className:"text-xs text-warning",children:"Account not configured"}):null,e[39]=$,e[40]=t.username,e[41]=H):H=e[41];let K;e[42]!==F||e[43]!==V||e[44]!==H?(K=a.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[F,V,H]}),e[42]=F,e[43]=V,e[44]=H,e[45]=K):K=e[45];const Z=`Re-test ${t.name}`,Y=j==="test";let X;e[46]!==t.id||e[47]!==i?(X=async()=>{_("test"),await i(t.id),_(null)},e[46]=t.id,e[47]=i,e[48]=X):X=e[48];const se=j==="test"&&"animate-spin";let Q;e[49]!==se?(Q=G(se),e[49]=se,e[50]=Q):Q=e[50];let te;e[51]!==Q?(te=a.jsx(On,{"data-icon":"inline-start",className:Q}),e[51]=Q,e[52]=te):te=e[52];let J;e[53]!==Z||e[54]!==Y||e[55]!==X||e[56]!==te?(J=a.jsx(ee,{variant:"ghost",size:"icon-sm","aria-label":Z,disabled:Y,onClick:X,children:te}),e[53]=Z,e[54]=Y,e[55]=X,e[56]=te,e[57]=J):J=e[57];const ne=`Edit account for ${t.name}`;let re;e[58]!==t.username?(re=()=>{m(SH),h(t.username??""),x(""),y(null)},e[58]=t.username,e[59]=re):re=e[59];let le;e[60]===Symbol.for("react.memo_cache_sentinel")?(le=a.jsx(pP,{"data-icon":"inline-start"}),e[60]=le):le=e[60];let ae;e[61]!==ne||e[62]!==re?(ae=a.jsx(ee,{variant:"ghost",size:"icon-sm","aria-label":ne,onClick:re,children:le}),e[61]=ne,e[62]=re,e[63]=ae):ae=e[63];const ue=`Rename ${t.name}`;let oe,ie;e[64]===Symbol.for("react.memo_cache_sentinel")?(oe=()=>c(!0),ie=a.jsx(Er,{"data-icon":"inline-start"}),e[64]=oe,e[65]=ie):(oe=e[64],ie=e[65]);let fe;e[66]!==ue?(fe=a.jsx(ee,{variant:"ghost",size:"icon-sm","aria-label":ue,onClick:oe,children:ie}),e[66]=ue,e[67]=fe):fe=e[67];const de=`Remove ${t.name}`;let ce;e[68]===Symbol.for("react.memo_cache_sentinel")?(ce=a.jsx(Od,{"data-icon":"inline-start"}),e[68]=ce):ce=e[68];let xe;e[69]!==de?(xe=a.jsx(ee,{variant:"ghost",size:"icon-sm","aria-label":de,className:"text-destructive hover:bg-destructive/10 hover:text-destructive",children:ce}),e[69]=de,e[70]=xe):xe=e[70];let pe;e[71]!==t.name?(pe=a.jsxs(a.Fragment,{children:["Remove ",t.name,"?"]}),e[71]=t.name,e[72]=pe):pe=e[72];let he;e[73]!==t.id||e[74]!==o?(he=async()=>(await o(t.id),null),e[73]=t.id,e[74]=o,e[75]=he):he=e[75];let ye;e[76]!==v||e[77]!==xe||e[78]!==pe||e[79]!==he?(ye=a.jsx(lH,{open:v,onOpenChange:k,trigger:xe,title:pe,description:"This device will disappear from Cogpit. You can add it again later.",confirmLabel:"Remove device",destructive:!0,onConfirm:he}),e[76]=v,e[77]=xe,e[78]=pe,e[79]=he,e[80]=ye):ye=e[80];let ve;e[81]!==J||e[82]!==ae||e[83]!==fe||e[84]!==ye?(ve=a.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[J,ae,fe,ye]}),e[81]=J,e[82]=ae,e[83]=fe,e[84]=ye,e[85]=ve):ve=e[85];let ke;e[86]!==U||e[87]!==K||e[88]!==ve?(ke=a.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2",children:[U,K,ve]}),e[86]=U,e[87]=K,e[88]=ve,e[89]=ke):ke=e[89];let je;e[90]!==j||e[91]!==b||e[92]!==g||e[93]!==p||e[94]!==t.id||e[95]!==t.name||e[96]!==t.username||e[97]!==f||e[98]!==z?(je=f&&a.jsxs(cH,{error:b,busy:j==="credentials",saveLabel:"Save account",onCancel:()=>{m(!1),h(t.username??""),x(""),y(null)},onSave:()=>void z(),children:[a.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[a.jsxs(un,{children:[a.jsxs(dn,{htmlFor:`device-username-${t.id}`,children:["Username ",a.jsx("span",{className:"text-muted-foreground/60",children:"(account sign-in)"})]}),a.jsx(Zn,{id:`device-username-${t.id}`,"aria-label":`Username for ${t.name}`,value:p,onChange:_e=>h(_e.target.value),placeholder:"Leave empty for password-only auth",autoComplete:"off",spellCheck:!1})]}),a.jsxs(un,{children:[a.jsxs(dn,{htmlFor:`device-password-${t.id}`,children:["New password ",a.jsx("span",{className:"text-muted-foreground/60",children:"(optional)"})]}),a.jsx(Zn,{id:`device-password-${t.id}`,"aria-label":`New password for ${t.name}`,type:"password",value:g,onChange:_e=>x(_e.target.value),placeholder:"Leave blank to keep the stored password",autoComplete:"new-password"})]})]}),t.username&&p.trim()===""&&a.jsx("p",{className:"text-xs text-warning",children:"Clearing the username switches this device back to password-only authentication."})]}),e[90]=j,e[91]=b,e[92]=g,e[93]=p,e[94]=t.id,e[95]=t.name,e[96]=t.username,e[97]=f,e[98]=z,e[99]=je):je=e[99];let Me;return e[100]!==ke||e[101]!==je?(Me=a.jsxs("div",{className:"rounded-lg border bg-card",children:[ke,je]}),e[100]=ke,e[101]=je,e[102]=Me):Me=e[102],Me}function SH(n){return!n}function p5(n){var nt,Qe;const e=q.c(115),{open:t,initialMode:s,onClose:r}=n,{devices:o,refresh:i,probe:l,addDevice:c,updateDevice:u,removeDevice:d,testDevice:f}=la(),[m,p]=w.useState(""),[h,g]=w.useState(""),[x,b]=w.useState(""),[y,v]=w.useState(""),[k,j]=w.useState(!1),[_,N]=w.useState(!1),[S,C]=w.useState(null),[E,T]=w.useState(!1),[A,P]=w.useState(null),I=w.useRef(null),$=w.useRef(0);let O,M;e[0]!==s||e[1]!==t?(O=()=>{t&&(p(""),g(""),b(""),v(""),j(!1),N(!1),C(null),P(null),s==="add"&&requestAnimationFrame(()=>{var Ee;return(Ee=I.current)==null?void 0:Ee.focus()}))},M=[t,s],e[0]=s,e[1]=t,e[2]=O,e[3]=M):(O=e[2],M=e[3]),w.useEffect(O,M);let R;e[4]!==k||e[5]!==h||e[6]!==l?(R=async()=>{const{host:Ee,port:me,tls:Oe}=Vc(h);if(!Ee){C(null),N(!1);return}const Ge=$.current=$.current+1;N(!0);const rt=await l(Ee,me,k,Oe);Ge===$.current&&(C({...bH(rt,Ee,me??(Oe?fH:dH)),hello:rt.ok?rt.hello:void 0}),N(!1))},e[4]=k,e[5]=h,e[6]=l,e[7]=R):R=e[7];const z=R;let W,D;e[8]!==h||e[9]!==t||e[10]!==z?(W=()=>{if(!t)return;if(!Vc(h).host){C(null),N(!1);return}const Ee=window.setTimeout(()=>void z(),mH);return()=>window.clearTimeout(Ee)},D=[t,h,z],e[8]=h,e[9]=t,e[10]=z,e[11]=W,e[12]=D):(W=e[11],D=e[12]),w.useEffect(W,D);const L=((nt=S==null?void 0:S.hello)==null?void 0:nt.signIn)==="account",U=L&&((Qe=S==null?void 0:S.hello)==null?void 0:Qe.setupRequired)===!0,F=L||!k;let B;e:{if(E){B=!1;break e}if(!Vc(h).host){B=!1;break e}if(_||!S){B=!1;break e}if(U){B=!1;break e}if(F&&!y){B=!1;break e}if(L&&!x.trim()){B=!1;break e}if((S==null?void 0:S.tone)==="error"){B=!1;break e}B=!0}const V=B;let H;e[13]!==c||e[14]!==k||e[15]!==F||e[16]!==h||e[17]!==m||e[18]!==r||e[19]!==y||e[20]!==L||e[21]!==x?(H=async function(){const{host:me,port:Oe,tls:Ge}=Vc(h);if(!me)return;T(!0),P(null);const rt=await c({name:m.trim()||void 0,host:me,port:Oe,tls:Ge,username:L?x.trim():void 0,password:F&&y||void 0,allowLocalTunnel:k});if(T(!1),rt.ok){r(),Fs(rt.device.id);return}P({field:xH.has(rt.code)?"username":gH.has(rt.code)?"password":"host",message:rt.error})},e[13]=c,e[14]=k,e[15]=F,e[16]=h,e[17]=m,e[18]=r,e[19]=y,e[20]=L,e[21]=x,e[22]=H):H=e[22];const K=H;let Z;e[23]!==u?(Z=async(Ee,me)=>{await u(Ee,{name:me})},e[23]=u,e[24]=Z):Z=e[24];const Y=Z;let X;e[25]!==d?(X=async Ee=>{await d(Ee)},e[25]=d,e[26]=X):X=e[26];const se=X;let Q;e[27]!==i||e[28]!==f?(Q=async Ee=>{await f(Ee),await i()},e[27]=i,e[28]=f,e[29]=Q):Q=e[29];const te=Q;let J;e[30]!==r?(J=Ee=>{Ee||r()},e[30]=r,e[31]=J):J=e[31];let ne;e[32]===Symbol.for("react.memo_cache_sentinel")?(ne=a.jsxs(wo,{children:[a.jsx(mr,{children:"Devices"}),a.jsxs(pr,{children:["Control another Cogpit device from here. The active device is chosen from the header switcher — ",hH," jumps between devices."]})]}),e[32]=ne):ne=e[32];let re;e[33]!==o||e[34]!==se||e[35]!==Y||e[36]!==te||e[37]!==u?(re=o.length>0&&a.jsx("div",{className:"flex flex-col gap-2",children:o.map(Ee=>a.jsx(wH,{device:Ee,onRename:Y,onCredentials:u,onRemove:se,onTest:te},Ee.id))}),e[33]=o,e[34]=se,e[35]=Y,e[36]=te,e[37]=u,e[38]=re):re=e[38];let le;e[39]===Symbol.for("react.memo_cache_sentinel")?(le=a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(tr,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),a.jsx("p",{className:"text-sm font-medium text-foreground",children:"Add a device"})]}),e[39]=le):le=e[39];const ae=(A==null?void 0:A.field)==="host";let ue,oe;e[40]===Symbol.for("react.memo_cache_sentinel")?(ue=a.jsx(dn,{htmlFor:"device-host",children:"Host"}),oe=a.jsx(Zu,{children:"Enter a local address or an HTTPS URL."}),e[40]=ue,e[41]=oe):(ue=e[40],oe=e[41]);let ie;e[42]===Symbol.for("react.memo_cache_sentinel")?(ie=Ee=>{$.current=$.current+1,g(Ee.target.value),b(""),C(null),P(null)},e[42]=ie):ie=e[42];let fe;e[43]!==z?(fe=()=>void z(),e[43]=z,e[44]=fe):fe=e[44];let de;e[45]!==h||e[46]!==fe?(de=a.jsx(Zn,{id:"device-host",ref:I,value:h,onChange:ie,onBlur:fe,placeholder:"192.168.1.42, my-mac.local:19384 or https://cogpit.example.com",spellCheck:!1,autoComplete:"off"}),e[45]=h,e[46]=fe,e[47]=de):de=e[47];let ce;e[48]!==_?(ce=_&&a.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[a.jsx(vt,{"data-icon":"inline-start",className:"size-3.5 animate-spin"})," Checking device…"]}),e[48]=_,e[49]=ce):ce=e[49];let xe;e[50]!==S||e[51]!==_?(xe=!_&&S&&a.jsxs("p",{role:"status",className:G("flex items-center gap-1.5 text-xs",m5[S.tone]),children:[a.jsx(vH,{tone:S.tone}),S.text]}),e[50]=S,e[51]=_,e[52]=xe):xe=e[52];let pe;e[53]!==A?(pe=(A==null?void 0:A.field)==="host"&&a.jsx(to,{children:A.message}),e[53]=A,e[54]=pe):pe=e[54];let he;e[55]!==ae||e[56]!==de||e[57]!==ce||e[58]!==xe||e[59]!==pe?(he=a.jsxs(un,{"data-invalid":ae,children:[ue,oe,de,ce,xe,pe]}),e[55]=ae,e[56]=de,e[57]=ce,e[58]=xe,e[59]=pe,e[60]=he):he=e[60];let ye;e[61]===Symbol.for("react.memo_cache_sentinel")?(ye=a.jsxs(dn,{htmlFor:"device-name",children:["Name ",a.jsx("span",{className:"text-muted-foreground/60",children:"(optional)"})]}),e[61]=ye):ye=e[61];let ve;e[62]===Symbol.for("react.memo_cache_sentinel")?(ve=Ee=>p(Ee.target.value),e[62]=ve):ve=e[62];let ke;e[63]!==m?(ke=a.jsxs(un,{children:[ye,a.jsx(Zn,{id:"device-name",value:m,onChange:ve,placeholder:"Defaults to the device's own name"})]}),e[63]=m,e[64]=ke):ke=e[64];let je;e[65]!==A||e[66]!==L||e[67]!==x?(je=L&&a.jsxs(un,{"data-invalid":(A==null?void 0:A.field)==="username",children:[a.jsx(dn,{htmlFor:"device-username",children:"Username"}),a.jsx(Zn,{id:"device-username",value:x,onChange:Ee=>b(Ee.target.value),placeholder:"Account username",autoComplete:"username",spellCheck:!1}),a.jsx(Zu,{children:"Requests through this hub act as this account on that server."}),(A==null?void 0:A.field)==="username"&&a.jsx(to,{children:A.message})]}),e[65]=A,e[66]=L,e[67]=x,e[68]=je):je=e[68];let Me;e[69]!==F||e[70]!==y||e[71]!==A||e[72]!==L?(Me=F&&a.jsxs(un,{"data-invalid":(A==null?void 0:A.field)==="password",children:[a.jsx(dn,{htmlFor:"device-password",children:"Password"}),a.jsx(Zn,{id:"device-password",type:"password",value:y,onChange:Ee=>v(Ee.target.value),placeholder:L?"Password for that account":"Network access password for that device",autoComplete:L?"current-password":"off"}),(A==null?void 0:A.field)==="password"&&a.jsx(to,{children:A.message})]}),e[69]=F,e[70]=y,e[71]=A,e[72]=L,e[73]=Me):Me=e[73];let _e;e[74]!==he||e[75]!==ke||e[76]!==je||e[77]!==Me?(_e=a.jsxs(Vl,{children:[he,ke,je,Me]}),e[74]=he,e[75]=ke,e[76]=je,e[77]=Me,e[78]=_e):_e=e[78];let Fe;e[79]===Symbol.for("react.memo_cache_sentinel")?(Fe=Ee=>{$.current=$.current+1,j(Ee===!0),C(null),P(null)},e[79]=Fe):Fe=e[79];let ze;e[80]!==k?(ze=a.jsx(e4,{id:"device-local-tunnel",name:"device-local-tunnel",checked:k,onCheckedChange:Fe}),e[80]=k,e[81]=ze):ze=e[81];const We=L?"":" — no password";let Pe;e[82]!==We?(Pe=a.jsxs(dn,{htmlFor:"device-local-tunnel",children:["This is a local tunnel",We]}),e[82]=We,e[83]=Pe):Pe=e[83];let qe;e[84]!==ze||e[85]!==Pe?(qe=a.jsxs(un,{orientation:"horizontal",children:[ze,Pe]}),e[84]=ze,e[85]=Pe,e[86]=qe):qe=e[86];let be;e[87]!==k||e[88]!==L?(be=k&&a.jsxs(Jt,{className:"border-warning/40 bg-warning/10 text-warning",children:[a.jsx(N3,{}),a.jsx(Qt,{className:"text-warning",children:L?a.jsx(a.Fragment,{children:"The loopback address is allowed because the tunnel is local; account sign-in still applies."}):a.jsxs(a.Fragment,{children:["Traffic to this device is forwarded ",a.jsx("strong",{children:"unauthenticated"}),". Only use this for an SSH tunnel or another already-secured local channel."]})})]}),e[87]=k,e[88]=L,e[89]=be):be=e[89];let Ie;e[90]!==r?(Ie=a.jsx(ee,{variant:"outline",onClick:r,children:"Close"}),e[90]=r,e[91]=Ie):Ie=e[91];const Se=!V;let Ne;e[92]!==K?(Ne=()=>void K(),e[92]=K,e[93]=Ne):Ne=e[93];let He;e[94]!==E?(He=E?a.jsxs(a.Fragment,{children:[a.jsx(vt,{"data-icon":"inline-start",className:"size-4 animate-spin"})," Adding…"]}):"Add device",e[94]=E,e[95]=He):He=e[95];let Ke;e[96]!==Se||e[97]!==Ne||e[98]!==He?(Ke=a.jsx(ee,{disabled:Se,onClick:Ne,children:He}),e[96]=Se,e[97]=Ne,e[98]=He,e[99]=Ke):Ke=e[99];let Ce;e[100]!==Ie||e[101]!==Ke?(Ce=a.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[Ie,Ke]}),e[100]=Ie,e[101]=Ke,e[102]=Ce):Ce=e[102];let Be;e[103]!==_e||e[104]!==qe||e[105]!==be||e[106]!==Ce?(Be=a.jsxs("div",{className:"flex flex-col gap-4 border-t pt-4",children:[le,_e,qe,be,Ce]}),e[103]=_e,e[104]=qe,e[105]=be,e[106]=Ce,e[107]=Be):Be=e[107];let Ye;e[108]!==re||e[109]!==Be?(Ye=a.jsxs(fr,{className:"max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-xl",children:[ne,re,Be]}),e[108]=re,e[109]=Be,e[110]=Ye):Ye=e[110];let Xe;return e[111]!==t||e[112]!==J||e[113]!==Ye?(Xe=a.jsx(dr,{open:t,onOpenChange:J,children:Ye}),e[111]=t,e[112]=J,e[113]=Ye,e[114]=Xe):Xe=e[114],Xe}const kH="Browsing folders needs a newer Cogpit on this machine.";async function h5(n){const e=await Ja(n,`Request failed (${n.status})`);return new Error(n.status===404&&e==="Not found"?kH:e)}async function jH(n,e){const t=await Re(n?`/api/folders?path=${encodeURIComponent(n)}`:"/api/folders",{signal:e});if(!t.ok)throw await h5(t);return await t.json()}async function NH(n,e){const t=await ws("/api/folders",{parent:n,name:e});if(!t.ok)throw await h5(t);return(await t.json()).path}function CH(n,e=null){const t=_H(n);if(e===null)return t;const s=o=>o.replace(/[\\/]+$/,""),r=t.findIndex(o=>s(o.path)===s(e));return r===-1?t:t.slice(r)}function _H(n){const e=n.split(/[\\/]+/).filter(Boolean);let t,s,r;if(n.startsWith("\\\\")){const[o="",i="",...l]=e;t={label:`\\\\${o}\\${i}`,path:`\\\\${o}\\${i}\\`},s=l,r="\\"}else if(/^[a-z]:/i.test(n)){const[o="",...i]=e;t={label:o,path:`${o}\\`},s=i,r="\\"}else t={label:"/",path:"/"},s=e,r="/";return[t,...s.map((o,i)=>({label:o,path:t.path+s.slice(0,i+1).join(r)}))]}const rg="cogpit-browse-folders";function g5(){window.dispatchEvent(new Event(rg))}function EH(n){return window.addEventListener(rg,n),()=>window.removeEventListener(rg,n)}const TH=w.lazy(()=>et(()=>import("./ProjectSwitcherModal-BUV_fZ5V.js"),__vite__mapDeps([24,1,2,3,4])).then(n=>({default:n.ProjectSwitcherModal})));function x5(n){const e=q.c(8),{onNewSession:t,onNewFolder:s,defaultAgentKind:r}=n,[o,i]=w.useState(null);let l,c;if(e[0]===Symbol.for("react.memo_cache_sentinel")?(l=()=>EH(()=>i(!0)),c=[],e[0]=l,e[1]=c):(l=e[0],c=e[1]),w.useEffect(l,c),o===null)return null;let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>i(!1),e[2]=u):u=e[2];let d;return e[3]!==r||e[4]!==s||e[5]!==t||e[6]!==o?(d=a.jsx(w.Suspense,{fallback:null,children:a.jsx(TH,{open:o,onClose:u,onNewSession:t,onNewFolder:s,defaultAgentKind:r,currentProjectDirName:null,currentProjectCwd:null,initialView:"folders"})}),e[3]=r,e[4]=s,e[5]=t,e[6]=o,e[7]=d):d=e[7],d}const AH=/^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?$/;function l2(n,e){if(!AH.test(e))throw new Error(`Invalid Cogpit ${n} id "${e}"`)}function Oo(n,e){return`${n}.${e}`}function PH(n){const e=new Set,t=new Set,s=[];for(const r of n){if(l2("plugin",r.id),e.has(r.id))throw new Error(`Duplicate Cogpit plugin id "${r.id}"`);e.add(r.id);for(const o of r.workspacePanels??[]){l2("panel",o.id);const i=Oo(r.id,o.id);if(t.has(i))throw new Error(`Duplicate Cogpit workspace panel id "${i}"`);t.add(i),s.push({...o,id:i,pluginId:r.id,localId:o.id})}}return s.sort((r,o)=>(r.order??100)-(o.order??100)||r.title.localeCompare(o.title))}function Wn({className:n,...e}){return a.jsx("div",{"data-slot":"skeleton",className:G("rounded-md bg-muted motion-safe:animate-in motion-safe:fade-in-0 motion-safe:duration-200 motion-safe:ease-out motion-reduce:animate-none",n),...e})}const hi="cogpit",zt={worktrees:Oo(hi,"worktrees"),projectFiles:Oo(hi,"project-files"),browser:Oo(hi,"browser"),fileChanges:Oo(hi,"file-changes"),sessionInfo:Oo(hi,"session-info")},IH=w.lazy(()=>et(()=>import("./CommandPaletteHost-B-n0sXM6.js"),__vite__mapDeps([25,1,2,3,4])).then(n=>({default:n.CommandPaletteHost}))),$H=w.lazy(()=>et(()=>import("./index-bXbR7jwp.js"),__vite__mapDeps([26,1,2,27,3,4])).then(n=>({default:n.ConfigDialog}))),RH=w.lazy(()=>et(()=>import("./KeyboardShortcutsDialog-DeIXxXmj.js"),__vite__mapDeps([28,1,2,3,4])).then(n=>({default:n.KeyboardShortcutsDialog}))),OH=w.lazy(()=>et(()=>import("./ProjectSwitcherModal-BUV_fZ5V.js"),__vite__mapDeps([24,1,2,3,4])).then(n=>({default:n.ProjectSwitcherModal}))),LH=w.lazy(()=>et(()=>import("./ThemeSelectorModal-t2P0tZVJ.js"),__vite__mapDeps([29,1,2,3,4])).then(n=>({default:n.ThemeSelectorModal})));function MH(n){const e=q.c(131),{navigation:t,project:s,chrome:r}=n,{state:o,config:i,theme:l}=bn(),{session:c,sessionSource:u}=xt(),{devices:d,activeDeviceId:f}=la(),[m,p]=w.useState(null);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=pt("manageDevices"),e[0]=h):h=e[0];const g=h,x=m1(),b=o.mainView==="extension"?o.extensionViewId:null;let y;e[1]!==o.pendingCwd||e[2]!==o.pendingDirName?(y=o.pendingCwd??(o.pendingDirName?ls(o.pendingDirName):null),e[1]=o.pendingCwd,e[2]=o.pendingDirName,e[3]=y):y=e[3];const v=y,k=(u==null?void 0:u.dirName)??o.pendingDirName??o.dashboardProject??null,j=r.onKeyboardShortcutsOpenChange;let _,N;e[4]!==j?(_=()=>{const Ee=function(Oe){qt("keyboardShortcuts",Oe)&&(i5(document.activeElement)||(Oe.preventDefault(),j(!0)))};return window.addEventListener("keydown",Ee),()=>window.removeEventListener("keydown",Ee)},N=[j],e[4]=j,e[5]=_,e[6]=N):(_=e[5],N=e[6]),w.useEffect(_,N);const S=f===Et;let C;e[7]!==S?(C={id:Et,name:"This machine",isLocal:!0,isActive:S},e[7]=S,e[8]=C):C=e[8];let E;if(e[9]!==f||e[10]!==d||e[11]!==C){let Ee;e[13]!==f?(Ee=me=>({id:me.id,name:me.name,isLocal:!1,isActive:me.id===f}),e[13]=f,e[14]=Ee):Ee=e[14],E=[C,...d.map(Ee)],e[9]=f,e[10]=d,e[11]=C,e[12]=E}else E=e[12];const T=E,{openMainView:A,closeMainView:P}=t.panels;let I;if(e[15]!==P||e[16]!==x||e[17]!==A||e[18]!==b){let Ee;e[20]!==P||e[21]!==A||e[22]!==b?(Ee=me=>{const Oe=me.id===b;return{id:`main-view-${me.id}`,label:`${Oe?"Close":"Open"} ${me.label}`,keywords:me.keywords,icon:me.icon,onSelect:Oe?P:()=>A(me.id)}},e[20]=P,e[21]=A,e[22]=b,e[23]=Ee):Ee=e[23],I=x.map(Ee),e[15]=P,e[16]=x,e[17]=A,e[18]=b,e[19]=I}else I=e[19];const $=I;let O;e[24]!==c||e[25]!==(u==null?void 0:u.agentKind)||e[26]!==(u==null?void 0:u.dirName)?(O=()=>{if(!c)return;const Ee=(u==null?void 0:u.agentKind)??nn((u==null?void 0:u.dirName)??null);Vd(y1(Ee,c.sessionId,c.cwd))},e[24]=c,e[25]=u==null?void 0:u.agentKind,e[26]=u==null?void 0:u.dirName,e[27]=O):O=e[27];const M=O,R=zH,z=r.processPanel,W=r.workflowsPanel,D=r.undoDialog,L=r.branchModal,U=i.claudeDir??"";let F;e[28]!==i.handleCloseConfigDialog||e[29]!==i.handleConfigSaved||e[30]!==i.showConfigDialog||e[31]!==U?(F=a.jsx(w.Suspense,{fallback:null,children:a.jsx($H,{open:i.showConfigDialog,currentPath:U,onClose:i.handleCloseConfigDialog,onSaved:i.handleConfigSaved})}),e[28]=i.handleCloseConfigDialog,e[29]=i.handleConfigSaved,e[30]=i.showConfigDialog,e[31]=U,e[32]=F):F=e[32];const B=(u==null?void 0:u.dirName)??o.pendingDirName??null,V=(c==null?void 0:c.cwd)??o.pendingCwd??null;let H;e[33]!==i.defaultAgentKind||e[34]!==t.onStartNewFolder||e[35]!==t.onStartNewSession||e[36]!==t.panels.handleCloseProjectSwitcher||e[37]!==t.panels.showProjectSwitcher||e[38]!==B||e[39]!==V?(H=a.jsx(w.Suspense,{fallback:null,children:a.jsx(OH,{open:t.panels.showProjectSwitcher,onClose:t.panels.handleCloseProjectSwitcher,onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:i.defaultAgentKind,currentProjectDirName:B,currentProjectCwd:V})}),e[33]=i.defaultAgentKind,e[34]=t.onStartNewFolder,e[35]=t.onStartNewSession,e[36]=t.panels.handleCloseProjectSwitcher,e[37]=t.panels.showProjectSwitcher,e[38]=B,e[39]=V,e[40]=H):H=e[40];let K;e[41]!==i.defaultAgentKind||e[42]!==t.onStartNewFolder||e[43]!==t.onStartNewSession?(K=a.jsx(x5,{onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:i.defaultAgentKind}),e[41]=i.defaultAgentKind,e[42]=t.onStartNewFolder,e[43]=t.onStartNewSession,e[44]=K):K=e[44];let Z;e[45]!==t.panels.handleCloseThemeSelector||e[46]!==t.panels.showThemeSelector||e[47]!==l.setPreview||e[48]!==l.setTheme||e[49]!==l.theme?(Z=a.jsx(w.Suspense,{fallback:null,children:a.jsx(LH,{open:t.panels.showThemeSelector,onClose:t.panels.handleCloseThemeSelector,currentTheme:l.theme,onSelectTheme:l.setTheme,onPreviewTheme:l.setPreview})}),e[45]=t.panels.handleCloseThemeSelector,e[46]=t.panels.showThemeSelector,e[47]=l.setPreview,e[48]=l.setTheme,e[49]=l.theme,e[50]=Z):Z=e[50];const Y=r.commandPaletteOpen,X=r.onCommandPaletteOpenChange,se=t.actions.handleGoHome,Q=t.panels.handleOpenProjectSwitcher,te=t.onOpenPaletteProject,J=t.actions.handleDashboardSelect,ne=t.panels.handleToggleSidebar;let re,le,ae;e[51]!==t.panels?(re=()=>t.panels.toggleWorkspacePanel(zt.sessionInfo),le=()=>t.panels.toggleWorkspacePanel(zt.fileChanges),ae=()=>t.panels.toggleWorkspacePanel(zt.worktrees),e[51]=t.panels,e[52]=re,e[53]=le,e[54]=ae):(re=e[52],le=e[53],ae=e[54]);const ue=t.panels.handleToggleMission,oe=c?t.handlers.handleDuplicateSession:void 0,ie=c?M:void 0,fe=c?R:void 0,de=pt("killAny")?r.onKillAll:void 0,ce=pt("configWrite")?t.panels.handleToggleConfig:void 0,xe=i.openConfigDialog;let pe;e[55]!==j?(pe=()=>j(!0),e[55]=j,e[56]=pe):pe=e[56];const he=s.currentCwd?s.onTogglePreview:void 0,ye=pt("hostFiles")&&s.currentCwd?s.onToggleProjectFiles:void 0;let ve;e[57]!==t.panels?(ve=pt("browser")?()=>t.panels.toggleWorkspacePanel(zt.browser):void 0,e[57]=t.panels,e[58]=ve):ve=e[58];const ke=t.panels.handleToggleThemeSelector,je=s.onOpenTerminal,Me=r.onFocusComposer,_e=r.onExpandAll,Fe=r.onExpandToolPayloads,ze=r.onCollapseAll,We=!!(c||o.pendingDirName);let Pe;e[59]!==v||e[60]!==(c==null?void 0:c.cwd)||e[61]!==(u==null?void 0:u.dirName)||e[62]!==o.dashboardProject||e[63]!==o.pendingDirName?(Pe=pt("terminal")&&!!((c==null?void 0:c.cwd)??v??(u==null?void 0:u.dirName)??o.pendingDirName??o.dashboardProject),e[59]=v,e[60]=c==null?void 0:c.cwd,e[61]=u==null?void 0:u.dirName,e[62]=o.dashboardProject,e[63]=o.pendingDirName,e[64]=Pe):Pe=e[64];const qe=!!c;let be;e[65]!==s.hasFileChanges?(be=pt("hostFiles")&&s.hasFileChanges,e[65]=s.hasFileChanges,e[66]=be):be=e[66];const Ie=t.panels.activeWorkspacePanel===zt.sessionInfo,Se=t.panels.activeWorkspacePanel===zt.browser,Ne=t.panels.activeWorkspacePanel===zt.fileChanges,He=t.panels.activeWorkspacePanel===zt.worktrees,Ke=o.mainView==="config",Ce=o.mainView==="mission",Be=(c==null?void 0:c.cwd)??v??null;let Ye;e[67]!==r.commandPaletteOpen||e[68]!==r.onCollapseAll||e[69]!==r.onCommandPaletteOpenChange||e[70]!==r.onExpandAll||e[71]!==r.onExpandToolPayloads||e[72]!==r.onFocusComposer||e[73]!==i.openConfigDialog||e[74]!==k||e[75]!==$||e[76]!==t.actions.handleDashboardSelect||e[77]!==t.actions.handleGoHome||e[78]!==t.onOpenPaletteProject||e[79]!==t.panels.handleOpenProjectSwitcher||e[80]!==t.panels.handleToggleMission||e[81]!==t.panels.handleToggleSidebar||e[82]!==t.panels.handleToggleThemeSelector||e[83]!==t.panels.showSidebar||e[84]!==T||e[85]!==s.launchTerminalRequest||e[86]!==s.onOpenTerminal||e[87]!==s.processPanel.addProcess||e[88]!==s.showProjectFiles||e[89]!==s.supportsWorktrees||e[90]!==re||e[91]!==le||e[92]!==ae||e[93]!==oe||e[94]!==ie||e[95]!==fe||e[96]!==de||e[97]!==ce||e[98]!==pe||e[99]!==he||e[100]!==ye||e[101]!==ve||e[102]!==We||e[103]!==Pe||e[104]!==qe||e[105]!==be||e[106]!==Ie||e[107]!==Se||e[108]!==Ne||e[109]!==He||e[110]!==Ke||e[111]!==Ce||e[112]!==Be?(Ye=a.jsx(w.Suspense,{fallback:null,children:a.jsx(IH,{open:Y,onOpenChange:X,onGoHome:se,onNewSession:Q,onOpenProject:te,onOpenSession:J,onToggleSidebar:ne,onToggleStats:re,onToggleFileChanges:le,onToggleWorktrees:ae,onToggleMissionControl:ue,extraActions:$,onDuplicateSession:oe,onCopyResumeCommand:ie,onFindInConversation:fe,onKillAll:de,onOpenConfig:ce,onOpenSettings:xe,onOpenKeyboardShortcuts:pe,onTogglePreview:he,onToggleProjectFiles:ye,onToggleBrowser:ve,onOpenTheme:ke,onOpenTerminal:je,onOpenDevices:g?p:void 0,onSwitchDevice:Fs,devices:T,onFocusComposer:Me,onExpandAll:_e,onExpandToolPayloads:Fe,onCollapseAll:ze,canFocusComposer:We,canOpenTerminal:Pe,hasSession:qe,hasFileChanges:be,supportsWorktrees:s.supportsWorktrees,showSidebar:t.panels.showSidebar,showStats:Ie,showProjectFiles:s.showProjectFiles,showBrowser:Se,showFileChanges:Ne,showWorktrees:He,showConfig:Ke,showMission:Ce,currentProjectDirName:k,projectCwd:Be,onProcessStarted:s.processPanel.addProcess,launchTerminalRequest:s.launchTerminalRequest})}),e[67]=r.commandPaletteOpen,e[68]=r.onCollapseAll,e[69]=r.onCommandPaletteOpenChange,e[70]=r.onExpandAll,e[71]=r.onExpandToolPayloads,e[72]=r.onFocusComposer,e[73]=i.openConfigDialog,e[74]=k,e[75]=$,e[76]=t.actions.handleDashboardSelect,e[77]=t.actions.handleGoHome,e[78]=t.onOpenPaletteProject,e[79]=t.panels.handleOpenProjectSwitcher,e[80]=t.panels.handleToggleMission,e[81]=t.panels.handleToggleSidebar,e[82]=t.panels.handleToggleThemeSelector,e[83]=t.panels.showSidebar,e[84]=T,e[85]=s.launchTerminalRequest,e[86]=s.onOpenTerminal,e[87]=s.processPanel.addProcess,e[88]=s.showProjectFiles,e[89]=s.supportsWorktrees,e[90]=re,e[91]=le,e[92]=ae,e[93]=oe,e[94]=ie,e[95]=fe,e[96]=de,e[97]=ce,e[98]=pe,e[99]=he,e[100]=ye,e[101]=ve,e[102]=We,e[103]=Pe,e[104]=qe,e[105]=be,e[106]=Ie,e[107]=Se,e[108]=Ne,e[109]=He,e[110]=Ke,e[111]=Ce,e[112]=Be,e[113]=Ye):Ye=e[113];let Xe;e[114]!==r.keyboardShortcutsOpen||e[115]!==j?(Xe=a.jsx(w.Suspense,{fallback:null,children:a.jsx(RH,{open:r.keyboardShortcutsOpen,onOpenChange:j})}),e[114]=r.keyboardShortcutsOpen,e[115]=j,e[116]=Xe):Xe=e[116];let nt;e[117]!==m?(nt=g&&a.jsx(p5,{open:m!==null,initialMode:m??"manage",onClose:()=>p(null)}),e[117]=m,e[118]=nt):nt=e[118];let Qe;return e[119]!==r.branchModal||e[120]!==r.processPanel||e[121]!==r.undoDialog||e[122]!==r.workflowsPanel||e[123]!==F||e[124]!==H||e[125]!==K||e[126]!==Z||e[127]!==Ye||e[128]!==Xe||e[129]!==nt?(Qe=a.jsxs(a.Fragment,{children:[z,W,D,L,F,H,K,Z,Ye,Xe,nt]}),e[119]=r.branchModal,e[120]=r.processPanel,e[121]=r.undoDialog,e[122]=r.workflowsPanel,e[123]=F,e[124]=H,e[125]=K,e[126]=Z,e[127]=Ye,e[128]=Xe,e[129]=nt,e[130]=Qe):Qe=e[130],Qe}function zH(){window.dispatchEvent(new Event(ng))}const b5={"github.repository":"cogpit.github.repository","clickup.tasks":"cogpit.clickup.tasks","vercel-deployments.deployments":"cogpit.vercel.deployments"};function c2(n){return n===null?null:b5[n]??n}function v5(n,e){return n?e.find(t=>t.id===n)??e.find(t=>t.id===b5[n])??null:null}function Tu(n){const e=q.c(10),{reason:t,children:s}=n;if(!t)return s;let r;e[0]!==t?(r=a.jsx("span",{className:"inline-flex",tabIndex:0,"aria-label":t}),e[0]=t,e[1]=r):r=e[1];let o;e[2]!==s||e[3]!==r?(o=a.jsx(Yt,{render:r,children:s}),e[2]=s,e[3]=r,e[4]=o):o=e[4];let i;e[5]!==t?(i=a.jsx(Xt,{children:t}),e[5]=t,e[6]=i):i=e[6];let l;return e[7]!==o||e[8]!==i?(l=a.jsxs(Zt,{children:[o,i]}),e[7]=o,e[8]=i,e[9]=l):l=e[9],l}const u2=f5.version,DH={ok:"bg-success",unknown:"bg-warning","bad-password":"bg-destructive"},d2={ok:"Reachable",unknown:"Not reachable","bad-password":"Password rejected"};function FH(n){const e=q.c(6),{state:t}=n,s=d2[t],r=d2[t],o=DH[t];let i;e[0]!==o?(i=G("size-2 shrink-0 rounded-full",o),e[0]=o,e[1]=i):i=e[1];let l;return e[2]!==s||e[3]!==r||e[4]!==i?(l=a.jsx("span",{"aria-label":s,title:r,className:i}),e[2]=s,e[3]=r,e[4]=i,e[5]=l):l=e[5],l}function Lx(n){const e=q.c(50),{compact:t}=n,s=t===void 0?!1:t,{devices:r,activeDeviceId:o,activeDevice:i,refresh:l,testDevice:c}=la(),[u,d]=w.useState(null),f=(i==null?void 0:i.name)??"This machine",m=o!==Et;let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=pt("manageDevices"),e[0]=p):p=e[0];const h=p;let g;e[1]!==r||e[2]!==l||e[3]!==c?(g=D=>{!D||r.length===0||Promise.all(r.map(L=>c(L.id).catch(BH))).then(()=>l())},e[1]=r,e[2]=l,e[3]=c,e[4]=g):g=e[4];const x=g;if(!s&&r.length===0&&!m)return null;const b=s?"sm":"xs",y=s&&"h-10";let v;e[5]!==y?(v=G("max-w-40 justify-start",y),e[5]=y,e[6]=v):v=e[6];let k;e[7]!==b||e[8]!==v?(k=a.jsx(ee,{variant:"ghost",size:b,"aria-label":"Switch device",className:v}),e[7]=b,e[8]=v,e[9]=k):k=e[9];let j;e[10]!==m?(j=m?a.jsx(y3,{"data-icon":"inline-start"}):a.jsx(kh,{"data-icon":"inline-start"}),e[10]=m,e[11]=j):j=e[11];let _;e[12]!==f?(_=a.jsx("span",{className:"truncate",children:f}),e[12]=f,e[13]=_):_=e[13];let N;e[14]===Symbol.for("react.memo_cache_sentinel")?(N=a.jsx(Ot,{"data-icon":"inline-end",className:"opacity-60"}),e[14]=N):N=e[14];let S;e[15]!==k||e[16]!==j||e[17]!==_?(S=a.jsxs(sa,{render:k,children:[j,_,N]}),e[15]=k,e[16]=j,e[17]=_,e[18]=S):S=e[18];let C;e[19]===Symbol.for("react.memo_cache_sentinel")?(C=a.jsx($j,{children:"Devices"}),e[19]=C):C=e[19];let E,T;e[20]===Symbol.for("react.memo_cache_sentinel")?(E=a.jsx(kh,{}),T=a.jsx("span",{className:"flex-1 truncate",children:"This machine"}),e[20]=E,e[21]=T):(E=e[20],T=e[21]);let A;e[22]!==m?(A=!m&&a.jsx(Ft,{className:"ml-auto text-success"}),e[22]=m,e[23]=A):A=e[23];let P;e[24]!==A?(P=a.jsxs(cn,{onClick:UH,children:[E,T,A]}),e[24]=A,e[25]=P):P=e[25];let I;if(e[26]!==o||e[27]!==s||e[28]!==r){let D;e[30]!==o||e[31]!==s?(D=L=>{const U=u5(L),F=U!==void 0&&U!==u2,B=L.id===o;return a.jsxs(cn,{onClick:()=>Fs(L.id),className:G(s&&"min-h-10"),children:[a.jsx(FH,{state:L.runtime.authState}),a.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[a.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[a.jsx("span",{className:"truncate",children:L.name}),F&&a.jsxs("span",{className:"shrink-0 font-mono text-xs text-warning",title:`Device runs v${U}; hub runs v${u2}`,children:["v",U]})]}),a.jsxs("span",{className:"truncate text-xs text-muted-foreground",children:[L.host,":",L.port,L.auth==="none"&&" · unauthenticated"]})]}),B&&a.jsx(Ft,{className:"ml-auto text-success"})]},L.id)},e[30]=o,e[31]=s,e[32]=D):D=e[32],I=r.map(D),e[26]=o,e[27]=s,e[28]=r,e[29]=I}else I=e[29];let $;e[33]!==P||e[34]!==I?($=a.jsxs(Nr,{children:[C,P,I]}),e[33]=P,e[34]=I,e[35]=$):$=e[35];let O;e[36]!==r.length?(O=h&&a.jsxs(a.Fragment,{children:[a.jsx(Yu,{}),a.jsxs(Nr,{children:[a.jsxs(cn,{onClick:()=>d("add"),children:[a.jsx(tr,{}),a.jsx("span",{children:"Add device…"})]}),r.length>0&&a.jsxs(cn,{onClick:()=>d("manage"),children:[a.jsx(Qg,{}),a.jsx("span",{children:"Manage devices…"})]})]})]}),e[36]=r.length,e[37]=O):O=e[37];let M;e[38]!==$||e[39]!==O?(M=a.jsxs(ra,{align:"end",sideOffset:6,className:"w-64",children:[$,O]}),e[38]=$,e[39]=O,e[40]=M):M=e[40];let R;e[41]!==x||e[42]!==S||e[43]!==M?(R=a.jsxs(na,{onOpenChange:x,children:[S,M]}),e[41]=x,e[42]=S,e[43]=M,e[44]=R):R=e[44];let z;e[45]!==u?(z=h&&a.jsx(p5,{open:u!==null,initialMode:u??"manage",onClose:()=>d(null)}),e[45]=u,e[46]=z):z=e[46];let W;return e[47]!==R||e[48]!==z?(W=a.jsxs(a.Fragment,{children:[R,z]}),e[47]=R,e[48]=z,e[49]=W):W=e[49],W}function UH(){return Fs(Et)}function BH(){return null}const WH=6e4;function qH(){const[n,e]=w.useState([]),[t,s]=w.useState(!1),r=w.useRef(!1),o=w.useCallback(async()=>{if(!r.current){r.current=!0;try{const l=await Re("/api/system-processes");if(l.ok){const c=await l.json();e((c.processes??[]).filter(u=>u.suspectedLeak))}}catch{}finally{r.current=!1}}},[]),i=w.useCallback(async l=>{if(l.length!==0){s(!0);try{await Re("/api/system-processes/kill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pids:l})}),await new Promise(c=>setTimeout(c,1e3)),await o()}catch{}finally{s(!1)}}},[o]);return w.useEffect(()=>{o();const l=window.setInterval(()=>{document.visibilityState==="visible"&&o()},WH);return()=>window.clearInterval(l)},[o]),{leaks:n,killing:t,killLeaks:i,refresh:o}}const VH=6e4;function HH(){const n=q.c(29),{leaks:e,killing:t,killLeaks:s,refresh:r}=qH(),[o,i]=w.useState(!1),l=e.length>0,c=e.reduce(ZH,0);let u,d;if(n[0]!==l?(u=()=>{if(l){i(!0);return}const A=window.setTimeout(()=>i(!1),VH);return()=>window.clearTimeout(A)},d=[l],n[0]=l,n[1]=u,n[2]=d):(u=n[1],d=n[2]),w.useEffect(u,d),!l&&!o)return null;const f=Zt,m=l?"destructive":"ghost",p=l?`Kill ${e.length} leaked agent ${e.length===1?"process":"processes"}`:"Leak monitor. No leaked agent processes";let h;n[3]!==l||n[4]!==s||n[5]!==e||n[6]!==r?(h=()=>void(l?s(e.map(GH)):r()),n[3]=l,n[4]=s,n[5]=e,n[6]=r,n[7]=h):h=n[7];const g=!l&&"text-muted-foreground";let x;n[8]!==g?(x=G("mr-1 font-mono",g),n[8]=g,n[9]=x):x=n[9];let b;n[10]!==t||n[11]!==m||n[12]!==p||n[13]!==h||n[14]!==x?(b=a.jsx(ee,{variant:m,size:"xs","aria-label":p,onClick:h,disabled:t,className:x}),n[10]=t,n[11]=m,n[12]=p,n[13]=h,n[14]=x,n[15]=b):b=n[15];let y;n[16]===Symbol.for("react.memo_cache_sentinel")?(y=a.jsx(hP,{"data-icon":"inline-start"}),n[16]=y):y=n[16];const v=t?"…":e.length;let k;n[17]!==v?(k=a.jsx("span",{className:"tabular-nums",children:v}),n[17]=v,n[18]=k):k=n[18];let j;n[19]!==k||n[20]!==b?(j=a.jsxs(Yt,{render:b,children:[y,k]}),n[19]=k,n[20]=b,n[21]=j):j=n[21];const _=Xt,N="bottom",S="p-3",C=l?a.jsxs("div",{className:"flex min-w-56 flex-col gap-2",children:[a.jsxs("div",{className:"text-xs font-medium",children:["Leaked agent processes · ",c.toFixed(0),"% CPU"]}),e.slice(0,6).map(KH),e.length>6&&a.jsxs("div",{className:"text-xs text-muted-foreground",children:["+",e.length-6," more"]}),a.jsx(Gt,{}),a.jsxs("div",{className:"text-xs text-muted-foreground",children:["Click to kill ",e.length===1?"it":"all of them"]})]}):a.jsxs("div",{className:"flex min-w-48 flex-col gap-1",children:[a.jsx("div",{className:"text-xs font-medium",children:"Leak monitor"}),a.jsx("div",{className:"text-xs text-muted-foreground",children:"No leaked agent processes. Click to scan again."})]});let E;n[22]!==_||n[23]!==C?(E=a.jsx(_,{side:N,className:S,children:C}),n[22]=_,n[23]=C,n[24]=E):E=n[24];let T;return n[25]!==f||n[26]!==j||n[27]!==E?(T=a.jsxs(f,{children:[j,E]}),n[25]=f,n[26]=j,n[27]=E,n[28]=T):T=n[28],T}function KH(n){return a.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[a.jsxs("span",{className:"truncate text-muted-foreground",children:[n.label," · ",E1(n.ageSeconds)]}),a.jsxs("span",{className:"shrink-0 font-semibold text-destructive",children:[n.cpuPercent.toFixed(0),"%"]})]},n.pid)}function GH(n){return n.pid}function ZH(n,e){return n+e.cpuPercent}const YH=15e3;function XH(){const[n,e]=w.useState([]),t=w.useCallback(async()=>{var l,c;try{const u=await Re("/api/notifications?limit=100");if(!u.ok)return;const d=await u.json();if(!Array.isArray(d.notifications))return;e(d.notifications),(c=(l=Th()).onInboxRead)==null||c.call(l,d.notifications)}catch{}},[]);w.useEffect(()=>{t();const l=()=>void t(),c=window.setInterval(l,YH);return window.addEventListener("focus",l),()=>{window.clearInterval(c),window.removeEventListener("focus",l)}},[t]);const s=w.useCallback(async(l,c)=>{const u=new Date().toISOString();e(d=>d.map(f=>f.readAt===null&&c(f)?{...f,readAt:u}:f));try{await Re("/api/notifications/read",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)})}catch{}},[]),r=w.useCallback(async l=>s({ids:l},c=>l.includes(c.id)),[s]),o=w.useCallback(async()=>s({all:!0},()=>!0),[s]),i=n.filter(l=>l.readAt===null).length;return{notifications:n,unreadCount:i,refresh:t,markRead:r,markAllRead:o}}function Mx(n){window.history.pushState({},"",n),window.dispatchEvent(new PopStateEvent("popstate"))}function y5(n,e){return`${Dd()}/${encodeURIComponent(n)}/${encodeURIComponent(v$(n,e))}`}async function Kge(n){let e;try{e=await Re(`/api/find-session/${encodeURIComponent(n)}`)}catch{return!1}const t=e.ok?await Zs(e):null;return typeof(t==null?void 0:t.dirName)!="string"||typeof t.fileName!="string"?!1:(Mx(y5(t.dirName,t.fileName)),!0)}const JH={turnComplete:io,permission:Ds,system:io,access:gP};function QH(){const n=q.c(30),{notifications:e,unreadCount:t,refresh:s,markRead:r,markAllRead:o}=XH(),[i,l]=w.useState(!1);let c;n[0]!==r?(c=function(S){r([S.id]),!(!S.dirName||!S.sessionId)&&(Mx(`${Dd()}/${encodeURIComponent(S.dirName)}/${encodeURIComponent(S.sessionId)}`),l(!1))},n[0]=r,n[1]=c):c=n[1];const u=c;let d;n[2]!==s?(d=N=>{l(N),N&&s()},n[2]=s,n[3]=d):d=n[3];const f=i?"secondary":"ghost",m=t>0?`Notifications, ${t} unread`:"Notifications";let p;n[4]!==f||n[5]!==m?(p=a.jsx(ee,{type:"button",variant:f,size:"icon-sm",className:"relative","aria-label":m}),n[4]=f,n[5]=m,n[6]=p):p=n[6];let h;n[7]===Symbol.for("react.memo_cache_sentinel")?(h=a.jsx(wh,{"data-icon":"inline-start"}),n[7]=h):h=n[7];let g;n[8]!==t?(g=t>0&&a.jsx(Ue,{className:"absolute -right-1 -top-1 h-4 min-w-4 px-1 tabular-nums",children:t>99?"99+":t}),n[8]=t,n[9]=g):g=n[9];let x;n[10]!==p||n[11]!==g?(x=a.jsxs(sa,{render:p,children:[h,g]}),n[10]=p,n[11]=g,n[12]=x):x=n[12];let b;n[13]===Symbol.for("react.memo_cache_sentinel")?(b=a.jsx("span",{className:"text-sm font-medium",children:"Notifications"}),n[13]=b):b=n[13];let y;n[14]!==o||n[15]!==t?(y=t>0&&a.jsxs(ee,{variant:"ghost",size:"xs",onClick:()=>void o(),children:[a.jsx(xP,{"data-icon":"inline-start"}),"Mark all read"]}),n[14]=o,n[15]=t,n[16]=y):y=n[16];let v;n[17]!==y?(v=a.jsxs("div",{className:"flex h-11 items-center justify-between border-b px-3",children:[b,y]}),n[17]=y,n[18]=v):v=n[18];let k;n[19]!==e||n[20]!==u?(k=a.jsx("div",{className:"max-h-96 overflow-y-auto",children:e.length===0?a.jsx(kn,{className:"min-h-40 p-6",children:a.jsxs(jn,{children:[a.jsx(Rn,{variant:"icon",children:a.jsx(wh,{})}),a.jsx(Nn,{children:"No notifications"}),a.jsx(Cn,{children:"Session updates will appear here."})]})}):a.jsx(Nr,{children:e.map(N=>a.jsx(eK,{notification:N,onOpen:u},N.id))})}),n[19]=e,n[20]=u,n[21]=k):k=n[21];let j;n[22]!==v||n[23]!==k?(j=a.jsxs(ra,{align:"end",sideOffset:6,className:"w-80 overflow-hidden p-0",children:[v,k]}),n[22]=v,n[23]=k,n[24]=j):j=n[24];let _;return n[25]!==i||n[26]!==d||n[27]!==j||n[28]!==x?(_=a.jsxs(na,{open:i,onOpenChange:d,children:[x,j]}),n[25]=i,n[26]=d,n[27]=j,n[28]=x,n[29]=_):_=n[29],_}function eK(n){const e=q.c(38),{notification:t,onOpen:s}=n,r=t.readAt===null,o=!!(t.dirName&&t.sessionId),i=Date.now();let l;e[0]!==t.at?(l=new Date(t.at).getTime(),e[0]=t.at,e[1]=l):l=e[1];const c=Math.max(0,(i-l)/1e3),u=JH[t.kind]??io;let d;e[2]!==t||e[3]!==s?(d=()=>s(t),e[2]=t,e[3]=s,e[4]=d):d=e[4];const f=!o&&"cursor-default",m=r&&"bg-accent/50";let p;e[5]!==f||e[6]!==m?(p=G("rounded-none border-b px-3 py-2.5 last:border-b-0",f,m),e[5]=f,e[6]=m,e[7]=p):p=e[7];const h=t.kind==="permission"?"text-warning":"text-info";let g;e[8]!==h?(g=G("mt-0.5",h),e[8]=h,e[9]=g):g=e[9];let x;e[10]!==u||e[11]!==g?(x=a.jsx(u,{className:g}),e[10]=u,e[11]=g,e[12]=x):x=e[12];const b=r?"font-medium text-foreground":"text-muted-foreground";let y;e[13]!==b?(y=G("truncate text-xs",b),e[13]=b,e[14]=y):y=e[14];let v;e[15]!==t.title||e[16]!==y?(v=a.jsx("span",{className:y,children:t.title}),e[15]=t.title,e[16]=y,e[17]=v):v=e[17];let k;e[18]!==c?(k=E1(c),e[18]=c,e[19]=k):k=e[19];let j;e[20]!==k?(j=a.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:k}),e[20]=k,e[21]=j):j=e[21];let _;e[22]!==v||e[23]!==j?(_=a.jsxs("span",{className:"flex items-baseline justify-between gap-2",children:[v,j]}),e[22]=v,e[23]=j,e[24]=_):_=e[24];let N;e[25]!==t.body?(N=a.jsx("span",{className:"mt-0.5 block truncate text-xs text-muted-foreground",children:t.body}),e[25]=t.body,e[26]=N):N=e[26];let S;e[27]!==_||e[28]!==N?(S=a.jsxs("span",{className:"min-w-0 flex-1",children:[_,N]}),e[27]=_,e[28]=N,e[29]=S):S=e[29];let C;e[30]!==r?(C=r&&a.jsx("span",{className:"mt-1.5 size-1.5 shrink-0 rounded-full bg-primary"}),e[30]=r,e[31]=C):C=e[31];let E;return e[32]!==S||e[33]!==C||e[34]!==d||e[35]!==p||e[36]!==x?(E=a.jsxs(cn,{onClick:d,className:p,children:[x,S,C]}),e[32]=S,e[33]=C,e[34]=d,e[35]=p,e[36]=x,e[37]=E):E=e[37],E}const tK=2e3;function Fi(n){return`${n.toFixed(n<10?1:0)}%`}function dd(n){return`${n.toFixed(0)} MB`}function nK(n){return n>=10?`${n.toFixed(0)}/s`:n>=1?`${n.toFixed(1)}/s`:`${n.toFixed(2)}/s`}function sK(n){return n<=0?null:n>=1024*1024?`${(n/1024/1024).toFixed(1)} MB/s`:n>=1024?`${(n/1024).toFixed(1)} KB/s`:`${n.toFixed(0)} B/s`}function rK(n){const e=q.c(44),{metric:t,onKill:s}=n;let r;e[0]!==t.label?(r=a.jsx("span",{className:"truncate text-sm font-medium",children:t.label}),e[0]=t.label,e[1]=r):r=e[1];let o;e[2]!==t.pid?(o=a.jsxs(Ue,{variant:"outline",children:["PID ",t.pid]}),e[2]=t.pid,e[3]=o):o=e[3];let i;e[4]!==t.suspectedLeak?(i=t.suspectedLeak&&a.jsx(Ue,{variant:"destructive",children:"possible leak"}),e[4]=t.suspectedLeak,e[5]=i):i=e[5];let l;e[6]!==t.orphaned||e[7]!==t.suspectedLeak?(l=t.orphaned&&!t.suspectedLeak&&a.jsx(Ue,{variant:"secondary",children:"orphaned"}),e[6]=t.orphaned,e[7]=t.suspectedLeak,e[8]=l):l=e[8];let c;e[9]!==r||e[10]!==o||e[11]!==i||e[12]!==l?(c=a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r,o,i,l]}),e[9]=r,e[10]=o,e[11]=i,e[12]=l,e[13]=c):c=e[13];let u;e[14]!==t.command?(u=a.jsx("p",{className:"mt-1 truncate font-mono text-xs text-muted-foreground",title:t.command,children:t.command}),e[14]=t.command,e[15]=u):u=e[15];let d;e[16]!==c||e[17]!==u?(d=a.jsxs("div",{className:"min-w-0 flex-1",children:[c,u]}),e[16]=c,e[17]=u,e[18]=d):d=e[18];let f;e[19]!==t.pid||e[20]!==t.suspectedLeak||e[21]!==s?(f=t.suspectedLeak&&s&&a.jsx(ee,{variant:"destructive",size:"xs",className:"shrink-0",onClick:()=>s(t.pid),children:"Kill"}),e[19]=t.pid,e[20]=t.suspectedLeak,e[21]=s,e[22]=f):f=e[22];const m=t.cpuPercent>=20&&"text-destructive";let p;e[23]!==m?(p=G("font-mono text-sm font-semibold tabular-nums",m),e[23]=m,e[24]=p):p=e[24];let h;e[25]!==t.cpuPercent?(h=Fi(t.cpuPercent),e[25]=t.cpuPercent,e[26]=h):h=e[26];let g;e[27]!==p||e[28]!==h?(g=a.jsx("div",{className:p,children:h}),e[27]=p,e[28]=h,e[29]=g):g=e[29];let x;e[30]!==t.memoryMb?(x=dd(t.memoryMb),e[30]=t.memoryMb,e[31]=x):x=e[31];let b;e[32]!==t.ageSeconds?(b=E1(t.ageSeconds),e[32]=t.ageSeconds,e[33]=b):b=e[33];let y;e[34]!==x||e[35]!==b?(y=a.jsxs("div",{className:"text-xs text-muted-foreground",children:[x," · ",b]}),e[34]=x,e[35]=b,e[36]=y):y=e[36];let v;e[37]!==g||e[38]!==y?(v=a.jsxs("div",{className:"shrink-0 text-right",children:[g,y]}),e[37]=g,e[38]=y,e[39]=v):v=e[39];let k;return e[40]!==v||e[41]!==d||e[42]!==f?(k=a.jsxs("div",{className:"flex items-start gap-3 py-2.5",children:[d,f,v]}),e[40]=v,e[41]=d,e[42]=f,e[43]=k):k=e[43],k}function oK(n){return n.name==="Server"?"API, file watching, session streams, and agent I/O":n.name==="Renderer"?"React rendering, markdown, layout, and animations":n.name==="GPU"?"Compositing, animation, and visual effects":n.name==="App"?"Electron window and application lifecycle":n.type}function iK(n,e,t=0){return t>0?t===1?'1 agent process outside Cogpit looks leaked. See "Agent processes" below.':`${t} agent processes outside Cogpit look leaked. See "Agent processes" below.`:n<5?"Cogpit is currently idle. Leave this open while the power spike happens.":e?e.name==="Server"?"The server is doing the most work. Compare the activity and API lists below to find the hot loop.":e.name==="Renderer"?"The renderer is doing the most work, which points to repeated UI rendering, layout, or animation.":e.name==="GPU"?"The GPU process is doing the most work, which points to continuous compositing or visual effects.":`${e.name} is currently the busiest Cogpit process.`:"The server is active. The lists below show its busiest recent work."}function w5(n){const e=q.c(34),{metric:t}=n;let s;e[0]!==t.name?(s=a.jsx("span",{className:"truncate text-sm font-medium",children:t.name}),e[0]=t.name,e[1]=s):s=e[1];let r;e[2]!==t.pid?(r=t.pid>0&&a.jsxs(Ue,{variant:"outline",children:["PID ",t.pid]}),e[2]=t.pid,e[3]=r):r=e[3];let o;e[4]!==s||e[5]!==r?(o=a.jsxs("div",{className:"flex items-center gap-2",children:[s,r]}),e[4]=s,e[5]=r,e[6]=o):o=e[6];let i;e[7]!==t?(i=oK(t),e[7]=t,e[8]=i):i=e[8];let l;e[9]!==i?(l=a.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:i}),e[9]=i,e[10]=l):l=e[10];let c;e[11]!==o||e[12]!==l?(c=a.jsxs("div",{className:"min-w-0 flex-1",children:[o,l]}),e[11]=o,e[12]=l,e[13]=c):c=e[13];const u=t.cpuPercent>=50&&"text-destructive";let d;e[14]!==u?(d=G("font-mono text-sm font-semibold tabular-nums",u),e[14]=u,e[15]=d):d=e[15];let f;e[16]!==t.cpuPercent?(f=Fi(t.cpuPercent),e[16]=t.cpuPercent,e[17]=f):f=e[17];let m;e[18]!==d||e[19]!==f?(m=a.jsx("div",{className:d,children:f}),e[18]=d,e[19]=f,e[20]=m):m=e[20];let p;e[21]!==t.memoryMb?(p=dd(t.memoryMb),e[21]=t.memoryMb,e[22]=p):p=e[22];let h;e[23]!==p?(h=a.jsx("div",{className:"text-xs text-muted-foreground",children:p}),e[23]=p,e[24]=h):h=e[24];let g;e[25]!==t.idleWakeupsPerSecond?(g=t.idleWakeupsPerSecond!==void 0&&t.idleWakeupsPerSecond>0&&a.jsxs("div",{className:"text-xs text-muted-foreground",children:[t.idleWakeupsPerSecond.toFixed(0)," wakeups/s"]}),e[25]=t.idleWakeupsPerSecond,e[26]=g):g=e[26];let x;e[27]!==m||e[28]!==h||e[29]!==g?(x=a.jsxs("div",{className:"shrink-0 text-right",children:[m,h,g]}),e[27]=m,e[28]=h,e[29]=g,e[30]=x):x=e[30];let b;return e[31]!==x||e[32]!==c?(b=a.jsxs("div",{className:"flex items-start gap-3 py-2.5",children:[c,x]}),e[31]=x,e[32]=c,e[33]=b):b=e[33],b}function f2(n){const e=q.c(6),{metrics:t,emptyLabel:s}=n;let r,o;if(e[0]!==s||e[1]!==t){o=Symbol.for("react.early_return_sentinel");e:{const i=t.slice(0,8);if(i.length===0){let l;e[4]!==s?(l=a.jsx("p",{className:"py-3 text-sm text-muted-foreground",children:s}),e[4]=s,e[5]=l):l=e[5],o=l;break e}r=i.map(aK)}e[0]=s,e[1]=t,e[2]=r,e[3]=o}else r=e[2],o=e[3];return o!==Symbol.for("react.early_return_sentinel")?o:r}function aK(n,e){const t=sK(n.bytesPerSecond);return a.jsxs("div",{children:[e>0&&a.jsx(Gt,{}),a.jsxs("div",{className:"flex items-center gap-3 py-2.5",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"truncate text-sm",children:n.name}),a.jsxs("div",{className:"mt-0.5 flex flex-wrap gap-x-2 text-xs text-muted-foreground",children:[a.jsx("span",{children:nK(n.ratePerSecond)}),t&&a.jsx("span",{children:t}),n.averageDurationMs!==void 0&&a.jsxs("span",{children:[n.averageDurationMs.toFixed(0)," ms avg"]})]})]}),n.active!==void 0&&n.active>0&&a.jsxs(Ue,{variant:"secondary",children:[n.active," open"]})]})]},n.name)}function lK(n){const e=q.c(8),{values:t}=n,s=Math.max(100,...t);let r;e[0]!==t?(r=t.map(cK).join(", "),e[0]=t,e[1]=r):r=e[1];const o=`Recent Cogpit CPU: ${r}`;let i;e[2]!==s||e[3]!==t?(i=t.length===0?a.jsx("span",{className:"self-center text-xs text-muted-foreground",children:"Collecting samples…"}):t.map((c,u)=>a.jsx("div",{className:G("min-w-1 flex-1 rounded-sm bg-primary/70",c>=80&&"bg-destructive/80"),style:{height:`${Math.max(4,Math.min(100,c/s*100))}%`},title:Fi(c)},u)),e[2]=s,e[3]=t,e[4]=i):i=e[4];let l;return e[5]!==o||e[6]!==i?(l=a.jsx("div",{className:"flex h-14 items-end gap-1 rounded-md bg-muted/50 p-2",role:"img","aria-label":o,children:i}),e[5]=o,e[6]=i,e[7]=l):l=e[7],l}function cK(n){return Fi(n)}function uK(n){var fe,de,ce,xe;const e=q.c(135),{open:t,onOpenChange:s}=n,[r,o]=w.useState(null),[i,l]=w.useState(null);let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=[],e[0]=c):c=e[0];const[u,d]=w.useState(c),[f,m]=w.useState(null),[p,h]=w.useState(!1),g=w.useRef(!1),[x,b]=Ar();let y;e[1]===Symbol.for("react.memo_cache_sentinel")?(y=async()=>{var Me;if(g.current)return;g.current=!0,h(!0);const pe=Re("/api/performance").then(gK),he=((Me=window.electronPerformance)==null?void 0:Me.getSnapshot())??Promise.resolve(null),[ye,ve]=await Promise.allSettled([pe,he]),ke=ye.status==="fulfilled"?ye.value:null,je=ve.status==="fulfilled"?ve.value:null;if(ke&&l(ke),je&&o(je),!ke&&!je)m("Performance data is unavailable.");else{m(null);const _e=je&&je.processes.length>0?je.processes.reduce(hK,0):(ke==null?void 0:ke.cpuPercent)??0;d(Fe=>[...Fe.slice(-29),_e])}g.current=!1,h(!1)},e[1]=y):y=e[1];const v=y;let k,j;e[2]!==t?(k=()=>{if(!t)return;v();const pe=window.setInterval(()=>void v(),tK);return()=>window.clearInterval(pe)},j=[t,v],e[2]=t,e[3]=k,e[4]=j):(k=e[3],j=e[4]),w.useEffect(k,j);let _,N,S,C,E,T,A,P,I,$,O,M,R,z,W,D,L,U,F;if(e[5]!==x||e[6]!==b||e[7]!==r||e[8]!==f||e[9]!==u||e[10]!==s||e[11]!==t||e[12]!==p||e[13]!==i){const pe=[...(r==null?void 0:r.processes)??[]].sort(pK),he=pe.length>0?pe.reduce(mK,0):(i==null?void 0:i.cpuPercent)??0,ye=pe[0];let ve;e[33]!==((fe=i==null?void 0:i.system)==null?void 0:fe.processes)?(ve=((de=i==null?void 0:i.system)==null?void 0:de.processes)??[],e[33]=(ce=i==null?void 0:i.system)==null?void 0:ce.processes,e[34]=ve):ve=e[34],A=ve;const ke=((xe=i==null?void 0:i.system)==null?void 0:xe.suspectedLeakCount)??0,je=ke>0||he>=80?"High":he>=15?"Active":"Idle";let Me;e[35]===Symbol.for("react.memo_cache_sentinel")?(Me=async rt=>{try{await Re("/api/system-processes/kill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pids:[rt]})}),await new Promise(fK)}catch{}v()},e[35]=Me):Me=e[35],T=Me;let _e;e[36]!==b||e[37]!==r||e[38]!==u||e[39]!==i?(_e=()=>{b(JSON.stringify({capturedAt:new Date().toISOString(),electron:r,server:i,cpuHistory:u},null,2))},e[36]=b,e[37]=r,e[38]=u,e[39]=i,e[40]=_e):_e=e[40];const Fe=_e;E=dr,R=t,z=s,C=fr,$="h-[min(780px,calc(100vh-2rem))] gap-0 p-0 sm:max-w-3xl";let ze;e[41]===Symbol.for("react.memo_cache_sentinel")?(ze=a.jsx(mr,{children:"Power & activity monitor"}),e[41]=ze):ze=e[41];const We=je==="High"?"destructive":"secondary";let Pe;e[42]!==je||e[43]!==We?(Pe=a.jsxs("div",{className:"flex items-center gap-2",children:[ze,a.jsx(Ue,{variant:We,children:je})]}),e[42]=je,e[43]=We,e[44]=Pe):Pe=e[44];let qe;e[45]===Symbol.for("react.memo_cache_sentinel")?(qe=a.jsx(pr,{className:"mt-1",children:"Live CPU, memory, and wakeups. Sampling runs only while this window is open."}),e[45]=qe):qe=e[45];let be;e[46]!==Pe?(be=a.jsxs("div",{className:"min-w-0 flex-1",children:[Pe,qe]}),e[46]=Pe,e[47]=be):be=e[47];let Ie;e[48]===Symbol.for("react.memo_cache_sentinel")?(Ie=()=>void v(),e[48]=Ie):Ie=e[48];const Se=p&&"animate-spin";let Ne;e[49]!==Se?(Ne=G(Se),e[49]=Se,e[50]=Ne):Ne=e[50];let He;e[51]!==Ne?(He=a.jsx(On,{"data-icon":"inline-start",className:Ne}),e[51]=Ne,e[52]=He):He=e[52];let Ke;e[53]!==p||e[54]!==He?(Ke=a.jsxs(ee,{variant:"outline",size:"sm",onClick:Ie,disabled:p,children:[He,"Refresh"]}),e[53]=p,e[54]=He,e[55]=Ke):Ke=e[55];const Ce=!i&&!r;let Be;e[56]!==x?(Be=x?a.jsx(Ft,{"data-icon":"inline-start"}):a.jsx(ys,{"data-icon":"inline-start"}),e[56]=x,e[57]=Be):Be=e[57];const Ye=x?"Copied":"Copy data";let Xe;e[58]!==Fe||e[59]!==Ce||e[60]!==Be||e[61]!==Ye?(Xe=a.jsxs(ee,{variant:"outline",size:"sm",onClick:Fe,disabled:Ce,children:[Be,Ye]}),e[58]=Fe,e[59]=Ce,e[60]=Be,e[61]=Ye,e[62]=Xe):Xe=e[62];let nt;e[63]!==Ke||e[64]!==Xe?(nt=a.jsxs("div",{className:"flex shrink-0 gap-1",children:[Ke,Xe]}),e[63]=Ke,e[64]=Xe,e[65]=nt):nt=e[65],e[66]!==be||e[67]!==nt?(O=a.jsx(wo,{className:"p-5 pb-4",children:a.jsxs("div",{className:"flex items-start gap-3 pr-8",children:[be,nt]})}),e[66]=be,e[67]=nt,e[68]=O):O=e[68],e[69]===Symbol.for("react.memo_cache_sentinel")?(M=a.jsx(Gt,{}),e[69]=M):M=e[69],S=Jl,I="min-h-0 min-w-0 flex-1",U="flex flex-col gap-4 p-5",e[70]!==f?(F=f&&a.jsx(Jt,{variant:"destructive",children:a.jsx(Qt,{children:f})}),e[70]=f,e[71]=F):F=e[71];let Qe;e[72]===Symbol.for("react.memo_cache_sentinel")?(Qe=a.jsx(Xs,{children:"Current load"}),e[72]=Qe):Qe=e[72];const Ee=he>=80&&"text-destructive";let me;e[73]!==Ee?(me=G("font-mono text-lg font-semibold tabular-nums",Ee),e[73]=Ee,e[74]=me):me=e[74];const Oe=a.jsxs(Ys,{children:[Qe,a.jsx(Js,{children:iK(he,ye,ke)}),a.jsx(EO,{children:a.jsxs("span",{className:me,children:[Fi(he)," CPU"]})})]});let Ge;e[75]!==u?(Ge=a.jsx(As,{children:a.jsx(lK,{values:u})}),e[75]=u,e[76]=Ge):Ge=e[76],e[77]!==Oe||e[78]!==Ge?(P=a.jsxs(Ts,{size:"sm",children:[Oe,Ge]}),e[77]=Oe,e[78]=Ge,e[79]=P):P=e[79],N=Ts,D="sm",e[80]===Symbol.for("react.memo_cache_sentinel")?(L=a.jsxs(Ys,{children:[a.jsx(Xs,{children:"Processes"}),a.jsx(Js,{children:"Which part of Cogpit is consuming CPU and memory."})]}),e[80]=L):L=e[80],_=As,W=pe.length>0?pe.map(dK):i?a.jsx(w5,{metric:{pid:0,name:"Server",type:"Node",cpuPercent:i.cpuPercent,memoryMb:i.memory.rssMb}}):a.jsx("p",{className:"py-3 text-sm text-muted-foreground",children:"Collecting process data…"}),e[5]=x,e[6]=b,e[7]=r,e[8]=f,e[9]=u,e[10]=s,e[11]=t,e[12]=p,e[13]=i,e[14]=_,e[15]=N,e[16]=S,e[17]=C,e[18]=E,e[19]=T,e[20]=A,e[21]=P,e[22]=I,e[23]=$,e[24]=O,e[25]=M,e[26]=R,e[27]=z,e[28]=W,e[29]=D,e[30]=L,e[31]=U,e[32]=F}else _=e[14],N=e[15],S=e[16],C=e[17],E=e[18],T=e[19],A=e[20],P=e[21],I=e[22],$=e[23],O=e[24],M=e[25],R=e[26],z=e[27],W=e[28],D=e[29],L=e[30],U=e[31],F=e[32];let B;e[81]!==_||e[82]!==W?(B=a.jsx(_,{children:W}),e[81]=_,e[82]=W,e[83]=B):B=e[83];let V;e[84]!==N||e[85]!==B||e[86]!==D||e[87]!==L?(V=a.jsxs(N,{size:D,children:[L,B]}),e[84]=N,e[85]=B,e[86]=D,e[87]=L,e[88]=V):V=e[88];let H;e[89]!==T||e[90]!==A?(H=A.length>0&&a.jsxs(Ts,{size:"sm",children:[a.jsxs(Ys,{children:[a.jsx(Xs,{children:"Agent processes"}),a.jsx(Js,{children:"Claude sessions, browsers, and scripts running outside Cogpit."})]}),a.jsx(As,{children:A.map((pe,he)=>a.jsxs("div",{children:[he>0&&a.jsx(Gt,{}),a.jsx(rK,{metric:pe,onKill:ye=>void T(ye)})]},pe.pid))})]}),e[89]=T,e[90]=A,e[91]=H):H=e[91];let K;e[92]===Symbol.for("react.memo_cache_sentinel")?(K=a.jsx(Xs,{children:"Server activity"}),e[92]=K):K=e[92];const Z=(i==null?void 0:i.sampleWindowSeconds)??10;let Y;e[93]!==Z?(Y=a.jsxs(Ys,{children:[K,a.jsxs(Js,{children:["File checks, streams, and agent work over the last ",Z," seconds."]})]}),e[93]=Z,e[94]=Y):Y=e[94];let X;e[95]!==(i==null?void 0:i.activities)?(X=(i==null?void 0:i.activities)??[],e[95]=i==null?void 0:i.activities,e[96]=X):X=e[96];let se;e[97]!==X?(se=a.jsx(As,{children:a.jsx(f2,{metrics:X,emptyLabel:"No watched-file or stream activity in this sample."})}),e[97]=X,e[98]=se):se=e[98];let Q;e[99]!==Y||e[100]!==se?(Q=a.jsxs(Ts,{size:"sm",children:[Y,se]}),e[99]=Y,e[100]=se,e[101]=Q):Q=e[101];let te;e[102]===Symbol.for("react.memo_cache_sentinel")?(te=a.jsxs(Ys,{children:[a.jsx(Xs,{children:"API activity"}),a.jsx(Js,{children:"Requests ranked by recent frequency and time."})]}),e[102]=te):te=e[102];let J;e[103]!==(i==null?void 0:i.requests)?(J=(i==null?void 0:i.requests)??[],e[103]=i==null?void 0:i.requests,e[104]=J):J=e[104];let ne;e[105]!==J?(ne=a.jsxs(Ts,{size:"sm",children:[te,a.jsx(As,{children:a.jsx(f2,{metrics:J,emptyLabel:"No API requests in this sample."})})]}),e[105]=J,e[106]=ne):ne=e[106];let re;e[107]!==Q||e[108]!==ne?(re=a.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[Q,ne]}),e[107]=Q,e[108]=ne,e[109]=re):re=e[109];let le;e[110]!==i?(le=i&&a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Server event loop ",Fi(i.eventLoopPercent)," · heap ",dd(i.memory.heapUsedMb)," · RSS ",dd(i.memory.rssMb)]}),e[110]=i,e[111]=le):le=e[111];let ae;e[112]!==P||e[113]!==V||e[114]!==H||e[115]!==re||e[116]!==le||e[117]!==U||e[118]!==F?(ae=a.jsxs("div",{className:U,children:[F,P,V,H,re,le]}),e[112]=P,e[113]=V,e[114]=H,e[115]=re,e[116]=le,e[117]=U,e[118]=F,e[119]=ae):ae=e[119];let ue;e[120]!==S||e[121]!==I||e[122]!==ae?(ue=a.jsx(S,{className:I,children:ae}),e[120]=S,e[121]=I,e[122]=ae,e[123]=ue):ue=e[123];let oe;e[124]!==C||e[125]!==$||e[126]!==O||e[127]!==M||e[128]!==ue?(oe=a.jsxs(C,{className:$,children:[O,M,ue]}),e[124]=C,e[125]=$,e[126]=O,e[127]=M,e[128]=ue,e[129]=oe):oe=e[129];let ie;return e[130]!==E||e[131]!==R||e[132]!==z||e[133]!==oe?(ie=a.jsx(E,{open:R,onOpenChange:z,children:oe}),e[130]=E,e[131]=R,e[132]=z,e[133]=oe,e[134]=ie):ie=e[134],ie}function dK(n,e){return a.jsxs("div",{children:[e>0&&a.jsx(Gt,{}),a.jsx(w5,{metric:n})]},n.pid)}function fK(n){return setTimeout(n,1e3)}function mK(n,e){return n+e.cpuPercent}function pK(n,e){return e.cpuPercent-n.cpuPercent}function hK(n,e){return n+e.cpuPercent}async function gK(n){if(!n.ok)throw new Error(`Server monitor returned ${n.status}`);return n.json()}function xK(n){return`${n.title??`Pull request #${n.number}`}
|
|
118
|
+
${n.repo}${n.isDraft?" · draft":""}`}function S5(n){return{href:n.url,target:"_blank",rel:"noreferrer",onClick:e=>e.stopPropagation(),"aria-label":`Pull request #${n.number}`,title:xK(n)}}function dc(n){const e=q.c(17),{pullRequests:t,max:s,compact:r,layout:o}=n,i=s===void 0?3:s,l=o===void 0?"chips":o;if(!(t!=null&&t.length))return null;if(l==="list"){let f;e[0]!==t?(f=t.map(vK),e[0]=t,e[1]=f):f=e[1];let m;return e[2]!==f?(m=a.jsx("div",{className:"flex flex-col gap-0.5",children:f}),e[2]=f,e[3]=m):m=e[3],m}let c,u;if(e[4]!==r||e[5]!==i||e[6]!==t){const f=t.slice(-i);if(e[9]!==i||e[10]!==t){const p=t.slice(0,-i);c=p.length>0&&a.jsxs("span",{className:"shrink-0 text-xs text-muted-foreground",title:p.map(bK).join(`
|
|
119
|
+
`),children:["+",p.length]}),e[9]=i,e[10]=t,e[11]=c}else c=e[11];let m;e[12]!==r?(m=p=>{const h=p.isDraft?C3:_3;return a.jsxs(Ue,{variant:p.isDraft?"outline":"secondary",render:a.jsx("a",{...S5(p)}),className:G("shrink-0",r&&"px-1"),children:[a.jsx(h,{"data-icon":"inline-start"}),"#",p.number]},p.url)},e[12]=r,e[13]=m):m=e[13],u=f.map(m),e[4]=r,e[5]=i,e[6]=t,e[7]=c,e[8]=u}else c=e[7],u=e[8];let d;return e[14]!==c||e[15]!==u?(d=a.jsxs(a.Fragment,{children:[c,u]}),e[14]=c,e[15]=u,e[16]=d):d=e[16],d}function bK(n){return`#${n.number} ${n.title??n.repo}`}function vK(n){const e=n.isDraft?C3:_3;return a.jsxs("a",{...S5(n),className:"flex items-center gap-1 text-foreground hover:underline",children:[a.jsx(e,{className:"size-2.5 shrink-0"}),a.jsxs("span",{className:"shrink-0",children:["#",n.number]}),n.title&&a.jsx("span",{className:"truncate text-muted-foreground",children:n.title})]},n.url)}const yK=w.memo(function(e){const t=q.c(37),{session:s,sessionSource:r,isLive:o,pullRequests:i,copied:l,creatingSession:c,onCopyResume:u,onNewSession:d,onDuplicateSession:f,onOpenTerminal:m}=e;let p;if(t[0]!==r){const T=r?lo(r.fileName):null;p=T?Cx(T.agentId):null,t[0]=r,t[1]=p}else p=t[1];const h=p;let g;t[2]!==s.turns?(g=s.turns.some(kK),t[2]=s.turns,t[3]=g):g=t[3];const x=g;let b;t[4]!==s.rawMessages||t[5]!==(r==null?void 0:r.dirName)?(b=Ri(r==null?void 0:r.dirName).contextWindow?s.rawMessages:[],t[4]=s.rawMessages,t[5]=r==null?void 0:r.dirName,t[6]=b):b=t[6];const y=b;let v;t[7]===Symbol.for("react.memo_cache_sentinel")?(v=a.jsx("div",{className:G(rs,"flex h-8 min-w-0 items-center gap-2 pl-1 pr-3")}),t[7]=v):v=t[7];let k;t[8]!==l||t[9]!==c||t[10]!==u||t[11]!==f||t[12]!==d||t[13]!==m||t[14]!==s||t[15]!==r?(k=r?a.jsx(SK,{session:s,sessionSource:r,copied:l,creatingSession:c,onCopyResume:u,onNewSession:d,onDuplicateSession:f,onOpenTerminal:m}):a.jsx("button",{type:"button",onClick:u,className:"truncate rounded-full px-1.5 py-1 text-sm font-medium text-foreground",children:l?"Copied":s.slug||s.sessionId.slice(0,8)}),t[8]=l,t[9]=c,t[10]=u,t[11]=f,t[12]=d,t[13]=m,t[14]=s,t[15]=r,t[16]=k):k=t[16];let j;t[17]!==o?(j=o&&a.jsx(Gd,{"aria-label":"Session is live"}),t[17]=o,t[18]=j):j=t[18];let _;t[19]!==s.model?(_=s.model&&a.jsx("span",{className:"shrink-0 font-mono text-[11px] text-foreground/80",children:Zo(s.model)}),t[19]=s.model,t[20]=_):_=t[20];let N;t[21]!==y?(N=a.jsx(Mj,{rawMessages:y}),t[21]=y,t[22]=N):N=t[22];let S;t[23]!==k||t[24]!==j||t[25]!==_||t[26]!==N?(S=a.jsxs(Yt,{delay:200,render:v,children:[k,j,_,N]}),t[23]=k,t[24]=j,t[25]=_,t[26]=N,t[27]=S):S=t[27];let C;t[28]!==i||t[29]!==y||t[30]!==s||t[31]!==h||t[32]!==x?(C=a.jsx(Xt,{role:"tooltip",side:"bottom",align:"start",sideOffset:6,className:"p-3",children:a.jsx(wK,{session:s,thinkingEnabled:x,subAgentLabel:h,pullRequests:i,rawMessages:y})}),t[28]=i,t[29]=y,t[30]=s,t[31]=h,t[32]=x,t[33]=C):C=t[33];let E;return t[34]!==C||t[35]!==S?(E=a.jsxs(Zt,{children:[S,C]}),t[34]=C,t[35]=S,t[36]=E):E=t[36],E});function ri(n){const e=q.c(7),{label:t,children:s}=n;let r;e[0]!==t?(r=a.jsx("span",{className:"w-24 shrink-0 text-muted-foreground",children:t}),e[0]=t,e[1]=r):r=e[1];let o;e[2]!==s?(o=a.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1",children:s}),e[2]=s,e[3]=o):o=e[3];let i;return e[4]!==r||e[5]!==o?(i=a.jsxs("div",{className:"flex gap-3",children:[r,o]}),e[4]=r,e[5]=o,e[6]=i):i=e[6],i}function wK(n){const e=q.c(33),{session:t,thinkingEnabled:s,subAgentLabel:r,pullRequests:o,rawMessages:i}=n;let l,c,u,d,f,m,p;if(e[0]!==o||e[1]!==i||e[2]!==t.branchedFrom||e[3]!==t.gitBranch||e[4]!==t.model||e[5]!==r||e[6]!==s){const g=pj(i),x=t.branchedFrom;l="flex min-w-64 max-w-96 flex-col gap-1.5 text-xs",e[14]!==t.model||e[15]!==s?(c=t.model&&a.jsxs(ri,{label:"Model",children:[a.jsx("span",{children:Zo(t.model)}),s&&a.jsx("span",{className:"text-muted-foreground",children:"· thinking"})]}),e[14]=t.model,e[15]=s,e[16]=c):c=e[16],e[17]!==t.gitBranch?(u=t.gitBranch&&a.jsx(ri,{label:"Branch",children:a.jsx("span",{className:"truncate font-mono",children:t.gitBranch})}),e[17]=t.gitBranch,e[18]=u):u=e[18],e[19]!==o?(d=o.length>0&&a.jsx(ri,{label:"Pull requests",children:a.jsx(dc,{pullRequests:o})}),e[19]=o,e[20]=d):d=e[20],e[21]!==r?(f=r&&a.jsx(ri,{label:"Agent",children:r}),e[21]=r,e[22]=f):f=e[22],e[23]!==x?(m=x&&a.jsxs(ri,{label:"Duplicated from",children:[x.sessionId.slice(0,8),x.turnIndex!=null?` at turn ${x.turnIndex+1}`:""]}),e[23]=x,e[24]=m):m=e[24],p=g&&a.jsxs(ri,{label:"Context",children:[Nt(Math.max(0,g.compactAt-g.used))," left before compact ·"," ",Nt(g.used)," / ",Nt(g.limit)]}),e[0]=o,e[1]=i,e[2]=t.branchedFrom,e[3]=t.gitBranch,e[4]=t.model,e[5]=r,e[6]=s,e[7]=l,e[8]=c,e[9]=u,e[10]=d,e[11]=f,e[12]=m,e[13]=p}else l=e[7],c=e[8],u=e[9],d=e[10],f=e[11],m=e[12],p=e[13];let h;return e[25]!==l||e[26]!==c||e[27]!==u||e[28]!==d||e[29]!==f||e[30]!==m||e[31]!==p?(h=a.jsxs("div",{className:l,children:[c,u,d,f,m,p]}),e[25]=l,e[26]=c,e[27]=u,e[28]=d,e[29]=f,e[30]=m,e[31]=p,e[32]=h):h=e[32],h}function SK(n){const e=q.c(55),{session:t,sessionSource:s,copied:r,creatingSession:o,onCopyResume:i,onNewSession:l,onDuplicateSession:c,onOpenTerminal:u}=n,{dispatch:d}=bn(),f=!!(t.cwd||s.dirName);let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=yo(),e[0]=m):m=e[0];const p=m;let h;e[1]!==t.sessionId||e[2]!==t.slug?(h=t.slug||t.sessionId.slice(0,8),e[1]=t.sessionId,e[2]=t.slug,e[3]=h):h=e[3];const g=h;let x;e[4]!==t.cwd||e[5]!==g?(x=t.cwd?`${rr(t.cwd)} / ${g}`:g,e[4]=t.cwd,e[5]=g,e[6]=x):x=e[6];const b=x;let y;e[7]!==t.cwd||e[8]!==s.dirName?(y={path:t.cwd,dirName:s.dirName},e[7]=t.cwd,e[8]=s.dirName,e[9]=y):y=e[9];const v=y;let k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=pt("hostFiles"),e[10]=k):k=e[10];const j=k;let _;e[11]===Symbol.for("react.memo_cache_sentinel")?(_=j&&(!p||X1()),e[11]=_):_=e[11];const N=_,S=j&&!p;let C;e[12]!==d||e[13]!==s.dirName?(C=function(){w.startTransition(()=>{d({type:"GO_HOME",isMobile:!1}),d({type:"SET_DASHBOARD_PROJECT",dirName:s.dirName})})},e[12]=d,e[13]=s.dirName,e[14]=C):C=e[14];const E=C,T=`Copy resume command for ${b}; open session actions with the context menu`;let A;e[15]!==i||e[16]!==T?(A=a.jsx("button",{type:"button",onClick:i,className:"flex min-w-0 max-w-80 items-center gap-1.5 truncate rounded-full px-1.5 py-1 text-sm font-medium text-foreground transition-colors hover:bg-accent","aria-label":T,"aria-haspopup":"menu",title:"Click to copy resume command. Right-click for session actions."}),e[15]=i,e[16]=T,e[17]=A):A=e[17];let P;e[18]!==r||e[19]!==t.cwd||e[20]!==g?(P=r?a.jsxs("span",{className:"flex items-center gap-1.5 text-success",children:[a.jsx(Ft,{className:"size-3"})," Copied"]}):a.jsxs(a.Fragment,{children:[t.cwd&&a.jsx("span",{className:"truncate text-muted-foreground",children:rr(t.cwd)}),t.cwd&&a.jsx("span",{className:"text-muted-foreground/50",children:"/"}),a.jsx("span",{className:"truncate",children:g})]}),e[18]=r,e[19]=t.cwd,e[20]=g,e[21]=P):P=e[21];let I;e[22]!==P||e[23]!==A?(I=a.jsx(xf,{render:A,children:P}),e[22]=P,e[23]=A,e[24]=I):I=e[24];let $;e[25]!==l||e[26]!==t.cwd||e[27]!==s.dirName?($=()=>l(s.dirName,t.cwd),e[25]=l,e[26]=t.cwd,e[27]=s.dirName,e[28]=$):$=e[28];let O;e[29]!==o?(O=o?a.jsx(An,{className:"size-3.5"}):a.jsx(tr,{className:"size-3.5"}),e[29]=o,e[30]=O):O=e[30];let M;e[31]!==o||e[32]!==$||e[33]!==O?(M=a.jsxs($n,{disabled:o,onClick:$,children:[O,"New session in this project"]}),e[31]=o,e[32]=$,e[33]=O,e[34]=M):M=e[34];let R;e[35]!==c?(R=c&&a.jsxs($n,{onClick:c,children:[a.jsx(ys,{className:"size-3.5"}),"Duplicate this session"]}),e[35]=c,e[36]=R):R=e[36];let z;e[37]!==f||e[38]!==v?(z=f&&(N||S)&&a.jsxs(a.Fragment,{children:[a.jsx(Di,{}),N&&a.jsxs($n,{onClick:()=>a4(v),children:[a.jsx(i1,{className:"size-3.5"}),"Open project in editor"]}),S&&a.jsxs($n,{onClick:()=>l4(v),children:[a.jsx(Ml,{className:"size-3.5"}),"Reveal in file manager"]})]}),e[37]=f,e[38]=v,e[39]=z):z=e[39];let W;e[40]!==u?(W=u&&!p&&pt("terminal")&&a.jsxs($n,{onClick:u,children:[a.jsx(Xi,{className:"size-3.5"}),"Open terminal in project"]}),e[40]=u,e[41]=W):W=e[41];let D;e[42]===Symbol.for("react.memo_cache_sentinel")?(D=a.jsx(Di,{}),e[42]=D):D=e[42];let L;e[43]===Symbol.for("react.memo_cache_sentinel")?(L=a.jsx(Tr,{className:"size-3.5"}),e[43]=L):L=e[43];let U;e[44]!==E?(U=a.jsxs($n,{onClick:E,children:[L,"View all sessions in this project"]}),e[44]=E,e[45]=U):U=e[45];let F;e[46]!==M||e[47]!==R||e[48]!==z||e[49]!==W||e[50]!==U?(F=a.jsxs(bf,{className:"min-w-56",children:[M,R,z,W,D,U]}),e[46]=M,e[47]=R,e[48]=z,e[49]=W,e[50]=U,e[51]=F):F=e[51];let B;return e[52]!==I||e[53]!==F?(B=a.jsxs(gf,{children:[I,F]}),e[52]=I,e[53]=F,e[54]=B):B=e[54],B}function kK(n){return n.thinking.length>0}const Sa="Could not reach the server";async function Hc(n,e){try{return await Re(n,e)}catch{return null}}function jK(){const n=q.c(15);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],n[0]=e):e=n[0];const[t,s]=w.useState(e),[r,o]=w.useState(null),i=w.useRef(!0);let l,c;n[1]===Symbol.for("react.memo_cache_sentinel")?(l=()=>(i.current=!0,()=>{i.current=!1}),c=[],n[1]=l,n[2]=c):(l=n[1],c=n[2]),w.useEffect(l,c);let u;n[3]===Symbol.for("react.memo_cache_sentinel")?(u=async()=>{const _=await Hc("/api/shares");if(!(_!=null&&_.ok))return;const N=await _.json().catch(EK);i.current&&Array.isArray(N)&&s(N)},n[3]=u):u=n[3];const d=u;let f,m;n[4]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{d()},m=[d],n[4]=f,n[5]=m):(f=n[4],m=n[5]),w.useEffect(f,m);let p;n[6]===Symbol.for("react.memo_cache_sentinel")?(p=async _=>{o(null);const N=await Hc("/api/shares",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:_})});if(!(N!=null&&N.ok))return i.current&&o(await Ja(N,Sa)),null;const S=await N.json().catch(_K);if(!(S!=null&&S.passphrase)||!S.share)return i.current&&o(Sa),null;const C=S.share;return i.current&&s(E=>[...E.filter(T=>T.sessionId!==C.sessionId),C]),S.passphrase},n[6]=p):p=n[6];const h=p;let g;n[7]===Symbol.for("react.memo_cache_sentinel")?(g=async _=>{o(null);const N=await Hc(`/api/shares/${encodeURIComponent(_)}/regenerate`,{method:"POST"});if(!(N!=null&&N.ok))return i.current&&o(await Ja(N,Sa)),null;const S=await N.json().catch(CK);return S!=null&&S.passphrase?(d(),S.passphrase):(i.current&&o(Sa),null)},n[7]=g):g=n[7];const x=g;let b;n[8]===Symbol.for("react.memo_cache_sentinel")?(b=async _=>{o(null);const N=await Hc(`/api/shares/${encodeURIComponent(_)}`,{method:"DELETE"});if(!(N!=null&&N.ok)){i.current&&o(await Ja(N,Sa));return}i.current&&s(S=>S.filter(C=>C.sessionId!==_))},n[8]=b):b=n[8];const y=b;let v;n[9]!==t?(v=async()=>{const _=t.map(NK);for(const N of _)await y(N)},n[9]=t,n[10]=v):v=n[10];const k=v;let j;return n[11]!==r||n[12]!==k||n[13]!==t?(j={shares:t,error:r,refresh:d,create:h,regenerate:x,revoke:y,revokeAll:k},n[11]=r,n[12]=k,n[13]=t,n[14]=j):j=n[14],j}function NK(n){return n.sessionId}function CK(){return null}function _K(){return null}function EK(){return null}const TK=5e3,AK="••••";function PK(n){return n===0?"No guests connected":n===1?"1 guest connected":`${n} guests connected`}function IK({sessionId:n}){const{config:{networkAccessDisabled:e}}=bn(),{shares:t,error:s,refresh:r,create:o,regenerate:i,revoke:l}=jK(),[c,u]=w.useState(!1),[d,f]=w.useState(null),[m,p]=w.useState(!1),[h,g]=Ar(),[x,b]=Ar(),y=t.find(_=>_.sessionId===n)??null,v=`${window.location.origin}${j9(n)}`;w.useEffect(()=>f(null),[n]),w.useEffect(()=>{if(!c)return;r();const _=setInterval(()=>void r(),TK);return()=>clearInterval(_)},[c,r]);async function k(_){p(!0);try{await _()}finally{p(!1)}}const j=e&&a.jsx("p",{className:"text-xs text-muted-foreground",children:"Network access is off, so this link only works on this machine."});return a.jsxs(na,{open:c,onOpenChange:_=>{u(_),_||f(null)},children:[a.jsx(sa,{render:a.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm","aria-label":y?"Session is shared":"Share session",className:G(y&&"bg-primary/15 text-primary hover:bg-primary/25")}),children:a.jsx(bP,{"data-icon":"inline-start"})}),a.jsx(ra,{align:"end",sideOffset:6,className:"w-80 p-3",children:y?a.jsxs("div",{className:"flex flex-col gap-2.5",children:[a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("code",{className:"min-w-0 flex-1 truncate rounded bg-muted px-2 py-1 font-mono text-[11px]",children:v}),a.jsx(ee,{variant:"ghost",size:"icon-xs","aria-label":"Copy link",onClick:()=>g(v),children:h?a.jsx(Ft,{"data-icon":"inline-start"}):a.jsx(ys,{"data-icon":"inline-start"})})]}),a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("code",{className:"min-w-0 flex-1 truncate rounded bg-muted px-2 py-1 font-mono text-[11px]",children:d??AK}),a.jsx(ee,{variant:"ghost",size:"icon-xs","aria-label":"Regenerate passphrase",disabled:m,onClick:()=>k(async()=>{f(await i(n))}),children:a.jsx(On,{"data-icon":"inline-start"})})]}),d?a.jsx(ee,{variant:"secondary",size:"xs",onClick:()=>b(`${v}
|
|
120
|
+
Passphrase: ${d}`),children:x?"Copied":"Copy link & passphrase"}):a.jsx("p",{className:"text-xs text-muted-foreground",children:"The passphrase is only shown once. Regenerate to get a new one."}),j,s&&a.jsx("p",{className:"text-xs text-destructive",children:s}),a.jsxs("div",{className:"flex items-center justify-between gap-2 border-t pt-2",children:[a.jsx("span",{className:"text-xs text-muted-foreground",children:PK(y.guests)}),a.jsx(ee,{variant:"ghost",size:"xs",className:"text-destructive hover:text-destructive",disabled:m,onClick:()=>k(async()=>{await l(n),f(null)}),children:"Stop sharing"})]})]}):a.jsxs("div",{className:"flex flex-col gap-2.5",children:[a.jsx("p",{className:"text-xs text-muted-foreground",children:"Anyone with the link and passphrase can read and join this session."}),j,s&&a.jsx("p",{className:"text-xs text-destructive",children:s}),a.jsx(ee,{size:"xs",disabled:m,onClick:()=>k(async()=>{f(await o(n))}),children:"Enable sharing"})]})})]})}function zx(n,e,t){if(!(n===void 0||!Number.isFinite(n)))return{utilization:Math.min(100,Math.max(0,n)),...e===void 0?{}:{resetsAt:e},...t===void 0?{}:{label:t}}}function kt(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)?n:void 0}function Ms(n){return typeof n=="number"&&Number.isFinite(n)?n:void 0}function so(n){return typeof n=="string"?n:void 0}function Jr(n){return n?zx(Ms(n.utilization),so(n.resets_at)):void 0}function k5(n){if(n)return{isEnabled:!!n.is_enabled,monthlyLimit:Ms(n.monthly_limit),usedCredits:Ms(n.used_credits),utilization:Ms(n.utilization)}}function $K(n){return{fiveHour:Jr(kt(n.five_hour)),sevenDay:Jr(kt(n.seven_day)),sevenDayOpus:Jr(kt(n.seven_day_opus)),sevenDaySonnet:Jr(kt(n.seven_day_sonnet)),extraUsage:k5(kt(n.extra_usage)),subscriptionType:so(n.subscriptionType)}}function RK(n){if(n.available!==!0)return null;const e=kt(n.usage),t=kt(e==null?void 0:e.rate_limits),s=kt(n.account),r={fiveHour:Jr(kt(t==null?void 0:t.five_hour)),sevenDay:Jr(kt(t==null?void 0:t.seven_day)),sevenDayOpus:Jr(kt(t==null?void 0:t.seven_day_opus)),sevenDaySonnet:Jr(kt(t==null?void 0:t.seven_day_sonnet)),extraUsage:k5(kt(t==null?void 0:t.extra_usage)),subscriptionType:so(e==null?void 0:e.subscription_type)??so(s==null?void 0:s.subscriptionType)};return r.fiveHour||r.sevenDay||r.extraUsage||r.subscriptionType?r:null}function OK(n){const e=Ms(n);if(e!==void 0)return new Date(e<1e10?e*1e3:e).toISOString()}function LK(n,e){const t=Ms(n);return t===void 0||t<=0?e:t%1440===0?`${t/1440}-day`:t%60===0?`${t/60}-hour`:`${t}-minute`}function m2(n,e){if(n)return zx(Ms(n.usedPercent),OK(n.resetsAt),LK(n.windowDurationMins,e))}function MK(n){var u,d,f;if(n.available!==!0)return null;const e=kt((u=kt(n.rateLimits))==null?void 0:u.rateLimits),t=kt((d=kt(n.account))==null?void 0:d.account),s=kt((f=kt(n.usage))==null?void 0:f.summary),r=kt(e==null?void 0:e.credits),o=m2(kt(e==null?void 0:e.primary),"Primary"),i=m2(kt(e==null?void 0:e.secondary),"Secondary"),l=s==null?void 0:s.lifetimeTokens,c=Ms(l)??(typeof l=="string"&&Number.isSafeInteger(Number(l))?Number(l):void 0);return!o&&!i&&c===void 0?null:{fiveHour:o,sevenDay:i,subscriptionType:so(e==null?void 0:e.planType)??so(t==null?void 0:t.planType),lifetimeTokens:c,creditBalance:so(r==null?void 0:r.balance),creditsUnlimited:(r==null?void 0:r.unlimited)===!0}}function p2(n,e){if(!n)return;const t=Ms(n.remainingPercentage),s=Ms(n.usedRequests),r=Ms(n.entitlementRequests);let o;return t!==void 0?o=100-t:n.isUnlimitedEntitlement===!0||r===-1?o=0:s!==void 0&&r!==void 0&&r>0&&(o=s/r*100),zx(o,so(n.resetDate),e)}function zK(n){var s;if(n.available!==!0)return null;const e=kt((s=kt(n.quota))==null?void 0:s.quotaSnapshots),t=p2(kt(e==null?void 0:e.chat),"Chat")??p2(kt(e==null?void 0:e.premium_interactions),"Premium interactions");return t?{fiveHour:t}:null}const DK={claude:{endpoint:"/api/claude/runtime",read:RK,legacy:{endpoint:"/api/usage",read:$K}},codex:{endpoint:"/api/codex/runtime",read:MK},copilot:{endpoint:"/api/copilot/runtime",read:zK}};function FK(n){return DK[n]}const UK=300*1e3;function BK(n=Go){const e=mn("viewUsage"),[t,s]=w.useState(null),[r,o]=w.useState(!1),[i,l]=w.useState(!1),c=w.useRef(0),u=w.useRef(null),d=w.useCallback(async()=>{var h;if(!e)return;const f=++c.current;(h=u.current)==null||h.abort();const m=new AbortController;u.current=m;const p=()=>c.current===f&&!m.signal.aborted;o(!0);try{const g=FK(n);let x=await Re(g.endpoint,{signal:m.signal}),b=g.read;if(g.legacy&&!x.ok&&!m.signal.aborted&&(x=await Re(g.legacy.endpoint,{signal:m.signal}),b=g.legacy.read),!p())return;if(x.status===501||x.status===404){l(!1);return}if(!x.ok){l(!0);return}const y=await x.json();if(!p())return;const v=b(y);l(v!==null),s(v?{...v,agentKind:n,fetchedAt:Date.now()}:null)}catch{}finally{p()&&(u.current=null,o(!1))}},[n,e]);return w.useEffect(()=>{var m;if(s(null),l(!1),!e){o(!1),c.current+=1,(m=u.current)==null||m.abort(),u.current=null;return}d();const f=setInterval(d,UK);return()=>{var p;clearInterval(f),c.current+=1,(p=u.current)==null||p.abort(),u.current=null}},[n,e,d]),{usage:e?t:null,loading:e&&r,available:e&&i,refresh:d}}function j5(n){return n>=90?"danger":n>=80?"warning":n>=60?"caution":"nominal"}const N5={nominal:"text-muted-foreground",caution:"text-warning",warning:"text-warning",danger:"text-destructive"};function WK(n){var u;const e=q.c(31),{usage:t}=n;let s,r,o;if(e[0]!==t.agentKind||e[1]!==t.fetchedAt||e[2]!==t.fiveHour||e[3]!==t.sevenDay||e[4]!==t.sevenDayOpus||e[5]!==t.sevenDaySonnet||e[6]!==t.subscriptionType){const d=[];t.fiveHour&&d.push({label:t.fiveHour.label??"5-hour",pct:t.fiveHour.utilization,resetsAt:t.fiveHour.resetsAt}),t.sevenDay&&d.push({label:t.sevenDay.label??"7-day",pct:t.sevenDay.utilization,resetsAt:t.sevenDay.resetsAt}),t.sevenDayOpus&&d.push({label:"Opus",pct:t.sevenDayOpus.utilization,resetsAt:t.sevenDayOpus.resetsAt}),t.sevenDaySonnet&&d.push({label:"Sonnet",pct:t.sevenDaySonnet.utilization,resetsAt:t.sevenDaySonnet.resetsAt}),s="flex min-w-[200px] flex-col gap-2";let f;e[10]!==t.agentKind?(f=t.agentKind?Hd(t.agentKind):"Agent",e[10]=t.agentKind,e[11]=f):f=e[11];let m;e[12]!==f?(m=a.jsxs("span",{className:"text-xs font-medium uppercase tracking-wide",children:[f," usage"]}),e[12]=f,e[13]=m):m=e[13];let p;e[14]!==t.subscriptionType?(p=t.subscriptionType&&a.jsx(Ue,{variant:"secondary",children:t.subscriptionType}),e[14]=t.subscriptionType,e[15]=p):p=e[15],e[16]!==m||e[17]!==p?(r=a.jsxs("div",{className:"flex items-center justify-between",children:[m,p]}),e[16]=m,e[17]=p,e[18]=r):r=e[18],o=d.map(h=>{const g=h.resetsAt&&t.fetchedAt!=null?new Date(h.resetsAt).getTime()-t.fetchedAt:null,x=g!=null?Math.max(0,Math.round(g/36e5)):null,b=j5(h.pct);return a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsxs("div",{className:"flex items-center justify-between text-xs",children:[a.jsx("span",{className:"text-muted-foreground",children:h.label}),a.jsxs("span",{className:G("font-semibold",N5[b]),children:[h.pct.toFixed(1),"%"]})]}),a.jsx(Xl,{value:Math.min(h.pct,100)}),x!=null&&a.jsxs("div",{className:"text-xs text-muted-foreground",children:["Resets in ",x,"h"]})]},h.label)}),e[0]=t.agentKind,e[1]=t.fetchedAt,e[2]=t.fiveHour,e[3]=t.sevenDay,e[4]=t.sevenDayOpus,e[5]=t.sevenDaySonnet,e[6]=t.subscriptionType,e[7]=s,e[8]=r,e[9]=o}else s=e[7],r=e[8],o=e[9];let i;e[19]!==t.extraUsage?(i=((u=t.extraUsage)==null?void 0:u.isEnabled)&&t.extraUsage.usedCredits!=null&&t.extraUsage.monthlyLimit!=null&&a.jsxs("div",{className:"flex flex-col gap-1 pt-1 text-xs text-muted-foreground",children:[a.jsx(Gt,{}),"Extra: $",t.extraUsage.usedCredits.toFixed(2)," / $",t.extraUsage.monthlyLimit.toFixed(2)]}),e[19]=t.extraUsage,e[20]=i):i=e[20];let l;e[21]!==t.creditBalance||e[22]!==t.creditsUnlimited||e[23]!==t.lifetimeTokens?(l=(t.lifetimeTokens!=null||t.creditBalance||t.creditsUnlimited)&&a.jsxs("div",{className:"flex flex-col gap-1 pt-1 text-xs text-muted-foreground",children:[a.jsx(Gt,{}),t.lifetimeTokens!=null&&a.jsxs("div",{children:["Lifetime: ",Nt(t.lifetimeTokens)," tokens"]}),t.creditsUnlimited?a.jsx("div",{children:"Credits: Unlimited"}):t.creditBalance?a.jsxs("div",{children:["Credits: ",t.creditBalance]}):null]}),e[21]=t.creditBalance,e[22]=t.creditsUnlimited,e[23]=t.lifetimeTokens,e[24]=l):l=e[24];let c;return e[25]!==s||e[26]!==r||e[27]!==o||e[28]!==i||e[29]!==l?(c=a.jsxs("div",{className:s,children:[r,o,i,l]}),e[25]=s,e[26]=r,e[27]=o,e[28]=i,e[29]=l,e[30]=c):c=e[30],c}function qK(n){var k,j;const e=q.c(22),{agentKind:t}=n,s=t===void 0?Go:t,{usage:r,loading:o,available:i,refresh:l}=BK(s);if(!i||!r)return null;const c=((k=r.fiveHour)==null?void 0:k.utilization)??((j=r.sevenDay)==null?void 0:j.utilization);if(c==null)return null;let u;e[0]!==r.agentKind?(u=r.agentKind?Hd(r.agentKind):"agent",e[0]=r.agentKind,e[1]=u):u=e[1];const d=`Refresh ${u} usage`;let f;e[2]!==o||e[3]!==l||e[4]!==d?(f=a.jsx(ee,{type:"button",variant:"ghost",size:"xs","aria-label":d,onClick:l,disabled:o,className:"mr-1 font-mono"}),e[2]=o,e[3]=l,e[4]=d,e[5]=f):f=e[5];const m=N5[j5(c)],p=o&&"opacity-50";let h;e[6]!==m||e[7]!==p?(h=G("tabular-nums",m,p),e[6]=m,e[7]=p,e[8]=h):h=e[8];let g;e[9]!==c?(g=c.toFixed(0),e[9]=c,e[10]=g):g=e[10];let x;e[11]!==h||e[12]!==g?(x=a.jsxs("span",{className:h,children:[g,"%"]}),e[11]=h,e[12]=g,e[13]=x):x=e[13];let b;e[14]!==f||e[15]!==x?(b=a.jsx(Yt,{render:f,children:x}),e[14]=f,e[15]=x,e[16]=b):b=e[16];let y;e[17]!==r?(y=a.jsx(Xt,{side:"bottom",className:"p-3",children:a.jsx(WK,{usage:r})}),e[17]=r,e[18]=y):y=e[18];let v;return e[19]!==b||e[20]!==y?(v=a.jsxs(Zt,{children:[b,y]}),e[19]=b,e[20]=y,e[21]=v):v=e[21],v}function VK(n){const e=q.c(9);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={summary:null,loading:!1,error:null},e[0]=t):t=e[0];const[s,r]=w.useState(t),[o,i]=w.useState(0);let l;e[1]!==n?(l=()=>{const m=new AbortController;r(KK);const p=Intl.DateTimeFormat().resolvedOptions().timeZone;return Re(`/api/usage-cost?days=${n}&tz=${encodeURIComponent(p)}`,{signal:m.signal}).then(async h=>{if(!h.ok)throw new Error(`Usage scan failed (${h.status})`);const g=await h.json();r({summary:g,loading:!1,error:null})}).catch(h=>{m.signal.aborted||r(g=>({...g,loading:!1,error:h instanceof Error?h.message:"Usage scan failed"}))}),()=>m.abort()},e[1]=n,e[2]=l):l=e[2];let c;e[3]!==n||e[4]!==o?(c=[n,o],e[3]=n,e[4]=o,e[5]=c):c=e[5],w.useEffect(l,c);let u;e[6]===Symbol.for("react.memo_cache_sentinel")?(u=()=>i(HK),e[6]=u):u=e[6];const d=u;let f;return e[7]!==s?(f={...s,refresh:d},e[7]=s,e[8]=f):f=e[8],f}function HK(n){return n+1}function KK(n){return{...n,loading:!0,error:null}}function GK(n){const e=n.trim().toLowerCase().replace(/\[[^\]]*\]$/,""),t=e.lastIndexOf("/");return t===-1?e:e.slice(t+1)}const ZK=new Set(["<synthetic>","synthetic","opus","sonnet","haiku","fable"]);function YK(n,e){const t=GK(e);return t.length===0||ZK.has(t)?null:n.get(t)??null}function XK(n,e){const t=n.longContextThresholdTokens,s=e.uncachedInputTokens+e.cachedInputTokens+e.cacheCreationTokens,r=t!==null&&s>t;return function(i,l,c){return i<=0?0:c===null||t===null?i*l:n.longContextPricing==="wholeRequest"?i*(r?c:l):i<=t?i*l:t*l+(i-t)*c}}function JK(n){return n.uncachedInputUsd+n.cachedInputUsd+n.cacheCreationUsd+n.outputUsd}function QK(n,e,t,s=null){const r=YK(n,e);if(r===null)return null;const o=Math.min(t.cacheCreation1hTokens,t.cacheCreationTokens),i=t.cacheCreationTokens-o,l=XK(r,t),c=s==="fast"?r.fastCostMultiplier:1;return{uncachedInputUsd:c*l(t.uncachedInputTokens,r.inputCostPerToken,r.inputCostPerTokenAboveThreshold),cachedInputUsd:c*l(t.cachedInputTokens,r.cacheReadCostPerToken,r.cacheReadCostPerTokenAboveThreshold),cacheCreationUsd:c*(l(i,r.cacheCreationCostPerToken,r.cacheCreationCostPerTokenAboveThreshold)+o*r.cacheCreation1hCostPerToken),outputUsd:c*l(t.outputTokens,r.outputCostPerToken,r.outputCostPerTokenAboveThreshold)}}function eG(n,e,t,s,r=null){const o=QK(n,e,t,r);return o===null?{costUsd:0,costSource:"unpriced"}:{costUsd:JK(o),costSource:"modelPriced"}}function Dx(n){return n.uncachedInputTokens+n.cachedInputTokens+n.cacheCreationTokens+n.outputTokens}function tG(n,e,t){if(!e)return 0;const{costUsd:s,costSource:r}=eG(n,e,{uncachedInputTokens:t.input_tokens,cachedInputTokens:t.cache_read_input_tokens??0,cacheCreationTokens:t.cache_creation_input_tokens??0,cacheCreation1hTokens:0,outputTokens:t.output_tokens});return r==="unpriced"?0:s}const nG=[{days:7,label:"7 days"},{days:30,label:"30 days"},{days:90,label:"90 days"}],el=vj.map(n=>({key:n,label:us(n).displayName,color:wR(n)}));function sG(n,e){const t=[],r=Date.parse(`${e}T00:00:00Z`);for(let o=Date.parse(`${n}T00:00:00Z`);o<=r;o+=864e5)t.push(new Date(o).toISOString().slice(0,10));return t}function h2(){return{claude:{costUsd:0,tokens:0},codex:{costUsd:0,tokens:0},copilot:{costUsd:0,tokens:0}}}function rG(n){const e=new Map;for(const r of sG(n.sinceDay,n.untilDay))e.set(r,{day:r,byProvider:h2(),costUsd:0,tokens:0});const t=new Map,s={costUsd:0,tokens:0,cacheSavingsUsd:0,byProvider:h2(),days:[],models:[]};for(const r of n.buckets){const o=Dx(r.totals);s.costUsd+=r.costUsd,s.tokens+=o,s.cacheSavingsUsd+=r.cacheSavingsUsd,s.byProvider[r.provider].costUsd+=r.costUsd,s.byProvider[r.provider].tokens+=o;const i=e.get(r.day);i&&(i.byProvider[r.provider].costUsd+=r.costUsd,i.byProvider[r.provider].tokens+=o,i.costUsd+=r.costUsd,i.tokens+=o);const l=`${r.provider}:${r.model}`;let c=t.get(l);c||(c={provider:r.provider,model:r.model,costUsd:0,tokens:0,unpriced:!0},t.set(l,c)),c.costUsd+=r.costUsd,c.tokens+=o,r.costSource!=="unpriced"&&(c.unpriced=!1)}return s.days=[...e.values()],s.models=[...t.values()].sort((r,o)=>o.costUsd-r.costUsd||o.tokens-r.tokens),s}function g2(n){const e=Date.parse(`${n}T00:00:00Z`);return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",timeZone:"UTC"}).format(e)}const Em=720,Tm=180,oG=18;function iG(n){const e=q.c(41),{days:t,metric:s}=n,[r,o]=w.useState(null);let i;e[0]!==s?(i=N=>s==="cost"?N.costUsd:N.tokens,e[0]=s,e[1]=i):i=e[1];const l=i;let c;if(e[2]!==t||e[3]!==l){let N;e[5]!==l?(N=S=>l(S),e[5]=l,e[6]=N):N=e[6],c=Math.max(...t.map(N)),e[2]=t,e[3]=l,e[4]=c}else c=e[4];const u=c;if(u<=0){let N;return e[7]===Symbol.for("react.memo_cache_sentinel")?(N=a.jsx("div",{className:"flex h-32 items-center justify-center text-xs text-muted-foreground",children:"No activity in this window."}),e[7]=N):N=e[7],N}const d=Tm-oG,f=Em/t.length,m=Math.max(2,Math.min(28,f-2)),p=r!==null?t[r]:null;let h;e[8]!==p||e[9]!==s||e[10]!==l?(h=p&&a.jsx("div",{className:"pointer-events-none absolute left-0 right-0 top-0 z-10 flex justify-center",children:a.jsxs("div",{className:"rounded-md border bg-popover px-2.5 py-1.5 text-xs text-popover-foreground shadow-xs",children:[a.jsx("span",{className:"font-medium",children:g2(p.day)}),el.map(N=>{const{key:S,label:C,color:E}=N,T=p.byProvider[S];return l(T)<=0?null:a.jsxs("span",{className:"ml-2 inline-flex items-center gap-1 text-muted-foreground",children:[a.jsx("span",{"aria-hidden":!0,className:"size-1.5 rounded-full",style:{backgroundColor:E}}),C,": ",s==="cost"?ms(T.costUsd):Nt(T.tokens)]},S)}),a.jsx("span",{className:"ml-2 font-medium",children:s==="cost"?ms(p.costUsd):Nt(p.tokens)})]})}),e[8]=p,e[9]=s,e[10]=l,e[11]=h):h=e[11];const g=`Daily ${s==="cost"?"raw API cost":"processed tokens"} by provider`;let x,b;e[12]===Symbol.for("react.memo_cache_sentinel")?(x=()=>o(null),b=a.jsx("line",{x1:0,y1:d,x2:Em,y2:d,stroke:"var(--border)",strokeWidth:1}),e[12]=x,e[13]=b):(x=e[12],b=e[13]);let y;if(e[14]!==m||e[15]!==t||e[16]!==r||e[17]!==u||e[18]!==f||e[19]!==l){let N;e[21]!==m||e[22]!==r||e[23]!==u||e[24]!==f||e[25]!==l?(N=(S,C)=>{const E=C*f+(f-m)/2;let T=d;const A=r===C;return a.jsxs("g",{onMouseEnter:()=>o(C),children:[a.jsx("rect",{x:C*f,y:0,width:f,height:d,fill:"transparent"}),A&&a.jsx("rect",{x:C*f,y:0,width:f,height:d,fill:"var(--foreground)",opacity:.05,rx:2}),el.map(P=>{const{key:I,color:$}=P,O=l(S.byProvider[I]);if(O<=0)return null;const M=O/u*(d-6);return T=T-M,a.jsx("rect",{x:E,y:T,width:m,height:Math.max(1,M-1.5),rx:1.5,fill:$,opacity:A?1:.85},I)})]},S.day)},e[21]=m,e[22]=r,e[23]=u,e[24]=f,e[25]=l,e[26]=N):N=e[26],y=t.map(N),e[14]=m,e[15]=t,e[16]=r,e[17]=u,e[18]=f,e[19]=l,e[20]=y}else y=e[20];let v;if(e[27]!==t||e[28]!==f){let N;e[30]!==t.length||e[31]!==f?(N=(S,C)=>C===0||C===t.length-1||t.length>10&&C%7===0&&C<t.length-3?a.jsx("text",{x:C*f+f/2,y:Tm-4,textAnchor:"middle",className:"fill-muted-foreground text-[10px]",children:g2(S.day)},S.day):null,e[30]=t.length,e[31]=f,e[32]=N):N=e[32],v=t.map(N),e[27]=t,e[28]=f,e[29]=v}else v=e[29];let k;e[33]!==g||e[34]!==y||e[35]!==v?(k=a.jsxs("svg",{viewBox:`0 0 ${Em} ${Tm}`,className:"w-full",role:"img","aria-label":g,onMouseLeave:x,children:[b,y,v]}),e[33]=g,e[34]=y,e[35]=v,e[36]=k):k=e[36];let j;e[37]===Symbol.for("react.memo_cache_sentinel")?(j=a.jsx("div",{className:"mt-1 flex items-center gap-4",children:el.map(aG)}),e[37]=j):j=e[37];let _;return e[38]!==h||e[39]!==k?(_=a.jsxs("div",{className:"relative",children:[h,k,j]}),e[38]=h,e[39]=k,e[40]=_):_=e[40],_}function aG(n){const{key:e,label:t,color:s}=n;return a.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[a.jsx("span",{"aria-hidden":!0,className:"size-2 rounded-full",style:{backgroundColor:s}}),t]},e)}function Am(n){const e=q.c(7),{label:t,value:s}=n;let r;e[0]!==t?(r=a.jsx("span",{className:"text-xs text-muted-foreground",children:t}),e[0]=t,e[1]=r):r=e[1];let o;e[2]!==s?(o=a.jsx("span",{className:"text-sm font-medium text-foreground tabular-nums",children:s}),e[2]=s,e[3]=o):o=e[3];let i;return e[4]!==r||e[5]!==o?(i=a.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[r,o]}),e[4]=r,e[5]=o,e[6]=i):i=e[6],i}function lG(n){const e=q.c(68),{days:t}=n,{summary:s,loading:r,error:o,refresh:i}=VK(t),[l,c]=w.useState("cost");let u;e[0]!==s?(u=s?rG(s):null,e[0]=s,e[1]=u):u=e[1];const d=u;if(o){let D;e[2]!==i?(D=a.jsx(ee,{variant:"outline",size:"sm",onClick:i,children:"Retry"}),e[2]=i,e[3]=D):D=e[3];let L;return e[4]!==o||e[5]!==D?(L=a.jsxs("div",{className:"flex flex-col items-center gap-2 py-10 text-sm text-muted-foreground",children:[o,D]}),e[4]=o,e[5]=D,e[6]=L):L=e[6],L}if(!d||!s){let D;return e[7]===Symbol.for("react.memo_cache_sentinel")?(D=a.jsxs("div",{className:"flex items-center justify-center gap-2 py-16 text-sm text-muted-foreground",children:[a.jsx(An,{className:"size-4"})," Scanning transcripts…"]}),e[7]=D):D=e[7],D}const f=r&&"opacity-60";let m;e[8]!==f?(m=G("flex flex-col gap-5",f),e[8]=f,e[9]=m):m=e[9];let p;e[10]!==d.costUsd||e[11]!==d.tokens||e[12]!==l?(p=l==="cost"?ms(d.costUsd):Nt(d.tokens),e[10]=d.costUsd,e[11]=d.tokens,e[12]=l,e[13]=p):p=e[13];let h;e[14]!==p?(h=a.jsx("span",{className:"text-3xl font-semibold text-foreground tabular-nums",children:p}),e[14]=p,e[15]=h):h=e[15];const g=l==="cost"?"raw API price":"processed tokens";let x;e[16]!==s.distinctSessions||e[17]!==g?(x=a.jsxs("span",{className:"text-xs text-muted-foreground",children:[s.distinctSessions," sessions · ",g]}),e[16]=s.distinctSessions,e[17]=g,e[18]=x):x=e[18];let b;e[19]!==h||e[20]!==x?(b=a.jsxs("div",{className:"flex flex-col gap-0.5",children:[h,x]}),e[19]=h,e[20]=x,e[21]=b):b=e[21];let y;e[22]===Symbol.for("react.memo_cache_sentinel")?(y=["cost","tokens"],e[22]=y):y=e[22];let v;e[23]!==l?(v=a.jsx("div",{className:"flex rounded-md border p-0.5",children:y.map(D=>a.jsx(ee,{variant:l===D?"secondary":"ghost",size:"xs",onClick:()=>c(D),children:D==="cost"?"Cost":"Tokens"},D))}),e[23]=l,e[24]=v):v=e[24];let k;e[25]!==d.byProvider||e[26]!==l?(k=el.map(D=>{const{key:L,label:U}=D,F=d.byProvider[L];return F.costUsd===0&&F.tokens===0?null:a.jsxs("span",{className:"text-xs text-muted-foreground tabular-nums",children:[U,": ",l==="cost"?ms(F.costUsd):Nt(F.tokens)]},L)}),e[25]=d.byProvider,e[26]=l,e[27]=k):k=e[27];let j;e[28]!==v||e[29]!==k?(j=a.jsxs("div",{className:"flex flex-col items-end gap-1.5",children:[v,k]}),e[28]=v,e[29]=k,e[30]=j):j=e[30];let _;e[31]!==j||e[32]!==b?(_=a.jsxs("div",{className:"flex items-end justify-between gap-4",children:[b,j]}),e[31]=j,e[32]=b,e[33]=_):_=e[33];let N;e[34]!==d.days||e[35]!==l?(N=a.jsx(iG,{days:d.days,metric:l}),e[34]=d.days,e[35]=l,e[36]=N):N=e[36];let S;e[37]!==d.tokens?(S=Nt(d.tokens),e[37]=d.tokens,e[38]=S):S=e[38];let C;e[39]!==S?(C=a.jsx(Am,{label:"Processed tokens",value:S}),e[39]=S,e[40]=C):C=e[40];let E;e[41]!==d.cacheSavingsUsd?(E=ms(d.cacheSavingsUsd),e[41]=d.cacheSavingsUsd,e[42]=E):E=e[42];let T;e[43]!==E?(T=a.jsx(Am,{label:"Cache savings",value:E}),e[43]=E,e[44]=T):T=e[44];const A=String(s.scannedFiles);let P;e[45]!==A?(P=a.jsx(Am,{label:"Files scanned",value:A}),e[45]=A,e[46]=P):P=e[46];let I;e[47]!==C||e[48]!==T||e[49]!==P?(I=a.jsxs("div",{className:"grid grid-cols-3 gap-x-6 gap-y-3 border-t pt-3",children:[C,T,P]}),e[47]=C,e[48]=T,e[49]=P,e[50]=I):I=e[50];let $;e[51]===Symbol.for("react.memo_cache_sentinel")?($=a.jsx("thead",{children:a.jsxs("tr",{className:"border-b text-left text-xs text-muted-foreground",children:[a.jsx("th",{className:"py-1.5 font-normal",children:"Model"}),a.jsx("th",{className:"py-1.5 text-right font-normal",children:"Cost"}),a.jsx("th",{className:"py-1.5 text-right font-normal",children:"Share"}),a.jsx("th",{className:"py-1.5 text-right font-normal",children:"Tokens"})]})}),e[51]=$):$=e[51];let O;if(e[52]!==d.costUsd||e[53]!==d.models){let D;e[55]!==d.costUsd?(D=L=>{var U;return a.jsxs("tr",{className:"border-b border-border/50",children:[a.jsx("td",{className:"max-w-56 truncate py-1.5 text-foreground",children:a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("span",{"aria-hidden":!0,className:"size-2 shrink-0 rounded-full",style:{backgroundColor:(U=el.find(F=>F.key===L.provider))==null?void 0:U.color}}),L.model]})}),a.jsx("td",{className:"py-1.5 text-right text-foreground tabular-nums",children:L.unpriced?"—":ms(L.costUsd)}),a.jsx("td",{className:"py-1.5 text-right text-muted-foreground tabular-nums",children:d.costUsd>0&&!L.unpriced?`${(L.costUsd/d.costUsd*100).toFixed(1)}%`:"—"}),a.jsx("td",{className:"py-1.5 text-right text-muted-foreground tabular-nums",children:Nt(L.tokens)})]},`${L.provider}:${L.model}`)},e[55]=d.costUsd,e[56]=D):D=e[56],O=d.models.map(D),e[52]=d.costUsd,e[53]=d.models,e[54]=O}else O=e[54];let M;e[57]!==O?(M=a.jsxs("table",{className:"w-full text-sm",children:[$,a.jsx("tbody",{children:O})]}),e[57]=O,e[58]=M):M=e[58];const R=s.pricing.status==="unavailable"?" (rate table unavailable — costs incomplete)":"";let z;e[59]!==R?(z=a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Raw API-equivalent prices from LiteLLM rates",R," ","— not what a subscription bills."]}),e[59]=R,e[60]=z):z=e[60];let W;return e[61]!==_||e[62]!==N||e[63]!==I||e[64]!==M||e[65]!==z||e[66]!==m?(W=a.jsxs("div",{className:m,children:[_,N,I,M,z]}),e[61]=_,e[62]=N,e[63]=I,e[64]=M,e[65]=z,e[66]=m,e[67]=W):W=e[67],W}function cG(n){const e=q.c(15),{open:t,onOpenChange:s}=n,[r,o]=w.useState(30);let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsxs("div",{children:[a.jsx(mr,{children:"API usage"}),a.jsx(pr,{children:"What this machine's agent usage would cost at raw API prices."})]}),e[0]=i):i=e[0];let l;e[1]!==r?(l=nG.map(m=>a.jsx(ee,{variant:r===m.days?"secondary":"ghost",size:"xs",onClick:()=>o(m.days),children:m.label},m.days)),e[1]=r,e[2]=l):l=e[2];let c;e[3]!==l?(c=a.jsx(wo,{children:a.jsxs("div",{className:"flex items-center justify-between gap-4 pr-6",children:[i,a.jsx("div",{className:"flex rounded-md border p-0.5",children:l})]})}),e[3]=l,e[4]=c):c=e[4];let u;e[5]!==r||e[6]!==t?(u=t&&a.jsx(lG,{days:r}),e[5]=r,e[6]=t,e[7]=u):u=e[7];let d;e[8]!==c||e[9]!==u?(d=a.jsxs(fr,{className:"max-h-[85vh] overflow-y-auto sm:max-w-3xl",children:[c,u]}),e[8]=c,e[9]=u,e[10]=d):d=e[10];let f;return e[11]!==s||e[12]!==t||e[13]!==d?(f=a.jsx(dr,{open:t,onOpenChange:s,children:d}),e[11]=s,e[12]=t,e[13]=d,e[14]=f):f=e[14],f}async function uG(n,e){try{return(await ws("/api/archive-sessions",{sessionIds:n,archived:e})).ok}catch{return!1}}function C5(){const n=ac(),e=n==null?void 0:n.setArchived,t=n==null?void 0:n.refresh,s=w.useCallback(async(r,o,i)=>{if(e==null||e(r,o),!await uG([...r],o)){e==null||e(r,!o),Bn.error(o?"Could not archive session":"Could not restore session");return}t==null||t(),i&&Bn(i,{action:{label:"Undo",onClick:()=>{s(r,!o,null)}}})},[e,t]);return s}function _5(n,e,t){const s=q.c(13),r=ac(),o=C5();if(!r||!t)return null;let i;s[0]!==r||s[1]!==n?(i=r.isArchived(n),s[0]=r,s[1]=n,s[2]=i):i=s[2];const l=i,c=l?"Restore from archive":"Archive session",u=l?zd:gs,d=e&&!l?"Stop the session before archiving it":void 0;let f;s[3]!==o||s[4]!==l||s[5]!==n?(f=()=>{o([n],!l,l?"Session restored":"Session archived")},s[3]=o,s[4]=l,s[5]=n,s[6]=f):f=s[6];let m;return s[7]!==l||s[8]!==c||s[9]!==u||s[10]!==d||s[11]!==f?(m={archived:l,label:c,icon:u,disabledReason:d,toggle:f},s[7]=l,s[8]=c,s[9]=u,s[10]=d,s[11]=f,s[12]=m):m=s[12],m}const dG=/https:\/\/github\.com\/([\w.-]+)\/([\w.-]+)\/pull\/(\d+)/,fG=/(?:^|[\n;&|(`])[ \t]*(?:[A-Za-z_]\w*=\S*[ \t]+)*gh[ \t]+pr[ \t]+create\b/,Pm=String.raw`(?:--title|(?:^|\s)-t)(?:=|\s+)`,mG=[new RegExp(`${Pm}"((?:[^"\\\\]|\\\\.)*)"`),new RegExp(`${Pm}'([^']*)'`),new RegExp(`${Pm}(\\S+)`)];function pG(n){const e=n.command??n.cmd;if(typeof e=="string")return[e];if(Array.isArray(e)){const i=e.filter(l=>typeof l=="string");return[i.join(" "),...i]}const t=n.source;if(typeof t!="string")return[];const s=[],r=/(?:["'](?:cmd|command)["']|\b(?:cmd|command))\s*:\s*"((?:\\.|[^"\\])*)"/g;for(const i of t.matchAll(r))try{s.push(JSON.parse(`"${i[1]}"`))}catch{}const o=/(?:["'](?:cmd|command)["']|\b(?:cmd|command))\s*:\s*`([^`]*)`/g;for(const i of t.matchAll(o))s.push(i[1]);return s}function hG(n){return pG(n).find(e=>fG.test(e))??null}function gG(n){for(const e of mG){const t=e.exec(n);if(t)return t[1].replace(/\\(.)/g,"$1")}return null}function xG(){const n=[],e=new Set;function t(s){e.has(s.url)||(e.add(s.url),n.push(s))}return{pullRequests:n,add:t,record(s,r,o,i){const l=dG.exec(s);l&&t({url:l[0],number:Number(l[3]),repo:`${l[1]}/${l[2]}`,title:gG(r),isDraft:/(?:^|\s)--draft(?:\s|$)/.test(r),toolCallId:o,timestamp:i})}}}function bG(n){const e=xG();for(const t of n)for(const s of t.toolCalls){if(s.isError||!s.result)continue;const r=hG(s.input);r&&e.record(s.result,r,s.id,s.timestamp)}return e.pullRequests}function vG(...n){const e=new Map;for(const t of n)for(const s of t??[])e.has(s.url)||e.set(s.url,s);return[...e.values()].sort((t,s)=>t.timestamp.localeCompare(s.timestamp))}const Ur="flex h-8 items-center px-0.5",yG=w.memo(function(e){var Xe;const t=q.c(113),{showSidebar:s,sidebarRendered:r,sidebarShortcut:o,killing:i,creatingSession:l,onNewSession:c,onDuplicateSession:u,onOpenTerminal:d,onBackToMain:f,onShowWorkflows:m,workflowCount:p,onToggleSidebar:h,onKillAll:g,onOpenSettings:x,onLogout:b,onOpenMainView:y}=e,v=r===void 0?s:r,{config:k}=bn(),{networkUrl:j,defaultAgentKind:_}=k,{session:N,sessionSource:S,isLive:C,permissions:E}=xt(),T=ac(),{AccountControl:A,SessionHeaderActions:P}=ur(),I=mn("viewUsage"),[$,O]=w.useState(!1),[M,R]=w.useState(!1),[z,W]=Ar(),D=N==null?void 0:N.turns;let L;t[0]!==(T==null?void 0:T.sessions)||t[1]!==(N==null?void 0:N.sessionId)?(L=(Xe=T==null?void 0:T.sessions.find(nt=>nt.sessionId===(N==null?void 0:N.sessionId)))==null?void 0:Xe.pullRequests,t[0]=T==null?void 0:T.sessions,t[1]=N==null?void 0:N.sessionId,t[2]=L):L=t[2];const U=L;let F;t[3]!==U||t[4]!==D?(F=vG(bG(D??[]),U),t[3]=U,t[4]=D,t[5]=F):F=t[5];const B=F,V=_5((N==null?void 0:N.sessionId)??"",C,E.archive);let H;t[6]!==_||t[7]!==S?(H=S?S.agentKind??nn(S.dirName):_,t[6]=_,t[7]=S,t[8]=H):H=t[8];const K=H;let Z;t[9]!==S?(Z=S?lo(S.fileName)!==null:!1,t[9]=S,t[10]=Z):Z=t[10];const Y=Z;let X;t[11]!==W||t[12]!==N||t[13]!==(S==null?void 0:S.agentKind)||t[14]!==(S==null?void 0:S.dirName)?(X=function(){if(!N)return;const Qe=(S==null?void 0:S.agentKind)??nn((S==null?void 0:S.dirName)??null);W(y1(Qe,N.sessionId,N.cwd))},t[11]=W,t[12]=N,t[13]=S==null?void 0:S.agentKind,t[14]=S==null?void 0:S.dirName,t[15]=X):X=t[15];const se=X;let Q;t[16]!==j?(Q=function(){j&&Vd(j).then(wG)},t[16]=j,t[17]=Q):Q=t[17];const te=Q;let J,ne;t[18]===Symbol.for("react.memo_cache_sentinel")?(ne=a.jsx("div",{"aria-hidden":!0,className:"drag-strip absolute inset-x-0 top-0 z-10 h-10"}),J=a.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-x-0 top-0 z-20 h-16 bg-gradient-to-b from-background from-50% to-transparent"}),t[18]=J,t[19]=ne):(J=t[18],ne=t[19]);const re=!v&&"window-inset-start";let le;t[20]!==re?(le=G("electron-no-drag pointer-events-auto flex min-w-0 items-center gap-1.5",re),t[20]=re,t[21]=le):le=t[21];let ae;t[22]!==h||t[23]!==s||t[24]!==o?(ae=!s&&a.jsx(x2,{icon:yP,label:`Show sidebar (${o})`,onClick:h}),t[22]=h,t[23]=s,t[24]=o,t[25]=ae):ae=t[25];let ue;t[26]!==Y||t[27]!==f||t[28]!==N?(ue=N&&Y&&f&&a.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:f,className:G(rs,"h-8 shrink-0 px-2.5 text-xs text-muted-foreground"),children:[a.jsx(ot,{className:"size-3 rotate-180"}),"Main"]}),t[26]=Y,t[27]=f,t[28]=N,t[29]=ue):ue=t[29];let oe;t[30]!==z||t[31]!==l||t[32]!==se||t[33]!==C||t[34]!==u||t[35]!==c||t[36]!==d||t[37]!==B||t[38]!==N||t[39]!==S?(oe=N&&a.jsx(yK,{session:N,sessionSource:S,isLive:C,pullRequests:B,copied:z,creatingSession:l,onCopyResume:se,onNewSession:c,onDuplicateSession:u,onOpenTerminal:d}),t[30]=z,t[31]=l,t[32]=se,t[33]=C,t[34]=u,t[35]=c,t[36]=d,t[37]=B,t[38]=N,t[39]=S,t[40]=oe):oe=t[40];let ie;t[41]!==m||t[42]!==N||t[43]!==p?(ie=N&&m&&(p??0)>0&&a.jsxs(ee,{variant:"ghost",size:"xs",className:G(rs,"h-8 shrink-0 gap-1 px-2.5 text-[11px] text-muted-foreground hover:text-foreground"),onClick:m,children:[a.jsx(E3,{className:"size-3"}),"Workflows",a.jsx(Ue,{variant:"outline",className:"h-4 min-w-4 justify-center px-1 text-[9px] font-semibold",children:p})]}),t[41]=m,t[42]=N,t[43]=p,t[44]=ie):ie=t[44];let fe;t[45]!==le||t[46]!==ae||t[47]!==ue||t[48]!==oe||t[49]!==ie?(fe=a.jsxs("div",{className:le,children:[ae,ue,oe,ie]}),t[45]=le,t[46]=ae,t[47]=ue,t[48]=oe,t[49]=ie,t[50]=fe):fe=t[50];let de,ce,xe;t[51]===Symbol.for("react.memo_cache_sentinel")?(de=a.jsx("div",{className:G(rs,Ur,"empty:hidden"),children:a.jsx(HH,{})}),ce=a.jsx("div",{className:G(rs,Ur,"empty:hidden"),children:a.jsx(QH,{})}),xe=G(rs,Ur,"empty:hidden"),t[51]=de,t[52]=ce,t[53]=xe):(de=t[51],ce=t[52],xe=t[53]);let pe;t[54]!==K?(pe=a.jsx("div",{className:xe,children:a.jsx(qK,{agentKind:K})}),t[54]=K,t[55]=pe):pe=t[55];let he;t[56]===Symbol.for("react.memo_cache_sentinel")?(he=a.jsx("div",{className:G(rs,Ur,"empty:hidden"),children:a.jsx(Lx,{})}),t[56]=he):he=t[56];let ye;t[57]!==K||t[58]!==N?(ye=N&&xn(K).sharing&&pt("share")&&a.jsx("div",{className:G(rs,Ur),children:a.jsx(IK,{sessionId:N.sessionId})}),t[57]=K,t[58]=N,t[59]=ye):ye=t[59];let ve;t[60]!==P||t[61]!==Y||t[62]!==N?(ve=N&&!Y&&P&&a.jsx("div",{className:G(rs,Ur,"empty:hidden"),children:a.jsx(P,{sessionId:N.sessionId})}),t[60]=P,t[61]=Y,t[62]=N,t[63]=ve):ve=t[63];let ke;t[64]!==V||t[65]!==Y||t[66]!==N?(ke=N&&!Y&&V&&a.jsx(x2,{icon:V.icon,label:V.label,disabledReason:V.disabledReason,onClick:V.toggle}),t[64]=V,t[65]=Y,t[66]=N,t[67]=ke):ke=t[67];let je;t[68]===Symbol.for("react.memo_cache_sentinel")?(je=G(rs,Ur),t[68]=je):je=t[68];let Me;t[69]===Symbol.for("react.memo_cache_sentinel")?(Me=a.jsx(sa,{render:a.jsx(ee,{variant:"ghost",size:"icon-sm","aria-label":"More actions"}),children:a.jsx(T3,{"data-icon":"inline-start"})}),t[69]=Me):Me=t[69];let _e;t[70]!==I?(_e=I&&a.jsxs(cn,{onClick:()=>O(!0),children:[a.jsx(wP,{}),"Usage & cost…"]}),t[70]=I,t[71]=_e):_e=t[71];let Fe;t[72]===Symbol.for("react.memo_cache_sentinel")?(Fe=a.jsxs(cn,{onClick:()=>R(!0),children:[a.jsx(jh,{}),"Server monitor…"]}),t[72]=Fe):Fe=t[72];let ze;t[73]!==te||t[74]!==j?(ze=j&&a.jsxs(cn,{onClick:te,children:[a.jsx(Pi,{className:"text-success"}),"Copy network URL",a.jsx("span",{className:"ml-auto truncate pl-2 font-mono text-[11px] text-muted-foreground",children:j})]}),t[73]=te,t[74]=j,t[75]=ze):ze=t[75];let We;t[76]!==_e||t[77]!==ze?(We=a.jsxs(Nr,{children:[_e,Fe,ze]}),t[76]=_e,t[77]=ze,t[78]=We):We=t[78];let Pe;t[79]===Symbol.for("react.memo_cache_sentinel")?(Pe=a.jsx(Yu,{}),t[79]=Pe):Pe=t[79];let qe;t[80]===Symbol.for("react.memo_cache_sentinel")?(qe=a.jsx(SP,{}),t[80]=qe):qe=t[80];let be;t[81]!==x?(be=a.jsx(Nr,{children:a.jsxs(cn,{onClick:x,children:[qe,"Settings"]})}),t[81]=x,t[82]=be):be=t[82];let Ie;t[83]!==i||t[84]!==g?(Ie=pt("killAny")&&a.jsxs(a.Fragment,{children:[a.jsx(Yu,{}),a.jsx(Nr,{children:a.jsxs(cn,{variant:"destructive",onClick:g,disabled:i,children:[a.jsx(vP,{}),i?"Stopping processes…":"Stop all agent processes"]})})]}),t[83]=i,t[84]=g,t[85]=Ie):Ie=t[85];let Se;t[86]!==We||t[87]!==be||t[88]!==Ie?(Se=a.jsx("div",{className:je,children:a.jsxs(na,{children:[Me,a.jsxs(ra,{align:"end",sideOffset:6,className:"w-64",children:[We,Pe,be,Ie]})]})}),t[86]=We,t[87]=be,t[88]=Ie,t[89]=Se):Se=t[89];let Ne;t[90]!==A||t[91]!==b||t[92]!==y?(Ne=A&&a.jsx("div",{className:G(rs,Ur,"empty:hidden"),children:a.jsx(A,{onLogout:b,onOpenMainView:y})}),t[90]=A,t[91]=b,t[92]=y,t[93]=Ne):Ne=t[93];let He;t[94]!==pe||t[95]!==ye||t[96]!==ve||t[97]!==ke||t[98]!==Se||t[99]!==Ne?(He=a.jsxs("div",{className:"electron-no-drag window-inset-end pointer-events-auto flex shrink-0 items-center gap-1.5",children:[de,ce,pe,he,ye,ve,ke,Se,Ne]}),t[94]=pe,t[95]=ye,t[96]=ve,t[97]=ke,t[98]=Se,t[99]=Ne,t[100]=He):He=t[100];let Ke;t[101]!==fe||t[102]!==He?(Ke=a.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-30 flex items-start justify-between gap-3 px-3 pt-2",children:[fe,He]}),t[101]=fe,t[102]=He,t[103]=Ke):Ke=t[103];let Ce;t[104]!==I||t[105]!==$?(Ce=I&&a.jsx(cG,{open:$,onOpenChange:O}),t[104]=I,t[105]=$,t[106]=Ce):Ce=t[106];let Be;t[107]!==M?(Be=a.jsx(uK,{open:M,onOpenChange:R}),t[107]=M,t[108]=Be):Be=t[108];let Ye;return t[109]!==Ke||t[110]!==Ce||t[111]!==Be?(Ye=a.jsxs(a.Fragment,{children:[ne,J,Ke,Ce,Be]}),t[109]=Ke,t[110]=Ce,t[111]=Be,t[112]=Ye):Ye=t[112],Ye});function x2(n){const e=q.c(23),{icon:t,label:s,onClick:r,disabledReason:o}=n;if(o){let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=G(rs,"size-8 shrink-0"),e[0]=m):m=e[0];let p;e[1]!==t?(p=a.jsx(t,{"data-icon":"inline-start"}),e[1]=t,e[2]=p):p=e[2];let h;e[3]!==s||e[4]!==p?(h=a.jsx(ee,{variant:"ghost",size:"icon-sm",disabled:!0,"aria-label":s,className:m,children:p}),e[3]=s,e[4]=p,e[5]=h):h=e[5];let g;return e[6]!==o||e[7]!==h?(g=a.jsx(Tu,{reason:o,children:h}),e[6]=o,e[7]=h,e[8]=g):g=e[8],g}let i;e[9]===Symbol.for("react.memo_cache_sentinel")?(i=G(rs,"size-8 shrink-0"),e[9]=i):i=e[9];let l;e[10]!==s||e[11]!==r?(l=a.jsx(ee,{variant:"ghost",size:"icon-sm",onClick:r,"aria-label":s,className:i}),e[10]=s,e[11]=r,e[12]=l):l=e[12];let c;e[13]!==t?(c=a.jsx(t,{"data-icon":"inline-start"}),e[13]=t,e[14]=c):c=e[14];let u;e[15]!==l||e[16]!==c?(u=a.jsx(Yt,{render:l,children:c}),e[15]=l,e[16]=c,e[17]=u):u=e[17];let d;e[18]!==s?(d=a.jsx(Xt,{side:"bottom",children:s}),e[18]=s,e[19]=d):d=e[19];let f;return e[20]!==u||e[21]!==d?(f=a.jsxs(Zt,{children:[u,d]}),e[20]=u,e[21]=d,e[22]=f):f=e[22],f}function wG(n){n&&Bn.success("Copied network URL")}const SG=w.memo(function(e){const t=q.c(13),{onToggleSidebar:s,onGoHome:r,onOpenCommandPalette:o,sidebarShortcut:i,commandPaletteShortcut:l}=e;let c;t[0]===Symbol.for("react.memo_cache_sentinel")?(c=a.jsx("div",{className:"flex-1"}),t[0]=c):c=t[0];let u;t[1]!==r?(u=a.jsx(am,{icon:Zi,label:"Home",onClick:r,size:"default"}),t[1]=r,t[2]=u):u=t[2];const d=`Search (${l})`;let f;t[3]!==o||t[4]!==d?(f=a.jsx(am,{icon:Yn,label:d,onClick:o,size:"default"}),t[3]=o,t[4]=d,t[5]=f):f=t[5];const m=`Hide sidebar (${i})`;let p;t[6]!==s||t[7]!==m?(p=a.jsx(am,{icon:kP,label:m,onClick:s,size:"default"}),t[6]=s,t[7]=m,t[8]=p):p=t[8];let h;return t[9]!==u||t[10]!==f||t[11]!==p?(h=a.jsxs("div",{className:"electron-drag window-inset-start flex h-12 shrink-0 items-center gap-1 px-2",children:[c,u,f,p]}),t[9]=u,t[10]=f,t[11]=p,t[12]=h):h=t[12],h});function kG(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex h-full w-full aria-[orientation=vertical]:flex-col",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(CP,{"data-slot":"resizable-panel-group",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function b2(n){const e=q.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(NP,{"data-slot":"resizable-panel",...t}),e[2]=t,e[3]=s):s=e[3],s}function jG(n){const e=q.c(12);let t,s,r;e[0]!==n?({withHandle:r,className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);let o;e[4]!==t?(o=G("relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-hidden aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 [&[aria-orientation=horizontal]>div]:rotate-90",t),e[4]=t,e[5]=o):o=e[5];let i;e[6]!==r?(i=r&&a.jsx("div",{className:"z-10 flex h-6 w-1 shrink-0 rounded-lg bg-border"}),e[6]=r,e[7]=i):i=e[7];let l;return e[8]!==s||e[9]!==o||e[10]!==i?(l=a.jsx(jP,{"data-slot":"resizable-handle",className:o,...s,children:i}),e[8]=s,e[9]=o,e[10]=i,e[11]=l):l=e[11],l}const E5=w.createContext(null);function T5(n){const e=q.c(3),{value:t,children:s}=n;let r;return e[0]!==s||e[1]!==t?(r=a.jsx(E5.Provider,{value:t,children:s}),e[0]=s,e[1]=t,e[2]=r):r=e[2],r}function Fx(){const n=w.useContext(E5);if(!n)throw new Error("Built-in workspace panel services are unavailable");return n}function A5(n){const e=q.c(18),{title:t,icon:s,active:r,onClick:o,children:i}=n,l=r&&"bg-sidebar-primary text-sidebar-primary-foreground hover:bg-sidebar-primary/90 hover:text-sidebar-primary-foreground";let c;e[0]!==l?(c=G("relative rounded-md",l),e[0]=l,e[1]=c):c=e[1];let u;e[2]!==r||e[3]!==o||e[4]!==c||e[5]!==t?(u=a.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm","aria-label":t,"aria-pressed":r,onClick:o,className:c}),e[2]=r,e[3]=o,e[4]=c,e[5]=t,e[6]=u):u=e[6];let d;e[7]!==s?(d=a.jsx(s,{"data-icon":"inline-start"}),e[7]=s,e[8]=d):d=e[8];let f;e[9]!==i||e[10]!==u||e[11]!==d?(f=a.jsxs(Yt,{render:u,children:[d,i]}),e[9]=i,e[10]=u,e[11]=d,e[12]=f):f=e[12];let m;e[13]!==t?(m=a.jsx(Xt,{side:"left",children:t}),e[13]=t,e[14]=m):m=e[14];let p;return e[15]!==f||e[16]!==m?(p=a.jsxs(Zt,{children:[f,m]}),e[15]=f,e[16]=m,e[17]=p):p=e[17],p}function Ux(n,e){return n.filter(t=>{var s;return((s=t.when)==null?void 0:s.call(t,e))??!0})}function NG(n){const e=q.c(25),{panels:t,context:s,activePanelId:r,onTogglePanel:o,actions:i}=n;let l;e[0]!==i?(l=i===void 0?[]:i,e[0]=i,e[1]=l):l=e[1];const c=l;let u,d,f,m,p,h;if(e[2]!==c||e[3]!==r||e[4]!==s||e[5]!==o||e[6]!==t){h=Symbol.for("react.early_return_sentinel");e:{const x=Ux(t,s);if(x.length===0&&c.length===0){h=null;break e}u="Workspace panels",d="electron-no-drag flex w-11 shrink-0 flex-col items-center gap-1 border-l bg-sidebar py-2 text-sidebar-foreground",e[13]!==c?(f=c.map(CG),e[13]=c,e[14]=f):f=e[14],m=c.length>0&&x.length>0&&a.jsx("div",{"aria-hidden":!0,className:"my-1 h-px w-6 bg-sidebar-border"});let b;e[15]!==r||e[16]!==s||e[17]!==o?(b=y=>{var _;const v=y.id===r,k=(_=y.badge)==null?void 0:_.call(y,s),j=y.indicator;return a.jsx(A5,{title:y.title,icon:y.icon,active:v,onClick:()=>o(y.id),children:j?a.jsx(j,{...y.indicatorProps,context:s,active:v}):k!=null&&a.jsx(Ue,{className:"absolute -right-1 -top-1 min-w-4 px-1 text-[9px]",variant:"secondary",children:k})},y.id)},e[15]=r,e[16]=s,e[17]=o,e[18]=b):b=e[18],p=x.map(b)}e[2]=c,e[3]=r,e[4]=s,e[5]=o,e[6]=t,e[7]=u,e[8]=d,e[9]=f,e[10]=m,e[11]=p,e[12]=h}else u=e[7],d=e[8],f=e[9],m=e[10],p=e[11],h=e[12];if(h!==Symbol.for("react.early_return_sentinel"))return h;let g;return e[19]!==u||e[20]!==d||e[21]!==f||e[22]!==m||e[23]!==p?(g=a.jsxs("aside",{"aria-label":u,className:d,children:[f,m,p]}),e[19]=u,e[20]=d,e[21]=f,e[22]=m,e[23]=p,e[24]=g):g=e[24],g}function CG(n){return a.jsx(A5,{title:n.title,icon:n.icon,active:n.active,onClick:n.onSelect},n.id)}function P5(n){const e=q.c(20),{panels:t,context:s,activePanelId:r,onClosePanel:o,active:i}=n,l=i===void 0?!0:i;let c;e[0]!==r?(c=()=>new Set([r]),e[0]=r,e[1]=c):c=e[1];const[u,d]=w.useState(c);let f,m;e[2]!==r?(f=()=>{d(g=>{if(g.has(r))return g;const x=new Set(g);return x.add(r),x})},m=[r],e[2]=r,e[3]=f,e[4]=m):(f=e[3],m=e[4]),w.useEffect(f,m);let p;if(e[5]!==r||e[6]!==s||e[7]!==l||e[8]!==o||e[9]!==t||e[10]!==u){let g;e[12]!==r||e[13]!==s||e[14]!==l||e[15]!==o||e[16]!==u?(g=x=>{const b=x.id===r,y=b&&l;if(!b&&(!x.keepAlive||!u.has(x.id)))return null;const v=x.component;return a.jsx("div",{className:G("absolute inset-0 min-h-0",!y&&"hidden"),"aria-hidden":!y,children:a.jsx(v,{...x.componentProps,context:s,active:y,closePanel:o})},x.id)},e[12]=r,e[13]=s,e[14]=l,e[15]=o,e[16]=u,e[17]=g):g=e[17],p=t.map(g),e[5]=r,e[6]=s,e[7]=l,e[8]=o,e[9]=t,e[10]=u,e[11]=p}else p=e[11];let h;return e[18]!==p?(h=a.jsx("div",{className:"relative h-full min-h-0 overflow-hidden bg-canvas",children:p}),e[18]=p,e[19]=h):h=e[19],h}function _G(n){const e=n==null?void 0:n.match(/^(\d+(?:\.\d+)?)%$/);if(!e)return"64%";const t=Number(e[1]);return t>0&&t<100?`${100-t}%`:"64%"}function EG(n){const e=q.c(23),{children:t,panels:s,context:r,activePanel:o,services:i,onClosePanel:l,onTogglePanel:c,actions:u}=n;let d;e[0]!==o?(d=o?_G(o.defaultSize):"100%",e[0]=o,e[1]=d):d=e[1];let f;e[2]!==t||e[3]!==d?(f=a.jsx(b2,{defaultSize:d,minSize:"320px",children:t}),e[2]=t,e[3]=d,e[4]=f):f=e[4];let m;e[5]!==o||e[6]!==r||e[7]!==l||e[8]!==s||e[9]!==i?(m=o&&a.jsxs(a.Fragment,{children:[a.jsx(jG,{withHandle:!0}),a.jsx(b2,{defaultSize:o.defaultSize??"36%",minSize:o.minSize??"300px",maxSize:o.maxSize??"70%",children:a.jsx(T5,{value:i,children:a.jsx(P5,{panels:s,context:r,activePanelId:o.id,onClosePanel:l})})})]}),e[5]=o,e[6]=r,e[7]=l,e[8]=s,e[9]=i,e[10]=m):m=e[10];let p;e[11]!==f||e[12]!==m?(p=a.jsxs(kG,{orientation:"horizontal",className:"min-h-0 min-w-0 w-auto flex-1",children:[f,m]}),e[11]=f,e[12]=m,e[13]=p):p=e[13];const h=(o==null?void 0:o.id)??null;let g;e[14]!==u||e[15]!==r||e[16]!==c||e[17]!==s||e[18]!==h?(g=a.jsx(NG,{panels:s,context:r,activePanelId:h,onTogglePanel:c,actions:u}),e[14]=u,e[15]=r,e[16]=c,e[17]=s,e[18]=h,e[19]=g):g=e[19];let x;return e[20]!==p||e[21]!==g?(x=a.jsxs(a.Fragment,{children:[p,g]}),e[20]=p,e[21]=g,e[22]=x):x=e[22],x}function og(n){const e=Object.values(n).filter(s=>typeof s=="number");return Object.entries(n).filter(([s,r])=>e.indexOf(+s)===-1).map(([s,r])=>r)}function v2(n,e="|"){return n.map(t=>L5(t)).join(e)}function ig(n,e){return typeof e=="bigint"?e.toString():e}class TG{constructor(e){this._getter=e,this._value=void 0}get value(){const e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}}function wf(n){return new TG(n)}function AG(n){return n==null}function Bx(n){const e=n.startsWith("^")?1:0,t=n.endsWith("$")?n.length-1:n.length;return n.slice(e,t)}function PG(n,e){const t=n/e,s=Math.round(t),r=4*Number.EPSILON*Math.max(Math.abs(t),1);return Math.abs(t-s)<r?0:t-s}function zr(n,e,t){Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0})}function Wx(n){const e=Object.getOwnPropertyDescriptor(n,"shape");return e!=null&&e.get?e.get.raw:e==null?void 0:e.value}function $r(n){return Wx(n._zod.def)??n._zod.def.shape}function I5(n,e,t){Object.defineProperty(n,e,{get(){const s=t();return zr(this,e,s),s},enumerable:!0,configurable:!0})}function $5(n,e,t){e in n?zr(n,e,t):n[e]=t}function Wo(n,e,t,s){const r=$r(e);for(const o of t){const i=Object.getOwnPropertyDescriptor(r,o);i.enumerable&&(i.get?I5(n,o,()=>{const l=e._zod.def.shape[o];return s?s(l,o):l}):$5(n,o,s?s(i.value,o):i.value))}}function IG(n,e){for(const t of Reflect.ownKeys(e)){const s=Object.getOwnPropertyDescriptor(e,t);s.enumerable&&(s.get?I5(n,t,()=>e[t]):$5(n,t,s.value))}}function as(...n){const e={};for(const t of n){const s=Object.getOwnPropertyDescriptors(t);Object.assign(e,s)}return Object.defineProperties({},e)}function $G(n){return JSON.stringify(n)}function RG(n){return n.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const R5="captureStackTrace"in Error?Error.captureStackTrace:(...n)=>{};function El(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}const OG=wf(()=>{var n;if(Us.jitless||typeof navigator<"u"&&((n=navigator==null?void 0:navigator.userAgent)!=null&&n.includes("Cloudflare")))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Ui(n){if(El(n)===!1)return!1;const e=n.constructor;if(e===void 0||typeof e!="function")return!0;const t=e.prototype;return!(El(t)===!1||Object.prototype.hasOwnProperty.call(t,"isPrototypeOf")===!1)}function O5(n){return Ui(n)?{...n}:Array.isArray(n)?[...n]:n instanceof Map?new Map(n):n instanceof Set?new Set(n):n}const LG=new Set(["string","number","symbol"]);function Bi(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Co(n,e,t){const s=new n._zod.constr(e??n._zod.def);return(!e||t!=null&&t.parent)&&(s._zod.parent=n),s}function Ve(n){const e=n;if(!e)return{};if(typeof e=="string")return{error:()=>e};if((e==null?void 0:e.message)!==void 0){if((e==null?void 0:e.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function L5(n){return typeof n=="bigint"?n.toString()+"n":typeof n=="string"?`"${n}"`:`${n}`}function MG(n){return Object.keys(n).filter(e=>n[e]._zod.optin!==void 0&&n[e]._zod.optout==="optional")}const M5={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},zG={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function DG(n,e){const t=n._zod.def,s=t.checks;if(s&&s.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const o={};return Wo(o,n,Sf(n,e)),Co(n,as(t,{shape:o,checks:[]}))}function Sf(n,e){var r;const t=$r(n),s=[];for(const o of Reflect.ownKeys(e)){if(!((r=Object.getOwnPropertyDescriptor(t,o))!=null&&r.enumerable))throw new Error(`Unrecognized key: "${String(o)}"`);e[o]&&s.push(o)}return s}function FG(n,e){const t=n._zod.def,s=t.checks;if(s&&s.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const o=new Set(Sf(n,e)),i={};return Wo(i,n,Reflect.ownKeys($r(n)).filter(l=>!o.has(l))),Co(n,as(t,{shape:i,checks:[]}))}function UG(n,e){if(!Ui(e))throw new Error("Invalid input to extend: expected a plain object");const t=n._zod.def.checks;if(t&&t.length>0){const r=$r(n);for(const o of Reflect.ownKeys(e))if(Object.getOwnPropertyDescriptor(r,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Co(n,as(n._zod.def,{shape:z5(n,e)}))}function z5(n,e){const t={};return Wo(t,n,Reflect.ownKeys($r(n))),IG(t,e),t}function BG(n,e){if(!Ui(e))throw new Error("Invalid input to safeExtend: expected a plain object");return Co(n,as(n._zod.def,{shape:z5(n,e)}))}function WG(n,e){var r,o;if(!((r=e==null?void 0:e._zod)!=null&&r.def))throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if((o=n._zod.def.checks)!=null&&o.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const t={};Wo(t,n,Reflect.ownKeys($r(n))),Wo(t,e,Reflect.ownKeys($r(e)));const s=as(n._zod.def,{shape:t,get catchall(){return e._zod.def.catchall},checks:e._zod.def.checks??[]});return Co(n,s)}function y2(n,e,t,s="partial"){const o=e._zod.def.checks;if(o&&o.length>0)throw new Error(`.${s}() cannot be used on object schemas containing refinements`);const l=t?new Set(Sf(e,t)):void 0,c={};return Wo(c,e,Reflect.ownKeys($r(e)),n&&((u,d)=>l&&!l.has(d)?u:new n({type:"optional",innerType:u}))),Co(e,as(e._zod.def,{shape:c,checks:[]}))}function qG(n,e,t){const s=t?new Set(Sf(e,t)):void 0,r={};return Wo(r,e,Reflect.ownKeys($r(e)),(o,i)=>s&&!s.has(i)?o:new n({type:"nonoptional",innerType:o})),Co(e,as(e._zod.def,{shape:r}))}function jr(n,e=0){var t;if(n.aborted===!0)return!0;for(let s=e;s<n.issues.length;s++)if(((t=n.issues[s])==null?void 0:t.continue)!==!0)return!0;return!1}function VG(n,e=0){var t;if(n.aborted===!0)return!0;for(let s=e;s<n.issues.length;s++)if(((t=n.issues[s])==null?void 0:t.continue)===!1)return!0;return!1}function bi(n,e){return e.map(t=>{var s;return(s=t).path??(s.path=[]),t.path.unshift(n),t})}function ka(n){return typeof n=="string"?n:n==null?void 0:n.message}function w2(n,e,t){var s;for(let r=e;r<n.length;r++)(s=n[r]).schema??(s.schema=t)}function mo(n,e,t){var c,u,d,f,m,p,h,g,x,b;var s;const r=(u=(c=n.inst)==null?void 0:c._zod)==null?void 0:u.traits;r!=null&&r.has("$ZodType")&&(r.has("$ZodCheck")?(s=n).schema??(s.schema=n.inst):n.schema=n.inst);const o=n.schema!==n.inst?(f=(d=n.schema)==null?void 0:d._zod.def)==null?void 0:f.error:void 0,i=n.message?n.message:ka((h=(p=(m=n.inst)==null?void 0:m._zod.def)==null?void 0:p.error)==null?void 0:h.call(p,n))??ka(o==null?void 0:o(n))??ka((g=e==null?void 0:e.error)==null?void 0:g.call(e,n))??ka((x=t.customError)==null?void 0:x.call(t,n))??ka((b=t.localeError)==null?void 0:b.call(t,n))??"Invalid input",l={};for(const y of Object.keys(n))y==="inst"||y==="schema"||y==="continue"||y==="input"||y==="__proto__"||(l[y]=n[y]);return l.path??(l.path=[]),l.message=i,e!=null&&e.reportInput&&(l.input=n.input),l}const HG=/[\uD800-\uDBFF]/;function qx(n){const e=n.length;if(!HG.test(n))return e;let t=e;for(let s=0;s<e-1;s++)(n.charCodeAt(s)&64512)===55296&&(n.charCodeAt(s+1)&64512)===56320&&(t--,s++);return t}function Vx(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function KG(n){const e=typeof n;switch(e){case"number":return Number.isNaN(n)?"nan":"number";case"object":{if(n===null)return"null";if(Array.isArray(n))return"array";const t=n;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&"constructor"in t&&t.constructor)return t.constructor.name}}return e}function Tl(...n){const[e,t,s]=n;return typeof e=="string"?{message:e,code:"custom",input:t,inst:s}:{...e}}function GG(n,e){for(const t in e){const s=Object.getOwnPropertyDescriptor(e,t);s.get?Object.defineProperty(n,t,{...s,enumerable:!1}):ZG(n,t,s.value)}}function po(n,e,t,s=!0){return Object.defineProperty(n,e,{configurable:!0,writable:!0,enumerable:s,value:t}),t}function D5(n,e,t){return po(n,e,t,!1)}function F5(n,e){for(const t in n){const s=n[t];Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){return po(this,t,s(this))},set(r){po(this,t,r)}})}return e}function ZG(n,e,t){Object.defineProperty(n,e,{configurable:!0,get(){return this==null?t:po(this,e,t.bind(this))},set(s){po(this,e,s)}})}function YG(n,e){const t=Object.getPrototypeOf(n);return e in t?void 0:t}let Im,Vr=!1;const XG={configurable:!0,get(){Vr=!0}};function gt(n,e,t){const s=Object.getPrototypeOf(n._zod);if(e in s&&Im!==n._zod){Im=void 0;return}Im=n._zod,Object.defineProperty(s,e,{configurable:!0,get(){Object.defineProperty(this,e,XG);const r=Vr;Vr=!1;try{const o=t(this);return Vr?delete this[e]:Object.defineProperty(this,e,{configurable:!0,writable:!0,value:o}),Vr=Vr||r,o}catch(o){throw delete this[e],Vr=Vr||r,o}},set(r){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:r})}})}function JG(n,e,t,s){const r=YG(n,e);r&&Object.defineProperty(r,e,{configurable:!0,get(){const o={configurable:!0,writable:!0,enumerable:s,value:void 0};return Object.defineProperty(this,e,o),o.value=t(this),Object.defineProperty(this,e,o),o.value},set(o){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:s,value:o})}})}const QG="~constantCatch";function eZ(n){const e=()=>n;return e[QG]=!0,e}var S2;const $m={value:void 0,enumerable:!1};let k2="captureStackTrace"in Error?Error:null;function tZ(n){const e=k2;if(e){const t=e.stackTraceLimit;if(typeof t=="number"){try{e.stackTraceLimit=0}catch{return k2=null,new n}try{return new n}finally{e.stackTraceLimit=t}}}return new n}function ge(n,e,t,s){const r={};function o(m){this.def=m,this.constr=f,this.traits=new Set}o.prototype=r;const i=t,l=i&&new WeakSet;function c(m,p){if(m._zod){if(m._zod.traits.has(n))return}else{$m.value=new o(p);try{Object.defineProperty(m,"_zod",$m)}finally{$m.value=void 0}}if(m._zod.traits.add(n),e(m,p),l){const g=Object.getPrototypeOf(m),x=m._zod.constr.prototype;let b=g;for(;b&&b!==x;)b=Object.getPrototypeOf(b);const y=b??g;l.has(y)||(l.add(y),GG(y,i))}const h=f.prototype;for(const g in h)Object.prototype.hasOwnProperty.call(h,g)&&(g in m||(m[g]=h[g].bind(m)))}const u=(s==null?void 0:s.Parent)??Object;class d extends u{}Object.defineProperty(d,"name",{value:n});function f(m){var x;const p=s!=null&&s.Parent?tZ(d):this;c(p,m);const h=p._zod.deferred;if(h){for(const b of h)b();p._zod.deferred=void 0}const g=(x=globalThis.__zod_globalConfig)==null?void 0:x.postProcessor;return g&&g(p),p}return Object.defineProperty(f,"init",{value:c}),Object.defineProperty(f,Symbol.hasInstance,{value:m=>{var p,h;return s!=null&&s.Parent&&m instanceof s.Parent?!0:(h=(p=m==null?void 0:m._zod)==null?void 0:p.traits)==null?void 0:h.has(n)}}),Object.defineProperty(f,"name",{value:n}),f}class Do extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class U5 extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}(S2=globalThis).__zod_globalConfig??(S2.__zod_globalConfig={});const Us=globalThis.__zod_globalConfig;function ar(n){return n&&Object.assign(Us,n),Us}function nZ(){const n=this._zod;return n.message??(n.message=JSON.stringify(n.def,ig,2)),n.message}function sZ(n){this._zod.message=n}const rZ={get:nZ,set:sZ,enumerable:!0,configurable:!0},Rm={value:void 0,enumerable:!1},j2=new WeakSet([Object.prototype,Error.prototype]),oZ=(n,e)=>{n.name="$ZodError",Rm.value=e,Object.defineProperty(n,"issues",Rm),Rm.value=void 0,Object.defineProperty(n,"message",rZ);const t=Object.getPrototypeOf(n);j2.has(t)||(j2.add(t),Object.defineProperty(t,"toString",{configurable:!0,enumerable:!1,get(){const s=()=>this.message;return Object.defineProperty(this,"toString",{value:s,configurable:!0,writable:!0}),s},set(s){Object.defineProperty(this,"toString",{value:s,configurable:!0,writable:!0})}}))},iZ=ge("$ZodError",oZ);function aZ(n,e,t){return Object.prototype.hasOwnProperty.call(n,e)||(e==="__proto__"?Object.defineProperty(n,e,{value:t(),writable:!0,enumerable:!0,configurable:!0}):n[e]=t()),n[e]}function lZ(n,e=t=>t.message){const t={},s=[];for(const r of n.issues)r.path.length>0?aZ(t,r.path[0],()=>[]).push(e(r)):s.push(e(r));return{formErrors:s,fieldErrors:t}}function cZ(n,e=t=>t.message){const t={_errors:[]},s=(r,o=[])=>{for(const i of r.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(l=>s({issues:l},[...o,...i.path]));else if(i.code==="invalid_key")s({issues:i.issues},[...o,...i.path]);else if(i.code==="invalid_element")s({issues:i.issues},[...o,...i.path]);else{const l=[...o,...i.path];if(l.length===0)t._errors.push(e(i));else{let c=t,u=0;for(;u<l.length;){const d=l[u],f=u===l.length-1;if(d==="_errors"){f&&c._errors.push(e(i)),u++;continue}Object.prototype.hasOwnProperty.call(c,d)||Object.defineProperty(c,d,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});const m=c[d];f&&m._errors.push(e(i)),c=m,u++}}}};return s(n),t}function kf(n,e){return{callee:(e==null?void 0:e.callee)??n,Err:e==null?void 0:e.Err}}const Hx=n=>{const e=(t,s,r,o)=>{const i=r?{...r,async:!1}:{async:!1},l=t._zod.run({value:s,issues:[]},i);if(l instanceof Promise)throw new Do;if(l.issues.length){const c=new((o==null?void 0:o.Err)??n)(l.issues.map(u=>mo(u,i,ar())));throw R5(c,(o==null?void 0:o.callee)??e),c}return l.value};return e},Kx=n=>{const e=async(t,s,r,o)=>{const i=r?{...r,async:!0}:{async:!0};let l=t._zod.run({value:s,issues:[]},i);if(l instanceof Promise&&(l=await l),l.issues.length){const c=new((o==null?void 0:o.Err)??n)(l.issues.map(u=>mo(u,i,ar())));throw R5(c,(o==null?void 0:o.callee)??e),c}return l.value};return e},Gx=n=>(e,t,s)=>{const r=s?{...s,async:!1}:{async:!1},o=e._zod.run({value:t,issues:[]},r);if(o instanceof Promise)throw new Do;return o.issues.length?B5(n,o.issues,r):{success:!0,data:o.value}};function B5(n,e,t){let s;return{success:!1,get error(){return s||(s=new n(e.map(r=>mo(r,t,ar()))),e=void 0,t=void 0),s},set error(r){s=r,e=void 0,t=void 0}}}const Zx=n=>async(e,t,s)=>{const r=s?{...s,async:!0}:{async:!0};let o=e._zod.run({value:t,issues:[]},r);return o instanceof Promise&&(o=await o),o.issues.length?B5(n,o.issues,r):{success:!0,data:o.value}},uZ=Symbol.for("zod.compile.invalid"),dZ=Symbol.for("zod.compile.fallback"),fZ=((n,e,t)=>{const s=n._zod.bag.validator;if(s!==void 0){if(s(e)!==uZ)return!0;if(s.definite===!0&&t===void 0)return!1}return mZ(n,e,t)});function mZ(n,e,t){const s=t?{...t,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},r=n._zod.bag.fallbackRun;let o;if(r?(s[dZ]=!0,o=r({value:e,issues:[]},s)):o=n._zod.run({value:e,issues:[]},s),o instanceof Promise)throw new Do;return o.issues.length===0}const pZ=async(n,e,t)=>{const s=t?{...t,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0};let r=n._zod.run({value:e,issues:[]},s);return r instanceof Promise&&(r=await r),r.issues.length===0},hZ=n=>{const e=Hx(n),t=(s,r,o,i)=>{const l=o?{...o,direction:"backward"}:{direction:"backward"};return e(s,r,l,kf(t,i))};return t},gZ=n=>{const e=Hx(n),t=(s,r,o,i)=>e(s,r,o,kf(t,i));return t},xZ=n=>{const e=Kx(n),t=async(s,r,o,i)=>{const l=o?{...o,direction:"backward"}:{direction:"backward"};return await e(s,r,l,kf(t,i))};return t},bZ=n=>{const e=Kx(n),t=async(s,r,o,i)=>await e(s,r,o,kf(t,i));return t},vZ=n=>(e,t,s)=>{const r=s?{...s,direction:"backward"}:{direction:"backward"};return Gx(n)(e,t,r)},yZ=n=>(e,t,s)=>Gx(n)(e,t,s),wZ=n=>async(e,t,s)=>{const r=s?{...s,direction:"backward"}:{direction:"backward"};return Zx(n)(e,t,r)},SZ=n=>async(e,t,s)=>Zx(n)(e,t,s),kZ=/^[cC][0-9a-z]{6,}$/,jZ=/^[0-9a-z]+$/,NZ=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,CZ=/^[0-9a-vA-V]{20}$/,_Z=/^[A-Za-z0-9]{27}$/,EZ=/^[a-zA-Z0-9_-]{21}$/;function TZ(n){return new RegExp(`^[a-zA-Z0-9_-]{${n}}$`)}const AZ=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,PZ=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,N2=n=>n?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${n}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,IZ=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,$Z="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function RZ(){return new RegExp($Z,"u")}const OZ=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,LZ=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,MZ=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,zZ=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,DZ=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,FZ=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,UZ=/^https?$/,BZ=/^\+[1-9]\d{6,14}$/,W5="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function WZ(n){return new RegExp(`^${n}$`)}const qZ=WZ(W5);function ag(n){const e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof n.precision=="number"?n.precision===-1?`${e}`:n.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${n.precision}}`:n.seconds?`${e}:[0-5]\\d(?:\\.\\d+)?`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function VZ(n){return new RegExp(`^${ag(n)}$`)}function HZ(n){const e=["Z"];n.offset&&e.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const t=`${ag({precision:n.precision,seconds:!0})}(?:${e.join("|")})`,s=n.local?`${t}|${ag({precision:n.precision})}`:t;return new RegExp(`^${W5}T(?:${s})$`)}const KZ=/^[\s\S]{0,}$/,GZ=/^-?\d+$/,Yx=/^-?\d+(?:\.\d+)?$/,ZZ=/^(?:true|false)$/i,YZ=/^null$/i,XZ=/^[^A-Z]*$/,JZ=/^[^a-z]*$/,Jn=ge("$ZodCheck",(n,e)=>{var t;n._zod??(n._zod={}),n._zod.def=e,(t=n._zod).onattach??(t.onattach=[])}),Xx=n=>{const e=n.value;return!AG(e)&&e.length!==void 0},fd={number:"number",bigint:"bigint",object:"date"},q5=ge("$ZodCheckLessThan",(n,e)=>{Jn.init(n,e);const t=fd[typeof e.value];n._zod.check=s=>{(e.inclusive?s.value<=e.value:s.value<e.value)||s.issues.push({origin:fd[typeof s.value]??t,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:s.value,inclusive:e.inclusive,inst:n,continue:!e.abort})}}),V5=ge("$ZodCheckGreaterThan",(n,e)=>{Jn.init(n,e);const t=fd[typeof e.value];n._zod.check=s=>{(e.inclusive?s.value>=e.value:s.value>e.value)||s.issues.push({origin:fd[typeof s.value]??t,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:s.value,inclusive:e.inclusive,inst:n,continue:!e.abort})}}),QZ=ge("$ZodCheckMultipleOf",(n,e)=>{Jn.init(n,e),n._zod.check=t=>{if(typeof t.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof t.value=="bigint"?e.value!==BigInt(0)&&t.value%e.value===BigInt(0):PG(t.value,e.value)===0)||t.issues.push({origin:typeof t.value,code:"not_multiple_of",divisor:e.value,input:t.value,inst:n,continue:!e.abort})}}),eY=ge("$ZodCheckNumberFormat",(n,e)=>{var i;Jn.init(n,e),e.format=e.format||"float64";const t=(i=e.format)==null?void 0:i.includes("int"),s=t?"int":"number",[r,o]=M5[e.format];n._zod.check=l=>{const c=l.value;if(t){if(!Number.isInteger(c)){l.issues.push({expected:s,format:e.format,code:"invalid_type",continue:!1,input:c,inst:n});return}if(!Number.isSafeInteger(c)){c>0?l.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:s,inclusive:!0,continue:!e.abort}):l.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:s,inclusive:!0,continue:!e.abort});return}}c<r&&l.issues.push({origin:"number",input:c,code:"too_small",minimum:r,inclusive:!0,inst:n,continue:!e.abort}),c>o&&l.issues.push({origin:"number",input:c,code:"too_big",maximum:o,inclusive:!0,inst:n,continue:!e.abort})}}),tY=ge("$ZodCheckMaxLength",(n,e)=>{var t;Jn.init(n,e),(t=n._zod.def).when??(t.when=Xx),n._zod.check=s=>{const r=s.value,o=r.length;if((typeof r=="string"&&o>e.maximum?qx(r):o)<=e.maximum)return;const l=Vx(r);s.issues.push({origin:l,code:"too_big",maximum:e.maximum,inclusive:!0,input:r,inst:n,continue:!e.abort})}}),nY=ge("$ZodCheckMinLength",(n,e)=>{var t;Jn.init(n,e),(t=n._zod.def).when??(t.when=Xx),n._zod.check=s=>{const r=s.value,o=r.length;if((typeof r=="string"&&o>=e.minimum&&o<e.minimum*2?qx(r):o)>=e.minimum)return;const l=Vx(r);s.issues.push({origin:l,code:"too_small",minimum:e.minimum,inclusive:!0,input:r,inst:n,continue:!e.abort})}}),sY=ge("$ZodCheckLengthEquals",(n,e)=>{var t;Jn.init(n,e),(t=n._zod.def).when??(t.when=Xx),n._zod.check=s=>{const r=s.value,o=r.length,i=typeof r=="string"&&o>=e.length&&o<=e.length*2?qx(r):o;if(i===e.length)return;const l=Vx(r),c=i>e.length;s.issues.push({origin:l,...c?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:s.value,inst:n,continue:!e.abort})}}),jf=ge("$ZodCheckStringFormat",(n,e)=>{var t,s;Jn.init(n,e),e.pattern?(t=n._zod).check??(t.check=r=>{e.pattern.lastIndex=0,!e.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:e.format,input:r.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:n,continue:!e.abort})}):(s=n._zod).check??(s.check=()=>{})}),rY=ge("$ZodCheckRegex",(n,e)=>{jf.init(n,e),n._zod.check=t=>{e.pattern.lastIndex=0,!e.pattern.test(t.value)&&t.issues.push({origin:"string",code:"invalid_format",format:"regex",input:t.value,pattern:e.pattern.toString(),inst:n,continue:!e.abort})}}),oY=ge("$ZodCheckLowerCase",(n,e)=>{e.pattern??(e.pattern=XZ),jf.init(n,e)}),iY=ge("$ZodCheckUpperCase",(n,e)=>{e.pattern??(e.pattern=JZ),jf.init(n,e)}),aY=ge("$ZodCheckIncludes",(n,e)=>{Jn.init(n,e);const t=Bi(e.includes),s=new RegExp(typeof e.position=="number"?`^.{${e.position},}${t}`:t);e.pattern=s,n._zod.check=r=>{r.value.includes(e.includes,e.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:r.value,inst:n,continue:!e.abort})}}),lY=ge("$ZodCheckStartsWith",(n,e)=>{Jn.init(n,e);const t=new RegExp(`^${Bi(e.prefix)}.*`);e.pattern??(e.pattern=t),n._zod.check=s=>{s.value.startsWith(e.prefix)||s.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:s.value,inst:n,continue:!e.abort})}}),cY=ge("$ZodCheckEndsWith",(n,e)=>{Jn.init(n,e);const t=new RegExp(`.*${Bi(e.suffix)}$`);e.pattern??(e.pattern=t),n._zod.check=s=>{s.value.endsWith(e.suffix)||s.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:s.value,inst:n,continue:!e.abort})}}),uY=ge("$ZodCheckOverwrite",(n,e)=>{Jn.init(n,e),n._zod.check=t=>{t.value=e.tx(t.value)}});class dY{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}const s=e.split(`
|
|
121
|
+
`).filter(i=>i),r=Math.min(...s.map(i=>i.length-i.trimStart().length)),o=s.map(i=>i.slice(r)).map(i=>" ".repeat(this.indent*2)+i);for(const i of o)this.content.push(i)}compile(){const e=Function,t=(this==null?void 0:this.content)??[""];return new e(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
|
|
122
|
+
${t.join(`
|
|
123
|
+
`)}
|
|
124
|
+
};`)(...Object.values(this.closed))}}const fY={major:4,minor:6,patch:5},At=ge("$ZodType",(n,e)=>{var o;var t;n??(n={}),n._zod.def=e,n._zod.bag=n._zod.bag||{},n._zod.version=fY;const s=n._zod.def.checks,r=n._zod.traits.has("$ZodCheck")?[n,...s??[]]:s!=null&&s.length?[...s]:[];for(const i of r)for(const l of i._zod.onattach)l(n);if(r.length===0)(t=n._zod).deferred??(t.deferred=[]),(o=n._zod.deferred)==null||o.push(()=>{n._zod.run=n._zod.parse});else{const i=(c,u,d)=>{if(c.memo)return c;let f=jr(c),m;for(const p of u){if(p._zod.def.when){if(VG(c)||!p._zod.def.when(c))continue}else if(f)continue;const h=c.issues.length,g=p._zod.check(c);if(g instanceof Promise&&(d==null?void 0:d.async)===!1)throw new Do;if(m||g instanceof Promise)m=(m??Promise.resolve()).then(async()=>{await g,c.issues.length!==h&&(w2(c.issues,h,n),f||(f=jr(c,h)))});else{if(c.issues.length===h)continue;w2(c.issues,h,n),f||(f=jr(c,h))}}return m?m.then(()=>c):c},l=(c,u,d)=>{if(jr(c))return c.aborted=!0,c;const f=i(u,r,d);if(f instanceof Promise){if(d.async===!1)throw new Do;return f.then(m=>n._zod.parse(m,d))}return n._zod.parse(f,d)};n._zod.run=(c,u)=>{if(u.skipChecks)return n._zod.parse(c,u);if(u.direction==="backward"){const f=n._zod.parse({value:c.value,issues:[]},{...u,skipChecks:!0});return f instanceof Promise?f.then(m=>l(m,c,u)):l(f,c,u)}const d=n._zod.parse(c,u);if(d instanceof Promise){if(u.async===!1)throw new Do;return d.then(f=>i(f,r,u))}return i(d,r,u)}}},{get"~standard"(){return D5(this,"~standard",K5(this))},set"~standard"(n){po(this,"~standard",n)}}),H5=(n,e)=>n.issues.length?{issues:n.issues.map(t=>mo(t,e,ar()))}:{value:n.value};async function mY(n,e){const t={async:!0};return H5(await n._zod.run({value:e,issues:[]},t),t)}function K5(n){return{validate:e=>{const t={async:!1};try{const s=n._zod.run({value:e,issues:[]},t);if(!(s instanceof Promise))return H5(s,t)}catch{}return mY(n,e)},vendor:"zod",version:1}}const Jx=ge("$ZodString",(n,e)=>{At.init(n,e),n._zod.pattern=e.pattern??KZ,n._zod.parse=(t,s)=>{if(e.coerce)try{t.value=String(t.value)}catch{}return typeof t.value=="string"||t.issues.push({expected:"string",code:"invalid_type",input:t.value,inst:n}),t}}),Pt=ge("$ZodStringFormat",(n,e)=>{jf.init(n,e),Jx.init(n,e)}),pY=ge("$ZodGUID",(n,e)=>{e.pattern??(e.pattern=PZ),Pt.init(n,e)}),hY=ge("$ZodUUID",(n,e)=>{if(e.version){const s={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(s===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=N2(s))}else e.pattern??(e.pattern=N2());Pt.init(n,e)}),gY=ge("$ZodEmail",(n,e)=>{e.pattern??(e.pattern=IZ),Pt.init(n,e)}),G5=1,md=2;function Z5(n){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(n):(new URL(n),!0)}catch{return!1}}function xY(n,e){return!("normalize"in e)&&!("hostname"in e)&&!("protocol"in e)?Z5(n)||md:bY(n,e)}function bY(n,e){var t;if(!e.normalize&&((t=e.protocol)==null?void 0:t.source)===UZ.source&&!/^https?:\/\//i.test(n))return G5;try{if(typeof URL<"u"){const s=URL;if(typeof s.parse=="function")return s.parse(n)??md}return new URL(n)}catch{return md}}const vY=/[\t\n\r]/g;function C2(n){return n.replace(vY,"")}function yY(n,e){return e.lastIndex=0,e.test(n.hostname)}function wY(n,e){return e.lastIndex=0,e.test(n.protocol.endsWith(":")?n.protocol.slice(0,-1):n.protocol)}const SY=ge("$ZodURL",(n,e)=>{Pt.init(n,e),n._zod.check=t=>{try{const s=t.value.trim(),r=xY(s,e);if(r===G5){t.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:t.value,inst:n,continue:!e.abort});return}if(r===md){t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:n,continue:!e.abort});return}if(r===!0){t.value=C2(s);return}e.hostname&&!yY(r,e.hostname)&&t.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:t.value,inst:n,continue:!e.abort}),e.protocol&&!wY(r,e.protocol)&&t.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:t.value,inst:n,continue:!e.abort}),t.value=e.normalize?r.href:C2(s);return}catch{t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:n,continue:!e.abort})}}}),kY=ge("$ZodEmoji",(n,e)=>{e.pattern??(e.pattern=RZ()),Pt.init(n,e)}),jY=ge("$ZodNanoID",(n,e)=>{if(e.length!==void 0&&(!Number.isInteger(e.length)||e.length<1))throw new Error(`Invalid nanoid length: ${e.length}`);e.pattern??(e.pattern=e.length===void 0?EZ:TZ(e.length)),Pt.init(n,e)}),NY=ge("$ZodCUID",(n,e)=>{e.pattern??(e.pattern=kZ),Pt.init(n,e)}),CY=ge("$ZodCUID2",(n,e)=>{e.pattern??(e.pattern=jZ),Pt.init(n,e)}),_Y=ge("$ZodULID",(n,e)=>{e.pattern??(e.pattern=NZ),Pt.init(n,e)}),EY=ge("$ZodXID",(n,e)=>{e.pattern??(e.pattern=CZ),Pt.init(n,e)}),TY=ge("$ZodKSUID",(n,e)=>{e.pattern??(e.pattern=_Z),Pt.init(n,e)}),AY=ge("$ZodISODateTime",(n,e)=>{e.pattern??(e.pattern=HZ(e)),Pt.init(n,e)}),PY=ge("$ZodISODate",(n,e)=>{e.pattern??(e.pattern=qZ),Pt.init(n,e)}),IY=ge("$ZodISOTime",(n,e)=>{e.pattern??(e.pattern=VZ(e)),Pt.init(n,e)}),$Y=ge("$ZodISODuration",(n,e)=>{e.pattern??(e.pattern=AZ),Pt.init(n,e)}),RY=ge("$ZodIPv4",(n,e)=>{e.pattern??(e.pattern=OZ),Pt.init(n,e)}),OY=/^[0-9a-fA-F:.]+$/;function Y5(n){return OY.test(n)?Z5(`http://[${n}]`):!1}const LY=ge("$ZodIPv6",(n,e)=>{e.pattern??(e.pattern=LZ),Pt.init(n,e),n._zod.check=t=>{Y5(t.value)||t.issues.push({code:"invalid_format",format:"ipv6",input:t.value,inst:n,continue:!e.abort})}}),MY=ge("$ZodCIDRv4",(n,e)=>{e.pattern??(e.pattern=MZ),Pt.init(n,e)});function zY(n){const e=n.split("/");if(e.length!==2)return!1;const[t,s]=e;if(!s)return!1;const r=Number(s);return`${r}`!==s||r<0||r>128?!1:Y5(t)}const DY=ge("$ZodCIDRv6",(n,e)=>{e.pattern??(e.pattern=zZ),Pt.init(n,e),n._zod.check=t=>{zY(t.value)||t.issues.push({code:"invalid_format",format:"cidrv6",input:t.value,inst:n,continue:!e.abort})}});function X5(n){if(n==="")return!0;if(/\s/.test(n)||n.length%4!==0)return!1;try{return atob(n),!0}catch{return!1}}const J5=/^[0-9a-zA-Z+/]*={0,2}$/,FY=ge("$ZodBase64",(n,e)=>{e.pattern??(e.pattern=J5),Pt.init(n,e),n._zod.check=t=>{X5(t.value)||t.issues.push({code:"invalid_format",format:"base64",input:t.value,inst:n,continue:!e.abort})}}),Qx=/^[A-Za-z0-9_-]*$/;function UY(n){if(!Qx.test(n))return!1;const e=n.replace(/[-_]/g,s=>s==="-"?"+":"/"),t=e.padEnd(Math.ceil(e.length/4)*4,"=");return X5(t)}const BY=ge("$ZodBase64URL",(n,e)=>{e.pattern??(e.pattern=Qx),Pt.init(n,e),n._zod.check=t=>{UY(t.value)||t.issues.push({code:"invalid_format",format:"base64url",input:t.value,inst:n,continue:!e.abort})}}),WY=ge("$ZodE164",(n,e)=>{e.pattern??(e.pattern=BZ),Pt.init(n,e)});function qY(n,e=null){try{const t=n.split(".");if(t.length!==3)return!1;const[s]=t;if(!s)return!1;const r=JSON.parse(atob(s));return!("typ"in r&&(r==null?void 0:r.typ)!=="JWT"||!r.alg||e&&(!("alg"in r)||r.alg!==e))}catch{return!1}}const VY=ge("$ZodJWT",(n,e)=>{Pt.init(n,e),n._zod.check=t=>{qY(t.value,e.alg)||t.issues.push({code:"invalid_format",format:"jwt",input:t.value,inst:n,continue:!e.abort})}}),Q5=ge("$ZodNumber",(n,e)=>{At.init(n,e),n._zod.pattern=Yx,n._zod.parse=(t,s)=>{if(e.coerce)try{t.value=Number(t.value)}catch{}const r=t.value;if(typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r))return t;const o=typeof r=="number"?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:String(r):void 0;return t.issues.push({expected:"number",code:"invalid_type",input:r,inst:n,...o?{received:o}:{}}),t}}),HY=ge("$ZodNumberFormat",(n,e)=>{eY.init(n,e),Q5.init(n,e)}),KY=ge("$ZodBoolean",(n,e)=>{At.init(n,e),n._zod.pattern=ZZ,n._zod.parse=(t,s)=>{if(e.coerce)try{t.value=!!t.value}catch{}const r=t.value;return typeof r=="boolean"||t.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:n}),t}}),GY=ge("$ZodNull",(n,e)=>{At.init(n,e),n._zod.pattern=YZ,n._zod.values=new Set([null]),n._zod.parse=(t,s)=>{const r=t.value;return r===null||t.issues.push({expected:"null",code:"invalid_type",input:r,inst:n}),t}}),ZY=ge("$ZodUnknown",(n,e)=>{At.init(n,e),n._zod.parse=t=>t}),YY=ge("$ZodNever",(n,e)=>{At.init(n,e),n._zod.parse=(t,s)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:n}),t)});function _2(n,e,t){n.issues.length&&e.issues.push(...bi(t,n.issues)),e.value[t]=n.value}const XY=ge("$ZodArray",(n,e)=>{At.init(n,e);const t=Us.memoizer;t==null||t.attach(n),n._zod.parse=(s,r)=>{const o=s.value;if(!Array.isArray(o))return s.issues.push({expected:"array",code:"invalid_type",input:o,inst:n}),s;s.value=t?t.alloc(n,s,Array(o.length),r):Array(o.length);const i=[],l=r==null?void 0:r.abortEarly;for(let c=0;c<o.length;c++){const u=o[c],d=e.element._zod.run({value:u,issues:[]},r);if(d instanceof Promise)i.push(d.then(f=>_2(f,s,c)));else if(_2(d,s,c),l&&d.issues.length!==0&&jr(d))break}return i.length?Promise.all(i).then(()=>s):s}});function pd(n,e,t,s,r,o){const i=t in s,l=o==="optional";if(!(!i&&l&&r==="optional")){if(n.issues.length){if(r!==void 0&&l&&!i)return;e.issues.push(...bi(t,n.issues))}if(!i&&r===void 0){n.issues.length||e.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[t]});return}n.value===void 0?(i||r==="defaulted"&&!l)&&(e.value[t]=void 0):e.value[t]=n.value}}const JY=[];function e_(n){var i,l,c,u;const e=Object.keys(n.shape),t=Object.getOwnPropertySymbols(n.shape),s=t.length?t:JY,r=s.length?[...e,...s]:e;for(const d of r)if(!((u=(c=(l=(i=n.shape)==null?void 0:i[d])==null?void 0:l._zod)==null?void 0:c.traits)!=null&&u.has("$ZodType")))throw new Error(`Invalid element at key "${String(d)}": expected a Zod schema`);const o=MG(n.shape);return{...n,allKeys:r,symbolKeys:s,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(o)}}function t_(n,e,t,s,r,o,i){const l=[],c=r.keySet,u=r.catchall._zod,d=u.def.type,f=u.optin,m=u.optout;let p=0;for(const h in e){if(i&&t.issues.length!==p){if(jr(t,p))break;p=t.issues.length}if(c.has(h))continue;if(h==="__proto__"){d==="never"&&l.push(h);continue}if(d==="never"){l.push(h);continue}const g=u.run({value:e[h],issues:[]},s);g instanceof Promise?n.push(g.then(x=>pd(x,t,h,e,f,m))):pd(g,t,h,e,f,m)}return l.length&&t.issues.push({code:"unrecognized_keys",keys:l,input:e,inst:o,continue:!0}),n.length?Promise.all(n).then(()=>t):t}const QY=ge("$ZodObject",(n,e)=>{At.init(n,e);const t=Object.getOwnPropertyDescriptor(e,"shape"),s=t!=null&&t.get?t.get.raw:e.shape??{};if(s){const u=()=>{const d={...s};return Object.defineProperty(e,"shape",{value:d}),u.raw=d,d};u.raw=s,Object.defineProperty(e,"shape",{get:u})}const r=wf(()=>e_(e));gt(n,"propValues",u=>{const d=u.def.shape,f={};for(const m in d){const p=d[m]._zod;if(p.values){Object.prototype.hasOwnProperty.call(f,m)||zr(f,m,new Set);for(const h of p.values)f[m].add(h);p.optin!==void 0&&f[m].add(void 0)}}return f});const o=El,i=e.catchall;let l;const c=Us.memoizer;c==null||c.attach(n),n._zod.parse=(u,d)=>{l??(l=r.value);const f=u.value;if(!o(f))return u.issues.push({expected:"object",code:"invalid_type",input:f,inst:n}),u;u.value=c?c.alloc(n,u,{},d):{};const m=[],p=l.shape,h=d==null?void 0:d.abortEarly;let g=u.issues.length;for(const x of l.allKeys){if(h&&u.issues.length!==g){if(jr(u,g))break;g=u.issues.length}if(x==="__proto__")continue;const b=p[x],y=b._zod.optin,v=b._zod.optout,k=b._zod.run({value:f[x],issues:[]},d);k instanceof Promise?m.push(k.then(j=>pd(j,u,x,f,y,v))):pd(k,u,x,f,y,v)}return i?t_(m,f,u,d,r.value,n,h===!0):m.length?Promise.all(m).then(()=>u):u}}),eX=ge("$ZodObjectJIT",(n,e)=>{QY.init(n,e);const t=n._zod.parse,s=wf(()=>e_(e)),r=Us.memoizer,o=p=>{var j,_;const h=s.value,g=h.symbolKeys,x=new dY(["payload","ctx"],{shape:p,inst:n,memo:r,syms:g}),b=N=>`shape[${N}]._zod.run({ value: input[${N}], issues: [] }, ctx)`,y=(N,S)=>`
|
|
125
|
+
let ${N}_ab = false;
|
|
126
|
+
for (let i = 0; i < ${N}.issues.length; i++) {
|
|
127
|
+
const iss = ${N}.issues[i];
|
|
128
|
+
iss.path = iss.path ? [${S}, ...iss.path] : [${S}];
|
|
129
|
+
payload.issues.push(iss);
|
|
130
|
+
if (iss.continue !== true) ${N}_ab = true;
|
|
131
|
+
}
|
|
132
|
+
if (${N}_ab && ctx && ctx.abortEarly) {
|
|
133
|
+
payload.value = newResult;
|
|
134
|
+
return payload;
|
|
135
|
+
}`;x.write("const input = payload.value;");const v=Object.create(null);let k=0;for(const N of h.allKeys)v[N]=`key_${k++}`;x.write(r?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(const N of h.allKeys){if(N==="__proto__")continue;const S=v[N],C=typeof N=="symbol"?`syms[${g.indexOf(N)}]`:$G(N),E=`${C} in input`,T=p[N],A=(j=T==null?void 0:T._zod)==null?void 0:j.optin,P=A!==void 0,I=((_=T==null?void 0:T._zod)==null?void 0:_.optout)==="optional";if(x.write(`const ${S} = ${b(C)};`),P&&I){const $=A==="optional"?`${S}_present`:`${S}.value !== undefined || ${S}_present`;x.write(`
|
|
136
|
+
const ${S}_present = ${E};
|
|
137
|
+
if (!${S}.issues.length || ${S}_present) {
|
|
138
|
+
if (${S}.issues.length) {${y(S,C)}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (${$}) {
|
|
142
|
+
newResult[${C}] = ${S}.value;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
`)}else P?(x.write(`
|
|
147
|
+
if (${S}.issues.length) {${y(S,C)}
|
|
148
|
+
}
|
|
149
|
+
`),A==="defaulted"?x.write(`newResult[${C}] = ${S}.value;`):x.write(`
|
|
150
|
+
if (${S}.value !== undefined || ${E}) {
|
|
151
|
+
newResult[${C}] = ${S}.value;
|
|
152
|
+
}
|
|
153
|
+
`)):x.write(`
|
|
154
|
+
const ${S}_present = ${E};
|
|
155
|
+
if (${S}.issues.length) {${y(S,C)}
|
|
156
|
+
}
|
|
157
|
+
if (!${S}_present && !${S}.issues.length) {
|
|
158
|
+
payload.issues.push({
|
|
159
|
+
code: "invalid_type",
|
|
160
|
+
expected: "nonoptional",
|
|
161
|
+
input: undefined,
|
|
162
|
+
path: [${C}]
|
|
163
|
+
});
|
|
164
|
+
if (ctx && ctx.abortEarly) {
|
|
165
|
+
payload.value = newResult;
|
|
166
|
+
return payload;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (${S}_present) {
|
|
171
|
+
newResult[${C}] = ${S}.value;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
`)}return x.write("payload.value = newResult;"),x.write("return payload;"),x.compile()};let i;const l=El,c=!Us.jitless,d=c&&OG.value,f=e.catchall;let m;n._zod.parse=(p,h)=>{m??(m=s.value);const g=p.value;return l(g)?c&&d&&(h==null?void 0:h.async)===!1&&h.jitless!==!0?(i||(i=o(e.shape)),p=i(p,h),f?t_([],g,p,h,m,n,(h==null?void 0:h.abortEarly)===!0):p):t(p,h):(p.issues.push({expected:"object",code:"invalid_type",input:g,inst:n}),p)}});function E2(n,e,t,s){for(const o of n)if(o.issues.length===0)return e.value=o.value,e;const r=n.filter(o=>!jr(o));return r.length===1?(e.value=r[0].value,r[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:t,errors:n.map(o=>o.issues.map(i=>mo(i,s,ar())))}),e)}const n_=ge("$ZodUnion",(n,e)=>{At.init(n,e),gt(n,"optin",s=>s.def.options.some(r=>r._zod.optin==="defaulted")?"defaulted":s.def.options.some(r=>r._zod.optin!==void 0)?"optional":void 0),gt(n,"optout",s=>s.def.options.some(r=>r._zod.optout==="optional")?"optional":void 0),gt(n,"values",s=>{if(s.def.options.every(r=>r._zod.values))return new Set(s.def.options.flatMap(r=>Array.from(r._zod.values)))}),gt(n,"pattern",s=>{if(s.def.options.every(r=>r._zod.pattern)){const r=s.def.options.map(o=>o._zod.pattern);return new RegExp(`^(${r.map(o=>Bx(o.source)).join("|")})$`)}});const t=e.options.length===1?e.options[0]._zod.run:null;n._zod.parse=(s,r)=>{if(t)return t(s,r);let o=!1;const i=[];for(const l of e.options){const c=l._zod.run({value:s.value,issues:[]},r);if(c instanceof Promise)i.push(c),o=!0;else{if(c.issues.length===0)return c;i.push(c)}}return o?Promise.all(i).then(l=>E2(l,s,n,r)):E2(i,s,n,r)}});function tX(n){var t;const e=new Map;for(const s of n.options){const r=(t=s._zod.propValues)==null?void 0:t[n.discriminator];if(!r||r.size===0)throw new Error(`Invalid discriminated union option at index "${n.options.indexOf(s)}"`);for(const o of r)if(e.has(o)){if(o!==void 0)throw new Error(`Duplicate discriminator value "${String(o)}"`);e.set(o,null)}else e.set(o,s)}return e}const nX=ge("$ZodDiscriminatedUnion",(n,e)=>{e.inclusive=!1,n_.init(n,e);const t=n._zod.parse;gt(n,"propValues",r=>{var l,c;const o={};let i=0;for(const u of r.def.options){const d=u._zod.propValues;if(!d||Object.keys(d).length===0)throw new Error(`Invalid discriminated union option at index "${r.def.options.indexOf(u)}"`);(l=d[r.def.discriminator])!=null&&l.has(void 0)&&i++;for(const[f,m]of Object.entries(d)){Object.prototype.hasOwnProperty.call(o,f)||zr(o,f,new Set);for(const p of m)o[f].add(p)}}return!r.def.unionFallback&&i>1&&((c=o[r.def.discriminator])==null||c.delete(void 0)),o}),e.options.forEach((r,o)=>{const i=Wx(r._zod.def);if(i&&!Object.prototype.hasOwnProperty.call(i,e.discriminator))throw new Error(`Invalid discriminated union option at index "${o}"`)});const s=wf(()=>tX(e));n._zod.parse=(r,o)=>{const i=r.value;if(!El(i))return r.issues.push({code:"invalid_type",expected:"object",input:i,inst:n}),r;const l=i==null?void 0:i[e.discriminator],c=s.value.get(l);return c&&(l!==void 0||o.direction!=="backward")?c._zod.run(r,o):e.unionFallback||o.direction==="backward"?t(r,o):(r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:e.discriminator,options:Array.from(s.value.keys()).filter(u=>s.value.get(u)!==null),input:i,path:[e.discriminator],inst:n}),r)}}),sX=ge("$ZodIntersection",(n,e)=>{At.init(n,e),n._zod.parse=(t,s)=>{const r=t.value,o=e.left._zod.run({value:r,issues:[]},s),i=e.right._zod.run({value:r,issues:[]},s);return o instanceof Promise||i instanceof Promise?Promise.all([o,i]).then(([c,u])=>T2(t,c,u)):T2(t,o,i)}});function lg(n,e){if(n===e)return{valid:!0,data:n};if(n instanceof Date&&e instanceof Date&&+n==+e)return{valid:!0,data:n};if(Ui(n)&&Ui(e)){const t=Object.keys(e),s=Object.keys(n).filter(o=>t.indexOf(o)!==-1),r={...n,...e};Object.prototype.hasOwnProperty.call(r,"__proto__")&&delete r.__proto__;for(const o of s){if(o==="__proto__")continue;const i=lg(n[o],e[o]);if(!i.valid)return{valid:!1,mergeErrorPath:[o,...i.mergeErrorPath]};r[o]=i.data}return{valid:!0,data:r}}if(Array.isArray(n)&&Array.isArray(e)){if(n.length!==e.length)return{valid:!1,mergeErrorPath:[]};const t=[];for(let s=0;s<n.length;s++){const r=n[s],o=e[s],i=lg(r,o);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};t.push(i.data)}return{valid:!0,data:t}}return{valid:!1,mergeErrorPath:[]}}function T2(n,e,t){const s=new Map;let r;const o=new Map,i=(u,d)=>{var m,p;let f;if(u.code==="unrecognized_keys"&&!((m=u.path)!=null&&m.length))r??(r=u),f=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&((p=u.path)==null?void 0:p.length)===1){const h=String(u.path[0]);o.has(h)||o.set(h,u),f=[h]}else return!1;for(const h of f)s.has(h)||s.set(h,{}),s.get(h)[d]=!0;return!0};for(const u of e.issues)i(u,"l")||n.issues.push(u);for(const u of t.issues)i(u,"r")||n.issues.push(u);const l=[...s].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(l.length){const u=r?l.filter(d=>r.keys.includes(d)):[];u.length&&n.issues.push({...r,keys:u});for(const d of l)!u.includes(d)&&o.has(d)&&n.issues.push(o.get(d))}const c=lg(e.value,t.value);if(!c.valid){if(jr(n))return n;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return n.value=c.data,n}const rX=ge("$ZodRecord",(n,e)=>{At.init(n,e);const t=Us.memoizer;t==null||t.attach(n),n._zod.parse=(s,r)=>{const o=s.value;if(!Ui(o))return s.issues.push({expected:"record",code:"invalid_type",input:o,inst:n}),s;const i=[],l=e.keyType._zod.values;if(l&&!e.partial){s.value=t?t.alloc(n,s,{},r):{};const c=new Set;for(const d of l)if(typeof d=="string"||typeof d=="number"||typeof d=="symbol"){if(c.add(typeof d=="number"?d.toString():d),d==="__proto__")continue;const f=e.keyType._zod.run({value:d,issues:[]},r);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(f.issues.length){s.issues.push({code:"invalid_key",origin:"record",issues:f.issues.map(h=>mo(h,r,ar())),input:d,path:[d],inst:n});continue}const m=f.value;if(m==="__proto__")continue;const p=e.valueType._zod.run({value:o[d],issues:[]},r);p instanceof Promise?i.push(p.then(h=>{h.issues.length&&s.issues.push(...bi(d,h.issues)),s.value[m]=h.value})):(p.issues.length&&s.issues.push(...bi(d,p.issues)),s.value[m]=p.value)}let u;for(const d in o)if(!c.has(d))if(e.mode==="loose"){if(d==="__proto__")continue;s.value[d]=o[d]}else u=u??[],u.push(d);u&&u.length>0&&s.issues.push({code:"unrecognized_keys",input:o,inst:n,keys:u,continue:!0})}else{s.value=t?t.alloc(n,s,{},r):{};let c;for(const u of Reflect.ownKeys(o)){if(u==="__proto__"||!Object.prototype.propertyIsEnumerable.call(o,u))continue;let d=e.keyType._zod.run({value:u,issues:[]},r);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof u=="string"&&Yx.test(u)&&d.issues.length){const h=e.keyType._zod.run({value:Number(u),issues:[]},r);if(h instanceof Promise)throw new Error("Async schemas not supported in object keys currently");h.issues.length===0&&(d=h)}if(d.issues.length){e.mode==="loose"?s.value[u]=o[u]:l?(c=c??[],c.push(u)):s.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(h=>mo(h,r,ar())),input:u,path:[u],inst:n});continue}const m=d.value;if(m==="__proto__")continue;const p=e.valueType._zod.run({value:o[u],issues:[]},r);p instanceof Promise?i.push(p.then(h=>{h.issues.length&&s.issues.push(...bi(u,h.issues)),s.value[m]=h.value})):(p.issues.length&&s.issues.push(...bi(u,p.issues)),s.value[m]=p.value)}c&&c.length>0&&s.issues.push({code:"unrecognized_keys",input:o,inst:n,keys:c,continue:!0})}return i.length?Promise.all(i).then(()=>s):s}}),oX=ge("$ZodEnum",(n,e)=>{At.init(n,e);const t=og(e.entries),s=new Set(t);n._zod.values=s,gt(n,"pattern",r=>{const o=og(r.def.entries).filter(i=>LG.has(typeof i));return new RegExp(o.length?`^(${o.map(i=>Bi(i.toString())).join("|")})$`:"^[^\\s\\S]$")}),n._zod.parse=(r,o)=>{const i=r.value;return s.has(i)||r.issues.push({code:"invalid_value",values:t,input:i,inst:n}),r}}),iX=ge("$ZodLiteral",(n,e)=>{At.init(n,e);const t=new Set(e.values);n._zod.values=t,gt(n,"pattern",s=>{const r=s.def.values;return new RegExp(r.length?`^(${r.map(o=>typeof o=="string"?Bi(o):o?Bi(o.toString()):String(o)).join("|")})$`:"^[^\\s\\S]$")}),n._zod.parse=(s,r)=>{const o=s.value;return t.has(o)||s.issues.push({code:"invalid_value",values:e.values,input:o,inst:n}),s}}),aX=ge("$ZodTransform",(n,e)=>{var t;At.init(n,e),n._zod.optin="optional",(t=Us.memoizer)==null||t.guard(n),n._zod.parse=(s,r)=>{if(r.direction==="backward")throw new U5(n.constructor.name);const o=e.transform(s.value,s);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(l=>(s.value=l,s));if(o instanceof Promise)throw new Do;return s.value=o,s}});function A2(n,e){return n.value=e.issues.length?void 0:e.value,n}const s_=ge("$ZodOptional",(n,e)=>{At.init(n,e),gt(n,"optin",t=>t.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),n._zod.optout="optional",gt(n,"values",t=>{const s=t.def.innerType._zod.values;return s?new Set([...s,void 0]):void 0}),gt(n,"pattern",t=>{const s=t.def.innerType._zod.pattern;return s?new RegExp(`^(${Bx(s.source)})?$`):void 0}),n._zod.parse=(t,s)=>{if(t.value===void 0){if(e.innerType._zod.optin!=="defaulted")return t;const r=e.innerType._zod.run({value:t.value,issues:[]},s);return r instanceof Promise?r.then(o=>A2(t,o)):A2(t,r)}return e.innerType._zod.run(t,s)}}),lX=ge("$ZodExactOptional",(n,e)=>{s_.init(n,e),gt(n,"values",t=>t.def.innerType._zod.values),gt(n,"pattern",t=>t.def.innerType._zod.pattern),n._zod.parse=(t,s)=>e.innerType._zod.run(t,s)}),cX=ge("$ZodNullable",(n,e)=>{At.init(n,e),gt(n,"optin",t=>t.def.innerType._zod.optin),gt(n,"optout",t=>t.def.innerType._zod.optout),gt(n,"pattern",t=>{const s=t.def.innerType._zod.pattern;return s?new RegExp(`^(${Bx(s.source)}|null)$`):void 0}),gt(n,"values",t=>t.def.innerType._zod.values?new Set([...t.def.innerType._zod.values,null]):void 0),n._zod.parse=(t,s)=>t.value===null?t:e.innerType._zod.run(t,s)}),uX=ge("$ZodDefault",(n,e)=>{At.init(n,e),n._zod.optin="defaulted",gt(n,"values",t=>t.def.innerType._zod.values),n._zod.parse=(t,s)=>{if(s.direction==="backward")return e.innerType._zod.run(t,s);if(t.value===void 0)return t.value=e.defaultValue,t;const r=e.innerType._zod.run(t,s);return r instanceof Promise?r.then(o=>P2(o,e)):P2(r,e)}});function P2(n,e){return n.value===void 0&&(n.value=e.defaultValue),n}const dX=ge("$ZodPrefault",(n,e)=>{At.init(n,e),n._zod.optin="defaulted",gt(n,"values",t=>t.def.innerType._zod.values),n._zod.parse=(t,s)=>(s.direction==="backward"||t.value===void 0&&(t.value=e.defaultValue),e.innerType._zod.run(t,s))}),fX=ge("$ZodNonOptional",(n,e)=>{At.init(n,e),gt(n,"values",t=>{const s=t.def.innerType._zod.values;return s?new Set([...s].filter(r=>r!==void 0)):void 0}),n._zod.parse=(t,s)=>{const r=e.innerType._zod.run(t,s);return r instanceof Promise?r.then(o=>I2(o,n)):I2(r,n)}});function I2(n,e){return!n.issues.length&&n.value===void 0&&n.issues.push({code:"invalid_type",expected:"nonoptional",input:n.value,inst:e}),n}function $2(n,e,t,s){return e.issues.length?(n.value=t.catchValue({...e,value:n.value,error:{issues:e.issues.map(r=>mo(r,s,ar()))},input:n.value}),n):(n.value=e.value,e.memo&&(n.memo=!0),n)}const mX=ge("$ZodCatch",(n,e)=>{At.init(n,e),gt(n,"optin",t=>t.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),gt(n,"optout",t=>t.def.innerType._zod.optout),gt(n,"values",t=>t.def.innerType._zod.values),n._zod.parse=(t,s)=>{if(s.direction==="backward")return e.innerType._zod.run(t,s);const r=e.innerType._zod.run({value:t.value,issues:[]},s);return r instanceof Promise?r.then(o=>$2(t,o,e,s)):$2(t,r,e,s)}}),pX=ge("$ZodPipe",(n,e)=>{At.init(n,e),gt(n,"values",t=>t.def.in._zod.values),gt(n,"optin",t=>t.def.in._zod.optin),gt(n,"optout",t=>t.def.out._zod.optout),gt(n,"propValues",t=>t.def.in._zod.propValues),n._zod.parse=(t,s)=>{if(s.direction==="backward"){const o=e.out._zod.run(t,s);return o instanceof Promise?o.then(i=>Kc(i,e.in,s)):Kc(o,e.in,s)}const r=e.in._zod.run(t,s);return r instanceof Promise?r.then(o=>Kc(o,e.out,s)):Kc(r,e.out,s)}});function Kc(n,e,t){return n.issues.some(s=>s.code!=="unrecognized_keys")?(n.aborted=!0,n):e._zod.run({value:n.value,issues:n.issues},t)}const hX=ge("$ZodReadonly",(n,e)=>{At.init(n,e),gt(n,"propValues",t=>t.def.innerType._zod.propValues),gt(n,"values",t=>t.def.innerType._zod.values),gt(n,"optin",t=>{var s,r;return(r=(s=t.def.innerType)==null?void 0:s._zod)==null?void 0:r.optin}),gt(n,"optout",t=>{var s,r;return(r=(s=t.def.innerType)==null?void 0:s._zod)==null?void 0:r.optout}),n._zod.parse=(t,s)=>{if(s.direction==="backward")return e.innerType._zod.run(t,s);const r=e.innerType._zod.run(t,s);return r instanceof Promise?r.then(R2):R2(r)}});function R2(n){return n.memo||(n.value=Object.freeze(n.value)),n}const gX=ge("$ZodCustom",(n,e)=>{Jn.init(n,e),At.init(n,e),n._zod.parse=(t,s)=>t,n._zod.check=t=>{const s=t.value,r=e.fn(s);if(r instanceof Promise)return r.then(o=>O2(o,t,s,n));O2(r,t,s,n)}});function O2(n,e,t,s){if(!n){const r={code:"custom",input:t,inst:s,path:[...s._zod.def.path??[]],continue:!s._zod.def.abort};s._zod.def.params&&(r.params=s._zod.def.params),e.issues.push(Tl(r))}}class xX extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}const cg="~memo",L2=[];function r_(n){return n!==null&&typeof n=="object"}function Om(n){return n.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}const o_=new WeakMap,$a=0,Au=1,tl=2;function Pu(n,e,t){const s=o_.get(n);if(s!==void 0)return s?tl:$a;if(e.has(n))return tl;e.add(n);let r=$a;const o=d=>{if(r!==tl&&(d!=null&&d._zod)){const f=Pu(d,e);f>r&&(r=f)}},i=(d,f)=>{var p;let m=$a;for(const h of Reflect.ownKeys(d)){const g=Object.getOwnPropertyDescriptor(d,h);if(!g.enumerable)continue;const x=g.get?Au:(p=g.value)!=null&&p._zod?Pu(g.value,e):$a;x>m&&(m=x)}return m},l=d=>{d>r&&(r=d)},c=n._zod.def;switch(c.type){case"object":{const d=Wx(c);l(d?i(d):Au),o(c.catchall);break}case"array":o(c.element);break;case"tuple":for(const d of c.items)o(d);o(c.rest);break;case"record":case"map":o(c.keyType),o(c.valueType);break;case"set":o(c.valueType);break;case"union":for(const d of c.options)o(d);break;case"intersection":o(c.left),o(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":o(c.innerType);break;case"pipe":o(c.in),o(c.out);break;case"function":o(c.input),o(c.output);break;case"lazy":{const d=c._cachedInner??void 0;l(d?Pu(d,e):Au);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(const d in c){const f=Object.getOwnPropertyDescriptor(c,d);if(!f||f.get)continue;const m=f.value;if(!(!m||typeof m!="object")){if(m._zod)o(m);else if(Array.isArray(m))for(const p of m)o(p)}}}return e.delete(n),bX(n,r)}function bX(n,e){return e!==Au&&o_.set(n,e===tl),e}function vX(n,e){let t=n.buckets.get(e);return t||(t=new WeakMap,n.buckets.set(e,t)),t}let Gc;const Zc=[],yX={alloc(n,e,t){const s=Gc;if(!s)return t;Gc=void 0;const r={value:t,issues:null};return s.set(e.value,r),Zc.push(r),t},guard(n){var e;(e=n._zod).deferred??(e.deferred=[]),n._zod.deferred.push(()=>{const t=n._zod.parse,s=(r,o)=>{if(o.direction!=="backward"&&SX(o,r.value))throw new xX;return t(r,o)};n._zod.parse=s,n._zod.run===t&&(n._zod.run=s)})},attach(n){var e;let t,s=!1,r,o;(e=n._zod).deferred??(e.deferred=[]),n._zod.deferred.push(()=>{const i=n._zod.parse,l=(c,u)=>{if(t===void 0){const b=Pu(n,new Set);if(b===$a)return n._zod.parse=i,n._zod.run===l&&(n._zod.run=i),i(c,u);b===tl||s?t=!0:s=!0}const d=c.value;if(!r_(d))return i(c,u);let f=u[cg];f||(f={buckets:new WeakMap,backEdges:void 0},u[cg]=f);let m;r===u?m=o:(m=vX(f,n),r=u,o=m);const p=m.get(d);if(p)return c.value=p.value,p.issues?p.issues.length&&c.issues.push(...Om(p.issues)):(c.memo=!0,f.backEdges??(f.backEdges=new WeakSet),f.backEdges.add(p.value)),c;Gc=m;const h=Zc.length,g=i(c,u);Gc=void 0;const x=Zc.length>h?Zc.pop():void 0;return g instanceof Promise?g.then(b=>(x&&(x.issues=b.issues.length?Om(b.issues):L2),b)):(x&&(x.issues=g.issues.length?Om(g.issues):L2),g)};n._zod.parse=l,n._zod.run===i&&(n._zod.run=l)})}};function wX(){return yX}function SX(n,e){var s;const t=(s=n[cg])==null?void 0:s.backEdges;return t!==void 0&&r_(e)&&t.has(e)}const kX=()=>{const n={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function e(o){return n[o]??null}const t={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},s={nan:"NaN"};function r(o,i){return o==="number"&&typeof i=="number"&&!Number.isFinite(i)?String(i):s[o]??o}return o=>{switch(o.code){case"invalid_type":{const i=r(o.expected),l=KG(o.input),c=r(l,o.input);return`Invalid input: expected ${i}, received ${c}`}case"invalid_value":return o.values.length===1?`Invalid input: expected ${L5(o.values[0])}`:`Invalid option: expected one of ${v2(o.values,"|")}`;case"too_big":{const i=o.exact?"exactly ":o.inclusive?"<=":"<",l=e(o.origin);return l?`Too big: expected ${o.origin??"value"} to have ${i}${o.maximum.toString()} ${l.unit??"elements"}`:`Too big: expected ${o.origin??"value"} to be ${i}${o.maximum.toString()}`}case"too_small":{const i=o.exact?"exactly ":o.inclusive?">=":">",l=e(o.origin);return l?`Too small: expected ${o.origin} to have ${i}${o.minimum.toString()} ${l.unit}`:`Too small: expected ${o.origin} to be ${i}${o.minimum.toString()}`}case"invalid_format":{const i=o;return i.format==="starts_with"?`Invalid string: must start with "${i.prefix}"`:i.format==="ends_with"?`Invalid string: must end with "${i.suffix}"`:i.format==="includes"?`Invalid string: must include "${i.includes}"`:i.format==="regex"?`Invalid string: must match pattern ${i.pattern}`:`Invalid ${t[i.format]??o.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${o.divisor}`;case"unrecognized_keys":return`Unrecognized key${o.keys.length>1?"s":""}: ${v2(o.keys,", ")}`;case"invalid_key":return`Invalid key in ${o.origin}`;case"invalid_union":return o.options&&Array.isArray(o.options)&&o.options.length>0?`Invalid discriminator value. Expected ${o.options.map(l=>`'${l}'`).join(" | ")}`:o.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${o.origin}`;default:return"Invalid input"}}};function jX(){return{localeError:kX()}}var M2;class NX{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const s=t[0];return this._map.set(e,s),s&&typeof s=="object"&&"id"in s&&this._idmap.set(s.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&typeof t=="object"&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const s={...this.get(t)??{}};delete s.id;const r={...s,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function CX(){return new NX}(M2=globalThis).__zod_globalRegistry??(M2.__zod_globalRegistry=CX());const Ra=globalThis.__zod_globalRegistry;function i_(n){return n.checks&&(n.checks=[...n.checks]),n}function _X(n,e){return new n(i_({type:"string",...Ve(e)}))}function EX(n,e){return new n({type:"string",format:"email",check:"string_format",abort:!1,...Ve(e)})}function TX(n,e){return new n({type:"string",format:"guid",check:"string_format",abort:!1,...Ve(e)})}function AX(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,...Ve(e)})}function PX(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Ve(e)})}function IX(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Ve(e)})}function $X(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Ve(e)})}function RX(n,e){return new n({type:"string",format:"url",check:"string_format",abort:!1,...Ve(e)})}function OX(n,e){return new n({type:"string",format:"emoji",check:"string_format",abort:!1,...Ve(e)})}function LX(n,e){return new n({type:"string",format:"nanoid",check:"string_format",abort:!1,...Ve(e)})}function MX(n,e){return new n({type:"string",format:"cuid",check:"string_format",abort:!1,...Ve(e)})}function zX(n,e){return new n({type:"string",format:"cuid2",check:"string_format",abort:!1,...Ve(e)})}function DX(n,e){return new n({type:"string",format:"ulid",check:"string_format",abort:!1,...Ve(e)})}function FX(n,e){return new n({type:"string",format:"xid",check:"string_format",abort:!1,...Ve(e)})}function UX(n,e){return new n({type:"string",format:"ksuid",check:"string_format",abort:!1,...Ve(e)})}function BX(n,e){return new n({type:"string",format:"ipv4",check:"string_format",abort:!1,...Ve(e)})}function WX(n,e){return new n({type:"string",format:"ipv6",check:"string_format",abort:!1,...Ve(e)})}function qX(n,e){return new n({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Ve(e)})}function VX(n,e){return new n({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Ve(e)})}function HX(n,e){return new n({type:"string",format:"base64",check:"string_format",abort:!1,...Ve(e)})}function KX(n,e){return new n({type:"string",format:"base64url",check:"string_format",abort:!1,...Ve(e)})}function GX(n,e){return new n({type:"string",format:"e164",check:"string_format",abort:!1,...Ve(e)})}function ZX(n,e){return new n({type:"string",format:"jwt",check:"string_format",abort:!1,...Ve(e)})}function YX(n,e){return new n({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Ve(e)})}function XX(n,e){return new n({type:"string",format:"date",check:"string_format",...Ve(e)})}function JX(n,e){return new n({type:"string",format:"time",check:"string_format",precision:null,...Ve(e)})}function QX(n,e){return new n({type:"string",format:"duration",check:"string_format",...Ve(e)})}function eJ(n,e){return new n(i_({type:"number",checks:[],...Ve(e)}))}function tJ(n,e){return new n({type:"number",check:"number_format",abort:!1,format:"safeint",...Ve(e)})}function nJ(n,e){return new n({type:"boolean",...Ve(e)})}function sJ(n,e){return new n({type:"null",...Ve(e)})}function rJ(n){return new n({type:"unknown"})}function oJ(n,e){return new n({type:"never",...Ve(e)})}function z2(n,e){return new q5({check:"less_than",...Ve(e),value:n,inclusive:!1})}function Lm(n,e){return new q5({check:"less_than",...Ve(e),value:n,inclusive:!0})}function D2(n,e){return new V5({check:"greater_than",...Ve(e),value:n,inclusive:!1})}function Mm(n,e){return new V5({check:"greater_than",...Ve(e),value:n,inclusive:!0})}function F2(n,e){return new QZ({check:"multiple_of",...Ve(e),value:n})}function a_(n,e){return new tY({check:"max_length",...Ve(e),maximum:n})}function hd(n,e){return new nY({check:"min_length",...Ve(e),minimum:n})}function l_(n,e){return new sY({check:"length_equals",...Ve(e),length:n})}function iJ(n,e){return new rY({check:"string_format",format:"regex",...Ve(e),pattern:n})}function aJ(n){return new oY({check:"string_format",format:"lowercase",...Ve(n)})}function lJ(n){return new iY({check:"string_format",format:"uppercase",...Ve(n)})}function cJ(n,e){return new aY({check:"string_format",format:"includes",...Ve(e),includes:n})}function uJ(n,e){return new lY({check:"string_format",format:"starts_with",...Ve(e),prefix:n})}function dJ(n,e){return new cY({check:"string_format",format:"ends_with",...Ve(e),suffix:n})}function ca(n){return new uY({check:"overwrite",tx:n})}function fJ(n){return ca(e=>e.normalize(n))}function mJ(){return ca(n=>n.trim())}function pJ(){return ca(n=>n.toLowerCase())}function hJ(){return ca(n=>n.toUpperCase())}function gJ(){return ca(n=>RG(n))}function xJ(n,e,t){return new n({type:"array",element:e,...Ve(t)})}function bJ(n,e,t){const s=Ve(t);return s.abort??(s.abort=!0),new n({type:"custom",check:"custom",fn:e,...s})}function vJ(n,e,t){return new n({type:"custom",check:"custom",fn:e,...Ve(t)})}function yJ(n,e){const t=wJ(s=>(s.addIssue=r=>{if(typeof r=="string")s.issues.push(Tl(r,s.value,t._zod.def));else{const o=r;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),"input"in o||(o.input=s.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),s.issues.push(Tl(o))}},n(s.value,s)),e);return t}function wJ(n,e){const t=new Jn({check:"custom",...Ve(e)});return t._zod.check=n,t}function nl(n,...e){for(const t of e)for(const s of Reflect.ownKeys(t))Object.prototype.propertyIsEnumerable.call(t,s)&&zr(n,s,t[s]);return n}function c_(n){let e=(n==null?void 0:n.target)??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:n.processors??{},metadataRegistry:(n==null?void 0:n.metadata)??Ra,target:e,unrepresentable:(n==null?void 0:n.unrepresentable)??"throw",override:(n==null?void 0:n.override)??(()=>{}),io:(n==null?void 0:n.io)??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:(n==null?void 0:n.cycles)??"ref",reused:(n==null?void 0:n.reused)??"inline",intersections:[],deferred:[],external:(n==null?void 0:n.external)??void 0}}function ho(n,e,t,s,r){const o=typeof e.unrepresentable=="function"?e.unrepresentable({zodSchema:n,path:s.path,message:r}):e.unrepresentable;if(o==="any")return!1;if(o===void 0||o==="throw")throw new Error(r);return Object.assign(t,o),!0}function tn(n,e,t={path:[],schemaPath:[]}){var d,f;var s;const r=n._zod.def,o=e.seen.get(n);if(o)return o.count++,t.schemaPath.includes(n)&&(o.cycle=t.path),o.schema;const i={schema:{},count:1,cycle:void 0,path:t.path};e.seen.set(n,i),e.sharedDefsExtractedFor=void 0,e.sharedEmitDoneFor=void 0;const l=(f=(d=n._zod).toJSONSchema)==null?void 0:f.call(d);if(l)i.schema=l;else{const m={...t,schemaPath:[...t.schemaPath,n],path:t.path};if(n._zod.processJSONSchema)n._zod.processJSONSchema(e,i.schema,m);else{const h=i.schema,g=e.processors[r.type];if(!g)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);g(n,e,h,m)}const p=n._zod.parent;p&&(i.ref||(i.ref=p),tn(p,e,m),e.seen.get(p).isParent=!0)}const c=e.metadataRegistry.get(n);return c&&nl(i.schema,c),e.io==="input"&&Dn(n)&&(delete i.schema.examples,delete i.schema.default),e.io==="input"&&"_prefault"in i.schema&&((s=i.schema).default??(s.default=i.schema._prefault)),delete i.schema._prefault,e.seen.get(n).schema}function U2(n){return n.replace(/~/g,"~0").replace(/\//g,"~1")}function u_(n,e){var i,l,c,u;const t=n.seen.get(e);if(!t)throw new Error("Unprocessed schema. This is a bug in Zod.");if(n.external&&n.sharedDefsExtractedFor===n.external)return;const s=new Map;for(const d of n.seen.entries()){const f=(i=n.metadataRegistry.get(d[0]))==null?void 0:i.id;if(f){const m=s.get(f);if(m&&m!==d[0])throw new Error(`Duplicate schema id "${f}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);s.set(f,d[0])}}const r=d=>{var g;const f=n.target==="draft-2020-12"?"$defs":"definitions";if(n.external){const x=(g=n.external.registry.get(d[0]))==null?void 0:g.id,b=n.external.uri??(v=>v);if(x)return{ref:b(x)};const y=d[1].defId??d[1].schema.id??`schema${n.counter++}`;return d[1].defId=y,{defId:y,ref:`${b("__shared")}#/${f}/${U2(y)}`}}const m="#",p=`${m}/${f}/`;if(d[1]===t&&!d[1].schema.id)return{ref:m};const h=d[1].schema.id??`__schema${n.counter++}`;return{defId:h,ref:p+U2(h)}},o=d=>{if(d[1].schema.$ref)return;const f=d[1],{ref:m,defId:p}=r(d);f.def={...f.schema},p&&(f.defId=p);const h=f.schema;for(const g in h)delete h[g];h.$ref=m};if(n.cycles==="throw")for(const d of n.seen.entries()){const f=d[1];if(f.cycle)throw new Error(`Cycle detected: #/${(l=f.cycle)==null?void 0:l.join("/")}/<root>
|
|
175
|
+
|
|
176
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const d of n.seen.entries()){const f=d[1];if(e===d[0]){o(d);continue}if(n.external){const p=(c=n.external.registry.get(d[0]))==null?void 0:c.id;if(e!==d[0]&&p){o(d);continue}}if((u=n.metadataRegistry.get(d[0]))==null?void 0:u.id){o(d);continue}if(f.cycle){o(d);continue}f.count>1&&n.reused==="ref"&&o(d)}n.external&&(n.sharedDefsExtractedFor=n.external)}function d_(n){const e=n.anyOf;if(!Array.isArray(e)||e.length===0||n.type!==void 0)return;const t=[];for(const s of e){if(!s||typeof s!="object")return;d_(s);const r=Object.keys(s);if(r.length!==1||r[0]!=="type")return;const o=s.type;for(const i of Array.isArray(o)?o:[o]){if(typeof i!="string")return;t.includes(i)||t.push(i)}}delete n.anyOf,n.type=t.length===1?t[0]:t}const f_=new Set(["type","properties","required","additionalProperties"]),B2=["oneOf","anyOf"];function W2(n){const e=n.additionalProperties;return e===void 0||e===!1||typeof e!="object"||e===null?null:Object.keys(e).length?e:null}function ug(n){var o;const e=[];for(const i of n){if(typeof i!="object"||i.type!=="object")return null;for(const l in i)if(!f_.has(l))return null;e.push(i)}const t={},s=new Set;for(const i of e){for(const l in i.properties){if(Object.prototype.hasOwnProperty.call(t,l))continue;const c=[];for(const d of e){const f=((o=d.properties)==null?void 0:o[l])??W2(d);f!=null&&(c.some(m=>JSON.stringify(m)===JSON.stringify(f))||c.push(f))}const u=c.length===1?c[0]:ug(c)??{allOf:c};zr(t,l,u)}for(const l of i.required??[])s.add(l)}const r={type:"object",properties:t};if(s.size&&(r.required=[...s]),e.every(i=>i.additionalProperties===!1))r.additionalProperties=!1;else{const i=[];for(const l of e){const c=W2(l);c&&!i.some(u=>JSON.stringify(u)===JSON.stringify(c))&&i.push(c)}i.length===1?r.additionalProperties=i[0]:i.length>1&&(r.additionalProperties={allOf:i})}return r}function SJ(n){const e=n.allOf;if(!Array.isArray(e)||e.length<2)return;for(const r of f_)if(r in n)return;const t=e.filter(r=>B2.some(o=>Array.isArray(r[o])));let s=null;if(!t.length)s=ug(e);else{const r=t[0],o=B2.find(c=>Array.isArray(r[c]));if(Object.keys(r).length!==1)return;const i=e.filter(c=>c!==r),l=r[o].map(c=>ug([...i,c]));if(l.some(c=>!c))return;s={[o]:l}}s&&(delete n.allOf,nl(n,s))}function m_(n,e){var l,c,u,d;const t=n.seen.get(e);if(!t)throw new Error("Unprocessed schema. This is a bug in Zod.");const s=f=>{const m=n.seen.get(f);if(m.ref===null)return;const p=m.def??m.schema,h={...p},g=m.ref;if(m.ref=null,g){s(g);const b=n.seen.get(g),y=b.schema;if(y.$ref&&(n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0")?(p.allOf=p.allOf??[],p.allOf.push(y)):nl(p,y),nl(p,h),f._zod.parent===g)for(const k in p)k==="$ref"||k==="allOf"||k in h||delete p[k];if(y.$ref&&b.def)for(const k in p)k==="$ref"||k==="allOf"||k in b.def&&JSON.stringify(p[k])===JSON.stringify(b.def[k])&&delete p[k]}const x=f._zod.parent;if(x&&x!==g){s(x);const b=n.seen.get(x);if(b!=null&&b.schema.$ref&&(p.$ref=b.schema.$ref,b.def))for(const y in p)y==="$ref"||y==="allOf"||y in b.def&&JSON.stringify(p[y])===JSON.stringify(b.def[y])&&delete p[y]}n.override({zodSchema:f,jsonSchema:p,path:m.path??[]})};if(!n.external||n.sharedEmitDoneFor!==n.external){for(const f of[...n.seen.entries()].reverse())s(f[0]);if(n.target!=="openapi-3.0")for(const f of n.seen.entries())d_(f[1].def??f[1].schema);for(const f of n.deferred)f();if(n.intersections.length){const f=new Map;for(const m of n.seen.values())for(const p of[m.schema,m.def]){const h=p==null?void 0:p.allOf;if(!Array.isArray(h))continue;const g=f.get(h);g?g.push(p):f.set(h,[p])}for(const m of n.intersections)for(const p of f.get(m)??[])SJ(p)}}const r={};if(n.target==="draft-2020-12"?r.$schema="https://json-schema.org/draft/2020-12/schema":n.target==="draft-07"?r.$schema="http://json-schema.org/draft-07/schema#":n.target==="draft-04"?r.$schema="http://json-schema.org/draft-04/schema#":n.target,(l=n.external)!=null&&l.uri){const f=(c=n.external.registry.get(e))==null?void 0:c.id;if(!f)throw new Error("Schema is missing an `id` property");r.$id=n.external.uri(f)}nl(r,t.defId?t.schema:t.def??t.schema);const o=(u=n.metadataRegistry.get(e))==null?void 0:u.id;o!==void 0&&r.id===o&&delete r.id;const i=((d=n.external)==null?void 0:d.defs)??{};if(!n.external||n.sharedEmitDoneFor!==n.external)for(const f of n.seen.entries()){const m=f[1];m.def&&m.defId&&(m.def.id===m.defId&&delete m.def.id,zr(i,m.defId,m.def))}n.external&&(n.sharedEmitDoneFor=n.external),n.external||Object.keys(i).length>0&&(n.target==="draft-2020-12"?r.$defs=i:r.definitions=i);try{const f=JSON.parse(JSON.stringify(r));return Object.defineProperty(f,"~standard",{value:{...e["~standard"],jsonSchema:{input:gd(e,"input",n.processors),output:gd(e,"output",n.processors)}},enumerable:!1,writable:!1}),f}catch{throw new Error("Error converting schema to JSON.")}}function Dn(n,e){const t=e??{seen:new Set};if(t.seen.has(n))return!1;t.seen.add(n);const s=n._zod.def;if(s.type==="transform")return!0;if(s.type==="array")return Dn(s.element,t);if(s.type==="set")return Dn(s.valueType,t);if(s.type==="lazy")return Dn(s.getter(),t);if(s.type==="promise"||s.type==="optional"||s.type==="nonoptional"||s.type==="nullable"||s.type==="readonly"||s.type==="default"||s.type==="prefault"||s.type==="catch")return Dn(s.innerType,t);if(s.type==="intersection")return Dn(s.left,t)||Dn(s.right,t);if(s.type==="record"||s.type==="map")return Dn(s.keyType,t)||Dn(s.valueType,t);if(s.type==="pipe")return n._zod.traits.has("$ZodCodec")?!0:Dn(s.in,t)||Dn(s.out,t);if(s.type==="object"){for(const r in s.shape)if(Dn(s.shape[r],t))return!0;return!1}if(s.type==="union"){for(const r of s.options)if(Dn(r,t))return!0;return!1}if(s.type==="tuple"){for(const r of s.items)if(Dn(r,t))return!0;return!!(s.rest&&Dn(s.rest,t))}return!1}const kJ=(n,e={})=>t=>{const s=c_({...t,processors:e});return tn(n,s),u_(s,n),m_(s,n)},gd=(n,e,t={})=>s=>{const{libraryOptions:r,target:o}=s??{},i=c_({...r??{},target:o,io:e,processors:t});return tn(n,i),u_(i,n),m_(i,n)},Wi=(n,e,t)=>{(n[e]===void 0||t>n[e])&&(n[e]=t)},qi=(n,e,t)=>{(n[e]===void 0||t<n[e])&&(n[e]=t)},q2=(n,e)=>{Wi(n,"minimum",e),qi(n,"maximum",e)},p_=(n,e)=>{n.multipleOf??(n.multipleOf=[]),n.multipleOf.includes(e)||n.multipleOf.push(e)},h_=(n,e)=>{n.patterns??(n.patterns=new Set),n.patterns.add(e)},g_=(n,e)=>{n.mime=n.mime?n.mime.filter(t=>e.includes(t)):[...e]},x_=(n,e)=>{n.format=e,e.includes("int")&&(n.isInt=!0)},V2=(n,e)=>Wi(n,"minimum",e.minimum),H2=(n,e)=>qi(n,"maximum",e.maximum),K2=n=>(e,t)=>{x_(e,t.format);const[s,r]=n[t.format];Wi(e,"minimum",s),qi(e,"maximum",r)},zm={greater_than:(n,e)=>Wi(n,e.inclusive?"minimum":"exclusiveMinimum",e.value),less_than:(n,e)=>qi(n,e.inclusive?"maximum":"exclusiveMaximum",e.value),multiple_of:(n,e)=>p_(n,e.value),number_format:K2(M5),bigint_format:K2(zG),min_length:V2,max_length:H2,length_equals:(n,e)=>q2(n,e.length),min_size:V2,max_size:H2,size_equals:(n,e)=>q2(n,e.size),string_format:(n,e)=>{x_(n,e.format),e.pattern&&h_(n,e.pattern),(e.format==="base64"||e.format==="base64url")&&(n.contentEncoding=e.format),(e.local||e.precision===-1)&&(n.laxFormat=!0)},mime_type:(n,e)=>g_(n,e.mime)};function $s(n){var o;const e={},t=n._zod.def,s=n._zod.traits.has("$ZodCheck")?[n,...t.checks??[]]:t.checks??[];for(const i of s)(o=zm[i._zod.def.check])==null||o.call(zm,e,i._zod.def);const r=n._zod.bag;r.minimum!==void 0&&Wi(e,"minimum",r.minimum),r.exclusiveMinimum!==void 0&&Wi(e,"exclusiveMinimum",r.exclusiveMinimum),r.maximum!==void 0&&qi(e,"maximum",r.maximum),r.exclusiveMaximum!==void 0&&qi(e,"exclusiveMaximum",r.exclusiveMaximum),r.multipleOf!==void 0&&p_(e,r.multipleOf),r.format!==void 0&&(e.format??(e.format=r.format),r.format.includes("int")&&(e.isInt=!0)),r.mime&&g_(e,r.mime);for(const i of r.patterns??[])h_(e,i);return e}const jJ={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},NJ=new Map([[J5,DZ],[Qx,FZ]]),b_=n=>NJ.get(n)??n,CJ=(n,e,t,s)=>{const r=t;r.type="string";const{minimum:o,maximum:i,format:l,patterns:c,contentEncoding:u,laxFormat:d}=$s(n);if(typeof o=="number"&&(r.minLength=o),typeof i=="number"&&(r.maxLength=i),l&&(r.format=jJ[l]??l,r.format===""&&delete r.format,(l==="time"||d)&&delete r.format),u&&(r.contentEncoding=u),c&&c.size>0){const f=[...c].map(b_);f.length===1?r.pattern=f[0].source:f.length>1&&(r.allOf=[...f.map(m=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))])}},_J=(n,e,t,s)=>{const r=t,{minimum:o,maximum:i,multipleOf:l,exclusiveMaximum:c,exclusiveMinimum:u,isInt:d}=$s(n);r.type=d?"integer":"number";const f=typeof u=="number"&&u>=(o??Number.NEGATIVE_INFINITY),m=typeof c=="number"&&c<=(i??Number.POSITIVE_INFINITY),p=e.target==="draft-04"||e.target==="openapi-3.0";if(f?p?(r.minimum=u,r.exclusiveMinimum=!0):r.exclusiveMinimum=u:typeof o=="number"&&(r.minimum=o),m?p?(r.maximum=c,r.exclusiveMaximum=!0):r.exclusiveMaximum=c:typeof i=="number"&&(r.maximum=i),l){const h=new Set;for(const b of l)Number.isFinite(b)&&b!==0?h.add(Math.abs(b)):ho(n,e,r,s,`A multipleOf divisor of ${b} cannot be represented in JSON Schema`);const[g,...x]=h;g!==void 0&&(r.multipleOf=g),x.length&&(r.allOf=[...r.allOf??[],...x.map(b=>({multipleOf:b}))])}},EJ=(n,e,t,s)=>{t.type="boolean"},TJ=(n,e,t,s)=>{e.target==="openapi-3.0"?(t.type="string",t.nullable=!0,t.enum=[null]):t.type="null"},AJ=(n,e,t,s)=>{t.not={}},PJ=(n,e,t,s)=>{},IJ=(n,e,t,s)=>{const r=n._zod.def,o=og(r.entries);if(o.length===0){t.not={};return}o.every(i=>typeof i=="number")&&(t.type="number"),o.every(i=>typeof i=="string")&&(t.type="string"),t.enum=o},$J=(n,e,t,s)=>{const r=n._zod.def;if(r.values.length===0){t.not={};return}const o=[];for(const i of r.values)if(i===void 0){if(ho(n,e,t,s,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof i=="bigint"){if(ho(n,e,t,s,"BigInt literals cannot be represented in JSON Schema"))return;o.push(Number(i))}else o.push(i);if(o.length!==0)if(o.length===1){const i=o[0];t.type=i===null?"null":typeof i,e.target==="draft-04"||e.target==="openapi-3.0"?t.enum=[i]:t.const=i}else o.every(i=>typeof i=="number")&&(t.type="number"),o.every(i=>typeof i=="string")&&(t.type="string"),o.every(i=>typeof i=="boolean")&&(t.type="boolean"),o.every(i=>i===null)&&(t.type="null"),t.enum=o},RJ=(n,e,t,s)=>{ho(n,e,t,s,"Custom types cannot be represented in JSON Schema")},OJ=(n,e,t,s)=>{ho(n,e,t,s,"Transforms cannot be represented in JSON Schema")},LJ=(n,e,t,s)=>{const r=t,o=n._zod.def,{minimum:i,maximum:l}=$s(n);typeof i=="number"&&(r.minItems=i),typeof l=="number"&&(r.maxItems=l),r.type="array",r.items=tn(o.element,e,{...s,path:[...s.path,"items"]})};function xd(n){const e=n._zod.def;return e.type==="pipe"&&e.in._zod.traits.has("$ZodTransform")?xd(e.out):e.type==="catch"?xd(e.innerType):n._zod.optin}const MJ=(n,e,t,s)=>{var u;const r=t,o=n._zod.def,i=o.shape;if(Object.getOwnPropertySymbols(i).length&&ho(n,e,r,s,"Symbol keys cannot be represented in JSON Schema"))return;r.type="object",r.properties={};for(const d in i)zr(r.properties,d,tn(i[d],e,{...s,path:[...s.path,"properties",d]}));const c=[];for(const d of Object.keys(i)){const f=o.shape[d];(e.io==="input"?xd(f)===void 0:f._zod.optout===void 0)&&c.push(d)}c.length>0&&(r.required=c),((u=o.catchall)==null?void 0:u._zod.def.type)==="never"?r.additionalProperties=!1:o.catchall?o.catchall&&(r.additionalProperties=tn(o.catchall,e,{...s,path:[...s.path,"additionalProperties"]})):e.io==="output"&&(r.additionalProperties=!1)},zJ=(n,e,t,s)=>{const r=n._zod.def,o=r.inclusive===!1,i=r.options.map((l,c)=>tn(l,e,{...s,path:[...s.path,o?"oneOf":"anyOf",c]}));o?t.oneOf=i:t.anyOf=i},DJ=(n,e,t,s)=>{const r=n._zod.def,o=tn(r.left,e,{...s,path:[...s.path,"allOf",0]}),i=tn(r.right,e,{...s,path:[...s.path,"allOf",1]}),l=u=>"allOf"in u&&Object.keys(u).length===1,c=[...l(o)?o.allOf:[o],...l(i)?i.allOf:[i]];t.allOf=c,e.intersections.push(c)};function dg(n,e,t){var h;if(e.$ref){if(t.has(e))return e;t.add(e);const g=(h=n.get(e))==null?void 0:h.def;if(!g)return e;const x=dg(n,g,t);return x===g?e:x}for(const g of["anyOf","oneOf"]){const x=e[g];if(!Array.isArray(x))continue;const b=x.map(y=>dg(n,y,t));b.some((y,v)=>y!==x[v])&&(e={...e,[g]:b})}const s=Array.isArray(e.type)?e.type:[e.type],r=!s.includes("string")&&s.some(g=>g==="number"||g==="integer"),o=e.enum??(e.const!==void 0?[e.const]:void 0);if(!r&&!(o!=null&&o.some(g=>typeof g=="number")))return e;const{minimum:i,maximum:l,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:d,format:f,id:m,...p}=e;return p.enum?p.enum=p.enum.map(g=>typeof g=="number"?String(g):g):typeof p.const=="number"&&(p.const=String(p.const)),r&&(p.type="string",o||(p.pattern=(s.includes("number")?Yx:GZ).source)),p}const fg=new WeakMap;function FJ(n){var s;const e=new Map;for(const r of n.seen.values())r.def&&!e.has(r.schema)&&e.set(r.schema,r);const t=new Map;for(const r of fg.get(n)??[]){const o=n.seen.get(r),i=(s=(o==null?void 0:o.def)??(o==null?void 0:o.schema))==null?void 0:s.propertyNames;if(!i||i===!0||t.has(i))continue;const l=dg(e,i,new Set);l!==i&&t.set(i,l)}if(t.size)for(const r of n.seen.values())for(const o of[r.schema,r.def]){const i=o&&t.get(o.propertyNames);i&&(o.propertyNames=i)}}const UJ=(n,e,t,s)=>{const r=t,o=n._zod.def;r.type="object";const i=o.keyType,l=$s(i).patterns;if(o.mode==="loose"&&l&&l.size>0){const d=tn(o.valueType,e,{...s,path:[...s.path,"patternProperties","*"]});r.patternProperties={};for(const f of l)zr(r.patternProperties,b_(f).source,d)}else{if(e.target==="draft-07"||e.target==="draft-2020-12"){r.propertyNames=tn(o.keyType,e,{...s,path:[...s.path,"propertyNames"]});let d=fg.get(e);d||(d=[],fg.set(e,d),e.deferred.push(()=>FJ(e))),d.push(n)}r.additionalProperties=tn(o.valueType,e,{...s,path:[...s.path,"additionalProperties"]})}const c=i._zod.values,u=e.io==="input"&&xd(o.valueType)!==void 0;if(c&&!o.partial&&!u){const d=[...c].filter(f=>typeof f=="string"||typeof f=="number");d.length>0&&(r.required=d.map(String))}},BJ=(n,e,t,s)=>{const r=n._zod.def,o=tn(r.innerType,e,s),i=e.seen.get(n);e.target==="openapi-3.0"?(i.ref=r.innerType,t.nullable=!0):t.anyOf=[o,{type:"null"}]},WJ=(n,e,t,s)=>{const r=n._zod.def;tn(r.innerType,e,s);const o=e.seen.get(n);o.ref=r.innerType},e0=Symbol();function v_(n,e,t,s,r){let o=!1;const i=JSON.stringify(n,(l,c)=>typeof c!="bigint"?c:(o=!0,null));return o?(ho(e,t,s,r,"BigInt defaults cannot be represented in JSON Schema"),e0):JSON.parse(i)}const qJ=(n,e,t,s)=>{const r=n._zod.def;tn(r.innerType,e,s);const o=e.seen.get(n);o.ref=r.innerType;const i=v_(r.defaultValue,n,e,t,s);i!==e0&&(t.default=i)},VJ=(n,e,t,s)=>{const r=n._zod.def;tn(r.innerType,e,s);const o=e.seen.get(n);if(o.ref=r.innerType,e.io!=="input")return;const i=v_(r.defaultValue,n,e,t,s);i!==e0&&(t._prefault=i)},HJ=(n,e,t,s)=>{const r=n._zod.def;tn(r.innerType,e,s);const o=e.seen.get(n);o.ref=r.innerType;let i;try{i=r.catchValue(void 0)}catch{ho(n,e,t,s,"Dynamic catch values are not supported in JSON Schema");return}t.default=i},KJ=(n,e,t,s)=>{const r=n._zod.def,o=r.in._zod.traits.has("$ZodTransform"),i=e.io==="input"?o?r.out:r.in:r.out;tn(i,e,s);const l=e.seen.get(n);l.ref=i},GJ=(n,e,t,s)=>{const r=n._zod.def;tn(r.innerType,e,s);const o=e.seen.get(n);o.ref=r.innerType,t.readOnly=!0},y_=(n,e,t,s)=>{const r=n._zod.def;tn(r.innerType,e,s);const o=e.seen.get(n);o.ref=r.innerType},G2=new WeakSet([Object.prototype,Error.prototype]);function Yc(n,e,t){Object.defineProperty(n,e,{configurable:!0,enumerable:!1,get(){const s=t(this);return Object.defineProperty(this,e,{value:s,configurable:!0,writable:!0}),s},set(s){Object.defineProperty(this,e,{value:s,configurable:!0,writable:!0})}})}const ZJ=(n,e)=>{iZ.init(n,e),n.name="ZodError";const t=Object.getPrototypeOf(n);G2.has(t)||(G2.add(t),Yc(t,"format",s=>r=>cZ(s,r)),Yc(t,"flatten",s=>r=>lZ(s,r)),Yc(t,"addIssue",s=>r=>{s.issues.push(r),s.message=JSON.stringify(s.issues,ig,2)}),Yc(t,"addIssues",s=>r=>{s.issues.push(...r),s.message=JSON.stringify(s.issues,ig,2)}),Object.defineProperty(t,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},ks=ge("ZodError",ZJ,void 0,{Parent:Error}),YJ=Hx(ks),XJ=Kx(ks),JJ=Gx(ks),QJ=Zx(ks),eQ=hZ(ks),tQ=gZ(ks),nQ=xZ(ks),sQ=bZ(ks),rQ=vZ(ks),oQ=yZ(ks),iQ=wZ(ks),aQ=SZ(ks);function lQ(){Us.localeError||ar(jX())}function Nf(){Us.memoizer||ar({memoizer:wX()})}const It=ge("ZodType",(n,e)=>(lQ(),At.init(n,e),n.def=e,n.type=e.type,n),{check(...n){const e=this.def;return this.clone(as(e,{checks:[...e.checks??[],...n.map(t=>typeof t=="function"?{_zod:{check:t,def:{check:"custom"},onattach:[]}}:t)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,e){return Co(this,n,e)},brand(){return this},register(n,e){return n.add(this,e),this},refine(n,e){return this.check(see(n,e))},superRefine(n,e){return this.check(ree(n,e))},overwrite(n){return this.check(ca(n))},optional(){return X2(this)},exactOptional(){return VQ(this)},nullable(){return J2(this)},nullish(){return X2(J2(this))},nonoptional(n){return XQ(this,n)},array(){return ct(this)},or(n){return qo([this,n])},and(n){return UQ(this,n)},transform(n){return Q2(this,qQ(n))},default(n){return GQ(this,n)},prefault(n){return YQ(this,n)},catch(n){return QQ(this,n)},pipe(n){return Q2(this,n)},readonly(){return nee(this)},describe(n){const e=this.clone();return Ra.add(e,{description:n}),e},meta(...n){if(n.length===0)return Ra.get(this);const e=this.clone();return Ra.add(e,n[0]),e},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n,...e){return e.length===0?n(this):n(this,...e)},get"~standard"(){return D5(this,"~standard",{...K5(this),jsonSchema:{input:gd(this,"input"),output:gd(this,"output")}})},set"~standard"(n){po(this,"~standard",n)},parse:function n(e,t){return YJ(this,e,t,{callee:n})},parseAsync:async function n(e,t){return await XJ(this,e,t,{callee:n})},safeParse(n,e){return JJ(this,n,e)},async safeParseAsync(n,e){return QJ(this,n,e)},get spa(){return this==null?void 0:this.safeParseAsync},set spa(n){po(this,"spa",n)},validate(n,e){return fZ(this,n,e)},validateAsync(n,e){return pZ(this,n,e)},encode:function n(e,t){return eQ(this,e,t,{callee:n})},decode:function n(e,t){return tQ(this,e,t,{callee:n})},encodeAsync:async function n(e,t){return await nQ(this,e,t,{callee:n})},decodeAsync:async function n(e,t){return await sQ(this,e,t,{callee:n})},safeEncode(n,e){return rQ(this,n,e)},safeDecode(n,e){return oQ(this,n,e)},async safeEncodeAsync(n,e){return iQ(this,n,e)},async safeDecodeAsync(n,e){return aQ(this,n,e)},toJSONSchema(n){return kJ(this,{})(n)},get description(){var n;return(n=Ra.get(this))==null?void 0:n.description},get _def(){return this._zod.def}}),w_=ge("_ZodString",(n,e)=>{Jx.init(n,e),It.init(n,e),n._zod.processJSONSchema=(t,s,r)=>CJ(n,t,s)},F5({format:n=>$s(n).format??null,minLength:n=>$s(n).minimum??null,maxLength:n=>$s(n).maximum??null},{regex(...n){return this.check(iJ(...n))},includes(...n){return this.check(cJ(...n))},startsWith(...n){return this.check(uJ(...n))},endsWith(...n){return this.check(dJ(...n))},min(...n){return this.check(hd(...n))},max(...n){return this.check(a_(...n))},length(...n){return this.check(l_(...n))},nonempty(...n){return this.check(hd(1,...n))},lowercase(n){return this.check(aJ(n))},uppercase(n){return this.check(lJ(n))},trim(){return this.check(mJ())},normalize(...n){return this.check(fJ(...n))},toLowerCase(){return this.check(pJ())},toUpperCase(){return this.check(hJ())},slugify(){return this.check(gJ())}})),cQ=ge("ZodString",(n,e)=>{Jx.init(n,e),w_.init(n,e)},{email(n){return this.check(EX(pQ,n))},url(n){return this.check(RX(gQ,n))},jwt(n){return this.check(ZX(PQ,n))},emoji(n){return this.check(OX(xQ,n))},guid(n){return this.check(TX(hQ,n))},uuid(n){return this.check(AX(Xc,n))},uuidv4(n){return this.check(PX(Xc,n))},uuidv6(n){return this.check(IX(Xc,n))},uuidv7(n){return this.check($X(Xc,n))},nanoid(n){return this.check(LX(bQ,n))},cuid(n){return this.check(MX(vQ,n))},cuid2(n){return this.check(zX(yQ,n))},ulid(n){return this.check(DX(wQ,n))},base64(n){return this.check(HX(EQ,n))},base64url(n){return this.check(KX(TQ,n))},xid(n){return this.check(FX(SQ,n))},ksuid(n){return this.check(UX(kQ,n))},ipv4(n){return this.check(BX(jQ,n))},ipv6(n){return this.check(WX(NQ,n))},cidrv4(n){return this.check(qX(CQ,n))},cidrv6(n){return this.check(VX(_Q,n))},e164(n){return this.check(GX(AQ,n))},datetime(n){return this.check(YX(uQ,n))},date(n){return this.check(XX(dQ,n))},time(n){return this.check(JX(fQ,n))},duration(n){return this.check(QX(mQ,n))}});function De(n){return _X(cQ,n)}const Lt=ge("ZodStringFormat",(n,e)=>{Pt.init(n,e),w_.init(n,e)}),uQ=ge("ZodISODateTime",(n,e)=>{AY.init(n,e),Lt.init(n,e)}),dQ=ge("ZodISODate",(n,e)=>{PY.init(n,e),Lt.init(n,e)}),fQ=ge("ZodISOTime",(n,e)=>{IY.init(n,e),Lt.init(n,e)}),mQ=ge("ZodISODuration",(n,e)=>{$Y.init(n,e),Lt.init(n,e)}),pQ=ge("ZodEmail",(n,e)=>{gY.init(n,e),Lt.init(n,e)}),hQ=ge("ZodGUID",(n,e)=>{pY.init(n,e),Lt.init(n,e)}),Xc=ge("ZodUUID",(n,e)=>{hY.init(n,e),Lt.init(n,e)}),gQ=ge("ZodURL",(n,e)=>{SY.init(n,e),Lt.init(n,e)}),xQ=ge("ZodEmoji",(n,e)=>{kY.init(n,e),Lt.init(n,e)}),bQ=ge("ZodNanoID",(n,e)=>{jY.init(n,e),Lt.init(n,e)}),vQ=ge("ZodCUID",(n,e)=>{NY.init(n,e),Lt.init(n,e)}),yQ=ge("ZodCUID2",(n,e)=>{CY.init(n,e),Lt.init(n,e)}),wQ=ge("ZodULID",(n,e)=>{_Y.init(n,e),Lt.init(n,e)}),SQ=ge("ZodXID",(n,e)=>{EY.init(n,e),Lt.init(n,e)}),kQ=ge("ZodKSUID",(n,e)=>{TY.init(n,e),Lt.init(n,e)}),jQ=ge("ZodIPv4",(n,e)=>{RY.init(n,e),Lt.init(n,e)}),NQ=ge("ZodIPv6",(n,e)=>{LY.init(n,e),Lt.init(n,e)}),CQ=ge("ZodCIDRv4",(n,e)=>{MY.init(n,e),Lt.init(n,e)}),_Q=ge("ZodCIDRv6",(n,e)=>{DY.init(n,e),Lt.init(n,e)}),EQ=ge("ZodBase64",(n,e)=>{FY.init(n,e),Lt.init(n,e)}),TQ=ge("ZodBase64URL",(n,e)=>{BY.init(n,e),Lt.init(n,e)}),AQ=ge("ZodE164",(n,e)=>{WY.init(n,e),Lt.init(n,e)}),PQ=ge("ZodJWT",(n,e)=>{VY.init(n,e),Lt.init(n,e)}),S_=ge("ZodNumber",(n,e)=>{Q5.init(n,e),It.init(n,e),n._zod.processJSONSchema=(t,s,r)=>_J(n,t,s,r),n.isFinite=!0},F5({minValue:n=>{const{minimum:e,exclusiveMinimum:t}=$s(n);return Math.max(e??Number.NEGATIVE_INFINITY,t??Number.NEGATIVE_INFINITY)},maxValue:n=>{const{maximum:e,exclusiveMaximum:t}=$s(n);return Math.min(e??Number.POSITIVE_INFINITY,t??Number.POSITIVE_INFINITY)},isInt:n=>{const{isInt:e,multipleOf:t}=$s(n);return!!e||!!(t!=null&&t.some(Number.isSafeInteger))},format:n=>$s(n).format??null},{gt(n,e){return this.check(D2(n,e))},gte(n,e){return this.check(Mm(n,e))},min(n,e){return this.check(Mm(n,e))},lt(n,e){return this.check(z2(n,e))},lte(n,e){return this.check(Lm(n,e))},max(n,e){return this.check(Lm(n,e))},int(n){return this.check(Z2(n))},safe(n){return this.check(Z2(n))},positive(n){return this.check(D2(0,n))},nonnegative(n){return this.check(Mm(0,n))},negative(n){return this.check(z2(0,n))},nonpositive(n){return this.check(Lm(0,n))},multipleOf(n,e){return this.check(F2(n,e))},step(n,e){return this.check(F2(n,e))},finite(){return this}}));function pn(n){return eJ(S_,n)}const IQ=ge("ZodNumberFormat",(n,e)=>{HY.init(n,e),S_.init(n,e)});function Z2(n){return tJ(IQ,n)}const $Q=ge("ZodBoolean",(n,e)=>{KY.init(n,e),It.init(n,e),n._zod.processJSONSchema=(t,s,r)=>EJ(n,t,s)});function hn(n){return nJ($Q,n)}const RQ=ge("ZodNull",(n,e)=>{GY.init(n,e),It.init(n,e),n._zod.processJSONSchema=(t,s,r)=>TJ(n,t,s)});function k_(n){return sJ(RQ,n)}const OQ=ge("ZodUnknown",(n,e)=>{ZY.init(n,e),It.init(n,e),n._zod.processJSONSchema=(t,s,r)=>PJ()});function Rr(){return rJ(OQ)}const LQ=ge("ZodNever",(n,e)=>{YY.init(n,e),It.init(n,e),n._zod.processJSONSchema=(t,s,r)=>AJ(n,t,s)});function j_(n){return oJ(LQ,n)}const MQ=ge("ZodArray",(n,e)=>{Nf(),XY.init(n,e),It.init(n,e),n._zod.processJSONSchema=(t,s,r)=>LJ(n,t,s,r),n.element=e.element},{min(n,e){return this.check(hd(n,e))},nonempty(n){return this.check(hd(1,n))},max(n,e){return this.check(a_(n,e))},length(n,e){return this.check(l_(n,e))},unwrap(){return this.element}});function ct(n,e){return xJ(MQ,n,e)}const N_=ge("ZodObject",(n,e)=>{Nf(),eX.init(n,e),It.init(n,e),n._zod.processJSONSchema=(t,s,r)=>MJ(n,t,s,r),JG(n,"shape",t=>t._zod.def.shape,!1)},{keyof(){return _t(Object.keys(this._zod.def.shape))},catchall(n){return this.clone(as(this._zod.def,{catchall:n}))},passthrough(){return this.clone(as(this._zod.def,{catchall:Rr()}))},loose(){return this.clone(as(this._zod.def,{catchall:Rr()}))},strict(){return this.clone(as(this._zod.def,{catchall:j_()}))},strip(){return this.clone(as(this._zod.def,{catchall:void 0}))},extend(n){return UG(this,n)},safeExtend(n){return BG(this,n)},merge(n){return WG(this,n)},pick(n){return DG(this,n)},omit(n){return FG(this,n)},partial(...n){return y2(__,this,n[0])},exactPartial(...n){return y2(E_,this,n[0],"exactPartial")},required(...n){return qG(T_,this,n[0])}});function zQ(n,e){const t={type:"object",shape:n??{},...Ve(e)};return new N_(t)}function we(n,e){return new N_({type:"object",shape:n,catchall:j_(),...Ve(e)})}const C_=ge("ZodUnion",(n,e)=>{n_.init(n,e),It.init(n,e),n._zod.processJSONSchema=(t,s,r)=>zJ(n,t,s,r),n.options=e.options});function qo(n,e){return new C_({type:"union",options:n,...Ve(e)})}const DQ=ge("ZodDiscriminatedUnion",(n,e)=>{C_.init(n,e),nX.init(n,e)});function Dr(n,e,t){return new DQ({type:"union",options:e,discriminator:n,...Ve(t)})}const FQ=ge("ZodIntersection",(n,e)=>{sX.init(n,e),It.init(n,e),n._zod.processJSONSchema=(t,s,r)=>DJ(n,t,s,r)});function UQ(n,e){return new FQ({type:"intersection",left:n,right:e})}const Y2=ge("ZodRecord",(n,e)=>{Nf(),rX.init(n,e),It.init(n,e),n._zod.processJSONSchema=(t,s,r)=>UJ(n,t,s,r),n.keyType=e.keyType,n.valueType=e.valueType});function bs(n,e,t){return!e||!e._zod?new Y2({type:"record",keyType:De(),valueType:n,...Ve(e)}):new Y2({type:"record",keyType:n,valueType:e,...Ve(t)})}const mg=ge("ZodEnum",(n,e)=>{oX.init(n,e),It.init(n,e),n._zod.processJSONSchema=(s,r,o)=>IJ(n,s,r),n.enum=e.entries,n.options=[...n._zod.values];const t=new Set(Object.keys(e.entries));n.extract=(s,r)=>{const o={};for(const i of s)if(t.has(i))o[i]=e.entries[i];else throw new Error(`Key ${i} not found in enum`);return new mg({...e,checks:[],...Ve(r),entries:o})},n.exclude=(s,r)=>{const o={...e.entries};for(const i of s)if(t.has(i))delete o[i];else throw new Error(`Key ${i} not found in enum`);return new mg({...e,checks:[],...Ve(r),entries:o})}});function _t(n,e){const t=Array.isArray(n)?Object.fromEntries(n.map(s=>[s,s])):n;return new mg({type:"enum",entries:t,...Ve(e)})}const BQ=ge("ZodLiteral",(n,e)=>{iX.init(n,e),It.init(n,e),n._zod.processJSONSchema=(t,s,r)=>$J(n,t,s,r),n.values=new Set(e.values),Object.defineProperty(n,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function Ze(n,e){return new BQ({type:"literal",values:Array.isArray(n)?n:[n],...Ve(e)})}const WQ=ge("ZodTransform",(n,e)=>{Nf(),aX.init(n,e),It.init(n,e),n._zod.processJSONSchema=(t,s,r)=>OJ(n,t,s,r),n._zod.parse=(t,s)=>{if(s.direction==="backward")throw new U5(n.constructor.name);t.addIssue=o=>{if(typeof o=="string")t.issues.push(Tl(o,t.value,e));else{const i=o;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=t.value),i.inst??(i.inst=n),t.issues.push(Tl(i))}};const r=e.transform(t.value,t);return r instanceof Promise?r.then(o=>(t.value=o,t)):(t.value=r,t)}});function qQ(n){return new WQ({type:"transform",transform:n})}const __=ge("ZodOptional",(n,e)=>{s_.init(n,e),It.init(n,e),n._zod.processJSONSchema=(t,s,r)=>y_(n,t,s,r),n.unwrap=()=>n._zod.def.innerType});function X2(n){return new __({type:"optional",innerType:n})}const E_=ge("ZodExactOptional",(n,e)=>{lX.init(n,e),It.init(n,e),n._zod.processJSONSchema=(t,s,r)=>y_(n,t,s,r),n.unwrap=()=>n._zod.def.innerType});function VQ(n){return new E_({type:"optional",innerType:n})}const HQ=ge("ZodNullable",(n,e)=>{cX.init(n,e),It.init(n,e),n._zod.processJSONSchema=(t,s,r)=>BJ(n,t,s,r),n.unwrap=()=>n._zod.def.innerType});function J2(n){return new HQ({type:"nullable",innerType:n})}const KQ=ge("ZodDefault",(n,e)=>{uX.init(n,e),It.init(n,e),n._zod.processJSONSchema=(t,s,r)=>qJ(n,t,s,r),n.unwrap=()=>n._zod.def.innerType,n.removeDefault=n.unwrap});function GQ(n,e){return new KQ({type:"default",innerType:n,get defaultValue(){return typeof e=="function"?e():O5(e)}})}const ZQ=ge("ZodPrefault",(n,e)=>{dX.init(n,e),It.init(n,e),n._zod.processJSONSchema=(t,s,r)=>VJ(n,t,s,r),n.unwrap=()=>n._zod.def.innerType});function YQ(n,e){return new ZQ({type:"prefault",innerType:n,get defaultValue(){return typeof e=="function"?e():O5(e)}})}const T_=ge("ZodNonOptional",(n,e)=>{fX.init(n,e),It.init(n,e),n._zod.processJSONSchema=(t,s,r)=>WJ(n,t,s,r),n.unwrap=()=>n._zod.def.innerType});function XQ(n,e){return new T_({type:"nonoptional",innerType:n,...Ve(e)})}const JQ=ge("ZodCatch",(n,e)=>{mX.init(n,e),It.init(n,e),n._zod.processJSONSchema=(t,s,r)=>HJ(n,t,s,r),n.unwrap=()=>n._zod.def.innerType,n.removeCatch=n.unwrap});function QQ(n,e){return new JQ({type:"catch",innerType:n,catchValue:typeof e=="function"?e:eZ(e)})}const eee=ge("ZodPipe",(n,e)=>{pX.init(n,e),It.init(n,e),n._zod.processJSONSchema=(t,s,r)=>KJ(n,t,s,r),n.in=e.in,n.out=e.out});function Q2(n,e){return new eee({type:"pipe",in:n,out:e})}const tee=ge("ZodReadonly",(n,e)=>{hX.init(n,e),It.init(n,e),n._zod.processJSONSchema=(t,s,r)=>GJ(n,t,s,r),n.unwrap=()=>n._zod.def.innerType});function nee(n){return new tee({type:"readonly",innerType:n})}const A_=ge("ZodCustom",(n,e)=>{gX.init(n,e),It.init(n,e),n._zod.processJSONSchema=(t,s,r)=>RJ(n,t,s,r)});function P_(n,e){return bJ(A_,n??(()=>!0),e)}function see(n,e={}){return vJ(A_,n,e)}function ree(n,e){return yJ(n,e)}class pg extends Error{constructor(t){super(t.map(s=>`${s.path}: ${s.message}`).join("; "));Wt(this,"issues");this.issues=t,this.name="ContractValidationError"}}const Ht=Object.freeze({manifestBytes:65536,definitionBytes:32768,messageBytes:65536,argumentBytes:4096,responseBytes:2*1024*1024,resultMessageBytes:2*1024*1024+16384,storageValueBytes:32768,responseNodes:1e5,depth:16,nodes:4096,outstandingRequests:32,requestTimeoutMs:3e4,composerBytes:16384});function Iu(n){return new TextEncoder().encode(n).byteLength}function t0(n,e={}){const t=e.maxBytes??Ht.messageBytes,s=e.maxDepth??Ht.depth,r=e.maxNodes??Ht.nodes;if(!Number.isSafeInteger(t)||t<1||!Number.isSafeInteger(s)||s<0||s>Ht.depth||!Number.isSafeInteger(r)||r<1||r>Ht.responseNodes+16)throw new pg([{path:"$",message:"Invalid JSON limits"}]);let o=t,i=r;const l=new Set,c=f=>{throw new pg([{path:f,message:"Expected bounded JSON data"}])};function u(f,m,p){if(--i<0||m>s||(o-=2)<0)return c(p);if(f===null||typeof f=="boolean")return f;if(typeof f=="number")return Number.isFinite(f)?f:c(p);if(typeof f=="string")return f.length<=o&&(o-=Iu(f))>=0?f:c(p);if(typeof f!="object"||l.has(f))return c(p);const h=Object.getPrototypeOf(f);if(Array.isArray(f)?h!==Array.prototype:h!==Object.prototype&&h!==null)return c(p);const g=Reflect.ownKeys(f);if(g.length>i+1||g.some(y=>typeof y=="symbol"))return c(p);const x=Object.getOwnPropertyDescriptors(f);for(const y of Object.values(x))if(y.get||y.set||!Object.hasOwn(y,"value"))return c(p);l.add(f);let b;if(Array.isArray(f)){if(f.length>r||Object.keys(x).length!==f.length+1)return c(p);b=Array.from({length:f.length},(y,v)=>{const k=x[String(v)];return k!=null&&k.enumerable?u(k.value,m+1,`${p}[${v}]`):c(`${p}[${v}]`)})}else{const y=Object.create(null);for(const[v,k]of Object.entries(x)){if(!k.enumerable||["__proto__","prototype","constructor"].includes(v)||(o-=Iu(v)+3)<0)return c(`${p}.${v}`);y[v]=u(k.value,m+1,`${p}.${v}`)}b=y}return l.delete(f),b}const d=u(n,0,"$");return Iu(JSON.stringify(d))>t?c("$"):d}var Jc={exports:{}},Dm,ew;function fc(){if(ew)return Dm;ew=1;const n="2.0.0",e=256,t=Number.MAX_SAFE_INTEGER||9007199254740991,s=16,r=e-6;return Dm={MAX_LENGTH:e,MAX_SAFE_COMPONENT_LENGTH:s,MAX_SAFE_BUILD_LENGTH:r,MAX_SAFE_INTEGER:t,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:n,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2},Dm}var Fm,tw;function Cf(){if(tw)return Fm;tw=1;var n={};return Fm=typeof process=="object"&&n&&n.NODE_DEBUG&&/\bsemver\b/i.test(n.NODE_DEBUG)?(...t)=>console.error("SEMVER",...t):()=>{},Fm}var nw;function mc(){return nw||(nw=1,(function(n,e){const{MAX_SAFE_COMPONENT_LENGTH:t,MAX_SAFE_BUILD_LENGTH:s,MAX_LENGTH:r}=fc(),o=Cf();e=n.exports={};const i=e.re=[],l=e.safeRe=[],c=e.src=[],u=e.safeSrc=[],d=e.t={};let f=0;const m="[a-zA-Z0-9-]",p=[["\\s",1],["\\d",r],[m,s]],h=x=>{for(const[b,y]of p)x=x.split(`${b}*`).join(`${b}{0,${y}}`).split(`${b}+`).join(`${b}{1,${y}}`);return x},g=(x,b,y)=>{const v=h(b),k=f++;o(x,k,b),d[x]=k,c[k]=b,u[k]=v,i[k]=new RegExp(b,y?"g":void 0),l[k]=new RegExp(v,y?"g":void 0)};g("NUMERICIDENTIFIER","0|[1-9]\\d*"),g("NUMERICIDENTIFIERLOOSE","\\d+"),g("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${m}*`),g("MAINVERSION",`(${c[d.NUMERICIDENTIFIER]})\\.(${c[d.NUMERICIDENTIFIER]})\\.(${c[d.NUMERICIDENTIFIER]})`),g("MAINVERSIONLOOSE",`(${c[d.NUMERICIDENTIFIERLOOSE]})\\.(${c[d.NUMERICIDENTIFIERLOOSE]})\\.(${c[d.NUMERICIDENTIFIERLOOSE]})`),g("PRERELEASEIDENTIFIER",`(?:${c[d.NONNUMERICIDENTIFIER]}|${c[d.NUMERICIDENTIFIER]})`),g("PRERELEASEIDENTIFIERLOOSE",`(?:${c[d.NONNUMERICIDENTIFIER]}|${c[d.NUMERICIDENTIFIERLOOSE]})`),g("PRERELEASE",`(?:-(${c[d.PRERELEASEIDENTIFIER]}(?:\\.${c[d.PRERELEASEIDENTIFIER]})*))`),g("PRERELEASELOOSE",`(?:-?(${c[d.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[d.PRERELEASEIDENTIFIERLOOSE]})*))`),g("BUILDIDENTIFIER",`${m}+`),g("BUILD",`(?:\\+(${c[d.BUILDIDENTIFIER]}(?:\\.${c[d.BUILDIDENTIFIER]})*))`),g("FULLPLAIN",`v?${c[d.MAINVERSION]}${c[d.PRERELEASE]}?${c[d.BUILD]}?`),g("FULL",`^${c[d.FULLPLAIN]}$`),g("LOOSEPLAIN",`[v=\\s]*${c[d.MAINVERSIONLOOSE]}${c[d.PRERELEASELOOSE]}?${c[d.BUILD]}?`),g("LOOSE",`^${c[d.LOOSEPLAIN]}$`),g("GTLT","((?:<|>)?=?)"),g("XRANGEIDENTIFIERLOOSE",`${c[d.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),g("XRANGEIDENTIFIER",`${c[d.NUMERICIDENTIFIER]}|x|X|\\*`),g("XRANGEPLAIN",`[v=\\s]*(${c[d.XRANGEIDENTIFIER]})(?:\\.(${c[d.XRANGEIDENTIFIER]})(?:\\.(${c[d.XRANGEIDENTIFIER]})(?:${c[d.PRERELEASE]})?${c[d.BUILD]}?)?)?`),g("XRANGEPLAINLOOSE",`[v=\\s]*(${c[d.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[d.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[d.XRANGEIDENTIFIERLOOSE]})(?:${c[d.PRERELEASELOOSE]})?${c[d.BUILD]}?)?)?`),g("XRANGE",`^${c[d.GTLT]}\\s*${c[d.XRANGEPLAIN]}$`),g("XRANGELOOSE",`^${c[d.GTLT]}\\s*${c[d.XRANGEPLAINLOOSE]}$`),g("COERCEPLAIN",`(^|[^\\d])(\\d{1,${t}})(?:\\.(\\d{1,${t}}))?(?:\\.(\\d{1,${t}}))?`),g("COERCE",`${c[d.COERCEPLAIN]}(?:$|[^\\d])`),g("COERCEFULL",c[d.COERCEPLAIN]+`(?:${c[d.PRERELEASE]})?(?:${c[d.BUILD]})?(?:$|[^\\d])`),g("COERCERTL",c[d.COERCE],!0),g("COERCERTLFULL",c[d.COERCEFULL],!0),g("LONETILDE","(?:~>?)"),g("TILDETRIM",`(\\s*)${c[d.LONETILDE]}\\s+`,!0),e.tildeTrimReplace="$1~",g("TILDE",`^${c[d.LONETILDE]}${c[d.XRANGEPLAIN]}$`),g("TILDELOOSE",`^${c[d.LONETILDE]}${c[d.XRANGEPLAINLOOSE]}$`),g("LONECARET","(?:\\^)"),g("CARETTRIM",`(\\s*)${c[d.LONECARET]}\\s+`,!0),e.caretTrimReplace="$1^",g("CARET",`^${c[d.LONECARET]}${c[d.XRANGEPLAIN]}$`),g("CARETLOOSE",`^${c[d.LONECARET]}${c[d.XRANGEPLAINLOOSE]}$`),g("COMPARATORLOOSE",`^${c[d.GTLT]}\\s*(${c[d.LOOSEPLAIN]})$|^$`),g("COMPARATOR",`^${c[d.GTLT]}\\s*(${c[d.FULLPLAIN]})$|^$`),g("COMPARATORTRIM",`(\\s*)${c[d.GTLT]}\\s*(${c[d.LOOSEPLAIN]}|${c[d.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace="$1$2$3",g("HYPHENRANGE",`^\\s*(${c[d.XRANGEPLAIN]})\\s+-\\s+(${c[d.XRANGEPLAIN]})\\s*$`),g("HYPHENRANGELOOSE",`^\\s*(${c[d.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[d.XRANGEPLAINLOOSE]})\\s*$`),g("STAR","(<|>)?=?\\s*\\*"),g("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),g("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")})(Jc,Jc.exports)),Jc.exports}var Um,sw;function n0(){if(sw)return Um;sw=1;const n=Object.freeze({loose:!0}),e=Object.freeze({});return Um=s=>s?typeof s!="object"?n:s:e,Um}var Bm,rw;function I_(){if(rw)return Bm;rw=1;const n=/^[0-9]+$/,e=(s,r)=>{if(typeof s=="number"&&typeof r=="number")return s===r?0:s<r?-1:1;const o=n.test(s),i=n.test(r);return o&&i&&(s=+s,r=+r),s===r?0:o&&!i?-1:i&&!o?1:s<r?-1:1};return Bm={compareIdentifiers:e,rcompareIdentifiers:(s,r)=>e(r,s)},Bm}var Wm,ow;function zn(){if(ow)return Wm;ow=1;const n=Cf(),{MAX_LENGTH:e,MAX_SAFE_INTEGER:t}=fc(),{safeRe:s,t:r}=mc(),o=n0(),{compareIdentifiers:i}=I_(),l=(u,d)=>{const f=d.split(".");if(f.length>u.length)return!1;for(let m=0;m<f.length;m++)if(i(u[m],f[m])!==0)return!1;return!0};class c{constructor(d,f){if(f=o(f),d instanceof c){if(d.loose===!!f.loose&&d.includePrerelease===!!f.includePrerelease)return d;d=d.version}else if(typeof d!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof d}".`);if(d.length>e)throw new TypeError(`version is longer than ${e} characters`);n("SemVer",d,f),this.options=f,this.loose=!!f.loose,this.includePrerelease=!!f.includePrerelease;const m=d.trim().match(f.loose?s[r.LOOSE]:s[r.FULL]);if(!m)throw new TypeError(`Invalid Version: ${d}`);if(this.raw=d,this.major=+m[1],this.minor=+m[2],this.patch=+m[3],this.major>t||this.major<0)throw new TypeError("Invalid major version");if(this.minor>t||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>t||this.patch<0)throw new TypeError("Invalid patch version");m[4]?this.prerelease=m[4].split(".").map(p=>{if(/^[0-9]+$/.test(p)){const h=+p;if(h>=0&&h<t)return h}return p}):this.prerelease=[],this.build=m[5]?m[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(d){if(n("SemVer.compare",this.version,this.options,d),!(d instanceof c)){if(typeof d=="string"&&d===this.version)return 0;d=new c(d,this.options)}return d.version===this.version?0:this.compareMain(d)||this.comparePre(d)}compareMain(d){return d instanceof c||(d=new c(d,this.options)),this.major<d.major?-1:this.major>d.major?1:this.minor<d.minor?-1:this.minor>d.minor?1:this.patch<d.patch?-1:this.patch>d.patch?1:0}comparePre(d){if(d instanceof c||(d=new c(d,this.options)),this.prerelease.length&&!d.prerelease.length)return-1;if(!this.prerelease.length&&d.prerelease.length)return 1;if(!this.prerelease.length&&!d.prerelease.length)return 0;let f=0;do{const m=this.prerelease[f],p=d.prerelease[f];if(n("prerelease compare",f,m,p),m===void 0&&p===void 0)return 0;if(p===void 0)return 1;if(m===void 0)return-1;if(m===p)continue;return i(m,p)}while(++f)}compareBuild(d){d instanceof c||(d=new c(d,this.options));let f=0;do{const m=this.build[f],p=d.build[f];if(n("build compare",f,m,p),m===void 0&&p===void 0)return 0;if(p===void 0)return 1;if(m===void 0)return-1;if(m===p)continue;return i(m,p)}while(++f)}inc(d,f,m){if(d.startsWith("pre")){if(!f&&m===!1)throw new Error("invalid increment argument: identifier is empty");if(f){const p=`-${f}`.match(this.options.loose?s[r.PRERELEASELOOSE]:s[r.PRERELEASE]);if(!p||p[1]!==f)throw new Error(`invalid identifier: ${f}`)}}switch(d){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",f,m);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",f,m);break;case"prepatch":this.prerelease.length=0,this.inc("patch",f,m),this.inc("pre",f,m);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",f,m),this.inc("pre",f,m);break;case"release":if(this.prerelease.length===0)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":{const p=Number(m)?1:0;if(this.prerelease.length===0)this.prerelease=[p];else{let h=this.prerelease.length;for(;--h>=0;)typeof this.prerelease[h]=="number"&&(this.prerelease[h]++,h=-2);if(h===-1){if(f===this.prerelease.join(".")&&m===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(p)}}if(f){let h=[f,p];if(m===!1&&(h=[f]),l(this.prerelease,f)){const g=this.prerelease[f.split(".").length];isNaN(g)&&(this.prerelease=h)}else this.prerelease=h}break}default:throw new Error(`invalid increment argument: ${d}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}return Wm=c,Wm}var qm,iw;function Jo(){if(iw)return qm;iw=1;const n=zn();return qm=(t,s,r=!1)=>{if(t instanceof n)return t;try{return new n(t,s)}catch(o){if(!r)return null;throw o}},qm}var Vm,aw;function oee(){if(aw)return Vm;aw=1;const n=Jo();return Vm=(t,s)=>{const r=n(t,s);return r?r.version:null},Vm}var Hm,lw;function iee(){if(lw)return Hm;lw=1;const n=Jo();return Hm=(t,s)=>{const r=n(t.trim().replace(/^[=v]+/,""),s);return r?r.version:null},Hm}var Km,cw;function aee(){if(cw)return Km;cw=1;const n=zn();return Km=(t,s,r,o,i)=>{typeof r=="string"&&(i=o,o=r,r=void 0);try{return new n(t instanceof n?t.version:t,r).inc(s,o,i).version}catch{return null}},Km}var Gm,uw;function lee(){if(uw)return Gm;uw=1;const n=Jo();return Gm=(t,s)=>{const r=n(t,null,!0),o=n(s,null,!0),i=r.compare(o);if(i===0)return null;const l=i>0,c=l?r:o,u=l?o:r,d=!!c.prerelease.length;if(!!u.prerelease.length&&!d){if(!u.patch&&!u.minor)return"major";if(u.compareMain(c)===0)return u.minor&&!u.patch?"minor":"patch"}const m=d?"pre":"";return r.major!==o.major?m+"major":r.minor!==o.minor?m+"minor":r.patch!==o.patch?m+"patch":"prerelease"},Gm}var Zm,dw;function cee(){if(dw)return Zm;dw=1;const n=zn();return Zm=(t,s)=>new n(t,s).major,Zm}var Ym,fw;function uee(){if(fw)return Ym;fw=1;const n=zn();return Ym=(t,s)=>new n(t,s).minor,Ym}var Xm,mw;function dee(){if(mw)return Xm;mw=1;const n=zn();return Xm=(t,s)=>new n(t,s).patch,Xm}var Jm,pw;function fee(){if(pw)return Jm;pw=1;const n=Jo();return Jm=(t,s)=>{const r=n(t,s);return r&&r.prerelease.length?r.prerelease:null},Jm}var Qm,hw;function Ws(){if(hw)return Qm;hw=1;const n=zn();return Qm=(t,s,r)=>new n(t,r).compare(new n(s,r)),Qm}var ep,gw;function mee(){if(gw)return ep;gw=1;const n=Ws();return ep=(t,s,r)=>n(s,t,r),ep}var tp,xw;function pee(){if(xw)return tp;xw=1;const n=Ws();return tp=(t,s)=>n(t,s,!0),tp}var np,bw;function s0(){if(bw)return np;bw=1;const n=zn();return np=(t,s,r)=>{const o=new n(t,r),i=new n(s,r);return o.compare(i)||o.compareBuild(i)},np}var sp,vw;function hee(){if(vw)return sp;vw=1;const n=s0();return sp=(t,s)=>t.sort((r,o)=>n(r,o,s)),sp}var rp,yw;function gee(){if(yw)return rp;yw=1;const n=s0();return rp=(t,s)=>t.sort((r,o)=>n(o,r,s)),rp}var op,ww;function _f(){if(ww)return op;ww=1;const n=Ws();return op=(t,s,r)=>n(t,s,r)>0,op}var ip,Sw;function r0(){if(Sw)return ip;Sw=1;const n=Ws();return ip=(t,s,r)=>n(t,s,r)<0,ip}var ap,kw;function $_(){if(kw)return ap;kw=1;const n=Ws();return ap=(t,s,r)=>n(t,s,r)===0,ap}var lp,jw;function R_(){if(jw)return lp;jw=1;const n=Ws();return lp=(t,s,r)=>n(t,s,r)!==0,lp}var cp,Nw;function o0(){if(Nw)return cp;Nw=1;const n=Ws();return cp=(t,s,r)=>n(t,s,r)>=0,cp}var up,Cw;function i0(){if(Cw)return up;Cw=1;const n=Ws();return up=(t,s,r)=>n(t,s,r)<=0,up}var dp,_w;function O_(){if(_w)return dp;_w=1;const n=$_(),e=R_(),t=_f(),s=o0(),r=r0(),o=i0();return dp=(l,c,u,d)=>{switch(c){case"===":return typeof l=="object"&&(l=l.version),typeof u=="object"&&(u=u.version),l===u;case"!==":return typeof l=="object"&&(l=l.version),typeof u=="object"&&(u=u.version),l!==u;case"":case"=":case"==":return n(l,u,d);case"!=":return e(l,u,d);case">":return t(l,u,d);case">=":return s(l,u,d);case"<":return r(l,u,d);case"<=":return o(l,u,d);default:throw new TypeError(`Invalid operator: ${c}`)}},dp}var fp,Ew;function xee(){if(Ew)return fp;Ew=1;const n=zn(),e=Jo(),{safeRe:t,t:s}=mc();return fp=(o,i)=>{if(o instanceof n)return o;if(typeof o=="number"&&(o=String(o)),typeof o!="string")return null;i=i||{};let l=null;if(!i.rtl)l=o.match(i.includePrerelease?t[s.COERCEFULL]:t[s.COERCE]);else{const p=i.includePrerelease?t[s.COERCERTLFULL]:t[s.COERCERTL];let h;for(;(h=p.exec(o))&&(!l||l.index+l[0].length!==o.length);)(!l||h.index+h[0].length!==l.index+l[0].length)&&(l=h),p.lastIndex=h.index+h[1].length+h[2].length;p.lastIndex=-1}if(l===null)return null;const c=l[2],u=l[3]||"0",d=l[4]||"0",f=i.includePrerelease&&l[5]?`-${l[5]}`:"",m=i.includePrerelease&&l[6]?`+${l[6]}`:"";return e(`${c}.${u}.${d}${f}${m}`,i)},fp}var mp,Tw;function bee(){if(Tw)return mp;Tw=1;const n=Jo(),e=fc(),t=zn(),s=(l,c,u)=>{if(!e.RELEASE_TYPES.includes(c))return null;const d=r(l,u);return d&&o(d,c)},r=(l,c)=>{const u=l instanceof t?l.version:l;return n(u,c)},o=(l,c)=>{if(i(c))return l.version;switch(l.prerelease=[],c){case"major":l.minor=0,l.patch=0;break;case"minor":l.patch=0;break}return l.format()},i=l=>l.startsWith("pre");return mp=s,mp}var pp,Aw;function vee(){if(Aw)return pp;Aw=1;class n{constructor(){this.max=1e3,this.map=new Map}get(t){const s=this.map.get(t);if(s!==void 0)return this.map.delete(t),this.map.set(t,s),s}delete(t){return this.map.delete(t)}set(t,s){if(!this.delete(t)&&s!==void 0){if(this.map.size>=this.max){const o=this.map.keys().next().value;this.delete(o)}this.map.set(t,s)}return this}}return pp=n,pp}var hp,Pw;function qs(){if(Pw)return hp;Pw=1;const n=/\s+/g;class e{constructor(R,z){if(z=r(z),R instanceof e)return R.loose===!!z.loose&&R.includePrerelease===!!z.includePrerelease?R:new e(R.raw,z);if(R instanceof o)return this.raw=R.value,this.set=[[R]],this.formatted=void 0,this;if(this.options=z,this.loose=!!z.loose,this.includePrerelease=!!z.includePrerelease,this.raw=R.trim().replace(n," "),this.set=this.raw.split("||").map(W=>this.parseRange(W.trim())).filter(W=>W.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const W=this.set[0];if(this.set=this.set.filter(D=>!b(D[0])),this.set.length===0)this.set=[W];else if(this.set.length>1){for(const D of this.set)if(D.length===1&&y(D[0])){this.set=[D];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let R=0;R<this.set.length;R++){R>0&&(this.formatted+="||");const z=this.set[R];for(let W=0;W<z.length;W++)W>0&&(this.formatted+=" "),this.formatted+=z[W].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(R){R=R.replace(x,"");const W=((this.options.includePrerelease&&h)|(this.options.loose&&g))+":"+R,D=s.get(W);if(D)return D;const L=this.options.loose,U=L?c[d.HYPHENRANGELOOSE]:c[d.HYPHENRANGE];R=R.replace(U,$(this.options.includePrerelease)),i("hyphen replace",R),R=R.replace(c[d.COMPARATORTRIM],f),i("comparator trim",R),R=R.replace(c[d.TILDETRIM],m),i("tilde trim",R),R=R.replace(c[d.CARETTRIM],p),i("caret trim",R);let F=R.split(" ").map(K=>k(K,this.options)).join(" ").split(/\s+/).map(K=>I(K,this.options));L&&(F=F.filter(K=>(i("loose invalid filter",K,this.options),!!K.match(c[d.COMPARATORLOOSE])))),i("range list",F);const B=new Map,V=F.map(K=>new o(K,this.options));for(const K of V){if(b(K))return[K];B.set(K.value,K)}B.size>1&&B.has("")&&B.delete("");const H=[...B.values()];return s.set(W,H),H}intersects(R,z){if(!(R instanceof e))throw new TypeError("a Range is required");return this.set.some(W=>v(W,z)&&R.set.some(D=>v(D,z)&&W.every(L=>D.every(U=>L.intersects(U,z)))))}test(R){if(!R)return!1;if(typeof R=="string")try{R=new l(R,this.options)}catch{return!1}for(let z=0;z<this.set.length;z++)if(O(this.set[z],R,this.options))return!0;return!1}}hp=e;const t=vee(),s=new t,r=n0(),o=Ef(),i=Cf(),l=zn(),{safeRe:c,src:u,t:d,comparatorTrimReplace:f,tildeTrimReplace:m,caretTrimReplace:p}=mc(),{FLAG_INCLUDE_PRERELEASE:h,FLAG_LOOSE:g}=fc(),x=new RegExp(u[d.BUILD],"g"),b=M=>M.value==="<0.0.0-0",y=M=>M.value==="",v=(M,R)=>{let z=!0;const W=M.slice();let D=W.pop();for(;z&&W.length;)z=W.every(L=>D.intersects(L,R)),D=W.pop();return z},k=(M,R)=>(M=M.replace(c[d.BUILD],""),i("comp",M,R),M=C(M,R),i("caret",M),M=N(M,R),i("tildes",M),M=T(M,R),i("xrange",M),M=P(M,R),i("stars",M),M),j=M=>!M||M.toLowerCase()==="x"||M==="*",_=(M,R,z)=>j(M)&&!j(R)||j(R)&&z&&!j(z),N=(M,R)=>M.trim().split(/\s+/).map(z=>S(z,R)).join(" "),S=(M,R)=>{const z=R.loose?c[d.TILDELOOSE]:c[d.TILDE],W=R.includePrerelease?"-0":"";return M.replace(z,(D,L,U,F,B)=>{i("tilde",M,D,L,U,F,B);let V;return j(L)?V="":j(U)?V=`>=${L}.0.0${W} <${+L+1}.0.0-0`:j(F)?V=`>=${L}.${U}.0${W} <${L}.${+U+1}.0-0`:B?(i("replaceTilde pr",B),V=`>=${L}.${U}.${F}-${B} <${L}.${+U+1}.0-0`):V=`>=${L}.${U}.${F} <${L}.${+U+1}.0-0`,i("tilde return",V),V})},C=(M,R)=>M.trim().split(/\s+/).map(z=>E(z,R)).join(" "),E=(M,R)=>{i("caret",M,R);const z=R.loose?c[d.CARETLOOSE]:c[d.CARET],W=R.includePrerelease?"-0":"";return M.replace(z,(D,L,U,F,B)=>{i("caret",M,D,L,U,F,B);let V;return j(L)?V="":j(U)?V=`>=${L}.0.0${W} <${+L+1}.0.0-0`:j(F)?L==="0"?V=`>=${L}.${U}.0${W} <${L}.${+U+1}.0-0`:V=`>=${L}.${U}.0${W} <${+L+1}.0.0-0`:B?(i("replaceCaret pr",B),L==="0"?U==="0"?V=`>=${L}.${U}.${F}-${B} <${L}.${U}.${+F+1}-0`:V=`>=${L}.${U}.${F}-${B} <${L}.${+U+1}.0-0`:V=`>=${L}.${U}.${F}-${B} <${+L+1}.0.0-0`):(i("no pr"),L==="0"?U==="0"?V=`>=${L}.${U}.${F} <${L}.${U}.${+F+1}-0`:V=`>=${L}.${U}.${F} <${L}.${+U+1}.0-0`:V=`>=${L}.${U}.${F} <${+L+1}.0.0-0`),i("caret return",V),V})},T=(M,R)=>(i("replaceXRanges",M,R),M.split(/\s+/).map(z=>A(z,R)).join(" ")),A=(M,R)=>{M=M.trim();const z=R.loose?c[d.XRANGELOOSE]:c[d.XRANGE];return M.replace(z,(W,D,L,U,F,B)=>{if(i("xRange",M,W,D,L,U,F,B),_(L,U,F))return M;const V=j(L),H=V||j(U),K=H||j(F),Z=K;return D==="="&&Z&&(D=""),B=R.includePrerelease?"-0":"",V?D===">"||D==="<"?W="<0.0.0-0":W="*":D&&Z?(H&&(U=0),F=0,D===">"?(D=">=",H?(L=+L+1,U=0,F=0):(U=+U+1,F=0)):D==="<="&&(D="<",H?L=+L+1:U=+U+1),D==="<"&&(B="-0"),W=`${D+L}.${U}.${F}${B}`):H?W=`>=${L}.0.0${B} <${+L+1}.0.0-0`:K&&(W=`>=${L}.${U}.0${B} <${L}.${+U+1}.0-0`),i("xRange return",W),W})},P=(M,R)=>(i("replaceStars",M,R),M.trim().replace(c[d.STAR],"")),I=(M,R)=>(i("replaceGTE0",M,R),M.trim().replace(c[R.includePrerelease?d.GTE0PRE:d.GTE0],"")),$=M=>(R,z,W,D,L,U,F,B,V,H,K,Z)=>(j(W)?z="":j(D)?z=`>=${W}.0.0${M?"-0":""}`:j(L)?z=`>=${W}.${D}.0${M?"-0":""}`:U?z=`>=${z}`:z=`>=${z}${M?"-0":""}`,j(V)?B="":j(H)?B=`<${+V+1}.0.0-0`:j(K)?B=`<${V}.${+H+1}.0-0`:Z?B=`<=${V}.${H}.${K}-${Z}`:M?B=`<${V}.${H}.${+K+1}-0`:B=`<=${B}`,`${z} ${B}`.trim()),O=(M,R,z)=>{for(let W=0;W<M.length;W++)if(!M[W].test(R))return!1;if(R.prerelease.length&&!z.includePrerelease){for(let W=0;W<M.length;W++)if(i(M[W].semver),M[W].semver!==o.ANY&&M[W].semver.prerelease.length>0){const D=M[W].semver;if(D.major===R.major&&D.minor===R.minor&&D.patch===R.patch)return!0}return!1}return!0};return hp}var gp,Iw;function Ef(){if(Iw)return gp;Iw=1;const n=Symbol("SemVer ANY");class e{static get ANY(){return n}constructor(d,f){if(f=t(f),d instanceof e){if(d.loose===!!f.loose)return d;d=d.value}d=d.trim().split(/\s+/).join(" "),i("comparator",d,f),this.options=f,this.loose=!!f.loose,this.parse(d),this.semver===n?this.value="":this.value=this.operator+this.semver.version,i("comp",this)}parse(d){const f=this.options.loose?s[r.COMPARATORLOOSE]:s[r.COMPARATOR],m=d.match(f);if(!m)throw new TypeError(`Invalid comparator: ${d}`);this.operator=m[1]!==void 0?m[1]:"",this.operator==="="&&(this.operator=""),m[2]?this.semver=new l(m[2],this.options.loose):this.semver=n}toString(){return this.value}test(d){if(i("Comparator.test",d,this.options.loose),this.semver===n||d===n)return!0;if(typeof d=="string")try{d=new l(d,this.options)}catch{return!1}return o(d,this.operator,this.semver,this.options)}intersects(d,f){if(!(d instanceof e))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new c(d.value,f).test(this.value):d.operator===""?d.value===""?!0:new c(this.value,f).test(d.semver):(f=t(f),f.includePrerelease&&(this.value==="<0.0.0-0"||d.value==="<0.0.0-0")||!f.includePrerelease&&(this.value.startsWith("<0.0.0")||d.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&d.operator.startsWith(">")||this.operator.startsWith("<")&&d.operator.startsWith("<")||this.semver.version===d.semver.version&&this.operator.includes("=")&&d.operator.includes("=")||o(this.semver,"<",d.semver,f)&&this.operator.startsWith(">")&&d.operator.startsWith("<")||o(this.semver,">",d.semver,f)&&this.operator.startsWith("<")&&d.operator.startsWith(">")))}}gp=e;const t=n0(),{safeRe:s,t:r}=mc(),o=O_(),i=Cf(),l=zn(),c=qs();return gp}var xp,$w;function Tf(){if($w)return xp;$w=1;const n=qs();return xp=(t,s,r)=>{try{s=new n(s,r)}catch{return!1}return s.test(t)},xp}var bp,Rw;function yee(){if(Rw)return bp;Rw=1;const n=qs();return bp=(t,s)=>new n(t,s).set.map(r=>r.map(o=>o.value).join(" ").trim().split(" ")),bp}var vp,Ow;function wee(){if(Ow)return vp;Ow=1;const n=zn(),e=qs();return vp=(s,r,o)=>{let i=null,l=null,c=null;try{c=new e(r,o)}catch{return null}return s.forEach(u=>{c.test(u)&&(!i||l.compare(u)===-1)&&(i=u,l=new n(i,o))}),i},vp}var yp,Lw;function See(){if(Lw)return yp;Lw=1;const n=zn(),e=qs();return yp=(s,r,o)=>{let i=null,l=null,c=null;try{c=new e(r,o)}catch{return null}return s.forEach(u=>{c.test(u)&&(!i||l.compare(u)===1)&&(i=u,l=new n(i,o))}),i},yp}var wp,Mw;function kee(){if(Mw)return wp;Mw=1;const n=zn(),e=qs(),t=_f();return wp=(r,o)=>{r=new e(r,o);let i=new n("0.0.0");if(r.test(i)||(i=new n("0.0.0-0"),r.test(i)))return i;i=null;for(let l=0;l<r.set.length;++l){const c=r.set[l];let u=null;c.forEach(d=>{const f=new n(d.semver.version);switch(d.operator){case">":f.prerelease.length===0?f.patch++:f.prerelease.push(0),f.raw=f.format();case"":case">=":(!u||t(f,u))&&(u=f);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${d.operator}`)}}),u&&(!i||t(i,u))&&(i=u)}return i&&r.test(i)?i:null},wp}var Sp,zw;function jee(){if(zw)return Sp;zw=1;const n=qs();return Sp=(t,s)=>{try{return new n(t,s).range||"*"}catch{return null}},Sp}var kp,Dw;function a0(){if(Dw)return kp;Dw=1;const n=zn(),e=Ef(),{ANY:t}=e,s=qs(),r=Tf(),o=_f(),i=r0(),l=i0(),c=o0();return kp=(d,f,m,p)=>{d=new n(d,p),f=new s(f,p);let h,g,x,b,y;switch(m){case">":h=o,g=l,x=i,b=">",y=">=";break;case"<":h=i,g=c,x=o,b="<",y="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(r(d,f,p))return!1;for(let v=0;v<f.set.length;++v){const k=f.set[v];let j=null,_=null;if(k.forEach(N=>{N.semver===t&&(N=new e(">=0.0.0")),j=j||N,_=_||N,h(N.semver,j.semver,p)?j=N:x(N.semver,_.semver,p)&&(_=N)}),j.operator===b||j.operator===y||(!_.operator||_.operator===b)&&g(d,_.semver))return!1;if(_.operator===y&&x(d,_.semver))return!1}return!0},kp}var jp,Fw;function Nee(){if(Fw)return jp;Fw=1;const n=a0();return jp=(t,s,r)=>n(t,s,">",r),jp}var Np,Uw;function Cee(){if(Uw)return Np;Uw=1;const n=a0();return Np=(t,s,r)=>n(t,s,"<",r),Np}var Cp,Bw;function _ee(){if(Bw)return Cp;Bw=1;const n=qs();return Cp=(t,s,r)=>(t=new n(t,r),s=new n(s,r),t.intersects(s,r)),Cp}var _p,Ww;function Eee(){if(Ww)return _p;Ww=1;const n=Tf(),e=Ws();return _p=(t,s,r)=>{const o=[];let i=null,l=null;const c=t.sort((m,p)=>e(m,p,r));for(const m of c)n(m,s,r)?(l=m,i||(i=m)):(l&&o.push([i,l]),l=null,i=null);i&&o.push([i,null]);const u=[];for(const[m,p]of o)m===p?u.push(m):!p&&m===c[0]?u.push("*"):p?m===c[0]?u.push(`<=${p}`):u.push(`${m} - ${p}`):u.push(`>=${m}`);const d=u.join(" || "),f=typeof s.raw=="string"?s.raw:String(s);return d.length<f.length?d:s},_p}var Ep,qw;function Tee(){if(qw)return Ep;qw=1;const n=qs(),e=Ef(),{ANY:t}=e,s=Tf(),r=Ws(),o=(f,m,p={})=>{if(f===m)return!0;f=new n(f,p),m=new n(m,p);let h=!1;e:for(const g of f.set){for(const x of m.set){const b=c(g,x,p);if(h=h||b!==null,b)continue e}if(h)return!1}return!0},i=[new e(">=0.0.0-0")],l=[new e(">=0.0.0")],c=(f,m,p)=>{if(f===m)return!0;if(f.length===1&&f[0].semver===t){if(m.length===1&&m[0].semver===t)return!0;p.includePrerelease?f=i:f=l}if(m.length===1&&m[0].semver===t){if(p.includePrerelease)return!0;m=l}const h=new Set;let g,x;for(const S of f)S.operator===">"||S.operator===">="?g=u(g,S,p):S.operator==="<"||S.operator==="<="?x=d(x,S,p):h.add(S.semver);if(h.size>1)return null;let b;if(g&&x){if(b=r(g.semver,x.semver,p),b>0)return null;if(b===0&&(g.operator!==">="||x.operator!=="<="))return null}for(const S of h){if(g&&!s(S,String(g),p)||x&&!s(S,String(x),p))return null;for(const C of m)if(!s(S,String(C),p))return!1;return!0}let y,v,k,j,_=x&&!p.includePrerelease&&x.semver.prerelease.length?x.semver:!1,N=g&&!p.includePrerelease&&g.semver.prerelease.length?g.semver:!1;_&&_.prerelease.length===1&&x.operator==="<"&&_.prerelease[0]===0&&(_=!1);for(const S of m){if(j=j||S.operator===">"||S.operator===">=",k=k||S.operator==="<"||S.operator==="<=",g){if(N&&S.semver.prerelease&&S.semver.prerelease.length&&S.semver.major===N.major&&S.semver.minor===N.minor&&S.semver.patch===N.patch&&(N=!1),S.operator===">"||S.operator===">="){if(y=u(g,S,p),y===S&&y!==g)return!1}else if(g.operator===">="&&!S.test(g.semver))return!1}if(x){if(_&&S.semver.prerelease&&S.semver.prerelease.length&&S.semver.major===_.major&&S.semver.minor===_.minor&&S.semver.patch===_.patch&&(_=!1),S.operator==="<"||S.operator==="<="){if(v=d(x,S,p),v===S&&v!==x)return!1}else if(x.operator==="<="&&!S.test(x.semver))return!1}if(!S.operator&&(x||g)&&b!==0)return!1}return!(g&&k&&!x&&b!==0||x&&j&&!g&&b!==0||N||_)},u=(f,m,p)=>{if(!f)return m;const h=r(f.semver,m.semver,p);return h>0?f:h<0||m.operator===">"&&f.operator===">="?m:f},d=(f,m,p)=>{if(!f)return m;const h=r(f.semver,m.semver,p);return h<0?f:h>0||m.operator==="<"&&f.operator==="<="?m:f};return Ep=o,Ep}var Tp,Vw;function Aee(){if(Vw)return Tp;Vw=1;const n=mc(),e=fc(),t=zn(),s=I_(),r=Jo(),o=oee(),i=iee(),l=aee(),c=lee(),u=cee(),d=uee(),f=dee(),m=fee(),p=Ws(),h=mee(),g=pee(),x=s0(),b=hee(),y=gee(),v=_f(),k=r0(),j=$_(),_=R_(),N=o0(),S=i0(),C=O_(),E=xee(),T=bee(),A=Ef(),P=qs(),I=Tf(),$=yee(),O=wee(),M=See(),R=kee(),z=jee(),W=a0(),D=Nee(),L=Cee(),U=_ee(),F=Eee(),B=Tee();return Tp={parse:r,valid:o,clean:i,inc:l,diff:c,major:u,minor:d,patch:f,prerelease:m,compare:p,rcompare:h,compareLoose:g,compareBuild:x,sort:b,rsort:y,gt:v,lt:k,eq:j,neq:_,gte:N,lte:S,cmp:C,coerce:E,truncate:T,Comparator:A,Range:P,satisfies:I,toComparators:$,maxSatisfying:O,minSatisfying:M,minVersion:R,validRange:z,outside:W,gtr:D,ltr:L,intersects:U,simplifyRange:F,subset:B,SemVer:t,re:n.re,src:n.src,tokens:n.t,SEMVER_SPEC_VERSION:e.SEMVER_SPEC_VERSION,RELEASE_TYPES:e.RELEASE_TYPES,compareIdentifiers:s.compareIdentifiers,rcompareIdentifiers:s.rcompareIdentifiers},Tp}var Fn=Aee();const bt=De().min(1).max(64).regex(/^[a-zA-Z][a-zA-Z0-9_.-]*$/u).refine(n=>!["constructor","prototype","__proto__"].includes(n),"Reserved identifier"),Vo=De().min(1).max(128).refine(n=>[...n].every(e=>e.charCodeAt(0)>=32&&e.charCodeAt(0)!==127),"Control characters are forbidden"),Al=n=>De().refine(e=>Iu(e)<=n,"Text exceeds byte limit"),Qc=De().min(1).max(256).refine(n=>/^[A-Za-z0-9_./-]+$/u.test(n)?n.split("/").every(e=>e!==""&&e!=="."&&e!==".."&&!e.endsWith(".")&&!/^(?:con|prn|aux|nul|com[0-9]|lpt[0-9])(?:\.|$)/iu.test(e)):!1,"Expected a canonical portable package path");function go(n,e,t,s){const r=n.safeParse(t0(e,{maxBytes:t,maxNodes:s}));if(!r.success)throw new pg(r.error.issues.map(o=>({path:o.path.length?`$.${o.path.map(String).join(".")}`:"$",message:o.message})));return r.data}const Pee=["actions","actionJobs","pulls","pullFiles","pullSessions","issues","mergePull"],Iee=["deployments","buildLogs"],$ee=["workspace","deployments","version"],Ap=n=>ct(_t(n)).min(1).max(n.length).refine(e=>new Set(e).size===e.length,"Duplicate operation"),Ree=Dr("id",[we({id:Ze("github"),operations:Ap(Pee)}),we({id:Ze("vercel"),operations:Ap(Iee)}),we({id:Ze("cloudflare"),operations:Ap($ee)})]),Sr=pn().int().positive().max(Number.MAX_SAFE_INTEGER),To={integration:Ze("github")},Hw={integration:Ze("vercel")},Pp={integration:Ze("cloudflare")},Kw=De().regex(/^[A-Za-z0-9_-]+$/).max(64).optional(),Ip=De().max(240).regex(/^(?:[^/\\]+\/)*wrangler\.(?:json|jsonc|toml)$/).refine(n=>n.split("/").every(e=>e!=="."&&e!==".."),"Invalid configuration path").optional(),Oee=Dr("operation",[we({...To,operation:Ze("actions"),limit:Sr.max(30).optional()}),we({...To,operation:Ze("actionJobs"),runId:Sr}),we({...To,operation:Ze("pulls"),limit:Sr.max(50).optional()}),we({...To,operation:Ze("pullFiles"),number:Sr}),we({...To,operation:Ze("pullSessions")}),we({...To,operation:Ze("issues"),limit:Sr.max(50).optional()}),we({...To,operation:Ze("mergePull"),number:Sr,method:_t(["merge","squash","rebase"]),headSha:De().regex(/^[0-9a-f]{40}$/)})]),Lee=Dr("operation",[we({...Hw,operation:Ze("deployments"),limit:Sr.max(30).optional()}),we({...Hw,operation:Ze("buildLogs"),deploymentId:De().regex(/^dpl_[A-Za-z0-9]+$/).max(128),limit:Sr.max(500).optional()})]),Mee=Dr("operation",[we({...Pp,operation:Ze("workspace"),config:Ip}),we({...Pp,operation:Ze("deployments"),config:Ip,environment:Kw,limit:Sr.max(30).optional()}),we({...Pp,operation:Ze("version"),config:Ip,environment:Kw,versionId:De().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/)})]),zee=Dr("integration",[Oee,Lee,Mee]),Dee=Dr("ok",[we({ok:Ze(!0),data:P_(()=>!0)}),we({ok:Ze(!1),error:we({code:De().min(1).max(64),message:De().min(1).max(512)})})]),fs=1,Fee="1.1.0",L_="browser-iife-v1",hg=De().max(128).refine(n=>Fn.valid(n)===n,"Expected strict SemVer"),$u=De().min(1).max(256).refine(n=>Fn.validRange(n)!==null,"Expected a SemVer range"),Gw=bs(bt,$u).refine(n=>Object.keys(n).length<=32,"Too many capabilities"),Zw=we({client:Gw,host:Gw}),Oa=n=>new Set(n).size===n.length,Uee=ct(bt).max(32).refine(Oa,"Duplicate identifier"),Yw=De().min(1).max(64).regex(/^[a-z][a-z0-9-]*$/u),$p=De().regex(/^(?:[1-9][0-9]{0,3}px|(?:[1-9][0-9]?|100)%)$/u),Bee=we({manifestVersion:Ze(1),id:De().max(128).regex(/^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*$/u),publisher:Yw,name:Vo,version:hg,runtime:Ze(L_),entry:Qc.refine(n=>n.endsWith(".js"),"Entry must be JavaScript"),style:Qc.refine(n=>n.endsWith(".css"),"Style must be CSS").optional(),engines:we({pluginApi:$u,client:$u,host:$u}),protocol:Ze(fs).default(fs),requires:Zw,optional:Zw.default({client:{},host:{}}),browser:ct(_t(["message-channel","blob-script","web-crypto"])).max(3).refine(Oa).default([]),contributes:we({panels:ct(we({id:Yw,title:Vo,icon:Qc.refine(n=>/\.(png|jpe?g|webp)$/u.test(n),"Expected a raster icon"),order:pn().int().min(0).max(1e3).optional(),defaultSize:$p.optional(),minSize:$p.optional(),maxSize:$p.optional(),when:_t(["always","project-selected"]).default("project-selected")})).min(1).max(8)}),permissions:we({context:ct(_t(["project.identity","session.identity"])).max(2).refine(Oa).default([]),composer:ct(Ze("append")).max(1).default([]),navigation:ct(_t(["external","session"])).max(2).refine(Oa).default([]),connections:ct(we({id:bt,definition:Qc,operations:Uee.min(1)})).max(8).default([]),integrations:ct(Ree).max(2).default([]),storage:we({scope:_t(["project","plugin"]),quotaKiB:pn().int().min(1).max(1024)}).optional()}),stateVersion:pn().int().min(1).max(Number.MAX_SAFE_INTEGER)}).superRefine((n,e)=>{n.id.startsWith(`${n.publisher}.`)||e.addIssue({code:"custom",path:["id"],message:"Plugin ID must belong to its publisher"}),["cogpit.worktrees","cogpit.project-files","cogpit.browser","cogpit.file-changes","cogpit.session-info"].includes(n.id)&&e.addIssue({code:"custom",path:["id"],message:"Reserved built-in ID"});for(const[t,s]of[["panels",n.contributes.panels],["connections",n.permissions.connections],["integrations",n.permissions.integrations]])Oa(s.map(r=>r.id))||e.addIssue({code:"custom",path:[t],message:"Duplicate contribution ID"});for(const t of["client","host"])for(const s of Object.keys(n.optional[t]))Object.hasOwn(n.requires[t],s)&&e.addIssue({code:"custom",path:["optional",t,s],message:"Capability is already required"})});function M_(n){return go(Bee,n,Ht.manifestBytes)}const z_=De().max(256).refine(n=>{try{const e=new URL(n);return e.protocol==="https:"&&e.origin===n&&!e.username&&!e.password&&!e.port&&/^(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z][a-z0-9-]*[a-z0-9]$/u.test(e.hostname)&&!/\.(?:localhost|local|internal)$/u.test(e.hostname)}catch{return!1}},"Expected an exact public HTTPS origin"),Qr=De().max(256).refine(n=>(!n||n.startsWith("/"))&&!/~(?![01])/u.test(n)&&n.split("/").length<=9&&!n.split("/").some(e=>["__proto__","prototype","constructor"].includes(e)),"Invalid bounded JSON pointer"),D_=De().min(1).max(1024).regex(/^[a-zA-Z0-9._~-]+$/u).refine(n=>n!=="."&&n!==".."),Wee=Dr("type",[we({type:Ze("string"),required:hn().optional(),maxLength:pn().int().min(1).max(1024),enum:ct(Vo).min(1).max(32).optional()}),we({type:Ze("integer"),required:hn().optional(),min:pn().int().min(Number.MIN_SAFE_INTEGER),max:pn().int().max(Number.MAX_SAFE_INTEGER)}),we({type:Ze("boolean"),required:hn().optional()})]),qee=qo([we({literal:D_}),we({resource:bt}),we({arg:bt})]),Vee=qo([bt,we({literal:qo([De().max(1024),pn().int().min(Number.MIN_SAFE_INTEGER).max(Number.MAX_SAFE_INTEGER),hn()])}),we({arg:bt}),we({resource:bt}),we({identity:bt})]),Hee=we({audience:_t(["setup","panel"]),origin:z_,method:Ze("GET"),path:ct(qee).min(1).max(16),args:bs(bt,Wee).refine(n=>Object.keys(n).length<=16),query:bs(De().max(68).regex(/^[a-zA-Z][a-zA-Z0-9_.-]*(?:\[\])?$/u).refine(n=>!["constructor","prototype","__proto__"].includes(n.replace(/\[\]$/u,""))),Vee).refine(n=>Object.keys(n).length<=16)}),Xw=we({operation:bt,items:Qr,nested:Qr.optional(),id:Qr,label:Qr}),Kee=we({label:Vo,scope:_t(["connection","project"]).optional(),dependsOn:ct(bt).max(7).refine(n=>new Set(n).size===n.length).optional(),options:qo([Xw,ct(Xw).min(1).max(4)]).optional(),input:we({allowId:hn(),urls:ct(we({origin:z_,pathMarker:D_})).min(1).max(8).optional(),validation:we({operation:bt,argument:bt,id:Qr.optional(),label:Qr,parents:bs(bt,Qr).refine(n=>Object.keys(n).length<=7).optional()})}).optional()}).refine(n=>!!n.options||!!n.input,"Expected listed or validated entered resources"),Gee=we({version:Ze(1),id:bt,label:Vo,secret:we({id:bt,label:Vo}),auth:we({header:De().max(64).regex(/^(?:Authorization|X-[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*)$/iu).refine(n=>!/^x-(?:forwarded|http-method|original|rewrite)(?:-|$)/iu.test(n),"Unsafe credential header"),scheme:_t(["raw","bearer"])}),validationOperation:bt,identity:bs(bt,Qr).refine(n=>Object.keys(n).length<=8).optional(),resources:bs(bt,Kee).refine(n=>Object.keys(n).length<=8),operations:bs(bt,Hee).refine(n=>Object.keys(n).length>0&&Object.keys(n).length<=32)});function bd(n){return n?[...n.path.flatMap(e=>"resource"in e?[e.resource]:[]),...Object.values(n.query).flatMap(e=>typeof e=="object"&&"resource"in e?[e.resource]:[])]:[]}function Jw(n,e){const t=n.resources[e];if(!t)return[];const s=t.options?Array.isArray(t.options)?t.options:[t.options]:[];return[...new Set([...t.dependsOn??[],...s.flatMap(r=>bd(n.operations[r.operation])),...bd(t.input?n.operations[t.input.validation.operation]:void 0)])]}const Zee=Gee.superRefine((n,e)=>{var u,d;const t=(f,m)=>e.addIssue({code:"custom",path:f,message:m}),s=f=>{var m;return((m=n.operations[f])==null?void 0:m.audience)==="setup"},r=(f,m)=>f&&Object.entries(f.args).every(([p,h])=>!h.required||p===m),o=n.operations[n.validationOperation];(!s(n.validationOperation)||!r(o)||bd(o).length||Object.values((o==null?void 0:o.query)??{}).some(f=>typeof f=="object"&&"identity"in f))&&t(["validationOperation"],"Expected an independent setup operation without required arguments");for(const[f,m]of Object.entries(n.resources)){const p=Jw(n,f);for(const g of p)(g===f||!Object.hasOwn(n.resources,g))&&t(["resources",f,"dependsOn"],"Unknown or self-dependent resource"),(m.scope??"connection")==="connection"&&((u=n.resources[g])==null?void 0:u.scope)==="project"&&t(["resources",f,"scope"],"Connection resource cannot depend on a project resource");const h=m.options?Array.isArray(m.options)?m.options:[m.options]:[];for(const g of h){const x=n.operations[g.operation];(!s(g.operation)||!r(x))&&t(["resources",f,"options"],"Expected a setup operation without required arguments"),p.some(b=>!bd(x).includes(b))&&t(["resources",f,"options"],"Every options source must bind all parent resources")}if(m.input){const g=m.input,x=g.validation,b=n.operations[x.operation],y=b==null?void 0:b.args[x.argument];!g.allowId&&!g.urls&&t(["resources",f,"input"],"Expected an accepted input format"),(!s(x.operation)||!r(b,x.argument)||(y==null?void 0:y.type)!=="string"||!y.required||b.path.filter(v=>"arg"in v&&v.arg===x.argument).length!==1)&&t(["resources",f,"input","validation"],"Validation must request the candidate as one required path argument"),(p.some(v=>!Object.hasOwn(x.parents??{},v))||Object.keys(x.parents??{}).some(v=>!p.includes(v)))&&t(["resources",f,"input","validation","parents"],"Validation must prove each selected parent")}}const i=new Set,l=new Set,c=f=>{if(i.has(f)){t(["resources",f,"dependsOn"],"Resource dependency cycle");return}if(!l.has(f)){i.add(f);for(const m of Jw(n,f))Object.hasOwn(n.resources,m)&&c(m);i.delete(f),l.add(f)}};for(const f of Object.keys(n.resources))c(f);for(const[f,m]of Object.entries(n.operations)){const p=new Set;for(const[h,g]of Object.entries(m.args))(Object.hasOwn(n.resources,h)||Object.hasOwn(n.identity??{},h))&&t(["operations",f,"args",h],"Argument shadows a host-owned binding"),g.type==="integer"&&g.min>g.max&&t(["operations",f,"args",h],"Inverted integer bounds"),g.type==="string"&&((d=g.enum)!=null&&d.some(x=>new TextEncoder().encode(x).byteLength>g.maxLength))&&t(["operations",f,"args",h],"Enum exceeds string limit");for(const h of m.path)if("resource"in h&&!Object.hasOwn(n.resources,h.resource)&&t(["operations",f,"path"],"Unknown selected resource"),"arg"in h){const g=m.args[h.arg];((g==null?void 0:g.type)!=="string"||g.required!==!0)&&t(["operations",f,"path"],"Path argument must be a required string"),p.add(h.arg)}for(const h of Object.values(m.query)){const g=typeof h=="string"?h:"arg"in h?h.arg:void 0;g!==void 0?(Object.hasOwn(m.args,g)||t(["operations",f,"query"],"Unknown query argument"),p.add(g)):typeof h=="object"&&"resource"in h&&!Object.hasOwn(n.resources,h.resource)?t(["operations",f,"query"],"Unknown selected resource"):typeof h=="object"&&"identity"in h&&!Object.hasOwn(n.identity??{},h.identity)&&t(["operations",f,"query"],"Unknown validated identity")}Object.keys(m.args).some(h=>!p.has(h))&&t(["operations",f,"args"],"Unused argument")}});function gg(n){return go(Zee,n,Ht.definitionBytes)}const F_={appVersion:De().min(1).max(128),apiVersions:ct(hg).max(16),manifestVersions:ct(pn().int().min(1).max(1024)).max(16),protocolVersions:ct(pn().int().min(1).max(1024)).max(16),runtimes:ct(De().min(1).max(64)).max(16),capabilities:bs(bt,hg).refine(n=>Object.keys(n).length<=64)},Yee=we({...F_,browser:ct(De().min(1).max(64)).max(16)}),Xee=we({...F_,platform:De().min(1).max(32),registryRevision:pn().int().min(0).max(Number.MAX_SAFE_INTEGER)});function Jee(n){return go(Yee,n,16*1024)}function Qee(n){return go(Xee,n,16*1024)}function ete(n,e,t,s={}){var f;const r=[],o=[],i=(m,p)=>!!Fn.valid(m)&&!!Fn.validRange(p)&&Fn.satisfies(m,p,{includePrerelease:s.allowPrerelease===!0}),l=(m,p,h,g,x)=>r.push({side:m,code:p,name:h,required:g,actual:x});s.revoked&&l("package","REVOKED",n.id,"non-revoked package",n.version),Fn.prerelease(n.version)&&!s.allowPrerelease&&l("package","PRERELEASE",n.id,"stable release",n.version);for(const m of["client","host"]){const p=m==="client"?e:t;i(p.appVersion,n.engines[m])||l(m,"APP_VERSION","app",n.engines[m],p.appVersion),p.manifestVersions.includes(n.manifestVersion)||l(m,"MANIFEST_VERSION","manifest",String(n.manifestVersion),p.manifestVersions.join(",")),p.protocolVersions.includes(n.protocol)||l(m,"PROTOCOL_VERSION","protocol",String(n.protocol),p.protocolVersions.join(",")),p.runtimes.includes(n.runtime)||l(m,"RUNTIME","runtime",n.runtime,p.runtimes.join(","));for(const[h,g]of Object.entries(n.requires[m])){const x=p.capabilities[h]??null;(!x||!i(x,g))&&l(m,"CAPABILITY",h,g,x)}for(const[h,g]of Object.entries(n.optional[m])){const x=p.capabilities[h]??null;(!x||!i(x,g))&&o.push({side:m,name:h,required:g,actual:x})}}for(const m of n.browser)e.browser.includes(m)||l("client","BROWSER",m,"available",null);const c=[],u=new Fn.Range(n.engines.pluginApi,{includePrerelease:s.allowPrerelease===!0});for(const m of e.apiVersions.filter(p=>Fn.valid(p)))for(const p of t.apiVersions.filter(h=>Fn.valid(h))){if(Fn.major(m)!==Fn.major(p))continue;const h=Fn.compare(m,p)<=0?m:p;i(h,n.engines.pluginApi)&&c.push(h);for(const g of u.set){const x=`${g.map(y=>y.value).join(" ")} >=${Fn.major(h)}.0.0 <=${h}`,b=(f=Fn.minVersion(x))==null?void 0:f.version;b&&i(b,n.engines.pluginApi)&&c.push(b)}}const d=c.sort(Fn.rcompare)[0]??null;if(!d){for(const m of["client","host"]){const p=m==="client"?e.apiVersions:t.apiVersions;p.some(h=>i(h,n.engines.pluginApi))||l(m,"API_VERSION","pluginApi",n.engines.pluginApi,p.join(","))}r.some(m=>m.code==="API_VERSION")||l("host","API_VERSION","pluginApi","common API version",t.apiVersions.join(","))}return{compatible:r.length===0,apiVersion:d,issues:r,unavailableOptional:o}}const vd=P_(()=>!0),tte=we({}),nte=we({id:bt,name:Vo}).nullable(),U_=we({mode:_t(["light","dark"]),tokens:bs(De().regex(/^--[a-z][a-z0-9-]{0,63}$/u),Al(256)).refine(n=>Object.keys(n).length<=64)}),B_=De().regex(/^s_[a-f0-9]{48}$/u),ste=we({handle:B_}).nullable().optional(),W_=we({project:nte,theme:U_,locale:De().min(1).max(64),reducedMotion:hn(),visible:hn(),session:ste});function Qw(n){return go(W_,n,Ht.responseBytes)}const q_=["INVALID_REQUEST","INVALID_RESPONSE","INCOMPATIBLE_HOST","INCOMPATIBLE_CLIENT","PERMISSION_REQUIRED","CONNECTION_REQUIRED","RESOURCE_REQUIRED","STALE_ACTIVATION","RATE_LIMITED","PLUGIN_DISABLED","CAPABILITY_UNAVAILABLE","UPSTREAM_FAILED","CANCELED","TIMEOUT","DISPOSED"],rte=we({code:_t(q_),message:Al(512)}),eu=De().min(1).max(64).regex(/^[a-zA-Z0-9_-]+$/u),ote=De().min(1).max(2048).refine(n=>{try{const e=new URL(n);return e.protocol==="https:"&&!e.username&&!e.password}catch{return!1}},"Expected an HTTPS URL without credentials"),Rp=bt,V_={"lifecycle.ready":tte,"connections.request":we({handle:bt,operationId:bt,args:bs(bt,qo([De(),pn().finite(),hn()]))}),"connections.status":we({handle:bt}),"integrations.request":zee,"storage.get":we({key:Rp}),"storage.set":we({key:Rp,value:vd}),"storage.delete":we({key:Rp}),"composer.append":we({text:Al(Ht.composerBytes)}),"navigation.openExternal":we({url:ote}),"navigation.openSession":we({handle:bt})},ite=we({configured:hn(),readOnly:hn(),selected:bs(bt,we({id:Al(1024),label:Al(256)})).refine(n=>Object.keys(n).length<=8)}),ate=Dr("event",[we({protocol:Ze(fs),type:Ze("event"),event:Ze("context"),value:W_}),we({protocol:Ze(fs),type:Ze("event"),event:Ze("theme"),value:U_}),we({protocol:Ze(fs),type:Ze("event"),event:Ze("visibility"),value:hn()}),we({protocol:Ze(fs),type:Ze("event"),event:Ze("session"),value:we({handle:B_}).nullable()}),we({protocol:Ze(fs),type:Ze("event"),event:Ze("dispose"),value:k_()})]),lte=qo([we({protocol:Ze(fs),type:Ze("request"),id:eu,method:_t(Object.keys(V_)),params:vd}),we({protocol:Ze(fs),type:Ze("result"),id:eu,value:vd}),we({protocol:Ze(fs),type:Ze("error"),id:eu,error:rte}),we({protocol:Ze(fs),type:Ze("cancel"),id:eu}),ate]);function eS(n){var s;const e=n!==null&&typeof n=="object"&&((s=Object.getOwnPropertyDescriptor(n,"type"))==null?void 0:s.value)==="result",t=go(lte,n,e?Ht.resultMessageBytes:Ht.messageBytes,e?Ht.responseNodes+16:Ht.nodes);if(t.type==="request"){const r=t.method==="composer.append"?Ht.composerBytes+64:t.method==="storage.set"?Ht.storageValueBytes:Ht.argumentBytes,o=go(V_[t.method],t.params,r);return{...t,params:o}}return t.type==="result"?{...t,value:t0(t.value,{maxBytes:Ht.responseBytes,maxNodes:Ht.responseNodes})}:t}function H_(n,e){const t=n==="integrations.request"?Dee:n==="connections.status"?ite:n==="connections.request"||n==="storage.get"?vd:k_();return go(t,e,Ht.responseBytes,Ht.responseNodes)}const pc=pn().int().min(0).max(Number.MAX_SAFE_INTEGER),Af=De().regex(/^[a-f0-9]{64}$/),Pl=Rr().transform(M_),K_=Dr("type",[we({type:Ze("all")}),we({type:Ze("projects"),projectIds:ct(De().min(1).max(512)).max(128).refine(n=>new Set(n).size===n.length)})]),cte=we({digest:Af,manifest:Pl,targetPath:De().min(1).max(512),installedAt:pc,unavailableReason:De().max(1e3).optional()}),ute=we({id:De().regex(/^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*$/).max(128),selectedDigest:Af,manifest:Pl,enabled:hn(),scope:K_,pinned:hn(),versions:ct(cte).min(1).max(64),lastError:De().max(1e3).optional()}),dte=we({id:De().max(128),label:De().max(128),kind:_t(["official","development"]),fingerprint:De().max(128),verifiedAt:pc.optional()}),G_=we({available:hn(),error:De().max(2e3).optional(),revision:pc,plugins:ct(ute).max(256),publishers:ct(dte).max(256),legacyPluginIds:ct(_t(["github","clickup","vercel-deployments"])).max(3).optional(),availableSeeds:ct(we({manifest:Pl,digest:Af})).max(256).optional(),recoveryCode:_t(["STORE_LOCKED","STORE_VERSION","STORE_CORRUPT","STORE_UNAVAILABLE"]).optional()}),fte=we({side:_t(["client","host"]),name:De().max(128),required:De().max(256),actual:De().max(512).nullable()}),mte=we({compatible:hn(),apiVersion:De().max(128).nullable(),issues:ct(we({side:_t(["client","host","package"]),code:_t(["APP_VERSION","API_VERSION","MANIFEST_VERSION","PROTOCOL_VERSION","RUNTIME","CAPABILITY","BROWSER","PRERELEASE","REVOKED"]),name:De().max(128),required:De().max(256),actual:De().max(512).nullable()})).max(128),unavailableOptional:ct(fte).max(128)});Rr().transform(Jee);const Ru=we({transactionId:De().uuid(),manifest:Pl,digest:Af,compatibility:mte,connectionDefinitions:ct(Rr().transform(gg)).max(8),oldVersion:De().max(128).nullable(),registryRevision:pc,publisherKind:_t(["official","development"]),scope:K_,operation:_t(["install","update","rollback"]).optional(),previousManifest:Pl.optional(),previousConnectionDefinitions:ct(Rr().transform(gg)).max(8).optional(),incompatibleClients:ct(De().max(256)).max(256).optional()}),Z_=we({id:De().regex(/^p_[a-f0-9]{40}$/),name:De().max(512),paths:ct(De().max(8192)).max(256)}),pte=we({runtime:Rr().transform(Qee),host:we({name:De().max(256),instanceId:De().max(128)}),store:G_,projects:ct(Z_).max(1024),safeMode:hn(),connectionRevision:pc.optional()}),xg=De().regex(/^[a-zA-Z][a-zA-Z0-9_.-]*$/).max(64),l0=pn().int().nonnegative().max(Number.MAX_SAFE_INTEGER),Y_=we({pluginId:De().regex(/^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*$/).max(128),projectId:De().regex(/^p_[a-f0-9]{40}$/).nullable()});Y_.extend({expectedRevision:l0});const hte=Y_.extend({connectionId:xg});hte.extend({expectedRevision:l0});const X_=we({id:De().min(1).max(1024),label:De().min(1).max(256)}),gte=ct(X_).max(1e3),tS=we({revision:l0,connections:ct(we({id:xg,label:De().min(1).max(128),status:_t(["disconnected","connected","environment"]),readOnly:hn(),legacyImportAvailable:hn().optional(),selected:bs(xg,X_).refine(n=>Object.keys(n).length<=8),definition:Rr().transform(gg)})).max(8)});function La(n=globalThis){var u,d,f,m,p,h,g,x,b,y,v,k,j,_,N,S,C,E;const e=T=>typeof T=="function",t=e(n.MessageChannel)&&e((d=(u=n.MessagePort)==null?void 0:u.prototype)==null?void 0:d.postMessage)&&e((m=(f=n.MessagePort)==null?void 0:f.prototype)==null?void 0:m.start)&&e((h=(p=n.MessagePort)==null?void 0:p.prototype)==null?void 0:h.close),s=e(n.Blob)&&e((g=n.URL)==null?void 0:g.createObjectURL)&&e((x=n.URL)==null?void 0:x.revokeObjectURL),r=e((y=(b=n.crypto)==null?void 0:b.subtle)==null?void 0:y.digest)&&e((v=n.crypto)==null?void 0:v.getRandomValues),o=n.isSecureContext===!0,l=[["secure context (HTTPS or localhost)",o],["MessageChannel",t],["Blob URLs",s],["Web Crypto",r],["AbortController",e(n.AbortController)],["AbortSignal.any",e((k=n.AbortSignal)==null?void 0:k.any)],["AbortSignal.timeout",e((j=n.AbortSignal)==null?void 0:j.timeout)],["AbortSignal.throwIfAborted",e((N=(_=n.AbortSignal)==null?void 0:_.prototype)==null?void 0:N.throwIfAborted)],["structuredClone",e(n.structuredClone)],["Object.hasOwn",e((S=n.Object)==null?void 0:S.hasOwn)],["fetch",e(n.fetch)],["Headers",e(n.Headers)],["ReadableStream",e((E=(C=n.ReadableStream)==null?void 0:C.prototype)==null?void 0:E.getReader)],["TextEncoder",e(n.TextEncoder)],["TextDecoder",e(n.TextDecoder)]].filter(([,T])=>!T).map(([T])=>T),c=[];return t&&c.push("message-channel"),s&&c.push("blob-script"),r&&o&&c.push("web-crypto"),{supported:l.length===0,browser:c,missing:l,error:l.length?`Runtime plugins are unavailable in this browser. Missing: ${l.join(", ")}. Update your browser or use a secure connection.`:null}}const xte=we({sessionId:De().regex(/^[a-f0-9]{64}$/),expiresAt:pn().int().positive()}),nS=we({id:De().min(1).max(128),expiresAt:pn().int().positive()}),bte=we({deadline:pn().int().positive()}),vte=we({status:_t(["prepared","trial","committing","committed","cancelled","abandoned"]),preview:Ru,deadline:pn().int().positive().optional()}),bg={status:null,error:null,activation:""};function gi(){const n=La();return{appVersion:d5,apiVersions:[Fee],manifestVersions:[1],protocolVersions:[fs],runtimes:n.supported?[L_]:[],capabilities:n.supported?{"workspace.panel":"1.0.0","composer.append":"1.0.0","navigation.external":"1.0.0","navigation.session":"1.0.0"}:{},browser:n.browser}}class vg extends Error{constructor(e,t,s){super(e),this.code=t,this.status=s}}async function J_(n,e){var c;const t=n.headers.get("Content-Length");if(t&&Number(t)>e)throw await((c=n.body)==null?void 0:c.cancel()),new Error("Plugin response exceeds its size limit");if(!n.body)throw new Error("Plugin host returned an empty response");const s=n.body.getReader(),r=[];let o=0;try{for(;;){const{done:u,value:d}=await s.read();if(u)break;if(o+=d.byteLength,o>e)throw new Error("Plugin response exceeds its size limit");r.push(d)}}catch(u){throw await s.cancel().catch(()=>{}),u}finally{s.releaseLock()}const i=new Uint8Array(o);let l=0;for(const u of r)i.set(u,l),l+=u.byteLength;return i.buffer}async function tu(n){const e=await J_(n,4194304);let t;try{t=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(e))}catch{throw new Error("This host does not support runtime plugins, or returned an invalid response")}if(!n.ok){const s=zQ({error:De().max(2e3),code:De().max(128).optional()}).safeParse(t);throw new vg(s.success?s.data.error:"Plugin request failed",s.success?s.data.code??"HOST_ERROR":"HOST_ERROR",n.status)}return t}class yte{constructor(){Wt(this,"scope",fn());Wt(this,"identity",xs());Wt(this,"base",new URL(c1("/api/plugins/"),window.location.origin));Wt(this,"lifetimeController");Wt(this,"session",null);Wt(this,"renewal",null);Wt(this,"refreshPromise",null);Wt(this,"timer");Wt(this,"listeners",new Set);Wt(this,"state",bg);Wt(this,"running",!1);Wt(this,"getSnapshot",()=>this.state);Wt(this,"subscribe",e=>(this.listeners.add(e),()=>this.listeners.delete(e)));Wt(this,"hostChanged",()=>{(this.scope!==fn()||this.identity!==xs())&&this.stop()})}get controller(){const e=La();if(!e.supported)throw new vg(e.error,"UNSUPPORTED_BROWSER",0);if(!this.lifetimeController)throw new Error("The plugin client has not started");return this.lifetimeController}publish(e){if(JSON.stringify(this.state)!==JSON.stringify(e)){this.state=e;for(const t of this.listeners)t()}}assertCurrent(e){const t=this.controller.signal;if((e??t).throwIfAborted(),!this.running||this.scope!==fn()||this.identity!==xs())throw new Error("The connected host or signed-in user changed")}start(){if(this.running)return;const e=La();if(!e.supported){this.publish({status:null,error:e.error,activation:""});return}this.running=!0,this.lifetimeController=new AbortController;for(const t of["cogpit-device-changed","cogpit-device-scope-changed","cogpit-identity-changed","popstate"])window.addEventListener(t,this.hostChanged);this.refresh(),this.timer=setInterval(()=>{this.refresh()},5e3)}stop(){var t;this.running=!1,clearInterval(this.timer),(t=this.lifetimeController)==null||t.abort();const e=this.session;this.session=null,this.renewal=null,this.refreshPromise=null;for(const s of["cogpit-device-changed","cogpit-device-scope-changed","cogpit-identity-changed","popstate"])window.removeEventListener(s,this.hostChanged);this.publish(bg),e&&this.releaseSession(e.sessionId)}releaseSession(e){La().supported&&Re(new URL("session",this.base),{method:"DELETE",headers:{"X-Cogpit-Plugin-Session":e},signal:AbortSignal.timeout(5e3),keepalive:!0}).catch(()=>{})}async ensureSession(){if(this.assertCurrent(),this.session&&this.session.expiresAt-Date.now()>25e3)return;if(this.renewal)return this.renewal;const e=this.controller.signal,t=new Headers;t.set("Content-Type","application/json"),this.session&&t.set("X-Cogpit-Plugin-Session",this.session.sessionId);const s=(async()=>{const r=await Re(new URL("session",this.base),{method:"POST",headers:t,body:JSON.stringify({client:gi()}),signal:AbortSignal.any([e,AbortSignal.timeout(2e4)])}),o=xte.parse(await tu(r));try{this.assertCurrent(e)}catch(i){throw this.releaseSession(o.sessionId),i}this.session=o})();this.renewal=s;try{await s}finally{this.renewal===s&&(this.renewal=null)}}async request(e,t={}){const s=this.controller.signal;await this.ensureSession(),this.assertCurrent(s);const r=new Headers(t.headers);r.set("X-Cogpit-Plugin-Session",this.session.sessionId);const o=await Re(new URL(e,this.base),{...t,headers:r,signal:AbortSignal.any([s,...t.signal?[t.signal]:[],AbortSignal.timeout(3e4)])});return this.assertCurrent(s),o}async json(e,t,s="POST",r){const o=this.controller.signal,i=await this.request(e,{method:s,signal:r,...t===void 0?{}:{body:JSON.stringify(t),headers:{"Content-Type":"application/json"}}}),l=await tu(i);return this.assertCurrent(o),l}refresh(){const e=La();if(!e.supported)return this.stop(),this.publish({status:null,error:e.error,activation:""}),Promise.resolve();if(this.refreshPromise)return this.refreshPromise;const t=this.controller.signal,s=(async()=>{var r;try{const o=pte.parse(await this.json("status",void 0,"GET"));if(this.assertCurrent(t),((r=this.state.status)==null?void 0:r.host.instanceId)===o.host.instanceId&&this.state.status.store.revision>o.store.revision)return;this.publish({status:o,error:null,activation:`${this.scope}:${this.identity??"personal"}:${o.host.instanceId}:${this.session.sessionId}:${o.connectionRevision??0}`})}catch(o){if(t.aborted||!this.running)return;o instanceof vg&&o.code==="STALE_ACTIVATION"&&(this.session=null),this.publish({status:null,error:o instanceof Error?o.message:"Plugin host is unavailable",activation:""})}})();return this.refreshPromise=s,s.finally(()=>{this.refreshPromise===s&&(this.refreshPromise=null)}),s}async stageSeed(e,t){return Ru.parse(await this.json("stage-seed",{pluginId:e,scope:t,client:gi()}))}async stage(e,t){const s=this.controller.signal;if(e.size>4*1024*1024)throw new Error("Choose a plugin package smaller than 4 MiB");const r=Ru.parse(await tu(await this.request("stage",{method:"POST",body:e,headers:{"Content-Type":"application/octet-stream","X-Cogpit-Plugin-Client":JSON.stringify(gi()),"X-Cogpit-Plugin-Scope":JSON.stringify(t)}})));return this.assertCurrent(s),r}async payload(e,t){const s=this.controller.signal,r=await this.request(`payload/${encodeURIComponent(e)}`,{signal:t});r.ok||await tu(r);const o=await J_(r,4*1024*1024);return this.assertCurrent(s),t==null||t.throwIfAborted(),o}acceptStore(e){const t=G_.parse(e),s=this.state.status;s&&t.revision>=s.store.revision&&this.publish({...this.state,status:{...s,store:t,runtime:{...s.runtime,registryRevision:t.revision}}})}async beginTrial(e,t){return bte.parse(await this.json(`transactions/${e.transactionId}/trial`,void 0,"POST",t)).deadline}async commit(e,t){this.acceptStore(await this.json(`transactions/${e.transactionId}/commit`,{expectedRevision:e.registryRevision},"POST",t)),await this.refresh()}async transactionOutcome(e){return vte.parse(await this.json(`transactions/${e.transactionId}`,void 0,"GET"))}async cancel(e){await this.json(`transactions/${e.transactionId}`,void 0,"DELETE")}async enrollDeveloper(e){this.acceptStore(await this.json("publishers",{...e,development:!0})),await this.refresh()}async changeInstalled(e,t,s,r){const o=`installed/${encodeURIComponent(e)}${t==="uninstall"?"":`/${t}`}`;this.acceptStore(await this.json(o,{...s,expectedRevision:r},t==="uninstall"?"DELETE":"POST")),await this.refresh()}async rollback(e,t,s){return Ru.parse(await this.json(`installed/${encodeURIComponent(e)}/rollback`,{digest:t,scope:s,client:gi()}))}async lease(e,t,s,r,o){return nS.parse(await this.json("leases",{pluginId:e,projectId:t,contextEpoch:s,...o?{workspacePath:o}:{},client:gi()},"POST",r))}async renewLease(e,t){return nS.parse(await this.json(`leases/${encodeURIComponent(e)}/renew`,void 0,"POST",t))}async revokeLease(e){await this.json(`leases/${encodeURIComponent(e)}`,void 0,"DELETE")}async call(e,t,s){const r=we({value:Rr()}).parse(await this.json(`leases/${encodeURIComponent(e)}/call`,t,"POST",s));return H_(t.method,r.value)}async resolveSession(e,t,s){return we({dirName:De().min(1).max(8192),fileName:De().min(1).max(8192)}).parse(await this.json(`leases/${encodeURIComponent(e)}/session`,{handle:t},"POST",s))}async sessionHandle(e,t,s){return we({handle:De().regex(/^s_[a-f0-9]{48}$/)}).parse(await this.json(`leases/${encodeURIComponent(e)}/session-handle`,t,"POST",s)).handle}async resolveWorkspace(e,t){return Z_.nullable().parse(await this.json("workspace/resolve",{workspacePath:e},"POST",t))}async connections(e,t){const s=new URLSearchParams({pluginId:e.pluginId,...e.projectId?{projectId:e.projectId}:{}});return tS.parse(await this.json(`connections?${s}`,void 0,"GET",t))}async connectionOptions(e,t,s,r){return gte.parse(await this.json("connections/options",{...e,connectionId:t,resourceId:s},"POST",r))}async changeConnection(e,t,s,r,o,i){const l=tS.parse(await this.json(`connections/${s}`,{...e,connectionId:t,...r,expectedRevision:o},"POST",i));return await this.refresh(),l}async clearPluginData(e,t,s){await this.json("connections/clear-data",{pluginId:e,expectedRevision:t},"POST",s),await this.refresh()}}function Q_(n){const e=q.c(7),[t]=w.useState(Ste),s=w.useSyncExternalStore(t.subscribe,t.getSnapshot,wte);let r,o;e[0]!==t||e[1]!==n?(r=()=>{if(n)return t.start(),()=>t.stop()},o=[t,n],e[0]=t,e[1]=n,e[2]=r,e[3]=o):(r=e[2],o=e[3]),w.useEffect(r,o);let i;return e[4]!==t||e[5]!==s?(i={client:t,...s},e[4]=t,e[5]=s,e[6]=i):i=e[6],i}function wte(){return bg}function Ste(){return new yte}function Cr(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)?n:null}function en(n,e=""){return typeof n=="string"?n:e}const kte=new Set(["open","custom","closed","done"]),jte=new Set(["urgent","high","normal","low"]);class Nte extends Error{constructor(t,s,r){super(r);Wt(this,"status");Wt(this,"code");this.status=t,this.code=s}}function sS(n){return typeof n=="number"?String(n):en(n)}function Ao(n){const e=typeof n=="string"?Number(n):n;return typeof e=="number"&&Number.isFinite(e)&&e>0?e:null}function Cte(n){const e=Cr(n);return e&&e.hidden!==!0&&en(e.name)||null}function _te(n){return new Nte(502,"invalid_response",`ClickUp returned an invalid ${n} response`)}function Ete(n){const e=Cr(n);if(!e||typeof e.id!="number")return null;const t=en(e.username)||en(e.email);return{id:e.id,username:t,initials:en(e.initials)||t.slice(0,2).toUpperCase(),color:en(e.color)||null}}function Tte(n){const e=Cr(n);if(!e)return null;const t=en(e.status);if(!t)return null;const s=en(e.type);return{name:t,type:kte.has(s)?s:"custom",color:en(e.color,"#d3d3d3"),order:typeof e.orderindex=="number"?e.orderindex:0}}function Ate(n){const e=Cr(n),t=en(e==null?void 0:e.name);return t?{name:t,background:en(e==null?void 0:e.tag_bg)||null}:null}function Pte(n){var t;const e=en((t=Cr(n))==null?void 0:t.priority);return jte.has(e)?e:null}function Ite(n){var i;const e=Cr(n);if(!e)return null;const t=en(e.id),s=Tte(e.status),r=Cr(e.list);if(!t||!s||!r)return null;const o=en(e.custom_id);return{id:t,customId:o||null,name:en(e.name,"Untitled task"),description:en(e.markdown_description)||en(e.description),status:s,priority:Pte(e.priority),url:en(e.url)||`https://app.clickup.com/t/${t}`,assignees:Array.isArray(e.assignees)?e.assignees.map(Ete).filter(l=>l!==null):[],tags:Array.isArray(e.tags)?e.tags.map(Ate).filter(l=>l!==null):[],parentId:en(e.parent)||null,listId:sS(r.id),listName:en(r.name,"List"),folderName:Cte(e.folder),spaceId:sS((i=Cr(e.space))==null?void 0:i.id),createdAt:Ao(e.date_created)??0,updatedAt:Ao(e.date_updated)??Ao(e.date_created)??0,dueAt:Ao(e.due_date),startAt:Ao(e.start_date),closedAt:Ao(e.date_closed)??Ao(e.date_done)}}function $te(n){const e=Cr(n);if(!e||!Array.isArray(e.tasks))throw _te("task list");return{tasks:e.tasks.map(Ite).filter(t=>t!==null),lastPage:e.last_page!==!1}}const Rte="absolute -right-1 -top-1 min-w-4 px-1 text-[9px]",Ote="absolute -right-0.5 -top-0.5 size-3 p-0 text-[8px]",Lte=new Set(["cogpit.github","cogpit.vercel","cogpit.clickup"]),Mte=new Set(["action_required","failure","startup_failure","timed_out"]),zte=new Set(["BUILDING","INITIALIZING","QUEUED"]),Dte=new Set(["BLOCKED","CANCELED","ERROR"]);function yd(n,e,t="default"){return n?{text:String(n),label:e,variant:t}:null}function Fte(n,e){var r;const t=n.filter(o=>o.status!=="completed").length;if(t)return yd(t,`${t} active GitHub Actions run${t===1?"":"s"}`);if((r=n[0])!=null&&r.conclusion&&Mte.has(n[0].conclusion))return{text:"!",label:"Latest GitHub Actions run failed",variant:"destructive",compact:!0};const s=e.filter(o=>(o.state==="open"||o.state==="draft")&&o.reviewRequested).length;return yd(s,`${s} pull request${s===1?"":"s"} waiting for your review`,"secondary")}function Ute(n){const e=n.filter(t=>zte.has(t.state)).length;return e?yd(e,`${e} active Vercel deployment${e===1?"":"s"}`):n[0]&&Dte.has(n[0].state)?{text:"!",label:"Latest Vercel deployment failed",variant:"destructive",compact:!0}:null}function Bte(n){const e=new Date;e.setHours(0,0,0,0);const t=n.filter(s=>s.status.type!=="closed"&&s.dueAt!==null&&s.dueAt<e.getTime()).length;return yd(t,`${t} overdue ClickUp task${t===1?"":"s"}`,"destructive")}class rS extends Error{}function Wte(n){let e=[],t=[],s=-1/0;return async(r,o)=>{let i=0;async function l(d){const f=await r({protocol:1,type:"request",id:`indicator-${++i}`,method:"integrations.request",params:d});if(o.throwIfAborted(),!f.ok)throw new rS("Integration unavailable");return f.data}if(n==="cogpit.vercel"){const d=await l({integration:"vercel",operation:"deployments",limit:20});return Ute(d.deployments)}if(n==="cogpit.github"){const d=await Promise.allSettled([l({integration:"github",operation:"actions",limit:20}),Date.now()-s>=3e4?l({integration:"github",operation:"pulls",limit:30}):Promise.resolve(null)]);o.throwIfAborted();for(const p of d)if(p.status==="rejected"&&!(p.reason instanceof rS))throw p.reason;const[f,m]=d;return f.status==="fulfilled"&&(e=f.value.runs),m.status==="fulfilled"&&m.value!==null&&(t=m.value.pulls,s=Date.now()),Fte(e,t)}const c=await r({protocol:1,type:"request",id:"indicator-status",method:"connections.status",params:{handle:"clickup"}});if(o.throwIfAborted(),!c.configured||!c.selected.workspace)return null;const u=new Map;for(let d=0;d<3;d++){const f=$te(await r({protocol:1,type:"request",id:`indicator-page-${d}`,method:"connections.request",params:{handle:"clickup",operationId:"mine",args:{page:d}}}));o.throwIfAborted();for(const m of f.tasks)u.set(m.id,m);if(f.lastPage)break}return Bte([...u.values()])}}function qte({client:n,pluginId:e,projectId:t,workspacePath:s,activation:r,registryRevision:o,enabled:i=!0}){const l=JSON.stringify([e,t,s,r,o,i]),[c,u]=w.useState(null);w.useEffect(()=>{if(!i||!r||!Lte.has(e)||e!=="cogpit.clickup"&&(!t||!s))return;const f=new AbortController,m=Wte(e),p=e==="cogpit.clickup"?6e4:1e4,h=Array.from(crypto.getRandomValues(new Uint8Array(16)),j=>j.toString(16).padStart(2,"0")).join("");let g,x=null,b=!1;function y(){const j=x;x=null,j&&n.revokeLease(j).catch(()=>{})}async function v(){if(b||f.signal.aborted)return;if(document.visibilityState==="hidden"){g=setTimeout(()=>{v()},p);return}b=!0;const j=new AbortController,_=Date.now()+2e4;let N=setTimeout(()=>{j.abort(),y()},2e4);const S=AbortSignal.any([f.signal,j.signal]);try{const C=await n.lease(e,t,h,S,s);x=C.id,S.throwIfAborted();const E=Math.min(_,C.expiresAt)-Date.now();if(E<=0)throw new Error("Plugin lease expired");clearTimeout(N),N=setTimeout(()=>{j.abort(),y()},E);const T=await m(A=>(S.throwIfAborted(),n.call(C.id,A,S)),S);S.throwIfAborted(),u({client:n,identity:l,indicator:T})}catch{f.signal.aborted||u({client:n,identity:l,indicator:null})}finally{clearTimeout(N),y(),b=!1,f.signal.aborted||(g=setTimeout(()=>{v()},p))}}function k(){document.visibilityState==="visible"&&!b&&(clearTimeout(g),v())}return v(),document.addEventListener("visibilitychange",k),()=>{f.abort(),clearTimeout(g),document.removeEventListener("visibilitychange",k),y()}},[n,e,t,s,r,o,i,l]);const d=(c==null?void 0:c.client)===n&&c.identity===l?c.indicator:null;return d?a.jsx(Ue,{variant:d.variant,className:d.compact?Ote:Rte,"aria-label":d.label,children:d.text}):null}const Gr=0,Ae=1,st=2,Kt=3,jt=4,cs=5,hc=6,wn=7,Un=8,lt=9,tt=10,Rt=11,at=12,Tt=13,gc=14,Kn=15,Ln=16,Mn=17,Qn=18,es=19,Xn=20,ft=21,Je=22,an=23,qn=24,on=25,Vte=0;function Sn(n){return n>=48&&n<=57}function xo(n){return Sn(n)||n>=65&&n<=70||n>=97&&n<=102}function c0(n){return n>=65&&n<=90}function Hte(n){return n>=97&&n<=122}function Kte(n){return c0(n)||Hte(n)}function Gte(n){return n>=128}function wd(n){return Kte(n)||Gte(n)||n===95}function eE(n){return wd(n)||Sn(n)||n===45}function Zte(n){return n>=0&&n<=8||n===11||n>=14&&n<=31||n===127}function Sd(n){return n===10||n===13||n===12}function Ho(n){return Sd(n)||n===32||n===9}function Rs(n,e){return!(n!==92||Sd(e)||e===Vte)}function Ou(n,e,t){return n===45?wd(e)||e===45||Rs(e,t):wd(n)?!0:n===92?Rs(n,e):!1}function Op(n,e,t){return n===43||n===45?Sn(e)?2:e===46&&Sn(t)?3:0:n===46?Sn(e)?2:0:Sn(n)?1:0}function tE(n){return n===65279||n===65534?1:0}const yg=new Array(128),Yte=128,Lu=130,nE=131,u0=132,sE=133;for(let n=0;n<yg.length;n++)yg[n]=Ho(n)&&Lu||Sn(n)&&nE||wd(n)&&u0||Zte(n)&&sE||n||Yte;function Lp(n){return n<128?yg[n]:u0}function _i(n,e){return e<n.length?n.charCodeAt(e):0}function wg(n,e,t){return t===13&&_i(n,e+1)===10?2:1}function Ei(n,e,t){let s=n.charCodeAt(e);return c0(s)&&(s=s|32),s===t}function Il(n,e,t,s){if(t-e!==s.length||e<0||t>n.length)return!1;for(let r=e;r<t;r++){const o=s.charCodeAt(r-e);let i=n.charCodeAt(r);if(c0(i)&&(i=i|32),i!==o)return!1}return!0}function Xte(n,e){for(;e>=0&&Ho(n.charCodeAt(e));e--);return e+1}function nu(n,e){for(;e<n.length&&Ho(n.charCodeAt(e));e++);return e}function Mp(n,e){for(;e<n.length&&Sn(n.charCodeAt(e));e++);return e}function Ko(n,e){if(e+=2,xo(_i(n,e-1))){for(const s=Math.min(n.length,e+5);e<s&&xo(_i(n,e));e++);const t=_i(n,e);Ho(t)&&(e+=wg(n,e,t))}return e}function su(n,e){for(;e<n.length;e++){const t=n.charCodeAt(e);if(!eE(t)){if(Rs(t,_i(n,e+1))){e=Ko(n,e)-1;continue}break}}return e}function Pf(n,e){let t=n.charCodeAt(e);if((t===43||t===45)&&(t=n.charCodeAt(e+=1)),Sn(t)&&(e=Mp(n,e+1),t=n.charCodeAt(e)),t===46&&Sn(n.charCodeAt(e+1))&&(e+=2,e=Mp(n,e)),Ei(n,e,101)){let s=0;t=n.charCodeAt(e+1),(t===45||t===43)&&(s=1,t=n.charCodeAt(e+2)),Sn(t)&&(e=Mp(n,e+1+s+1))}return e}function zp(n,e){for(;e<n.length;e++){const t=n.charCodeAt(e);if(t===41){e++;break}Rs(t,_i(n,e+1))&&(e=Ko(n,e))}return e}function d0(n){if(n.length===1&&!xo(n.charCodeAt(0)))return n[0];let e=parseInt(n,16);return(e===0||e>=55296&&e<=57343||e>1114111)&&(e=65533),String.fromCodePoint(e)}const Sg=["EOF-token","ident-token","function-token","at-keyword-token","hash-token","string-token","bad-string-token","url-token","bad-url-token","delim-token","number-token","percentage-token","dimension-token","whitespace-token","CDO-token","CDC-token","colon-token","semicolon-token","comma-token","[-token","]-token","(-token",")-token","{-token","}-token","comment-token"],Jte=16*1024;function kd(n=null,e){return n===null||n.length<e?new Uint32Array(Math.max(e+1024,Jte)):n}const oS=10,Qte=12,iS=13;function aS(n){const e=n.source,t=e.length,s=e.length>0?tE(e.charCodeAt(0)):0,r=kd(n.lines,t),o=kd(n.columns,t);let i=n.startLine,l=n.startColumn;for(let c=s;c<t;c++){const u=e.charCodeAt(c);r[c]=i,o[c]=l++,(u===oS||u===iS||u===Qte)&&(u===iS&&c+1<t&&e.charCodeAt(c+1)===oS&&(c++,r[c]=i,o[c]=l),i++,l=1)}r[t]=i,o[t]=l,n.lines=r,n.columns=o,n.computed=!0}class ene{constructor(e,t,s,r){this.setSource(e,t,s,r),this.lines=null,this.columns=null}setSource(e="",t=0,s=1,r=1){this.source=e,this.startOffset=t,this.startLine=s,this.startColumn=r,this.computed=!1}getLocation(e,t){return this.computed||aS(this),{source:t,offset:this.startOffset+e,line:this.lines[e],column:this.columns[e]}}getLocationRange(e,t,s){return this.computed||aS(this),{source:s,start:{offset:this.startOffset+e,line:this.lines[e],column:this.columns[e]},end:{offset:this.startOffset+t,line:this.lines[t],column:this.columns[t]}}}}const Ns=16777215,Cs=24,xc=1,If=2,eo=new Uint8Array(32);eo[st]=Je;eo[ft]=Je;eo[es]=Xn;eo[an]=qn;const Os=new Uint8Array(32);Os[st]=xc;Os[ft]=xc;Os[es]=xc;Os[an]=xc;Os[Je]=If;Os[Xn]=If;Os[qn]=If;function lS(n,e,t){return n<e?e:n>t?t:n}class tne{constructor(e,t){this.setSource(e,t)}reset(){this.eof=!1,this.tokenIndex=-1,this.tokenType=0,this.tokenStart=this.firstCharOffset,this.tokenEnd=this.firstCharOffset}setSource(e="",t=()=>{}){e=String(e||"");const s=e.length,r=kd(this.offsetAndType,e.length+1),o=kd(this.balance,e.length+1);let i=0,l=-1,c=0,u=e.length;this.offsetAndType=null,this.balance=null,o.fill(0),t(e,(d,f,m)=>{const p=i++;if(r[p]=d<<Cs|m,l===-1&&(l=f),o[p]=u,d===c){const h=o[u];o[u]=p,u=h,c=eo[r[h]>>Cs]}else this.isBlockOpenerTokenType(d)&&(u=p,c=eo[d])}),r[i]=Gr<<Cs|s,o[i]=i;for(let d=0;d<i;d++){const f=o[d];if(f<=d){const m=o[f];m!==d&&(o[d]=m)}else f>i&&(o[d]=i)}this.source=e,this.firstCharOffset=l===-1?0:l,this.tokenCount=i,this.offsetAndType=r,this.balance=o,this.reset(),this.next()}lookupType(e){return e+=this.tokenIndex,e<this.tokenCount?this.offsetAndType[e]>>Cs:Gr}lookupTypeNonSC(e){for(let t=this.tokenIndex;t<this.tokenCount;t++){const s=this.offsetAndType[t]>>Cs;if(s!==Tt&&s!==on&&e--===0)return s}return Gr}lookupOffset(e){return e+=this.tokenIndex,e<this.tokenCount?this.offsetAndType[e-1]&Ns:this.source.length}lookupOffsetNonSC(e){for(let t=this.tokenIndex;t<this.tokenCount;t++){const s=this.offsetAndType[t]>>Cs;if(s!==Tt&&s!==on&&e--===0)return t-this.tokenIndex}return Gr}lookupValue(e,t){return e+=this.tokenIndex,e<this.tokenCount?Il(this.source,this.offsetAndType[e-1]&Ns,this.offsetAndType[e]&Ns,t):!1}getTokenStart(e){return e===this.tokenIndex?this.tokenStart:e>0?e<this.tokenCount?this.offsetAndType[e-1]&Ns:this.offsetAndType[this.tokenCount]&Ns:this.firstCharOffset}getTokenEnd(e){return e===this.tokenIndex?this.tokenEnd:this.offsetAndType[lS(e,0,this.tokenCount)]&Ns}getTokenType(e){return e===this.tokenIndex?this.tokenType:this.offsetAndType[lS(e,0,this.tokenCount)]>>Cs}substrToCursor(e){return this.source.substring(e,this.tokenStart)}isBlockOpenerTokenType(e){return Os[e]===xc}isBlockCloserTokenType(e){return Os[e]===If}getBlockTokenPairIndex(e){const t=this.getTokenType(e);if(Os[t]===1){const s=this.balance[e],r=this.getTokenType(s);return eo[t]===r?s:-1}else if(Os[t]===2){const s=this.balance[e],r=this.getTokenType(s);return eo[r]===t?s:-1}return-1}isBalanceEdge(e){return this.balance[this.tokenIndex]<e}isDelim(e,t){return t?this.lookupType(t)===lt&&this.source.charCodeAt(this.lookupOffset(t))===e:this.tokenType===lt&&this.source.charCodeAt(this.tokenStart)===e}skip(e){let t=this.tokenIndex+e;t<this.tokenCount?(this.tokenIndex=t,this.tokenStart=this.offsetAndType[t-1]&Ns,t=this.offsetAndType[t],this.tokenType=t>>Cs,this.tokenEnd=t&Ns):(this.tokenIndex=this.tokenCount,this.next())}next(){let e=this.tokenIndex+1;e<this.tokenCount?(this.tokenIndex=e,this.tokenStart=this.tokenEnd,e=this.offsetAndType[e],this.tokenType=e>>Cs,this.tokenEnd=e&Ns):(this.eof=!0,this.tokenIndex=this.tokenCount,this.tokenType=Gr,this.tokenStart=this.tokenEnd=this.source.length)}skipSC(){for(;this.tokenType===Tt||this.tokenType===on;)this.next()}skipUntilBalanced(e,t){let s=e,r=0,o=0;e:for(;s<this.tokenCount;s++){if(r=this.balance[s],r<e)break e;switch(o=s>0?this.offsetAndType[s-1]&Ns:this.firstCharOffset,t(this.source.charCodeAt(o))){case 1:break e;case 2:s++;break e;default:this.isBlockOpenerTokenType(this.offsetAndType[s]>>Cs)&&(s=r)}}this.skip(s-this.tokenIndex)}forEachToken(e){for(let t=0,s=this.firstCharOffset;t<this.tokenCount;t++){const r=s,o=this.offsetAndType[t],i=o&Ns,l=o>>Cs;s=i,e(l,r,i,t)}}dump(){const e=new Array(this.tokenCount);return this.forEachToken((t,s,r,o)=>{e[o]={idx:o,type:Sg[t],chunk:this.source.substring(s,r),balance:this.balance[o]}}),e}}function $f(n,e){function t(f){return f<l?n.charCodeAt(f):0}function s(){if(u=Pf(n,u),Ou(t(u),t(u+1),t(u+2))){d=at,u=su(n,u);return}if(t(u)===37){d=Rt,u++;return}d=tt}function r(){const f=u;if(u=su(n,u),Il(n,f,u,"url")&&t(u)===40){if(u=nu(n,u+1),t(u)===34||t(u)===39){d=st,u=f+4;return}i();return}if(t(u)===40){d=st,u++;return}d=Ae}function o(f){for(f||(f=t(u++)),d=cs;u<n.length;u++){const m=n.charCodeAt(u);switch(Lp(m)){case f:u++;return;case Lu:if(Sd(m)){u+=wg(n,u,m),d=hc;return}break;case 92:if(u===n.length-1)break;const p=t(u+1);Sd(p)?u+=wg(n,u+1,p):Rs(m,p)&&(u=Ko(n,u)-1);break}}}function i(){for(d=wn,u=nu(n,u);u<n.length;u++){const f=n.charCodeAt(u);switch(Lp(f)){case 41:u++;return;case Lu:if(u=nu(n,u),t(u)===41||u>=n.length){u<n.length&&u++;return}u=zp(n,u),d=Un;return;case 34:case 39:case 40:case sE:u=zp(n,u),d=Un;return;case 92:if(Rs(f,t(u+1))){u=Ko(n,u)-1;break}u=zp(n,u),d=Un;return}}}n=String(n||"");const l=n.length;let c=tE(t(0)),u=c,d;for(;u<l;){const f=n.charCodeAt(u);switch(Lp(f)){case Lu:d=Tt,u=nu(n,u+1);break;case 34:o();break;case 35:eE(t(u+1))||Rs(t(u+1),t(u+2))?(d=jt,u=su(n,u+1)):(d=lt,u++);break;case 39:o();break;case 40:d=ft,u++;break;case 41:d=Je,u++;break;case 43:Op(f,t(u+1),t(u+2))?s():(d=lt,u++);break;case 44:d=Qn,u++;break;case 45:Op(f,t(u+1),t(u+2))?s():t(u+1)===45&&t(u+2)===62?(d=Kn,u=u+3):Ou(f,t(u+1),t(u+2))?r():(d=lt,u++);break;case 46:Op(f,t(u+1),t(u+2))?s():(d=lt,u++);break;case 47:t(u+1)===42?(d=on,u=n.indexOf("*/",u+2),u=u===-1?n.length:u+2):(d=lt,u++);break;case 58:d=Ln,u++;break;case 59:d=Mn,u++;break;case 60:t(u+1)===33&&t(u+2)===45&&t(u+3)===45?(d=gc,u=u+4):(d=lt,u++);break;case 64:Ou(t(u+1),t(u+2),t(u+3))?(d=Kt,u=su(n,u+1)):(d=lt,u++);break;case 91:d=es,u++;break;case 92:Rs(f,t(u+1))?r():(d=lt,u++);break;case 93:d=Xn,u++;break;case 123:d=an,u++;break;case 125:d=qn,u++;break;case nE:s();break;case u0:r();break;default:d=lt,u++}e(d,c,c=u)}}let oi=null;class ln{static createItem(e){return{prev:null,next:null,data:e}}constructor(){this.head=null,this.tail=null,this.cursor=null}createItem(e){return ln.createItem(e)}allocateCursor(e,t){let s;return oi!==null?(s=oi,oi=oi.cursor,s.prev=e,s.next=t,s.cursor=this.cursor):s={prev:e,next:t,cursor:this.cursor},this.cursor=s,s}releaseCursor(){const{cursor:e}=this;this.cursor=e.cursor,e.prev=null,e.next=null,e.cursor=oi,oi=e}updateCursors(e,t,s,r){let{cursor:o}=this;for(;o!==null;)o.prev===e&&(o.prev=t),o.next===s&&(o.next=r),o=o.cursor}*[Symbol.iterator](){for(let e=this.head;e!==null;e=e.next)yield e.data}get size(){let e=0;for(let t=this.head;t!==null;t=t.next)e++;return e}get isEmpty(){return this.head===null}get first(){return this.head&&this.head.data}get last(){return this.tail&&this.tail.data}fromArray(e){let t=null;this.head=null;for(let s of e){const r=ln.createItem(s);t!==null?t.next=r:this.head=r,r.prev=t,t=r}return this.tail=t,this}toArray(){return[...this]}toJSON(){return[...this]}forEach(e,t=this){const s=this.allocateCursor(null,this.head);for(;s.next!==null;){const r=s.next;s.next=r.next,e.call(t,r.data,r,this)}this.releaseCursor()}forEachRight(e,t=this){const s=this.allocateCursor(this.tail,null);for(;s.prev!==null;){const r=s.prev;s.prev=r.prev,e.call(t,r.data,r,this)}this.releaseCursor()}reduce(e,t,s=this){let r=this.allocateCursor(null,this.head),o=t,i;for(;r.next!==null;)i=r.next,r.next=i.next,o=e.call(s,o,i.data,i,this);return this.releaseCursor(),o}reduceRight(e,t,s=this){let r=this.allocateCursor(this.tail,null),o=t,i;for(;r.prev!==null;)i=r.prev,r.prev=i.prev,o=e.call(s,o,i.data,i,this);return this.releaseCursor(),o}some(e,t=this){for(let s=this.head;s!==null;s=s.next)if(e.call(t,s.data,s,this))return!0;return!1}map(e,t=this){const s=new ln;for(let r=this.head;r!==null;r=r.next)s.appendData(e.call(t,r.data,r,this));return s}filter(e,t=this){const s=new ln;for(let r=this.head;r!==null;r=r.next)e.call(t,r.data,r,this)&&s.appendData(r.data);return s}nextUntil(e,t,s=this){if(e===null)return;const r=this.allocateCursor(null,e);for(;r.next!==null;){const o=r.next;if(r.next=o.next,t.call(s,o.data,o,this))break}this.releaseCursor()}prevUntil(e,t,s=this){if(e===null)return;const r=this.allocateCursor(e,null);for(;r.prev!==null;){const o=r.prev;if(r.prev=o.prev,t.call(s,o.data,o,this))break}this.releaseCursor()}clear(){this.head=null,this.tail=null}copy(){const e=new ln;for(let t of this)e.appendData(t);return e}prepend(e){return this.updateCursors(null,e,this.head,e),this.head!==null?(this.head.prev=e,e.next=this.head):this.tail=e,this.head=e,this}prependData(e){return this.prepend(ln.createItem(e))}append(e){return this.insert(e)}appendData(e){return this.insert(ln.createItem(e))}insert(e,t=null){if(t!==null)if(this.updateCursors(t.prev,e,t,e),t.prev===null){if(this.head!==t)throw new Error("before doesn't belong to list");this.head=e,t.prev=e,e.next=t,this.updateCursors(null,e)}else t.prev.next=e,e.prev=t.prev,t.prev=e,e.next=t;else this.updateCursors(this.tail,e,null,e),this.tail!==null?(this.tail.next=e,e.prev=this.tail):this.head=e,this.tail=e;return this}insertData(e,t){return this.insert(ln.createItem(e),t)}remove(e){if(this.updateCursors(e,e.prev,e,e.next),e.prev!==null)e.prev.next=e.next;else{if(this.head!==e)throw new Error("item doesn't belong to list");this.head=e.next}if(e.next!==null)e.next.prev=e.prev;else{if(this.tail!==e)throw new Error("item doesn't belong to list");this.tail=e.prev}return e.prev=null,e.next=null,e}push(e){this.insert(ln.createItem(e))}pop(){return this.tail!==null?this.remove(this.tail):null}unshift(e){this.prepend(ln.createItem(e))}shift(){return this.head!==null?this.remove(this.head):null}prependList(e){return this.insertList(e,this.head)}appendList(e){return this.insertList(e)}insertList(e,t){return e.head===null?this:(t!=null?(this.updateCursors(t.prev,e.tail,t,e.head),t.prev!==null?(t.prev.next=e.head,e.head.prev=t.prev):this.head=e.head,t.prev=e.tail,e.tail.next=t):(this.updateCursors(this.tail,e.tail,null,e.head),this.tail!==null?(this.tail.next=e.head,e.head.prev=this.tail):this.head=e.head,this.tail=e.tail),e.head=null,e.tail=null,this)}replace(e,t){"head"in t?this.insertList(t,e):this.insert(t,e),this.remove(e)}}function Rf(n,e){const t=Object.create(SyntaxError.prototype),s=new Error;return Object.assign(t,{name:n,message:e,get stack(){return(s.stack||"").replace(/^(.+\n){1,3}/,`${n}: ${e}
|
|
177
|
+
`)}})}const Dp=100,cS=60,uS=" ";function dS({source:n,line:e,column:t,baseLine:s,baseColumn:r},o){function i(h,g){return u.slice(h,g).map((x,b)=>String(h+b+1).padStart(m)+" |"+x).join(`
|
|
178
|
+
`)}const l=`
|
|
179
|
+
`.repeat(Math.max(s-1,0)),c=" ".repeat(Math.max(r-1,0)),u=(l+c+n).split(/\r\n?|\n|\f/),d=Math.max(1,e-o)-1,f=Math.min(e+o,u.length+1),m=Math.max(4,String(f).length)+1;let p=0;t+=(uS.length-1)*(u[e-1].substr(0,t-1).match(/\t/g)||[]).length,t>Dp&&(p=t-cS+3,t=cS-2);for(let h=d;h<=f;h++)h>=0&&h<u.length&&(u[h]=u[h].replace(/\t/g,uS),u[h]=(p>0&&u[h].length>p?"…":"")+u[h].substr(p,Dp-2)+(u[h].length>p+Dp-1?"…":""));return[i(d,e),new Array(t+m+2).join("-")+"^",i(e,f)].filter(Boolean).join(`
|
|
180
|
+
`).replace(/^(\s+\d+\s+\|\n)+/,"").replace(/\n(\s+\d+\s+\|)+$/,"")}function fS(n,e,t,s,r,o=1,i=1){return Object.assign(Rf("SyntaxError",n),{source:e,offset:t,line:s,column:r,sourceFragment(c){return dS({source:e,line:s,column:r,baseLine:o,baseColumn:i},isNaN(c)?0:c)},get formattedMessage(){return`Parse error: ${n}
|
|
181
|
+
`+dS({source:e,line:s,column:r,baseLine:o,baseColumn:i},2)}})}function nne(n){const e=this.createList();let t=!1;const s={recognizer:n};for(;!this.eof;){switch(this.tokenType){case on:this.next();continue;case Tt:t=!0,this.next();continue}let r=n.getNode.call(this,s);if(r===void 0)break;t&&(n.onWhiteSpace&&n.onWhiteSpace.call(this,r,e,s),t=!1),e.push(r)}return t&&n.onWhiteSpace&&n.onWhiteSpace.call(this,null,e,s),e}const ii=()=>{},sne=33,rne=35,Fp=59,mS=123,pS=0,one={createList(){return[]},createSingleNodeList(n){return[n]},getFirstListNode(n){return n&&n[0]||null},getLastListNode(n){return n&&n.length>0?n[n.length-1]:null}},ine={createList(){return new ln},createSingleNodeList(n){return new ln().appendData(n)},getFirstListNode(n){return n&&n.first},getLastListNode(n){return n&&n.last}};function ane(n){return function(){return this[n]()}}function Up(n){const e=Object.create(null);for(const t of Object.keys(n)){const s=n[t],r=s.parse||s;r&&(e[t]=r)}return e}function lne(n){const e={context:Object.create(null),features:Object.assign(Object.create(null),n.features),scope:Object.assign(Object.create(null),n.scope),atrule:Up(n.atrule),pseudo:Up(n.pseudo),node:Up(n.node)};for(const[t,s]of Object.entries(n.parseContext))switch(typeof s){case"function":e.context[t]=s;break;case"string":e.context[t]=ane(s);break}return{config:e,...e,...e.node}}function cne(n){let e="",t="<unknown>",s=!1,r=ii,o=!1;const i=new ene,l=Object.assign(new tne,lne(n||{}),{parseAtrulePrelude:!0,parseRulePrelude:!0,parseValue:!0,parseCustomProperty:!1,readSequence:nne,consumeUntilBalanceEnd:()=>0,consumeUntilLeftCurlyBracket(d){return d===mS?1:0},consumeUntilLeftCurlyBracketOrSemicolon(d){return d===mS||d===Fp?1:0},consumeUntilExclamationMarkOrSemicolon(d){return d===sne||d===Fp?1:0},consumeUntilSemicolonIncluded(d){return d===Fp?2:0},createList:ii,createSingleNodeList:ii,getFirstListNode:ii,getLastListNode:ii,parseWithFallback(d,f){const m=this.tokenIndex;try{return d.call(this)}catch(p){if(o)throw p;this.skip(m-this.tokenIndex);const h=f.call(this);return o=!0,r(p,h),o=!1,h}},lookupNonWSType(d){let f;do if(f=this.lookupType(d++),f!==Tt&&f!==on)return f;while(f!==pS);return pS},charCodeAt(d){return d>=0&&d<e.length?e.charCodeAt(d):0},substring(d,f){return e.substring(d,f)},substrToCursor(d){return this.source.substring(d,this.tokenStart)},cmpChar(d,f){return Ei(e,d,f)},cmpStr(d,f,m){return Il(e,d,f,m)},consume(d){const f=this.tokenStart;return this.eat(d),this.substrToCursor(f)},consumeFunctionName(){const d=e.substring(this.tokenStart,this.tokenEnd-1);return this.eat(st),d},consumeNumber(d){const f=e.substring(this.tokenStart,Pf(e,this.tokenStart));return this.eat(d),f},eat(d){if(this.tokenType!==d){const f=Sg[d].slice(0,-6).replace(/-/g," ").replace(/^./,h=>h.toUpperCase());let m=`${/[[\](){}]/.test(f)?`"${f}"`:f} is expected`,p=this.tokenStart;switch(d){case Ae:this.tokenType===st||this.tokenType===wn?(p=this.tokenEnd-1,m="Identifier is expected but function found"):m="Identifier is expected";break;case jt:this.isDelim(rne)&&(this.next(),p++,m="Name is expected");break;case Rt:this.tokenType===tt&&(p=this.tokenEnd,m="Percent sign is expected");break}this.error(m,p)}this.next()},eatIdent(d){(this.tokenType!==Ae||this.lookupValue(0,d)===!1)&&this.error(`Identifier "${d}" is expected`),this.next()},eatDelim(d){this.isDelim(d)||this.error(`Delim "${String.fromCharCode(d)}" is expected`),this.next()},getLocation(d,f){return s?i.getLocationRange(d,f,t):null},getLocationFromList(d){if(s){const f=this.getFirstListNode(d),m=this.getLastListNode(d);return i.getLocationRange(f!==null?f.loc.start.offset-i.startOffset:this.tokenStart,m!==null?m.loc.end.offset-i.startOffset:this.tokenStart,t)}return null},error(d,f){const m=typeof f<"u"&&f<e.length?i.getLocation(f):this.eof?i.getLocation(Xte(e,e.length-1)):i.getLocation(this.tokenStart);throw new fS(d||"Unexpected input",e,m.offset,m.line,m.column,i.startLine,i.startColumn)}}),c=()=>({filename:t,source:e,tokenCount:l.tokenCount,getTokenType:d=>l.getTokenType(d),getTokenTypeName:d=>Sg[l.getTokenType(d)],getTokenStart:d=>l.getTokenStart(d),getTokenEnd:d=>l.getTokenEnd(d),getTokenValue:d=>l.source.substring(l.getTokenStart(d),l.getTokenEnd(d)),substring:(d,f)=>l.source.substring(d,f),balance:l.balance.subarray(0,l.tokenCount+1),isBlockOpenerTokenType:l.isBlockOpenerTokenType,isBlockCloserTokenType:l.isBlockCloserTokenType,getBlockTokenPairIndex:d=>l.getBlockTokenPairIndex(d),getLocation:d=>i.getLocation(d,t),getRangeLocation:(d,f)=>i.getLocationRange(d,f,t)});return Object.assign(function(d,f){e=d,f=f||{},l.setSource(e,$f),i.setSource(e,f.offset,f.line,f.column),t=f.filename||"<unknown>",s=!!f.positions,r=typeof f.onParseError=="function"?f.onParseError:ii,o=!1,l.parseAtrulePrelude="parseAtrulePrelude"in f?!!f.parseAtrulePrelude:!0,l.parseRulePrelude="parseRulePrelude"in f?!!f.parseRulePrelude:!0,l.parseValue="parseValue"in f?!!f.parseValue:!0,l.parseCustomProperty="parseCustomProperty"in f?!!f.parseCustomProperty:!1;const{context:m="default",list:p=!0,onComment:h,onToken:g}=f;if(!(m in l.context))throw new Error("Unknown context `"+m+"`");Object.assign(l,p?ine:one),Array.isArray(g)?l.forEachToken((b,y,v)=>{g.push({type:b,start:y,end:v})}):typeof g=="function"&&l.forEachToken(g.bind(c())),typeof h=="function"&&l.forEachToken((b,y,v)=>{if(b===on){const k=l.getLocation(y,v),j=Il(e,v-2,v,"*/")?e.slice(y+2,v-2):e.slice(y+2,v);h(j,k)}});const x=l.context[m].call(l,f);return l.eof||l.error(),x},{SyntaxError:fS,config:l.config})}var Bp={},ru={},ou={},hS;function une(){if(hS)return ou;hS=1;var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");return ou.encode=function(e){if(0<=e&&e<n.length)return n[e];throw new TypeError("Must be between 0 and 63: "+e)},ou.decode=function(e){var t=65,s=90,r=97,o=122,i=48,l=57,c=43,u=47,d=26,f=52;return t<=e&&e<=s?e-t:r<=e&&e<=o?e-r+d:i<=e&&e<=l?e-i+f:e==c?62:e==u?63:-1},ou}var gS;function dne(){if(gS)return ru;gS=1;var n=une(),e=5,t=1<<e,s=t-1,r=t;function o(l){return l<0?(-l<<1)+1:(l<<1)+0}function i(l){var c=(l&1)===1,u=l>>1;return c?-u:u}return ru.encode=function(c){var u="",d,f=o(c);do d=f&s,f>>>=e,f>0&&(d|=r),u+=n.encode(d);while(f>0);return u},ru.decode=function(c,u,d){var f=c.length,m=0,p=0,h,g;do{if(u>=f)throw new Error("Expected more digits in base 64 VLQ value.");if(g=n.decode(c.charCodeAt(u++)),g===-1)throw new Error("Invalid base64 digit: "+c.charAt(u-1));h=!!(g&r),g&=s,m=m+(g<<p),p+=e}while(h);d.value=i(m),d.rest=u},ru}var Wp={},xS;function f0(){return xS||(xS=1,(function(n){function e(S,C,E){if(C in S)return S[C];if(arguments.length===3)return E;throw new Error('"'+C+'" is a required argument.')}n.getArg=e;var t=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,s=/^data:.+\,.+$/;function r(S){var C=S.match(t);return C?{scheme:C[1],auth:C[2],host:C[3],port:C[4],path:C[5]}:null}n.urlParse=r;function o(S){var C="";return S.scheme&&(C+=S.scheme+":"),C+="//",S.auth&&(C+=S.auth+"@"),S.host&&(C+=S.host),S.port&&(C+=":"+S.port),S.path&&(C+=S.path),C}n.urlGenerate=o;var i=32;function l(S){var C=[];return function(E){for(var T=0;T<C.length;T++)if(C[T].input===E){var A=C[0];return C[0]=C[T],C[T]=A,C[0].result}var P=S(E);return C.unshift({input:E,result:P}),C.length>i&&C.pop(),P}}var c=l(function(C){var E=C,T=r(C);if(T){if(!T.path)return C;E=T.path}for(var A=n.isAbsolute(E),P=[],I=0,$=0;;)if(I=$,$=E.indexOf("/",I),$===-1){P.push(E.slice(I));break}else for(P.push(E.slice(I,$));$<E.length&&E[$]==="/";)$++;for(var O,M=0,$=P.length-1;$>=0;$--)O=P[$],O==="."?P.splice($,1):O===".."?M++:M>0&&(O===""?(P.splice($+1,M),M=0):(P.splice($,2),M--));return E=P.join("/"),E===""&&(E=A?"/":"."),T?(T.path=E,o(T)):E});n.normalize=c;function u(S,C){S===""&&(S="."),C===""&&(C=".");var E=r(C),T=r(S);if(T&&(S=T.path||"/"),E&&!E.scheme)return T&&(E.scheme=T.scheme),o(E);if(E||C.match(s))return C;if(T&&!T.host&&!T.path)return T.host=C,o(T);var A=C.charAt(0)==="/"?C:c(S.replace(/\/+$/,"")+"/"+C);return T?(T.path=A,o(T)):A}n.join=u,n.isAbsolute=function(S){return S.charAt(0)==="/"||t.test(S)};function d(S,C){S===""&&(S="."),S=S.replace(/\/$/,"");for(var E=0;C.indexOf(S+"/")!==0;){var T=S.lastIndexOf("/");if(T<0||(S=S.slice(0,T),S.match(/^([^\/]+:\/)?\/*$/)))return C;++E}return Array(E+1).join("../")+C.substr(S.length+1)}n.relative=d;var f=(function(){var S=Object.create(null);return!("__proto__"in S)})();function m(S){return S}function p(S){return g(S)?"$"+S:S}n.toSetString=f?m:p;function h(S){return g(S)?S.slice(1):S}n.fromSetString=f?m:h;function g(S){if(!S)return!1;var C=S.length;if(C<9||S.charCodeAt(C-1)!==95||S.charCodeAt(C-2)!==95||S.charCodeAt(C-3)!==111||S.charCodeAt(C-4)!==116||S.charCodeAt(C-5)!==111||S.charCodeAt(C-6)!==114||S.charCodeAt(C-7)!==112||S.charCodeAt(C-8)!==95||S.charCodeAt(C-9)!==95)return!1;for(var E=C-10;E>=0;E--)if(S.charCodeAt(E)!==36)return!1;return!0}function x(S,C,E){var T=k(S.source,C.source);return T!==0||(T=S.originalLine-C.originalLine,T!==0)||(T=S.originalColumn-C.originalColumn,T!==0||E)||(T=S.generatedColumn-C.generatedColumn,T!==0)||(T=S.generatedLine-C.generatedLine,T!==0)?T:k(S.name,C.name)}n.compareByOriginalPositions=x;function b(S,C,E){var T;return T=S.originalLine-C.originalLine,T!==0||(T=S.originalColumn-C.originalColumn,T!==0||E)||(T=S.generatedColumn-C.generatedColumn,T!==0)||(T=S.generatedLine-C.generatedLine,T!==0)?T:k(S.name,C.name)}n.compareByOriginalPositionsNoSource=b;function y(S,C,E){var T=S.generatedLine-C.generatedLine;return T!==0||(T=S.generatedColumn-C.generatedColumn,T!==0||E)||(T=k(S.source,C.source),T!==0)||(T=S.originalLine-C.originalLine,T!==0)||(T=S.originalColumn-C.originalColumn,T!==0)?T:k(S.name,C.name)}n.compareByGeneratedPositionsDeflated=y;function v(S,C,E){var T=S.generatedColumn-C.generatedColumn;return T!==0||E||(T=k(S.source,C.source),T!==0)||(T=S.originalLine-C.originalLine,T!==0)||(T=S.originalColumn-C.originalColumn,T!==0)?T:k(S.name,C.name)}n.compareByGeneratedPositionsDeflatedNoLine=v;function k(S,C){return S===C?0:S===null?1:C===null?-1:S>C?1:-1}function j(S,C){var E=S.generatedLine-C.generatedLine;return E!==0||(E=S.generatedColumn-C.generatedColumn,E!==0)||(E=k(S.source,C.source),E!==0)||(E=S.originalLine-C.originalLine,E!==0)||(E=S.originalColumn-C.originalColumn,E!==0)?E:k(S.name,C.name)}n.compareByGeneratedPositionsInflated=j;function _(S){return JSON.parse(S.replace(/^\)]}'[^\n]*\n/,""))}n.parseSourceMapInput=_;function N(S,C,E){if(C=C||"",S&&(S[S.length-1]!=="/"&&C[0]!=="/"&&(S+="/"),C=S+C),E){var T=r(E);if(!T)throw new Error("sourceMapURL could not be parsed");if(T.path){var A=T.path.lastIndexOf("/");A>=0&&(T.path=T.path.substring(0,A+1))}C=u(o(T),C)}return c(C)}n.computeSourceURL=N})(Wp)),Wp}var qp={},bS;function fne(){if(bS)return qp;bS=1;var n=f0(),e=Object.prototype.hasOwnProperty,t=typeof Map<"u";function s(){this._array=[],this._set=t?new Map:Object.create(null)}return s.fromArray=function(o,i){for(var l=new s,c=0,u=o.length;c<u;c++)l.add(o[c],i);return l},s.prototype.size=function(){return t?this._set.size:Object.getOwnPropertyNames(this._set).length},s.prototype.add=function(o,i){var l=t?o:n.toSetString(o),c=t?this.has(o):e.call(this._set,l),u=this._array.length;(!c||i)&&this._array.push(o),c||(t?this._set.set(o,u):this._set[l]=u)},s.prototype.has=function(o){if(t)return this._set.has(o);var i=n.toSetString(o);return e.call(this._set,i)},s.prototype.indexOf=function(o){if(t){var i=this._set.get(o);if(i>=0)return i}else{var l=n.toSetString(o);if(e.call(this._set,l))return this._set[l]}throw new Error('"'+o+'" is not in the set.')},s.prototype.at=function(o){if(o>=0&&o<this._array.length)return this._array[o];throw new Error("No element indexed by "+o)},s.prototype.toArray=function(){return this._array.slice()},qp.ArraySet=s,qp}var Vp={},vS;function mne(){if(vS)return Vp;vS=1;var n=f0();function e(s,r){var o=s.generatedLine,i=r.generatedLine,l=s.generatedColumn,c=r.generatedColumn;return i>o||i==o&&c>=l||n.compareByGeneratedPositionsInflated(s,r)<=0}function t(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}return t.prototype.unsortedForEach=function(r,o){this._array.forEach(r,o)},t.prototype.add=function(r){e(this._last,r)?(this._last=r,this._array.push(r)):(this._sorted=!1,this._array.push(r))},t.prototype.toArray=function(){return this._sorted||(this._array.sort(n.compareByGeneratedPositionsInflated),this._sorted=!0),this._array},Vp.MappingList=t,Vp}var yS;function pne(){if(yS)return Bp;yS=1;var n=dne(),e=f0(),t=fne().ArraySet,s=mne().MappingList;function r(o){o||(o={}),this._file=e.getArg(o,"file",null),this._sourceRoot=e.getArg(o,"sourceRoot",null),this._skipValidation=e.getArg(o,"skipValidation",!1),this._ignoreInvalidMapping=e.getArg(o,"ignoreInvalidMapping",!1),this._sources=new t,this._names=new t,this._mappings=new s,this._sourcesContents=null}return r.prototype._version=3,r.fromSourceMap=function(i,l){var c=i.sourceRoot,u=new r(Object.assign(l||{},{file:i.file,sourceRoot:c}));return i.eachMapping(function(d){var f={generated:{line:d.generatedLine,column:d.generatedColumn}};d.source!=null&&(f.source=d.source,c!=null&&(f.source=e.relative(c,f.source)),f.original={line:d.originalLine,column:d.originalColumn},d.name!=null&&(f.name=d.name)),u.addMapping(f)}),i.sources.forEach(function(d){var f=d;c!==null&&(f=e.relative(c,d)),u._sources.has(f)||u._sources.add(f);var m=i.sourceContentFor(d);m!=null&&u.setSourceContent(d,m)}),u},r.prototype.addMapping=function(i){var l=e.getArg(i,"generated"),c=e.getArg(i,"original",null),u=e.getArg(i,"source",null),d=e.getArg(i,"name",null);!this._skipValidation&&this._validateMapping(l,c,u,d)===!1||(u!=null&&(u=String(u),this._sources.has(u)||this._sources.add(u)),d!=null&&(d=String(d),this._names.has(d)||this._names.add(d)),this._mappings.add({generatedLine:l.line,generatedColumn:l.column,originalLine:c!=null&&c.line,originalColumn:c!=null&&c.column,source:u,name:d}))},r.prototype.setSourceContent=function(i,l){var c=i;this._sourceRoot!=null&&(c=e.relative(this._sourceRoot,c)),l!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[e.toSetString(c)]=l):this._sourcesContents&&(delete this._sourcesContents[e.toSetString(c)],Object.keys(this._sourcesContents).length===0&&(this._sourcesContents=null))},r.prototype.applySourceMap=function(i,l,c){var u=l;if(l==null){if(i.file==null)throw new Error(`SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map's "file" property. Both were omitted.`);u=i.file}var d=this._sourceRoot;d!=null&&(u=e.relative(d,u));var f=new t,m=new t;this._mappings.unsortedForEach(function(p){if(p.source===u&&p.originalLine!=null){var h=i.originalPositionFor({line:p.originalLine,column:p.originalColumn});h.source!=null&&(p.source=h.source,c!=null&&(p.source=e.join(c,p.source)),d!=null&&(p.source=e.relative(d,p.source)),p.originalLine=h.line,p.originalColumn=h.column,h.name!=null&&(p.name=h.name))}var g=p.source;g!=null&&!f.has(g)&&f.add(g);var x=p.name;x!=null&&!m.has(x)&&m.add(x)},this),this._sources=f,this._names=m,i.sources.forEach(function(p){var h=i.sourceContentFor(p);h!=null&&(c!=null&&(p=e.join(c,p)),d!=null&&(p=e.relative(d,p)),this.setSourceContent(p,h))},this)},r.prototype._validateMapping=function(i,l,c,u){if(l&&typeof l.line!="number"&&typeof l.column!="number"){var d="original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.";if(this._ignoreInvalidMapping)return typeof console<"u"&&console.warn&&console.warn(d),!1;throw new Error(d)}if(!(i&&"line"in i&&"column"in i&&i.line>0&&i.column>=0&&!l&&!c&&!u)){if(i&&"line"in i&&"column"in i&&l&&"line"in l&&"column"in l&&i.line>0&&i.column>=0&&l.line>0&&l.column>=0&&c)return;var d="Invalid mapping: "+JSON.stringify({generated:i,source:c,original:l,name:u});if(this._ignoreInvalidMapping)return typeof console<"u"&&console.warn&&console.warn(d),!1;throw new Error(d)}},r.prototype._serializeMappings=function(){for(var i=0,l=1,c=0,u=0,d=0,f=0,m="",p,h,g,x,b=this._mappings.toArray(),y=0,v=b.length;y<v;y++){if(h=b[y],p="",h.generatedLine!==l)for(i=0;h.generatedLine!==l;)p+=";",l++;else if(y>0){if(!e.compareByGeneratedPositionsInflated(h,b[y-1]))continue;p+=","}p+=n.encode(h.generatedColumn-i),i=h.generatedColumn,h.source!=null&&(x=this._sources.indexOf(h.source),p+=n.encode(x-f),f=x,p+=n.encode(h.originalLine-1-u),u=h.originalLine-1,p+=n.encode(h.originalColumn-c),c=h.originalColumn,h.name!=null&&(g=this._names.indexOf(h.name),p+=n.encode(g-d),d=g)),m+=p}return m},r.prototype._generateSourcesContent=function(i,l){return i.map(function(c){if(!this._sourcesContents)return null;l!=null&&(c=e.relative(l,c));var u=e.toSetString(c);return Object.prototype.hasOwnProperty.call(this._sourcesContents,u)?this._sourcesContents[u]:null},this)},r.prototype.toJSON=function(){var i={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return this._file!=null&&(i.file=this._file),this._sourceRoot!=null&&(i.sourceRoot=this._sourceRoot),this._sourcesContents&&(i.sourcesContent=this._generateSourcesContent(i.sources,i.sourceRoot)),i},r.prototype.toString=function(){return JSON.stringify(this.toJSON())},Bp.SourceMapGenerator=r,Bp}var hne=pne();const wS=new Set(["Atrule","Selector","Declaration"]);function gne(n){const e=new hne.SourceMapGenerator,t={line:1,column:0},s={line:0,column:0},r={line:1,column:0},o={generated:r};let i=1,l=0,c=!1;const u=n.node;n.node=function(m){if(m.loc&&m.loc.start&&wS.has(m.type)){const p=m.loc.start.line,h=m.loc.start.column-1;(s.line!==p||s.column!==h)&&(s.line=p,s.column=h,t.line=i,t.column=l,c&&(c=!1,(t.line!==r.line||t.column!==r.column)&&e.addMapping(o)),c=!0,e.addMapping({source:m.loc.source,original:s,generated:t}))}u.call(this,m),c&&wS.has(m.type)&&(r.line=i,r.column=l)};const d=n.emit;n.emit=function(m,p,h){for(let g=0;g<m.length;g++)m.charCodeAt(g)===10?(i++,l=0):l++;d(m,p,h)};const f=n.result;return n.result=function(){return c&&e.addMapping(o),{css:f(),map:e}},n}const xne=43,bne=45,Hp=(n,e)=>(n===lt&&(n=e),typeof n=="string"&&(n=Math.min(n.charCodeAt(0),128)<<6),n<<1),rE=[[Ae,Ae],[Ae,st],[Ae,wn],[Ae,Un],[Ae,"-"],[Ae,tt],[Ae,Rt],[Ae,at],[Ae,Kn],[Ae,ft],[Kt,Ae],[Kt,st],[Kt,wn],[Kt,Un],[Kt,"-"],[Kt,tt],[Kt,Rt],[Kt,at],[Kt,Kn],[jt,Ae],[jt,st],[jt,wn],[jt,Un],[jt,"-"],[jt,tt],[jt,Rt],[jt,at],[jt,Kn],[at,Ae],[at,st],[at,wn],[at,Un],[at,"-"],[at,tt],[at,Rt],[at,at],[at,Kn],["#",Ae],["#",st],["#",wn],["#",Un],["#","-"],["#",tt],["#",Rt],["#",at],["#",Kn],["-",Ae],["-",st],["-",wn],["-",Un],["-","-"],["-",tt],["-",Rt],["-",at],["-",Kn],[tt,Ae],[tt,st],[tt,wn],[tt,Un],[tt,tt],[tt,Rt],[tt,at],[tt,"%"],[tt,Kn],["@",Ae],["@",st],["@",wn],["@",Un],["@","-"],["@",Kn],[".",tt],[".",Rt],[".",at],["+",tt],["+",Rt],["+",at],["/","*"]],vne=rE.concat([[Ae,jt],[at,jt],[jt,jt],[Kt,ft],[Kt,cs],[Kt,Ln],[Rt,Rt],[Rt,at],[Rt,st],[Rt,"-"],[Je,Ae],[Je,st],[Je,Rt],[Je,at],[Je,jt],[Je,"-"]]);function oE(n){const e=new Set(n.map(([t,s])=>Hp(t)<<16|Hp(s)));return function(t,s,r){const o=Hp(s,r),i=r.charCodeAt(0),l=i===bne&&s!==Ae&&s!==st&&s!==Kn||i===xne?e.has((t&65534)<<16|i<<7):e.has((t&65534)<<16|o);return o|l}}const yne=oE(rE),iE=oE(vne),SS=Object.freeze(Object.defineProperty({__proto__:null,safe:iE,spec:yne},Symbol.toStringTag,{value:"Module"})),wne=92;function Sne(n,e){if(typeof e=="function"){let t=null;n.children.forEach(s=>{t!==null&&e.call(this,t),this.node(s),t=s});return}n.children.forEach(this.node,this)}function kne(n){const e=new Map;for(let[t,s]of Object.entries(n.node))typeof(s.generate||s)=="function"&&e.set(t,s.generate||s);return function(t,s){let r="",o=0,i={node(c){if(e.has(c.type))e.get(c.type).call(l,c);else throw new Error("Unknown node type: "+c.type)},tokenBefore:iE,token(c,u,d){o=this.tokenBefore(o,c,u),!d&&o&1&&this.emit(" ",Tt,!0),this.emit(u,c,!1),c===lt&&u.charCodeAt(0)===wne&&this.emit(`
|
|
182
|
+
`,Tt,!0)},emit(c){r+=c},result(){return r}};s&&(typeof s.decorator=="function"&&(i=s.decorator(i)),s.sourceMap&&(i=gne(i)),s.mode in SS&&(i.tokenBefore=SS[s.mode]));const l={node:c=>i.node(c),children:Sne,token:(c,u)=>i.token(c,u),tokenize:c=>$f(c,(u,d,f)=>{i.token(u,c.slice(d,f),d!==0)})};return i.node(t),i.result()}}function jne(n){return{fromPlainObject(e){return n(e,{enter(t){t.children&&!(t.children instanceof ln)&&(t.children=new ln().fromArray(t.children))}}),e},toPlainObject(e){return n(e,{leave(t){t.children&&t.children instanceof ln&&(t.children=t.children.toArray())}}),e}}}const{hasOwnProperty:m0}=Object.prototype,Ma=function(){};function kS(n){return typeof n=="function"?n:Ma}function jS(n,e){return function(t,s,r){t.type===e&&n.call(this,t,s,r)}}function Nne(n,e){const t=e.structure,s=[];for(const r in t){if(m0.call(t,r)===!1)continue;let o=t[r];const i={name:r,type:!1,nullable:!1};Array.isArray(o)||(o=[o]);for(const l of o)l===null?i.nullable=!0:typeof l=="string"?i.type="node":Array.isArray(l)&&(i.type="list");i.type&&s.push(i)}return s.length?{context:e.walkContext,fields:s}:null}function Cne(n){const e={};for(const t in n.node)if(m0.call(n.node,t)){const s=n.node[t];if(!s.structure)throw new Error("Missed `structure` field in `"+t+"` node type definition");e[t]=Nne(t,s)}return e}function NS(n,e){const t=n.fields.slice(),s=n.context,r=typeof s=="string";return e&&t.reverse(),function(o,i,l,c){let u;r&&(u=i[s],i[s]=o);for(const d of t){const f=o[d.name];if(!d.nullable||f){if(d.type==="list"){if(e?f.reduceRight(c,!1):f.reduce(c,!1))return!0}else if(l(f))return!0}}r&&(i[s]=u)}}function CS({StyleSheet:n,Atrule:e,Rule:t,Block:s,DeclarationList:r}){return{Atrule:{StyleSheet:n,Atrule:e,Rule:t,Block:s},Rule:{StyleSheet:n,Atrule:e,Rule:t,Block:s},Declaration:{StyleSheet:n,Atrule:e,Rule:t,Block:s,DeclarationList:r}}}function _ne(n){const e=Cne(n),t={},s={},r=Symbol("break-walk"),o=Symbol("skip-node");for(const u in e)m0.call(e,u)&&e[u]!==null&&(t[u]=NS(e[u],!1),s[u]=NS(e[u],!0));const i=CS(t),l=CS(s),c=function(u,d){function f(b,y,v){const k=m.call(x,b,y,v);return k===r?!0:k===o?!1:!!(h.hasOwnProperty(b.type)&&h[b.type](b,x,f,g)||p.call(x,b,y,v)===r)}let m=Ma,p=Ma,h=t,g=(b,y,v,k)=>b||f(y,v,k);const x={break:r,skip:o,root:u,stylesheet:null,atrule:null,atrulePrelude:null,rule:null,selector:null,block:null,declaration:null,function:null};if(typeof d=="function")m=d;else if(d&&(m=kS(d.enter),p=kS(d.leave),d.reverse&&(h=s),d.visit)){if(i.hasOwnProperty(d.visit))h=d.reverse?l[d.visit]:i[d.visit];else if(!e.hasOwnProperty(d.visit))throw new Error("Bad value `"+d.visit+"` for `visit` option (should be: "+Object.keys(e).sort().join(", ")+")");m=jS(m,d.visit),p=jS(p,d.visit)}if(m===Ma&&p===Ma)throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");f(u)};return c.break=r,c.skip=o,c.find=function(u,d){let f=null;return c(u,function(m,p,h){if(d.call(this,m,p,h))return f=m,r}),f},c.findLast=function(u,d){let f=null;return c(u,{reverse:!0,enter(m,p,h){if(d.call(this,m,p,h))return f=m,r}}),f},c.findAll=function(u,d){const f=[];return c(u,function(m,p,h){d.call(this,m,p,h)&&f.push(m)}),f},c}function Ene(n){return n}function Tne(n){const{min:e,max:t,comma:s}=n;return e===0&&t===0?s?"#?":"*":e===0&&t===1?"?":e===1&&t===0?s?"#":"+":e===1&&t===1?"":(s?"#":"")+(e===t?"{"+e+"}":"{"+e+","+(t!==0?t:"")+"}")}function Ane(n){switch(n.type){case"Range":return" ["+(n.min===null?"-∞":n.min)+","+(n.max===null?"∞":n.max)+"]";default:throw new Error("Unknown node type `"+n.type+"`")}}function Pne(n,e,t,s){const r=n.combinator===" "||s?n.combinator:" "+n.combinator+" ",o=n.terms.map(i=>jd(i,e,t,s)).join(r);return n.explicit||t?(s||o[0]===","?"[":"[ ")+o+(s?"]":" ]"):o}function jd(n,e,t,s){let r;switch(n.type){case"Group":r=Pne(n,e,t,s)+(n.disallowEmpty?"!":"");break;case"Multiplier":return jd(n.term,e,t,s)+e(Tne(n),n);case"Boolean":r="<boolean-expr["+jd(n.term,e,t,s)+"]>";break;case"Type":r="<"+n.name+(n.opts?e(Ane(n.opts),n.opts):"")+">";break;case"Property":r="<'"+n.name+"'>";break;case"Keyword":r=n.name;break;case"AtKeyword":r="@"+n.name;break;case"Function":r=n.name+"(";break;case"String":case"Token":r=n.value;break;case"Comma":r=",";break;default:throw new Error("Unknown node type `"+n.type+"`")}return e(r,n)}function p0(n,e){let t=Ene,s=!1,r=!1;return typeof e=="function"?t=e:e&&(s=!!e.forceBraces,r=!!e.compact,typeof e.decorate=="function"&&(t=e.decorate)),jd(n,t,s,r)}const _S={offset:0,line:1,column:1};function Ine(n,e){const t=n.tokens,s=n.longestMatch,r=s<t.length&&t[s].node||null,o=r!==e?r:null;let i=0,l=0,c=0,u="",d,f;for(let m=0;m<t.length;m++){const p=t[m].value;m===s&&(l=p.length,i=u.length),o!==null&&t[m].node===o&&(m<=s?c++:c=0),u+=p}return s===t.length||c>1?(d=iu(o||e,"end")||za(_S,u),f=za(d)):(d=iu(o,"start")||za(iu(e,"start")||_S,u.slice(0,i)),f=iu(o,"end")||za(d,u.substr(i,l))),{css:u,mismatchOffset:i,mismatchLength:l,start:d,end:f}}function iu(n,e){const t=n&&n.loc&&n.loc[e];return t?"line"in t?za(t):t:null}function za({offset:n,line:e,column:t},s){const r={offset:n,line:e,column:t};if(s){const o=s.split(/\n|\r\n?|\f/);r.offset+=s.length,r.line+=o.length-1,r.column=o.length===1?r.column+s.length:o.pop().length+1}return r}const ja=function(n,e){const t=Rf("SyntaxReferenceError",n+(e?" `"+e+"`":""));return t.reference=e,t},$ne=function(n,e,t,s){const r=Rf("SyntaxMatchError",n),{css:o,mismatchOffset:i,mismatchLength:l,start:c,end:u}=Ine(s,t);return r.rawMessage=n,r.syntax=e?p0(e):"<generic>",r.css=o,r.mismatchOffset=i,r.mismatchLength=l,r.message=n+`
|
|
183
|
+
syntax: `+r.syntax+`
|
|
184
|
+
value: `+(o||"<empty string>")+`
|
|
185
|
+
--------`+new Array(r.mismatchOffset+1).join("-")+"^",Object.assign(r,c),r.loc={source:t&&t.loc&&t.loc.source||"<unknown>",start:c,end:u},r},au=new Map,ai=new Map,Nd=45,Kp=Rne,ES=One;function h0(n,e){return e=e||0,n.length-e>=2&&n.charCodeAt(e)===Nd&&n.charCodeAt(e+1)===Nd}function aE(n,e){if(e=e||0,n.length-e>=3&&n.charCodeAt(e)===Nd&&n.charCodeAt(e+1)!==Nd){const t=n.indexOf("-",e+2);if(t!==-1)return n.substring(e,t+1)}return""}function Rne(n){if(au.has(n))return au.get(n);const e=n.toLowerCase();let t=au.get(e);if(t===void 0){const s=h0(e,0),r=s?"":aE(e,0);t=Object.freeze({basename:e.substr(r.length),name:e,prefix:r,vendor:r,custom:s})}return au.set(n,t),t}function One(n){if(ai.has(n))return ai.get(n);let e=n,t=n[0];t==="/"?t=n[1]==="/"?"//":"/":t!=="_"&&t!=="*"&&t!=="$"&&t!=="#"&&t!=="+"&&t!=="&"&&(t="");const s=h0(e,t.length);if(!s&&(e=e.toLowerCase(),ai.has(e))){const l=ai.get(e);return ai.set(n,l),l}const r=s?"":aE(e,t.length),o=e.substr(0,t.length+r.length),i=Object.freeze({basename:e.substr(o.length),name:e.substr(t.length),hack:t,vendor:r,prefix:o,custom:s});return ai.set(n,i),i}const g0=["initial","inherit","unset","revert","revert-layer"],$l=43,Gs=45,Gp=110,li=!0,Lne=!1;function kg(n,e){return n!==null&&n.type===lt&&n.value.charCodeAt(0)===e}function sl(n,e,t){for(;n!==null&&(n.type===Tt||n.type===on);)n=t(++e);return e}function Hr(n,e,t,s){if(!n)return 0;const r=n.value.charCodeAt(e);if(r===$l||r===Gs){if(t)return 0;e++}for(;e<n.value.length;e++)if(!Sn(n.value.charCodeAt(e)))return 0;return s+1}function Zp(n,e,t){let s=!1,r=sl(n,e,t);if(n=t(r),n===null)return e;if(n.type!==tt)if(kg(n,$l)||kg(n,Gs)){if(s=!0,r=sl(t(++r),r,t),n=t(r),n===null||n.type!==tt)return 0}else return e;if(!s){const o=n.value.charCodeAt(0);if(o!==$l&&o!==Gs)return 0}return Hr(n,s?0:1,s,r)}function Mne(n,e){let t=0;if(!n)return 0;if(n.type===tt)return Hr(n,0,Lne,t);if(n.type===Ae&&n.value.charCodeAt(0)===Gs){if(!Ei(n.value,1,Gp))return 0;switch(n.value.length){case 2:return Zp(e(++t),t,e);case 3:return n.value.charCodeAt(2)!==Gs?0:(t=sl(e(++t),t,e),n=e(t),Hr(n,0,li,t));default:return n.value.charCodeAt(2)!==Gs?0:Hr(n,3,li,t)}}else if(n.type===Ae||kg(n,$l)&&e(t+1).type===Ae){if(n.type!==Ae&&(n=e(++t)),n===null||!Ei(n.value,0,Gp))return 0;switch(n.value.length){case 1:return Zp(e(++t),t,e);case 2:return n.value.charCodeAt(1)!==Gs?0:(t=sl(e(++t),t,e),n=e(t),Hr(n,0,li,t));default:return n.value.charCodeAt(1)!==Gs?0:Hr(n,2,li,t)}}else if(n.type===at){let s=n.value.charCodeAt(0),r=s===$l||s===Gs?1:0,o=r;for(;o<n.value.length&&Sn(n.value.charCodeAt(o));o++);return o===r||!Ei(n.value,o,Gp)?0:o+1===n.value.length?Zp(e(++t),t,e):n.value.charCodeAt(o+1)!==Gs?0:o+2===n.value.length?(t=sl(e(++t),t,e),n=e(t),Hr(n,0,li,t)):Hr(n,o+2,li,t)}return 0}const zne=43,lE=45,cE=63,Dne=117;function jg(n,e){return n!==null&&n.type===lt&&n.value.charCodeAt(0)===e}function Fne(n,e){return n.value.charCodeAt(0)===e}function Da(n,e,t){let s=0;for(let r=e;r<n.value.length;r++){const o=n.value.charCodeAt(r);if(o===lE&&t&&s!==0)return Da(n,e+s+1,!1),6;if(!xo(o)||++s>6)return 0}return s}function lu(n,e,t){if(!n)return 0;for(;jg(t(e),cE);){if(++n>6)return 0;e++}return e}function Une(n,e){let t=0;if(n===null||n.type!==Ae||!Ei(n.value,0,Dne)||(n=e(++t),n===null))return 0;if(jg(n,zne))return n=e(++t),n===null?0:n.type===Ae?lu(Da(n,0,!0),++t,e):jg(n,cE)?lu(1,++t,e):0;if(n.type===tt){const s=Da(n,1,!0);return s===0?0:(n=e(++t),n===null?t:n.type===at||n.type===tt?!Fne(n,lE)||!Da(n,1,!1)?0:t+1:lu(s,t,e))}return n.type===at?lu(Da(n,1,!0),++t,e):0}const x0=["calc(","-moz-calc(","-webkit-calc("],b0=["min(","max(","clamp("],v0=["round(","mod(","rem("],Bne=["sin(","cos(","tan("],Wne=["asin(","acos(","atan(","atan2("],qne=["pow(","sqrt(","log(","exp(","sign("],y0=["hypot("],w0=["abs("],TS=[...x0,...b0,...v0,...Bne,...qne,...y0,...w0],Vne=[...x0,...b0,...v0,...y0,...w0],yr=[...x0,...b0,...v0,...Wne,...y0,...w0],S0=new Map([[st,Je],[ft,Je],[es,Xn],[an,qn]]);function zs(n,e){return e<n.length?n.charCodeAt(e):0}function uE(n,e){return Il(n,0,n.length,e)}function dE(n,e){for(let t=0;t<e.length;t++)if(uE(n,e[t]))return!0;return!1}function fE(n,e){return e!==n.length-2?!1:zs(n,e)===92&&Sn(zs(n,e+1))}function Of(n,e,t){if(n&&n.type==="Range"){const s=Number(t!==void 0&&t!==e.length?e.substr(0,t):e);if(isNaN(s)||n.min!==null&&s<n.min&&typeof n.min!="string"||n.max!==null&&s>n.max&&typeof n.max!="string")return!0}return!1}function Hne(n,e){let t=0,s=[],r=0;e:do{switch(n.type){case qn:case Je:case Xn:if(n.type!==t)break e;if(t=s.pop(),s.length===0){r++;break e}break;case st:case ft:case es:case an:s.push(t),t=S0.get(n.type);break}r++}while(n=e(r));return r}function ds(n,e){return function(t,s,r){return t===null?0:t.type===st&&dE(t.value,e)?Hne(t,s):n(t,s,r)}}function St(n){return function(e){return e===null||e.type!==n?0:1}}function Kne(n){if(n===null||n.type!==Ae)return 0;const e=n.value.toLowerCase();return dE(e,g0)||uE(e,"default")?0:1}function mE(n){return n===null||n.type!==Ae||zs(n.value,0)!==45||zs(n.value,1)!==45?0:1}function Gne(n){return!mE(n)||n.value==="--"?0:1}function Zne(n){if(n===null||n.type!==jt)return 0;const e=n.value.length;if(e!==4&&e!==5&&e!==7&&e!==9)return 0;for(let t=1;t<e;t++)if(!xo(zs(n.value,t)))return 0;return 1}function Yne(n){return n===null||n.type!==jt||!Ou(zs(n.value,1),zs(n.value,2),zs(n.value,3))?0:1}function Xne(n,e){if(!n)return 0;let t=0,s=[],r=0;e:do{switch(n.type){case hc:case Un:break e;case qn:case Je:case Xn:if(n.type!==t)break e;t=s.pop();break;case Mn:if(t===0)break e;break;case lt:if(t===0&&n.value==="!")break e;break;case st:case ft:case es:case an:s.push(t),t=S0.get(n.type);break}r++}while(n=e(r));return r}function Jne(n,e){if(!n)return 0;let t=0,s=[],r=0;e:do{switch(n.type){case hc:case Un:break e;case qn:case Je:case Xn:if(n.type!==t)break e;t=s.pop();break;case st:case ft:case es:case an:s.push(t),t=S0.get(n.type);break}r++}while(n=e(r));return r}function wr(n){return n&&(n=new Set(n)),function(e,t,s){if(e===null||e.type!==at)return 0;const r=Pf(e.value,0);if(n!==null){const o=e.value.indexOf("\\",r),i=o===-1||!fE(e.value,o)?e.value.substr(r):e.value.substring(r,o);if(n.has(i.toLowerCase())===!1)return 0}return Of(s,e.value,r)?0:1}}function Qne(n,e,t){return n===null||n.type!==Rt||Of(t,n.value,n.value.length-1)?0:1}function pE(n){return typeof n!="function"&&(n=function(){return 0}),function(e,t,s){return e!==null&&e.type===tt&&Number(e.value)===0?1:n(e,t,s)}}function ese(n,e,t){if(n===null)return 0;const s=Pf(n.value,0);return!(s===n.value.length)&&!fE(n.value,s)||Of(t,n.value,s)?0:1}function tse(n,e,t){if(n===null||n.type!==tt)return 0;let s=zs(n.value,0)===43||zs(n.value,0)===45?1:0;for(;s<n.value.length;s++)if(!Sn(zs(n.value,s)))return 0;return Of(t,n.value,s)?0:1}const nse={"ident-token":St(Ae),"function-token":St(st),"at-keyword-token":St(Kt),"hash-token":St(jt),"string-token":St(cs),"bad-string-token":St(hc),"url-token":St(wn),"bad-url-token":St(Un),"delim-token":St(lt),"number-token":St(tt),"percentage-token":St(Rt),"dimension-token":St(at),"whitespace-token":St(Tt),"CDO-token":St(gc),"CDC-token":St(Kn),"colon-token":St(Ln),"semicolon-token":St(Mn),"comma-token":St(Qn),"[-token":St(es),"]-token":St(Xn),"(-token":St(ft),")-token":St(Je),"{-token":St(an),"}-token":St(qn)},sse={string:St(cs),ident:St(Ae),percentage:ds(Qne,Vne),zero:pE(),number:ds(ese,TS),integer:ds(tse,TS),"custom-ident":Kne,"dashed-ident":mE,"custom-property-name":Gne,"hex-color":Zne,"id-selector":Yne,"an-plus-b":Mne,urange:Une,"declaration-value":Xne,"any-value":Jne},rse=["length","angle","time","frequency","resolution","flex","decibel","semitones"];function ose(n){const{angle:e,decibel:t,frequency:s,flex:r,length:o,resolution:i,semitones:l,time:c}=n||{};return{dimension:ds(wr(null),yr),angle:ds(wr(e),yr),decibel:ds(wr(t),yr),frequency:ds(wr(s),yr),flex:ds(wr(r),yr),length:ds(pE(wr(o)),yr),resolution:ds(wr(i),yr),semitones:ds(wr(l),yr),time:ds(wr(c),yr)}}function ise(n){const e=new Set;for(const t of rse)if(Array.isArray(n[t]))for(const s of n[t])e.add(s.toLowerCase());return function(s){return s===null?0:s.type===lt&&s.value==="%"||s.type===Ae&&e.has(s.value.toLowerCase())?1:0}}function ase(n){return{...nse,...sse,...ose(n),"attr-unit":ise(n)}}const lse=["cm","mm","q","in","pt","pc","px","em","rem","ex","rex","cap","rcap","ch","rch","ic","ric","lh","rlh","vw","svw","lvw","dvw","vh","svh","lvh","dvh","vi","svi","lvi","dvi","vb","svb","lvb","dvb","vmin","svmin","lvmin","dvmin","vmax","svmax","lvmax","dvmax","cqw","cqh","cqi","cqb","cqmin","cqmax"],cse=["deg","grad","rad","turn"],use=["s","ms"],dse=["hz","khz"],fse=["dpi","dpcm","dppx","x"],mse=["fr"],pse=["db"],hse=["st"],AS=Object.freeze(Object.defineProperty({__proto__:null,angle:cse,decibel:pse,flex:mse,frequency:dse,length:lse,resolution:fse,semitones:hse,time:use},Symbol.toStringTag,{value:"Module"}));function gse(n,e,t){return Object.assign(Rf("SyntaxError",n),{input:e,offset:t,rawMessage:n,message:n+`
|
|
186
|
+
`+e+`
|
|
187
|
+
--`+new Array((t||e.length)+1).join("-")+"^"})}const xse=9,bse=10,vse=12,yse=13,wse=32,PS=new Uint8Array(128).map((n,e)=>/[a-zA-Z0-9\-]/.test(String.fromCharCode(e))?1:0);class Sse{constructor(e){this.str=e,this.pos=0}charCodeAt(e){return e<this.str.length?this.str.charCodeAt(e):0}charCode(){return this.charCodeAt(this.pos)}isNameCharCode(e=this.charCode()){return e<128&&PS[e]===1}nextCharCode(){return this.charCodeAt(this.pos+1)}nextNonWsCode(e){return this.charCodeAt(this.findWsEnd(e))}skipWs(){this.pos=this.findWsEnd(this.pos)}findWsEnd(e){for(;e<this.str.length;e++){const t=this.str.charCodeAt(e);if(t!==yse&&t!==bse&&t!==vse&&t!==wse&&t!==xse)break}return e}substringToPos(e){return this.str.substring(this.pos,this.pos=e)}eat(e){this.charCode()!==e&&this.error("Expect `"+String.fromCharCode(e)+"`"),this.pos++}peek(){return this.pos<this.str.length?this.str.charAt(this.pos++):""}error(e){throw new gse(e,this.str,this.pos)}scanSpaces(){return this.substringToPos(this.findWsEnd(this.pos))}scanWord(){let e=this.pos;for(;e<this.str.length;e++){const t=this.str.charCodeAt(e);if(t>=128||PS[t]===0)break}return this.pos===e&&this.error("Expect a keyword"),this.substringToPos(e)}scanNumber(){let e=this.pos;for(;e<this.str.length;e++){const t=this.str.charCodeAt(e);if(t<48||t>57)break}return this.pos===e&&this.error("Expect a number"),this.substringToPos(e)}scanString(){const e=this.str.indexOf("'",this.pos+1);return e===-1&&(this.pos=this.str.length,this.error("Expect an apostrophe")),this.substringToPos(e+1)}}const kse=9,jse=10,Nse=12,Cse=13,_se=32,hE=33,k0=35,IS=38,Cd=39,gE=40,xE=41,bE=42,j0=43,N0=44,$S=45,C0=60,Ng=62,_d=63,Ese=64,Rl=91,Vi=93,Ed=123,RS=124,Cg=125,OS=8734,LS={" ":1,"&&":2,"||":3,"|":4};function MS(n){let e=null,t=null;return n.eat(Ed),n.skipWs(),e=n.scanNumber(n),n.skipWs(),n.charCode()===N0?(n.pos++,n.skipWs(),n.charCode()!==Cg&&(t=n.scanNumber(n),n.skipWs())):t=e,n.eat(Cg),{min:Number(e),max:t?Number(t):0}}function Tse(n){let e=null,t=!1;switch(n.charCode()){case bE:n.pos++,e={min:0,max:0};break;case j0:n.pos++,e={min:1,max:0};break;case _d:n.pos++,e={min:0,max:1};break;case k0:n.pos++,t=!0,n.charCode()===Ed?e=MS(n):n.charCode()===_d?(n.pos++,e={min:0,max:0}):e={min:1,max:0};break;case Ed:e=MS(n);break;default:return null}return{type:"Multiplier",comma:t,min:e.min,max:e.max,term:null}}function Or(n,e){const t=Tse(n);return t!==null?(t.term=e,n.charCode()===k0&&n.charCodeAt(n.pos-1)===j0||n.charCode()===_d&&n.charCodeAt(n.pos-1)===Cg?Or(n,t):t):e}function Yp(n){const e=n.peek();return e===""?null:Or(n,{type:"Token",value:e})}function Ase(n){let e;return n.eat(C0),n.eat(Cd),e=n.scanWord(),n.eat(Cd),n.eat(Ng),Or(n,{type:"Property",name:e})}function Pse(n){let e=null,t=null,s=1;return n.eat(Rl),n.charCode()===$S&&(n.peek(),s=-1),s==-1&&n.charCode()===OS?n.peek():(e=s*Number(n.scanNumber(n)),n.isNameCharCode()&&(e+=n.scanWord())),n.skipWs(),n.eat(N0),n.skipWs(),n.charCode()===OS?n.peek():(s=1,n.charCode()===$S&&(n.peek(),s=-1),t=s*Number(n.scanNumber(n)),n.isNameCharCode()&&(t+=n.scanWord())),n.eat(Vi),{type:"Range",min:e,max:t}}function Ise(n){let e,t=null;if(n.eat(C0),e=n.scanWord(),e==="boolean-expr"){n.eat(Rl);const s=Lf(n,Vi);return n.eat(Vi),n.eat(Ng),Or(n,{type:"Boolean",term:s.terms.length===1?s.terms[0]:s})}return n.charCode()===gE&&n.nextCharCode()===xE&&(n.pos+=2,e+="()"),n.charCodeAt(n.findWsEnd(n.pos))===Rl&&(n.skipWs(),t=Pse(n)),n.eat(Ng),Or(n,{type:"Type",name:e,opts:t})}function $se(n){const e=n.scanWord();return n.charCode()===gE?(n.pos++,{type:"Function",name:e}):Or(n,{type:"Keyword",name:e})}function Rse(n,e){function t(r,o){return{type:"Group",terms:r,combinator:o,disallowEmpty:!1,explicit:!1}}let s;for(e=Object.keys(e).sort((r,o)=>LS[r]-LS[o]);e.length>0;){s=e.shift();let r=0,o=0;for(;r<n.length;r++){const i=n[r];i.type==="Combinator"&&(i.value===s?(o===-1&&(o=r-1),n.splice(r,1),r--):(o!==-1&&r-o>1&&(n.splice(o,r-o,t(n.slice(o,r),s)),r=o+1),o=-1))}o!==-1&&e.length&&n.splice(o,r-o,t(n.slice(o,r),s))}return s}function Lf(n,e=-1){const t=Object.create(null),s=[];let r=null,o=n.pos,i=!1;for(;n.charCode()!==e;){let l=i?Lf(n,xE):Lse(n);if(!l)break;if(l.type!=="Spaces"){if(i){if(l.terms.length===0){i=!1;continue}if(l.combinator===" "){for(;l.terms.length>1;)t[" "]=!0,s.push({type:"Combinator",value:" "},l.terms.shift());l=l.terms[0]}}l.type==="Combinator"?((r===null||r.type==="Combinator")&&(n.pos=o,n.error("Unexpected combinator")),t[l.value]=!0):r!==null&&r.type!=="Combinator"&&(t[" "]=!0,s.push({type:"Combinator",value:" "})),s.push(l),r=l,o=n.pos,i=l.type==="Function"}}return r!==null&&r.type==="Combinator"&&(n.pos-=o,n.error("Unexpected combinator")),{type:"Group",terms:s,combinator:Rse(s,t)||" ",disallowEmpty:!1,explicit:!1}}function Ose(n){let e;return n.eat(Rl),e=Lf(n,Vi),n.eat(Vi),e.explicit=!0,n.charCode()===hE&&(n.pos++,e.disallowEmpty=!0),e}function Lse(n){let e=n.charCode();switch(e){case Vi:break;case Rl:return Or(n,Ose(n));case C0:return n.nextCharCode()===Cd?Ase(n):Ise(n);case RS:return{type:"Combinator",value:n.substringToPos(n.pos+(n.nextCharCode()===RS?2:1))};case IS:return n.pos++,n.eat(IS),{type:"Combinator",value:"&&"};case N0:return n.pos++,{type:"Comma"};case Cd:return Or(n,{type:"String",value:n.scanString()});case _se:case kse:case jse:case Cse:case Nse:return{type:"Spaces",value:n.scanSpaces()};case Ese:return e=n.nextCharCode(),n.isNameCharCode(e)?(n.pos++,{type:"AtKeyword",name:n.scanWord()}):Yp(n);case bE:case j0:case _d:case k0:case hE:break;case Ed:if(e=n.nextCharCode(),e<48||e>57)return Yp(n);break;default:return n.isNameCharCode(e)?$se(n):Yp(n)}}function vE(n){const e=new Sse(n),t=Lf(e);return e.pos!==n.length&&e.error("Unexpected input"),t.terms.length===1&&t.terms[0].type==="Group"?t.terms[0]:t}const Fa=function(){};function zS(n){return typeof n=="function"?n:Fa}function Mse(n,e,t){function s(i){switch(r.call(t,i),i.type){case"Group":i.terms.forEach(s);break;case"Multiplier":case"Boolean":s(i.term);break;case"Type":case"Property":case"Keyword":case"AtKeyword":case"Function":case"String":case"Token":case"Comma":break;default:throw new Error("Unknown type: "+i.type)}o.call(t,i)}let r=Fa,o=Fa;if(typeof e=="function"?r=e:e&&(r=zS(e.enter),o=zS(e.leave)),r===Fa&&o===Fa)throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");s(n)}const zse={decorator(n){const e=[];let t=null;return{...n,node(s){const r=t;t=s,n.node.call(this,s),t=r},emit(s,r,o){e.push({type:r,value:s,node:o?null:t})},result(){return e}}}};function Dse(n){const e=[];return $f(n,(t,s,r)=>e.push({type:t,value:n.slice(s,r),node:null})),e}function Fse(n,e){return typeof n=="string"?Dse(n):e.generate(n,zse)}const ht={type:"Match"},yt={type:"Mismatch"},_0={type:"DisallowEmpty"},Use=40,Bse=41;function In(n,e,t){return e===ht&&t===yt||n===ht&&e===ht&&t===ht?n:(n.type==="If"&&n.else===yt&&e===ht&&(e=n.then,n=n.match),{type:"If",match:n,then:e,else:t})}function yE(n){return n.length>2&&n.charCodeAt(n.length-2)===Use&&n.charCodeAt(n.length-1)===Bse}function DS(n){return n.type==="Keyword"||n.type==="AtKeyword"||n.type==="Function"||n.type==="Type"&&yE(n.name)}function Br(n,e=" ",t=!1){return{type:"Group",terms:n,combinator:e,disallowEmpty:!1,explicit:t}}function rl(n,e,t=new Set){if(!t.has(n))switch(t.add(n),n.type){case"If":n.match=rl(n.match,e,t),n.then=rl(n.then,e,t),n.else=rl(n.else,e,t);break;case"Type":return e[n.name]||n}return n}function _g(n,e,t){switch(n){case" ":{let s=ht;for(let r=e.length-1;r>=0;r--){const o=e[r];s=In(o,s,yt)}return s}case"|":{let s=yt,r=null;for(let o=e.length-1;o>=0;o--){let i=e[o];if(DS(i)&&(r===null&&o>0&&DS(e[o-1])&&(r=Object.create(null),s=In({type:"Enum",map:r},ht,s)),r!==null)){const l=(yE(i.name)?i.name.slice(0,-1):i.name).toLowerCase();if(!(l in r)){r[l]=i;continue}}r=null,s=In(i,ht,s)}return s}case"&&":{if(e.length>5)return{type:"MatchOnce",terms:e,all:!0};let s=yt;for(let r=e.length-1;r>=0;r--){const o=e[r];let i;e.length>1?i=_g(n,e.filter(function(l){return l!==o}),!1):i=ht,s=In(o,i,s)}return s}case"||":{if(e.length>5)return{type:"MatchOnce",terms:e,all:!1};let s=t?ht:yt;for(let r=e.length-1;r>=0;r--){const o=e[r];let i;e.length>1?i=_g(n,e.filter(function(l){return l!==o}),!0):i=ht,s=In(o,i,s)}return s}}}function Wse(n){let e=ht,t=vi(n.term);if(n.max===0)t=In(t,_0,yt),e=In(t,null,yt),e.then=In(ht,ht,e),n.comma&&(e.then.else=In({type:"Comma",syntax:n},e,yt));else for(let s=n.min||1;s<=n.max;s++)n.comma&&e!==ht&&(e=In({type:"Comma",syntax:n},e,yt)),e=In(t,In(ht,ht,e),yt);if(n.min===0)e=In(ht,ht,e);else for(let s=0;s<n.min-1;s++)n.comma&&e!==ht&&(e=In({type:"Comma",syntax:n},e,yt)),e=In(t,e,yt);return e}function vi(n){if(typeof n=="function")return{type:"Generic",fn:n};switch(n.type){case"Group":{let e=_g(n.combinator,n.terms.map(vi),!1);return n.disallowEmpty&&(e=In(e,_0,yt)),e}case"Multiplier":return Wse(n);case"Boolean":{const e=vi(n.term),t=vi(Br([Br([{type:"Keyword",name:"not"},{type:"Type",name:"!boolean-group"}]),Br([{type:"Type",name:"!boolean-group"},Br([{type:"Multiplier",comma:!1,min:0,max:0,term:Br([{type:"Keyword",name:"and"},{type:"Type",name:"!boolean-group"}])},{type:"Multiplier",comma:!1,min:0,max:0,term:Br([{type:"Keyword",name:"or"},{type:"Type",name:"!boolean-group"}])}],"|")])],"|")),s=vi(Br([{type:"Type",name:"!term"},Br([{type:"Token",value:"("},{type:"Type",name:"!self"},{type:"Token",value:")"}]),{type:"Type",name:"general-enclosed"}],"|"));return rl(s,{"!term":e,"!self":t}),rl(t,{"!boolean-group":s}),t}case"Type":case"Property":return{type:n.type,name:n.name,syntax:n};case"Keyword":return{type:n.type,name:n.name.toLowerCase(),syntax:n};case"AtKeyword":return{type:n.type,name:"@"+n.name.toLowerCase(),syntax:n};case"Function":return{type:n.type,name:n.name.toLowerCase()+"(",syntax:n};case"String":return n.value.length===3?{type:"Token",value:n.value.charAt(1),syntax:n}:{type:n.type,value:n.value.substr(1,n.value.length-2).replace(/\\'/g,"'"),syntax:n};case"Token":return{type:n.type,value:n.value,syntax:n};case"Comma":return{type:n.type,syntax:n};default:throw new Error("Unknown node type:",n.type)}}function cu(n,e){return typeof n=="string"&&(n=vE(n)),{type:"MatchGraph",match:vi(n),syntax:e||null,source:n}}const{hasOwnProperty:FS}=Object.prototype,qse=0,Vse=1,Eg=2,wE=3,US="Match",Hse="Mismatch",Kse="Maximum iteration number exceeded (please fill an issue on https://github.com/csstree/csstree/issues)",BS=15e3;function Gse(n){let e=null,t=null,s=n;for(;s!==null;)t=s.prev,s.prev=e,e=s,s=t;return e}function Xp(n,e){if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++){const s=e.charCodeAt(t);let r=n.charCodeAt(t);if(r>=65&&r<=90&&(r=r|32),r!==s)return!1}return!0}function Zse(n){return n.type!==lt?!1:n.value!=="?"}function WS(n){return n===null?!0:n.type===Qn||n.type===st||n.type===ft||n.type===es||n.type===an||Zse(n)}function qS(n){return n===null?!0:n.type===Je||n.type===Xn||n.type===qn||n.type===lt&&n.value==="/"}function Yse(n,e,t){function s(){do y++,b=y<n.length?n[y]:null;while(b!==null&&(b.type===Tt||b.type===on))}function r(j){const _=y+j;return _<n.length?n[_]:null}function o(j,_){return{nextState:j,matchStack:k,syntaxStack:f,thenStack:m,tokenIndex:y,prev:_}}function i(j){m={nextState:j,matchStack:k,syntaxStack:f,prev:m}}function l(j){p=o(j,p)}function c(){k={type:Vse,syntax:e.syntax,token:b,prev:k},s(),h=null,y>v&&(v=y)}function u(){f={syntax:e.syntax,opts:e.syntax.opts||f!==null&&f.opts||null,prev:f},k={type:Eg,syntax:e.syntax,token:k.token,prev:k}}function d(){k.type===Eg?k=k.prev:k={type:wE,syntax:f.syntax,token:k.token,prev:k},f=f.prev}let f=null,m=null,p=null,h=null,g=0,x=null,b=null,y=-1,v=0,k={type:qse,syntax:null,token:null,prev:null};for(s();x===null&&++g<BS;)switch(e.type){case"Match":if(m===null){if(b!==null&&(y!==n.length-1||b.value!=="\\0"&&b.value!=="\\9")){e=yt;break}x=US;break}if(e=m.nextState,e===_0)if(m.matchStack===k){e=yt;break}else e=ht;for(;m.syntaxStack!==f;)d();m=m.prev;break;case"Mismatch":if(h!==null&&h!==!1)(p===null||y>p.tokenIndex)&&(p=h,h=!1);else if(p===null){x=Hse;break}e=p.nextState,m=p.thenStack,f=p.syntaxStack,k=p.matchStack,y=p.tokenIndex,b=y<n.length?n[y]:null,p=p.prev;break;case"MatchGraph":e=e.match;break;case"If":e.else!==yt&&l(e.else),e.then!==ht&&i(e.then),e=e.match;break;case"MatchOnce":e={type:"MatchOnceBuffer",syntax:e,index:0,mask:0};break;case"MatchOnceBuffer":{const N=e.syntax.terms;if(e.index===N.length){if(e.mask===0||e.syntax.all){e=yt;break}e=ht;break}if(e.mask===(1<<N.length)-1){e=ht;break}for(;e.index<N.length;e.index++){const S=1<<e.index;if((e.mask&S)===0){l(e),i({type:"AddMatchOnce",syntax:e.syntax,mask:e.mask|S}),e=N[e.index++];break}}break}case"AddMatchOnce":e={type:"MatchOnceBuffer",syntax:e.syntax,index:0,mask:e.mask};break;case"Enum":if(b!==null){let N=b.value.toLowerCase();if(N.indexOf("\\")!==-1&&(N=N.replace(/\\[09].*$/,"")),FS.call(e.map,N)){e=e.map[N];break}}e=yt;break;case"Generic":{const N=f!==null?f.opts:null,S=y+Math.floor(e.fn(b,r,N));if(!isNaN(S)&&S>y){for(;y<S;)c();e=ht}else e=yt;break}case"Type":case"Property":{const N=e.type==="Type"?"types":"properties",S=FS.call(t,N)?t[N][e.name]:null;if(!S||!S.match)throw new Error("Bad syntax reference: "+(e.type==="Type"?"<"+e.name+">":"<'"+e.name+"'>"));if(h!==!1&&b!==null&&e.type==="Type"&&(e.name==="custom-ident"&&b.type===Ae||e.name==="length"&&b.value==="0")){h===null&&(h=o(e,p)),e=yt;break}u(),e=S.matchRef||S.match;break}case"Keyword":{const N=e.name;if(b!==null){let S=b.value;if(S.indexOf("\\")!==-1&&(S=S.replace(/\\[09].*$/,"")),Xp(S,N)){c(),e=ht;break}}e=yt;break}case"AtKeyword":case"Function":if(b!==null&&Xp(b.value,e.name)){c(),e=ht;break}e=yt;break;case"Token":if(b!==null&&b.value===e.value){c(),e=ht;break}e=yt;break;case"Comma":b!==null&&b.type===Qn?WS(k.token)?e=yt:(c(),e=qS(b)?yt:ht):e=WS(k.token)||qS(b)?ht:yt;break;case"String":let j="",_=y;for(;_<n.length&&j.length<e.value.length;_++)j+=n[_].value;if(Xp(j,e.value)){for(;y<_;)c();e=ht}else e=yt;break;default:throw new Error("Unknown node type: "+e.type)}switch(x){case null:console.warn("[csstree-match] BREAK after "+BS+" iterations"),x=Kse,k=null;break;case US:for(;f!==null;)d();break;default:k=null}return{tokens:n,reason:x,iterations:g,match:k,longestMatch:v}}function VS(n,e,t){const s=Yse(n,e,t||{});if(s.match===null)return s;let r=s.match,o=s.match={syntax:e.syntax||null,match:[]};const i=[o];for(r=Gse(r).prev;r!==null;){switch(r.type){case Eg:o.match.push(o={syntax:r.syntax,match:[]}),i.push(o);break;case wE:i.pop(),o=i[i.length-1];break;default:o.match.push({syntax:r.syntax||null,token:r.token.value,node:r.token.node})}r=r.prev}return s}function SE(n){function e(r){return r===null?!1:r.type==="Type"||r.type==="Property"||r.type==="Keyword"}function t(r){if(Array.isArray(r.match)){for(let o=0;o<r.match.length;o++)if(t(r.match[o]))return e(r.syntax)&&s.unshift(r.syntax),!0}else if(r.node===n)return s=e(r.syntax)?[r.syntax]:[],!0;return!1}let s=null;return this.matched!==null&&t(this.matched),s}function Xse(n,e){return E0(this,n,t=>t.type==="Type"&&t.name===e)}function Jse(n,e){return E0(this,n,t=>t.type==="Property"&&t.name===e)}function Qse(n){return E0(this,n,e=>e.type==="Keyword")}function E0(n,e,t){const s=SE.call(n,e);return s===null?!1:s.some(t)}const ere=Object.freeze(Object.defineProperty({__proto__:null,getTrace:SE,isKeyword:Qse,isProperty:Jse,isType:Xse},Symbol.toStringTag,{value:"Module"}));function kE(n){return"node"in n?n.node:kE(n.match[0])}function jE(n){return"node"in n?n.node:jE(n.match[n.match.length-1])}function HS(n,e,t,s,r){function o(l){if(l.syntax!==null&&l.syntax.type===s&&l.syntax.name===r){const c=kE(l),u=jE(l);n.syntax.walk(e,function(d,f,m){if(d===c){const p=new ln;do{if(p.appendData(f.data),f.data===u)break;f=f.next}while(f!==null);i.push({parent:m,nodes:p})}})}Array.isArray(l.match)&&l.match.forEach(o)}const i=[];return t.matched!==null&&o(t.matched),i}const{hasOwnProperty:ol}=Object.prototype;function Jp(n){return typeof n=="number"&&isFinite(n)&&Math.floor(n)===n&&n>=0}function KS(n){return!!n&&Jp(n.offset)&&Jp(n.line)&&Jp(n.column)}function tre(n,e){return function(s,r){if(!s||s.constructor!==Object)return r(s,"Type of node should be an Object");for(let o in s){let i=!0;if(ol.call(s,o)!==!1){if(o==="type")s.type!==n&&r(s,"Wrong node type `"+s.type+"`, expected `"+n+"`");else if(o==="loc"){if(s.loc===null)continue;if(s.loc&&s.loc.constructor===Object)if(typeof s.loc.source!="string")o+=".source";else if(!KS(s.loc.start))o+=".start";else if(!KS(s.loc.end))o+=".end";else continue;i=!1}else if(e.hasOwnProperty(o)){i=!1;for(let l=0;!i&&l<e[o].length;l++){const c=e[o][l];switch(c){case String:i=typeof s[o]=="string";break;case Boolean:i=typeof s[o]=="boolean";break;case null:i=s[o]===null;break;default:typeof c=="string"?i=s[o]&&s[o].type===c:Array.isArray(c)&&(i=s[o]instanceof ln)}}}else r(s,"Unknown field `"+o+"` for "+n+" node type");i||r(s,"Bad value for `"+n+"."+o+"`")}}for(const o in e)ol.call(e,o)&&ol.call(s,o)===!1&&r(s,"Field `"+n+"."+o+"` is missed")}}function NE(n,e){const t=[];for(let s=0;s<n.length;s++){const r=n[s];if(r===String||r===Boolean)t.push(r.name.toLowerCase());else if(r===null)t.push("null");else if(typeof r=="string")t.push(r);else if(Array.isArray(r))t.push("List<"+(NE(r,e)||"any")+">");else throw new Error("Wrong value `"+r+"` in `"+e+"` structure definition")}return t.join(" | ")}function nre(n,e){const t=e.structure,s={type:String,loc:!0},r={type:'"'+n+'"'};for(const o in t){if(ol.call(t,o)===!1)continue;const i=s[o]=Array.isArray(t[o])?t[o].slice():[t[o]];r[o]=NE(i,n+"."+o)}return{docs:r,check:tre(n,s)}}function sre(n){const e={};if(n.node){for(const t in n.node)if(ol.call(n.node,t)){const s=n.node[t];if(s.structure)e[t]=nre(t,s);else throw new Error("Missed `structure` field in `"+t+"` node type definition")}}return e}function Tg(n,e,t){const s={};for(const r in n)n[r].syntax&&(s[r]=t?n[r].syntax:p0(n[r].syntax,{compact:e}));return s}function rre(n,e,t){const s={};for(const[r,o]of Object.entries(n))s[r]={prelude:o.prelude&&(t?o.prelude.syntax:p0(o.prelude.syntax,{compact:e})),descriptors:o.descriptors&&Tg(o.descriptors,e,t)};return s}function ore(n){for(let e=0;e<n.length;e++)if(n[e].value.toLowerCase()==="var(")return!0;return!1}function ire(n){const e=n.terms[0];return n.explicit===!1&&n.terms.length===1&&e.type==="Multiplier"&&e.comma===!0}function Es(n,e,t){return{matched:n,iterations:t,error:e,...ere}}function ci(n,e,t,s){const r=Fse(t,n.syntax);let o;return ore(r)?Es(null,new Error("Matching for a tree with var() is not supported")):(s&&(o=VS(r,n.cssWideKeywordsSyntax,n)),(!s||!o.match)&&(o=VS(r,e.match,n),!o.match)?Es(null,new $ne(o.reason,e.syntax,t,o),o.iterations):Es(o.match,null,o.iterations))}class GS{constructor(e,t,s){if(this.cssWideKeywords=g0,this.syntax=t,this.generic=!1,this.units={...AS},this.atrules=Object.create(null),this.properties=Object.create(null),this.types=Object.create(null),this.structure=s||sre(e),e){if(e.cssWideKeywords&&(this.cssWideKeywords=e.cssWideKeywords),e.units)for(const r of Object.keys(AS))Array.isArray(e.units[r])&&(this.units[r]=e.units[r]);if(e.types)for(const[r,o]of Object.entries(e.types))this.addType_(r,o);if(e.generic){this.generic=!0;for(const[r,o]of Object.entries(ase(this.units)))this.addType_(r,o)}if(e.atrules)for(const[r,o]of Object.entries(e.atrules))this.addAtrule_(r,o);if(e.properties)for(const[r,o]of Object.entries(e.properties))this.addProperty_(r,o)}this.cssWideKeywordsSyntax=cu(this.cssWideKeywords.join(" | "))}checkStructure(e){function t(o,i){r.push({node:o,message:i})}const s=this.structure,r=[];return this.syntax.walk(e,function(o){s.hasOwnProperty(o.type)?s[o.type].check(o,t):t(o,"Unknown node type `"+o.type+"`")}),r.length?r:!1}createDescriptor(e,t,s,r=null){const o={type:t,name:s},i={type:t,name:s,parent:r,serializable:typeof e=="string"||e&&typeof e.type=="string",syntax:null,match:null,matchRef:null};return typeof e=="function"?i.match=cu(e,o):(typeof e=="string"?Object.defineProperty(i,"syntax",{get(){return Object.defineProperty(i,"syntax",{value:vE(e)}),i.syntax}}):i.syntax=e,Object.defineProperty(i,"match",{get(){return Object.defineProperty(i,"match",{value:cu(i.syntax,o)}),i.match}}),t==="Property"&&Object.defineProperty(i,"matchRef",{get(){const l=i.syntax,c=ire(l)?cu({...l,terms:[l.terms[0].term]},o):null;return Object.defineProperty(i,"matchRef",{value:c}),c}})),i}addAtrule_(e,t){t&&(this.atrules[e]={type:"Atrule",name:e,prelude:t.prelude?this.createDescriptor(t.prelude,"AtrulePrelude",e):null,descriptors:t.descriptors?Object.keys(t.descriptors).reduce((s,r)=>(s[r]=this.createDescriptor(t.descriptors[r],"AtruleDescriptor",r,e),s),Object.create(null)):null})}addProperty_(e,t){t&&(this.properties[e]=this.createDescriptor(t,"Property",e))}addType_(e,t){t&&(this.types[e]=this.createDescriptor(t,"Type",e))}checkAtruleName(e){if(!this.getAtrule(e))return new ja("Unknown at-rule","@"+e)}checkAtrulePrelude(e,t){const s=this.checkAtruleName(e);if(s)return s;const r=this.getAtrule(e);if(!r.prelude&&t)return new SyntaxError("At-rule `@"+e+"` should not contain a prelude");if(r.prelude&&!t&&!ci(this,r.prelude,"",!1).matched)return new SyntaxError("At-rule `@"+e+"` should contain a prelude")}checkAtruleDescriptorName(e,t){const s=this.checkAtruleName(e);if(s)return s;const r=this.getAtrule(e),o=Kp(t);if(!r.descriptors)return new SyntaxError("At-rule `@"+e+"` has no known descriptors");if(!r.descriptors[o.name]&&!r.descriptors[o.basename])return new ja("Unknown at-rule descriptor",t)}checkPropertyName(e){if(!this.getProperty(e))return new ja("Unknown property",e)}matchAtrulePrelude(e,t){const s=this.checkAtrulePrelude(e,t);if(s)return Es(null,s);const r=this.getAtrule(e);return r.prelude?ci(this,r.prelude,t||"",!1):Es(null,null)}matchAtruleDescriptor(e,t,s){const r=this.checkAtruleDescriptorName(e,t);if(r)return Es(null,r);const o=this.getAtrule(e),i=Kp(t);return ci(this,o.descriptors[i.name]||o.descriptors[i.basename],s,!1)}matchDeclaration(e){return e.type!=="Declaration"?Es(null,new Error("Not a Declaration node")):this.matchProperty(e.property,e.value)}matchProperty(e,t){if(ES(e).custom)return Es(null,new Error("Lexer matching doesn't applicable for custom properties"));const s=this.checkPropertyName(e);return s?Es(null,s):ci(this,this.getProperty(e),t,!0)}matchType(e,t){const s=this.getType(e);return s?ci(this,s,t,!1):Es(null,new ja("Unknown type",e))}match(e,t){return typeof e!="string"&&(!e||!e.type)?Es(null,new ja("Bad syntax")):((typeof e=="string"||!e.match)&&(e=this.createDescriptor(e,"Type","anonymous")),ci(this,e,t,!1))}findValueFragments(e,t,s,r){return HS(this,t,this.matchProperty(e,t),s,r)}findDeclarationValueFragments(e,t,s){return HS(this,e.value,this.matchDeclaration(e),t,s)}findAllFragments(e,t,s){const r=[];return this.syntax.walk(e,{visit:"Declaration",enter:o=>{r.push.apply(r,this.findDeclarationValueFragments(o,t,s))}}),r}getAtrule(e,t=!0){const s=Kp(e);return(s.vendor&&t?this.atrules[s.name]||this.atrules[s.basename]:this.atrules[s.name])||null}getAtrulePrelude(e,t=!0){const s=this.getAtrule(e,t);return s&&s.prelude||null}getAtruleDescriptor(e,t){return this.atrules.hasOwnProperty(e)&&this.atrules.declarators&&this.atrules[e].declarators[t]||null}getProperty(e,t=!0){const s=ES(e);return(s.vendor&&t?this.properties[s.name]||this.properties[s.basename]:this.properties[s.name])||null}getType(e){return hasOwnProperty.call(this.types,e)?this.types[e]:null}validate(){function e(c,u){return u?`<${c}>`:`<'${c}'>`}function t(c,u,d,f){if(d.has(u))return d.get(u);d.set(u,!1),f.syntax!==null&&Mse(f.syntax,function(m){if(m.type!=="Type"&&m.type!=="Property")return;const p=m.type==="Type"?c.types:c.properties,h=m.type==="Type"?r:o;hasOwnProperty.call(p,m.name)?t(c,m.name,h,p[m.name])&&(s.push(`${e(u,d===r)} used broken syntax definition ${e(m.name,m.type==="Type")}`),d.set(u,!0)):(s.push(`${e(u,d===r)} used missed syntax definition ${e(m.name,m.type==="Type")}`),d.set(u,!0))},this)}const s=[];let r=new Map,o=new Map;for(const c in this.types)t(this,c,r,this.types[c]);for(const c in this.properties)t(this,c,o,this.properties[c]);const i=[...r.keys()].filter(c=>r.get(c)),l=[...o.keys()].filter(c=>o.get(c));return i.length||l.length?{errors:s,types:i,properties:l}:null}dump(e,t){return{generic:this.generic,cssWideKeywords:this.cssWideKeywords,units:this.units,types:Tg(this.types,!t,e),properties:Tg(this.properties,!t,e),atrules:rre(this.atrules,!t,e)}}toString(){return JSON.stringify(this.dump())}}function Qp(n,e){return typeof e=="string"&&/^\s*\|/.test(e)?typeof n=="string"?n+e:e.replace(/^\s*\|\s*/,""):e||null}function are(n,e){const t=Object.create(null);for(const s of Object.keys(n))e.includes(s)&&(t[s]=n[s]);return t}function eh(n,e,t){const s={...n};for(const[r,o]of Object.entries(e))s[r]={...s[r],...t?are(o,t):o};return s}function Ag(n,e){const t={...n};for(const[s,r]of Object.entries(e))switch(s){case"generic":t[s]=!!r;break;case"cssWideKeywords":t[s]=n[s]?[...n[s],...r]:r||[];break;case"units":t[s]={...n[s]};for(const[o,i]of Object.entries(r))t[s][o]=Array.isArray(i)?i:[];break;case"atrules":t[s]={...n[s]};for(const[o,i]of Object.entries(r)){const l=t[s][o]||{},c=t[s][o]={prelude:l.prelude||null,descriptors:{...l.descriptors}};if(i){c.prelude=i.prelude?Qp(c.prelude,i.prelude):c.prelude||null;for(const[u,d]of Object.entries(i.descriptors||{}))c.descriptors[u]=d?Qp(c.descriptors[u],d):null;Object.keys(c.descriptors).length||(c.descriptors=null)}}break;case"types":case"properties":t[s]={...n[s]};for(const[o,i]of Object.entries(r))t[s][o]=Qp(t[s][o],i);break;case"parseContext":t[s]={...n[s],...r};break;case"scope":case"features":t[s]=eh(n[s],r);break;case"atrule":case"pseudo":t[s]=eh(n[s],r,["parse"]);break;case"node":t[s]=eh(n[s],r,["name","structure","parse","generate","walkContext"]);break}return t}function CE(n){const e=cne(n),t=_ne(n),s=kne(n),{fromPlainObject:r,toPlainObject:o}=jne(t),i={lexer:null,createLexer:l=>new GS(l,i,i.lexer.structure),tokenize:$f,parse:e,generate:s,walk:t,find:t.find,findLast:t.findLast,findAll:t.findAll,fromPlainObject:r,toPlainObject:o,fork(l){const c=Ag({},n);return CE(typeof l=="function"?l(c):Ag(c,l))}};return i.lexer=new GS({generic:n.generic,cssWideKeywords:n.cssWideKeywords,units:n.units,types:n.types,atrules:n.atrules,properties:n.properties,node:n.node},i),i}const lre=n=>CE(Ag({},n)),cre={generic:!0,cssWideKeywords:["initial","inherit","unset","revert","revert-layer"],units:{angle:["deg","grad","rad","turn"],decibel:["db"],flex:["fr"],frequency:["hz","khz"],length:["cm","mm","q","in","pt","pc","px","em","rem","ex","rex","cap","rcap","ch","rch","ic","ric","lh","rlh","vw","svw","lvw","dvw","vh","svh","lvh","dvh","vi","svi","lvi","dvi","vb","svb","lvb","dvb","vmin","svmin","lvmin","dvmin","vmax","svmax","lvmax","dvmax","cqw","cqh","cqi","cqb","cqmin","cqmax"],resolution:["dpi","dpcm","dppx","x"],semitones:["st"],time:["s","ms"]},types:{"abs()":"abs( <calc-sum> )","absolute-size":"xx-small|x-small|small|medium|large|x-large|xx-large|xxx-large","acos()":"acos( <calc-sum> )","alpha-value":"<number>|<percentage>","an+b":"odd|even|<integer>|<n-dimension>|'+'? † n|-n|<ndashdigit-dimension>|'+'? † <ndashdigit-ident>|<dashndashdigit-ident>|<n-dimension> <signed-integer>|'+'? † n <signed-integer>|-n <signed-integer>|<ndash-dimension> <signless-integer>|'+'? † n- <signless-integer>|-n- <signless-integer>|<n-dimension> ['+'|'-'] <signless-integer>|'+'? † n ['+'|'-'] <signless-integer>|-n ['+'|'-'] <signless-integer>","anchor()":"anchor( <anchor-name>?&&<anchor-side> , <length-percentage>? )","anchor-name":"<dashed-ident>","anchor-side":"inside|outside|top|left|right|bottom|start|end|self-start|self-end|<percentage>|center","anchor-size":"width|height|block|inline|self-block|self-inline","anchor-size()":"anchor-size( [<anchor-name>||<anchor-size>]? , <length-percentage>? )","angle-percentage":"<angle>|<percentage>","angular-color-hint":"<angle-percentage>|<zero>","angular-color-stop":"<color> <color-stop-angle>?","angular-color-stop-list":"<angular-color-stop> , [<angular-color-hint>? , <angular-color-stop>]#?","animateable-feature":"scroll-position|contents|<custom-ident>","animation-action":"none|play|play-once|play-forwards|play-backwards|pause|reset|replay","asin()":"asin( <calc-sum> )","atan()":"atan( <calc-sum> )","atan2()":"atan2( <calc-sum> , <calc-sum> )",attachment:"scroll|fixed|local","attr()":"attr( <attr-name> <attr-type>? , <declaration-value>? )","attr-matcher":"['~'|'|'|'^'|'$'|'*']? '='","attr-modifier":"i|s","attr-type":"type( <syntax> )|raw-string|number|<attr-unit>","attribute-selector":"'[' <wq-name> ']'|'[' <wq-name> <attr-matcher> [<string-token>|<ident-token>] <attr-modifier>? ']'","auto-repeat":"repeat( [auto-fill|auto-fit] , [<line-names>? <fixed-size>]+ <line-names>? )","auto-track-list":"[<line-names>? [<fixed-size>|<fixed-repeat>]]* <line-names>? <auto-repeat> [<line-names>? [<fixed-size>|<fixed-repeat>]]* <line-names>?",axis:"block|inline|x|y","baseline-position":"[first|last]? baseline","basic-shape":"<inset()>|<xywh()>|<rect()>|<circle()>|<ellipse()>|<polygon()>|<path()>","basic-shape-rect":"<inset()>|<rect()>|<xywh()>","bg-clip":"<visual-box>|border-area|text","bg-image":"<image>|none","bg-layer":"<bg-image>||<bg-position> [/ <bg-size>]?||<repeat-style>||<attachment>||<visual-box>||<visual-box>","bg-position":"[[left|center|right|top|bottom|<length-percentage>]|[left|center|right|<length-percentage>] [top|center|bottom|<length-percentage>]|[center|[left|right] <length-percentage>?]&&[center|[top|bottom] <length-percentage>?]]","bg-size":"[<length-percentage [0,∞]>|auto]{1,2}|cover|contain","blend-mode":"normal|multiply|screen|overlay|darken|lighten|color-dodge|color-burn|hard-light|soft-light|difference|exclusion|hue|saturation|color|luminosity","blur()":"blur( <length>? )","brightness()":"brightness( [<number>|<percentage>]? )","calc()":"calc( <calc-sum> )","calc-constant":"e|pi|infinity|-infinity|NaN","calc-product":"<calc-value> ['*' <calc-value>|'/' <number>]*","calc-size()":"calc-size( <calc-size-basis> , <calc-sum> )","calc-size-basis":"<intrinsic-size-keyword>|<calc-size()>|any|<calc-sum>","calc-sum":"<calc-product> [['+'|'-'] <calc-product>]*","calc-value":"<number>|<dimension>|<percentage>|<calc-constant>|( <calc-sum> )","cf-final-image":"<image>|<color>","cf-mixing-image":"<percentage>?&&<image>","circle()":"circle( <radial-size>? [at <position>]? )","clamp()":"clamp( <calc-sum>#{3} )","class-selector":"'.' <ident-token>","clip-source":"<url>",color:"<color-base>|currentColor|<system-color>|<device-cmyk()>|<light-dark()>|<-non-standard-color>","color()":"color( <colorspace-params> [/ [<alpha-value>|none]]? )","color-base":"<hex-color>|<color-function>|<named-color>|<color-mix()>|transparent","color-function":"<rgb()>|<rgba()>|<hsl()>|<hsla()>|<hwb()>|<lab()>|<lch()>|<oklab()>|<oklch()>|<color()>","color-interpolation-method":"in [<rectangular-color-space>|<polar-color-space> <hue-interpolation-method>?|<custom-color-space>]","color-mix()":"color-mix( <color-interpolation-method> , [<color>&&<percentage [0,100]>?]#{2} )","color-stop":"<color-stop-length>|<color-stop-angle>","color-stop-angle":"[<angle-percentage>|<zero>]{1,2}","color-stop-length":"<length-percentage>{1,2}","color-stop-list":"<linear-color-stop> , [<linear-color-hint>? , <linear-color-stop>]#?","colorspace-params":"[<predefined-rgb-params>|<xyz-params>]",combinator:"'>'|'+'|'~'|['|' '|']","common-lig-values":"[common-ligatures|no-common-ligatures]","compat-auto":"searchfield|textarea|checkbox|radio|menulist|listbox|meter|progress-bar|button","compat-special":"textfield|menulist-button","complex-selector":"<complex-selector-unit> [<combinator>? <complex-selector-unit>]*","complex-selector-list":"<complex-selector>#","composite-style":"clear|copy|source-over|source-in|source-out|source-atop|destination-over|destination-in|destination-out|destination-atop|xor","compositing-operator":"add|subtract|intersect|exclude","compound-selector":"[<type-selector>? <subclass-selector>*]!","compound-selector-list":"<compound-selector>#","conic-gradient()":"conic-gradient( [<conic-gradient-syntax>] )","conic-gradient-syntax":"[[[from [<angle>|<zero>]]? [at <position>]?]||<color-interpolation-method>]? , <angular-color-stop-list>","container-condition":"not <query-in-parens>|<query-in-parens> [[and <query-in-parens>]*|[or <query-in-parens>]*]","container-name":"<custom-ident>","container-query":"not <query-in-parens>|<query-in-parens> [[and <query-in-parens>]*|[or <query-in-parens>]*]","content-distribution":"space-between|space-around|space-evenly|stretch","content-list":"[<string>|contents|<image>|<counter>|<quote>|<target>|<leader()>|<attr()>]+","content-position":"center|start|end|flex-start|flex-end","content-replacement":"<image>","contextual-alt-values":"[contextual|no-contextual]","contrast()":"contrast( [<number>|<percentage>]? )","coord-box":"content-box|padding-box|border-box|fill-box|stroke-box|view-box","corner-shape-value":"round|scoop|bevel|notch|square|squircle|<superellipse()>","cos()":"cos( <calc-sum> )",counter:"<counter()>|<counters()>","counter()":"counter( <counter-name> , <counter-style>? )","counter-name":"<custom-ident>","counter-style":"<counter-style-name>|symbols( )","counter-style-name":"<custom-ident>","counters()":"counters( <counter-name> , <string> , <counter-style>? )","cross-fade()":"cross-fade( <cf-mixing-image> , <cf-final-image>? )","cubic-bezier()":"cubic-bezier( [<number [0,1]> , <number>]#{2} )","cubic-bezier-easing-function":"ease|ease-in|ease-out|ease-in-out|cubic-bezier( <number [0,1]> , <number> , <number [0,1]> , <number> )","cursor-predefined":"auto|default|none|context-menu|help|pointer|progress|wait|cell|crosshair|text|vertical-text|alias|copy|move|no-drop|not-allowed|e-resize|n-resize|ne-resize|nw-resize|s-resize|se-resize|sw-resize|w-resize|ew-resize|ns-resize|nesw-resize|nwse-resize|col-resize|row-resize|all-scroll|zoom-in|zoom-out|grab|grabbing","custom-color-space":"<dashed-ident>","custom-params":"<dashed-ident> [<number>|<percentage>|none]+",dasharray:"[[<length-percentage>|<number>]+]#","dashndashdigit-ident":"<ident-token>","deprecated-system-color":"ActiveBorder|ActiveCaption|AppWorkspace|Background|ButtonHighlight|ButtonShadow|CaptionText|InactiveBorder|InactiveCaption|InactiveCaptionText|InfoBackground|InfoText|Menu|MenuText|Scrollbar|ThreeDDarkShadow|ThreeDFace|ThreeDHighlight|ThreeDLightShadow|ThreeDShadow|Window|WindowFrame|WindowText","discretionary-lig-values":"[discretionary-ligatures|no-discretionary-ligatures]","display-box":"contents|none","display-inside":"flow|flow-root|table|flex|grid|ruby","display-internal":"table-row-group|table-header-group|table-footer-group|table-row|table-cell|table-column-group|table-column|table-caption|ruby-base|ruby-text|ruby-base-container|ruby-text-container","display-legacy":"inline-block|inline-list-item|inline-table|inline-flex|inline-grid","display-listitem":"<display-outside>?&&[flow|flow-root]?&&list-item","display-outside":"block|inline|run-in","drop-shadow()":"drop-shadow( [<color>?&&<length>{2,3}] )","dynamic-range-limit-mix()":"dynamic-range-limit-mix( [<'dynamic-range-limit'>&&<percentage [0,100]>]#{2,} )","easing-function":"<linear-easing-function>|<cubic-bezier-easing-function>|<step-easing-function>","east-asian-variant-values":"[jis78|jis83|jis90|jis04|simplified|traditional]","east-asian-width-values":"[full-width|proportional-width]","element()":"element( <custom-ident> , [first|start|last|first-except]? )|element( <id-selector> )","ellipse()":"ellipse( <radial-size>? [at <position>]? )","env()":"env( <custom-ident> , <declaration-value>? )","exp()":"exp( <calc-sum> )","explicit-track-list":"[<line-names>? <track-size>]+ <line-names>?","family-name":"<string>|<custom-ident>+","feature-tag-value":"<string> [<integer>|on|off]?","feature-type":"@stylistic|@historical-forms|@styleset|@character-variant|@swash|@ornaments|@annotation","feature-value-block":"<feature-type> '{' <feature-value-declaration-list> '}'","feature-value-block-list":"<feature-value-block>+","feature-value-declaration":"<custom-ident> : <integer>+ ;","feature-value-declaration-list":"<feature-value-declaration>","feature-value-name":"<custom-ident>","filter-function":"<blur()>|<brightness()>|<contrast()>|<drop-shadow()>|<grayscale()>|<hue-rotate()>|<invert()>|<opacity()>|<saturate()>|<sepia()>","filter-value-list":"[<filter-function>|<url>]+","final-bg-layer":"<bg-image>||<bg-position> [/ <bg-size>]?||<repeat-style>||<attachment>||<visual-box>||<visual-box>||<'background-color'>","fit-content()":"fit-content( <length-percentage [0,∞]> )","fixed-breadth":"<length-percentage>","fixed-repeat":"repeat( [<integer [1,∞]>] , [<line-names>? <fixed-size>]+ <line-names>? )","fixed-size":"<fixed-breadth>|minmax( <fixed-breadth> , <track-breadth> )|minmax( <inflexible-breadth> , <fixed-breadth> )","font-stretch-absolute":"normal|ultra-condensed|extra-condensed|condensed|semi-condensed|semi-expanded|expanded|extra-expanded|ultra-expanded|<percentage>","font-variant-css2":"normal|small-caps","font-weight-absolute":"normal|bold|<number [1,1000]>","font-width-css3":"normal|ultra-condensed|extra-condensed|condensed|semi-condensed|semi-expanded|expanded|extra-expanded|ultra-expanded","form-control-identifier":"select","frequency-percentage":"<frequency>|<percentage>","generic-complete":"serif|sans-serif|system-ui|cursive|fantasy|math|monospace","general-enclosed":"[<function-token> <any-value>? )]|[( <any-value>? )]","generic-family":"<generic-script-specific>|<generic-complete>|<generic-incomplete>|<-non-standard-generic-family>","generic-incomplete":"ui-serif|ui-sans-serif|ui-monospace|ui-rounded","geometry-box":"<shape-box>|fill-box|stroke-box|view-box",gradient:"<linear-gradient()>|<repeating-linear-gradient()>|<radial-gradient()>|<repeating-radial-gradient()>|<conic-gradient()>|<repeating-conic-gradient()>|<-legacy-gradient>","grayscale()":"grayscale( [<number>|<percentage>]? )","grid-line":"auto|<custom-ident>|[<integer>&&<custom-ident>?]|[span&&[<integer>||<custom-ident>]]","historical-lig-values":"[historical-ligatures|no-historical-ligatures]","hsl()":"hsl( <hue> , <percentage> , <percentage> , <alpha-value>? )|hsl( [<hue>|none] [<percentage>|<number>|none] [<percentage>|<number>|none] [/ [<alpha-value>|none]]? )","hsla()":"hsla( <hue> , <percentage> , <percentage> , <alpha-value>? )|hsla( [<hue>|none] [<percentage>|<number>|none] [<percentage>|<number>|none] [/ [<alpha-value>|none]]? )",hue:"<number>|<angle>","hue-interpolation-method":"[shorter|longer|increasing|decreasing] hue","hue-rotate()":"hue-rotate( [<angle>|<zero>]? )","hwb()":"hwb( [<hue>|none] [<percentage>|<number>|none] [<percentage>|<number>|none] [/ [<alpha-value>|none]]? )","hypot()":"hypot( <calc-sum># )",image:"<url>|<image()>|<image-set()>|<element()>|<paint()>|<cross-fade()>|<gradient>","image()":"image( <image-tags>? [<image-src>? , <color>?]! )","image-set()":"image-set( <image-set-option># )","image-set-option":"[<image>|<string>] [<resolution>||type( <string> )]","image-src":"<url>|<string>","image-tags":"ltr|rtl","inflexible-breadth":"<length-percentage>|min-content|max-content|auto","inset()":"inset( <length-percentage>{1,4} [round <'border-radius'>]? )","invert()":"invert( [<number>|<percentage>]? )","keyframe-block":"<keyframe-selector># { <declaration-list> }","keyframe-selector":"from|to|<percentage [0,100]>|<timeline-range-name> <percentage>","keyframes-name":"<custom-ident>|<string>","lab()":"lab( [<percentage>|<number>|none] [<percentage>|<number>|none] [<percentage>|<number>|none] [/ [<alpha-value>|none]]? )","layer()":"layer( <layer-name> )","layer-name":"<ident> ['.' <ident>]*","lch()":"lch( [<percentage>|<number>|none] [<percentage>|<number>|none] [<hue>|none] [/ [<alpha-value>|none]]? )","leader()":"leader( <leader-type> )","leader-type":"dotted|solid|space|<string>","length-percentage":"<length>|<percentage>","light-dark()":"light-dark( <color> , <color> )","line-name-list":"[<line-names>|<name-repeat>]+","line-names":"'[' <custom-ident>* ']'","line-style":"none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset","line-width":"<length>|thin|medium|thick","linear()":"linear( [<number>&&<percentage>{0,2}]# )","linear-color-hint":"<length-percentage>","linear-color-stop":"<color> <color-stop-length>?","linear-easing-function":"linear|<linear()>","linear-gradient()":"linear-gradient( [<linear-gradient-syntax>] )","linear-gradient-syntax":"[[<angle>|<zero>|to <side-or-corner>]||<color-interpolation-method>]? , <color-stop-list>","log()":"log( <calc-sum> , <calc-sum>? )","mask-layer":"<mask-reference>||<position> [/ <bg-size>]?||<repeat-style>||<geometry-box>||[<geometry-box>|no-clip]||<compositing-operator>||<masking-mode>","mask-position":"[<length-percentage>|left|center|right] [<length-percentage>|top|center|bottom]?","mask-reference":"none|<image>|<mask-source>","mask-source":"<url>","masking-mode":"alpha|luminance|match-source","matrix()":"matrix( <number>#{6} )","matrix3d()":"matrix3d( <number>#{16} )","max()":"max( <calc-sum># )","media-and":"<media-in-parens> [and <media-in-parens>]+","media-condition":"<media-not>|<media-and>|<media-or>|<media-in-parens>","media-condition-without-or":"<media-not>|<media-and>|<media-in-parens>","media-feature":"( [<mf-plain>|<mf-boolean>|<mf-range>] )","media-in-parens":"( <media-condition> )|<media-feature>|<general-enclosed>","media-not":"not <media-in-parens>","media-or":"<media-in-parens> [or <media-in-parens>]+","media-query":"<media-condition>|[not|only]? <media-type> [and <media-condition-without-or>]?","media-query-list":"<media-query>#","media-type":"<ident>","mf-boolean":"<mf-name>","mf-name":"<ident>","mf-plain":"<mf-name> : <mf-value>","mf-range":"<mf-name> ['<'|'>']? '='? <mf-value>|<mf-value> ['<'|'>']? '='? <mf-name>|<mf-value> '<' '='? <mf-name> '<' '='? <mf-value>|<mf-value> '>' '='? <mf-name> '>' '='? <mf-value>","mf-value":"<number>|<dimension>|<ident>|<ratio>","min()":"min( <calc-sum># )","minmax()":"minmax( [<length-percentage>|min-content|max-content|auto] , [<length-percentage>|<flex>|min-content|max-content|auto] )","mod()":"mod( <calc-sum> , <calc-sum> )","n-dimension":"<dimension-token>","name-repeat":"repeat( [<integer [1,∞]>|auto-fill] , <line-names>+ )","named-color":"aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkgrey|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|grey|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgray|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightslategrey|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|rebeccapurple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|slategrey|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen","namespace-prefix":"<ident>","ndash-dimension":"<dimension-token>","ndashdigit-dimension":"<dimension-token>","ndashdigit-ident":"<ident-token>","ns-prefix":"[<ident-token>|'*']? '|'","number-percentage":"<number>|<percentage>","numeric-figure-values":"[lining-nums|oldstyle-nums]","numeric-fraction-values":"[diagonal-fractions|stacked-fractions]","numeric-spacing-values":"[proportional-nums|tabular-nums]","offset-path":"<ray()>|<url>|<basic-shape>","oklab()":"oklab( [<percentage>|<number>|none] [<percentage>|<number>|none] [<percentage>|<number>|none] [/ [<alpha-value>|none]]? )","oklch()":"oklch( [<percentage>|<number>|none] [<percentage>|<number>|none] [<hue>|none] [/ [<alpha-value>|none]]? )","opacity()":"opacity( [<number>|<percentage>]? )","opacity-value":"<number>|<percentage>","outline-line-style":"none|dotted|dashed|solid|double|groove|ridge|inset|outset","outline-radius":"<length>|<percentage>","overflow-position":"unsafe|safe","page-body":"<declaration>? [; <page-body>]?|<page-margin-box> <page-body>","page-margin-box":"<page-margin-box-type> '{' <declaration-list> '}'","page-margin-box-type":"@top-left-corner|@top-left|@top-center|@top-right|@top-right-corner|@bottom-left-corner|@bottom-left|@bottom-center|@bottom-right|@bottom-right-corner|@left-top|@left-middle|@left-bottom|@right-top|@right-middle|@right-bottom","page-selector":"<pseudo-page>+|<ident> <pseudo-page>*","page-selector-list":"[<page-selector>#]?","page-size":"A5|A4|A3|B5|B4|JIS-B5|JIS-B4|letter|legal|ledger",paint:"none|<color>|<url> [none|<color>]?|context-fill|context-stroke","paint()":"paint( <ident> , <declaration-value>? )","paint-box":"<visual-box>|fill-box|stroke-box","palette-identifier":"<dashed-ident>","palette-mix()":"palette-mix( <color-interpolation-method> , [[normal|light|dark|<palette-identifier>|<palette-mix()>]&&<percentage [0,100]>?]#{2} )","path()":"path( <'fill-rule'>? , <string> )","perspective()":"perspective( [<length [0,∞]>|none] )","polar-color-space":"hsl|hwb|lch|oklch","polygon()":"polygon( <'fill-rule'>? , [<length-percentage> <length-percentage>]# )",position:"[[left|center|right]||[top|center|bottom]|[left|center|right|<length-percentage>] [top|center|bottom|<length-percentage>]?|[[left|right] <length-percentage>]&&[[top|bottom] <length-percentage>]]","position-area":"[[left|center|right|span-left|span-right|x-start|x-end|span-x-start|span-x-end|x-self-start|x-self-end|span-x-self-start|span-x-self-end|span-all]||[top|center|bottom|span-top|span-bottom|y-start|y-end|span-y-start|span-y-end|y-self-start|y-self-end|span-y-self-start|span-y-self-end|span-all]|[block-start|center|block-end|span-block-start|span-block-end|span-all]||[inline-start|center|inline-end|span-inline-start|span-inline-end|span-all]|[self-block-start|center|self-block-end|span-self-block-start|span-self-block-end|span-all]||[self-inline-start|center|self-inline-end|span-self-inline-start|span-self-inline-end|span-all]|[start|center|end|span-start|span-end|span-all]{1,2}|[self-start|center|self-end|span-self-start|span-self-end|span-all]{1,2}]","pow()":"pow( <calc-sum> , <calc-sum> )","predefined-rgb":"srgb|srgb-linear|display-p3|display-p3-linear|a98-rgb|prophoto-rgb|rec2020","predefined-rgb-params":"<predefined-rgb> [<number>|<percentage>|none]{3}","pseudo-class-selector":"':' <ident-token>|':' <function-token> <any-value> ')'","pseudo-element-selector":"':' <pseudo-class-selector>|<legacy-pseudo-element-selector>","pseudo-page":": [left|right|first|blank]","query-in-parens":"( <container-condition> )|( <size-feature> )|style( <style-query> )|<general-enclosed>",quote:"open-quote|close-quote|no-open-quote|no-close-quote","radial-extent":"closest-corner|closest-side|farthest-corner|farthest-side","radial-gradient()":"radial-gradient( [<radial-gradient-syntax>] )","radial-gradient-syntax":"[[[<radial-shape>||<radial-size>]? [at <position>]?]||<color-interpolation-method>]? , <color-stop-list>","radial-shape":"circle|ellipse","radial-size":"<radial-extent>|<length [0,∞]>|<length-percentage [0,∞]>{2}",ratio:"<number [0,∞]> [/ <number [0,∞]>]?","ray()":"ray( <angle>&&<ray-size>?&&contain?&&[at <position>]? )","ray-size":"closest-side|closest-corner|farthest-side|farthest-corner|sides","rect()":"rect( [<length-percentage>|auto]{4} [round <'border-radius'>]? )","rectangular-color-space":"srgb|srgb-linear|display-p3|display-p3-linear|a98-rgb|prophoto-rgb|rec2020|lab|oklab|xyz|xyz-d50|xyz-d65","relative-selector":"<combinator>? <complex-selector>","relative-selector-list":"<relative-selector>#","relative-size":"larger|smaller","rem()":"rem( <calc-sum> , <calc-sum> )","repeat-style":"repeat-x|repeat-y|[repeat|space|round|no-repeat]{1,2}","repeating-conic-gradient()":"repeating-conic-gradient( [<conic-gradient-syntax>] )","repeating-linear-gradient()":"repeating-linear-gradient( [<linear-gradient-syntax>] )","repeating-radial-gradient()":"repeating-radial-gradient( [<radial-gradient-syntax>] )","reversed-counter-name":"reversed( <counter-name> )","rgb()":"rgb( <percentage>#{3} , <alpha-value>? )|rgb( <number>#{3} , <alpha-value>? )|rgb( [<number>|<percentage>|none]{3} [/ [<alpha-value>|none]]? )","rgba()":"rgba( <percentage>#{3} , <alpha-value>? )|rgba( <number>#{3} , <alpha-value>? )|rgba( [<number>|<percentage>|none]{3} [/ [<alpha-value>|none]]? )","rotate()":"rotate( [<angle>|<zero>] )","rotate3d()":"rotate3d( <number> , <number> , <number> , [<angle>|<zero>] )","rotateX()":"rotateX( [<angle>|<zero>] )","rotateY()":"rotateY( [<angle>|<zero>] )","rotateZ()":"rotateZ( [<angle>|<zero>] )","round()":"round( <rounding-strategy>? , <calc-sum> , <calc-sum> )","rounding-strategy":"nearest|up|down|to-zero","saturate()":"saturate( [<number>|<percentage>]? )","scale()":"scale( [<number>|<percentage>]#{1,2} )","scale3d()":"scale3d( [<number>|<percentage>]#{3} )","scaleX()":"scaleX( [<number>|<percentage>] )","scaleY()":"scaleY( [<number>|<percentage>] )","scaleZ()":"scaleZ( [<number>|<percentage>] )","scope-end":"<forgiving-selector-list>","scope-start":"<forgiving-selector-list>","scroll()":"scroll( [<scroller>||<axis>]? )",scroller:"root|nearest|self","scroll-state-feature":"<media-query-list>","scroll-state-in-parens":"( <scroll-state-query> )|( <scroll-state-feature> )|<general-enclosed>","scroll-state-query":"not <scroll-state-in-parens>|<scroll-state-in-parens> [[and <scroll-state-in-parens>]*|[or <scroll-state-in-parens>]*]|<scroll-state-feature>","selector-list":"<complex-selector-list>","self-position":"center|start|end|self-start|self-end|flex-start|flex-end","sepia()":"sepia( [<number>|<percentage>]? )",shadow:"inset?&&<length>{2,4}&&<color>?","shadow-t":"[<length>{2,3}&&<color>?]",shape:"rect( <top> , <right> , <bottom> , <left> )|rect( <top> <right> <bottom> <left> )","shape-box":"<visual-box>|margin-box","side-or-corner":"[left|right]||[top|bottom]","sign()":"sign( <calc-sum> )","signed-integer":"<number-token>","signless-integer":"<number-token>","sin()":"sin( <calc-sum> )","single-animation":"<'animation-duration'>||<easing-function>||<'animation-delay'>||<single-animation-iteration-count>||<single-animation-direction>||<single-animation-fill-mode>||<single-animation-play-state>||[none|<keyframes-name>]||<single-animation-timeline>","single-animation-composition":"replace|add|accumulate","single-animation-direction":"normal|reverse|alternate|alternate-reverse","single-animation-fill-mode":"none|forwards|backwards|both","single-animation-iteration-count":"infinite|<number>","single-animation-play-state":"running|paused","single-animation-timeline":"auto|none|<dashed-ident>|<scroll()>|<view()>","single-transition":"[none|<single-transition-property>]||<time>||<easing-function>||<time>||<transition-behavior-value>","single-transition-property":"all|<custom-ident>",size:"closest-side|farthest-side|closest-corner|farthest-corner|<length>|<length-percentage>{2}","size-feature":"<mf-plain>|<mf-boolean>|<mf-range>","skew()":"skew( [<angle>|<zero>] , [<angle>|<zero>]? )","skewX()":"skewX( [<angle>|<zero>] )","skewY()":"skewY( [<angle>|<zero>] )","sqrt()":"sqrt( <calc-sum> )","step-position":"jump-start|jump-end|jump-none|jump-both|start|end","step-easing-function":"step-start|step-end|<steps()>","steps()":"steps( <integer> , <step-position>? )","style-feature":"<declaration>","style-in-parens":"( <style-condition> )|( <style-feature> )|<general-enclosed>","style-query":"<style-condition>|<style-feature>","subclass-selector":"<id-selector>|<class-selector>|<attribute-selector>|<pseudo-class-selector>","superellipse()":"superellipse( [<number>|infinity|-infinity] )","supports-condition":"not <supports-in-parens>|<supports-in-parens> [and <supports-in-parens>]*|<supports-in-parens> [or <supports-in-parens>]*","supports-decl":"( <declaration> )","supports-feature":"<supports-decl>|<supports-selector-fn>","supports-in-parens":"( <supports-condition> )|<supports-feature>|<general-enclosed>","supports-selector-fn":"selector( <complex-selector> )",symbol:"<string>|<image>|<custom-ident>","symbols()":"symbols( <symbols-type>? [<string>|<image>]+ )","symbols-type":"cyclic|numeric|alphabetic|symbolic|fixed","system-color":"AccentColor|AccentColorText|ActiveText|ButtonBorder|ButtonFace|ButtonText|Canvas|CanvasText|Field|FieldText|GrayText|Highlight|HighlightText|LinkText|Mark|MarkText|SelectedItem|SelectedItemText|VisitedText","system-family-name":"caption|icon|menu|message-box|small-caption|status-bar","tan()":"tan( <calc-sum> )",target:"<target-counter()>|<target-counters()>|<target-text()>","target-counter()":"target-counter( [<string>|<url>] , <custom-ident> , <counter-style>? )","target-counters()":"target-counters( [<string>|<url>] , <custom-ident> , <string> , <counter-style>? )","target-text()":"target-text( [<string>|<url>] , [content|before|after|first-letter]? )","text-edge":"[text|cap|ex|ideographic|ideographic-ink] [text|alphabetic|ideographic|ideographic-ink]?","time-percentage":"<time>|<percentage>","timeline-range-name":"cover|contain|entry|exit|entry-crossing|exit-crossing","track-breadth":"<length-percentage>|<flex>|min-content|max-content|auto","track-list":"[<line-names>? [<track-size>|<track-repeat>]]+ <line-names>?","track-repeat":"repeat( [<integer [1,∞]>] , [<line-names>? <track-size>]+ <line-names>? )","track-size":"<track-breadth>|minmax( <inflexible-breadth> , <track-breadth> )|fit-content( <length-percentage> )","transform-function":"<matrix()>|<translate()>|<translateX()>|<translateY()>|<scale()>|<scaleX()>|<scaleY()>|<rotate()>|<skew()>|<skewX()>|<skewY()>|<matrix3d()>|<translate3d()>|<translateZ()>|<scale3d()>|<scaleZ()>|<rotate3d()>|<rotateX()>|<rotateY()>|<rotateZ()>|<perspective()>","transform-list":"<transform-function>+","transition-behavior-value":"normal|allow-discrete","translate()":"translate( <length-percentage> , <length-percentage>? )","translate3d()":"translate3d( <length-percentage> , <length-percentage> , <length> )","translateX()":"translateX( <length-percentage> )","translateY()":"translateY( <length-percentage> )","translateZ()":"translateZ( <length> )","try-size":"most-width|most-height|most-block-size|most-inline-size","try-tactic":"flip-block||flip-inline||flip-start","type-or-unit":"string|color|url|integer|number|length|angle|time|frequency|cap|ch|em|ex|ic|lh|rlh|rem|vb|vi|vw|vh|vmin|vmax|mm|Q|cm|in|pt|pc|px|deg|grad|rad|turn|ms|s|Hz|kHz|%","type-selector":"<wq-name>|<ns-prefix>? '*'","var()":"var( <custom-property-name> , <declaration-value>? )","view()":"view( [<axis>||<'view-timeline-inset'>]? )","viewport-length":"auto|<length-percentage>","visual-box":"content-box|padding-box|border-box","wq-name":"<ns-prefix>? <ident-token>","xywh()":"xywh( <length-percentage>{2} <length-percentage [0,∞]>{2} [round <'border-radius'>]? )",xyz:"xyz|xyz-d50|xyz-d65","xyz-params":"<xyz-space> [<number>|<percentage>|none]{3}","-legacy-gradient":"<-webkit-gradient()>|<-legacy-linear-gradient>|<-legacy-repeating-linear-gradient>|<-legacy-radial-gradient>|<-legacy-repeating-radial-gradient>","-legacy-linear-gradient":"-moz-linear-gradient( <-legacy-linear-gradient-arguments> )|-webkit-linear-gradient( <-legacy-linear-gradient-arguments> )|-o-linear-gradient( <-legacy-linear-gradient-arguments> )","-legacy-repeating-linear-gradient":"-moz-repeating-linear-gradient( <-legacy-linear-gradient-arguments> )|-webkit-repeating-linear-gradient( <-legacy-linear-gradient-arguments> )|-o-repeating-linear-gradient( <-legacy-linear-gradient-arguments> )","-legacy-linear-gradient-arguments":"[<angle>|<side-or-corner>]? , <color-stop-list>","-legacy-radial-gradient":"-moz-radial-gradient( <-legacy-radial-gradient-arguments> )|-webkit-radial-gradient( <-legacy-radial-gradient-arguments> )|-o-radial-gradient( <-legacy-radial-gradient-arguments> )","-legacy-repeating-radial-gradient":"-moz-repeating-radial-gradient( <-legacy-radial-gradient-arguments> )|-webkit-repeating-radial-gradient( <-legacy-radial-gradient-arguments> )|-o-repeating-radial-gradient( <-legacy-radial-gradient-arguments> )","-legacy-radial-gradient-arguments":"[<position> ,]? [[[<-legacy-radial-gradient-shape>||<-legacy-radial-gradient-size>]|[<length>|<percentage>]{2}] ,]? <color-stop-list>","-legacy-radial-gradient-size":"closest-side|closest-corner|farthest-side|farthest-corner|contain|cover","-legacy-radial-gradient-shape":"circle|ellipse","-non-standard-font":"-apple-system-body|-apple-system-headline|-apple-system-subheadline|-apple-system-caption1|-apple-system-caption2|-apple-system-footnote|-apple-system-short-body|-apple-system-short-headline|-apple-system-short-subheadline|-apple-system-short-caption1|-apple-system-short-footnote|-apple-system-tall-body","-non-standard-color":"-moz-ButtonDefault|-moz-ButtonHoverFace|-moz-ButtonHoverText|-moz-CellHighlight|-moz-CellHighlightText|-moz-Combobox|-moz-ComboboxText|-moz-Dialog|-moz-DialogText|-moz-dragtargetzone|-moz-EvenTreeRow|-moz-Field|-moz-FieldText|-moz-html-CellHighlight|-moz-html-CellHighlightText|-moz-mac-accentdarkestshadow|-moz-mac-accentdarkshadow|-moz-mac-accentface|-moz-mac-accentlightesthighlight|-moz-mac-accentlightshadow|-moz-mac-accentregularhighlight|-moz-mac-accentregularshadow|-moz-mac-chrome-active|-moz-mac-chrome-inactive|-moz-mac-focusring|-moz-mac-menuselect|-moz-mac-menushadow|-moz-mac-menutextselect|-moz-MenuHover|-moz-MenuHoverText|-moz-MenuBarText|-moz-MenuBarHoverText|-moz-nativehyperlinktext|-moz-OddTreeRow|-moz-win-communicationstext|-moz-win-mediatext|-moz-activehyperlinktext|-moz-default-background-color|-moz-default-color|-moz-hyperlinktext|-moz-visitedhyperlinktext|-webkit-activelink|-webkit-focus-ring-color|-webkit-link|-webkit-text","-non-standard-image-rendering":"optimize-contrast|-moz-crisp-edges|-o-crisp-edges|-webkit-optimize-contrast","-non-standard-overflow":"overlay|-moz-scrollbars-none|-moz-scrollbars-horizontal|-moz-scrollbars-vertical|-moz-hidden-unscrollable","-non-standard-size":"intrinsic|min-intrinsic|-webkit-fill-available|-webkit-fit-content|-webkit-min-content|-webkit-max-content|-moz-available|-moz-fit-content|-moz-min-content|-moz-max-content","-webkit-gradient()":"-webkit-gradient( <-webkit-gradient-type> , <-webkit-gradient-point> [, <-webkit-gradient-point>|, <-webkit-gradient-radius> , <-webkit-gradient-point>] [, <-webkit-gradient-radius>]? [, <-webkit-gradient-color-stop>]* )","-webkit-gradient-color-stop":"from( <color> )|color-stop( [<number-zero-one>|<percentage>] , <color> )|to( <color> )","-webkit-gradient-point":"[left|center|right|<length-percentage>] [top|center|bottom|<length-percentage>]","-webkit-gradient-radius":"<length>|<percentage>","-webkit-gradient-type":"linear|radial","-webkit-mask-box-repeat":"repeat|stretch|round","-ms-filter-function-list":"<-ms-filter-function>+","-ms-filter-function":"<-ms-filter-function-progid>|<-ms-filter-function-legacy>","-ms-filter-function-progid":"'progid:' [<ident-token> '.']* [<ident-token>|<function-token> <any-value>? )]","-ms-filter-function-legacy":"<ident-token>|<function-token> <any-value>? )",age:"child|young|old","attr-name":"<wq-name>","attr-fallback":"<any-value>",autospace:"no-autospace|[ideograph-alpha||ideograph-numeric||punctuation]||[insert|replace]",bottom:"<length>|auto","generic-voice":"[<age>? <gender> <integer>?]",gender:"male|female|neutral","generic-script-specific":"generic( kai )|generic( fangsong )|generic( nastaliq )","-non-standard-generic-family":"-apple-system|BlinkMacSystemFont","intrinsic-size-keyword":"min-content|max-content|fit-content",left:"<length>|auto","device-cmyk()":"<legacy-device-cmyk-syntax>|<modern-device-cmyk-syntax>","legacy-device-cmyk-syntax":"device-cmyk( <number>#{4} )","modern-device-cmyk-syntax":"device-cmyk( <cmyk-component>{4} [/ [<alpha-value>|none]]? )","cmyk-component":"<number>|<percentage>|none","color-space":"<rectangular-color-space>|<polar-color-space>|<custom-color-space>",right:"<length>|auto","forgiving-selector-list":"<complex-real-selector-list>","forgiving-relative-selector-list":"<relative-real-selector-list>","complex-real-selector-list":"<complex-real-selector>#","simple-selector-list":"<simple-selector>#","relative-real-selector-list":"<relative-real-selector>#","complex-selector-unit":"[<compound-selector>? <pseudo-compound-selector>*]!","complex-real-selector":"<compound-selector> [<combinator>? <compound-selector>]*","relative-real-selector":"<combinator>? <complex-real-selector>","pseudo-compound-selector":"<pseudo-element-selector> <pseudo-class-selector>*","simple-selector":"<type-selector>|<subclass-selector>","legacy-pseudo-element-selector":"':' [before|after|first-line|first-letter]","svg-length":"<percentage>|<length>|<number>","svg-writing-mode":"lr-tb|rl-tb|tb-rl|lr|rl|tb",top:"<length>|auto",x:"<number>",y:"<number>",declaration:"<ident-token> : <declaration-value>? ['!' important]?","declaration-list":"[<declaration>? ';']* <declaration>?",url:"url( <string> <url-modifier>* )|<url-token>","url-modifier":"<ident>|<function-token> <any-value> )","number-zero-one":"<number [0,1]>","number-one-or-greater":"<number [1,∞]>","xyz-space":"xyz|xyz-d50|xyz-d65","style-condition":"not <style-in-parens>|<style-in-parens> [[and <style-in-parens>]*|[or <style-in-parens>]*]","-non-standard-display":"-ms-inline-flexbox|-ms-grid|-ms-inline-grid|-webkit-flex|-webkit-inline-flex|-webkit-box|-webkit-inline-box|-moz-inline-stack|-moz-box|-moz-inline-box","inset-area":"[[left|center|right|span-left|span-right|x-start|x-end|span-x-start|span-x-end|x-self-start|x-self-end|span-x-self-start|span-x-self-end|span-all]||[top|center|bottom|span-top|span-bottom|y-start|y-end|span-y-start|span-y-end|y-self-start|y-self-end|span-y-self-start|span-y-self-end|span-all]|[block-start|center|block-end|span-block-start|span-block-end|span-all]||[inline-start|center|inline-end|span-inline-start|span-inline-end|span-all]|[self-block-start|self-block-end|span-self-block-start|span-self-block-end|span-all]||[self-inline-start|self-inline-end|span-self-inline-start|span-self-inline-end|span-all]|[start|center|end|span-start|span-end|span-all]{1,2}|[self-start|center|self-end|span-self-start|span-self-end|span-all]{1,2}]",syntax:"'*'|<syntax-component> [<syntax-combinator> <syntax-component>]*|<syntax-string>","syntax-component":"<syntax-single-component> <syntax-multiplier>?|'<' transform-list '>'","syntax-single-component":"'<' <syntax-type-name> '>'|<ident>","syntax-type-name":"angle|color|custom-ident|image|integer|length|length-percentage|number|percentage|resolution|string|time|url|transform-function","syntax-combinator":"'|'","syntax-multiplier":"'#'|'+'","syntax-string":"<string>"},properties:{"--*":"<declaration-value>","-ms-accelerator":"false|true","-ms-block-progression":"tb|rl|bt|lr","-ms-content-zoom-chaining":"none|chained","-ms-content-zoom-limit":"<'-ms-content-zoom-limit-min'> <'-ms-content-zoom-limit-max'>","-ms-content-zoom-limit-max":"<percentage>","-ms-content-zoom-limit-min":"<percentage>","-ms-content-zoom-snap":"<'-ms-content-zoom-snap-type'>||<'-ms-content-zoom-snap-points'>","-ms-content-zoom-snap-points":"snapInterval( <percentage> , <percentage> )|snapList( <percentage># )","-ms-content-zoom-snap-type":"none|proximity|mandatory","-ms-content-zooming":"none|zoom","-ms-filter":"<string>","-ms-flow-from":"[none|<custom-ident>]#","-ms-flow-into":"[none|<custom-ident>]#","-ms-grid-columns":"none|<track-list>|<auto-track-list>","-ms-grid-rows":"none|<track-list>|<auto-track-list>","-ms-high-contrast-adjust":"auto|none","-ms-hyphenate-limit-chars":"auto|<integer>{1,3}","-ms-hyphenate-limit-lines":"no-limit|<integer>","-ms-hyphenate-limit-zone":"<percentage>|<length>","-ms-ime-align":"auto|after","-ms-overflow-style":"auto|none|scrollbar|-ms-autohiding-scrollbar","-ms-scroll-chaining":"chained|none","-ms-scroll-limit":"<'-ms-scroll-limit-x-min'> <'-ms-scroll-limit-y-min'> <'-ms-scroll-limit-x-max'> <'-ms-scroll-limit-y-max'>","-ms-scroll-limit-x-max":"auto|<length>","-ms-scroll-limit-x-min":"<length>","-ms-scroll-limit-y-max":"auto|<length>","-ms-scroll-limit-y-min":"<length>","-ms-scroll-rails":"none|railed","-ms-scroll-snap-points-x":"snapInterval( <length-percentage> , <length-percentage> )|snapList( <length-percentage># )","-ms-scroll-snap-points-y":"snapInterval( <length-percentage> , <length-percentage> )|snapList( <length-percentage># )","-ms-scroll-snap-type":"none|proximity|mandatory","-ms-scroll-snap-x":"<'-ms-scroll-snap-type'> <'-ms-scroll-snap-points-x'>","-ms-scroll-snap-y":"<'-ms-scroll-snap-type'> <'-ms-scroll-snap-points-y'>","-ms-scroll-translation":"none|vertical-to-horizontal","-ms-scrollbar-3dlight-color":"<color>","-ms-scrollbar-arrow-color":"<color>","-ms-scrollbar-base-color":"<color>","-ms-scrollbar-darkshadow-color":"<color>","-ms-scrollbar-face-color":"<color>","-ms-scrollbar-highlight-color":"<color>","-ms-scrollbar-shadow-color":"<color>","-ms-scrollbar-track-color":"<color>","-ms-text-autospace":"none|ideograph-alpha|ideograph-numeric|ideograph-parenthesis|ideograph-space","-ms-touch-select":"grippers|none","-ms-user-select":"none|element|text","-ms-wrap-flow":"auto|both|start|end|maximum|clear","-ms-wrap-margin":"<length>","-ms-wrap-through":"wrap|none","-moz-appearance":"none|button|button-arrow-down|button-arrow-next|button-arrow-previous|button-arrow-up|button-bevel|button-focus|caret|checkbox|checkbox-container|checkbox-label|checkmenuitem|dualbutton|groupbox|listbox|listitem|menuarrow|menubar|menucheckbox|menuimage|menuitem|menuitemtext|menulist|menulist-button|menulist-text|menulist-textfield|menupopup|menuradio|menuseparator|meterbar|meterchunk|progressbar|progressbar-vertical|progresschunk|progresschunk-vertical|radio|radio-container|radio-label|radiomenuitem|range|range-thumb|resizer|resizerpanel|scale-horizontal|scalethumbend|scalethumb-horizontal|scalethumbstart|scalethumbtick|scalethumb-vertical|scale-vertical|scrollbarbutton-down|scrollbarbutton-left|scrollbarbutton-right|scrollbarbutton-up|scrollbarthumb-horizontal|scrollbarthumb-vertical|scrollbartrack-horizontal|scrollbartrack-vertical|searchfield|separator|sheet|spinner|spinner-downbutton|spinner-textfield|spinner-upbutton|splitter|statusbar|statusbarpanel|tab|tabpanel|tabpanels|tab-scroll-arrow-back|tab-scroll-arrow-forward|textfield|textfield-multiline|toolbar|toolbarbutton|toolbarbutton-dropdown|toolbargripper|toolbox|tooltip|treeheader|treeheadercell|treeheadersortarrow|treeitem|treeline|treetwisty|treetwistyopen|treeview|-moz-mac-unified-toolbar|-moz-win-borderless-glass|-moz-win-browsertabbar-toolbox|-moz-win-communicationstext|-moz-win-communications-toolbox|-moz-win-exclude-glass|-moz-win-glass|-moz-win-mediatext|-moz-win-media-toolbox|-moz-window-button-box|-moz-window-button-box-maximized|-moz-window-button-close|-moz-window-button-maximize|-moz-window-button-minimize|-moz-window-button-restore|-moz-window-frame-bottom|-moz-window-frame-left|-moz-window-frame-right|-moz-window-titlebar|-moz-window-titlebar-maximized","-moz-binding":"<url>|none","-moz-border-bottom-colors":"<color>+|none","-moz-border-left-colors":"<color>+|none","-moz-border-right-colors":"<color>+|none","-moz-border-top-colors":"<color>+|none","-moz-context-properties":"none|[fill|fill-opacity|stroke|stroke-opacity]#","-moz-float-edge":"border-box|content-box|margin-box|padding-box","-moz-force-broken-image-icon":"0|1","-moz-orient":"inline|block|horizontal|vertical","-moz-outline-radius":"<outline-radius>{1,4} [/ <outline-radius>{1,4}]?","-moz-outline-radius-bottomleft":"<outline-radius>","-moz-outline-radius-bottomright":"<outline-radius>","-moz-outline-radius-topleft":"<outline-radius>","-moz-outline-radius-topright":"<outline-radius>","-moz-stack-sizing":"ignore|stretch-to-fit","-moz-text-blink":"none|blink","-moz-user-focus":"ignore|normal|select-after|select-before|select-menu|select-same|select-all|none","-moz-user-input":"auto|none|enabled|disabled","-moz-user-modify":"read-only|read-write|write-only","-moz-window-dragging":"drag|no-drag","-moz-window-shadow":"default|menu|tooltip|sheet|none","-webkit-appearance":"none|button|button-bevel|caps-lock-indicator|caret|checkbox|default-button|inner-spin-button|listbox|listitem|media-controls-background|media-controls-fullscreen-background|media-current-time-display|media-enter-fullscreen-button|media-exit-fullscreen-button|media-fullscreen-button|media-mute-button|media-overlay-play-button|media-play-button|media-seek-back-button|media-seek-forward-button|media-slider|media-sliderthumb|media-time-remaining-display|media-toggle-closed-captions-button|media-volume-slider|media-volume-slider-container|media-volume-sliderthumb|menulist|menulist-button|menulist-text|menulist-textfield|meter|progress-bar|progress-bar-value|push-button|radio|scrollbarbutton-down|scrollbarbutton-left|scrollbarbutton-right|scrollbarbutton-up|scrollbargripper-horizontal|scrollbargripper-vertical|scrollbarthumb-horizontal|scrollbarthumb-vertical|scrollbartrack-horizontal|scrollbartrack-vertical|searchfield|searchfield-cancel-button|searchfield-decoration|searchfield-results-button|searchfield-results-decoration|slider-horizontal|slider-vertical|sliderthumb-horizontal|sliderthumb-vertical|square-button|textarea|textfield|-apple-pay-button","-webkit-border-before":"<'border-width'>||<'border-style'>||<color>","-webkit-border-before-color":"<color>","-webkit-border-before-style":"<'border-style'>","-webkit-border-before-width":"<'border-width'>","-webkit-box-reflect":"[above|below|right|left]? <length>? <image>?","-webkit-line-clamp":"none|<integer>","-webkit-mask":"[<mask-reference>||<position> [/ <bg-size>]?||<repeat-style>||[<visual-box>|border|padding|content|text]||[<visual-box>|border|padding|content]]#","-webkit-mask-attachment":"<attachment>#","-webkit-mask-clip":"[<coord-box>|no-clip|border|padding|content|text]#","-webkit-mask-composite":"<composite-style>#","-webkit-mask-image":"<mask-reference>#","-webkit-mask-origin":"[<coord-box>|border|padding|content]#","-webkit-mask-position":"<position>#","-webkit-mask-position-x":"[<length-percentage>|left|center|right]#","-webkit-mask-position-y":"[<length-percentage>|top|center|bottom]#","-webkit-mask-repeat":"<repeat-style>#","-webkit-mask-repeat-x":"repeat|no-repeat|space|round","-webkit-mask-repeat-y":"repeat|no-repeat|space|round","-webkit-mask-size":"<bg-size>#","-webkit-overflow-scrolling":"auto|touch","-webkit-tap-highlight-color":"<color>","-webkit-text-fill-color":"<color>","-webkit-text-stroke":"<length>||<color>","-webkit-text-stroke-color":"<color>","-webkit-text-stroke-width":"<length>","-webkit-touch-callout":"default|none","-webkit-user-modify":"read-only|read-write|read-write-plaintext-only","-webkit-user-select":"auto|none|text|all","accent-color":"auto|<color>","align-content":"normal|<baseline-position>|<content-distribution>|<overflow-position>? <content-position>","align-items":"normal|stretch|<baseline-position>|[<overflow-position>? <self-position>]|anchor-center","align-self":"auto|normal|stretch|<baseline-position>|<overflow-position>? <self-position>|anchor-center","align-tracks":"[normal|<baseline-position>|<content-distribution>|<overflow-position>? <content-position>]#","alignment-baseline":"auto|baseline|before-edge|text-before-edge|middle|central|after-edge|text-after-edge|ideographic|alphabetic|hanging|mathematical",all:"initial|inherit|unset|revert|revert-layer","anchor-name":"none|<dashed-ident>#","anchor-scope":"none|all|<dashed-ident>#",animation:"<single-animation>#","animation-composition":"<single-animation-composition>#","animation-delay":"<time>#","animation-direction":"<single-animation-direction>#","animation-duration":"[auto|<time [0s,∞]>]#","animation-fill-mode":"<single-animation-fill-mode>#","animation-iteration-count":"<single-animation-iteration-count>#","animation-name":"[none|<keyframes-name>]#","animation-play-state":"<single-animation-play-state>#","animation-range":"[<'animation-range-start'> <'animation-range-end'>?]#","animation-range-end":"[normal|<length-percentage>|<timeline-range-name> <length-percentage>?]#","animation-range-start":"[normal|<length-percentage>|<timeline-range-name> <length-percentage>?]#","animation-timeline":"<single-animation-timeline>#","animation-timing-function":"<easing-function>#","animation-trigger":"[none|[<dashed-ident> <animation-action>+]+]#",appearance:"none|auto|<compat-auto>|<compat-special>","aspect-ratio":"auto||<ratio>","backdrop-filter":"none|<filter-value-list>","backface-visibility":"visible|hidden",background:"<bg-layer>#? , <final-bg-layer>","background-attachment":"<attachment>#","background-blend-mode":"<blend-mode>#","background-clip":"<bg-clip>#","background-color":"<color>","background-image":"<bg-image>#","background-origin":"<visual-box>#","background-position":"<bg-position>#","background-position-x":"[center|[[left|right|x-start|x-end]? <length-percentage>?]!]#","background-position-y":"[center|[[top|bottom|y-start|y-end]? <length-percentage>?]!]#","background-repeat":"<repeat-style>#","background-size":"<bg-size>#","baseline-shift":"baseline|sub|super|<svg-length>","baseline-source":"auto|first|last","block-size":"<'width'>",border:"<line-width>||<line-style>||<color>","border-block":"<'border-block-start'>","border-block-color":"<'border-top-color'>{1,2}","border-block-end":"<'border-top-width'>||<'border-top-style'>||<color>","border-block-end-color":"<'border-top-color'>","border-block-end-style":"<'border-top-style'>","border-block-end-width":"<'border-top-width'>","border-block-start":"<'border-top-width'>||<'border-top-style'>||<color>","border-block-start-color":"<'border-top-color'>","border-block-start-style":"<'border-top-style'>","border-block-start-width":"<'border-top-width'>","border-block-style":"<'border-top-style'>{1,2}","border-block-width":"<'border-top-width'>{1,2}","border-bottom":"<line-width>||<line-style>||<color>","border-bottom-color":"<'border-top-color'>","border-bottom-left-radius":"<length-percentage [0,∞]>{1,2}","border-bottom-right-radius":"<length-percentage [0,∞]>{1,2}","border-bottom-style":"<line-style>","border-bottom-width":"<line-width>","border-collapse":"separate|collapse","border-color":"<color>{1,4}","border-end-end-radius":"<'border-top-left-radius'>","border-end-start-radius":"<'border-top-left-radius'>","border-image":"<'border-image-source'>||<'border-image-slice'> [/ <'border-image-width'>|/ <'border-image-width'>? / <'border-image-outset'>]?||<'border-image-repeat'>","border-image-outset":"[<length [0,∞]>|<number [0,∞]>]{1,4}","border-image-repeat":"[stretch|repeat|round|space]{1,2}","border-image-slice":"[<number [0,∞]>|<percentage [0,∞]>]{1,4}&&fill?","border-image-source":"none|<image>","border-image-width":"[<length-percentage [0,∞]>|<number [0,∞]>|auto]{1,4}","border-inline":"<'border-block-start'>","border-inline-color":"<'border-top-color'>{1,2}","border-inline-end":"<'border-top-width'>||<'border-top-style'>||<color>","border-inline-end-color":"<'border-top-color'>","border-inline-end-style":"<'border-top-style'>","border-inline-end-width":"<'border-top-width'>","border-inline-start":"<'border-top-width'>||<'border-top-style'>||<color>","border-inline-start-color":"<'border-top-color'>","border-inline-start-style":"<'border-top-style'>","border-inline-start-width":"<'border-top-width'>","border-inline-style":"<'border-top-style'>{1,2}","border-inline-width":"<'border-top-width'>{1,2}","border-left":"<line-width>||<line-style>||<color>","border-left-color":"<color>","border-left-style":"<line-style>","border-left-width":"<line-width>","border-radius":"<length-percentage [0,∞]>{1,4} [/ <length-percentage [0,∞]>{1,4}]?","border-right":"<line-width>||<line-style>||<color>","border-right-color":"<color>","border-right-style":"<line-style>","border-right-width":"<line-width>","border-spacing":"<length>{1,2}","border-start-end-radius":"<'border-top-left-radius'>","border-start-start-radius":"<'border-top-left-radius'>","border-style":"<line-style>{1,4}","border-top":"<line-width>||<line-style>||<color>","border-top-color":"<color>","border-top-left-radius":"<length-percentage [0,∞]>{1,2}","border-top-right-radius":"<length-percentage [0,∞]>{1,2}","border-top-style":"<line-style>","border-top-width":"<line-width>","border-width":"<line-width>{1,4}",bottom:"auto|<length-percentage>|<anchor()>|<anchor-size()>","box-align":"start|center|end|baseline|stretch","box-decoration-break":"slice|clone","box-direction":"normal|reverse|inherit","box-flex":"<number>","box-flex-group":"<integer>","box-lines":"single|multiple","box-ordinal-group":"<integer>","box-orient":"horizontal|vertical|inline-axis|block-axis|inherit","box-pack":"start|center|end|justify","box-shadow":"none|<shadow>#","box-sizing":"content-box|border-box","break-after":"auto|avoid|always|all|avoid-page|page|left|right|recto|verso|avoid-column|column|avoid-region|region","break-before":"auto|avoid|always|all|avoid-page|page|left|right|recto|verso|avoid-column|column|avoid-region|region","break-inside":"auto|avoid|avoid-page|avoid-column|avoid-region","caption-side":"top|bottom",caret:"<'caret-color'>||<'caret-animation'>||<'caret-shape'>","caret-animation":"auto|manual","caret-color":"auto|<color>","caret-shape":"auto|bar|block|underscore",clear:"none|left|right|both|inline-start|inline-end",clip:"<shape>|auto","clip-path":"<clip-source>|[<basic-shape>||<geometry-box>]|none","clip-rule":"nonzero|evenodd",color:"<color>","color-interpolation-filters":"auto|sRGB|linearRGB","color-scheme":"normal|[light|dark|<custom-ident>]+&&only?","column-count":"<integer>|auto","column-fill":"auto|balance","column-gap":"normal|<length-percentage>","column-height":"auto|<length [0,∞]>","column-rule":"<'column-rule-width'>||<'column-rule-style'>||<'column-rule-color'>","column-rule-color":"<color>","column-rule-style":"<'border-style'>","column-rule-width":"<'border-width'>","column-span":"none|all","column-width":"auto|<length [0,∞]>","column-wrap":"auto|nowrap|wrap",columns:"[<'column-width'>||<'column-count'>] [/ <'column-height'>]?",contain:"none|strict|content|[[size||inline-size]||layout||style||paint]","contain-intrinsic-block-size":"auto? [none|<length>]","contain-intrinsic-height":"auto? [none|<length>]","contain-intrinsic-inline-size":"auto? [none|<length>]","contain-intrinsic-size":"[auto? [none|<length>]]{1,2}","contain-intrinsic-width":"auto? [none|<length>]",container:"<'container-name'> [/ <'container-type'>]?","container-name":"none|<custom-ident>+","container-type":"normal||[size|inline-size]",content:"normal|none|[<content-replacement>|<content-list>] [/ [<string>|<counter>|<attr()>]+]?","content-visibility":"visible|auto|hidden","corner-block-end-shape":"<corner-shape-value>{1,2}","corner-block-start-shape":"<corner-shape-value>{1,2}","corner-bottom-shape":"<corner-shape-value>{1,2}","corner-bottom-left-shape":"<corner-shape-value>","corner-bottom-right-shape":"<corner-shape-value>","corner-end-end-shape":"<corner-shape-value>","corner-end-start-shape":"<corner-shape-value>","corner-inline-end-shape":"<corner-shape-value>{1,2}","corner-inline-start-shape":"<corner-shape-value>{1,2}","corner-left-shape":"<corner-shape-value>{1,2}","corner-right-shape":"<corner-shape-value>{1,2}","corner-shape":"<corner-shape-value>{1,4}","corner-start-start-shape":"<corner-shape-value>","corner-start-end-shape":"<corner-shape-value>","corner-top-shape":"<corner-shape-value>{1,2}","corner-top-left-shape":"<corner-shape-value>","corner-top-right-shape":"<corner-shape-value>","counter-increment":"[<counter-name> <integer>?]+|none","counter-reset":"[<counter-name> <integer>?|<reversed-counter-name> <integer>?]+|none","counter-set":"[<counter-name> <integer>?]+|none",cursor:"[[<url> [<x> <y>]? ,]* [auto|default|none|context-menu|help|pointer|progress|wait|cell|crosshair|text|vertical-text|alias|copy|move|no-drop|not-allowed|e-resize|n-resize|ne-resize|nw-resize|s-resize|se-resize|sw-resize|w-resize|ew-resize|ns-resize|nesw-resize|nwse-resize|col-resize|row-resize|all-scroll|zoom-in|zoom-out|grab|grabbing|hand|-webkit-grab|-webkit-grabbing|-webkit-zoom-in|-webkit-zoom-out|-moz-grab|-moz-grabbing|-moz-zoom-in|-moz-zoom-out]]",cx:"<length>|<percentage>",cy:"<length>|<percentage>",d:"none|path( <string> )",direction:"ltr|rtl",display:"[<display-outside>||<display-inside>]|<display-listitem>|<display-internal>|<display-box>|<display-legacy>|<-non-standard-display>","dominant-baseline":"auto|use-script|no-change|reset-size|ideographic|alphabetic|hanging|mathematical|central|middle|text-after-edge|text-before-edge","dynamic-range-limit":"standard|no-limit|constrained|<dynamic-range-limit-mix()>","empty-cells":"show|hide","field-sizing":"content|fixed",fill:"<paint>","fill-opacity":"<number-zero-one>|<percentage>","fill-rule":"nonzero|evenodd",filter:"none|<filter-value-list>|<-ms-filter-function-list>",flex:"none|[<'flex-grow'> <'flex-shrink'>?||<'flex-basis'>]","flex-basis":"content|<'width'>","flex-direction":"row|row-reverse|column|column-reverse","flex-flow":"<'flex-direction'>||<'flex-wrap'>","flex-grow":"<number>","flex-shrink":"<number>","flex-wrap":"nowrap|wrap|wrap-reverse",float:"left|right|none|inline-start|inline-end","flood-color":"<color>","flood-opacity":"<'opacity'>",font:"[[<'font-style'>||<font-variant-css2>||<'font-weight'>||<font-width-css3>]? <'font-size'> [/ <'line-height'>]? <'font-family'>#]|<system-family-name>|<-non-standard-font>","font-family":"[<family-name>|<generic-family>]#","font-feature-settings":"normal|<feature-tag-value>#","font-kerning":"auto|normal|none","font-language-override":"normal|<string>","font-optical-sizing":"auto|none","font-palette":"normal|light|dark|<palette-identifier>|<palette-mix()>","font-size":"<absolute-size>|<relative-size>|<length-percentage [0,∞]>|math","font-size-adjust":"none|[ex-height|cap-height|ch-width|ic-width|ic-height]? [from-font|<number>]","font-smooth":"auto|never|always|<absolute-size>|<length>","font-stretch":"<font-stretch-absolute>","font-style":"normal|italic|oblique <angle>?","font-synthesis":"none|[weight||style||small-caps||position]","font-synthesis-position":"auto|none","font-synthesis-small-caps":"auto|none","font-synthesis-style":"auto|none","font-synthesis-weight":"auto|none","font-variant":"normal|none|[<common-lig-values>||<discretionary-lig-values>||<historical-lig-values>||<contextual-alt-values>||stylistic( <feature-value-name> )||historical-forms||styleset( <feature-value-name># )||character-variant( <feature-value-name># )||swash( <feature-value-name> )||ornaments( <feature-value-name> )||annotation( <feature-value-name> )||[small-caps|all-small-caps|petite-caps|all-petite-caps|unicase|titling-caps]||<numeric-figure-values>||<numeric-spacing-values>||<numeric-fraction-values>||ordinal||slashed-zero||<east-asian-variant-values>||<east-asian-width-values>||ruby]","font-variant-alternates":"normal|[stylistic( <feature-value-name> )||historical-forms||styleset( <feature-value-name># )||character-variant( <feature-value-name># )||swash( <feature-value-name> )||ornaments( <feature-value-name> )||annotation( <feature-value-name> )]","font-variant-caps":"normal|small-caps|all-small-caps|petite-caps|all-petite-caps|unicase|titling-caps","font-variant-east-asian":"normal|[<east-asian-variant-values>||<east-asian-width-values>||ruby]","font-variant-emoji":"normal|text|emoji|unicode","font-variant-ligatures":"normal|none|[<common-lig-values>||<discretionary-lig-values>||<historical-lig-values>||<contextual-alt-values>]","font-variant-numeric":"normal|[<numeric-figure-values>||<numeric-spacing-values>||<numeric-fraction-values>||ordinal||slashed-zero]","font-variant-position":"normal|sub|super","font-variation-settings":"normal|[<string> <number>]#","font-weight":"<font-weight-absolute>|bolder|lighter","font-width":"normal|<percentage [0,∞]>|ultra-condensed|extra-condensed|condensed|semi-condensed|semi-expanded|expanded|extra-expanded|ultra-expanded","forced-color-adjust":"auto|none|preserve-parent-color",gap:"<'row-gap'> <'column-gap'>?",grid:"<'grid-template'>|<'grid-template-rows'> / [auto-flow&&dense?] <'grid-auto-columns'>?|[auto-flow&&dense?] <'grid-auto-rows'>? / <'grid-template-columns'>","grid-area":"<grid-line> [/ <grid-line>]{0,3}","grid-auto-columns":"<track-size>+","grid-auto-flow":"[row|column]||dense","grid-auto-rows":"<track-size>+","grid-column":"<grid-line> [/ <grid-line>]?","grid-column-end":"<grid-line>","grid-column-gap":"<length-percentage>","grid-column-start":"<grid-line>","grid-gap":"<'grid-row-gap'> <'grid-column-gap'>?","grid-row":"<grid-line> [/ <grid-line>]?","grid-row-end":"<grid-line>","grid-row-gap":"<length-percentage>","grid-row-start":"<grid-line>","grid-template":"none|[<'grid-template-rows'> / <'grid-template-columns'>]|[<line-names>? <string> <track-size>? <line-names>?]+ [/ <explicit-track-list>]?","grid-template-areas":"none|<string>+","grid-template-columns":"none|<track-list>|<auto-track-list>|subgrid <line-name-list>?","grid-template-rows":"none|<track-list>|<auto-track-list>|subgrid <line-name-list>?","hanging-punctuation":"none|[first||[force-end|allow-end]||last]",height:"auto|<length-percentage [0,∞]>|min-content|max-content|fit-content|fit-content( <length-percentage [0,∞]> )|<calc-size()>|<anchor-size()>|stretch|<-non-standard-size>","hyphenate-character":"auto|<string>","hyphenate-limit-chars":"[auto|<integer>]{1,3}",hyphens:"none|manual|auto","image-orientation":"from-image|<angle>|[<angle>? flip]","image-rendering":"auto|crisp-edges|pixelated|smooth|optimizeSpeed|optimizeQuality|<-non-standard-image-rendering>","image-resolution":"[from-image||<resolution>]&&snap?","ime-mode":"auto|normal|active|inactive|disabled","initial-letter":"normal|[<number> <integer>?]","initial-letter-align":"[auto|alphabetic|hanging|ideographic]","inline-size":"<'width'>",inset:"<'top'>{1,4}","inset-block":"<'top'>{1,2}","inset-block-end":"<'top'>","inset-block-start":"<'top'>","inset-inline":"<'top'>{1,2}","inset-inline-end":"<'top'>","inset-inline-start":"<'top'>","interpolate-size":"numeric-only|allow-keywords",isolation:"auto|isolate",interactivity:"auto|inert","interest-delay":"<'interest-delay-start'>{1,2}","interest-delay-end":"normal|<time>","interest-delay-start":"normal|<time>","justify-content":"normal|<content-distribution>|<overflow-position>? [<content-position>|left|right]","justify-items":"normal|stretch|<baseline-position>|<overflow-position>? [<self-position>|left|right]|legacy|legacy&&[left|right|center]|anchor-center","justify-self":"auto|normal|stretch|<baseline-position>|<overflow-position>? [<self-position>|left|right]|anchor-center","justify-tracks":"[normal|<content-distribution>|<overflow-position>? [<content-position>|left|right]]#",left:"auto|<length-percentage>|<anchor()>|<anchor-size()>","letter-spacing":"normal|<length-percentage>","lighting-color":"<color>","line-break":"auto|loose|normal|strict|anywhere","line-clamp":"none|<integer>","line-height":"normal|<number>|<length>|<percentage>","line-height-step":"<length>","list-style":"<'list-style-type'>||<'list-style-position'>||<'list-style-image'>","list-style-image":"<image>|none","list-style-position":"inside|outside","list-style-type":"<counter-style>|<string>|none",margin:"<'margin-top'>{1,4}","margin-block":"<'margin-top'>{1,2}","margin-block-end":"<'margin-top'>","margin-block-start":"<'margin-top'>","margin-bottom":"<length-percentage>|auto|<anchor-size()>","margin-inline":"<'margin-top'>{1,2}","margin-inline-end":"<'margin-top'>","margin-inline-start":"<'margin-top'>","margin-left":"<length-percentage>|auto|<anchor-size()>","margin-right":"<length-percentage>|auto|<anchor-size()>","margin-top":"<length-percentage>|auto|<anchor-size()>","margin-trim":"none|in-flow|all",marker:"none|<url>","marker-end":"none|<url>","marker-mid":"none|<url>","marker-start":"none|<url>",mask:"<mask-layer>#","mask-border":"<'mask-border-source'>||<'mask-border-slice'> [/ <'mask-border-width'>? [/ <'mask-border-outset'>]?]?||<'mask-border-repeat'>||<'mask-border-mode'>","mask-border-mode":"luminance|alpha","mask-border-outset":"[<length>|<number>]{1,4}","mask-border-repeat":"[stretch|repeat|round|space]{1,2}","mask-border-slice":"<number-percentage>{1,4} fill?","mask-border-source":"none|<image>","mask-border-width":"[<length-percentage>|<number>|auto]{1,4}","mask-clip":"[<coord-box>|no-clip]#","mask-composite":"<compositing-operator>#","mask-image":"<mask-reference>#","mask-mode":"<masking-mode>#","mask-origin":"<coord-box>#","mask-position":"<position>#","mask-repeat":"<repeat-style>#","mask-size":"<bg-size>#","mask-type":"luminance|alpha","masonry-auto-flow":"[pack|next]||[definite-first|ordered]","math-depth":"auto-add|add( <integer> )|<integer>","math-shift":"normal|compact","math-style":"normal|compact","max-block-size":"<'max-width'>","max-height":"none|<length-percentage [0,∞]>|min-content|max-content|fit-content|fit-content( <length-percentage [0,∞]> )|<calc-size()>|<anchor-size()>|stretch|<-non-standard-size>","max-inline-size":"<'max-width'>","max-lines":"none|<integer>","max-width":"none|<length-percentage [0,∞]>|min-content|max-content|fit-content|fit-content( <length-percentage [0,∞]> )|<calc-size()>|<anchor-size()>|stretch|<-non-standard-size>","min-block-size":"<'min-width'>","min-height":"auto|<length-percentage [0,∞]>|min-content|max-content|fit-content|fit-content( <length-percentage [0,∞]> )|<calc-size()>|<anchor-size()>|stretch|<-non-standard-size>","min-inline-size":"<'min-width'>","min-width":"auto|<length-percentage [0,∞]>|min-content|max-content|fit-content|fit-content( <length-percentage [0,∞]> )|<calc-size()>|<anchor-size()>|stretch|<-non-standard-size>","mix-blend-mode":"<blend-mode>|plus-darker|plus-lighter","object-fit":"fill|contain|cover|none|scale-down","object-position":"<position>","object-view-box":"none|<basic-shape-rect>",offset:"[<'offset-position'>? [<'offset-path'> [<'offset-distance'>||<'offset-rotate'>]?]?]! [/ <'offset-anchor'>]?","offset-anchor":"auto|<position>","offset-distance":"<length-percentage>","offset-path":"none|<offset-path>||<coord-box>","offset-position":"normal|auto|<position>","offset-rotate":"[auto|reverse]||<angle>",opacity:"<opacity-value>",order:"<integer>",orphans:"<integer>",outline:"<'outline-width'>||<'outline-style'>||<'outline-color'>","outline-color":"auto|<color>","outline-offset":"<length>","outline-style":"auto|<outline-line-style>","outline-width":"<line-width>",overflow:"[visible|hidden|clip|scroll|auto]{1,2}|<-non-standard-overflow>","overflow-anchor":"auto|none","overflow-block":"visible|hidden|clip|scroll|auto|<-non-standard-overflow>","overflow-clip-box":"padding-box|content-box","overflow-clip-margin":"<visual-box>||<length [0,∞]>","overflow-inline":"visible|hidden|clip|scroll|auto|<-non-standard-overflow>","overflow-wrap":"normal|break-word|anywhere","overflow-x":"visible|hidden|clip|scroll|auto|<-non-standard-overflow>","overflow-y":"visible|hidden|clip|scroll|auto|<-non-standard-overflow>",overlay:"none|auto","overscroll-behavior":"[contain|none|auto]{1,2}","overscroll-behavior-block":"contain|none|auto","overscroll-behavior-inline":"contain|none|auto","overscroll-behavior-x":"contain|none|auto","overscroll-behavior-y":"contain|none|auto",padding:"<'padding-top'>{1,4}","padding-block":"<'padding-top'>{1,2}","padding-block-end":"<'padding-top'>","padding-block-start":"<'padding-top'>","padding-bottom":"<length-percentage [0,∞]>","padding-inline":"<'padding-top'>{1,2}","padding-inline-end":"<'padding-top'>","padding-inline-start":"<'padding-top'>","padding-left":"<length-percentage [0,∞]>","padding-right":"<length-percentage [0,∞]>","padding-top":"<length-percentage [0,∞]>",page:"auto|<custom-ident>","page-break-after":"auto|always|avoid|left|right|recto|verso","page-break-before":"auto|always|avoid|left|right|recto|verso","page-break-inside":"auto|avoid","paint-order":"normal|[fill||stroke||markers]",perspective:"none|<length>","perspective-origin":"<position>","place-content":"<'align-content'> <'justify-content'>?","place-items":"<'align-items'> <'justify-items'>?","place-self":"<'align-self'> <'justify-self'>?","pointer-events":"auto|none|visiblePainted|visibleFill|visibleStroke|visible|painted|fill|stroke|all|inherit",position:"static|relative|absolute|sticky|fixed|-webkit-sticky","position-anchor":"auto|none|<anchor-name>","position-area":"none|<position-area>","position-try":"<'position-try-order'>? <'position-try-fallbacks'>","position-try-fallbacks":"none|[[<dashed-ident>||<try-tactic>]|<'position-area'>]#","position-try-order":"normal|<try-size>","position-visibility":"always|[anchors-valid||anchors-visible||no-overflow]","print-color-adjust":"economy|exact",quotes:"none|auto|[<string> <string>]+",r:"<length>|<percentage>","reading-flow":"normal|source-order|flex-visual|flex-flow|grid-rows|grid-columns|grid-order","reading-order":"<integer>",resize:"none|both|horizontal|vertical|block|inline",right:"auto|<length-percentage>|<anchor()>|<anchor-size()>",rotate:"none|<angle>|[x|y|z|<number>{3}]&&<angle>","row-gap":"normal|<length-percentage>","ruby-align":"start|center|space-between|space-around","ruby-merge":"separate|collapse|auto","ruby-overhang":"auto|none","ruby-position":"[alternate||[over|under]]|inter-character",rx:"<length>|<percentage>",ry:"<length>|<percentage>",scale:"none|[<number>|<percentage>]{1,3}","scroll-behavior":"auto|smooth","scroll-initial-target":"none|nearest","scroll-margin":"<length>{1,4}","scroll-margin-block":"<length>{1,2}","scroll-margin-block-end":"<length>","scroll-margin-block-start":"<length>","scroll-margin-bottom":"<length>","scroll-margin-inline":"<length>{1,2}","scroll-margin-inline-end":"<length>","scroll-margin-inline-start":"<length>","scroll-margin-left":"<length>","scroll-margin-right":"<length>","scroll-margin-top":"<length>","scroll-marker-group":"none|before|after","scroll-padding":"[auto|<length-percentage>]{1,4}","scroll-padding-block":"[auto|<length-percentage>]{1,2}","scroll-padding-block-end":"auto|<length-percentage>","scroll-padding-block-start":"auto|<length-percentage>","scroll-padding-bottom":"auto|<length-percentage>","scroll-padding-inline":"[auto|<length-percentage>]{1,2}","scroll-padding-inline-end":"auto|<length-percentage>","scroll-padding-inline-start":"auto|<length-percentage>","scroll-padding-left":"auto|<length-percentage>","scroll-padding-right":"auto|<length-percentage>","scroll-padding-top":"auto|<length-percentage>","scroll-snap-align":"[none|start|end|center]{1,2}","scroll-snap-coordinate":"none|<position>#","scroll-snap-destination":"<position>","scroll-snap-points-x":"none|repeat( <length-percentage> )","scroll-snap-points-y":"none|repeat( <length-percentage> )","scroll-snap-stop":"normal|always","scroll-snap-type":"none|[x|y|block|inline|both] [mandatory|proximity]?","scroll-snap-type-x":"none|mandatory|proximity","scroll-snap-type-y":"none|mandatory|proximity","scroll-target-group":"none|auto","scroll-timeline":"[<'scroll-timeline-name'> <'scroll-timeline-axis'>?]#","scroll-timeline-axis":"[block|inline|x|y]#","scroll-timeline-name":"[none|<dashed-ident>]#","scrollbar-color":"auto|<color>{2}","scrollbar-gutter":"auto|stable&&both-edges?","scrollbar-width":"auto|thin|none","shape-image-threshold":"<opacity-value>","shape-margin":"<length-percentage>","shape-outside":"none|[<shape-box>||<basic-shape>]|<image>","shape-rendering":"auto|optimizeSpeed|crispEdges|geometricPrecision","speak-as":"normal|spell-out||digits||[literal-punctuation|no-punctuation]","stop-color":"<'color'>","stop-opacity":"<'opacity'>",stroke:"<paint>","stroke-color":"<color>","stroke-dasharray":"none|[<svg-length>+]#","stroke-dashoffset":"<svg-length>","stroke-linecap":"butt|round|square","stroke-linejoin":"miter|round|bevel","stroke-miterlimit":"<number-one-or-greater>","stroke-opacity":"<'opacity'>","stroke-width":"<svg-length>","tab-size":"<integer>|<length>","table-layout":"auto|fixed","text-align":"start|end|left|right|center|justify|match-parent","text-align-last":"auto|start|end|left|right|center|justify","text-anchor":"start|middle|end","text-autospace":"normal|<autospace>|auto","text-box":"normal|<'text-box-trim'>||<'text-box-edge'>","text-box-edge":"auto|<text-edge>","text-box-trim":"none|trim-start|trim-end|trim-both","text-combine-upright":"none|all|[digits <integer>?]","text-decoration":"<'text-decoration-line'>||<'text-decoration-style'>||<'text-decoration-color'>||<'text-decoration-thickness'>","text-decoration-color":"<color>","text-decoration-inset":"<length>{1,2}|auto","text-decoration-line":"none|[underline||overline||line-through||blink]|spelling-error|grammar-error","text-decoration-skip":"none|[objects||[spaces|[leading-spaces||trailing-spaces]]||edges||box-decoration]","text-decoration-skip-ink":"auto|all|none","text-decoration-style":"solid|double|dotted|dashed|wavy","text-decoration-thickness":"auto|from-font|<length>|<percentage>","text-emphasis":"<'text-emphasis-style'>||<'text-emphasis-color'>","text-emphasis-color":"<color>","text-emphasis-position":"auto|[over|under]&&[right|left]?","text-emphasis-style":"none|[[filled|open]||[dot|circle|double-circle|triangle|sesame]]|<string>","text-indent":"<length-percentage>&&hanging?&&each-line?","text-justify":"auto|inter-character|inter-word|none","text-orientation":"mixed|upright|sideways","text-overflow":"[clip|ellipsis|<string>]{1,2}","text-rendering":"auto|optimizeSpeed|optimizeLegibility|geometricPrecision","text-shadow":"none|<shadow-t>#","text-size-adjust":"none|auto|<percentage>","text-spacing-trim":"space-all|normal|space-first|trim-start","text-transform":"none|[capitalize|uppercase|lowercase]||full-width||full-size-kana|math-auto","text-underline-offset":"auto|<length>|<percentage>","text-underline-position":"auto|from-font|[under||[left|right]]","text-wrap":"<'text-wrap-mode'>||<'text-wrap-style'>","text-wrap-mode":"wrap|nowrap","text-wrap-style":"auto|balance|stable|pretty","timeline-scope":"none|<dashed-ident>#","timeline-trigger":"none|[<'timeline-trigger-name'> <'timeline-trigger-source'> <'timeline-trigger-range'> ['/' <'timeline-trigger-exit-range'>]?]#","timeline-trigger-name":"none|<dashed-ident>#","timeline-trigger-exit-range":"[<'timeline-trigger-exit-range-start'> <'timeline-trigger-exit-range-end'>?]#","timeline-trigger-exit-range-end":"[auto|normal|<length-percentage>|<timeline-range-name> <length-percentage>?]#","timeline-trigger-exit-range-start":"[auto|normal|<length-percentage>|<timeline-range-name> <length-percentage>?]#","timeline-trigger-range":"[<'timeline-trigger-range-start'> <'timeline-trigger-range-end'>?]#","timeline-trigger-range-end":"[normal|<length-percentage>|<timeline-range-name> <length-percentage>?]#","timeline-trigger-range-start":"[normal|<length-percentage>|<timeline-range-name> <length-percentage>?]#","timeline-trigger-source":"<single-animation-timeline>#",top:"auto|<length-percentage>|<anchor()>|<anchor-size()>","touch-action":"auto|none|[[pan-x|pan-left|pan-right]||[pan-y|pan-up|pan-down]||pinch-zoom]|manipulation",transform:"none|<transform-list>","transform-box":"content-box|border-box|fill-box|stroke-box|view-box","transform-origin":"[<length-percentage>|left|center|right|top|bottom]|[[<length-percentage>|left|center|right]&&[<length-percentage>|top|center|bottom]] <length>?","transform-style":"flat|preserve-3d",transition:"<single-transition>#","transition-behavior":"<transition-behavior-value>#","transition-delay":"<time>#","transition-duration":"<time>#","transition-property":"none|<single-transition-property>#","transition-timing-function":"<easing-function>#",translate:"none|<length-percentage> [<length-percentage> <length>?]?","trigger-scope":"none|all|<dashed-ident>#","unicode-bidi":"normal|embed|isolate|bidi-override|isolate-override|plaintext|-moz-isolate|-moz-isolate-override|-moz-plaintext|-webkit-isolate|-webkit-isolate-override|-webkit-plaintext","user-select":"auto|text|none|all","vector-effect":"none|non-scaling-stroke|non-scaling-size|non-rotation|fixed-position","vertical-align":"baseline|sub|super|text-top|text-bottom|middle|top|bottom|<percentage>|<length>","view-timeline":"[<'view-timeline-name'> [<'view-timeline-axis'>||<'view-timeline-inset'>]?]#","view-timeline-axis":"[block|inline|x|y]#","view-timeline-inset":"[[auto|<length-percentage>]{1,2}]#","view-timeline-name":"[none|<dashed-ident>]#","view-transition-class":"none|<custom-ident>+","view-transition-name":"none|<custom-ident>|match-element",visibility:"visible|hidden|collapse","white-space":"normal|pre|pre-wrap|pre-line|<'white-space-collapse'>||<'text-wrap-mode'>","white-space-collapse":"collapse|preserve|preserve-breaks|preserve-spaces|break-spaces",widows:"<integer>",width:"auto|<length-percentage [0,∞]>|min-content|max-content|fit-content|fit-content( <length-percentage [0,∞]> )|<calc-size()>|<anchor-size()>|stretch|<-non-standard-size>","will-change":"auto|<animateable-feature>#","word-break":"normal|break-all|keep-all|break-word|auto-phrase","word-spacing":"normal|<length>","word-wrap":"normal|break-word","writing-mode":"horizontal-tb|vertical-rl|vertical-lr|sideways-rl|sideways-lr|<svg-writing-mode>",x:"<length>|<percentage>",y:"<length>|<percentage>","z-index":"auto|<integer>",zoom:"normal|reset|<number [0,∞]>||<percentage [0,∞]>","-moz-background-clip":"padding|border","-moz-border-radius-bottomleft":"<'border-bottom-left-radius'>","-moz-border-radius-bottomright":"<'border-bottom-right-radius'>","-moz-border-radius-topleft":"<'border-top-left-radius'>","-moz-border-radius-topright":"<'border-bottom-right-radius'>","-moz-control-character-visibility":"visible|hidden","-moz-osx-font-smoothing":"auto|grayscale","-moz-user-select":"none|text|all|-moz-none","-ms-flex-align":"start|end|center|baseline|stretch","-ms-flex-item-align":"auto|start|end|center|baseline|stretch","-ms-flex-line-pack":"start|end|center|justify|distribute|stretch","-ms-flex-negative":"<'flex-shrink'>","-ms-flex-pack":"start|end|center|justify|distribute","-ms-flex-order":"<integer>","-ms-flex-positive":"<'flex-grow'>","-ms-flex-preferred-size":"<'flex-basis'>","-ms-interpolation-mode":"nearest-neighbor|bicubic","-ms-grid-column-align":"start|end|center|stretch","-ms-grid-row-align":"start|end|center|stretch","-ms-hyphenate-limit-last":"none|always|column|page|spread","-webkit-background-clip":"[<visual-box>|border|padding|content|text]#","-webkit-column-break-after":"always|auto|avoid","-webkit-column-break-before":"always|auto|avoid","-webkit-column-break-inside":"always|auto|avoid","-webkit-font-smoothing":"auto|none|antialiased|subpixel-antialiased","-webkit-mask-box-image":"[<url>|<gradient>|none] [<length-percentage>{4} <-webkit-mask-box-repeat>{2}]?","-webkit-print-color-adjust":"economy|exact","-webkit-text-security":"none|circle|disc|square","-webkit-user-drag":"none|element|auto",behavior:"<url>+",cue:"<'cue-before'> <'cue-after'>?","cue-after":"<url> <decibel>?|none","cue-before":"<url> <decibel>?|none","glyph-orientation-horizontal":"<angle>","glyph-orientation-vertical":"<angle>",kerning:"auto|<svg-length>",pause:"<'pause-before'> <'pause-after'>?","pause-after":"<time>|none|x-weak|weak|medium|strong|x-strong","pause-before":"<time>|none|x-weak|weak|medium|strong|x-strong","position-try-options":"<'position-try-fallbacks'>",rest:"<'rest-before'> <'rest-after'>?","rest-after":"<time>|none|x-weak|weak|medium|strong|x-strong","rest-before":"<time>|none|x-weak|weak|medium|strong|x-strong",speak:"auto|never|always","voice-balance":"<number>|left|center|right|leftwards|rightwards","voice-duration":"auto|<time>","voice-family":"[[<family-name>|<generic-voice>] ,]* [<family-name>|<generic-voice>]|preserve","voice-pitch":"<frequency>&&absolute|[[x-low|low|medium|high|x-high]||[<frequency>|<semitones>|<percentage>]]","voice-range":"<frequency>&&absolute|[[x-low|low|medium|high|x-high]||[<frequency>|<semitones>|<percentage>]]","voice-rate":"[normal|x-slow|slow|medium|fast|x-fast]||<percentage>","voice-stress":"normal|strong|moderate|none|reduced","voice-volume":"silent|[[x-soft|soft|medium|loud|x-loud]||<decibel>]","white-space-trim":"none|discard-before||discard-after||discard-inner"},atrules:{charset:{prelude:"<string>",descriptors:null},"counter-style":{prelude:"<counter-style-name>",descriptors:{"additive-symbols":"[<integer [0,∞]>&&<symbol>]#",fallback:"<counter-style-name>",negative:"<symbol> <symbol>?",pad:"<integer [0,∞]>&&<symbol>",prefix:"<symbol>",range:"[[<integer>|infinite]{2}]#|auto","speak-as":"auto|bullets|numbers|words|spell-out|<counter-style-name>",suffix:"<symbol>",symbols:"<symbol>+",system:"cyclic|numeric|alphabetic|symbolic|additive|[fixed <integer>?]|[extends <counter-style-name>]"}},container:{prelude:"[<container-name>]? <container-condition>",descriptors:null},document:{prelude:"[<url>|url-prefix( <string> )|domain( <string> )|media-document( <string> )|regexp( <string> )]#",descriptors:null},"font-face":{prelude:null,descriptors:{"ascent-override":"normal|<percentage>","descent-override":"normal|<percentage>","font-display":"auto|block|swap|fallback|optional","font-family":"<family-name>","font-feature-settings":"normal|<feature-tag-value>#","font-stretch":"<font-stretch-absolute>{1,2}","font-style":"normal|italic|oblique <angle>{0,2}","font-variation-settings":"normal|[<string> <number>]#","font-weight":"<font-weight-absolute>{1,2}","line-gap-override":"normal|<percentage>","size-adjust":"<percentage>",src:"[<url> [format( <string># )]?|local( <family-name> )]#","unicode-range":"<urange>#"}},"font-feature-values":{prelude:"<family-name>#",descriptors:null},"font-palette-values":{prelude:"<dashed-ident>",descriptors:{"base-palette":"light|dark|<integer [0,∞]>","font-family":"<family-name>#","override-colors":"[<integer [0,∞]> <color>]#"}},import:{prelude:"[<string>|<url>] [layer|layer( <layer-name> )]? [supports( [<supports-condition>|<declaration>] )]? <media-query-list>?",descriptors:null},keyframes:{prelude:"<keyframes-name>",descriptors:null},layer:{prelude:"[<layer-name>#|<layer-name>?]",descriptors:null},media:{prelude:"<media-query-list>",descriptors:null},namespace:{prelude:"<namespace-prefix>? [<string>|<url>]",descriptors:null},page:{prelude:"<page-selector-list>",descriptors:{bleed:"auto|<length>",marks:"none|[crop||cross]","page-orientation":"upright|rotate-left|rotate-right",size:"<length [0,∞]>{1,2}|auto|[<page-size>||[portrait|landscape]]"}},"position-try":{prelude:"<dashed-ident>",descriptors:{top:"<'top'>",left:"<'left'>",bottom:"<'bottom'>",right:"<'right'>","inset-block-start":"<'inset-block-start'>","inset-block-end":"<'inset-block-end'>","inset-inline-start":"<'inset-inline-start'>","inset-inline-end":"<'inset-inline-end'>","inset-block":"<'inset-block'>","inset-inline":"<'inset-inline'>",inset:"<'inset'>","margin-top":"<'margin-top'>","margin-left":"<'margin-left'>","margin-bottom":"<'margin-bottom'>","margin-right":"<'margin-right'>","margin-block-start":"<'margin-block-start'>","margin-block-end":"<'margin-block-end'>","margin-inline-start":"<'margin-inline-start'>","margin-inline-end":"<'margin-inline-end'>",margin:"<'margin'>","margin-block":"<'margin-block'>","margin-inline":"<'margin-inline'>",width:"<'width'>",height:"<'height'>","min-width":"<'min-width'>","min-height":"<'min-height'>","max-width":"<'max-width'>","max-height":"<'max-height'>","block-size":"<'block-size'>","inline-size":"<'inline-size'>","min-block-size":"<'min-block-size'>","min-inline-size":"<'min-inline-size'>","max-block-size":"<'max-block-size'>","max-inline-size":"<'max-inline-size'>","align-self":"<'align-self'>|anchor-center","justify-self":"<'justify-self'>|anchor-center"}},property:{prelude:"<custom-property-name>",descriptors:{inherits:"true|false","initial-value":"<declaration-value>?",syntax:"<string>"}},scope:{prelude:"[( <scope-start> )]? [to ( <scope-end> )]?",descriptors:null},"starting-style":{prelude:null,descriptors:null},supports:{prelude:"<supports-condition>",descriptors:null},"view-transition":{prelude:null,descriptors:{navigation:"auto|none",types:"none|<custom-ident>+"}},"font-features-values":{prelude:"[<string>|<custom-ident>]+",descriptors:{"font-display":"auto|block|swap|fallback|optional"}}}},Qs=43,is=45,Mu=110,$o=!0,ure=!1;function zu(n,e){let t=this.tokenStart+n;const s=this.charCodeAt(t);for((s===Qs||s===is)&&(e&&this.error("Number sign is not allowed"),t++);t<this.tokenEnd;t++)Sn(this.charCodeAt(t))||this.error("Integer is expected",t)}function yi(n){return zu.call(this,0,n)}function Wr(n,e){if(!this.cmpChar(this.tokenStart+n,e)){let t="";switch(e){case Mu:t="N is expected";break;case is:t="HyphenMinus is expected";break}this.error(t,this.tokenStart+n)}}function th(){let n=0,e=0,t=this.tokenType;for(;t===Tt||t===on;)t=this.lookupType(++n);if(t!==tt)if(this.isDelim(Qs,n)||this.isDelim(is,n)){e=this.isDelim(Qs,n)?Qs:is;do t=this.lookupType(++n);while(t===Tt||t===on);t!==tt&&(this.skip(n),yi.call(this,$o))}else return null;return n>0&&this.skip(n),e===0&&(t=this.charCodeAt(this.tokenStart),t!==Qs&&t!==is&&this.error("Number sign is expected")),yi.call(this,e!==0),e===is?"-"+this.consume(tt):this.consume(tt)}const dre="AnPlusB",fre={a:[String,null],b:[String,null]};function _E(){const n=this.tokenStart;let e=null,t=null;if(this.tokenType===tt)yi.call(this,ure),t=this.consume(tt);else if(this.tokenType===Ae&&this.cmpChar(this.tokenStart,is))switch(e="-1",Wr.call(this,1,Mu),this.tokenEnd-this.tokenStart){case 2:this.next(),t=th.call(this);break;case 3:Wr.call(this,2,is),this.next(),this.skipSC(),yi.call(this,$o),t="-"+this.consume(tt);break;default:Wr.call(this,2,is),zu.call(this,3,$o),this.next(),t=this.substrToCursor(n+2)}else if(this.tokenType===Ae||this.isDelim(Qs)&&this.lookupType(1)===Ae){let s=0;switch(e="1",this.isDelim(Qs)&&(s=1,this.next()),Wr.call(this,0,Mu),this.tokenEnd-this.tokenStart){case 1:this.next(),t=th.call(this);break;case 2:Wr.call(this,1,is),this.next(),this.skipSC(),yi.call(this,$o),t="-"+this.consume(tt);break;default:Wr.call(this,1,is),zu.call(this,2,$o),this.next(),t=this.substrToCursor(n+s+1)}}else if(this.tokenType===at){const s=this.charCodeAt(this.tokenStart),r=s===Qs||s===is;let o=this.tokenStart+r;for(;o<this.tokenEnd&&Sn(this.charCodeAt(o));o++);o===this.tokenStart+r&&this.error("Integer is expected",this.tokenStart+r),Wr.call(this,o-this.tokenStart,Mu),e=this.substring(n,o),o+1===this.tokenEnd?(this.next(),t=th.call(this)):(Wr.call(this,o-this.tokenStart+1,is),o+2===this.tokenEnd?(this.next(),this.skipSC(),yi.call(this,$o),t="-"+this.consume(tt)):(zu.call(this,o-this.tokenStart+2,$o),this.next(),t=this.substrToCursor(o+1)))}else this.error();return e!==null&&e.charCodeAt(0)===Qs&&(e=e.substr(1)),t!==null&&t.charCodeAt(0)===Qs&&(t=t.substr(1)),{type:"AnPlusB",loc:this.getLocation(n,this.tokenStart),a:e,b:t}}function mre(n){if(n.a){const e=n.a==="+1"&&"n"||n.a==="1"&&"n"||n.a==="-1"&&"-n"||n.a+"n";if(n.b){const t=n.b[0]==="-"||n.b[0]==="+"?n.b:"+"+n.b;this.tokenize(e+t)}else this.tokenize(e)}else this.tokenize(n.b)}const pre=Object.freeze(Object.defineProperty({__proto__:null,generate:mre,name:dre,parse:_E,structure:fre},Symbol.toStringTag,{value:"Module"}));function ZS(){return this.Raw(this.consumeUntilLeftCurlyBracketOrSemicolon,!0)}function hre(){for(let n=1,e;e=this.lookupType(n);n++){if(e===qn)return!0;if(e===an||e===Kt)return!1}return!1}const gre="Atrule",xre="atrule",bre={name:String,prelude:["AtrulePrelude","Raw",null],block:["Block",null]};function EE(n=!1){const e=this.tokenStart;let t,s,r=null,o=null;switch(this.eat(Kt),t=this.substrToCursor(e+1),s=t.toLowerCase(),this.skipSC(),this.eof===!1&&this.tokenType!==an&&this.tokenType!==Mn&&(this.parseAtrulePrelude?r=this.parseWithFallback(this.AtrulePrelude.bind(this,t,n),ZS):r=ZS.call(this,this.tokenIndex),this.skipSC()),this.tokenType){case Mn:this.next();break;case an:hasOwnProperty.call(this.atrule,s)&&typeof this.atrule[s].block=="function"?o=this.atrule[s].block.call(this,n):o=this.Block(hre.call(this));break}return{type:"Atrule",loc:this.getLocation(e,this.tokenStart),name:t,prelude:r,block:o}}function vre(n){this.token(Kt,"@"+n.name),n.prelude!==null&&this.node(n.prelude),n.block?this.node(n.block):this.token(Mn,";")}const yre=Object.freeze(Object.defineProperty({__proto__:null,generate:vre,name:gre,parse:EE,structure:bre,walkContext:xre},Symbol.toStringTag,{value:"Module"})),wre="AtrulePrelude",Sre="atrulePrelude",kre={children:[[]]};function TE(n){let e=null;return n!==null&&(n=n.toLowerCase()),this.skipSC(),hasOwnProperty.call(this.atrule,n)&&typeof this.atrule[n].prelude=="function"?e=this.atrule[n].prelude.call(this):e=this.readSequence(this.scope.AtrulePrelude),this.skipSC(),this.eof!==!0&&this.tokenType!==an&&this.tokenType!==Mn&&this.error("Semicolon or block is expected"),{type:"AtrulePrelude",loc:this.getLocationFromList(e),children:e}}function jre(n){this.children(n)}const Nre=Object.freeze(Object.defineProperty({__proto__:null,generate:jre,name:wre,parse:TE,structure:kre,walkContext:Sre},Symbol.toStringTag,{value:"Module"})),Cre=36,AE=42,Du=61,_re=94,Pg=124,Ere=126;function Tre(){this.eof&&this.error("Unexpected end of input");const n=this.tokenStart;let e=!1;return this.isDelim(AE)?(e=!0,this.next()):this.isDelim(Pg)||this.eat(Ae),this.isDelim(Pg)?this.charCodeAt(this.tokenStart+1)!==Du?(this.next(),this.eat(Ae)):e&&this.error("Identifier is expected",this.tokenEnd):e&&this.error("Vertical line is expected"),{type:"Identifier",loc:this.getLocation(n,this.tokenStart),name:this.substrToCursor(n)}}function Are(){const n=this.tokenStart,e=this.charCodeAt(n);return e!==Du&&e!==Ere&&e!==_re&&e!==Cre&&e!==AE&&e!==Pg&&this.error("Attribute selector (=, ~=, ^=, $=, *=, |=) is expected"),this.next(),e!==Du&&(this.isDelim(Du)||this.error("Equal sign is expected"),this.next()),this.substrToCursor(n)}const Pre="AttributeSelector",Ire={name:"Identifier",matcher:[String,null],value:["String","Identifier",null],flags:[String,null]};function PE(){const n=this.tokenStart;let e,t=null,s=null,r=null;return this.eat(es),this.skipSC(),e=Tre.call(this),this.skipSC(),this.tokenType!==Xn&&(this.tokenType!==Ae&&(t=Are.call(this),this.skipSC(),s=this.tokenType===cs?this.String():this.Identifier(),this.skipSC()),this.tokenType===Ae&&(r=this.consume(Ae),this.skipSC())),this.eat(Xn),{type:"AttributeSelector",loc:this.getLocation(n,this.tokenStart),name:e,matcher:t,value:s,flags:r}}function $re(n){this.token(lt,"["),this.node(n.name),n.matcher!==null&&(this.tokenize(n.matcher),this.node(n.value)),n.flags!==null&&this.token(Ae,n.flags),this.token(lt,"]")}const Rre=Object.freeze(Object.defineProperty({__proto__:null,generate:$re,name:Pre,parse:PE,structure:Ire},Symbol.toStringTag,{value:"Module"})),Ore=38;function IE(){return this.Raw(null,!0)}function YS(){return this.parseWithFallback(this.Rule,IE)}function XS(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}function Lre(){if(this.tokenType===Mn)return XS.call(this,this.tokenIndex);const n=this.parseWithFallback(this.Declaration,XS);return this.tokenType===Mn&&this.next(),n}const Mre="Block",zre="block",Dre={children:[["Atrule","Rule","Declaration"]]};function $E(n){const e=n?Lre:YS,t=this.tokenStart;let s=this.createList();this.eat(an);e:for(;!this.eof;)switch(this.tokenType){case qn:break e;case Tt:case on:this.next();break;case Kt:s.push(this.parseWithFallback(this.Atrule.bind(this,n),IE));break;default:n&&this.isDelim(Ore)?s.push(YS.call(this)):s.push(e.call(this))}return this.eof||this.eat(qn),{type:"Block",loc:this.getLocation(t,this.tokenStart),children:s}}function Fre(n){this.token(an,"{"),this.children(n,e=>{e.type==="Declaration"&&this.token(Mn,";")}),this.token(qn,"}")}const Ure=Object.freeze(Object.defineProperty({__proto__:null,generate:Fre,name:Mre,parse:$E,structure:Dre,walkContext:zre},Symbol.toStringTag,{value:"Module"})),Bre="Brackets",Wre={children:[[]]};function RE(n,e){const t=this.tokenStart;let s=null;return this.eat(es),s=n.call(this,e),this.eof||this.eat(Xn),{type:"Brackets",loc:this.getLocation(t,this.tokenStart),children:s}}function qre(n){this.token(lt,"["),this.children(n),this.token(lt,"]")}const Vre=Object.freeze(Object.defineProperty({__proto__:null,generate:qre,name:Bre,parse:RE,structure:Wre},Symbol.toStringTag,{value:"Module"})),Hre="CDC",Kre=[];function OE(){const n=this.tokenStart;return this.eat(Kn),{type:"CDC",loc:this.getLocation(n,this.tokenStart)}}function Gre(){this.token(Kn,"-->")}const Zre=Object.freeze(Object.defineProperty({__proto__:null,generate:Gre,name:Hre,parse:OE,structure:Kre},Symbol.toStringTag,{value:"Module"})),Yre="CDO",Xre=[];function LE(){const n=this.tokenStart;return this.eat(gc),{type:"CDO",loc:this.getLocation(n,this.tokenStart)}}function Jre(){this.token(gc,"<!--")}const Qre=Object.freeze(Object.defineProperty({__proto__:null,generate:Jre,name:Yre,parse:LE,structure:Xre},Symbol.toStringTag,{value:"Module"})),eoe=46,toe="ClassSelector",noe={name:String};function ME(){return this.eatDelim(eoe),{type:"ClassSelector",loc:this.getLocation(this.tokenStart-1,this.tokenEnd),name:this.consume(Ae)}}function soe(n){this.token(lt,"."),this.token(Ae,n.name)}const roe=Object.freeze(Object.defineProperty({__proto__:null,generate:soe,name:toe,parse:ME,structure:noe},Symbol.toStringTag,{value:"Module"})),ooe=43,JS=47,ioe=62,aoe=126,loe="Combinator",coe={name:String};function zE(){const n=this.tokenStart;let e;switch(this.tokenType){case Tt:e=" ";break;case lt:switch(this.charCodeAt(this.tokenStart)){case ioe:case ooe:case aoe:this.next();break;case JS:this.next(),this.eatIdent("deep"),this.eatDelim(JS);break;default:this.error("Combinator is expected")}e=this.substrToCursor(n);break}return{type:"Combinator",loc:this.getLocation(n,this.tokenStart),name:e}}function uoe(n){this.tokenize(n.name)}const doe=Object.freeze(Object.defineProperty({__proto__:null,generate:uoe,name:loe,parse:zE,structure:coe},Symbol.toStringTag,{value:"Module"})),foe=42,moe=47,poe="Comment",hoe={value:String};function DE(){const n=this.tokenStart;let e=this.tokenEnd;return this.eat(on),e-n+2>=2&&this.charCodeAt(e-2)===foe&&this.charCodeAt(e-1)===moe&&(e-=2),{type:"Comment",loc:this.getLocation(n,this.tokenStart),value:this.substring(n+2,e)}}function goe(n){this.token(on,"/*"+n.value+"*/")}const xoe=Object.freeze(Object.defineProperty({__proto__:null,generate:goe,name:poe,parse:DE,structure:hoe},Symbol.toStringTag,{value:"Module"})),boe=new Set([Ln,Je,Gr]),voe="Condition",yoe={kind:String,children:[["Identifier","Feature","FeatureFunction","FeatureRange","SupportsDeclaration"]]};function QS(n){return this.lookupTypeNonSC(1)===Ae&&boe.has(this.lookupTypeNonSC(2))?this.Feature(n):this.FeatureRange(n)}const woe={media:QS,container:QS,supports(){return this.SupportsDeclaration()}};function FE(n="media"){const e=this.createList();e:for(;!this.eof;)switch(this.tokenType){case on:case Tt:this.next();continue;case Ae:e.push(this.Identifier());break;case ft:{let t=this.parseWithFallback(()=>woe[n].call(this,n),()=>null);t||(t=this.parseWithFallback(()=>{this.eat(ft);const s=this.Condition(n);return this.eat(Je),s},()=>this.GeneralEnclosed(n))),e.push(t);break}case st:{let t=this.parseWithFallback(()=>this.FeatureFunction(n),()=>null);t||(t=this.GeneralEnclosed(n)),e.push(t);break}default:break e}return e.isEmpty&&this.error("Condition is expected"),{type:"Condition",loc:this.getLocationFromList(e),kind:n,children:e}}function Soe(n){n.children.forEach(e=>{e.type==="Condition"?(this.token(ft,"("),this.node(e),this.token(Je,")")):this.node(e)})}const koe=Object.freeze(Object.defineProperty({__proto__:null,generate:Soe,name:voe,parse:FE,structure:yoe},Symbol.toStringTag,{value:"Module"})),UE=33,joe=35,Noe=36,Coe=38,_oe=42,Eoe=43,ek=47;function Toe(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!0)}function Aoe(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!1)}function Poe(){const n=this.tokenIndex,e=this.Value();return e.type!=="Raw"&&this.eof===!1&&this.tokenType!==Mn&&this.isDelim(UE)===!1&&this.isBalanceEdge(n)===!1&&this.error(),e}const Ioe="Declaration",$oe="declaration",Roe={important:[Boolean,String],property:String,value:["Value","Raw"]};function BE(){const n=this.tokenStart,e=this.tokenIndex,t=Loe.call(this),s=h0(t),r=s?this.parseCustomProperty:this.parseValue,o=s?Aoe:Toe;let i=!1,l;this.skipSC(),this.eat(Ln);const c=this.tokenIndex;if(s||this.skipSC(),r?l=this.parseWithFallback(Poe,o):l=o.call(this,this.tokenIndex),s&&l.type==="Value"&&l.children.isEmpty){for(let u=c-this.tokenIndex;u<=0;u++)if(this.lookupType(u)===Tt){l.children.appendData({type:"WhiteSpace",loc:null,value:" "});break}}return this.isDelim(UE)&&(i=Moe.call(this),this.skipSC()),this.eof===!1&&this.tokenType!==Mn&&this.isBalanceEdge(e)===!1&&this.error(),{type:"Declaration",loc:this.getLocation(n,this.tokenStart),important:i,property:t,value:l}}function Ooe(n){this.token(Ae,n.property),this.token(Ln,":"),this.node(n.value),n.important&&(this.token(lt,"!"),this.token(Ae,n.important===!0?"important":n.important))}function Loe(){const n=this.tokenStart;if(this.tokenType===lt)switch(this.charCodeAt(this.tokenStart)){case _oe:case Noe:case Eoe:case joe:case Coe:this.next();break;case ek:this.next(),this.isDelim(ek)&&this.next();break}return this.tokenType===jt?this.eat(jt):this.eat(Ae),this.substrToCursor(n)}function Moe(){this.eat(lt),this.skipSC();const n=this.consume(Ae);return n==="important"?!0:n}const zoe=Object.freeze(Object.defineProperty({__proto__:null,generate:Ooe,name:Ioe,parse:BE,structure:Roe,walkContext:$oe},Symbol.toStringTag,{value:"Module"})),Doe=38;function nh(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}const Foe="DeclarationList",Uoe={children:[["Declaration","Atrule","Rule"]]};function WE(){const n=this.createList();for(;!this.eof;)switch(this.tokenType){case Tt:case on:case Mn:this.next();break;case Kt:n.push(this.parseWithFallback(this.Atrule.bind(this,!0),nh));break;default:this.isDelim(Doe)?n.push(this.parseWithFallback(this.Rule,nh)):n.push(this.parseWithFallback(this.Declaration,nh))}return{type:"DeclarationList",loc:this.getLocationFromList(n),children:n}}function Boe(n){this.children(n,e=>{e.type==="Declaration"&&this.token(Mn,";")})}const Woe=Object.freeze(Object.defineProperty({__proto__:null,generate:Boe,name:Foe,parse:WE,structure:Uoe},Symbol.toStringTag,{value:"Module"})),qoe="Dimension",Voe={value:String,unit:String};function qE(){const n=this.tokenStart,e=this.consumeNumber(at);return{type:"Dimension",loc:this.getLocation(n,this.tokenStart),value:e,unit:this.substring(n+e.length,this.tokenStart)}}function Hoe(n){this.token(at,n.value+n.unit)}const Koe=Object.freeze(Object.defineProperty({__proto__:null,generate:Hoe,name:qoe,parse:qE,structure:Voe},Symbol.toStringTag,{value:"Module"})),Goe=47,Zoe="Feature",Yoe={kind:String,name:String,value:["Identifier","Number","Dimension","Ratio","Function",null]};function VE(n){const e=this.tokenStart;let t,s=null;if(this.eat(ft),this.skipSC(),t=this.consume(Ae),this.skipSC(),this.tokenType!==Je){switch(this.eat(Ln),this.skipSC(),this.tokenType){case tt:this.lookupNonWSType(1)===lt?s=this.Ratio():s=this.Number();break;case at:s=this.Dimension();break;case Ae:s=this.Identifier();break;case st:s=this.parseWithFallback(()=>{const r=this.Function(this.readSequence,this.scope.Value);return this.skipSC(),this.isDelim(Goe)&&this.error(),r},()=>this.Ratio());break;default:this.error("Number, dimension, ratio or identifier is expected")}this.skipSC()}return this.eof||this.eat(Je),{type:"Feature",loc:this.getLocation(e,this.tokenStart),kind:n,name:t,value:s}}function Xoe(n){this.token(ft,"("),this.token(Ae,n.name),n.value!==null&&(this.token(Ln,":"),this.node(n.value)),this.token(Je,")")}const Joe=Object.freeze(Object.defineProperty({__proto__:null,generate:Xoe,name:Zoe,parse:VE,structure:Yoe},Symbol.toStringTag,{value:"Module"})),Qoe="FeatureFunction",eie={kind:String,feature:String,value:["Declaration","Selector"]};function tie(n,e){const s=(this.features[n]||{})[e];return typeof s!="function"&&this.error(`Unknown feature ${e}()`),s}function HE(n="unknown"){const e=this.tokenStart,t=this.consumeFunctionName(),s=tie.call(this,n,t.toLowerCase());this.skipSC();const r=this.parseWithFallback(()=>{const o=this.tokenIndex,i=s.call(this);return this.eof===!1&&this.isBalanceEdge(o)===!1&&this.error(),i},()=>this.Raw(null,!1));return this.eof||this.eat(Je),{type:"FeatureFunction",loc:this.getLocation(e,this.tokenStart),kind:n,feature:t,value:r}}function nie(n){this.token(st,n.feature+"("),this.node(n.value),this.token(Je,")")}const sie=Object.freeze(Object.defineProperty({__proto__:null,generate:nie,name:Qoe,parse:HE,structure:eie},Symbol.toStringTag,{value:"Module"})),tk=47,rie=60,nk=61,oie=62,iie="FeatureRange",aie={kind:String,left:["Identifier","Number","Dimension","Ratio","Function"],leftComparison:String,middle:["Identifier","Number","Dimension","Ratio","Function"],rightComparison:[String,null],right:["Identifier","Number","Dimension","Ratio","Function",null]};function sh(){switch(this.skipSC(),this.tokenType){case tt:return this.isDelim(tk,this.lookupOffsetNonSC(1))?this.Ratio():this.Number();case at:return this.Dimension();case Ae:return this.Identifier();case st:return this.parseWithFallback(()=>{const n=this.Function(this.readSequence,this.scope.Value);return this.skipSC(),this.isDelim(tk)&&this.error(),n},()=>this.Ratio());default:this.error("Number, dimension, ratio or identifier is expected")}}function sk(n){if(this.skipSC(),this.isDelim(rie)||this.isDelim(oie)){const e=this.source[this.tokenStart];return this.next(),this.isDelim(nk)?(this.next(),e+"="):e}if(this.isDelim(nk))return"=";this.error(`Expected ${n?'":", ':""}"<", ">", "=" or ")"`)}function KE(n="unknown"){const e=this.tokenStart;this.skipSC(),this.eat(ft);const t=sh.call(this),s=sk.call(this,t.type==="Identifier"),r=sh.call(this);let o=null,i=null;return this.lookupNonWSType(0)!==Je&&(o=sk.call(this),i=sh.call(this)),this.skipSC(),this.eat(Je),{type:"FeatureRange",loc:this.getLocation(e,this.tokenStart),kind:n,left:t,leftComparison:s,middle:r,rightComparison:o,right:i}}function lie(n){this.token(ft,"("),this.node(n.left),this.tokenize(n.leftComparison),this.node(n.middle),n.right&&(this.tokenize(n.rightComparison),this.node(n.right)),this.token(Je,")")}const cie=Object.freeze(Object.defineProperty({__proto__:null,generate:lie,name:iie,parse:KE,structure:aie},Symbol.toStringTag,{value:"Module"})),uie="Function",die="function",fie={name:String,children:[[]]};function GE(n,e){const t=this.tokenStart,s=this.consumeFunctionName(),r=s.toLowerCase();let o;return o=e.hasOwnProperty(r)?e[r].call(this,e):n.call(this,e),this.eof||this.eat(Je),{type:"Function",loc:this.getLocation(t,this.tokenStart),name:s,children:o}}function mie(n){this.token(st,n.name+"("),this.children(n),this.token(Je,")")}const pie=Object.freeze(Object.defineProperty({__proto__:null,generate:mie,name:uie,parse:GE,structure:fie,walkContext:die},Symbol.toStringTag,{value:"Module"})),hie="GeneralEnclosed",gie={kind:String,function:[String,null],children:[[]]};function ZE(n){const e=this.tokenStart;let t=null;this.tokenType===st?t=this.consumeFunctionName():this.eat(ft);const s=this.parseWithFallback(()=>{const r=this.tokenIndex,o=this.readSequence(this.scope.Value);return this.eof===!1&&this.isBalanceEdge(r)===!1&&this.error(),o},()=>this.createSingleNodeList(this.Raw(null,!1)));return this.eof||this.eat(Je),{type:"GeneralEnclosed",loc:this.getLocation(e,this.tokenStart),kind:n,function:t,children:s}}function xie(n){n.function?this.token(st,n.function+"("):this.token(ft,"("),this.children(n),this.token(Je,")")}const bie=Object.freeze(Object.defineProperty({__proto__:null,generate:xie,name:hie,parse:ZE,structure:gie},Symbol.toStringTag,{value:"Module"})),vie="XXX",yie="Hash",wie={value:String};function YE(){const n=this.tokenStart;return this.eat(jt),{type:"Hash",loc:this.getLocation(n,this.tokenStart),value:this.substrToCursor(n+1)}}function Sie(n){this.token(jt,"#"+n.value)}const kie=Object.freeze(Object.defineProperty({__proto__:null,generate:Sie,name:yie,parse:YE,structure:wie,xxx:vie},Symbol.toStringTag,{value:"Module"})),jie="Identifier",Nie={name:String};function XE(){return{type:"Identifier",loc:this.getLocation(this.tokenStart,this.tokenEnd),name:this.consume(Ae)}}function Cie(n){this.token(Ae,n.name)}const _ie=Object.freeze(Object.defineProperty({__proto__:null,generate:Cie,name:jie,parse:XE,structure:Nie},Symbol.toStringTag,{value:"Module"})),Eie="IdSelector",Tie={name:String};function JE(){const n=this.tokenStart;return this.eat(jt),{type:"IdSelector",loc:this.getLocation(n,this.tokenStart),name:this.substrToCursor(n+1)}}function Aie(n){this.token(lt,"#"+n.name)}const Pie=Object.freeze(Object.defineProperty({__proto__:null,generate:Aie,name:Eie,parse:JE,structure:Tie},Symbol.toStringTag,{value:"Module"})),Iie=46,$ie="Layer",Rie={name:String};function QE(){let n=this.tokenStart,e=this.consume(Ae);for(;this.isDelim(Iie);)this.eat(lt),e+="."+this.consume(Ae);return{type:"Layer",loc:this.getLocation(n,this.tokenStart),name:e}}function Oie(n){this.tokenize(n.name)}const Lie=Object.freeze(Object.defineProperty({__proto__:null,generate:Oie,name:$ie,parse:QE,structure:Rie},Symbol.toStringTag,{value:"Module"})),Mie="LayerList",zie={children:[["Layer"]]};function eT(){const n=this.createList();for(this.skipSC();!this.eof&&(n.push(this.Layer()),this.lookupTypeNonSC(0)===Qn);)this.skipSC(),this.next(),this.skipSC();return{type:"LayerList",loc:this.getLocationFromList(n),children:n}}function Die(n){this.children(n,()=>this.token(Qn,","))}const Fie=Object.freeze(Object.defineProperty({__proto__:null,generate:Die,name:Mie,parse:eT,structure:zie},Symbol.toStringTag,{value:"Module"})),Uie="MediaQuery",Bie={modifier:[String,null],mediaType:[String,null],condition:["Condition",null]};function tT(){const n=this.tokenStart;let e=null,t=null,s=null;if(this.skipSC(),this.tokenType===Ae&&this.lookupTypeNonSC(1)!==ft){const r=this.consume(Ae),o=r.toLowerCase();switch(o==="not"||o==="only"?(this.skipSC(),e=o,t=this.consume(Ae)):t=r,this.lookupTypeNonSC(0)){case Ae:{this.skipSC(),this.eatIdent("and"),s=this.Condition("media");break}case an:case Mn:case Qn:case Gr:break;default:this.error("Identifier or parenthesis is expected")}}else switch(this.tokenType){case Ae:case ft:case st:{s=this.Condition("media");break}case an:case Mn:case Gr:break;default:this.error("Identifier or parenthesis is expected")}return{type:"MediaQuery",loc:this.getLocation(n,this.tokenStart),modifier:e,mediaType:t,condition:s}}function Wie(n){n.mediaType?(n.modifier&&this.token(Ae,n.modifier),this.token(Ae,n.mediaType),n.condition&&(this.token(Ae,"and"),this.node(n.condition))):n.condition&&this.node(n.condition)}const qie=Object.freeze(Object.defineProperty({__proto__:null,generate:Wie,name:Uie,parse:tT,structure:Bie},Symbol.toStringTag,{value:"Module"})),Vie="MediaQueryList",Hie={children:[["MediaQuery"]]};function nT(){const n=this.createList();for(this.skipSC();!this.eof&&(n.push(this.MediaQuery()),this.tokenType===Qn);)this.next();return{type:"MediaQueryList",loc:this.getLocationFromList(n),children:n}}function Kie(n){this.children(n,()=>this.token(Qn,","))}const Gie=Object.freeze(Object.defineProperty({__proto__:null,generate:Kie,name:Vie,parse:nT,structure:Hie},Symbol.toStringTag,{value:"Module"})),Zie=38,Yie="NestingSelector",Xie={};function sT(){const n=this.tokenStart;return this.eatDelim(Zie),{type:"NestingSelector",loc:this.getLocation(n,this.tokenStart)}}function Jie(){this.token(lt,"&")}const Qie=Object.freeze(Object.defineProperty({__proto__:null,generate:Jie,name:Yie,parse:sT,structure:Xie},Symbol.toStringTag,{value:"Module"})),eae="Nth",tae={nth:["AnPlusB","Identifier"],selector:["SelectorList",null]};function rT(){this.skipSC();const n=this.tokenStart;let e=n,t=null,s;return this.lookupValue(0,"odd")||this.lookupValue(0,"even")?s=this.Identifier():s=this.AnPlusB(),e=this.tokenStart,this.skipSC(),this.lookupValue(0,"of")&&(this.next(),t=this.SelectorList(),e=this.tokenStart),{type:"Nth",loc:this.getLocation(n,e),nth:s,selector:t}}function nae(n){this.node(n.nth),n.selector!==null&&(this.token(Ae,"of"),this.node(n.selector))}const sae=Object.freeze(Object.defineProperty({__proto__:null,generate:nae,name:eae,parse:rT,structure:tae},Symbol.toStringTag,{value:"Module"})),rae="Number",oae={value:String};function oT(){return{type:"Number",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consume(tt)}}function iae(n){this.token(tt,n.value)}const aae=Object.freeze(Object.defineProperty({__proto__:null,generate:iae,name:rae,parse:oT,structure:oae},Symbol.toStringTag,{value:"Module"})),lae="Operator",cae={value:String};function iT(){const n=this.tokenStart;return this.next(),{type:"Operator",loc:this.getLocation(n,this.tokenStart),value:this.substrToCursor(n)}}function uae(n){this.tokenize(n.value)}const dae=Object.freeze(Object.defineProperty({__proto__:null,generate:uae,name:lae,parse:iT,structure:cae},Symbol.toStringTag,{value:"Module"})),fae="Parentheses",mae={children:[[]]};function aT(n,e){const t=this.tokenStart;let s=null;return this.eat(ft),s=n.call(this,e),this.eof||this.eat(Je),{type:"Parentheses",loc:this.getLocation(t,this.tokenStart),children:s}}function pae(n){this.token(ft,"("),this.children(n),this.token(Je,")")}const hae=Object.freeze(Object.defineProperty({__proto__:null,generate:pae,name:fae,parse:aT,structure:mae},Symbol.toStringTag,{value:"Module"})),gae="Percentage",xae={value:String};function lT(){return{type:"Percentage",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consumeNumber(Rt)}}function bae(n){this.token(Rt,n.value+"%")}const vae=Object.freeze(Object.defineProperty({__proto__:null,generate:bae,name:gae,parse:lT,structure:xae},Symbol.toStringTag,{value:"Module"})),yae="PseudoClassSelector",wae="function",Sae={name:String,children:[["Raw"],null]};function cT(){const n=this.tokenStart;let e=null,t,s;return this.eat(Ln),this.tokenType===st?(t=this.consumeFunctionName(),s=t.toLowerCase(),this.lookupNonWSType(0)==Je?e=this.createList():hasOwnProperty.call(this.pseudo,s)?(this.skipSC(),e=this.pseudo[s].call(this),this.skipSC()):(e=this.createList(),e.push(this.Raw(null,!1))),this.eat(Je)):t=this.consume(Ae),{type:"PseudoClassSelector",loc:this.getLocation(n,this.tokenStart),name:t,children:e}}function kae(n){this.token(Ln,":"),n.children===null?this.token(Ae,n.name):(this.token(st,n.name+"("),this.children(n),this.token(Je,")"))}const jae=Object.freeze(Object.defineProperty({__proto__:null,generate:kae,name:yae,parse:cT,structure:Sae,walkContext:wae},Symbol.toStringTag,{value:"Module"})),Nae="PseudoElementSelector",Cae="function",_ae={name:String,children:[["Raw"],null]};function uT(){const n=this.tokenStart;let e=null,t,s;return this.eat(Ln),this.eat(Ln),this.tokenType===st?(t=this.consumeFunctionName(),s=t.toLowerCase(),this.lookupNonWSType(0)==Je?e=this.createList():hasOwnProperty.call(this.pseudo,s)?(this.skipSC(),e=this.pseudo[s].call(this),this.skipSC()):(e=this.createList(),e.push(this.Raw(null,!1))),this.eat(Je)):t=this.consume(Ae),{type:"PseudoElementSelector",loc:this.getLocation(n,this.tokenStart),name:t,children:e}}function Eae(n){this.token(Ln,":"),this.token(Ln,":"),n.children===null?this.token(Ae,n.name):(this.token(st,n.name+"("),this.children(n),this.token(Je,")"))}const Tae=Object.freeze(Object.defineProperty({__proto__:null,generate:Eae,name:Nae,parse:uT,structure:_ae,walkContext:Cae},Symbol.toStringTag,{value:"Module"})),rk=47;function ok(){switch(this.skipSC(),this.tokenType){case tt:return this.Number();case st:return this.Function(this.readSequence,this.scope.Value);default:this.error("Number of function is expected")}}const Aae="Ratio",Pae={left:["Number","Function"],right:["Number","Function",null]};function dT(){const n=this.tokenStart,e=ok.call(this);let t=null;return this.skipSC(),this.isDelim(rk)&&(this.eatDelim(rk),t=ok.call(this)),{type:"Ratio",loc:this.getLocation(n,this.tokenStart),left:e,right:t}}function Iae(n){this.node(n.left),this.token(lt,"/"),n.right?this.node(n.right):this.node(tt,1)}const $ae=Object.freeze(Object.defineProperty({__proto__:null,generate:Iae,name:Aae,parse:dT,structure:Pae},Symbol.toStringTag,{value:"Module"}));function Rae(){return this.tokenIndex>0&&this.lookupType(-1)===Tt?this.tokenIndex>1?this.getTokenStart(this.tokenIndex-1):this.firstCharOffset:this.tokenStart}const Oae="Raw",Lae={value:String};function fT(n,e){const t=this.getTokenStart(this.tokenIndex);let s;return this.skipUntilBalanced(this.tokenIndex,n||this.consumeUntilBalanceEnd),e&&this.tokenStart>t?s=Rae.call(this):s=this.tokenStart,{type:"Raw",loc:this.getLocation(t,s),value:this.substring(t,s)}}function Mae(n){this.tokenize(n.value)}const zae=Object.freeze(Object.defineProperty({__proto__:null,generate:Mae,name:Oae,parse:fT,structure:Lae},Symbol.toStringTag,{value:"Module"}));function ik(){return this.Raw(this.consumeUntilLeftCurlyBracket,!0)}function Dae(){const n=this.SelectorList();return n.type!=="Raw"&&this.eof===!1&&this.tokenType!==an&&this.error(),n}const Fae="Rule",Uae="rule",Bae={prelude:["SelectorList","Raw"],block:["Block"]};function mT(){const n=this.tokenIndex,e=this.tokenStart;let t,s;return this.parseRulePrelude?t=this.parseWithFallback(Dae,ik):t=ik.call(this,n),s=this.Block(!0),{type:"Rule",loc:this.getLocation(e,this.tokenStart),prelude:t,block:s}}function Wae(n){this.node(n.prelude),this.node(n.block)}const qae=Object.freeze(Object.defineProperty({__proto__:null,generate:Wae,name:Fae,parse:mT,structure:Bae,walkContext:Uae},Symbol.toStringTag,{value:"Module"})),Vae="Scope",Hae={root:["SelectorList","Raw",null],limit:["SelectorList","Raw",null]};function pT(){let n=null,e=null;this.skipSC();const t=this.tokenStart;return this.tokenType===ft&&(this.next(),this.skipSC(),n=this.parseWithFallback(this.SelectorList,()=>this.Raw(!1,!0)),this.skipSC(),this.eat(Je)),this.lookupNonWSType(0)===Ae&&(this.skipSC(),this.eatIdent("to"),this.skipSC(),this.eat(ft),this.skipSC(),e=this.parseWithFallback(this.SelectorList,()=>this.Raw(!1,!0)),this.skipSC(),this.eat(Je)),{type:"Scope",loc:this.getLocation(t,this.tokenStart),root:n,limit:e}}function Kae(n){n.root&&(this.token(ft,"("),this.node(n.root),this.token(Je,")")),n.limit&&(this.token(Ae,"to"),this.token(ft,"("),this.node(n.limit),this.token(Je,")"))}const Gae=Object.freeze(Object.defineProperty({__proto__:null,generate:Kae,name:Vae,parse:pT,structure:Hae},Symbol.toStringTag,{value:"Module"})),Zae="Selector",Yae={children:[["TypeSelector","IdSelector","ClassSelector","AttributeSelector","PseudoClassSelector","PseudoElementSelector","Combinator"]]};function hT(){const n=this.readSequence(this.scope.Selector);return this.getFirstListNode(n)===null&&this.error("Selector is expected"),{type:"Selector",loc:this.getLocationFromList(n),children:n}}function Xae(n){this.children(n)}const Jae=Object.freeze(Object.defineProperty({__proto__:null,generate:Xae,name:Zae,parse:hT,structure:Yae},Symbol.toStringTag,{value:"Module"})),Qae="SelectorList",ele="selector",tle={children:[["Selector","Raw"]]};function gT(){const n=this.createList();for(;!this.eof;){if(n.push(this.Selector()),this.tokenType===Qn){this.next();continue}break}return{type:"SelectorList",loc:this.getLocationFromList(n),children:n}}function nle(n){this.children(n,()=>this.token(Qn,","))}const sle=Object.freeze(Object.defineProperty({__proto__:null,generate:nle,name:Qae,parse:gT,structure:tle,walkContext:ele},Symbol.toStringTag,{value:"Module"})),Ig=92,xT=34,rle=39;function Td(n){const e=n.length,t=n.charCodeAt(0),s=t===xT||t===rle?1:0,r=s===1&&e>1&&n.charCodeAt(e-1)===t?e-2:e-1;let o="";for(let i=s;i<=r;i++){let l=n.charCodeAt(i);if(l===Ig){if(i===r){i!==e-1&&(o=n.substr(i+1));break}if(l=n.charCodeAt(++i),Rs(Ig,l)){const c=i-1,u=Ko(n,c);i=u-1,o+=d0(n.substring(c+1,u))}else l===13&&n.charCodeAt(i+1)===10&&i++}else o+=n[i]}return o}function bT(n,e){const s=xT;let r="",o=!1;for(let i=0;i<n.length;i++){const l=n.charCodeAt(i);if(l===0){r+="�";continue}if(l<=31||l===127){r+="\\"+l.toString(16),o=!0;continue}l===s||l===Ig?(r+="\\"+n.charAt(i),o=!1):(o&&(xo(l)||Ho(l))&&(r+=" "),r+=n.charAt(i),o=!1)}return'"'+r+'"'}const ole="String",ile={value:String};function vT(){return{type:"String",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:Td(this.consume(cs))}}function ale(n){this.token(cs,bT(n.value))}const lle=Object.freeze(Object.defineProperty({__proto__:null,generate:ale,name:ole,parse:vT,structure:ile},Symbol.toStringTag,{value:"Module"})),cle=33;function ak(){return this.Raw(null,!1)}const ule="StyleSheet",dle="stylesheet",fle={children:[["Comment","CDO","CDC","Atrule","Rule","Raw"]]};function yT(){const n=this.tokenStart,e=this.createList();let t;for(;!this.eof;){switch(this.tokenType){case Tt:this.next();continue;case on:if(this.charCodeAt(this.tokenStart+2)!==cle){this.next();continue}t=this.Comment();break;case gc:t=this.CDO();break;case Kn:t=this.CDC();break;case Kt:t=this.parseWithFallback(this.Atrule,ak);break;default:t=this.parseWithFallback(this.Rule,ak)}e.push(t)}return{type:"StyleSheet",loc:this.getLocation(n,this.tokenStart),children:e}}function mle(n){this.children(n)}const ple=Object.freeze(Object.defineProperty({__proto__:null,generate:mle,name:ule,parse:yT,structure:fle,walkContext:dle},Symbol.toStringTag,{value:"Module"})),hle="SupportsDeclaration",gle={declaration:"Declaration"};function wT(){const n=this.tokenStart;this.eat(ft),this.skipSC();const e=this.Declaration();return this.eof||this.eat(Je),{type:"SupportsDeclaration",loc:this.getLocation(n,this.tokenStart),declaration:e}}function xle(n){this.token(ft,"("),this.node(n.declaration),this.token(Je,")")}const ble=Object.freeze(Object.defineProperty({__proto__:null,generate:xle,name:hle,parse:wT,structure:gle},Symbol.toStringTag,{value:"Module"})),vle=42,lk=124;function rh(){this.tokenType!==Ae&&this.isDelim(vle)===!1&&this.error("Identifier or asterisk is expected"),this.next()}const yle="TypeSelector",wle={name:String};function ST(){const n=this.tokenStart;return this.isDelim(lk)?(this.next(),rh.call(this)):(rh.call(this),this.isDelim(lk)&&(this.next(),rh.call(this))),{type:"TypeSelector",loc:this.getLocation(n,this.tokenStart),name:this.substrToCursor(n)}}function Sle(n){this.tokenize(n.name)}const kle=Object.freeze(Object.defineProperty({__proto__:null,generate:Sle,name:yle,parse:ST,structure:wle},Symbol.toStringTag,{value:"Module"})),kT=43,jT=45,$g=63;function Ua(n,e){let t=0;for(let s=this.tokenStart+n;s<this.tokenEnd;s++){const r=this.charCodeAt(s);if(r===jT&&e&&t!==0)return Ua.call(this,n+t+1,!1),-1;xo(r)||this.error(e&&t!==0?"Hyphen minus"+(t<6?" or hex digit":"")+" is expected":t<6?"Hex digit is expected":"Unexpected input",s),++t>6&&this.error("Too many hex digits",s)}return this.next(),t}function uu(n){let e=0;for(;this.isDelim($g);)++e>n&&this.error("Too many question marks"),this.next()}function jle(n){this.charCodeAt(this.tokenStart)!==n&&this.error((n===kT?"Plus sign":"Hyphen minus")+" is expected")}function Nle(){let n=0;switch(this.tokenType){case tt:if(n=Ua.call(this,1,!0),this.isDelim($g)){uu.call(this,6-n);break}if(this.tokenType===at||this.tokenType===tt){jle.call(this,jT),Ua.call(this,1,!1);break}break;case at:n=Ua.call(this,1,!0),n>0&&uu.call(this,6-n);break;default:if(this.eatDelim(kT),this.tokenType===Ae){n=Ua.call(this,0,!0),n>0&&uu.call(this,6-n);break}if(this.isDelim($g)){this.next(),uu.call(this,5);break}this.error("Hex digit or question mark is expected")}}const Cle="UnicodeRange",_le={value:String};function NT(){const n=this.tokenStart;return this.eatIdent("u"),Nle.call(this),{type:"UnicodeRange",loc:this.getLocation(n,this.tokenStart),value:this.substrToCursor(n)}}function Ele(n){this.tokenize(n.value)}const Tle=Object.freeze(Object.defineProperty({__proto__:null,generate:Ele,name:Cle,parse:NT,structure:_le},Symbol.toStringTag,{value:"Module"})),Ale=32,Rg=92,Ple=34,Ile=39,$le=40,CT=41;function _T(n){const e=n.length;let t=4,s=n.charCodeAt(e-1)===CT?e-2:e-1,r="";for(;t<s&&Ho(n.charCodeAt(t));)t++;for(;t<s&&Ho(n.charCodeAt(s));)s--;for(let o=t;o<=s;o++){let i=n.charCodeAt(o);if(i===Rg){if(o===s){o!==e-1&&(r=n.substr(o+1));break}if(i=n.charCodeAt(++o),Rs(Rg,i)){const l=o-1,c=Ko(n,l);o=c-1,r+=d0(n.substring(l+1,c))}else i===13&&n.charCodeAt(o+1)===10&&o++}else r+=n[o]}return r}function Rle(n){let e="",t=!1;for(let s=0;s<n.length;s++){const r=n.charCodeAt(s);if(r===0){e+="�";continue}if(r<=31||r===127){e+="\\"+r.toString(16),t=!0;continue}r===Ale||r===Rg||r===Ple||r===Ile||r===$le||r===CT?(e+="\\"+n.charAt(s),t=!1):(t&&xo(r)&&(e+=" "),e+=n.charAt(s),t=!1)}return"url("+e+")"}const Ole="Url",Lle={value:String};function ET(){const n=this.tokenStart;let e;switch(this.tokenType){case wn:e=_T(this.consume(wn));break;case st:this.cmpStr(this.tokenStart,this.tokenEnd,"url(")||this.error("Function name must be `url`"),this.eat(st),this.skipSC(),e=Td(this.consume(cs)),this.skipSC(),this.eof||this.eat(Je);break;default:this.error("Url or Function is expected")}return{type:"Url",loc:this.getLocation(n,this.tokenStart),value:e}}function Mle(n){this.token(wn,Rle(n.value))}const zle=Object.freeze(Object.defineProperty({__proto__:null,generate:Mle,name:Ole,parse:ET,structure:Lle},Symbol.toStringTag,{value:"Module"})),Dle="Value",Fle={children:[[]]};function TT(){const n=this.tokenStart,e=this.readSequence(this.scope.Value);return{type:"Value",loc:this.getLocation(n,this.tokenStart),children:e}}function Ule(n){this.children(n)}const Ble=Object.freeze(Object.defineProperty({__proto__:null,generate:Ule,name:Dle,parse:TT,structure:Fle},Symbol.toStringTag,{value:"Module"})),Wle=Object.freeze({type:"WhiteSpace",loc:null,value:" "}),qle="WhiteSpace",Vle={value:String};function AT(){return this.eat(Tt),Wle}function Hle(n){this.token(Tt,n.value)}const Kle=Object.freeze(Object.defineProperty({__proto__:null,generate:Hle,name:qle,parse:AT,structure:Vle},Symbol.toStringTag,{value:"Module"})),PT=Object.freeze(Object.defineProperty({__proto__:null,AnPlusB:pre,Atrule:yre,AtrulePrelude:Nre,AttributeSelector:Rre,Block:Ure,Brackets:Vre,CDC:Zre,CDO:Qre,ClassSelector:roe,Combinator:doe,Comment:xoe,Condition:koe,Declaration:zoe,DeclarationList:Woe,Dimension:Koe,Feature:Joe,FeatureFunction:sie,FeatureRange:cie,Function:pie,GeneralEnclosed:bie,Hash:kie,IdSelector:Pie,Identifier:_ie,Layer:Lie,LayerList:Fie,MediaQuery:qie,MediaQueryList:Gie,NestingSelector:Qie,Nth:sae,Number:aae,Operator:dae,Parentheses:hae,Percentage:vae,PseudoClassSelector:jae,PseudoElementSelector:Tae,Ratio:$ae,Raw:zae,Rule:qae,Scope:Gae,Selector:Jae,SelectorList:sle,String:lle,StyleSheet:ple,SupportsDeclaration:ble,TypeSelector:kle,UnicodeRange:Tle,Url:zle,Value:Ble,WhiteSpace:Kle},Symbol.toStringTag,{value:"Module"})),Gle={generic:!0,cssWideKeywords:g0,...cre,node:PT},Zle=35,Yle=42,ck=43,Xle=45,Jle=47,Qle=117;function IT(n){switch(this.tokenType){case jt:return this.Hash();case Qn:return this.Operator();case ft:return this.Parentheses(this.readSequence,n.recognizer);case es:return this.Brackets(this.readSequence,n.recognizer);case cs:return this.String();case at:return this.Dimension();case Rt:return this.Percentage();case tt:return this.Number();case st:return this.cmpStr(this.tokenStart,this.tokenEnd,"url(")?this.Url():this.Function(this.readSequence,n.recognizer);case wn:return this.Url();case Ae:return this.cmpChar(this.tokenStart,Qle)&&this.cmpChar(this.tokenStart+1,ck)?this.UnicodeRange():this.Identifier();case lt:{const e=this.charCodeAt(this.tokenStart);if(e===Jle||e===Yle||e===ck||e===Xle)return this.Operator();e===Zle&&this.error("Hex or identifier is expected",this.tokenStart+1);break}}}const ece={getNode:IT},tce=35,nce=38,sce=42,rce=43,oce=47,uk=46,ice=62,ace=124,lce=126;function cce(n,e){e.last!==null&&e.last.type!=="Combinator"&&n!==null&&n.type!=="Combinator"&&e.push({type:"Combinator",loc:null,name:" "})}function uce(){switch(this.tokenType){case es:return this.AttributeSelector();case jt:return this.IdSelector();case Ln:return this.lookupType(1)===Ln?this.PseudoElementSelector():this.PseudoClassSelector();case Ae:return this.TypeSelector();case tt:case Rt:return this.Percentage();case at:this.charCodeAt(this.tokenStart)===uk&&this.error("Identifier is expected",this.tokenStart+1);break;case lt:{switch(this.charCodeAt(this.tokenStart)){case rce:case ice:case lce:case oce:return this.Combinator();case uk:return this.ClassSelector();case sce:case ace:return this.TypeSelector();case tce:return this.IdSelector();case nce:return this.NestingSelector()}break}}}const dce={onWhiteSpace:cce,getNode:uce};function fce(){return this.createSingleNodeList(this.Raw(null,!1))}function mce(){const n=this.createList();if(this.skipSC(),n.push(this.Identifier()),this.skipSC(),this.tokenType===Qn){n.push(this.Operator());const e=this.tokenIndex,t=this.parseCustomProperty?this.Value(null):this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!1);if(t.type==="Value"&&t.children.isEmpty){for(let s=e-this.tokenIndex;s<=0;s++)if(this.lookupType(s)===Tt){t.children.appendData({type:"WhiteSpace",loc:null,value:" "});break}}n.push(t)}return n}function dk(n){return n!==null&&n.type==="Operator"&&(n.value[n.value.length-1]==="-"||n.value[n.value.length-1]==="+")}const pce={getNode:IT,onWhiteSpace(n,e){dk(n)&&(n.value=" "+n.value),dk(e.last)&&(e.last.value+=" ")},expression:fce,var:mce},hce=Object.freeze(Object.defineProperty({__proto__:null,AtrulePrelude:ece,Selector:dce,Value:pce},Symbol.toStringTag,{value:"Module"})),gce=new Set(["none","and","not","or"]),xce={parse:{prelude(){const n=this.createList();if(this.tokenType===Ae){const e=this.substring(this.tokenStart,this.tokenEnd);gce.has(e.toLowerCase())||n.push(this.Identifier())}return n.push(this.Condition("container")),n},block(n=!1){return this.Block(n)}}},bce={parse:{prelude:null,block(){return this.Block(!0)}}};function oh(n,e){return this.parseWithFallback(()=>{try{return n.call(this)}finally{this.skipSC(),this.lookupNonWSType(0)!==Je&&this.error()}},e||(()=>this.Raw(null,!0)))}const fk={layer(){this.skipSC();const n=this.createList(),e=oh.call(this,this.Layer);return(e.type!=="Raw"||e.value!=="")&&n.push(e),n},supports(){this.skipSC();const n=this.createList(),e=oh.call(this,this.Declaration,()=>oh.call(this,()=>this.Condition("supports")));return(e.type!=="Raw"||e.value!=="")&&n.push(e),n}},vce={parse:{prelude(){const n=this.createList();switch(this.tokenType){case cs:n.push(this.String());break;case wn:case st:n.push(this.Url());break;default:this.error("String or url() is expected")}return this.skipSC(),this.tokenType===Ae&&this.cmpStr(this.tokenStart,this.tokenEnd,"layer")?n.push(this.Identifier()):this.tokenType===st&&this.cmpStr(this.tokenStart,this.tokenEnd,"layer(")&&n.push(this.Function(null,fk)),this.skipSC(),this.tokenType===st&&this.cmpStr(this.tokenStart,this.tokenEnd,"supports(")&&n.push(this.Function(null,fk)),(this.lookupNonWSType(0)===Ae||this.lookupNonWSType(0)===ft)&&n.push(this.MediaQueryList()),n},block:null}},yce={parse:{prelude(){return this.createSingleNodeList(this.LayerList())},block(){return this.Block(!1)}}},wce={parse:{prelude(){return this.createSingleNodeList(this.MediaQueryList())},block(n=!1){return this.Block(n)}}},Sce={parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}},kce={parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}},jce={parse:{prelude(){return this.createSingleNodeList(this.Scope())},block(n=!1){return this.Block(n)}}},Nce={parse:{prelude:null,block(n=!1){return this.Block(n)}}},Cce={parse:{prelude(){return this.createSingleNodeList(this.Condition("supports"))},block(n=!1){return this.Block(n)}}},_ce={container:xce,"font-face":bce,import:vce,layer:yce,media:wce,nest:Sce,page:kce,scope:jce,"starting-style":Nce,supports:Cce};function Ece(){const n=this.createList();this.skipSC();e:for(;!this.eof;){switch(this.tokenType){case Ae:n.push(this.Identifier());break;case cs:n.push(this.String());break;case Qn:n.push(this.Operator());break;case Je:break e;default:this.error("Identifier, string or comma is expected")}this.skipSC()}return n}const Po={parse(){return this.createSingleNodeList(this.SelectorList())}},ih={parse(){return this.createSingleNodeList(this.Selector())}},Tce={parse(){return this.createSingleNodeList(this.Identifier())}},Ace={parse:Ece},du={parse(){return this.createSingleNodeList(this.Nth())}},Pce={dir:Tce,has:Po,lang:Ace,matches:Po,is:Po,"-moz-any":Po,"-webkit-any":Po,where:Po,not:Po,"nth-child":du,"nth-last-child":du,"nth-last-of-type":du,"nth-of-type":du,slotted:ih,host:ih,"host-context":ih},Ice=Object.freeze(Object.defineProperty({__proto__:null,AnPlusB:_E,Atrule:EE,AtrulePrelude:TE,AttributeSelector:PE,Block:$E,Brackets:RE,CDC:OE,CDO:LE,ClassSelector:ME,Combinator:zE,Comment:DE,Condition:FE,Declaration:BE,DeclarationList:WE,Dimension:qE,Feature:VE,FeatureFunction:HE,FeatureRange:KE,Function:GE,GeneralEnclosed:ZE,Hash:YE,IdSelector:JE,Identifier:XE,Layer:QE,LayerList:eT,MediaQuery:tT,MediaQueryList:nT,NestingSelector:sT,Nth:rT,Number:oT,Operator:iT,Parentheses:aT,Percentage:lT,PseudoClassSelector:cT,PseudoElementSelector:uT,Ratio:dT,Raw:fT,Rule:mT,Scope:pT,Selector:hT,SelectorList:gT,String:vT,StyleSheet:yT,SupportsDeclaration:wT,TypeSelector:ST,UnicodeRange:NT,Url:ET,Value:TT,WhiteSpace:AT},Symbol.toStringTag,{value:"Module"})),$ce={parseContext:{default:"StyleSheet",stylesheet:"StyleSheet",atrule:"Atrule",atrulePrelude(n){return this.AtrulePrelude(n.atrule?String(n.atrule):null)},mediaQueryList:"MediaQueryList",mediaQuery:"MediaQuery",condition(n){return this.Condition(n.kind)},rule:"Rule",selectorList:"SelectorList",selector:"Selector",block(){return this.Block(!0)},declarationList:"DeclarationList",declaration:"Declaration",value:"Value"},features:{supports:{selector(){return this.Selector()}},container:{style(){return this.Declaration()}}},scope:hce,atrule:_ce,pseudo:Pce,node:Ice},Rce={node:PT},Oce=lre({...Gle,...$ce,...Rce}),mk=92;function pk(n){const e=n.length-1;let t="";for(let s=0;s<n.length;s++){let r=n.charCodeAt(s);if(r===mk){if(s===e)break;if(r=n.charCodeAt(++s),Rs(mk,r)){const o=s-1,i=Ko(n,o);s=i-1,t+=d0(n.substring(o+1,i))}else r===13&&n.charCodeAt(s+1)===10&&s++}else t+=n[s]}return t}const{tokenize:Lce,parse:Gge,generate:Zge,lexer:Yge,createLexer:Xge,walk:Jge,find:Qge,findLast:e1e,findAll:t1e,toPlainObject:n1e,fromPlainObject:s1e,fork:r1e}=Oce,Mce=4*1024*1024,T0=16*1024*1024,zce=we({archiveVersion:Ze(1),files:ct(we({path:De().min(1).max(240),mime:De().max(80),content:De().max(T0)})).min(2).max(256)});function Dce(n,e,t){const s=r=>r.every((o,i)=>t[i]===o);return e==="image/png"?/\.png$/i.test(n)&&t.length>=24&&s([137,80,78,71,13,10,26,10]):e==="image/jpeg"?/\.jpe?g$/i.test(n)&&t.length>=4&&s([255,216])&&t.at(-2)===255&&t.at(-1)===217:/\.webp$/i.test(n)&&t.length>=16&&s([82,73,70,70])&&t[8]===87&&t[9]===69&&t[10]===66&&t[11]===80}function $T(n){if(!/^[A-Za-z0-9_-][A-Za-z0-9_./-]*$/.test(n)||n.split("/").some(e=>!e||e==="."||e===".."||e.endsWith(".")||/^(?:con|prn|aux|nul|com[0-9]|lpt[0-9])(?:\.|$)/i.test(e)))throw new Error("Invalid package asset path")}function Fce(n){if(n.length>T0||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(n))throw new Error("Invalid package encoding");const e=atob(n);if(btoa(e)!==n)throw new Error("Non-canonical package encoding");return Uint8Array.from(e,t=>t.charCodeAt(0))}function hk(n,e,t){if(!n||/[:?#%]/.test(n)||n.startsWith("/"))throw new Error("Stylesheet references an external asset");const s=e.split("/").slice(0,-1);for(const o of n.split("/"))if(o===".."){if(!s.length)throw new Error("Stylesheet asset escapes package");s.pop()}else o!=="."&&s.push(o);const r=s.join("/");if($T(r),!t.has(r))throw new Error("Stylesheet references an unavailable raster asset");return`url("${r}")`}function Uce(n,e,t){var l,c;const s=[],r=[];if(Lce(n,(u,d,f)=>{if(s.length>=2e5)throw new Error("Stylesheet exceeds its token limit");const m=n.slice(d,f);if(u===hc||u===Un)throw new Error("Malformed stylesheet resource");if(u===st||u===ft)r.push(Je);else if(u===an)r.push(qn);else if(u===es)r.push(Xn);else if([Je,qn,Xn].includes(u)&&r.pop()!==u)throw new Error("Unbalanced stylesheet");if(r.length>128)throw new Error("Stylesheet exceeds its nesting limit");s.push({type:u,value:m})}),r.length)throw new Error("Unbalanced stylesheet");const o=[],i=u=>{var d,f;for(;((d=s[u])==null?void 0:d.type)===Tt||((f=s[u])==null?void 0:f.type)===on;)u++;return u};for(let u=0;u<s.length;u++){const{type:d,value:f}=s[u];if(d===Kt&&["import","font-face"].includes(pk(f.slice(1)).toLowerCase()))throw new Error("Stylesheet imports and font sources are unsupported");if(d===st){const m=pk(f.slice(0,-1)).toLowerCase();if(["image","image-set","-webkit-image-set","src"].includes(m))throw new Error("Unsupported stylesheet resource function");if(m==="url"){const p=i(u+1),h=i(p+1);if(((l=s[p])==null?void 0:l.type)!==cs||((c=s[h])==null?void 0:c.type)!==Je)throw new Error("Malformed stylesheet URL");o.push(hk(Td(s[p].value),e,t)),u=h;continue}}if(d===wn){if(!f.endsWith(")"))throw new Error("Malformed stylesheet URL");o.push(hk(_T(f),e,t))}else if(d===cs){if(f.length<2||f.at(-1)!==f[0])throw new Error("Unterminated stylesheet string");o.push(bT(Td(f)))}else if(d===on){if(!f.endsWith("*/"))throw new Error("Unterminated stylesheet comment");o.push(" ")}else o.push(f)}return o.join("")}async function Bce(n,e,t=globalThis.crypto){if(!(t!=null&&t.subtle))throw new Error("Plugin integrity verification requires a secure browser connection with Web Crypto");if(!/^[a-f0-9]{64}$/.test(e)||n.byteLength>Mce)throw new Error("Invalid package digest or size");const s=n.slice(0);if(Array.from(new Uint8Array(await t.subtle.digest("SHA-256",s)),x=>x.toString(16).padStart(2,"0")).join("")!==e)throw new Error("Plugin package failed integrity verification");const o=new TextDecoder("utf-8",{fatal:!0}),i=zce.parse(JSON.parse(o.decode(s))),l=new Map,c=new Set;let u=s.byteLength;for(const x of i.files){if($T(x.path),c.has(x.path.toLowerCase()))throw new Error("Duplicate package asset path");c.add(x.path.toLowerCase());const b=Fce(x.content);if(u+=b.byteLength,u>T0)throw new Error("Expanded plugin package exceeds its limit");l.set(x.path,{mime:x.mime,bytes:b})}for(const x of c){const b=x.split("/");if(b.slice(0,-1).some((y,v)=>c.has(b.slice(0,v+1).join("/"))))throw new Error("Package file/directory collision")}const d=l.get("plugin.json");if(!d||d.mime!=="application/json"||d.bytes.byteLength>65536)throw new Error("Missing or invalid plugin manifest");const f=M_(JSON.parse(o.decode(d.bytes))),m=l.get(f.entry);if(!m||m.mime!=="text/javascript")throw new Error("Missing plugin entry");const p=[];for(const[x,b]of l){if(b.mime==="text/javascript"&&x!==f.entry)throw new Error("Undeclared JavaScript entry");if(b.mime==="text/css"&&x!==f.style)throw new Error("Undeclared stylesheet");if(["image/png","image/jpeg","image/webp"].includes(b.mime)){if(!Dce(x,b.mime,b.bytes))throw new Error("Invalid raster package asset");p.push({path:x,mime:b.mime,bytes:b.bytes.buffer})}else if(!["text/javascript","text/css","text/plain","application/json"].includes(b.mime))throw new Error("Unsupported package asset MIME")}const h=new Set(p.map(x=>x.path));if(f.contributes.panels.some(x=>!h.has(x.icon)))throw new Error("Missing panel raster icon");const g=f.style?l.get(f.style):null;if(f.style&&(!g||g.mime!=="text/css"))throw new Error("Missing plugin stylesheet");return{manifest:f,entry:o.decode(m.bytes),style:g?Uce(o.decode(g.bytes),f.style,h):null,assets:p}}const Wce="/api/plugins/shell/v1",gk=1e4,qce=120;function Vce(n){const{frame:e}=n,t=n.crypto??globalThis.crypto,s=n.now??(()=>performance.now());let r=Qw(n.context),o=n.active??!0,i=!1,l=!1,c=!1,u=!1,d=!1,f,m,p="",h,g=s(),x=0;const b=new Map;let y=setTimeout(()=>_(new Error("Plugin runtime shell did not load")),gk);const v=(P,I)=>{if(!(i||!m))try{m.port1.postMessage(P,I??[])}catch{_(new Error("Plugin message channel became unavailable"))}},k=(P=!0,I=!1)=>{for(const[$,O]of b)!P&&$===f||(O.abort(),b.delete($),I&&E($,"CANCELED","Plugin request was canceled"))};function j(){var P;if(!i){if(i=!0,clearTimeout(y),k(),e.removeEventListener("load",S),m){try{m.port1.postMessage({protocol:1,type:"event",event:"dispose",value:null})}catch{}m.port1.removeEventListener("message",A),m.port1.removeEventListener("messageerror",C),m.port1.close(),m.port2.close()}e.removeAttribute("src"),(P=n.onDispose)==null||P.call(n)}}function _(P){var I;i||(j(),(I=n.onError)==null||I.call(n,P))}function N(){if(i||!c||!h||u)return;u=!0,clearTimeout(y),y=setTimeout(()=>_(new Error("Plugin did not become ready within 10 seconds")),gk);const P=h.assets.map(I=>({...I,bytes:I.bytes.slice(0)}));v({type:"cogpit-plugin-load",entry:h.entry,style:h.style,assets:P,context:{...r,visible:o}},P.map(I=>I.bytes))}function S(){if(!i){if(l){_(new Error("Plugin frame navigated or reloaded"));return}if(l=!0,!e.contentWindow||!(t!=null&&t.subtle)){_(new Error("Plugin runtime requires a secure browser connection"));return}try{p=Array.from(t.getRandomValues(new Uint8Array(32)),P=>P.toString(16).padStart(2,"0")).join(""),m=(n.createChannel??(()=>new MessageChannel))(),m.port1.addEventListener("message",A),m.port1.addEventListener("messageerror",C),m.port1.start(),e.contentWindow.postMessage({type:"cogpit-plugin-connect",nonce:p},"*",[m.port2])}catch{_(new Error("Unable to connect the plugin runtime"))}}}function C(){_(new Error("Plugin sent an unreadable message"))}function E(P,I,$){v({protocol:1,type:"error",id:P,error:{code:I,message:$}})}async function T(P){var $;if(b.has(P.id)||b.size>=Ht.outstandingRequests){_(new Error("Plugin exceeded its outstanding request limit"));return}if(P.method==="lifecycle.ready"){if(d){_(new Error("Plugin signaled readiness more than once"));return}d=!0,f=P.id}else if(!o){E(P.id,"RATE_LIMITED","Plugin panel is hidden");return}const I=new AbortController;b.set(P.id,I);try{const O=H_(P.method,await n.execute(P,I.signal));if(i||I.signal.aborted||b.get(P.id)!==I||(v(eS({protocol:1,type:"result",id:P.id,value:O})),i))return;P.method==="lifecycle.ready"&&(clearTimeout(y),($=n.onReady)==null||$.call(n))}catch(O){if(i||I.signal.aborted)return;const M=O&&typeof O=="object"&&"code"in O?O.code:null,R=q_.includes(M)?M:"UPSTREAM_FAILED";E(P.id,R,"The host could not complete this operation"),P.method==="lifecycle.ready"&&_(new Error("Host refused plugin readiness"))}finally{b.get(P.id)===I&&b.delete(P.id)}}function A(P){var I;if(!i){if(s()-g>=1e3&&(g=s(),x=0),++x>qce){_(new Error("Plugin exceeded its message rate limit"));return}try{const $=t0(P.data);if(!c){if(!$||typeof $!="object"||Array.isArray($)||Object.keys($).length!==2||$.type!=="cogpit-plugin-connected"||$.nonce!==p)throw new Error("Invalid plugin handshake");c=!0,N();return}if($&&typeof $=="object"&&!Array.isArray($)&&Object.keys($).length===1&&$.type==="cogpit-plugin-load-error")throw new Error("Plugin entry failed to load");if(!u)throw new Error("Plugin sent a request before activation");const O=eS($);if(O.type==="cancel"){(I=b.get(O.id))==null||I.abort(),b.delete(O.id);return}if(O.type!=="request")throw new Error("Invalid plugin message direction");T(O)}catch($){_($ instanceof Error?$:new Error("Invalid plugin message"))}}}return Bce(n.payload,n.digest,t).then(P=>{i||(h=P,N())}).catch(P=>_(P instanceof Error?P:new Error("Plugin package could not be loaded"))),e.addEventListener("load",S),e.src=Wce,{dispose:j,setActive(P){i||o===P||(o=P,o||k(!1,!0),u&&v({protocol:1,type:"event",event:"visibility",value:o}))},updateContext(P){var O,M;if(i)return;const I=Qw(P);if(JSON.stringify(I.project)!==JSON.stringify(r.project)){j();return}if(JSON.stringify(I)===JSON.stringify(r))return;const $=r;r=I,u&&($.locale!==I.locale||$.reducedMotion!==I.reducedMotion?(k(!1,!0),v({protocol:1,type:"event",event:"context",value:{...I,visible:o}})):(((O=$.session)==null?void 0:O.handle)!==((M=I.session)==null?void 0:M.handle)&&v({protocol:1,type:"event",event:"session",value:I.session??null}),JSON.stringify($.theme)!==JSON.stringify(I.theme)&&v({protocol:1,type:"event",event:"theme",value:I.theme})))}}}function Hce(n){const e=q.c(30),t=w.useRef(null),s=w.useRef(null),r=w.useRef(n);let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={key:"",error:null,ready:!1},e[0]=o):o=e[0];const[i,l]=w.useState(o);let c;e[1]!==n.context.project?(c=JSON.stringify(n.context.project),e[1]=n.context.project,e[2]=c):c=e[2];const u=c,d=`${n.activationKey}:${n.digest}:${u}`;let f;e[3]!==n?(f=()=>{r.current=n},e[3]=n,e[4]=f):f=e[4],w.useLayoutEffect(f);let m,p;e[5]!==d||e[6]!==n.digest||e[7]!==n.payload?(m=()=>{if(!t.current)return;const C=r.current,E=Vce({frame:t.current,payload:n.payload,digest:n.digest,context:C.context,active:C.active,execute:C.execute,onReady:()=>{var T;l({key:d,error:null,ready:!0}),(T=C.onReady)==null||T.call(C)},onError:T=>{var A;l({key:d,error:T.message,ready:!1}),(A=C.onError)==null||A.call(C,T)},onDispose:C.onDispose});return s.current=E,()=>{E.dispose(),s.current=null}},p=[n.payload,n.digest,d],e[5]=d,e[6]=n.digest,e[7]=n.payload,e[8]=m,e[9]=p):(m=e[8],p=e[9]),w.useLayoutEffect(m,p);let h,g;e[10]!==n.active||e[11]!==n.context?(h=()=>{var C,E;(C=s.current)==null||C.setActive(n.active??!0),(E=s.current)==null||E.updateContext(n.context)},g=[n.active,n.context],e[10]=n.active,e[11]=n.context,e[12]=h,e[13]=g):(h=e[12],g=e[13]),w.useLayoutEffect(h,g);let x;e[14]!==d||e[15]!==i?(x=i.key===d?i:{error:null,ready:!1},e[14]=d,e[15]=i,e[16]=x):x=e[16];const b=x,y=n.title??"Plugin panel";let v;e[17]!==b.error||e[18]!==b.ready?(v=!b.ready&&!b.error&&a.jsx("p",{role:"status",className:"p-4 text-sm text-muted-foreground",children:"Loading plugin…"}),e[17]=b.error,e[18]=b.ready,e[19]=v):v=e[19];let k;e[20]!==b.error?(k=b.error&&a.jsx("p",{role:"alert",className:"p-4 text-sm text-destructive",children:b.error}),e[20]=b.error,e[21]=k):k=e[21];const j=n.title??"Plugin panel",_=!b.ready||!!b.error||n.active===!1;let N;e[22]!==j||e[23]!==_?(N=a.jsx("iframe",{ref:t,title:j,sandbox:"allow-scripts",referrerPolicy:"no-referrer",className:"h-full w-full border-0",hidden:_}),e[22]=j,e[23]=_,e[24]=N):N=e[24];let S;return e[25]!==k||e[26]!==N||e[27]!==y||e[28]!==v?(S=a.jsxs("section",{className:"relative h-full min-h-0 w-full","aria-label":y,children:[v,k,N]}),e[25]=k,e[26]=N,e[27]=y,e[28]=v,e[29]=S):S=e[29],S}const Kce=`@custom-variant dark (&:is(.dark *));
|
|
188
|
+
|
|
189
|
+
@theme inline {
|
|
190
|
+
--font-sans: "Geist Variable", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
191
|
+
--font-mono: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
192
|
+
--color-canvas: var(--canvas);
|
|
193
|
+
--color-selection: var(--selection);
|
|
194
|
+
--color-background: var(--background);
|
|
195
|
+
--color-foreground: var(--foreground);
|
|
196
|
+
--color-card: var(--card);
|
|
197
|
+
--color-card-foreground: var(--card-foreground);
|
|
198
|
+
--color-popover: var(--popover);
|
|
199
|
+
--color-popover-foreground: var(--popover-foreground);
|
|
200
|
+
--color-primary: var(--primary);
|
|
201
|
+
--color-primary-foreground: var(--primary-foreground);
|
|
202
|
+
--color-secondary: var(--secondary);
|
|
203
|
+
--color-secondary-foreground: var(--secondary-foreground);
|
|
204
|
+
--color-muted: var(--muted);
|
|
205
|
+
--color-muted-foreground: var(--muted-foreground);
|
|
206
|
+
--color-prompt-surface: var(--prompt-surface);
|
|
207
|
+
--color-composer-surface: var(--composer-surface);
|
|
208
|
+
--color-accent: var(--accent);
|
|
209
|
+
--color-accent-foreground: var(--accent-foreground);
|
|
210
|
+
--color-destructive: var(--destructive);
|
|
211
|
+
--color-destructive-foreground: var(--destructive-foreground);
|
|
212
|
+
--color-success: var(--success);
|
|
213
|
+
--color-success-foreground: var(--success-foreground);
|
|
214
|
+
--color-warning: var(--warning);
|
|
215
|
+
--color-warning-foreground: var(--warning-foreground);
|
|
216
|
+
--color-info: var(--info);
|
|
217
|
+
--color-info-foreground: var(--info-foreground);
|
|
218
|
+
--color-border: var(--border);
|
|
219
|
+
--color-input: var(--input);
|
|
220
|
+
--color-ring: var(--ring);
|
|
221
|
+
--color-chart-1: var(--chart-1);
|
|
222
|
+
--color-chart-2: var(--chart-2);
|
|
223
|
+
--color-chart-3: var(--chart-3);
|
|
224
|
+
--color-chart-4: var(--chart-4);
|
|
225
|
+
--color-chart-5: var(--chart-5);
|
|
226
|
+
--color-sidebar: var(--sidebar);
|
|
227
|
+
--color-sidebar-foreground: var(--sidebar-foreground);
|
|
228
|
+
--color-sidebar-primary: var(--sidebar-primary);
|
|
229
|
+
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
|
|
230
|
+
--color-sidebar-accent: var(--sidebar-accent);
|
|
231
|
+
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
|
|
232
|
+
--color-sidebar-border: var(--sidebar-border);
|
|
233
|
+
--color-sidebar-ring: var(--sidebar-ring);
|
|
234
|
+
--radius-sm: calc(var(--radius) - 4px);
|
|
235
|
+
--radius-md: calc(var(--radius) - 2px);
|
|
236
|
+
--radius-lg: var(--radius);
|
|
237
|
+
--radius-xl: calc(var(--radius) + 4px);
|
|
238
|
+
--default-transition-duration: var(--motion-duration-fast);
|
|
239
|
+
--default-transition-timing-function: var(--motion-ease-standard);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
:root {
|
|
243
|
+
--motion-duration-instant: 80ms;
|
|
244
|
+
--motion-duration-fast: 120ms;
|
|
245
|
+
--motion-duration-base: 180ms;
|
|
246
|
+
--motion-duration-slow: 240ms;
|
|
247
|
+
--motion-duration-spinner: 900ms;
|
|
248
|
+
--motion-duration-indicator: 1600ms;
|
|
249
|
+
--motion-ease-standard: cubic-bezier(0.2, 0, 0, 1);
|
|
250
|
+
--motion-ease-enter: cubic-bezier(0.16, 1, 0.3, 1);
|
|
251
|
+
--motion-ease-exit: cubic-bezier(0.4, 0, 1, 1);
|
|
252
|
+
--motion-distance-sm: 4px;
|
|
253
|
+
--motion-distance-md: 8px;
|
|
254
|
+
--motion-distance-lg: 12px;
|
|
255
|
+
--motion-stagger-step: 20ms;
|
|
256
|
+
--canvas: var(--background);
|
|
257
|
+
--selection: rgba(0, 0, 0, 0.2);
|
|
258
|
+
--terminal-selection: color-mix(in srgb, var(--foreground) 20%, var(--canvas));
|
|
259
|
+
--terminal-black: #171717;
|
|
260
|
+
--terminal-white: #fafafa;
|
|
261
|
+
--terminal-magenta: #b83ba4;
|
|
262
|
+
--terminal-cyan: #008fa3;
|
|
263
|
+
--background: oklch(1 0 0);
|
|
264
|
+
--foreground: oklch(0.145 0 0);
|
|
265
|
+
--card: oklch(1 0 0);
|
|
266
|
+
--card-foreground: oklch(0.145 0 0);
|
|
267
|
+
--popover: oklch(1 0 0);
|
|
268
|
+
--popover-foreground: oklch(0.145 0 0);
|
|
269
|
+
--primary: oklch(0.205 0 0);
|
|
270
|
+
--primary-foreground: oklch(0.985 0 0);
|
|
271
|
+
--secondary: oklch(0.97 0 0);
|
|
272
|
+
--secondary-foreground: oklch(0.205 0 0);
|
|
273
|
+
--muted: oklch(0.97 0 0);
|
|
274
|
+
--muted-foreground: oklch(0.556 0 0);
|
|
275
|
+
--prompt-surface: oklch(0.955 0 0);
|
|
276
|
+
--composer-surface: oklch(0.985 0 0);
|
|
277
|
+
--accent: oklch(0.96 0 0);
|
|
278
|
+
--accent-foreground: oklch(0.205 0 0);
|
|
279
|
+
--destructive: oklch(0.577 0.245 27.325);
|
|
280
|
+
--destructive-foreground: oklch(0.985 0 0);
|
|
281
|
+
--success: oklch(0.51 0.15 151);
|
|
282
|
+
--success-foreground: oklch(0.985 0 0);
|
|
283
|
+
--warning: oklch(0.68 0.16 72);
|
|
284
|
+
--warning-foreground: oklch(0.2 0.04 72);
|
|
285
|
+
--info: oklch(0.55 0.18 255);
|
|
286
|
+
--info-foreground: oklch(0.985 0 0);
|
|
287
|
+
--border: oklch(0.922 0 0);
|
|
288
|
+
--input: oklch(0.922 0 0);
|
|
289
|
+
--ring: oklch(0.556 0 0);
|
|
290
|
+
--chart-1: oklch(0.646 0.222 41.116);
|
|
291
|
+
--chart-2: oklch(0.6 0.118 184.704);
|
|
292
|
+
--chart-3: oklch(0.398 0.07 227.392);
|
|
293
|
+
--chart-4: oklch(0.828 0.189 84.429);
|
|
294
|
+
--chart-5: oklch(0.769 0.188 70.08);
|
|
295
|
+
--radius: 0.5rem;
|
|
296
|
+
--sidebar: oklch(0.985 0 0);
|
|
297
|
+
--sidebar-foreground: oklch(0.145 0 0);
|
|
298
|
+
--sidebar-primary: oklch(0.205 0 0);
|
|
299
|
+
--sidebar-primary-foreground: oklch(0.985 0 0);
|
|
300
|
+
--sidebar-accent: oklch(0.96 0 0);
|
|
301
|
+
--sidebar-accent-foreground: oklch(0.205 0 0);
|
|
302
|
+
--sidebar-border: oklch(0.922 0 0);
|
|
303
|
+
--sidebar-ring: oklch(0.556 0 0);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
.dark {
|
|
307
|
+
--selection: rgba(255, 255, 255, 0.2);
|
|
308
|
+
--terminal-magenta: #e879f9;
|
|
309
|
+
--terminal-cyan: #22d3ee;
|
|
310
|
+
--canvas: var(--background);
|
|
311
|
+
--background: oklch(0.105 0 0);
|
|
312
|
+
--foreground: oklch(0.985 0 0);
|
|
313
|
+
--card: oklch(0.13 0 0);
|
|
314
|
+
--card-foreground: oklch(0.985 0 0);
|
|
315
|
+
--popover: oklch(0.16 0 0);
|
|
316
|
+
--popover-foreground: oklch(0.985 0 0);
|
|
317
|
+
--primary: oklch(0.985 0 0);
|
|
318
|
+
--primary-foreground: oklch(0.205 0 0);
|
|
319
|
+
--secondary: oklch(0.19 0 0);
|
|
320
|
+
--secondary-foreground: oklch(0.985 0 0);
|
|
321
|
+
--muted: oklch(0.18 0 0);
|
|
322
|
+
--muted-foreground: oklch(0.708 0 0);
|
|
323
|
+
--prompt-surface: oklch(0.16 0 0);
|
|
324
|
+
--composer-surface: oklch(0.19 0 0);
|
|
325
|
+
--accent: oklch(0.2 0 0);
|
|
326
|
+
--accent-foreground: oklch(0.985 0 0);
|
|
327
|
+
--destructive: oklch(0.64 0.22 25);
|
|
328
|
+
--destructive-foreground: oklch(0.985 0 0);
|
|
329
|
+
--success: oklch(0.72 0.17 151);
|
|
330
|
+
--success-foreground: oklch(0.12 0.03 151);
|
|
331
|
+
--warning: oklch(0.78 0.15 78);
|
|
332
|
+
--warning-foreground: oklch(0.16 0.03 72);
|
|
333
|
+
--info: oklch(0.72 0.14 255);
|
|
334
|
+
--info-foreground: oklch(0.12 0.03 255);
|
|
335
|
+
--border: oklch(0.24 0 0);
|
|
336
|
+
--input: oklch(0.22 0 0);
|
|
337
|
+
--ring: oklch(0.556 0 0);
|
|
338
|
+
--chart-1: oklch(0.488 0.243 264.376);
|
|
339
|
+
--chart-2: oklch(0.696 0.17 162.48);
|
|
340
|
+
--chart-3: oklch(0.769 0.188 70.08);
|
|
341
|
+
--chart-4: oklch(0.627 0.265 303.9);
|
|
342
|
+
--chart-5: oklch(0.645 0.246 16.439);
|
|
343
|
+
--sidebar: oklch(0.125 0 0);
|
|
344
|
+
--sidebar-foreground: oklch(0.985 0 0);
|
|
345
|
+
--sidebar-primary: oklch(0.985 0 0);
|
|
346
|
+
--sidebar-primary-foreground: oklch(0.205 0 0);
|
|
347
|
+
--sidebar-accent: oklch(0.2 0 0);
|
|
348
|
+
--sidebar-accent-foreground: oklch(0.985 0 0);
|
|
349
|
+
--sidebar-border: oklch(0.24 0 0);
|
|
350
|
+
--sidebar-ring: oklch(0.556 0 0);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/* ── Deep OLED Theme ──
|
|
354
|
+
Pure black backgrounds, zero blue tint, maximum contrast.
|
|
355
|
+
Great for OLED displays where true black saves power. */
|
|
356
|
+
.dark.theme-oled {
|
|
357
|
+
--background: oklch(0 0 0);
|
|
358
|
+
--foreground: oklch(0.985 0 0);
|
|
359
|
+
--card: oklch(0.08 0 0);
|
|
360
|
+
--card-foreground: oklch(0.985 0 0);
|
|
361
|
+
--popover: oklch(0.10 0 0);
|
|
362
|
+
--popover-foreground: oklch(0.985 0 0);
|
|
363
|
+
--primary: oklch(0.985 0 0);
|
|
364
|
+
--primary-foreground: oklch(0 0 0);
|
|
365
|
+
--secondary: oklch(0.10 0 0);
|
|
366
|
+
--secondary-foreground: oklch(0.985 0 0);
|
|
367
|
+
--muted: oklch(0.10 0 0);
|
|
368
|
+
--muted-foreground: oklch(0.65 0 0);
|
|
369
|
+
--prompt-surface: oklch(0.07 0 0);
|
|
370
|
+
--composer-surface: oklch(0.13 0 0);
|
|
371
|
+
--accent: oklch(0.10 0 0);
|
|
372
|
+
--accent-foreground: oklch(0.985 0 0);
|
|
373
|
+
--destructive: oklch(0.64 0.22 25);
|
|
374
|
+
--destructive-foreground: oklch(0.985 0 0);
|
|
375
|
+
--border: oklch(0.18 0 0);
|
|
376
|
+
--input: oklch(0.10 0 0);
|
|
377
|
+
--ring: oklch(0.556 0 0);
|
|
378
|
+
--sidebar: oklch(0.08 0 0);
|
|
379
|
+
--sidebar-foreground: oklch(0.985 0 0);
|
|
380
|
+
--sidebar-primary: oklch(0.985 0 0);
|
|
381
|
+
--sidebar-primary-foreground: oklch(0 0 0);
|
|
382
|
+
--sidebar-accent: oklch(0.10 0 0);
|
|
383
|
+
--sidebar-accent-foreground: oklch(0.985 0 0);
|
|
384
|
+
--sidebar-border: oklch(0.18 0 0);
|
|
385
|
+
--sidebar-ring: oklch(0.439 0 0);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
.theme-layered {
|
|
389
|
+
--surface-opacity: 3%;
|
|
390
|
+
--canvas: #fff;
|
|
391
|
+
--surface-rgb: 0 0 0;
|
|
392
|
+
--surface: rgb(var(--surface-rgb) / var(--surface-opacity));
|
|
393
|
+
--surface-hover: rgb(var(--surface-rgb) / calc(var(--surface-opacity) * 2));
|
|
394
|
+
--background: var(--surface);
|
|
395
|
+
--card: var(--surface);
|
|
396
|
+
--secondary: var(--surface);
|
|
397
|
+
--muted: var(--surface);
|
|
398
|
+
--muted-foreground: oklch(0.5 0 0);
|
|
399
|
+
--prompt-surface: var(--surface);
|
|
400
|
+
--composer-surface: var(--surface);
|
|
401
|
+
--sidebar: var(--canvas);
|
|
402
|
+
--accent: var(--surface-hover);
|
|
403
|
+
--sidebar-accent: var(--surface-hover);
|
|
404
|
+
--border: rgb(var(--surface-rgb) / 8%);
|
|
405
|
+
--input: var(--border);
|
|
406
|
+
--sidebar-border: var(--border);
|
|
407
|
+
/* Portals need a canvas beneath their layers to cover the page behind them. */
|
|
408
|
+
--popover: color-mix(in srgb, var(--canvas), rgb(var(--surface-rgb)) calc(var(--surface-opacity) * 2));
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
.dark.theme-layered {
|
|
412
|
+
--canvas: #000;
|
|
413
|
+
--surface-rgb: 255 255 255;
|
|
414
|
+
--muted-foreground: oklch(0.708 0 0);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
@layer base {
|
|
418
|
+
* {
|
|
419
|
+
@apply border-border;
|
|
420
|
+
}
|
|
421
|
+
body {
|
|
422
|
+
@apply bg-canvas text-foreground;
|
|
423
|
+
font-family: var(--font-sans);
|
|
424
|
+
font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
|
|
425
|
+
font-optical-sizing: auto;
|
|
426
|
+
letter-spacing: 0;
|
|
427
|
+
text-rendering: optimizeLegibility;
|
|
428
|
+
-webkit-tap-highlight-color: transparent;
|
|
429
|
+
-webkit-text-size-adjust: 100%;
|
|
430
|
+
-webkit-font-smoothing: antialiased;
|
|
431
|
+
-moz-osx-font-smoothing: grayscale;
|
|
432
|
+
}
|
|
433
|
+
button,
|
|
434
|
+
[role="button"] {
|
|
435
|
+
cursor: pointer;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
`,Gce=[...Array.from(Kce.matchAll(/--color-[\w-]+:\s*var\((--[\w-]+)\)/g),n=>n[1]),"--surface-opacity","--surface-rgb","--surface","--surface-hover","--radius","--font-sans","--font-mono"];function xk(){const n=document.documentElement,e=getComputedStyle(n),t={};for(const s of Gce){const r=e.getPropertyValue(s).trim();r&&new TextEncoder().encode(r).byteLength<=256&&(t[s]=r)}return{theme:{mode:n.classList.contains("dark")?"dark":"light",tokens:t},locale:(n.lang||navigator.language||"en").slice(0,64),reducedMotion:window.matchMedia("(prefers-reduced-motion: reduce)").matches}}function Zce(n,e,t,s,r=null){let o="";for(const l of(e==null?void 0:e.name.trim())??""){if(o.length+l.length>128)break;l.charCodeAt(0)>=32&&l.charCodeAt(0)!==127&&(o+=l)}const i=n.permissions.context.includes("session.identity")?{session:r?{handle:r}:null}:{};return{...s,project:e&&n.permissions.context.includes("project.identity")?{id:e.id,name:o.trim()||"Project"}:null,visible:t,...i}}function Yce(){const n=q.c(2),[e,t]=w.useState(xk);let s,r;return n[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>{const o=()=>{const c=xk();t(u=>JSON.stringify(u)===JSON.stringify(c)?u:c)},i=new MutationObserver(o);i.observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","lang"]});const l=window.matchMedia("(prefers-reduced-motion: reduce)");return l.addEventListener("change",o),window.addEventListener("languagechange",o),()=>{i.disconnect(),l.removeEventListener("change",o),window.removeEventListener("languagechange",o)}},r=[],n[0]=s,n[1]=r):(s=n[0],r=n[1]),w.useEffect(s,r),e}function Xce(n){const e=new AbortController;let t=new AbortController,s=new AbortController,r=n.active,o,i,l,c=-1/0,u=-1/0;const d=x=>{n.client.revokeLease(x).catch(()=>{})};function f(){e.signal.aborted||(e.abort(),t.abort(),s.abort(),clearTimeout(i),clearTimeout(l),o&&d(o.id))}function m(x){e.signal.aborted||(f(),n.onError(x))}function p(){if(!o||e.signal.aborted)return;const x=o.expiresAt-Date.now();if(x<=0){m(new Error("Plugin activation expired"));return}clearTimeout(l),l=setTimeout(()=>m(new Error("Plugin activation expired")),x),i=setTimeout(()=>{h()},Math.min(8e3,Math.max(1,Math.floor(x/2))))}async function h(){if(!(!o||e.signal.aborted))try{const x=await n.client.renewLease(o.id,e.signal);if(e.signal.aborted)return;if(x.id!==o.id)throw d(x.id),new Error("Plugin activation changed during renewal");o=x,p()}catch{m(new Error("Plugin activation could not be renewed"))}}const g=n.client.lease(n.pluginId,n.projectId,n.contextEpoch,e.signal,n.workspacePath).then(x=>{if(e.signal.aborted){d(x.id);return}o=x,p()});return Promise.all([g,n.client.payload(n.digest,e.signal)]).then(([,x])=>{!e.signal.aborted&&o&&n.onLoaded(x,o.id)}).catch(()=>m(new Error("Plugin panel could not be loaded"))),{async execute(x,b){const y=x.method==="composer.append"||x.method.startsWith("navigation."),v=AbortSignal.any([b,e.signal,...x.method==="lifecycle.ready"?[]:[t.signal],...y?[s.signal]:[]]);if(v.throwIfAborted(),!o||o.expiresAt<=Date.now())throw new Error("Plugin activation expired");if(!r&&x.method!=="lifecycle.ready")throw new Error("Plugin panel is hidden");if(x.method==="composer.append"&&!n.appendDraft)throw Object.assign(new Error("The message composer is unavailable"),{code:"CAPABILITY_UNAVAILABLE"});if(x.method==="navigation.openExternal"&&!n.openExternal)throw Object.assign(new Error("External navigation is unavailable"),{code:"CAPABILITY_UNAVAILABLE"});if(x.method==="navigation.openSession"&&(!n.openSession||!n.client.resolveSession))throw Object.assign(new Error("Session navigation is unavailable"),{code:"CAPABILITY_UNAVAILABLE"});const k=await n.client.call(o.id,x,v);if(v.throwIfAborted(),x.method==="composer.append"){if(performance.now()-c<1e3)throw Object.assign(new Error("Wait before adding another draft"),{code:"RATE_LIMITED"});c=performance.now(),n.appendDraft(x.params.text)}if(x.method==="navigation.openExternal"){if(performance.now()-u<1e3)throw Object.assign(new Error("Wait before opening another link"),{code:"RATE_LIMITED"});u=performance.now(),await n.openExternal(x.params.url,v),v.throwIfAborted()}if(x.method==="navigation.openSession"){if(performance.now()-u<1e3)throw Object.assign(new Error("Wait before opening another session"),{code:"RATE_LIMITED"});u=performance.now();const j=await n.client.resolveSession(o.id,x.params.handle,v);v.throwIfAborted(),n.openSession(j.dirName,j.fileName)}return k},setActive(x){r!==x&&(r=x,t.abort(),t=new AbortController)},resetSession(){s.abort(),s=new AbortController},fail:m,dispose:f}}function Jce(n){const e=q.c(8),t=w.useRef(null),[s,r]=w.useState(null);let o,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=()=>()=>{var m;(m=t.current)==null||m.finish(!1)},i=[],e[0]=o,e[1]=i):(o=e[0],i=e[1]),w.useEffect(o,i);let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=(m,p)=>{p.throwIfAborted();const h=new URL(m);return m.length>2048||h.protocol!=="https:"||h.username||h.password?Promise.reject(Object.assign(new Error("Only HTTPS links without credentials are supported"),{code:"INVALID_REQUEST"})):t.current?Promise.reject(Object.assign(new Error("A link is already awaiting review"),{code:"RATE_LIMITED"})):new Promise((g,x)=>{const b=()=>y.finish(!1),y={url:h.href,finish(v){t.current===y&&(t.current=null,p.removeEventListener("abort",b),r(null),v&&!p.aborted?g():x(Object.assign(new Error("Opening the link was canceled"),{code:"CANCELED"})))}};t.current=y,p.addEventListener("abort",b,{once:!0}),r(y)})},e[2]=l):l=e[2];const c=l;let u;e[3]!==s||e[4]!==n?(u=s?a.jsx(dr,{open:!0,onOpenChange:m=>{var p;m||(p=t.current)==null||p.finish(!1)},children:a.jsxs(fr,{children:[a.jsxs(mr,{children:["Open link from ",n,"?"]}),a.jsx(pr,{children:"This opens a website outside Cogpit."}),a.jsx("p",{className:"max-h-48 overflow-auto break-all rounded-md bg-muted p-3 text-sm",dir:"ltr",children:s==null?void 0:s.url}),a.jsxs($1,{children:[a.jsx(ee,{variant:"outline",onClick:()=>{var m;return(m=t.current)==null?void 0:m.finish(!1)},children:"Cancel"}),a.jsx(ee,{onClick:()=>{!s||t.current!==s||(window.open(s.url,"_blank","noopener,noreferrer"),s.finish(!0))},children:"Open website"})]})]})}):null,e[3]=s,e[4]=n,e[5]=u):u=e[5];const d=u;let f;return e[6]!==d?(f={openExternal:c,dialog:d},e[6]=d,e[7]=f):f=e[7],f}const RT=()=>new URLSearchParams(window.location.search).get("pluginSafeMode")==="1",Qce=n=>(window.addEventListener("popstate",n),()=>window.removeEventListener("popstate",n)),OT=()=>w.useSyncExternalStore(Qce,RT,eue);function o1e(n){const e=new URL(window.location.href);n?e.searchParams.set("pluginSafeMode","1"):e.searchParams.delete("pluginSafeMode"),window.history.replaceState(window.history.state,"",e),window.dispatchEvent(new PopStateEvent("popstate"))}function eue(){return!0}function tue(n){const e=q.c(20),t=OT();let s;e[0]!==n.activation||e[1]!==n.plugin.id||e[2]!==n.plugin.selectedDigest||e[3]!==n.registryRevision?(s=JSON.stringify([n.activation,n.registryRevision,n.plugin.id,n.plugin.selectedDigest]),e[0]=n.activation,e[1]=n.plugin.id,e[2]=n.plugin.selectedDigest,e[3]=n.registryRevision,e[4]=s):s=e[4];const r=s;if(!n.activation||!n.plugin.enabled||t)return null;let o;e[5]!==n?(o=n.openSettings&&n.plugin.manifest.permissions.connections.length>0&&a.jsx(ee,{size:"sm",variant:"ghost",onClick:()=>{var m;return(m=n.openSettings)==null?void 0:m.call(n,n.plugin.id)},children:"Connections"}),e[5]=n,e[6]=o):o=e[6];const i=`Close ${n.title??n.plugin.manifest.name}`;let l;e[7]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(Ut,{className:"size-4"}),e[7]=l):l=e[7];let c;e[8]!==n.closePanel||e[9]!==i?(c=a.jsx(ee,{size:"icon-sm",variant:"ghost","aria-label":i,onClick:n.closePanel,children:l}),e[8]=n.closePanel,e[9]=i,e[10]=c):c=e[10];let u;e[11]!==o||e[12]!==c?(u=a.jsxs("div",{className:"flex items-center justify-end gap-1 border-b px-2 py-1",children:[o,c]}),e[11]=o,e[12]=c,e[13]=u):u=e[13];let d;e[14]!==r||e[15]!==n?(d=a.jsx("div",{className:"min-h-0 flex-1",children:a.jsx(nue,{...n},r)}),e[14]=r,e[15]=n,e[16]=d):d=e[16];let f;return e[17]!==u||e[18]!==d?(f=a.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[u,d]}),e[17]=u,e[18]=d,e[19]=f):f=e[19],f}function nue(n){var p,h,g,x,b,y;const e=q.c(36);let t;e[0]!==n.context.projectPath||e[1]!==((p=n.project)==null?void 0:p.id)||e[2]!==((h=n.project)==null?void 0:h.name)?(t=JSON.stringify([(g=n.project)==null?void 0:g.id,(x=n.project)==null?void 0:x.name,n.context.projectPath]),e[0]=n.context.projectPath,e[1]=(b=n.project)==null?void 0:b.id,e[2]=(y=n.project)==null?void 0:y.name,e[3]=t):t=e[3];const s=t;let r;e[4]!==s||e[5]!==n.context.projectPath||e[6]!==n.project?(r={key:s,project:n.project,path:n.context.projectPath},e[4]=s,e[5]=n.context.projectPath,e[6]=n.project,e[7]=r):r=e[7];const o=r;let i;e[8]!==o?(i=[o],e[8]=o,e[9]=i):i=e[9];let l;e[10]!==s?(l=[s],e[10]=s,e[11]=l):l=e[11];let c;e[12]!==i||e[13]!==l?(c={entries:i,recent:l},e[12]=i,e[13]=l,e[14]=c):c=e[14];const[u,d]=w.useState(c);let f=u.entries;if(u.recent.at(-1)!==s){let v;if(e[15]!==u.recent||e[16]!==s){let j;e[18]!==s?(j=_=>_!==s,e[18]=s,e[19]=j):j=e[19],v=[...u.recent.filter(j),s].slice(-3),e[15]=u.recent,e[16]=s,e[17]=v}else v=e[17];const k=v;if(e[20]!==u.entries||e[21]!==o||e[22]!==s||e[23]!==k){let j;e[25]!==k?(j=N=>k.includes(N.key),e[25]=k,e[26]=j):j=e[26],f=u.entries.filter(j);let _;e[27]!==s?(_=N=>N.key===s,e[27]=s,e[28]=_):_=e[28],f.some(_)||(f=[...f,o]),e[20]=u.entries,e[21]=o,e[22]=s,e[23]=k,e[24]=f}else f=e[24];d({entries:f,recent:k})}let m;if(e[29]!==f||e[30]!==s||e[31]!==n){let v;e[33]!==s||e[34]!==n?(v=k=>a.jsx("div",{className:"h-full min-h-0",hidden:k.key!==s,children:a.jsx(sue,{...n,epoch:k.key,project:k.project,context:{...n.context,projectPath:k.path},active:n.active&&k.key===s})},k.key),e[33]=s,e[34]=n,e[35]=v):v=e[35],m=f.map(v),e[29]=f,e[30]=s,e[31]=n,e[32]=m}else m=e[32];return m}function sue(n){var oe,ie,fe;const e=q.c(73),{client:t,plugin:s,project:r,active:o,title:i,epoch:l,context:c}=n,u=Yce(),{openExternal:d,dialog:f}=Jce(s.manifest.name),[m]=w.useState(oue),p=w.useRef(o),h=w.useRef(c.composePrompt),g=w.useRef(c.openSession),x=w.useRef(null);let b;e[0]!==((oe=c.session)==null?void 0:oe.sessionId)||e[1]!==c.sessionChangeKey?(b=JSON.stringify([(ie=c.session)==null?void 0:ie.sessionId,c.sessionChangeKey]),e[0]=(fe=c.session)==null?void 0:fe.sessionId,e[1]=c.sessionChangeKey,e[2]=b):b=e[2];const y=b,[v,k]=w.useState(null),[j,_]=w.useState(null);let N,S;e[3]!==o?(N=()=>{var de;p.current=o,(de=x.current)==null||de.setActive(o)},S=[o],e[3]=o,e[4]=N,e[5]=S):(N=e[4],S=e[5]),w.useLayoutEffect(N,S);let C;e[6]===Symbol.for("react.memo_cache_sentinel")?(C=()=>{var de;(de=x.current)==null||de.resetSession()},e[6]=C):C=e[6];let E;e[7]!==y?(E=[y],e[7]=y,e[8]=E):E=e[8],w.useLayoutEffect(C,E);let T,A;e[9]!==c.composePrompt?(T=()=>{h.current=c.composePrompt},A=[c.composePrompt],e[9]=c.composePrompt,e[10]=T,e[11]=A):(T=e[10],A=e[11]),w.useLayoutEffect(T,A);let P,I;e[12]!==c.openSession?(P=()=>{g.current=c.openSession},I=[c.openSession],e[12]=c.openSession,e[13]=P,e[14]=I):(P=e[13],I=e[14]),w.useLayoutEffect(P,I);const $=s.id,O=s.selectedDigest,M=(r==null?void 0:r.id)??null;let R;e[15]!==c.composePrompt||e[16]!==s.manifest.permissions.composer?(R=s.manifest.permissions.composer.includes("append")&&!!c.composePrompt,e[15]=c.composePrompt,e[16]=s.manifest.permissions.composer,e[17]=R):R=e[17];const z=R;let W;e[18]!==c.openSession||e[19]!==s.manifest.permissions.navigation?(W=s.manifest.permissions.navigation.includes("session")&&!!c.openSession,e[18]=c.openSession,e[19]=s.manifest.permissions.navigation,e[20]=W):W=e[20];const D=W,L=r?c.projectPath:null;let U;e[21]!==s.manifest.permissions.navigation?(U=s.manifest.permissions.navigation.includes("external"),e[21]=s.manifest.permissions.navigation,e[22]=U):U=e[22];const F=U,B=s.manifest.permissions.context.includes("session.identity")&&t.sessionHandle&&L?c.sessionAddress??null:null,V=(B==null?void 0:B.dirName)??null,H=(B==null?void 0:B.fileName)??null,[K,Z]=w.useState(null);let Y,X;e[23]!==t||e[24]!==V||e[25]!==H||e[26]!==v?(Y=()=>{if(!v||!V||!H)return;const de=new AbortController;return t.sessionHandle(v.leaseId,{dirName:V,fileName:H},de.signal).then(ce=>{de.signal.aborted||Z({leaseId:v.leaseId,dirName:V,fileName:H,handle:ce})}).catch(rue),()=>de.abort()},X=[t,v,V,H],e[23]=t,e[24]=V,e[25]=H,e[26]=v,e[27]=Y,e[28]=X):(Y=e[27],X=e[28]),w.useEffect(Y,X);const se=K&&v&&K.leaseId===v.leaseId&&K.dirName===V&&K.fileName===H?K.handle:null;let Q;e[29]!==z||e[30]!==F||e[31]!==D||e[32]!==t||e[33]!==m||e[34]!==O||e[35]!==d||e[36]!==$||e[37]!==M||e[38]!==L?(Q=()=>{const de=Xce({client:t,pluginId:$,digest:O,projectId:M,workspacePath:L,contextEpoch:m,active:p.current,...z?{appendDraft:ce=>{var xe;return(xe=h.current)==null?void 0:xe.call(h,ce)}}:{},...D?{openSession:(ce,xe)=>{var pe;return(pe=g.current)==null?void 0:pe.call(g,ce,xe)}}:{},...F?{openExternal:d}:{},onLoaded:(ce,xe)=>k({payload:ce,leaseId:xe,runtime:de}),onError:ce=>_(ce.message)});return x.current=de,()=>{de.dispose(),x.current=null}},e[29]=z,e[30]=F,e[31]=D,e[32]=t,e[33]=m,e[34]=O,e[35]=d,e[36]=$,e[37]=M,e[38]=L,e[39]=Q):Q=e[39];let te;if(e[40]!==z||e[41]!==F||e[42]!==D||e[43]!==t||e[44]!==m||e[45]!==O||e[46]!==l||e[47]!==d||e[48]!==$||e[49]!==M||e[50]!==L?(te=[t,$,O,M,l,m,z,F,d,D,L],e[40]=z,e[41]=F,e[42]=D,e[43]=t,e[44]=m,e[45]=O,e[46]=l,e[47]=d,e[48]=$,e[49]=M,e[50]=L,e[51]=te):te=e[51],w.useLayoutEffect(Q,te),j){let de;return e[52]!==j?(de=a.jsx("p",{role:"alert",className:"p-4 text-sm text-destructive",children:j}),e[52]=j,e[53]=de):de=e[53],de}if(!v){let de;return e[54]===Symbol.for("react.memo_cache_sentinel")?(de=a.jsx("p",{role:"status",className:"p-4 text-sm text-muted-foreground",children:"Loading plugin…"}),e[54]=de):de=e[54],de}const J=v.payload,ne=`${l}:${v.leaseId}`;let re;e[55]!==o||e[56]!==se||e[57]!==s.manifest||e[58]!==u||e[59]!==r?(re=Zce(s.manifest,r,o,u,se),e[55]=o,e[56]=se,e[57]=s.manifest,e[58]=u,e[59]=r,e[60]=re):re=e[60];const le=i??s.manifest.name;let ae;e[61]!==o||e[62]!==O||e[63]!==v.payload||e[64]!==v.runtime.execute||e[65]!==v.runtime.fail||e[66]!==ne||e[67]!==re||e[68]!==le?(ae=a.jsx(Hce,{payload:J,digest:O,activationKey:ne,context:re,active:o,title:le,execute:v.runtime.execute,onError:v.runtime.fail}),e[61]=o,e[62]=O,e[63]=v.payload,e[64]=v.runtime.execute,e[65]=v.runtime.fail,e[66]=ne,e[67]=re,e[68]=le,e[69]=ae):ae=e[69];let ue;return e[70]!==f||e[71]!==ae?(ue=a.jsxs(a.Fragment,{children:[ae,f]}),e[70]=f,e[71]=ae,e[72]=ue):ue=e[72],ue}function rue(){}function oue(){return Array.from(crypto.getRandomValues(new Uint8Array(16)),iue).join("")}function iue(n){return n.toString(16).padStart(2,"0")}function aue(n,e,t){const s=q.c(16);let r;s[0]===Symbol.for("react.memo_cache_sentinel")?(r={summary:null,loading:!1,error:null},s[0]=r):r=s[0];const[o,i]=w.useState(r),[l,c]=w.useState(0);let u,d;s[1]!==n||s[2]!==e?(u=()=>{i({summary:null,loading:!!(n&&e),error:null})},d=[n,e],s[1]=n,s[2]=e,s[3]=u,s[4]=d):(u=s[3],d=s[4]),w.useEffect(u,d);let f;s[5]!==n||s[6]!==e?(f=()=>{if(!n||!e)return;const x=new AbortController;i(cue);const b=new URLSearchParams({dirName:n,fileName:e});return Re(`/api/usage-cost/session?${b}`,{signal:x.signal}).then(async y=>{if(!y.ok)throw new Error(`Cost scan failed (${y.status})`);const v=await y.json();i({summary:v,loading:!1,error:null})}).catch(y=>{x.signal.aborted||i(v=>({...v,loading:!1,error:y instanceof Error?y.message:"Cost scan failed"}))}),()=>x.abort()},s[5]=n,s[6]=e,s[7]=f):f=s[7];let m;s[8]!==n||s[9]!==e||s[10]!==l||s[11]!==t?(m=[n,e,l,t],s[8]=n,s[9]=e,s[10]=l,s[11]=t,s[12]=m):m=s[12],w.useEffect(f,m);let p;s[13]===Symbol.for("react.memo_cache_sentinel")?(p=()=>c(lue),s[13]=p):p=s[13];const h=p;let g;return s[14]!==o?(g={...o,refresh:h},s[14]=o,s[15]=g):g=s[15],g}function lue(n){return n+1}function cue(n){return{...n,loading:!0,error:null}}function uue(n){return n.records===0?"No usage":n.unpricedRecords===n.records?"Rates unavailable":n.unpricedRecords>0?"Partial estimate":n.providerReportedRecords===n.records?"Provider reported":n.providerReportedRecords>0?"Transcript + API rates":"Current API rates"}function due(n){return[{label:"New input",tokens:n.totals.uncachedInputTokens,costUsd:n.breakdown.uncachedInputUsd},{label:"Cache reads",tokens:n.totals.cachedInputTokens,costUsd:n.breakdown.cachedInputUsd},{label:"Cache writes",tokens:n.totals.cacheCreationTokens,costUsd:n.breakdown.cacheCreationUsd},{label:"Output",tokens:n.totals.outputTokens,costUsd:n.breakdown.outputUsd},{label:"Provider total",tokens:0,costUsd:n.breakdown.unallocatedUsd}].filter(e=>e.tokens>0||e.costUsd>0)}function fue(){const n=q.c(3);let e,t;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx(Wn,{className:"h-4 w-24"}),a.jsx(Wn,{className:"h-10 w-32"}),a.jsx(Wn,{className:"h-3 w-44"})]}),t=a.jsx(Wn,{className:"h-20 w-full"}),n[0]=e,n[1]=t):(e=n[0],t=n[1]);let s;return n[2]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsxs("div",{className:"flex flex-col gap-5 pt-2",role:"status","aria-label":"Reading session cost",children:[e,t,a.jsxs("div",{className:"flex flex-col gap-3",children:[a.jsx(Wn,{className:"h-8 w-full"}),a.jsx(Wn,{className:"h-8 w-full"}),a.jsx(Wn,{className:"h-8 w-full"})]})]}),n[2]=s):s=n[2],s}function mue(n){const e=q.c(10),{message:t,retry:s}=n;let r,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(Pd,{}),o=a.jsx(_n,{children:"Cost unavailable"}),e[0]=r,e[1]=o):(r=e[0],o=e[1]);let i;e[2]!==t?(i=a.jsx(Qt,{children:t}),e[2]=t,e[3]=i):i=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(On,{"data-icon":"inline-start"}),e[4]=l):l=e[4];let c;e[5]!==s?(c=a.jsxs(ee,{variant:"outline",size:"xs",onClick:s,className:"mt-2",children:[l,"Retry"]}),e[5]=s,e[6]=c):c=e[6];let u;return e[7]!==i||e[8]!==c?(u=a.jsxs(Jt,{variant:"destructive",className:"mt-2",children:[r,o,i,c]}),e[7]=i,e[8]=c,e[9]=u):u=e[9],u}function fu(n){const e=q.c(7),{label:t,value:s}=n;let r;e[0]!==t?(r=a.jsx("dt",{className:"text-xs text-muted-foreground",children:t}),e[0]=t,e[1]=r):r=e[1];let o;e[2]!==s?(o=a.jsx("dd",{className:"truncate text-sm font-medium text-foreground tabular-nums",children:s}),e[2]=s,e[3]=o):o=e[3];let i;return e[4]!==r||e[5]!==o?(i=a.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[r,o]}),e[4]=r,e[5]=o,e[6]=i):i=e[6],i}function pue(n){const e=q.c(22),{row:t,totalCost:s}=n,r=s>0?t.costUsd/s*100:0;let o;e[0]!==t.label?(o=a.jsx(Fj,{children:t.label}),e[0]=t.label,e[1]=o):o=e[1];let i;e[2]!==t.costUsd?(i=a.jsx(Uj,{children:()=>ms(t.costUsd)}),e[2]=t.costUsd,e[3]=i):i=e[3];let l;e[4]!==r||e[5]!==o||e[6]!==i?(l=a.jsxs(Xl,{value:r,children:[o,i]}),e[4]=r,e[5]=o,e[6]=i,e[7]=l):l=e[7];let c;e[8]!==t.tokens?(c=t.tokens>0?Nt(t.tokens):"Reported by provider",e[8]=t.tokens,e[9]=c):c=e[9];let u;e[10]!==c?(u=a.jsx("span",{children:c}),e[10]=c,e[11]=u):u=e[11];let d;e[12]!==r?(d=r>0?`${r.toFixed(1)}%`:"—",e[12]=r,e[13]=d):d=e[13];let f;e[14]!==d?(f=a.jsx("span",{children:d}),e[14]=d,e[15]=f):f=e[15];let m;e[16]!==u||e[17]!==f?(m=a.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs text-muted-foreground tabular-nums",children:[u,f]}),e[16]=u,e[17]=f,e[18]=m):m=e[18];let p;return e[19]!==l||e[20]!==m?(p=a.jsxs("div",{className:"flex flex-col gap-1.5",children:[l,m]}),e[19]=l,e[20]=m,e[21]=p):p=e[21],p}function hue(n){const e=q.c(8),{summary:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx("h3",{id:"cost-models-heading",className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"By model"}),e[0]=s):s=e[0];let r;if(e[1]!==t.costUsd||e[2]!==t.models){let i;e[4]!==t.costUsd?(i=l=>{const c=t.costUsd>0?l.costUsd/t.costUsd*100:0;return a.jsxs("div",{className:"flex flex-col gap-1.5",children:[a.jsxs(Xl,{value:c,children:[a.jsx(Fj,{title:l.model,children:Zo(l.model)}),a.jsx(Uj,{children:()=>l.costSource==="unpriced"?"Unpriced":ms(l.costUsd)})]}),a.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs text-muted-foreground tabular-nums",children:[a.jsxs("span",{children:[l.records," ",l.records===1?"call":"calls"]}),a.jsxs("span",{children:[Nt(Dx(l.totals))," tokens"]})]})]},l.model)},e[4]=t.costUsd,e[5]=i):i=e[5],r=t.models.map(i),e[1]=t.costUsd,e[2]=t.models,e[3]=r}else r=e[3];let o;return e[6]!==r?(o=a.jsxs("section",{"aria-labelledby":"cost-models-heading",className:"flex flex-col gap-3",children:[s,a.jsx("div",{className:"flex flex-col gap-3",children:r})]}),e[6]=r,e[7]=o):o=e[7],o}function gue(n){return n.map((e,t)=>({...e,call:t+1})).filter(e=>e.costSource!=="unpriced").sort((e,t)=>t.costUsd-e.costUsd).slice(0,5)}function xue(n){const e=q.c(5),{rows:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx("h3",{id:"cost-calls-heading",className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Most expensive calls"}),e[0]=s):s=e[0];let r;e[1]!==t?(r=t.map(bue),e[1]=t,e[2]=r):r=e[2];let o;return e[3]!==r?(o=a.jsxs("section",{"aria-labelledby":"cost-calls-heading",className:"flex flex-col gap-2",children:[s,a.jsx("ol",{className:"flex flex-col gap-0.5",children:r})]}),e[3]=r,e[4]=o):o=e[4],o}function bue(n){return a.jsxs("li",{className:"flex items-center gap-2 rounded-md px-2 py-1.5 hover:bg-muted/50",children:[a.jsxs("span",{className:"min-w-0 flex-1 truncate text-xs text-foreground",children:["Call ",n.call," · ",Zo(n.model)]}),n.isSubagent&&a.jsx(Ue,{variant:"outline",children:"Agent"}),a.jsx("span",{className:"shrink-0 font-mono text-xs text-foreground tabular-nums",children:ms(n.costUsd)})]},`${n.timestamp}:${n.call}`)}function vue(n){const e=q.c(74),{summary:t}=n;let s;e[0]!==t.provider?(s=xR(t.provider),e[0]=t.provider,e[1]=s):s=e[1];const r=s;let o,i,l,c,u,d;if(e[2]!==r||e[3]!==t){const g=Dx(t.totals),x=due(t);let b;e[10]!==t.calls?(b=gue(t.calls),e[10]=t.calls,e[11]=b):b=e[11],d=b;const y=t.providerReportedRecords+t.modelPricedRecords>0;o="flex flex-col gap-5 pt-2";let v;e[12]===Symbol.for("react.memo_cache_sentinel")?(v=a.jsx("p",{id:"session-cost-heading",className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"API equivalent"}),e[12]=v):v=e[12];let k;e[13]!==r?(k=a.jsx(r,{"aria-hidden":"true"}),e[13]=r,e[14]=k):k=e[14];let j;e[15]!==t.provider?(j=us(t.provider),e[15]=t.provider,e[16]=j):j=e[16];let _;e[17]!==j.displayName||e[18]!==k?(_=a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[v,a.jsxs(Ue,{variant:"outline",children:[k,j.displayName]})]}),e[17]=j.displayName,e[18]=k,e[19]=_):_=e[19];let N;e[20]!==y||e[21]!==t.costUsd?(N=y?ms(t.costUsd):"—",e[20]=y,e[21]=t.costUsd,e[22]=N):N=e[22];let S;e[23]!==N?(S=a.jsx("span",{className:"text-4xl font-semibold tracking-tight text-foreground tabular-nums",children:N}),e[23]=N,e[24]=S):S=e[24];const C=t.unpricedRecords>0?"secondary":"outline";let E;e[25]!==t?(E=uue(t),e[25]=t,e[26]=E):E=e[26];let T;e[27]!==C||e[28]!==E?(T=a.jsx(Ue,{variant:C,children:E}),e[27]=C,e[28]=E,e[29]=T):T=e[29];let A;e[30]!==S||e[31]!==T?(A=a.jsxs("div",{className:"flex items-end justify-between gap-3",children:[S,T]}),e[30]=S,e[31]=T,e[32]=A):A=e[32];const P=t.records===1?"model call":"model calls",I=t.includedSubagents>0?` · ${t.includedSubagents} agent ${t.includedSubagents===1?"transcript":"transcripts"}`:"";let $;e[33]!==t.records||e[34]!==P||e[35]!==I?($=a.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.records," ",P,I]}),e[33]=t.records,e[34]=P,e[35]=I,e[36]=$):$=e[36],e[37]!==_||e[38]!==A||e[39]!==$?(i=a.jsxs("section",{"aria-labelledby":"session-cost-heading",className:"flex flex-col gap-2",children:[_,A,$]}),e[37]=_,e[38]=A,e[39]=$,e[40]=i):i=e[40],e[41]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(Gt,{}),e[41]=l):l=e[41];const O=Nt(g);let M;e[42]!==O?(M=a.jsx(fu,{label:"Processed tokens",value:O}),e[42]=O,e[43]=M):M=e[43];let R;e[44]!==t.cacheSavingsUsd?(R=ms(t.cacheSavingsUsd),e[44]=t.cacheSavingsUsd,e[45]=R):R=e[45];let z;e[46]!==R?(z=a.jsx(fu,{label:"Cache savings",value:R}),e[46]=R,e[47]=z):z=e[47];let W;e[48]!==t.totals.cachedInputTokens?(W=Nt(t.totals.cachedInputTokens),e[48]=t.totals.cachedInputTokens,e[49]=W):W=e[49];let D;e[50]!==W?(D=a.jsx(fu,{label:"Cached input",value:W}),e[50]=W,e[51]=D):D=e[51];let L;e[52]!==t.totals.reasoningTokens?(L=Nt(t.totals.reasoningTokens),e[52]=t.totals.reasoningTokens,e[53]=L):L=e[53];let U;e[54]!==L?(U=a.jsx(fu,{label:"Reasoning",value:L}),e[54]=L,e[55]=U):U=e[55],e[56]!==M||e[57]!==z||e[58]!==D||e[59]!==U?(c=a.jsxs("dl",{className:"grid grid-cols-2 gap-x-4 gap-y-3",children:[M,z,D,U]}),e[56]=M,e[57]=z,e[58]=D,e[59]=U,e[60]=c):c=e[60],u=x.length>0&&a.jsxs(a.Fragment,{children:[a.jsx(Gt,{}),a.jsxs("section",{"aria-labelledby":"cost-breakdown-heading",className:"flex flex-col gap-3",children:[a.jsx("h3",{id:"cost-breakdown-heading",className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Cost by token type"}),a.jsx("div",{className:"flex flex-col gap-4",children:x.map(F=>a.jsx(pue,{row:F,totalCost:t.costUsd},F.label))})]})]}),e[2]=r,e[3]=t,e[4]=o,e[5]=i,e[6]=l,e[7]=c,e[8]=u,e[9]=d}else o=e[4],i=e[5],l=e[6],c=e[7],u=e[8],d=e[9];let f;e[61]!==t?(f=t.models.length>0&&a.jsxs(a.Fragment,{children:[a.jsx(Gt,{}),a.jsx(hue,{summary:t})]}),e[61]=t,e[62]=f):f=e[62];let m;e[63]!==d?(m=d.length>=2&&a.jsxs(a.Fragment,{children:[a.jsx(Gt,{}),a.jsx(xue,{rows:d})]}),e[63]=d,e[64]=m):m=e[64];let p;e[65]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsxs(Jt,{children:[a.jsx(Pd,{}),a.jsx(_n,{children:"How this is calculated"}),a.jsx(Qt,{children:"Token counts come from the provider transcript. Costs use provider totals when present, then current LiteLLM API rates, the same pricing source as ccusage. This is not a subscription bill."})]}),e[65]=p):p=e[65];let h;return e[66]!==o||e[67]!==i||e[68]!==l||e[69]!==c||e[70]!==u||e[71]!==f||e[72]!==m?(h=a.jsxs("div",{className:o,children:[i,l,c,u,f,m,p]}),e[66]=o,e[67]=i,e[68]=l,e[69]=c,e[70]=u,e[71]=f,e[72]=m,e[73]=h):h=e[73],h}function yue(n){const e=q.c(7),{dirName:t,fileName:s,revision:r}=n,{summary:o,loading:i,error:l,refresh:c}=aue(t,s,r);if(l){let d;return e[0]!==l||e[1]!==c?(d=a.jsx(mue,{message:l,retry:c}),e[0]=l,e[1]=c,e[2]=d):d=e[2],d}if(!o){if(i){let f;return e[3]===Symbol.for("react.memo_cache_sentinel")?(f=a.jsx(fue,{}),e[3]=f):f=e[3],f}let d;return e[4]===Symbol.for("react.memo_cache_sentinel")?(d=a.jsx(kn,{className:"mt-2 min-h-52",children:a.jsxs(jn,{children:[a.jsx(Rn,{variant:"icon",children:a.jsx(_P,{})}),a.jsx(Nn,{children:"No transcript cost yet"}),a.jsx(Cn,{children:"Cost appears after the first model response is written."})]})}),e[4]=d):d=e[4],d}let u;return e[5]!==o?(u=a.jsx(vue,{summary:o}),e[5]=o,e[6]=u):u=e[6],u}function wue(n){const e=[];for(let t=0;t<n.length;t++)for(const s of n[t].toolCalls)s.isError&&s.result&&e.push({turnIndex:t,toolName:s.name,message:s.result.slice(0,200)});return e}function Sue(n){const e=q.c(14),{turns:t,onJumpToTurn:s}=n;let r;e[0]!==t?(r=wue(t),e[0]=t,e[1]=r):r=e[1];const o=r;if(o.length===0)return null;let i;e[2]!==o.length?(i=a.jsxs(Ql,{children:["Errors (",o.length,")"]}),e[2]=o.length,e[3]=i):i=e[3];let l;if(e[4]!==o||e[5]!==s){let d;e[7]!==s?(d=(f,m)=>a.jsxs(ee,{type:"button",variant:"ghost",onClick:()=>s==null?void 0:s(f.turnIndex),className:"h-auto w-full flex-col items-stretch rounded-none border-b border-border px-2 py-2.5 text-left whitespace-normal last:border-b-0 hover:bg-destructive/5",children:[a.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[a.jsx("span",{className:"font-medium text-destructive",children:f.toolName}),a.jsxs("span",{className:"text-muted-foreground",children:["Turn ",f.turnIndex+1]})]}),a.jsx("div",{className:"mt-0.5 line-clamp-2 text-xs leading-relaxed text-muted-foreground",children:f.message})]},m),e[7]=s,e[8]=d):d=e[8],l=o.map(d),e[4]=o,e[5]=s,e[6]=l}else l=e[6];let c;e[9]!==l?(c=a.jsx("div",{className:"flex max-h-[300px] flex-col overflow-y-auto pr-1",children:l}),e[9]=l,e[10]=c):c=e[10];let u;return e[11]!==i||e[12]!==c?(u=a.jsxs("section",{children:[i,c]}),e[11]=i,e[12]=c,e[13]=u):u=e[13],u}function bk(n){const e=q.c(42),{agentId:t,subagentType:s,agentName:r,preview:o,isViewing:i,isBackground:l,status:c,durationMs:u,toolUseCount:d,disabled:f,onClick:m,onStop:p}=n;let h;e[0]!==t||e[1]!==r||e[2]!==s?(h=r||Cx(t,s),e[0]=t,e[1]=r,e[2]=s,e[3]=h):h=e[3];const g=h;let x;e[4]!==u?(x=u==null?null:u<1e3?`${u}ms`:`${(u/1e3).toFixed(u>=1e4?0:1)}s`,e[4]=u,e[5]=x):x=e[5];const b=x;let y;e[6]!==c?(y=c==="running"?a.jsx(vt,{className:"size-3 shrink-0 animate-spin text-success","data-icon":"inline-start"}):c==="done"?a.jsx(Mr,{className:"size-3 shrink-0 text-success","data-icon":"inline-start"}):c==="failed"?a.jsx(vo,{className:"size-3 shrink-0 text-destructive","data-icon":"inline-start"}):a.jsx(s1,{className:"size-2.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),e[6]=c,e[7]=y):y=e[7];const v=y,k=i?"bg-accent":"hover:bg-muted/40";let j;e[8]!==k?(j=G("motion-list-item flex w-full items-start border-b border-border text-left transition-colors last:border-b-0",k),e[8]=k,e[9]=j):j=e[9];let _;e[10]!==g?(_=a.jsx(Ue,{variant:"outline",children:g}),e[10]=g,e[11]=_):_=e[11];let N;e[12]!==l?(N=l&&a.jsx(Ue,{variant:"outline",children:"Background"}),e[12]=l,e[13]=N):N=e[13];let S;e[14]!==i?(S=i&&a.jsx(Ue,{children:"Viewing"}),e[14]=i,e[15]=S):S=e[15];const C=c==="running"?"active":c;let E;e[16]!==C?(E=a.jsx("span",{className:"ml-auto text-xs uppercase tracking-wide text-muted-foreground",children:C}),e[16]=C,e[17]=E):E=e[17];let T;e[18]!==v||e[19]!==E||e[20]!==_||e[21]!==N||e[22]!==S?(T=a.jsxs("div",{className:"flex items-center gap-1.5",children:[v,_,N,S,E]}),e[18]=v,e[19]=E,e[20]=_,e[21]=N,e[22]=S,e[23]=T):T=e[23];let A;e[24]!==o?(A=o&&a.jsx("p",{className:"mt-1 line-clamp-2 text-xs leading-relaxed text-muted-foreground",children:o}),e[24]=o,e[25]=A):A=e[25];let P;e[26]!==b||e[27]!==d?(P=(b||d!=null)&&a.jsxs("div",{className:"mt-1.5 flex items-center gap-2 text-xs text-muted-foreground",children:[b&&a.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[a.jsx(Wu,{className:"size-2.5","data-icon":"inline-start"}),b]}),d!=null&&a.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[a.jsx(Rd,{className:"size-2.5","data-icon":"inline-start"}),d," tools"]})]}),e[26]=b,e[27]=d,e[28]=P):P=e[28];let I;e[29]!==f||e[30]!==m||e[31]!==T||e[32]!==A||e[33]!==P?(I=a.jsxs(ee,{type:"button",variant:"ghost",onClick:m,disabled:f,className:"h-auto min-w-0 flex-1 flex-col items-stretch rounded-none px-2.5 py-2 text-left whitespace-normal",children:[T,A,P]}),e[29]=f,e[30]=m,e[31]=T,e[32]=A,e[33]=P,e[34]=I):I=e[34];let $;e[35]!==g||e[36]!==p?($=p&&a.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",className:"m-1",onClick:p,"aria-label":`Stop ${g}`,children:a.jsx(Ut,{"data-icon":"inline-start"})}),e[35]=g,e[36]=p,e[37]=$):$=e[37];let O;return e[38]!==I||e[39]!==$||e[40]!==j?(O=a.jsxs("div",{className:j,children:[I,$]}),e[38]=I,e[39]=$,e[40]=j,e[41]=O):O=e[41],O}function kue(n,e=!1){const t=n==null?void 0:n.toLowerCase();return t==="completed"||t==="success"||t==="done"?"done":t==="failed"||t==="error"||t==="cancelled"?"failed":e||t==="running"||t==="async_launched"?"running":"seen"}function Og(n){return n.split(`
|
|
439
|
+
`).map(e=>e.trim()).find(Boolean)??""}function jue(n){return n.name==="Task"||n.name==="Agent"}function Nue(n,e){var o;const t=new Map;for(const i of n.turns)for(const l of i.contentBlocks)if(!(l.kind!=="sub_agent"&&l.kind!=="background_agent"))for(const c of l.messages){const u=t.get(c.agentId),d=kue(c.status);t.set(c.agentId,{agentId:c.agentId,agentName:c.agentName??(u==null?void 0:u.agentName)??null,subagentType:c.subagentType??(u==null?void 0:u.subagentType)??null,preview:Og(((o=c.prompt)==null?void 0:o.trim())||c.text.find(f=>f.trim())||"")||(u==null?void 0:u.preview)||"No task summary recorded",isBackground:c.isBackground||(u==null?void 0:u.isBackground)||!1,status:d==="seen"&&(u!=null&&u.status)?u.status:d,durationMs:c.durationMs??(u==null?void 0:u.durationMs),toolUseCount:c.toolUseCount??(u==null?void 0:u.toolUseCount),parentToolUseId:c.parentToolUseId??(u==null?void 0:u.parentToolUseId)})}const s=new Set;for(const i of t.values())i.parentToolUseId&&s.add(i.parentToolUseId);const r=new Set;for(const i of e)i.parentToolUseId&&r.add(i.parentToolUseId);for(const i of n.turns)for(const l of i.toolCalls){if(!jue(l)||!r.has(l.id)||s.has(l.id))continue;const c=l.input;t.set(`tool:${l.id}`,{agentId:`tool:${l.id}`,agentName:typeof c.name=="string"?c.name:null,subagentType:typeof c.subagent_type=="string"?c.subagent_type:null,preview:Og(typeof c.prompt=="string"?c.prompt:typeof c.description=="string"?c.description:"Agent task in progress"),isBackground:!1,status:"running",parentToolUseId:l.id})}return[...t.values()]}function Cue({session:n,sessionSource:e,bgAgents:t,canStop:s,onLoadSession:r}){const o=jx(),i=w.useMemo(()=>{if(!e)return null;const v=lo(e.fileName);return v?{...v,dirName:e.dirName}:null},[e]),l=w.useMemo(()=>Nue(n,o),[n,o]),c=w.useRef(l);w.useEffect(()=>{!i&&l.length>0&&(c.current=l)},[i,l]);const u=i&&l.length===0?c.current:l,d=w.useMemo(()=>{if(i)return i.parentSessionId;if(e!=null&&e.fileName){const v=e.fileName.match(/^([^/]+)\.jsonl$/);if(v)return v[1]}return null},[i,e]),f=w.useMemo(()=>d?t.filter(v=>v.parentSessionId===d):t,[t,d]),m=w.useMemo(()=>new Map(u.map(v=>[v.agentId,v])),[u]),p=w.useMemo(()=>{const v=new Set(f.map(k=>k.agentId));return u.filter(k=>!v.has(k.agentId))},[f,u]),h=w.useMemo(()=>[...f].sort((v,k)=>k.modifiedAt-v.modifiedAt),[f]),g=w.useMemo(()=>[...p].reverse(),[p]),x=f.length+p.length;if(x===0)return null;const b=v=>{Re(`/api/claude/tasks/${encodeURIComponent(n.sessionId)}/${encodeURIComponent(v)}`,{method:"DELETE"})},y=(i==null?void 0:i.agentId)??null;return a.jsxs("section",{children:[a.jsxs(Ql,{children:["Agents (",x,")"]}),i&&r&&a.jsxs(ee,{type:"button",variant:"outline",size:"sm",onClick:()=>r(i.dirName,i.parentFileName),className:"mb-2 w-full justify-start",children:[a.jsx(ot,{"data-icon":"inline-start",className:"rotate-180"}),"Back to Main Agent"]}),a.jsxs("div",{className:"flex max-h-[280px] flex-col gap-1.5 overflow-y-auto pr-0.5",children:[h.map(v=>{const k=Og(v.preview??""),j=m.get(v.agentId);return a.jsx(bk,{agentId:v.agentId,subagentType:(j==null?void 0:j.subagentType)??null,agentName:(j==null?void 0:j.agentName)??null,preview:(j==null?void 0:j.preview)||(k!==v.agentId?k:""),isViewing:y===v.agentId,isBackground:!0,status:v.isActive?"running":(j==null?void 0:j.status)==="failed"?"failed":"done",durationMs:j==null?void 0:j.durationMs,toolUseCount:j==null?void 0:j.toolUseCount,disabled:!r,onStop:s&&v.isActive?()=>b(v.agentId):void 0,onClick:()=>r==null?void 0:r(v.dirName,v.fileName)},v.agentId)}),g.map(v=>{const k=!!r&&!!d&&!!e&&!v.agentId.startsWith("tool:");return a.jsx(bk,{agentId:v.agentId,subagentType:v.subagentType,agentName:v.agentName,preview:v.preview,isViewing:y===v.agentId,isBackground:v.isBackground,status:v.status,durationMs:v.durationMs,toolUseCount:v.toolUseCount,disabled:!k,onClick:()=>{k&&r(e.dirName,`${d}/subagents/agent-${v.agentId}.jsonl`)}},v.agentId)})]})]})}function _ue(n,e){return`${n.id}-${e}`}function Eue(n){const e=q.c(14),{turns:t,onJumpToTurn:s}=n,[r,o]=w.useState(null);if(t.length===0)return null;let i;e[0]!==t.length?(i=a.jsxs(Ql,{children:["Turns (",t.length,")"]}),e[0]=t.length,e[1]=i):i=e[1];let l;if(e[2]!==r||e[3]!==s||e[4]!==t){let d;e[6]!==r||e[7]!==s?(d=(f,m)=>{const p=cf(f.userMessage),h=r===m;return a.jsxs(ee,{type:"button",variant:"ghost",onClick:()=>{o(m),s==null||s(m)},className:G("group h-auto w-full justify-start gap-2 px-2 py-1.5 text-left font-normal",h?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:[a.jsx("span",{className:"mt-0.5 shrink-0 font-mono text-xs text-muted-foreground",children:String(m+1).padStart(2,"0")}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-xs",children:p?Is(p,50):"(no message)"}),a.jsx("span",{className:"flex shrink-0 items-center gap-1",children:f.toolCalls.length>0&&a.jsx(Ue,{variant:"secondary",className:"font-normal",children:f.toolCalls.length})})]},_ue(f,m))},e[6]=r,e[7]=s,e[8]=d):d=e[8],l=t.map(d),e[2]=r,e[3]=s,e[4]=t,e[5]=l}else l=e[5];let c;e[9]!==l?(c=a.jsx("div",{className:"max-h-[400px] overflow-y-auto",children:a.jsx("div",{className:"flex flex-col gap-0.5 pr-2",children:l})}),e[9]=l,e[10]=c):c=e[10];let u;return e[11]!==i||e[12]!==c?(u=a.jsxs("section",{children:[i,c]}),e[11]=i,e[12]=c,e[13]=u):u=e[13],u}const Lg=new Map;let ah=null,lh=null;async function Tue(){try{const n=await Re("/api/usage-cost/rates");if(!n.ok)return Lg;const e=await n.json();return new Map(Object.entries(e.rates??{}))}catch{return Lg}}function Aue(){const[n,e]=w.useState(ah??Lg);return w.useEffect(()=>{if(ah!==null)return;let t=!0;return lh??(lh=Tue().then(s=>(s.size>0&&(ah=s),lh=null,s))),lh.then(s=>{t&&e(s)}),()=>{t=!1}},[]),n}function Pue(n){const e=n.input;return e.file_path&&typeof e.file_path=="string"?e.file_path.split("/").slice(-2).join("/"):e.command&&typeof e.command=="string"?Is(e.command,40):e.pattern&&typeof e.pattern=="string"?e.pattern:e.query&&typeof e.query=="string"?Is(e.query,40):e.url&&typeof e.url=="string"?Is(e.url,40):Is(PB(n),40)}function Iue(n,e){return n.map(t=>{const s=t.tokenUsage;return!s||t.toolCalls.length===0?0:tG(e,t.model,s)/t.toolCalls.length})}function $ue(n,e){const t=new Map;for(let s=0;s<n.length;s++)for(const r of n[s].toolCalls){const o=aa(r);t.has(o.label)||t.set(o.label,{calls:[],count:0,estimatedCost:0,styleName:o.styleName});const i=t.get(o.label);i.calls.push({tc:r,turnIndex:s}),i.count++,i.estimatedCost+=e[s]}return Array.from(t.entries()).sort((s,r)=>r[1].count-s[1].count)}function Rue(n){const e=q.c(14),{turns:t,onJumpToTurn:s}=n,r=Aue();let o;e[0]!==r||e[1]!==t?(o=Iue(t,r),e[0]=r,e[1]=t,e[2]=o):o=e[2];const i=o;let l;e[3]!==i||e[4]!==t?(l=$ue(t,i),e[3]=i,e[4]=t,e[5]=l):l=e[5];const c=l;if(c.length===0)return null;let u;e[6]===Symbol.for("react.memo_cache_sentinel")?(u=a.jsx(Ql,{children:"Tool Calls"}),e[6]=u):u=e[6];let d;if(e[7]!==s||e[8]!==c){let m;e[10]!==s?(m=p=>{const[h,g]=p;return a.jsxs(En,{children:[a.jsxs(vs,{className:"group flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-xs transition-colors hover:bg-muted",children:[a.jsx(ot,{className:"size-3 shrink-0 text-muted-foreground transition-transform group-data-panel-open:rotate-90 motion-reduce:transition-none"}),a.jsx("span",{className:"font-medium text-foreground",children:h}),a.jsxs("span",{className:"ml-auto flex items-center gap-1.5",children:[g.estimatedCost>0&&a.jsx("span",{className:"font-mono text-xs text-warning",children:ms(g.estimatedCost)}),a.jsx(Ue,{variant:"secondary",className:"font-normal",children:g.count})]})]}),a.jsx(Tn,{children:a.jsxs("div",{className:"ml-4 flex flex-col gap-0.5 border-l border-border pl-2 pt-0.5",children:[g.calls.slice(0,50).map((x,b)=>{const{tc:y,turnIndex:v}=x,k=Pue(y);return a.jsx("div",{children:a.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>s==null?void 0:s(v,y.id),className:G("h-auto w-full justify-start gap-1 px-1.5 py-0.5 text-left font-mono text-xs font-normal",y.isError?"text-destructive hover:bg-destructive/10":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:[y.isError&&a.jsx(lr,{className:"size-2.5 shrink-0 text-destructive","data-icon":"inline-start"}),a.jsx("span",{className:"truncate",children:k||y.id.slice(0,8)})]})},`${y.id}-${b}`)}),g.calls.length>50&&a.jsxs("div",{className:"px-1.5 py-0.5 text-xs text-muted-foreground",children:["+",g.calls.length-50," more"]})]})})]},h)},e[10]=s,e[11]=m):m=e[11],d=c.map(m),e[7]=s,e[8]=c,e[9]=d}else d=e[9];let f;return e[12]!==d?(f=a.jsxs("section",{children:[u,a.jsx("div",{className:"max-h-[320px] overflow-y-auto",children:a.jsx("div",{className:"flex flex-col gap-0.5 pr-2",children:d})})]}),e[12]=d,e[13]=f):f=e[13],f}function Oue(n){const e=q.c(19),{searchInputRef:t}=n,{state:s,dispatch:r}=bn(),{searchQuery:o,expandAll:i}=s,{actions:l}=xt(),{handleToggleExpandAll:c}=l;let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=a.jsx("span",{className:"text-sm font-medium text-foreground",children:"Session details"}),e[0]=u):u=e[0];const d=i?"Collapse all":"Expand all";let f;e[1]!==i?(f=i?a.jsx(Md,{"data-icon":"inline-start"}):a.jsx(Ji,{"data-icon":"inline-start"}),e[1]=i,e[2]=f):f=e[2];let m;e[3]!==c||e[4]!==d||e[5]!==f?(m=a.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[u,a.jsx(ee,{variant:"ghost",size:"icon-sm",className:"shrink-0",onClick:c,"aria-label":d,children:f})]}),e[3]=c,e[4]=d,e[5]=f,e[6]=m):m=e[6];const p=o??"";let h;e[7]!==r?(h=v=>r({type:"SET_SEARCH_QUERY",value:v.target.value}),e[7]=r,e[8]=h):h=e[8];let g;e[9]!==t||e[10]!==p||e[11]!==h?(g=a.jsx(ko,{ref:t,type:"text",value:p,onChange:h,placeholder:"Search conversation","aria-label":"Search conversation"}),e[9]=t,e[10]=p,e[11]=h,e[12]=g):g=e[12];let x;e[13]===Symbol.for("react.memo_cache_sentinel")?(x=a.jsx(or,{align:"inline-start",children:a.jsx(Yn,{})}),e[13]=x):x=e[13];let b;e[14]!==g?(b=a.jsxs(So,{children:[g,x]}),e[14]=g,e[15]=b):b=e[15];let y;return e[16]!==b||e[17]!==m?(y=a.jsxs("div",{className:"sticky top-0 border-b bg-popover px-3 py-3",children:[m,b]}),e[16]=b,e[17]=m,e[18]=y):y=e[18],y}const Lue=w.memo(function(e){const t=q.c(50),{onJumpToTurn:s,onToggleServer:r,onServersChanged:o,searchInputRef:i,onLoadSession:l,backgroundAgents:c}=e,{isMobile:u}=bn(),{session:d,sessionSource:f,permissions:m}=xt(),p=mn("killAny"),h=d,{turns:g}=h;let x;t[0]!==h.stats.totalCacheCreationTokens||t[1]!==h.stats.totalCacheReadTokens||t[2]!==h.stats.totalInputTokens||t[3]!==h.stats.totalOutputTokens||t[4]!==g.length?(x=[h.stats.totalInputTokens,h.stats.totalOutputTokens,h.stats.totalCacheCreationTokens,h.stats.totalCacheReadTokens,g.length],t[0]=h.stats.totalCacheCreationTokens,t[1]=h.stats.totalCacheReadTokens,t[2]=h.stats.totalInputTokens,t[3]=h.stats.totalOutputTokens,t[4]=g.length,t[5]=x):x=t[5];const b=x.join(":"),y=u?"mobile-scroll w-full flex-1":"w-full";let v;t[6]!==y?(v=G("h-full min-h-0 shrink-0 overflow-y-auto bg-canvas",y),t[6]=y,t[7]=v):v=t[7];let k;t[8]!==i?(k=i&&a.jsx(Oue,{searchInputRef:i}),t[8]=i,t[9]=k):k=t[9];const j=u?"p-4":"p-3";let _;t[10]!==j?(_=G(j),t[10]=j,t[11]=_):_=t[11];let N;t[12]===Symbol.for("react.memo_cache_sentinel")?(N=a.jsxs(Zj,{variant:"line",className:"grid w-full grid-cols-4",children:[a.jsx(Ea,{value:"activity",children:"Activity"}),a.jsx(Ea,{value:"agents",children:"Agents"}),a.jsx(Ea,{value:"cost",children:"Cost"}),a.jsx(Ea,{value:"issues",children:"Issues"})]}),t[12]=N):N=t[12];let S;t[13]!==s||t[14]!==g?(S=a.jsxs(Ta,{value:"activity",className:"flex flex-col gap-6 pt-3",children:[a.jsx(Eue,{turns:g,onJumpToTurn:s}),a.jsx(Rue,{turns:g,onJumpToTurn:s})]}),t[13]=s,t[14]=g,t[15]=S):S=t[15];const C=p&&m.stop;let E;t[16]!==o||t[17]!==r||t[18]!==h.cwd||t[19]!==C||t[20]!==g?(E=a.jsx(Qj,{cwd:h.cwd,turns:g,canStop:C,onToggleServer:r,onServersChanged:o}),t[16]=o,t[17]=r,t[18]=h.cwd,t[19]=C,t[20]=g,t[21]=E):E=t[21];let T;t[22]!==c?(T=c??[],t[22]=c,t[23]=T):T=t[23];let A;t[24]!==l||t[25]!==m.stop||t[26]!==h||t[27]!==f||t[28]!==T?(A=a.jsx(Cue,{session:h,sessionSource:f,bgAgents:T,canStop:m.stop,onLoadSession:l}),t[24]=l,t[25]=m.stop,t[26]=h,t[27]=f,t[28]=T,t[29]=A):A=t[29];let P;t[30]!==E||t[31]!==A?(P=a.jsxs(Ta,{value:"agents",className:"flex flex-col gap-6 pt-3",children:[E,A]}),t[30]=E,t[31]=A,t[32]=P):P=t[32];const I=(f==null?void 0:f.dirName)??null,$=(f==null?void 0:f.fileName)??null;let O;t[33]!==b||t[34]!==I||t[35]!==$?(O=a.jsx(Ta,{value:"cost",className:"pt-3",children:a.jsx(yue,{dirName:I,fileName:$,revision:b})}),t[33]=b,t[34]=I,t[35]=$,t[36]=O):O=t[36];let M;t[37]!==s||t[38]!==g?(M=a.jsx(Ta,{value:"issues",className:"flex flex-col gap-6 pt-3",children:a.jsx(Sue,{turns:g,onJumpToTurn:s})}),t[37]=s,t[38]=g,t[39]=M):M=t[39];let R;t[40]!==P||t[41]!==O||t[42]!==M||t[43]!==_||t[44]!==S?(R=a.jsxs(Gj,{defaultValue:"activity",className:_,children:[N,S,P,O,M]}),t[40]=P,t[41]=O,t[42]=M,t[43]=_,t[44]=S,t[45]=R):R=t[45];let z;return t[46]!==R||t[47]!==v||t[48]!==k?(z=a.jsxs("aside",{className:v,children:[k,R]}),t[46]=R,t[47]=v,t[48]=k,t[49]=z):z=t[49],z}),Mue="default",zue="tmp-",Due=/^[a-z0-9][a-z0-9_-]{0,39}$/;function Fue(n){return Due.test(n)}function Uue(n){return n.startsWith(zue)}function vk(n,e){let t="",s="",r=!0,o=e;for(;o<n.length;o++){const i=n[o],l=n[o+1];if(!s&&/[\s;&|()<>]/.test(i))break;if(i==="\\"&&s!=="'"){if(l===void 0)return null;if(!s||/[$`"\\\n]/.test(l)){l!==`
|
|
440
|
+
`&&(t+=l),o++;continue}}if(i===s){s="";continue}if(!s&&(i==="'"||i==='"')){s=i;continue}if(s!=="'"){if(i==="`"||i==="$"&&/[('"{]/.test(l??""))return null;(i==="$"||!s&&/[*?[{}~]/.test(i))&&(r=!1)}t+=i}return s?null:{value:t,start:e,end:o,literal:r}}function Bue(n){const e=[];let t=[],s=0,r=0;const o=()=>({commands:[...e,{words:t,end:n.length,pipeline:s}],complete:!1});for(let i=0;i<n.length;){const l=n[i];if(l==="\\"&&n[i+1]===`
|
|
441
|
+
`){i+=2;continue}if(l==="#"){const d=n.indexOf(`
|
|
442
|
+
`,i);e.push({words:t,end:i,pipeline:s}),t.length>0&&r===0&&s++,t=[],i=d<0?n.length:d;continue}if(/[^\S\n]/.test(l)){i++;continue}if(/[;&|()\n]/.test(l)){const d=n[i+1],f=l==="|"&&d!=="|";if(l==="("&&r++,l===")"&&r--,r<0)return o();e.push({words:t,end:i,pipeline:s}),r===0&&!f&&l!=="("&&l!==")"&&(l!==`
|
|
443
|
+
`||t.length>0)&&s++,t=[],i+=(l==="&"||l==="|")&&(d===l||f&&d==="&")?2:1;continue}if(/^(?:\d+)?<</.test(n.slice(i)))return o();const c=/^(?:\d+)?(?:>>|>\||>&|<&|<>|[<>])/.exec(n.slice(i));if(c){for(i+=c[0].length;/[^\S\n]/.test(n[i]??"");)i++;const d=vk(n,i);if(!d||d.end===i)return o();i=d.end;continue}const u=vk(n,i);if(!u||u.end===i)return o();t.push(u),i=u.end}return e.push({words:t,end:n.length,pipeline:s}),{commands:e,complete:r===0}}const Ba="agent-browser",Wue=new Map([["env",new Set(["-i","--ignore-environment","--"])],["command",new Set(["--"])],["exec",new Set(["--"])],["npx",new Set(["-y","--yes","--"])],["bunx",new Set(["--bun","--"])]]),que=new Set(["echo","printf","rg","grep","cat","head","tail","wc","ls","stat","file","basename","dirname","cp","mv","rm","mkdir","rmdir","touch"]),Vue=new Set(["commit","log","show","diff","status","add","grep","ls-files","rev-parse"]),Hue=/^(?:if|then|else|elif|fi|while|until|for|select|case|esac|do|done|function|\{|\}|!)$/,Kue=/^[A-Za-z_][A-Za-z_\d]*=/;function LT(n){return n.slice(n.lastIndexOf("/")+1)}function Gue(n,e){var s,r;let t=0;for(;t<n.length;){const o=n[t];if(Kue.test(e.slice(o.start,o.end))){t++;continue}if(!o.literal||Hue.test(o.value))return null;const i=LT(o.value);if(i==="command"&&["-v","-V"].includes((s=n[t+1])==null?void 0:s.value))return-1;const l=Wue.get(i);if(!l)return t;for(t++;(r=n[t])!=null&&r.value.startsWith("-");){if(!n[t].literal||!l.has(n[t].value))return null;if(n[t++].value==="--")break}}return-1}function Zue(n,e,t){const[s,...r]=n;if(r.some(l=>!l.literal))return null;let o=Mue,i=null;for(let l=0;l<r.length;l++){const c=r[l];if(c.value!=="--session"&&!c.value.startsWith("--session="))continue;if(i!==null)return null;const u=c.value==="--session"?r[++l]:c;if(o=c.value==="--session"?u==null?void 0:u.value:c.value.slice(10),!o||!Fue(o)||u!==c&&!/^(?:\s|\\\n)*$/.test(t.slice(c.end,u.start)))return null;i={start:c.start,end:u.end}}return{text:Ba+t.slice(s.end,e).trimEnd(),binaryEnd:s.end,browser:o,sessionFlag:i}}function Yue(n){var l;const{commands:e,complete:t}=Bue(n),s=[],r=e.some(({words:c})=>c.some(({value:u})=>u.includes(Ba)));if(!t)return{invocations:s,ambiguous:r||n.includes(Ba)};const o=new Set(e.filter(({words:c})=>c.some(({value:u})=>u.includes(Ba))).map(({pipeline:c})=>c));let i=!1;for(const{words:c,end:u,pipeline:d}of e){const f=Gue(c,n);if(f===null){i||(i=r);continue}if(f<0)continue;const m=LT(c[f].value);if(m!==Ba){!(que.has(m)||m==="git"&&Vue.has((l=c[f+1])==null?void 0:l.value))&&o.has(d)&&(i=!0);continue}const p=Zue(c.slice(f),u,n);p===null?i=!0:s.push(p)}return{invocations:s,ambiguous:i}}function Xue(n){return Yue(n).invocations}const yk=120,Jue=/(?:^|[._])exec_command$/;function Que(n){return n==="Bash"||Jue.test(n)}function ede(n){return vD(n).filter(e=>Que(e.name)).map(e=>Xo(e.input))}function tde(n){for(const e of ede(n)){const[t]=Xue(e);if(t===void 0||Uue(t.browser))continue;const{text:s}=t;return{session:t.browser,command:s.length>yk?`${s.slice(0,yk-1)}…`:s,timestamp:n.timestamp,toolCallId:n.id,done:n.result!==null}}return null}function nde(n){const e=(n==null?void 0:n.turns)??[];for(let t=e.length-1;t>=0;t--){const s=e[t].toolCalls;for(let r=s.length-1;r>=0;r--){const o=tde(s[r]);if(o)return o}}return null}const wk=1e4,sde=w.lazy(()=>et(()=>import("./ProjectFilesPanel-DJ-_Lb_R.js"),__vite__mapDeps([30,1,31,2,4,3])).then(n=>({default:n.ProjectFilesPanel}))),rde=w.lazy(()=>et(()=>import("./WorktreePanel-F9QlbnAH.js"),__vite__mapDeps([32,1,2,3,4])).then(n=>({default:n.WorktreePanel}))),ode=w.lazy(()=>et(()=>import("./index-CRUYvx2l.js"),__vite__mapDeps([33,1,2,3,4])).then(n=>({default:n.BrowserPanel})));function A0(){const n=q.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=a.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-sm text-muted-foreground",role:"status",children:[a.jsx(An,{}),"Loading panel…"]}),n[0]=e):e=n[0],e}function ide(n){const e=q.c(6),{context:t,closePanel:s}=n,r=Fx(),o=r.projectFilesRoot??t.projectPath;if(!o)return null;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsx(A0,{}),e[0]=i):i=e[0];let l;return e[1]!==s||e[2]!==o||e[3]!==r.addProjectContext||e[4]!==r.projectFilesRequest?(l=a.jsx(w.Suspense,{fallback:i,children:a.jsx(sde,{cwd:o,onClose:s,onAddToPrompt:r.addProjectContext,openRequest:r.projectFilesRequest},o)}),e[1]=s,e[2]=o,e[3]=r.addProjectContext,e[4]=r.projectFilesRequest,e[5]=l):l=e[5],l}function ade(n){const e=q.c(3),{context:t}=n;if(!t.session)return null;let s;return e[0]!==t.session||e[1]!==t.sessionChangeKey?(s=a.jsx(Bq,{session:t.session,sessionChangeKey:t.sessionChangeKey}),e[0]=t.session,e[1]=t.sessionChangeKey,e[2]=s):s=e[2],s}function lde(){const n=q.c(7),e=Fx();let t;return n[0]!==e.backgroundAgents||n[1]!==e.jumpToTurn||n[2]!==e.loadSession||n[3]!==e.searchInputRef||n[4]!==e.serversChanged||n[5]!==e.toggleServer?(t=a.jsx(Lue,{onJumpToTurn:e.jumpToTurn,onToggleServer:e.toggleServer,onServersChanged:e.serversChanged,searchInputRef:e.searchInputRef,onLoadSession:e.loadSession,backgroundAgents:e.backgroundAgents}),n[0]=e.backgroundAgents,n[1]=e.jumpToTurn,n[2]=e.loadSession,n[3]=e.searchInputRef,n[4]=e.serversChanged,n[5]=e.toggleServer,n[6]=t):t=n[6],t}function cde(n){const e=q.c(3);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=a.jsx(A0,{}),e[0]=t):t=e[0];let s;return e[1]!==n?(s=a.jsx(w.Suspense,{fallback:t,children:a.jsx(ode,{...n})}),e[1]=n,e[2]=s):s=e[2],s}function ude(n){var u;const e=q.c(8),{context:t}=n,[,s]=w.useState(0);let r;e[0]!==t.session?(r=Date.parse(((u=nde(t.session))==null?void 0:u.timestamp)??""),e[0]=t.session,e[1]=r):r=e[1];const o=r;let i;e[2]!==o||e[3]!==s?(i=()=>{const d=o+wk-Date.now();if(Number.isNaN(d)||d<=0)return;const f=setTimeout(()=>s(dde),d);return()=>clearTimeout(f)},e[2]=o,e[3]=s,e[4]=i):i=e[4];let l;if(e[5]!==o?(l=[o],e[5]=o,e[6]=l):l=e[6],w.useEffect(i,l),Number.isNaN(o)||Date.now()-o>=wk)return null;let c;return e[7]===Symbol.for("react.memo_cache_sentinel")?(c=a.jsx("span",{role:"status","aria-label":"The agent is using the browser",className:"absolute -right-0.5 -top-0.5 size-2 rounded-full bg-emerald-500 motion-safe:animate-pulse"}),e[7]=c):c=e[7],c}function dde(n){return n+1}function fde(n){const e=q.c(8),{closePanel:t}=n,s=Fx();let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(A0,{}),e[0]=r):r=e[0];let o;return e[1]!==t||e[2]!==s.openWorktreeSession||e[3]!==s.worktreeDirName||e[4]!==s.worktrees.loading||e[5]!==s.worktrees.refetch||e[6]!==s.worktrees.worktrees?(o=a.jsx(w.Suspense,{fallback:r,children:a.jsx(rde,{worktrees:s.worktrees.worktrees,loading:s.worktrees.loading,dirName:s.worktreeDirName,onRefetch:s.worktrees.refetch,onOpenSession:s.openWorktreeSession,onClose:t})}),e[1]=t,e[2]=s.openWorktreeSession,e[3]=s.worktreeDirName,e[4]=s.worktrees.loading,e[5]=s.worktrees.refetch,e[6]=s.worktrees.worktrees,e[7]=o):o=e[7],o}const mde={id:hi,workspacePanels:[{id:"worktrees",title:"Worktrees",icon:_r,component:fde,order:5,defaultSize:"36%",minSize:"320px",when:n=>n.supportsWorktrees===!0},{id:"project-files",title:"Project files",icon:EP,component:ide,order:10,defaultSize:"55%",minSize:"340px",maxSize:"75%",keepAlive:!0,when:n=>n.canAccessHostFiles&&n.projectPath!==null},{id:"browser",title:"Browser",icon:Pi,component:cde,indicator:ude,order:15,defaultSize:"46%",minSize:"360px",maxSize:"75%",keepAlive:!0,when:n=>n.canUseBrowser},{id:"file-changes",title:"File changes",icon:Ll,component:ade,order:20,defaultSize:"36%",minSize:"320px",when:n=>n.canAccessHostFiles&&n.hasFileChanges&&n.session!==null},{id:"session-info",title:"Session details",icon:TP,component:lde,order:30,defaultSize:"36%",minSize:"320px",when:n=>n.session!==null}]},pde=PH([mde]);function hde(n,e,t){if(!e)return null;const s=l=>{const c=(t==="win32"?l.replaceAll("\\","/").toLowerCase():l).replace(/\/+$/,"")||"/";return c.split("/").some(u=>u==="."||u==="..")?null:c},r=s(e);if(!r)return null;let o=null,i=-1;for(const l of n)for(const c of l.paths){const u=s(c);u&&u.length>i&&(r===u||r.startsWith(u.endsWith("/")?u:`${u}/`))&&(o=l,i=u.length)}return o}function gde(n){const e=q.c(22),{client:t,status:s,activation:r,projectPath:o}=n,i=!!(s!=null&&s.store.available)&&!!r;let l;e[0]!==i||e[1]!==o||e[2]!==s?(l=i?hde(s.projects,o,s.runtime.platform):null,e[0]=i,e[1]=o,e[2]=s,e[3]=l):l=e[3];const c=l,u=i&&!c?o:null;let d;e[4]!==r||e[5]!==o||e[6]!==(s==null?void 0:s.connectionRevision)||e[7]!==(s==null?void 0:s.host.instanceId)||e[8]!==(s==null?void 0:s.projects)||e[9]!==(s==null?void 0:s.store)?(d=JSON.stringify([r,o,s==null?void 0:s.host.instanceId,s==null?void 0:s.store.revision,s==null?void 0:s.connectionRevision,s==null?void 0:s.projects]),e[4]=r,e[5]=o,e[6]=s==null?void 0:s.connectionRevision,e[7]=s==null?void 0:s.host.instanceId,e[8]=s==null?void 0:s.projects,e[9]=s==null?void 0:s.store,e[10]=d):d=e[10];const f=d,[m,p]=w.useState(null);let h,g;if(e[11]!==t||e[12]!==f||e[13]!==u?(h=()=>{if(!u)return;const b=new AbortController;return Promise.resolve().then(()=>(b.signal.throwIfAborted(),t.resolveWorkspace(u,b.signal))).then(y=>{b.signal.aborted||p({key:f,project:y})}).catch(()=>{b.signal.aborted||p({key:f,project:null})}),()=>b.abort()},g=[t,f,u],e[11]=t,e[12]=f,e[13]=u,e[14]=h,e[15]=g):(h=e[14],g=e[15]),w.useEffect(h,g),!i||!o){let b;return e[16]===Symbol.for("react.memo_cache_sentinel")?(b={project:null,resolving:!1},e[16]=b):b=e[16],b}if(c){let b;return e[17]!==c?(b={project:c,resolving:!1},e[17]=c,e[18]=b):b=e[18],b}let x;return e[19]!==f||e[20]!==m?(x=(m==null?void 0:m.key)===f?{project:m.project,resolving:!1}:{project:null,resolving:!0},e[19]=f,e[20]=m,e[21]=x):x=e[21],x}const Sk={"cogpit.github":l3,"cogpit.clickup":IP,"cogpit.vercel":PP,"cogpit.cloudflare":AP};function xde(n){const e=q.c(6);let t,s;e[0]!==n?({runtime:s,...t}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;return e[3]!==t||e[4]!==s?(r=s?a.jsx(tue,{...t,...s}):null,e[3]=t,e[4]=s,e[5]=r):r=e[5],r}function bde(n){var o;const e=q.c(3),{runtime:t,context:s}=n;let r;return e[0]!==s||e[1]!==t?(r=t?a.jsx(qte,{client:t.client,pluginId:t.plugin.id,projectId:((o=t.project)==null?void 0:o.id)??null,workspacePath:t.project?s.projectPath:null,activation:t.activation,registryRevision:t.registryRevision}):null,e[0]=s,e[1]=t,e[2]=r):r=e[2],r}function vde({client:n,status:e,activation:t,project:s,legacyPanels:r=pde,openSettings:o}){const i=[...r];if(!(e!=null&&e.store.available)||e.safeMode||!t||RT())return i;const l=new Set(i.map(u=>u.id)),c=gi();for(const u of e.store.plugins)if(!(!u.enabled||u.scope.type==="projects"&&(!s||!u.scope.projectIds.includes(s.id)))&&ete(u.manifest,c,e.runtime,{allowPrerelease:u.manifest.publisher.startsWith("dev-")}).compatible)for(const d of u.manifest.contributes.panels){const f=Oo(u.id,d.id);if(l.has(f)||d.when==="project-selected"&&!s)continue;l.add(f);const m={client:n,plugin:u,activation:t,registryRevision:e.store.revision,project:s,title:d.title,openSettings:o};i.push({id:f,pluginId:u.id,localId:d.id,title:d.title,icon:Sk[u.id]??l1,order:d.order,defaultSize:d.defaultSize,minSize:d.minSize,maxSize:d.maxSize,keepAlive:!0,...Sk[u.id]?{indicator:bde,indicatorProps:{runtime:m}}:{},component:xde,componentProps:{runtime:m}})}return i.sort((u,d)=>(u.order??100)-(d.order??100)||u.title.localeCompare(d.title))}function MT(n){const e=q.c(11),{client:t,status:s,activation:r,projectPath:o,openSettings:i}=n,l=OT();let c;e[0]!==r||e[1]!==t||e[2]!==o||e[3]!==s?(c={client:t,status:s,activation:r,projectPath:o},e[0]=r,e[1]=t,e[2]=o,e[3]=s,e[4]=c):c=e[4];const{project:u,resolving:d}=gde(c),f=l||d?"":r;let m;return e[5]!==t||e[6]!==i||e[7]!==u||e[8]!==s||e[9]!==f?(m=vde({client:t,status:s,activation:f,project:u,openSettings:i}),e[5]=t,e[6]=i,e[7]=u,e[8]=s,e[9]=f,e[10]=m):m=e[10],m}function Mf(n){const e=q.c(4),{floating:t,children:s}=n;if(t){let o;return e[0]!==s?(o=a.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 z-20 flex justify-center bg-gradient-to-t from-canvas via-canvas/70 to-transparent pt-4",children:a.jsx("div",{className:"pointer-events-auto w-full max-w-[var(--chat-width)] px-3 pb-3",children:s})}),e[0]=s,e[1]=o):o=e[1],o}let r;return e[2]!==s?(r=a.jsx("div",{className:"flex w-full shrink-0 justify-center",children:a.jsx("div",{className:"w-full max-w-[var(--chat-width)] px-3 pb-3",children:s})}),e[2]=s,e[3]=r):r=e[3],r}function Hi(n){const e=q.c(13),{projectPath:t,fallback:s,className:r}=n,[o,i]=w.useState(null);if(!t||o===t){let m;return e[0]!==s?(m=a.jsx(a.Fragment,{children:s}),e[0]=s,e[1]=m):m=e[1],m}const l=`/api/project-icon?cwd=${encodeURIComponent(t)}`;let c;e[2]!==l?(c=g1(l),e[2]=l,e[3]=c):c=e[3];let u;e[4]!==t?(u=()=>i(t),e[4]=t,e[5]=u):u=e[5];let d;e[6]!==r?(d=G("size-3.5 shrink-0 rounded-[3px] object-contain",r),e[6]=r,e[7]=d):d=e[7];let f;return e[8]!==t||e[9]!==c||e[10]!==u||e[11]!==d?(f=a.jsx("img",{src:c,alt:"","aria-hidden":!0,loading:"lazy",decoding:"async",onError:u,className:d},t),e[8]=t,e[9]=c,e[10]=u,e[11]=d,e[12]=f):f=e[12],f}function zT(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G(t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("nav",{"aria-label":"breadcrumb","data-slot":"breadcrumb",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function DT(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex flex-wrap items-center gap-1.5 text-sm wrap-break-word text-muted-foreground",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("ol",{"data-slot":"breadcrumb-list",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Mg(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("inline-flex items-center gap-1",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("li",{"data-slot":"breadcrumb-item",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function FT(n){const e=q.c(10);let t,s,r,o;if(e[0]!==n){const{className:c,render:u,...d}=n;t=u,o=f3,s="a",r=d3({className:G("transition-colors hover:text-foreground",c)},d),e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o}else t=e[1],s=e[2],r=e[3],o=e[4];let i;e[5]===Symbol.for("react.memo_cache_sentinel")?(i={slot:"breadcrumb-link"},e[5]=i):i=e[5];let l;return e[6]!==t||e[7]!==s||e[8]!==r?(l={defaultTagName:s,props:r,render:t,state:i},e[6]=t,e[7]=s,e[8]=r,e[9]=l):l=e[9],o(l)}function UT(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("font-normal text-foreground",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("span",{"data-slot":"breadcrumb-page",role:"link","aria-disabled":"true","aria-current":"page",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function BT(n){const e=q.c(12);let t,s,r;e[0]!==n?({children:t,className:s,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);let o;e[4]!==s?(o=G("[&>svg]:size-3.5",s),e[4]=s,e[5]=o):o=e[5];let i;e[6]!==t?(i=t??a.jsx(ot,{}),e[6]=t,e[7]=i):i=e[7];let l;return e[8]!==r||e[9]!==o||e[10]!==i?(l=a.jsx("li",{"data-slot":"breadcrumb-separator",role:"presentation","aria-hidden":"true",className:o,...r,children:i}),e[8]=r,e[9]=o,e[10]=i,e[11]=l):l=e[11],l}const yde=1e3,wde=255;function Sde(n){for(const e of n){const t=e.codePointAt(0)??0;if(t<32||t===127)return!0}return!1}function kde(n){return n.trim()===""?"Enter a folder name":n!==n.trim()?"A folder name cannot start or end with a space":n==="."||n===".."?`"${n}" is not a folder name`:n.includes("/")||n.includes("\\")?"A folder name cannot contain / or \\":Sde(n)?"A folder name cannot contain control characters":new TextEncoder().encode(n).length>wde?"That folder name is too long":null}function kk(n,e){return n instanceof Error&&n.message?n.message:e}function jde({hostName:n,projectPaths:e,onStart:t,onBack:s}){var U;const[r,o]=w.useState({path:null,request:0}),i=`${r.request}:${r.path??""}`,[l,c]=w.useState(null),[u,d]=w.useState(""),[f,m]=w.useState(""),[p,h]=w.useState(!1),[g,x]=w.useState(""),[b,y]=w.useState(null),[v,k]=w.useState(!1),j=w.useRef(null),_=w.useRef(null),N=w.useRef(null),S=w.useRef(!1);w.useEffect(()=>{const F=new AbortController;return jH(r.path,F.signal).then(B=>c({request:i,listing:B})).catch(B=>{F.signal.aborted||c({request:i,error:kk(B,"This folder could not be read")})}),()=>F.abort()},[i,r.path]);const C=(l==null?void 0:l.request)!==i,E=l&&"listing"in l?l.listing:null,T=!C&&l&&"error"in l?l.error:null,A=C?null:(E==null?void 0:E.path)??null,P=u.trim().toLowerCase(),I=(E==null?void 0:E.folders.filter(F=>F.name.toLowerCase().includes(P)))??[],$=I.some(F=>F.path===f)?f:((U=I[0])==null?void 0:U.path)??"",O=E==null?void 0:E.path;w.useEffect(()=>{var B,V;const F=N.current;F&&(F.scrollLeft=F.scrollWidth),S.current&&!((B=j.current)!=null&&B.contains(document.activeElement))&&((V=_.current)==null||V.focus()),S.current=!1},[O]);function M(F){var B;S.current=((B=j.current)==null?void 0:B.contains(document.activeElement))??!1,o(V=>({path:F,request:V.request+1})),d(""),h(!1),x(""),y(null)}function R(){A&&t(A)}function z(F){F.key==="Enter"&&(F.metaKey||F.ctrlKey)&&!p?(F.preventDefault(),R()):F.key==="Backspace"&&F.target===_.current&&u===""&&(E!=null&&E.parent)&&!C&&(F.preventDefault(),M(E.parent))}function W(){var F;h(!1),x(""),y(null),(F=_.current)==null||F.focus()}async function D(F){var H;F.preventDefault();const B=g.trim(),V=kde(B);if(V){y(V);return}if(!(!A||v)){k(!0);try{const K=await NH(A,B);M(K),(H=_.current)==null||H.focus()}catch(K){y(kk(K,"The folder could not be made"))}finally{k(!1)}}}const L=n?`Folders on ${n}`:"Folders";return a.jsxs("div",{ref:j,onKeyDownCapture:z,className:"flex min-h-0 flex-col bg-popover text-popover-foreground",children:[a.jsxs("div",{className:"flex items-center gap-1 border-b px-2 py-1.5 in-data-[slot=dialog-content]:pr-12",children:[a.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:s,"aria-label":"Back to projects",children:a.jsx(A3,{})}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:L}),E&&E.path!==E.root&&a.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>M(null),"aria-label":"Go to the projects root",title:E.root,children:a.jsx($P,{})})]}),E&&a.jsx(Nde,{path:E.path,top:E.confined?E.root:null,listRef:N,onOpen:M}),a.jsxs(Gl,{shouldFilter:!1,label:"Filter folders",value:$,onValueChange:m,className:"rounded-none p-0",children:[a.jsx(R1,{ref:_,autoFocus:!0,placeholder:"Filter folders...",value:u,onValueChange:d}),a.jsx(Zl,{className:"box-content max-h-72 p-1","aria-busy":C,children:T!==null?a.jsx(Cde,{message:T,onRetry:()=>M(r.path),onRoot:r.path===null?void 0:()=>M(null)}):E===null?a.jsxs("div",{role:"status",className:"flex items-center justify-center gap-2 py-8 text-sm text-muted-foreground",children:[a.jsx(An,{className:"size-4"}),"Loading folders…"]}):I.length===0?a.jsx(kn,{className:"border-0 py-8",children:a.jsxs(jn,{children:[a.jsx(Rn,{variant:"icon",children:a.jsx(Tr,{})}),a.jsx(Nn,{children:P?"No folder matches":"No folders here"}),a.jsx(Cn,{children:P?"Try another name.":"Start a session right here, or make a new folder."})]})}):a.jsxs(Uo,{className:G("p-0 transition-opacity",C&&"opacity-50"),children:[I.map(F=>a.jsxs(no,{value:F.path,onSelect:()=>M(F.path),onMouseDown:B=>B.preventDefault(),className:"motion-list-item h-auto gap-3 px-3 py-2",children:[a.jsx(Ii,{className:"size-4 shrink-0 text-muted-foreground"}),a.jsx("span",{className:"min-w-0 flex-1 truncate",children:F.name}),e.has(F.path)&&a.jsx(Ue,{variant:"secondary",children:"Project"}),a.jsx(ot,{className:"size-4 shrink-0 text-muted-foreground"})]},F.path)),E.truncated&&a.jsxs("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:["Showing the first ",yde.toLocaleString()," folders."]})]})})]}),a.jsxs("div",{className:"flex flex-col gap-1.5 border-t p-2",children:[p?a.jsxs("form",{onSubmit:F=>void D(F),className:"flex items-center gap-2",children:[a.jsx(Zn,{autoFocus:!0,"aria-label":"New folder name",placeholder:"New folder name",value:g,disabled:v,"aria-invalid":b?!0:void 0,onChange:F=>{x(F.target.value),y(null)},onKeyDown:F=>{F.key==="Escape"&&(F.preventDefault(),F.stopPropagation(),W())}}),a.jsxs(ee,{type:"submit",size:"sm",disabled:v||!A||g.trim()==="",children:[v&&a.jsx(An,{"data-icon":"inline-start",className:"size-4"}),"Create"]}),a.jsx(ee,{type:"button",variant:"ghost",size:"sm",onClick:W,children:"Cancel"})]}):a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(ee,{type:"button",variant:"ghost",size:"sm",disabled:!A,onClick:()=>h(!0),children:[a.jsx(P3,{"data-icon":"inline-start"}),"New folder"]}),a.jsx(ee,{type:"button",size:"sm",className:"ml-auto",disabled:!A,onClick:R,"aria-keyshortcuts":"Meta+Enter Control+Enter",children:"Start session here"})]}),b&&a.jsx("p",{role:"alert",className:"px-1 text-xs text-destructive",children:b})]})]})}function Nde(n){const e=q.c(19),{path:t,top:s,listRef:r,onOpen:o}=n;let i,l,c,u,d,f;if(e[0]!==r||e[1]!==o||e[2]!==t||e[3]!==s){const h=CH(t,s);l=zT,f="border-b px-3 py-1.5",i=DT,c=r,u="no-scrollbar flex-nowrap gap-1 overflow-x-auto text-xs",d=h.map((g,x)=>a.jsxs(w.Fragment,{children:[x>0&&a.jsx(BT,{}),a.jsx(Mg,{className:"shrink-0",children:x===h.length-1?a.jsx(UT,{children:g.label}):a.jsx(FT,{render:a.jsx("button",{type:"button",onClick:()=>o(g.path)}),children:g.label})})]},g.path)),e[0]=r,e[1]=o,e[2]=t,e[3]=s,e[4]=i,e[5]=l,e[6]=c,e[7]=u,e[8]=d,e[9]=f}else i=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=e[9];let m;e[10]!==i||e[11]!==c||e[12]!==u||e[13]!==d?(m=a.jsx(i,{ref:c,className:u,children:d}),e[10]=i,e[11]=c,e[12]=u,e[13]=d,e[14]=m):m=e[14];let p;return e[15]!==l||e[16]!==f||e[17]!==m?(p=a.jsx(l,{className:f,children:m}),e[15]=l,e[16]=f,e[17]=m,e[18]=p):p=e[18],p}function Cde(n){const e=q.c(14),{message:t,onRetry:s,onRoot:r}=n;let o,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx(Rn,{variant:"icon",children:a.jsx(Ds,{})}),i=a.jsx(Nn,{children:"This folder could not be opened"}),e[0]=o,e[1]=i):(o=e[0],i=e[1]);let l;e[2]!==t?(l=a.jsxs(jn,{children:[o,i,a.jsx(Cn,{children:t})]}),e[2]=t,e[3]=l):l=e[3];let c;e[4]!==s?(c=a.jsx(ee,{type:"button",variant:"outline",size:"sm",onClick:s,children:"Try again"}),e[4]=s,e[5]=c):c=e[5];let u;e[6]!==r?(u=r&&a.jsx(ee,{type:"button",variant:"ghost",size:"sm",onClick:r,children:"Go to the projects root"}),e[6]=r,e[7]=u):u=e[7];let d;e[8]!==c||e[9]!==u?(d=a.jsxs("div",{className:"flex gap-2",children:[c,u]}),e[8]=c,e[9]=u,e[10]=d):d=e[10];let f;return e[11]!==l||e[12]!==d?(f=a.jsxs(kn,{className:"border-0 py-8",children:[l,d]}),e[11]=l,e[12]=d,e[13]=f):f=e[13],f}function _de(){const n=q.c(7),e=mn("manageDevices");let t;n[0]!==e?(t={enabled:e},n[0]=e,n[1]=t):t=n[1];const{activeDevice:s}=la(t);let r;n[2]!==s?(r=!s&&Wd(),n[2]=s,n[3]=r):r=n[3];const o=r,[i,l]=w.useState(null);let c,u;return n[4]!==o?(c=()=>{if(!o)return;const d=new AbortController;return Re("/api/hello",{signal:d.signal}).then(Zs).then(f=>{typeof(f==null?void 0:f.name)=="string"&&f.name&&l(f.name)}).catch(Ede),()=>d.abort()},u=[o],n[4]=o,n[5]=c,n[6]=u):(c=n[5],u=n[6]),w.useEffect(c,u),(s==null?void 0:s.name)??(o?i:null)}function Ede(){}function jk(n){return n.replace(/[\\/]+$/,"")||n}function WT(n){const e=n.map(s=>({...s,worktrees:[]})),t=new Map;for(const s of e){const r=jk(s.path);!nr(s.path)&&!t.has(r)&&t.set(r,s)}return e.filter((s,r)=>{const o=nr(s.path),i=o&&t.get(jk(o.parentPath));return i?(i.worktrees.push(n[r]),!1):!0})}function qT(n){function e(){try{const i=localStorage.getItem(gn(n));return i?JSON.parse(i):{}}catch{return{}}}let t=e();const s=new Set;function r(){for(const i of s)i()}function o(){t=e(),r()}return typeof window<"u"&&(window.addEventListener("cogpit-device-changed",o),window.addEventListener("cogpit-identity-changed",o)),{subscribe:i=>(s.add(i),()=>{s.delete(i)}),getSnapshot:()=>t,rename:(i,l)=>{const c={...t},u=l.trim();u?c[i]=u:delete c[i],localStorage.setItem(gn(n),JSON.stringify(c)),t=c,r()}}}const zg=qT("project-custom-names"),Tde=zg.rename;function P0(){const n=q.c(2),e=w.useSyncExternalStore(zg.subscribe,zg.getSnapshot);let t;return n[0]!==e?(t={names:e,rename:Tde},n[0]=e,n[1]=t):t=n[1],t}const Nk="browse-folders";function Wa(n){return n.replace(/[\\/]+$/,"")||n}function Ade(n){const e=q.c(4);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0];const[s,r]=w.useState(t);let o,i;return e[1]!==n?(o=()=>{if(!n)return;const l=new AbortController;return Re("/api/projects",{signal:l.signal}).then(Pde).then(r).catch(()=>{l.signal.aborted||r([])}),()=>l.abort()},i=[n],e[1]=n,e[2]=o,e[3]=i):(o=e[2],i=e[3]),w.useEffect(o,i),s}async function Pde(n){return n.ok?await n.json():[]}function Ide(n){var F;const e=q.c(58),{projects:t,onNewSession:s,onNewFolder:r,defaultAgentKind:o,currentPath:i,initialView:l,children:c}=n,u=l===void 0?"projects":l,[d,f]=w.useState(u),[m,p]=w.useState(""),[h,g]=w.useState(null),{names:x}=P0(),b=_de();let y;if(e[0]!==m||e[1]!==x||e[2]!==t){e:{const B=WT(t);if(!m){y=B;break e}const V=m.toLowerCase();y=B.filter(H=>{var K;return H.path.toLowerCase().includes(V)||H.shortName.toLowerCase().includes(V)||H.dirName.toLowerCase().includes(V)||((K=x[H.dirName])==null?void 0:K.toLowerCase().includes(V))})}e[0]=m,e[1]=x,e[2]=t,e[3]=y}else y=e[3];const v=y;let k,j;e[4]!==m||e[5]!==t?(k=m.trim(),j=(k.startsWith("/")||/^[a-z]:[\\/]/i.test(k)||k.startsWith("\\\\"))&&!t.some(V=>Wa(V.path)===Wa(k)),e[4]=m,e[5]=t,e[6]=k,e[7]=j):(k=e[6],j=e[7]);const _=j;let N;e[8]!==i?(N=i?Wa(((F=nr(i))==null?void 0:F.parentPath)??i):null,e[8]=i,e[9]=N):N=e[9];const S=N;let C;e[10]!==_||e[11]!==k?(C=_?[`folder:${k}`]:[],e[10]=_,e[11]=k,e[12]=C):C=e[12];let E;e[13]!==v||e[14]!==C?(E=[...C,...v.map(Rde),Nk],e[13]=v,e[14]=C,e[15]=E):E=e[15];const T=E,A=h!==null&&T.includes(h)?h:T[0];if(d==="folders"){let B;e[16]!==t?(B=new Set(t.map($de)),e[16]=t,e[17]=B):B=e[17];let V;e[18]===Symbol.for("react.memo_cache_sentinel")?(V=()=>f("projects"),e[18]=V):V=e[18];let H;return e[19]!==b||e[20]!==r||e[21]!==B?(H=a.jsx(jde,{hostName:b,projectPaths:B,onStart:r,onBack:V}),e[19]=b,e[20]=r,e[21]=B,e[22]=H):H=e[22],H}let P;e[23]!==m?(P=a.jsx(R1,{autoFocus:!0,placeholder:"Search projects, paste a folder path, or browse",value:m,onValueChange:p}),e[23]=m,e[24]=P):P=e[24];let I;e[25]!==_||e[26]!==v.length?(I=v.length===0&&!_&&a.jsx(kn,{className:"border-0 py-8",children:a.jsxs(jn,{children:[a.jsx(Rn,{variant:"icon",children:a.jsx(Tr,{})}),a.jsx(Nn,{children:"No projects found"}),a.jsx(Cn,{children:"Try another name, paste an absolute path, or browse the folders."})]})}),e[25]=_,e[26]=v.length,e[27]=I):I=e[27];let $;e[28]!==_||e[29]!==o||e[30]!==k||e[31]!==r?($=_&&a.jsxs(no,{value:`folder:${k}`,className:"motion-list-item h-auto gap-3 px-3 py-2.5",onSelect:()=>r(k),children:[a.jsx(P3,{"data-icon":"inline-start",className:"size-4 shrink-0 text-foreground"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"text-sm font-medium",children:"Start in this folder"}),a.jsxs("div",{className:"truncate text-xs text-muted-foreground",children:[k," · ",bR(o)]})]})]}),e[28]=_,e[29]=o,e[30]=k,e[31]=r,e[32]=$):$=e[32];let O;if(e[33]!==S||e[34]!==v||e[35]!==s||e[36]!==x){let B;e[38]!==S||e[39]!==s||e[40]!==x?(B=V=>{const H=x[V.dirName],K=ql(V.path);return a.jsxs(no,{value:`project:${V.dirName}`,"data-checked":S!==null&&Wa(V.path)===S,className:"motion-list-item h-auto gap-3 px-3 py-2.5",onSelect:()=>s(V.dirName,V.path),children:[a.jsx(Hi,{projectPath:V.path,fallback:a.jsx(Tr,{"data-icon":"inline-start",className:"size-4 shrink-0 text-muted-foreground"}),className:"size-4"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"truncate text-sm font-medium",children:H||K}),a.jsxs("div",{className:"text-xs text-muted-foreground",children:[H&&a.jsx("span",{className:"mr-1.5",children:K}),V.sessionCount," session",V.sessionCount!==1?"s":"",V.lastModified&&a.jsxs(a.Fragment,{children:[" · ",new Date(V.lastModified).toLocaleDateString()]})]})]})]},V.dirName)},e[38]=S,e[39]=s,e[40]=x,e[41]=B):B=e[41],O=v.map(B),e[33]=S,e[34]=v,e[35]=s,e[36]=x,e[37]=O}else O=e[37];let M;e[42]!==O||e[43]!==$?(M=a.jsxs(Uo,{className:"p-0",children:[$,O]}),e[42]=O,e[43]=$,e[44]=M):M=e[44];let R,z;e[45]===Symbol.for("react.memo_cache_sentinel")?(R=()=>f("folders"),z=a.jsx(Ml,{"data-icon":"inline-start",className:"size-4 shrink-0 text-muted-foreground"}),e[45]=R,e[46]=z):(R=e[45],z=e[46]);const W=b?`Browse folders on ${b}…`:"Browse folders…";let D;e[47]!==W?(D=a.jsx(Uo,{className:"sticky -bottom-1 border-t bg-popover p-0 py-1",children:a.jsxs(no,{value:Nk,className:"h-auto gap-3 px-3 py-2.5",onSelect:R,children:[z,a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:W})]})}),e[47]=W,e[48]=D):D=e[48];let L;e[49]!==M||e[50]!==D||e[51]!==I?(L=a.jsxs(Zl,{className:"box-content max-h-80 p-1",children:[I,M,D]}),e[49]=M,e[50]=D,e[51]=I,e[52]=L):L=e[52];let U;return e[53]!==c||e[54]!==A||e[55]!==L||e[56]!==P?(U=a.jsxs(Gl,{shouldFilter:!1,value:A,onValueChange:g,className:"rounded-none p-0",children:[P,L,c]}),e[53]=c,e[54]=A,e[55]=L,e[56]=P,e[57]=U):U=e[57],U}function $de(n){return Wa(n.path)}function Rde(n){return`project:${n.dirName}`}function VT(n){const e=q.c(13),{projectPath:t,switcher:s}=n;let r;e[0]!==t?(r=t?rr(t):null,e[0]=t,e[1]=r):r=e[1];const o=r;let i;e[2]!==o||e[3]!==t||e[4]!==s?(i=o?a.jsxs(a.Fragment,{children:["What should we build in"," ",a.jsx(Ode,{name:o,projectPath:t,switcher:s}),"?"]}):"What should we build?",e[2]=o,e[3]=t,e[4]=s,e[5]=i):i=e[5];let l;e[6]!==i?(l=a.jsx("h1",{className:"text-balance text-2xl font-semibold tracking-tight text-foreground",children:i}),e[6]=i,e[7]=l):l=e[7];let c;e[8]!==t?(c=t&&a.jsx("p",{className:"font-mono text-xs text-muted-foreground",children:ql(t)}),e[8]=t,e[9]=c):c=e[9];let u;return e[10]!==l||e[11]!==c?(u=a.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 text-center",children:[l,c]}),e[10]=l,e[11]=c,e[12]=u):u=e[12],u}function Ode(n){const e=q.c(24),{name:t,projectPath:s,switcher:r}=n,{onNewSession:o,onNewFolder:i,defaultAgentKind:l}=r,[c,u]=w.useState(!1),d=Ade(c);let f;e[0]!==s?(f=a.jsx(Hi,{projectPath:s,fallback:null,className:"size-5"}),e[0]=s,e[1]=f):f=e[1];let m;e[2]!==t?(m=a.jsx("span",{className:"truncate underline decoration-dotted decoration-muted-foreground/50 underline-offset-[6px] transition-colors group-hover/project:decoration-foreground/70 group-data-popup-open/project:decoration-foreground/70",children:t}),e[2]=t,e[3]=m):m=e[3];let p;e[4]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsx(Ji,{className:"size-4 shrink-0 text-muted-foreground transition-colors group-hover/project:text-foreground group-data-popup-open/project:text-foreground","aria-hidden":"true"}),e[4]=p):p=e[4];let h;e[5]!==f||e[6]!==m?(h=a.jsxs(Wl,{title:"Switch project",className:"group/project -mx-1 inline-flex max-w-full items-center gap-1.5 rounded-lg px-1.5 align-baseline outline-none transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring data-popup-open:bg-accent",children:[f,m,p]}),e[5]=f,e[6]=m,e[7]=h):h=e[7];let g;e[8]!==o?(g=(j,_)=>{u(!1),o(j,_)},e[8]=o,e[9]=g):g=e[9];let x;e[10]!==i?(x=j=>{u(!1),i(j)},e[10]=i,e[11]=x):x=e[11];let b;e[12]===Symbol.for("react.memo_cache_sentinel")?(b=a.jsx("span",{children:"Switch where this session starts"}),e[12]=b):b=e[12];let y;e[13]===Symbol.for("react.memo_cache_sentinel")?(y=a.jsxs("div",{className:"flex items-center justify-between border-t px-3 py-2 text-[11px] text-muted-foreground",children:[b,a.jsx("kbd",{className:"font-mono",children:Eu("newSession")})]}),e[13]=y):y=e[13];let v;e[14]!==l||e[15]!==s||e[16]!==d||e[17]!==g||e[18]!==x?(v=a.jsx(k1,{align:"center",className:"w-96 max-w-[calc(100vw-2rem)] p-0",children:a.jsx(Ide,{projects:d,currentPath:s,defaultAgentKind:l,onNewSession:g,onNewFolder:x,children:y})}),e[14]=l,e[15]=s,e[16]=d,e[17]=g,e[18]=x,e[19]=v):v=e[19];let k;return e[20]!==c||e[21]!==v||e[22]!==h?(k=a.jsxs(Bl,{open:c,onOpenChange:u,children:[h,v]}),e[20]=c,e[21]=v,e[22]=h,e[23]=k):k=e[23],k}function I0(n){const e=q.c(56),{children:t,sessionLabel:s,customName:r,onDuplicate:o,onDelete:i,onRename:l,onArchive:c,onUnarchive:u,archiveDisabled:d}=n,f=d===void 0?!1:d,[m,p]=w.useState(!1),[h,g]=w.useState(!1),[x,b]=w.useState(""),y=w.useRef(null);let v;e[0]!==r?(v=function(){b(r||""),g(!0),requestAnimationFrame(()=>{var H;return(H=y.current)==null?void 0:H.select()})},e[0]=r,e[1]=v):v=e[1];const k=v;let j;e[2]===Symbol.for("react.memo_cache_sentinel")?(j=a.jsx("div",{className:"w-full"}),e[2]=j):j=e[2];let _;e[3]!==t?(_=a.jsx(xf,{render:j,children:t}),e[3]=t,e[4]=_):_=e[4];let N;e[5]!==f||e[6]!==c||e[7]!==o||e[8]!==l||e[9]!==u||e[10]!==k?(N=(l||o||c||u)&&a.jsxs(zo,{children:[l&&a.jsxs($n,{onClick:k,children:[a.jsx(Er,{"data-icon":"inline-start"}),"Rename session"]}),o&&a.jsxs($n,{onClick:o,children:[a.jsx(ys,{"data-icon":"inline-start"}),"Duplicate session"]}),u?a.jsxs($n,{onClick:u,children:[a.jsx(zd,{"data-icon":"inline-start"}),"Restore from archive"]}):c&&a.jsxs($n,{onClick:c,disabled:f,children:[a.jsx(gs,{"data-icon":"inline-start"}),f?"Archive (stop the session first)":"Archive session"]})]}),e[5]=f,e[6]=c,e[7]=o,e[8]=l,e[9]=u,e[10]=k,e[11]=N):N=e[11];let S;e[12]!==c||e[13]!==i||e[14]!==o||e[15]!==l||e[16]!==u?(S=i&&a.jsxs(a.Fragment,{children:[(o||l||c||u)&&a.jsx(Di,{}),a.jsx(zo,{children:a.jsxs($n,{variant:"destructive",onClick:()=>p(!0),children:[a.jsx(Od,{"data-icon":"inline-start"}),"Delete session"]})})]}),e[12]=c,e[13]=i,e[14]=o,e[15]=l,e[16]=u,e[17]=S):S=e[17];let C;e[18]!==N||e[19]!==S?(C=a.jsxs(bf,{className:"min-w-44",children:[N,S]}),e[18]=N,e[19]=S,e[20]=C):C=e[20];let E;e[21]!==_||e[22]!==C?(E=a.jsxs(gf,{children:[_,C]}),e[21]=_,e[22]=C,e[23]=E):E=e[23];let T;e[24]===Symbol.for("react.memo_cache_sentinel")?(T=a.jsx(V1,{children:"Delete session?"}),e[24]=T):T=e[24];let A;e[25]!==s?(A=a.jsxs(W1,{children:[T,a.jsxs(H1,{children:["This will permanently delete"," ",a.jsx("span",{className:"font-medium text-foreground",children:s}),". This action cannot be undone."]})]}),e[25]=s,e[26]=A):A=e[26];let P;e[27]===Symbol.for("react.memo_cache_sentinel")?(P=a.jsx(G1,{size:"sm",children:"Cancel"}),e[27]=P):P=e[27];let I;e[28]!==i?(I=a.jsxs(q1,{children:[P,a.jsx(K1,{variant:"destructive",size:"sm",onClick:()=>{i==null||i(),p(!1)},children:"Delete"})]}),e[28]=i,e[29]=I):I=e[29];let $;e[30]!==A||e[31]!==I?($=a.jsxs(B1,{children:[A,I]}),e[30]=A,e[31]=I,e[32]=$):$=e[32];let O;e[33]!==m||e[34]!==$?(O=a.jsx(U1,{open:m,onOpenChange:p,children:$}),e[33]=m,e[34]=$,e[35]=O):O=e[35];let M;e[36]===Symbol.for("react.memo_cache_sentinel")?(M=a.jsxs(wo,{children:[a.jsx(mr,{className:"text-foreground",children:"Rename session"}),a.jsx(pr,{className:"text-muted-foreground",children:"Give this session a custom name. Clear to reset to default."})]}),e[36]=M):M=e[36];let R;e[37]!==l||e[38]!==x?(R=V=>{V.preventDefault(),l==null||l(x),g(!1)},e[37]=l,e[38]=x,e[39]=R):R=e[39];let z;e[40]===Symbol.for("react.memo_cache_sentinel")?(z=a.jsx(dn,{htmlFor:"session-rename",children:"Session name"}),e[40]=z):z=e[40];let W;e[41]===Symbol.for("react.memo_cache_sentinel")?(W=V=>b(V.target.value),e[41]=W):W=e[41];let D;e[42]!==x||e[43]!==s?(D=a.jsxs(un,{children:[z,a.jsx(Zn,{id:"session-rename",ref:y,value:x,onChange:W,placeholder:s})]}),e[42]=x,e[43]=s,e[44]=D):D=e[44];let L;e[45]===Symbol.for("react.memo_cache_sentinel")?(L=a.jsxs($1,{children:[a.jsx(ee,{type:"button",variant:"ghost",size:"sm",onClick:()=>g(!1),children:"Cancel"}),a.jsx(ee,{type:"submit",size:"sm",children:"Save"})]}),e[45]=L):L=e[45];let U;e[46]!==R||e[47]!==D?(U=a.jsxs(fr,{className:"sm:max-w-md",children:[M,a.jsxs("form",{className:"flex flex-col gap-4",onSubmit:R,children:[D,L]})]}),e[46]=R,e[47]=D,e[48]=U):U=e[48];let F;e[49]!==h||e[50]!==U?(F=a.jsx(dr,{open:h,onOpenChange:g,children:U}),e[49]=h,e[50]=U,e[51]=F):F=e[51];let B;return e[52]!==O||e[53]!==F||e[54]!==E?(B=a.jsxs(a.Fragment,{children:[E,O,F]}),e[52]=O,e[53]=F,e[54]=E,e[55]=B):B=e[55],B}const Dg=qT("session-custom-names"),HT=Dg.rename;function KT(){const n=q.c(2),e=w.useSyncExternalStore(Dg.subscribe,Dg.getSnapshot);let t;return n[0]!==e?(t={names:e,rename:HT},n[0]=e,n[1]=t):t=n[1],t}function Fg(n,e){return Object.freeze({canInteract:n,canOwn:e,send:n,stop:n,answer:n,configure:n,mcp:n,undo:n,archive:e,delete:e})}const ch=Fg(!1,!1),Lde={unknown:ch,none:ch,view:ch,interact:Fg(!0,!1),own:Fg(!0,!0)};function Ki(n){return Lde[n]}function zf(){const n=q.c(3),{enforcesSessionAccess:e}=eC(),t=e===!1?"own":"unknown";let s;return n[0]!==e||n[1]!==t?(s=r=>Ki(e!==null&&r?r.level:t),n[0]=e,n[1]=t,n[2]=s):s=n[2],s}function GT(n){const e=q.c(16),{value:t,onChange:s,placeholder:r,loading:o}=n,i=o===void 0?!1:o;let l;e[0]!==i?(l=a.jsx(or,{children:i?a.jsx(vt,{className:"animate-spin","aria-label":"Searching session history"}):a.jsx(Yn,{"aria-hidden":"true"})}),e[0]=i,e[1]=l):l=e[1];let c;e[2]!==s?(c=m=>s(m.target.value),e[2]=s,e[3]=c):c=e[3];let u;e[4]!==i||e[5]!==r||e[6]!==c||e[7]!==t?(u=a.jsx(ko,{type:"search","aria-busy":i,"aria-label":r,value:t,onChange:c,placeholder:r}),e[4]=i,e[5]=r,e[6]=c,e[7]=t,e[8]=u):u=e[8];let d;e[9]!==s||e[10]!==t?(d=t&&a.jsx(or,{align:"inline-end",children:a.jsx(Jd,{"aria-label":"Clear search",onClick:()=>s(""),size:"icon-xs",children:a.jsx(Ut,{})})}),e[9]=s,e[10]=t,e[11]=d):d=e[11];let f;return e[12]!==l||e[13]!==u||e[14]!==d?(f=a.jsxs(So,{className:"w-full sm:max-w-sm",children:[l,u,d]}),e[12]=l,e[13]=u,e[14]=d,e[15]=f):f=e[15],f}function ZT(n){const e=q.c(10),{message:t,onRetry:s}=n;let r,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(lr,{"aria-hidden":"true"}),o=a.jsx(_n,{children:"Could not load this data"}),e[0]=r,e[1]=o):(r=e[0],o=e[1]);let i;e[2]!==t?(i=a.jsx(Qt,{children:t}),e[2]=t,e[3]=i):i=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(On,{"data-icon":"inline-start"}),e[4]=l):l=e[4];let c;e[5]!==s?(c=a.jsx(uo,{children:a.jsxs(ee,{variant:"ghost",size:"xs",onClick:s,children:[l,"Retry"]})}),e[5]=s,e[6]=c):c=e[6];let u;return e[7]!==i||e[8]!==c?(u=a.jsxs(Jt,{variant:"destructive",children:[r,o,i,c]}),e[7]=i,e[8]=c,e[9]=u):u=e[9],u}function YT(n){const e=q.c(5),{count:t,includeMessagePlaceholder:s}=n,r=t===void 0?4:t,o=s===void 0?!1:s;let i;if(e[0]!==r||e[1]!==o){let l;e[3]!==o?(l=(c,u)=>a.jsxs("div",{children:[u>0&&a.jsx(Gt,{}),a.jsxs("div",{className:"flex items-center gap-3 px-4 py-3.5",children:[a.jsx(Wn,{className:"size-8 shrink-0 rounded-md"}),a.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:[a.jsx(Wn,{className:"h-4 w-40 max-w-full"}),o&&a.jsx(Wn,{className:"h-3 w-72 max-w-full"}),a.jsx(Wn,{className:"h-3 w-52 max-w-full"})]}),a.jsx(Wn,{className:"hidden h-5 w-20 sm:block"})]})]},u),e[3]=o,e[4]=l):l=e[4],i=a.jsx("div",{className:"overflow-hidden rounded-lg border","aria-hidden":"true",children:Array.from({length:r},l)}),e[0]=r,e[1]=o,e[2]=i}else i=e[2];return i}function XT(n){const e=q.c(3),{access:t}=n,{SessionBadges:s}=ur();let r;return e[0]!==s||e[1]!==t?(r=s?a.jsx(s,{access:t}):null,e[0]=s,e[1]=t,e[2]=r):r=e[2],r}function bc(n){return n==="idle"||n==="completed"}function Df(n){return bc(n)?"text-success":n==="thinking"||n==="deferred"?"text-warning":"text-info"}const ro={attention:"bg-warning",working:"bg-success ring-2 ring-success/30",idle:"bg-success/40"},Mde=/(?:https?:\/\/)?github\.com\/([\w.-]+)\/([\w.-]+)\/pull\/(\d+)/i,zde=/^([\w.-]+(?:\/[\w.-]+)?)#(\d+)$/,Dde=/(?:^|\s)#(\d+)(?=\s|$)/,Fde=/^(?:pr|pull\s+request)\s*#?(\d+)$/i;function mu(n){const e=Number(n);return Number.isSafeInteger(e)&&e>0?e:null}function Ude(n){const e=n.trim().replace(/^(?:pr|pull\s+request)\b/i,"").trim().replace(/^(?:in|on)\s+/i,"");return!e||/^(?:pr|pull\s+request)$/i.test(e)?null:e.toLowerCase()}function JT(n){const e=n.trim();if(!e)return null;const t=Mde.exec(e);if(t){const l=mu(t[3]);return l===null?null:{number:l,repoHint:`${t[1]}/${t[2]}`.toLowerCase()}}const s=zde.exec(e);if(s){const l=mu(s[2]);return l===null?null:{number:l,repoHint:s[1].toLowerCase()}}const r=Dde.exec(e);if(r){const l=mu(r[1]);if(l===null)return null;const c=`${e.slice(0,r.index)} ${e.slice(r.index+r[0].length)}`;return{number:l,repoHint:Ude(c)}}const o=Fde.exec(e);if(!o)return null;const i=mu(o[1]);return i===null?null:{number:i,repoHint:null}}function Ck(n,e){if(!n)return!1;const t=n.toLowerCase().replace(/\.git$/,"");return t===e||t.endsWith(`/${e}`)||e.endsWith(`/${t}`)}function Bde(n,e){if(!n)return!1;const t=n.toLowerCase().replace(/\.git$/,"").split(/[\\/]/).filter(Boolean).at(-1);if(!t)return!1;const s=t.replace(/[^a-z0-9]/g,"");return e.split("/").some(r=>r.replace(/[^a-z0-9]/g,"")===s)}function Wde(n,e,t=[]){if(n.number!==e.number)return!1;const s=e.repoHint;return s?n.repo&&s.includes("/")?Ck(n.repo,s):Ck(n.repo,s)?!0:t.some(r=>Bde(r,s)):!0}function QT(n,e,t=[]){var o;const s=JT(e);if(s){const i=[n.cwd,n.projectShortName,...t];return((o=n.pullRequests)==null?void 0:o.some(l=>Wde(l,s,i)))??!1}const r=e.trim().toLowerCase();return r?[...t,n.aiTitle,n.name,n.slug,n.customTitle,n.firstUserMessage,n.lastUserMessage,n.model,n.gitBranch,n.agentName,n.teamName,n.sessionId,n.cwd,n.projectShortName].some(i=>i==null?void 0:i.toLowerCase().includes(r)):!0}const qde=120*1e3;function e6(n){return n?Date.now()-new Date(n).getTime()<qde:!1}function t6(n,e){const t=n.teamName?n.agentName:"",s=e||n.aiTitle||n.name||t||n.slug||n.firstUserMessage||n.customTitle;return s?Is(s,70):Is(n.sessionId,16)}function _k(n){return n.trim().replace(/\s+/g," ").slice(0,40).toLowerCase()}function Vde(n,e){const t=(n.lastUserMessage||n.firstUserMessage||"").trim();return!t||_k(t)===_k(e)?null:Is(t,220)}function Hde(n,e){return QT(n,e)}function Kde(n,e){if(!n||!e)return null;const t=new Date(e).getTime()-new Date(n).getTime();return t>=6e4?sr(t):null}function Gde(n){const e=[n.sessionId];return n.cwd&&e.push(n.cwd),n.version&&e.push(`CLI ${n.version}`),n.timestamp&&e.push(`Started ${new Date(n.timestamp).toLocaleString()}`),e.join(`
|
|
444
|
+
`)}function Zde(n){var t;const e=n.cwd?(t=nr(n.cwd))==null?void 0:t.worktreeName:void 0;return e?{icon:RP,label:e,title:n.cwd}:n.gitBranch?{icon:_r,label:n.gitBranch}:null}function Yde(n,e){return n.agentStatus==="deferred"?"attention":e?bc(n.agentStatus)?"idle":"working":null}function Xde(n){const e=q.c(20),{session:t,live:s}=n;if(t.agentStatus==="deferred"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(Ue,{variant:"outline",className:"border-warning/30 bg-warning/10 text-warning",children:"Needs review"}),e[0]=r):r=e[0],r}if(s){const r=bc(t.agentStatus);let o;e[1]!==t.agentPendingAgents||e[2]!==t.agentStatus||e[3]!==t.agentTerminalReason||e[4]!==t.agentToolName?(o=cc(t.agentStatus,t.agentToolName,t.agentTerminalReason,t.agentPendingAgents)??"Active",e[1]=t.agentPendingAgents,e[2]=t.agentStatus,e[3]=t.agentTerminalReason,e[4]=t.agentToolName,e[5]=o):o=e[5];const i=o;let l;e[6]!==t.agentStatus?(l=Df(t.agentStatus),e[6]=t.agentStatus,e[7]=l):l=e[7];const c=r?"bg-success/60":"bg-current";let u;e[8]!==c?(u=G("size-1.5 rounded-full",c),e[8]=c,e[9]=u):u=e[9];let d;e[10]!==u?(d=a.jsx("span",{"aria-hidden":"true","data-icon":"inline-start",className:u}),e[10]=u,e[11]=d):d=e[11];let f;return e[12]!==i||e[13]!==l||e[14]!==d?(f=a.jsxs(Ue,{variant:"secondary",className:l,children:[d,i]}),e[12]=i,e[13]=l,e[14]=d,e[15]=f):f=e[15],f}if(t.agentTerminalReason){let r;e[16]!==t.agentTerminalReason?(r=Ix(t.agentTerminalReason),e[16]=t.agentTerminalReason,e[17]=r):r=e[17];let o;return e[18]!==r?(o=a.jsx(Ue,{variant:"outline",className:"max-w-44 truncate text-warning",children:r}),e[18]=r,e[19]=o):o=e[19],o}return null}function uh(n){const e=q.c(9),{icon:t,title:s,className:r,children:o}=n;let i;e[0]!==r?(i=G("flex items-center gap-1",r),e[0]=r,e[1]=i):i=e[1];let l;e[2]!==t?(l=a.jsx(t,{className:"size-3 shrink-0"}),e[2]=t,e[3]=l):l=e[3];let c;return e[4]!==o||e[5]!==i||e[6]!==l||e[7]!==s?(c=a.jsxs("span",{className:i,title:s,children:[l,o]}),e[4]=o,e[5]=i,e[6]=l,e[7]=s,e[8]=c):c=e[8],c}function Jde(n){const e=q.c(103),{session:t,customName:s,onSelect:r}=n,o=t.lastActivityAt||t.lastModified;let i,l;e[0]!==o||e[1]!==t?(i=e6(o),l=Yde(t,i),e[0]=o,e[1]=t,e[2]=i,e[3]=l):(i=e[2],l=e[3]);const c=l,u=t.teamName?t.agentName:void 0;let d,f,m,p,h,g,x,b,y,v,k,j,_,N,S;if(e[4]!==s||e[5]!==c||e[6]!==o||e[7]!==i||e[8]!==r||e[9]!==t||e[10]!==u){const R=Zde(t);let z;e[26]!==o||e[27]!==t.timestamp?(z=Kde(t.timestamp,o),e[26]=o,e[27]=t.timestamp,e[28]=z):z=e[28];const W=z,D=t.turnCount??0;let L,U;e[29]!==s||e[30]!==t?(U=t6(t,s),L=Vde(t,U),e[29]=s,e[30]=t,e[31]=L,e[32]=U):(L=e[31],U=e[32]);const F=L;x="motion-list-item group flex w-full items-start gap-3 px-4 py-3 transition-colors hover:bg-muted/50 focus-within:bg-muted",f="button",m=r,e[33]!==t?(p=Gde(t),e[33]=t,e[34]=p):p=e[34],h="flex min-w-0 flex-1 items-start gap-3 rounded-sm text-left outline-none focus-visible:ring-2 focus-visible:ring-ring";let B;e[35]===Symbol.for("react.memo_cache_sentinel")?(B=a.jsx(Wb,{className:"size-4"}),e[35]=B):B=e[35];let V;e[36]!==c?(V=c&&a.jsx("span",{"aria-hidden":"true","data-status-dot":c,className:G("absolute -top-1 -right-1 size-2 rounded-full ring-2 ring-card",ro[c])}),e[36]=c,e[37]=V):V=e[37],e[38]!==V?(g=a.jsxs("span",{className:"relative mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-md border bg-muted/40 text-muted-foreground",children:[B,V]}),e[38]=V,e[39]=g):g=e[39],N="flex min-w-0 flex-1 flex-col gap-1";let H;e[40]!==U?(H=a.jsx("span",{className:"truncate text-sm font-medium",children:U}),e[40]=U,e[41]=H):H=e[41];let K;e[42]!==u?(K=u&&a.jsxs(Ue,{variant:"outline",className:"shrink-0",children:[a.jsx($i,{"data-icon":"inline-start"}),Is(u,18)]}),e[42]=u,e[43]=K):K=e[43];let Z;e[44]!==t.branchedFrom?(Z=t.branchedFrom&&a.jsxs(Ue,{variant:"outline",className:"shrink-0",title:"Branched from another session",children:[a.jsx(a1,{"data-icon":"inline-start"}),"branch"]}),e[44]=t.branchedFrom,e[45]=Z):Z=e[45];let Y;e[46]!==i||e[47]!==t?(Y=a.jsx(Xde,{session:t,live:i}),e[46]=i,e[47]=t,e[48]=Y):Y=e[48];let X;e[49]!==o?(X=o&&a.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:Yo(o)}),e[49]=o,e[50]=X):X=e[50];let se;e[51]!==Y||e[52]!==X?(se=a.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-2",children:[Y,X]}),e[51]=Y,e[52]=X,e[53]=se):se=e[53],e[54]!==H||e[55]!==K||e[56]!==Z||e[57]!==se?(S=a.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[H,K,Z,se]}),e[54]=H,e[55]=K,e[56]=Z,e[57]=se,e[58]=S):S=e[58],e[59]!==F?(d=F&&a.jsx("span",{className:"line-clamp-1 text-sm text-muted-foreground",children:F}),e[59]=F,e[60]=d):d=e[60],b="flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",e[61]!==t.access?(y=a.jsx(XT,{access:t.access}),e[61]=t.access,e[62]=y):y=e[62],e[63]!==t.model?(v=t.model&&a.jsx(Ue,{variant:"outline",children:Zo(t.model)}),e[63]=t.model,e[64]=v):v=e[64],e[65]!==D?(k=D>0&&a.jsxs(uh,{icon:Wb,children:[D," ",D===1?"turn":"turns"]}),e[65]=D,e[66]=k):k=e[66],e[67]!==W?(j=W&&a.jsx(uh,{icon:oo,title:"First prompt to last activity",children:W}),e[67]=W,e[68]=j):j=e[68],_=R&&a.jsx(uh,{icon:R.icon,className:"max-w-40 truncate",title:R.title,children:Is(R.label,22)}),e[4]=s,e[5]=c,e[6]=o,e[7]=i,e[8]=r,e[9]=t,e[10]=u,e[11]=d,e[12]=f,e[13]=m,e[14]=p,e[15]=h,e[16]=g,e[17]=x,e[18]=b,e[19]=y,e[20]=v,e[21]=k,e[22]=j,e[23]=_,e[24]=N,e[25]=S}else d=e[11],f=e[12],m=e[13],p=e[14],h=e[15],g=e[16],x=e[17],b=e[18],y=e[19],v=e[20],k=e[21],j=e[22],_=e[23],N=e[24],S=e[25];let C;e[69]!==t.size?(C=mj(t.size),e[69]=t.size,e[70]=C):C=e[70];let E;e[71]!==C?(E=a.jsx("span",{children:C}),e[71]=C,e[72]=E):E=e[72];let T;e[73]!==E||e[74]!==b||e[75]!==y||e[76]!==v||e[77]!==k||e[78]!==j||e[79]!==_?(T=a.jsxs("span",{className:b,children:[y,v,k,j,_,E]}),e[73]=E,e[74]=b,e[75]=y,e[76]=v,e[77]=k,e[78]=j,e[79]=_,e[80]=T):T=e[80];let A;e[81]!==d||e[82]!==T||e[83]!==N||e[84]!==S?(A=a.jsxs("span",{className:N,children:[S,d,T]}),e[81]=d,e[82]=T,e[83]=N,e[84]=S,e[85]=A):A=e[85];let P;e[86]!==f||e[87]!==m||e[88]!==p||e[89]!==h||e[90]!==g||e[91]!==A?(P=a.jsxs("button",{type:f,onClick:m,title:p,className:h,children:[g,A]}),e[86]=f,e[87]=m,e[88]=p,e[89]=h,e[90]=g,e[91]=A,e[92]=P):P=e[92];let I;e[93]!==t.matchedPullRequestNumber||e[94]!==t.pullRequests?(I=t.matchedPullRequestNumber?a.jsxs(Ue,{variant:"outline",children:["Matched #",t.matchedPullRequestNumber]}):a.jsx(dc,{pullRequests:t.pullRequests,max:2,compact:!0}),e[93]=t.matchedPullRequestNumber,e[94]=t.pullRequests,e[95]=I):I=e[95];let $;e[96]===Symbol.for("react.memo_cache_sentinel")?($=a.jsx(ot,{className:"size-4 text-muted-foreground transition-transform group-hover:translate-x-0.5"}),e[96]=$):$=e[96];let O;e[97]!==I?(O=a.jsxs("span",{className:"flex shrink-0 items-center gap-2 pt-1.5",children:[I,$]}),e[97]=I,e[98]=O):O=e[98];let M;return e[99]!==x||e[100]!==P||e[101]!==O?(M=a.jsxs("div",{className:x,children:[P,O]}),e[99]=x,e[100]=P,e[101]=O,e[102]=M):M=e[102],M}function Qde(n){const e=q.c(63),{selectedProject:t,filterEmpty:s,sessions:r,sessionsTotal:o,sessionsLoading:i,searchLoading:l,searchFilter:c,setSearchFilter:u,filteredSessions:d,fetchError:f,onSelectSession:m,onNewSession:p,creatingSession:h,onDuplicateSession:g,onDeleteSession:x,onBack:b,onRetryFetch:y,loadMoreSessions:v}=n,{names:k,rename:j}=KT(),_=zf();let N;e[0]!==t.path?(N=rr(t.path),e[0]=t.path,e[1]=N):N=e[1];const S=N;let C;e[2]!==b?(C=a.jsx(Mg,{children:a.jsx(FT,{render:a.jsx("button",{type:"button",onClick:b}),children:"Projects"})}),e[2]=b,e[3]=C):C=e[3];let E;e[4]===Symbol.for("react.memo_cache_sentinel")?(E=a.jsx(BT,{}),e[4]=E):E=e[4];let T;e[5]!==S?(T=a.jsx(Mg,{className:"min-w-0",children:a.jsx(UT,{className:"truncate",children:S})}),e[5]=S,e[6]=T):T=e[6];let A;e[7]!==C||e[8]!==T?(A=a.jsx(zT,{children:a.jsxs(DT,{children:[C,E,T]})}),e[7]=C,e[8]=T,e[9]=A):A=e[9];let P;e[10]!==S?(P=a.jsx("h1",{className:"truncate text-2xl font-semibold tracking-tight",children:S}),e[10]=S,e[11]=P):P=e[11];let I;e[12]!==o?(I=a.jsx(Ue,{variant:"secondary",children:o}),e[12]=o,e[13]=I):I=e[13];let $;e[14]!==P||e[15]!==I?($=a.jsxs("div",{className:"flex items-center gap-2",children:[P,I]}),e[14]=P,e[15]=I,e[16]=$):$=e[16];let O;e[17]!==t.path?(O=ql(t.path),e[17]=t.path,e[18]=O):O=e[18];let M;e[19]!==O?(M=a.jsx("p",{className:"truncate text-sm text-muted-foreground",children:O}),e[19]=O,e[20]=M):M=e[20];let R;e[21]!==M||e[22]!==$?(R=a.jsxs("header",{className:"flex min-w-0 flex-col gap-1",children:[$,M]}),e[21]=M,e[22]=$,e[23]=R):R=e[23];let z;e[24]!==c||e[25]!==l||e[26]!==u?(z=a.jsx(GT,{value:c,onChange:u,placeholder:"Search sessions or PRs...",loading:l}),e[24]=c,e[25]=l,e[26]=u,e[27]=z):z=e[27];let W;e[28]!==h||e[29]!==p||e[30]!==t.dirName||e[31]!==t.path?(W=p&&a.jsxs(ee,{size:"sm",disabled:h,onClick:()=>p(t.dirName,t.path),children:[h?a.jsx(An,{"data-icon":"inline-start"}):a.jsx(tr,{"data-icon":"inline-start"}),"New Session"]}),e[28]=h,e[29]=p,e[30]=t.dirName,e[31]=t.path,e[32]=W):W=e[32];let D;e[33]!==z||e[34]!==W?(D=a.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[z,W]}),e[33]=z,e[34]=W,e[35]=D):D=e[35];let L;e[36]!==f||e[37]!==y?(L=f&&a.jsx(ZT,{message:f,onRetry:y}),e[36]=f,e[37]=y,e[38]=L):L=e[38];let U;e[39]!==s||e[40]!==d||e[41]!==v||e[42]!==x||e[43]!==g||e[44]!==m||e[45]!==_||e[46]!==j||e[47]!==c||e[48]!==l||e[49]!==t.dirName||e[50]!==k||e[51]!==r||e[52]!==i||e[53]!==o?(U=(i||l)&&d.length===0?a.jsx(YT,{includeMessagePlaceholder:!0}):d.length===0?a.jsx(efe,{searchFilter:c,filterEmpty:s}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"overflow-hidden rounded-lg border bg-card",children:d.map((V,H)=>a.jsxs(w.Fragment,{children:[H>0&&a.jsx(Gt,{}),a.jsx(I0,{sessionLabel:t6(V),customName:k[V.sessionId],onRename:K=>j(V.sessionId,K),onDuplicate:g?()=>g(t.dirName,V.fileName):void 0,onDelete:x&&_(V.access).delete?()=>x(t.dirName,V.fileName):void 0,children:a.jsx(Jde,{session:V,customName:k[V.sessionId],onSelect:()=>m(t.dirName,V.fileName)})})]},V.fileName))}),r.length<o&&!c&&a.jsx("div",{className:"flex justify-center",children:a.jsxs(ee,{variant:"outline",size:"sm",disabled:i,onClick:v,children:[i&&a.jsx(An,{"data-icon":"inline-start"}),i?"Loading...":"Load more sessions"]})})]}),e[39]=s,e[40]=d,e[41]=v,e[42]=x,e[43]=g,e[44]=m,e[45]=_,e[46]=j,e[47]=c,e[48]=l,e[49]=t.dirName,e[50]=k,e[51]=r,e[52]=i,e[53]=o,e[54]=U):U=e[54];let F;e[55]!==D||e[56]!==L||e[57]!==U?(F=a.jsxs("section",{className:"flex flex-col gap-4","aria-label":"Sessions",children:[D,L,U]}),e[55]=D,e[56]=L,e[57]=U,e[58]=F):F=e[58];let B;return e[59]!==R||e[60]!==F||e[61]!==A?(B=a.jsx(Jl,{className:"h-full",children:a.jsxs("main",{className:"mx-auto flex max-w-6xl flex-col gap-6 px-4 py-6 sm:px-6 sm:pb-10 sm:pt-14",children:[A,R,F]})}),e[59]=R,e[60]=F,e[61]=A,e[62]=B):B=e[62],B}function efe(n){const e=q.c(8),{searchFilter:t,filterEmpty:s}=n;if(!t&&s)return s;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(Rn,{variant:"icon",children:a.jsx(io,{})}),e[0]=r):r=e[0];const o=t?"No sessions match your search":"No sessions yet";let i;e[1]!==o?(i=a.jsx(Nn,{children:o}),e[1]=o,e[2]=i):i=e[2];const l=t?"Try #157, honest-cms #157, or paste a PR URL.":"Start a session in this project and it will appear here.";let c;e[3]!==l?(c=a.jsx(Cn,{children:l}),e[3]=l,e[4]=c):c=e[4];let u;return e[5]!==i||e[6]!==c?(u=a.jsx(kn,{className:"min-h-72 border",children:a.jsxs(jn,{children:[r,i,c]})}),e[5]=i,e[6]=c,e[7]=u):u=e[7],u}function n6(n){const e=q.c(40),{children:t,projectLabel:s,customName:r,className:o,onRename:i,archivableCount:l,onArchiveIdle:c}=n,u=l===void 0?0:l,[d,f]=w.useState(!1),[m,p]=w.useState(""),h=w.useRef(null);let g;e[0]!==r?(g=function(){p(r||""),f(!0),requestAnimationFrame(()=>{var z;return(z=h.current)==null?void 0:z.select()})},e[0]=r,e[1]=g):g=e[1];const x=g;let b;e[2]!==o?(b=G("w-full",o),e[2]=o,e[3]=b):b=e[3];let y;e[4]!==b?(y=a.jsx("div",{className:b}),e[4]=b,e[5]=y):y=e[5];let v;e[6]!==t||e[7]!==y?(v=a.jsx(xf,{render:y,children:t}),e[6]=t,e[7]=y,e[8]=v):v=e[8];let k;e[9]===Symbol.for("react.memo_cache_sentinel")?(k=a.jsx(Er,{"data-icon":"inline-start"}),e[9]=k):k=e[9];let j;e[10]!==x?(j=a.jsx(zo,{children:a.jsxs($n,{onClick:x,children:[k,"Rename project"]})}),e[10]=x,e[11]=j):j=e[11];let _;e[12]!==u||e[13]!==c?(_=c&&a.jsxs(a.Fragment,{children:[a.jsx(Di,{}),a.jsx(zo,{children:a.jsxs($n,{onClick:c,disabled:u===0,children:[a.jsx(gs,{"data-icon":"inline-start"}),u>0?`Archive ${u} idle ${u===1?"session":"sessions"}`:"Archive idle sessions"]})})]}),e[12]=u,e[13]=c,e[14]=_):_=e[14];let N;e[15]!==j||e[16]!==_?(N=a.jsxs(bf,{className:"min-w-44",children:[j,_]}),e[15]=j,e[16]=_,e[17]=N):N=e[17];let S;e[18]!==v||e[19]!==N?(S=a.jsxs(gf,{children:[v,N]}),e[18]=v,e[19]=N,e[20]=S):S=e[20];let C;e[21]===Symbol.for("react.memo_cache_sentinel")?(C=a.jsxs(wo,{children:[a.jsx(mr,{className:"text-foreground",children:"Rename project"}),a.jsx(pr,{className:"text-muted-foreground",children:"Give this project a custom name. Clear to reset to default."})]}),e[21]=C):C=e[21];let E;e[22]!==i||e[23]!==m?(E=R=>{R.preventDefault(),i(m),f(!1)},e[22]=i,e[23]=m,e[24]=E):E=e[24];let T;e[25]===Symbol.for("react.memo_cache_sentinel")?(T=a.jsx(dn,{htmlFor:"project-rename",children:"Project name"}),e[25]=T):T=e[25];let A;e[26]===Symbol.for("react.memo_cache_sentinel")?(A=R=>p(R.target.value),e[26]=A):A=e[26];let P;e[27]!==s||e[28]!==m?(P=a.jsxs(un,{children:[T,a.jsx(Zn,{id:"project-rename",ref:h,value:m,onChange:A,placeholder:s})]}),e[27]=s,e[28]=m,e[29]=P):P=e[29];let I;e[30]===Symbol.for("react.memo_cache_sentinel")?(I=a.jsxs($1,{children:[a.jsx(ee,{type:"button",variant:"ghost",size:"sm",onClick:()=>f(!1),children:"Cancel"}),a.jsx(ee,{type:"submit",size:"sm",children:"Save"})]}),e[30]=I):I=e[30];let $;e[31]!==E||e[32]!==P?($=a.jsxs(fr,{className:"sm:max-w-md",children:[C,a.jsxs("form",{className:"flex flex-col gap-4",onSubmit:E,children:[P,I]})]}),e[31]=E,e[32]=P,e[33]=$):$=e[33];let O;e[34]!==d||e[35]!==$?(O=a.jsx(dr,{open:d,onOpenChange:f,children:$}),e[34]=d,e[35]=$,e[36]=O):O=e[36];let M;return e[37]!==S||e[38]!==O?(M=a.jsxs(a.Fragment,{children:[S,O]}),e[37]=S,e[38]=O,e[39]=M):M=e[39],M}function tfe(n){const e=q.c(47),{projects:t,activeSessions:s,loading:r,refreshing:o,searchFilter:i,setSearchFilter:l,fetchError:c,selectedProjectDirName:u,onSelectProject:d,onRefresh:f}=n;let m;if(e[0]!==s){m={};for(const R of s)e6(R.lastModified)&&(m[R.dirName]=(m[R.dirName]||0)+1);e[0]=s,e[1]=m}else m=e[1];const p=m,{names:h,rename:g}=P0();let x;e[2]!==t?(x=WT(t),e[2]=t,e[3]=x):x=e[3];const b=x;let y;e:{if(!i){y=b;break e}let R;if(e[4]!==h||e[5]!==b||e[6]!==i){const z=i.toLowerCase(),W=D=>{var L;return D.path.toLowerCase().includes(z)||D.shortName.toLowerCase().includes(z)||((L=h[D.dirName])==null?void 0:L.toLowerCase().includes(z))};R=b.filter(D=>W(D)||D.worktrees.some(W)),e[4]=h,e[5]=b,e[6]=i,e[7]=R}else R=e[7];y=R}const v=y;let k;e[8]===Symbol.for("react.memo_cache_sentinel")?(k=a.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Projects"}),e[8]=k):k=e[8];let j;e[9]!==b.length?(j=a.jsxs("div",{className:"flex items-center gap-2",children:[k,a.jsx(Ue,{variant:"secondary",children:b.length})]}),e[9]=b.length,e[10]=j):j=e[10];let _;e[11]===Symbol.for("react.memo_cache_sentinel")?(_=a.jsx("p",{className:"text-sm text-muted-foreground",children:"Open a project to browse and resume its sessions."}),e[11]=_):_=e[11];let N;e[12]!==j?(N=a.jsxs("header",{className:"flex flex-col gap-1",children:[j,_]}),e[12]=j,e[13]=N):N=e[13];let S;e[14]!==i||e[15]!==l?(S=a.jsx(GT,{value:i,onChange:l,placeholder:"Filter projects..."}),e[14]=i,e[15]=l,e[16]=S):S=e[16];const C=o&&"animate-spin";let E;e[17]!==C?(E=G(C),e[17]=C,e[18]=E):E=e[18];let T;e[19]!==E?(T=a.jsx(On,{"data-icon":"inline-start",className:E}),e[19]=E,e[20]=T):T=e[20];let A;e[21]!==f||e[22]!==o||e[23]!==T?(A=a.jsxs(ee,{variant:"outline",size:"sm",onClick:f,disabled:o,"aria-label":"Refresh projects",children:[T,"Refresh"]}),e[21]=f,e[22]=o,e[23]=T,e[24]=A):A=e[24];let P;e[25]!==A||e[26]!==S?(P=a.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[S,A]}),e[25]=A,e[26]=S,e[27]=P):P=e[27];let I;e[28]!==c||e[29]!==f||e[30]!==u?(I=c&&!u&&a.jsx(ZT,{message:c,onRetry:f}),e[28]=c,e[29]=f,e[30]=u,e[31]=I):I=e[31];let $;e[32]!==p||e[33]!==v||e[34]!==r||e[35]!==d||e[36]!==h||e[37]!==g||e[38]!==i?($=r?a.jsx(YT,{}):v.length===0?a.jsxs(kn,{className:"min-h-72 border",children:[a.jsxs(jn,{children:[a.jsx(Rn,{variant:"icon",children:a.jsx(Tr,{})}),a.jsx(Nn,{children:i?"No projects match your search":"No projects yet"}),a.jsx(Cn,{children:i?"Try a project name or path.":"Start Claude Code, Codex, or Copilot and its project will appear here."})]}),!i&&a.jsx(zl,{children:a.jsxs(ee,{variant:"outline",size:"sm",onClick:nfe,children:[a.jsx(Ml,{"data-icon":"inline-start"}),"Start in a folder"]})})]}):a.jsx("div",{className:"overflow-hidden rounded-lg border bg-card",children:v.map((R,z)=>{const W=p[R.dirName]||0,D=h[R.dirName],L=vR(nn(R.dirName));return a.jsxs(w.Fragment,{children:[z>0&&a.jsx(Gt,{}),a.jsx(n6,{projectLabel:rr(R.path),customName:D,onRename:U=>g(R.dirName,U),children:a.jsxs("button",{type:"button",onClick:()=>d==null?void 0:d(R.dirName),className:"motion-list-item group flex w-full flex-col gap-3 px-4 py-3.5 text-left outline-none transition-colors hover:bg-muted/50 focus-visible:bg-muted focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset sm:flex-row sm:items-center",children:[a.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-3",children:[a.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-md border bg-muted/40",children:a.jsx(Hi,{projectPath:R.path,className:"size-4",fallback:a.jsx(Tr,{className:"size-4 text-muted-foreground"})})}),a.jsxs("span",{className:"min-w-0",children:[a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"truncate text-sm font-medium",children:D||rr(R.path)}),L&&a.jsx(Ue,{variant:"outline",className:"h-5 shrink-0 px-1.5 text-[10px]",children:L})]}),a.jsxs("span",{className:"block truncate text-xs text-muted-foreground",children:[ql(R.path),R.worktrees.length>0&&a.jsxs(a.Fragment,{children:[" · ",R.worktrees.length," ",R.worktrees.length===1?"worktree":"worktrees"]})]})]})]}),a.jsxs("span",{className:"flex items-center gap-4 pl-11 text-sm text-muted-foreground sm:pl-0",children:[W>0&&a.jsxs(Ue,{variant:"secondary",children:[a.jsx("span",{"aria-hidden":"true","data-icon":"inline-start",className:"size-1.5 rounded-full bg-success"}),W," active"]}),a.jsxs("span",{className:"whitespace-nowrap",children:[R.sessionCount," ",R.sessionCount===1?"session":"sessions"]}),R.lastModified&&a.jsx("span",{className:"hidden w-24 whitespace-nowrap text-right md:inline",children:Yo(R.lastModified)}),a.jsx(ot,{className:"size-4 shrink-0 transition-transform group-hover:translate-x-0.5"})]})]})}),R.worktrees.map(U=>a.jsx(sfe,{worktree:U,customName:h[U.dirName],activeCount:p[U.dirName]||0,onSelect:()=>d==null?void 0:d(U.dirName)},U.dirName))]},R.dirName)})}),e[32]=p,e[33]=v,e[34]=r,e[35]=d,e[36]=h,e[37]=g,e[38]=i,e[39]=$):$=e[39];let O;e[40]!==P||e[41]!==I||e[42]!==$?(O=a.jsxs("section",{className:"flex flex-col gap-4","aria-label":"Projects",children:[P,I,$]}),e[40]=P,e[41]=I,e[42]=$,e[43]=O):O=e[43];let M;return e[44]!==O||e[45]!==N?(M=a.jsx(Jl,{className:"h-full",children:a.jsxs("main",{className:"mx-auto flex max-w-6xl flex-col gap-6 px-4 py-6 sm:px-6 sm:pb-10 sm:pt-14",children:[N,O]})}),e[44]=O,e[45]=N,e[46]=M):M=e[46],M}function nfe(){return g5()}function sfe(n){var b;const e=q.c(23),{worktree:t,customName:s,activeCount:r,onSelect:o}=n;let i;e[0]!==s||e[1]!==t.path?(i=s||((b=nr(t.path))==null?void 0:b.worktreeName)||rr(t.path),e[0]=s,e[1]=t.path,e[2]=i):i=e[2];const l=i;let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=a.jsx(_r,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),e[3]=c):c=e[3];let u;e[4]!==l?(u=a.jsx("span",{className:"min-w-0 flex-1 truncate text-muted-foreground group-hover:text-foreground",children:l}),e[4]=l,e[5]=u):u=e[5];let d;e[6]!==r?(d=r>0&&a.jsxs(Ue,{variant:"secondary",children:[a.jsx("span",{"aria-hidden":"true","data-icon":"inline-start",className:"size-1.5 rounded-full bg-success"}),r," active"]}),e[6]=r,e[7]=d):d=e[7];const f=t.sessionCount===1?"session":"sessions";let m;e[8]!==f||e[9]!==t.sessionCount?(m=a.jsxs("span",{className:"whitespace-nowrap",children:[t.sessionCount," ",f]}),e[8]=f,e[9]=t.sessionCount,e[10]=m):m=e[10];let p;e[11]!==t.lastModified?(p=t.lastModified&&a.jsx("span",{className:"hidden w-24 whitespace-nowrap text-right md:inline",children:Yo(t.lastModified)}),e[11]=t.lastModified,e[12]=p):p=e[12];let h;e[13]===Symbol.for("react.memo_cache_sentinel")?(h=a.jsx(ot,{className:"size-4 shrink-0 transition-transform group-hover:translate-x-0.5"}),e[13]=h):h=e[13];let g;e[14]!==d||e[15]!==m||e[16]!==p?(g=a.jsxs("span",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[d,m,p,h]}),e[14]=d,e[15]=m,e[16]=p,e[17]=g):g=e[17];let x;return e[18]!==o||e[19]!==u||e[20]!==g||e[21]!==t.path?(x=a.jsxs("button",{type:"button",onClick:o,title:t.path,className:"motion-list-item group flex w-full items-center gap-3 py-2 pl-15 pr-4 text-left text-sm outline-none transition-colors hover:bg-muted/50 focus-visible:bg-muted focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",children:[c,u,g]}),e[18]=o,e[19]=u,e[20]=g,e[21]=t.path,e[22]=x):x=e[22],x}const rfe=250,ofe=400,Ek={results:null,loading:!1,error:null};function s6(n,e,t){const s=w.useMemo(()=>JT(n),[n]),[r,o]=w.useState(0),[i,l]=w.useState(Ek);w.useEffect(()=>{if(!s){l(Ek);return}const d=new AbortController;l({results:null,loading:!0,error:null});let f=null;const m=async()=>{const h=new URLSearchParams({search:n.trim(),limit:"200"});t&&h.set("project",t);const g=Pr();try{const x=await Re(ff(h,e),{signal:d.signal});if(!x.ok)throw new Error(`Search failed (${x.status})`);const b=await x.json();if(d.signal.aborted)return;const y=Number(x.headers.get("X-Cogpit-PR-Index-Pending")??"0");if(Number.isFinite(y)&&y>0){f=setTimeout(()=>{m()},ofe);return}const v=Array.isArray(b)?b:[];Mi(v,g),l({results:v,loading:!1,error:null})}catch(x){if(d.signal.aborted)return;l({results:[],loading:!1,error:x instanceof Error?x.message:"Search failed"})}},p=setTimeout(()=>{m()},rfe);return()=>{clearTimeout(p),f&&clearTimeout(f),d.abort()}},[e,t,s,n,r]);const c=w.useCallback(()=>o(d=>d+1),[]),u=s!==null;return w.useEffect(()=>{if(u)return mf(c)},[u,c]),{...i,active:u,refresh:c}}const ife=w.memo(function({onSelectSession:e,onNewSession:t,creatingSession:s,selectedProjectDirName:r,onSelectProject:o,onDuplicateSession:i,onDeleteSession:l}){var te;const c=df(),u=(te=ur().sessionListFilter)==null?void 0:te.Empty,[d]=w.useState(()=>({projects:Ci(kl.projects),activeSessions:Ci(Nu(c.key))})),[f,m]=w.useState(d.projects??[]),[p,h]=w.useState(d.activeSessions??[]),[g,x]=w.useState(d.projects===void 0),[b,y]=w.useState(!1),[v,k]=w.useState(null),[j,_]=w.useState(null),[N,S]=w.useState([]),[C,E]=w.useState(0),[T,A]=w.useState(1),[P,I]=w.useState(!1),[$,O]=w.useState(""),[M,R]=w.useState(null),z=w.useRef(0),W=w.useRef(null),D=w.useRef(null),L=w.useRef(c.key),U=w.useCallback(async()=>{try{const J=await Re("/api/projects");if(!J.ok)throw new Error("Failed to fetch dashboard data");const ne=await J.json(),re=Array.isArray(ne)?ne:[];m(re),Ya(kl.projects,re),k(null)}catch(J){k(J instanceof Error?J.message:"Failed to load data")}finally{x(!1)}},[]),F=w.useCallback(async()=>{var re;(re=D.current)==null||re.abort();const J=new AbortController;D.current=J;const ne=Pr();try{const le=await Re(ff({},c),{signal:J.signal});if(!le.ok)throw new Error("Failed to fetch dashboard data");const ae=await le.json();if(J.signal.aborted)return;const ue=Array.isArray(ae)?ae:[];Mi(ue,ne),h(ue),Ya(Nu(c.key),ue),_(null)}catch(le){if(J.signal.aborted)return;_(le instanceof Error?le.message:"Failed to load data")}},[c]);w.useEffect(()=>{U()},[U]),w.useEffect(()=>{L.current!==c.key&&(L.current=c.key,h(Ci(Nu(c.key))??[])),F()},[c,F]);async function B(){y(!0),await Promise.all([U(),F()]),y(!1)}const V=w.useCallback(async(J,ne=1,re=!1)=>{var ie;const le=++z.current;(ie=W.current)==null||ie.abort();const ae=new AbortController;W.current=ae;const ue=()=>le===z.current;I(!0),R(null);const oe=Pr();if(!re){const fe=oU(J,c.key);fe?(S(fe.sessions),E(fe.total),A(1)):S([])}try{const fe=await Re(Xa(`/api/sessions/${encodeURIComponent(J)}`,c,{page:String(ne),limit:"20"}),{signal:ae.signal});if(!fe.ok)throw new Error(`Failed to load sessions (${fe.status})`);const de=await fe.json();if(!ue())return;const ce=Array.isArray(de.sessions)?de.sessions:[],xe=typeof de.total=="number"?de.total:ce.length;Mi(ce,oe),S(pe=>re?[...pe,...ce]:ce),E(xe),A(ne),re||iU(J,c.key,{sessions:ce,total:xe})}catch(fe){if(!ue()||ae.signal.aborted)return;R(fe instanceof Error?fe.message:"Failed to load sessions")}finally{ue()&&(W.current=null,I(!1))}},[c]);w.useEffect(()=>{var J;if(!r){z.current+=1,(J=W.current)==null||J.abort(),W.current=null,S([]),E(0),A(1),I(!1);return}V(r)},[r,V]),w.useEffect(()=>{O("")},[r]),w.useEffect(()=>()=>{var J,ne;z.current+=1,(J=W.current)==null||J.abort(),(ne=D.current)==null||ne.abort()},[]),w.useEffect(()=>mf(()=>{F(),r&&V(r)}),[F,V,r]);const H=w.useMemo(()=>{if(!r)return null;const J=f.find(re=>re.dirName===r);if(J)return J;const ne=ls(r);return{dirName:r,path:ne,shortName:rr(ne),sessionCount:C,lastModified:null}},[r,f,C]),K=w.useCallback(()=>{o==null||o(null)},[o]),Z=w.useCallback(()=>{r&&V(r,T+1,!0)},[r,T,V]),Y=s6(r?$:"",c,r??void 0),X=w.useMemo(()=>$?N.filter(J=>Hde(J,$)):N,[N,$]),se=Y.results??X;async function Q(J,ne){await(l==null?void 0:l(J,ne))&&(S(re=>re.filter(le=>le.fileName!==ne)),E(re=>re-1))}return H?a.jsx(Qde,{selectedProject:H,filterEmpty:c.key!==null&&u?a.jsx(u,{className:"min-h-72 border"}):null,sessions:N,sessionsTotal:C,sessionsLoading:P,searchLoading:Y.loading,searchFilter:$,setSearchFilter:O,filteredSessions:se,fetchError:Y.error??M,onSelectSession:e,onNewSession:t,creatingSession:s,onDuplicateSession:i,onDeleteSession:Q,onBack:K,onRetryFetch:()=>{if(Y.error){Y.refresh();return}R(null),r&&V(r)},loadMoreSessions:Z}):a.jsx(tfe,{projects:f,activeSessions:p,loading:g,refreshing:b,searchFilter:$,setSearchFilter:O,fetchError:v??j,selectedProjectDirName:r??null,onSelectProject:o,onRefresh:()=>void B()})});async function r6(n,e,t){return(await ws(`/api/permissions/${encodeURIComponent(n)}/respond`,{requestId:e,behavior:t})).ok}async function afe(n,e){return(await ws(`/api/permissions/${encodeURIComponent(n)}/respond-all`,{behavior:e})).ok}function lfe(n,e,t){return O1("/api/elicitation-answer",{sessionId:n,requestId:e,...t})}function cfe(n,e,t){return O1("/api/user-dialog-answer",{sessionId:n,requestId:e,choice:t})}const ufe=3e3,o6=w.createContext(null);async function dh(n){try{const e=await Re(n);return e.ok?await e.text():void 0}catch{return}}function fh(n,e){if(!(n===void 0||n===e.current))try{const t=JSON.parse(n);return e.current=n,t}catch{return}}function Na(n){const e=new Map;for(const[t,s]of Object.entries(n??{}))Array.isArray(s)&&s.length>0&&e.set(t,s);return e}function pu(n,e,t){const s=new Map(n),r=(s.get(e)??[]).filter(o=>!t(o));return r.length>0?s.set(e,r):s.delete(e),s}function dfe({children:n}){const[e,t]=w.useState(new Map),[s,r]=w.useState(new Map),[o,i]=w.useState(new Map),[l,c]=w.useState(new Map),[u,d]=w.useState(new Set),[f,m]=w.useState(new Set),p=w.useRef(""),h=w.useRef(""),g=w.useRef(""),x=df(),b=tC()!==null,y=w.useRef(x.key);w.useLayoutEffect(()=>{y.current=x.key},[x.key]);const v=w.useCallback(async()=>{const[$,O,M]=await Promise.all([dh(Xa("/api/permissions",x)),dh(Xa("/api/user-questions",x)),dh(Xa("/api/agent-prompts",x))]);if(y.current!==x.key)return;const R=fh($,p),z=fh(O,h),W=fh(M,g);R&&(t(Na(R.bySession)),d(new Set(Na(R.plansBySession).keys()))),z&&r(Na(z.bySession)),W&&(i(Na(W.elicitationsBySession)),c(Na(W.dialogsBySession)))},[x]);w.useEffect(()=>{if(b)return;const $=()=>{document.visibilityState==="visible"&&v()};$();const O=setInterval($,ufe);return document.addEventListener("visibilitychange",$),()=>{clearInterval(O),document.removeEventListener("visibilitychange",$)}},[v,b]);const k=w.useCallback(async($,O)=>{m(M=>new Set(M).add($));try{return await O()}finally{m(M=>{const R=new Set(M);return R.delete($),R}),v()}},[v]),j=w.useCallback(($,O,M)=>k(O,async()=>{await r6($,O,M).catch(()=>!1)&&(t(z=>pu(z,$,W=>W.requestId===O)),p.current="")}),[k]),_=w.useCallback(($,O,M)=>k(O,async()=>{const R=await L1($,O,M);return R.ok&&(r(z=>pu(z,$,W=>W.toolUseId===O)),h.current=""),R}),[k]),N=w.useCallback(($,O,M)=>k(O,async()=>{const R=await lfe($,O,M);return R.ok&&(i(z=>pu(z,$,W=>W.requestId===O)),g.current=""),R}),[k]),S=w.useCallback(($,O,M)=>k(O,async()=>{const R=await cfe($,O,M);return R.ok&&(c(z=>pu(z,$,W=>W.requestId===O)),g.current=""),R}),[k]),C=w.useMemo(()=>new Set(e.keys()),[e]),E=w.useMemo(()=>new Set(s.keys()),[s]),T=w.useMemo(()=>new Set(o.keys()),[o]),A=w.useMemo(()=>new Set(l.keys()),[l]),P=w.useCallback(()=>{v()},[v]),I=w.useMemo(()=>({permissionsBySession:e,questionsBySession:s,elicitationsBySession:o,dialogsBySession:l,awaitingPermission:C,awaitingQuestion:E,awaitingElicitation:T,awaitingDialog:A,awaitingPlan:u,responding:f,respond:j,answerQuestion:_,answerElicitation:N,answerDialog:S,refresh:P}),[e,s,o,l,C,E,T,A,u,f,j,_,N,S,P]);return a.jsx(o6.Provider,{value:I,children:n})}function ffe(){const n=w.useContext(o6);if(!n)throw new Error("usePendingHumanInput must be used within a PendingHumanInputProvider");return n}const Tk=768;function $0(){const n=q.c(2),[e,t]=w.useState(typeof window<"u"?window.innerWidth<Tk:!1);let s,r;return n[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>{const o=window.matchMedia(`(max-width: ${Tk-1}px)`),i=l=>t(l.matches);return o.addEventListener("change",i),t(o.matches),()=>o.removeEventListener("change",i)},r=[],n[0]=s,n[1]=r):(s=n[0],r=n[1]),w.useEffect(s,r),e}const i6=typeof navigator<"u"&&"vibrate"in navigator;function Ug(){i6&&navigator.vibrate(10)}function mfe(){i6&&navigator.vibrate(20)}function pfe(n){return!!(n.teamName&&n.agentName)}function hfe(n,e,t,s,r,o,i,l=()=>!0){const c=[],u=[];for(const d of oc(n)){const f=p=>{l(d)&&c.push({session:d,reason:p})};if(s!=null&&s.has(d.sessionId)){f("permission");continue}if(r!=null&&r.has(d.sessionId)){f("question");continue}if(o!=null&&o.has(d.sessionId)){f("prompt");continue}if(i!=null&&i.has(d.sessionId)){f("plan");continue}if(d.agentStatus==="deferred"){f("deferred");continue}if(pfe(d))continue;const m=rC(d,e);if(d.agentStatus==="completed"||!m){t.has(d.sessionId)&&f("done");continue}if(d.agentStatus==="idle"){f("waiting");continue}(!d.agentStatus||wx.has(d.agentStatus))&&u.push(d)}return{needsYou:c,working:u}}function gfe(n){switch(n.agentStatus){case"tool_use":return n.agentToolName||"Tool";case"thinking":return"Thinking";case"processing":return"Processing";case"compacting":return"Compacting";case"awaiting_agents":return"Agents running";default:return"Running"}}function R0(n,e){return n?xn(n).externalProcesses&&(e==null?void 0:e.managed)===!1:!1}const a6="aw:turnCounts",xfe=200,Ff=new Map;try{const n=localStorage.getItem(a6);if(n){const e=JSON.parse(n);for(const[t,s]of e)Ff.set(t,s)}}catch{}function bfe(){try{const n=[...Ff.entries()].slice(-xfe);localStorage.setItem(a6,JSON.stringify(n))}catch{}}function vfe(n,e){Ff.set(gn(n),e),bfe()}function l6(n,e){const t=Ff.get(gn(n));return Math.max(t??0,e??0)}function O0(n){const e=q.c(51),{session:t,proc:s,statusLabel:r,customName:o,worktreeName:i,projectLabel:l}=n,c=o||t.aiTitle,u=t.firstUserMessage,d=t.lastUserMessage&&t.lastUserMessage!==u?t.lastUserMessage:void 0,f=l6(t.sessionId,t.turnCount);let m;e[0]!==c?(m=c&&a.jsx("span",{className:"font-medium leading-snug text-foreground",children:c}),e[0]=c,e[1]=m):m=e[1];let p;e[2]!==l?(p=l&&a.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[a.jsx(Ii,{className:"size-3 shrink-0"}),a.jsx("span",{className:"truncate",children:l})]}),e[2]=l,e[3]=p):p=e[3];let h;e[4]!==t.agentStatus||e[5]!==r?(h=r&&a.jsx("span",{className:G("font-medium",Df(t.agentStatus)),children:r}),e[4]=t.agentStatus,e[5]=r,e[6]=h):h=e[6];let g;e[7]!==t.agentName||e[8]!==t.teamName?(g=t.teamName&&t.agentName&&a.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[a.jsx(Bs,{className:"size-3"}),t.agentName," · ",t.teamName]}),e[7]=t.agentName,e[8]=t.teamName,e[9]=g):g=e[9];let x;e[10]!==t.archived||e[11]!==t.archivedReason?(x=t.archived&&a.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[a.jsx(gs,{className:"size-3"}),vx(t.archivedReason)]}),e[10]=t.archived,e[11]=t.archivedReason,e[12]=x):x=e[12];let b;e[13]!==u||e[14]!==d?(b=u&&a.jsxs("div",{className:"flex flex-col gap-0.5",children:[d&&a.jsx("span",{className:"text-[10px] text-muted-foreground/70",children:"Started with"}),a.jsx("div",{className:"border-l-2 pl-2 text-muted-foreground",children:a.jsx("span",{"data-first-prompt":!0,className:"line-clamp-8 leading-relaxed",children:u})})]}),e[13]=u,e[14]=d,e[15]=b):b=e[15];let y;e[16]!==d?(y=d&&a.jsxs("div",{className:"flex flex-col gap-0.5",children:[a.jsx("span",{className:"text-[10px] text-muted-foreground/70",children:"Latest"}),a.jsx("div",{className:"border-l-2 pl-2 text-muted-foreground",children:a.jsx("span",{"data-last-prompt":!0,className:"line-clamp-4 leading-relaxed",children:d})})]}),e[16]=d,e[17]=y):y=e[17];let v;e[18]!==t.pullRequests?(v=a.jsx(dc,{pullRequests:t.pullRequests,layout:"list"}),e[18]=t.pullRequests,e[19]=v):v=e[19];let k;e[20]!==t.gitBranch||e[21]!==i?(k=t.gitBranch&&a.jsxs("span",{className:"flex items-center gap-0.5",children:[a.jsx(_r,{className:"size-2.5"}),i?`${t.gitBranch} · ${i}`:t.gitBranch]}),e[20]=t.gitBranch,e[21]=i,e[22]=k):k=e[22];let j;e[23]!==f?(j=f>0&&a.jsxs("span",{className:"flex items-center gap-0.5",children:[a.jsx(io,{className:"size-2.5"}),f," ",f===1?"turn":"turns"]}),e[23]=f,e[24]=j):j=e[24];let _;e[25]!==t.size?(_=mj(t.size),e[25]=t.size,e[26]=_):_=e[26];let N;e[27]!==_?(N=a.jsx("span",{children:_}),e[27]=_,e[28]=N):N=e[28];let S;e[29]!==s?(S=s&&a.jsxs("span",{className:"flex items-center gap-0.5 text-success",children:[a.jsx(OP,{className:"size-2.5"}),s.memMB," MB"]}),e[29]=s,e[30]=S):S=e[30];const C=t.lastActivityAt||t.lastModified;let E;e[31]!==C?(E=Yo(C),e[31]=C,e[32]=E):E=e[32];let T;e[33]!==E?(T=a.jsx("span",{children:E}),e[33]=E,e[34]=T):T=e[34];let A;e[35]!==j||e[36]!==N||e[37]!==S||e[38]!==T||e[39]!==k?(A=a.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 text-muted-foreground",children:[k,j,N,S,T]}),e[35]=j,e[36]=N,e[37]=S,e[38]=T,e[39]=k,e[40]=A):A=e[40];let P;return e[41]!==m||e[42]!==A||e[43]!==p||e[44]!==h||e[45]!==g||e[46]!==x||e[47]!==b||e[48]!==y||e[49]!==v?(P=a.jsxs("div",{className:"flex w-72 flex-col gap-2 text-xs",children:[m,p,h,g,x,b,y,v,A]}),e[41]=m,e[42]=A,e[43]=p,e[44]=h,e[45]=g,e[46]=x,e[47]=b,e[48]=y,e[49]=v,e[50]=P):P=e[50],P}const yfe=120;function L0(n){const e=q.c(7),t=w.useRef(null);let s,r;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>()=>{t.current&&clearTimeout(t.current)},r=[],e[0]=s,e[1]=r):(s=e[0],r=e[1]),w.useEffect(s,r);let o;e[2]!==n?(o=()=>{n&&(t.current&&clearTimeout(t.current),t.current=setTimeout(n,yfe))},e[2]=n,e[3]=o):o=e[3];const i=o;let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{t.current&&(clearTimeout(t.current),t.current=null)},e[4]=l):l=e[4];const c=l;let u;return e[5]!==i?(u={onHoverStart:i,onHoverEnd:c},e[5]=i,e[6]=u):u=e[6],u}const wfe=6;function Sfe(n){const e=q.c(7),{iso:t}=n,[,s]=w.useState(0);let r;e[0]!==s?(r=()=>{const c=setInterval(()=>s(kfe),15e3);return()=>clearInterval(c)},e[0]=s,e[1]=r):r=e[1];let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=[],e[2]=o):o=e[2],w.useEffect(r,o);let i;e[3]!==t?(i=Yo(t),e[3]=t,e[4]=i):i=e[4];let l;return e[5]!==i?(l=a.jsx("span",{"data-relative-time":!0,className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:i}),e[5]=i,e[6]=l):l=e[6],l}function kfe(n){return n+1}const jfe={permission:{label:"Permission",className:"border-warning/30 bg-warning/10 text-warning"},deferred:{label:"Deferred",className:"border-warning/30 bg-warning/10 text-warning"},question:{label:"Question",className:"border-warning/30 bg-warning/10 text-warning"},prompt:{label:"Input needed",className:"border-warning/30 bg-warning/10 text-warning"},plan:{label:"Review plan",className:"border-warning/30 bg-warning/10 text-warning"},waiting:{label:"Waiting",className:"border-warning/30 bg-warning/10 text-warning"},done:{label:"Done",className:"border-success/30 bg-success/10 text-success"}},Nfe={permission:ro.attention,deferred:ro.attention,waiting:ro.attention,question:"bg-warning",prompt:"bg-warning",plan:"bg-warning",done:"bg-success"};function Ak(n){const e=q.c(76),{session:t,chip:s,dotClassName:r,cardClassName:o,isActiveSession:i,proc:l,killingPids:c,customName:u,projectLabel:d,compact:f,onSelect:m,onKill:p,onResume:h,onPrefetch:g}=n,x=f===void 0?!1:f;let b;e[0]!==l||e[1]!==t.dirName?(b=R0(nn(t.dirName),l),e[0]=l,e[1]=t.dirName,e[2]=b):b=e[2];const y=b;let v;e[3]!==s||e[4]!==y||e[5]!==t.agentPendingAgents||e[6]!==t.agentStatus||e[7]!==t.agentTerminalReason||e[8]!==t.agentToolName?(v=y?"Read-only":cc(t.agentStatus,t.agentToolName,t.agentTerminalReason,t.agentPendingAgents)??s.label,e[3]=s,e[4]=y,e[5]=t.agentPendingAgents,e[6]=t.agentStatus,e[7]=t.agentTerminalReason,e[8]=t.agentToolName,e[9]=v):v=e[9];const k=v,j=!!h&&!y,{onHoverStart:_,onHoverEnd:N}=L0(g),S=x?"px-2.5 py-2":"border px-2 py-2",C=i&&!x&&"ring-1 ring-ring";let E;e[10]!==o||e[11]!==S||e[12]!==C?(E=G("group relative w-full rounded-md text-left transition-colors",S,o,C),e[10]=o,e[11]=S,e[12]=C,e[13]=E):E=e[13];let T;e[14]!==x||e[15]!==i?(T=x&&i&&a.jsx("span",{className:"absolute inset-y-2 left-0 w-0.5 rounded-full bg-primary","aria-hidden":"true"}),e[14]=x,e[15]=i,e[16]=T):T=e[16];const A=j&&"pr-20";let P;e[17]!==A?(P=G("w-full rounded-sm text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",A),e[17]=A,e[18]=P):P=e[18];let I;e[19]!==N||e[20]!==_||e[21]!==m||e[22]!==P?(I=a.jsx("button",{type:"button","data-attention-session":!0,onClick:m,onMouseEnter:_,onMouseLeave:N,onFocus:_,onBlur:N,className:P}),e[19]=N,e[20]=_,e[21]=m,e[22]=P,e[23]=I):I=e[23];const $=x&&"ring-0";let O;e[24]!==r||e[25]!==$?(O=G("size-1.5 shrink-0 rounded-full",r,$),e[24]=r,e[25]=$,e[26]=O):O=e[26];let M;e[27]!==O?(M=a.jsx("span",{className:O,"aria-hidden":"true"}),e[27]=O,e[28]=M):M=e[28];let R;e[29]!==u||e[30]!==t?(R=nd(t,u),e[29]=u,e[30]=t,e[31]=R):R=e[31];let z;e[32]!==R?(z=a.jsx("span",{className:"min-w-0 flex-1 truncate text-xs leading-tight text-foreground",children:R}),e[32]=R,e[33]=z):z=e[33];const W=x?"text-muted-foreground":s.className;let D;e[34]!==W?(D=G("shrink-0",W),e[34]=W,e[35]=D):D=e[35];const L=y?"Read-only":s.label;let U;e[36]!==D||e[37]!==L?(U=a.jsx(Ue,{variant:"outline",className:D,children:L}),e[36]=D,e[37]=L,e[38]=U):U=e[38];let F;e[39]!==x||e[40]!==t.lastActivityAt||e[41]!==t.lastModified?(F=!x&&a.jsx(Sfe,{iso:t.lastActivityAt||t.lastModified}),e[39]=x,e[40]=t.lastActivityAt,e[41]=t.lastModified,e[42]=F):F=e[42];let B;e[43]!==M||e[44]!==z||e[45]!==U||e[46]!==F?(B=a.jsxs("span",{className:"flex items-center gap-1.5",children:[M,z,U,F]}),e[43]=M,e[44]=z,e[45]=U,e[46]=F,e[47]=B):B=e[47];let V;e[48]!==d?(V=a.jsx("span",{className:"mt-1 block truncate pl-3 text-xs text-muted-foreground",children:d}),e[48]=d,e[49]=V):V=e[49];let H;e[50]!==I||e[51]!==B||e[52]!==V?(H=a.jsxs(Yt,{render:I,children:[B,V]}),e[50]=I,e[51]=B,e[52]=V,e[53]=H):H=e[53];let K;e[54]!==u||e[55]!==l||e[56]!==t||e[57]!==k?(K=a.jsx(Xt,{side:"right",className:"max-w-[280px]",children:a.jsx(O0,{session:t,proc:l,statusLabel:k,customName:u})}),e[54]=u,e[55]=l,e[56]=t,e[57]=k,e[58]=K):K=e[58];let Z;e[59]!==H||e[60]!==K?(Z=a.jsxs(Zt,{children:[H,K]}),e[59]=H,e[60]=K,e[61]=Z):Z=e[61];let Y;e[62]!==j||e[63]!==h?(Y=j&&a.jsxs(ee,{type:"button",variant:"outline",size:"xs",onClick:h,className:"absolute bottom-1 right-1 text-warning","aria-label":"Resume to evaluate",children:[a.jsx(Yi,{"data-icon":"inline-start"}),"Resume"]}),e[62]=j,e[63]=h,e[64]=Y):Y=e[64];let X;e[65]!==y||e[66]!==c||e[67]!==p||e[68]!==l?(X=l&&p&&!y&&a.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:Q=>p(l.pid,Q),disabled:c.has(l.pid),className:"absolute right-0 top-0 text-destructive opacity-0 group-focus-within:opacity-100 group-hover:opacity-100",title:`Kill PID ${l.pid}`,"aria-label":`Kill process ${l.pid}`,children:a.jsx(Ut,{"data-icon":"inline-start"})}),e[65]=y,e[66]=c,e[67]=p,e[68]=l,e[69]=X):X=e[69];let se;return e[70]!==Z||e[71]!==Y||e[72]!==X||e[73]!==E||e[74]!==T?(se=a.jsxs("div",{className:E,children:[T,Z,Y,X]}),e[70]=Z,e[71]=Y,e[72]=X,e[73]=E,e[74]=T,e[75]=se):se=e[75],se}function Cfe(n){const e=q.c(15),{dotClassName:t,labelClassName:s,label:r,count:o}=n;let i;e[0]!==t?(i=G("size-1.5 rounded-full",t),e[0]=t,e[1]=i):i=e[1];let l;e[2]!==i?(l=a.jsx("span",{className:i,"aria-hidden":"true"}),e[2]=i,e[3]=l):l=e[3];let c;e[4]!==s?(c=G("text-xs font-medium",s),e[4]=s,e[5]=c):c=e[5];let u;e[6]!==r||e[7]!==c?(u=a.jsx("span",{className:c,children:r}),e[6]=r,e[7]=c,e[8]=u):u=e[8];let d;e[9]!==o?(d=a.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:o}),e[9]=o,e[10]=d):d=e[10];let f;return e[11]!==l||e[12]!==u||e[13]!==d?(f=a.jsxs("div",{className:"flex items-center gap-1.5 px-0.5",children:[l,u,d]}),e[11]=l,e[12]=u,e[13]=d,e[14]=f):f=e[14],f}function _fe(n){const e=q.c(28),{groups:t,activeSessionKey:s,procBySession:r,killingPids:o,sessionNames:i,projectNames:l,onSelectSession:c,onKill:u,onResumeSession:d,onPrefetchSession:f}=n,m=zf(),[p,h]=w.useState(!1);let g;e[0]!==t.working||e[1]!==p?(g=p?t.working:t.working.slice(0,wfe),e[0]=t.working,e[1]=p,e[2]=g):g=e[2];const x=g,b=t.working.length-x.length;let y;e[3]!==l?(y=C=>l[C.dirName]||xx(C.cwd||ls(C.dirName)),e[3]=l,e[4]=y):y=e[4];const v=y;let k;e[5]!==s||e[6]!==o||e[7]!==u||e[8]!==f||e[9]!==c||e[10]!==m||e[11]!==r||e[12]!==v||e[13]!==i?(k=C=>{const E=s===`${C.dirName}/${C.fileName}`;return{session:C,isActiveSession:E,proc:r.get(C.sessionId),killingPids:o,customName:i[C.sessionId],projectLabel:v(C),onSelect:()=>c(C.dirName,C.fileName),onKill:m(C.access).stop?u:void 0,onPrefetch:f&&!E?()=>f(C.dirName,C.fileName):void 0}},e[5]=s,e[6]=o,e[7]=u,e[8]=f,e[9]=c,e[10]=m,e[11]=r,e[12]=v,e[13]=i,e[14]=k):k=e[14];const j=k;let _;e[15]!==t.needsYou||e[16]!==d||e[17]!==m||e[18]!==j?(_=t.needsYou.length>0&&a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsx(Cfe,{dotClassName:ro.attention,labelClassName:"text-warning",label:"Needs you",count:t.needsYou.length}),t.needsYou.map(C=>{const{session:E,reason:T}=C;return a.jsx(Ak,{...j(E),chip:jfe[T],dotClassName:Nfe[T],cardClassName:"border-warning/20 bg-warning/5 hover:bg-warning/10",onResume:T==="deferred"&&d&&m(E.access).send?()=>d(E.sessionId,E.cwd,E.dirName):void 0},`${E.dirName}/${E.fileName}`)})]}),e[15]=t.needsYou,e[16]=d,e[17]=m,e[18]=j,e[19]=_):_=e[19];let N;e[20]!==t.working.length||e[21]!==b||e[22]!==j||e[23]!==x?(N=t.working.length>0&&a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsxs("div",{className:"flex items-center justify-between px-1",children:[a.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Working"}),a.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:t.working.length})]}),a.jsx("div",{"data-working-list":!0,className:"flex flex-col gap-0.5 overflow-hidden rounded-lg border bg-background p-0.5",children:x.map(C=>a.jsx(Ak,{...j(C),chip:{label:gfe(C),className:""},dotClassName:ro.working,cardClassName:"hover:bg-accent/50",compact:!0},`${C.dirName}/${C.fileName}`))}),b>0&&a.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>h(!0),className:"justify-start",children:[a.jsx(Ot,{"data-icon":"inline-start"}),"Show ",b," more"]})]}),e[20]=t.working.length,e[21]=b,e[22]=j,e[23]=x,e[24]=N):N=e[24];let S;return e[25]!==_||e[26]!==N?(S=a.jsxs("div",{className:"flex flex-col gap-2","data-attention-strip":!0,children:[_,N]}),e[25]=_,e[26]=N,e[27]=S):S=e[27],S}function Efe(n){const e=q.c(44),{loading:t,isMobile:s,searchQuery:r,searchLoading:o,showArchived:i,archivedCount:l,onSearchQueryChange:c,onToggleShowArchived:u,onRefresh:d}=n,f=l===0?"No archived sessions":`${l} archived ${l===1?"session":"sessions"}`;let m;e[0]!==c?(m=M=>c(M.target.value),e[0]=c,e[1]=m):m=e[1];let p;e[2]!==o||e[3]!==r||e[4]!==m?(p=a.jsx(ko,{type:"search",value:r,onChange:m,placeholder:"Search sessions or PRs","aria-label":"Search sessions by project, branch, title, prompt, PR number, or PR URL","aria-busy":o}),e[2]=o,e[3]=r,e[4]=m,e[5]=p):p=e[5];let h;e[6]!==o?(h=a.jsx(or,{align:"inline-start",children:o?a.jsx(vt,{className:"animate-spin"}):a.jsx(Yn,{})}),e[6]=o,e[7]=h):h=e[7];let g;e[8]!==c||e[9]!==r?(g=r&&a.jsx(or,{align:"inline-end",children:a.jsx(Jd,{size:"icon-xs",onClick:()=>c(""),"aria-label":"Clear session search",children:a.jsx(Ut,{"data-icon":"inline-start"})})}),e[8]=c,e[9]=r,e[10]=g):g=e[10];let x;e[11]!==p||e[12]!==h||e[13]!==g?(x=a.jsxs(So,{children:[p,h,g]}),e[11]=p,e[12]=h,e[13]=g,e[14]=x):x=e[14];const b=s?"icon-sm":"icon-xs",y=i?"Hide archived sessions":"Show archived sessions",v=i&&"bg-accent text-accent-foreground";let k;e[15]!==v?(k=G(v),e[15]=v,e[16]=k):k=e[16];let j;e[17]!==u||e[18]!==i||e[19]!==b||e[20]!==y||e[21]!==k?(j=a.jsx(ee,{variant:"ghost",size:b,onClick:u,"aria-pressed":i,"aria-label":y,className:k}),e[17]=u,e[18]=i,e[19]=b,e[20]=y,e[21]=k,e[22]=j):j=e[22];let _;e[23]===Symbol.for("react.memo_cache_sentinel")?(_=a.jsx(gs,{"data-icon":"inline-start"}),e[23]=_):_=e[23];let N;e[24]!==j?(N=a.jsx(Yt,{render:j,children:_}),e[24]=j,e[25]=N):N=e[25];const S=i?"Hide archived":"Show archived";let C;e[26]!==f||e[27]!==S?(C=a.jsxs(Xt,{side:"bottom",children:[S," · ",f]}),e[26]=f,e[27]=S,e[28]=C):C=e[28];let E;e[29]!==N||e[30]!==C?(E=a.jsxs(Zt,{children:[N,C]}),e[29]=N,e[30]=C,e[31]=E):E=e[31];const T=s?"icon-sm":"icon-xs",A=t&&"animate-spin";let P;e[32]!==A?(P=G(A),e[32]=A,e[33]=P):P=e[33];let I;e[34]!==P?(I=a.jsx(On,{"data-icon":"inline-start",className:P}),e[34]=P,e[35]=I):I=e[35];let $;e[36]!==d||e[37]!==T||e[38]!==I?($=a.jsx(ee,{variant:"ghost",size:T,onClick:d,"aria-label":"Refresh sessions",children:I}),e[36]=d,e[37]=T,e[38]=I,e[39]=$):$=e[39];let O;return e[40]!==E||e[41]!==$||e[42]!==x?(O=a.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b px-2.5 py-2",children:[x,E,$]}),e[40]=E,e[41]=$,e[42]=x,e[43]=O):O=e[43],O}const Tfe=["first","second","third","fourth","fifth"];function Afe(n){const e=q.c(33),{fetchError:t,showEmpty:s,searching:r,loading:o,sessionCount:i,hiddenArchivedCount:l,focusedProject:c,onShowAllProjects:u,filterEmpty:d,onShowArchived:f,onRetry:m}=n,p=c===void 0?null:c,h=d===void 0?null:d,g=!!h;let x;e[0]!==p||e[1]!==l||e[2]!==r||e[3]!==s||e[4]!==g?(x=Ife({showEmpty:s,searching:r,focusedProject:p,hiddenArchivedCount:l,filtered:g}),e[0]=p,e[1]=l,e[2]=r,e[3]=s,e[4]=g,e[5]=x):x=e[5];const b=x;let y;e[6]!==t||e[7]!==m?(y=t&&a.jsxs(Jt,{variant:"destructive",children:[a.jsx(lr,{}),a.jsx(_n,{children:"Could not load sessions"}),a.jsx(Qt,{className:"truncate",children:t}),a.jsx(uo,{children:a.jsx(ee,{variant:"outline",size:"xs",onClick:m,children:"Retry"})})]}),e[6]=t,e[7]=m,e[8]=y):y=e[8];let v;e[9]!==b||e[10]!==l||e[11]!==f?(v=b==="archived"&&a.jsxs(kn,{className:"min-h-56 px-4 py-8",children:[a.jsxs(jn,{children:[a.jsx(Rn,{variant:"icon",children:a.jsx(gs,{})}),a.jsx(Nn,{children:"Everything is archived"}),a.jsx(Cn,{children:l===1?"1 archived session is hidden.":`${l} archived sessions are hidden.`})]}),a.jsxs(ee,{variant:"outline",size:"sm",onClick:f,children:[a.jsx(gs,{"data-icon":"inline-start"}),"Show archived"]})]}),e[9]=b,e[10]=l,e[11]=f,e[12]=v):v=e[12];let k;e[13]!==b||e[14]!==p||e[15]!==l||e[16]!==u||e[17]!==f||e[18]!==r?(k=b==="focused"&&a.jsxs(kn,{className:"min-h-56 px-4 py-8",children:[a.jsxs(jn,{children:[a.jsx(Rn,{variant:"icon",children:r?a.jsx(Yn,{}):a.jsx(jh,{})}),a.jsx(Nn,{children:r?`No matching sessions in ${p}`:`No sessions in ${p}`}),a.jsx(Cn,{children:$fe(r,l)})]}),a.jsxs("div",{className:"flex flex-wrap justify-center gap-2",children:[a.jsxs(ee,{variant:"outline",size:"sm",onClick:u,children:[a.jsx(qu,{"data-icon":"inline-start"}),"All projects"]}),!r&&l>0&&a.jsxs(ee,{variant:"ghost",size:"sm",onClick:f,children:[a.jsx(gs,{"data-icon":"inline-start"}),"Show archived"]})]})]}),e[13]=b,e[14]=p,e[15]=l,e[16]=u,e[17]=f,e[18]=r,e[19]=k):k=e[19];const j=b==="filtered"&&h;let _;e[20]!==b||e[21]!==r?(_=b==="plain"&&a.jsx(kn,{className:"min-h-56 px-4 py-8",children:a.jsxs(jn,{children:[a.jsx(Rn,{variant:"icon",children:r?a.jsx(Yn,{}):a.jsx(jh,{})}),a.jsx(Nn,{children:r?"No matching sessions":"No sessions yet"}),a.jsx(Cn,{children:r?"Try #157, honest-cms #157, or paste a PR URL.":"Start Claude Code, Codex, or Copilot to see recent work here."})]})}),e[20]=b,e[21]=r,e[22]=_):_=e[22];let N;e[23]!==o||e[24]!==i?(N=o&&i===0&&a.jsx("div",{className:"flex flex-col gap-2 px-2 py-4","aria-label":"Loading sessions",children:Tfe.map(Pfe)}),e[23]=o,e[24]=i,e[25]=N):N=e[25];let S;return e[26]!==N||e[27]!==y||e[28]!==v||e[29]!==k||e[30]!==j||e[31]!==_?(S=a.jsxs(a.Fragment,{children:[y,v,k,j,_,N]}),e[26]=N,e[27]=y,e[28]=v,e[29]=k,e[30]=j,e[31]=_,e[32]=S):S=e[32],S}function Pfe(n){return a.jsxs("div",{className:"flex items-center gap-2 py-1",children:[a.jsx(Wn,{className:"size-2 shrink-0 rounded-full"}),a.jsx(Wn,{className:"h-4 flex-1"}),a.jsx(Wn,{className:"h-4 w-10"})]},n)}function Ife({showEmpty:n,searching:e,focusedProject:t,hiddenArchivedCount:s,filtered:r}){return n?t!==null?"focused":!e&&s>0?"archived":!e&&r?"filtered":"plain":null}function $fe(n,e){return n?"Try another search, or look across every project.":e>0?"Its sessions may be archived. Start a new one, or look across every project.":"Start a new session here, or look across every project."}const mh=864e5;function Rfe(n){const e=new Date(n);return e.setHours(0,0,0,0),e.getTime()}function Ofe(n,e=Date.now()){const t=Date.parse(n);if(!Number.isFinite(t))return"Older";const s=Rfe(e);return t>=s?"Today":t>=s-mh?"Yesterday":t>=s-6*mh?"Last 7 days":t>=s-29*mh?"Last 30 days":"Older"}function c6(n,e,t=!1){const s=e!==void 0,r=n.isActive===!0,o=s||r,i=r&&bc(n.agentStatus),l=n.agentStatus==="deferred",c=R0(nn(n.dirName),e);return{hasProcess:s,isLive:o,isRunning:yx(n,e),isNativeIdle:i,isDeferred:l,isReadOnly:c,isTeammate:!!(n.teamName&&n.agentName),isArchived:n.archived===!0,statusLabel:Lfe(n,{isReadOnly:c,isLive:o,isNativeIdle:i}),dotState:Mfe(n,{isDeferred:l,isLive:o}),justFinished:!r&&s&&n.agentStatus==="completed"&&t}}function Lfe(n,{isReadOnly:e,isLive:t,isNativeIdle:s}){return e?"Read-only":t?s?"Running":cc(n.agentStatus,n.agentToolName,n.agentTerminalReason,n.agentPendingAgents)??"Running":null}function Mfe(n,{isDeferred:e,isLive:t}){return e?"attention":t?bc(n.agentStatus)?"idle":"working":null}function zfe(n){var rt,wt;const e=q.c(159),{session:t,projectLabel:s,projectPath:r,showProject:o,isActiveSession:i,proc:l,killingPids:c,isNewlyCompleted:u,customName:d,worktreeName:f,teammateCount:m,teammatesCollapsed:p,onToggleTeammates:h,onSelectSession:g,onKill:x,onDuplicateSession:b,onDeleteSession:y,onArchiveSession:v,onUnarchiveSession:k,onRenameSession:j,onPrefetchSession:_,onResumeSession:N}=n,{isLive:S,isRunning:C,isNativeIdle:E,isDeferred:T,isReadOnly:A,isTeammate:P,isArchived:I,statusLabel:$,dotState:O,justFinished:M}=c6(t,l,u),[R,z]=w.useState(!1);let W;e[0]!==d||e[1]!==t?(W=sC(t,d),e[0]=d,e[1]=t,e[2]=W):W=e[2];const D=W,L=VF(t,d),U=o?s:void 0,F=t.lastUserMessage||t.firstUserMessage,B=!!F&&F!==D,V=l6(t.sessionId,t.turnCount);let H;e[3]!==t.archivedReason?(H=vx(t.archivedReason),e[3]=t.archivedReason,e[4]=H):H=e[4];const K=H,Z=I?k&&{label:"Restore from archive",icon:zd,run:()=>k(t)}:v&&!C&&{label:"Archive session",icon:gs,run:()=>v(t)},Y=T&&!!N&&!A,X=!!m&&!!h,se=!!t.matchedPullRequestNumber||!!((rt=t.pullRequests)!=null&&rt.length),Q=Y||X||se;let te;e[5]!==i||e[6]!==_||e[7]!==t.dirName||e[8]!==t.fileName?(te=_&&!i?()=>_(t.dirName,t.fileName):void 0,e[5]=i,e[6]=_,e[7]=t.dirName,e[8]=t.fileName,e[9]=te):te=e[9];const{onHoverStart:J,onHoverEnd:ne}=L0(te);let re;e[10]!==N||e[11]!==R||e[12]!==t.cwd||e[13]!==t.dirName||e[14]!==t.sessionId?(re=()=>{!N||R||(z(!0),N(t.sessionId,t.cwd,t.dirName),setTimeout(()=>z(!1),3e3))},e[10]=N,e[11]=R,e[12]=t.cwd,e[13]=t.dirName,e[14]=t.sessionId,e[15]=re):re=e[15];const le=re,ae=!0,ue=I||void 0,oe=G("motion-list-item group relative flex flex-col rounded-lg border transition-colors",Dfe(i,M),I&&"opacity-60 hover:opacity-100 focus-within:opacity-100");let ie;e[16]!==g||e[17]!==t.dirName||e[18]!==t.fileName?(ie=()=>g(t.dirName,t.fileName),e[16]=g,e[17]=t.dirName,e[18]=t.fileName,e[19]=ie):ie=e[19];const fe=i?"true":void 0,de=Q?"pb-1.5":"pb-2.5";let ce;e[20]!==de?(ce=G("flex w-full flex-col gap-1.5 rounded-lg px-3 pt-2.5 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",de),e[20]=de,e[21]=ce):ce=e[21];let xe;e[22]!==ne||e[23]!==J||e[24]!==ce||e[25]!==ie||e[26]!==fe?(xe=a.jsx("button",{type:"button","data-live-session":!0,onClick:ie,onMouseEnter:J,onMouseLeave:ne,onFocus:J,onBlur:ne,"aria-current":fe,className:ce}),e[22]=ne,e[23]=J,e[24]=ce,e[25]=ie,e[26]=fe,e[27]=xe):xe=e[27];let pe;e[28]!==U||e[29]!==r?(pe=U&&a.jsxs("span",{"data-session-project":!0,className:"flex items-center gap-1.5 pl-3.5 text-[11px] leading-tight text-muted-foreground",children:[a.jsx(Hi,{projectPath:r,fallback:a.jsx(Ii,{className:"size-3 shrink-0","aria-hidden":"true"}),className:"size-3"}),a.jsx("span",{className:"truncate",children:U})]}),e[28]=U,e[29]=r,e[30]=pe):pe=e[30];let he;e[31]!==O?(he=O&&a.jsx("span",{"data-status-dot":O,className:G("size-1.5 rounded-full",ro[O])}),e[31]=O,e[32]=he):he=e[32];let ye;e[33]!==he?(ye=a.jsx("span",{className:"mt-[7px] flex w-1.5 shrink-0 justify-center","aria-hidden":"true",children:he}),e[33]=he,e[34]=ye):ye=e[34];const ve=L?"text-muted-foreground":"font-medium text-foreground";let ke;e[35]!==ve?(ke=G("line-clamp-2 flex-1 text-sm leading-snug",ve),e[35]=ve,e[36]=ke):ke=e[36];let je;e[37]!==D||e[38]!==ke?(je=a.jsx("span",{className:ke,children:D}),e[37]=D,e[38]=ke,e[39]=je):je=e[39];let Me;e[40]!==ye||e[41]!==je?(Me=a.jsxs("span",{className:"flex items-start gap-2",children:[ye,je]}),e[40]=ye,e[41]=je,e[42]=Me):Me=e[42];let _e;e[43]!==F||e[44]!==B?(_e=B&&a.jsx("span",{className:"line-clamp-2 pl-3.5 text-xs leading-relaxed text-muted-foreground",children:F}),e[43]=F,e[44]=B,e[45]=_e):_e=e[45];let Fe;e[46]!==T||e[47]!==S||e[48]!==E||e[49]!==t.agentStatus||e[50]!==$?(Fe=S&&!T&&$&&a.jsx(Ue,{variant:"secondary","data-session-live-state":!0,className:G(E?"text-success":Df(t.agentStatus)),children:$}),e[46]=T,e[47]=S,e[48]=E,e[49]=t.agentStatus,e[50]=$,e[51]=Fe):Fe=e[51];let ze;e[52]!==T?(ze=T&&a.jsx(Ue,{variant:"outline",className:"border-warning/30 bg-warning/10 text-warning",children:"deferred"}),e[52]=T,e[53]=ze):ze=e[53];let We;e[54]!==D||e[55]!==P||e[56]!==t.agentName?(We=P&&a.jsxs(Ue,{variant:"outline",children:[a.jsx($i,{"data-icon":"inline-start"}),D!==t.agentName?t.agentName:"Agent"]}),e[54]=D,e[55]=P,e[56]=t.agentName,e[57]=We):We=e[57];let Pe;e[58]!==t.access?(Pe=a.jsx(XT,{access:t.access}),e[58]=t.access,e[59]=Pe):Pe=e[59];let qe;e[60]!==f?(qe=f&&a.jsxs(Ue,{variant:"outline",children:[a.jsx(_r,{"data-icon":"inline-start"}),f]}),e[60]=f,e[61]=qe):qe=e[61];let be;e[62]!==t.gitBranch||e[63]!==f?(be=t.gitBranch&&!f&&a.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[a.jsx(_r,{className:"size-3 shrink-0","aria-hidden":"true"}),a.jsx("span",{className:"truncate",children:t.gitBranch})]}),e[62]=t.gitBranch,e[63]=f,e[64]=be):be=e[64];let Ie;e[65]!==V?(Ie=V>0&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(io,{className:"size-3 shrink-0","aria-hidden":"true"}),V," ",V===1?"turn":"turns"]}),e[65]=V,e[66]=Ie):Ie=e[66];let Se;e[67]!==K||e[68]!==I?(Se=I&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(gs,{className:"size-3 shrink-0","aria-label":K,role:"img"}),"Archived"]}),e[67]=K,e[68]=I,e[69]=Se):Se=e[69];const Ne=t.lastActivityAt||t.lastModified;let He;e[70]!==Ne?(He=Yo(Ne),e[70]=Ne,e[71]=He):He=e[71];let Ke;e[72]!==He?(Ke=a.jsx("span",{className:"ml-auto tabular-nums",children:He}),e[72]=He,e[73]=Ke):Ke=e[73];let Ce;e[74]!==Fe||e[75]!==ze||e[76]!==We||e[77]!==Pe||e[78]!==qe||e[79]!==be||e[80]!==Ie||e[81]!==Se||e[82]!==Ke?(Ce=a.jsxs("span",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 pl-3.5 text-[11px] text-muted-foreground",children:[Fe,ze,We,Pe,qe,be,Ie,Se,Ke]}),e[74]=Fe,e[75]=ze,e[76]=We,e[77]=Pe,e[78]=qe,e[79]=be,e[80]=Ie,e[81]=Se,e[82]=Ke,e[83]=Ce):Ce=e[83];let Be;e[84]!==xe||e[85]!==pe||e[86]!==Me||e[87]!==_e||e[88]!==Ce?(Be=a.jsxs(Yt,{render:xe,children:[pe,Me,_e,Ce]}),e[84]=xe,e[85]=pe,e[86]=Me,e[87]=_e,e[88]=Ce,e[89]=Be):Be=e[89];const Ye=U?void 0:s;let Xe;e[90]!==d||e[91]!==l||e[92]!==t||e[93]!==$||e[94]!==Ye||e[95]!==f?(Xe=a.jsx(Xt,{side:"right",className:"max-w-[320px]",children:a.jsx(O0,{session:t,proc:l,statusLabel:$,customName:d,worktreeName:f,projectLabel:Ye})}),e[90]=d,e[91]=l,e[92]=t,e[93]=$,e[94]=Ye,e[95]=f,e[96]=Xe):Xe=e[96];let nt;e[97]!==Be||e[98]!==Xe?(nt=a.jsxs(Zt,{children:[Be,Xe]}),e[97]=Be,e[98]=Xe,e[99]=nt):nt=e[99];let Qe;e[100]!==Y||e[101]!==le||e[102]!==Q||e[103]!==X||e[104]!==h||e[105]!==R||e[106]!==t.matchedPullRequestNumber||e[107]!==t.pullRequests||e[108]!==m||e[109]!==p?(Qe=Q&&a.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 px-3 pb-2.5 pl-[26px]",children:[t.matchedPullRequestNumber?a.jsxs(Ue,{variant:"outline",className:"px-1",children:["Matched #",t.matchedPullRequestNumber]}):a.jsx(dc,{pullRequests:t.pullRequests,max:2,compact:!0}),X&&a.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:h,"aria-expanded":!p,"aria-label":p?`Show ${m} team agents`:`Hide ${m} team agents`,children:[a.jsx(Bs,{"data-icon":"inline-start"}),m,a.jsx(ot,{"data-icon":"inline-end",className:G("transition-transform duration-150",!p&&"rotate-90")})]}),Y&&a.jsxs(ee,{type:"button",variant:"outline",size:"xs",onClick:le,disabled:R,className:"text-warning",title:"Resume to evaluate deferred permission","aria-label":"Resume to evaluate",children:[a.jsx(Yi,{"data-icon":"inline-start"}),"Resume"]})]}),e[100]=Y,e[101]=le,e[102]=Q,e[103]=X,e[104]=h,e[105]=R,e[106]=t.matchedPullRequestNumber,e[107]=t.pullRequests,e[108]=m,e[109]=p,e[110]=Qe):Qe=e[110];let Ee;e[111]!==Z?(Ee=Z&&a.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:Z.run,className:"absolute bottom-1.5 right-1.5 bg-popover text-muted-foreground opacity-0 group-focus-within:opacity-100 group-hover:opacity-100 hover:text-foreground",title:Z.label,"aria-label":Z.label,children:a.jsx(Z.icon,{"data-icon":"inline-start"})}),e[111]=Z,e[112]=Ee):Ee=e[112];let me;e[113]!==I||e[114]!==A||e[115]!==C||e[116]!==c||e[117]!==x||e[118]!==l?(me=l&&x&&C&&!I&&!A&&a.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:Ct=>x(l.pid,Ct),disabled:c.has(l.pid),className:"absolute bottom-1.5 right-1.5 bg-popover text-destructive opacity-0 group-focus-within:opacity-100 group-hover:opacity-100",title:`Kill PID ${l.pid}`,"aria-label":`Kill process ${l.pid}`,children:a.jsx(Ut,{"data-icon":"inline-start"})}),e[113]=I,e[114]=A,e[115]=C,e[116]=c,e[117]=x,e[118]=l,e[119]=me):me=e[119];let Oe;e[120]!==nt||e[121]!==Qe||e[122]!==Ee||e[123]!==me||e[124]!==ue||e[125]!==oe?(Oe=a.jsxs("div",{"data-session-card":ae,"data-archived":ue,className:oe,children:[nt,Qe,Ee,me]}),e[120]=nt,e[121]=Qe,e[122]=Ee,e[123]=me,e[124]=ue,e[125]=oe,e[126]=Oe):Oe=e[126];const Ge=Oe;if(b||y||j||v||k){let Ct;e[127]!==t.firstUserMessage||e[128]!==t.sessionId||e[129]!==t.slug?(Ct=t.slug||((wt=t.firstUserMessage)==null?void 0:wt.slice(0,30))||t.sessionId.slice(0,12),e[127]=t.firstUserMessage,e[128]=t.sessionId,e[129]=t.slug,e[130]=Ct):Ct=e[130];let Pn;e[131]!==b||e[132]!==t.dirName||e[133]!==t.fileName?(Pn=b?()=>b(t.dirName,t.fileName):void 0,e[131]=b,e[132]=t.dirName,e[133]=t.fileName,e[134]=Pn):Pn=e[134];let ts;e[135]!==y||e[136]!==t?(ts=y?()=>y(t):void 0,e[135]=y,e[136]=t,e[137]=ts):ts=e[137];let ns;e[138]!==j||e[139]!==t.sessionId?(ns=j?vc=>j(t.sessionId,vc):void 0,e[138]=j,e[139]=t.sessionId,e[140]=ns):ns=e[140];let Bt;e[141]!==I||e[142]!==v||e[143]!==t?(Bt=v&&!I?()=>v(t):void 0,e[141]=I,e[142]=v,e[143]=t,e[144]=Bt):Bt=e[144];let xr;e[145]!==I||e[146]!==k||e[147]!==t?(xr=k&&I?()=>k(t):void 0,e[145]=I,e[146]=k,e[147]=t,e[148]=xr):xr=e[148];let Vn;return e[149]!==Ge||e[150]!==d||e[151]!==C||e[152]!==Ct||e[153]!==Pn||e[154]!==ts||e[155]!==ns||e[156]!==Bt||e[157]!==xr?(Vn=a.jsx(I0,{sessionLabel:Ct,customName:d,onDuplicate:Pn,onDelete:ts,onRename:ns,onArchive:Bt,onUnarchive:xr,archiveDisabled:C,children:Ge}),e[149]=Ge,e[150]=d,e[151]=C,e[152]=Ct,e[153]=Pn,e[154]=ts,e[155]=ns,e[156]=Bt,e[157]=xr,e[158]=Vn):Vn=e[158],Vn}return Ge}function Dfe(n,e){return n?"border-foreground/15 bg-accent":e?"border-success/30 bg-success/10":"border-border/70 bg-card hover:border-border hover:bg-accent"}function Ffe(n){var de;const e=q.c(87),{session:t,isActiveSession:s,proc:r,killingPids:o,isNewlyCompleted:i,customName:l,worktreeName:c,teammateCount:u,teammatesCollapsed:d,onToggleTeammates:f,onSelectSession:m,onKill:p,onDuplicateSession:h,onDeleteSession:g,onArchiveSession:x,onUnarchiveSession:b,onRenameSession:y,onPrefetchSession:v,onResumeSession:k}=n,{isLive:j,isRunning:_,isNativeIdle:N,isDeferred:S,isReadOnly:C,isTeammate:E,isArchived:T,statusLabel:A,dotState:P,justFinished:I}=c6(t,r,i),[$,O]=w.useState(!1);let M;e[0]!==t.archivedReason?(M=vx(t.archivedReason),e[0]=t.archivedReason,e[1]=M):M=e[1];const R=M;let z;e[2]!==l||e[3]!==t?(z=nd(t,l),e[2]=l,e[3]=t,e[4]=z):z=e[4];const W=z,D=T?b&&{label:"Restore from archive",icon:zd,run:()=>b(t)}:x&&!_&&{label:"Archive session",icon:gs,run:()=>x(t)};let L;e[5]!==s||e[6]!==v||e[7]!==t.dirName||e[8]!==t.fileName?(L=v&&!s?()=>v(t.dirName,t.fileName):void 0,e[5]=s,e[6]=v,e[7]=t.dirName,e[8]=t.fileName,e[9]=L):L=e[9];const{onHoverStart:U,onHoverEnd:F}=L0(L);let B;e[10]!==k||e[11]!==$||e[12]!==t.cwd||e[13]!==t.dirName||e[14]!==t.sessionId?(B=ce=>{ce.stopPropagation(),!(!k||$)&&(O(!0),k(t.sessionId,t.cwd,t.dirName),setTimeout(()=>O(!1),3e3))},e[10]=k,e[11]=$,e[12]=t.cwd,e[13]=t.dirName,e[14]=t.sessionId,e[15]=B):B=e[15];const V=B,H=G("motion-list-item group relative flex min-h-9 w-full items-center gap-1.5 rounded-md px-2.5 py-2 transition-colors",Ufe(s,I),T&&"opacity-60 hover:opacity-100 focus-within:opacity-100");let K;e[16]!==m||e[17]!==t.dirName||e[18]!==t.fileName?(K=()=>m(t.dirName,t.fileName),e[16]=m,e[17]=t.dirName,e[18]=t.fileName,e[19]=K):K=e[19];let Z;e[20]!==F||e[21]!==U||e[22]!==K?(Z=a.jsx("button",{type:"button","data-live-session":!0,onClick:K,onMouseEnter:U,onMouseLeave:F,onFocus:U,onBlur:F,className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-sm text-left outline-none focus-visible:ring-2 focus-visible:ring-ring"}),e[20]=F,e[21]=U,e[22]=K,e[23]=Z):Z=e[23];let Y;e[24]!==W?(Y=a.jsx("span",{className:"flex-1 truncate text-sm leading-tight text-foreground",children:W}),e[24]=W,e[25]=Y):Y=e[25];let X;e[26]!==S?(X=S&&a.jsx(Ue,{variant:"outline",className:"border-warning/30 bg-warning/10 text-warning",children:"deferred"}),e[26]=S,e[27]=X):X=e[27];let se;e[28]!==c?(se=c&&a.jsxs(Ue,{variant:"outline",children:[a.jsx(_r,{"data-icon":"inline-start"}),c]}),e[28]=c,e[29]=se):se=e[29];let Q;e[30]!==l||e[31]!==r||e[32]!==t||e[33]!==A||e[34]!==c?(Q=a.jsx(Xt,{side:"right",className:"max-w-[280px]",children:a.jsx(O0,{session:t,proc:r,statusLabel:A,customName:l,worktreeName:c})}),e[30]=l,e[31]=r,e[32]=t,e[33]=A,e[34]=c,e[35]=Q):Q=e[35];let te;e[36]!==f||e[37]!==u||e[38]!==d?(te=!!u&&f&&a.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:f,className:"shrink-0",title:d?"Show team agents":"Hide team agents","aria-label":d?`Show ${u} team agents`:`Hide ${u} team agents`,"aria-expanded":!d,children:[a.jsx(Bs,{"data-icon":"inline-start"}),u,a.jsx(ot,{"data-icon":"inline-end",className:G("transition-transform duration-150",!d&&"rotate-90")})]}),e[36]=f,e[37]=u,e[38]=d,e[39]=te):te=e[39];let J;e[40]!==V||e[41]!==S||e[42]!==C||e[43]!==k||e[44]!==$?(J=S&&k&&!C&&a.jsxs(ee,{type:"button",variant:"outline",size:"xs",onClick:V,disabled:$,className:"shrink-0 text-warning",title:"Resume to evaluate deferred permission","aria-label":"Resume to evaluate",children:[a.jsx(Yi,{"data-icon":"inline-start"}),"Resume"]}),e[40]=V,e[41]=S,e[42]=C,e[43]=k,e[44]=$,e[45]=J):J=e[45];let ne;e[46]!==t.matchedPullRequestNumber||e[47]!==t.pullRequests?(ne=t.matchedPullRequestNumber?a.jsxs(Ue,{variant:"outline",className:"shrink-0 px-1",children:["Matched #",t.matchedPullRequestNumber]}):a.jsx(dc,{pullRequests:t.pullRequests,max:1,compact:!0}),e[46]=t.matchedPullRequestNumber,e[47]=t.pullRequests,e[48]=ne):ne=e[48];let re;e[49]!==R||e[50]!==T?(re=T&&a.jsx(gs,{className:"size-3 shrink-0 text-muted-foreground","aria-label":R,role:"img"}),e[49]=R,e[50]=T,e[51]=re):re=e[51];const le=t.lastActivityAt||t.lastModified;let ae;e[52]!==le?(ae=Yo(le),e[52]=le,e[53]=ae):ae=e[53];let ue;e[54]!==ae?(ue=a.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:ae}),e[54]=ae,e[55]=ue):ue=e[55];let oe;e[56]!==D?(oe=D&&a.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:ce=>{ce.stopPropagation(),D.run()},className:"absolute right-0 top-0 bg-popover text-muted-foreground opacity-0 group-focus-within:opacity-100 group-hover:opacity-100 hover:text-foreground",title:D.label,"aria-label":D.label,children:a.jsx(D.icon,{"data-icon":"inline-start"})}),e[56]=D,e[57]=oe):oe=e[57];let ie;e[58]!==T||e[59]!==C||e[60]!==_||e[61]!==o||e[62]!==p||e[63]!==r?(ie=r&&p&&_&&!T&&!C&&a.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:ce=>p(r.pid,ce),disabled:o.has(r.pid),className:"absolute right-0 top-0 text-destructive opacity-0 group-focus-within:opacity-100 group-hover:opacity-100",title:`Kill PID ${r.pid}`,"aria-label":`Kill process ${r.pid}`,children:a.jsx(Ut,{"data-icon":"inline-start"})}),e[58]=T,e[59]=C,e[60]=_,e[61]=o,e[62]=p,e[63]=r,e[64]=ie):ie=e[64];const fe=a.jsxs("div",{className:H,"data-archived":T||void 0,children:[a.jsxs(Zt,{children:[a.jsxs(Yt,{render:Z,children:[a.jsx("span",{className:"flex w-1.5 shrink-0 items-center justify-center","aria-hidden":"true",children:P&&a.jsx("span",{"data-status-dot":P,className:G("size-1.5 rounded-full",ro[P])})}),Y,E&&a.jsxs(Ue,{variant:"outline",children:[a.jsx($i,{"data-icon":"inline-start"}),W!==t.agentName?t.agentName:"Agent"]}),j&&!S&&A&&a.jsx(Ue,{variant:"secondary","data-session-live-state":!0,className:G("shrink-0",N&&"text-success",!N&&Df(t.agentStatus)),children:A}),X,se]}),Q]}),te,J,ne,re,ue,oe,ie]});if(h||g||y||x||b){let ce;e[65]!==t.firstUserMessage||e[66]!==t.sessionId||e[67]!==t.slug?(ce=t.slug||((de=t.firstUserMessage)==null?void 0:de.slice(0,30))||t.sessionId.slice(0,12),e[65]=t.firstUserMessage,e[66]=t.sessionId,e[67]=t.slug,e[68]=ce):ce=e[68];let xe;e[69]!==h||e[70]!==t.dirName||e[71]!==t.fileName?(xe=h?()=>h(t.dirName,t.fileName):void 0,e[69]=h,e[70]=t.dirName,e[71]=t.fileName,e[72]=xe):xe=e[72];let pe;e[73]!==g||e[74]!==t?(pe=g?()=>g(t):void 0,e[73]=g,e[74]=t,e[75]=pe):pe=e[75];let he;e[76]!==y||e[77]!==t.sessionId?(he=y?ke=>y(t.sessionId,ke):void 0,e[76]=y,e[77]=t.sessionId,e[78]=he):he=e[78];let ye;e[79]!==T||e[80]!==x||e[81]!==t?(ye=x&&!T?()=>x(t):void 0,e[79]=T,e[80]=x,e[81]=t,e[82]=ye):ye=e[82];let ve;return e[83]!==T||e[84]!==b||e[85]!==t?(ve=b&&T?()=>b(t):void 0,e[83]=T,e[84]=b,e[85]=t,e[86]=ve):ve=e[86],a.jsx(I0,{sessionLabel:ce,customName:l,onDuplicate:xe,onDelete:pe,onRename:he,onArchive:ye,onUnarchive:ve,archiveDisabled:_,children:fe})}return fe}function Ufe(n,e){return n?"bg-accent":e?"bg-success/10":"hover:bg-accent/60"}function Bfe(n){const e=q.c(51),{sessions:t,pendingSession:s,older:r,showProject:o,activeSessionKey:i,procBySession:l,killingPids:c,newlyCompleted:u,sessionNames:d,projectNames:f,onSelectSession:m,onKill:p,onDuplicateSession:h,onDeleteSession:g,onArchiveSession:x,onUnarchiveSession:b,onRenameSession:y,onPrefetchSession:v,onResumeSession:k}=n,j=zf();let _,N,S;if(e[0]!==t){_=HF(t),S=oc(_.topLevelSessions);const B=Date.now(),V=S.map(H=>Ofe(H.lastActivityAt||H.lastModified,B));N=V.map((H,K)=>H===V[K-1]?null:H),e[0]=t,e[1]=_,e[2]=N,e[3]=S}else _=e[1],N=e[2],S=e[3];const C=N;let E;e[4]!==C||e[5]!==_.teammatesByLead||e[6]!==S?(E={topLevelSessions:S,teammatesByLead:_.teammatesByLead,shelves:C},e[4]=C,e[5]=_.teammatesByLead,e[6]=S,e[7]=E):E=e[7];const{topLevelSessions:T,teammatesByLead:A,shelves:P}=E;let I;e[8]===Symbol.for("react.memo_cache_sentinel")?(I=new Set,e[8]=I):I=e[8];const[$,O]=w.useState(I);let M;e[9]===Symbol.for("react.memo_cache_sentinel")?(M=B=>{O(V=>{const H=new Set(V);return H.has(B)?H.delete(B):H.add(B),H})},e[9]=M):M=e[9];const R=M;let z;e[10]!==i||e[11]!==c||e[12]!==u||e[13]!==x||e[14]!==g||e[15]!==h||e[16]!==p||e[17]!==v||e[18]!==y||e[19]!==k||e[20]!==m||e[21]!==b||e[22]!==j||e[23]!==l||e[24]!==d?(z=B=>{const V=j(B.access);return{session:B,isActiveSession:i===ph(B),proc:l.get(B.sessionId),killingPids:c,isNewlyCompleted:u.has(B.sessionId),customName:d[B.sessionId],onSelectSession:m,onKill:V.stop?p:void 0,onDuplicateSession:h,onDeleteSession:V.delete?g:void 0,onArchiveSession:V.archive?x:void 0,onUnarchiveSession:V.archive?b:void 0,onRenameSession:y,onPrefetchSession:v,onResumeSession:V.send?k:void 0}},e[10]=i,e[11]=c,e[12]=u,e[13]=x,e[14]=g,e[15]=h,e[16]=p,e[17]=v,e[18]=y,e[19]=k,e[20]=m,e[21]=b,e[22]=j,e[23]=l,e[24]=d,e[25]=z):z=e[25];const W=z;let D;e[26]!==s?(D=s&&a.jsx(qfe,{firstMessage:s.firstMessage}),e[26]=s,e[27]=D):D=e[27];let L;if(e[28]!==$||e[29]!==f||e[30]!==W||e[31]!==P||e[32]!==o||e[33]!==A||e[34]!==T){let B;e[36]!==$||e[37]!==f||e[38]!==W||e[39]!==P||e[40]!==o||e[41]!==A?(B=(V,H)=>{const K=ph(V),Z=V.cwd??ls(V.dirName),Y=nr(Z),X=f[V.dirName]??bx(V),se=A.get(V.sessionId),Q=$.has(V.sessionId),te=P[H],J=a.jsx(zfe,{...W(V),worktreeName:Y==null?void 0:Y.worktreeName,projectLabel:X,projectPath:(Y==null?void 0:Y.parentPath)??Z,showProject:o,teammateCount:se==null?void 0:se.length,teammatesCollapsed:se?Q:void 0,onToggleTeammates:se?()=>R(V.sessionId):void 0});return a.jsxs(w.Fragment,{children:[te&&a.jsx(Wfe,{label:te}),se&&!Q?a.jsxs("div",{className:"flex flex-col gap-px",children:[J,a.jsx("div",{className:"ml-3 flex flex-col gap-px border-l pl-1",children:se.map(ne=>a.jsx(Ffe,{...W(ne)},ph(ne)))})]}):J]},K)},e[36]=$,e[37]=f,e[38]=W,e[39]=P,e[40]=o,e[41]=A,e[42]=B):B=e[42],L=T.map(B),e[28]=$,e[29]=f,e[30]=W,e[31]=P,e[32]=o,e[33]=A,e[34]=T,e[35]=L}else L=e[35];let U;e[43]!==r.canLoad||e[44]!==r.load||e[45]!==r.loading?(U=r.canLoad&&a.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:r.load,disabled:r.loading,className:"justify-start text-muted-foreground",children:[r.loading?a.jsx(vt,{"data-icon":"inline-start",className:"animate-spin"}):a.jsx(k3,{"data-icon":"inline-start"}),"Load older sessions"]}),e[43]=r.canLoad,e[44]=r.load,e[45]=r.loading,e[46]=U):U=e[46];let F;return e[47]!==D||e[48]!==L||e[49]!==U?(F=a.jsxs("div",{className:"flex flex-col gap-1.5","data-session-card-list":!0,children:[D,L,U]}),e[47]=D,e[48]=L,e[49]=U,e[50]=F):F=e[50],F}function Wfe(n){const e=q.c(2),{label:t}=n;let s;return e[0]!==t?(s=a.jsx("div",{"data-recency-divider":!0,className:"px-1 pb-0.5 pt-2 text-[11px] font-medium text-muted-foreground/80 first:pt-0",children:t}),e[0]=t,e[1]=s):s=e[1],s}function qfe(n){const e=q.c(3),{firstMessage:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(vt,{className:"size-3 shrink-0 animate-spin text-info"}),e[0]=s):s=e[0];const r=t||"New session";let o;return e[1]!==r?(o=a.jsxs("div",{className:"motion-enter relative flex w-full items-center gap-1.5 rounded-lg border border-border/70 bg-accent px-3 py-2.5 text-left",children:[s,a.jsx("span",{className:"flex-1 truncate text-sm leading-tight text-foreground",children:r})]}),e[1]=r,e[2]=o):o=e[2],o}function ph(n){return`${n.dirName}/${n.fileName}`}function wi(n,e){return`${n} ${n===1?e:`${e}s`}`}function Vfe(n){if(!n)return"No sessions listed";const e=wi(n.total,"session"),t=n.live>0?`${e}, ${n.live} live`:e;return n.worktrees>0?`${t} · ${wi(n.worktrees,"worktree")}`:t}function Pk(n){const e=q.c(7),{count:t,label:s,className:r}=n;let o;e[0]!==r?(o=G("flex shrink-0 items-center gap-1 font-medium text-warning",r),e[0]=r,e[1]=o):o=e[1];let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsx("span",{className:"size-1.5 rounded-full bg-warning","aria-hidden":"true"}),e[2]=i):i=e[2];let l;return e[3]!==t||e[4]!==s||e[5]!==o?(l=a.jsxs("span",{className:o,"aria-label":s,children:[i,t]}),e[3]=t,e[4]=s,e[5]=o,e[6]=l):l=e[6],l}function Hfe(n,e){return e===null?0:n.reduce((t,s)=>s.key===e?t:t+s.needsYou,0)}function Kfe(n){const e=q.c(71),{options:t,value:s,focused:r,totalSessions:o,onChange:i,onNewSession:l,creatingSession:c,onRenameProject:u,archivableCount:d,onArchiveIdle:f}=n,[m,p]=w.useState(!1),h=(r==null?void 0:r.customName)??s;let g;e[0]!==r||e[1]!==t.length||e[2]!==o||e[3]!==s?(g=s===null?`${wi(t.length,"project")}, ${wi(o,"session")}`:Vfe(r),e[0]=r,e[1]=t.length,e[2]=o,e[3]=s,e[4]=g):g=e[4];const x=g,b=Hfe(t,s);let y;e[5]!==i?(y=Y=>{i(Y),p(!1)},e[5]=i,e[6]=y):y=e[6];const v=y,k=s===null?"Choose a project to focus on":`Focused on ${h}. Change project`;let j;e[7]!==(r==null?void 0:r.cwd)||e[8]!==s?(j=s===null?a.jsx(qu,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}):a.jsx(Hi,{projectPath:(r==null?void 0:r.cwd)??null,fallback:a.jsx(Ii,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),className:"size-5"}),e[7]=r==null?void 0:r.cwd,e[8]=s,e[9]=j):j=e[9];const _=s===null?"All projects":h;let N;e[10]!==_?(N=a.jsx("span",{className:"truncate text-sm font-medium leading-tight text-foreground",children:_}),e[10]=_,e[11]=N):N=e[11];let S;e[12]!==x?(S=a.jsx("span",{className:"truncate text-[11px] leading-tight text-muted-foreground",children:x}),e[12]=x,e[13]=S):S=e[13];let C;e[14]!==N||e[15]!==S?(C=a.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[N,S]}),e[14]=N,e[15]=S,e[16]=C):C=e[16];let E;e[17]!==b?(E=b>0&&a.jsx(Pk,{count:b,label:b===1?"1 session in another project is waiting for you":`${b} sessions in other projects are waiting for you`,className:"rounded-full border border-warning/30 bg-warning/10 px-1.5 py-0.5 text-[11px]"}),e[17]=b,e[18]=E):E=e[18];let T;e[19]===Symbol.for("react.memo_cache_sentinel")?(T=a.jsx(Ji,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),e[19]=T):T=e[19];let A;e[20]!==k||e[21]!==j||e[22]!==C||e[23]!==E?(A=a.jsxs(Wl,{"aria-label":k,className:"flex h-11 min-w-0 flex-1 items-center gap-2.5 rounded-lg px-2 text-left outline-none transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring data-popup-open:bg-accent",children:[j,C,E,T]}),e[20]=k,e[21]=j,e[22]=C,e[23]=E,e[24]=A):A=e[24];const P=A;let I;e[25]!==d||e[26]!==r||e[27]!==f||e[28]!==u||e[29]!==P?(I=r&&u?a.jsx(n6,{projectLabel:r.key,customName:r.customName,className:"flex min-w-0 flex-1",archivableCount:d,onArchiveIdle:f,onRename:Y=>u(r.dirName,Y),children:P}):P,e[25]=d,e[26]=r,e[27]=f,e[28]=u,e[29]=P,e[30]=I):I=e[30];let $;e[31]===Symbol.for("react.memo_cache_sentinel")?($=a.jsx(R1,{placeholder:"Find a project",autoFocus:!0}),e[31]=$):$=e[31];let O;e[32]===Symbol.for("react.memo_cache_sentinel")?(O=a.jsx(L8,{children:"No project matches."}),e[32]=O):O=e[32];const M=s===null;let R;e[33]!==v?(R=()=>v(null),e[33]=v,e[34]=R):R=e[34];let z,W;e[35]===Symbol.for("react.memo_cache_sentinel")?(z=a.jsx(qu,{className:"text-muted-foreground","aria-hidden":"true"}),W=a.jsx("span",{className:"flex-1 truncate",children:"All projects"}),e[35]=z,e[36]=W):(z=e[35],W=e[36]);let D;e[37]!==o?(D=a.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:o}),e[37]=o,e[38]=D):D=e[38];let L;e[39]!==M||e[40]!==R||e[41]!==D?(L=a.jsx(Uo,{children:a.jsxs(no,{value:"all-projects","data-checked":M,onSelect:R,className:"gap-2.5",children:[z,W,D]})}),e[39]=M,e[40]=R,e[41]=D,e[42]=L):L=e[42];let U;if(e[43]!==t||e[44]!==v||e[45]!==s){let Y;e[47]!==v||e[48]!==s?(Y=X=>a.jsxs(no,{value:X.key,keywords:X.customName?[X.customName]:void 0,"data-checked":s===X.key,onSelect:()=>v(X.key),className:"gap-2.5",children:[a.jsx(Hi,{projectPath:X.cwd??null,fallback:a.jsx(Ii,{className:"text-muted-foreground","aria-hidden":"true"}),className:"size-4"}),a.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[a.jsx("span",{className:"truncate",children:X.customName??X.key}),X.customName&&a.jsx("span",{className:"truncate text-[11px] text-muted-foreground",children:X.key})]}),X.needsYou>0&&a.jsx(Pk,{count:X.needsYou,label:`${wi(X.needsYou,"session")} waiting for you`,className:"text-xs"}),X.live>0&&a.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs font-medium text-success","aria-label":wi(X.live,"live session"),children:[a.jsx(Gd,{className:"size-1.5","aria-hidden":"true"}),X.live]}),a.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:X.total})]},X.key),e[47]=v,e[48]=s,e[49]=Y):Y=e[49],U=t.map(Y),e[43]=t,e[44]=v,e[45]=s,e[46]=U}else U=e[46];let F;e[50]!==U?(F=a.jsx(Uo,{heading:"Projects",children:U}),e[50]=U,e[51]=F):F=e[51];let B;e[52]!==L||e[53]!==F?(B=a.jsx(k1,{className:"w-(--anchor-width) min-w-72 p-0",children:a.jsxs(Gl,{children:[$,a.jsxs(Zl,{children:[O,L,F]})]})}),e[52]=L,e[53]=F,e[54]=B):B=e[54];let V;e[55]!==m||e[56]!==I||e[57]!==B?(V=a.jsxs(Bl,{open:m,onOpenChange:p,children:[I,B]}),e[55]=m,e[56]=I,e[57]=B,e[58]=V):V=e[58];let H;e[59]!==c||e[60]!==r||e[61]!==h||e[62]!==l?(H=r&&l&&a.jsx(ee,{type:"button",variant:"outline",size:"icon-sm",className:"shrink-0",disabled:c,onClick:()=>l(r.dirName,r.cwd),"aria-label":`New session in ${h}`,children:c?a.jsx(vt,{"data-icon":"inline-start",className:"animate-spin"}):a.jsx(tr,{"data-icon":"inline-start"})}),e[59]=c,e[60]=r,e[61]=h,e[62]=l,e[63]=H):H=e[63];let K;e[64]!==c||e[65]!==l?(K=l&&a.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",className:"shrink-0",disabled:c,onClick:Gfe,"aria-label":"Start a session in a folder",title:"Start a session in a folder",children:a.jsx(Ml,{"data-icon":"inline-start"})}),e[64]=c,e[65]=l,e[66]=K):K=e[66];let Z;return e[67]!==V||e[68]!==H||e[69]!==K?(Z=a.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b px-2 py-1.5",children:[V,H,K]}),e[67]=V,e[68]=H,e[69]=K,e[70]=Z):Z=e[70],Z}function Gfe(){return g5()}function Zfe(n,e){return n.reduce((t,s)=>s.isActive?t+1:e.has(s.sessionId)?s.agentStatus==="completed"?t:t+1:t,0)}function Yfe(n){const e=nr(n.cwd??ls(n.dirName));if(!e)return{dirName:n.dirName,cwd:n.cwd};const{parentPath:t}=e;return{dirName:Ss(n.dirName).dirName.encode(t),cwd:t}}function Xfe(n){const e=n.map(t=>{var s;return(s=nr(t.cwd??ls(t.dirName)))==null?void 0:s.worktreeName});return new Set(e.filter(Boolean)).size}function Jfe(n,e,t,s){return[...YF(n).entries()].map(([r,o])=>{const i=KF(o),l=Yfe(i);return{key:r,customName:t[l.dirName],...l,dirNames:[...new Set(o.map(c=>c.dirName))],total:o.length,live:Zfe(o,e),needsYou:o.filter(c=>s.has(c.sessionId)).length,worktrees:Xfe(o)}})}function Ik(n,e){return e===null?n:n.filter(t=>bx(t)===e)}function Qfe(n,e){if(e.length===0)return n;const t=new Set(n.map(r=>r.sessionId)),s=e.filter(r=>!t.has(r.sessionId));return s.length===0?n:oc([...n,...s])}const $k={key:null,sessions:[],loading:!1,loaded:!1};function eme(n,e){const t=n.dirNames?n.dirNames.map(s=>new URLSearchParams({project:s,limit:"200"})):[new URLSearchParams({limit:"200",perProject:"100"})];if(e)for(const s of t)s.set("archived","include");return t}function tme(n,e,t){const s=q.c(14),r=n?`${e?"a":"l"}:${t.key??""}:${n.key}`:null,[o,i]=w.useState($k),l=o.key===r?o:$k;let c;s[0]!==t||s[1]!==e||s[2]!==r||s[3]!==n?(c=async()=>{if(r===null||!n)return;i(g=>g.key===r?{...g,loading:!0}:{key:r,sessions:[],loading:!0,loaded:!1});const h=Pr();try{const x=(await Promise.all(eme(n,e).map(async b=>{const y=await Re(ff(b,t));if(!y.ok)throw new Error(`Could not load older sessions (${y.status})`);const v=await y.json();return Array.isArray(v)?v:[]}))).flat();Mi(x,h),i(b=>b.key===r?{key:r,sessions:x,loading:!1,loaded:!0}:b)}catch(g){const x=g;i(b=>b.key===r?{...b,loading:!1}:b),Bn.error(x instanceof Error?x.message:"Could not load older sessions")}},s[0]=t,s[1]=e,s[2]=r,s[3]=n,s[4]=c):c=s[4];const u=c,{loaded:d}=l;let f,m;s[5]!==u||s[6]!==d?(f=()=>{if(d)return mf(()=>void u())},m=[d,u],s[5]=u,s[6]=d,s[7]=f,s[8]=m):(f=s[7],m=s[8]),w.useEffect(f,m);let p;return s[9]!==l.loading||s[10]!==l.sessions||s[11]!==u||s[12]!==d?(p={sessions:l.sessions,loading:l.loading,loaded:d,load:u},s[9]=l.loading,s[10]=l.sessions,s[11]=u,s[12]=d,s[13]=p):p=s[13],p}const nme={key:"all"},sme=w.memo(function({activeSessionKey:e,onSelectSession:t,onDuplicateSession:s,onDeleteSession:r,onNewSession:o,creatingSession:i,pendingSession:l,refreshRef:c,onPrefetchSession:u}){const{names:d,rename:f}=KT(),{names:m,rename:p}=P0(),h=F1(),g=mn("terminal"),x=mn("killAny"),b=zf(),y=df(),{Control:v,Empty:k}=ur().sessionListFilter??{},{sessions:j,procBySession:_,newlyCompleted:N,loading:S,error:C,refresh:E,removeSession:T,acknowledgeCompleted:A,showArchived:P,setShowArchived:I,setSearchActive:$,archivedCount:O}=kx(),{awaitingPermission:M,awaitingQuestion:R,awaitingElicitation:z,awaitingDialog:W,awaitingPlan:D}=ffe(),L=w.useMemo(()=>new Set([...z,...W]),[z,W]),[U,F]=w.useState(new Set),[B,V]=w.useState(""),[H,K]=oa(gn("live-sessions-project-scope"),null),Z=!!B.trim(),Y=P||Z;w.useEffect(()=>($(Z),()=>$(!1)),[Z,$]);const X=w.useRef(new Set),se=w.useRef(!1),Q=w.useCallback((be,Ie)=>{if(!se.current)return;const Se=setTimeout(()=>{X.current.delete(Se),se.current&&be()},Ie);X.current.add(Se)},[]);w.useEffect(()=>{const be=X.current;return se.current=!0,()=>{se.current=!1;for(const Ie of be)clearTimeout(Ie);be.clear()}},[]),w.useEffect(()=>{if(c)return c.current=E,()=>{c.current===E&&(c.current=null)}},[E,c]);const te=$0(),J=s6(B,y),ne=w.useMemo(()=>ZF(j,Y),[j,Y]),re=Y?0:O,le=w.useMemo(()=>hfe(ne,_,N,M,R,L,D,be=>b(be.access).canInteract),[ne,_,N,M,R,L,D,b]),ae=w.useMemo(()=>new Set(le.needsYou.map(be=>be.session.sessionId)),[le]),ue=w.useMemo(()=>Jfe(ne,_,m,ae),[ne,_,m,ae]),oe=H===null?null:ue.find(be=>be.key===H)??null,ie=(oe==null?void 0:oe.customName)??H,fe=tme(H===null?nme:oe,Y,y),de=w.useMemo(()=>Qfe(Ik(ne,H),fe.sessions),[ne,H,fe.sessions]),ce=w.useMemo(()=>Z?de.filter(be=>{const Ie=d[be.sessionId],Se=m[be.dirName];return QT(be,B,[Ie,Se])}):de,[de,Z,B,d,m]),xe=w.useMemo(()=>J.results?Ik(J.results,H):ce,[J.results,H,ce]),pe=le.needsYou.length>0||le.working.length>0,he=!Z&&pe&&H===null,ye=w.useMemo(()=>H===null?[]:de.filter(be=>!be.archived&&b(be.access).archive&&!yx(be,_.get(be.sessionId))),[H,de,_,b]),ve=H===null||l!=null&&xx(l.cwd||ls(l.dirName))===H,ke=w.useRef(!1);w.useEffect(()=>{if(ke.current||!u||j.length===0)return;ke.current=!0;const be=oc(j).slice(0,3),Ie=globalThis,Se=()=>{for(const Ke of be)u(Ke.dirName,Ke.fileName)};let Ne=null,He=null;return typeof Ie.requestIdleCallback=="function"?Ne=Ie.requestIdleCallback(Se,{timeout:1500}):He=setTimeout(Se,300),()=>{Ne!=null&&typeof Ie.cancelIdleCallback=="function"&&Ie.cancelIdleCallback(Ne),He!=null&&clearTimeout(He)}},[j,u]);const je=w.useCallback(async(be,Ie)=>{Ie.stopPropagation(),F(Se=>new Set(Se).add(be));try{if(!(await Re("/api/kill-process",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pid:be})})).ok)throw new Error("Could not stop session");Q(E,1500)}catch{Bn.error("Could not stop session")}Q(()=>{F(Se=>{const Ne=new Set(Se);return Ne.delete(be),Ne})},2e3)},[E,Q]);w.useEffect(()=>{const be=j.find(Ie=>`${Ie.dirName}/${Ie.fileName}`===e);be&&N.has(be.sessionId)&&A(be.sessionId)},[e,j,N,A]);const Me=w.useCallback(async be=>{await(r==null?void 0:r(be.dirName,be.fileName))&&T(be.sessionId)},[r,T]),_e=C5(),Fe=w.useCallback(be=>{_e([be.sessionId],!0,`Archived “${nd(be,d[be.sessionId])}”`)},[_e,d]),ze=w.useCallback(be=>{_e([be.sessionId],!1,`Restored “${nd(be,d[be.sessionId])}”`)},[_e,d]),We=w.useCallback(be=>{if(be.length===0)return;const Ie=be.map(Se=>Se.sessionId);_e(Ie,!0,`Archived ${Ie.length} ${Ie.length===1?"session":"sessions"}`)},[_e]),Pe=w.useCallback((be,Ie,Se)=>{const{command:Ne,args:He}=w$(nn(Se),be),Ke=`resume_${crypto.randomUUID().slice(0,8)}`;h.send({type:"spawn",id:Ke,name:`Resume ${be.slice(0,8)}`,command:Ne,args:He,cwd:Ie??void 0,metadata:{type:"terminal"}}),Q(E,3e3)},[h,E,Q]),qe={activeSessionKey:e,procBySession:_,killingPids:U,newlyCompleted:N,sessionNames:d,projectNames:m,onSelectSession:t,onKill:x?je:void 0,onDuplicateSession:s,onDeleteSession:r?Me:void 0,onArchiveSession:Fe,onUnarchiveSession:ze,onRenameSession:f,onPrefetchSession:u,onResumeSession:g?Pe:void 0};return a.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[a.jsx(Efe,{loading:S,isMobile:te,searchQuery:B,searchLoading:J.loading,showArchived:P,archivedCount:O,onSearchQueryChange:V,onToggleShowArchived:()=>I(!P),onRefresh:()=>{mfe(),E()}}),v&&a.jsx(v,{}),a.jsx(Kfe,{options:ue,value:H,focused:oe,totalSessions:ne.length,onChange:K,onNewSession:o,creatingSession:i,onRenameProject:p,archivableCount:ye.length,onArchiveIdle:()=>We(ye)}),a.jsx(Jl,{className:"flex-1",children:a.jsxs("div",{className:"flex flex-col gap-4 p-2",children:[a.jsx(Afe,{fetchError:J.error??C,showEmpty:xe.length===0&&!(l&&ve)&&!S&&!J.loading&&!C&&!J.error,searching:Z,loading:S||J.loading,sessionCount:J.active?xe.length:ne.length,hiddenArchivedCount:re,focusedProject:ie,onShowAllProjects:()=>K(null),filterEmpty:y.key!==null&&k?a.jsx(k,{className:"min-h-56 px-4 py-8"}):null,onShowArchived:()=>I(!0),onRetry:J.error?J.refresh:E}),he&&a.jsx(_fe,{groups:le,activeSessionKey:e,procBySession:_,killingPids:U,sessionNames:d,projectNames:m,onSelectSession:t,onKill:x?je:void 0,onResumeSession:g?Pe:void 0,onPrefetchSession:u}),a.jsx(Bfe,{...qe,sessions:xe,pendingSession:ve?l:null,showProject:H===null,older:{canLoad:(H===null||!!oe)&&!fe.loaded&&!Z,loading:fe.loading,load:fe.load}})]})})]})}),rme=w.memo(function(e){const t=q.c(16),{activeSessionKey:s,onSelectSession:r,onNewSession:o,creatingSession:i,isMobile:l,onDuplicateSession:c,onDeleteSession:u,pendingSession:d,liveSessionsRefreshRef:f,onPrefetchSession:m,header:p}=e,h=l?"w-full":"w-80";let g;t[0]!==h?(g=G("flex h-full shrink-0 flex-col bg-sidebar",h),t[0]=h,t[1]=g):g=t[1];let x;t[2]!==s||t[3]!==i||t[4]!==f||t[5]!==u||t[6]!==c||t[7]!==o||t[8]!==m||t[9]!==r||t[10]!==d?(x=a.jsx(sme,{activeSessionKey:s,onSelectSession:r,onDuplicateSession:c,onDeleteSession:u,onNewSession:o,creatingSession:i,pendingSession:d,refreshRef:f,onPrefetchSession:m}),t[2]=s,t[3]=i,t[4]=f,t[5]=u,t[6]=c,t[7]=o,t[8]=m,t[9]=r,t[10]=d,t[11]=x):x=t[11];let b;return t[12]!==p||t[13]!==g||t[14]!==x?(b=a.jsxs("aside",{className:g,"aria-label":"Session browser",children:[p,x]}),t[12]=p,t[13]=g,t[14]=x,t[15]=b):b=t[15],b}),ome=w.lazy(()=>et(()=>import("./index-C4W7tiDS.js"),__vite__mapDeps([34,1,2,3,4])).then(n=>({default:n.MissionControl})));function Uf(n){const e=q.c(3),{label:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(An,{className:"size-4"}),e[0]=s):s=e[0];let r;return e[1]!==t?(r=a.jsxs("div",{className:"motion-enter flex min-h-0 flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",role:"status",children:[s,t]}),e[1]=t,e[2]=r):r=e[2],r}function u6(n){const e=q.c(12),{navigation:t,mobile:s,header:r}=n,o=s===void 0?!1:s,{sessionSource:i}=xt(),l=i?`${i.dirName}/${i.fileName}`:null;let c;return e[0]!==l||e[1]!==r||e[2]!==o||e[3]!==t.actions.handleDashboardSelect||e[4]!==t.creatingSession||e[5]!==t.handlers.handleDeleteSession||e[6]!==t.handlers.handleDuplicateSessionByPath||e[7]!==t.liveSessionsRefreshRef||e[8]!==t.onPrefetchSession||e[9]!==t.onStartNewSession||e[10]!==t.pendingSession?(c=a.jsx(rme,{activeSessionKey:l,onSelectSession:t.actions.handleDashboardSelect,onNewSession:t.onStartNewSession,creatingSession:t.creatingSession,pendingSession:t.pendingSession,onDuplicateSession:t.handlers.handleDuplicateSessionByPath,onDeleteSession:t.handlers.handleDeleteSession,liveSessionsRefreshRef:t.liveSessionsRefreshRef,onPrefetchSession:t.onPrefetchSession,isMobile:o,header:r}),e[0]=l,e[1]=r,e[2]=o,e[3]=t.actions.handleDashboardSelect,e[4]=t.creatingSession,e[5]=t.handlers.handleDeleteSession,e[6]=t.handlers.handleDuplicateSessionByPath,e[7]=t.liveSessionsRefreshRef,e[8]=t.onPrefetchSession,e[9]=t.onStartNewSession,e[10]=t.pendingSession,e[11]=c):c=e[11],c}function d6(n){const e=q.c(8),{navigation:t}=n,{state:s}=bn();let r;return e[0]!==t.actions.handleDashboardSelect||e[1]!==t.creatingSession||e[2]!==t.handlers.handleDeleteSession||e[3]!==t.handlers.handleDuplicateSessionByPath||e[4]!==t.onSelectProject||e[5]!==t.onStartNewSession||e[6]!==s.dashboardProject?(r=a.jsx(ife,{onSelectSession:t.actions.handleDashboardSelect,onNewSession:t.onStartNewSession,creatingSession:t.creatingSession,selectedProjectDirName:s.dashboardProject,onSelectProject:t.onSelectProject,onDuplicateSession:t.handlers.handleDuplicateSessionByPath,onDeleteSession:t.handlers.handleDeleteSession}),e[0]=t.actions.handleDashboardSelect,e[1]=t.creatingSession,e[2]=t.handlers.handleDeleteSession,e[3]=t.handlers.handleDuplicateSessionByPath,e[4]=t.onSelectProject,e[5]=t.onStartNewSession,e[6]=s.dashboardProject,e[7]=r):r=e[7],r}function f6(n){const e=q.c(3),{navigation:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(Uf,{label:"Loading Mission Control…"}),e[0]=s):s=e[0];let r;return e[1]!==t.actions.handleDashboardSelect?(r=a.jsx(w.Suspense,{fallback:s,children:a.jsx("div",{className:"motion-session-enter flex min-h-0 flex-1 flex-col",children:a.jsx(ome,{onSelectSession:t.actions.handleDashboardSelect})})}),e[1]=t.actions.handleDashboardSelect,e[2]=r):r=e[2],r}function m6(n){const e=q.c(8),{view:t,onClose:s}=n,{Component:r}=t,o=`Loading ${t.label}…`;let i;e[0]!==o?(i=a.jsx(Uf,{label:o}),e[0]=o,e[1]=i):i=e[1];let l;e[2]!==r||e[3]!==s?(l=a.jsx("div",{className:"motion-session-enter flex min-h-0 flex-1 flex-col",children:a.jsx(r,{onClose:s})}),e[2]=r,e[3]=s,e[4]=l):l=e[4];let c;return e[5]!==i||e[6]!==l?(c=a.jsx(w.Suspense,{fallback:i,children:l}),e[5]=i,e[6]=l,e[7]=c):c=e[7],c}function ime({mainView:n,hasSession:e,pendingDirName:t,extensionViewAvailable:s}){return n==="config"?"config":n==="mission"?"mission":n==="extension"&&s?"extension":e?"session":t?"pending":"dashboard"}function ame({sessionCwd:n,pendingPath:e,sessionDirPath:t,dashboardProjectPath:s}){return n??e??t??s??null}function p6({path:n,text:e,startLine:t,endLine:s,comment:r}){if(!e)return`@${n}`;const o=e.includes("```")?"````":"```",i=t===s?`line ${t}`:`lines ${t}-${s}`;return`${r?`Review request: ${r}
|
|
445
|
+
`:""}${n} (${i})
|
|
446
|
+
${o}
|
|
447
|
+
${e}
|
|
448
|
+
${o}`}const lme=w.lazy(()=>et(()=>import("./ConfigBrowser-DOdqaQra.js"),__vite__mapDeps([35,1,2,31,3,4])).then(n=>({default:n.ConfigBrowser}))),cme=w.lazy(()=>et(()=>import("./PreviewPanel-DChL85Uq.js"),__vite__mapDeps([36,1,2,3,4])).then(n=>({default:n.PreviewPanel}))),ume=w.lazy(()=>et(()=>import("./PluginsDialog-qcJTbfeg.js"),__vite__mapDeps([37,1,2,3,4])).then(n=>({default:n.PluginsDialog})));function dme(n){const e=q.c(20),{sessionView:t,floatingChrome:s}=n,{session:r}=xt();if(!r)return null;let o;e[0]!==t.teamMembersBar?(o=t.teamMembersBar&&a.jsx("div",{className:"pt-10",children:t.teamMembersBar}),e[0]=t.teamMembersBar,e[1]=o):o=e[1];const i=!!t.todoProgress&&t.todosExpanded;let l;e[2]!==t.hasMoreTurns||e[3]!==t.isLoadingOlderTurns||e[4]!==t.onLoadMoreTurns||e[5]!==t.searchInputRef||e[6]!==i?(l=a.jsx(yf,{searchInputRef:t.searchInputRef,hasTodos:i,hasMore:t.hasMoreTurns,isLoadingOlder:t.isLoadingOlderTurns,onLoadMore:t.onLoadMoreTurns}),e[2]=t.hasMoreTurns,e[3]=t.isLoadingOlderTurns,e[4]=t.onLoadMoreTurns,e[5]=t.searchInputRef,e[6]=i,e[7]=l):l=e[7];let c;e[8]!==t.onTodosExpandedChange||e[9]!==t.todoProgress||e[10]!==t.todosExpanded?(c=t.todoProgress&&a.jsx(BN,{progress:t.todoProgress,expanded:t.todosExpanded,onExpandedChange:t.onTodosExpandedChange}),e[8]=t.onTodosExpandedChange,e[9]=t.todoProgress,e[10]=t.todosExpanded,e[11]=c):c=e[11];let u;e[12]!==t.activeComposer||e[13]!==c?(u=a.jsxs(Mf,{floating:!0,children:[c,t.activeComposer]}),e[12]=t.activeComposer,e[13]=c,e[14]=u):u=e[14];let d;return e[15]!==s||e[16]!==o||e[17]!==l||e[18]!==u?(d=a.jsx("div",{className:"flex min-h-0 flex-1",children:a.jsxs("div",{className:"relative flex h-full min-h-0 flex-1 flex-col",children:[s,o,l,u]})}),e[15]=s,e[16]=o,e[17]=l,e[18]=u,e[19]=d):d=e[19],d}function fme(n){const e=q.c(41),{navigation:t,sessionView:s,project:r,view:o,extensionView:i,floatingChrome:l}=n,{state:c,config:u}=bn(),{session:d,sessionSource:f}=xt();let m,p;if(e[0]!==(d==null?void 0:d.cwd)||e[1]!==f||e[2]!==c.configFilePath||e[3]!==c.dashboardProject||e[4]!==c.pendingCwd||e[5]!==c.pendingDirName||e[6]!==o){p=Symbol.for("react.early_return_sentinel");e:if(m=c.pendingCwd??(c.pendingDirName?ls(c.pendingDirName):null),o==="config"){let g;e[9]===Symbol.for("react.memo_cache_sentinel")?(g=a.jsx(Uf,{label:"Loading configuration…"}),e[9]=g):g=e[9];const x=a.jsx(lme,{projectPath:ame({sessionCwd:d==null?void 0:d.cwd,pendingPath:m,sessionDirPath:f!=null&&f.dirName?ls(f.dirName):null,dashboardProjectPath:c.dashboardProject?ls(c.dashboardProject):null}),initialFilePath:c.configFilePath});let b;e[10]!==x?(b=a.jsx(w.Suspense,{fallback:g,children:a.jsx("div",{className:"motion-session-enter flex min-h-0 flex-1 pt-10",children:x})}),e[10]=x,e[11]=b):b=e[11],p=b;break e}e[0]=d==null?void 0:d.cwd,e[1]=f,e[2]=c.configFilePath,e[3]=c.dashboardProject,e[4]=c.pendingCwd,e[5]=c.pendingDirName,e[6]=o,e[7]=m,e[8]=p}else m=e[7],p=e[8];if(p!==Symbol.for("react.early_return_sentinel"))return p;if(o==="mission"){let g;return e[12]!==t?(g=a.jsx("div",{className:"flex min-h-0 flex-1 flex-col pt-10",children:a.jsx(f6,{navigation:t})}),e[12]=t,e[13]=g):g=e[13],g}if(o==="extension"&&i){let g;return e[14]!==i||e[15]!==t.panels.closeMainView?(g=a.jsx("div",{className:"flex min-h-0 flex-1 flex-col pt-10",children:a.jsx(m6,{view:i,onClose:t.panels.closeMainView})}),e[14]=i,e[15]=t.panels.closeMainView,e[16]=g):g=e[16],g}if(o==="session"){let g;return e[17]!==l||e[18]!==s?(g=a.jsx(dme,{sessionView:s,floatingChrome:l}),e[17]=l,e[18]=s,e[19]=g):g=e[19],g}if(o==="pending"){const g=s.pendingTurns.length>0,x=yo()?"Only on the machine running this session":void 0;let b;e[20]===Symbol.for("react.memo_cache_sentinel")?(b=X1()?void 0:x,e[20]=b):b=e[20];const y=b,v=!g&&"justify-center gap-4";let k;e[21]!==v?(k=G("flex min-h-0 min-w-0 flex-1 flex-col",v),e[21]=v,e[22]=k):k=e[22];let j;e[23]!==u||e[24]!==g||e[25]!==t||e[26]!==m||e[27]!==s.pendingTurns?(j=g?a.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-6 pt-14",children:a.jsx("div",{className:"mx-auto w-full max-w-[var(--chat-width)]",children:s.pendingTurns})}):a.jsx(VT,{projectPath:m,switcher:{onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:u.defaultAgentKind}}),e[23]=u,e[24]=g,e[25]=t,e[26]=m,e[27]=s.pendingTurns,e[28]=j):j=e[28];let _;e[29]!==s.pendingComposer?(_=a.jsx(Mf,{children:s.pendingComposer}),e[29]=s.pendingComposer,e[30]=_):_=e[30];let N;e[31]!==g||e[32]!==r?(N=!g&&a.jsxs("div",{className:"flex items-center justify-center gap-2",children:[pt("terminal")&&a.jsx(Tu,{reason:x,children:a.jsxs(ee,{variant:"outline",size:"xs",disabled:!!x,onClick:r.onOpenTerminal,children:[a.jsx(Xi,{"data-icon":"inline-start"}),"Terminal"]})}),pt("hostFiles")&&a.jsxs(a.Fragment,{children:[a.jsx(Tu,{reason:y,children:a.jsxs(ee,{variant:"outline",size:"xs",disabled:!!y,onClick:()=>a4(r.pendingProject),children:[a.jsx(i1,{"data-icon":"inline-start"}),"Open in editor"]})}),a.jsx(Tu,{reason:x,children:a.jsxs(ee,{variant:"outline",size:"xs",disabled:!!x,onClick:()=>l4(r.pendingProject),children:[a.jsx(Ml,{"data-icon":"inline-start"}),"Reveal in files"]})})]})]}),e[31]=g,e[32]=r,e[33]=N):N=e[33];let S;return e[34]!==k||e[35]!==j||e[36]!==_||e[37]!==N?(S=a.jsxs("div",{className:k,children:[j,_,N]}),e[34]=k,e[35]=j,e[36]=_,e[37]=N,e[38]=S):S=e[38],S}let h;return e[39]!==t?(h=a.jsx(d6,{navigation:t}),e[39]=t,e[40]=h):h=e[40],h}function mme(n){const e=q.c(117),{navigation:t,sessionView:s,project:r,chrome:o}=n,{state:i,config:l}=bn(),{session:c,sessionSource:u}=xt(),[d,f]=w.useState(pme),[m,p]=w.useState();let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=ke=>{p(ke),f(!0)},e[0]=h):h=e[0];const g=h;let x;e[1]===Symbol.for("react.memo_cache_sentinel")?(x=pt("configWrite"),e[1]=x):x=e[1];const b=Q_(x),y=r.currentCwd??null;let v;e[2]!==b||e[3]!==y?(v={...b,projectPath:y,openSettings:g},e[2]=b,e[3]=y,e[4]=v):v=e[4];const k=MT(v),j=D3(i.mainView==="extension"?i.extensionViewId:null);let _;e[5]!==s.chatInputRef?(_=function(je){var _e,Fe,ze;const Me=((_e=s.chatInputRef.current)==null?void 0:_e.getText().trimEnd())??"";(Fe=s.chatInputRef.current)==null||Fe.setText(Me?`${Me}
|
|
449
|
+
|
|
450
|
+
${je}
|
|
451
|
+
`:`${je}
|
|
452
|
+
`),(ze=s.chatInputRef.current)==null||ze.focus()},e[5]=s.chatInputRef,e[6]=_):_=e[6];const N=_;let S;e[7]!==N?(S=function(je){const{path:Me,text:_e,startLine:Fe,endLine:ze,comment:We}=je;N(p6({path:Me,text:_e,startLine:Fe,endLine:ze,comment:We}))},e[7]=N,e[8]=S):S=e[8];const C=S,E=i.mainView,T=!!c,A=j!==null;let P;e[9]!==i.mainView||e[10]!==i.pendingDirName||e[11]!==T||e[12]!==A?(P=ime({mainView:E,hasSession:T,pendingDirName:i.pendingDirName,extensionViewAvailable:A}),e[9]=i.mainView,e[10]=i.pendingDirName,e[11]=T,e[12]=A,e[13]=P):P=e[13];const I=P,$=t.panels.handleToggleSidebar,O=t.actions.handleGoHome,M=o.onOpenCommandPalette;let R,z;e[14]===Symbol.for("react.memo_cache_sentinel")?(R=Eu("toggleSidebar"),z=Eu("commandPalette"),e[14]=R,e[15]=z):(R=e[14],z=e[15]);let W;e[16]!==o.onOpenCommandPalette||e[17]!==t.actions.handleGoHome||e[18]!==t.panels.handleToggleSidebar?(W=a.jsx(SG,{onToggleSidebar:$,onGoHome:O,onOpenCommandPalette:M,sidebarShortcut:R,commandPaletteShortcut:z}),e[16]=o.onOpenCommandPalette,e[17]=t.actions.handleGoHome,e[18]=t.panels.handleToggleSidebar,e[19]=W):W=e[19];const D=W,L=t.panels.showSidebar&&i.mainView!=="config";let U,F,B;e[20]!==N||e[21]!==t.handlers.handleLoadSessionScrollAware||e[22]!==t.panels.activeWorkspacePanel||e[23]!==r.currentCwd||e[24]!==r.hasFileChanges||e[25]!==r.supportsWorktrees||e[26]!==c||e[27]!==u||e[28]!==i.mainView||e[29]!==i.sessionChangeKey||e[30]!==k?(U={session:c,sessionAddress:u?{dirName:u.dirName,fileName:u.fileName}:null,sessionChangeKey:i.sessionChangeKey,projectPath:r.currentCwd??null,hasFileChanges:r.hasFileChanges,canAccessHostFiles:pt("hostFiles"),canUseBrowser:pt("browser"),supportsWorktrees:r.supportsWorktrees,openSession:t.handlers.handleLoadSessionScrollAware,composePrompt:N},B=Ux(k,U),F=i.mainView==="sessions"?v5(t.panels.activeWorkspacePanel,B):null,e[20]=N,e[21]=t.handlers.handleLoadSessionScrollAware,e[22]=t.panels.activeWorkspacePanel,e[23]=r.currentCwd,e[24]=r.hasFileChanges,e[25]=r.supportsWorktrees,e[26]=c,e[27]=u,e[28]=i.mainView,e[29]=i.sessionChangeKey,e[30]=k,e[31]=U,e[32]=F,e[33]=B):(U=e[31],F=e[32],B=e[33]);const V=F,H=(u==null?void 0:u.dirName)??i.pendingDirName??i.dashboardProject??null;let K;e[34]!==t.panels||e[35]!==r?(K=function(je){r.showPreview&&r.onCloseRightWorkspace(),t.panels.toggleWorkspacePanel(je)},e[34]=t.panels,e[35]=r,e[36]=K):K=e[36];const Z=K;let Y;e[37]!==t.actions||e[38]!==t.panels?(Y=function(je){t.actions.handleDashboardSelect(je.dirName,`${je.sessionId}.jsonl`),t.panels.closeWorkspacePanel()},e[37]=t.actions,e[38]=t.panels,e[39]=Y):Y=e[39];const X=Y,se=t.panels.showSidebar;let Q;e[40]===Symbol.for("react.memo_cache_sentinel")?(Q=Eu("toggleSidebar"),e[40]=Q):Q=e[40];let te;e[41]!==o.killing||e[42]!==o.onKillAll||e[43]!==o.onLogout||e[44]!==l.openConfigDialog||e[45]!==t.creatingSession||e[46]!==t.handlers.handleDuplicateSession||e[47]!==t.onStartNewSession||e[48]!==t.panels.handleToggleSidebar||e[49]!==t.panels.openMainView||e[50]!==t.panels.showSidebar||e[51]!==r.onOpenTerminal||e[52]!==s.onBackToMain||e[53]!==s.onShowWorkflows||e[54]!==s.workflowCount||e[55]!==L?(te=a.jsx(yG,{showSidebar:se,sidebarRendered:L,sidebarShortcut:Q,killing:o.killing,creatingSession:t.creatingSession,onNewSession:t.onStartNewSession,onDuplicateSession:t.handlers.handleDuplicateSession,onOpenTerminal:r.onOpenTerminal,onBackToMain:s.onBackToMain,onShowWorkflows:s.onShowWorkflows,workflowCount:s.workflowCount,onToggleSidebar:t.panels.handleToggleSidebar,onKillAll:o.onKillAll,onOpenSettings:l.openConfigDialog,onLogout:o.onLogout,onOpenMainView:t.panels.openMainView}),e[41]=o.killing,e[42]=o.onKillAll,e[43]=o.onLogout,e[44]=l.openConfigDialog,e[45]=t.creatingSession,e[46]=t.handlers.handleDuplicateSession,e[47]=t.onStartNewSession,e[48]=t.panels.handleToggleSidebar,e[49]=t.panels.openMainView,e[50]=t.panels.showSidebar,e[51]=r.onOpenTerminal,e[52]=s.onBackToMain,e[53]=s.onShowWorkflows,e[54]=s.workflowCount,e[55]=L,e[56]=te):te=e[56];const J=te;let ne;e[57]!==t||e[58]!==D||e[59]!==L?(ne=L&&a.jsx("div",{className:"view-transition-sidebar panel-enter w-80 shrink-0 border-r bg-sidebar text-sidebar-foreground",children:a.jsx(u6,{navigation:t,header:D})}),e[57]=t,e[58]=D,e[59]=L,e[60]=ne):ne=e[60];const re=V??null,le=r.projectFilesRoot??r.currentCwd??null;let ae;e[61]!==C||e[62]!==t.actions.handleJumpToTurn||e[63]!==t.handlers.handleLoadSessionScrollAware||e[64]!==X||e[65]!==r.backgroundAgents||e[66]!==r.processPanel.handleServersChanged||e[67]!==r.processPanel.handleToggleServer||e[68]!==r.projectFilesRequest||e[69]!==r.worktrees||e[70]!==s.searchInputRef||e[71]!==le||e[72]!==H?(ae={projectFilesRoot:le,projectFilesRequest:r.projectFilesRequest,backgroundAgents:r.backgroundAgents,searchInputRef:s.searchInputRef,addProjectContext:C,jumpToTurn:t.actions.handleJumpToTurn,toggleServer:r.processPanel.handleToggleServer,serversChanged:r.processPanel.handleServersChanged,loadSession:t.handlers.handleLoadSessionScrollAware,worktrees:r.worktrees,worktreeDirName:H,openWorktreeSession:X},e[61]=C,e[62]=t.actions.handleJumpToTurn,e[63]=t.handlers.handleLoadSessionScrollAware,e[64]=X,e[65]=r.backgroundAgents,e[66]=r.processPanel.handleServersChanged,e[67]=r.processPanel.handleToggleServer,e[68]=r.projectFilesRequest,e[69]=r.worktrees,e[70]=s.searchInputRef,e[71]=le,e[72]=H,e[73]=ae):ae=e[73];const ue=i.mainView==="mission";let oe;e[74]!==t.panels.handleToggleMission||e[75]!==ue?(oe={id:"mission-control",title:"Mission Control",icon:I3,active:ue,onSelect:t.panels.handleToggleMission},e[74]=t.panels.handleToggleMission,e[75]=ue,e[76]=oe):oe=e[76];let ie;e[77]!==t.panels.handleToggleConfig||e[78]!==d||e[79]!==i.mainView?(ie=pt("configWrite")?[{id:"plugins",title:"Plugins",icon:l1,active:d,onSelect:()=>f(!0)},{id:"config",title:"Config",icon:$3,active:i.mainView==="config",onSelect:t.panels.handleToggleConfig}]:[],e[77]=t.panels.handleToggleConfig,e[78]=d,e[79]=i.mainView,e[80]=ie):ie=e[80];let fe;e[81]!==oe||e[82]!==ie?(fe=[oe,...ie],e[81]=oe,e[82]=ie,e[83]=fe):fe=e[83];const de=I!=="session"&&J;let ce;e[84]!==j||e[85]!==J||e[86]!==t||e[87]!==r||e[88]!==s||e[89]!==I?(ce=a.jsx(fme,{navigation:t,sessionView:s,project:r,view:I,extensionView:j,floatingChrome:J}),e[84]=j,e[85]=J,e[86]=t,e[87]=r,e[88]=s,e[89]=I,e[90]=ce):ce=e[90];let xe;e[91]!==de||e[92]!==ce?(xe=a.jsxs("main",{className:"app-view-transition relative flex size-full min-w-0 flex-col overflow-hidden",children:[de,ce]}),e[91]=de,e[92]=ce,e[93]=xe):xe=e[93];let pe;e[94]!==t.panels.closeWorkspacePanel||e[95]!==U||e[96]!==re||e[97]!==ae||e[98]!==fe||e[99]!==xe||e[100]!==Z||e[101]!==B?(pe=a.jsx(EG,{panels:B,context:U,activePanel:re,services:ae,onClosePanel:t.panels.closeWorkspacePanel,onTogglePanel:Z,actions:fe,children:xe}),e[94]=t.panels.closeWorkspacePanel,e[95]=U,e[96]=re,e[97]=ae,e[98]=fe,e[99]=xe,e[100]=Z,e[101]=B,e[102]=pe):pe=e[102];let he;e[103]!==r.currentCwd||e[104]!==r.onCloseRightWorkspace||e[105]!==r.showPreview?(he=r.showPreview&&r.currentCwd&&a.jsx(w.Suspense,{fallback:null,children:a.jsx(cme,{cwd:r.currentCwd,onClose:r.onCloseRightWorkspace})}),e[103]=r.currentCwd,e[104]=r.onCloseRightWorkspace,e[105]=r.showPreview,e[106]=he):he=e[106];let ye;e[107]!==m||e[108]!==d||e[109]!==r.currentCwd||e[110]!==b?(ye=d&&pt("configWrite")&&a.jsx(w.Suspense,{fallback:null,children:a.jsx(ume,{client:b.client,state:b,currentPath:r.currentCwd??null,initialPluginId:m,onClose:()=>{f(!1),p(void 0)}})}),e[107]=m,e[108]=d,e[109]=r.currentCwd,e[110]=b,e[111]=ye):ye=e[111];let ve;return e[112]!==ne||e[113]!==pe||e[114]!==he||e[115]!==ye?(ve=a.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[ne,pe,he,ye]}),e[112]=ne,e[113]=pe,e[114]=he,e[115]=ye,e[116]=ve):ve=e[116],ve}function pme(){return new URLSearchParams(window.location.search).get("pluginSafeMode")==="1"}function hme(n){const e=q.c(15),{navigation:t,sessionView:s,project:r,chrome:o}=n;let i,l;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsx(VN,{}),l=a.jsx(qN,{}),e[0]=i,e[1]=l):(i=e[0],l=e[1]);let c;e[2]!==o||e[3]!==t||e[4]!==r||e[5]!==s?(c=a.jsx(mme,{navigation:t,sessionView:s,project:r,chrome:o}),e[2]=o,e[3]=t,e[4]=r,e[5]=s,e[6]=c):c=e[6];let u;e[7]!==o||e[8]!==t||e[9]!==r?(u=a.jsx(MH,{navigation:t,project:r,chrome:o}),e[7]=o,e[8]=t,e[9]=r,e[10]=u):u=e[10];let d;return e[11]!==o.backgroundServers||e[12]!==c||e[13]!==u?(d=a.jsxs("div",{className:"flex h-dvh flex-col bg-canvas text-foreground",children:[o.backgroundServers,i,l,c,u]}),e[11]=o.backgroundServers,e[12]=c,e[13]=u,e[14]=d):d=e[14],d}const gme=[{id:"sessions",label:"Sessions",icon:Tr},{id:"chat",label:"Chat",icon:io},{id:"workspace",label:"Workspace",icon:LP}],xme=w.memo(function(e){const t=q.c(6),{activeTab:s,onTabChange:r}=e,{isLive:o}=xt();let i;t[0]!==s||t[1]!==o||t[2]!==r?(i=gme.map(c=>{const u=c.icon,d=s===c.id;return a.jsx("button",{type:"button","aria-current":d?"page":void 0,"aria-label":c.label,title:c.label,onClick:()=>{Ug(),r(c.id)},className:G("flex min-h-14 flex-1 items-center justify-center outline-none transition-[color,transform] duration-150 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset motion-reduce:transition-none",d?"text-foreground":"text-muted-foreground hover:text-foreground"),children:a.jsxs("div",{className:G("relative flex size-9 items-center justify-center rounded-md transition-[background-color,transform,scale] duration-150 ease-out motion-reduce:transition-none",d?"scale-100 bg-accent":"scale-95"),children:[a.jsx(u,{className:G("size-[18px] transition-transform duration-150 ease-out motion-reduce:transition-none",d&&"scale-110"),"aria-hidden":"true"}),c.id==="chat"&&o&&a.jsx(Gd,{className:"absolute right-0.5 top-0.5 size-1.5 ring-2 ring-background"})]})},c.id)}),t[0]=s,t[1]=o,t[2]=r,t[3]=i):i=t[3];let l;return t[4]!==i?(l=a.jsx("nav",{className:"flex shrink-0 items-stretch border-t bg-background pb-[env(safe-area-inset-bottom)]","aria-label":"Navigation",children:i}),t[4]=i,t[5]=l):l=t[5],l});function bme(n){const e=q.c(68),{session:t,sessionSource:s,isSubAgentView:r,isLive:o,canArchive:i,claudeRawMessages:l,headerAccessory:c,creatingSession:u,onNewSession:d,onDuplicateSession:f,onBackToMain:m,onShowFileChanges:p,hasFileChanges:h,onShowWorkflows:g,workflowCount:x,onSearch:b,expandAll:y,onToggleExpandAll:v}=n,k=_5(t.sessionId,o,i);let j;e[0]!==d||e[1]!==t.cwd||e[2]!==s?(j=()=>{s&&d(s.dirName,t.cwd)},e[0]=d,e[1]=t.cwd,e[2]=s,e[3]=j):j=e[3];const _=j;let N;e[4]!==r||e[5]!==m?(N=r&&m&&a.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:m,"aria-label":"Back to main agent",children:a.jsx(t1,{"data-icon":"inline-start"})}),e[4]=r,e[5]=m,e[6]=N):N=e[6];let S,C;e[7]===Symbol.for("react.memo_cache_sentinel")?(S=a.jsx(Lx,{compact:!0}),C=a.jsx(Gt,{orientation:"vertical",className:"h-4"}),e[7]=S,e[8]=C):(S=e[7],C=e[8]);let E;e[9]!==l?(E=a.jsx(Mj,{rawMessages:l,warnOnly:!0}),e[9]=l,e[10]=E):E=e[10];let T;e[11]!==t.cwd?(T=t.cwd?rr(t.cwd):"Session",e[11]=t.cwd,e[12]=T):T=e[12];let A;e[13]!==T?(A=a.jsx("span",{className:"min-w-0 flex-1 truncate text-center text-xs font-medium text-muted-foreground",children:T}),e[13]=T,e[14]=A):A=e[14];let P;e[15]===Symbol.for("react.memo_cache_sentinel")?(P=a.jsx(sa,{render:a.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"Session actions"}),children:a.jsx(T3,{"data-icon":"inline-start"})}),e[15]=P):P=e[15];let I;e[16]!==t.cwd?(I=t.cwd?rr(t.cwd):"Current session",e[16]=t.cwd,e[17]=I):I=e[17];let $;e[18]!==I?($=a.jsx("span",{className:"truncate text-foreground",children:I}),e[18]=I,e[19]=$):$=e[19];let O;e[20]!==t.gitBranch||e[21]!==t.model?(O=[t.model,t.gitBranch].filter(Boolean).join(" · ")||"Session actions",e[20]=t.gitBranch,e[21]=t.model,e[22]=O):O=e[22];let M;e[23]!==O?(M=a.jsx("span",{className:"truncate font-normal",children:O}),e[23]=O,e[24]=M):M=e[24];let R;e[25]!==$||e[26]!==M?(R=a.jsxs($j,{className:"flex flex-col gap-0.5",children:[$,M]}),e[25]=$,e[26]=M,e[27]=R):R=e[27];let z;e[28]!==u||e[29]!==_||e[30]!==s?(z=s&&a.jsxs(cn,{onClick:_,disabled:u,children:[u?a.jsx(An,{}):a.jsx(tr,{}),a.jsx("span",{children:"New session"})]}),e[28]=u,e[29]=_,e[30]=s,e[31]=z):z=e[31];let W;e[32]!==f?(W=f&&a.jsxs(cn,{onClick:f,children:[a.jsx(ys,{}),a.jsx("span",{children:"Duplicate session"})]}),e[32]=f,e[33]=W):W=e[33];let D;e[34]!==k||e[35]!==r?(D=k&&!r&&a.jsxs(cn,{onClick:k.toggle,disabled:!!k.disabledReason,children:[a.jsx(k.icon,{}),a.jsxs("span",{className:"flex flex-col",children:[k.label,k.disabledReason&&a.jsx("span",{className:"text-xs text-muted-foreground",children:k.disabledReason})]})]}),e[34]=k,e[35]=r,e[36]=D):D=e[36];let L;e[37]!==R||e[38]!==z||e[39]!==W||e[40]!==D?(L=a.jsxs(Nr,{children:[R,z,W,D]}),e[37]=R,e[38]=z,e[39]=W,e[40]=D,e[41]=L):L=e[41];let U;e[42]===Symbol.for("react.memo_cache_sentinel")?(U=a.jsx(Yu,{}),e[42]=U):U=e[42];let F;e[43]!==b?(F=b&&a.jsxs(cn,{onClick:b,children:[a.jsx(Yn,{}),a.jsx("span",{children:"Search conversation"})]}),e[43]=b,e[44]=F):F=e[44];let B;e[45]!==y||e[46]!==v?(B=v&&a.jsxs(cn,{onClick:v,children:[y?a.jsx(Md,{}):a.jsx(Ji,{}),a.jsx("span",{children:y?"Collapse tool calls":"Expand tool calls"})]}),e[45]=y,e[46]=v,e[47]=B):B=e[47];let V;e[48]!==h||e[49]!==p?(V=h&&p&&a.jsxs(cn,{onClick:p,children:[a.jsx(Ll,{}),a.jsx("span",{children:"File changes"})]}),e[48]=h,e[49]=p,e[50]=V):V=e[50];let H;e[51]!==g||e[52]!==x?(H=g&&(x??0)>0&&a.jsxs(cn,{onClick:g,children:[a.jsx(E3,{}),a.jsx("span",{className:"flex-1",children:"Workflows"}),a.jsx(Ue,{variant:"secondary",children:x})]}),e[51]=g,e[52]=x,e[53]=H):H=e[53];let K;e[54]!==F||e[55]!==B||e[56]!==V||e[57]!==H?(K=a.jsxs(Nr,{children:[F,B,V,H]}),e[54]=F,e[55]=B,e[56]=V,e[57]=H,e[58]=K):K=e[58];let Z;e[59]!==L||e[60]!==K?(Z=a.jsxs(na,{children:[P,a.jsxs(ra,{align:"end",sideOffset:6,className:"w-72",children:[L,U,K]})]}),e[59]=L,e[60]=K,e[61]=Z):Z=e[61];let Y;return e[62]!==c||e[63]!==N||e[64]!==Z||e[65]!==E||e[66]!==A?(Y=a.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-1.5 border-b bg-background px-2",children:[N,S,C,E,A,c,Z]}),e[62]=c,e[63]=N,e[64]=Z,e[65]=E,e[66]=A,e[67]=Y):Y=e[67],Y}const vme=w.memo(function(e){const t=q.c(13),{isMobile:s}=bn(),{session:r,sessionSource:o,isLive:i,permissions:l}=xt();if(!s||!r)return null;let c;t[0]!==o?(c=o?lo(o.fileName):null,t[0]=o,t[1]=c):c=t[1];const u=c;let d;t[2]!==r||t[3]!==(o==null?void 0:o.dirName)?(d=Ri(o==null?void 0:o.dirName).contextWindow?r.rawMessages:[],t[2]=r,t[3]=o==null?void 0:o.dirName,t[4]=d):d=t[4];const f=d,m=u!==null;let p;return t[5]!==f||t[6]!==i||t[7]!==l.archive||t[8]!==e||t[9]!==r||t[10]!==o||t[11]!==m?(p=a.jsx(bme,{...e,session:r,sessionSource:o,isSubAgentView:m,isLive:i,canArchive:l.archive,claudeRawMessages:f}),t[5]=f,t[6]=i,t[7]=l.archive,t[8]=e,t[9]=r,t[10]=o,t[11]=m,t[12]=p):p=t[12],p}),yme=50;function wme({onSwipeLeft:n,onSwipeRight:e}){const t=w.useRef(null),s=w.useRef(null),r=w.useRef(n),o=w.useRef(e);return r.current=n,o.current=e,w.useEffect(()=>{const i=t.current;if(!i)return;function l(u){const d=u.touches[0];s.current={x:d.clientX,y:d.clientY}}function c(u){var p,h;if(!s.current)return;const d=u.changedTouches[0],f=d.clientX-s.current.x,m=d.clientY-s.current.y;s.current=null,!(Math.abs(f)<yme||Math.abs(f)<Math.abs(m))&&(f>0?(p=o.current)==null||p.call(o):(h=r.current)==null||h.call(r))}return i.addEventListener("touchstart",l,{passive:!0}),i.addEventListener("touchend",c,{passive:!0}),()=>{i.removeEventListener("touchstart",l),i.removeEventListener("touchend",c)}},[]),t}const Rk=["sessions","chat","workspace"];function Ok(n,e,t){const s=n.indexOf(e);return s===-1?null:n[s+t]??null}function Sme(n){var $;const e=q.c(46),{panels:t,context:s,activePanelId:r,active:o,onSelectPanel:i,onClosePanel:l,actions:c,actionContent:u}=n;let d;e[0]!==c?(d=c===void 0?[]:c,e[0]=c,e[1]=d):d=e[1];const f=d;let m,p,h,g,x,b,y,v;if(e[2]!==f||e[3]!==r||e[4]!==s||e[5]!==l||e[6]!==i||e[7]!==t){p=Ux(t,s);let O;e[16]!==r?(O=D=>D.id===r,e[16]=r,e[17]=O):O=e[17],h=p.find(O);let M;e[18]!==f?(M=f.find(jme),e[18]=f,e[19]=M):M=e[19],m=M,v=(m==null?void 0:m.title)??(h==null?void 0:h.title);let R;e[20]!==s.projectPath?(R=($=s.projectPath)==null?void 0:$.split(/[/\\]/).filter(Boolean).at(-1),e[20]=s.projectPath,e[21]=R):R=e[21];const z=R;g="Workspace",x="flex min-h-0 min-w-0 flex-1 flex-col";const W=v?a.jsxs(a.Fragment,{children:[a.jsx(ee,{variant:"ghost",size:"icon-lg",onClick:l,"aria-label":"All workspace tools",children:a.jsx(A3,{"data-icon":"inline-start"})}),a.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:v}),a.jsx(ee,{variant:"outline",onClick:l,children:"Switch"})]}):a.jsxs("div",{className:"flex min-w-0 flex-1 items-baseline justify-between gap-3",children:[a.jsx("h1",{className:"text-base font-medium",children:"Workspace"}),z&&a.jsx("span",{className:"truncate text-xs text-muted-foreground",title:s.projectPath??void 0,children:z})]});e[22]!==W?(b=a.jsx("header",{className:"flex min-h-14 shrink-0 items-center gap-2 border-b px-3",children:W}),e[22]=W,e[23]=b):b=e[23],y=!v&&a.jsx("div",{className:"mobile-scroll min-h-0 flex-1 overflow-y-auto p-3",children:a.jsxs("nav",{"aria-label":"Workspace tools",className:"grid grid-cols-2 gap-2",children:[p.map(D=>{var B;const L=D.icon,U=D.indicator,F=(B=D.badge)==null?void 0:B.call(D,s);return a.jsxs(ee,{variant:"outline","aria-label":D.title,className:"h-auto min-h-24 min-w-0 flex-col items-start justify-between gap-3 whitespace-normal p-3 text-left",onClick:()=>i(D.id),children:[a.jsxs("span",{className:"flex w-full items-center justify-between gap-2",children:[a.jsxs("span",{className:"relative",children:[a.jsx(L,{"data-icon":"inline-start"}),U&&a.jsx(U,{context:s,active:!1})]}),F!=null&&a.jsx(Ue,{variant:"secondary",children:F})]}),a.jsxs("span",{className:"flex w-full items-center justify-between gap-2",children:[a.jsx("span",{children:D.title}),a.jsx(ot,{"data-icon":"inline-end"})]})]},D.id)}),f.map(kme)]})}),e[2]=f,e[3]=r,e[4]=s,e[5]=l,e[6]=i,e[7]=t,e[8]=m,e[9]=p,e[10]=h,e[11]=g,e[12]=x,e[13]=b,e[14]=y,e[15]=v}else m=e[8],p=e[9],h=e[10],g=e[11],x=e[12],b=e[13],y=e[14],v=e[15];const k=v?"relative min-h-0 flex-1":"hidden",j=(m==null?void 0:m.id)??(h==null?void 0:h.id)??"workspace",_=m&&u;let N;e[24]!==j||e[25]!==_?(N=a.jsx(n5,{fallbackMessage:"Couldn't open this workspace tool",children:_},j),e[24]=j,e[25]=_,e[26]=N):N=e[26];const S=m?"hidden":"h-full min-h-0",C=(h==null?void 0:h.id)??"",E=o&&!m;let T;e[27]!==p||e[28]!==s||e[29]!==l||e[30]!==C||e[31]!==E?(T=a.jsx(P5,{panels:p,context:s,activePanelId:C,active:E,onClosePanel:l}),e[27]=p,e[28]=s,e[29]=l,e[30]=C,e[31]=E,e[32]=T):T=e[32];let A;e[33]!==S||e[34]!==T?(A=a.jsx("div",{className:S,children:T}),e[33]=S,e[34]=T,e[35]=A):A=e[35];let P;e[36]!==N||e[37]!==A||e[38]!==k?(P=a.jsxs("div",{className:k,children:[N,A]}),e[36]=N,e[37]=A,e[38]=k,e[39]=P):P=e[39];let I;return e[40]!==P||e[41]!==g||e[42]!==x||e[43]!==b||e[44]!==y?(I=a.jsxs("section",{"aria-label":g,className:x,children:[b,y,P]}),e[40]=P,e[41]=g,e[42]=x,e[43]=b,e[44]=y,e[45]=I):I=e[45],I}function kme(n){const{id:e,title:t,icon:s,onSelect:r}=n;return a.jsxs(ee,{variant:"outline",className:"h-auto min-h-24 min-w-0 flex-col items-start justify-between gap-3 whitespace-normal p-3 text-left",onClick:r,children:[a.jsx(s,{"data-icon":"inline-start"}),a.jsxs("span",{className:"flex w-full items-center justify-between gap-2",children:[a.jsx("span",{children:t}),a.jsx(ot,{"data-icon":"inline-end"})]})]},e)}function jme(n){return n.active}const Nme=w.lazy(()=>et(()=>import("./PluginsDialog-qcJTbfeg.js"),__vite__mapDeps([37,1,2,3,4])).then(n=>({default:n.PluginsDialog}))),Cme=w.lazy(()=>et(()=>import("./ConfigBrowser-DOdqaQra.js"),__vite__mapDeps([35,1,2,31,3,4])).then(n=>({default:n.ConfigBrowser})));function _me(n){var le;const e=q.c(89),{navigation:t,sessionView:s,project:r,active:o}=n,{state:i}=bn(),{session:l,sessionSource:c}=xt(),u=mn("hostFiles"),d=mn("browser"),f=mn("configWrite"),[m,p]=w.useState(Eme),[h,g]=w.useState();let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=ae=>{g(ae),p(!0)},e[0]=x):x=e[0];const b=x,y=Q_(f),v=r.currentCwd??null;let k;e[1]!==y||e[2]!==v?(k={...y,projectPath:v,openSettings:b},e[1]=y,e[2]=v,e[3]=k):k=e[3];const j=MT(k),[_,N]=w.useState(null),{panels:S}=t,C=S.activeWorkspacePanel===null?_:null,E=(c==null?void 0:c.dirName)??i.pendingDirName??i.dashboardProject;let T;e[4]!==S?(T=function(){N(null),S.closeWorkspacePanel()},e[4]=S,e[5]=T):T=e[5];const A=T;let P;e[6]!==S?(P=function(ue){S.closeWorkspacePanel(),N(ue)},e[6]=S,e[7]=P):P=e[7];const I=P;let $;e[8]!==t.actions||e[9]!==s.chatInputRef?($=function(ue){const oe=s.chatInputRef.current,ie=(oe==null?void 0:oe.getText().trimEnd())??"";oe==null||oe.setText(ie?`${ie}
|
|
453
|
+
|
|
454
|
+
${ue}
|
|
455
|
+
`:`${ue}
|
|
456
|
+
`),t.actions.handleMobileTabChange("chat"),requestAnimationFrame(()=>oe==null?void 0:oe.focus())},e[8]=t.actions,e[9]=s.chatInputRef,e[10]=$):$=e[10];const O=$;let M;e[11]!==c?(M=c?{dirName:c.dirName,fileName:c.fileName}:null,e[11]=c,e[12]=M):M=e[12];const R=r.currentCwd??null;let z;e[13]!==u||e[14]!==d||e[15]!==O||e[16]!==t.handlers.handleLoadSessionScrollAware||e[17]!==r.hasFileChanges||e[18]!==r.supportsWorktrees||e[19]!==l||e[20]!==i.sessionChangeKey||e[21]!==M||e[22]!==R?(z={session:l,sessionAddress:M,sessionChangeKey:i.sessionChangeKey,projectPath:R,hasFileChanges:r.hasFileChanges,canAccessHostFiles:u,canUseBrowser:d,supportsWorktrees:r.supportsWorktrees,openSession:t.handlers.handleLoadSessionScrollAware,composePrompt:O},e[13]=u,e[14]=d,e[15]=O,e[16]=t.handlers.handleLoadSessionScrollAware,e[17]=r.hasFileChanges,e[18]=r.supportsWorktrees,e[19]=l,e[20]=i.sessionChangeKey,e[21]=M,e[22]=R,e[23]=z):z=e[23];const W=z,D=r.projectFilesRoot??r.currentCwd??null;let L;e[24]!==O?(L=ae=>O(p6(ae)),e[24]=O,e[25]=L):L=e[25];let U;e[26]!==t.actions||e[27]!==r.processPanel?(U=(...ae)=>{const ue=ae;r.processPanel.handleToggleServer(...ue),t.actions.handleMobileTabChange("chat")},e[26]=t.actions,e[27]=r.processPanel,e[28]=U):U=e[28];let F;e[29]!==t.actions?(F=ae=>{t.actions.handleDashboardSelect(ae.dirName,`${ae.sessionId}.jsonl`)},e[29]=t.actions,e[30]=F):F=e[30];let B;e[31]!==t.handlers.handleLoadSessionScrollAware||e[32]!==t.handlers.handleMobileJumpToTurn||e[33]!==r.backgroundAgents||e[34]!==r.processPanel.handleServersChanged||e[35]!==r.projectFilesRequest||e[36]!==r.worktrees||e[37]!==s.searchInputRef||e[38]!==D||e[39]!==L||e[40]!==U||e[41]!==F||e[42]!==E?(B={projectFilesRoot:D,projectFilesRequest:r.projectFilesRequest,backgroundAgents:r.backgroundAgents,searchInputRef:s.searchInputRef,addProjectContext:L,jumpToTurn:t.handlers.handleMobileJumpToTurn,toggleServer:U,serversChanged:r.processPanel.handleServersChanged,loadSession:t.handlers.handleLoadSessionScrollAware,worktrees:r.worktrees,worktreeDirName:E,openWorktreeSession:F},e[31]=t.handlers.handleLoadSessionScrollAware,e[32]=t.handlers.handleMobileJumpToTurn,e[33]=r.backgroundAgents,e[34]=r.processPanel.handleServersChanged,e[35]=r.projectFilesRequest,e[36]=r.worktrees,e[37]=s.searchInputRef,e[38]=D,e[39]=L,e[40]=U,e[41]=F,e[42]=E,e[43]=B):B=e[43];let V;e[44]!==S.activeWorkspacePanel||e[45]!==j?(V=((le=v5(S.activeWorkspacePanel,j))==null?void 0:le.id)??S.activeWorkspacePanel,e[44]=S.activeWorkspacePanel,e[45]=j,e[46]=V):V=e[46];let H;e[47]!==S?(H=ae=>{N(null),S.openWorkspacePanel(ae)},e[47]=S,e[48]=H):H=e[48];let K;e[49]!==f?(K=f?[{id:"plugins",title:"Plugins",icon:l1,active:!1,onSelect:()=>p(!0)}]:[],e[49]=f,e[50]=K):K=e[50];const Z=C==="mission";let Y;e[51]!==I?(Y=()=>I("mission"),e[51]=I,e[52]=Y):Y=e[52];let X;e[53]!==Z||e[54]!==Y?(X={id:"mission",title:"Mission Control",icon:I3,active:Z,onSelect:Y},e[53]=Z,e[54]=Y,e[55]=X):X=e[55];let se;e[56]!==f||e[57]!==I||e[58]!==C?(se=f?[{id:"config",title:"Config",icon:$3,active:C==="config",onSelect:()=>I("config")}]:[],e[56]=f,e[57]=I,e[58]=C,e[59]=se):se=e[59];let Q;e[60]!==K||e[61]!==X||e[62]!==se?(Q=[...K,X,...se],e[60]=K,e[61]=X,e[62]=se,e[63]=Q):Q=e[63];let te;e[64]!==f||e[65]!==t||e[66]!==r.currentCwd||e[67]!==C||e[68]!==i.configFilePath?(te=C==="mission"?a.jsx("div",{className:"flex h-full min-h-0 flex-col",children:a.jsx(f6,{navigation:t})}):C==="config"&&f?a.jsx(w.Suspense,{fallback:a.jsx(Uf,{label:"Loading configuration…"}),children:a.jsx("div",{className:"flex h-full min-h-0",children:a.jsx(Cme,{projectPath:r.currentCwd??null,initialFilePath:i.configFilePath})})}):null,e[64]=f,e[65]=t,e[66]=r.currentCwd,e[67]=C,e[68]=i.configFilePath,e[69]=te):te=e[69];let J;e[70]!==o||e[71]!==A||e[72]!==W||e[73]!==V||e[74]!==H||e[75]!==Q||e[76]!==te||e[77]!==j?(J=a.jsx(Sme,{panels:j,context:W,activePanelId:V,active:o,onSelectPanel:H,onClosePanel:A,actions:Q,actionContent:te}),e[70]=o,e[71]=A,e[72]=W,e[73]=V,e[74]=H,e[75]=Q,e[76]=te,e[77]=j,e[78]=J):J=e[78];let ne;e[79]!==f||e[80]!==h||e[81]!==m||e[82]!==r.currentCwd||e[83]!==y?(ne=m&&f&&a.jsx(w.Suspense,{fallback:null,children:a.jsx(Nme,{client:y.client,state:y,currentPath:r.currentCwd??null,initialPluginId:h,onClose:()=>{p(!1),g(void 0)}})}),e[79]=f,e[80]=h,e[81]=m,e[82]=r.currentCwd,e[83]=y,e[84]=ne):ne=e[84];let re;return e[85]!==B||e[86]!==J||e[87]!==ne?(re=a.jsxs(T5,{value:B,children:[J,ne]}),e[85]=B,e[86]=J,e[87]=ne,e[88]=re):re=e[88],re}function Eme(){return new URLSearchParams(window.location.search).get("pluginSafeMode")==="1"}const Tme=w.lazy(()=>et(()=>import("./MobileFileChanges-Dze0jsvc.js"),__vite__mapDeps([38,1,2,3,4])).then(n=>({default:n.MobileFileChanges})));function Ame(n){const e=q.c(79),{navigation:t,sessionView:s,project:r,chrome:o}=n,{state:i,config:l}=bn(),{session:c}=xt(),[u,d]=w.useState(!1),{AccountControl:f}=ur(),m=D3(i.mainView==="extension"?i.extensionViewId:null),p=i.mobileTab==="workspace"||(m==null?void 0:m.locksSwipe)===!0;let h;e[0]!==t.actions||e[1]!==i.mobileTab||e[2]!==p?(h={onSwipeLeft:()=>{if(p)return;const K=Ok(Rk,i.mobileTab,1);K&&(Ug(),t.actions.handleMobileTabChange(K))},onSwipeRight:()=>{if(p)return;const K=Ok(Rk,i.mobileTab,-1);K&&(Ug(),t.actions.handleMobileTabChange(K))}},e[0]=t.actions,e[1]=i.mobileTab,e[2]=p,e[3]=h):h=e[3];const g=wme(h);let x;e[4]!==f||e[5]!==o.onLogout||e[6]!==t.panels?(x=f&&a.jsx(f,{mobile:!0,onLogout:o.onLogout,onOpenMainView:t.panels.openMainView,className:"ml-auto"}),e[4]=f,e[5]=o.onLogout,e[6]=t.panels,e[7]=x):x=e[7];const b=x;let y;e[8]!==m||e[9]!==t.actions||e[10]!==t.panels?(y=K=>{d(!1),m&&t.panels.closeMainView(),t.actions.handleMobileTabChange(K)},e[8]=m,e[9]=t.actions,e[10]=t.panels,e[11]=y):y=e[11];const v=y,k=o.backgroundServers;let j,_;e[12]===Symbol.for("react.memo_cache_sentinel")?(j=a.jsx(VN,{}),_=a.jsx(qN,{}),e[12]=j,e[13]=_):(j=e[12],_=e[13]);let N;e[14]!==b||e[15]!==c||e[16]!==i.mobileTab?(N=!(i.mobileTab==="chat"&&c)&&a.jsxs("div",{className:"motion-slide-down-in flex h-12 shrink-0 items-center border-b bg-background px-2",children:[a.jsx(Lx,{compact:!0}),b]}),e[14]=b,e[15]=c,e[16]=i.mobileTab,e[17]=N):N=e[17];let S;e[18]!==t||e[19]!==i.mobileTab?(S=i.mobileTab==="sessions"&&a.jsx(u6,{navigation:t,mobile:!0}),e[18]=t,e[19]=i.mobileTab,e[20]=S):S=e[20];const C=i.mobileTab!=="chat",E=i.mobileTab!=="chat",T=i.mobileTab!=="chat"&&"invisible pointer-events-none";let A;e[21]!==T?(A=G("absolute inset-0 flex min-h-0 min-w-0 flex-col",T),e[21]=T,e[22]=A):A=e[22];let P;e[23]!==o||e[24]!==b||e[25]!==t||e[26]!==r||e[27]!==u||e[28]!==s?(P=a.jsx(Pme,{navigation:t,sessionView:s,project:r,chrome:o,headerAccessory:b,searchOpen:u,onSearchOpenChange:d}),e[23]=o,e[24]=b,e[25]=t,e[26]=r,e[27]=u,e[28]=s,e[29]=P):P=e[29];let I;e[30]!==E||e[31]!==A||e[32]!==P||e[33]!==C?(I=a.jsx("div",{"aria-hidden":C,inert:E,className:A,children:P}),e[30]=E,e[31]=A,e[32]=P,e[33]=C,e[34]=I):I=e[34];const $=i.mobileTab!=="workspace",O=i.mobileTab!=="workspace",M=i.mobileTab!=="workspace"&&"hidden";let R;e[35]!==M?(R=G("absolute inset-0 flex min-h-0 min-w-0 flex-col",M),e[35]=M,e[36]=R):R=e[36];const z=i.mobileTab==="workspace";let W;e[37]!==o||e[38]!==t||e[39]!==r||e[40]!==s||e[41]!==z?(W=a.jsx(_me,{navigation:t,sessionView:s,project:r,chrome:o,active:z}),e[37]=o,e[38]=t,e[39]=r,e[40]=s,e[41]=z,e[42]=W):W=e[42];let D;e[43]!==$||e[44]!==O||e[45]!==R||e[46]!==W?(D=a.jsx("div",{"aria-hidden":$,inert:O,className:R,children:W}),e[43]=$,e[44]=O,e[45]=R,e[46]=W,e[47]=D):D=e[47];let L;e[48]!==m||e[49]!==t.panels?(L=m&&a.jsx("div",{className:"absolute inset-0 z-10 flex min-h-0 min-w-0 flex-col bg-canvas",children:a.jsx(m6,{view:m,onClose:t.panels.closeMainView})}),e[48]=m,e[49]=t.panels,e[50]=L):L=e[50];let U;e[51]!==g||e[52]!==I||e[53]!==D||e[54]!==L||e[55]!==S?(U=a.jsxs("main",{ref:g,className:"app-view-transition relative flex flex-1 min-h-0 overflow-hidden",children:[S,I,D,L]}),e[51]=g,e[52]=I,e[53]=D,e[54]=L,e[55]=S,e[56]=U):U=e[56];let F;e[57]!==v||e[58]!==i.mobileTab?(F=a.jsx(xme,{activeTab:i.mobileTab,onTabChange:v}),e[57]=v,e[58]=i.mobileTab,e[59]=F):F=e[59];let B;e[60]!==l.defaultAgentKind||e[61]!==t.onStartNewFolder||e[62]!==t.onStartNewSession?(B=a.jsx(x5,{onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:l.defaultAgentKind}),e[60]=l.defaultAgentKind,e[61]=t.onStartNewFolder,e[62]=t.onStartNewSession,e[63]=B):B=e[63];let V;e[64]!==o||e[65]!==r||e[66]!==c||e[67]!==i.sessionChangeKey?(V=c&&r.hasFileChanges&&a.jsx(w.Suspense,{fallback:null,children:a.jsx(Tme,{open:o.fileChangesOpen,onClose:()=>o.onFileChangesOpenChange(!1),session:c,sessionChangeKey:i.sessionChangeKey})}),e[64]=o,e[65]=r,e[66]=c,e[67]=i.sessionChangeKey,e[68]=V):V=e[68];let H;return e[69]!==o.backgroundServers||e[70]!==o.branchModal||e[71]!==o.undoDialog||e[72]!==o.workflowsPanel||e[73]!==U||e[74]!==F||e[75]!==B||e[76]!==V||e[77]!==N?(H=a.jsxs("div",{className:"flex h-dvh flex-col bg-canvas text-foreground",children:[k,j,_,N,U,o.workflowsPanel,F,o.undoDialog,o.branchModal,B,V]}),e[69]=o.backgroundServers,e[70]=o.branchModal,e[71]=o.undoDialog,e[72]=o.workflowsPanel,e[73]=U,e[74]=F,e[75]=B,e[76]=V,e[77]=N,e[78]=H):H=e[78],H}function Pme(n){const e=q.c(23),{navigation:t,sessionView:s,project:r,chrome:o,headerAccessory:i,searchOpen:l,onSearchOpenChange:c}=n,{state:u,config:d}=bn(),{session:f,isSubAgentView:m}=xt();let p;e[0]!==o||e[1]!==d||e[2]!==i||e[3]!==m||e[4]!==t||e[5]!==c||e[6]!==r||e[7]!==l||e[8]!==f||e[9]!==s||e[10]!==u.expandAll||e[11]!==u.pendingDirName?(p=f?a.jsxs("div",{className:"flex flex-1 min-h-0 flex-col",children:[s.teamMembersBar,a.jsx(vme,{headerAccessory:i,creatingSession:t.creatingSession,onNewSession:t.onStartNewSession,onDuplicateSession:t.handlers.handleDuplicateSession,onBackToMain:m?s.onBackToMain:void 0,onShowFileChanges:()=>o.onFileChangesOpenChange(!0),hasFileChanges:r.hasFileChanges,onShowWorkflows:s.onShowWorkflows,workflowCount:s.workflowCount,onSearch:()=>c(!0),expandAll:u.expandAll,onToggleExpandAll:s.onToggleExpandAll}),a.jsx(yf,{searchInputRef:s.searchInputRef,hasMore:s.hasMoreTurns,isLoadingOlder:s.isLoadingOlderTurns,onLoadMore:s.onLoadMoreTurns,mobileSearchOpen:l,onMobileSearchClose:()=>c(!1)})]}):u.pendingDirName?a.jsx("div",{className:"flex flex-1 min-h-0 flex-col",children:s.pendingTurns.length>0?a.jsx("div",{className:"flex-1 overflow-y-auto px-1 py-3",children:s.pendingTurns}):a.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-4 px-4",children:[a.jsx(VT,{projectPath:s.pendingPath??null,switcher:{onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:d.defaultAgentKind}}),pt("terminal")&&a.jsxs(ee,{variant:"outline",size:"xs",onClick:r.onOpenTerminal,children:[a.jsx(Xi,{"data-icon":"inline-start"}),"Terminal"]})]})}):a.jsx(d6,{navigation:t}),e[0]=o,e[1]=d,e[2]=i,e[3]=m,e[4]=t,e[5]=c,e[6]=r,e[7]=l,e[8]=f,e[9]=s,e[10]=u.expandAll,e[11]=u.pendingDirName,e[12]=p):p=e[12];let h;e[13]!==f||e[14]!==s||e[15]!==u.pendingDirName?(h=(f||u.pendingDirName)&&a.jsxs(a.Fragment,{children:[s.todoProgress,f?s.activeComposer:s.pendingComposer]}),e[13]=f,e[14]=s,e[15]=u.pendingDirName,e[16]=h):h=e[16];let g;e[17]!==o.processPanel||e[18]!==h?(g=a.jsxs("div",{className:"shrink-0",children:[o.processPanel,h]}),e[17]=o.processPanel,e[18]=h,e[19]=g):g=e[19];let x;return e[20]!==p||e[21]!==g?(x=a.jsxs(a.Fragment,{children:[p,g]}),e[20]=p,e[21]=g,e[22]=x):x=e[22],x}function Ime(n){const e=q.c(10),{sessionId:t,loadError:s,searchInputRef:r,activeComposer:o,hasMoreTurns:i,isLoadingOlderTurns:l,onLoadMoreTurns:c}=n,{isMobile:u}=bn(),{session:d}=xt();let f;return e[0]!==o||e[1]!==i||e[2]!==l||e[3]!==u||e[4]!==s||e[5]!==c||e[6]!==r||e[7]!==d||e[8]!==t?(f=a.jsx("div",{className:"flex h-dvh flex-col overflow-hidden bg-canvas text-foreground",children:d?a.jsxs("main",{className:"relative flex min-h-0 flex-1 flex-col",children:[a.jsx(yf,{searchInputRef:r,hasMore:i,isLoadingOlder:l,onLoadMore:c}),u?o:a.jsx(Mf,{floating:!0,children:o})]}):a.jsx("main",{className:"flex min-h-0 flex-1 items-center justify-center p-6",children:a.jsx(kn,{className:"max-w-md",children:a.jsxs(jn,{children:[a.jsx(Rn,{variant:"icon",children:s?a.jsx(Ds,{}):a.jsx(vt,{className:"animate-spin"})}),a.jsx(Nn,{children:s?"Unable to open session":"Opening session"}),a.jsx(Cn,{children:s??`Looking for ${t} in your local Claude, Codex, and Copilot history.`})]})})})}),e[0]=o,e[1]=i,e[2]=l,e[3]=u,e[4]=s,e[5]=c,e[6]=r,e[7]=d,e[8]=t,e[9]=f):f=e[9],f}const $me=5;function h6(){const n=fn(),e=xs();return e===null?n:`${n}:${e}`}function hu(n,e){return`${h6()}:${n}/${e}`}class Rme{constructor(){Wt(this,"cache",new Map)}get(e,t){const s=hu(e,t),r=this.cache.get(s);return r&&(r.lastAccessed=Date.now()),r}set(e,t,s,r,o,i,l,c){const u=hu(e,t);!this.cache.has(u)&&this.cache.size>=$me&&this.evictLRU(),this.cache.set(u,{parsed:s,olderTurns:[],source:{dirName:e,fileName:t,rawText:r,agentKind:l,...c!==void 0?{watchOffset:c}:{}},nextByteOffset:o,hasMore:i,lastAccessed:Date.now()})}update(e,t,s){const r=hu(e,t),o=this.cache.get(r);o&&(s.parsed!==void 0&&(o.parsed=s.parsed),s.olderTurns!==void 0&&(o.olderTurns=s.olderTurns),s.nextByteOffset!==void 0&&(o.nextByteOffset=s.nextByteOffset),s.hasMore!==void 0&&(o.hasMore=s.hasMore),s.lastAccessed!==void 0&&(o.lastAccessed=s.lastAccessed),s.source&&(o.source={...o.source,...s.source}))}evict(e,t){e!==void 0&&t!==void 0?this.cache.delete(hu(e,t)):this.evictLRU()}evictSession(e){const t=`${h6()}:`;for(const[s,{source:r}]of this.cache)s.startsWith(t)&&v1(r.dirName,r.fileName)===e&&this.cache.delete(s)}clear(){this.cache.clear()}evictLRU(){let e,t=1/0;for(const[s,r]of this.cache)r.lastAccessed<t&&(t=r.lastAccessed,e=s);e!==void 0&&this.cache.delete(e)}}const hs=new Rme,Lk={};function g6(n,e,t,s,r,o){const[i,l]=w.useState(!1),[c,u]=w.useState("disconnected"),[d,f]=w.useState(!1),[m,p]=w.useState(null),[h,g]=w.useState(Lk),[x,b]=w.useState(null),[y,v]=w.useState(null),[k,j]=w.useState(pi),_=w.useRef(""),N=w.useRef(null),S=w.useRef(pi),C=w.useRef("disconnected"),E=w.useRef(e);E.current=e;const T=w.useRef(r);T.current=r;const A=w.useRef(t);A.current=t;const P=w.useRef(s);P.current=s;const I=w.useRef(o??null);I.current=o??null;const $=w.useRef(!1),O=(n==null?void 0:n.dirName)??null,M=(n==null?void 0:n.fileName)??null,R=(n==null?void 0:n.rawText)??"",z=(n==null?void 0:n.watchOffset)??new TextEncoder().encode(R).byteLength;return w.useEffect(()=>{if(_.current=R,!R){N.current=null,l(!1);return}const W=I.current;if(W){N.current=W;return}A.current(R).then(D=>{N.current=D})},[R]),w.useEffect(()=>{if(b(null),v(null),!O||!M){l(!1),u("disconnected");return}u("connecting");const W=`/api/watch/${encodeURIComponent(O)}/${encodeURIComponent(M)}?offset=${z}`,D=D1(W),L=D.source;let U=null;const F=(oe=3e4)=>{U&&clearTimeout(U),U=setTimeout(()=>{l(!1),f(!1)},oe)};let B="",V=z,H=!1,K=!1,Z=!1,Y=null;const X=()=>{Z=!1,Y=null,N.current&&E.current(N.current)},se=()=>{Z||(Z=!0,Y=requestAnimationFrame(X))};let Q=!1,te=null,J=null;const ne=()=>{Q=!1,te=null,j(S.current)},re=()=>{Q||(Q=!0,te=requestAnimationFrame(ne))},le=oe=>{oe!==S.current&&(S.current=oe,re(),oe.length>0&&!J&&(J=setInterval(()=>{const ie=MU(S.current);ie!==S.current&&(S.current=ie,re()),S.current.length===0&&J&&(clearInterval(J),J=null)},5e3)))},ae=()=>{le(pi),g(Lk)},ue=()=>{if(K||H||!B)return;const oe=B;B="",H=!0;const ie=N.current;(ie?P.current(ie,oe):A.current(_.current)).then(de=>{K||(N.current=de,O&&M&&hs.update(O,M,{parsed:de,source:{rawText:_.current,watchOffset:V}}),se())}).catch(de=>{console.error("[useLiveSession] worker parse failed:",de)}).finally(()=>{H=!1,!K&&B&&ue()})};return L.onopen=()=>{var oe;if(C.current!=="connected"){const ie=$.current;$.current=!1,C.current="connected",u("connected"),ie&&((oe=T.current)==null||oe.call(T))}},L.onmessage=oe=>{try{C.current!=="connected"&&(C.current="connected",u("connected"));const ie=JSON.parse(oe.data);if(ie.type==="init")ie.recentlyActive?(l(!0),F(5e3)):F();else if(ie.type==="compacting")ie.active&&(l(!0),ae(),F()),f(ie.active===!0);else if(ie.type==="subagent_activity")l(!0),F();else if(ie.type==="runtime_activity")l(!0),F();else if(ie.type==="stream_snapshot")l(!0),F(),le(RU(ie.messages??[]));else if(ie.type==="stream_delta")l(!0),F(),p(null),b(null),v(null),le(OU(S.current,ie.events??[]));else if(ie.type==="rate_limit")v(ie.block??null);else if(ie.type==="agent_progress")l(!0),F(),g(fe=>({...fe,[ie.toolUseId]:ie.summary}));else if(ie.type==="prompt_suggestion")b(typeof ie.suggestion=="string"?ie.suggestion:null);else if(ie.type==="turn_error")p(typeof ie.message=="string"?ie.message:"The turn failed");else if(ie.type==="stream_clear")ae(),f(!1);else if(ie.type==="lines"&&ie.lines.length>0){l(!0),f(!1),F(),le(LU(S.current,ie.lines));const fe=ie.lines.join(`
|
|
457
|
+
`)+`
|
|
458
|
+
`;V+=new TextEncoder().encode(fe).byteLength,_.current+=fe,B+=fe,ue()}}catch(ie){console.error("[useLiveSession] Error processing SSE message:",ie)}},L.onerror=()=>{l(!1),f(!1),$.current=C.current==="connected",C.current="disconnected",u("disconnected"),ae()},()=>{K=!0,D.close(),l(!1),C.current="disconnected",u("disconnected"),U&&clearTimeout(U),Y!==null&&cancelAnimationFrame(Y),te!==null&&cancelAnimationFrame(te),J&&clearInterval(J),S.current=pi,j(pi)}},[O,M,R,z]),{isLive:i,sseState:c,isCompacting:d,streamingOverlay:k,turnError:m,agentProgress:h,promptSuggestion:x,rateLimit:y}}const Ome=3e4;function x6(n,e,t){const s=q.c(12);let r;s[0]!==t?(r=t===void 0?{}:t,s[0]=t,s[1]=r):r=s[1];const{onLost:o,staleAfterMs:i}=r,l=i===void 0?Ome:i,[c,u]=w.useState(!1),d=w.useRef(e),f=w.useRef(o);let m,p;s[2]!==o||s[3]!==e?(m=()=>{d.current=e,f.current=o},p=[e,o],s[2]=o,s[3]=e,s[4]=m,s[5]=p):(m=s[4],p=s[5]),w.useEffect(m,p);let h,g;s[6]!==l||s[7]!==n?(h=()=>{if(!n){u(!1);return}let b=!0,y=null;const v=D1(n,{onLost:()=>{var _;return(_=f.current)==null?void 0:_.call(f)}}),k=v.source;u(!1);const j=()=>{y&&clearTimeout(y),y=setTimeout(()=>{b&&u(!1)},l)};return k.onmessage=_=>{if(b)try{const N=JSON.parse(_.data);N.type==="init"?j():N.type==="update"&&(u(!0),j(),d.current())}catch{}},k.onerror=()=>{b&&u(!1)},()=>{b=!1,v.close(),y&&clearTimeout(y)}},g=[n,l],s[6]=l,s[7]=n,s[8]=h,s[9]=g):(h=s[8],g=s[9]),w.useEffect(h,g);let x;return s[10]!==c?(x={isLive:c},s[10]=c,s[11]=x):x=s[11],x}function Lme(n,e,t){const s=q.c(2),r=n?`/api/team-watch/${encodeURIComponent(n)}`:null;let o;return s[0]!==t?(o={onLost:t},s[0]=t,s[1]=o):o=s[1],x6(r,e,o)}function Mme(n,e){const[t,s]=w.useState(null),r=w.useRef(null),o=(()=>{if(!n)return null;let c,u=null;const d=n.match(/^([^/]+)\/subagents\/(.+)$/);d?(c=d[1],u=d[2]):c=n.replace(".jsonl","");const f=new URLSearchParams({leadSessionId:c});return u&&f.set("subagentFile",u),e&&f.set("dirName",e),f.toString()})();r.current=o;const i=w.useCallback(async()=>{const c=r.current;if(c)try{const u=await Re(`/api/session-team?${c}`);if(!u.ok){s(null);return}const d=await u.json();s(d?{teamName:d.teamName,config:d.config,currentMemberName:d.currentMemberName||null}:null)}catch{s(null)}},[]);w.useEffect(()=>{if(!n){s(null);return}i()},[n,i]);const l=w.useCallback(()=>s(null),[]);return Lme((t==null?void 0:t.teamName)??null,i,l),t}function zme(n,e,t,s){let r=null;return n&&e&&(r=`/api/workflow-watch/${encodeURIComponent(n)}/${encodeURIComponent(e)}`,t&&(r=r+`/${encodeURIComponent(t)}`)),x6(r,s)}function Dme(n,e,t=!0){const[s,r]=w.useState([]),[o,i]=w.useState(!1),l=w.useRef(0),c=!!n&&!!e,u=w.useCallback(async()=>{const m=++l.current;if(!c){r([]);return}try{const p=await Re(`/api/workflows/${encodeURIComponent(n)}/${encodeURIComponent(e)}`);if(!p.ok){m===l.current&&r([]);return}const h=await p.json();m===l.current&&r(Array.isArray(h)?h:[])}catch{m===l.current&&r([])}finally{m===l.current&&i(!1)}},[c,n,e]);w.useEffect(()=>{if(!c){r([]),i(!1);return}i(!0),u()},[c,u]);const d=c&&(t||s.length>0),{isLive:f}=zme(d?n:null,d?e:null,null,u);return{workflows:s,loading:o,isLive:f,refetch:u}}function Fme(n){if(!n)return!1;const e=n.toLowerCase();return e.includes("issue with the selected model")||e.includes("selected model")&&e.includes("may not exist or you may not have access")||e.includes("run --model to pick a different model")}async function Mk(n,e){const t=await n.json().catch(()=>({}));return{message:typeof t.error=="string"&&t.error?t.error:e,code:typeof t.code=="string"?t.code:null}}async function b6(n,{model:e,agentKind:t,errorFallback:s,onModelRejected:r}){const o=u=>typeof s=="function"?s(u):s;let l=await n(t==="copilot"?e||"auto":e||void 0),c=l.ok?null:await Mk(l,o(l));return!l.ok&&t==="codex"&&e&&Fme(c==null?void 0:c.message)&&(r==null||r(e),l=await n(void 0),c=l.ok?null:await Mk(l,o(l))),{res:l,errorMessage:(c==null?void 0:c.message)??null,errorCode:(c==null?void 0:c.code)??null}}const Ume=[];function Bme({sessionSource:n,parsedSessionId:e,cwd:t,permissions:s,onPermissionsApplied:r,model:o,effort:i,contextWindowTokens:l,fastMode:c,ultracode:u,settingsChange:d=Ume,onSettingsChangeSent:f,mcpConfig:m,onModelRejected:p,readOnly:h=!1,onCreateSession:g}){const[x,b]=w.useState("idle"),[y,v]=w.useState(),[k,j]=w.useState([]),_=w.useRef(null),N=w.useRef(null),S=w.useRef(!1),C=n!=null&&n.fileName?Gu(n.fileName):null,E=e||C,T=n?nn(n.dirName):null,A=w.useCallback(()=>{var z;(z=_.current)==null||z.abort(),_.current=null,S.current=!1,b("idle"),v(void 0),j([])},[]);w.useEffect(()=>{var z;N.current!==E&&(S.current?(S.current=!1,(z=_.current)==null||z.abort(),_.current=null,b("idle"),v(void 0)):A(),N.current=E)},[E,A]),w.useEffect(()=>()=>{var z;(z=_.current)==null||z.abort()},[]),w.useEffect(()=>{h&&A()},[h,A]);const P=w.useCallback(async(z,W)=>{if(h)return!1;if(!E&&g){j(L=>[...L,z]),b("connected"),v(void 0),S.current=!0,r==null||r();try{if(!await g(z,W))return S.current=!1,b("idle"),j([]),!0;b("idle")}catch(L){S.current=!1,v(L instanceof Error?L.message:"Failed to create session"),b("error"),j([])}return!0}if(!E)return!0;j(L=>[...L,z]),b("connected"),v(void 0),r==null||r();const D=new AbortController;_.current=D;try{const L={sessionId:E,message:z,images:W||void 0,cwd:t||void 0,permissions:s,effort:i||void 0,contextWindowTokens:l,fastMode:c||d.includes("fastMode")?c:void 0,ultracode:u||d.includes("ultracode")?u:void 0,mcpConfig:m||void 0,settingsChange:d.length>0?d:void 0},{res:U,errorMessage:F}=await b6(B=>Re("/api/send-message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...L,model:B}),signal:D.signal}),{model:o,agentKind:T,errorFallback:B=>`Request failed (${B.status})`,onModelRejected:p});return _.current===D&&(U.ok?b("idle"):(v(F||`Request failed (${U.status})`),b("error"),j(B=>B.slice(0,-1)))),U.ok&&d.length>0&&(f==null||f()),!YI(U)}catch(L){return L instanceof Error&&L.name==="AbortError"||_.current===D&&(v(L instanceof Error?L.message:"Unknown error"),b("error"),j(U=>U.slice(0,-1))),!0}},[E,T,t,s,r,o,i,l,c,u,d,f,m,p,h,g]),I=w.useCallback(()=>{A()},[A]),$=w.useCallback(()=>{!E||h||Re("/api/interrupt-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:E})}).catch(()=>{})},[E,h]),O=w.useCallback(()=>{var z;(z=_.current)==null||z.abort(),_.current=null,$(),b("idle"),j([])},[$]),M=O,R=w.useCallback((z=1)=>{j(W=>W.slice(z))},[]);return{status:x,error:y,pendingMessages:k,sendMessage:P,disconnect:I,interrupt:O,stopAgent:M,consumePending:R,isConnected:x==="connected"}}const xi={expandAll:!1,expandToolPayloads:!1},Wme={session:null,windowTurns:[],olderTurns:[],sessionSource:null,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...xi,sessionChangeKey:0,currentMemberName:null,loadingMember:null,mainView:"sessions",extensionViewId:null,configFilePath:null,mobileTab:"sessions",dashboardProject:null};function zk(n,e,t,s){const r=e5(e,t,s);return r===n.turns?n:{...n,turns:r}}function gu(n){return{session:n,windowTurns:(n==null?void 0:n.turns)??[],olderTurns:[]}}function qme(n,e){var t,s;switch(e.type){case"LOAD_SESSION":case"FINALIZE_SESSION":case"INIT_PENDING_SESSION":{const r=e.type==="INIT_PENDING_SESSION";return{...n,...gu(r?null:e.session),sessionSource:r?null:e.source,pendingDirName:r?e.dirName:null,pendingCwd:r?e.cwd??null:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...xi,mainView:"sessions",currentMemberName:null,dashboardProject:null,sessionChangeKey:n.sessionChangeKey+1,mobileTab:e.isMobile?"chat":n.mobileTab}}case"GO_HOME":case"CLOSE_SESSION":{const r=e.type==="GO_HOME";return{...n,...gu(null),sessionSource:null,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...xi,mainView:r?"sessions":n.mainView,currentMemberName:null,dashboardProject:null,mobileTab:e.isMobile&&(r||n.mobileTab==="chat")?"sessions":n.mobileTab}}case"SWITCH_TEAM_MEMBER":return{...n,...gu(e.session),sessionSource:e.source,activeTurnIndex:null,searchQuery:"",...xi,currentMemberName:e.memberName,sessionChangeKey:n.sessionChangeKey+1};case"JUMP_TO_TURN":return{...n,activeTurnIndex:e.index,activeToolCallId:e.toolCallId??null};case"SET_SEARCH_QUERY":return n.searchQuery===e.value?n:{...n,searchQuery:e.value};case"SET_EXPAND_ALL":return e.value?n.expandAll&&!n.expandToolPayloads?n:{...n,expandAll:!0,expandToolPayloads:!1}:!n.expandAll&&!n.expandToolPayloads?n:{...n,...xi};case"SET_EXPAND_TOOL_PAYLOADS":return e.value?n.expandAll&&n.expandToolPayloads?n:{...n,expandAll:!0,expandToolPayloads:!0}:n.expandToolPayloads?{...n,expandToolPayloads:!1}:n;case"TOGGLE_EXPAND_ALL":return n.expandAll?{...n,...xi}:{...n,expandAll:!0};case"SET_MOBILE_TAB":return n.mobileTab===e.tab?n:{...n,mobileTab:e.tab};case"UPDATE_SESSION":return{...n,windowTurns:e.session.turns,session:zk(e.session,e.session.turns,n.olderTurns,(t=n.sessionSource)==null?void 0:t.agentKind)};case"SET_OLDER_TURNS":return!n.session||e.turns===n.olderTurns?n:{...n,olderTurns:e.turns,session:zk(n.session,n.windowTurns,e.turns,(s=n.sessionSource)==null?void 0:s.agentKind)};case"RELOAD_SESSION_CONTENT":return{...n,...gu(e.session),sessionSource:e.source,sessionChangeKey:n.sessionChangeKey+1};case"SET_CURRENT_MEMBER_NAME":return n.currentMemberName===e.name?n:{...n,currentMemberName:e.name};case"GUARD_MOBILE_TAB":{let r=n.mobileTab;return!e.hasSession&&r==="chat"&&(r="sessions"),r!==n.mobileTab?{...n,mobileTab:r}:n}case"SET_LOADING_MEMBER":return n.loadingMember===e.name?n:{...n,loadingMember:e.name};case"SET_DASHBOARD_PROJECT":return n.dashboardProject===e.dirName?n:{...n,dashboardProject:e.dirName};case"OPEN_CONFIG":return{...n,mainView:"config",configFilePath:e.filePath??null};case"CLOSE_CONFIG":return{...n,mainView:"sessions",configFilePath:null};case"OPEN_MISSION":return{...n,mainView:"mission"};case"CLOSE_MISSION":return{...n,mainView:"sessions"};case"OPEN_EXTENSION_VIEW":return{...n,mainView:"extension",extensionViewId:e.id};case"CLOSE_EXTENSION_VIEW":return{...n,mainView:"sessions",extensionViewId:null};default:return n}}function v6(){return w.useReducer(qme,Wme)}function Dk(n){n(),requestAnimationFrame(()=>{n(),requestAnimationFrame(n)})}function y6({session:n,isLive:e,pendingMessages:t,consumePending:s,sessionChangeKey:r,partialSignal:o}){const i=w.useRef(null),l=w.useRef(null),c=w.useRef(!0),u=w.useRef(!1),d=w.useRef(0),f=w.useMemo(()=>(n==null?void 0:n.turns.flatMap(O=>O.contentBlocks.flatMap(M=>M.kind==="queued_prompt"?[{id:JSON.stringify([M.timestamp??"",M.content]),content:M.content}]:[])))??[],[n==null?void 0:n.turns]),m=w.useRef(null),p=w.useRef(!1),[h,g]=w.useState(!1),[x,b]=w.useState(null),y=w.useCallback(()=>{requestAnimationFrame(()=>{var O;(O=l.current)==null||O.scrollIntoView({behavior:"smooth"})})},[]),v=w.useCallback(()=>{Dk(()=>{const O=i.current;O&&(O.scrollTop=O.scrollHeight),c.current=!0,u.current=!1})},[]),k=w.useCallback(()=>{p.current=!0},[]),j=w.useRef(!1),_=w.useCallback(()=>{const O=i.current;if(!O)return;const M=O.scrollHeight-O.scrollTop-O.clientHeight>10;M!==j.current&&(j.current=M,g(M))},[]),N=w.useCallback(()=>{const O=i.current;O&&(c.current=O.scrollHeight-O.scrollTop-O.clientHeight<150,_())},[_]),S=w.useCallback(O=>{d.current=O},[]),C=w.useRef(r);w.useEffect(()=>{if(r===C.current)return;C.current=r;const O=p.current;p.current=!1;const M=()=>{const z=i.current;z&&(O?(z.scrollTop=0,c.current=!1):(z.scrollTop=z.scrollHeight,c.current=!0),u.current=!1)};Dk(M);const R=setTimeout(()=>{M(),b(r)},150);return()=>clearTimeout(R)},[r]);const E=t.length;w.useEffect(()=>{E>0&&(u.current=!0,y())},[E,y]),w.useEffect(()=>{const O=(n==null?void 0:n.sessionId)??null,M=m.current,R=new Set(f.map(D=>D.id));if(!M||M.sessionId!==O){m.current={sessionId:O,ids:R};return}const z=f.filter(D=>!M.ids.has(D.id));if(m.current={sessionId:O,ids:R},z.length===0||E===0)return;let W=0;for(const D of z){const L=t[W];(L===D.content||(L==null?void 0:L.trim())===""&&D.content.length>0)&&W++}W>0&&s(W)},[n==null?void 0:n.sessionId,f,t,E,s]);const T=(n==null?void 0:n.turns.length)??0;w.useEffect(()=>{if(T===0)return;const O=T-d.current;O>0&&(E>0&&s(Math.min(O,E)),(u.current||c.current)&&(y(),u.current=!1)),d.current=T},[T,E,s,y]);const A=n==null?void 0:n.turns.at(-1),P=(A==null?void 0:A.toolCalls.length)??0,I=(A==null?void 0:A.assistantText.length)??0;w.useEffect(()=>{if(!(!n||!e)){if(c.current){const O=i.current;O&&(O.scrollTop=O.scrollHeight)}requestAnimationFrame(_)}},[T,P,I,o,e,_]);const $=x===r;return w.useMemo(()=>({chatScrollRef:i,scrollEndRef:l,canScrollDown:h,initialScrollDone:$,handleScroll:N,scrollToBottomInstant:v,requestScrollToTop:k,resetTurnCount:S}),[h,$,N,v,k,S])}async function w6(n,e,t,s,{background:r=!1}={}){const o=await Re(`/api/sessions/${encodeURIComponent(n)}/${encodeURIComponent(e)}?tail=30`,{background:r});if(!o.ok)throw new Error(`Failed to load ${s} (${o.status})`);const i=await o.json(),l=new Set(i.headerLines),c=i.tailLines.filter(f=>!l.has(f)),u=[...i.headerLines,...c].join(`
|
|
459
|
+
`);return{parsed:await t(u),source:{dirName:n,fileName:e,rawText:u,agentKind:nn(n),watchOffset:i.totalSize},byteOffset:i.byteOffset,hasMore:i.hasMore}}async function Gi(n,e,t,s,r={}){const o=hs.get(n,e);if(o)return{parsed:o.parsed,source:o.source};const i=fn(),l=xs(),{parsed:c,source:u,byteOffset:d,hasMore:f}=await w6(n,e,t,s,r);if(fn()!==i||xs()!==l)return{parsed:c,source:u};const m=hs.get(n,e);return m?{parsed:m.parsed,source:m.source}:(hs.set(n,e,c,u.rawText,d,f,u.agentKind,u.watchOffset),{parsed:c,source:u})}async function S6(n,e,t,s){hs.evict(n,e);const r=fn(),o=xs(),{parsed:i,source:l,byteOffset:c,hasMore:u}=await w6(n,e,t,s);return fn()===r&&xs()===o&&hs.set(n,e,i,l.rawText,c,u,l.agentKind,l.watchOffset),{parsed:i,source:l}}function Vme({dispatch:n,isMobile:e,mobileTab:t="sessions",teamContext:s,scrollToBottomInstant:r,resetTurnCount:o,workerParse:i,onBeforeSwitch:l}){const[c,u]=w.useState(null),d=w.useCallback((y,v)=>{u(null),w.startTransition(()=>{n({type:"LOAD_SESSION",session:y,source:v,isMobile:e})}),o(y.turns.length),vfe(y.sessionId,y.turns.length),r()},[n,e,o,r]),f=w.useCallback(async(y,v)=>{l==null||l(),u(null);try{const{parsed:k,source:j}=await Gi(y,v,i,"session");d(k,j)}catch(k){u(k instanceof Error?k.message:"Failed to load session")}},[d,i,l]),m=w.useCallback(async y=>{if(s){l==null||l(),u(null),n({type:"SET_LOADING_MEMBER",name:y.name});try{const v=await Re(`/api/team-member-session/${encodeURIComponent(s.teamName)}/${encodeURIComponent(y.name)}`);if(!v.ok)throw new Error(`Failed to find session for ${y.name}`);const{dirName:k,fileName:j}=await v.json(),{parsed:_,source:N}=await Gi(k,j,i,`session for ${y.name}`);w.startTransition(()=>{n({type:"SWITCH_TEAM_MEMBER",session:_,source:N,memberName:y.name})}),o(_.turns.length),r()}catch(v){u(v instanceof Error?v.message:"Failed to switch team member")}finally{n({type:"SET_LOADING_MEMBER",name:null})}}},[n,s,o,r,i,l]),p=w.useCallback(()=>u(null),[]),h=w.useCallback(()=>{w.startTransition(()=>{n({type:"GO_HOME",isMobile:e})})},[n,e]),g=w.useCallback(()=>{w.startTransition(()=>{n({type:"CLOSE_SESSION",isMobile:e})})},[n,e]),x=w.useCallback((y,v)=>{n({type:"JUMP_TO_TURN",index:y,toolCallId:v})},[n]),b=w.useCallback(y=>{y!==t&&n({type:"SET_MOBILE_TAB",tab:y})},[n,t]);return{loadError:c,clearLoadError:p,handleLoadSession:d,handleDashboardSelect:f,handleTeamMemberSwitch:m,handleGoHome:h,handleCloseSession:g,handleJumpToTurn:x,handleMobileTabChange:b}}const Hme=/^\/preview\/([^/]+)\/?$/;function M0(n){const e=Hme.exec(n);if(!e)return null;try{const t=decodeURIComponent(e[1]);return t.length>0?t:null}catch{return null}}function Bg(){const n=Dd();return n?`${n}/`:"/"}function k6(n){const e=/^\/d\/[^/]+(\/.*)?$/.exec(n);return e?e[1]||"/":n}function Kme(n,e){return y$(n,e)}function Gme(n){const e=Dd();return n.sessionSource?y5(n.sessionSource.dirName,n.sessionSource.fileName):n.pendingDirName?`${e}/${encodeURIComponent(n.pendingDirName)}`:n.dashboardProject?`${e}/${encodeURIComponent(n.dashboardProject)}`:Bg()}function Fk(n){const e=k6(n),t=M0(e);if(t)return{type:"preview",sessionId:t};if(e.startsWith("/team/"))return{type:"home",normalizeHome:!0};const s=e.split("/").filter(Boolean);return s.length>=2?{type:"session",dirName:decodeURIComponent(s[0]),sessionId:decodeURIComponent(s[1])}:s.length===1?{type:"project",dirName:decodeURIComponent(s[0])}:{type:"home"}}function Zme({state:n,dispatch:e,isMobile:t,resetTurnCount:s,scrollToBottomInstant:r,workerParse:o}){const[i,l]=w.useState(null),c=w.useRef(0),u=w.useRef(window.location.pathname),d=w.useRef(!1),f=w.useCallback(async m=>{c.current++;try{if(m.type==="preview"&&m.sessionId){l(null);try{const p=await Re(`/api/find-session/${encodeURIComponent(m.sessionId)}`);if(!p.ok)throw new Error(p.status===404?`Session ${m.sessionId} was not found.`:`Failed to resolve session (${p.status}).`);const h=await p.json();if(!h.dirName||!h.fileName)throw new Error("Cogpit returned an invalid session location.");const g=await Gi(h.dirName,h.fileName,o,"session preview");e({type:"LOAD_SESSION",session:g.parsed,source:g.source,isMobile:t}),s(g.parsed.turns.length),r()}catch(p){e({type:"GO_HOME",isMobile:t}),l(p instanceof Error?p.message:"Failed to load session preview.")}}else if(m.type==="session"&&m.dirName&&m.sessionId){l(null);const p=Kme(m.dirName,m.sessionId);let h;try{h=await Gi(m.dirName,p,o,"session")}catch{e({type:"GO_HOME",isMobile:t});const g=Bg();window.history.replaceState(null,"",g),u.current=g,ha(Dt(),g);return}e({type:"LOAD_SESSION",session:h.parsed,source:h.source,isMobile:t}),s(h.parsed.turns.length),r()}else if(m.type==="project"&&m.dirName)l(null),e({type:"SET_DASHBOARD_PROJECT",dirName:m.dirName});else if(l(null),e({type:"GO_HOME",isMobile:t}),m.normalizeHome){const p=Bg();window.history.replaceState(null,"",p),u.current=p,ha(Dt(),p)}}finally{c.current--}},[e,t,s,r,o]);return w.useEffect(()=>{if(d.current)return;d.current=!0,ha(Dt(),window.location.pathname);const m=Fk(window.location.pathname);(m.type!=="home"||m.normalizeHome)&&f(m)},[f]),w.useEffect(()=>{if(c.current>0||M0(k6(window.location.pathname)))return;const m=Gme(n);m!==u.current&&(window.history.pushState(null,"",m),u.current=m,ha(Dt(),m))},[n.sessionSource,n.pendingDirName,n.mainView,n.dashboardProject]),w.useEffect(()=>{const m=()=>{const p=Fk(window.location.pathname);u.current=window.location.pathname,ha(Dt(),window.location.pathname),f(p)};return window.addEventListener("popstate",m),()=>window.removeEventListener("popstate",m)},[f]),{previewLoadError:i}}const Yme=400;function Uk(){return Array.from(document.querySelectorAll("[data-live-session]"))}function Xme(n){let e=n.parentElement;for(;e;){const{overflowY:t}=getComputedStyle(e);if(t==="auto"||t==="scroll")return e;e=e.parentElement}return null}function Bk(n){n.focus({preventScroll:!0});const e=Xme(n);if(e){const t=e.getBoundingClientRect(),s=n.getBoundingClientRect();s.top<t.top?e.scrollTop-=t.top-s.top+8:s.bottom>t.bottom&&(e.scrollTop+=s.bottom-t.bottom+8)}}function Jme(n){const e=q.c(20),{isMobile:t,searchInputRef:s,chatInputRef:r,dispatch:o,onToggleSidebar:i,onToggleRightSidebar:l,onToggleMissionControl:c,onOpenCommandPalette:u,onOpenProjectSwitcher:d,onOpenThemeSelector:f,onOpenTerminal:m,onToggleIntegratedTerminal:p,onTogglePreview:h,onToggleProjectFiles:g,onHistoryBack:x,onHistoryForward:b,onNavigateToSession:y,onCommitNavigation:v}=n;let k,j;e[0]!==r||e[1]!==o||e[2]!==t||e[3]!==v||e[4]!==x||e[5]!==b||e[6]!==y||e[7]!==u||e[8]!==d||e[9]!==m||e[10]!==f||e[11]!==p||e[12]!==c||e[13]!==h||e[14]!==g||e[15]!==l||e[16]!==i||e[17]!==s?(k=()=>{if(t)return;let _=!1,N=!1,S=null;const C=function(P){var M,R;const I=r2("missionControl");if(I){if(P.key===I){P.repeat||(_=!0,N=P.shiftKey||P.altKey||(I==="Meta"?P.ctrlKey:P.metaKey));return}_&&(N=!0),S=null}if(qt("commandPalette",P)){P.preventDefault(),u==null||u();return}if(qt("integratedTerminal",P)){if(!pt("terminal"))return;P.preventDefault(),p();return}if(qt("preview",P)){P.preventDefault(),h();return}if(qt("projectFiles",P)){if(!pt("hostFiles"))return;P.preventDefault(),g();return}if(qt("expandAll",P)){P.preventDefault(),o({type:"SET_EXPAND_ALL",value:!0});return}if(qt("expandToolPayloads",P)){P.preventDefault(),o({type:"SET_EXPAND_TOOL_PAYLOADS",value:!0});return}if(qt("toggleSidebar",P)){P.preventDefault(),i();return}if(qt("toggleStats",P)){P.preventDefault(),l();return}if(qt("missionControl",P)){P.preventDefault(),c();return}if(qt("newSession",P)&&(P.preventDefault(),d()),qt("themeSelector",P)&&(P.preventDefault(),f()),qt("systemTerminal",P)){if(!pt("terminal"))return;P.preventDefault(),m()}if(P.key==="Escape"&&(o({type:"SET_SEARCH_QUERY",value:""}),(M=s.current)==null||M.blur()),(P.metaKey||P.ctrlKey)&&P.shiftKey&&P.code.startsWith("Digit")){const z=parseInt(P.code.charAt(5),10);if(z>=1&&z<=9){P.preventDefault();const D=Uk()[z-1];D&&(Bk(D),D.click())}}const $=qt("recentSessionForward",P);if($||qt("recentSessionBack",P)){P.preventDefault();const z=$?b():x();z&&y(z.dirName,z.fileName)}qt("focusComposer",P)&&!i5(document.activeElement)&&(P.preventDefault(),(R=r.current)==null||R.focus());const O=qt("nextLiveSession",P);if(O||qt("prevLiveSession",P)){P.preventDefault();const z=Uk();if(z.length===0)return;const W=z.findIndex(Qme);let D;W===-1?D=O?0:z.length-1:D=Math.max(0,Math.min(z.length-1,W+(O?1:-1))),Bk(z[D])}},E=function(P){const I=r2("missionControl");if(I&&P.key===I&&_){const $=!N;if(_=!1,N=!1,$){const O=Date.now();S!==null&&O-S<=Yme?(S=null,P.preventDefault(),c()):S=O}else S=null}P.key==="Control"&&(v==null||v())},T=function(){_=!1,N=!1,S=null};return window.addEventListener("keydown",C),window.addEventListener("keyup",E),window.addEventListener("blur",T),()=>{window.removeEventListener("keydown",C),window.removeEventListener("keyup",E),window.removeEventListener("blur",T)}},j=[t,s,r,o,i,l,c,u,d,f,m,p,h,g,x,b,y,v],e[0]=r,e[1]=o,e[2]=t,e[3]=v,e[4]=x,e[5]=b,e[6]=y,e[7]=u,e[8]=d,e[9]=m,e[10]=f,e[11]=p,e[12]=c,e[13]=h,e[14]=g,e[15]=l,e[16]=i,e[17]=s,e[18]=k,e[19]=j):(k=e[18],j=e[19]),w.useEffect(k,j)}function Qme(n){return n===document.activeElement}function j6(){const n=q.c(7),[e,t]=w.useState(UI),[s,r]=w.useState(null);let o;n[0]===Symbol.for("react.memo_cache_sentinel")?(o=f=>{BI(f),t(f),r(null)},n[0]=o):o=n[0];const i=o,l=s??e;let c,u;n[1]!==l?(c=()=>WI(l),u=[l],n[1]=l,n[2]=c,n[3]=u):(c=n[2],u=n[3]),w.useEffect(c,u);let d;return n[4]!==l||n[5]!==e?(d={theme:e,activeTheme:l,setTheme:i,setPreview:r},n[4]=l,n[5]=e,n[6]=d):d=n[6],d}const epe="cogpit-session-history",Wg=50;function N6(){return gn(epe)}function tpe(){try{const n=localStorage.getItem(N6());if(!n)return[];const e=JSON.parse(n);if(Array.isArray(e))return e.slice(0,Wg)}catch{}return[]}function hh(n){try{localStorage.setItem(N6(),JSON.stringify(n))}catch{}}function npe(){const n=q.c(7);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=tpe(),n[0]=e):e=n[0];const t=w.useRef(e),s=w.useRef(0),r=w.useRef(!1);let o;n[1]===Symbol.for("react.memo_cache_sentinel")?(o=(x,b)=>{if(r.current){r.current=!1;return}const y=`${x}/${b}`;t.current=t.current.filter(v=>`${v.dirName}/${v.fileName}`!==y),t.current.unshift({dirName:x,fileName:b}),t.current.length>Wg&&(t.current.length=Wg),s.current=0,hh(t.current)},n[1]=o):o=n[1];const i=o;let l;n[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{if(t.current.length<=1)return null;const x=(s.current+1)%t.current.length;return s.current=x,r.current=!0,t.current[x]},n[2]=l):l=n[2];const c=l;let u;n[3]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{if(t.current.length<=1)return null;const x=(s.current-1+t.current.length)%t.current.length;return s.current=x,r.current=!0,t.current[x]},n[3]=u):u=n[3];const d=u;let f;n[4]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{if(s.current===0){r.current=!1;return}const x=t.current[s.current];x&&(t.current.splice(s.current,1),t.current.unshift(x),hh(t.current)),s.current=0,r.current=!1},n[4]=f):f=n[4];const m=f;let p;n[5]===Symbol.for("react.memo_cache_sentinel")?(p=x=>{const b=t.current.filter(y=>v1(y.dirName,y.fileName)!==x);b.length!==t.current.length&&(t.current=b,s.current=0,hh(b))},n[5]=p):p=n[5];const h=p;let g;return n[6]===Symbol.for("react.memo_cache_sentinel")?(g={push:i,goBack:c,goForward:d,commitNavigation:m,forget:h},n[6]=g):g=n[6],g}const spe="You no longer have access to this session",rpe="You don't have access to this session";function ope(n){const e=q.c(7),{openSessionId:t,leave:s,forgetVisits:r}=n,{removeSession:o}=kx();let i,l;e[0]!==r||e[1]!==s||e[2]!==t||e[3]!==o?(i=()=>{const u=function(p){hs.evictSession(p),aU(p),wU(p),o(p),r(p),pC(),p===t&&s()},d=QI((m,p)=>{const h=xU(m)?spe:rpe;u(m),!(p&&m!==t)&&t$(m).then(g=>{g||Bn.error(h,{id:`session-access-lost:${m}`})})}),f=n$(u);return()=>{d(),f()}},l=[t,s,r,o],e[0]=r,e[1]=s,e[2]=t,e[3]=o,e[4]=i,e[5]=l):(i=e[4],l=e[5]),w.useEffect(i,l);let c;e[6]===Symbol.for("react.memo_cache_sentinel")?(c=[],e[6]=c):c=e[6],w.useEffect(ipe,c)}function ipe(){return Z3(ape)}function ape(){return pC()}const Wk={mode:"bypassPermissions",allowedTools:[],disallowedTools:[]},lpe="cogpit:permissions";function C6(){return gn(lpe)}function qk(){try{const n=localStorage.getItem(C6());if(n){const e=JSON.parse(n);return{mode:e.mode||Wk.mode,allowedTools:Array.isArray(e.allowedTools)?e.allowedTools:[],disallowedTools:Array.isArray(e.disallowedTools)?e.disallowedTools:[]}}}catch{}return Wk}function cpe(n){localStorage.setItem(C6(),JSON.stringify(n))}function upe(){const n=q.c(17),[e,t]=w.useState(qk),[s,r]=w.useState(qk),o=w.useRef(!0);let i,l;n[0]!==e?(i=()=>{if(o.current){o.current=!1;return}cpe(e)},l=[e],n[0]=e,n[1]=i,n[2]=l):(i=n[1],l=n[2]),w.useEffect(i,l);let c;n[3]!==s.allowedTools||n[4]!==s.disallowedTools||n[5]!==s.mode||n[6]!==e.allowedTools||n[7]!==e.disallowedTools||n[8]!==e.mode?(c=e.mode!==s.mode||JSON.stringify(e.allowedTools)!==JSON.stringify(s.allowedTools)||JSON.stringify(e.disallowedTools)!==JSON.stringify(s.disallowedTools),n[3]=s.allowedTools,n[4]=s.disallowedTools,n[5]=s.mode,n[6]=e.allowedTools,n[7]=e.disallowedTools,n[8]=e.mode,n[9]=c):c=n[9];const u=c;let d;n[10]===Symbol.for("react.memo_cache_sentinel")?(d=g=>{t(x=>({...x,mode:g}))},n[10]=d):d=n[10];const f=d;let m;n[11]!==e?(m=()=>{r(e)},n[11]=e,n[12]=m):m=n[12];const p=m;let h;return n[13]!==e||n[14]!==u||n[15]!==p?(h={config:e,hasPendingChanges:u,setMode:f,markApplied:p},n[13]=e,n[14]=u,n[15]=p,n[16]=h):h=n[16],h}const dpe=2e3;function fpe(n,e){return n.length!==e.length?!1:JSON.stringify(n)===JSON.stringify(e)}function mpe(n){const[e,t]=w.useState([]),[s,r]=w.useState(null),[o,i]=w.useState(new Set);w.useEffect(()=>{if(!n){t([]),r(null);return}let u=!1;const d=async()=>{if(!u)try{const h=await Re(`/api/permissions/${encodeURIComponent(n)}`);if(u)return;if(h.ok){const g=await h.json();if(u)return;t(b=>fpe(b,g.permissions)?b:g.permissions);const x=g.plan?{type:"plan",provider:"copilot",...g.plan}:null;r(b=>JSON.stringify(b)===JSON.stringify(x)?b:x)}}catch{}},f=()=>{(typeof document>"u"||document.visibilityState==="visible")&&d()},m=()=>{document.visibilityState==="visible"&&d()};f();const p=setInterval(f,dpe);return document.addEventListener("visibilitychange",m),()=>{u=!0,clearInterval(p),document.removeEventListener("visibilitychange",m)}},[n]);const l=w.useCallback(async(u,d)=>{if(n){i(f=>new Set(f).add(u));try{await r6(n,u,d)&&t(f=>f.filter(m=>m.requestId!==u))}finally{i(f=>{const m=new Set(f);return m.delete(u),m})}}},[n]),c=w.useCallback(async u=>{if(n)try{await afe(n,u)&&t([])}catch{}},[n]);return{requests:e,plan:s,responding:o,respond:l,respondAll:c}}async function ppe(n,e){const t=await ws(`/api/copilot-history/${encodeURIComponent(n)}/preview`,{eventId:e});return t.ok?await t.json():null}async function hpe(n,e,t){const s=await ws(`/api/copilot-history/${encodeURIComponent(n)}/rewind`,{eventId:e,mode:t}),r=await s.json().catch(()=>null);return!s.ok||(r==null?void 0:r.outcome)!=="success"?{ok:!1,error:(r==null?void 0:r.error)||`Copilot rewind failed${r!=null&&r.outcome?`: ${r.outcome}`:""}`}:{ok:!0}}function gpe(n){return n.file_path??n.path??""}function _6(n){const e=[];for(const t of n.toolCalls){if(t.isError||t.awaitingReview||xq(t))continue;const s=gpe(t.input);if(s){if(t.name==="Edit"){const r=t.input.old_string,o=t.input.new_string;r!==void 0&&o!==void 0&&e.push({type:"Edit",filePath:s,oldString:r,newString:o,replaceAll:t.input.replace_all??!1})}else if(t.name==="Write"){const r=t.input.content;r!==void 0&&e.push({type:"Write",filePath:s,content:r})}}}return e}function xpe(n,e){return{index:e,id:n.id,userMessage:cf(n.userMessage),toolCalls:_6(n),thinkingBlocks:n.thinking.map(t=>t.thinking),assistantText:[...n.assistantText],timestamp:n.timestamp,model:n.model}}function Ad(n,e,t){const s=[];for(let r=e;r>t;r--){const o=n[r];if(!o)continue;const i=_6(o);for(let l=i.length-1;l>=0;l--){const c=i[l];c&&(c.type==="Edit"?s.push({type:"reverse-edit",filePath:c.filePath,oldString:c.newString,newString:c.oldString,replaceAll:c.replaceAll,turnIndex:r}):c.type==="Write"&&s.push({type:"delete-write",filePath:c.filePath,content:c.content,turnIndex:r}))}}return s}function bpe(n,e){const t=[];for(const s of n)s.type==="Edit"?t.push({type:"apply-edit",filePath:s.filePath,oldString:s.oldString,newString:s.newString,replaceAll:s.replaceAll,turnIndex:e}):s.type==="Write"&&t.push({type:"create-write",filePath:s.filePath,content:s.content,turnIndex:e});return t}function il(n,e){const t=[],s=e!==void 0?e+1:n.length;for(let r=0;r<s;r++){const o=n[r];o&&t.push(...bpe(o.toolCalls,o.index))}return t}function E6(n,e,t,s,r){var c;const o=[];for(let u=e+1;u<n.length;u++){const d=n[u];d&&o.push(xpe(d,u))}const i=((c=o[0])==null?void 0:c.userMessage)||"Untitled branch",l=i.length>60?i.slice(0,57)+"...":i;return{id:crypto.randomUUID(),createdAt:new Date().toISOString(),branchPointTurnIndex:e,...r!==void 0?{branchPointTurnId:r}:{},label:l,turns:o,jsonlLines:t,...s&&s.length>0?{childBranches:s}:{}}}const vpe=-2;function ype(n,e){const t=new Map(e.map((o,i)=>[o.id,i]));let s=!1;const r=n.map(o=>{const{branchPointTurnId:i}=o;if(i===void 0)return o;const l=i===null?-1:t.get(i)??vpe;return l===o.branchPointTurnIndex?o:(s=!0,{...o,branchPointTurnIndex:l})});return s?r:n}function wpe(n){return(n.childBranches??[]).map(e=>{if(typeof e.branchPointTurnId!="string")return e;const t=n.turns.findIndex(s=>s.id===e.branchPointTurnId);return t<0?e:{...e,branchPointTurnIndex:n.branchPointTurnIndex+1+t}})}function T6(n,e){const t=[],s=[];for(const r of n)r.branchPointTurnIndex>e?s.push(r):t.push(r);return{retained:t,scooped:s}}function Spe(n,e,t){const s=e+t,r=[],o=[];for(const i of n)i.branchPointTurnIndex<=s?r.push(i):o.push(i);return{restored:r,remaining:o}}function kpe(n){const e=new Set(n.map(t=>t.filePath));return{fileCount:e.size,filePaths:[...e],operationCount:n.length}}function jpe(n){return{sessionId:n,branches:[],activeBranchId:null}}function xu(n,e){return{...kpe(n),turnCount:e}}function Npe(n,e,t){return SN(vN(nn(t)),n,e)}function Cpe(n,e,t,s,r,o){var c,u;const i=vN(nn(o)),l=bD(i,n);if(l){const d=e?l.findLastIndex(m=>m.id===e.id):-1;if(d>=0)return{cutoffLine:((c=l[d+1])==null?void 0:c.line)??n.length,branchPointTurnId:l[d].id};const f=t?l.findIndex(m=>m.id===t.id):-1;if(f>=0)return{cutoffLine:l[f].line,branchPointTurnId:((u=l[f-1])==null?void 0:u.id)??null}}return fx(i,n).length>r?null:{cutoffLine:SN(i,n,s),branchPointTurnId:void 0}}class Si extends Error{constructor(){super("abort")}}const A6="Unable to locate the selected turn in the current session file";function P6(n,e,t,s,r){const o=Cpe(t,n.turns[s-1],n.turns[s],s,n.turns.length,e.dirName);if(!o)throw r(A6),new Si;return o}async function _pe(n,e,t,s,r,o,i){var v;const l=n.targetTurnIndex,c=Ad(e.turns,e.turns.length-1,l),u=l+1,d=r.split(`
|
|
460
|
+
`).filter(Boolean),{cutoffLine:f,branchPointTurnId:m}=P6(e,t,d,u,i),p=d.slice(f);if(p.length===0)throw i(A6),new Si;const{retained:h,scooped:g}=T6(s.branches,l),x=E6(e.turns,l,p,g,m),b={...s,branches:[...h,x],activeBranchId:null},y=Ri(t.dirName).fileCheckpoints?(v=e.turns[l+1])==null?void 0:v.id:void 0;await o({operations:c,sessionSource:t,sessionMutation:{type:"truncate",keepLines:f,expectedLineCount:d.length},state:b,...y?{checkpoint:{sessionId:e.sessionId,userMessageId:y,cwd:e.cwd}}:{}})}function I6(n,e,t){var d,f;const s=e+1,r=wpe(n),o=e<n.turns.length-1?Npe(n.jsonlLines,s,t):n.jsonlLines.length,i=n.jsonlLines.slice(0,o),l=n.jsonlLines.slice(o);if(l.length===0)return{restoredLines:i,replacement:r};const{restored:c,remaining:u}=Spe(r,n.branchPointTurnIndex,s);return{restoredLines:i,replacement:[{...n,branchPointTurnIndex:n.branchPointTurnIndex+s,branchPointTurnId:(d=n.turns[s-1])==null?void 0:d.id,turns:n.turns.slice(s),jsonlLines:l,label:((f=n.turns[s])==null?void 0:f.userMessage)||n.label,childBranches:u.length>0?u:void 0},...c]}}async function Epe(n,e,t,s,r,o){const i=n.redoUpToArchiveIndex??s.turns.length-1,{restoredLines:l,replacement:c}=I6(s,i,e.dirName),u=il(s.turns,i),d={...t,branches:[...t.branches.filter(m=>m.id!==s.id),...c],activeBranchId:null},f=r.split(`
|
|
461
|
+
`).filter(Boolean);await o({operations:u,sessionSource:e,sessionMutation:{type:"append",lines:l,expectedLineCount:f.length},state:d})}async function Tpe(n,e,t,s,r,o,i,l){let c=[...t.branches],u=r.split(`
|
|
462
|
+
`).filter(Boolean);const d=[];if(n.turns.length>s.branchPointTurnIndex+1){const g=Ad(n.turns,n.turns.length-1,s.branchPointTurnIndex);d.push(...g);const{retained:x,scooped:b}=T6(c,s.branchPointTurnIndex);c=x;const y=s.branchPointTurnIndex+1,{cutoffLine:v,branchPointTurnId:k}=P6(n,e,u,y,l),j=u.slice(v);if(j.length>0){const _=E6(n.turns,s.branchPointTurnIndex,j,b,k);c=[...c,_],u=u.slice(0,v)}}const f=o.branchTurnIndex??s.turns.length-1,{restoredLines:m,replacement:p}=I6(s,f,e.dirName);d.push(...il(s.turns,f));const h={...t,branches:[...c.filter(g=>g.id!==s.id),...p],activeBranchId:null};await i({operations:d,sessionSource:e,sessionMutation:{type:"splice",keepLines:u.length,lines:m,expectedLineCount:r.split(`
|
|
463
|
+
`).filter(Boolean).length},state:h})}const Ape=[];function $6(n,e,t,s=!0){const[r,o]=w.useState(null),[i,l]=w.useState(null),[c,u]=w.useState(!1),[d,f]=w.useState(null),m=w.useRef(null),p=w.useRef(0);w.useEffect(()=>{if(p.current+=1,!s||!n){o(null),l(null),f(null),m.current=null;return}if(n.sessionId===m.current)return;if(m.current=n.sessionId,!Ri(e==null?void 0:e.dirName).redo){o(null);return}const P=n.sessionId,I=new AbortController;return Re(`/api/undo-state/${encodeURIComponent(P)}`,{signal:I.signal}).then($=>$.ok?$.json():null).then($=>{m.current===P&&o($??null)}).catch($=>{$ instanceof Error&&$.name==="AbortError"||m.current===P&&o(null)}),()=>I.abort()},[s,n==null?void 0:n.sessionId]);const h=w.useCallback(async P=>{try{const I=await Re("/api/undo/transaction",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({operations:P.operations,session:{dirName:P.sessionSource.dirName,fileName:P.sessionSource.fileName,mutation:P.sessionMutation},state:P.state,checkpoint:P.checkpoint})}),$=await I.json().catch(()=>null);if(!I.ok)throw f(($==null?void 0:$.error)||"Undo transaction failed"),new Si;o(P.state)}catch(I){throw I instanceof Si?I:(f(String(I)),new Si)}},[]),g=(r==null?void 0:r.branches)??Ape,x=n==null?void 0:n.turns,b=w.useMemo(()=>x?ype(g,x):g,[g,x]),{canRedo:y,redoTurnCount:v,redoBranch:k}=w.useMemo(()=>{if(!n||b.length===0)return{canRedo:!1,redoTurnCount:0,redoBranch:null};for(let P=b.length-1;P>=0;P--){const I=b[P];if(I.branchPointTurnIndex+1===n.turns.length)return{canRedo:!0,redoTurnCount:I.turns.length,redoBranch:I}}return{canRedo:!1,redoTurnCount:0,redoBranch:null}},[n,b]),j=w.useMemo(()=>{if(!k||k.jsonlLines.length===0)return[];try{return lf(k.jsonlLines.join(`
|
|
464
|
+
`)).turns}catch{return[]}},[k]),_=w.useCallback(P=>b.filter(I=>I.branchPointTurnIndex===P),[b]),N=w.useCallback(P=>{if(!s||!n)return;const I=P-1;if(I>=n.turns.length-1||I<-1)return;if(Ri(e==null?void 0:e.dirName).nativeRewind){const O=n.turns[P];if(!O)return;const M=n.sessionId,R=++p.current,z=()=>p.current===R&&m.current===M,W=O.id.includes("@")?O.id.slice(O.id.lastIndexOf("@")+1):O.id,D=n.turns.length-P;ppe(n.sessionId,W).then(L=>{var B;if(!z())return;const U=((B=L==null?void 0:L.files)==null?void 0:B.map(({path:V})=>V).filter(V=>typeof V=="string"))??[],F=L!=null&&L.available?L.fileCount??U.length:0;l({type:"undo",summary:{turnCount:D,fileCount:F,filePaths:U,operationCount:F},targetTurnIndex:I,nativeRewind:{eventId:W,mode:"conversation",filesAvailable:!!(L!=null&&L.available&&F>0)}})}).catch(()=>{z()&&l({type:"undo",summary:{turnCount:D,fileCount:0,filePaths:[],operationCount:0},targetTurnIndex:I,nativeRewind:{eventId:W,mode:"conversation"}})});return}const $=Ad(n.turns,n.turns.length-1,I);l({type:"undo",summary:xu($,n.turns.length-1-I),targetTurnIndex:I})},[s,n,e==null?void 0:e.dirName]),S=w.useCallback(()=>{if(!s||!y||!k||!n)return;const P=il(k.turns);l({type:"redo",summary:xu(P,k.turns.length),targetTurnIndex:k.branchPointTurnIndex+k.turns.length,branchId:k.id})},[s,y,k,n]),C=w.useCallback(P=>{if(!s||!y||!k||!n)return;const I=P+1,$=il(k.turns,P);l({type:"redo",summary:xu($,I),targetTurnIndex:k.branchPointTurnIndex+I,branchId:k.id,redoUpToArchiveIndex:P})},[s,y,k,n]),E=w.useCallback((P,I)=>{if(!s||!n)return;const $=b.find(z=>z.id===P);if(!$)return;const O=I??$.turns.length-1,M=n.turns.length>$.branchPointTurnIndex+1?Ad(n.turns,n.turns.length-1,$.branchPointTurnIndex):[],R=il($.turns,O);l({type:"branch-switch",summary:xu([...M,...R],O+1),targetTurnIndex:$.branchPointTurnIndex,branchId:P,branchTurnIndex:O})},[s,n,b]),T=w.useCallback(async(P=!1)=>{if(!s||!i||!n||!e){l(null);return}u(!0),f(null);try{if(i.nativeRewind){const M=P&&i.nativeRewind.filesAvailable?"conversation-and-files":"conversation",R=await hpe(n.sessionId,i.nativeRewind.eventId,M);if(!R.ok){f(R.error);return}await t(),l(null);return}const I={...r??jpe(n.sessionId),branches:b},$=await Re(`/api/sessions/${encodeURIComponent(e.dirName)}/${encodeURIComponent(e.fileName)}`);if(!$.ok){f("Failed to read session file");return}const O=await $.text();if(i.type==="undo")await _pe(i,n,e,I,O,h,f);else if(i.type==="redo"){const M=b.find(R=>R.id===i.branchId);if(!M){l(null);return}await Epe(i,e,I,M,O,h)}else if(i.type==="branch-switch"){const M=b.find(R=>R.id===i.branchId);if(!M){l(null);return}await Tpe(n,e,I,M,O,i,h,f)}try{await Re("/api/stop-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:n.sessionId})})}catch{}await t(),l(null)}catch(I){if(!(I instanceof Si))throw I}finally{u(!1)}},[s,i,n,e,r,b,h,t]),A=w.useCallback(()=>{p.current+=1,l(null),f(null)},[]);return{enabled:s,undoState:r,canRedo:y,redoTurnCount:v,redoGhostTurns:j,branches:b,branchesAtTurn:_,requestUndo:N,requestRedoAll:S,requestRedoUpTo:C,requestBranchSwitch:E,confirmState:i,confirmApply:T,confirmCancel:A,isApplying:c,applyError:d}}async function Ppe(n){try{const t=await(await Kr("/api/network-info",{signal:n})).json();return{url:t.enabled&&t.url?t.url:null,disabled:!t.enabled}}catch{return{url:null,disabled:!1}}}async function Ipe(n){const e=await Re("/api/config",{signal:n});if(!e.ok)throw new Error(`Config request failed (${e.status})`);const t=await e.json();return{claudeDir:(t==null?void 0:t.claudeDir)??null,defaultAgentKind:x$(t==null?void 0:t.mode,Go),useBuiltInEditor:(t==null?void 0:t.useBuiltInEditor)===!0}}function $pe(){const n=q.c(26),[e,t]=w.useState(!0),[s,r]=w.useState(null),[o,i]=w.useState(null),[l,c]=w.useState(Go),[u,d]=w.useState(!1),[f,m]=w.useState(null),[p,h]=w.useState(!1),[g,x]=w.useState(0),b=w.useRef(null);let y;n[0]===Symbol.for("react.memo_cache_sentinel")?(y=U=>{i(U.claudeDir),c(U.defaultAgentKind),zO(U.useBuiltInEditor)},n[0]=y):y=n[0];const v=y;let k;n[1]===Symbol.for("react.memo_cache_sentinel")?(k=async()=>{var B;(B=b.current)==null||B.abort();const U=new AbortController;b.current=U;const F=await Ppe(U.signal);U.signal.aborted||b.current!==U||(m(F.url),h(F.disabled))},n[1]=k):k=n[1];const j=k;let _,N;n[2]===Symbol.for("react.memo_cache_sentinel")?(_=()=>()=>{var U;(U=b.current)==null||U.abort()},N=[],n[2]=_,n[3]=N):(_=n[2],N=n[3]),w.useEffect(_,N);let S;n[4]===Symbol.for("react.memo_cache_sentinel")?(S=()=>{const U=new AbortController;return t(!0),r(null),Ipe(U.signal).then(v).catch(F=>{F instanceof Error&&F.name==="AbortError"||(i(null),r(F instanceof Error?F.message:"Failed to load configuration"))}).finally(()=>{U.signal.aborted||t(!1)}),()=>U.abort()},n[4]=S):S=n[4];let C;n[5]!==g?(C=[v,g],n[5]=g,n[6]=C):C=n[6],w.useEffect(S,C);let E,T;n[7]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{const U=()=>x(Lpe);return window.addEventListener("cogpit-auth-changed",U),()=>window.removeEventListener("cogpit-auth-changed",U)},T=[],n[7]=E,n[8]=T):(E=n[7],T=n[8]),w.useEffect(E,T);let A;n[9]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{j()},n[9]=A):A=n[9];let P;n[10]!==o?(P=[o,j],n[10]=o,n[11]=P):P=n[11],w.useEffect(A,P);let I;n[12]===Symbol.for("react.memo_cache_sentinel")?(I=()=>d(!1),n[12]=I):I=n[12];const $=I;let O;n[13]!==o?(O=U=>{if(d(!1),U!==o){i(U),window.location.reload();return}x(Ope),j()},n[13]=o,n[14]=O):O=n[14];const M=O;let R;n[15]===Symbol.for("react.memo_cache_sentinel")?(R=()=>d(!0),n[15]=R):R=n[15];const z=R;let W;n[16]===Symbol.for("react.memo_cache_sentinel")?(W=()=>x(Rpe),n[16]=W):W=n[16];const D=W;let L;return n[17]!==o||n[18]!==s||n[19]!==e||n[20]!==l||n[21]!==M||n[22]!==p||n[23]!==f||n[24]!==u?(L={configLoading:e,configError:s,claudeDir:o,defaultAgentKind:l,setClaudeDir:i,showConfigDialog:u,openConfigDialog:z,handleCloseConfigDialog:$,handleConfigSaved:M,retryConfig:D,networkUrl:f,networkAccessDisabled:p},n[17]=o,n[18]=s,n[19]=e,n[20]=l,n[21]=M,n[22]=p,n[23]=f,n[24]=u,n[25]=L):L=n[25],L}function Rpe(n){return n+1}function Ope(n){return n+1}function Lpe(n){return n+1}const Vk={authenticated:!0,edition:"personal",user:null,capabilities:u1},Fu={authenticated:!1,edition:null,user:null,capabilities:Qi,checked:!1},Mpe=Object.keys(u1);function Hk(n,e){return n!==null&&n.edition===e&&n.authenticated&&(e==="personal"?n.user===null:n.user!==null)&&Mpe.every(t=>{var s;return typeof((s=n.capabilities)==null?void 0:s[t])=="boolean"})}function zpe(n,e){const t={};for(const[s,r]of Object.entries(e))t[s]=r===!0&&n[s]!==!1;return{...Qi,...t}}function Dpe(n){const e=n==null?void 0:n.capabilities;return!n||!e||typeof e.browser=="boolean"?n:{...n,capabilities:{...e,browser:e.hostFiles===!0}}}async function Kk(n,e){try{const t=await n("/api/me",{signal:e});return t.ok?Dpe(await t.json()):null}catch{return null}}async function Fpe(n){try{const e=await Re("/api/hello",{signal:n});if(!e.ok)return null;const t=await e.json();return L3(t.edition)?t.edition:"personal"}catch{return null}}function ui(n,e){return Ha(n,e),_I((e==null?void 0:e.id)??null),n?{...n,checked:!0}:Fu}function Upe(n){const e=q.c(11),[t,s]=w.useState(Fu),[r,o]=w.useState(0),i=w.useRef(null),l=w.useRef(!1);let c;e[0]!==n?(c=()=>{var N;if((N=i.current)==null||N.abort(),n===null){l.current=!1,Ha(null),s(Fu);return}const b=l.current;l.current=!1,Ha(null),s(S=>b?{...S,capabilities:Qi,checked:!1}:Fu);const y=new AbortController;i.current=y;const v=yo(),k=Kk(Kr,y.signal),j=v?Fpe(y.signal):Promise.resolve(n),_=v?Kk(Re,y.signal):Promise.resolve(null);return Promise.all([k,j,_]).then(S=>{const[C,E,T]=S;if(y.signal.aborted)return;const A=Hk(C,n)?C:n==="personal"?Vk:null;if(v&&(A!=null&&A.gate)){Fs(Et);return}if(!A||E===null){s(ui(null,null));return}if(!v){s(ui(A,A.user));return}const P=Hk(T,E)?T:E==="personal"?Vk:null;if(!P){s(ui(null,null));return}s(ui({authenticated:P.authenticated,edition:P.edition,user:P.user,capabilities:zpe(A.capabilities,P.capabilities),...P.enforcesSessionAccess&&{enforcesSessionAccess:!0},...P.gate&&{gate:P.gate}},A.user))}).catch(()=>{y.signal.aborted||s(ui(null,null))}),()=>{y.abort(),i.current===y&&(i.current=null)}},e[0]=n,e[1]=c):c=e[1];let u;e[2]!==n||e[3]!==r?(u=[n,r],e[2]=n,e[3]=r,e[4]=u):u=e[4],w.useEffect(c,u);let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{var b;(b=i.current)==null||b.abort(),l.current=!0,Ha(null),s(qpe),o(Wpe)},e[5]=d):d=e[5];const f=d;let m,p;e[6]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{const b=()=>{var v;(v=i.current)==null||v.abort(),l.current=!1,s(ui(null,null)),o(Bpe)},y=v=>{var _;const k=Dt();if(k===Et)return;const j=(_=v.detail)==null?void 0:_.deviceId;j&&j!==k||f()};return window.addEventListener("cogpit-auth-changed",b),window.addEventListener("cogpit-devices-changed",y),()=>{window.removeEventListener("cogpit-auth-changed",b),window.removeEventListener("cogpit-devices-changed",y)}},p=[f],e[6]=m,e[7]=p):(m=e[6],p=e[7]),w.useEffect(m,p);const h=t.checked&&!t.gate;let g,x;return e[8]!==h?(g=()=>{if(h)return VI(f)},x=[h,f],e[8]=h,e[9]=g,e[10]=x):(g=e[9],x=e[10]),w.useEffect(g,x),t}function Bpe(n){return n+1}function Wpe(n){return n+1}function qpe(n){return{...n,capabilities:Qi,checked:!1}}const Vpe=3e4;function Hpe(n){const[e,t]=w.useState(()=>({dirName:n,worktrees:[],loading:n!==null,error:null})),s=w.useRef(0),r=w.useCallback(async()=>{if(!n)return;const i=++s.current;t(l=>l.dirName===n&&l.loading?l:{dirName:n,worktrees:l.dirName===n?l.worktrees:[],loading:!0,error:l.dirName===n?l.error:null});try{const l=await Re(`/api/worktrees/${encodeURIComponent(n)}`);if(i!==s.current)return;if(l.ok){const c=await l.json();if(i!==s.current)return;t({dirName:n,worktrees:c,loading:!1,error:null});return}t(c=>c.dirName===n?{...c,loading:!1,error:"Failed to fetch worktrees"}:c)}catch(l){if(i!==s.current)return;t(c=>c.dirName===n?{...c,loading:!1,error:l instanceof Error?l.message:"Unknown error"}:c)}},[n]);w.useEffect(()=>{if(!n){s.current+=1;return}r();const i=setInterval(()=>void r(),Vpe);return()=>{clearInterval(i),s.current+=1}},[n,r]);const o=e.dirName===n?e:{worktrees:[],loading:n!==null,error:null};return{worktrees:o.worktrees,loading:o.loading,error:o.error,refetch:r}}function Kpe(){const n=q.c(3),[e,t]=w.useState(!1);let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=async()=>{t(!0);try{await Re("/api/kill-all",{method:"POST"})}catch{}setTimeout(()=>t(!1),1500)},n[0]=s):s=n[0];const r=s;let o;return n[1]!==e?(o={killing:e,handleKillAll:r},n[1]=e,n[2]=o):o=n[2],o}function Gpe(n,e){return n?`${n}.jsonl`:e??null}async function R6(n){await L6(n);try{const e=await Re(`/api/session-config/${encodeURIComponent(n)}`);if(!e.ok)return null;const t=await e.json();return t&&typeof t=="object"?t:null}catch{return null}}const Zpe=300,al=new Map,qa=new Map;function Ype(n,e,t){const s=(qa.get(n)??Promise.resolve(!0)).then(async()=>{try{return(await ws(`/api/session-config/${encodeURIComponent(e)}`,t,{method:"PUT"})).ok}catch{return!1}});return qa.set(n,s),s.then(()=>{qa.get(n)===s&&qa.delete(n)}),s}function Xpe(){let n;return{stored:new Promise(t=>{n=t}),answer:n}}function O6(n,e,t){clearTimeout(t.timer),al.delete(n);const s=Ype(n,e,t.patch);return s.then(t.answer),s}async function L6(n){const e=gn(n),t=al.get(e);await(t?O6(e,n,t):qa.get(e))}function qg(n,e){const t=gn(n),s=al.get(t);s&&clearTimeout(s.timer);const{stored:r,answer:o}=s??Xpe(),i={patch:s?{...s.patch,...e}:e,stored:r,answer:o,timer:setTimeout(()=>{gn(n)===t?O6(t,n,i):(al.delete(t),i.answer(!1))},Zpe)};return al.set(t,i),r}function Vg(n){return new Set(n.filter(e=>e.status==="connected").map(e=>e.name))}async function Gk(n){const e=await R6(n);return Array.isArray(e==null?void 0:e.mcpServers)?e.mcpServers:null}function gh(n,e){qg(n,{mcpServers:e})}async function Jpe(n){if(!n.ok)return null;const e=await n.json();return{servers:e.servers??[],configs:e.configs??{}}}async function Zk(n,e){try{const t=await Re(n,{signal:e});if(e.aborted)return null;const s=await Jpe(t);return e.aborted?null:s}catch{return null}}async function Yk(n,e,t){const s=Vg(t);if(s.size===0)return[];if(n){const r=await Gk(n);if(r)return r.filter(o=>s.has(o))}if(e&&n!==e){const r=await Gk(e);if(r)return r.filter(o=>s.has(o))}return[...s]}function Qpe(n,e,t,s=!0){const[r,o]=w.useState([]),[i,l]=w.useState({}),[c,u]=w.useState([]),[d,f]=w.useState(!1),[m,p]=w.useState(!1),h=w.useRef(null),g=w.useRef(e);g.current=e;const x=t??e??null,b=w.useRef(x);b.current=x;const y=w.useRef(void 0);w.useEffect(()=>{var S,C;if(!s||!n){(S=h.current)==null||S.abort(),y.current=void 0,o([]),l({}),u([]),f(!1),p(!1);return}const N=new AbortController;return(C=h.current)==null||C.abort(),o([]),l({}),u([]),f(!0),p(!1),y.current=n,Zk(`/api/mcp-servers?cwd=${encodeURIComponent(n)}`,N.signal).then(async E=>{if(N.signal.aborted||y.current!==n||!E)return;o(E.servers),l(E.configs);const T=await Yk(b.current,g.current,E.servers);N.signal.aborted||y.current!==n||u(T)}).finally(()=>{N.signal.aborted||y.current!==n||(f(!1),p(!0))}),()=>N.abort()},[n,s]),w.useEffect(()=>()=>{var N;return(N=h.current)==null?void 0:N.abort()},[]),w.useEffect(()=>{if(r.length===0||!x)return;let N=!1;return Yk(x,e,r).then(S=>{N||b.current!==x||u(S)}),()=>{N=!0}},[x]);const v=w.useCallback(N=>{u(S=>{const C=S.includes(N)?S.filter(E=>E!==N):[...S,N];return b.current&&gh(b.current,C),C})},[]),k=w.useCallback(N=>{u(()=>(b.current&&gh(b.current,N),N))},[]),j=w.useCallback(()=>{var S;if(!s||!n)return;(S=h.current)==null||S.abort();const N=new AbortController;h.current=N,f(!0),Zk(`/api/mcp-servers?cwd=${encodeURIComponent(n)}&refresh=1`,N.signal).then(C=>{if(N.signal.aborted||y.current!==n||!C)return;o(C.servers),l(C.configs);const E=Vg(C.servers);u(T=>{const A=T.filter(P=>E.has(P));return b.current&&gh(b.current,A),A})}).finally(()=>{N.signal.aborted||h.current!==N||f(!1)})},[n,s]),_=w.useMemo(()=>{if(r.length===0)return null;const N=Vg(r);if(c.length===N.size&&N.size>0&&c.every(E=>N.has(E))||!c.every(E=>i[E]))return null;const C=Object.fromEntries(c.map(E=>[E,i[E]]));return JSON.stringify({mcpServers:C})},[c,i,r]);return{servers:r,selectedServers:c,mcpConfigJson:_,loading:d,loaded:m,toggleServer:v,setSelection:k,refresh:j}}function ehe(n){var s,r;const e=q.c(12);let t;e:{if(!n){t=null;break e}let o=null,i;if(e[0]!==o||e[1]!==n.turns){const p=new Map;let h=0;for(const g of n.turns)for(const x of g.toolCalls){if(x.name==="TodoWrite"){const b=x.input;Array.isArray(b.todos)&&(o=b.todos);continue}if(x.name==="TaskCreate"){const b=x.input;h=h+1;const v=((r=(s=x.result)==null?void 0:s.match(/(?:Task\s*#?|task[_ ]?id["': ]+)(\d+)/i))==null?void 0:r[1])??String(h);p.set(v,{id:v,content:b.subject||b.description||`Task ${v}`,activeForm:b.activeForm||b.subject||`Working on task ${v}`,status:"pending",owner:b.owner});continue}if(x.name==="TaskUpdate"){const b=x.input,y=String(b.taskId??"");if(!y)continue;if(b.status==="deleted"){p.delete(y);continue}const v=p.get(y)??{id:y,content:b.subject||b.description||`Task ${y}`,activeForm:b.activeForm||b.subject||`Working on task ${y}`,status:"pending"};p.set(y,{...v,content:b.subject||b.description||v.content,activeForm:b.activeForm||v.activeForm,status:b.status||v.status,owner:b.owner??v.owner,blockedBy:b.addBlockedBy?[...new Set([...v.blockedBy??[],...b.addBlockedBy])]:v.blockedBy})}}i=p.size>0?[...p.values()]:o,e[0]=o,e[1]=n.turns,e[2]=i,e[3]=o}else i=e[2],o=e[3];const l=i;if(!l||l.length===0){t=null;break e}let c;e[4]!==l?(c=l.filter(nhe),e[4]=l,e[5]=c):c=e[5];const u=c.length;let d;e[6]!==l?(d=l.find(the)??null,e[6]=l,e[7]=d):d=e[7];const f=d;let m;e[8]!==u||e[9]!==f||e[10]!==l?(m={todos:l,completed:u,total:l.length,inProgress:f},e[8]=u,e[9]=f,e[10]=l,e[11]=m):m=e[11],t=m}return t}function the(n){return n.status==="in_progress"}function nhe(n){return n.status==="completed"}function she(n){const e=q.c(4);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0];const[s,r]=w.useState(t);let o,i;return e[1]!==n?(o=()=>{if(!n){r([]);return}let l=!1;const c=async function(){try{const f=await Re(`/api/background-agents?cwd=${encodeURIComponent(n)}`);if(l)return;if(f.ok){const m=await f.json();r(m)}}catch{}};c();const u=setInterval(c,5e3);return()=>{l=!0,clearInterval(u)}},i=[n],e[1]=n,e[2]=o,e[3]=i):(o=e[2],i=e[3]),w.useEffect(o,i),s}function rhe(n,e){const t=q.c(8),s=e===void 0?!0:e;let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=[],t[0]=r):r=t[0];const[o,i]=w.useState(r),[l,c]=w.useState(!1),u=w.useRef(void 0);let d,f;t[1]!==n||t[2]!==s?(d=()=>{if(!s){u.current=void 0,i([]),c(!1);return}if(u.current===n)return;u.current=n,c(!0);const p=n?`?cwd=${encodeURIComponent(n)}`:"";Re(`/api/slash-suggestions${p}`).then(ohe).then(h=>i(h.suggestions||[])).catch(()=>i([])).finally(()=>c(!1))},f=[n,s],t[1]=n,t[2]=s,t[3]=d,t[4]=f):(d=t[3],f=t[4]),w.useEffect(d,f);let m;return t[5]!==l||t[6]!==o?(m={suggestions:o,loading:l},t[5]=l,t[6]=o,t[7]=m):m=t[7],m}function ohe(n){return n.json()}function Xk(n,e){const t=q.c(6),[s,r]=oa(n,e),o=typeof s=="boolean"?s:e;let i;t[0]!==e||t[1]!==r?(i=u=>{r(d=>typeof u=="function"?u(typeof d=="boolean"?d:e):u)},t[0]=e,t[1]=r,t[2]=i):i=t[2];const l=i;let c;return t[3]!==l||t[4]!==o?(c=[o,l],t[3]=l,t[4]=o,t[5]=c):c=t[5],c}const Jk={config:{type:"CLOSE_CONFIG"},mission:{type:"CLOSE_MISSION"},extension:{type:"CLOSE_EXTENSION_VIEW"}};function Qk(){if(typeof window>"u")return zt.fileChanges;try{if(JSON.parse(localStorage.getItem("panel-worktrees-visible")??"false")===!0)return zt.worktrees;if(JSON.parse(localStorage.getItem("panel-stats-visible")??"false")===!0)return zt.sessionInfo;if(JSON.parse(localStorage.getItem("panel-file-changes-visible")??"true")===!1)return null}catch{}return zt.fileChanges}function ihe(n,e){const t=q.c(53),[s,r]=Xk("panel-sidebar-visible",!0),[o,i]=Xk("panel-workflows-visible",!1);let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l=Qk(),t[0]=l):l=t[0];const[c,u]=oa("workspace-panel-active",l);let d;t[1]!==c?(d=typeof c=="string"||c===null?c:Qk(),t[1]=c,t[2]=d):d=t[2];const f=d,[m,p]=w.useState(!1),[h,g]=w.useState(!1),{mainView:x}=n;let b;t[3]!==r||t[4]!==s?(b=()=>{w.startTransition(()=>r(!s))},t[3]=r,t[4]=s,t[5]=b):b=t[5];const y=b;let v;t[6]!==e||t[7]!==x||t[8]!==u?(v=te=>{w.startTransition(()=>{const J=x!=="sessions";J&&e(Jk[x]),u(ne=>J||c2(ne)!==c2(te)?te:null)})},t[6]=e,t[7]=x,t[8]=u,t[9]=v):v=t[9];const k=v;let j;t[10]!==e||t[11]!==x||t[12]!==u?(j=te=>{w.startTransition(()=>{x!=="sessions"&&e(Jk[x]),u(te)})},t[10]=e,t[11]=x,t[12]=u,t[13]=j):j=t[13];const _=j;let N;t[14]!==u?(N=()=>{w.startTransition(()=>u(null))},t[14]=u,t[15]=N):N=t[15];const S=N;let C;t[16]!==e||t[17]!==x?(C=()=>{const te=x==="config";w.startTransition(()=>{e({type:te?"CLOSE_CONFIG":"OPEN_CONFIG"})})},t[16]=e,t[17]=x,t[18]=C):C=t[18];const E=C;let T;t[19]!==e||t[20]!==x?(T=()=>{const te=x==="mission";w.startTransition(()=>{e({type:te?"CLOSE_MISSION":"OPEN_MISSION"})})},t[19]=e,t[20]=x,t[21]=T):T=t[21];const A=T;let P;t[22]!==e?(P=te=>{w.startTransition(()=>e({type:"OPEN_EXTENSION_VIEW",id:te}))},t[22]=e,t[23]=P):P=t[23];const I=P;let $;t[24]!==e?($=()=>{w.startTransition(()=>e({type:"CLOSE_EXTENSION_VIEW"}))},t[24]=e,t[25]=$):$=t[25];const O=$,M=m1();let R;t[26]===Symbol.for("react.memo_cache_sentinel")?(R=new Set,t[26]=R):R=t[26];const z=w.useRef(R),W=w.useRef(!1);let D,L;t[27]!==M||t[28]!==I?(D=()=>{var J;if(W.current)return;const te=z.current;for(const ne of M)if(!te.has(ne.id)&&(te.add(ne.id),(J=ne.openOnStart)!=null&&J.call(ne))){W.current=!0,I(ne.id);return}},L=[M,I],t[27]=M,t[28]=I,t[29]=D,t[30]=L):(D=t[29],L=t[30]),w.useEffect(D,L);let U;t[31]!==e?(U=te=>{w.startTransition(()=>{e({type:"OPEN_CONFIG",filePath:te})})},t[31]=e,t[32]=U):U=t[32];const F=U;let B;t[33]===Symbol.for("react.memo_cache_sentinel")?(B=()=>p(!0),t[33]=B):B=t[33];const V=B;let H;t[34]===Symbol.for("react.memo_cache_sentinel")?(H=()=>p(!1),t[34]=H):H=t[34];const K=H;let Z;t[35]===Symbol.for("react.memo_cache_sentinel")?(Z=()=>g(ahe),t[35]=Z):Z=t[35];const Y=Z;let X;t[36]===Symbol.for("react.memo_cache_sentinel")?(X=()=>g(!1),t[36]=X):X=t[36];const se=X;let Q;return t[37]!==f||t[38]!==O||t[39]!==S||t[40]!==F||t[41]!==E||t[42]!==A||t[43]!==y||t[44]!==I||t[45]!==_||t[46]!==i||t[47]!==m||t[48]!==s||t[49]!==h||t[50]!==o||t[51]!==k?(Q={showSidebar:s,showWorkflows:o,activeWorkspacePanel:f,showProjectSwitcher:m,showThemeSelector:h,handleToggleSidebar:y,toggleWorkspacePanel:k,openWorkspacePanel:_,closeWorkspacePanel:S,handleToggleConfig:E,handleToggleMission:A,openMainView:I,closeMainView:O,handleEditConfig:F,handleOpenProjectSwitcher:V,handleCloseProjectSwitcher:K,handleToggleThemeSelector:Y,handleCloseThemeSelector:se,setShowWorkflows:i},t[37]=f,t[38]=O,t[39]=S,t[40]=F,t[41]=E,t[42]=A,t[43]=y,t[44]=I,t[45]=_,t[46]=i,t[47]=m,t[48]=s,t[49]=h,t[50]=o,t[51]=k,t[52]=Q):Q=t[52],Q}function ahe(n){return!n}async function lhe(n,e){let t;try{t=await ws("/api/delete-session",{dirName:n,fileName:e})}catch{return Bn.error("Could not delete session"),!1}return t.ok||t.status===404?!0:(Bn.error(await Ja(t,"Could not delete session")),!1)}function che(n){var se;const{state:e,dispatch:t,isMobile:s,handleJumpToTurn:r,markPermissionsApplied:o,hasPermsPendingChanges:i,permissionsConfig:l,settingsChange:c,onSettingsChangeSent:u,selectedModel:d,selectedEffort:f,fastMode:m,ultracode:p,mcpConfig:h,scrollRequestScrollToTop:g,handleDashboardSelect:x,workerParse:b,canInteract:y}=n,v=w.useCallback(async()=>{if(!e.sessionSource)return;const{dirName:Q,fileName:te}=e.sessionSource;try{const{parsed:J,source:ne}=await S6(Q,te,b,"session");t({type:"RELOAD_SESSION_CONTENT",session:J,source:ne})}catch{}},[e.sessionSource,t,b]),[k,j]=w.useState(null),_=w.useCallback(Q=>j(Q),[]),N=w.useCallback(()=>j(null),[]),S=w.useCallback(async Q=>{try{const te=await Re("/api/branch-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Q)});if(!te.ok)return;const J=await te.json();mC(J.sessionId);const{parsed:ne,source:re}=await Gi(J.dirName,J.fileName,b,"session");t({type:"LOAD_SESSION",session:ne,source:re,isMobile:s})}catch{}},[t,s,b]),C=w.useCallback((Q,te)=>S({dirName:Q,fileName:te}),[S]),E=w.useCallback(()=>{e.sessionSource&&C(e.sessionSource.dirName,e.sessionSource.fileName)},[e.sessionSource,C]),T=w.useCallback((Q,te)=>{const J=lhe(Q,te),ne=b$(Q,te);return ne?e$(ne,J):J},[]),A=w.useCallback(async Q=>{var re,le;if(!e.sessionSource)return;const{dirName:te,fileName:J}=e.sessionSource,ne=(le=(re=e.session)==null?void 0:re.turns[Q])==null?void 0:le.id;await S({dirName:te,fileName:J,turnIndex:Q,turnUuid:ne})},[e.sessionSource,e.session,S]),P=w.useCallback((Q,te)=>{r(Q,te),t({type:"SET_MOBILE_TAB",tab:"chat"})},[r,t]),[I,$]=w.useState({}),O=w.useRef(d);O.current=d;const M=w.useRef(f);M.current=f;const R=w.useRef(h);R.current=h;const z=w.useRef(m);z.current=m;const W=w.useRef(p);W.current=p;const D=w.useRef(l);D.current=l;const L=w.useRef(c);L.current=c;const U=w.useRef(u);U.current=u;const F=((se=e.session)==null?void 0:se.sessionId)??null,B=w.useRef(null);w.useEffect(()=>{F!==B.current&&(B.current=F,F&&$(Q=>F in Q?Q:{...Q,[F]:{model:O.current,effort:M.current,fastMode:z.current,ultracode:W.current,mcpConfig:R.current}}))},[F]);const V=F?I[F]:void 0,H=h!==((V==null?void 0:V.mcpConfig)??null),K=V!=null&&(d!==V.model||f!==V.effort||m!==V.fastMode||p!==V.ultracode||i||H),Z=w.useCallback(async()=>{var ie,fe;if(!F||!y)return;const Q=O.current,te=M.current,J=z.current,ne=W.current,re=R.current,le=D.current,ae=L.current,ue=U.current,oe=((ie=e.sessionSource)==null?void 0:ie.agentKind)??nn(((fe=e.sessionSource)==null?void 0:fe.dirName)??null);xn(oe).settingsApply==="live"&&(await Re(`/api/claude/settings/${encodeURIComponent(F)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:Q,effort:te,fastMode:J,ultracode:ne,mcpConfig:re,...le&&{permissionMode:le.mode,allowedTools:le.allowedTools,disallowedTools:le.disallowedTools},...ae.length>0&&{settingsChange:ae}})})).ok&&ae.length>0&&ue(),$(de=>({...de,[F]:{model:Q,effort:te,fastMode:J,ultracode:ne,mcpConfig:re}})),o()},[F,y,e.sessionSource,o]),Y=w.useCallback(async()=>{if(!(!F||!y))try{await Re("/api/stop-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:F})})}catch{}},[F,y]),X=w.useCallback((Q,te)=>{lo(te)&&g(),x(Q,te)},[g,x]);return{reloadSession:v,branchModalTurn:k,setBranchModalTurn:j,handleOpenBranches:_,handleCloseBranchModal:N,handleDuplicateSessionByPath:C,handleDuplicateSession:E,handleDeleteSession:T,handleBranchFromHere:A,handleMobileJumpToTurn:P,hasSettingsChanges:K,handleApplySettings:Z,handleStopSession:Y,handleLoadSessionScrollAware:X}}function M6(){const n=q.c(6),e=w.useRef(null);let t;n[0]===Symbol.for("react.memo_cache_sentinel")?(t=new Map,n[0]=t):t=n[0];const s=w.useRef(t),r=w.useRef(0);let o,i;n[1]===Symbol.for("react.memo_cache_sentinel")?(o=()=>{const m=s.current,p=new Worker(new URL("/assets/session-parser.worker-CkTPpg3t.js",import.meta.url),{type:"module"});return p.onmessage=h=>{const g=h.data,x=m.get(g.id);x&&(m.delete(g.id),g.type==="result"?x.resolve(g.session):x.reject(new Error(g.error)))},p.onerror=h=>{for(const[,g]of m)g.reject(new Error(`Worker error: ${h.message}`));m.clear()},e.current=p,()=>{p.terminate(),e.current=null;for(const[,h]of m)h.reject(new Error("Worker terminated"));m.clear()}},i=[],n[1]=o,n[2]=i):(o=n[1],i=n[2]),w.useEffect(o,i);let l;n[3]===Symbol.for("react.memo_cache_sentinel")?(l=m=>{const p=e.current;return p?new Promise((h,g)=>{r.current=r.current+1;const x=r.current;s.current.set(x,{resolve:h,reject:g}),p.postMessage({type:"parse",id:x,text:m})}):Promise.resolve().then(()=>lf(m))},n[3]=l):l=n[3];const c=l;let u;n[4]===Symbol.for("react.memo_cache_sentinel")?(u=(m,p)=>{const h=e.current;return h?new Promise((g,x)=>{r.current=r.current+1;const b=r.current;s.current.set(b,{resolve:g,reject:x}),h.postMessage({type:"append",id:b,existing:m,newText:p})}):Promise.resolve().then(()=>CD(m,p))},n[4]=u):u=n[4];const d=u;let f;return n[5]===Symbol.for("react.memo_cache_sentinel")?(f={parse:c,append:d},n[5]=f):f=n[5],f}const uhe=30;function z6({dirName:n,fileName:e,sessionChangeKey:t,workerParse:s,onOlderTurns:r}){const[o,i]=w.useState(!1),[l,c]=w.useState(!1),u=w.useRef(""),d=w.useRef(null),f=`${n??""}::${e??""}::${t}`;return w.useEffect(()=>{u.current=f,d.current=null,c(!1);const p=n&&e?hs.get(n,e):void 0;i((p==null?void 0:p.hasMore)??!1),p&&p.olderTurns.length>0&&r(p.olderTurns)},[f,n,e,t,r]),{loadMore:w.useCallback(async()=>{if(!n||!e||d.current)return 0;const p=`${n}::${e}::${t}`,h=hs.get(n,e);if(!(h!=null&&h.hasMore))return u.current===p&&i(!1),0;const g=Symbol("paging-flight");d.current=g,c(!0);try{const x=await Re(`/api/sessions/${encodeURIComponent(n)}/${encodeURIComponent(e)}?before=${h.nextByteOffset}&count=${uhe}`);if(!x.ok)return 0;const b=await x.json(),y=b.lines.length>0&&b.hasMore;if(u.current===p&&i(y),b.lines.length===0)return hs.update(n,e,{hasMore:y,nextByteOffset:b.byteOffset}),0;const v=new Set(b.headerLines),k=b.lines.filter(N=>!v.has(N)),j=await s([...b.headerLines,...k].join(`
|
|
465
|
+
`)),_=e5(h.olderTurns,j.turns,h.source.agentKind);return hs.update(n,e,{hasMore:y,nextByteOffset:b.byteOffset,olderTurns:_}),u.current!==p?0:(r(_),j.turns.length)}finally{d.current===g&&(d.current=null,u.current===p&&c(!1))}},[n,e,t,s,r]),hasMore:o,isLoadingOlder:l}}function dhe(n){const e=q.c(47),{agentKind:t,session:s,sessionSource:r,pendingDirName:o,isLive:i}=n,l=t??Go,[c,u]=w.useState(""),[d,f]=w.useState(""),[m,p]=w.useState(null),[h,g]=w.useState(!1),[x,b]=w.useState(!1),{options:y,fastTier:v,imageInput:k,normalizeEffort:j}=dj(l,c),_=c||(s==null?void 0:s.model);let N;e[0]!==l||e[1]!==_?(N=O$(l,_),e[0]=l,e[1]=_,e[2]=N):N=e[2];const S=N,C=x&&S;let E;e[3]!==j||e[4]!==d||e[5]!==C?(E=C?"xhigh":j(d),e[3]=j,e[4]=d,e[5]=C,e[6]=E):E=e[6];const T=E,A=!!v,P=A&&h,[I,$]=w.useState(null),O=w.useRef(null),M=(r==null?void 0:r.fileName)??null,R=w.useRef(M);let z,W;e[7]!==M?(z=()=>{const ne=R.current;R.current=M,!(ne===null||ne===M)&&(b(!1),p(null))},W=[M],e[7]=M,e[8]=z,e[9]=W):(z=e[8],W=e[9]),w.useEffect(z,W);let D,L;e[10]!==o?(D=()=>{o&&(b(!1),p(null))},L=[o],e[10]=o,e[11]=D,e[12]=L):(D=e[11],L=e[12]),w.useEffect(D,L);let U;e[13]!==l?(U=ne=>{u(re=>re===ne?"":re),$(`${ne} is unavailable for this account. Cogpit retried the turn with ${us(l).displayName}'s default model.`)},e[13]=l,e[14]=U):U=e[14];const F=U;let B;e[15]===Symbol.for("react.memo_cache_sentinel")?(B=()=>{$(null)},e[15]=B):B=e[15];const V=B;let H,K;e[16]!==y||e[17]!==o||e[18]!==c||e[19]!==r?(H=()=>{c&&(!r&&!o||y.some(ne=>ne.value===c)||u(""))},K=[y,c,r,o],e[16]=y,e[17]=o,e[18]=c,e[19]=r,e[20]=H,e[21]=K):(H=e[20],K=e[21]),w.useEffect(H,K);let Z,Y;e[22]!==I?(Z=()=>{if(!I)return;const ne=setTimeout(()=>$(null),12e3);return()=>clearTimeout(ne)},Y=[I],e[22]=I,e[23]=Z,e[24]=Y):(Z=e[23],Y=e[24]),w.useEffect(Z,Y);const X=s==null?void 0:s.rawMessages;let se,Q;e[25]!==l||e[26]!==i||e[27]!==X?(se=()=>{if(!i||!X||!xn(l).modelFallbackNotices)return;let ne;for(let oe=X.length-1;oe>=0;oe=oe-1,oe){const ie=X[oe];if(ie.type==="system"&&ie.subtype==="model_refusal_fallback"){ne=ie;break}}if(!ne)return;const re=typeof ne.uuid=="string"?ne.uuid:`${String(ne.original_model)}:${String(ne.fallback_model)}:${String(ne.request_id)}`;if(O.current===re)return;O.current=re;const le=typeof ne.original_model=="string"?ne.original_model:"Fable",ae=typeof ne.fallback_model=="string"?ne.fallback_model:"Opus",ue=typeof ne.api_refusal_explanation=="string"?` ${ne.api_refusal_explanation}`:"";$(`${le} could not handle this request, so Claude continued with ${ae}.${ue}`)},Q=[i,X,l],e[25]=l,e[26]=i,e[27]=X,e[28]=se,e[29]=Q):(se=e[28],Q=e[29]),w.useEffect(se,Q);let te;e[30]!==l?(te=xn(l),e[30]=l,e[31]=te):te=e[31];let J;return e[32]!==m||e[33]!==T||e[34]!==P||e[35]!==A||e[36]!==h||e[37]!==F||e[38]!==k||e[39]!==I||e[40]!==d||e[41]!==c||e[42]!==te.configurableContextWindow||e[43]!==C||e[44]!==S||e[45]!==x?(J={contextWindowTokens:m,setContextWindowTokens:p,contextWindowAvailable:te.configurableContextWindow,selectedModel:c,setSelectedModel:u,selectedEffort:d,setSelectedEffort:f,fastModeEnabled:h,ultracodeEnabled:x,effectiveEffort:T,fastModeAvailable:A,fastModeActive:P,setFastModeEnabled:g,ultracodeAvailable:S,ultracodeActive:C,setUltracodeEnabled:b,imageInputAvailable:k,modelFallbackNotice:I,dismissModelFallbackNotice:V,handleModelRejected:F},e[32]=m,e[33]=T,e[34]=P,e[35]=A,e[36]=h,e[37]=F,e[38]=k,e[39]=I,e[40]=d,e[41]=c,e[42]=te.configurableContextWindow,e[43]=C,e[44]=S,e[45]=x,e[46]=J):J=e[46],J}const Ti=["permissionMode","model","effort","contextWindowTokens","fastMode","ultracode"];function fhe(n){return Ti.some(e=>e===n)}function mhe(n){return JSON.stringify(n,[...Ti])}function Ca(n,e){return Ti.filter(t=>n[t]!==e[t])}function bu(n,e){const t={};for(const s of e)Object.assign(t,{[s]:n[s]});return t}function phe(n,e){return{model:n.model??e.model,effort:n.effort??e.effort,contextWindowTokens:n.contextWindowTokens??null,fastMode:n.fastMode??e.fastMode,ultracode:n.ultracode??e.ultracode,permissionMode:n.permissionMode??e.permissionMode}}function hhe({sessionKey:n,sessionId:e,values:t,access:s,onHydrate:r}){const[o,i]=w.useState(null),l=w.useRef(null),c=w.useRef(0),u=w.useRef(r);u.current=r;const d=w.useRef(t);d.current=t;const f=w.useRef(s);f.current=s;const m=w.useCallback((y,v)=>{const k=l.current;if((k==null?void 0:k.key)!==y||!Ki(f.current).configure)return;const j=Ca(k.values,v);if(j.length===0)return;const _=bu(v,j);l.current={key:y,values:v},qg(y,_).then(N=>{N&&i(S=>(S==null?void 0:S.key)===y?{key:y,values:{...S.values,..._}}:S)})},[]),p=w.useCallback(y=>{var _;const v=++c.current,k=d.current,j=((_=l.current)==null?void 0:_.key)===y?l.current.values:null;R6(y).then(N=>{if(v!==c.current||N===null)return;const S=d.current,C=Ki(f.current).configure;if(!Ti.some(P=>N[P]!==void 0)){if(l.current={key:y,values:S},i({key:y,values:S}),!C)return;const P=f.current==="own"?Ti:Ti.filter(I=>I!=="permissionMode");qg(y,bu(S,P));return}const E=phe(N,j??S),T=j?[...new Set([...Ca(j,k),...Ca(k,S)])]:[],A={...E,...bu(S,T)};(!j||Ca(S,A).length>0)&&u.current({...N,...bu(S,T)}),l.current={key:y,values:E},i({key:y,values:E}),m(y,A)})},[m]);w.useEffect(()=>{var y;if(((y=l.current)==null?void 0:y.key)!==n&&(l.current=null),!!n)return p(n),()=>{c.current+=1}},[n,s,p]),w.useEffect(()=>{if(!n)return;const y=()=>p(n),v=e?Z9(e,y):void 0;let k=document.visibilityState==="hidden";function j(){k&&(k=!1,y())}function _(){document.visibilityState==="hidden"?k=!0:j()}return document.addEventListener("visibilitychange",_),window.addEventListener("focus",j),()=>{v==null||v(),document.removeEventListener("visibilitychange",_),window.removeEventListener("focus",j)}},[n,e,p]);const h=mhe(t);w.useEffect(()=>{n&&m(n,d.current)},[h,n,m]);const g=(o==null?void 0:o.key)===n?Ca(o.values,t).join():"",x=w.useMemo(()=>g.split(",").filter(fhe),[g]),b=w.useCallback(()=>{n&&L6(n)},[n]);return{picked:x,settlePicked:b}}function ghe(n){const[e,t]=w.useState(new Map),[s,r]=w.useState(null),[o,i]=w.useState(!0),l=w.useRef(new Map),c=w.useRef(null);w.useEffect(()=>{const x=n??null,b=c.current;if(b&&b!==x&&l.current.set(b,{activeId:s,collapsed:o}),x!==b){const y=x?l.current.get(x):null;y?(r(y.activeId),i(y.collapsed)):(r(null),i(!0))}c.current=x},[n]);const u=w.useCallback(()=>i(x=>!x),[]),d=w.useCallback(x=>{t(b=>{const y=new Map(b);return y.set(x.id,x),y}),r(x.id),i(!1)},[]),f=w.useCallback(x=>{t(b=>{const y=new Map(b);return y.delete(x),r(v=>{if(v!==x)return v;const k=[...y.keys()];return k.length>0?k[k.length-1]:null}),y})},[]),m=w.useCallback(x=>{r(x),i(!1)},[]),p=w.useCallback((x,b)=>{t(y=>{const v=y.get(x);if(!v||v.status===b)return y;const k=new Map(y);return k.set(x,{...v,status:b}),k})},[]),h=w.useCallback(x=>{t(b=>{let y=!1;const v=new Map(b),k=new Set(x.map(j=>j.id));for(const[j,_]of v)_.type==="task"&&!k.has(j)&&(v.delete(j),y=!0);for(const j of x){const _=v.get(j.id);_?(_.name!==j.title||_.outputPath!==j.outputPath)&&(v.set(j.id,{..._,name:j.title,outputPath:j.outputPath}),y=!0):(v.set(j.id,{id:j.id,name:j.title,type:"task",status:"running",outputPath:j.outputPath}),y=!0)}return y?v:b})},[]),g=w.useCallback((x,b,y)=>{b&&y&&t(v=>{if(v.has(x))return v;const k=new Map(v);return k.set(x,{id:x,name:y,type:"task",status:"running",outputPath:b}),k}),r(v=>v===x?(i(!0),v):(i(!1),x))},[]);return{processes:e,activeProcessId:s,collapsed:o,toggleCollapse:u,addProcess:d,removeProcess:f,setActive:m,updateProcessStatus:p,handleServersChanged:h,handleToggleServer:g}}function xhe(n){const e=q.c(52),{sessionId:t,sessionCwd:s,pendingPath:r,sessionDirName:o,pendingDirName:i,dashboardProject:l,supportsFileWorkspace:c,activeWorkspacePanel:u,openWorkspacePanel:d,closeWorkspacePanel:f}=n,m=ghe(t),[p,h]=w.useState(null),[g,x]=w.useState(0),b=w.useRef(0),y=s??r??void 0,v=!!(y&&(p==null?void 0:p.kind)==="preview"&&p.cwd===y),k=(p==null?void 0:p.kind)==="project-files"&&p.anchorCwd===(y??null)?p:null;let j;e[0]!==i||e[1]!==r?(j={path:r,dirName:i},e[0]=i,e[1]=r,e[2]=j):j=e[2];const _=j;let N;e[3]!==l||e[4]!==i||e[5]!==r||e[6]!==s||e[7]!==o?(N=()=>({path:s??r??void 0,dirName:o??i??l??void 0}),e[3]=l,e[4]=i,e[5]=r,e[6]=s,e[7]=o,e[8]=N):N=e[8];const S=N;let C;e[9]!==S?(C=()=>{tg(S())},e[9]=S,e[10]=C):C=e[10];const E=C;let T;e[11]!==S?(T=X=>{tg({...S(),command:"claude /mcp"})},e[11]=S,e[12]=T):T=e[12];const A=T;let P;e[13]!==r||e[14]!==m||e[15]!==s?(P=()=>{const se=[...m.processes.values()].filter(yhe).at(-1);if(!se){(s??r)&&x(vhe);return}m.activeProcessId===se.id&&!m.collapsed?m.toggleCollapse():m.setActive(se.id)},e[13]=r,e[14]=m,e[15]=s,e[16]=P):P=e[16];const I=P;let $;e[17]!==r||e[18]!==s?($=()=>{(s??r)&&x(bhe)},e[17]=r,e[18]=s,e[19]=$):$=e[19];const O=$;let M;e[20]!==f||e[21]!==y||e[22]!==v?(M=()=>{y&&w.startTransition(()=>{f(),h(v?null:{kind:"preview",cwd:y})})},e[20]=f,e[21]=y,e[22]=v,e[23]=M):M=e[23];const R=M;let z;e[24]!==u||e[25]!==f||e[26]!==y||e[27]!==d?(z=()=>{if(y){if(u===zt.projectFiles){f();return}w.startTransition(()=>{h({kind:"project-files",root:y,anchorCwd:y,request:null}),d(zt.projectFiles)})}},e[24]=u,e[25]=f,e[26]=y,e[27]=d,e[28]=z):z=e[28];const W=z;let D;e[29]!==y||e[30]!==d||e[31]!==c?(D=X=>{if(!c)return!1;const se=FO(X,y);if(!se)return!1;b.current=b.current+1;const Q=b.current;return w.startTransition(()=>h({kind:"project-files",root:se.root,anchorCwd:y??null,request:se.file?{file:se.file,mode:se.mode,line:se.line,token:Q}:null})),d(zt.projectFiles),!0},e[29]=y,e[30]=d,e[31]=c,e[32]=D):D=e[32];const L=D;let U,F;e[33]!==L?(U=()=>DO(L),F=[L],e[33]=L,e[34]=U,e[35]=F):(U=e[34],F=e[35]),w.useEffect(U,F);let B;e[36]===Symbol.for("react.memo_cache_sentinel")?(B=()=>{w.startTransition(()=>h(null))},e[36]=B):B=e[36];const V=B,H=!!(y&&u===zt.projectFiles),K=k==null?void 0:k.root,Z=(k==null?void 0:k.request)??null;let Y;return e[37]!==y||e[38]!==A||e[39]!==O||e[40]!==E||e[41]!==I||e[42]!==R||e[43]!==W||e[44]!==g||e[45]!==_||e[46]!==m||e[47]!==v||e[48]!==H||e[49]!==K||e[50]!==Z?(Y={processPanel:m,currentCwd:y,showPreview:v,showProjectFiles:H,projectFilesRoot:K,projectFilesRequest:Z,launchTerminalRequest:g,pendingProject:_,handleOpenTerminal:E,handleMcpAuth:A,handleToggleIntegratedTerminal:I,handleNewIntegratedTerminal:O,handleTogglePreview:R,handleToggleProjectFiles:W,closeRightWorkspace:V},e[37]=y,e[38]=A,e[39]=O,e[40]=E,e[41]=I,e[42]=R,e[43]=W,e[44]=g,e[45]=_,e[46]=m,e[47]=v,e[48]=H,e[49]=K,e[50]=Z,e[51]=Y):Y=e[51],Y}function bhe(n){return n+1}function vhe(n){return n+1}function yhe(n){return n.type==="terminal"}function whe(n){const e=n.replace(/<[^>]+>[\s\S]*?<\/[^>]+>/g,"").trim();if(!e)return"";const t=e.split(`
|
|
466
|
+
`)[0].trim();return t.length<=60?t:t.slice(0,57)+"..."}const She={totalInputTokens:0,totalOutputTokens:0,totalCacheCreationTokens:0,totalCacheReadTokens:0,toolCallCounts:{},errorCount:0,totalDurationMs:0,turnCount:0};function D6(n,e){return{dirName:n.dirName,fileName:n.fileName,rawText:e,agentKind:nn(n.dirName)}}function khe(n){return{sessionId:n.sessionId,version:"",gitBranch:"",cwd:"",slug:"",name:"",model:"",turns:[],stats:{...She},rawMessages:[],agentKind:nn(n.dirName)}}function F6(n){if(!(n!=null&&n.trim()))return null;try{return{rawText:n,parsed:lf(n)}}catch{return null}}async function jhe(n,e,t=3,s=100,r=!0){if(r){const o=F6(n.initialContent);if(o)return o}for(let o=0;o<t;o++){if(e.signal.aborted)throw new DOMException("Aborted","AbortError");const i=await Re(`/api/sessions/${encodeURIComponent(n.dirName)}/${encodeURIComponent(n.fileName)}`,{signal:e.signal});if(i.ok){const l=await i.text();if(l.trim())try{return{rawText:l,parsed:lf(l)}}catch{}}o<t-1&&await new Promise(l=>setTimeout(l,s))}return null}async function Nhe(n,e,t,s){let r=s;for(let o=0;o<30;o++){if(e.signal.aborted)return;const i=await jhe(n,e,1,0,!1);if(i&&i.rawText!==r){t({type:"RELOAD_SESSION_CONTENT",session:i.parsed,source:D6(n,i.rawText)});return}r=(i==null?void 0:i.rawText)??r,await new Promise(l=>setTimeout(l,200))}}async function Che(n,e,t,s,r){const o=F6(n.initialContent),i=(o==null?void 0:o.rawText)??"",l=(o==null?void 0:o.parsed)??khe(n),c=D6(n,i);return t({type:"FINALIZE_SESSION",session:l,source:c,isMobile:s}),r(l,c),Nhe(n,e,t,i),n.sessionId}function _he(n){return n.access?n.access.mine:!0}async function Ehe(n,e,t,s){const r=Pr(),o=await Re(`/api/sessions/${encodeURIComponent(n)}?page=1&limit=10`,{signal:s.signal});if(!o.ok)return null;const i=await o.json();Mi(i.sessions??[],r);const l=t-3e4,c=e.trim(),u=(i.sessions??[]).filter(f=>{const m=f.lastModified?new Date(f.lastModified).getTime():0;return Number.isFinite(m)&&m>=l&&_he(f)}),d=u.find(f=>{var m,p;return((m=f.firstUserMessage)==null?void 0:m.trim())===c||((p=f.lastUserMessage)==null?void 0:p.trim())===c})??u[0];return d?{dirName:n,fileName:d.fileName,sessionId:d.sessionId}:null}function The({permissionsConfig:n,dispatch:e,isMobile:t,onSessionFinalized:s,onCreateStarted:r,onModelRejected:o,model:i,effort:l,contextWindowTokens:c,fastMode:u,ultracode:d,mcpConfig:f}){const[m,p]=w.useState(!1),[h,g]=w.useState(null),[x,b]=w.useState(!1),y=w.useRef(null),v=w.useRef(null),k=w.useRef(null),j=w.useCallback((C,E)=>{v.current=C,k.current=E??null,g(null),p(!1),e({type:"INIT_PENDING_SESSION",dirName:C,cwd:E,isMobile:t})},[e,t]),_=w.useCallback(async(C,E)=>{var R;const T=v.current;if(!T)return null;const A=nn(T),P=k.current;(R=y.current)==null||R.abort();const I=new AbortController;y.current=I,p(!0),g(null),r==null||r(C);const $=Date.now(),O=whe(C);async function M(z){v.current=null,k.current=null,mC(z.sessionId);const W=await Che(z,I,e,t,s);return O&&W&&HT(W,O),W}try{const z=us(A),{capabilities:W}=z,D={dirName:T,cwd:z.dirName.lossy?P??void 0:void 0,message:C,images:E,permissions:n,effort:l||void 0,contextWindowTokens:c,fastMode:u?!0:void 0,ultracode:W.ultracode&&d?!0:void 0,name:W.namedSessions&&O||void 0,worktreeName:W.worktrees&&x?M$(C):void 0,mcpConfig:W.mcp&&f||void 0},{res:L,errorMessage:U,errorCode:F}=await b6(B=>Re("/api/create-and-send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...D,model:B}),signal:I.signal}),{model:i,agentKind:A,errorFallback:"Unknown error",onModelRejected:o});if(!L.ok){if(A==="codex"&&F!=="SESSION_UNCONFIRMED"){const B=await Ehe(T,C,$,I);if(B)return await M(B)}return g(U||`Failed to create session (${L.status})`),null}return await M(await L.json())}catch(z){return I.signal.aborted||g(z instanceof Error?z.message:"Failed to create session"),null}finally{I.signal.aborted||p(!1)}},[n,i,l,c,u,d,f,x,e,t,s,r,o]),N=w.useCallback(()=>g(null),[]),S=w.useCallback(()=>{var C;(C=y.current)==null||C.abort(),y.current=null,v.current=null,k.current=null,p(!1),g(null)},[]);return{creatingSession:m,createError:h,clearCreateError:N,handleNewSession:j,createAndSend:_,cancelCreation:S,worktreeEnabled:x,setWorktreeEnabled:b}}function Ahe(n){const e=q.c(41),{permissionsConfig:t,dispatch:s,isMobile:r,defaultAgentKind:o,pendingDirName:i,pendingCwd:l,model:c,effort:u,contextWindowTokens:d,fastMode:f,ultracode:m,mcpConfig:p,onModelRejected:h}=n,g=w.useRef(null),x=w.useRef(null),[b,y]=w.useState(null);let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=V=>{var H;(H=g.current)==null||H.call(g,V),setTimeout(()=>{var K;return(K=x.current)==null?void 0:K.call(x)},300),setTimeout(()=>{var K;return(K=x.current)==null?void 0:K.call(x)},2e3)},e[0]=v):v=e[0];let k;e[1]!==d||e[2]!==s||e[3]!==u||e[4]!==f||e[5]!==r||e[6]!==p||e[7]!==c||e[8]!==h||e[9]!==t||e[10]!==m?(k={permissionsConfig:t,dispatch:s,isMobile:r,onSessionFinalized:v,onCreateStarted:y,onModelRejected:h,model:c,effort:u,contextWindowTokens:d,fastMode:f,ultracode:m,mcpConfig:p},e[1]=d,e[2]=s,e[3]=u,e[4]=f,e[5]=r,e[6]=p,e[7]=c,e[8]=h,e[9]=t,e[10]=m,e[11]=k):k=e[11];const j=The(k),_=j.handleNewSession,[N,S]=w.useState(null);let C;e[12]===Symbol.for("react.memo_cache_sentinel")?(C=new Map,e[12]=C):C=e[12];const E=w.useRef(C),T=Phe;let A;e[13]===Symbol.for("react.memo_cache_sentinel")?(A=async V=>{if(Ic===null)return null;const H=E.current;if(H.has(V))return H.get(V)??null;const K=S$(await T(),V,Ic);return H.set(V,K),K},e[13]=A):A=e[13];const P=A;let I;e[14]!==_?(I=async(V,H)=>{var X;const K=H??((X=(await T()).find(se=>se.dirName===V))==null?void 0:X.path)??null;if(!K){S(null),_(V);return}const Z=nn(V)===Ic?Ic:null,Y=Z?sm(Z,K):await P(K);S({discoveredDirName:Y,cwd:K}),_(Z&&Y?Y:V,K)},e[14]=_,e[15]=I):I=e[15];const $=I;let O;e[16]!==o||e[17]!==$?(O=V=>{const H=sm(o,V);$(H,V)},e[16]=o,e[17]=$,e[18]=O):O=e[18];const M=O;let R;e[19]!==_||e[20]!==N?(R=V=>{if(!N)return;const H=sm(V,N.cwd,N.discoveredDirName??void 0);_(H,N.cwd)},e[19]=_,e[20]=N,e[21]=R):R=e[21];const z=R;let W;e:{if(!j.creatingSession||!i){W=null;break e}const V=b??void 0;let H;e[22]!==l||e[23]!==i||e[24]!==V?(H={dirName:i,cwd:l,firstMessage:V},e[22]=l,e[23]=i,e[24]=V,e[25]=H):H=e[25],W=H}const D=W;let L,U;e[26]!==i?(U=()=>{i||(y(null),S(null))},L=[i],e[26]=i,e[27]=L,e[28]=U):(L=e[27],U=e[28]),w.useEffect(U,L);const F=N?z:void 0;let B;return e[29]!==M||e[30]!==$||e[31]!==j.cancelCreation||e[32]!==j.clearCreateError||e[33]!==j.createAndSend||e[34]!==j.createError||e[35]!==j.creatingSession||e[36]!==j.setWorktreeEnabled||e[37]!==j.worktreeEnabled||e[38]!==D||e[39]!==F?(B={creatingSession:j.creatingSession,createError:j.createError,clearCreateError:j.clearCreateError,createAndSend:j.createAndSend,cancelCreation:j.cancelCreation,worktreeEnabled:j.worktreeEnabled,setWorktreeEnabled:j.setWorktreeEnabled,sessionFinalizedRef:g,liveSessionsRefreshRef:x,pendingSessionInfo:D,pendingAgentKindChange:F,handleStartNewSession:$,handleStartNewFolder:M},e[29]=M,e[30]=$,e[31]=j.cancelCreation,e[32]=j.clearCreateError,e[33]=j.createAndSend,e[34]=j.createError,e[35]=j.creatingSession,e[36]=j.setWorktreeEnabled,e[37]=j.worktreeEnabled,e[38]=D,e[39]=F,e[40]=B):B=e[40],B}async function Phe(){try{const n=await Re("/api/projects");return n.ok?await n.json():[]}catch{return[]}}const xh=new Set;function Ihe(n,e){const t=fn(),s=xs();return`${s===null?t:`${t}:${s}`}:${n}/${e}`}async function $he(n,e,t){const s=Ihe(n,e);if(!xh.has(s)&&!hs.get(n,e)){xh.add(s);try{await Gi(n,e,t,"session prefetch",{background:!0})}catch{}finally{xh.delete(s)}}}function Rhe({onAuthenticated:n,setupRequired:e=!1}){const[t,s]=w.useState(null),[r,o]=w.useState(""),[i,l]=w.useState(""),[c,u]=w.useState(!1),[d,f]=w.useState(null),[m,p]=w.useState(!1),h=t==="account",{LoginNotice:g}=ur();w.useEffect(()=>{let y=!1;return Q3().then(v=>{y||s(v)}),()=>{y=!0}},[]);const x=w.useCallback(async y=>{if(y.preventDefault(),!(!i.trim()||h&&!r.trim())){p(!0),f(null);try{const v=await fetch("/api/auth/verify",h?{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"Content-Type":"application/json","X-Cogpit-Client":"1"},body:JSON.stringify({username:r.trim(),password:i})}:{method:"POST",credentials:"same-origin",cache:"no-store",headers:{Authorization:`Bearer ${i}`,"Content-Type":"application/json","X-Cogpit-Client":"1"}}),k=await v.json();v.ok&&k.valid?(qd(),l(""),o(""),n()):f(k.error||(h?"Invalid credentials":"Invalid password"))}catch{f("Failed to connect to server")}finally{p(!1)}}},[h,n,i,r]),b=m||!i.trim()||h&&!r.trim();return a.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-canvas px-4 py-8",children:a.jsx("form",{onSubmit:x,className:"w-full max-w-sm",children:a.jsxs(Ts,{children:[a.jsxs(Ys,{children:[a.jsx("div",{className:"mb-2 flex size-9 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:a.jsx(MP,{className:"size-4"})}),a.jsx(Xs,{children:"Sign in to Cogpit"}),a.jsx(Js,{children:h?"Sign in with your account to continue.":"Enter the server password to continue."})]}),t===null?a.jsx(As,{children:a.jsx("div",{className:"flex min-h-24 items-center justify-center",role:"status","aria-label":"Checking server",children:a.jsx(An,{className:"size-5 text-muted-foreground"})})}):a.jsxs(a.Fragment,{children:[a.jsxs(As,{className:"flex flex-col gap-4",children:[e&&a.jsxs(Jt,{children:[a.jsx(Pd,{"aria-hidden":"true"}),a.jsx(Qt,{children:"This server has no accounts yet."})]}),a.jsxs(Vl,{children:[h&&a.jsxs(un,{children:[a.jsx(dn,{htmlFor:"login-username",children:"Username"}),a.jsx(Zn,{id:"login-username",type:"text",value:r,onChange:y=>o(y.target.value),placeholder:"Username",autoComplete:"username",autoFocus:!0})]}),a.jsxs(un,{children:[a.jsx(dn,{htmlFor:"login-password",children:"Password"}),a.jsxs(So,{children:[a.jsx(ko,{id:"login-password",type:c?"text":"password",value:i,onChange:y=>l(y.target.value),placeholder:"Password",autoComplete:"current-password",autoFocus:!h}),a.jsx(or,{align:"inline-end",children:a.jsx(Jd,{size:"icon-xs",onClick:()=>u(y=>!y),"aria-label":c?"Hide password":"Show password",children:c?a.jsx(n1,{}):a.jsx(Zi,{})})})]})]})]}),h&&g&&a.jsx(g,{}),d&&a.jsxs(Jt,{variant:"destructive",children:[a.jsx(Ds,{"aria-hidden":"true"}),a.jsx(_n,{children:"Sign in failed"}),a.jsx(Qt,{children:d})]})]}),a.jsx(Xd,{children:a.jsxs(ee,{type:"submit",className:"w-full",disabled:b,children:[m&&a.jsx(An,{"data-icon":"inline-start"}),"Connect"]})})]})]})})})}function Ohe(){const n=q.c(18);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=Wd(),n[0]=e):e=n[0];const t=e,[s,r]=w.useState(null),[o,i]=w.useState(!1),[l,c]=w.useState(!1),u=w.useRef(0);let d,f;n[1]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{let A=!1;return J3().then(P=>{A||r(P)}),()=>{A=!0}},f=[],n[1]=d,n[2]=f):(d=n[1],f=n[2]),w.useEffect(d,f);const m=t?!0:s===null?null:s.signIn==="account";let p,h;n[3]!==m?(p=()=>{if(m===null)return;if(!m){i(!0),c(!0);return}let A=!1;const P=u.current;return a$().then(I=>{!A&&u.current===P&&(i(I),c(!0))}),()=>{A=!0}},h=[m],n[3]=m,n[4]=p,n[5]=h):(p=n[4],h=n[5]),w.useEffect(p,h);let g;n[6]!==(s==null?void 0:s.signIn)?(g=()=>{let A=!1;const P=()=>{const I=u.current=u.current+1,$=()=>{A||u.current!==I||(i(!1),c(!0))};if(t||(s==null?void 0:s.signIn)==="account"){$();return}nv().then(O=>{A||u.current!==I||(r(O),O.signIn==="account"&&$())})};return window.addEventListener("cogpit-auth-required",P),()=>{A=!0,window.removeEventListener("cogpit-auth-required",P)}},n[6]=s==null?void 0:s.signIn,n[7]=g):g=n[7];const x=s==null?void 0:s.signIn;let b;n[8]!==x?(b=[x,t],n[8]=x,n[9]=b):b=n[9],w.useEffect(g,b);let y;n[10]===Symbol.for("react.memo_cache_sentinel")?(y=()=>{u.current=u.current+1,i(!0),c(!0),window.dispatchEvent(new Event("cogpit-auth-changed"))},n[10]=y):y=n[10];const v=y;let k;n[11]===Symbol.for("react.memo_cache_sentinel")?(k=async()=>{r(await nv())},n[11]=k):k=n[11];const j=k;let _;n[12]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{lU(),u.current=u.current+1,i(!1),c(!0),l$().finally(Lhe)},n[12]=_):_=n[12];const N=_,S=(s==null?void 0:s.edition)??null,C=l&&s!==null,E=(s==null?void 0:s.setupRequired)===!0;let T;return n[13]!==o||n[14]!==S||n[15]!==C||n[16]!==E?(T={isRemote:t,edition:S,authChecked:C,authenticated:o,setupRequired:E,handleAuthenticated:v,refreshServerState:j,logout:N},n[13]=o,n[14]=S,n[15]=C,n[16]=E,n[17]=T):T=n[17],T}function Lhe(){window.dispatchEvent(new Event("cogpit-auth-changed"))}function Mhe(n){const e=q.c(18),{onRestored:t,onLogout:s}=n,{activeDevice:r,activeDeviceId:o}=la();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=yo(),e[0]=i):i=e[0];const l=i,c=l?(r==null?void 0:r.name)??o:"This server";let u;e[1]===Symbol.for("react.memo_cache_sentinel")?(u=a.jsx(Rn,{variant:"icon",children:a.jsx(N3,{className:"text-destructive"})}),e[1]=u):u=e[1];let d;e[2]!==c?(d=a.jsxs(Nn,{children:[c," isn’t available to your account right now"]}),e[2]=c,e[3]=d):d=e[3];let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=a.jsx(Cn,{children:"Its administrator can let you back in. Check again once they have."}),e[4]=f):f=e[4];let m;e[5]!==d?(m=a.jsxs(jn,{children:[u,d,f]}),e[5]=d,e[6]=m):m=e[6];let p;e[7]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsx(On,{"data-icon":"inline-start"}),e[7]=p):p=e[7];let h;e[8]!==t?(h=a.jsxs(ee,{size:"sm",onClick:t,children:[p,"Check again"]}),e[8]=t,e[9]=h):h=e[9];let g;e[10]!==s?(g=l?a.jsxs(ee,{variant:"outline",size:"sm",onClick:zhe,children:[a.jsx(kh,{"data-icon":"inline-start"}),"Switch to this machine"]}):a.jsxs(ee,{variant:"outline",size:"sm",onClick:s,children:[a.jsx(zP,{"data-icon":"inline-start"}),"Sign out"]}),e[10]=s,e[11]=g):g=e[11];let x;e[12]!==h||e[13]!==g?(x=a.jsxs(zl,{className:"flex-row justify-center",children:[h,g]}),e[12]=h,e[13]=g,e[14]=x):x=e[14];let b;return e[15]!==m||e[16]!==x?(b=a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas text-foreground",children:a.jsxs(kn,{children:[m,x]})}),e[15]=m,e[16]=x,e[17]=b):b=e[17],b}function zhe(){return Fs(Et)}function Dhe(n){const e=q.c(4),{onRetry:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsxs(jn,{children:[a.jsx(Rn,{variant:"icon",children:a.jsx(DP,{className:"text-destructive"})}),a.jsx(Nn,{children:"Cogpit couldn’t finish loading"}),a.jsx(Cn,{children:"Part of this server’s interface didn’t download. Check your connection and try again."})]}),e[0]=s):s=e[0];let r;e[1]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(On,{"data-icon":"inline-start"}),e[1]=r):r=e[1];let o;return e[2]!==t?(o=a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas text-foreground",children:a.jsxs(kn,{children:[s,a.jsx(zl,{className:"flex-row justify-center",children:a.jsxs(ee,{size:"sm",onClick:t,children:[r,"Retry"]})})]})}),e[2]=t,e[3]=o):o=e[3],o}const Hg="cogpit:edition-ui-reloaded";let bh=null;function Fhe(){return bh??(bh=et(()=>import("./edition-ui-C0x29noh.js"),__vite__mapDeps([39,1,2,27,3,4])).then(n=>n.default,n=>{throw bh=null,n})),bh}function Uhe(){try{if(sessionStorage.getItem(Hg)!==null)return!1;sessionStorage.setItem(Hg,"1")}catch{return!1}return window.location.reload(),!0}function U6(){try{sessionStorage.removeItem(Hg)}catch{}}async function Bhe(n,e){let t;try{t=await Fhe()}catch{return e&&Uhe()?"reloading":"failed"}return U6(),(t==null?void 0:t.edition)===n?t:null}async function B6(n,e,t){RI();const s=await Bhe(n,t);s!=="reloading"&&(s==="failed"&&e?(U6(),LI()):s===null||s==="failed"?OI():$I(s))}async function Whe(n,{required:e=!1}={}){if(n==="personal")return;const t=ml();t==="installed"||t==="loading"||t==="failed"||await B6(n,e,!0)}async function qhe(n){ml()==="failed"&&await B6(n,!0,!1)}function e3(n){return n==="personal"?null:n}function Vhe(n,e){const t=q.c(16),s=w.useSyncExternalStore(f1,ml,ml);let r;t[0]!==n?(r=e3(n),t[0]=n,t[1]=r):r=t[1];const o=r;let i;t[2]!==e||t[3]!==o?(i=o??e3(e),t[2]=e,t[3]=o,t[4]=i):i=t[4];const l=i,c=o!==null;let u,d;t[5]!==c||t[6]!==l?(u=()=>{l!==null&&Whe(l,{required:c})},d=[l,c],t[5]=c,t[6]=l,t[7]=u,t[8]=d):(u=t[7],d=t[8]),w.useEffect(u,d);let f;t[9]!==l?(f=()=>{l!==null&&qhe(l)},t[9]=l,t[10]=f):f=t[10];const m=f,p=s==="installed"||s==="unavailable",h=o===null||p,g=l===null||p,x=c&&s==="failed";let b;return t[11]!==m||t[12]!==h||t[13]!==g||t[14]!==x?(b={serverReady:h,ready:g,failed:x,retry:m},t[11]=m,t[12]=h,t[13]=g,t[14]=x,t[15]=b):b=t[15],b}const W6={level:"own"},t3={level:"unknown"},Hhe={none:{level:"none"},view:{level:"view"},interact:{level:"interact"},own:W6};function Khe(n){const e=q.c(5),{enforcesSessionAccess:t}=eC(),s=t?n:null;let r;e[0]!==s?(r=()=>s?gU(s):void 0,e[0]=s,e[1]=r):r=e[1];const o=r,i=w.useSyncExternalStore(bU,o,o);let l,c;return e[2]!==s?(l=()=>s?SU(s):void 0,c=[s],e[2]=s,e[3]=l,e[4]=c):(l=e[3],c=e[4]),w.useEffect(l,c),t===null?t3:s?i?Hhe[i]:t3:W6}function Ghe({level:n}){return n==="unknown"?{kind:"checking"}:n==="none"?{kind:"no-access"}:Ki(n).canInteract?null:{kind:"view-only"}}function Zhe(n){const e=q.c(8),{reason:t}=n;switch(t.kind){case"subagent":{let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(Uu,{icon:$i,children:"Viewing sub-agent session (read-only)"}),e[0]=s):s=e[0],s}case"external":{let s;e[1]!==t.agentKind?(s=SR(t.agentKind),e[1]=t.agentKind,e[2]=s):s=e[2];let r;return e[3]!==s?(r=a.jsx(Uu,{icon:$i,status:!0,children:s}),e[3]=s,e[4]=r):r=e[4],r}case"no-access":{let s;return e[5]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(Uu,{icon:UP,status:!0,children:"You don't have access to this session"}),e[5]=s):s=e[5],s}case"checking":{let s;return e[6]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(n3,{icon:FP,children:"Checking access…"}),e[6]=s):s=e[6],s}case"view-only":{let s;return e[7]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(n3,{icon:Zi,children:a.jsx(Yhe,{})}),e[7]=s):s=e[7],s}}}function Yhe(){const n=q.c(3),{ReadOnlyNote:e}=ur(),{session:t}=xt();let s;return n[0]!==e||n[1]!==t?(s=e&&t?a.jsx(e,{sessionId:t.sessionId}):"View only",n[0]=e,n[1]=t,n[2]=s):s=n[2],s}function n3(n){const e=q.c(4),{icon:t,children:s}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(Xhe,{}),e[0]=r):r=e[0];let o;return e[1]!==s||e[2]!==t?(o=a.jsxs("div",{className:"shrink-0",children:[r,a.jsx(Uu,{icon:t,status:!0,children:s})]}),e[1]=s,e[2]=t,e[3]=o):o=e[3],o}function Xhe(){const n=q.c(7),{pendingInteraction:e,permissionRequests:t}=xt(),s=(e==null?void 0:e.type)==="plan"?e:null;if(!s&&t.length===0)return null;let r;n[0]!==s?(r=s&&a.jsx(Rj,{allowedPrompts:s.allowedPrompts,summary:s.summary,planContent:s.planContent}),n[0]=s,n[1]=r):r=n[1];let o;n[2]!==t?(o=t.length>0&&a.jsx("div",{className:"mb-2 overflow-hidden rounded-xl border border-warning/40 bg-popover",children:a.jsx(Oj,{requests:t})}),n[2]=t,n[3]=o):o=n[3];let i;return n[4]!==r||n[5]!==o?(i=a.jsxs("div",{className:"px-3 pt-2",children:[r,o]}),n[4]=r,n[5]=o,n[6]=i):i=n[6],i}function Uu(n){const e=q.c(8),{icon:t,status:s,children:r}=n,i=(s===void 0?!1:s)?"status":void 0;let l;e[0]!==t?(l=a.jsx(t,{"data-icon":"inline-start",className:"size-3.5 text-muted-foreground"}),e[0]=t,e[1]=l):l=e[1];let c;e[2]!==r?(c=a.jsx("span",{className:"text-xs text-muted-foreground",children:r}),e[2]=r,e[3]=c):c=e[3];let u;return e[4]!==i||e[5]!==l||e[6]!==c?(u=a.jsxs("div",{role:i,className:"flex shrink-0 items-center justify-center gap-2 border-t bg-card px-4 py-2.5",children:[l,c]}),e[4]=i,e[5]=l,e[6]=c,e[7]=u):u=e[7],u}const Jhe=w.lazy(()=>et(()=>import("./index-BtmLHL6v.js"),__vite__mapDeps([40,1,2,3,4])).then(n=>({default:n.BranchModal}))),Qhe=w.lazy(()=>et(()=>import("./WorkflowsPanel-Bv2RwtYI.js"),__vite__mapDeps([41,1,4,2,3])).then(n=>({default:n.WorkflowsPanel})));function ege(){window.location.reload()}function tge(){var gb,xb,bb,vb,yb,wb,Sb,kb,jb,Nb,Cb,_b,Eb,Tb,Ab,Pb,Ib,$b,Rb,Ob,Lb,Mb,zb;const n=M0(window.location.pathname),e=$pe(),t=Ohe(),s=Upe(t.edition),r=Vhe(t.edition,s.edition),o=ur(),i=s.checked&&(s.edition==="personal"||s.user!==null),l=i&&s.capabilities.configWrite,c=i&&s.capabilities.hostFiles,u=i&&s.capabilities.terminal,d=$0(),f=j6(),[m,p]=v6(),{procBySession:h}=kx(),{parse:g,append:x}=M6(),b=w.useCallback(Le=>{p({type:"SET_OLDER_TURNS",turns:Le})},[p]),y=w.useCallback((Le,it)=>{$he(Le,it,g)},[g]),v=z6({dirName:((gb=m.sessionSource)==null?void 0:gb.dirName)??null,fileName:((xb=m.sessionSource)==null?void 0:xb.fileName)??null,sessionChangeKey:m.sessionChangeKey,workerParse:g,onOlderTurns:b}),{loadMore:k}=v,j=!!m.searchQuery&&v.hasMore,_=((bb=m.session)==null?void 0:bb.turns.length)??0;w.useEffect(()=>{j&&k()},[j,k,_]);const N=ihe(m,p),S=w.useRef(null),C=w.useRef(null),[E,T]=w.useState(!1),[A,P]=w.useState(!1),I=w.useCallback(()=>p({type:"TOGGLE_EXPAND_ALL"}),[p]),$=w.useCallback(()=>T(!0),[]),O=w.useCallback(()=>{var Le;return(Le=C.current)==null?void 0:Le.focus()},[]),M=w.useCallback(()=>p({type:"SET_EXPAND_ALL",value:!0}),[p]),R=w.useCallback(()=>p({type:"SET_EXPAND_TOOL_PAYLOADS",value:!0}),[p]),z=w.useCallback(()=>p({type:"SET_EXPAND_ALL",value:!1}),[p]),W=N.toggleWorkspacePanel,D=w.useCallback(()=>W(zt.sessionInfo),[W]),L=w.useCallback(Le=>{w.startTransition(()=>{p({type:"SET_DASHBOARD_PROJECT",dirName:Le})})},[p]),U=m.pendingCwd??(m.pendingDirName?ls(m.pendingDirName):null),F=((vb=m.sessionSource)==null?void 0:vb.agentKind)??nn(((yb=m.sessionSource)==null?void 0:yb.dirName)??m.pendingDirName??null),B=(wb=m.session)!=null&&wb.sessionId?h.get(m.session.sessionId):void 0,V=xn(F),H=R0(F,B),K=Khe(((Sb=m.session)==null?void 0:Sb.sessionId)??null),Z=Ki(K.level),Y=V.worktrees,X=V.mcp&&l&&Z.mcp,se=rhe(l?((kb=m.session)==null?void 0:kb.cwd)??U??void 0:void 0,l&&V.slashCommands),Q=w.useCallback(Le=>{if(!l)return;const it=se.suggestions.find(sn=>sn.name===Le);w.startTransition(()=>{p({type:"OPEN_CONFIG",filePath:it==null?void 0:it.filePath})})},[l,p,se.suggestions]),te=w.useCallback(async(Le,it)=>{if(!l)return null;const sn=se.suggestions.find(vr=>vr.name===Le);if(!(sn!=null&&sn.filePath))return null;try{const vr=await Re("/api/expand-command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:sn.filePath,args:it||""})});return vr.ok?(await vr.json()).content??null:null}catch{return null}},[l,se.suggestions]),J=N.openWorkspacePanel,ne=w.useCallback(Le=>{J(Le),d&&p({type:"SET_MOBILE_TAB",tab:"workspace"})},[J,d,p]),{processPanel:re,currentCwd:le,showPreview:ae,showProjectFiles:ue,projectFilesRoot:oe,projectFilesRequest:ie,launchTerminalRequest:fe,pendingProject:de,handleOpenTerminal:ce,handleMcpAuth:xe,handleToggleIntegratedTerminal:pe,handleNewIntegratedTerminal:he,handleTogglePreview:ye,handleToggleProjectFiles:ve,closeRightWorkspace:ke}=xhe({sessionId:(jb=m.session)==null?void 0:jb.sessionId,sessionCwd:(Nb=m.session)==null?void 0:Nb.cwd,pendingPath:U,sessionDirName:(Cb=m.sessionSource)==null?void 0:Cb.dirName,pendingDirName:m.pendingDirName,dashboardProject:m.dashboardProject,supportsFileWorkspace:c,activeWorkspacePanel:N.activeWorkspacePanel,openWorkspacePanel:ne,closeWorkspacePanel:N.closeWorkspacePanel}),je=ehe(m.session??null),[Me,_e]=w.useState(!1),Fe=((_b=m.sessionSource)==null?void 0:_b.dirName)??m.pendingDirName??m.dashboardProject??null,{activeWorkspacePanel:ze,closeWorkspacePanel:We,showWorkflows:Pe}=N,qe=Hpe(i&&Y&&m.mainView==="sessions"&&ze===zt.worktrees?Fe:null),be=w.useMemo(()=>{const Le=m.session;return Le?Le.turns.some(it=>cd(it.toolCalls,Le.cwd)||it.subAgentActivity.some(sn=>cd(sn.toolCalls,Le.cwd))):!1},[m.session]),Ie=w.useMemo(()=>{if(!m.session||!V.workflows)return 0;let Le=0;for(const it of m.session.turns)for(const sn of it.toolCalls)sn.name==="Workflow"&&Le++;return Le},[m.session,V.workflows]),Se=Ie>0,Ne=w.useMemo(()=>{const Le=m.sessionSource;return!Le||!V.workflows||lo(Le.fileName)?{dirName:null,sessionId:null}:{dirName:Le.dirName,sessionId:Gu(Le.fileName)}},[m.sessionSource,V.workflows]),He=Dme(Ne.dirName,Ne.sessionId,Se),Ke=Se||He.workflows.length>0,Ce=He.workflows.length||Ie,Be=N.setShowWorkflows,Ye=w.useCallback(()=>Be(!0),[Be]),[Xe,nt]=w.useState(!1);w.useEffect(()=>{if(!c)return;const Le=()=>{d?nt(!0):J(zt.fileChanges)};return window.addEventListener(Cl,Le),()=>window.removeEventListener(Cl,Le)},[c,J,d]);const Qe=w.useMemo(()=>m.session?kN(m.session):null,[m.session]),Ee=w.useRef(null),{isLive:me,sseState:Oe,isCompacting:Ge,streamingOverlay:rt,turnError:wt,agentProgress:Ct,promptSuggestion:Pn,rateLimit:ts}=g6(m.sessionSource,Le=>{w.startTransition(()=>{p({type:"UPDATE_SESSION",session:Le})})},g,x,()=>{var Le;return(Le=Ee.current)==null?void 0:Le.call(Ee)},m.session),ns=she(((Eb=m.session)==null?void 0:Eb.cwd)??null),Bt=upe(),xr=Bt.setMode,Vn=mpe(H?null:((Tb=m.session)==null?void 0:Tb.sessionId)??null),vc=H?null:Vn.plan??Qe,{contextWindowTokens:yc,setContextWindowTokens:Bf,contextWindowAvailable:Wf,selectedModel:ua,setSelectedModel:qf,selectedEffort:H6,setSelectedEffort:Vf,fastModeEnabled:K6,ultracodeEnabled:G6,effectiveEffort:wc,fastModeAvailable:Z6,fastModeActive:Sc,setFastModeEnabled:Hf,ultracodeAvailable:Y6,ultracodeActive:kc,setUltracodeEnabled:Kf,imageInputAvailable:z0,modelFallbackNotice:X6,dismissModelFallbackNotice:D0,handleModelRejected:F0}=dhe({agentKind:F,session:m.session,sessionSource:m.sessionSource,pendingDirName:m.pendingDirName,isLive:me}),U0=Gpe((Ab=m.session)==null?void 0:Ab.sessionId,(Pb=m.sessionSource)==null?void 0:Pb.fileName),da=hhe({sessionKey:U0,sessionId:((Ib=m.session)==null?void 0:Ib.sessionId)??null,access:K.level,values:{model:ua,effort:H6,contextWindowTokens:yc,fastMode:K6,ultracode:G6,permissionMode:Bt.config.mode},onHydrate:w.useCallback(Le=>{Bf(Le.contextWindowTokens??null),Le.model!==void 0&&qf(Le.model),Le.effort!==void 0&&Vf(Le.effort),Le.fastMode!==void 0&&Hf(Le.fastMode),Le.ultracode!==void 0&&Kf(Le.ultracode),Le.permissionMode&&xr(Le.permissionMode)},[Bf,qf,Vf,Hf,Kf,xr])}),B0=da.picked.includes("permissionMode")?Bt.config:void 0,ss=Qpe(X?le:void 0,X?Fe??void 0:void 0,X?U0??void 0:void 0,X);w.useEffect(()=>{!Y&&ze===zt.worktrees&&We()},[Y,ze,We]),w.useEffect(()=>{Pe&&!Ke&&Be(!1)},[Pe,Ke,Be]);const{creatingSession:W0,createError:q0,clearCreateError:J6,createAndSend:Q6,cancelCreation:V0,worktreeEnabled:eA,setWorktreeEnabled:tA,sessionFinalizedRef:jc,liveSessionsRefreshRef:H0,pendingSessionInfo:K0,pendingAgentKindChange:nA,handleStartNewSession:G0,handleStartNewFolder:Z0}=Ahe({permissionsConfig:Bt.config,dispatch:p,isMobile:d,defaultAgentKind:e.defaultAgentKind,pendingDirName:m.pendingDirName,pendingCwd:m.pendingCwd,onModelRejected:F0,model:ua,effort:wc,contextWindowTokens:Wf?yc:void 0,fastMode:Sc,ultracode:kc,mcpConfig:X?ss.mcpConfigJson:null}),Mt=Bme({sessionSource:m.sessionSource,parsedSessionId:(($b=m.session)==null?void 0:$b.sessionId)??null,cwd:(Rb=m.session)==null?void 0:Rb.cwd,permissions:B0,onPermissionsApplied:Bt.markApplied,settingsChange:da.picked,onSettingsChangeSent:da.settlePicked,model:ua,effort:wc,contextWindowTokens:Wf?yc:void 0,fastMode:Sc,ultracode:kc,mcpConfig:X?ss.mcpConfigJson:null,onModelRejected:F0,readOnly:H||!Z.send,onCreateSession:m.pendingDirName?Q6:void 0}),vn=Mme(V.agentTeams?((Ob=m.sessionSource)==null?void 0:Ob.fileName)??null:null,((Lb=m.sessionSource)==null?void 0:Lb.dirName)??null);w.useEffect(()=>{vn!=null&&vn.currentMemberName?p({type:"SET_CURRENT_MEMBER_NAME",name:vn.currentMemberName}):vn||p({type:"SET_CURRENT_MEMBER_NAME",name:null})},[vn==null?void 0:vn.currentMemberName,vn,p]),w.useEffect(()=>{d&&p({type:"GUARD_MOBILE_TAB",hasSession:!!m.session||!!m.pendingDirName})},[m.session,m.pendingDirName,m.mobileTab,d,p]);const Vs=y6({session:m.session,isLive:me,pendingMessages:Mt.pendingMessages,consumePending:Mt.consumePending,sessionChangeKey:m.sessionChangeKey,partialSignal:rt}),Y0=Vs.chatScrollRef,X0=Vs.resetTurnCount,J0=Vs.scrollToBottomInstant,sA=w.useCallback(Le=>{_e(Le),requestAnimationFrame(()=>{const it=Y0.current;it&&it.scrollTo({top:it.scrollTop+(Le?64:-64),behavior:"smooth"})})},[Y0]);w.useLayoutEffect(()=>{const Le=it=>{X0(0),J0()};return jc.current=Le,()=>{jc.current===Le&&(jc.current=null)}},[X0,J0,jc]);const rA=w.useCallback(()=>{Mt.disconnect(),V0()},[Mt.disconnect,V0]),js=Vme({dispatch:p,isMobile:d,mobileTab:m.mobileTab,teamContext:vn,scrollToBottomInstant:Vs.scrollToBottomInstant,resetTurnCount:Vs.resetTurnCount,workerParse:g,onBeforeSwitch:rA}),oA=w.useCallback(Le=>{w.startTransition(()=>{p({type:"GO_HOME",isMobile:d}),p({type:"SET_DASHBOARD_PROJECT",dirName:Le})})},[p,d]),{previewLoadError:iA}=Zme({state:m,dispatch:p,isMobile:d,resetTurnCount:Vs.resetTurnCount,scrollToBottomInstant:Vs.scrollToBottomInstant,workerParse:g}),fa=npe();ope({openSessionId:(m.sessionSource&&v1(m.sessionSource.dirName,m.sessionSource.fileName))??((Mb=m.session)==null?void 0:Mb.sessionId)??null,leave:js.handleCloseSession,forgetVisits:fa.forget});const Q0=fa.push;w.useEffect(()=>{m.sessionSource&&Q0(m.sessionSource.dirName,m.sessionSource.fileName)},[m.sessionSource,Q0]);const $t=che({state:{session:m.session,sessionSource:m.sessionSource},dispatch:p,isMobile:d,handleJumpToTurn:js.handleJumpToTurn,markPermissionsApplied:Bt.markApplied,hasPermsPendingChanges:Bt.hasPendingChanges,permissionsConfig:B0,settingsChange:da.picked,onSettingsChangeSent:da.settlePicked,selectedModel:ua,selectedEffort:wc,fastMode:Sc,ultracode:kc,mcpConfig:X?ss.mcpConfigJson:null,scrollRequestScrollToTop:Vs.requestScrollToTop,handleDashboardSelect:js.handleDashboardSelect,workerParse:g,canInteract:Z.canInteract}),{hasSettingsChanges:eb,handleApplySettings:tb}=$t,nb=X&&ss.mcpConfigJson!==null,sb=w.useRef(!1);w.useEffect(()=>{var sn;const Le=ss.loaded&&!sb.current;sb.current=ss.loaded;const it=(sn=m.session)==null?void 0:sn.sessionId;Le&&it&&nb&&eb&&tb()},[ss.loaded,nb,eb,tb,(zb=m.session)==null?void 0:zb.sessionId]),w.useLayoutEffect(()=>(Ee.current=$t.reloadSession,()=>{Ee.current===$t.reloadSession&&(Ee.current=null)}),[$t.reloadSession]);const br=$6(m.session,m.sessionSource,$t.reloadSession,c&&Z.undo),Nc=br.requestBranchSwitch,Cc=$t.setBranchModalTurn,aA=w.useCallback((Le,it)=>{Nc(Le,it),Cc(null)},[Nc,Cc]),lA=w.useCallback(Le=>{Nc(Le),Cc(null)},[Nc,Cc]);Jme({isMobile:d,searchInputRef:S,chatInputRef:C,dispatch:p,onToggleSidebar:N.handleToggleSidebar,onToggleRightSidebar:D,onToggleMissionControl:N.handleToggleMission,onOpenCommandPalette:$,onOpenProjectSwitcher:N.handleOpenProjectSwitcher,onOpenThemeSelector:N.handleToggleThemeSelector,onOpenTerminal:ce,onToggleIntegratedTerminal:pe,onTogglePreview:ye,onToggleProjectFiles:ve,onHistoryBack:fa.goBack,onHistoryForward:fa.goForward,onNavigateToSession:js.handleDashboardSelect,onCommitNavigation:fa.commitNavigation});const{killing:cA,handleKillAll:uA}=Kpe(),Fr=m.sessionSource?lo(m.sessionSource.fileName):null,dA=Fr!==null&&!!(vn!=null&&vn.currentMemberName),Gf=Fr!==null&&!dA,_c=js.handleDashboardSelect,rb=w.useCallback(()=>{!m.sessionSource||!Fr||_c(m.sessionSource.dirName,Fr.parentFileName)},[m.sessionSource,Fr,_c]);w.useEffect(()=>{const Le=it=>{const{agentId:sn}=it.detail??{};if(!sn||!m.sessionSource||!V.subagentTranscripts)return;const vr=Fr?Fr.parentSessionId:Gu(m.sessionSource.fileName);_c(m.sessionSource.dirName,`${vr}/subagents/agent-${sn}.jsonl`)};return window.addEventListener(ud,Le),()=>window.removeEventListener(ud,Le)},[m.sessionSource,Fr,_c,V.subagentTranscripts]);const[fA,ob]=w.useState(null),mA=$t.branchModalTurn!==null,Qo=$t.branchModalTurn??fA;w.useEffect(()=>{$t.branchModalTurn!==null&&ob($t.branchModalTurn)},[$t.branchModalTurn]);const ib=Qo!==null?br.branchesAtTurn(Qo):[];let ma=null;Gf?ma={kind:"subagent"}:H?ma={kind:"external",agentKind:F}:ma=Ghe(K);const Zf=ma&&a.jsx(Zhe,{reason:ma}),pA=js.loadError||q0||null;let Yf;js.loadError?Yf=js.clearLoadError:q0&&(Yf=J6);const hA=!!(m.session&&m.sessionSource&&Oe==="disconnected"),Xf=w.useMemo(()=>({state:m,dispatch:p,config:e,theme:f,isMobile:d}),[m.activeTurnIndex,m.activeToolCallId,m.searchQuery,m.expandAll,m.expandToolPayloads,m.mainView,m.extensionViewId,m.mobileTab,m.dashboardProject,m.pendingDirName,m.pendingCwd,m.currentMemberName,m.loadingMember,m.configFilePath,m.sessionChangeKey,p,e,f,d]),Jf=w.useMemo(()=>({session:m.session,sessionSource:m.sessionSource,isLive:me,sseState:Oe,isCompacting:Ge,turnError:wt,promptSuggestion:Pn,rateLimit:ts,undoRedo:br,pendingInteraction:vc,permissionRequests:Vn.requests,permissionResponding:Vn.responding,respondPermission:Vn.respond,respondAllPermissions:Vn.respondAll,isSubAgentView:Gf,permissions:Z,slashSuggestions:se.suggestions,slashSuggestionsLoading:se.loading,actions:{handleStopSession:$t.handleStopSession,handleEditConfig:l?N.handleEditConfig:void 0,handleEditCommand:l?Q:void 0,handleExpandCommand:l?te:void 0,handleOpenBranches:$t.handleOpenBranches,handleBranchFromHere:$t.handleBranchFromHere,handleToggleExpandAll:I,handleLoadSession:$t.handleLoadSessionScrollAware}}),[m.session,m.sessionSource,me,Oe,Ge,wt,Pn,ts,br,vc,Gf,Z,Vn.requests,Vn.responding,Vn.respond,Vn.respondAll,se.suggestions,se.loading,$t.handleStopSession,l,N.handleEditConfig,Q,te,$t.handleOpenBranches,$t.handleBranchFromHere,I,$t.handleLoadSessionScrollAware]),Qf=w.useMemo(()=>({chat:{status:Mt.status,error:Mt.error,pendingMessages:Mt.pendingMessages,isConnected:Mt.isConnected,sendMessage:Mt.sendMessage,interrupt:Mt.interrupt,stopAgent:Mt.stopAgent,consumePending:Mt.consumePending},scroll:Vs}),[Mt.status,Mt.error,Mt.pendingMessages,Mt.isConnected,Mt.sendMessage,Mt.interrupt,Mt.stopAgent,Mt.consumePending,Vs]),pa=!!m.pendingDirName&&!m.session;if(w.useEffect(()=>{if(!pa||d)return;const Le=requestAnimationFrame(()=>{var it;return(it=C.current)==null?void 0:it.focus()});return()=>cancelAnimationFrame(Le)},[pa,d,m.pendingDirName]),r.failed)return a.jsx(Dhe,{onRetry:r.retry});if(!t.authChecked||!r.serverReady)return a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas",role:"status","aria-label":"Checking authentication",children:a.jsx(vt,{"data-icon":"inline-start",className:"size-6 animate-spin text-muted-foreground"})});if(!t.authenticated){const Le=o.SetupScreen;return t.setupRequired&&Le?a.jsx(Le,{onAuthenticated:t.handleAuthenticated,onSetupClosed:t.refreshServerState}):a.jsx(Rhe,{onAuthenticated:t.handleAuthenticated,setupRequired:t.setupRequired})}if(!i||!r.ready)return a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas",role:"status","aria-label":"Loading identity",children:a.jsx(vt,{"data-icon":"inline-start",className:"size-6 animate-spin text-muted-foreground"})});if(s.gate){const Le=o.GateScreen??Mhe;return a.jsxs(a.Fragment,{children:[a.jsx(Le,{gate:s.gate,onRestored:ege,onLogout:t.logout}),a.jsx(Jb,{activeError:null,modelFallbackNotice:null,dismissModelFallbackNotice:D0,connectionLost:!1,theme:f.activeTheme})]})}if(e.configLoading)return a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas",role:"status","aria-label":"Loading",children:a.jsx(vt,{"data-icon":"inline-start",className:"size-6 animate-spin text-muted-foreground"})});if(e.configError)return a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas text-foreground",children:a.jsxs(kn,{children:[a.jsxs(jn,{children:[a.jsx(Rn,{variant:"icon",children:a.jsx(lr,{className:"text-destructive"})}),a.jsx(Nn,{children:"Failed to connect"}),a.jsx(Cn,{children:e.configError})]}),a.jsx(zl,{children:a.jsxs(ee,{variant:"outline",size:"sm",onClick:e.retryConfig,children:[a.jsx(On,{"data-icon":"inline-start"}),"Retry"]})})]})});if(!e.claudeDir)return l?a.jsx(LO,{onConfigured:e.setClaudeDir}):a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas text-sm text-muted-foreground",children:"Cogpit is waiting for an administrator to finish server setup."});const em=a.jsx(Jb,{activeError:pA,clearActiveError:Yf,modelFallbackNotice:X6,dismissModelFallbackNotice:D0,connectionLost:hA,theme:f.activeTheme}),ab=c?a.jsx(_O,{state:br.confirmState,isApplying:br.isApplying,applyError:br.applyError,onConfirm:br.confirmApply,onCancel:br.confirmCancel}):null,gA=Qo!==null&&m.session?m.session.turns.slice(Qo):[],lb=c&&Qo!==null&&ib.length>0&&a.jsx(w.Suspense,{fallback:null,children:a.jsx(Jhe,{open:mA,branches:ib,branchPointTurnIndex:Qo,currentTurns:gA,onClose:$t.handleCloseBranchModal,onCloseComplete:()=>ob(null),onRedoToTurn:aA,onRedoEntireBranch:lA})}),cb=u&&a.jsx(gO,{processes:re.processes,activeProcessId:re.activeProcessId,collapsed:re.collapsed,onSetActive:re.setActive,onRemove:re.removeProcess,onToggleCollapse:re.toggleCollapse,onRequestTerminal:pt("terminal")?he:void 0,onAddTerminalContext:Le=>{var Db,Fb,Ub;const it=Le.trim();if(!it)return;const sn=it.includes("```")?"````":"```",vr=`${sn}terminal
|
|
467
|
+
${it}
|
|
468
|
+
${sn}`,tm=((Db=C.current)==null?void 0:Db.getText().trimEnd())??"";(Fb=C.current)==null||Fb.setText(tm?`${tm}
|
|
469
|
+
|
|
470
|
+
${vr}
|
|
471
|
+
`:`${vr}
|
|
472
|
+
`),(Ub=C.current)==null||Ub.focus()},onUpdateStatus:re.updateProcessStatus,projectDir:le,onProcessStarted:re.addProcess,mobile:d}),ub=vn&&a.jsx(l8,{teamName:vn.config.name||vn.teamName,members:vn.config.members,currentMemberName:m.currentMemberName,loadingMember:m.loadingMember,onMemberClick:js.handleTeamMemberSwitch}),db=Ke&&a.jsx(w.Suspense,{fallback:null,children:a.jsx(Qhe,{open:N.showWorkflows,onOpenChange:N.setShowWorkflows,dirName:Ne.dirName,sessionId:Ne.sessionId,workflows:He.workflows,isLive:He.isLive,canStop:Z.stop,onRefetchList:He.refetch},`${Ne.dirName??""}:${Ne.sessionId??""}`)}),Ec=V.goals?m.session:null,fb=Le=>{var it;return a.jsx(r8,{mobile:d,agentKind:F,onAgentKindChange:pa?nA:void 0,selectedModel:ua,onModelChange:qf,selectedEffort:wc,onEffortChange:Vf,contextWindowTokens:yc,onContextWindowTokensChange:Wf?Bf:void 0,fastModeEnabled:Sc,onFastModeEnabledChange:Z6?Hf:void 0,isNewSession:pa,worktreeEnabled:eA,onWorktreeEnabledChange:pa&&Y?tA:void 0,ultracodeEnabled:kc,onUltracodeEnabledChange:Y6?Kf:void 0,onApplySettings:$t.handleApplySettings,activeModelId:(it=m.session)==null?void 0:it.model,mcpServers:X?ss.servers:void 0,selectedMcpServers:X?ss.selectedServers:void 0,onToggleMcpServer:X?ss.toggleServer:void 0,onSetMcpServers:X?ss.setSelection:void 0,onRefreshMcpServers:X?ss.refresh:void 0,mcpLoading:X?ss.loading:void 0,onMcpAuth:X?xe:void 0,permissionMode:Bt.config.mode,onPermissionModeChange:Bt.setMode,mobileExtra:Le&&Ec?a.jsx(jv,{}):void 0,trailingExtra:Le&&Ec?a.jsx(jv,{}):void 0})},xA=fb(!0),bA=fb(!1),mb=a.jsxs("div",{className:G("shrink-0",d&&"bg-background"),children:[a.jsx(B9,{}),a.jsx(Fh,{ref:C,allowImages:z0,agentKind:F,projectCwd:le,footer:xA})]}),Tc=Ec?a.jsx(U9,{agentKind:F,session:Ec,onSendCommand:Mt.sendMessage,children:mb}):mb,vA=a.jsx("div",{className:G("shrink-0",d&&"bg-background"),children:a.jsx(Fh,{ref:C,allowImages:z0,agentKind:F,projectCwd:le,footer:bA})}),pb=Mt.pendingMessages.map((Le,it)=>a.jsx(UN,{message:Le,turnNumber:it+1},it)),yA=d?m.mobileTab==="workspace"&&N.activeWorkspacePanel===zt.sessionInfo:N.activeWorkspacePanel===zt.sessionInfo,hb=m.session&&!yA&&a.jsx("div",{className:"hidden",children:a.jsx(Qj,{cwd:m.session.cwd,turns:m.session.turns,onServersChanged:re.handleServersChanged})});return n?a.jsxs(_u,{value:Xf,children:[a.jsx(lm,{children:a.jsx(Su,{value:Jf,chatValue:Qf,children:a.jsx(ym,{value:rt,agentProgress:Ct,children:a.jsx(Ime,{sessionId:n,loadError:iA,searchInputRef:S,activeComposer:Zf||vA,hasMoreTurns:v.hasMore,isLoadingOlderTurns:v.isLoadingOlder,onLoadMoreTurns:v.loadMore})})})}),em]}):d?a.jsxs(_u,{value:Xf,children:[a.jsx(lm,{enabled:u,children:a.jsx(Su,{value:Jf,chatValue:Qf,children:a.jsx(ym,{value:rt,agentProgress:Ct,children:a.jsx(Ame,{navigation:{panels:N,actions:js,handlers:$t,creatingSession:W0,pendingSession:K0,onStartNewSession:G0,onStartNewFolder:Z0,onSelectProject:L,liveSessionsRefreshRef:H0,onPrefetchSession:y},sessionView:{chatInputRef:C,searchInputRef:S,teamMembersBar:ub,activeComposer:Zf||Tc,pendingComposer:Tc,pendingTurns:pb,todoProgress:je&&a.jsx(BN,{progress:je}),hasMoreTurns:v.hasMore,isLoadingOlderTurns:v.isLoadingOlder,onLoadMoreTurns:v.loadMore,onBackToMain:rb,onShowWorkflows:Ye,onToggleExpandAll:I,workflowCount:Ce,pendingPath:U},project:{currentCwd:le,supportsWorktrees:Y,worktrees:qe,projectFilesRoot:oe,projectFilesRequest:ie,processPanel:re,backgroundAgents:ns,hasFileChanges:c&&be,onOpenTerminal:ce},chrome:{backgroundServers:hb,processPanel:cb,workflowsPanel:db,undoDialog:ab,branchModal:lb,fileChangesOpen:Xe,onFileChangesOpenChange:nt,onLogout:t.logout}})})})}),em]}):a.jsxs(_u,{value:Xf,children:[a.jsx(lm,{enabled:u,children:a.jsx(Su,{value:Jf,chatValue:Qf,children:a.jsx(ym,{value:rt,agentProgress:Ct,children:a.jsx(hme,{navigation:{panels:N,actions:js,handlers:$t,creatingSession:W0,pendingSession:K0,onStartNewSession:G0,onStartNewFolder:Z0,onSelectProject:L,onOpenPaletteProject:oA,liveSessionsRefreshRef:H0,onPrefetchSession:y},sessionView:{searchInputRef:S,chatInputRef:C,teamMembersBar:ub,activeComposer:Zf||Tc,pendingComposer:Tc,pendingTurns:pb,todoProgress:je,todosExpanded:Me,onTodosExpandedChange:sA,hasMoreTurns:v.hasMore,isLoadingOlderTurns:v.isLoadingOlder,onLoadMoreTurns:v.loadMore,onBackToMain:rb,onShowWorkflows:Ye,workflowCount:Ce},project:{processPanel:re,worktrees:qe,backgroundAgents:ns,supportsWorktrees:Y,hasFileChanges:c&&be,currentCwd:le,showPreview:ae,showProjectFiles:c&&ue,projectFilesRoot:oe,projectFilesRequest:ie,launchTerminalRequest:fe,pendingProject:de,onOpenTerminal:ce,onTogglePreview:ye,onToggleProjectFiles:ve,onCloseRightWorkspace:ke},chrome:{backgroundServers:hb,processPanel:cb,workflowsPanel:db,undoDialog:ab,branchModal:lb,killing:cA,onKillAll:uA,commandPaletteOpen:E,onCommandPaletteOpenChange:T,onOpenCommandPalette:$,onFocusComposer:O,onExpandAll:M,onExpandToolPayloads:R,onCollapseAll:z,keyboardShortcutsOpen:A,onKeyboardShortcutsOpenChange:P,onLogout:t.logout}})})})}),em]})}const q6={unreachable:{title:"Remote device unavailable",description:n=>`Can’t reach ${n}. Cogpit will keep retrying.`},"bad-password":{title:"Device credentials need attention",description:n=>`${n} rejected the stored password. Update it in Devices.`},refused:{title:"Device not admitting this account",description:n=>`${n} is not admitting this account right now. Cogpit will keep retrying.`}};function nge(n,e){return n.kind==="refused"&&n.detail?`${n.detail} Cogpit will keep retrying.`:q6[n.kind].description(e)}const sge=new Map(Object.entries({DEVICE_AUTH_FAILED:"bad-password",DEVICE_REFUSED:"refused"}));function rge(n){return{kind:sge.get(n??"")??"unreachable"}}function oge(n){return n.ok?null:n.reachable&&n.authState==="bad-password"?{kind:"bad-password"}:n.code==="DEVICE_REFUSED"?{kind:"refused",detail:n.error}:{kind:"unreachable"}}function ige(){var y;const[n,e]=w.useState(Dt),[t,s]=w.useState(()=>vu(Dt())),[r,o]=w.useState(xs),[i,l]=w.useState(0),[c,u]=w.useState(null),[d,f]=w.useState(!1),{devices:m,testDevice:p}=la();w.useEffect(()=>{const v=()=>{const k=Dt();e(j=>j===k?j:k),s(vu(k))};return window.addEventListener("cogpit-device-changed",v),window.addEventListener("popstate",v),()=>{window.removeEventListener("cogpit-device-changed",v),window.removeEventListener("popstate",v)}},[]),w.useEffect(()=>{const v=k=>{const j=k.detail;(j==null?void 0:j.deviceId)===Dt()&&s(vu(j.deviceId))};return window.addEventListener("cogpit-device-scope-changed",v),()=>window.removeEventListener("cogpit-device-scope-changed",v)},[]),w.useEffect(()=>{const v=()=>o(xs());return window.addEventListener("cogpit-identity-changed",v),()=>window.removeEventListener("cogpit-identity-changed",v)},[]),w.useEffect(()=>(window.__cogpitRevealSession=Mx,()=>{delete window.__cogpitRevealSession}),[]),w.useEffect(()=>{const v=k=>{const j=[Et,...m.map(C=>C.id)],_=Dt();let N;const S=iH(k);if(S!==null)N=j[S-1];else if(aH(k)){const C=j.indexOf(_);N=j[(C+1)%j.length]}!N||N===_||(k.preventDefault(),Fs(N))};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[m]),w.useEffect(()=>{u(null),f(!1)},[n,t]);const h=w.useCallback(async()=>{const v=fn(),k=()=>fn()===v;f(!0);try{const j=oge(await p(n));if(!k())return;u(j),j===null&&l(_=>_+1)}finally{k()&&f(!1)}},[n,p]),g=c==null?void 0:c.kind;w.useEffect(()=>{const v=k=>{const j=k.detail;if(!(j!=null&&j.deviceId)||j.deviceId!==Dt())return;const _=rge(j.reason);_.kind!==g&&(u(_),_.kind==="refused"&&h())};return window.addEventListener("cogpit-device-unreachable",v),()=>window.removeEventListener("cogpit-device-unreachable",v)},[g,h]);const x=c!==null&&c.kind!=="bad-password";w.useEffect(()=>{if(!x)return;const v=setInterval(()=>void h(),1e4);return()=>clearInterval(v)},[x,h]);const b=((y=m.find(v=>v.id===n))==null?void 0:y.name)??n;return a.jsxs(a.Fragment,{children:[c&&n!==Et&&a.jsxs(Jt,{role:"status",className:"fixed inset-x-3 top-3 z-40 mx-auto max-w-2xl border-warning/40 bg-popover shadow-md",children:[a.jsx(BP,{"data-icon":"inline-start",className:"text-warning"}),a.jsx(_n,{children:q6[c.kind].title}),a.jsx(Qt,{children:nge(c,b)}),a.jsxs("div",{className:"col-start-2 mt-2 flex flex-wrap gap-2",children:[x&&a.jsxs(ee,{variant:"outline",size:"xs",onClick:()=>void h(),disabled:d,children:[d&&a.jsx(vt,{"data-icon":"inline-start",className:"animate-spin"}),d?"Retrying":"Retry now"]}),a.jsx(ee,{variant:"outline",size:"xs",onClick:()=>Fs(Et),children:"Switch to this machine"})]})]}),a.jsx(NU,{children:a.jsx(dfe,{children:a.jsx(tge,{})})},`${n}:${t}:${i}:${r??""}`)]})}const s3="Invalid link or passphrase.";function age(n,e){return n===401?s3:n===429?e||"Too many attempts. Try again in a minute.":n===426?"This link needs a secure HTTPS connection. Open the tunnel URL instead of the plain http address.":n===403?"Network access is off on the host, so this session cannot be joined right now.":e||s3}function lge({sessionId:n,onAuthenticated:e}){const[t,s]=w.useState(""),[r,o]=w.useState(!1),[i,l]=w.useState(null),[c,u]=w.useState(!1),d=w.useCallback(async f=>{if(f.preventDefault(),!!t.trim()){u(!0),l(null);try{const m=await fetch("/api/share/verify",{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"Content-Type":"application/json","X-Cogpit-Client":"1"},body:JSON.stringify({sessionId:n,passphrase:t})}),p=await m.json();m.ok&&p.valid?(s(""),e()):l(age(m.status,p.error))}catch{l("Failed to connect to server")}finally{u(!1)}}},[e,t,n]);return a.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-canvas px-4 py-8",children:a.jsx("form",{onSubmit:d,className:"w-full max-w-sm",children:a.jsxs(Ts,{children:[a.jsxs(Ys,{children:[a.jsx("div",{className:"mb-2 flex size-9 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:a.jsx(Bs,{className:"size-4"})}),a.jsx(Xs,{children:"Join this session"}),a.jsx(Js,{children:"Enter the passphrase you were given to join the shared session."})]}),a.jsxs(As,{className:"flex flex-col gap-4",children:[a.jsx(Vl,{children:a.jsxs(un,{children:[a.jsx(dn,{htmlFor:"share-passphrase",children:"Passphrase"}),a.jsxs(So,{children:[a.jsx(ko,{id:"share-passphrase",type:r?"text":"password",value:t,onChange:f=>s(f.target.value),placeholder:"copper-lantern-drift-92",autoComplete:"current-password",autoFocus:!0}),a.jsx(or,{align:"inline-end",children:a.jsx(Jd,{size:"icon-xs",onClick:()=>o(f=>!f),"aria-label":r?"Hide passphrase":"Show passphrase",children:r?a.jsx(n1,{}):a.jsx(Zi,{})})})]})]})}),i&&a.jsxs(Jt,{variant:"destructive",children:[a.jsx(Ds,{"aria-hidden":"true"}),a.jsx(_n,{children:"Could not join"}),a.jsx(Qt,{children:i})]})]}),a.jsx(Xd,{children:a.jsxs(ee,{type:"submit",className:"w-full",disabled:c||!t.trim(),children:[c&&a.jsx(An,{"data-icon":"inline-start"}),"Connect"]})})]})})})}function cge(){const n=q.c(9),[e,t]=w.useState("idle"),[s,r]=w.useState();let o;n[0]===Symbol.for("react.memo_cache_sentinel")?(o=[],n[0]=o):o=n[0];const[i,l]=w.useState(o);let c;n[1]===Symbol.for("react.memo_cache_sentinel")?(c=(x,b)=>(l(y=>[...y,x]),t("connected"),r(void 0),x9(x,b).then(y=>{if(y.ok){t("idle");return}r(`Request failed (${y.status})`),t("error"),l(mge)}).catch(y=>{r(y instanceof Error?y.message:"Unknown error"),t("error"),l(fge)}).then(dge)),n[1]=c):c=n[1];const u=c;let d;n[2]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{b9().catch(uge),t("idle"),l([])},n[2]=d):d=n[2];const f=d;let m;n[3]===Symbol.for("react.memo_cache_sentinel")?(m=x=>{const b=x===void 0?1:x;l(y=>y.slice(b))},n[3]=m):m=n[3];const p=m,h=e==="connected";let g;return n[4]!==s||n[5]!==i||n[6]!==e||n[7]!==h?(g={status:e,error:s,pendingMessages:i,isConnected:h,sendMessage:u,interrupt:f,stopAgent:f,consumePending:p},n[4]=s,n[5]=i,n[6]=e,n[7]=h,n[8]=g):g=n[8],g}function uge(){}function dge(){return!0}function fge(n){return n.slice(0,-1)}function mge(n){return n.slice(0,-1)}const pge=2e3;function hge(n,e){return n.length!==e.length?!1:JSON.stringify(n)===JSON.stringify(e)}function gge(){const n=q.c(11);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],n[0]=e):e=n[0];const[t,s]=w.useState(e);let r;n[1]===Symbol.for("react.memo_cache_sentinel")?(r=new Set,n[1]=r):r=n[1];const[o,i]=w.useState(r);let l,c;n[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{let h=!1;const g=async()=>{const y=await S9();h||y===null||s(v=>hge(v,y)?v:y)},x=()=>{document.visibilityState==="visible"&&g()};x();const b=setInterval(x,pge);return document.addEventListener("visibilitychange",x),()=>{h=!0,clearInterval(b),document.removeEventListener("visibilitychange",x)}},c=[],n[2]=l,n[3]=c):(l=n[2],c=n[3]),w.useEffect(l,c);let u;n[4]===Symbol.for("react.memo_cache_sentinel")?(u=(h,g)=>{i(x=>new Set(x).add(h)),y9(h,g).then(x=>{x&&s(b=>b.filter(y=>y.requestId!==h))}).finally(()=>{i(x=>{const b=new Set(x);return b.delete(h),b})})},n[4]=u):u=n[4];const d=u;let f;n[5]!==t?(f=h=>{for(const g of t)d(g.requestId,h)},n[5]=t,n[6]=f):f=n[6];const m=f;let p;return n[7]!==t||n[8]!==m||n[9]!==o?(p={requests:t,responding:o,respond:d,respondAll:m},n[7]=t,n[8]=m,n[9]=o,n[10]=p):p=n[10],p}const xge={edition:"personal",user:null,capabilities:Qi};function bge(n){var he,ye;const e=q.c(78),{info:t,children:s}=n,r=$0(),o=j6(),[i,l]=v6(),{parse:c,append:u}=M6(),[d,f]=w.useState("loading");let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=[],e[0]=m):m=e[0],w.useEffect(Sge,m);const p=cge(),h=gge();let g;e[1]!==l||e[2]!==t.dirName||e[3]!==t.fileName||e[4]!==r||e[5]!==c?(g=async()=>{try{const{parsed:ve,source:ke}=await S6(t.dirName,t.fileName,c,"shared session");l({type:"LOAD_SESSION",session:ve,source:ke,isMobile:r}),f("ready")}catch{f("failed")}},e[1]=l,e[2]=t.dirName,e[3]=t.fileName,e[4]=r,e[5]=c,e[6]=g):g=e[6];const x=g,b=w.useRef(!1);let y,v;e[7]!==x?(y=()=>{b.current||(b.current=!0,x())},v=[x],e[7]=x,e[8]=y,e[9]=v):(y=e[8],v=e[9]),w.useEffect(y,v);let k;e[10]!==l?(k=ve=>{l({type:"UPDATE_SESSION",session:ve})},e[10]=l,e[11]=k):k=e[11];const j=k,{isLive:_,sseState:N,isCompacting:S,turnError:C}=g6(i.sessionSource,j,c,u,void 0,i.session);let E;e[12]!==l?(E=ve=>{l({type:"SET_OLDER_TURNS",turns:ve})},e[12]=l,e[13]=E):E=e[13];const T=E,A=((he=i.sessionSource)==null?void 0:he.dirName)??null,P=((ye=i.sessionSource)==null?void 0:ye.fileName)??null;let I;e[14]!==T||e[15]!==i.sessionChangeKey||e[16]!==A||e[17]!==P||e[18]!==c?(I={dirName:A,fileName:P,sessionChangeKey:i.sessionChangeKey,workerParse:c,onOlderTurns:T},e[14]=T,e[15]=i.sessionChangeKey,e[16]=A,e[17]=P,e[18]=c,e[19]=I):I=e[19];const $=z6(I);let O;e[20]!==p.consumePending||e[21]!==p.pendingMessages||e[22]!==_||e[23]!==i.session||e[24]!==i.sessionChangeKey?(O={session:i.session,isLive:_,pendingMessages:p.pendingMessages,consumePending:p.consumePending,sessionChangeKey:i.sessionChangeKey},e[20]=p.consumePending,e[21]=p.pendingMessages,e[22]=_,e[23]=i.session,e[24]=i.sessionChangeKey,e[25]=O):O=e[25];const M=y6(O),R=$6(i.session,i.sessionSource,x,!1);let z;e[26]!==i.session?(z=i.session?kN(i.session):null,e[26]=i.session,e[27]=z):z=e[27];const W=z;let D;e[28]!==l?(D=()=>{l({type:"TOGGLE_EXPAND_ALL"})},e[28]=l,e[29]=D):D=e[29];const L=D,U=yge,F=vge;let B;e[30]!==t.dirName?(B=nn(t.dirName),e[30]=t.dirName,e[31]=B):B=e[31];let V;e[32]!==B?(V={configLoading:!1,configError:null,claudeDir:null,defaultAgentKind:B,setClaudeDir:F,showConfigDialog:!1,openConfigDialog:F,handleCloseConfigDialog:F,handleConfigSaved:F,retryConfig:F,networkUrl:null,networkAccessDisabled:!1},e[32]=B,e[33]=V):V=e[33];let H;e[34]!==l||e[35]!==r||e[36]!==i||e[37]!==V||e[38]!==o?(H={state:i,dispatch:l,config:V,theme:o,isMobile:r},e[34]=l,e[35]=r,e[36]=i,e[37]=V,e[38]=o,e[39]=H):H=e[39];const K=H,Z=i.session,Y=i.sessionSource,X=h.requests,se=h.responding,Q=h.respond,te=h.respondAll;let J,ne;e[40]===Symbol.for("react.memo_cache_sentinel")?(J=Ki("interact"),ne=[],e[40]=J,e[41]=ne):(J=e[40],ne=e[41]);let re;e[42]!==L?(re={handleStopSession:U,handleOpenBranches:F,handleBranchFromHere:F,handleToggleExpandAll:L,handleLoadSession:F},e[42]=L,e[43]=re):re=e[43];let le;e[44]!==S||e[45]!==_||e[46]!==W||e[47]!==h.requests||e[48]!==h.respond||e[49]!==h.respondAll||e[50]!==h.responding||e[51]!==N||e[52]!==i.session||e[53]!==i.sessionSource||e[54]!==re||e[55]!==C||e[56]!==R?(le={session:Z,sessionSource:Y,isLive:_,sseState:N,isCompacting:S,turnError:C,undoRedo:R,pendingInteraction:W,permissionRequests:X,permissionResponding:se,respondPermission:Q,respondAllPermissions:te,isSubAgentView:!1,permissions:J,slashSuggestions:ne,slashSuggestionsLoading:!1,promptSuggestion:null,rateLimit:null,actions:re},e[44]=S,e[45]=_,e[46]=W,e[47]=h.requests,e[48]=h.respond,e[49]=h.respondAll,e[50]=h.responding,e[51]=N,e[52]=i.session,e[53]=i.sessionSource,e[54]=re,e[55]=C,e[56]=R,e[57]=le):le=e[57];const ae=le;let ue;e[58]!==p||e[59]!==M?(ue={chat:p,scroll:M},e[58]=p,e[59]=M,e[60]=ue):ue=e[60];const oe=ue;let ie;e[61]!==$?(ie=()=>{$.loadMore()},e[61]=$,e[62]=ie):ie=e[62];let fe;e[63]!==d||e[64]!==$.hasMore||e[65]!==$.isLoadingOlder||e[66]!==ie?(fe={loadState:d,hasMore:$.hasMore,isLoadingOlder:$.isLoadingOlder,loadMore:ie},e[63]=d,e[64]=$.hasMore,e[65]=$.isLoadingOlder,e[66]=ie,e[67]=fe):fe=e[67];const de=fe;let ce;e[68]!==s||e[69]!==de?(ce=s(de),e[68]=s,e[69]=de,e[70]=ce):ce=e[70];let xe;e[71]!==oe||e[72]!==ae||e[73]!==ce?(xe=a.jsx(Su,{value:ae,chatValue:oe,children:ce}),e[71]=oe,e[72]=ae,e[73]=ce,e[74]=xe):xe=e[74];let pe;return e[75]!==K||e[76]!==xe?(pe=a.jsx(_u,{value:K,children:xe}),e[75]=K,e[76]=xe,e[77]=pe):pe=e[77],pe}function vge(){}async function yge(){await v9().catch(wge)}function wge(){}function Sge(){Ha(xge)}function kge(n){const e=q.c(6),{info:t}=n,s=w.useRef(null);let r;e[0]!==t.provider||e[1]!==t.title?(r=i=>a.jsxs("div",{className:"flex h-dvh min-h-0 flex-col bg-canvas",children:[a.jsxs("header",{className:"flex shrink-0 items-center gap-2 border-b px-4 py-2",children:[a.jsx(Bs,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),a.jsx("h1",{className:"truncate text-sm font-medium text-foreground",children:t.title}),a.jsx("span",{className:"ml-auto shrink-0 text-xs text-muted-foreground",children:"Guest view"})]}),i.loadState==="failed"?a.jsx("div",{className:"flex flex-1 items-center justify-center p-6",children:a.jsxs(Jt,{variant:"destructive",className:"max-w-sm",children:[a.jsx(Ds,{"aria-hidden":"true"}),a.jsx(_n,{children:"Session unavailable"}),a.jsx(Qt,{children:"This conversation could not be loaded. It may have been deleted on the host."})]})}):i.loadState==="loading"?a.jsx("div",{className:"flex flex-1 items-center justify-center",role:"status","aria-label":"Loading shared session",children:a.jsx(An,{className:"size-5 text-muted-foreground"})}):a.jsxs(a.Fragment,{children:[a.jsx(yf,{searchInputRef:s,hasMore:i.hasMore,isLoadingOlder:i.isLoadingOlder,onLoadMore:i.loadMore}),a.jsx(Mf,{children:a.jsx(Fh,{agentKind:t.provider,projectCwd:null})})]})]}),e[0]=t.provider,e[1]=t.title,e[2]=r):r=e[2];let o;return e[3]!==t||e[4]!==r?(o=a.jsx(bge,{info:t,children:r}),e[3]=t,e[4]=r,e[5]=o):o=e[5],o}function vh(n){const e=q.c(2),{children:t}=n;let s;return e[0]!==t?(s=a.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-canvas px-4 py-8",children:a.jsx("div",{className:"w-full max-w-sm",children:t})}),e[0]=t,e[1]=s):s=e[1],s}function jge(){const n=q.c(19);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=Dj(window.location.pathname),n[0]=e):e=n[0];const t=e;let s;n[1]===Symbol.for("react.memo_cache_sentinel")?(s=t?{kind:"probing"}:{kind:"error",message:"This share link is not valid."},n[1]=s):s=n[1];const[r,o]=w.useState(s);let i;n[2]===Symbol.for("react.memo_cache_sentinel")?(i=async()=>{o({kind:"probing"});const p=await g9();o(p.status==="ok"?{kind:"ready",info:p.info}:p.status==="unauthenticated"?{kind:"login"}:{kind:"error",message:p.message})},n[2]=i):i=n[2];const l=i;let c,u;n[3]===Symbol.for("react.memo_cache_sentinel")?(c=()=>{t&&l()},u=[l,t],n[3]=c,n[4]=u):(c=n[3],u=n[4]),w.useEffect(c,u);let d,f;if(n[5]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{const p=()=>{o(Nge)};return window.addEventListener(Dh,p),window.addEventListener("cogpit-auth-required",p),()=>{window.removeEventListener(Dh,p),window.removeEventListener("cogpit-auth-required",p)}},f=[],n[5]=d,n[6]=f):(d=n[5],f=n[6]),w.useEffect(d,f),r.kind==="ready"){let p;return n[7]!==r.info?(p=a.jsx(kge,{info:r.info}),n[7]=r.info,n[8]=p):p=n[8],p}if(r.kind==="login"&&t){let p;return n[9]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsx(lge,{sessionId:t,onAuthenticated:()=>void l()}),n[9]=p):p=n[9],p}if(r.kind==="ended"){let p;return n[10]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsx(vh,{children:a.jsx(Ts,{children:a.jsxs(Ys,{children:[a.jsx("div",{className:"mb-2 flex size-9 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:a.jsx(WP,{className:"size-4"})}),a.jsx(Xs,{children:"Sharing has ended"}),a.jsx(Js,{children:"The host stopped sharing this session or changed its passphrase. Ask for a new link to rejoin."})]})})}),n[10]=p):p=n[10],p}if(r.kind==="error"){let p,h;n[11]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsx(Ds,{"aria-hidden":"true"}),h=a.jsx(_n,{children:"Could not open this session"}),n[11]=p,n[12]=h):(p=n[11],h=n[12]);let g;n[13]!==r.message?(g=a.jsxs(Jt,{variant:"destructive",children:[p,h,a.jsx(Qt,{children:r.message})]}),n[13]=r.message,n[14]=g):g=n[14];let x;n[15]===Symbol.for("react.memo_cache_sentinel")?(x=t&&a.jsx(ee,{className:"mt-3 w-full",onClick:()=>void l(),children:"Try again"}),n[15]=x):x=n[15];let b;return n[16]!==g?(b=a.jsxs(vh,{children:[g,x]}),n[16]=g,n[17]=b):b=n[17],b}let m;return n[18]===Symbol.for("react.memo_cache_sentinel")?(m=a.jsx(vh,{children:a.jsx(Ts,{children:a.jsxs(As,{className:"flex min-h-24 items-center justify-center gap-2",role:"status","aria-label":"Opening shared session",children:[a.jsx(Bs,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),a.jsx(An,{className:"size-5 text-muted-foreground"})]})})}),n[18]=m):m=n[18],m}function Nge(n){return n.kind==="ready"?{kind:"ended"}:n}class Cge extends w.Component{constructor(){super(...arguments);Wt(this,"state",{error:null})}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,s){console.error("[Cogpit] Unhandled render error",t,s.componentStack)}render(){if(!this.state.error)return this.props.children;const t=this.state.error.message||"An unexpected render error occurred.";return a.jsx("main",{className:"flex h-dvh items-center justify-center bg-canvas p-6 text-foreground",children:a.jsxs(Ts,{className:"w-full max-w-lg text-center",children:[a.jsxs(Ys,{className:"justify-items-center",children:[a.jsx(lr,{"aria-hidden":"true",className:"mb-2 size-8 text-destructive"}),a.jsx(Xs,{children:a.jsx("h1",{children:"Cogpit hit a render error"})}),a.jsx(Js,{children:"Reload the app to recover. Your sessions and project files are unchanged."})]}),a.jsx(As,{children:a.jsx("pre",{className:"max-h-40 w-full overflow-auto rounded-md bg-muted p-3 text-left font-mono text-xs whitespace-pre-wrap",children:t})}),a.jsx(Xd,{className:"justify-center",children:a.jsxs(ee,{onClick:()=>window.location.reload(),children:[a.jsx(On,{"data-icon":"inline-start"}),"Reload Cogpit"]})})]})})}}const V6=document.getElementById("root");if(!V6)throw new Error("Root element not found");NA.createRoot(V6).render(a.jsx(w.StrictMode,{children:a.jsx(Cge,{children:Zd(window.location.pathname)?a.jsx(jge,{}):a.jsx(ige,{})})}));export{Yo as $,Jt as A,ee as B,un as C,dr as D,Jd as E,Bq as F,to as G,$W as H,or as I,G as J,vf as K,kn as L,jn as M,Rn as N,Nn as O,Ide as P,Cn as Q,gn as R,XR as S,IW as T,Re as U,ec as V,m4 as W,qO as X,mn as Y,Ue as Z,Ige as _,JR as a,zme as a$,En as a0,vs as a1,zi as a2,Tn as a3,U1 as a4,B1 as a5,W1 as a6,jO as a7,V1 as a8,H1 as a9,Vd as aA,Bd as aB,Eq as aC,m9 as aD,hr as aE,Zh as aF,Qh as aG,_x as aH,gr as aI,Yd as aJ,$1 as aK,aa as aL,Ys as aM,Xs as aN,As as aO,Xd as aP,Ts as aQ,lf as aR,M1 as aS,RN as aT,Ar as aU,Nt as aV,sr as aW,_n as aX,Js as aY,EO as aZ,Xl as a_,q1 as aa,G1 as ab,K1 as ac,Bn as ad,Eu as ae,rH as af,An as ag,Uo as ah,no as ai,M8 as aj,Lge as ak,Gl as al,R1 as am,Zl as an,L8 as ao,F1 as ap,df as aq,WT as ar,yo as as,pt as at,X1 as au,Pr as av,ff as aw,Mi as ax,a4 as ay,l4 as az,QR as b,zl as b$,Gd as b0,dn as b1,Zu as b2,jK as b3,us as b4,Rge as b5,Zn as b6,Ja as b7,IO as b8,Fl as b9,bf as bA,zo as bB,Dge as bC,$n as bD,Di as bE,wO as bF,Wn as bG,Xa as bH,PR as bI,Mge as bJ,oc as bK,rC as bL,wx as bM,nd as bN,XT as bO,Zo as bP,kx as bQ,ffe as bR,KT as bS,P0 as bT,zf as bU,oa as bV,uo as bW,bx as bX,c1 as bY,Zs as bZ,O3 as b_,e4 as ba,$R as bb,IR as bc,Hce as bd,UR as be,zR as bf,BR as bg,DR as bh,FR as bi,MR as bj,Jw as bk,gi as bl,ete as bm,OT as bn,gde as bo,o1e as bp,Gj as bq,Zj as br,Ea as bs,Ta as bt,$ge as bu,Zt as bv,Yt as bw,Xt as bx,gf as by,xf as bz,YR as c,Mue as c0,Bl as c1,Wl as c2,k1 as c3,iR as c4,Oge as c5,nde as c6,Dd as c7,ws as c8,cH as c9,fl as cA,lU as cB,zge as cC,Kge as cD,xt as cE,am as cF,ls as ca,xx as cb,vR as cc,nn as cd,pC as ce,sa as cf,$j as cg,cn as ch,ra as ci,Nr as cj,na as ck,ms as cl,FD as cm,Yu as cn,zD as co,lH as cp,DD as cq,LD as cr,MD as cs,OD as ct,eC as cu,DI as cv,Mhe as cw,Fs as cx,Et as cy,Fd as cz,VR as d,Fge as e,sH as f,Uge as g,fr as h,wo as i,mr as j,pr as k,Gt as l,So as m,ko as n,qge as o,Qt as p,Jl as q,Wge as r,Vge as s,Hge as t,Bge as u,Ade as v,qt as w,S$ as x,la as y,Vl as z};
|