cogpit 2.6.6 → 2.7.4
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 +16883 -10322
- package/dist/web/assets/{CommandPaletteHost-iiTEkWGR.js → CommandPaletteHost-ByD_7YRK.js} +1 -1
- package/dist/web/assets/ConfigBrowser-vXK8JNMg.js +1 -0
- package/dist/web/assets/{HighlightedEditor-7K1IXoMd.js → HighlightedEditor-BwET41dr.js} +1 -1
- package/dist/web/assets/{KeyboardShortcutsDialog-C7QHuM2e.js → KeyboardShortcutsDialog-DQuepxQo.js} +1 -1
- package/dist/web/assets/{MobileFileChanges-qnY-uxZ_.js → MobileFileChanges-B6rggNR6.js} +1 -1
- package/dist/web/assets/PluginsDialog-DTF9NnK7.js +1 -0
- package/dist/web/assets/{PreviewPanel-DBIaGXu0.js → PreviewPanel-BaXxki5D.js} +1 -1
- package/dist/web/assets/ProjectFilesPanel-CO6Znhgi.js +4 -0
- package/dist/web/assets/{ProjectSwitcherModal-BhevYH6F.js → ProjectSwitcherModal-Chi-U3vv.js} +1 -1
- package/dist/web/assets/{TerminalOutput-DnTT9ONj.js → TerminalOutput-CUmbXM9h.js} +1 -1
- package/dist/web/assets/{ThemeSelectorModal-GimQk0yY.js → ThemeSelectorModal-B2m42_1f.js} +1 -1
- package/dist/web/assets/WorkflowsPanel-CiYzHaQg.js +1 -0
- package/dist/web/assets/{WorktreePanel-DbSH2Fyv.js → WorktreePanel-CldMZY3n.js} +1 -1
- package/dist/web/assets/{index-7fgSFumo.js → index-BA1eUNuR.js} +4 -4
- package/dist/web/assets/{index-j1RyyaFQ.js → index-C-0I_ZqI.js} +1 -1
- package/dist/web/assets/index-C6wvrmo0.js +221 -0
- package/dist/web/assets/index-CYN2JttE.js +1 -0
- package/dist/web/assets/index-DYWsIgvZ.css +1 -0
- package/dist/web/assets/index-QH_v3Ygj.js +1 -0
- package/dist/web/assets/session-parser.worker-CnA52U1J.js +29 -0
- package/dist/web/assets/vendor-ui-ZKZkD5k3.js +887 -0
- package/dist/web/index.html +3 -3
- package/package.json +8 -2
- package/dist/web/assets/ConfigBrowser-CV_FDTPG.js +0 -1
- package/dist/web/assets/ProjectFilesPanel-DdllBXuv.js +0 -4
- package/dist/web/assets/WorkflowsPanel-BTeZdY1F.js +0 -1
- package/dist/web/assets/index-Bl7YHn3e.js +0 -1
- package/dist/web/assets/index-C640apmk.css +0 -1
- package/dist/web/assets/index-CVF75nuK.js +0 -153
- package/dist/web/assets/index-CmAiGDkv.js +0 -1
- package/dist/web/assets/session-parser.worker-DlF00ZHH.js +0 -29
- package/dist/web/assets/vendor-ui-C4lFQWec.js +0 -937
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalOutput-CUmbXM9h.js","assets/vendor-react-gGw_S5I_.js","assets/vendor-ui-ZKZkD5k3.js","assets/vendor-shiki-DOn6sF-i.js","assets/vendor-markdown-BE1gYnO9.js","assets/TerminalOutput-6GBZ9nXN.css","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/CommandPaletteHost-ByD_7YRK.js","assets/index-C-0I_ZqI.js","assets/KeyboardShortcutsDialog-DQuepxQo.js","assets/ProjectSwitcherModal-Chi-U3vv.js","assets/ThemeSelectorModal-B2m42_1f.js","assets/ProjectFilesPanel-CO6Znhgi.js","assets/HighlightedEditor-BwET41dr.js","assets/WorktreePanel-CldMZY3n.js","assets/index-QH_v3Ygj.js","assets/index-CYN2JttE.js","assets/ConfigBrowser-vXK8JNMg.js","assets/PreviewPanel-BaXxki5D.js","assets/PluginsDialog-DTF9NnK7.js","assets/MobileFileChanges-B6rggNR6.js","assets/index-BA1eUNuR.js","assets/WorkflowsPanel-CiYzHaQg.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var tE=Object.defineProperty;var nE=(n,e,t)=>e in n?tE(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var qt=(n,e,t)=>nE(n,typeof e!="symbol"?e+"":e,t);import{j as a,d as Ne,e as sE,c as q,r as w,a as rE,f as oE}from"./vendor-react-gGw_S5I_.js";import{aF as iE,aG as aE,aH as lE,aI as _r,af as ht,aJ as cE,N as Us,aK as Wh,av as Tr,aL as uE,aM as dE,aN as fE,aO as mE,aP as pE,aQ as hE,a3 as It,aR as gE,J as Bt,aS as xE,an as SS,b as Un,aT as bE,aU as kS,aV as vE,aW as yE,aX as wE,aY as SE,aZ as kE,a_ as jS,a$ as su,h as Da,b0 as NS,G as Qr,b1 as qh,b2 as jE,b3 as NE,b4 as CE,b5 as _E,b6 as TE,b7 as EE,b8 as AE,b9 as PE,ba as IE,bb as $E,bc as RE,bd as OE,be as ME,bf as LE,bg as Hu,bh as Vh,bi as Hh,bj as Kh,bk as CS,bl as Gh,bm as ul,X as Wt,bn as Zh,bo as zE,I as Yh,ag as Bs,bp as DE,bq as _S,br as TS,bs as pi,bt as mo,bu as FE,bv as UE,bw as BE,bx as WE,by as Fa,S as Bn,z as yi,bz as yr,bA as ES,bB as qE,bC as VE,bD as AS,bE as PS,bF as IS,bG as $S,bH as RS,bI as OS,bJ as HE,bK as KE,bL as GE,ai as Ku,bM as ZE,a0 as Gu,o as wi,ab as Mi,bN as Cp,bO as YE,bP as XE,bQ as JE,bR as QE,bS as e6,bT as t6,bU as n6,bV as Xh,bW as s6,bX as zs,A as fs,bY as r6,bZ as o6,b_ as i6,b$ as a6,c0 as l6,c1 as c6,c2 as Ua,c3 as Li,c4 as u6,j as Zu,c5 as d6,c6 as f6,c7 as m6,c8 as p6,c9 as h6,ca as g6,cb as x6,cc as b6,cd as v6,ce as y6,C as at,P as Qs,y as zi,d as MS,cf as w6,cg as S6,ch as k6,ci as j6,F as Si,aj as po,cj as N6,ck as LS,Y as Jh,f as Yu,aa as Xu,cl as C6,cm as Qh,cn as _p,co as _6,R as eg,cp as T6,cq as E6,a1 as eo,c as zS,cr as A6,t as dl,cs as P6,a2 as Ca,ct as I6,cu as ru,cv as tg,l as Di,cw as $6,cx as R6,cy as O6,cz as DS,cA as M6,cB as Xl,cC as bo,al as yb,k as fl,D as ng,cD as L6,a6 as ou,cE as z6,aw as D6,u as Ju,O as Ba,W as sg,cF as F6,cG as U6,a5 as ki,cH as B6,cI as W6,cJ as q6,cK as V6,cL as H6,cM as FS,cN as K6,cO as G6,at as Z6,n as wb,cP as Y6,cQ as Sb,cR as X6,cS as US,i as BS,B as WS,cT as J6,a7 as qS,s as Q6,cU as eA,cV as VS,q as tA,ax as Tp,w as nA,cW as sA,cX as rA,cY as oA,cZ as iA,c_ as aA,p as lA,c$ as cA,d0 as uA,d1 as dA,d2 as fA,ak as rg,aC as og,aB as Ps,d3 as mA,d4 as kb,ae as pA,L as HS,x as KS,ah as hA,Q as gA,ar as xA,d5 as bA,ad as vA,d6 as yA}from"./vendor-ui-ZKZkD5k3.js";import{c as wA,a as SA}from"./vendor-shiki-DOn6sF-i.js";import{r as kA,M as sr}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 jA="modulepreload",NA=function(n){return"/"+n},jb={},Qe=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=NA(u),u in jb)return;jb[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":jA,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 K(...n){return iE(aE(n))}const CA=_r("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 J({className:n,variant:e,size:t,...s}){return a.jsx(lE,{"data-slot":"button",className:K(CA({variant:e,size:t,className:n})),...s})}function is({className:n,...e}){return a.jsx("div",{"data-slot":"empty",className:K("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 as({className:n,...e}){return a.jsx("div",{"data-slot":"empty-header",className:K("flex max-w-sm flex-col items-center gap-2",n),...e})}const _A=_r("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 Is({className:n,variant:e="default",...t}){return a.jsx("div",{"data-slot":"empty-icon","data-variant":e,className:K(_A({variant:e,className:n})),...t})}function ls({className:n,...e}){return a.jsx("div",{"data-slot":"empty-title",className:K("text-sm font-medium tracking-tight",n),...e})}function cs({className:n,...e}){return a.jsx("div",{"data-slot":"empty-description",className:K("text-sm/relaxed text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",n),...e})}function GS({className:n,...e}){return a.jsx("div",{"data-slot":"empty-content",className:K("flex w-full max-w-sm min-w-0 flex-col items-center gap-2.5 text-sm text-balance",n),...e})}function TA(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 EA=n=>{switch(n){case"success":return IA;case"info":return RA;case"warning":return $A;case"error":return OA;default:return null}},AA=Array(12).fill(0),PA=({visible:n,className:e})=>Ne.createElement("div",{className:["sonner-loading-wrapper",e].filter(Boolean).join(" "),"data-visible":n},Ne.createElement("div",{className:"sonner-spinner"},AA.map((t,s)=>Ne.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${s}`})))),IA=Ne.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},Ne.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"})),$A=Ne.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},Ne.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"})),RA=Ne.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},Ne.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"})),OA=Ne.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},Ne.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"})),MA=Ne.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"},Ne.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),Ne.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),LA=()=>{const[n,e]=Ne.useState(document.hidden);return Ne.useEffect(()=>{const t=()=>{e(document.hidden)};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[]),n};let zA=1;const DA=100,Nb=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:zA++};class FA{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-DA;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=Nb(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],Ne.isValidElement(u))o=!1,this.create({id:s,type:"default",message:u});else if(BA(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"&&!Ne.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"&&!Ne.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"&&!Ne.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"&&!Ne.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=Nb(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 Ln=new FA,UA=(n,e)=>Ln.message(n,e),BA=n=>n&&typeof n=="object"&&"ok"in n&&typeof n.ok=="boolean"&&"status"in n&&typeof n.status=="number",WA=UA,qA=()=>Ln.toasts,VA=()=>Ln.getActiveToasts(),ys=Object.assign(WA,{success:Ln.success,info:Ln.info,warning:Ln.warning,error:Ln.error,custom:Ln.custom,message:Ln.message,promise:Ln.promise,dismiss:Ln.dismiss,loading:Ln.loading},{getHistory:qA,getToasts:VA});TA("[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 Jl(n){return n.label!==void 0}const HA=3,KA="24px",GA="16px",Cb=4e3,ZA=356,YA=14,XA=45,JA=200;function Ks(...n){return n.filter(Boolean).join(" ")}function QA(n){const[e,t]=n.split("-"),s=[];return e&&s.push(e),t&&s.push(t),s}const eP=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:v,expanded:y,removeToast:k,defaultRichColors:j,closeButton:C,style:_,cancelButtonStyle:S,actionButtonStyle:N,className:T="",descriptionClassName:E="",duration:A,position:P,gap:I,expandByDefault:O,classNames:R,icons:$,closeButtonAriaLabel:M="Close toast"}=n,[z,F]=Ne.useState(null),[D,L]=Ne.useState(null),[B,U]=Ne.useState(!1),[W,V]=Ne.useState(!1),[H,G]=Ne.useState(!1),[Z,Y]=Ne.useState(!1),[X,ee]=Ne.useState(!1),[Q,ne]=Ne.useState(0),[re,se]=Ne.useState(0),oe=Ne.useRef(f.duration||A||Cb),ae=Ne.useRef(null),ie=Ne.useRef(null),ce=b===0,te=b+1<=g,le=f.type,ge=le??"default",be=f.dismissible!==!1,ue=f.className||"",he=f.descriptionClassName||"",me=Ne.useMemo(()=>x.findIndex(Ee=>Ee.toastId===f.id)||0,[x,f.id]),xe=Ne.useMemo(()=>{var Ee;return(Ee=f.closeButton)!=null?Ee:C},[f.closeButton,C]),je=Ne.useMemo(()=>f.duration||A||Cb,[f.duration,A]),Le=Ne.useRef(0),Se=Ne.useRef(0),Ie=Ne.useRef(0),we=Ne.useRef(null),[Be,De]=P.split("-"),Ue=Ne.useMemo(()=>x.reduce((Ee,Ze,fe)=>fe>=me?Ee:Ee+Ze.height,0),[x,me]),We=LA(),Oe=Ne.useMemo(()=>{var Ee;return(Ee=n.swipeDirections)!=null?Ee:QA(P)},[n.swipeDirections,P]),pe=f.invert||d,ke=le==="loading";Se.current=Ne.useMemo(()=>me*I+Ue,[me,Ue]),Ne.useEffect(()=>{oe.current=je},[je]),Ne.useEffect(()=>{U(!0)},[]),Ne.useEffect(()=>{const Ee=ie.current;if(Ee){const Ze=Ee.getBoundingClientRect().height;return se(Ze),h(fe=>[{toastId:f.id,height:Ze,position:f.position},...fe]),()=>h(fe=>fe.filter(Te=>Te.toastId!==f.id))}},[h,f.id]),Ne.useLayoutEffect(()=>{if(!B)return;const Ee=ie.current,Ze=Ee.style.height;Ee.style.height="auto";const fe=Ee.getBoundingClientRect().height;Ee.style.height=Ze,se(fe),h(Te=>Te.find(He=>He.toastId===f.id)?Te.map(He=>He.toastId===f.id?{...He,height:fe}:He):[{toastId:f.id,height:fe,position:f.position},...Te])},[B,f.title,f.description,h,f.id,f.jsx,f.action,f.cancel]);const _e=Ne.useCallback(()=>{V(!0),ne(Se.current),h(Ee=>Ee.filter(Ze=>Ze.toastId!==f.id)),setTimeout(()=>{k(f)},JA)},[f,k,h,Se]);Ne.useEffect(()=>{if(f.promise&&le==="loading"||f.duration===1/0||f.type==="loading")return;let Ee;return y||p||We?(()=>{if(Ie.current<Le.current){const Te=new Date().getTime()-Le.current;oe.current=oe.current-Te}Ie.current=new Date().getTime()})():(()=>{oe.current!==1/0&&(Le.current=new Date().getTime(),Ee=setTimeout(()=>{f.onAutoClose==null||f.onAutoClose.call(f,f),_e()},oe.current))})(),()=>clearTimeout(Ee)},[y,p,f,le,We,_e]),Ne.useEffect(()=>{f.delete&&(_e(),f.onDismiss==null||f.onDismiss.call(f,f))},[_e,f.delete]);function ye(){var Ee;if($!=null&&$.loading){var Ze;return Ne.createElement("div",{className:Ks(R==null?void 0:R.loader,f==null||(Ze=f.classNames)==null?void 0:Ze.loader,"sonner-loader"),"data-visible":le==="loading"},$.loading)}return Ne.createElement(PA,{className:Ks(R==null?void 0:R.loader,f==null||(Ee=f.classNames)==null?void 0:Ee.loader),visible:le==="loading"})}const Pe=f.icon||($==null?void 0:$[le])||EA(le);var Ye,Xe;return Ne.createElement("li",{tabIndex:0,ref:ie,className:Ks(T,ue,R==null?void 0:R.toast,f==null||(e=f.classNames)==null?void 0:e.toast,R==null?void 0:R[ge],f==null||(t=f.classNames)==null?void 0:t[ge]),"data-sonner-toast":"","data-rich-colors":(Ye=f.richColors)!=null?Ye:j,"data-styled":!(f.jsx||f.unstyled||m),"data-mounted":B,"data-promise":!!f.promise,"data-swiped":X,"data-removed":W,"data-visible":te,"data-y-position":Be,"data-x-position":De,"data-index":b,"data-front":ce,"data-swiping":H,"data-dismissible":be,"data-type":le,"data-invert":pe,"data-swipe-out":Z,"data-swipe-direction":D,"data-expanded":!!(y||O&&B),"data-testid":f.testId,style:{"--index":b,"--toasts-before":b,"--z-index":v.length-b,"--offset":`${W?Q:Se.current}px`,"--initial-height":O?"auto":`${re}px`,..._,...f.style},onDragEnd:()=>{G(!1),F(null),we.current=null},onPointerDown:Ee=>{Ee.button!==2&&(ke||!be||(ae.current=new Date,ne(Se.current),Ee.target.setPointerCapture(Ee.pointerId),Ee.target.tagName!=="BUTTON"&&(G(!0),we.current={x:Ee.clientX,y:Ee.clientY})))},onPointerUp:()=>{var Ee,Ze,fe;if(Z||!be)return;we.current=null;const Te=Number(((Ee=ie.current)==null?void 0:Ee.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Ve=Number(((Ze=ie.current)==null?void 0:Ze.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),He=new Date().getTime()-((fe=ae.current)==null?void 0:fe.getTime()),$e=z==="x"?Te:Ve,tt=Math.abs($e)/He;if((z==="x"?Oe.includes(Te>0?"right":"left"):Oe.includes(Ve>0?"bottom":"top"))&&(Math.abs($e)>=XA||tt>.11)){ne(Se.current),f.onDismiss==null||f.onDismiss.call(f,f),L(z==="x"?Te>0?"right":"left":Ve>0?"down":"up"),_e(),Y(!0);return}else{var ut,vt;(ut=ie.current)==null||ut.style.setProperty("--swipe-amount-x","0px"),(vt=ie.current)==null||vt.style.setProperty("--swipe-amount-y","0px")}ee(!1),G(!1),F(null)},onPointerMove:Ee=>{var Ze,fe,Te;if(!we.current||!be||((Ze=window.getSelection())==null?void 0:Ze.toString().length)>0)return;const He=Ee.clientY-we.current.y,$e=Ee.clientX-we.current.x;!z&&(Math.abs($e)>1||Math.abs(He)>1)&&F(Math.abs($e)>Math.abs(He)?"x":"y");let tt={x:0,y:0};const bt=ut=>1/(1.5+Math.abs(ut)/20);if(z==="y"){if(Oe.includes("top")||Oe.includes("bottom"))if(Oe.includes("top")&&He<0||Oe.includes("bottom")&&He>0)tt.y=He;else{const ut=He*bt(He);tt.y=Math.abs(ut)<Math.abs(He)?ut:He}}else if(z==="x"&&(Oe.includes("left")||Oe.includes("right")))if(Oe.includes("left")&&$e<0||Oe.includes("right")&&$e>0)tt.x=$e;else{const ut=$e*bt($e);tt.x=Math.abs(ut)<Math.abs($e)?ut:$e}(Math.abs(tt.x)>0||Math.abs(tt.y)>0)&&ee(!0),(fe=ie.current)==null||fe.style.setProperty("--swipe-amount-x",`${tt.x}px`),(Te=ie.current)==null||Te.style.setProperty("--swipe-amount-y",`${tt.y}px`)}},xe&&!f.jsx&&le!=="loading"?Ne.createElement("button",{"aria-label":M,"data-disabled":ke,"data-close-button":!0,onClick:ke||!be?()=>{}:()=>{_e(),f.onDismiss==null||f.onDismiss.call(f,f)},className:Ks(R==null?void 0:R.closeButton,f==null||(s=f.classNames)==null?void 0:s.closeButton)},(Xe=$==null?void 0:$.close)!=null?Xe:MA):null,(le||f.icon||f.promise)&&f.icon!==null&&(($==null?void 0:$[le])!==null||f.icon)?Ne.createElement("div",{"data-icon":"",className:Ks(R==null?void 0:R.icon,f==null||(r=f.classNames)==null?void 0:r.icon)},le==="loading"?f.icon||ye():f.promise?ye():null,le!=="loading"?Pe:null):null,Ne.createElement("div",{"data-content":"",className:Ks(R==null?void 0:R.content,f==null||(o=f.classNames)==null?void 0:o.content)},Ne.createElement("div",{"data-title":"",className:Ks(R==null?void 0:R.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?Ne.createElement("div",{"data-description":"",className:Ks(E,he,R==null?void 0:R.description,f==null||(l=f.classNames)==null?void 0:l.description)},typeof f.description=="function"?f.description():f.description):null),Ne.isValidElement(f.cancel)?f.cancel:f.cancel&&Jl(f.cancel)?Ne.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||S,onClick:Ee=>{Jl(f.cancel)&&be&&(f.cancel.onClick==null||f.cancel.onClick.call(f.cancel,Ee),_e())},className:Ks(R==null?void 0:R.cancelButton,f==null||(c=f.classNames)==null?void 0:c.cancelButton)},f.cancel.label):null,Ne.isValidElement(f.action)?f.action:f.action&&Jl(f.action)?Ne.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||N,onClick:Ee=>{Jl(f.action)&&(f.action.onClick==null||f.action.onClick.call(f.action,Ee),!Ee.defaultPrevented&&_e())},className:Ks(R==null?void 0:R.actionButton,f==null||(u=f.classNames)==null?void 0:u.actionButton)},f.action.label):null)};function _b(){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 tP(n,e){const t={};return[n,e].forEach((s,r)=>{const o=r===1,i=o?"--mobile-offset":"--offset",l=o?GA:KA;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 nP=Ne.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=HA,toastOptions:b,dir:v=_b(),gap:y=YA,icons:k,customAriaLabel:j,containerAriaLabel:C="Notifications"}=e,[_,S]=Ne.useState([]),N=Ne.useMemo(()=>s?_.filter(U=>U.toasterId===s):_.filter(U=>!U.toasterId),[_,s]),T=Ne.useMemo(()=>Array.from(new Set([o].concat(N.filter(U=>U.position).map(U=>U.position)))),[N,o]),[E,A]=Ne.useState([]),[P,I]=Ne.useState(!1),[O,R]=Ne.useState(!1),[$,M]=Ne.useState(m!=="system"?m:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),z=Ne.useRef(null),F=i.join("+").replace(/Key/g,"").replace(/Digit/g,""),D=Ne.useRef(null),L=Ne.useRef(!1),B=Ne.useCallback(U=>{S(W=>{var V;return(V=W.find(H=>H.id===U.id))!=null&&V.delete||Ln.dismiss(U.id),W.filter(({id:H})=>H!==U.id)})},[]);return Ne.useEffect(()=>Ln.subscribe(U=>{if(U.dismiss){requestAnimationFrame(()=>{S(W=>W.map(V=>V.id===U.id?{...V,delete:!0}:V))});return}setTimeout(()=>{sE.flushSync(()=>{S(W=>{const V=W.findIndex(H=>H.id===U.id);return V!==-1?[...W.slice(0,V),{...W[V],...U},...W.slice(V+1)]:[U,...W]})})})}),[]),Ne.useEffect(()=>{if(m!=="system"){M(m);return}if(m==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?M("dark"):M("light")),typeof window>"u")return;const U=window.matchMedia("(prefers-color-scheme: dark)");try{U.addEventListener("change",({matches:W})=>{M(W?"dark":"light")})}catch{U.addListener(({matches:V})=>{try{M(V?"dark":"light")}catch(H){console.error(H)}})}},[m]),Ne.useEffect(()=>{_.length<=1&&I(!1)},[_]),Ne.useEffect(()=>{const U=W=>{var V;if(i.length>0&&i.every(Z=>W[Z]||W.code===Z)){var G;I(!0),(G=z.current)==null||G.focus()}W.code==="Escape"&&(document.activeElement===z.current||(V=z.current)!=null&&V.contains(document.activeElement))&&I(!1)};return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[i]),Ne.useEffect(()=>{if(z.current)return()=>{D.current&&(D.current.focus({preventScroll:!0}),D.current=null,L.current=!1)}},[z.current]),Ne.createElement("section",{ref:t,"aria-label":j??`${C} ${F}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0,"data-react-aria-top-layer":!0},T.map((U,W)=>{var V;const[H,G]=U.split("-");return N.length?Ne.createElement("ol",{key:U,dir:v==="auto"?_b():v,tabIndex:-1,ref:z,className:u,"data-sonner-toaster":!0,"data-sonner-theme":$,"data-y-position":H,"data-x-position":G,style:{"--front-toast-height":`${((V=E[0])==null?void 0:V.height)||0}px`,"--width":`${ZA}px`,"--gap":`${y}px`,...g,...tP(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:()=>{O||I(!1)},onDragEnd:()=>I(!1),onPointerDown:Z=>{Z.target instanceof HTMLElement&&Z.target.dataset.dismissible==="false"||R(!0)},onPointerUp:()=>R(!1)},N.filter(Z=>!Z.position&&W===0||Z.position===U).map((Z,Y)=>{var X,ee;return Ne.createElement(eP,{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:(ee=b==null?void 0:b.closeButton)!=null?ee:c,interacting:O,position:U,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:B,toasts:N.filter(Q=>Q.position==Z.position),heights:E.filter(Q=>Q.position==Z.position),setHeights:A,expandByDefault:l,gap:y,expanded:P,swipeDirections:e.swipeDirections})})):null}))}),sP=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(Tr,{className:"size-4"}),info:a.jsx(Wh,{className:"size-4"}),warning:a.jsx(Us,{className:"size-4"}),error:a.jsx(cE,{className:"size-4"}),loading:a.jsx(ht,{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(nP,{className:"toaster group",icons:s,style:r,...t}),e[4]=t,e[5]=o):o=e[5],o};function rP(n){const e=q.c(13),{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){ys.dismiss("app-error");return}ys.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){ys.dismiss("model-fallback");return}ys.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){ys.dismiss("session-connection");return}ys.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=l==="light"?"light":"dark";let g;return e[11]!==h?(g=a.jsx(sP,{theme:h,position:"bottom-center",closeButton:!0,visibleToasts:3}),e[11]=h,e[12]=g):g=e[12],g}const Qt="local",ZS="cogpit-last-path::",Ep=new Map;function Mt(){var t;const n=typeof window<"u"?(t=window.location)==null?void 0:t.pathname:void 0;if(!n)return Qt;const e=/^\/d\/([^/]+)/.exec(n);return e?e[1]:Qt}function Lo(){return Mt()!==Qt}function YS(){const n=Mt();return n===Qt?"":`/hub/${n}`}function ig(n){const e=YS();return!e||n.startsWith("/api/hub/")||n.startsWith("/api/auth/")?n:n.startsWith("/api")||n.startsWith("/__pty")||n.startsWith("/__browser")?`${e}${n}`:n}let Wa=null;function XS(n){n!==Wa&&(Wa=n,window.dispatchEvent(new Event("cogpit-identity-changed")))}function $s(){return Wa}function Dc(n){return n===Qt?0:Ep.get(n)??0}function oP(n,e){if(n===Qt||!Number.isSafeInteger(e)||e<0)return!1;const t=Ep.get(n);return t!==void 0&&e<=t?!1:(Ep.set(n,e),window.dispatchEvent(new CustomEvent("cogpit-device-scope-changed",{detail:{deviceId:n,connectionRevision:e}})),!0)}function Fn(){const n=Mt(),e=Dc(n);return e===0?n:`${n}@${e}`}function Rn(n){const e=Mt(),t=Fn();return Wa!==null?`${n}::${t}::${Wa}`:e===Qt?n:`${n}::${t}`}function Ji(n,e){sessionStorage.setItem(`${ZS}${n}`,e)}function to(n){const t=sessionStorage.getItem(`${ZS}${n}`)??(n===Qt?"/":`/d/${n}/`);window.history.pushState(null,"",t),window.dispatchEvent(new Event("cogpit-device-changed"))}const Tb="cogpit-network-token",iP=new Set(["localhost","127.0.0.1","::1","0:0:0:0:0:0:0:1"]);function ag(){const n=window.location.hostname.toLowerCase(),e=n.startsWith("[")&&n.endsWith("]")?n.slice(1,-1):n;return!iP.has(e)}function Qu(){try{localStorage.removeItem(Tb),sessionStorage.removeItem(Tb)}catch{}}typeof window<"u"&&Qu();const aP={edition:"personal",needsBootstrap:!1};let qa=null,hi=null;function JS(){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();return hi=e.edition==="team"?"team":"personal",{edition:hi,needsBootstrap:hi==="team"&&e.needsBootstrap===!0}}).catch(()=>(qa=null,aP))}function QS(){return qa??(qa=JS()),qa}function Eb(){return qa=JS(),qa}function ek(){return QS().then(n=>n.edition)}async function lP(){if(!ag()&&hi!=="team")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 cP(){try{await fetch("/api/auth/logout",{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"X-Cogpit-Client":"1"}})}finally{Qu()}}function Ab(){return Qu(),window.dispatchEvent(new Event("cogpit-auth-required")),Promise.reject(new Error("Authentication required"))}function tk(n,e,t){t&&typeof n=="string"&&n.startsWith("/api")&&(n=ig(n));const s=new Headers(e==null?void 0:e.headers);return s.delete("Authorization"),s.set("X-Cogpit-Client","1"),fetch(n,{...e,headers:s,credentials:"same-origin"}).then(r=>{if(r.status===401){if(ag()||hi==="team")return Ab();if(hi===null)return ek().then(o=>o==="team"?Ab():r)}if(r.status===502){const o=r.headers.get("X-Cogpit-Hub-Error"),i=r.headers.get("X-Cogpit-Device");i&&(o==="DEVICE_UNREACHABLE"||o==="DEVICE_AUTH_FAILED")&&window.dispatchEvent(new CustomEvent("cogpit-device-unreachable",{detail:{deviceId:i,reason:o}}))}return r})}function Re(n,e){return tk(n,e,!0)}function rr(n,e,t={}){return Re(n,{method:"POST",...t,headers:{"Content-Type":"application/json",...t.headers},body:JSON.stringify(e)})}function Ur(n,e){return tk(n,e,!1)}function ml(n){return ig(n)}const no=["codex","copilot","claude"],Ap="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";function uP(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 dP(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 nk(n){return{lossy:!1,owns:e=>typeof e=="string"&&e.startsWith(n),encode:e=>uP(n,e),decode:e=>dP(n,e)}}function sk(n){const e=new RegExp(`(${Ap})\\.jsonl$`,"i").exec(n);return e?e[1]:null}const rk={urlId:n=>n.replace(/\.jsonl$/,""),fileNameFromUrlId:n=>n.endsWith(".jsonl")?n:`${n}.jsonl`};function ok(n){return`'${n.replace(/'/g,"'\\''")}'`}function Va(n,e){return e?[n,e]:[]}function iu(n,e){var t;return((t=e.exec(n))==null?void 0:t[1])??null}const au="[0-9a-f-]{36}",ik="codex__",ak="copilot__",fP=new Set(["default","plan","acceptEdits","dontAsk","auto"]),lk={kind:"claude",displayName:"Claude Code",binName:"claude",dirName:{lossy:!0,owns:n=>typeof n=="string"&&!n.startsWith(ik)&&!n.startsWith(ak),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,"/")}},sessionFile:{name:n=>`${n}.jsonl`,sessionId:sk,...rk},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"]:[...fP.has(n.mode)?["--permission-mode",n.mode]:[],...(n.allowedTools??[]).flatMap(e=>["--allowedTools",e]),...(n.disallowedTools??[]).flatMap(e=>["--disallowedTools",e])]:["--permission-mode","default"],model:n=>Va("--model",n),effort:n=>Va("--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=>iu(n,new RegExp(`--resume(?:=|\\s+)(${au})`))??iu(n,new RegExp(`--session-id(?:=|\\s+)(${au})`))}},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}},Pb={appServerValue:"priority",cliConfigValue:"fast"},mP={kind:"codex",displayName:"Codex",binName:"codex",dirName:nk(ik),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:sk,...rk},metadataFromHead:!1,resume:{command:(n,e)=>e?`codex -C ${ok(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=>Va("-m",n),effort:n=>n?["-c",`model_reasoning_effort=${JSON.stringify(n)}`]:[],fastTier:n=>n?["-c",`service_tier=${JSON.stringify(Pb.cliConfigValue)}`,"--enable","fast_mode"]:[]},serviceTier:Pb,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=>iu(n,new RegExp(`codex(?:\\s+\\S+)*\\s+exec\\s+resume\\s+(${au})`))}},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}},pP={kind:"copilot",displayName:"GitHub Copilot CLI",binName:"copilot",dirName:nk(ak),sessionFile:{name:n=>`${n}/events.jsonl`,sessionId:n=>{const e=new RegExp(`^(${Ap})/events\\.jsonl$`,"i").exec(n);return e?e[1]:null},urlId:n=>{const e=new RegExp(`^(${Ap})/events\\.jsonl$`,"i").exec(n);return e?e[1]:n.replace(/\.jsonl$/,"")},fileNameFromUrlId:n=>n.endsWith(".jsonl")?n:`${n}/events.jsonl`},metadataFromHead:!0,resume:{command:(n,e)=>e?`copilot -C ${ok(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=>Va("--model",n),effort:n=>Va("--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=>iu(n,new RegExp(`--resume(?:=|\\s+)(${au})`))}},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}},Ha=Object.freeze({claude:lk,codex:mP,copilot:pP});function es(n){return Ha[n]}function ed(){return no.map(n=>Ha[n])}function hP(n,e){const t=ed().filter(n);if(t.length!==1)throw new Error(`Expected exactly one agent with ${e}, found ${t.length}`);return t[0]}function Er(n){for(const e of no)if(e!=="claude"&&Ha[e].dirName.owns(n))return Ha[e];return lk}function sn(n){return Er(n).kind}function lf(n,e,t){const s=Ha[n].dirName;return t&&s.lossy?t:s.encode(e)}const zo=Er(null).kind;var yS;const Ql=((yS=ed().find(n=>n.dirName.lossy))==null?void 0:yS.kind)??null;function ji(n){return Er(n).capabilities}function pn(n){return es(n).capabilities}function gP(n,e){return no.find(t=>t===n)??e}function lu(n){for(const e of ed()){const t=e.sessionFile.sessionId(n);if(t)return t}return n.replace(/\.jsonl$/,"")}function xP(n,e){return Er(n).sessionFile.urlId(e)}function bP(n,e){return Er(n).sessionFile.fileNameFromUrlId(e)}function lg(n,e,t){return es(n).resume.command(e,t)}function vP(n,e){const t=es(n);return{command:t.binName,args:[...t.resume.args(e)]}}function Ib(n){return n.replace(/\/+$/,"")||"/"}function yP(n,e,t){var r;const s=Ib(e);return((r=n.find(o=>Er(o.dirName).kind===t&&Ib(o.path)===s))==null?void 0:r.dirName)??null}const wP=[{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"}],cg=[{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"}],ck=[...cg,{value:"ultra",label:"Ultra",description:"Maximum reasoning with automatic task delegation"}],ec=cg.slice(0,4);var wS;const ua=[{value:((wS=es("codex").serviceTier)==null?void 0:wS.appServerValue)??"priority",label:"Fast",description:"1.5× speed with increased usage"}],$b={defaultReasoningEffort:"medium",supportedReasoningEfforts:ck,inputModalities:["text","image"],supportsPersonality:!1,serviceTiers:ua},SP=[{value:"",label:"Default",description:"Use the model configured in Codex"},{value:"gpt-6-astra",label:"GPT-6 Astra",description:"For complex, demanding work",...$b,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",...$b},{value:"gpt-5.6-terra",label:"GPT-5.6 Terra",description:"Balanced model for everyday work",defaultReasoningEffort:"medium",supportedReasoningEfforts:ck,inputModalities:["text","image"],supportsPersonality:!1,serviceTiers:ua},{value:"gpt-5.6-luna",label:"GPT-5.6 Luna",description:"Fastest, most cost-efficient model",defaultReasoningEffort:"medium",supportedReasoningEfforts:cg,inputModalities:["text","image"],supportsPersonality:!1,serviceTiers:ua},{value:"gpt-5.5",label:"GPT-5.5",description:"Frontier model for complex real-world work",defaultReasoningEffort:"medium",supportedReasoningEfforts:ec,inputModalities:["text","image"],supportsPersonality:!0,serviceTiers:ua},{value:"gpt-5.4",label:"GPT-5.4",description:"Strong model for everyday coding",defaultReasoningEffort:"medium",supportedReasoningEfforts:ec,inputModalities:["text","image"],supportsPersonality:!0,serviceTiers:ua},{value:"gpt-5.4-mini",label:"GPT-5.4 Mini",description:"Small, fast model for simpler tasks",defaultReasoningEffort:"medium",supportedReasoningEfforts:ec,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:ec,inputModalities:["text"],supportsPersonality:!0}],kP=[{value:"",label:"Default",supportsEffort:!1,inputModalities:["text"]},{value:"auto",label:"Auto",description:"Let Copilot choose the best available model",supportsEffort:!1,inputModalities:["text"]}],jP={claude:wP,codex:SP,copilot:kP};function NP(n){return jP[n]}const uk=new Map,Pp=new Set;function CP(n,e){!Array.isArray(e)||e.length===0||(uk.set(n,e),Pp.forEach(t=>t()))}function _P(n){return Pp.add(n),()=>Pp.delete(n)}const Rb="high",TP=[{value:"low",label:"Light"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"xhigh",label:"Extra High"},{value:"max",label:"Max"}];function EP(n){return uk.get(n)??NP(n)}function pl(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 dk(n,e,t){const s=pl(e,t),r=s==null?void 0:s.supportedReasoningEfforts;return r&&r.length>0?r:(s==null?void 0:s.supportsEffort)===!1||!pn(n).reasoningEffort?[]:TP}function AP(n,e){var t,s;return(s=(t=pl(n,e))==null?void 0:t.serviceTiers)==null?void 0:s.find(r=>r.value==="fast"||r.value==="priority"||r.label.toLowerCase()==="fast")}function PP(n,e,t){var r;const s=(r=pl(e,t))==null?void 0:r.inputModalities;return s?s.includes("image"):pn(n).imageInput}function IP(n,e,t){var r;const s=pn(n).autoPermissionMode;return s==="always"?!0:s==="never"?!1:((r=pl(e,t))==null?void 0:r.supportsAutoMode)===!0}function $P(n,e){return pn(n).ultracode?!(e??"").toLowerCase().startsWith("haiku"):!1}function RP(n,e,t,s){var l;const r=dk(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=pl(e,s))==null?void 0:l.defaultReasoningEffort;return o(i)?i:o(Rb)?Rb:r[0].value}function OP(n){return n.toLowerCase().replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-").slice(0,40).replace(/-$/,"")}async function td(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 MP=300*1e3,LP=30*1e3;let Ip=0,Qi=null;function zP(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 DP(){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 no){const s=e==null?void 0:e[t];zP(s)&&CP(t,s)}Ip=Date.now()+MP}catch{Ip=Date.now()+LP}}function ug(){return Qi||(Date.now()<Ip?Promise.resolve():(Qi=DP().finally(()=>{Qi=null}),Qi))}function FP(){const n=()=>{document.visibilityState==="visible"&&ug()};return window.addEventListener("focus",n),document.addEventListener("visibilitychange",n),()=>{window.removeEventListener("focus",n),document.removeEventListener("visibilitychange",n)}}function UP(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(BP,t);let s;return e[1]!==n?(s=()=>EP(n),e[1]=n,e[2]=s):s=e[2],w.useSyncExternalStore(_P,s)}function BP(){return ug(),FP()}function fk(n,e){const t=q.c(26),s=UP(n);let r;t[0]!==n||t[1]!==e||t[2]!==s?(r=dk(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=AP(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=PP(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=IP(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=>RP(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 nd(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(uE,{"data-slot":"popover",...t}),e[2]=t,e[3]=s):s=e[3],s}function sd(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(dE,{"data-slot":"popover-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function mk(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=K("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(fE,{"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(mE,{children:a.jsx(pE,{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 WP=new Set(["mcp","server","servers","api","app","the","and"]),qP=/^([\w-]+\.[a-z]{2,})\s+(.+)$/i;function pk(n){const e=qP.exec(n.trim());return e?{short:e[2],namespace:e[1]}:{short:n.trim()}}function VP(n){const{short:e}=pk(n),t=e.split(/[^a-z0-9]+/i).filter(o=>o&&!WP.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 dg(n){return n?"bottom":"top"}function fg(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=K("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(It,{"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(J,{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 mg(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=K("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(mk,{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 gi(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=K("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 $p(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=K("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(hE,{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 HP="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 pg(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=K(HP,"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(gE,{keepMounted:!0,className:"shrink-0 text-foreground opacity-0 transition-opacity duration-100 data-checked:opacity-100",children:a.jsx(Bt,{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(xE,{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 KP=8;function GP(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,v,y,k,j,C,_,S,N,T,E,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 $=t.filter(XP),M=t.filter(YP);let z;e[27]!==s?(z=new Set(s),e[27]=s,e[28]=z):z=e[28];const F=z;let D;e[29]!==F?(D=te=>F.has(te.name),e[29]=F,e[30]=D):D=e[30];const L=$.filter(D).length,B=l&&t.length===0,U=B?"MCPs":`MCPs ${L}/${$.length}`,W=d.trim().toLowerCase(),V=te=>!W||te.name.toLowerCase().includes(W),H=$.filter(V),G=M.filter(V);h=nd,y=!1,e[31]===Symbol.for("react.memo_cache_sentinel")?(k=te=>{te||f("")},e[31]=k):k=e[31];let Z;e[32]!==U?(Z=a.jsx(fg,{"aria-label":U}),e[32]=U,e[33]=Z):Z=e[33];let Y;e[34]===Symbol.for("react.memo_cache_sentinel")?(Y=a.jsx(SS,{"data-icon":"inline-start"}),e[34]=Y):Y=e[34];let X;e[35]!==U?(X=a.jsx("span",{className:"truncate",children:U}),e[35]=U,e[36]=X):X=e[36];let ee;e[37]!==B?(ee=B&&a.jsx(Un,{className:"size-3 animate-spin","aria-hidden":!0}),e[37]=B,e[38]=ee):ee=e[38],e[39]!==Z||e[40]!==X||e[41]!==ee?(j=a.jsxs(sd,{render:Z,children:[Y,X,ee]}),e[39]=Z,e[40]=X,e[41]=ee,e[42]=j):j=e[42],p=mg,e[43]!==u?(A=dg(u),e[43]=u,e[44]=A):A=e[44],P="MCP servers",x="w-[23rem]";const Q=$.length>0&&a.jsxs("span",{"aria-hidden":!0,className:"ml-1.5 font-normal normal-case tracking-normal",children:[L," on"]});let ne;e[45]!==m||e[46]!==Q?(ne=a.jsxs(gi,{id:m,className:"pt-1",children:["MCP servers",Q]}),e[45]=m,e[46]=Q,e[47]=ne):ne=e[47];const re=o&&$.length>1&&a.jsxs(a.Fragment,{children:[a.jsx(Ob,{label:"Turn every server on",disabled:L===$.length,onClick:()=>o($.map(ZP)),children:"All"}),a.jsx(Ob,{label:"Turn every server off",disabled:L===0,onClick:()=>o([]),children:"None"})]}),se=l&&"animate-spin";let oe;e[48]!==se?(oe=K(se),e[48]=se,e[49]=oe):oe=e[49];let ae;e[50]!==oe?(ae=a.jsx(Un,{className:oe}),e[50]=oe,e[51]=ae):ae=e[51];let ie;e[52]!==i||e[53]!==ae?(ie=a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:i,"aria-label":"Refresh status",title:"Refresh status",className:"text-muted-foreground",children:ae}),e[52]=i,e[53]=ae,e[54]=ie):ie=e[54];let ce;e[55]!==re||e[56]!==ie?(ce=a.jsxs("div",{className:"flex items-center gap-0.5",children:[re,ie]}),e[55]=re,e[56]=ie,e[57]=ce):ce=e[57],e[58]!==ne||e[59]!==ce?(b=a.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 px-1.5 pt-1.5",children:[ne,ce]}),e[58]=ne,e[59]=ce,e[60]=b):b=e[60],e[61]!==d||e[62]!==t.length?(v=t.length>KP&&a.jsx("div",{className:"shrink-0 px-1.5 pt-1",children:a.jsx("input",{type:"search",value:d,onChange:te=>f(te.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]=v):v=e[63],g="group",C=m,_="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],N=t.length>0&&H.length===0&&G.length===0&&a.jsx("p",{className:"px-0.5 py-1 text-xs text-muted-foreground",children:"No servers match."}),T=H.length>0&&a.jsx("div",{className:"grid grid-cols-2 gap-1",children:H.map(te=>a.jsx(Mb,{server:te,on:F.has(te.name),onClick:()=>r(te.name)},te.name))}),E=G.length>0&&a.jsxs(a.Fragment,{children:[a.jsx(gi,{className:"px-0.5 pt-2 text-warning/80",children:"Needs sign-in"}),a.jsx("div",{className:"grid grid-cols-2 gap-1",children:G.map(te=>a.jsx(Mb,{server:te,onClick:()=>c(te.name)},te.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]=v,e[16]=y,e[17]=k,e[18]=j,e[19]=C,e[20]=_,e[21]=S,e[22]=N,e[23]=T,e[24]=E,e[25]=A,e[26]=P}else p=e[10],h=e[11],g=e[12],x=e[13],b=e[14],v=e[15],y=e[16],k=e[17],j=e[18],C=e[19],_=e[20],S=e[21],N=e[22],T=e[23],E=e[24],A=e[25],P=e[26];let I;e[67]!==g||e[68]!==C||e[69]!==_||e[70]!==S||e[71]!==N||e[72]!==T||e[73]!==E?(I=a.jsxs("div",{role:g,"aria-labelledby":C,className:_,children:[S,N,T,E]}),e[67]=g,e[68]=C,e[69]=_,e[70]=S,e[71]=N,e[72]=T,e[73]=E,e[74]=I):I=e[74];let O;e[75]!==p||e[76]!==x||e[77]!==b||e[78]!==v||e[79]!==I||e[80]!==A||e[81]!==P?(O=a.jsxs(p,{side:A,"aria-label":P,className:x,children:[b,v,I]}),e[75]=p,e[76]=x,e[77]=b,e[78]=v,e[79]=I,e[80]=A,e[81]=P,e[82]=O):O=e[82];let R;return e[83]!==h||e[84]!==y||e[85]!==k||e[86]!==j||e[87]!==O?(R=a.jsxs(h,{modal:y,onOpenChange:k,children:[j,O]}),e[83]=h,e[84]=y,e[85]=k,e[86]=j,e[87]=O,e[88]=R):R=e[88],R}function ZP(n){return n.name}function YP(n){return n.status!=="connected"}function XP(n){return n.status==="connected"}function Ob(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(J,{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 Mb(n){const e=q.c(34),{server:t,on:s,onClick:r}=n;let o;e[0]!==t.name?(o=pk(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=K("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",v=s===!0&&"bg-primary text-primary-foreground",y=s===!1&&"bg-muted text-muted-foreground";let k;e[6]!==b||e[7]!==v||e[8]!==y?(k=K("flex size-6 shrink-0 items-center justify-center rounded-md text-[10px] font-semibold tracking-wide transition-colors duration-100",b,v,y),e[6]=b,e[7]=v,e[8]=y,e[9]=k):k=e[9];let j;e[10]!==t.name?(j=VP(t.name),e[10]=t.name,e[11]=j):j=e[11];let C;e[12]!==k||e[13]!==j?(C=a.jsx("span",{"aria-hidden":!0,className:k,children:j}),e[12]=k,e[13]=j,e[14]=C):C=e[14];let _;e[15]!==i?(_=a.jsx("span",{className:"truncate leading-4",children:i}),e[15]=i,e[16]=_):_=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 N;e[19]!==_||e[20]!==S?(N=a.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[_,S]}),e[19]=_,e[20]=S,e[21]=N):N=e[21];let T;e[22]!==c?(T=c&&a.jsx(bE,{className:"size-3.5 shrink-0 text-warning","aria-hidden":!0}),e[22]=c,e[23]=T):T=e[23];let E;return e[24]!==r||e[25]!==C||e[26]!==N||e[27]!==T||e[28]!==u||e[29]!==d||e[30]!==f||e[31]!==m||e[32]!==x?(E=a.jsxs("button",{type:"button",role:u,"aria-checked":d,"aria-label":f,title:m,onClick:r,className:x,children:[C,N,T]}),e[24]=r,e[25]=C,e[26]=N,e[27]=T,e[28]=u,e[29]=d,e[30]=f,e[31]=m,e[32]=x,e[33]=E):E=e[33],E}function JP(n,e){var i;const{defaultLimit:t,limits:s,extendedContext:r}=es(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 QP(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=JP(e,t),c=l-es(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 eI=["fable","mythos","opus","sonnet","haiku"];function Lb(n){return n.charAt(0).toUpperCase()+n.slice(1)}function Do(n){if(!n)return"unknown";const e=n.toLowerCase(),t=/\[1m\]$/.test(e)?" 1M":"",s=e.replace(/\[[^\]]*\]$/,"");for(const r of eI){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`${Lb(r)}${i}${t}`}if(s.startsWith("gpt-")){const[r,...o]=s.slice(4).split("-"),i=o.map(Lb).join(" ");return`GPT-${r}${i?` ${i}`:""}${t}`}return n.length>20?n.slice(0,20)+"...":n}function rs(n){return Number.isFinite(n)?n<.01?`$${n.toFixed(4)}`:n<1?`$${n.toFixed(3)}`:`$${n.toFixed(2)}`:"—"}function jt(n){return n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}k`:String(n)}function er(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 tI(n){if(n<60)return`${n}s`;const e=Math.floor(n/60),t=n%60;return`${e}m ${t}s`}function hk(n){return n>=1e6?`${(n/1e6).toFixed(1)}MB`:n>=1e3?`${(n/1e3).toFixed(0)}KB`:`${n}B`}function Fi(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 hg(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 gg(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 Ns(n,e){return n.length<=e?n:n.slice(0,e)+"..."}function Rs(n){return Er(n).dirName.decode(n)??n}function rd(n,e=2){const t=n.replace(/\/+$/,"").split("/").filter(Boolean);return t.length<=e?n:t.slice(-e).join("/")}function od(n){const e="/.worktrees/",t=n.indexOf(e);if(t===-1)return null;const s=n.slice(t+e.length).split("/")[0];return s?{parentPath:n.slice(0,t),worktreeName:s}:null}function wr(n){return n.replace(/\/+$/,"").split("/").at(-1)??n}function so(n){const e=n.match(/^([^/]+)\/subagents\/agent-([^.]+)\.jsonl$/);return e?{parentSessionId:e[1],agentId:e[2],parentFileName:`${e[1]}.jsonl`}:null}function gk(n){for(let e=n.length-1;e>=0;e--){const t=n[e];if(t.type==="assistant")return QP(t.message.usage,t.message.model??"","claude")}return null}const Fc=[27e4,5e5,1e6];function zb(n){return Fc.includes(n)?jt(n).replace(/\.0(?=[kM]$)/,""):n.toLocaleString("en-US")}function xk(n){const e=q.c(12),{value:t,onChange:s}=n;let r;e[0]!==t?(r=t===null?"Default":zb(t),e[0]=t,e[1]=r):r=e[1];const o=r,i=Fc[(Fc.indexOf(t??0)+1)%Fc.length],l=`Context window: ${o}`;let c;e[2]!==i?(c=zb(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(J,{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 bk=_r("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 nI(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=K(bk({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(kS,{"data-slot":"toggle",className:c,...s}),e[9]=s,e[10]=c,e[11]=u):u=e[11],u}function sI(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 y;e[3]!==s?(y=k=>k.value===s,e[3]=s,e[4]=y):y=e[4],c=t.findIndex(y),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=y=>{const k=t[y];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=K("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(vE,{className:"rounded-full bg-primary"}),e[11]=p):p=e[11];let h;if(e[12]!==u||e[13]!==l||e[14]!==t){let y;e[16]!==u||e[17]!==l?(y=(k,j)=>a.jsx("span",{"aria-hidden":!0,className:K("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]=y):y=e[18],h=t.map(y),e[12]=u,e[13]=l,e[14]=t,e[15]=h}else h=e[15];let g;e[19]!==t?(g=(y,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(yE,{"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(wE,{className:"flex h-6 w-full touch-none select-none items-center px-1.5",children:a.jsxs(SE,{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 v;return e[27]!==o||e[28]!==u||e[29]!==l||e[30]!==d||e[31]!==m||e[32]!==b?(v=a.jsx(kE,{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]=v):v=e[33],v}function vk(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 rI=vk("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"),oI=vk("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"),yk={claude:rI,codex:oI,copilot:jS},xg={claude:"Claude",codex:"Codex",copilot:"Copilot"},iI={claude:"Claude",codex:"Codex",copilot:"GitHub Copilot"},aI={claude:null,codex:"Codex",copilot:"Copilot"},lI={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"}},cI={claude:"var(--chart-1)",codex:"var(--chart-2)",copilot:"var(--chart-3)"},uI={claude:"Interrupt agent",codex:"Stop active turn",copilot:"Stop Copilot turn"},dI={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 fI(n){return dI[n]}function mI(n){return yk[n]}function id(n){return xg[n]}function Qde(n){return iI[n]}function pI(n){return aI[n]}function efe(n){return lI[n]}function hI(n){return uI[n]}function gI(n){return cI[n]}const Db=Er(null).kind,wk=[Db,...no.filter(n=>n!==Db)];function xI(n){return`This ${xg[n]} session is controlled by another process. Cogpit can only view it.`}const Rp=wk.map(n=>({value:n,label:xg[n],Icon:yk[n]}));function bI(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 vI(n){var t;const e=(t=n.find(s=>s.value===""))==null?void 0:t.resolvedModel;return e?bg(e,n):"Default"}function bg(n,e){var t;return((t=bI(n,e))==null?void 0:t.label)??Do(n)}function yI(n){var ye;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:v}=n,y=h===void 0?!1:h,k=x===void 0?!1:x;let j;e[0]!==t?(j=pn(t),e[0]=t,e[1]=j):j=e[1];const C=j;let _;e[2]!==t?(_=Rp.find(Pe=>Pe.value===t),e[2]=t,e[3]=_):_=e[3];const S=_,N=S==null?void 0:S.Icon,T=(S==null?void 0:S.label)??t;let E;e[4]!==i||e[5]!==o||e[6]!==r?(E=((ye=i.find(Pe=>Pe.value===r))==null?void 0:ye.label)??o,e[4]=i,e[5]=o,e[6]=r,e[7]=E):E=e[7];const A=E;let P;if(e[8]!==u||e[9]!==c){let Pe;e[11]!==c?(Pe=Ye=>Ye.value===c,e[11]=c,e[12]=Pe):Pe=e[12],P=u.find(Pe),e[8]=u,e[9]=c,e[10]=P}else P=e[10];const I=P,O=!s,R=C.reasoningEffort,$=C.configurableContextWindow&&!!m,M=C.fastTier,z=C.ultracode,F=!!p&&!!g,D=!!b,L=y&&F,B=k&&D,U=B?"Pinned by Ultracode":I==null?void 0:I.description,W=I==null?void 0:I.label;let V;e[13]!==A||e[14]!==T||e[15]!==W?(V=[T,A,W].filter(Boolean),e[13]=A,e[14]=T,e[15]=W,e[16]=V):V=e[16];const H=V.join(" · "),G=L?"Fast mode on":null,Z=B?"Ultracode on":null;let Y;e[17]!==Z||e[18]!==G?(Y=[G,Z].filter(Boolean),e[17]=Z,e[18]=G,e[19]=Y):Y=e[19];const X=Y.join(", "),ee=w.useId(),Q=w.useId(),ne=w.useId(),re=X?`${H} (${X})`:H,se=X?`${H} · ${X}`:void 0;let oe;e[20]!==re||e[21]!==se?(oe=a.jsx(fg,{"aria-label":re,title:se}),e[20]=re,e[21]=se,e[22]=oe):oe=e[22];let ae;e[23]!==N?(ae=N&&a.jsx(N,{"data-icon":"inline-start"}),e[23]=N,e[24]=ae):ae=e[24];let ie;e[25]!==A?(ie=a.jsx("span",{className:"truncate",children:A}),e[25]=A,e[26]=ie):ie=e[26];let ce;e[27]!==I?(ce=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]=ce):ce=e[28];let te;e[29]!==ie||e[30]!==ce?(te=a.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[ie,ce]}),e[29]=ie,e[30]=ce,e[31]=te):te=e[31];let le;e[32]!==L?(le=L&&a.jsx(su,{className:"size-3 shrink-0 fill-current","aria-hidden":!0}),e[32]=L,e[33]=le):le=e[33];let ge;e[34]!==B?(ge=B&&a.jsx(Da,{className:"size-3 shrink-0 fill-current","aria-hidden":!0}),e[34]=B,e[35]=ge):ge=e[35];let be;e[36]!==oe||e[37]!==ae||e[38]!==te||e[39]!==le||e[40]!==ge?(be=a.jsxs(sd,{render:oe,children:[ae,te,le,ge]}),e[36]=oe,e[37]=ae,e[38]=te,e[39]=le,e[40]=ge,e[41]=be):be=e[41];let ue;e[42]!==v?(ue=dg(v),e[42]=v,e[43]=ue):ue=e[43];let he;e[44]!==ee?(he=a.jsx(gi,{id:ee,children:"Provider"}),e[44]=ee,e[45]=he):he=e[45];let me;e[46]!==s?(me=Pe=>s==null?void 0:s(Pe),e[46]=s,e[47]=me):me=e[47];let xe;e[48]!==t||e[49]!==O?(xe=Rp.map(Pe=>a.jsx(pg,{value:Pe.value,title:Pe.label,icon:Pe.Icon,disabled:O&&Pe.value!==t},Pe.value)),e[48]=t,e[49]=O,e[50]=xe):xe=e[50];let je;e[51]!==t||e[52]!==ee||e[53]!==me||e[54]!==xe?(je=a.jsx($p,{value:t,onValueChange:me,"aria-labelledby":ee,children:xe}),e[51]=t,e[52]=ee,e[53]=me,e[54]=xe,e[55]=je):je=e[55];let Le;e[56]!==v||e[57]!==O?(Le=O&&!v&&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]=v,e[57]=O,e[58]=Le):Le=e[58];let Se;e[59]!==he||e[60]!==je||e[61]!==Le?(Se=a.jsxs("div",{className:"flex min-h-0 flex-col overflow-y-auto border-r bg-muted/30 p-1.5",children:[he,je,Le]}),e[59]=he,e[60]=je,e[61]=Le,e[62]=Se):Se=e[62];let Ie;e[63]!==Q?(Ie=a.jsx(gi,{id:Q,children:"Model"}),e[63]=Q,e[64]=Ie):Ie=e[64];let we;e[65]!==f||e[66]!==F||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]!==$||e[74]!==M||e[75]!==z||e[76]!==D||e[77]!==B?(we=($||M||z)&&a.jsxs("div",{className:"flex items-center gap-1",children:[$&&a.jsx(xk,{value:f??null,onChange:m}),M&&a.jsx(Fb,{label:"Fast mode",pressed:L,onPressedChange:Pe=>g==null?void 0:g(Pe),disabled:!F,title:F?`Fast mode · ${(p==null?void 0:p.description)??"Lower latency with increased usage"}`:`Fast mode isn't offered for ${A}`,children:a.jsx(su,{className:K(L&&"fill-current")})}),z&&a.jsxs(Fb,{label:"Ultracode",pressed:B,onPressedChange:Pe=>b==null?void 0:b(Pe),disabled:!D,title:D?"Ultracode · Extra High effort with standing multi-agent orchestration":`Ultracode isn't available for ${A}`,children:[a.jsx(Da,{className:K(B&&"fill-current")}),"Ultracode"]})]}),e[65]=f,e[66]=F,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]=$,e[74]=M,e[75]=z,e[76]=D,e[77]=B,e[78]=we):we=e[78];let Be;e[79]!==Ie||e[80]!==we?(Be=a.jsxs("div",{className:"flex items-center justify-between gap-2 pr-0.5",children:[Ie,we]}),e[79]=Ie,e[80]=we,e[81]=Be):Be=e[81];let De;e[82]!==i?(De=i.map(wI),e[82]=i,e[83]=De):De=e[83];let Ue;e[84]!==Q||e[85]!==l||e[86]!==r||e[87]!==De?(Ue=a.jsx($p,{value:r,onValueChange:l,"aria-labelledby":Q,className:"max-h-56 min-h-0 flex-1 overflow-y-auto",children:De}),e[84]=Q,e[85]=l,e[86]=r,e[87]=De,e[88]=Ue):Ue=e[88];let We;e[89]!==Be||e[90]!==Ue?(We=a.jsxs("div",{className:"flex min-h-0 flex-col p-1.5",children:[Be,Ue]}),e[89]=Be,e[90]=Ue,e[91]=We):We=e[91];let Oe;e[92]!==Se||e[93]!==We?(Oe=a.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-[10.5rem_minmax(0,1fr)] overflow-hidden",children:[Se,We]}),e[92]=Se,e[93]=We,e[94]=Oe):Oe=e[94];let pe;e[95]!==U||e[96]!==ne||e[97]!==u||e[98]!==A||e[99]!==d||e[100]!==c||e[101]!==I||e[102]!==R||e[103]!==B?(pe=R&&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(gi,{id:ne,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)]}),U&&a.jsx("span",{className:"truncate text-[11px] leading-4 text-muted-foreground",children:U})]}),u.length>0?a.jsx(sI,{options:u,value:c,onChange:d,disabled:B,labelId:ne}):a.jsxs("p",{className:"px-1.5 pb-1 text-xs leading-5 text-muted-foreground",children:["Not adjustable for ",A,"."]})]}),e[95]=U,e[96]=ne,e[97]=u,e[98]=A,e[99]=d,e[100]=c,e[101]=I,e[102]=R,e[103]=B,e[104]=pe):pe=e[104];let ke;e[105]!==ue||e[106]!==Oe||e[107]!==pe?(ke=a.jsxs(mg,{side:ue,align:"end","aria-label":"Model settings",className:"w-[34rem] max-w-[calc(100vw-1.5rem)]",children:[Oe,pe]}),e[105]=ue,e[106]=Oe,e[107]=pe,e[108]=ke):ke=e[108];let _e;return e[109]!==be||e[110]!==ke?(_e=a.jsxs(nd,{modal:!1,onOpenChange:SI,children:[be,ke]}),e[109]=be,e[110]=ke,e[111]=_e):_e=e[111],_e}function wI(n){return a.jsx(pg,{value:n.value,title:n.menuLabel??n.label,description:n.description},n.value)}function SI(n){n&&ug()}function Fb(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(nI,{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 Sk(n,e){return fI(n).filter(t=>t.value!=="auto"||e)}function kI(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=Sk(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(fg,{"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(NS,{"data-icon":"inline-start"}),e[2]=g):g=e[2];const x=mg;let b;e[3]!==i?(b=dg(i),e[3]=i,e[4]=b):b=e[4];const v="Permissions",y="w-80",k="p-1.5";let j;e[5]!==m?(j=a.jsx(gi,{id:m,children:"Permissions"}),e[5]=m,e[6]=j):j=e[6];const C=$p;let _;e[7]!==r?(_=A=>{r(A),u(!1)},e[7]=r,e[8]=_):_=e[8];const S=d.map(jI);let N;e[9]!==C||e[10]!==m||e[11]!==s||e[12]!==_||e[13]!==S?(N=a.jsx(C,{value:s,onValueChange:_,"aria-labelledby":m,children:S}),e[9]=C,e[10]=m,e[11]=s,e[12]=_,e[13]=S,e[14]=N):N=e[14];let T;e[15]!==N||e[16]!==j?(T=a.jsxs("div",{className:k,children:[j,N]}),e[15]=N,e[16]=j,e[17]=T):T=e[17];let E;return e[18]!==x||e[19]!==T||e[20]!==b?(E=a.jsx(x,{side:b,"aria-label":v,className:y,children:T}),e[18]=x,e[19]=T,e[20]=b,e[21]=E):E=e[21],a.jsxs(nd,{modal:!1,open:c,onOpenChange:u,children:[a.jsxs(sd,{render:h,children:[g,a.jsx("span",{className:"truncate",children:f.label})]}),E]})}function jI(n){return a.jsx(pg,{value:n.value,title:n.label,description:n.description},n.value)}function NI(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:v,ultracodeEnabled:y,onUltracodeEnabledChange:k,autoModeAvailable:j,permissionMode:C,onPermissionModeChange:_,mcpServers:S,selectedMcpServers:N,onToggleMcpServer:T,onSetMcpServers:E,onRefreshMcpServers:A,mcpLoading:P,onMcpAuth:I,changeAndApply:O,trailingExtra:R}=n;let $;e[0]!==t?($=pn(t),e[0]=t,e[1]=$):$=e[1];const{worktrees:M}=$;let z;e[2]!==t||e[3]!==j||e[4]!==O||e[5]!==x||e[6]!==_||e[7]!==C?(z=_&&C&&a.jsx(kI,{agentKind:t,mode:C,onChange:H=>O(()=>_(H)),autoAvailable:j,isNewSession:x}),e[2]=t,e[3]=j,e[4]=O,e[5]=x,e[6]=_,e[7]=C,e[8]=z):z=e[8];let F;e[9]!==x||e[10]!==v||e[11]!==M||e[12]!==b?(F=M&&x&&v&&a.jsxs(J,{type:"button",variant:b?"secondary":"ghost",size:"xs","aria-pressed":!!b,onClick:()=>v(!b),children:[a.jsx(Qr,{"data-icon":"inline-start"}),"Worktree"]}),e[9]=x,e[10]=v,e[11]=M,e[12]=b,e[13]=F):F=e[13];let D;e[14]!==O||e[15]!==x||e[16]!==P||e[17]!==S||e[18]!==I||e[19]!==A||e[20]!==E||e[21]!==T||e[22]!==N?(D=T&&A&&I&&(P||S&&S.length>0)&&a.jsx(GP,{servers:S??[],selected:N??[],onToggle:H=>O(()=>T(H)),onSetSelection:E?H=>O(()=>E(H)):void 0,onRefresh:A,loading:P??!1,onAuth:I,isNewSession:x}),e[14]=O,e[15]=x,e[16]=P,e[17]=S,e[18]=I,e[19]=A,e[20]=E,e[21]=T,e[22]=N,e[23]=D):D=e[23];let L;e[24]!==z||e[25]!==F||e[26]!==D||e[27]!==R?(L=a.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1",children:[z,F,D,R]}),e[24]=z,e[25]=F,e[26]=D,e[27]=R,e[28]=L):L=e[28];let B;e[29]!==O||e[30]!==g?(B=g?H=>O(()=>g(H)):void 0,e[29]=O,e[30]=g,e[31]=B):B=e[31];let U;e[32]!==O||e[33]!==k?(U=k?H=>O(()=>k(H)):void 0,e[32]=O,e[33]=k,e[34]=U):U=e[34];let W;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]!==B||e[50]!==U||e[51]!==y?(W=a.jsx(yI,{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:B,ultracodeEnabled:y,onUltracodeEnabledChange:U,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]=B,e[50]=U,e[51]=y,e[52]=W):W=e[52];let V;return e[53]!==L||e[54]!==W?(V=a.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1",role:"group","aria-label":"Session settings",children:[L,W]}),e[53]=L,e[54]=W,e[55]=V):V=e[55],V}function Zt(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=K("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(qh,{"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 CI(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=K("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 _I(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=K("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 TI(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=K("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 Ui(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=K("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 EI=_r("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 Lt(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=K(EI({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 tfe(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=K("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 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=K("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(CI,{"data-slot":"field-label",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Ni(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=K("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 Yr(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(PI)).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(AI)}),e[7]=m,e[8]=p):p=e[8],i=p}const l=i;if(!l)return null;let c;e[9]!==s?(c=K("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 AI(n,e){return(n==null?void 0:n.message)&&a.jsx("li",{children:n.message},e)}function PI(n){return[n==null?void 0:n.message,n]}const II=_E;function $I(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=K("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(NE,{"data-slot":"select-group",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function RI(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=K("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(TE,{"data-slot":"select-value",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function OI(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=K("group/select-trigger flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input bg-transparent 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 dark:bg-input/30 dark:hover:bg-input/50 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(AE,{render:a.jsx(It,{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(EE,{"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 MI(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=K("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(zI,{}),e[11]=x):x=e[11];let b;e[12]!==t?(b=a.jsx(PE,{children:t}),e[12]=t,e[13]=b):b=e[13];let v;e[14]===Symbol.for("react.memo_cache_sentinel")?(v=a.jsx(DI,{}),e[14]=v):v=e[14];let y;e[15]!==r||e[16]!==g||e[17]!==b?(y=a.jsxs(jE,{"data-slot":"select-content",className:g,...r,children:[x,b,v]}),e[15]=r,e[16]=g,e[17]=b,e[18]=y):y=e[18];let k;return e[19]!==m||e[20]!==h||e[21]!==p||e[22]!==d||e[23]!==f||e[24]!==y?(k=a.jsx(IE,{children:a.jsx($E,{side:d,sideOffset:f,align:m,alignOffset:p,alignItemWithTrigger:h,className:"isolate z-50",children:y})}),e[19]=m,e[20]=h,e[21]=p,e[22]=d,e[23]=f,e[24]=y,e[25]=k):k=e[25],k}function LI(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=K("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(RE,{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(OE,{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(Bt,{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(CE,{"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 zI(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=K("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(Hu,{}),e[5]=o):o=e[5];let i;return e[6]!==s||e[7]!==r?(i=a.jsx(ME,{"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 DI(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=K("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(It,{}),e[5]=o):o=e[5];let i;return e[6]!==s||e[7]!==r?(i=a.jsx(LE,{"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 FI(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(CS,{"data-slot":"sheet",...t}),e[2]=t,e[3]=s):s=e[3],s}function UI(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(zE,{"data-slot":"sheet-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function BI(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(ul,{"data-slot":"sheet-close",...t}),e[2]=t,e[3]=s):s=e[3],s}function WI(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(Gh,{"data-slot":"sheet-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}function qI(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=K("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(Zh,{"data-slot":"sheet-overlay",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function VI(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(qI,{}),e[6]=u):u=e[6];let d;e[7]!==s?(d=K("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(ul,{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(Wt,{"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(WI,{children:[u,a.jsxs(Kh,{"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 HI(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=K("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 KI(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=K("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(Vh,{"data-slot":"sheet-title",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function GI(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=K("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(Hh,{"data-slot":"sheet-description",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function _a(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=K("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(zt,{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(Lt,{className:l,children:[c,u]}),e[6]=l,e[7]=c,e[8]=u,e[9]=d):d=e[9],d}function tc(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(RI,{}),e[2]=d):d=e[2];let f;e[3]!==s||e[4]!==c?(f=a.jsx(OI,{"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(ZI),e[6]=o,e[7]=m):m=e[7];let p;e[8]!==m?(p=a.jsx(MI,{children:a.jsx($I,{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(II,{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(_a,{label:t,children:h}),e[17]=t,e[18]=h,e[19]=g):g=e[19],g}function ZI(n){return a.jsx(LI,{value:n.value,children:n.menuLabel??n.label},n.value||"default")}function YI(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:v,changeAndApply:y}=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=pn(r).configurableContextWindow&&s&&a.jsx(xk,{value:t??null,onChange:s}),e[1]=r,e[2]=t,e[3]=s,e[4]=j):j=e[4];let C;e[5]!==j?(C=a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[k,j]}),e[5]=j,e[6]=C):C=e[6];let _;e[7]!==r||e[8]!==o?(_=o&&a.jsx(tc,{label:"Agent",ariaLabel:"Agent",value:r,options:Rp,onChange:I=>o(I)}),e[7]=r,e[8]=o,e[9]=_):_=e[9];let S;e[10]!==c||e[11]!==l||e[12]!==i?(S=a.jsx(tc,{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 N;e[14]!==f||e[15]!==d||e[16]!==u||e[17]!==m?(N=f.length>0&&a.jsx(tc,{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]=N):N=e[18];let T;e[19]!==y||e[20]!==h||e[21]!==p||e[22]!==g?(T=p&&g&&a.jsx(_a,{label:"Speed",children:a.jsxs(J,{type:"button",variant:h?"secondary":"ghost","aria-pressed":!!h,onClick:()=>y(()=>g(!h)),title:p.description,className:"h-10 justify-start",children:[a.jsx(su,{"data-icon":"inline-start",className:K(h&&"fill-current")}),h?"Fast":"Standard"]})}),e[19]=y,e[20]=h,e[21]=p,e[22]=g,e[23]=T):T=e[23];let E;e[24]!==v||e[25]!==x||e[26]!==b?(E=v&&x&&a.jsx(tc,{label:"Access",ariaLabel:"Access policy",value:x,options:b,onChange:I=>v(I)}),e[24]=v,e[25]=x,e[26]=b,e[27]=E):E=e[27];let A;e[28]!==_||e[29]!==S||e[30]!==N||e[31]!==T||e[32]!==E?(A=a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[_,S,N,T,E]}),e[28]=_,e[29]=S,e[30]=N,e[31]=T,e[32]=E,e[33]=A):A=e[33];let P;return e[34]!==C||e[35]!==A?(P=a.jsxs("section",{"aria-labelledby":"mobile-model-controls",className:"flex flex-col gap-2",children:[C,A]}),e[34]=C,e[35]=A,e[36]=P):P=e[36],P}function XI(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=pn(t),e[0]=t,e[1]=g):g=e[1];const{worktrees:x,ultracode:b}=g,v=!!(d&&f&&p&&(m||c&&c.length>0)),y=!!(x&&s&&o||b&&l||v);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 C=j;if(!y)return null;let _;e[6]===Symbol.for("react.memo_cache_sentinel")?(_=a.jsx("h3",{id:"mobile-advanced-controls",className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Advanced"}),e[6]=_):_=e[6];let S;e[7]!==s||e[8]!==o||e[9]!==x||e[10]!==r?(S=x&&s&&o&&a.jsx(_a,{label:"Isolation",children:a.jsxs(J,{type:"button",variant:r?"secondary":"ghost","aria-pressed":!!r,onClick:()=>o(!r),className:"h-10 justify-start",children:[a.jsx(Qr,{"data-icon":"inline-start"}),"Worktree"]})}),e[7]=s,e[8]=o,e[9]=x,e[10]=r,e[11]=S):S=e[11];let N;e[12]!==h||e[13]!==l||e[14]!==b||e[15]!==i?(N=b&&l&&a.jsx(_a,{label:"Workflow",children:a.jsxs(J,{type:"button",variant:i?"secondary":"ghost","aria-pressed":!!i,onClick:()=>h(()=>l(!i)),className:"h-10 justify-start",children:[a.jsx(su,{"data-icon":"inline-start",className:K(i&&"fill-current")}),"Ultracode"]})}),e[12]=h,e[13]=l,e[14]=b,e[15]=i,e[16]=N):N=e[16];let T;e[17]!==h||e[18]!==m||e[19]!==c||e[20]!==p||e[21]!==f||e[22]!==d||e[23]!==C||e[24]!==v?(T=v&&d&&f&&p&&a.jsx(_a,{label:"Connections",wide:!0,children:a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsxs(J,{type:"button",variant:"ghost",onClick:f,className:"min-h-10 justify-start",children:[a.jsx(Un,{"data-icon":"inline-start",className:K(m&&"animate-spin")}),"Refresh MCP status"]}),(c??[]).map(A=>{const P=C.has(A.name),I=A.status==="connected";return a.jsxs(J,{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:K("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]=C,e[24]=v,e[25]=T):T=e[25];let E;return e[26]!==S||e[27]!==N||e[28]!==T?(E=a.jsxs("section",{"aria-labelledby":"mobile-advanced-controls",className:"flex flex-col gap-2",children:[_,a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[S,N,T]})]}),e[26]=S,e[27]=N,e[28]=T,e[29]=E):E=e[29],E}function JI(n){var ce,te;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:v,isNewSession:y,worktreeEnabled:k,onWorktreeEnabledChange:j,ultracodeEnabled:C,onUltracodeEnabledChange:_,autoModeAvailable:S,permissionMode:N,onPermissionModeChange:T,mcpServers:E,selectedMcpServers:A,onToggleMcpServer:P,onRefreshMcpServers:I,mcpLoading:O,onMcpAuth:R,mobileExtra:$,changeAndApply:M}=n;let z,F;e[0]!==r||e[1]!==S||e[2]!==N?(z=Sk(r,S),F=(ce=z.find(le=>le.value===N))==null?void 0:ce.label,e[0]=r,e[1]=S,e[2]=N,e[3]=z,e[4]=F):(z=e[3],F=e[4]);const D=F;let L;e[5]!==c||e[6]!==l||e[7]!==i?(L=i?bg(i,c):l,e[5]=c,e[6]=l,e[7]=i,e[8]=L):L=e[8];let B;e[9]!==m||e[10]!==f?(B=(te=m.find(le=>le.value===f))==null?void 0:te.label,e[9]=m,e[10]=f,e[11]=B):B=e[11];let U;e[12]!==D||e[13]!==L||e[14]!==B?(U=[L,B,D].filter(Boolean),e[12]=D,e[13]=L,e[14]=B,e[15]=U):U=e[15];const W=U.join(" · ");let V;e[16]!==M||e[17]!==T?(V=le=>{T&&M(()=>T(le))},e[16]=M,e[17]=T,e[18]=V):V=e[18];const H=V;let G;e[19]===Symbol.for("react.memo_cache_sentinel")?(G=a.jsx(UI,{render:a.jsx(J,{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(Yh,{})}),e[19]=G):G=e[19];let Z;e[20]===Symbol.for("react.memo_cache_sentinel")?(Z=a.jsx(KI,{children:"Session controls"}),e[20]=Z):Z=e[20];let Y;e[21]!==W?(Y=a.jsx(GI,{className:"truncate text-xs",children:W}),e[21]=W,e[22]=Y):Y=e[22];let X;e[23]===Symbol.for("react.memo_cache_sentinel")?(X=a.jsx(BI,{render:a.jsx(J,{type:"button",variant:"ghost",size:"icon-lg",className:"absolute right-2 top-2","aria-label":"Close session controls"}),children:a.jsx(Wt,{})}),e[23]=X):X=e[23];let ee;e[24]!==Y?(ee=a.jsxs(HI,{className:"gap-1 px-4 pb-3 pt-4",children:[Z,Y,X]}),e[24]=Y,e[25]=ee):ee=e[25];let Q;e[26]!==r||e[27]!==M||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]!==v||e[38]!==d||e[39]!==N||e[40]!==z||e[41]!==f||e[42]!==i||e[43]!==C?(Q=a.jsx(YI,{contextWindowTokens:h,onContextWindowTokensChange:g,agentKind:r,onAgentKindChange:o,selectedModel:i,onModelChange:d,modelOptions:u,selectedEffort:f,onEffortChange:p,effortOptions:m,ultracodeEnabled:C,fastTier:x,fastModeEnabled:b,onFastModeEnabledChange:v,permissionMode:N,permissionOptions:z,onPermissionModeChange:H,changeAndApply:M}),e[26]=r,e[27]=M,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]=v,e[38]=d,e[39]=N,e[40]=z,e[41]=f,e[42]=i,e[43]=C,e[44]=Q):Q=e[44];let ne;e[45]!==r||e[46]!==M||e[47]!==y||e[48]!==O||e[49]!==E||e[50]!==R||e[51]!==I||e[52]!==P||e[53]!==_||e[54]!==j||e[55]!==A||e[56]!==C||e[57]!==k?(ne=a.jsx(XI,{agentKind:r,isNewSession:y,worktreeEnabled:k,onWorktreeEnabledChange:j,ultracodeEnabled:C,onUltracodeEnabledChange:_,mcpServers:E,selectedMcpServers:A,onToggleMcpServer:P,onRefreshMcpServers:I,mcpLoading:O,onMcpAuth:R,changeAndApply:M}),e[45]=r,e[46]=M,e[47]=y,e[48]=O,e[49]=E,e[50]=R,e[51]=I,e[52]=P,e[53]=_,e[54]=j,e[55]=A,e[56]=C,e[57]=k,e[58]=ne):ne=e[58];let re;e[59]!==$?(re=$&&a.jsxs("section",{"aria-labelledby":"mobile-goal-controls",className:"flex flex-col gap-2 pt-1",children:[a.jsx(Zt,{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:$})]}),e[59]=$,e[60]=re):re=e[60];let se;e[61]!==r||e[62]!==y?(se=!y&&a.jsx("p",{className:"text-xs text-muted-foreground",children:pn(r).settingsApply==="live"?"Changes apply live.":"Changes apply on the next turn."}),e[61]=r,e[62]=y,e[63]=se):se=e[63];let oe;e[64]!==Q||e[65]!==ne||e[66]!==re||e[67]!==se?(oe=a.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-4 py-4",children:[Q,ne,re,se]}),e[64]=Q,e[65]=ne,e[66]=re,e[67]=se,e[68]=oe):oe=e[68];let ae;e[69]!==ee||e[70]!==oe?(ae=a.jsxs(VI,{side:"bottom",className:"max-h-[82dvh] overflow-hidden rounded-t-2xl pb-[env(safe-area-inset-bottom)]",showCloseButton:!1,children:[ee,oe]}),e[69]=ee,e[70]=oe,e[71]=ae):ae=e[71];let ie;return e[72]!==s||e[73]!==t||e[74]!==ae?(ie=a.jsx(a.Fragment,{children:a.jsxs(FI,{open:t,onOpenChange:s,children:[G,ae]})}),e[72]=s,e[73]=t,e[74]=ae,e[75]=ie):ie=e[75],ie}const QI=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:v,activeModelId:y,mcpServers:k,selectedMcpServers:j,onToggleMcpServer:C,onSetMcpServers:_,onRefreshMcpServers:S,mcpLoading:N,onMcpAuth:T,permissionMode:E,onPermissionModeChange:A,mobileExtra:P,trailingExtra:I,mobile:O}=e,R=s===void 0?zo:s,$=O===void 0?!1:O,[M,z]=w.useState(!1);let F;t[0]!==p||t[1]!==v?(F=te=>{te(),!p&&v&&setTimeout(()=>v(),0)},t[0]=p,t[1]=v,t[2]=F):F=t[2];const D=F;let L;t[3]!==D||t[4]!==i?(L=te=>D(()=>i(te)),t[3]=D,t[4]=i,t[5]=L):L=t[5];const B=L;let U;t[6]!==D||t[7]!==c?(U=te=>D(()=>c(te)),t[6]=D,t[7]=c,t[8]=U):U=t[8];const W=U,{options:V,effortOptions:H,fastTier:G,autoPermissionMode:Z,normalizeEffort:Y}=fk(R,o),X=(y==null?void 0:y.toLowerCase().startsWith("gpt-"))??!1,Q=y&&(R==="copilot"||X===(R==="codex"))?y:void 0;let ne,re;t[9]!==V||t[10]!==Q?(ne=Q?bg(Q,V):vI(V),re=V.map(te=>{const le=[te.description,te.availabilityMessage].filter(Boolean).join(" · ")||void 0;return te.value===""?{...te,description:le,label:ne,menuLabel:te.label}:{...te,description:le}}),t[9]=V,t[10]=Q,t[11]=ne,t[12]=re):(ne=t[11],re=t[12]);const se=re;let oe;t[13]!==Y||t[14]!==l?(oe=Y(l),t[13]=Y,t[14]=l,t[15]=oe):oe=t[15];let ae;t[16]!==R||t[17]!==Z||t[18]!==D||t[19]!==u||t[20]!==H||t[21]!==f||t[22]!==G||t[23]!==W||t[24]!==B||t[25]!==p||t[26]!==N||t[27]!==k||t[28]!==se||t[29]!==r||t[30]!==d||t[31]!==m||t[32]!==T||t[33]!==A||t[34]!==S||t[35]!==_||t[36]!==C||t[37]!==b||t[38]!==g||t[39]!==E||t[40]!==ne||t[41]!==j||t[42]!==o||t[43]!==oe||t[44]!==x||t[45]!==h?(ae={agentKind:R,onAgentKindChange:r,selectedModel:o,resolvedDefaultName:ne,modelOptions:se,onModelChange:B,selectedEffort:oe,effortOptions:H,onEffortChange:W,contextWindowTokens:u,onContextWindowTokensChange:d,fastTier:G,fastModeEnabled:f,onFastModeEnabledChange:m,isNewSession:p,worktreeEnabled:h,onWorktreeEnabledChange:g,ultracodeEnabled:x,onUltracodeEnabledChange:b,autoModeAvailable:Z,permissionMode:E,onPermissionModeChange:A,mcpServers:k,selectedMcpServers:j,onToggleMcpServer:C,onSetMcpServers:_,onRefreshMcpServers:S,mcpLoading:N,onMcpAuth:T,changeAndApply:D},t[16]=R,t[17]=Z,t[18]=D,t[19]=u,t[20]=H,t[21]=f,t[22]=G,t[23]=W,t[24]=B,t[25]=p,t[26]=N,t[27]=k,t[28]=se,t[29]=r,t[30]=d,t[31]=m,t[32]=T,t[33]=A,t[34]=S,t[35]=_,t[36]=C,t[37]=b,t[38]=g,t[39]=E,t[40]=ne,t[41]=j,t[42]=o,t[43]=oe,t[44]=x,t[45]=h,t[46]=ae):ae=t[46];const ie=ae;if($){let te;return t[47]!==V||t[48]!==ie||t[49]!==P||t[50]!==M?(te=a.jsx(JI,{...ie,open:M,onOpenChange:z,catalogOptions:V,mobileExtra:P}),t[47]=V,t[48]=ie,t[49]=P,t[50]=M,t[51]=te):te=t[51],te}let ce;return t[52]!==ie||t[53]!==I?(ce=a.jsx(NI,{...ie,trailingExtra:I}),t[52]=ie,t[53]=I,t[54]=ce):ce=t[54],ce});function kk(n){return n.agentType==="team-lead"}function e7(n){return kk(n)?void 0:n.color}const t7={blue:"bg-blue-500",green:"bg-green-500",yellow:"bg-yellow-500",purple:"bg-purple-500",orange:"bg-orange-500"};function n7(n){return n?t7[n]??"bg-zinc-400":"bg-zinc-400"}const s7=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(Zt,{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,v=n7(e7(g));return a.jsxs(J,{variant:"ghost",size:"xs",onClick:()=>l(g),disabled:b,className:K("whitespace-nowrap",x?"bg-accent text-accent-foreground":"text-muted-foreground"),children:[b?a.jsx(ht,{"data-icon":"inline-start",className:"animate-spin"}):a.jsx("span",{className:K("inline-flex size-1.5 shrink-0 rounded-full",v)}),a.jsx("span",{children:g.name}),kk(g)&&a.jsx(DE,{"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 jk(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 Nk=w.createContext(null),Ck=w.createContext(null);function Uc(n){const e=q.c(6),{value:t,chatValue:s,children:r}=n;let o;e[0]!==s||e[1]!==r?(o=a.jsx(Ck.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(Nk.Provider,{value:t,children:o}),e[3]=o,e[4]=t,e[5]=i):i=e[5],i}function xt(){const n=w.useContext(Nk);if(!n)throw new Error("useSessionContext must be used within a SessionProvider");return n}function hl(){const n=w.useContext(Ck);if(!n)throw new Error("useSessionChatContext must be used within a SessionProvider");return n}const r7=_r("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 Fe(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=TS,s="span",r=_S({className:K(r7({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 Ub=1,o7=.9,i7=.8,a7=.17,cf=.1,uf=.999,l7=.9999,c7=.99,u7=/[\\\/_+.#"@\[\(\{&]/,d7=/[\\\/_+.#"@\[\(\{&]/g,f7=/[\s-]/,_k=/[\s-]/g;function Op(n,e,t,s,r,o,i){if(o===e.length)return r===n.length?Ub:c7;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=Op(n,e,t,s,u+1,o+1,i),f>d&&(u===r?f*=Ub:u7.test(n.charAt(u-1))?(f*=i7,p=n.slice(r,u-1).match(d7),p&&r>0&&(f*=Math.pow(uf,p.length))):f7.test(n.charAt(u-1))?(f*=o7,h=n.slice(r,u-1).match(_k),h&&r>0&&(f*=Math.pow(uf,h.length))):(f*=a7,r>0&&(f*=Math.pow(uf,u-r))),n.charAt(u)!==e.charAt(o)&&(f*=l7)),(f<cf&&t.charAt(u-1)===s.charAt(o+1)||s.charAt(o+1)===s.charAt(o)&&t.charAt(u-1)!==s.charAt(o))&&(m=Op(n,e,t,s,u+1,o+2,i),m*cf>f&&(f=m*cf)),f>d&&(d=f),u=t.indexOf(c,u+1);return i[l]=d,d}function Bb(n){return n.toLowerCase().replace(_k," ")}function m7(n,e,t){return n=t&&t.length>0?`${n+" "+t.join(" ")}`:n,Op(n,e,Bb(n),Bb(e),0,0,{})}var ea='[cmdk-group=""]',df='[cmdk-group-items=""]',p7='[cmdk-group-heading=""]',Tk='[cmdk-item=""]',Wb=`${Tk}:not([aria-disabled="true"])`,Mp="cmdk-item-select",ni="data-value",h7=(n,e,t)=>m7(n,e,t),Ek=w.createContext(void 0),gl=()=>w.useContext(Ek),Ak=w.createContext(void 0),vg=()=>w.useContext(Ak),Pk=w.createContext(void 0),Ik=w.forwardRef((n,e)=>{let t=si(()=>{var L,B;return{search:"",value:(B=(L=n.value)!=null?L:n.defaultValue)!=null?B:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),s=si(()=>new Set),r=si(()=>new Map),o=si(()=>new Map),i=si(()=>new Set),l=$k(n),{label:c,children:u,value:d,onValueChange:f,filter:m,shouldFilter:p,loop:h,disablePointerSelection:g=!1,vimBindings:x=!0,...b}=n,v=pi(),y=pi(),k=pi(),j=w.useRef(null),C=C7();Ao(()=>{if(d!==void 0){let L=d.trim();t.current.value=L,_.emit()}},[d]),Ao(()=>{C(6,P)},[]);let _=w.useMemo(()=>({subscribe:L=>(i.current.add(L),()=>i.current.delete(L)),snapshot:()=>t.current,setState:(L,B,U)=>{var W,V,H,G;if(!Object.is(t.current[L],B)){if(t.current[L]=B,L==="search")A(),T(),C(1,E);else if(L==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let Z=document.getElementById(k);Z?Z.focus():(W=document.getElementById(v))==null||W.focus()}if(C(7,()=>{var Z;t.current.selectedItemId=(Z=I())==null?void 0:Z.id,_.emit()}),U||C(5,P),((V=l.current)==null?void 0:V.value)!==void 0){let Z=B??"";(G=(H=l.current).onValueChange)==null||G.call(H,Z);return}}_.emit()}},emit:()=>{i.current.forEach(L=>L())}}),[]),S=w.useMemo(()=>({value:(L,B,U)=>{var W;B!==((W=o.current.get(L))==null?void 0:W.value)&&(o.current.set(L,{value:B,keywords:U}),t.current.filtered.items.set(L,N(B,U)),C(2,()=>{T(),_.emit()}))},item:(L,B)=>(s.current.add(L),B&&(r.current.has(B)?r.current.get(B).add(L):r.current.set(B,new Set([L]))),C(3,()=>{A(),T(),t.current.value||E(),_.emit()}),()=>{o.current.delete(L),s.current.delete(L),t.current.filtered.items.delete(L);let U=I();C(4,()=>{A(),(U==null?void 0:U.getAttribute("id"))===L&&E(),_.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:v,inputId:k,labelId:y,listInnerRef:j}),[]);function N(L,B){var U,W;let V=(W=(U=l.current)==null?void 0:U.filter)!=null?W:h7;return L?V(L,t.current.search,B):0}function T(){if(!t.current.search||l.current.shouldFilter===!1)return;let L=t.current.filtered.items,B=[];t.current.filtered.groups.forEach(W=>{let V=r.current.get(W),H=0;V.forEach(G=>{let Z=L.get(G);H=Math.max(Z,H)}),B.push([W,H])});let U=j.current;O().sort((W,V)=>{var H,G;let Z=W.getAttribute("id"),Y=V.getAttribute("id");return((H=L.get(Y))!=null?H:0)-((G=L.get(Z))!=null?G:0)}).forEach(W=>{let V=W.closest(df);V?V.appendChild(W.parentElement===V?W:W.closest(`${df} > *`)):U.appendChild(W.parentElement===U?W:W.closest(`${df} > *`))}),B.sort((W,V)=>V[1]-W[1]).forEach(W=>{var V;let H=(V=j.current)==null?void 0:V.querySelector(`${ea}[${ni}="${encodeURIComponent(W[0])}"]`);H==null||H.parentElement.appendChild(H)})}function E(){let L=O().find(U=>U.getAttribute("aria-disabled")!=="true"),B=L==null?void 0:L.getAttribute(ni);_.setState("value",B||void 0)}function A(){var L,B,U,W;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 G=(B=(L=o.current.get(H))==null?void 0:L.value)!=null?B:"",Z=(W=(U=o.current.get(H))==null?void 0:U.keywords)!=null?W:[],Y=N(G,Z);t.current.filtered.items.set(H,Y),Y>0&&V++}for(let[H,G]of r.current)for(let Z of G)if(t.current.filtered.items.get(Z)>0){t.current.filtered.groups.add(H);break}t.current.filtered.count=V}function P(){var L,B,U;let W=I();W&&(((L=W.parentElement)==null?void 0:L.firstChild)===W&&((U=(B=W.closest(ea))==null?void 0:B.querySelector(p7))==null||U.scrollIntoView({block:"nearest"})),W.scrollIntoView({block:"nearest"}))}function I(){var L;return(L=j.current)==null?void 0:L.querySelector(`${Tk}[aria-selected="true"]`)}function O(){var L;return Array.from(((L=j.current)==null?void 0:L.querySelectorAll(Wb))||[])}function R(L){let B=O()[L];B&&_.setState("value",B.getAttribute(ni))}function $(L){var B;let U=I(),W=O(),V=W.findIndex(G=>G===U),H=W[V+L];(B=l.current)!=null&&B.loop&&(H=V+L<0?W[W.length-1]:V+L===W.length?W[0]:W[V+L]),H&&_.setState("value",H.getAttribute(ni))}function M(L){let B=I(),U=B==null?void 0:B.closest(ea),W;for(;U&&!W;)U=L>0?j7(U,ea):N7(U,ea),W=U==null?void 0:U.querySelector(Wb);W?_.setState("value",W.getAttribute(ni)):$(L)}let z=()=>R(O().length-1),F=L=>{L.preventDefault(),L.metaKey?z():L.altKey?M(1):$(1)},D=L=>{L.preventDefault(),L.metaKey?R(0):L.altKey?M(-1):$(-1)};return w.createElement(mo.div,{ref:e,tabIndex:-1,...b,"cmdk-root":"",onKeyDown:L=>{var B;(B=b.onKeyDown)==null||B.call(b,L);let U=L.nativeEvent.isComposing||L.keyCode===229;if(!(L.defaultPrevented||U))switch(L.key){case"n":case"j":{x&&L.ctrlKey&&F(L);break}case"ArrowDown":{F(L);break}case"p":case"k":{x&&L.ctrlKey&&D(L);break}case"ArrowUp":{D(L);break}case"Home":{L.preventDefault(),R(0);break}case"End":{L.preventDefault(),z();break}case"Enter":{L.preventDefault();let W=I();if(W){let V=new Event(Mp);W.dispatchEvent(V)}}}}},w.createElement("label",{"cmdk-label":"",htmlFor:S.inputId,id:S.labelId,style:T7},c),ad(n,L=>w.createElement(Ak.Provider,{value:_},w.createElement(Ek.Provider,{value:S},L))))}),g7=w.forwardRef((n,e)=>{var t,s;let r=pi(),o=w.useRef(null),i=w.useContext(Pk),l=gl(),c=$k(n),u=(s=(t=c.current)==null?void 0:t.forceMount)!=null?s:i==null?void 0:i.forceMount;Ao(()=>{if(!u)return l.item(r,i==null?void 0:i.id)},[u]);let d=Rk(r,o,[n.value,n.children,o],n.keywords),f=vg(),m=ro(C=>C.value&&C.value===d.current),p=ro(C=>u||l.filter()===!1?!0:C.search?C.filtered.items.get(r)>0:!0);w.useEffect(()=>{let C=o.current;if(!(!C||n.disabled))return C.addEventListener(Mp,h),()=>C.removeEventListener(Mp,h)},[p,n.onSelect,n.disabled]);function h(){var C,_;g(),(_=(C=c.current).onSelect)==null||_.call(C,d.current)}function g(){f.setState("value",d.current,!0)}if(!p)return null;let{disabled:x,value:b,onSelect:v,forceMount:y,keywords:k,...j}=n;return w.createElement(mo.div,{ref:Fa(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)}),x7=w.forwardRef((n,e)=>{let{heading:t,children:s,forceMount:r,...o}=n,i=pi(),l=w.useRef(null),c=w.useRef(null),u=pi(),d=gl(),f=ro(p=>r||d.filter()===!1?!0:p.search?p.filtered.groups.has(i):!0);Ao(()=>d.group(i),[]),Rk(i,l,[n.value,n.heading,c]);let m=w.useMemo(()=>({id:i,forceMount:r}),[r]);return w.createElement(mo.div,{ref:Fa(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),ad(n,p=>w.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":t?u:void 0},w.createElement(Pk.Provider,{value:m},p))))}),b7=w.forwardRef((n,e)=>{let{alwaysRender:t,...s}=n,r=w.useRef(null),o=ro(i=>!i.search);return!t&&!o?null:w.createElement(mo.div,{ref:Fa(r,e),...s,"cmdk-separator":"",role:"separator"})}),v7=w.forwardRef((n,e)=>{let{onValueChange:t,...s}=n,r=n.value!=null,o=vg(),i=ro(u=>u.search),l=ro(u=>u.selectedItemId),c=gl();return w.useEffect(()=>{n.value!=null&&o.setState("search",n.value)},[n.value]),w.createElement(mo.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)}})}),y7=w.forwardRef((n,e)=>{let{children:t,label:s="Suggestions",...r}=n,o=w.useRef(null),i=w.useRef(null),l=ro(u=>u.selectedItemId),c=gl();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(mo.div,{ref:Fa(o,e),...r,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":l,"aria-label":s,id:c.listId},ad(n,u=>w.createElement("div",{ref:Fa(i,c.listInnerRef),"cmdk-list-sizer":""},u)))}),w7=w.forwardRef((n,e)=>{let{open:t,onOpenChange:s,overlayClassName:r,contentClassName:o,container:i,...l}=n;return w.createElement(FE,{open:t,onOpenChange:s},w.createElement(UE,{container:i},w.createElement(BE,{"cmdk-overlay":"",className:r}),w.createElement(WE,{"aria-label":n.label,"cmdk-dialog":"",className:o},w.createElement(Ik,{ref:e,...l}))))}),S7=w.forwardRef((n,e)=>ro(t=>t.filtered.count===0)?w.createElement(mo.div,{ref:e,...n,"cmdk-empty":"",role:"presentation"}):null),k7=w.forwardRef((n,e)=>{let{progress:t,children:s,label:r="Loading...",...o}=n;return w.createElement(mo.div,{ref:e,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,"aria-label":r},ad(n,i=>w.createElement("div",{"aria-hidden":!0},i)))}),Bi=Object.assign(Ik,{List:y7,Item:g7,Input:v7,Group:x7,Separator:b7,Dialog:w7,Empty:S7,Loading:k7});function j7(n,e){let t=n.nextElementSibling;for(;t;){if(t.matches(e))return t;t=t.nextElementSibling}}function N7(n,e){let t=n.previousElementSibling;for(;t;){if(t.matches(e))return t;t=t.previousElementSibling}}function $k(n){let e=w.useRef(n);return Ao(()=>{e.current=n}),e}var Ao=typeof window>"u"?w.useEffect:w.useLayoutEffect;function si(n){let e=w.useRef();return e.current===void 0&&(e.current=n()),e}function ro(n){let e=vg(),t=()=>n(e.snapshot());return w.useSyncExternalStore(e.subscribe,t,t)}function Rk(n,e,t,s=[]){let r=w.useRef(),o=gl();return Ao(()=>{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(ni,l),r.current=l}),r}var C7=()=>{let[n,e]=w.useState(),t=si(()=>new Map);return Ao(()=>{t.current.forEach(s=>s()),t.current=new Map},[n]),(s,r)=>{t.current.set(s,r),e({})}};function _7(n){let e=n.type;return typeof e=="function"?e(n.props):"render"in e?e.render(n.props):n}function ad({asChild:n,children:e},t){return n&&w.isValidElement(e)?w.cloneElement(_7(e),{ref:e.ref},t(e.props.children)):t(e)}var T7={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function or(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(CS,{"data-slot":"dialog",...t}),e[2]=t,e[3]=s):s=e[3],s}function E7(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(Gh,{"data-slot":"dialog-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}function nfe(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(ul,{"data-slot":"dialog-close",...t}),e[2]=t,e[3]=s):s=e[3],s}function A7(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=K("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(Zh,{"data-slot":"dialog-overlay",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function ir(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(A7,{}),e[5]=l):l=e[5];let c;e[6]!==s?(c=K("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(ul,{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(Wt,{"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(E7,{children:[l,a.jsxs(Kh,{"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 ho(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=K("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 yg(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=K("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 ar(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=K("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(Vh,{"data-slot":"dialog-title",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function lr(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=K("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(Hh,{"data-slot":"dialog-description",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function wg(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=K("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(Bi,{"data-slot":"command",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function sfe(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=K("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(ar,{children:c}),e[9]=c,e[10]=m):m=e[10];let p;e[11]!==u?(p=a.jsx(lr,{children:u}),e[11]=u,e[12]=p):p=e[12];let h;e[13]!==m||e[14]!==p?(h=a.jsxs(ho,{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(ir,{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(or,{...r,children:g}),e[21]=r,e[22]=g,e[23]=x):x=e[23],x}function P7(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(Bn,{className:"size-4 shrink-0 text-muted-foreground"}),e[3]=r):r=e[3];let o;e[4]!==t?(o=K("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(Bi.Input,{"data-slot":"command-input",className:o,...s})]}),e[6]=s,e[7]=o,e[8]=i):i=e[8],i}function Sg(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=K("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(Bi.List,{"data-slot":"command-list",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function I7(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=K("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(Bi.Empty,{"data-slot":"command-empty",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function cu(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=K("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(Bi.Group,{"data-slot":"command-group",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function uu(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=K("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:bg-muted data-selected:text-foreground motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-selected:*:[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(Bt,{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(Bi.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 $7(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=K("ml-auto text-xs tracking-widest text-muted-foreground group-data-selected/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 R7(n){return a.jsx(Fe,{variant:n.source==="built-in"?"secondary":"outline",children:n.source})}const O7=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 E;const T=f.current.get(i);T&&((E=T.scrollIntoView)==null||E.call(T,{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 T;return t[4]===Symbol.for("react.memo_cache_sentinel")?(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.jsxs("div",{className:"flex items-center gap-2 rounded-lg border bg-popover p-3 text-popover-foreground shadow-sm",children:[a.jsx(ht,{className:"size-3.5 animate-spin text-muted-foreground"}),a.jsx("span",{className:"text-xs text-muted-foreground",children:"Loading suggestions..."})]})}),t[4]=T):T=t[4],T}if(s.length===0){const T=r?`No commands or skills matching "${r}"`:"No commands or skills found";let E;return t[5]!==T?(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.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:T})})}),t[5]=T,t[6]=E):E=t[6],E}let h,g,x,b,v,y,k,j,C;if(t[7]!==u||t[8]!==c||t[9]!==l||t[10]!==i||t[11]!==s){const T=s.filter(L7),E=[{heading:"Commands",suggestions:T,offset:0},{heading:"Skills",suggestions:s.filter(z7),offset:T.length}];x="motion-popover-in absolute bottom-full left-0 right-0 z-50 mx-auto mb-2 max-w-[var(--chat-width)]",g=wg,v="slash-suggestions",y=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,C="border shadow-sm",h=Sg,b=E.map(A=>A.suggestions.length>0&&a.jsx(cu,{heading:A.heading,children:A.suggestions.map((P,I)=>{const O=A.offset+I;return a.jsx(M7,{suggestion:P,index:O,isSelected:O===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]=v,t[17]=y,t[18]=k,t[19]=j,t[20]=C}else h=t[12],g=t[13],x=t[14],b=t[15],v=t[16],y=t[17],k=t[18],j=t[19],C=t[20];let _;t[24]!==h||t[25]!==b?(_=a.jsx(h,{children:b}),t[24]=h,t[25]=b,t[26]=_):_=t[26];let S;t[27]!==g||t[28]!==_||t[29]!==v||t[30]!==y||t[31]!==k||t[32]!==j||t[33]!==C?(S=a.jsx(g,{id:v,value:y,onValueChange:k,shouldFilter:j,className:C,children:_}),t[27]=g,t[28]=_,t[29]=v,t[30]=y,t[31]=k,t[32]=j,t[33]=C,t[34]=S):S=t[34];let N;return t[35]!==x||t[36]!==S?(N=a.jsx("div",{className:x,children:S}),t[35]=x,t[36]=S,t[37]=N):N=t[37],N});function M7({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(uu,{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(yi,{className:"size-4 text-muted-foreground"}):a.jsx(Da,{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]}),R7(n)]}),n.description&&a.jsx("p",{className:"mt-0.5 line-clamp-1 text-xs text-muted-foreground",children:n.description})]}),t&&a.jsx($7,{className:o&&n.filePath?"mr-6":void 0,children:"Enter"})]}),o&&n.filePath&&a.jsx(J,{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(yr,{"data-icon":"inline-start"})})]})}function L7(n){return n.type==="command"}function z7(n){return n.type==="skill"}function D7(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 y,k;(k=(y=u.current.get(o))==null?void 0:y.scrollIntoView)==null||k.call(y,{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=y=>{const k=t.indexOf(y);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(ht,{"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((y,k)=>a.jsxs(uu,{ref:j=>{j?(j.id=`file-suggestion-${k}`,u.current.set(k,j)):u.current.delete(k)},value:y,onMouseEnter:()=>l(k),onSelect:()=>i(y),onMouseDown:F7,children:[a.jsx(ES,{"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:y}),k===o&&a.jsx("span",{className:"text-xs text-muted-foreground",children:"↵"})]},y)),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(Sg,{className:"max-h-70",children:a.jsx(cu,{heading:g,children:x})}),e[18]=g,e[19]=x,e[20]=b):b=e[20];let v;return e[21]!==m||e[22]!==p||e[23]!==b?(v=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(wg,{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]=v):v=e[24],v}function F7(n){return n.preventDefault()}const U7=_r("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 Ft({className:n,variant:e,...t}){return a.jsx("div",{"data-slot":"alert",role:"alert",className:K(U7({variant:e}),n),...t})}function on({className:n,...e}){return a.jsx("div",{"data-slot":"alert-title",className:K("font-medium group-has-[>svg]/alert:col-start-2 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground",n),...e})}function Ut({className:n,...e}){return a.jsx("div",{"data-slot":"alert-description",className:K("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 oo({className:n,...e}){return a.jsx("div",{"data-slot":"alert-action",className:K("absolute top-2 right-2",n),...e})}function Wi(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(qE,{"data-slot":"dropdown-menu",...t}),e[2]=t,e[3]=s):s=e[3],s}function qi(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(VE,{"data-slot":"dropdown-menu-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function Vi(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=K("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(AS,{"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($S,{children:a.jsx(RS,{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 br(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(PS,{"data-slot":"dropdown-menu-group",...t}),e[2]=t,e[3]=s):s=e[3],s}function Ok(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=K("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(OS,{"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 vn(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=K("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(IS,{"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 du(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=K("-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(qh,{"data-slot":"dropdown-menu-separator",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function wn({...n}){return a.jsx(KE,{"data-slot":"collapsible",...n})}function ds({...n}){return a.jsx(GE,{"data-slot":"collapsible-trigger",...n})}function Sn({className:n,...e}){return a.jsx(HE,{"data-slot":"collapsible-content",className:K("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 B7={exit_only:"Exit plan mode",interactive:"Implement interactively",autopilot:"Implement with Autopilot",autopilot_fleet:"Implement with Fleet"};function qb(n){return B7[n]??n.replaceAll("_"," ")}function W7(n){const e=q.c(46),{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,b,v,y,k;if(e[0]!==u||e[1]!==i||e[2]!==s||e[3]!==o||e[4]!==l){const E=o===void 0?[]:o;p=l===void 0?!1:l;const A=i??E[0],P=E.filter(R=>R!==A);m=Ft,b="mb-3 pr-44",e[15]===Symbol.for("react.memo_cache_sentinel")?(v=a.jsx(Ku,{}),y=a.jsx(on,{children:"Plan ready for review"}),e[15]=v,e[16]=y):(v=e[15],y=e[16]);const I=s||"Approve the plan or ask the agent to revise it.";e[17]!==I?(k=a.jsx(Ut,{children:I}),e[17]=I,e[18]=k):k=e[18],f=oo,h="flex gap-2";let O;e[19]!==p?(O=p&&a.jsx(ht,{className:"animate-spin","data-icon":"inline-start"}),e[19]=p,e[20]=O):O=e[20],g=a.jsxs(J,{size:"sm",disabled:p,onClick:()=>u(A),children:[O,p?"Sending...":A?qb(A):"Approve"]}),x=P.length>0&&a.jsxs(Wi,{children:[a.jsx(qi,{render:a.jsx(J,{type:"button",variant:"outline",size:"icon-sm","aria-label":"Other plan actions",disabled:p}),children:a.jsx(It,{"data-icon":"icon"})}),a.jsx(Vi,{align:"end",children:a.jsx(br,{children:P.map(R=>a.jsx(vn,{onClick:()=>u(R),children:qb(R)},R))})})]}),e[0]=u,e[1]=i,e[2]=s,e[3]=o,e[4]=l,e[5]=f,e[6]=m,e[7]=p,e[8]=h,e[9]=g,e[10]=x,e[11]=b,e[12]=v,e[13]=y,e[14]=k}else f=e[5],m=e[6],p=e[7],h=e[8],g=e[9],x=e[10],b=e[11],v=e[12],y=e[13],k=e[14];let j;e[21]!==d||e[22]!==p?(j=a.jsx(J,{variant:"ghost",size:"sm",disabled:p,onClick:d,children:"Reject"}),e[21]=d,e[22]=p,e[23]=j):j=e[23];let C;e[24]!==f||e[25]!==j||e[26]!==h||e[27]!==g||e[28]!==x?(C=a.jsxs(f,{className:h,children:[g,x,j]}),e[24]=f,e[25]=j,e[26]=h,e[27]=g,e[28]=x,e[29]=C):C=e[29];let _;e[30]!==c?(_=c&&a.jsx("div",{role:"alert",className:"col-span-full mt-2 text-xs text-destructive",children:c}),e[30]=c,e[31]=_):_=e[31];let S;e[32]!==r?(S=r&&a.jsxs(wn,{className:"col-span-full mt-2",children:[a.jsx(ds,{render:a.jsx(J,{type:"button",variant:"ghost",size:"xs"}),children:"Review full plan"}),a.jsx(Sn,{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[32]=r,e[33]=S):S=e[33];let N;e[34]!==t?(N=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(q7)]}),e[34]=t,e[35]=N):N=e[35];let T;return e[36]!==m||e[37]!==C||e[38]!==_||e[39]!==S||e[40]!==N||e[41]!==b||e[42]!==v||e[43]!==y||e[44]!==k?(T=a.jsxs(m,{className:b,children:[v,y,k,C,_,S,N]}),e[36]=m,e[37]=C,e[38]=_,e[39]=S,e[40]=N,e[41]=b,e[42]=v,e[43]=y,e[44]=k,e[45]=T):T=e[45],T}function q7(n,e){return a.jsx(Fe,{variant:"outline",children:n.prompt},e)}const V7=["allow","allow_always","deny"];function nc(n,e){return(n.availableDecisions??V7).includes(e)}function H7(n){switch(n){case"Bash":return{label:"Run command",icon:yi,tone:"cmd"};case"Edit":return{label:"Edit file",icon:Cp,tone:"write"};case"Write":return{label:"Write file",icon:Cp,tone:"write"};case"Read":return{label:"Read file",icon:Mi,tone:"read"};case"Glob":return{label:"File search",icon:Bn,tone:"search"};case"Grep":return{label:"Content search",icon:Bn,tone:"search"};case"WebFetch":return{label:"Fetch URL",icon:wi,tone:"net"};case"WebSearch":return{label:"Web search",icon:wi,tone:"net"};default:return{label:n,icon:Gu,tone:"other"}}}function K7(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 G7({requests:n,responding:e,onRespond:t,onRespondAll:s}){var y;const r=n[0],o=n.length,i=r?nc(r,"allow"):!1,l=r?nc(r,"allow_always"):!1,c=r?nc(r,"deny"):!1,u=o>1&&n.every(k=>!k.defaultToNo&&nc(k,"allow")),d=!(r!=null&&r.defaultToNo),f=w.useEffectEvent(k=>{if(!r)return;const j=k.target;if(j&&(j.tagName==="INPUT"||j.tagName==="TEXTAREA"||j.isContentEditable)||k.metaKey||k.ctrlKey||k.altKey)return;const C=k.key.toLowerCase();C==="a"&&k.shiftKey&&u?(k.preventDefault(),s("allow")):C==="a"&&i&&d?(k.preventDefault(),t(r.requestId,"allow")):C==="s"&&l&&d?(k.preventDefault(),t(r.requestId,"allow_always")):C==="d"&&c&&(k.preventDefault(),t(r.requestId,"deny"))});w.useEffect(()=>{const k=j=>f(j);return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[]);const m=r?H7(r.toolName):null,p=r?K7(r.toolName,r.input):null,h=(r==null?void 0:r.decisionReason)||(r==null?void 0:r.description)||(r==null?void 0:r.blockedPath),g=(((y=r==null?void 0:r.suggestions)==null?void 0:y.length)??0)>0;if(!r||!m)return null;const x=m.icon,b=e.has(r.requestId),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(NS,{className:"size-4"})}),a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(x,{className:"size-4 text-muted-foreground"}),a.jsx("span",{className:"text-sm font-medium text-foreground",children:m.label})]})]}),p&&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:p})}),h&&h!==p&&a.jsx("p",{className:"hidden max-w-64 truncate text-xs text-muted-foreground xl:block",title:h,children:h}),v&&a.jsxs(Fe,{variant:"outline",className:"shrink-0 tabular-nums",children:["+",o-1," more"]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[c&&a.jsxs(J,{autoFocus:r.defaultToNo,variant:"ghost",size:"sm",className:"text-destructive",disabled:b,onClick:()=>t(r.requestId,"deny"),title:"Deny (D)",children:[a.jsx(Wt,{"data-icon":"inline-start"}),"Deny",a.jsx("kbd",{className:"ml-0.5 font-mono text-xs text-muted-foreground",children:"D"})]},r.requestId),l&&a.jsxs(J,{variant:"outline",size:"sm",disabled:b,onClick:()=>t(r.requestId,"allow_always"),title:g?`Apply the suggested scoped permission rule${d?" (S)":""}`:`Allow ${r.toolName} for this session${d?" (S)":""}`,children:[a.jsx(ZE,{"data-icon":"inline-start"}),g?"Remember rule":"Session",d&&a.jsx("kbd",{className:"ml-0.5 font-mono text-xs text-muted-foreground",children:"S"})]}),u&&a.jsxs(J,{variant:"secondary",size:"sm",disabled:b,onClick:()=>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"})]}),i&&a.jsxs(J,{size:"sm",disabled:b,onClick:()=>t(r.requestId,"allow"),title:d?"Allow once (A)":"Allow once",children:[a.jsx(Bt,{"data-icon":"inline-start"}),"Allow",d&&a.jsx("kbd",{className:"ml-0.5 font-mono text-xs opacity-70",children:"A"})]}),!i&&!l&&!c&&a.jsx("span",{className:"text-xs text-muted-foreground",children:"Resolve this approval in Codex"})]})]})})}const Z7=1568,Y7=.85,Vb=35e5;function X7(n,e){let{width:t,height:s}=n;const r=Math.min(1,Z7/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?Y7:void 0),d=u.split(",")[1];if(d.length>Vb){let f=l?.7:.8;for(;d.length>Vb&&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 J7(n){const e=q.c(24),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 $=Array.from(R).filter(t$);if(!t){$.length>0&&u(!0);return}u(!1);for(const M of $){const z=new FileReader;z.onload=()=>{if(!d.current){u(!0);return}const F=z.result,D=new Image;D.onload=()=>{if(!d.current){u(!0);return}const L=X7(D,M.type);o(B=>[...B,{id:crypto.randomUUID(),file:M,preview:L.dataUrl,data:L.base64,mediaType:L.mediaType}])},D.src=F},z.onerror=()=>{console.warn(`Failed to read image file: ${M.name}`)},z.readAsDataURL(M)}},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($=>$.filter((M,z)=>z!==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 v=b;let y;e[8]===Symbol.for("react.memo_cache_sentinel")?(y=()=>u(!1),e[8]=y):y=e[8];const k=y;let j;e[9]!==t?(j=R=>{R.preventDefault(),t&&l(!0)},e[9]=t,e[10]=j):j=e[10];const C=j;let _;e[11]===Symbol.for("react.memo_cache_sentinel")?(_=R=>{R.preventDefault(),R.currentTarget.contains(R.relatedTarget)||l(!1)},e[11]=_):_=e[11];const S=_;let N;e[12]!==h?(N=R=>{R.preventDefault(),l(!1),R.dataTransfer.files.length>0&&h(R.dataTransfer.files)},e[12]=h,e[13]=N):N=e[13];const T=N;let E;e[14]!==h?(E=R=>{var F;const $=(F=R.clipboardData)==null?void 0:F.items;if(!$)return;const M=Array.from($).filter(e$);if(M.length===0)return;R.preventDefault();const z=M.map(Q7).filter(Boolean);h(z)},e[14]=h,e[15]=E):E=e[15];const A=E,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,I=!t&&r.length>0;let O;return e[16]!==C||e[17]!==T||e[18]!==A||e[19]!==r||e[20]!==i||e[21]!==P||e[22]!==I?(O={images:r,isDragOver:i,imageError:P,hasUnsupportedAttachments:I,dismissImageError:k,removeImage:x,clearImages:v,handleDragOver:C,handleDragLeave:S,handleDrop:T,handlePaste:A},e[16]=C,e[17]=T,e[18]=A,e[19]=r,e[20]=i,e[21]=P,e[22]=I,e[23]=O):O=e[23],O}function Q7(n){return n.getAsFile()}function e$(n){return n.type.startsWith("image/")}function t$(n){return n.type.startsWith("image/")}function n$(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(QE,{"data-slot":"tooltip-provider",delay:r,...t}),e[3]=r,e[4]=t,e[5]=o):o=e[5],o}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(n$,{children:a.jsx(JE,{"data-slot":"tooltip",...t})}),e[2]=t,e[3]=s):s=e[3],s}function Xt(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(YE,{"data-slot":"tooltip-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function Jt(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=K("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(XE,{"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(e6,{children:a.jsx(t6,{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 Gs="rounded-full border bg-background/80 shadow-sm backdrop-blur",ld=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=K("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}),ff=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(J,{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(Xt,{render:m,children:p}),t[9]=m,t[10]=p,t[11]=h):h=t[11];let g;t[12]!==r?(g=a.jsx(Jt,{children:r}),t[12]=r,t[13]=g):g=t[13];let x;return t[14]!==h||t[15]!==g?(x=a.jsxs(Yt,{children:[h,g]}),t[14]=h,t[15]=g,t[16]=x):x=t[16],x});function s$(n){return n<10?"critical":n<30?"warning":"healthy"}const r$={critical:"border-destructive/30 bg-destructive/10 text-destructive",warning:"border-warning/30 bg-warning/10 text-warning",healthy:"text-muted-foreground"},Mk=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,v,y,k,j,C;if(t[0]!==s||t[1]!==l||t[2]!==c||t[3]!==u){x=Symbol.for("react.early_return_sentinel");e:{const T=gk(s);if(!T){x=null;break e}const E=Math.max(0,100-T.percent),A=s$(E);if(u&&A==="healthy"){x=null;break e}const P=Math.max(0,T.compactAt-T.used);let I;t[17]!==E||t[18]!==P||t[19]!==l?(I=l?`${E.toFixed(0)}% · ${jt(P)}`:`${E.toFixed(0)}%`,t[17]=E,t[18]=P,t[19]=l,t[20]=I):I=t[20];const O=I,R=r$[A],$=l&&"gap-1";let M;t[21]!==R||t[22]!==$?(M=K("shrink-0 tabular-nums",R,$),t[21]=R,t[22]=$,t[23]=M):M=t[23];let z;t[24]!==O||t[25]!==M?(z=a.jsx(Fe,{variant:"outline",className:M,children:O}),t[24]=O,t[25]=M,t[26]=z):z=t[26];const F=z;if(!c){x=F;break e}f=Yt,t[27]!==F?(g=a.jsx(Xt,{render:F}),t[27]=F,t[28]=g):g=t[28],d=Jt,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=jt(P),t[30]=P,t[31]=D):D=t[31];let L;t[32]!==E?(L=E.toFixed(1),t[32]=E,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",v=jt(T.used),y=" / ",k=jt(T.limit),j=" tokens used (",C=T.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]=v,t[13]=y,t[14]=k,t[15]=j,t[16]=C}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],v=t[12],y=t[13],k=t[14],j=t[15],C=t[16];if(x!==Symbol.for("react.early_return_sentinel"))return x;let _;t[37]!==b||t[38]!==v||t[39]!==y||t[40]!==k||t[41]!==j||t[42]!==C?(_=a.jsxs("div",{className:b,children:[v,y,k,j,C,"%)"]}),t[37]=b,t[38]=v,t[39]=y,t[40]=k,t[41]=j,t[42]=C,t[43]=_):_=t[43];let S;t[44]!==d||t[45]!==m||t[46]!==p||t[47]!==h||t[48]!==_?(S=a.jsxs(d,{className:m,children:[p,h,_]}),t[44]=d,t[45]=m,t[46]=p,t[47]=h,t[48]=_,t[49]=S):S=t[49];let N;return t[50]!==f||t[51]!==g||t[52]!==S?(N=a.jsxs(f,{children:[g,S]}),t[50]=f,t[51]=g,t[52]=S,t[53]=N):N=t[53],N});function o$(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:tI(r)}),a.jsx(ld,{})]}),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 i$(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)??sn((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=hI(g),e[3]=g,e[4]=x):x=e[4];const b=x;let v;e[5]!==b||e[6]!==m||e[7]!==p?(v=p&&a.jsxs(Yt,{children:[a.jsx(Xt,{render:a.jsx(J,{variant:"outline",size:"icon-sm",className:"motion-enter shrink-0 rounded-full text-warning",onClick:m,"aria-label":b,title:b}),children:a.jsx(Xh,{"data-icon":"inline-start",className:"fill-current"})}),a.jsxs(Jt,{children:[b," (Esc)"]})]}),e[5]=b,e[6]=m,e[7]=p,e[8]=v):v=e[8];let y;e[9]!==g||e[10]!==u||e[11]!==p?(y=p&&pn(g).stopSession&&a.jsxs(Yt,{children:[a.jsx(Xt,{render:a.jsx(J,{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(n6,{"data-icon":"inline-start"})}),a.jsx(Jt,{children:"Stop session"})]}),e[9]=g,e[10]=u,e[11]=p,e[12]=y):y=e[12];const k=t?"default":"secondary",j=!t&&"text-muted-foreground";let C;e[13]!==j?(C=K("shrink-0 rounded-full",j),e[13]=j,e[14]=C):C=e[14];const _=!t;let S;e[15]===Symbol.for("react.memo_cache_sentinel")?(S=a.jsx(s6,{"data-icon":"inline-start"}),e[15]=S):S=e[15];let N;e[16]!==s||e[17]!==o||e[18]!==C||e[19]!==_||e[20]!==k?(N=a.jsx(J,{variant:k,size:"icon-sm",className:C,disabled:_,onClick:s,"aria-label":o,title:o,children:S}),e[16]=s,e[17]=o,e[18]=C,e[19]=_,e[20]=k,e[21]=N):N=e[21];let T;return e[22]!==N||e[23]!==v||e[24]!==y?(T=a.jsxs("div",{className:"flex items-center gap-1",children:[v,y,N]}),e[22]=N,e[23]=v,e[24]=y,e[25]=T):T=e[25],T}function Hb(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(zs,{"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(J,{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 v;e[16]===Symbol.for("react.memo_cache_sentinel")?(v=a.jsxs(ho,{children:[a.jsxs(ar,{className:"flex items-center gap-2 text-destructive",children:[a.jsx(zs,{className:"size-4"}),"Error details"]}),a.jsx(lr,{children:"The full output from the failed request, including the underlying process stderr."})]}),e[16]=v):v=e[16];let y;e[17]!==t?(y=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]=y):y=e[18];let k;e[19]!==o?(k=o?a.jsx(Bt,{"data-icon":"inline-start"}):a.jsx(fs,{"data-icon":"inline-start"}),e[19]=o,e[20]=k):k=e[20];const j=o?"Copied":"Copy";let C;e[21]!==m||e[22]!==k||e[23]!==j?(C=a.jsx("div",{className:"flex justify-end",children:a.jsxs(J,{type:"button",variant:"outline",size:"sm",onClick:m,children:[k,j]})}),e[21]=m,e[22]=k,e[23]=j,e[24]=C):C=e[24];let _;e[25]!==y||e[26]!==C?(_=a.jsxs(ir,{className:"max-w-2xl",children:[v,y,C]}),e[25]=y,e[26]=C,e[27]=_):_=e[27];let S;e[28]!==s||e[29]!==_?(S=a.jsx(or,{open:s,onOpenChange:r,children:_}),e[28]=s,e[29]=_,e[30]=S):S=e[30];let N;return e[31]!==S||e[32]!==b?(N=a.jsxs(a.Fragment,{children:[b,S]}),e[31]=S,e[32]=b,e[33]=N):N=e[33],N}function a$(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(Da,{"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(J,{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(Wt,{}),e[11]=f):f=e[11];let m;e[12]!==d?(m=a.jsx(J,{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 l$(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 c$(n,e,t){return`${n.slice(0,e.start)}@${t} `}const cd={terminal:!0,configWrite:!0,hostFiles:!0,manageUsers:!0,manageWorkspaces:!0,manageDevices:!0,killAny:!0,viewAllSessions:!0,viewUsage:!0,share:!0,runFlows:!0},xl={terminal:!1,configWrite:!1,hostFiles:!1,manageUsers:!1,manageWorkspaces:!1,manageDevices:!1,killAny:!1,viewAllSessions:!1,viewUsage:!1,share:!1,runFlows:!1};let Lk=cd;const Lp=new Set;function ci(n){Lk=(n==null?void 0:n.capabilities)??cd;for(const e of Lp)e()}function gt(n){return Lk[n]}function u$(n){return Lp.add(n),()=>Lp.delete(n)}function Wn(n){const e=q.c(3);let t,s;return e[0]!==n?(t=()=>gt(n),s=()=>gt(n),e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]),w.useSyncExternalStore(u$,t,s)}function d$(n){const e=n.files;return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function f$(n,e,t){const s=Wn("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(d$(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 zp="cogpit-share-revoked";function m$(){window.dispatchEvent(new Event(zp))}async function zk(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&&m$(),s}function bl(n,e){return zk(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e??{})})}async function p$(){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 h$(n,e){return bl("/api/share/send-message",e!=null&&e.length?{message:n,images:e}:{message:n})}function g$(){return bl("/api/share/interrupt")}function x$(){return bl("/api/share/stop")}async function b$(n,e){return(await bl("/api/share/permission",{requestId:n,behavior:e})).ok}async function v$(n,e){try{const t=await bl("/api/share/answer",{toolUseId:n,answers:e});return{ok:t.ok,gone:t.status===404}}catch{return{ok:!1,gone:!1}}}async function y$(){try{const n=await zk("/api/share/pending");if(!n.ok)return null;const e=await n.json();return Array.isArray(e.permissions)?e.permissions:[]}catch{return null}}const w$=/^\/shared\/([^/]+)\/?$/;function Dk(n){const e=w$.exec(n);if(!e)return null;try{return decodeURIComponent(e[1])||null}catch{return null}}function ud(n){return Dk(n)!==null}function S$(n){return`/shared/${encodeURIComponent(n)}`}function rfe(n){return[...n].join(", ")}async function kg(n,e){try{const t=await rr(n,e);return{ok:t.ok,gone:t.status===404}}catch{return{ok:!1,gone:!1}}}function jg(n,e,t){return ud(window.location.pathname)?v$(e,t):kg("/api/ask-user-answer",{sessionId:n,toolUseId:e,answers:t})}async function k$(n,e,t){try{return(await rr(`/api/permissions/${encodeURIComponent(n)}/plan`,{requestId:e,...t})).ok}catch{return!1}}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=K("flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent 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:bg-input/30 dark:disabled:bg-input/80 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 sc(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 j$(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 N$(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 C$(n,e,t){return n?"px-4 pb-1.5 pt-3.5":e?K("col-span-2 row-start-1",t?"py-2.5 pr-3 pl-2":"py-3 pr-4 pl-4"):K("col-start-2 row-start-1",t?"py-2 pr-1 pl-2":"py-2.5 pr-2 pl-4")}function _$(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 Dp=w.memo(w.forwardRef(function({allowImages:e=!0,agentKind:t,projectCwd:s,leadingAccessory:r,footer:o,compact:i=!1},l){var Ze;const c=Wn("hostFiles"),{session:u,isLive:d,actions:{handleEditConfig:f},pendingInteraction:m,permissionRequests:p,permissionResponding:h,respondPermission:g,respondAllPermissions:x,slashSuggestions:b,slashSuggestionsLoading:v,turnError:y,promptSuggestion:k}=xt(),{chat:{status:j,error:C,isConnected:_,sendMessage:S,interrupt:N}}=hl(),T=_||d,[E,A]=w.useState(""),[P,I]=w.useState(!1),[O,R]=w.useState(!1),[$,M]=w.useState(null),z=w.useRef(null),F=w.useRef(null),D=w.useRef(!1),L=w.useRef(""),B=w.useRef(null);w.useEffect(()=>{L.current=E},[E]);const U=w.useCallback(fe=>{D.current=fe,I(fe)},[]),{images:W,isDragOver:V,imageError:H,hasUnsupportedAttachments:G,dismissImageError:Z,removeImage:Y,clearImages:X,handleDragOver:ee,handleDragLeave:Q,handleDrop:ne,handlePaste:re}=J7(e),[se,oe]=w.useState(0),[ae,ie]=w.useState(0),[ce,te]=w.useState(!1),le=E.startsWith("/")&&!E.includes(" "),ge=le?E.slice(1):"",be=w.useMemo(()=>{if(!le)return[];const fe=ge.toLowerCase(),Te=b.filter($e=>fe?$e.name.toLowerCase().includes(fe)||$e.description.toLowerCase().includes(fe):!0),Ve=Te.filter($e=>$e.type==="command"),He=Te.filter($e=>$e.type==="skill");return[...Ve,...He]},[le,ge,b]),ue=w.useMemo(()=>l$(E),[E]),he=!!(c&&ue&&s&&!ce),me=f$(s,(ue==null?void 0:ue.query)??"",he);w.useEffect(()=>{oe(0)},[ge]),w.useEffect(()=>{ie(0)},[ue==null?void 0:ue.query]);const xe=jk(_),je=(m==null?void 0:m.type)==="plan"?m.requestId??null:null;w.useEffect(()=>{F.current=je,z.current=null,R(!1),M(null)},[je]);const Le=w.useCallback(async fe=>{const Te=m;if(!(u!=null&&u.sessionId)||(Te==null?void 0:Te.type)!=="question")return;const Ve=Te.questions[0];if(!Ve||!fe.trim())return;(await jg(u.sessionId,Te.toolUseId,{[Ve.question]:fe})).ok||S(fe)},[m,u==null?void 0:u.sessionId,S]),Se=w.useCallback(async(fe,Te,Ve)=>{const He=m;if((He==null?void 0:He.type)==="plan"&&He.provider==="copilot"&&He.requestId&&(u!=null&&u.sessionId)){const $e=He.requestId;if(z.current)return!1;z.current=$e,R(!0),M(null);try{const tt=await k$(u.sessionId,$e,{approved:fe,...Te?{selectedAction:Te}:{},...Ve?{feedback:Ve}:{}});return!tt&&F.current===$e&&M("Couldn't send the plan response. Try again."),tt}finally{z.current===$e&&(z.current=null,R(!1))}}return S(fe?"yes":Ve||"no"),!0},[m,u==null?void 0:u.sessionId,S]),Ie=w.useCallback(()=>{requestAnimationFrame(()=>{const fe=B.current;fe&&(fe.focus(),fe.selectionStart=fe.selectionEnd=fe.value.length,U(sc(fe,D.current)))})},[U]),we=w.useCallback(fe=>{A(`/${fe.name} `),oe(0),Ie()},[Ie]),Be=w.useCallback(fe=>{A(fe),Ie()},[Ie]),De=w.useCallback(fe=>{if(!ue)return;const Te=c$(E,ue,fe);A(Te),te(!0),ie(0),requestAnimationFrame(()=>{const Ve=B.current;Ve&&(Ve.focus(),Ve.selectionStart=Ve.selectionEnd=Ve.value.length,U(sc(Ve,D.current)))})},[ue,E,U]),Ue=w.useCallback(async()=>{const fe=E.trim();if(!fe&&W.length===0||!e&&W.length>0)return;if((m==null?void 0:m.type)==="question"){Le(fe),A(""),U(!1),B.current&&(B.current.style.height="auto");return}if((m==null?void 0:m.type)==="plan"&&m.provider==="copilot"){if(!fe||!await Se(!1,void 0,fe))return;A(""),U(!1),B.current&&(B.current.style.height="auto");return}const Te=e&&W.length>0?W.map(Ve=>({data:Ve.data,mediaType:Ve.mediaType})):void 0;S(fe,Te),A(""),X(),U(!1),B.current&&(B.current.style.height="auto")},[E,W,e,S,X,U,m,Le,Se]),We=w.useCallback(fe=>{if(he&&fe.key==="Escape"){fe.preventDefault(),te(!0);return}if(he&&me.files.length>0){if(fe.key==="ArrowDown"){fe.preventDefault(),ie(Te=>Te<me.files.length-1?Te+1:0);return}if(fe.key==="ArrowUp"){fe.preventDefault(),ie(Te=>Te>0?Te-1:me.files.length-1);return}if(fe.key==="Tab"||fe.key==="Enter"&&!fe.shiftKey){fe.preventDefault();const Te=me.files[ae];Te&&De(Te);return}}if(le&&be.length>0){if(fe.key==="ArrowDown"){fe.preventDefault(),oe(Te=>Te<be.length-1?Te+1:0);return}if(fe.key==="ArrowUp"){fe.preventDefault(),oe(Te=>Te>0?Te-1:be.length-1);return}if(fe.key==="Tab"||fe.key==="Enter"&&!fe.shiftKey){fe.preventDefault();const Te=be[se];Te&&we(Te);return}if(fe.key==="Escape"){fe.preventDefault(),A("");return}}if(fe.key==="Escape"&&T&&N){fe.preventDefault(),N();return}fe.key==="Enter"&&!fe.shiftKey&&(fe.preventDefault(),Ue())},[Ue,T,N,he,me.files,ae,De,le,be,se,we]),Oe=w.useCallback(fe=>{A(fe.target.value),te(!1),U(sc(fe.target,D.current))},[U]);w.useImperativeHandle(l,()=>({focus:()=>{var fe;return(fe=B.current)==null?void 0:fe.focus()},getText:()=>L.current,setText:fe=>{A(fe),te(!1),requestAnimationFrame(()=>U(sc(B.current,D.current)))}}),[U]);const pe=(m==null?void 0:m.type)==="plan",ke=(m==null?void 0:m.type)==="question",_e=p.length>0,ye=!!o,Pe=(E.trim().length>0||W.length>0)&&!G,Ye=pn(t??zo).midTurnSteering&&T,Xe=he?"file-suggestions":le?"slash-suggestions":void 0,Ee=he&&me.files[ae]?`file-suggestion-${ae}`:le&&be[se]?`slash-suggestion-${se}`:void 0;return a.jsxs("div",{className:K("relative pb-0",i?"px-2 pt-2":"px-3 pt-2",V&&"ring-2 ring-info/40 ring-inset"),onDragOver:ee,onDragLeave:Q,onDrop:ne,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"})}),le&&a.jsx(O7,{suggestions:be,filter:ge,loading:v,selectedIndex:se,onSelect:we,onHover:oe,onEdit:f}),he&&a.jsx(D7,{files:me.files,query:(ue==null?void 0:ue.query)??"",loading:me.loading,selectedIndex:ae,onSelect:De,onHover:ie}),a.jsxs("div",{children:[pe&&a.jsx(W7,{allowedPrompts:m.allowedPrompts,summary:m.summary,planContent:m.planContent,actions:m.actions,recommendedAction:m.recommendedAction,responding:O,responseError:$,onApprove:fe=>{Se(!0,fe)},onReject:()=>{Se(!1)}}),a.jsx(a$,{suggestion:k,onAccept:Be}),W.length>0&&a.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:W.map((fe,Te)=>a.jsxs("div",{className:"motion-list-item relative group/thumb",children:[a.jsx("img",{src:fe.preview,alt:`Upload ${Te+1}`,className:"h-16 w-auto rounded-md border bg-muted object-contain"}),a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>Y(Te),className:"absolute -right-1.5 -top-1.5 size-5 rounded-full border bg-background 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 ${Te+1}`,children:a.jsx(Wt,{className:"size-3","data-icon":"icon"})})]},fe.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}),!G&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:Z,className:"text-muted-foreground","aria-label":"Dismiss image notice",children:a.jsx(Wt,{"data-icon":"icon"})})]}),a.jsxs("div",{className:K("relative overflow-hidden border bg-composer-surface/85 shadow-lg shadow-black/5 backdrop-blur-xl transition-[border-color,box-shadow] duration-150",ye?"rounded-3xl":"rounded-xl",N$(pe,ke,_e),"focus-within:ring-3"),children:[_e&&a.jsx(G7,{requests:p,responding:h,onRespond:g,onRespondAll:x},(Ze=p[0])==null?void 0:Ze.requestId),a.jsxs("div",{className:K("min-w-0",ye?"flex flex-col":"grid items-end",!ye&&(P?"grid-cols-[1fr_auto]":"grid-cols-[auto_minmax(0,1fr)_auto]")),children:[r&&a.jsx("div",{className:K("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(dd,{ref:B,value:E,onChange:Oe,onKeyDown:We,onPaste:re,onFocus:()=>{setTimeout(()=>{var fe;return(fe=B.current)==null?void 0:fe.scrollIntoView({behavior:"smooth",block:"center"})},300)},placeholder:j$(pe,ke,_,_e,Ye,i),"aria-label":"Message",role:"combobox","aria-autocomplete":"list","aria-expanded":!!Xe,"aria-controls":Xe,"aria-activedescendant":Ee,rows:1,className:K("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 dark:bg-transparent",C$(ye,P,i))}),a.jsxs("div",{className:K("flex shrink-0 items-center justify-end",_$(ye,P)),children:[o,a.jsx(o$,{isPlanApproval:pe,isUserQuestion:ke,elapsedSec:xe}),a.jsx(i$,{hasContent:Pe,onSubmit:Ue,submitLabel:Ye?"Steer active turn":"Send message"})]})]})]}),j==="error"&&C&&a.jsx(Hb,{error:C},C),y&&a.jsx(Hb,{error:y},y)]})]})}));function T$(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function E$(n){return T$(n)?n:null}function A$(n){for(let e=n.length-1;e>=0;e-=1){const t=n[e];if(t.type!=="attachment")continue;const s=E$(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 rc(n){return`/api/codex/goals/${encodeURIComponent(n)}`}function Nn({className:n,...e}){return a.jsx(r6,{"data-slot":"input",className:K("h-8 w-full min-w-0 rounded-lg border border-input bg-transparent 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:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",n),...e})}function vl(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=K("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(P$,{children:a.jsx(I$,{})}),e[7]=l):l=e[7];let c;return e[8]!==t||e[9]!==r||e[10]!==i||e[11]!==o?(c=a.jsxs(o6,{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 P$(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=K("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(i6,{className:r,"data-slot":"progress-track",...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function I$(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=K("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(a6,{"data-slot":"progress-indicator",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Fk(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=K("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(l6,{className:r,"data-slot":"progress-label",...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Uk(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=K("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(c6,{className:r,"data-slot":"progress-value",...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}const $$={section:null,canCreate:!1,beginEditing:()=>{}},Ng=w.createContext($$);function Bk(){return w.useContext(Ng)}const Wk="mx-3 mb-1.5 rounded-lg border border-border bg-muted/30 px-2.5 py-1",qk="mx-3 mb-1.5 rounded-lg border border-border bg-muted/30 px-2.5 py-2";function R$(n){return n==="usageLimited"?"Usage limited":n==="budgetLimited"?"Budget limited":n.charAt(0).toUpperCase()+n.slice(1)}function O$(n){return n==="complete"?"secondary":n==="blocked"||n.endsWith("Limited")?"destructive":n==="paused"?"outline":"default"}function M$({agentKind:n,threadId:e,children:t}){const s=id(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),v=w.useCallback(async T=>{try{const E=await Re(rc(e),{signal:T});if(E.status===404||E.status===501){l(!1);return}if(!E.ok)return;const A=await E.json();o(A.goal),l(!0)}catch{}},[e]);w.useEffect(()=>{const T=new AbortController;v(T.signal);const E=i?setInterval(()=>void v(),1e4):void 0;return()=>{T.abort(),E!==void 0&&clearInterval(E)}},[v,i]);const y=w.useCallback(()=>{var T;f((r==null?void 0:r.objective)??""),p(((T=r==null?void 0:r.tokenBudget)==null?void 0:T.toString())??""),b(null),u(!0)},[r]),k=async()=>{const T=d.trim();if(!T)return;const E=m.trim()?Number(m):null;if(E!==null&&(!Number.isSafeInteger(E)||E<=0)){b("Token budget must be a positive whole number");return}g(!0),b(null);try{const A=await Re(rc(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({objective:T,status:(r==null?void 0:r.status)==="complete"?"active":(r==null?void 0:r.status)??"active",tokenBudget:E})}),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 T=>{if(r){g(!0);try{const E=await Re(rc(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:T})});E.ok&&o((await E.json()).goal)}finally{g(!1)}}},C=async()=>{g(!0);try{(await Re(rc(e),{method:"DELETE"})).ok&&(o(null),u(!1))}finally{g(!1)}},_=r!=null&&r.tokenBudget?Math.min(100,r.tokensUsed/r.tokenBudget*100):null;let S=null;if(i&&c)S=a.jsxs("form",{className:qk,onSubmit:T=>{T.preventDefault(),k()},children:[a.jsxs("div",{className:"mb-2 flex items-center gap-1.5 text-xs font-medium text-foreground",children:[a.jsx(Ua,{className:"size-3.5","data-icon":"inline-start"}),r?"Edit long-running goal":"Set a long-running goal"]}),a.jsxs(Ui,{className:"gap-2",children:[a.jsxs(Lt,{children:[a.jsx(zt,{className:"sr-only",htmlFor:"goal-objective",children:"Goal objective"}),a.jsx(dd,{id:"goal-objective",value:d,onChange:T=>f(T.target.value),placeholder:`What should ${s} keep working toward?`,rows:2,autoFocus:!0})]}),a.jsxs(Lt,{orientation:"horizontal","data-invalid":!!x,children:[a.jsx(zt,{className:"text-xs text-muted-foreground",htmlFor:"goal-budget",children:"Token budget"}),a.jsx(Nn,{id:"goal-budget",type:"number",min:1,step:1,value:m,onChange:T=>p(T.target.value),placeholder:"Optional",className:"ml-auto h-8 w-28","aria-invalid":!!x})]})]}),a.jsx(Yr,{className:"mt-1.5",children:x}),a.jsxs("div",{className:"mt-2 flex items-center justify-end gap-1",children:[a.jsxs(J,{type:"button",variant:"ghost",size:"xs",onClick:()=>u(!1),children:[a.jsx(Wt,{"data-icon":"inline-start"}),"Cancel"]}),a.jsxs(J,{type:"submit",size:"xs",disabled:h||!d.trim(),children:[a.jsx(Bt,{"data-icon":"inline-start"}),"Save goal"]})]})]});else if(i&&r){const T=r.status==="paused",E=r.status==="complete";S=a.jsxs("section",{className:Wk,"aria-label":`${s} goal`,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ua,{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(Fe,{variant:O$(r.status),children:R$(r.status)}),a.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[jt(r.tokensUsed),r.tokenBudget?` / ${jt(r.tokenBudget)}`:""," · ",Math.max(0,Math.round(r.timeUsedSeconds/60)),"m"]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[T&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void j("active"),disabled:h,"aria-label":"Resume goal",children:a.jsx(Li,{"data-icon":"icon"})}),!T&&!E&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void j("paused"),disabled:h,"aria-label":"Pause goal",children:a.jsx(u6,{"data-icon":"icon"})}),!E&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void j("complete"),disabled:h,"aria-label":"Mark goal complete",children:a.jsx(Bt,{"data-icon":"icon"})}),a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:y,"aria-label":"Edit goal",children:a.jsx(yr,{"data-icon":"icon"})}),a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void C(),disabled:h,className:"text-destructive","aria-label":"Clear goal",children:a.jsx(Zu,{"data-icon":"icon"})})]})]}),_!==null&&a.jsx(vl,{className:"mt-1 mb-0.5",value:_,"aria-label":`${_.toFixed(0)}% of goal token budget used`})]})}const N=w.useMemo(()=>({section:S,canCreate:i&&!r&&!c,beginEditing:y}),[S,i,r,c,y]);return a.jsx(Ng.Provider,{value:N,children:t})}function L$(n){switch(n){case"active":return"Goal active";case"achieved":return"Achieved";default:return"Needs attention"}}function z$(n){switch(n){case"failed":return"destructive";case"achieved":return"secondary";default:return"outline"}}function D$(n){const e=q.c(84),{agentKind:t,session:s,onSendCommand:r,children:o}=n;let i;e[0]!==t?(i=id(t),e[0]=t,e[1]=i):i=e[1];const l=i;let c;e[2]!==s.rawMessages?(c=A$(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),v=u?`${u.status}\0${u.condition}`:"",[y,k]=w.useState(v);y!==v&&(k(v),f(void 0));const j=d!==void 0?d:u;let C;e[4]!==(j==null?void 0:j.condition)?(C=()=>{g((j==null?void 0:j.condition)??""),b(null),p(!0)},e[4]=j==null?void 0:j.condition,e[5]=C):C=e[5];const _=C;let S;e[6]!==h||e[7]!==r?(S=()=>{const $=h.trim();if($){if($.length>4e3){b("Goal conditions can be at most 4,000 characters");return}f({condition:$,status:"active",iterations:0,durationMs:0,tokens:0}),p(!1),r(`/goal ${$}`)}},e[6]=h,e[7]=r,e[8]=S):S=e[8];const N=S;let T;e[9]!==r?(T=()=>{f(null),p(!1),r("/goal clear")},e[9]=r,e[10]=T):T=e[10];const E=T;let A;if(e[11]!==l||e[12]!==_||e[13]!==E||e[14]!==h||e[15]!==m||e[16]!==x||e[17]!==j||e[18]!==N){if(A=null,m){let $;e[20]===Symbol.for("react.memo_cache_sentinel")?($=a.jsx(Ua,{className:"size-3.5","data-icon":"inline-start"}),e[20]=$):$=e[20];const M=j?"Replace goal":"Set a long-running goal";let z;e[21]!==M?(z=a.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5 text-xs font-medium text-foreground",children:[$,M]}),e[21]=M,e[22]=z):z=e[22];const F=!!x;let D;e[23]===Symbol.for("react.memo_cache_sentinel")?(D=a.jsx(zt,{className:"sr-only",htmlFor:"goal-condition",children:"Goal condition"}),e[23]=D):D=e[23];let L;e[24]===Symbol.for("react.memo_cache_sentinel")?(L=Q=>g(Q.target.value),e[24]=L):L=e[24];const B=`A measurable condition ${l} should keep working toward…`,U=!!x;let W;e[25]!==h||e[26]!==B||e[27]!==U?(W=a.jsx(dd,{id:"goal-condition",value:h,onChange:L,placeholder:B,rows:2,maxLength:4e3,"aria-invalid":U,autoFocus:!0}),e[25]=h,e[26]=B,e[27]=U,e[28]=W):W=e[28];let V;e[29]!==x?(V=a.jsx(Yr,{children:x}),e[29]=x,e[30]=V):V=e[30];let H;e[31]!==W||e[32]!==V||e[33]!==F?(H=a.jsxs(Lt,{"data-invalid":F,children:[D,W,V]}),e[31]=W,e[32]=V,e[33]=F,e[34]=H):H=e[34];let G;e[35]===Symbol.for("react.memo_cache_sentinel")?(G=a.jsxs(J,{type:"button",variant:"ghost",size:"xs",onClick:()=>p(!1),children:[a.jsx(Wt,{"data-icon":"inline-start"}),"Cancel"]}),e[35]=G):G=e[35];let Z;e[36]!==h?(Z=h.trim(),e[36]=h,e[37]=Z):Z=e[37];const Y=!Z;let X;e[38]===Symbol.for("react.memo_cache_sentinel")?(X=a.jsx(Bt,{"data-icon":"inline-start"}),e[38]=X):X=e[38];let ee;e[39]!==N||e[40]!==Y?(ee=a.jsxs("div",{className:"mt-2 flex items-center justify-end gap-1",children:[G,a.jsxs(J,{type:"button",size:"xs",onClick:N,disabled:Y,children:[X,"Start goal"]})]}),e[39]=N,e[40]=Y,e[41]=ee):ee=e[41],A=a.jsxs("section",{className:qk,"aria-label":`${l} goal editor`,children:[z,H,ee]})}else if(j){let $;e[42]===Symbol.for("react.memo_cache_sentinel")?($=a.jsx(Ua,{className:"size-3.5 shrink-0 text-primary","data-icon":"inline-start"}),e[42]=$):$=e[42];let M;e[43]!==j.condition?(M=a.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground",title:j.condition,children:j.condition}),e[43]=j.condition,e[44]=M):M=e[44];let z;e[45]!==j.status?(z=z$(j.status),e[45]=j.status,e[46]=z):z=e[46];let F;e[47]!==j.status?(F=L$(j.status),e[47]=j.status,e[48]=F):F=e[48];let D;e[49]!==z||e[50]!==F?(D=a.jsx(Fe,{variant:z,children:F}),e[49]=z,e[50]=F,e[51]=D):D=e[51];const L=j.iterations,B=j.iterations===1?"":"s";let U;e[52]!==j.tokens?(U=jt(j.tokens),e[52]=j.tokens,e[53]=U):U=e[53];let W;e[54]!==j.durationMs?(W=Math.round(j.durationMs/6e4),e[54]=j.durationMs,e[55]=W):W=e[55];const V=Math.max(0,W);let H;e[56]!==j.iterations||e[57]!==B||e[58]!==U||e[59]!==V?(H=a.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[L," turn",B," · ",U," · ",V,"m"]}),e[56]=j.iterations,e[57]=B,e[58]=U,e[59]=V,e[60]=H):H=e[60];let G;e[61]===Symbol.for("react.memo_cache_sentinel")?(G=a.jsx(yr,{"data-icon":"icon"}),e[61]=G):G=e[61];let Z;e[62]!==_?(Z=a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:_,"aria-label":"Replace goal",children:G}),e[62]=_,e[63]=Z):Z=e[63];let Y;e[64]===Symbol.for("react.memo_cache_sentinel")?(Y=a.jsx(Zu,{"data-icon":"icon"}),e[64]=Y):Y=e[64];let X;e[65]!==E?(X=a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:E,"aria-label":"Clear goal",children:Y}),e[65]=E,e[66]=X):X=e[66];let ee;e[67]!==Z||e[68]!==X?(ee=a.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[Z,X]}),e[67]=Z,e[68]=X,e[69]=ee):ee=e[69];let Q;e[70]!==D||e[71]!==H||e[72]!==ee||e[73]!==M?(Q=a.jsxs("div",{className:"flex items-center gap-2",children:[$,M,D,H,ee]}),e[70]=D,e[71]=H,e[72]=ee,e[73]=M,e[74]=Q):Q=e[74];let ne;e[75]!==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[75]=j.reason,e[76]=ne):ne=e[76],A=a.jsxs("section",{className:Wk,"aria-label":`${l} goal`,children:[Q,ne]})}e[11]=l,e[12]=_,e[13]=E,e[14]=h,e[15]=m,e[16]=x,e[17]=j,e[18]=N,e[19]=A}else A=e[19];const P=!j&&!m;let I;e[77]!==_||e[78]!==A||e[79]!==P?(I={section:A,canCreate:P,beginEditing:_},e[77]=_,e[78]=A,e[79]=P,e[80]=I):I=e[80];const O=I;let R;return e[81]!==o||e[82]!==O?(R=a.jsx(Ng.Provider,{value:O,children:o}),e[81]=o,e[82]=O,e[83]=R):R=e[83],R}function F$(n){const e=q.c(9),{agentKind:t,session:s,onSendCommand:r,children:o}=n,i=pn(t).goals;if(i==="thread-api"){let l;return e[0]!==t||e[1]!==o||e[2]!==s.sessionId?(l=a.jsx(M$,{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(D$,{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 U$(){return Bk().section}function Kb(){const n=q.c(3),{canCreate:e,beginEditing:t}=Bk();if(!e)return null;let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(Ua,{"data-icon":"inline-start"}),n[0]=s):s=n[0];let r;return n[1]!==t?(r=a.jsxs(J,{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 B$=/\x1b\].*?(?:\x07|\x1b\\)/g,W$=/\x1b\[[0-9;]*[A-Za-z]/g,q$=/\x1b[()][AB012]/g,V$=/\[2K\[1G/g;function Vk(n){return n.replace(B$,"").replace(W$,"").replace(q$,"").replace(V$,`
|
|
5
|
+
`).replace(/\r/g,"")}function yl({className:n,children:e,...t}){return a.jsxs(d6,{"data-slot":"scroll-area",className:K("relative overflow-hidden",n),...t,children:[a.jsx(f6,{"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(H$,{}),a.jsx(m6,{})]})}function H$({className:n,orientation:e="vertical",...t}){return a.jsx(p6,{"data-slot":"scroll-area-scrollbar","data-orientation":e,orientation:e,className:K("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(h6,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"})})}function Hk({className:n,...e}){return a.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",className:K("size-5",n),...e,children:[a.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.2"}),a.jsx("path",{className:"status-icon-spin",d:"M12 2A10 10 0 0 1 22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function K$({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:K("size-5",n),...e,children:a.jsx("path",{className:"status-icon-complete",d:"M20 6L9 17L4 12"})})}function G$({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:K("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 Z$({className:n,...e}){return a.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",className:K("size-5",n),...e,children:[a.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.1"}),a.jsx("path",{className:"status-icon-spin",d:"M12 2A10 10 0 0 1 22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),a.jsx("path",{className:"status-icon-spin",d:"M12 22A10 10 0 0 1 2 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function Cn({className:n,...e}){const t=n==null?void 0:n.replace(/\banimate-spin\b/g,"").trim();return a.jsx(Hk,{className:K(t),...e})}function Y$(n){const e=Wn("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 Gb=500,X$=5e3;function J$(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(Gb),m=w.useRef(null),p=w.useRef(!1),h=w.useRef(Q$);let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=F=>{var B;const D=F.type,L=F.id;if(D==="sessions"){l(F.sessions??[]);return}L&&((B=d.current.get(L))==null||B(D,F))},e[2]=g):g=e[2];const x=g;let b,v;e[3]!==t?(b=()=>{if(p.current=!1,!t)return()=>{p.current=!0};const F=function(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}${YS()}/__pty`},D=function(){if(p.current||c.current&&c.current.readyState!==WebSocket.CLOSED)return;r("connecting");const B=new WebSocket(F());c.current=B,B.onopen=()=>{if(p.current){B.close();return}f.current=Gb,r("connected"),B.send(JSON.stringify({type:"list"}))},B.onmessage=U=>{try{const W=JSON.parse(U.data);x(W)}catch{}},B.onclose=()=>{if(p.current)return;r("disconnected"),c.current=null;const U=f.current;f.current=Math.min(U*2,X$),m.current=setTimeout(()=>h.current(),U)}};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)}},v=[t,x],e[3]=t,e[4]=b,e[5]=v):(b=e[4],v=e[5]),w.useEffect(b,v);let y;e[6]!==t?(y=F=>{if(!t)return;const D=c.current;D&&D.readyState===WebSocket.OPEN&&D.send(JSON.stringify(F))},e[6]=t,e[7]=y):y=e[7];const k=y;let j;e[8]===Symbol.for("react.memo_cache_sentinel")?(j=(F,D)=>{d.current.set(F,D)},e[8]=j):j=e[8];const C=j;let _;e[9]===Symbol.for("react.memo_cache_sentinel")?(_=F=>{d.current.delete(F)},e[9]=_):_=e[9];const S=_;let N;e[10]!==k?(N=F=>{const D=F===void 0?{}:F,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]=N):N=e[11];const T=N;let E;e[12]!==k?(E=F=>{const D=`script_${crypto.randomUUID().slice(0,8)}`;return k({type:"spawn",id:D,name:F.name,cwd:F.cwd,args:["run",F.scriptName],command:"bun",metadata:{type:"script",source:F.source,scriptName:F.scriptName}}),D},e[12]=k,e[13]=E):E=e[13];const A=E;let P;e[14]!==k?(P=F=>{k({type:"kill",id:F})},e[14]=k,e[15]=P):P=e[15];const I=P;let O;e[16]!==k?(O=(F,D)=>{k({type:"input",id:F,data:D})},e[16]=k,e[17]=O):O=e[17];const R=O;let $;e[18]!==k?($=(F,D,L)=>{k({type:"resize",id:F,cols:D,rows:L})},e[18]=k,e[19]=$):$=e[19];const M=$;let z;return e[20]!==I||e[21]!==M||e[22]!==k||e[23]!==i||e[24]!==A||e[25]!==T||e[26]!==s||e[27]!==R?(z={status:s,send:k,subscribe:C,unsubscribe:S,sessions:i,spawnTerminal:T,spawnScript:A,killSession:I,writeInput:R,resize:M},e[20]=I,e[21]=M,e[22]=k,e[23]=i,e[24]=A,e[25]=T,e[26]=s,e[27]=R,e[28]=z):z=e[28],z}function Q$(){}const Kk=w.createContext(null);function mf(n){const e=q.c(3),{children:t,enabled:s}=n,o=J$(s===void 0?!0:s);let i;return e[0]!==t||e[1]!==o?(i=a.jsx(Kk.Provider,{value:o,children:t}),e[0]=t,e[1]=o,e[2]=i):i=e[2],i}function Cg(){const n=w.useContext(Kk);if(!n)throw new Error("usePty must be used within a PtyProvider");return n}function eR(n){var d;const e=q.c(11),t=Cg();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 tR(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=K("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(Xh,{"data-icon":"inline-end",className:"fill-current text-destructive"}):a.jsx(Li,{"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(J,{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 nR=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}=Y$(s),{runningProcesses:h,runScript:g,stopScript:x}=eR(r);let b;if(t[1]!==m||t[2]!==l){const D=l.trim().toLowerCase(),L=D?m.filter(B=>B.name.toLowerCase().includes(D)||B.dirLabel.toLowerCase().includes(D)):m;b=new Map;for(const B of L){const U=b.get(B.dirLabel)??[];U.push(B),b.set(B.dirLabel,U)}t[1]=m,t[2]=l,t[3]=b}else b=t[3];const v=b;let y;if(t[4]!==h){y=new Map;for(const[D,L]of h)y.set(`${L.name}:${L.cwd}`,{id:D,status:L.status});t[4]=h,t[5]=y}else y=t[5];const k=y;if(!s||!p&&m.length===0)return null;let j;t[6]===Symbol.for("react.memo_cache_sentinel")?(j=function(L){f(B=>{const U=new Set(B);return U.has(L)?U.delete(L):U.add(L),U})},t[6]=j):j=t[6];const C=j;let _;t[7]===Symbol.for("react.memo_cache_sentinel")?(_=a.jsx("span",{className:"flex-1 text-xs font-medium text-muted-foreground",children:"Scripts"}),t[7]=_):_=t[7];let S;t[8]!==p?(S=p&&a.jsx(Cn,{className:"size-3 text-muted-foreground","aria-label":"Loading scripts"}),t[8]=p,t[9]=S):S=t[9];const N=o?"Close script search":"Search scripts";let T,E;t[10]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{i(sR),c("")},E=a.jsx(Bn,{}),t[10]=T,t[11]=E):(T=t[10],E=t[11]);let A;t[12]!==o||t[13]!==N?(A=a.jsx(J,{type:"button",variant:"ghost",size:"icon-sm","aria-label":N,"aria-expanded":o,onClick:T,children:E}),t[12]=o,t[13]=N,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:[_,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(Nn,{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 O;t[21]!==d||t[22]!==v||t[23]!==g||t[24]!==k||t[25]!==l||t[26]!==x?(O=[...v.entries()].map(D=>{const[L,B]=D,U=d.has(L)||!!l,W=B.filter(rR),V=B.filter(oR),H=U?B:W.length>0?W:B.slice(0,1);return a.jsxs("div",{className:"flex flex-col gap-0.5 pb-1",children:[v.size>1&&a.jsx("div",{className:"truncate px-2 pt-1 text-xs text-muted-foreground",children:L}),H.map(G=>{const Z=k.get(`${G.name}:${G.dir}`);return a.jsx(tR,{script:G,status:(Z==null?void 0:Z.status)??null,onRun:()=>g(G.name,G.dir,G.dirLabel),onStop:()=>{Z&&x(Z.id)}},`${L}:${G.name}`)}),!l&&V.length>0&&a.jsx(J,{type:"button",variant:"link",size:"sm",className:"h-auto justify-start px-2 py-1",onClick:()=>C(L),children:U?"Show less":`Show ${V.length} more`})]},L)}),t[21]=d,t[22]=v,t[23]=g,t[24]=k,t[25]=l,t[26]=x,t[27]=O):O=t[27];let R;t[28]!==v.size||t[29]!==p||t[30]!==l?(R=!p&&v.size===0&&l&&a.jsx(is,{className:"gap-1 p-3",children:a.jsxs(as,{className:"gap-1",children:[a.jsx(ls,{children:"No matching scripts"}),a.jsx(cs,{children:"Try another name."})]})}),t[28]=v.size,t[29]=p,t[30]=l,t[31]=R):R=t[31];let $;t[32]!==O||t[33]!==R?($=a.jsxs(yl,{className:"min-h-0 flex-1 px-1 pb-1",children:[O,R]}),t[32]=O,t[33]=R,t[34]=$):$=t[34];let M;t[35]!==I||t[36]!==$||t[37]!==P?(M=a.jsxs("section",{className:"flex w-56 shrink-0 flex-col","aria-label":"Scripts",children:[P,I,$]}),t[35]=I,t[36]=$,t[37]=P,t[38]=M):M=t[38];let z;t[39]===Symbol.for("react.memo_cache_sentinel")?(z=a.jsx(Zt,{orientation:"vertical"}),t[39]=z):z=t[39];let F;return t[40]!==M?(F=a.jsxs(a.Fragment,{children:[M,z]}),t[40]=M,t[41]=F):F=t[41],F});function sR(n){return!n}function rR(n){return n.isCommon}function oR(n){return!n.isCommon}function Gk({className:n,orientation:e="horizontal",...t}){return a.jsx(v6,{"data-slot":"tabs","data-orientation":e,className:K("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 iR=_r("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 Zk({className:n,children:e,variant:t="default",...s}){return a.jsxs(x6,{"data-slot":"tabs-list","data-variant":t,className:K(iR({variant:t}),"relative isolate",n),...s,children:[e,a.jsx(b6,{"data-slot":"tabs-indicator","data-variant":t,className:K("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 da({className:n,...e}){return a.jsx(y6,{"data-slot":"tabs-trigger",className:K("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 fa({className:n,...e}){return a.jsx(g6,{"data-slot":"tabs-content",className:K("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 aR=w.lazy(()=>Qe(()=>import("./TerminalOutput-CUmbXM9h.js"),__vite__mapDeps([0,1,2,3,4,5])).then(n=>({default:n.TerminalOutput})));function lR({process:n}){const[e,t]=w.useState(""),[s,r]=w.useState(!1),o=w.useRef(null);return w.useEffect(()=>{let i;if(n.type==="task"&&n.outputPath)i=ml(`/api/task-output?path=${encodeURIComponent(n.outputPath)}`);else return;t(""),r(!1);const l=new EventSource(i);return l.onopen=()=>r(!0),l.onmessage=c=>{try{const u=JSON.parse(c.data);if(u.type==="output"&&u.text){const d=Vk(u.text);d&&t(f=>{const m=f+d;return m.length>1e5?m.slice(-1e5):m})}}catch{}},l.onerror=()=>{},()=>l.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 cR(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=K("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=K("px-1 py-0 font-normal",x),e[11]=x,e[12]=b):b=e[12];let v;e[13]!==t.type||e[14]!==b?(v=a.jsx(Fe,{variant:"secondary",className:b,children:t.type}),e[13]=t.type,e[14]=b,e[15]=v):v=e[15];let y;e[16]!==t.id||e[17]!==t.name||e[18]!==v||e[19]!==d||e[20]!==m||e[21]!==p||e[22]!==h||e[23]!==g?(y=a.jsxs(da,{value:c,"aria-label":u,onClick:d,className:m,children:[p,h,g,v]}),e[16]=t.id,e[17]=t.name,e[18]=v,e[19]=d,e[20]=m,e[21]=p,e[22]=h,e[23]=g,e[24]=y):y=e[24];const k=`Close ${t.name}`,j=`Close ${t.name}`;let C;e[25]===Symbol.for("react.memo_cache_sentinel")?(C=a.jsx(Wt,{"data-icon":"inline-start"}),e[25]=C):C=e[25];let _;e[26]!==o||e[27]!==k||e[28]!==j?(_=a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs","aria-label":k,title:j,onClick:o,className:"mr-0.5 text-muted-foreground",children:C}),e[26]=o,e[27]=k,e[28]=j,e[29]=_):_=e[29];let S;return e[30]!==l||e[31]!==y||e[32]!==_?(S=a.jsxs("div",{title:l,className:"inline-flex h-6 shrink-0 items-center",children:[y,_]}),e[30]=l,e[31]=y,e[32]=_,e[33]=S):S=e[33],S}const Yk=100,Xk=600,uR=200,Jk="process-panel-height";function dR(){try{const n=localStorage.getItem(Jk);if(n)return Math.min(Xk,Math.max(Yk,Number(n)))}catch{}return uR}const fR=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=Cg(),[b,v]=w.useState(dR),y=w.useRef(null);let k,j;t[0]!==f||t[1]!==x.sessions?(k=()=>{for(const ue of x.sessions)ue.status==="exited"&&(f==null||f(ue.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 C;t[4]!==l||t[5]!==x?(C=ue=>{ue.type!=="task"&&x.killSession(ue.id),l(ue.id)},t[4]=l,t[5]=x,t[6]=C):C=t[6];const _=C;let S;t[7]!==b?(S=ue=>{ue.preventDefault(),y.current={startY:ue.clientY,startH:b},ue.target.setPointerCapture(ue.pointerId)},t[7]=b,t[8]=S):S=t[8];const N=S;let T;t[9]===Symbol.for("react.memo_cache_sentinel")?(T=ue=>{if(!y.current)return;const he=y.current.startY-ue.clientY,me=Math.min(Xk,Math.max(Yk,y.current.startH+he));v(me)},t[9]=T):T=t[9];const E=T;let A;t[10]!==b?(A=()=>{if(y.current){y.current=null;try{localStorage.setItem(Jk,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 O=I;let R;t[15]!==s?(R=[...s.values()],t[15]=s,t[16]=R):R=t[16];const $=R;let M;t[17]!==i?(M=ue=>{typeof ue=="string"&&i(ue)},t[17]=i,t[18]=M):M=t[18];let z;t[19]!==O||t[20]!==o||t[21]!==g||t[22]!==N||t[23]!==P?(z=!g&&!o&&O&&a.jsx("div",{className:"h-1 cursor-row-resize transition-colors hover:bg-accent active:bg-muted-foreground/30",onPointerDown:N,onPointerMove:E,onPointerUp:P,onPointerCancel:P}),t[19]=O,t[20]=o,t[21]=g,t[22]=N,t[23]=P,t[24]=z):z=t[24];const F=g?"h-7 gap-1 px-2":"h-8 gap-2 px-3";let D;t[25]!==F?(D=K("flex shrink-0 items-center border-b bg-card",F),t[25]=F,t[26]=D):D=t[26];const L=o?"Expand terminal panel":"Collapse terminal panel",B=!o;let U;t[27]!==o?(U=o?a.jsx(at,{"data-icon":"inline-start"}):a.jsx(It,{"data-icon":"inline-start"}),t[27]=o,t[28]=U):U=t[28];const W=g&&"sr-only";let V;t[29]!==W?(V=K(W),t[29]=W,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 G;t[33]!==c||t[34]!==L||t[35]!==B||t[36]!==U||t[37]!==H?(G=a.jsxs(J,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2",onClick:c,"aria-label":L,"aria-expanded":B,children:[U,H]}),t[33]=c,t[34]=L,t[35]=B,t[36]=U,t[37]=H,t[38]=G):G=t[38];const Z=!g&&"ml-2";let Y;t[39]!==Z?(Y=K("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]!==_||t[43]!==g||t[44]!==i||t[45]!==$?(X=$.map(ue=>a.jsx(cR,{process:ue,isActive:ue.id===r,onSelectActive:()=>i(ue.id),onClose:()=>_(ue),mobile:g},ue.id)),t[41]=r,t[42]=_,t[43]=g,t[44]=i,t[45]=$,t[46]=X):X=t[46];let ee;t[47]!==Y||t[48]!==X?(ee=a.jsx(Zk,{variant:"default","aria-label":"Open processes",className:Y,children:X}),t[47]=Y,t[48]=X,t[49]=ee):ee=t[49];let Q;t[50]!==u||t[51]!==m?(Q=u&&a.jsx(J,{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(Qs,{})}),t[50]=u,t[51]=m,t[52]=Q):Q=t[52];let ne;t[53]!==D||t[54]!==G||t[55]!==ee||t[56]!==Q?(ne=a.jsxs("div",{className:D,children:[G,ee,Q]}),t[53]=D,t[54]=G,t[55]=ee,t[56]=Q,t[57]=ne):ne=t[57];const re=!o,se=g?"min(36dvh, 260px)":b;let oe;t[58]!==se?(oe={height:se},t[58]=se,t[59]=oe):oe=t[59];let ae;t[60]!==g||t[61]!==p||t[62]!==m?(ae=!g&&a.jsx(nR,{projectDir:m,onProcessStarted:p}),t[60]=g,t[61]=p,t[62]=m,t[63]=ae):ae=t[63];let ie;t[64]!==_||t[65]!==d||t[66]!==u||t[67]!==$?(ie=$.map(ue=>a.jsx(fa,{value:ue.id,className:"col-start-1 row-start-1 flex min-h-0 flex-col",children:ue.type==="task"?a.jsx(lR,{process:ue}):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(aR,{processId:ue.id,autoFocus:!0,onRequestNew:u,onRequestClose:()=>_(ue),onAddContext:d})})},ue.id)),t[64]=_,t[65]=d,t[66]=u,t[67]=$,t[68]=ie):ie=t[68];let ce;t[69]!==O||t[70]!==u||t[71]!==m?(ce=!O&&a.jsxs(is,{className:"col-start-1 row-start-1 rounded-none",children:[a.jsxs(as,{children:[a.jsx(Is,{variant:"icon",children:a.jsx(zi,{})}),a.jsx(ls,{children:"No terminal open"}),a.jsx(cs,{children:"Start a terminal here or run a project script from the left."})]}),u&&m&&a.jsx(GS,{children:a.jsxs(J,{type:"button",size:"sm",onClick:u,children:[a.jsx(Qs,{"data-icon":"inline-start"}),"New terminal"]})})]}),t[69]=O,t[70]=u,t[71]=m,t[72]=ce):ce=t[72];let te;t[73]!==ie||t[74]!==ce?(te=a.jsxs("div",{className:"grid min-h-0 min-w-0 flex-1 grid-cols-1",children:[ie,ce]}),t[73]=ie,t[74]=ce,t[75]=te):te=t[75];let le;t[76]!==oe||t[77]!==ae||t[78]!==te?(le=a.jsx(Sn,{children:a.jsxs("div",{className:"flex min-h-0",style:oe,children:[ae,te]})}),t[76]=oe,t[77]=ae,t[78]=te,t[79]=le):le=t[79];let ge;t[80]!==re||t[81]!==le?(ge=a.jsx(wn,{open:re,className:"min-h-0",children:le}),t[80]=re,t[81]=le,t[82]=ge):ge=t[82];let be;return t[83]!==r||t[84]!==M||t[85]!==z||t[86]!==ne||t[87]!==ge?(be=a.jsxs(Gk,{value:r,onValueChange:M,className:"shrink-0 gap-0 border-t bg-background",children:[z,ne,ge]}),t[83]=r,t[84]=M,t[85]=z,t[86]=ne,t[87]=ge,t[88]=be):be=t[88],be});function wl(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 mR=/(?::(\d{4,5}))|(?:port\s+(\d{4,5}))|(?:localhost:(\d{4,5}))/gi;function pR(n){const e=new Set;for(const t of n.matchAll(mR)){const s=parseInt(t[1]||t[2]||t[3],10);s>0&&s<65536&&e.add(s)}return[...e]}function hR(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=pR(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 Zb(n){var e;return((e=n.preview.split(`
|
|
6
|
+
`).find(t=>t.trim()))==null?void 0:e.trim())||`Task ${n.id}`}function gR(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=K("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(Fe,{variant:"secondary",className:"font-mono",children:[i,c]}),e[7]=i,e[8]=c,e[9]=u):u=e[9],u}function Qk({cwd:n,turns:e,onToggleServer:t,onServersChanged:s}){const[r,o]=w.useState([]),i=hR(e);w.useEffect(()=>{if(!n)return;let c=!1;async function u(){try{const f=await Re(`/api/background-tasks?cwd=${encodeURIComponent(n)}`);if(c)return;if(f.ok){const h=await f.json();if(c)return;if(h.length>0){o(h);return}}if(i.size===0){o([]);return}const m=[...i.keys()],p=await Re(`/api/check-ports?ports=${m.join(",")}`);if(c)return;if(p.ok){const h=await p.json();if(c)return;const g=[],x=new Set;for(const[b,v]of i)!h[b]||x.has(b)||(x.add(b),g.push({id:`port-${b}`,outputPath:v.outputPath,ports:[b],portStatus:{[b]:!0},preview:v.description}));o(g)}}catch{}}u();const d=setInterval(u,1e4);return()=>{c=!0,clearInterval(d)}},[n,i]);const l=w.useCallback(async c=>{try{await Re("/api/kill-port",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({port:c})}),setTimeout(()=>{o(u=>u.filter(d=>!d.ports.includes(c)))},1500)}catch{}},[]);return w.useEffect(()=>{if(!s)return;const c=r.filter(u=>u.outputPath).map(u=>({id:u.id,outputPath:u.outputPath,title:Zb(u)}));s(c)},[r,s]),r.length===0?null:a.jsxs("section",{children:[a.jsxs(wl,{children:["Active Servers (",r.length,")"]}),a.jsx("div",{className:"flex flex-col gap-1.5",children:r.map(c=>{const u=c.ports.filter(f=>c.portStatus[f]),d=Zb(c);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(MS,{className:"size-3 shrink-0 text-success","data-icon":"inline-start"}),a.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:d})]}),a.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5",children:[c.ports.map(f=>a.jsx(gR,{port:f,isActive:c.portStatus[f]},f)),a.jsx("div",{className:"flex-1"}),c.outputPath&&a.jsx(J,{variant:"ghost",size:"icon-xs",onClick:()=>t==null?void 0:t(c.id,c.outputPath,d),title:"View server output","aria-label":"View server output",children:a.jsx(zi,{"data-icon":"inline-start"})}),u.length>0&&a.jsxs(J,{variant:"ghost",size:"xs",className:"text-destructive",onClick:()=>u.forEach(f=>l(f)),title:"Stop server","aria-label":"Stop server",children:[a.jsx(Xh,{"data-icon":"inline-start",className:"fill-current"}),a.jsx("span",{children:"Stop"})]})]})]},c.id)})})]})}function _g(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(w6,{"data-slot":"alert-dialog",...t}),e[2]=t,e[3]=s):s=e[3],s}function xR(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(S6,{"data-slot":"alert-dialog-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function bR(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(Gh,{"data-slot":"alert-dialog-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}function vR(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=K("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(Zh,{"data-slot":"alert-dialog-overlay",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Tg(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(vR,{}),e[4]=i):i=e[4];let l;e[5]!==t?(l=K("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(bR,{children:[i,a.jsx(Kh,{"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 Eg(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=K("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 Ag(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=K("-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 yR(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=K("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 Pg(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=K("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(Vh,{"data-slot":"alert-dialog-title",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Ig(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=K("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(Hh,{"data-slot":"alert-dialog-description",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function $g(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=K(t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(J,{"data-slot":"alert-dialog-action",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Rg(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=K(t),e[5]=t,e[6]=c):c=e[6];let u;e[7]!==l||e[8]!==i?(u=a.jsx(J,{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(ul,{"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 e3(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=K("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 dark:bg-input/30 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 dark:data-checked:bg-primary",t),e[3]=t,e[4]=r):r=e[4];let o;e[5]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx(j6,{"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(Bt,{})}),e[5]=o):o=e[5];let i;return e[6]!==s||e[7]!==r?(i=a.jsx(k6,{"data-slot":"checkbox",className:r,...s,children:o}),e[6]=s,e[7]=r,e[8]=i):i=e[8],i}const wR={undo:"Undo turns?",redo:"Redo turns?","branch-switch":"Switch branch?"},SR={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 kR({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(_g,{open:n!==null,onOpenChange:p=>{p||r()},onOpenChangeComplete:p=>{p||(o.current=null,l({key:"",selected:!1}))},children:a.jsxs(Tg,{children:[a.jsxs(Eg,{children:[a.jsx(yR,{children:a.jsx(Us,{className:"text-warning"})}),a.jsx(Pg,{children:wR[c.type]}),a.jsx(Ig,{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.":SR[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(e3,{checked:d,disabled:e,onCheckedChange:p=>l({key:u,selected:p===!0})}),"Restore captured file changes"]})]}),t&&a.jsx(Ft,{variant:"destructive",children:a.jsx(Ut,{children:t})}),a.jsxs(Ag,{children:[a.jsx(Rg,{onClick:r,disabled:e,children:"Cancel"}),a.jsx($g,{onClick:()=>s(d),disabled:e,children:e?a.jsxs(a.Fragment,{children:[a.jsx(ht,{"data-icon":"inline-start",className:"animate-spin"}),"Applying..."]}):c.type==="undo"?"Undo":c.type==="redo"?"Redo":"Switch"})]})]})})}function ns(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=K("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 ws(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=K("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 Ss(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=K("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 ks(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=K("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 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=K("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 ss(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=K("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 Sl(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=K("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 Ar(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=K("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 dark:bg-input/30 dark:has-disabled:bg-input/80 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 NR=_r("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 Ds(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=K(NR({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:CR,...s}),e[7]=o,e[8]=s,e[9]=i,e[10]=l):l=e[10],l}function CR(n){var e,t;n.target.closest("button")||(t=(e=n.currentTarget.parentElement)==null?void 0:e.querySelector("input"))==null||t.focus()}const _R=_r("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 kl(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=K(_R({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(J,{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 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=K("flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(Nn,{"data-slot":"input-group-control",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function TR(){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 ri=hP(n=>!n.cli.homeIsDiscoverable,"a home Cogpit has to be told about"),t3=ed().filter(n=>n.cli.homeIsDiscoverable);function n3(n){return n.flatMap((e,t)=>t===0?[e]:[t===n.length-1?" and ":", ",e])}function s3(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 ER=n3(t3.map(n=>n.displayName)),AR=n3(t3.map(n=>a.jsx(s3,{children:["~",n.cli.homeDirName,n.cli.installMarker].filter(Boolean).join("/")},n.kind))),PR=`~/${ri.cli.homeDirName}`;function IR(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}=TR();let f;e[0]!==u?(f=z=>{const F=z.target.value;r(F),u(F)},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(Yh,{className:"size-4"})}),b=a.jsx(Ss,{children:"Connect your coding agent"}),e[10]=x,e[11]=b):(x=e[10],b=e[11]);let v;e[12]===Symbol.for("react.memo_cache_sentinel")?(v=a.jsxs(ws,{children:[x,b,a.jsxs(ks,{children:["Cogpit detects ",ER," automatically. Existing histories live in"," ",AR,"."," ","For ",ri.displayName,", enter its data directory, usually"," ",a.jsx(s3,{children:PR}),"."]})]}),e[12]=v):v=e[12];const y=l==="invalid";let k;e[13]===Symbol.for("react.memo_cache_sentinel")?(k=a.jsxs(zt,{htmlFor:"agent-data-directory",children:[ri.displayName," data directory"]}),e[13]=k):k=e[13];let j;e[14]===Symbol.for("react.memo_cache_sentinel")?(j=a.jsx(Ds,{children:a.jsx(Si,{"aria-hidden":"true"})}),e[14]=j):j=e[14];const C=l==="invalid";let _;e[15]!==m||e[16]!==s||e[17]!==C?(_=a.jsxs(Ar,{children:[j,a.jsx(Pr,{id:"agent-data-directory",value:s,onChange:m,placeholder:`/Users/you/${ri.cli.homeDirName}`,autoFocus:!0,"aria-invalid":C,"aria-describedby":"agent-directory-status"})]}),e[15]=m,e[16]=s,e[17]=C,e[18]=_):_=e[18];let S;e[19]!==l?(S=l==="validating"&&a.jsxs(Ni,{className:"flex items-center gap-2",children:[a.jsx(Cn,{className:"size-4"}),"Checking path..."]}),e[19]=l,e[20]=S):S=e[20];let N;e[21]!==l?(N=l==="valid"&&a.jsxs(Ni,{className:"flex items-center gap-2 text-success",children:[a.jsx(Ku,{className:"size-4"}),ri.displayName," history found"]}),e[21]=l,e[22]=N):N=e[22];let T;e[23]!==c||e[24]!==l?(T=l==="invalid"&&c&&a.jsxs(Yr,{className:"flex items-center gap-2",children:[a.jsx(po,{className:"size-4"}),c]}),e[23]=c,e[24]=l,e[25]=T):T=e[25];let E;e[26]!==S||e[27]!==N||e[28]!==T?(E=a.jsxs("div",{id:"agent-directory-status",className:"min-h-5",role:"status","aria-live":"polite",children:[S,N,T]}),e[26]=S,e[27]=N,e[28]=T,e[29]=E):E=e[29];let A;e[30]!==_||e[31]!==E||e[32]!==y?(A=a.jsx(ss,{children:a.jsx(Ui,{children:a.jsxs(Lt,{"data-invalid":y,children:[k,_,E]})})}),e[30]=_,e[31]=E,e[32]=y,e[33]=A):A=e[33];const P=l!=="valid"||o;let I;e[34]!==o?(I=o&&a.jsx(Cn,{"data-icon":"inline-start"}),e[34]=o,e[35]=I):I=e[35];const O=o?"Saving...":`Connect ${ri.displayName}`;let R;e[36]!==P||e[37]!==I||e[38]!==O?(R=a.jsx(Sl,{children:a.jsxs(J,{type:"submit",className:"w-full",disabled:P,children:[I,O]})}),e[36]=P,e[37]=I,e[38]=O,e[39]=R):R=e[39];let $;e[40]!==A||e[41]!==R?($=a.jsxs(ns,{children:[v,A,R]}),e[40]=A,e[41]=R,e[42]=$):$=e[42];let M;return e[43]!==$||e[44]!==g?(M=a.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-4 py-8 text-foreground",children:a.jsx("form",{className:"w-full max-w-lg",onSubmit:g,children:$})}),e[43]=$,e[44]=g,e[45]=M):M=e[45],M}const r3=/^[a-z]:[\\/]/i;function Og(n){return(r3.test(n)?n.replace(/\\/g,"/"):n).replace(/\/+$/,"")||"/"}function Yb(n){const e=Og(n);return r3.test(n)?e.toLowerCase():e}function $R(n){const e=Og(n),t=e.lastIndexOf("/");return t<0?e:t===0?"/":e.slice(0,t)}function Xb(n,e){const t=Yb(n),s=Yb(e);if(t===s)return"";const r=t==="/"?"/":`${t}/`;return s.startsWith(r)?Og(e).slice(r.length):null}let Mg=!1;function RR(n){Mg=n}function Lg(){return Mg}let Ta=null;function OR(n){return Ta=n,()=>{Ta===n&&(Ta=null)}}function MR(n,e){if(!n.path)return null;if(n.kind==="project")return{root:n.path,file:null,mode:"edit"};if(e){const r=Xb(e,n.path);if(r)return{root:e,file:r,mode:Jb(n),line:n.line}}const t=$R(n.path),s=Xb(t,n.path);return s?{root:t,file:s,mode:Jb(n),line:n.line}:null}function Jb(n){return n.mode==="diff"?"diff":"edit"}function o3(n){return Mg&&Ta!==null&&Ta(n)}function i3(n,e){rr(n,e).catch(()=>{})}function Ka(n,e={}){if(gt("hostFiles")&&!o3({kind:"file",path:n,...e})){if(Lo()){td(n);return}i3("/api/open-in-editor",{path:n,mode:e.mode??"file",line:e.line,column:e.column})}}function a3(n){gt("hostFiles")&&(n.path&&o3({kind:"project",path:n.path})||c3("/api/open-in-editor",n))}function l3(n){gt("hostFiles")&&c3("/api/reveal-in-folder",n)}function c3(n,e){!e.path&&!e.dirName||i3(n,{path:e.path||void 0,dirName:e.dirName||void 0})}const LR=1500;function Sr(){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 td(d)||!r.current||(t(!0),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>t(!1),LR))},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 jl(){const n=q.c(2),[e,t]=w.useState(zR);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 zR(){return typeof document<"u"&&document.documentElement.classList.contains("dark")}let pf=null;const Fp=new Set,oc=new Map,Qb=["typescript","tsx","javascript","jsx","json","css","html","python","bash","yaml","markdown"],u3={typescript:()=>Qe(()=>import("./typescript-BPQ3VLAy.js"),[]),tsx:()=>Qe(()=>import("./tsx-COt5Ahok.js"),[]),javascript:()=>Qe(()=>import("./javascript-wDzz0qaB.js"),[]),jsx:()=>Qe(()=>import("./jsx-g9-lgVsj.js"),[]),json:()=>Qe(()=>import("./json-Cp-IABpG.js"),[]),css:()=>Qe(()=>import("./css-DPfMkruS.js"),[]),html:()=>Qe(()=>import("./html-GMplVEZG.js"),__vite__mapDeps([6,7,8])),python:()=>Qe(()=>import("./python-B6aJPvgy.js"),[]),bash:()=>Qe(()=>import("./bash-Yzrsuije.js"),[]),yaml:()=>Qe(()=>import("./yaml-Buea-lGh.js"),[]),markdown:()=>Qe(()=>import("./markdown-Cvjx9yec.js"),[]),rust:()=>Qe(()=>import("./rust-B1yitclQ.js"),[]),go:()=>Qe(()=>import("./go-CxLEBnE3.js"),[]),toml:()=>Qe(()=>import("./toml-vGWfd6FD.js"),[]),sql:()=>Qe(()=>import("./sql-BLtJtn59.js"),[]),c:()=>Qe(()=>import("./c-BIGW1oBm.js"),[]),cpp:()=>Qe(()=>import("./cpp-BRuaLJcg.js"),__vite__mapDeps([9,10,11])),java:()=>Qe(()=>import("./java-CylS5w8V.js"),[]),ruby:()=>Qe(()=>import("./ruby-B0Tyh1qT.js"),__vite__mapDeps([12,6,7,8,13,14,11,15,16,17,9,10,18,19])),swift:()=>Qe(()=>import("./swift-D82vCrfD.js"),[]),kotlin:()=>Qe(()=>import("./kotlin-BdnUsdx6.js"),[]),php:()=>Qe(()=>import("./php-aq0itWAE.js"),__vite__mapDeps([20,6,7,8,13,14,11,21])),vue:()=>Qe(()=>import("./vue-DVfSmUF7.js"),__vite__mapDeps([22,8,7,15,21,6])),svelte:()=>Qe(()=>import("./svelte-DZMnMd3x.js"),__vite__mapDeps([23,7,15,8])),scss:()=>Qe(()=>import("./scss-OYdSNvt2.js"),__vite__mapDeps([24,8]))};function d3(){return pf||(pf=(async()=>{const[n,e,...t]=await Promise.all([Qe(()=>import("./github-dark-DHJKELXO.js"),[]).then(r=>r.default),Qe(()=>import("./github-light-DAi9KRSo.js"),[]).then(r=>r.default),...Qb.map(r=>u3[r]().then(o=>o.default))]),s=await wA({themes:[n,e],langs:t,engine:SA()});for(const r of Qb)Fp.add(r);return s})()),pf}async function f3(n,e){if(Fp.has(e))return;if(oc.has(e))return oc.get(e);const t=u3[e];if(!t)return;const s=t().then(async r=>{await n.loadLanguage(r.default),Fp.add(e)}).finally(()=>oc.delete(e));oc.set(e,s),await s}const DR={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 m3(n){var t;const e=((t=n.split(".").pop())==null?void 0:t.toLowerCase())??"";return DR[e]??null}async function FR(n,e,t){try{const s=await d3();await f3(s,e);const r=t?"github-dark":"github-light";return s.codeToTokens(n,{lang:e,theme:r}).tokens}catch{return null}}const UR="min-w-0 max-h-96 overflow-y-auto whitespace-pre-wrap break-words [overflow-wrap:anywhere] rounded-md border bg-muted/30 p-3 font-mono text-xs leading-relaxed text-foreground/85",zg="min-w-0 max-h-96 overflow-auto whitespace-pre-wrap break-words [overflow-wrap:anywhere] rounded-md bg-muted/40 p-3 font-mono text-xs leading-relaxed text-foreground/85";function fd(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 FR(n,e,t).then(u=>{c||o({code:n,lang:e,isDark:t,tokens:u})}).catch(BR),()=>{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 BR(){}function Dg(n){const e=q.c(13),{lines:t,tokens:s,lineNums:r,variant:o,label:i}=n,l=o==="boxed"?UR:zg;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(WR):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 WR(n,e){return a.jsx("span",{style:{color:n.color},children:n.content},e)}function p3(n){const e=q.c(6),{code:t,language:s,label:r}=n,o=jl(),i=fd(t,s,o);let l;e[0]!==t?(l=Ga(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(Dg,{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 qR=/^(\s*\d+)→(.*)$/;function Ga(n){return n.split(/\r\n|\r|\n/)}function VR(n){const e=[],t=[];for(const s of Ga(n)){const r=s.match(qR);r?(e.push(r[1]),t.push(r[2])):(e.push(""),t.push(s))}return{lineNums:e,codeLines:t}}function HR(n){const e=q.c(11),{result:t,filePath:s,variant:r}=n,o=r===void 0?"boxed":r,i=jl();let l;e[0]!==s?(l=m3(s),e[0]=s,e[1]=l):l=e[1];const c=l;let u;e[2]!==t?(u=VR(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=fd(m,c,i);let g;return e[6]!==f||e[7]!==d||e[8]!==h||e[9]!==o?(g=a.jsx(Dg,{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 h3(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 g3(n){const e=q.c(9),{result:t,alreadyPretty:s,variant:r}=n,o=r===void 0?"boxed":r,i=jl();let l;e[0]!==s||e[1]!==t?(l=s?t:h3(t)??t,e[0]=s,e[1]=t,e[2]=l):l=e[2];const c=l;let u;e[3]!==c?(u=Ga(c),e[3]=c,e[4]=u):u=e[4];const d=u,f=fd(c,"json",i);let m;return e[5]!==d||e[6]!==f||e[7]!==o?(m=a.jsx(Dg,{lines:d,tokens:f,variant:o}),e[5]=d,e[6]=f,e[7]=o,e[8]=m):m=e[8],m}function KR(n){const e=Ga(n),t=e.slice(0,8).join(`
|
|
8
|
+
`),s=t.slice(0,1e3);return{text:s,hiddenLines:Math.max(0,e.length-Ga(s).length),truncated:e.length>8||t.length>1e3}}function x3(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]=Sr(),f=w.useId();let m;e[0]!==r||e[1]!==i||e[2]!==t?(m=!i&&!r?h3(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=KR(h),e[4]=h,e[5]=g):g=e[5];const x=g,b=l?h:x.text,v=i&&"text-destructive";let y;e[6]!==v?(y=K("text-xs text-muted-foreground",v),e[6]=v,e[7]=y):y=e[7];const k=i?"Error":"Result";let j;e[8]!==y||e[9]!==k?(j=a.jsx("span",{className:y,children:k}),e[8]=y,e[9]=k,e[10]=j):j=e[10];let C;e[11]!==u||e[12]!==d||e[13]!==t?(C=t.trim()&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>d(t),"aria-label":u?"Result copied":"Copy result",children:u?a.jsx(Bt,{"data-icon":"icon"}):a.jsx(fs,{"data-icon":"icon"})}),e[11]=u,e[12]=d,e[13]=t,e[14]=C):C=e[14];let _;e[15]!==j||e[16]!==C?(_=a.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[j,C]}),e[15]=j,e[16]=C,e[17]=_):_=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(HR,{result:b,filePath:r,variant:"unboxed"}):p!==null?a.jsx(g3,{result:b,alreadyPretty:!0,variant:"unboxed"}):a.jsx("pre",{tabIndex:0,className:K(zg,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 N;e[25]!==f||e[26]!==S?(N=a.jsx("div",{id:f,children:S}),e[25]=f,e[26]=S,e[27]=N):N=e[27];let T;e[28]!==l||e[29]!==x.hiddenLines||e[30]!==x.truncated||e[31]!==f?(T=x.truncated&&a.jsx(J,{type:"button",variant:"ghost",size:"xs",className:"mt-1",onClick:()=>c(GR),"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]=T):T=e[32];let E;return e[33]!==N||e[34]!==T||e[35]!==_?(E=a.jsxs("section",{className:"mt-3 min-w-0","aria-label":"Result",children:[_,N,T]}),e[33]=N,e[34]=T,e[35]=_,e[36]=E):E=e[36],E}function GR(n){return!n}const ZR={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 YR(n){return ZR[n.toLowerCase()]??n}function XR(n){if(!n)return null;const e=n.match(/language-(\S+)/);return(e==null?void 0:e[1])??null}function JR(n){const e=q.c(9),{text:t}=n,[s,r]=Sr();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(Bt,{className:"text-success","data-icon":"inline-start"}),a.jsx("span",{className:"text-success",children:"Copied"})]}):a.jsx(fs,{"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(J,{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 QR(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 b3(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=XR(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(e8,{code:d,lang:l,...r}),e[12]=d,e[13]=l,e[14]=r,e[15]=f):f=e[15],f}function e8(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=jl(),i=fd(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?at:It;d="my-3 overflow-hidden rounded-lg border border-border bg-muted/20";let v;e[13]!==b||e[14]!==l||e[15]!==x?(v=x&&a.jsx(J,{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]=v):v=e[16];let y;e[17]!==s?(y=s&&a.jsx(Fe,{variant:"ghost",className:"px-0 uppercase tracking-wide text-muted-foreground",children:YR(s)}),e[17]=s,e[18]=y):y=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]!==v||e[23]!==y||e[24]!==k?(j=a.jsxs("div",{className:"flex items-center gap-2",children:[v,y,k]}),e[22]=v,e[23]=y,e[24]=k,e[25]=j):j=e[25];let C;e[26]!==t?(C=a.jsx(JR,{text:t}),e[26]=t,e[27]=C):C=e[27],e[28]!==j||e[29]!==C?(f=a.jsxs("div",{className:"flex items-center justify-between border-b border-border bg-muted/40 px-3 py-1.5",children:[j,C]}),e[28]=j,e[29]=C,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:K("block",!i&&"text-foreground/90"),...r,children:g.map((_,S)=>{const N=i==null?void 0:i[S];return a.jsxs("span",{className:"block",children:[a.jsx(QR,{num:S+1}),N?N.map(t8):_||" "]},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(J,{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 t8(n,e){return a.jsx("span",{style:{color:n.color},children:n.content},e)}var Co=function(n,e){return Number(n.toFixed(e))},n8=function(n,e){return e},ct=function(n,e,t){t&&typeof t=="function"&&t(n,e)},s8=function(n){return-Math.cos(n*Math.PI)/2+.5},r8=function(n){return n},o8=function(n){return n*n},i8=function(n){return n*(2-n)},a8=function(n){return n<.5?2*n*n:-1+(4-2*n)*n},l8=function(n){return n*n*n},c8=function(n){return--n*n*n+1},u8=function(n){return n<.5?4*n*n*n:(n-1)*(2*n-2)*(2*n-2)+1},d8=function(n){return n*n*n*n},f8=function(n){return 1- --n*n*n*n},m8=function(n){return n<.5?8*n*n*n*n:1-8*--n*n*n*n},p8=function(n){return n*n*n*n*n},h8=function(n){return 1+--n*n*n*n*n},g8=function(n){return n<.5?16*n*n*n*n*n:1+16*--n*n*n*n*n},v3={easeOut:s8,linear:r8,easeInQuad:o8,easeOutQuad:i8,easeInOutQuad:a8,easeInCubic:l8,easeOutCubic:c8,easeInOutCubic:u8,easeInQuart:d8,easeOutQuart:f8,easeInOutQuart:m8,easeInQuint:p8,easeOutQuint:h8,easeInOutQuint:g8},y3=function(n){typeof n=="number"&&cancelAnimationFrame(n)},js=function(n){n.mounted&&(y3(n.animation),n.isAnimating=!1,n.animation=null,n.velocity=null)};function w3(n,e,t,s){if(n.mounted){var r=new Date().getTime(),o=1;js(n),n.animation=function(){if(!n.mounted)return y3(n.animation);var i=new Date().getTime()-r,l=i/t,c=v3[e],u=c(l);i>=t?(s(o),n.animation=null):n.animation&&(s(u),requestAnimationFrame(n.animation))},requestAnimationFrame(n.animation)}}function x8(n){var e=n.scale,t=n.positionX,s=n.positionY;return!(Number.isNaN(e)||Number.isNaN(t)||Number.isNaN(s))}function go(n,e,t,s){var r=x8(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):w3(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 b8(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 v8=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}},Fg=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=b8(t,s,e),c=l.wrapperWidth,u=l.wrapperHeight,d=l.newContentWidth,f=l.newContentHeight,m=l.newDiffWidth,p=l.newDiffHeight,h=v8(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,v=x.maxPositionX,y=x.minPositionY,k=x.maxPositionY;return b!=null&&(h.minPositionX=c*(1-e)+b*e),v!=null&&(h.maxPositionX=v*e),y!=null&&(h.minPositionY=u*(1-e)+y*e),k!=null&&(h.maxPositionY=k*e),h},Za=function(n,e,t,s){return s?n<e?Co(e,2):n>t?Co(t,2):Co(n,2):Co(n,2)},Ci=function(n,e){var t=Fg(n,e);return n.bounds=t,t};function Nl(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=Za(n,l-f,u+f,s),h=Za(e,c-m,d+m,s);return{x:p,y:h}}function md(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=Nl(f,m,r,o,0,0,null);return p}var e0=1e-7;function Cl(n,e,t,s,r){var o=r?s:0,i=Math.max(e-o,e0),l=t+o;return!Number.isNaN(t)&&n>=l?l:!Number.isNaN(e)&&n<=i?i:Math.max(n,e0)}var t0=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=_l(o,t);return!(u||o.getAttribute("draggable")==="true"||o.getAttribute("contenteditable")==="true"||o.isContentEditable)},n0=function(n){var e=n.isInitialized,t=n.isPanning,s=n.setup,r=s.panning.disabled,o=e&&t&&!r;return!!o},y8=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}},w8=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 S8(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,v=s>p?u.offsetHeight:n.setup.minPositionY||0,y=md(n,b,v,r,n.bounds,l||c),k=y.x,j=y.y;return{scale:r,positionX:g?k:t,positionY:x?j:s}}}function S3(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=Nl(e,t,l,o,s,r,i),p=m.x,h=m.y;n.setState(u,p,h)}}var k8=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}},io=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},qr;(function(n){n.TRACK_PAD="track_pad",n.MOUSE="mouse",n.TOUCH="touch"})(qr||(qr={}));var j8=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},N8=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 C8(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 s0(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:Za(n,o,i,r)}function _8(n){var e=1,t=n.offsetWidth/window.innerWidth;return Number.isNaN(t)?e:Math.min(e,t)}var hf=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 T8(n,e,t){var s,r,o=j8(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=_8(u),b=(s={},s[qr.TOUCH]=p,s[qr.MOUSE]=h,s)[t],v=(r={},r[qr.TOUCH]=m,r[qr.MOUSE]=f,r)[t],y=e.x-i.x,k=e.y-i.y,j=hf(y/x,v,b),C=hf(k/x,v,b),_=g-l,S=y*y+k*k,N=hf(Math.sqrt(S)/_,v,b);n.velocity={velocityX:j,velocityY:C,total:N}}n.lastMousePosition=e,n.velocityTime=g}}function E8(n){var e=n.velocity,t=n.bounds,s=n.setup,r=n.wrapperComponent,o=N8(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,v=x.lockAxisX,y=g.animationType,k=h.sizeX,j=h.sizeY,C=h.velocityAlignmentTime,_=C,S=C8(n,c),N=Math.max(S,_),T=io(n,k),E=io(n,j),A=T*r.offsetWidth/100,P=E*r.offsetHeight/100,I=u+A,O=d-A,R=f+P,$=m-P,M=n.state,z=new Date().getTime();w3(n,y,N,function(F){var D=n.state,L=D.scale,B=D.positionX,U=D.positionY,W=new Date().getTime()-z,V=W/_,H=v3[h.animationType],G=1-H(Math.min(1,V)),Z=1-F,Y=B+i*Z,X=U+l*Z,ee=s0(Y,M.positionX,B,v,p,d,u,O,I,G),Q=s0(X,M.positionY,U,b,p,m,f,$,R,G);if(B!==Y||U!==X){n.setState(L,ee,Q);var ne=n.props.onPanning;ne&&ne(it(n),{})}})}}function r0(n,e){var t=n.state,s=t.scale,r=t.positionX,o=t.positionY;n.panStartPosition={x:r,y:o},js(n),Ci(n,s),window.TouchEvent!==void 0&&e instanceof TouchEvent?w8(n,e):y8(n,e)}function k3(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=S8(n);m&&go(n,m,u,d)}}function o0(n,e,t,s){var r=n.startCoords,o=n.setup,i=o.autoAlignment,l=i.sizeX,c=i.sizeY;if(r){var u=k8(n,e,t),d=u.x,f=u.y,m=io(n,l),p=io(n,c);T8(n,{x:d,y:f},s),S3(n,d,f,m,p)}}function A8(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?E8(n):k3(n)}}function Ug(n,e,t,s){var r=n.setup,o=r.minScale,i=r.maxScale,l=r.limitToBounds,c=Cl(Co(e,2),o,i,0,!1),u=Ci(n,c),d=md(n,t,s,c,u,l),f=d.x,m=d.y;return{scale:c,positionX:f,positionY:m}}function Bg(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)&&k3(n),!(h||!r||!n.mounted)){var g=e||r.offsetWidth/2,x=t||r.offsetHeight/2,b=s<i?i:l,v=Ug(n,b,g,x);v&&go(n,v,f,m)}}var os=function(){return os=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},os.apply(this,arguments)};function i0(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 gf={scale:1,positionX:0,positionY:0},jo={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"}},Up={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},j3=function(n){var e,t,s,r,o,i,l,c,u,d=Math.max((e=n.minScale)!==null&&e!==void 0?e:jo.minScale,1e-7),f=(t=n.maxScale)!==null&&t!==void 0?t:jo.maxScale,m=(s=n.initialScale)!==null&&s!==void 0?s:gf.scale,p=Math.min(Math.max(m,d),f),h=Za((r=n.initialPositionX)!==null&&r!==void 0?r:gf.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=Za((l=n.initialPositionY)!==null&&l!==void 0?l:gf.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}},a0=function(n){var e=os({},jo);return Object.keys(n).forEach(function(t){var s=t,r=typeof n[s]<"u",o=typeof jo[s]<"u";if(o&&r){var i=Object.prototype.toString.call(jo[s]),l=i==="[object Object]",c=i==="[object Array]";l?e[s]=os(os({},jo[s]),n[s]):c?e[s]=i0(i0([],jo[s],!0),n[s]):e[s]=n[s]}}),e.minScale<=0&&(e.minScale=1e-7),e},N3=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=Cl(Co(f,3),l,i,d,!1);return m};function C3(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,v=N3(n,e,t),y=Ug(n,v,x,b);if(!y)return console.error("Error during zoom event. New transformation state was not calculated.");var k=n.props,j=k.onZoomStart,C=k.onZoom,_=k.onZoomStop,S=new MouseEvent("mousemove",{bubbles:!0}),N=it(n);ct(N,S,j),ct(N,S,C),go(n,y,p,r);var T=(i=(o=l.ownerDocument)===null||o===void 0?void 0:o.defaultView)!==null&&i!==void 0?i:typeof window<"u"?window:null;T&&T.setTimeout(function(){n.mounted&&ct(it(n),S,_)},p)}function _3(n,e,t,s){var r,o,i=n.setup,l=n.wrapperComponent,c=n.contentComponent,u=i.limitToBounds,d=i.centerOnInit,f=j3(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 v=Wg(f.scale,l,c);x=v.positionX,b=v.positionY}var y=Fg(n,f.scale),k=Nl(x,b,y,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 C=n.props,_=C.onZoomStart,S=C.onZoom,N=C.onZoomStop,T=new MouseEvent("mousemove",{bubbles:!0}),E=it(n);ct(E,T,_),ct(E,T,S),go(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&&ct(it(n),T,N)},e)}}}function P8(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 I8(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=P8(e,o,i,l),g=h.x,x=h.y,b=p.width/l.scale,v=p.height/l.scale,y=o.offsetWidth/b,k=o.offsetHeight/v,j=Cl(t||Math.min(y,k),d,f,0,!1),C=(m.width-b*j)/2,_=(m.height-v*j)/2,S=(m.left-g)*j+C+s,N=(m.top-x)*j+_+r,T=Fg(n,j),E=Nl(S,N,T,u,0,0,o),A=E.x,P=E.y;return{positionX:A,positionY:P,scale:j}}var $8=function(n){return function(e,t,s){e===void 0&&(e=.5),t===void 0&&(t=300),s===void 0&&(s="easeOut"),C3(n,1,e,t,s)}},R8=function(n){return function(e,t,s){e===void 0&&(e=.5),t===void 0&&(t=300),s===void 0&&(s="easeOut"),C3(n,-1,e,t,s)}},O8=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};go(n,p,r,o)}}},M8=function(n){return function(e,t){e===void 0&&(e=200),t===void 0&&(t="easeOut"),_3(n,e,t)}},L8=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=Wg(e||r.scale,o,i);go(n,l,t,s)}}},z8=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),js(n);var l=n.wrapperComponent,c=typeof e=="string"?document.getElementById(e):e;if(l&&c&&l.contains(c)){var u=I8(n,c,t,o,i);go(n,u,s,r)}}},Bp=function(n){return{instance:n,state:n.state,zoomIn:$8(n),zoomOut:R8(n),setTransform:O8(n),resetTransform:M8(n),centerView:L8(n),zoomToElement:z8(n)}},D8=function(n){return{instance:n,state:n.state}},it=function(n){var e={};return Object.assign(e,D8(n)),Object.assign(e,Bp(n)),e},xf=!1;function bf(){try{var n={get passive(){return xf=!0,!1}};return n}catch{return xf=!1,xf}}var ic=".".concat(Up.wrapperClass),_l=function(n,e){return e.some(function(t){return n.matches("".concat(ic," ").concat(t,", ").concat(ic," .").concat(t,", ").concat(ic," ").concat(t," *, ").concat(ic," .").concat(t," *"))})},Ya=function(n){n&&clearTimeout(n)},F8=function(n){return Number.parseFloat(n.toFixed(8))},T3=function(n,e,t){var s=F8(t);return"translate(".concat(n,"px, ").concat(e,"px) scale(").concat(s,")")},Wg=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 U8(n,e){n!=null&&(typeof n=="function"?n(e):n.current=e)}function B8(n){return function(e){n.forEach(function(t){typeof t=="function"?t(e):t!=null&&(t.current=e)})}}var E3=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=_l(u,i);if(f)return!1;var m=n.isPressingKeys(n.setup.wheel.activationKeys);return!!m},W8=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=E3(n,e);if(l)return!1;var c=e.target,u=_l(c,i);if(u)return!1;var d=n.isPressingKeys(o);return!!d},q8=function(n){return n?n.deltaY<0?1:-1:0};function V8(n,e){var t=q8(n),s=n8(e,t);return s}function A3(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 H8=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=Cl(h,u,c,m,g&&!f);return x},P3=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},K8=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=_l(i,r);return!c},G8=function(n){var e=n.setup.pinch.disabled,t=n.isInitialized,s=n.pinchStartDistance,r=t&&!e&&s!==null;return!!r},Z8=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}},I3=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))},Y8=5,X8=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/Y8),x=t+g,b=x===1/0?0:Co(x,10);return Cl(b,i,o,d,!f&&!c)},$3=160,R3=100,J8=function(n,e){var t=n.props,s=t.onWheelStart,r=t.onZoomStart;n.wheelStopEventTimer||(js(n),ct(it(n),e,s),ct(it(n),e,r))},Q8=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 v=V8(e,null),y=h?b*Math.abs(e.deltaY):b,k=H8(n,v,y,!e.ctrlKey);if(c!==k){var j=Ci(n,k),C=A3(e,o,c),_=x||g===0||d||p,S=u&&_,N=md(n,C.x,C.y,k,j,S),T=N.x,E=N.y;n.previousWheelEvent=e,n.setState(k,T,E),ct(it(n),e,s),ct(it(n),e,r)}},eO=function(n,e){var t=n.props,s=t.onWheelStop,r=t.onZoomStop;Ya(n.wheelAnimationTimer),n.wheelAnimationTimer=setTimeout(function(){n.mounted&&(Bg(n,e.x,e.y),n.wheelAnimationTimer=null)},R3);var o=P3(n,e);o&&(Ya(n.wheelStopEventTimer),n.wheelStopEventTimer=setTimeout(function(){n.mounted&&(n.wheelStopEventTimer=null,ct(it(n),e,s),ct(it(n),e,r))},$3))},tO=function(n,e){var t=n.props,s=t.onWheelStart,r=t.onPanningStart;n.wheelStopEventTimer||(js(n),ct(it(n),e,s),ct(it(n),e,r))},nO=function(n,e){var t=n.props,s=t.onWheelStop,r=t.onPanningStop;Ya(n.wheelAnimationTimer),n.wheelAnimationTimer=setTimeout(function(){n.mounted&&(Bg(n,e.x,e.y),n.wheelAnimationTimer=null)},R3);var o=P3(n,e);o&&(Ya(n.wheelStopEventTimer),n.wheelStopEventTimer=setTimeout(function(){n.mounted&&(n.wheelStopEventTimer=null,ct(it(n),e,s),ct(it(n),e,r))},$3))},O3=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}},sO=function(n,e){var t=I3(e);n.pinchStartDistance=t,n.lastDistance=t,n.pinchStartScale=n.state.scale,n.isPanning=!1,n.isPinching=!0,n.pinchPreviousCenter=O3(e),js(n)},rO=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=Z8(e,i,t);if(!(!Number.isFinite(b.x)||!Number.isFinite(b.y))){var v=I3(e),y=X8(n,v),k=O3(e),j=i/y,C=(k.x-((o==null?void 0:o.x)||0))*j,_=(k.y-((o==null?void 0:o.y)||0))*j;if(!(y===i&&C===0&&_===0)){n.pinchPreviousCenter=k;var S=Ci(n,y),N=h||g===0||u,T=c&&N,E=md(n,b.x,b.y,y,S,T),A=E.x,P=E.y;if(n.pinchMidpoint=b,n.lastDistance=v,p.disabled||!x)n.setState(y,A,P);else{var I=f.sizeX,O=f.sizeY,R=io(n,I,y),$=io(n,O,y),M=A+C,z=P+_,F=Nl(M,z,S,c,R,$,r),D=F.x,L=F.y;n.setState(y,D,L)}}}}},oO=function(n){var e=n.pinchMidpoint;n.velocity=null,n.lastDistance=null,n.pinchMidpoint=null,n.pinchStartScale=null,n.pinchStartDistance=null,n.isPinching=!1,Bg(n,e==null?void 0:e.x,e==null?void 0:e.y)},M3=function(n,e){var t=n.props.onZoomStop,s=n.setup.doubleClick.animationTime;Ya(n.doubleClickStopEventTimer),n.doubleClickStopEventTimer=setTimeout(function(){n.doubleClickStopEventTimer=null,ct(it(n),e,t)},s)},iO=function(n,e){var t=n.props,s=t.onZoomStart,r=t.onZoom,o=n.setup.doubleClick,i=o.animationTime,l=o.animationType;ct(it(n),e,s),_3(n,i,l,function(){return ct(it(n),e,r)}),M3(n,e)};function aO(n,e){return n==="toggle"?e===1?1:-1:n==="zoomOut"?-1:1}function lO(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 iO(n,e);if(!o)return console.error("No ContentComponent found");var x=aO(m,n.state.scale),b=N3(n,x,p);if(i!==b){ct(it(n),e,c);var v=A3(e,o,i),y=Ug(n,b,v.x,v.y);if(!y)return console.error("Error during zoom event. New transformation state was not calculated.");ct(it(n),e,u),go(n,y,h,g),M3(n,e)}}}var cO=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=_l(c,l);return!f},uO=(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&&Ci(t,t.state.scale),t.setup=a0(s)},this.initializeWindowEvents=function(){var s,r,o,i,l=bf(),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=bf(),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),js(t),(l=t.observer)===null||l===void 0||l.disconnect()},this.handleInitializeWrapperEvents=function(s){var r=bf();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(it(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(it(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=E3(t,s);o&&(J8(t,s),Q8(t,s),eO(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=W8(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,v=x.sizeY,y=io(t,b),k=io(t,v);h===d&&g===f||(tO(t,s),S3(t,h,g,y,k),ct(it(t),s,r),nO(t,s))}},this.onPanningStart=function(s){var r=t.setup.disabled,o=t.props.onPanningStart;if(!r){t.syncModifierKeys(s);var i=t0(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(),js(t),r0(t,s),ct(it(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=n0(t);if(i){var l=t.isPressingKeys(t.setup.panning.activationKeys);l&&(s.cancelable&&s.preventDefault(),s.stopPropagation(),o0(t,s.clientX,s.clientY,qr.MOUSE),ct(it(t),s,o))}}},this.onPanningStop=function(s){var r=t.setup.panning.velocityDisabled,o=t.props.onPanningStop;t.isPanning&&(A8(t,r),ct(it(t),s,o))},this.onPinchStart=function(s){var r=t.setup.disabled,o=t.props.onPinchStart;if(!r){var i=K8(t,s);i&&(sO(t,s),js(t),ct(it(t),s,o))}},this.onPinch=function(s){var r=t.setup.disabled,o=t.props.onPinch;if(!r){var i=G8(t);i&&(s.cancelable&&s.preventDefault(),s.stopPropagation(),rO(t,s),ct(it(t),s,o))}},this.onPinchStop=function(s){var r=t.props.onPinchStop;t.pinchStartScale&&(oO(t),ct(it(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,js(t);var d=s.touches,f=d.length===1,m=d.length===2,p=t0(t,s);if(f){if(!p)return;js(t),r0(t,s),ct(it(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=n0(t);if(!i)return;s.cancelable&&s.preventDefault(),s.stopPropagation();var l=s.touches[0];o0(t,l.clientX,l.clientY,qr.TOUCH),ct(it(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=cO(t,s);o&&lO(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=Wg(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):T3(s,r,o)},this.getContext=function(){return it(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:it(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=it(t);t.onChangeCallbacks.forEach(function(u){return u(c)}),ct(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,Ci(t,t.state.scale),t.handleInitializeWrapperEvents(s),t.handleInitialize(r),t.initializeWindowEvents(),t.isInitialized=!0;var o=it(t);ct(o,void 0,t.props.onInit),U8(t.props.ref,o)},this.props=e,this.setup=a0(this.props),this.state=j3(this.props)}return n})(),pd=Ne.createContext(null),dO=function(n,e){return typeof n=="function"?n(e):n},fO=Ne.forwardRef(function(n,e){var t=w.useRef(new uO(n)).current,s=dO(n.children,Bp(t));return w.useImperativeHandle(e,function(){return Bp(t)},[t]),w.useEffect(function(){t.update(n)},[t,n]),a.jsx(pd.Provider,os({value:t},{children:s}))});Ne.forwardRef(function(n,e){var t=w.useRef(null),s=w.useContext(pd);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",os({},n,{ref:B8([t,e])}))});function mO(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 pO=`.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
|
+
`,vf={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo",infiniteGrid:"transform-component-module_infiniteGrid__Z-aP3"};mO(pO);var hO=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(pd),g=h.init,x=h.cleanupWindowEvents,b=w.useRef(null),v=w.useRef(null),y=w.useRef(null);return w.useEffect(function(){var k=b.current,j=v.current;return k!==null&&j!==null&&g&&(g==null||g(k,j)),function(){x==null||x()}},[]),w.useEffect(function(){if(p){var k=y.current;if(k){var j=function(){var C=h.state,_=C.positionX,S=C.positionY;k.style.backgroundPosition="".concat(_,"px ").concat(S,"px")};return j(),h.onChange(j)}}},[p,h]),a.jsxs("div",os({},u,{ref:b,className:"".concat(Up.wrapperClass," ").concat(vf.wrapper," ").concat(s),style:i},{children:[p&&a.jsx("div",{ref:y,className:vf.infiniteGrid,"aria-hidden":!0}),a.jsx("div",os({},f,{ref:v,className:"".concat(Up.contentClass," ").concat(vf.content," ").concat(o),style:os(os({},l),{transform:T3(h.state.positionX,h.state.positionY,h.state.scale)})},{children:e}))]}))};function gO(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 xO(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 v=g.width*g.height;if(v<=0)return!1;var y=gO(h,g);return y/v>=p}Ne.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(pd),v=w.useState(!1),y=v[0],k=v[1],j=w.useRef(!1),C=w.useRef(m),_=w.useRef(p);return C.current=m,_.current=p,w.useEffect(function(){var S=function(){var E,A,P=b.wrapperComponent;if(P){var I=xO({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?(E=C.current)===null||E===void 0||E.call(C):(A=_.current)===null||A===void 0||A.call(_))}};S();var N=b.onChange(S),T;return b.wrapperComponent||(T=b.onInit(function(){return S()})),function(){N(),T==null||T()}},[b,t,s,r,o,l,u]),y?a.jsx("div",os({ref:e,className:g,style:x},{children:h})):f?a.jsx(a.Fragment,{children:f}):null});const l0=8,bO=56;function ta(n){const e=q.c(8),{label:t,disabled:s,onClick:r,children:o,className:i}=n;let l;e[0]!==i?(l=K("size-8 border border-white/10 bg-white/[0.06] text-white/75","hover:bg-white/10 hover:text-white focus-visible:ring-white/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(J,{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 qg(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=ye=>{d(Math.min(Math.max(ye,0),s.length-1)),m(100)},e[0]=s.length,e[1]=x):x=e[1];const b=x;let v;e[2]!==b||e[3]!==u?(v=()=>b(u-1),e[2]=b,e[3]=u,e[4]=v):v=e[4];const y=v;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 C=s.length>1,_=u>0,S=u<s.length-1,N=f>100;let T;e[8]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{var ye;return(ye=p.current)==null?void 0:ye.zoomIn()},e[8]=T):T=e[8];const E=T;let A;e[9]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{var ye;return(ye=p.current)==null?void 0:ye.zoomOut()},e[9]=A):A=e[9];const P=A;let I;e[10]===Symbol.for("react.memo_cache_sentinel")?(I=()=>{var ye;return(ye=p.current)==null?void 0:ye.resetTransform()},e[10]=I):I=e[10];const O=I;let R;e[11]!==S||e[12]!==_||e[13]!==j||e[14]!==y?(R=ye=>{ye.key==="ArrowLeft"&&_?(ye.preventDefault(),y()):ye.key==="ArrowRight"&&S?(ye.preventDefault(),j()):ye.key==="+"||ye.key==="="?(ye.preventDefault(),E()):ye.key==="-"?(ye.preventDefault(),P()):ye.key==="0"&&(ye.preventDefault(),O())},e[11]=S,e[12]=_,e[13]=j,e[14]=y,e[15]=R):R=e[15];const $=R;let M;e[16]===Symbol.for("react.memo_cache_sentinel")?(M=ye=>{if(ye.pointerType==="mouse"||ye.isPrimary===!1){h.current=null;return}h.current={x:ye.clientX,y:ye.clientY}},e[16]=M):M=e[16];const z=M;let F;e[17]!==S||e[18]!==_||e[19]!==j||e[20]!==y?(F=ye=>{var Ze;const Pe=h.current;h.current=null;const Ye=((Ze=p.current)==null?void 0:Ze.instance.state.scale)??1;if(!Pe||Ye>1.01)return;const Xe=ye.clientX-Pe.x,Ee=ye.clientY-Pe.y;Math.abs(Xe)<bO||Math.abs(Xe)<Math.abs(Ee)||(Xe>0&&_&&y(),Xe<0&&S&&j())},e[17]=S,e[18]=_,e[19]=j,e[20]=y,e[21]=F):F=e[21];const D=F;let L;e[22]!==o?(L=ye=>{ye||o()},e[22]=o,e[23]=L):L=e[23];let B;e[24]!==i?(B=ye=>{ye||i==null||i()},e[24]=i,e[25]=B):B=e[25];let U,W,V;e[26]===Symbol.for("react.memo_cache_sentinel")?(U=K("flex h-[calc(100dvh-1rem)] w-[calc(100vw-1rem)] max-w-none flex-col gap-0 overflow-hidden rounded-xl border-white/10 bg-black p-0 text-white","sm:h-[min(820px,calc(100dvh-2rem))] sm:w-[min(1120px,calc(100vw-2rem))] sm:max-w-none"),W=a.jsx(ar,{className:"sr-only",children:"Image viewer"}),V=a.jsx(lr,{className:"sr-only",children:"View and navigate images from this session."}),e[26]=U,e[27]=W,e[28]=V):(U=e[26],W=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-white/[0.06]",children:a.jsx(N6,{className:"size-3.5 text-white/65","data-icon":"icon"})}),e[29]=H):H=e[29];const G=g.label||g.alt||"Session image";let Z;e[30]!==G?(Z=a.jsx("div",{className:"truncate text-xs font-medium text-white/90",children:G}),e[30]=G,e[31]=Z):Z=e[31];let Y;e[32]!==C||e[33]!==s.length||e[34]!==u?(Y=C&&a.jsxs("div",{className:"text-xs tabular-nums text-white/50",children:[u+1," of ",s.length]}),e[32]=C,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 ee=f<=100;let Q;e[39]===Symbol.for("react.memo_cache_sentinel")?(Q=a.jsx(LS,{className:"size-3.5","data-icon":"icon"}),e[39]=Q):Q=e[39];let ne;e[40]!==ee?(ne=a.jsx(ta,{label:"Zoom out",disabled:ee,onClick:P,children:Q}),e[40]=ee,e[41]=ne):ne=e[41];let re;e[42]!==f?(re=a.jsxs(J,{type:"button",variant:"ghost",size:"sm",onClick:O,className:"min-w-12 px-1.5 font-mono text-xs tabular-nums text-white/60 hover:bg-white/[0.06] hover:text-white","aria-label":"Reset zoom",title:"Reset zoom",children:[f,"%"]}),e[42]=f,e[43]=re):re=e[43];const se=f>=l0*100;let oe;e[44]===Symbol.for("react.memo_cache_sentinel")?(oe=a.jsx(Qs,{className:"size-3.5","data-icon":"icon"}),e[44]=oe):oe=e[44];let ae;e[45]!==se?(ae=a.jsx(ta,{label:"Zoom in",disabled:se,onClick:E,children:oe}),e[45]=se,e[46]=ae):ae=e[46];let ie;e[47]===Symbol.for("react.memo_cache_sentinel")?(ie=a.jsx("div",{className:"mx-1 h-5 w-px bg-white/10"}),e[47]=ie):ie=e[47];let ce;e[48]===Symbol.for("react.memo_cache_sentinel")?(ce=a.jsx(Wt,{className:"size-4","data-icon":"icon"}),e[48]=ce):ce=e[48];let te;e[49]!==o?(te=a.jsx(ta,{label:"Close image viewer",onClick:o,children:ce}),e[49]=o,e[50]=te):te=e[50];let le;e[51]!==ne||e[52]!==re||e[53]!==ae||e[54]!==te?(le=a.jsxs("div",{className:"flex items-center gap-1",children:[ne,re,ae,ie,te]}),e[51]=ne,e[52]=re,e[53]=ae,e[54]=te,e[55]=le):le=e[55];let ge;e[56]!==X||e[57]!==le?(ge=a.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-2 border-b border-white/10 bg-black/20 px-2.5 sm:px-3",children:[H,X,le]}),e[56]=X,e[57]=le,e[58]=ge):ge=e[58];const be=g.id;let ue,he,me;e[59]===Symbol.for("react.memo_cache_sentinel")?(ue={mode:"toggle"},he={step:.005},me=(ye,Pe)=>m(Math.round(Pe.scale*100)),e[59]=ue,e[60]=he,e[61]=me):(ue=e[59],he=e[60],me=e[61]);let xe,je;e[62]===Symbol.for("react.memo_cache_sentinel")?(xe={width:"100%",height:"100%"},je={width:"100%",height:"100%"},e[62]=xe,e[63]=je):(xe=e[62],je=e[63]);const Le=g.src,Se=g.alt,Ie=N?"cursor-grab active:cursor-grabbing":"cursor-zoom-in";let we;e[64]!==Ie?(we=K("max-h-full max-w-full select-none object-contain",Ie),e[64]=Ie,e[65]=we):we=e[65];let Be;e[66]!==g.alt||e[67]!==g.src||e[68]!==we?(Be=a.jsx(hO,{wrapperStyle:xe,contentStyle:je,contentClass:"flex items-center justify-center p-3 sm:p-6",children:a.jsx("img",{src:Le,alt:Se,draggable:!1,className:we})}),e[66]=g.alt,e[67]=g.src,e[68]=we,e[69]=Be):Be=e[69];let De;e[70]!==g.id||e[71]!==Be?(De=a.jsx(fO,{ref:p,minScale:1,maxScale:l0,centerOnInit:!0,centerZoomedOut:!0,doubleClick:ue,wheel:he,onTransform:me,children:Be},be),e[70]=g.id,e[71]=Be,e[72]=De):De=e[72];let Ue;e[73]!==S||e[74]!==_||e[75]!==j||e[76]!==y||e[77]!==C?(Ue=C&&a.jsxs(a.Fragment,{children:[a.jsx(ta,{label:"Previous image",disabled:!_,onClick:y,className:"absolute left-2 top-1/2 size-10 -translate-y-1/2 rounded-full bg-black/45 backdrop-blur sm:left-3",children:a.jsx(Jh,{className:"size-5","data-icon":"icon"})}),a.jsx(ta,{label:"Next image",disabled:!S,onClick:j,className:"absolute right-2 top-1/2 size-10 -translate-y-1/2 rounded-full bg-black/45 backdrop-blur sm:right-3",children:a.jsx(at,{className:"size-5","data-icon":"icon"})})]}),e[73]=S,e[74]=_,e[75]=j,e[76]=y,e[77]=C,e[78]=Ue):Ue=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-black/60 px-2.5 py-1 text-xs text-white/60 sm:flex",children:[a.jsx(Yu,{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 Oe;e[81]!==D||e[82]!==De||e[83]!==Ue||e[84]!==We?(Oe=a.jsxs("div",{className:"relative min-h-0 flex-1 overflow-hidden bg-black",onPointerDown:z,onPointerUp:D,children:[De,Ue,We]}),e[81]=D,e[82]=De,e[83]=Ue,e[84]=We,e[85]=Oe):Oe=e[85];let pe;e[86]!==b||e[87]!==C||e[88]!==s||e[89]!==u?(pe=C&&a.jsx("footer",{className:"shrink-0 border-t border-white/10 bg-black/25 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((ye,Pe)=>a.jsxs(J,{type:"button",variant:"ghost",onClick:()=>b(Pe),"aria-label":`View image ${Pe+1}`,"aria-current":Pe===u?"true":void 0,className:K("relative size-12 shrink-0 overflow-hidden rounded-md border bg-white/[0.04] p-0.5 sm:h-14 sm:w-[4.5rem]",Pe===u?"border-white ring-1 ring-white/40":"border-white/10 opacity-55 hover:border-white/25 hover:opacity-90"),children:[a.jsx("img",{src:ye.src,alt:"",draggable:!1,className:"size-full rounded-[3px] object-cover"}),a.jsx("span",{className:"absolute bottom-0.5 right-0.5 rounded bg-black/70 px-1 font-mono text-xs text-white/80",children:Pe+1})]},`${ye.id}-${Pe}`))})}),e[86]=b,e[87]=C,e[88]=s,e[89]=u,e[90]=pe):pe=e[90];let ke;e[91]!==$||e[92]!==ge||e[93]!==Oe||e[94]!==pe?(ke=a.jsxs(ir,{showCloseButton:!1,onKeyDown:$,className:U,children:[W,V,ge,Oe,pe]}),e[91]=$,e[92]=ge,e[93]=Oe,e[94]=pe,e[95]=ke):ke=e[95];let _e;return e[96]!==l||e[97]!==L||e[98]!==B||e[99]!==ke?(_e=a.jsx(or,{open:l,onOpenChange:L,onOpenChangeComplete:B,children:ke}),e[96]=l,e[97]=L,e[98]=B,e[99]=ke,e[100]=_e):_e=e[100],_e}const c0={0:"\0",b:"\b",f:"\f",n:`
|
|
54
|
+
`,r:"\r",t:" ",v:"\v"};function vO(n){return!!(n&&/[A-Za-z_$]/.test(n))}function fu(n){return!!(n&&/[\w$]/.test(n))}function tr(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 c0){s+=c0[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 Vr={"(":")","[":"]","{":"}"};function Vg(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 Tl(n,e){const t=tr(n,e);if(t)return{endIndex:t.endIndex,isString:!0};const s=Vg(n,e);return s===null?null:{endIndex:s,isString:!1}}function Dn(n,e){let t=e;for(;t<n.length;){if(/\s/.test(n[t])){t++;continue}const s=Vg(n,t);if(s===null)break;t=s}return t}function hd(n,e){const t=n[e];if(!Vr[t])return null;const s=[Vr[t]];for(let r=e+1;r<n.length;r++){const o=Tl(n,r);if(o){r=o.endIndex-1;continue}const i=n[r];if(Vr[i]){s.push(Vr[i]);continue}if(i===s.at(-1)&&(s.pop(),s.length===0))return r}return null}function L3(n,e){if(!vO(n[e]))return null;let t=e+1;for(;fu(n[t]);)t++;return{value:n.slice(e,t),endIndex:t}}function yO(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=Tl(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=Dn(r,i.index+i[0].length),c=r[l];if(c==="{"||c==="["||c==="("){const f=hd(r,l);if(f!==null)return r.slice(l,f+1).trim()}const u=tr(r,l);return u?r.slice(l,u.endIndex).trim():t}function z3(n){const e=[];let t="";for(let s=0;s<n.length;s++){const r=Tl(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)||fu(n[s-1])||fu(n[s+5]))continue;let i=Dn(n,s+5),l="";if(n[i]==="."){i=Dn(n,i+1);const d=L3(n,i);if(!d)continue;l=d.value,i=d.endIndex}else if(n[i]==="["){i=Dn(n,i+1);const d=tr(n,i);if(!d||(i=Dn(n,d.endIndex),n[i]!=="]"))continue;l=d.value,i++}else continue;if(i=Dn(n,i),n[i]!=="(")continue;const c=hd(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:yO(n,s,u),startIndex:s})}return e}function D3(n,e){return tr(n,e)??L3(n,e)}function wO(n,e,t){const s=[];for(let r=e;r<t;r++){const o=Tl(n,r);if(o){r=o.endIndex-1;continue}const i=n[r];if(Vr[i]){s.push(Vr[i]);continue}if(s.length>0&&i===s.at(-1)){s.pop();continue}if(s.length===0&&i===",")return r}return t}function gd(n,e){let t=Dn(n,0);for(;n[t]==="(";)t=Dn(n,t+1);if(n[t]!=="{")return null;const s=hd(n,t);if(s===null)return null;let r=t+1;for(;r<s;){if(r=Dn(n,r),n[r]===","){r++;continue}const o=D3(n,r);if(!o){r++;continue}if(r=Dn(n,o.endIndex),n[r]!==":"){r++;continue}const i=Dn(n,r+1),l=wO(n,i,s);if(o.value===e)return n.slice(i,l).trim();r=l+1}return null}function F3(n,e,t){const s=[];for(let r=0;r<n.length;r++){const o=Vg(n,r);if(o!==null){r=o-1;continue}const i=D3(n,r);if(i){if(i.value===e&&!fu(n[r-1])){const l=Dn(n,i.endIndex);if(n[l]===":"){const c=t(Dn(n,l+1));c!==null&&s.push(c)}}r=i.endIndex-1}}return s}function Hg(n,e){return F3(n,e,t=>{var s;return((s=tr(n,t))==null?void 0:s.value)??null})}function U3(n,e){return F3(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 B3(n){const e=Dn(n,0);if(!n.slice(e).trim())return 0;if(n[e]!=="[")return 1;const t=hd(n,e);if(t===null)return 1;let s=0,r=!1;const o=[];for(let i=e+1;i<t;i++){const l=Tl(n,i);if(l){r||(r=l.isString),i=l.endIndex-1;continue}const c=n[i];Vr[c]?(r=!0,o.push(Vr[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 SO=["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 u0(n){try{return{value:JSON.parse(n)}}catch{}if(n.startsWith("`")&&n.includes("${"))return null;const e=tr(n,0);return e&&e.endIndex===n.length?{value:e.value}:null}function Kg(n){return typeof n.input.raw=="string"&&/(?:^|__|[.:/])exec$/.test(n.name)}function W3(n){return typeof n.raw!="string"?[]:z3(n.raw).map(({name:e,argumentSource:t})=>{const s=t.trim(),r=u0(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 SO){const l=gd(s,i);if(l===null)continue;const c=u0(l);c&&(o[i]=c.value)}return{name:e,input:o}})}function Wp(n){return n.type==="user"}function Gg(n){return n.type==="assistant"}function d0(n){return n.type==="progress"}function f0(n){return n.type==="system"}function q3(n){return n.type==="summary"}function kO(n){return n.type==="queue-operation"}function V3(n){return n.type==="attachment"}function jO(n){return n.type==="user"&&n.isCompactSummary===!0}function H3(n){return n.type==="system"&&n.subtype==="compact_boundary"}function m0(n,e){let t=0;for(const s of n)e[s.name]=(e[s.name]??0)+1,s.isError&&t++;return t}function p0(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 xd(n){return{totalInputTokens:0,totalOutputTokens:0,totalCacheCreationTokens:0,totalCacheReadTokens:0,toolCallCounts:{},errorCount:0,totalDurationMs:0,turnCount:n}}function bd(n){const e=xd(n.length);for(const t of n){t.tokenUsage&&p0(e,t.tokenUsage),t.durationMs&&(e.totalDurationMs+=t.durationMs),e.errorCount+=m0(t.toolCalls,e.toolCallCounts);for(const s of t.subAgentActivity)e.errorCount+=m0(s.toolCalls,e.toolCallCounts),s.tokenUsage&&p0(e,s.tokenUsage)}return e}function xi(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 NO=/<(agent-message|teammate-message)([^>]*)>([\s\S]*?)<\/\1>/g,CO=[/\bteammate_id=(?:"([^"]*)"|'([^']*)')/,/\bfrom=(?:"([^"]*)"|'([^']*)')/];function _O(n){for(const e of CO){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 TO(n){return n.replace(/^\s*<(?:agent-message|teammate-message)\b[^>]*>/,"").replace(/<\/(?:agent-message|teammate-message)>\s*$/,"").trim()}function Xa(n){let e=null,t=!1;const s=n.replace(NO,(r,o,i,l)=>(t=!0,e===null&&(e=_O(i)),l.trim()));return{sender:e,matched:t,body:t?s.trim():n}}const EO=[/\bblocking question\b/,/\bbefore i touch\b/,/\bshould i\b/,/\btell me one of\b/,/\byour call\b/,/\bwho owns\b/,/\bconfirm whether\b/],AO=[/(?:^|[,;:.!?—–-]\s*)tell me\b/,/(?:^|[,;:.!?—–-]\s*)say so\b/],PO=200,IO=/\bhttps?:\/\/\S+/g;function $O(n){const e=n.trim();if(!e)return!1;const t=e.slice(0,PO).toLowerCase();if(EO.some(o=>o.test(t)))return!0;const r=e.slice(e.lastIndexOf(`
|
|
58
|
+
`)+1).slice(-200).replace(IO,"").toLowerCase();return r.includes("?")||AO.some(o=>o.test(r))}function ac(n){return n&&typeof n=="object"?n:{}}function RO(n,e){const t=ac(e);if(n==="Edit"||n==="Write")return t.staged===!0?{awaitingReview:!0}:{};if(n!=="Bash")return{};const s=ac(t.bashEditDiff);if(!Array.isArray(s.files))return{};const r=[];for(const i of s.files){const l=ac(i);if(typeof l.filePath!="string"||!l.filePath||!Array.isArray(l.hunks))continue;const c=[];for(const u of l.hunks){const d=ac(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 OO(n){return n.hunks.map(e=>[`@@ -${e.oldStart},${e.oldLines} +${e.newStart},${e.newLines} @@`,...e.lines].join(`
|
|
59
|
+
`)).join(`
|
|
60
|
+
`)}function MO(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 vd(n){return typeof n=="string"?n:n.filter(e=>e.type==="text").map(e=>e.text).join(`
|
|
62
|
+
`)}function h0(n){return n?typeof n=="string"?n:n.map(e=>e.type==="text"?e.text:"").filter(Boolean).join(`
|
|
63
|
+
`):""}function K3(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 LO=/<task-notification>[\s\S]*?<\/task-notification>/g,zO=/<[^>]*>/g;function DO(n){var t;if(((t=n.origin)==null?void 0:t.kind)==="task-notification")return!0;const e=vd(n.message.content);return e.includes("<task-notification>")?e.replace(LO,"").replace(zO,"").trim()==="":!1}function FO(n){if(!V3(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:vd(t);if(!K3(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??Xa(s).body}}if((r==null?void 0:r.kind)==="human")return{raw:s,sender:null,body:s};const o=Xa(s);return{raw:s,sender:o.sender,body:o.body}}const UO=[["attributionAgent","agent"],["attributionSkill","skill"],["attributionPlugin","plugin"],["attributionMcpServer","mcpServer"],["attributionMcpTool","mcpTool"]];function BO(n,e){let t=n;for(const[s,r]of UO){const o=e[s];typeof o!="string"||!o||(t={...t,[r]:o})}return t}const WO=/^This session is being continued from a previous conversation[\s\S]*?\n\nSummary:\s*\n/,qO=/\n+(?:If you need specific details from before compaction|(?:Please c|C)ontinue the conversation from where it left off)[\s\S]*$/;function VO(n){return vd(n).trim().replace(WO,"").replace(qO,"").trim()}function HO(n){if(n)return{trigger:n.trigger,preTokens:n.preTokens,postTokens:n.postTokens}}function lc(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 KO(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 v=b.toolCalls.findIndex(y=>y.name==="ExitPlanMode");if(v!==-1){u.push(...b.toolCalls.slice(0,v)),m=b.toolCalls[v],p=m.input.path?String(m.input.path):void 0,m.result!==null&&(h=m.isError?"rejected":"approved");const y=b.toolCalls.slice(v+1);e.push({kind:"plan_mode",plan:i,planFilePath:p,status:h,toolCalls:u,timestamp:l}),e.push(...x),y.length>0&&e.push({kind:"tool_calls",toolCalls:y,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 GO(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 Zg(n){var s;const e=n.map(GO),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 ZO(n){const e=[];let t=!1;for(let s=0;s<n.length;s++){const r=n[s];if(q3(r)||H3(r)){t=!1;continue}if(Wp(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}Gg(r)&&!t&&(e.push(s),t=!0)}return e}function G3(n){var C,_;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,N){let T=x.get(S);T||(T=new Map,x.set(S,T)),T.set(N,(T.get(N)??0)+1)}function v(S,N){const T=x.get(S),E=T==null?void 0:T.get(N);return!T||!E?!1:(E===1?T.delete(N):T.set(N,E-1),!0)}function y(){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 N=f.get(S);if(!N||N.length===0)return;o.subAgentActivity.push(...N),f.delete(S);const T=p.has(S)?"background_agent":"sub_agent",E=m.get(S);if(E)E.messages.push(...N);else{const A={kind:T,messages:[...N]};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 N of S.events){if(!(N.eventName==="PostToolUse"||N.eventName.startsWith("PostToolUse:"))||!N.toolUseId)continue;const E=o.toolCalls.find(A=>A.id===N.toolUseId);E&&(N.updatedToolOutput&&(E.outputReplacedByHook=!0),N.durationMs!==void 0&&(E.hookDurationMs=(E.hookDurationMs??0)+N.durationMs))}o.contentBlocks=KO(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(q3(S)){j(),i={summary:S.summary};continue}if(H3(S)){j(),i={meta:HO(S.compactMetadata)};continue}if(jO(S)){j(),s=r,o=lc(S,null),o.compactionSummary=VO(S.message.content),o.compactionMeta=i==null?void 0:i.meta,i=null;continue}if(f0(S)&&S.subtype==="away_summary"&&S.content){c={content:S.content,timestamp:S.timestamp};continue}if(kO(S)){if(o&&S.operation==="enqueue"&&K3(S.content)){const N=Xa(S.content);g.push({turn:o,content:S.content,timestamp:S.timestamp,sender:N.sender,body:N.body}),b(o,S.content)}continue}if(V3(S)){const N=FO(S);o&&N!==null&&!v(o,N.raw)&&g.push({turn:o,content:N.raw,timestamp:((C=S.attachment)==null?void 0:C.timestamp)??S.timestamp,sender:N.sender,body:N.body});continue}if(g.length>0){const N=Wp(S)&&!S.isMeta?S.message.content:null;if(typeof N=="string"){const T=g.findIndex(E=>E.content===N);if(T>=0){const[E]=g.splice(T,1);v(E.turn,E.content)}}y()}if(Wp(S)&&!S.isMeta){const N=S.message.content;if(typeof N!="string"&&Array.isArray(N)&&N.some(E=>E.type==="tool_result")&&o){for(const A of N)if(A.type==="tool_result"){const P=u.get(A.tool_use_id);if(P){P.turn.toolCalls[P.index].result=h0(A.content),P.turn.toolCalls[P.index].isError=A.is_error===!0;const I=P.turn.toolCalls[P.index];Object.assign(I,RO(I.name,S.toolUseResult)),u.delete(A.tool_use_id)}}const E=S.toolUseResult;if(E!=null&&E.agentId){const A=((_=N.find(M=>M.type==="tool_result"))==null?void 0:_.tool_use_id)??"",P=h.get(A),I=p.has(A),O=[];if(Array.isArray(E.content))for(const M of E.content)M.type==="text"&&O.push(M.text);const R={agentId:E.agentId,parentToolUseId:A||void 0,agentName:(P==null?void 0:P.name)??null,subagentType:(P==null?void 0:P.subagentType)??null,type:"assistant",content:E.content,toolCalls:[],thinking:[],text:O,timestamp:S.timestamp??"",tokenUsage:E.usage?{input_tokens:E.usage.input_tokens??0,output_tokens:E.usage.output_tokens??0,cache_creation_input_tokens:E.usage.cache_creation_input_tokens??0,cache_read_input_tokens:E.usage.cache_read_input_tokens??0}:null,model:null,isBackground:I,prompt:E.prompt,status:E.status,durationMs:E.totalDurationMs,toolUseCount:E.totalToolUseCount};if(!m.get(A)){o.subAgentActivity.push(R);const z={kind:I?"background_agent":"sub_agent",messages:[R]};o.contentBlocks.push(z),m.set(A,z)}}continue}if(DO(S)){const T={kind:"task_notification",content:vd(N),timestamp:S.timestamp};if(o){o.contentBlocks.push(T);continue}s=r,o=lc(S,null),o.contentBlocks.push(T),l(o);continue}j(),s=r,o=lc(S,S.message.content),l(o),c&&(o.contentBlocks.push({kind:"recap",content:c.content,timestamp:c.timestamp}),c=null);continue}if(Gg(S)){let N=function(){I.length>0&&(O.contentBlocks.push({kind:"tool_calls",toolCalls:[...I],timestamp:A}),I.length=0)},T=function(){if(P.length>0){const R=O.contentBlocks[O.contentBlocks.length-1];R&&R.kind==="thinking"?R.blocks.push(...P):O.contentBlocks.push({kind:"thinking",blocks:[...P],timestamp:A}),P.length=0}};o||(s=r,o=lc(S,null),l(o)),o.model=S.message.model,S.effort&&(o.effort=S.effort),o.attribution=BO(o.attribution,S);const E=S.message.id;d.has(E)||(d.add(E),o.tokenUsage=xi(o.tokenUsage,S.message.usage));const A=S.timestamp??"",P=[],I=[],O=o;for(const R of S.message.content)if(R.type==="thinking"){N();const $=R;if(!$.thinking)continue;o.thinking.push($),P.push($)}else if(R.type==="text"){N(),T();const $=/<thinking>([\s\S]*?)<\/thinking>/g;let M=R.text,z;for(;(z=$.exec(R.text))!==null;){const F=z[1].trim();if(F){const D={type:"thinking",thinking:F,signature:""};o.thinking.push(D),o.contentBlocks.push({kind:"thinking",blocks:[D],timestamp:A})}M=M.replace(z[0],"")}if(M=M.trim(),M){o.assistantText.push(M);const F=o.contentBlocks[o.contentBlocks.length-1];F&&F.kind==="text"?F.text.push(M):o.contentBlocks.push({kind:"text",text:[M],timestamp:A})}}else if(R.type==="tool_use"){T();const $={id:R.id,name:R.name,input:R.input,result:null,isError:!1,timestamp:S.timestamp??""},M=o.toolCalls.length;if(o.toolCalls.push($),I.push($),u.set(R.id,{turn:o,index:M}),R.name==="Task"||R.name==="Agent"){const z=R.input;z.run_in_background===!0&&p.add(R.id),h.set(R.id,{name:z.name??null,subagentType:z.subagent_type??null})}}T(),N();continue}if(d0(S)&&S.data.type==="agent_progress"){const N=S.data,T=S.parentToolUseID??"";let E=null;if(N.message.type==="assistant"){const R=N.message.message,$=R.id,M=R.usage;M&&$&&!d.has($)&&(d.add($),E={input_tokens:M.input_tokens??0,output_tokens:M.output_tokens??0,cache_creation_input_tokens:M.cache_creation_input_tokens??0,cache_read_input_tokens:M.cache_read_input_tokens??0})}const A=N.message.type==="assistant"?N.message.message.model??null:null,P=h.get(T),I={agentId:N.agentId,parentToolUseId:T||void 0,agentName:(P==null?void 0:P.name)??null,subagentType:(P==null?void 0:P.subagentType)??null,type:N.message.type,content:N.message.message.content,toolCalls:[],thinking:[],text:[],timestamp:N.message.timestamp??S.timestamp??"",tokenUsage:E,model:A,isBackground:p.has(T)};if(N.message.type==="assistant"){const R=N.message.message.content;if(Array.isArray(R))for(const $ of R)$.type==="thinking"?I.thinking.push($.thinking):$.type==="text"?I.text.push($.text):$.type==="tool_use"&&I.toolCalls.push({id:$.id,name:$.name,input:$.input,result:null,isError:!1,timestamp:N.message.timestamp??S.timestamp??""})}else if(N.message.type==="user"){const R=N.message.message.content;if(Array.isArray(R)){for(const $ of R)if($.type==="tool_result"){const M=f.get(T);if(M)for(const z of M){const F=z.toolCalls.find(D=>D.id===$.tool_use_id);F&&(F.result=h0($.content),F.isError=$.is_error===!0)}}}}let O=f.get(T);O||(O=[],f.set(T,O)),O.push(I),o&&k(T);continue}if(d0(S)&&S.data.type==="hook_progress"){const N=S.data,T=String(N.hook_event_name??N.hookEvent??"unknown"),E=N.hookSpecificOutput,A={eventName:T,source:N.source!==void 0?String(N.source):void 0,toolName:N.tool_name!==void 0?String(N.tool_name):void 0,toolUseId:N.tool_use_id!==void 0?String(N.tool_use_id):void 0,command:N.command!==void 0?String(N.command):void 0,output:N.output!==void 0?String(N.output):void 0,stderr:N.stderr!==void 0?String(N.stderr):void 0,exitCode:N.exit_code!==void 0?Number(N.exit_code):void 0,decision:N.decision!==void 0?String(N.decision):void 0,durationMs:N.duration_ms!==void 0?Number(N.duration_ms):void 0,updatedToolOutput:(E==null?void 0:E.updatedToolOutput)!==void 0?String(E.updatedToolOutput):void 0,sessionTitle:(E==null?void 0:E.sessionTitle)!==void 0?String(E.sessionTitle):void 0,worktreePath:(E==null?void 0:E.worktreePath)!==void 0?String(E.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(f0(S)&&S.subtype==="turn_duration"&&o){S.durationMs!==void 0&&S.durationMs!==null&&(o.durationMs=(o.durationMs??0)+S.durationMs);continue}}return y(),j(),{turns:Zg(e),turnStartIndices:t}}function Z3(n){return G3(n).turns}function g0(){return!0}function Y3(n){const e=[];for(const t of n){const s=t.trim();if(s)try{e.push(JSON.parse(s))}catch{}}return e}function X3(n){return Y3(n.split(`
|
|
64
|
+
`))}function J3(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),Gg(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 YO(n){return J3(Y3(n))}function XO(n,e){const t=X3(n),s=J3(t),r=Z3(t),o=e!=null&&e.skipStats?xd(r.length):bd(r);return{...s,turns:r,stats:o,rawMessages:e!=null&&e.skipStats?[]:t,agentKind:"claude"}}function JO(n,e){const t=X3(e);if(t.length===0)return n;const s=n.rawMessages,r=[...s,...t],o=ZO(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=Z3(r.slice(u)),m=Zg([...d,...f]),p=bd(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 Q3="<task-notification>",QO=/<task-id>([^<]+)<\/task-id>/g,e9=/<tool-use-id>([^<]+)<\/tool-use-id>/g;function Zs(n){return typeof n=="object"&&n!==null}function t9(n){const e=Zs(n.message)?n.message:null,t=e==null?void 0:e.content;return typeof t=="string"?[t]:Array.isArray(t)?t.filter(s=>Zs(s)&&typeof s.text=="string").map(s=>s.text):[]}function n9(n){const e=[],t=new Set,s=new Set,r=new Set;function o(i,l){if(i.includes(Q3)){for(const c of i.matchAll(QO))t.add(c[1]),l==null||l.add(c[1]);for(const c of i.matchAll(e9))t.add(c[1]),l==null||l.add(c[1])}}for(const i of n){if(i.type==="user"){const l=Zs(i.toolUseResult)?i.toolUseResult:null;if((l==null?void 0:l.status)==="async_launched"){const c=Zs(i.message)?i.message:null,d=(Array.isArray(c==null?void 0:c.content)?c.content:[]).filter(p=>Zs(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 t9(i))o(c,r);continue}if(i.type==="assistant"){const l=Zs(i.message)?i.message:null,c=Array.isArray(l==null?void 0:l.content)?l.content:[];for(const u of c){if(!Zs(u)||u.type!=="tool_use"||u.name!=="TaskStop")continue;const d=Zs(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=Zs(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 s9(n,e){return{status:"awaiting_agents",pendingQueue:e,pendingAgents:n.length,pendingAgentDescriptions:n.filter(t=>t.length>0)}}function r9(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=n9(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(Q3))continue;const d=u.operation;d==="enqueue"?e++:(d==="dequeue"||d==="remove")&&e--;continue}if(u.type==="attachment"){const d=Zs(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 s9(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 o9(n,e,t){const s=typeof n.sessionId=="string"?n.sessionId:"";return{record:{...n,sessionId:e,branchedFrom:{sessionId:s,turnIndex:t}},originalId:s}}function i9(n){return G3(n).turnStartIndices}function ej(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 x0(n){return n.includes("*** Begin Patch")&&n.includes("*** End Patch")}function a9(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=tr(n,i);if(l){if(x0(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=tr(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||!x0(u)||s.has(u)||(s.add(u),t.push(u))}return t}function b0(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 v0(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=b0(f.filePath,s),x=b0(h||f.filePath,s),b=p.split(/^@@.*$/m).filter(j=>j.trim()),v=[],y=[];for(const j of b)for(const C of j.split(`
|
|
65
|
+
`))C.startsWith("-")?v.push(C.slice(1)):C.startsWith("+")?y.push(C.slice(1)):C.startsWith(" ")&&(v.push(C.slice(1)),y.push(C.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:y.join(`
|
|
66
|
+
`)},result:null,isError:!1,timestamp:t}):f.action==="Delete File"?r.push({id:k,name:"Edit",input:{file_path:x,old_string:v.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:v.join(`
|
|
68
|
+
`),new_string:y.join(`
|
|
69
|
+
`)},result:null,isError:!1,timestamp:t})}return r}function tj(n,e,t,s,r=""){return n==="apply_patch"?v0(e,t,s,r):a9(e).flatMap((o,i)=>v0(o,`${t}:patch-${i}`,s,r))}function l9(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 Js(n){return typeof n=="object"&&n!==null}const c9=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"]]),u9=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 Os(n){if(n.startsWith("mcp__"))return n;const e=n.split(/(?:__|[.:/])+/).filter(Boolean).at(-1)??n;return c9.get(e)??(u9.has(e)?e:n)}function d9(n){const e=n==null?void 0:n.match(/Process exited with code (\d+)/);return e?e[1]!=="0":!1}function f9(n){return n==="request_user_input"||n==="request_user_input_async"}function m9(n){const t=(Array.isArray(n.questions)?n.questions:[n]).filter(s=>Js(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}:!Js(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 p9(n){return{todos:(Array.isArray(n.plan)?n.plan:[]).filter(s=>Js(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 h9(n){if(n.type!=="image"&&n.type!=="input_image"&&n.type!=="image_url")return null;const e=Js(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=Js(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 y0(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(!Js(s))continue;typeof s.text=="string"&&e.push(s.text);const r=h9(s);r&&t.push(r)}return{parts:e,text:e.join(""),images:t}}const g9=/^Script (?:completed|failed|running)\b/;function nj(n,e){Js(n)&&(n.status==="rejected"?e.push(1):n.status==="fulfilled"?nj(n.value,e):typeof n.exit_code=="number"&&e.push(n.exit_code))}function x9(n){const e=n[0]??"";if(!g9.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])nj(o,t)}return t.length>0?t.some(s=>s!==0):void 0}function qp(n){const e=y0(n);let t=Js(n)&&!Array.isArray(n)?n:null;try{const u=t??JSON.parse(e.text);Js(u)&&!Array.isArray(u)&&(t=u)}catch{}const s=t&&("output"in t||"content"in t)?y0(t.output??t.content):e,r=s===e?e.images:[...e.images,...s.images],o=Js(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??x9(e.parts)??d9(s.text));return{text:s.text,isError:c,...r.length>0?{images:r}:{}}}const b9=["# AGENTS.md instructions for ","<recommended_plugins>","<environment_context>","<permissions instructions>","<collaboration_mode>","<skills_instructions>"];function v9(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 Yg(n){try{return JSON.parse(n)}catch{return null}}function ft(n){return typeof n=="object"&&n!==null}function _i(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 mu(n,e){const t=n==null?void 0:n.content;return Array.isArray(t)?t.filter(s=>ft(s)&&s.type===e&&typeof s.text=="string").map(s=>s.text).join(`
|
|
70
|
+
`).trim():""}const y9=/^data:(image\/(?:png|jpeg|gif|webp));base64,(.+)$/is,w9=/^data:(audio\/(?:wav|x-wav|mpeg|mp4|webm|ogg));base64,(.+)$/is;function sj(n){if(typeof n!="string")return null;const e=y9.exec(n);return!(e!=null&&e[1])||!e[2]?null:{type:"image",source:{type:"base64",media_type:e[1].toLowerCase(),data:e[2]}}}function rj(n){if(typeof n!="string")return null;const e=w9.exec(n);return!(e!=null&&e[1])||!e[2]?null:{type:"audio",source:{type:"base64",media_type:e[1].toLowerCase(),data:e[2]}}}function S9(n){return Array.isArray(n.images)?n.images.map(sj).filter(e=>e!==null):[]}function k9(n){return Array.isArray(n.audio)?n.audio.map(rj).filter(e=>e!==null):[]}function oj(n){return Array.isArray(n.content)?n.content.filter(e=>ft(e)&&e.type==="input_image").map(e=>sj(e.image_url)).filter(e=>e!==null):[]}function ij(n){return Array.isArray(n.content)?n.content.filter(e=>ft(e)&&e.type==="input_audio").map(e=>rj(e.audio_url)).filter(e=>e!==null):[]}function w0(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 j9(n){var i,l;const e=mu(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 na(n){return n.split(/[\\/]/).filter(Boolean).at(-1)??null}function N9(n){if(typeof n!="string")return"";const e=n.trim();return/^gAAAAA[A-Za-z0-9_-]+$/.test(e)?"":e}function Vp(n){const e=n.trim();return!e||b9.some(t=>e.startsWith(t))?"":e}function C9(n){if(!ft(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 _9(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 Wo(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 T9(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 S0(n){if(typeof n!="string"||!n.trim())return{};try{const e=JSON.parse(n);return ft(e)?e:{value:e}}catch{return{raw:n}}}function sa(n){if(typeof n=="string")return n;try{return JSON.stringify(n)}catch{return String(n??"")}}function k0(...n){return n.find(e=>typeof e=="string")}function E9(n){return n.startsWith("exec-")}function A9(n){var r;if(!ft(n))return{text:sa(n),isError:!1};if("Err"in n)return{text:sa(n.Err),isError:!0};const e=ft(n.Ok)?n.Ok:null;if(!e)return{text:sa(n),isError:!1};const t=qp({...e,content:e.content}),s=t.text||((r=t.images)!=null&&r.length?"":e.structuredContent!==void 0?sa(e.structuredContent):sa(e));return{...t,text:s,isError:t.isError}}function P9(n,e,t){return{id:n?`${n}@${e}`:v9("codex-turn"),userMessage:null,contentBlocks:[],thinking:[],assistantText:[],toolCalls:[],subAgentActivity:[],timestamp:e,durationMs:null,tokenUsage:null,model:t}}function aj(n){return n.type==="event_msg"&&ft(n.payload)&&n.payload.type==="user_message"&&typeof n.payload.message=="string"?Vp(n.payload.message):n.type==="response_item"&&ft(n.payload)&&n.payload.type==="message"&&n.payload.role==="user"?Vp(mu(n.payload,"input_text")):""}function I9(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 aj(n)!==""||oj(e).length>0||ij(e).length>0}return!0}function lj(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(!ft(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&&ft(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 v=ft(x.payload.source)?x.payload.source:null;if(v&&ft(v.subagent)){m=!0;const k=ft(v.subagent.thread_spawn)?v.subagent.thread_spawn:null;k&&typeof k.agent_path=="string"&&(h=k.agent_path)}typeof x.payload.forked_from_id=="string"&&x.payload.forked_from_id&&(p=x.payload.forked_from_id);const y=ft(x.payload.git)?x.payload.git:null;s||(s=y&&typeof y.branch=="string"?y.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=aj(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 cj(n){for(const e of n.split(`
|
|
73
|
+
`)){const t=e.trim();if(t)return _i(Yg(t))}return!1}function $9(n){return _i(n[0]??null)}function R9(n){const e=n.map(Yg).filter(_i);return lj(e)}function uj(n,e){const t=lj(n.filter(_i)),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(T,E,A,P={}){const I=c.get(T);let O=f.get(T);if(!O){const $={agentId:T,parentToolUseId:(I==null?void 0:I.parentToolCallId)||void 0,agentName:(I==null?void 0:I.nickname)??(I!=null&&I.agentPath?na(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"};E.subAgentActivity.push($);const M=E.contentBlocks[E.contentBlocks.length-1];(M==null?void 0:M.kind)==="sub_agent"?M.messages.push($):E.contentBlocks.push({kind:"sub_agent",messages:[$],timestamp:A}),O={message:$,turn:E},f.set(T,O)}const R=O.message;if(I&&(R.parentToolUseId=I.parentToolCallId||R.parentToolUseId,R.agentName=I.nickname??(I.agentPath?na(I.agentPath):R.agentName),R.subagentType=I.agentType,R.model=I.model,R.prompt=I.message||R.prompt),P.text&&!R.text.includes(P.text)&&(R.text.push(P.text),R.content=R.text.join(`
|
|
74
|
+
|
|
75
|
+
`)),P.status){const $=new Set(["completed","failed","interrupted"]);if(P.status==="running"&&R.status&&$.has(R.status)||(R.status=P.status),$.has(P.status)&&R.timestamp&&A){const M=new Date(R.timestamp).getTime(),z=new Date(A).getTime();Number.isFinite(M)&&Number.isFinite(z)&&z>=M&&(R.durationMs=z-M)}}return R}let p=null,h=null,g=t.model||null,x="",b=null,v=!1;const y=[];let k=0,j=null,C=null;function _(T){const E=s.length,A=T9(s,T,x);return s.length>E&&C!==null&&y.push(C),C=null,A}function S(T,E,A){const P=P9(T,E,A);return C=j??k,j=null,v||(P.isFragment=!0),b&&(P.compactionSummary=b,b=null),P}function N(T,E,A,P,I){const O=o.get(E);if(O){O.input={...O.input,...A},O.result=P,O.isError=P==="failed";return}const R={id:E,name:"WebSearch",input:A,result:P,isError:P==="failed",timestamp:I};o.set(E,R),Wo(T,R,I)}for(let T=0;T<n.length;T++){const E=n[T];if(!_i(E))continue;k=T;const A=ft(E.payload)?E.payload:void 0,P=E.timestamp??"";if(E.type==="compacted"){p=_(p),b="Conversation compacted",x=P;continue}if(E.type!=="world_state"){if(E.type==="turn_context"){p=_(p),j=T,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,v=!0;continue}if(E.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=_(p)),v=!0,p??(p=S(h,P,g));const I=(Array.isArray(A.local_images)?A.local_images:[]).filter(R=>typeof R=="string"&&R.length>0),O=(Array.isArray(A.local_audio)?A.local_audio:[]).filter(R=>typeof R=="string"&&R.length>0);p.userMessage=w0(A.message,S9(A),k9(A),I,O),p.isFragment=!1,p.timestamp=p.timestamp||P,x=P;continue}if(!(!p&&!I9(E,A))){if(p??(p=S(h,P,g)),!p.model&&g&&(p.model=g),p.timestamp||(p.timestamp=P),P&&(x=P),E.type==="event_msg"&&(A==null?void 0:A.type)==="token_count"){const I=ft(A.info)?A.info:null,O=I?C9(I.last_token_usage):null;O&&(p.tokenUsage=xi(p.tokenUsage,O));continue}if(E.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),ft(A.action)&&(I.action=A.action),N(p,A.call_id,I,"completed",P);continue}if(E.type==="event_msg"&&(A==null?void 0:A.type)==="mcp_tool_call_end"&&typeof A.call_id=="string"&&ft(A.invocation)){const I=A.invocation,O=typeof I.server=="string"?I.server:"mcp",R=typeof I.tool=="string"?I.tool:"tool",$=ft(I.arguments)?I.arguments:{},M=A9(A.result),z=r.get(A.call_id);z?(z.result=M.text,z.isError=M.isError,M.images&&(z.resultImages=M.images),r.delete(A.call_id)):E9(A.call_id)||Wo(p,{id:A.call_id,name:`mcp__${O}__${R}`,input:$,result:M.text,isError:M.isError,...M.images?{resultImages:M.images}:{},timestamp:P},P);continue}if(E.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,O=typeof A.event_id=="string"?A.event_id:"",R=typeof A.kind=="string"?A.kind:"started",$=O?l.get(O):void 0,M=u.get(A.agent_path),z=c.get(I)??(M?c.get(M):void 0);if(R!=="started"&&!z&&!$)continue;if(M&&M!==I&&!f.has(I)){const L=f.get(M);L&&(L.message.agentId=I,f.delete(M),f.set(I,L)),c.delete(M)}const F={agentId:I,nickname:(z==null?void 0:z.nickname)??na(A.agent_path)??($==null?void 0:$.taskName)??null,agentPath:A.agent_path,message:(z==null?void 0:z.message)??($==null?void 0:$.message)??"",model:(z==null?void 0:z.model)??($==null?void 0:$.model)??null,agentType:(z==null?void 0:z.agentType)??($==null?void 0:$.agentType)??null,timestamp:(z==null?void 0:z.timestamp)??(P||($==null?void 0:$.timestamp)||""),parentToolCallId:(z==null?void 0:z.parentToolCallId)??O};c.set(I,F),u.set(A.agent_path,I),O&&(R==="started"||$)&&d.set(O,I),m(I,p,P,{status:R==="interrupted"?"interrupted":"running"});continue}if(!(E.type!=="response_item"||!A)){if(A.type==="reasoning"){const I=Array.isArray(A.summary)?A.summary.filter(O=>typeof O=="string").join(`
|
|
76
|
+
`):"";_9(p,I.trim(),P);continue}if(A.type==="message"&&A.role==="assistant"){ej(p,mu(A,"output_text"),P);continue}if(A.type==="message"&&A.role==="user"&&p.userMessage===null){const I=Vp(mu(A,"input_text")),O=oj(A),R=ij(A);(I||O.length>0||R.length>0)&&(p.userMessage=w0(I,O,R),p.isFragment=!1,v=!0);continue}if(A.type==="web_search_call"&&typeof A.id=="string"){const I={};ft(A.action)&&(I.action=A.action);const O=typeof A.status=="string"?A.status:"completed";N(p,A.id,I,O,P);continue}if(A.type==="tool_search_call"){const I=k0(A.call_id,A.id)??"";if(I){const O={id:I,name:"ToolSearch",input:ft(A.arguments)?A.arguments:{},result:null,isError:!1,timestamp:P};r.set(I,O),Wo(p,O,P)}continue}if(A.type==="tool_search_output"&&typeof A.call_id=="string"){const I=r.get(A.call_id);if(I){const O=Array.isArray(A.tools)?A.tools:[],R=O.filter(ft).map(z=>k0(z.name)??"").filter(Boolean),$=R.length>0?R.length:O.length,M=`Found ${$} tool${$===1?"":"s"}`;I.result=R.length>0?`${M}: ${R.join(", ")}`:M,I.isError=A.status==="failed",r.delete(A.call_id)}continue}if(A.type==="agent_message"&&typeof A.author=="string"){const I=A.author,O=typeof A.recipient=="string"?A.recipient:null,R=j9(A);if(R.messageType==="NEW_TASK")continue;const $=u.get(I),M=I.startsWith(`${t.agentPath}/`)&&(O===null||O===t.agentPath);if(!$&&!M)continue;const z=$??I;$||(c.set(z,{agentId:z,nickname:na(I),agentPath:I,message:"",model:null,agentType:null,timestamp:P,parentToolCallId:""}),u.set(I,z));let F;R.messageType==="FINAL_ANSWER"?F="completed":R.messageType==="ERROR"||R.messageType==="FAILED"?F="failed":R.messageType==="INTERRUPTED"?F="interrupted":R.messageType==="MESSAGE"&&(F="running"),m(z,p,P,{status:F,text:R.text||void 0});continue}if(A.type==="function_call"&&typeof A.call_id=="string"){const I=typeof A.name=="string"?A.name:"tool",O=Os(I),R=S0(A.arguments);let $=O,M=R;O==="exec_command"?$="Bash":O==="update_plan"?($="TodoWrite",M=p9(R)):f9(O)&&($="AskUserQuestion",M=m9(R)),O==="spawn_agent"&&l.set(A.call_id,{callId:A.call_id,message:N9(R.message),taskName:typeof R.task_name=="string"?R.task_name:null,model:typeof R.model=="string"?R.model:null,agentType:typeof R.agent_type=="string"?R.agent_type:null,timestamp:P});const z={id:A.call_id,name:$,input:M,result:null,isError:!1,timestamp:P,...O==="request_user_input_async"?{asyncQuestion:!0}:{}};r.set(z.id,z),Wo(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 O=qp(A.output),R=O.text;if(I.result=R,I.isError=O.isError,O.images&&(I.resultImages=O.images),r.delete(A.call_id),I.name==="spawn_agent"&&R)try{const $=JSON.parse(R),M=typeof $.agent_id=="string"?$.agent_id:d.get(I.id)??"",z=typeof $.task_name=="string"?$.task_name:null,F=typeof $.nickname=="string"?$.nickname:z?na(z):null;if(M){const D=l.get(I.id),L=c.get(M),B={agentId:M,nickname:F??(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(M,B),d.set(I.id,M),B.agentPath&&u.set(B.agentPath,M),m(M,p,P,{status:"running"})}}catch{}if(I.name==="wait_agent"&&R&&p)try{const $=JSON.parse(R),M=ft($.status)?$.status:{};for(const[z,F]of Object.entries(M)){const D=ft(F)?F:{},L=typeof D.completed=="string"?D.completed:"",B=typeof D.failed=="string"?D.failed:typeof D.error=="string"?D.error:"",U=typeof D.interrupted=="string"?D.interrupted:"",W=L?"completed":B?"failed":U?"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:W,text:L||B||U||void 0})}}catch{}continue}if(A.type==="custom_tool_call"&&typeof A.call_id=="string"){const I=Os(typeof A.name=="string"?A.name:"tool"),O=typeof A.input=="string"?A.input:"",R=A.call_id,$=O?tj(I,O,R,P,t.cwd):[];if(I!=="apply_patch"){const M={id:R,name:I==="exec_command"?"Bash":I,input:S0(O),result:null,isError:!1,timestamp:P};r.set(M.id,M),Wo(p,M,P)}for(const M of $)r.set(M.id,M),Wo(p,M,P);$.length>0&&i.set(R,{calls:$,direct:I==="apply_patch"});continue}if(A.type==="custom_tool_call_output"&&typeof A.call_id=="string"){const I=A.call_id,{text:O,isError:R,images:$}=qp(A.output),M=i.get(I);if(M){const F=M.direct&&R?new Set(M.calls.map(D=>D.id)):l9(O,R,M.calls);for(const D of M.calls){const L=r.get(D.id);L&&(L.result=O,L.isError=F.has(L.id),r.delete(L.id))}i.delete(I)}const z=r.get(I);z&&(z.result=O,z.isError=R,$&&(z.resultImages=$),r.delete(I));continue}}}}}return _(p),{turnStartIndices:y,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?xd(s.length):bd(s),rawMessages:e!=null&&e.skipStats?[]:n,branchedFrom:t.branchedFrom,agentKind:"codex"}}function Xg(n,e){const t=n.split(`
|
|
77
|
+
`).map(o=>o.trim()).filter(Boolean).map(Yg).filter(_i),{turnStartIndices:s,...r}=uj(t,e);return r}function O9(n,e){const t=n.rawMessages.map(s=>JSON.stringify(s)).join(`
|
|
78
|
+
`);return Xg(t?`${t}
|
|
79
|
+
${e}`:e)}const M9=new Set(["FINAL_ANSWER","ERROR","FAILED","INTERRUPTED"]);function L9(n){const e=n.content;return Array.isArray(e)?e.filter(t=>ft(t)&&t.type==="input_text"&&typeof t.text=="string").map(t=>t.text).join(`
|
|
80
|
+
`):""}function cc(n){if(typeof n!="string")return null;try{const e=JSON.parse(n);return ft(e)?e:null}catch{return null}}function z9(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=ft(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=Os(typeof f.name=="string"?f.name:"");if(m==="spawn_agent"){const p=cc(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=cc(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=cc(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=cc(f.output),h=ft(p==null?void 0:p.status)?p.status:{};for(const[g,x]of Object.entries(h)){const b=ft(x)?x:{},v=typeof b.status=="string"?b.status:"";(typeof b.completed=="string"||typeof b.failed=="string"||typeof b.error=="string"||typeof b.interrupted=="string"||v==="completed"||v==="failed"||v==="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=L9(f).match(/^Message Type:\s*([^\r\n]+)/))==null?void 0:c[1])==null?void 0:u.trim().toUpperCase())??"";if(!M9.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 D9(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=z9(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?Os(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 F9(n,e,t){const s=ft(n.payload)?{...n.payload}:{},r=typeof s.id=="string"?s.id:"";return s.id=e,s.branchedFrom={sessionId:r,turnIndex:t},{record:{...n,payload:s},originalId:r}}function U9(n){return uj(n,{skipStats:!0}).turnStartIndices}const B9=/^(?: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 an(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function dj(n){return typeof n.agentId!="string"||n.agentId.length===0}function fj(n){return!an(n)||typeof n.type!="string"||!an(n.data)?!1:n.type==="abort"||n.type==="binary_asset"||n.type==="user.message"||B9.test(n.type)}function mj(n){try{const e=JSON.parse(n);return fj(e)?e:null}catch{return null}}function W9(n){return n.split(`
|
|
81
|
+
`).map(e=>e.trim()).filter(Boolean).map(mj).filter(e=>e!==null)}function Ae(...n){return n.find(e=>typeof e=="string")??""}function hr(n){return typeof n=="number"&&Number.isFinite(n)?n:0}function ma(n){return typeof n.timestamp=="string"?n.timestamp:""}function zr(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 j0(n){const e=zr(n,"copilot-turn"),t=Ae(n.data.turnId);return t?`${t}@${e}`:e}function yf(n,e){if(!an(n))return;const t=Ae(n.cwd),s=Ae(n.branch);t&&(e.cwd=t),s&&(e.gitBranch=s)}function pj(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(!dj(t))continue;const{data:s}=t,r=ma(t);if(r&&(e.lastTimestamp=r),t.type==="session.start"){e.sessionId||(e.sessionId=Ae(s.sessionId)),e.version||(e.version=Ae(s.copilotVersion)||(typeof s.version=="number"?String(s.version):Ae(s.version))),yf(s.context,e),e.model=Ae(s.selectedModel)||e.model;continue}if(t.type==="session.resume"){yf(s.context,e),e.model=Ae(s.selectedModel)||e.model;continue}if(t.type==="session.context_changed"){yf(s,e);continue}if(t.type==="session.auto_mode_resolved"){e.model=Ae(s.chosenModel)||e.model;continue}if(t.type==="session.model_change"){e.model=Ae(s.newModel)||e.model;continue}if(t.type==="session.title_changed"){e.name=Ae(s.title)||e.name;continue}if(t.type==="session.shutdown"){e.model=Ae(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=Ae(s.model)||e.model),t.type!=="user.message")continue;e.turnCount++,e.timestamp||(e.timestamp=r);const o=Ae(s.content).trim();o&&(e.firstUserMessage||(e.firstUserMessage=o),e.lastUserMessage=o)}return e.lastTimestamp||(e.lastTimestamp=e.timestamp),e}function q9(n){for(const e of n.split(`
|
|
82
|
+
`)){const t=e.trim();if(t)try{const s=JSON.parse(t);if(fj(s))return!0}catch{}}return!1}function V9(n){var e;return oM((e=n[0])==null?void 0:e.type)}function H9(n){const e=n.map(t=>mj(t.trim())).filter(t=>t!==null);return pj(e)}function wf(n){if(typeof n=="string")return n;if(n===void 0)return"";try{return JSON.stringify(n)}catch{return String(n)}}function N0(n){return typeof n=="string"?n:Array.isArray(n)?n.flatMap(e=>{const t=typeof e=="string"?e:an(e)?Ae(e.text,e.content):"";return t?[t]:[]}).join(`
|
|
83
|
+
`):""}function K9(n){const e=new Map;for(const t of n){if(t.type!=="session.binary_asset"&&t.type!=="binary_asset")continue;const s=Ae(t.data.assetId),r=Ae(t.data.data),o=Ae(t.data.mimeType);s&&r&&o&&e.set(s,{data:r,mimeType:o})}return e}function G9(n,e){if(!an(n))return null;const t=e.get(Ae(n.assetId)),s=Ae(n.mimeType,t==null?void 0:t.mimeType).toLowerCase(),r=Ae(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 hj(n,e){if(!Array.isArray(n))return[];const t=[],s=new Set;for(const r of n){const o=G9(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 Z9(n,e){const t=Ae(n.content),s=hj(n.attachments,e);return s.length===0?t:[...s,...t?[{type:"text",text:t}]:[]]}function Y9(n,e){return an(n.result)?hj([...Array.isArray(n.result.contents)?n.result.contents:[],...Array.isArray(n.result.binaryResultsForLlm)?n.result.binaryResultsForLlm:[]],e):[]}function Hp(n,e=!1){const t=hr(n.cacheWriteTokens),s=hr(n.cacheReadTokens),r=hr(n.inputTokens),o={input_tokens:e?Math.max(0,r-t-s):r,output_tokens:hr(n.outputTokens),cache_creation_input_tokens:t,cache_read_input_tokens:s},i=hr(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 X9(n){if(!an(n.modelMetrics))return null;let e=null;for(const t of Object.values(n.modelMetrics)){if(!an(t)||!an(t.usage))continue;const s=Hp(t.usage,!0);s&&(e=xi(e,s))}return e}function J9(n){if(typeof n=="string")return{label:n};if(!an(n))return null;const e=Ae(n.label,n.title,n.value,n.name);if(!e)return null;const t=Ae(n.description);return t?{label:e,description:t}:{label:e}}function Q9(n){return Array.isArray(n)?n.map(J9).filter(e=>e!==null):[]}function eM(n){if(!an(n))return null;const e=Ae(n.question,n.prompt,n.text,n.message);if(!e)return null;const t=Ae(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:Q9(n.options??n.choices),...s===void 0?{}:{multiSelect:s}}}function tM(n){const t=(Array.isArray(n.questions)?n.questions:[n]).map(eM).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 pu(n,e){const t=an(e)?e:e===void 0?{}:{value:e};return n==="AskUserQuestion"?tM(t):n==="Edit"?{...t,file_path:Ae(t.file_path,t.path),old_string:Ae(t.old_string,t.old_str),new_string:Ae(t.new_string,t.new_str)}:n==="Write"?{...t,file_path:Ae(t.file_path,t.path),content:Ae(t.content,t.file_text)}:n==="Bash"&&typeof t.command!="string"&&typeof t.cmd=="string"?{...t,command:t.cmd}:t}function nM(n){const e=n.error;if(typeof e=="string")return e;if(an(e)){const s=Ae(e.message,e.code);if(s)return s}const t=n.result;if(typeof t=="string")return t;if(!an(t))return t===void 0?"":wf(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:an(r)?Ae(r.text,r.content,r.output):"";return o?[o]:[]}).join(`
|
|
84
|
+
`);if(s)return s}return t.structuredContent!==void 0?wf(t.structuredContent):wf(t)}function C0(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 uc(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 ha(n,e,t,s){return{id:n,name:e,input:t,result:null,isError:!1,timestamp:s}}function _0(n,e,t){if(!Array.isArray(n))return[];const s=[];for(const r of n){if(!an(r))continue;const o=Ae(r.toolCallId),i=Ae(r.name);if(!o||!i||t(o))continue;const l=pa(i);s.push(ha(o,l,pu(l,r.arguments),e))}return s}function T0(n,e,t,s){n.name=e,n.input=pu(e,t),n.timestamp=s||n.timestamp}function E0(n,e,t){n.result=nM(e);const s=Y9(e,t);s.length>0&&(n.resultImages=s),n.isError=e.success===!1||e.error!==void 0&&e.error!==null}function A0(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 sM(n){return n.userMessage!==null||n.assistantText.length>0||n.thinking.length>0||n.toolCalls.length>0||n.subAgentActivity.length>0}function gj(n,e){const t=W9(n),s=pj(t),r=K9(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(_,S){S&&u.set(_,S)}function v(_){return f||(f=A0(j0(_),ma(_),null,m,p,!0)),f}function y(){f&&(sM(f)&&o.push(f),f=null)}function k(_){var O;const S=typeof _.agentId=="string"?_.agentId:"";if(!S)return null;const N=l.get(S);if(N)return N.message;const T=_.data,E=Ae(T.toolCallId),A=E?((O=i.get(E))==null?void 0:O.turn)??f:f;if(!A)return null;const P=Ae(T.executionMode),I={agentId:S,...E?{parentToolUseId:E}:{},agentName:Ae(T.agentDisplayName,T.agentName)||null,subagentType:Ae(T.agentType,T.agentName)||null,type:"assistant",content:null,toolCalls:[],thinking:[],text:[],timestamp:ma(_),tokenUsage:null,model:Ae(T.model)||null,isBackground:P==="background",...Ae(T.description)?{prompt:Ae(T.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(_){if(dj(_))return!1;const S=k(_);if(!S)return!0;const{data:N}=_,T=ma(_);if(_.type==="subagent.started"||_.type==="subagent.configured")return S.parentToolUseId||(S.parentToolUseId=Ae(N.toolCallId)||void 0),S.agentName=Ae(N.agentDisplayName,N.agentName)||S.agentName,S.subagentType=Ae(N.agentType,N.agentName)||S.subagentType,S.model=Ae(N.model)||S.model,S.prompt||(S.prompt=Ae(N.description)||void 0),S.isBackground||(S.isBackground=Ae(N.executionMode)==="background"),S.status="running",!0;if(_.type==="subagent.completed"||_.type==="subagent.failed"){S.agentName=Ae(N.agentDisplayName,N.agentName)||S.agentName,S.subagentType=Ae(N.agentType,N.agentName)||S.subagentType,S.model=Ae(N.model)||S.model,S.durationMs=hr(N.durationMs)||S.durationMs,S.toolUseCount=hr(N.totalToolCalls)||S.toolUseCount,S.status=_.type==="subagent.completed"?"completed":"failed";const E=Ae(N.error,N.message);return E&&!S.text.includes(E)&&S.text.push(E),!0}if(_.type==="user.message")return S.prompt||(S.prompt=Ae(N.content)||void 0),!0;if(_.type==="assistant.reasoning"){const E=Ae(N.content);return E&&!S.thinking.includes(E)&&S.thinking.push(E),!0}if(_.type==="assistant.message"){S.model=Ae(N.model)||S.model;const E=Ae(N.reasoningText);E&&!S.thinking.includes(E)&&S.thinking.push(E);const A=N0(N.content);A&&!S.text.includes(A)&&S.text.push(A);for(const P of _0(N.toolRequests,T,I=>c.has(I)))S.toolCalls.push(P),c.set(P.id,{call:P,message:S});return!0}if(_.type==="assistant.usage"){S.model=Ae(N.model)||S.model;const E=Hp(N);return E&&(S.tokenUsage=xi(S.tokenUsage,E)),!0}if(_.type==="tool.execution_start"){const E=Ae(N.toolCallId)||zr(_,"copilot-agent-tool"),A=Ae(N.toolName)||"Tool",P=pa(A),I=c.get(E);if(I)T0(I.call,P,N.arguments,T);else{const O=ha(E,P,pu(P,N.arguments),T);S.toolCalls.push(O),c.set(E,{call:O,message:S})}return!0}if(_.type==="tool.execution_complete"){const E=Ae(N.toolCallId)||zr(_,"copilot-agent-tool");let A=c.get(E);if(!A){const P=Ae(N.toolName)||"Tool",I=pa(P),O=ha(E,I,{},T);S.toolCalls.push(O),A={call:O,message:S}}return E0(A.call,N,r),c.delete(E),!0}return!0}for(const _ of t){if(j(_))continue;const{data:S}=_,N=ma(_);if(_.type==="session.start"||_.type==="session.resume"){m=Ae(S.selectedModel)||m,p=Ae(S.reasoningEffort)||p;continue}if(_.type==="session.auto_mode_resolved"){m=Ae(S.chosenModel)||m,f&&(f.model=m);continue}if(_.type==="session.model_change"){m=Ae(S.newModel)||m;const T=S.reasoningEffort;typeof T=="string"&&(p=T),f&&(f.model=m,p&&(f.effort=p));continue}if(_.type==="session.shutdown"){m=Ae(S.currentModel)||m,f&&!f.model&&(f.model=m),x=X9(S)??x;const T=hr(S.totalApiDurationMs);f&&!g&&T&&d.set(f,T);continue}if(_.type==="user.message"){y(),f=A0(j0(_),N,Z9(S,r),m,p,!1),b(f,N);continue}if(_.type==="assistant.turn_start"){m=Ae(S.model)||m;const T=v(_);T.model=m,p&&(T.effort=p),b(T,N);continue}if(_.type==="assistant.reasoning"){const T=v(_);C0(T,Ae(S.content),N,Ae(S.reasoningId)||zr(_,"copilot-thinking")),b(T,N);continue}if(_.type==="assistant.message"){m=Ae(S.model)||m;const T=v(_);T.model=m,p&&(T.effort=p),C0(T,Ae(S.reasoningText),N,zr(_,"copilot-thinking")),ej(T,N0(S.content),N);for(const E of _0(S.toolRequests,N,A=>i.has(A)))uc(T,E,N),i.set(E.id,{call:E,turn:T});b(T,N);continue}if(_.type==="assistant.usage"){m=Ae(S.model)||m,p=Ae(S.reasoningEffort)||p;const T=Hp(S),E=hr(S.duration);T&&(h=!0),E&&(g=!0);const A=v(_);A.model=m,p&&(A.effort=p),T&&(A.tokenUsage=xi(A.tokenUsage,T)),E&&d.set(A,(d.get(A)??0)+E),b(A,N);continue}if(_.type==="tool.execution_start"){m=Ae(S.model)||m;const T=v(_);T.model=m;const E=Ae(S.toolCallId)||zr(_,"copilot-tool"),A=Ae(S.toolName)||"Tool",P=pa(A),I=i.get(E);if(I)T0(I.call,P,S.arguments,N);else{const O=ha(E,P,pu(P,S.arguments),N);uc(T,O,N),i.set(E,{call:O,turn:T})}b(T,N);continue}if(_.type==="tool.execution_complete"){m=Ae(S.model)||m;const T=Ae(S.toolCallId)||zr(_,"copilot-tool");let E=i.get(T);if(!E){const A=v(_),P=Ae(S.toolName)||"Tool",I=pa(P),O=ha(T,I,{},N);uc(A,O,N),E={call:O,turn:A}}E0(E.call,S,r),i.delete(T),b(E.turn,N);continue}if(_.type==="session.error"){const T=v(_),A={errorType:Ae(S.errorType)||"unknown"};typeof S.statusCode=="number"&&(A.statusCode=S.statusCode),typeof S.errorCode=="string"&&(A.errorCode=S.errorCode),uc(T,{id:zr(_,"copilot-error"),name:"Error",input:A,result:Ae(S.message)||"Copilot session error",isError:!0,timestamp:N},N),b(T,N);continue}(_.type==="assistant.turn_end"||_.type==="assistant.idle"||_.type==="session.idle")&&f&&b(f,N)}if(y(),!h&&x&&o.length===1&&(o[0].tokenUsage=xi(o[0].tokenUsage,x)),s.model)for(const _ of o)_.model||(_.model=s.model);for(const _ of o){const S=u.get(_),N=Date.parse(_.timestamp),T=S?Date.parse(S):Number.NaN;if(Number.isFinite(N)&&Number.isFinite(T)&&T>=N)_.durationMs=T-N;else{const E=d.get(_)??0;E&&(_.durationMs=E)}}const C=e!=null&&e.skipStats?xd(o.length):bd(o);return!(e!=null&&e.skipStats)&&!h&&x&&o.length>1&&(C.totalInputTokens=x.input_tokens,C.totalOutputTokens=x.output_tokens,C.totalCacheCreationTokens=x.cache_creation_input_tokens??0,C.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:C,rawMessages:e!=null&&e.skipStats?[]:t,agentKind:"copilot"}}function rM(n,e){const t=n.rawMessages.map(s=>JSON.stringify(s)).join(`
|
|
85
|
+
`);return gj(t?`${t}
|
|
86
|
+
${e}`:e)}function oM(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 iM(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=an(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=an(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=an(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"?Os(i.toolName):typeof i.name=="string"?Os(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 aM(){throw new Error("Copilot sessions branch through the CLI's fork API, not by copying the transcript")}function lM(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 xj=no[no.length-1],cM={kind:"codex",descriptor:es("codex"),detectsText:cj,detectsRecords:$9,parse:Xg,append:O9,metadataFromLines:R9,status:D9,brandBranch:F9,turnBoundaries:U9},uM={kind:"copilot",descriptor:es("copilot"),detectsText:q9,detectsRecords:V9,parse:gj,append:rM,metadataFromLines:H9,status:iM,brandBranch:aM,turnBoundaries:lM},dM={kind:"claude",descriptor:es("claude"),detectsText:g0,detectsRecords:g0,parse:XO,append:JO,metadataFromLines:YO,status:r9,brandBranch:o9,turnBoundaries:i9},Bc=Object.freeze({claude:dM,codex:cM,copilot:uM});function bj(n){for(const e of no)if(n(Bc[e]))return Bc[e];return Bc[xj]}function vj(n){return Bc[n]}function yj(n){return bj(e=>e.detectsText(n))}function wj(n){return bj(e=>e.detectsRecords(n))}function Jg(n,e){return n.turnBoundaries(e.map(fM))}function fM(n){try{const e=JSON.parse(n);return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function Sj(n,e,t){return Jg(n,e)[t]??e.length}function mM(n,e){const t=Jg(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 pM(n){return Kg(n)?W3(n.input):[n]}function hM(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 gM(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 xM(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 bM(n){for(let e=n.toolCalls.length-1;e>=0;e--){const t=n.toolCalls[e];if(!t.asyncQuestion||t.isError)continue;if(xM(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 vM(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||hM(n,s)||t.isError&&gM(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 kj(n){const{turns:e}=n;if(e.length===0)return null;const t=e[e.length-1];return!t||t.toolCalls.length===0?null:vM(e,t)??bM(t)}function yM(n){return typeof n=="string"?n:n.filter(e=>e.type==="text").map(e=>e.text).join(`
|
|
88
|
+
`)}function yd(n,e){return yj(n).parse(n,e)}function wM(n,e){const t=wj(n.rawMessages);return(t.kind===xj?yj(e):t).append(n,e)}function wd(n){return n===null?"":typeof n=="string"?n:yM(n)}function jj(n){return n===null||typeof n=="string"?[]:n.filter(e=>e.type==="image")}const Nj=w.createContext(null);function SM(n){const e=[];for(let t=0;t<n.length;t+=1){const s=n[t],r=jj(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 kM(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(qg,{open:r.open,images:r.images,initialIndex:r.index,onClose:()=>o(jM),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(Nj.Provider,{value:u,children:[s,d]}),e[6]=s,e[7]=d,e[8]=u,e[9]=f):f=e[9],f}function jM(n){return n?{...n,open:!1}:null}function NM(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=SM(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(kM,{images:i,children:t}),e[4]=t,e[5]=i,e[6]=l):l=e[6],l}function Cj(){return w.useContext(Nj)}const CM={".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"},_M={".mp4":"video/mp4",".m4v":"video/x-m4v",".webm":"video/webm",".mov":"video/quicktime"},_j=new Set(Object.keys(CM)),Tj=new Set(Object.keys(_M));function Ej(n,e){if(!n)return!1;const t=n.lastIndexOf(".");return t!==-1&&e.has(n.slice(t).toLowerCase())}function TM(n){return Ej(n,_j)}function Aj(n){return Ej(n,Tj)}function Pj(n){return!n||n.startsWith("http://")||n.startsWith("https://")||n.startsWith("data:")?!1:n.startsWith("/")}function Qg(n){return Pj(n)&&TM(n)}function Ij(n){return Pj(n)&&Aj(n)}function $j(n){return Qg(n)||Ij(n)?ml(`/api/local-file?path=${encodeURIComponent(n)}`):n}function Kp(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=Wn("hostFiles"),[u,d]=w.useState(!1),[f,m]=w.useState(!1),[p,h]=w.useState(),g=Cj();let x;e[0]!==c||e[1]!==t?(x=Qg(t)&&!c,e[0]=c,e[1]=t,e[2]=x):x=e[2];const b=x;let v;e[3]!==b||e[4]!==t?(v=b?void 0:$j(t),e[3]=b,e[4]=t,e[5]=v):v=e[5];const y=v;let k;e[6]!==s||e[7]!==l||e[8]!==y?(k=y?{id:l,src:y,alt:s??"Rendered image",label:s||"Rendered image"}:null,e[6]=s,e[7]=l,e[8]=y,e[9]=k):k=e[9];const j=k;let C;e[10]!==g||e[11]!==j?(C=()=>{j&&(g?g.openImage(j):(m(!0),d(!0)))},e[10]=g,e[11]=j,e[12]=C):C=e[12];const _=C;if(b){let M;return e[13]!==s?(M=s?a.jsx("span",{className:"text-muted-foreground",children:s}):null,e[13]=s,e[14]=M):M=e[14],M}if(y&&p===y){const M=s?`: ${s}`:"";let z;return e[15]!==M?(z=a.jsxs("span",{role:"status",className:"my-3 block text-xs text-muted-foreground",children:["Image unavailable",M]}),e[15]=M,e[16]=z):z=e[16],z}const S=`Open ${s||"rendered image"}`;let N;e[17]!==o?(N=K("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]=N):N=e[18];const T=s??"";let E;e[19]!==y?(E=()=>h(y),e[19]=y,e[20]=E):E=e[20];let A;e[21]!==i?(A=K("max-h-96 max-w-full rounded-lg object-contain",i),e[21]=i,e[22]=A):A=e[22];let P;e[23]!==y||e[24]!==A||e[25]!==T||e[26]!==E?(P=a.jsx("img",{src:y,alt:T,loading:"lazy",decoding:"async",onError:E,className:A}),e[23]=y,e[24]=A,e[25]=T,e[26]=E,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-white/10 bg-black/45 text-white/70 opacity-80 backdrop-blur transition-[color,background-color,opacity] group-hover/image:bg-black/65 group-hover/image:text-white sm:opacity-0 sm:group-hover/image:opacity-100 sm:group-focus-visible/image:opacity-100",children:a.jsx(Yu,{className:"size-3.5","data-icon":"icon"})}),e[28]=I):I=e[28];let O;e[29]!==_||e[30]!==P||e[31]!==S||e[32]!==N?(O=a.jsxs(J,{type:"button",variant:"ghost",onClick:_,"aria-label":S,className:N,children:[P,I]}),e[29]=_,e[30]=P,e[31]=S,e[32]=N,e[33]=O):O=e[33];let R;e[34]!==u||e[35]!==f||e[36]!==j?(R=f&&j&&a.jsx(qg,{open:u,images:[j],initialIndex:0,onClose:()=>d(!1),onCloseComplete:()=>m(!1)}),e[34]=u,e[35]=f,e[36]=j,e[37]=R):R=e[37];let $;return e[38]!==O||e[39]!==R?($=a.jsxs(a.Fragment,{children:[O,R]}),e[38]=O,e[39]=R,e[40]=$):$=e[40],$}function EM(n){const e=q.c(21),{src:t,alt:s,className:r}=n,o=Wn("hostFiles"),[i,l]=w.useState();let c;e[0]!==o||e[1]!==t?(c=Ij(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:$j(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 v;return e[8]!==b?(v=a.jsxs("span",{role:"status",className:"my-3 block text-xs text-muted-foreground",children:["Video unavailable",b]}),e[8]=b,e[9]=v):v=e[9],v}let m;e[10]!==r?(m=K("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 AM(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=K("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 PM(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=K("[&_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 IM(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=K("[&_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 $M(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=K("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 RM(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=K("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 OM(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=K("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 MM(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 LM(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=Wn("hostFiles");let i;e[4]!==s?(i=MM(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?Ka(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 zM=[..._j,...Tj].map(n=>n.slice(1)).join("|"),DM=new RegExp(`^([ \\t]*)(\\/[^\\s]+\\.(?:${zM}))[ \\t]*$`,"gim");function Rj(n){return n.replace(DM,(e,t,s)=>`${t}`)}function FM(n){const e=q.c(3),{src:t,alt:s}=n;let r;return e[0]!==s||e[1]!==t?(r=Aj(t)?a.jsx(EM,{src:t,alt:s}):a.jsx(Kp,{src:t,alt:s}),e[0]=s,e[1]=t,e[2]=r):r=e[2],r}const cr={code:b3,pre({children:n}){return a.jsx(a.Fragment,{children:n})},a:LM,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(Zt,{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(AM,{className:"border-collapse text-sm",children:n})})},thead({children:n}){return a.jsx(PM,{className:"bg-muted/50",children:n})},tbody({children:n}){return a.jsx(IM,{children:n})},tr({children:n}){return a.jsx($M,{className:"even:bg-muted/20",children:n})},th({children:n}){return a.jsx(RM,{className:"h-9 px-3 py-2 text-xs font-medium text-muted-foreground",children:n})},td({children:n}){return a.jsx(OM,{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:FM,input({checked:n,...e}){return a.jsx("input",{type:"checkbox",checked:n,readOnly:!0,className:"mr-2 rounded border-border accent-primary",...e})}},ur=[kA],UM=["system-reminder","local-command-caveat","command-name","command-message","command-args","env","claude_background_info","fast_mode_info","gitStatus","user-prompt-submit-hook"],BM=UM.join("|");function Oj(){return new RegExp(`<(${BM})[^>]*>[\\s\\S]*?<\\/\\1>`,"g")}function Mj(n){return n.replace(Oj(),"").trim()}function WM(n){return Oj().test(n)}const qM=/<command-message>([^<]+)<\/command-message>/,VM=/<command-name>([\s\S]*?)<\/command-name>/,HM=/<command-args>([\s\S]*?)<\/command-args>/;function Lj(n){const e=n.match(qM);if(e)return e[1];const t=n.match(VM);return t?t[1].trim().replace(/^\//,""):null}function zj(n){const e=n.match(HM);if(!e)return null;const t=e[1].trim();return t.length>0?t:null}const Dj={"local-command-stdout":"stdout","local-command-stderr":"stderr","bash-input":"input","bash-stdout":"stdout","bash-stderr":"stderr"},KM=new RegExp(`<(${Object.keys(Dj).join("|")})>([\\s\\S]*?)<\\/\\1>`,"g");function GM(n){const e=[],t=n.replace(KM,(s,r,o)=>(e.push({text:Vk(o).trim(),stream:Dj[r]}),"")).trim();return{outputs:e,remainingText:t}}const ZM=/<task-notification>([\s\S]*?)<\/task-notification>/g;function qo(n,e){const t=n.match(new RegExp(`<${e}>([\\s\\S]*?)<\\/${e}>`));return t?t[1].trim():""}function e1(n){const e=[],t=n.replace(ZM,(s,r)=>(e.push({taskId:qo(r,"task-id"),toolUseId:qo(r,"tool-use-id"),outputFile:qo(r,"output-file"),status:qo(r,"status"),summary:qo(r,"summary"),result:qo(r,"result")}),"")).trim();return{notifications:e,remainingText:t}}const YM=/\[Request interrupted by user[^\]]*\]/g;function XM(n){const e=[],t=n.replace(YM,s=>(e.push(s),"")).trim();return{interrupts:e,remainingText:t}}const P0="[SYSTEM NOTIFICATION - NOT USER INPUT]";function JM(n){const e=n.indexOf(P0);if(e===-1)return{text:n,isSystemNotification:!1};const t=e+P0.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 I0={Icon:G$,color:"text-destructive",bg:"border-destructive/20 bg-destructive/5",badgeVariant:"destructive"},$0={completed:{Icon:K$,color:"text-success",bg:"border-success/20 bg-success/5",badgeVariant:"secondary",label:"Completed"},failed:{...I0,label:"Failed"},error:{...I0,label:"Error"},running:{Icon:Z$,color:"text-warning",bg:"border-warning/20 bg-warning/5",badgeVariant:"outline",label:"Running"}};function Fj(n){const e=q.c(32),{notification:t}=n,[s,r]=w.useState(!1),o=$0[t.status]??$0.running,{Icon:i}=o,l=t.result.length>0||t.outputFile.length>0,c=s?It:at;let u;e[0]!==o.bg?(u=K("my-1 rounded-lg border p-3",o.bg),e[0]=o.bg,e[1]=u):u=e[1];let d;e[2]!==o.color?(d=K("mt-0.5 size-4 shrink-0",o.color),e[2]=o.color,e[3]=d):d=e[3];let f;e[4]!==i||e[5]!==d?(f=a.jsx(i,{className:d}),e[4]=i,e[5]=d,e[6]=f):f=e[6];let m;e[7]!==t.summary?(m=a.jsx("span",{className:"text-sm font-medium text-foreground",children:t.summary}),e[7]=t.summary,e[8]=m):m=e[8];let p;e[9]!==o.badgeVariant||e[10]!==o.color||e[11]!==o.label?(p=a.jsx(Fe,{variant:o.badgeVariant,className:o.color,children:o.label}),e[9]=o.badgeVariant,e[10]=o.color,e[11]=o.label,e[12]=p):p=e[12];let h;e[13]!==m||e[14]!==p?(h=a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[m,p]}),e[13]=m,e[14]=p,e[15]=h):h=e[15];let g;e[16]!==c||e[17]!==s||e[18]!==l||e[19]!==t.outputFile||e[20]!==t.result?(g=l&&a.jsxs(a.Fragment,{children:[a.jsxs(ds,{render:a.jsx(J,{type:"button",variant:"ghost",size:"xs",className:"mt-1.5 -ml-2 text-muted-foreground"}),children:[a.jsx(c,{"data-icon":"inline-start"}),s?"Hide detail":"Show detail"]}),a.jsx(Sn,{children:a.jsxs("div",{className:"mt-2 border-t border-border/30 pt-2 text-sm text-foreground/90",children:[t.result&&a.jsx(sr,{components:cr,remarkPlugins:ur,children:t.result}),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[16]=c,e[17]=s,e[18]=l,e[19]=t.outputFile,e[20]=t.result,e[21]=g):g=e[21];let x;e[22]!==h||e[23]!==g?(x=a.jsxs("div",{className:"min-w-0 flex-1",children:[h,g]}),e[22]=h,e[23]=g,e[24]=x):x=e[24];let b;e[25]!==f||e[26]!==x?(b=a.jsxs("div",{className:"flex items-start gap-2",children:[f,x]}),e[25]=f,e[26]=x,e[27]=b):b=e[27];let v;return e[28]!==s||e[29]!==u||e[30]!==b?(v=a.jsx(wn,{open:s,onOpenChange:r,className:u,children:b}),e[28]=s,e[29]=u,e[30]=b,e[31]=v):v=e[31],v}function QM(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}=e1(t);if(l.length===0){o=null;break e}s="flex flex-col",r=l.map(eL)}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 eL(n,e){return a.jsx(Fj,{notification:n},n.taskId||`notification-${e}`)}function tL(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=K("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(at,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}):a.jsx(yi,{className:K("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 nL(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(Hk,{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(sr,{components:cr,remarkPlugins:ur,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 t1=w.memo(function({content:e,timestamp:t,onEditCommand:s,onExpandCommand:r,compact:o=!1}){const i=Cj(),[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,v]=w.useState(null),y=w.useMemo(()=>wd(e),[e]),k=w.useMemo(()=>Lj(y),[y]),j=w.useMemo(()=>zj(y),[y]),{sender:C,body:_,matched:S}=w.useMemo(()=>Xa(y),[y]),N=w.useMemo(()=>Mj(_),[_]),{text:T,isSystemNotification:E}=w.useMemo(()=>JM(N),[N]),{notifications:A,remainingText:P}=w.useMemo(()=>e1(T),[T]),{outputs:I,remainingText:O}=w.useMemo(()=>GM(P),[P]),{interrupts:R,remainingText:$}=w.useMemo(()=>XM(O),[O]),M=w.useCallback(async H=>{if(!H){m(!1);return}if(p!==null){m(!0);return}if(!(!r||!k)){x(!0),m(!0);try{const G=await r(k,j??void 0);h(G)}finally{x(!1)}}},[p,r,k,j]),z=w.useMemo(()=>jj(e),[e]),F=w.useMemo(()=>z.map(H=>`data:${H.source.media_type};base64,${H.source.data}`),[z]),D=w.useMemo(()=>F.map((H,G)=>({id:`message-attachment-${G}`,src:H,alt:`Attachment ${G+1}`,label:F.length>1?`Attachment ${G+1}`:"Attached image"})),[F]),L=w.useMemo(()=>WM(y)||E||S,[y,E,S]),B=u?y:$,W=B.length>500&&!l?B.slice(0,500)+"...":B,V=H=>{const G=D[H];G&&(i?i.openImage(G):v({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(J,{type:"button",variant:"ghost",size:"xs",onClick:()=>d(!u),className:"-ml-2 text-muted-foreground",children:u?a.jsxs(a.Fragment,{children:[a.jsx(Xu,{"data-icon":"inline-start"})," Hide raw"]}):a.jsxs(a.Fragment,{children:[a.jsx(Mi,{"data-icon":"inline-start"})," Show raw"]})})}),!u&&E&&a.jsx("div",{className:"mb-2",children:a.jsxs(Fe,{variant:"outline",className:"text-muted-foreground",children:[a.jsx(yi,{"data-icon":"inline-start"}),"System event"]})}),!u&&S&&a.jsx("div",{className:"mb-2",children:a.jsxs(Fe,{variant:"outline",className:"text-muted-foreground",children:[a.jsx(Bs,{"data-icon":"inline-start"}),C?`From ${C}`:"Teammate message"]})}),k&&a.jsxs(wn,{open:f,onOpenChange:H=>void M(H),className:"mb-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(Fe,{variant:"outline",className:"font-mono text-foreground",children:[a.jsx(yi,{"data-icon":"inline-start"}),"/",k,j&&a.jsx("span",{className:"text-muted-foreground",children:j})]}),r&&a.jsxs(ds,{render:a.jsx(J,{type:"button",variant:"ghost",size:"xs",className:"text-muted-foreground"}),children:[f?a.jsx(It,{"data-icon":"inline-start"}):a.jsx(at,{"data-icon":"inline-start"}),f?"Collapse":"Expand"]}),f&&s&&a.jsxs(J,{type:"button",variant:"ghost",size:"xs",onClick:()=>s(k),className:"text-muted-foreground",children:[a.jsx(yr,{"data-icon":"inline-start"}),"Edit"]})]}),a.jsx(Sn,{children:a.jsx(nL,{loading:g,content:p})})]}),F.length>0&&a.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:F.map((H,G)=>a.jsxs(J,{type:"button",variant:"ghost",onClick:()=>V(G),"aria-label":`Open attached image ${G+1}`,className:K("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 ${G+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-white/10 bg-black/45 text-white/70 opacity-80 backdrop-blur transition-[color,background-color,opacity] group-hover/image:bg-black/65 group-hover/image:text-white sm:opacity-0 sm:group-hover/image:opacity-100 sm:group-focus-visible/image:opacity-100",children:a.jsx(Yu,{className:"size-3.5","data-icon":"icon"})}),F.length>1&&a.jsxs("span",{className:"absolute bottom-2 right-2 rounded-md bg-black/55 px-1.5 py-0.5 font-mono text-xs text-white/80",children:[G+1," / ",F.length]})]},`${z[G].source.media_type}-${z[G].source.data.slice(0,24)}-${G}`))}),!u&&A.length>0&&a.jsx("div",{className:"mb-2 flex flex-col gap-2",children:A.map(H=>a.jsx(Fj,{notification:H},H.taskId))}),!u&&I.length>0&&a.jsx("div",{className:"mb-2 flex flex-col gap-1",children:I.map((H,G)=>a.jsx(tL,{output:H},G))}),!u&&R.length>0&&a.jsx("div",{className:"mb-2 flex flex-col gap-1",children:R.map((H,G)=>a.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium text-destructive",children:[a.jsx(C6,{className:"size-3 shrink-0","data-icon":"inline-start"}),a.jsx("span",{children:H})]},G))}),W&&a.jsx("div",{className:"max-w-none overflow-hidden break-words text-sm leading-relaxed",children:a.jsx(sr,{components:cr,remarkPlugins:ur,children:W})}),B.length>500&&a.jsx(J,{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(It,{"data-icon":"inline-start"})," Show less"]}):a.jsxs(a.Fragment,{children:[a.jsx(at,{"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(qg,{open:b.open,images:D,initialIndex:b.index,onClose:()=>v(H=>H?{...H,open:!1}:null),onCloseComplete:()=>v(null)},b.index)]})}),Uj=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(Fe,{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(t1,{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}),Bj=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=T=>{o==null||o(T),l(T)},t[0]=o,t[1]=p):p=t[1];let h;t[2]===Symbol.for("react.memo_cache_sentinel")?(h=a.jsx(J,{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(It,{"data-icon":"inline-start"}):a.jsx(Hu,{"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 v;t[9]!==m?(v=m.toFixed(0),t[9]=m,t[10]=v):v=t[10];const y=`${v}% of tasks complete`;let k;t[11]!==m||t[12]!==y?(k=a.jsx(vl,{value:m,className:"max-w-[200px] flex-1","aria-label":y}),t[11]=m,t[12]=y,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(ht,{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 C;t[16]!==g||t[17]!==b||t[18]!==k||t[19]!==j?(C=a.jsxs(ds,{render:h,children:[g,x,b,k,j]}),t[16]=g,t[17]=b,t[18]=k,t[19]=j,t[20]=C):C=t[20];let _;t[21]!==u?(_=u.map(sL),t[21]=u,t[22]=_):_=t[22];let S;t[23]!==_?(S=a.jsx(Sn,{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:_})})}),t[23]=_,t[24]=S):S=t[24];let N;return t[25]!==c||t[26]!==p||t[27]!==C||t[28]!==S?(N=a.jsxs(wn,{open:c,onOpenChange:p,className:"shrink-0 border-t bg-background",children:[C,S]}),t[25]=c,t[26]=p,t[27]=C,t[28]=S,t[29]=N):N=t[29],N});function sL(n,e){return a.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[n.status==="completed"?a.jsx(Tr,{className:"size-3 shrink-0 text-success"}):n.status==="in_progress"?a.jsx(ht,{className:"size-3 shrink-0 animate-spin text-info"}):a.jsx(Qh,{className:"size-3 shrink-0 text-muted-foreground"}),a.jsx("span",{className:K("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 Hi(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 Wj(n){return`${n.provider}:${n.latestVersion??"unknown"}`}function rL(n,e){const t=e.split(":")[0];return[...n.filter(s=>s.split(":")[0]!==t),e]}const oL="cogpit:provider-update-dismissals:v1";function iL(n,e){return n.filter(t=>t.status==="behind"&&!e.includes(Wj(t)))}async function aL(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 lL(n){const e=await rr("/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 cL=360*60*1e3;function uL(){const[n,e]=w.useState([]),[t,s]=Hi(oL,[]),[r,o]=w.useState(null),[i,l]=w.useState(null);w.useEffect(()=>{const d=new AbortController,f=()=>{aL(d.signal).then(e).catch(()=>{})};f();const m=setInterval(f,cL);return()=>{d.abort(),clearInterval(m)}},[]);const c=w.useCallback(async d=>{o(d),l(null);try{const f=await lL(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=>rL(f,Wj(d)))},[s]);return{pending:iL(n,t),updating:r,outcome:i,update:c,dismiss:u,clearOutcome:w.useCallback(()=>l(null),[])}}const dL=5e3,fL={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 Sf(n){return`grid-cols-[auto_minmax(0,1fr)_auto] rounded-none border-x-0 border-t-0 px-4 py-2 ${fL[n]}`}function R0(n){const e=n.currentVersion?`v${n.currentVersion}`:"an older build";return`${n.displayName} ${e} → v${n.latestVersion}`}function qj(){const n=q.c(39),{pending:e,updating:t,outcome:s,update:r,dismiss:o,clearOutcome:i}=uL(),l=gt("configWrite"),c=(s==null?void 0:s.status)==="succeeded";let u,d;if(n[0]!==i||n[1]!==c?(u=()=>{if(!c)return;const P=setTimeout(i,dL);return()=>clearTimeout(P)},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 P;return n[4]!==i||n[5]!==s.message||n[6]!==c?(P=c?a.jsxs(Ft,{className:Sf("success"),children:[a.jsx(Ku,{}),a.jsx(on,{children:s.message}),a.jsx(Ut,{className:"text-success/80",children:"New sessions will use the updated CLI."})]}):a.jsxs(Ft,{className:Sf("destructive"),children:[a.jsx(po,{}),a.jsx(on,{children:"Update did not complete"}),a.jsx(Ut,{className:"text-destructive/80",children:s.message}),a.jsx(oo,{className:"static col-start-3 row-span-2 row-start-1 self-center",children:a.jsx(J,{variant:"ghost",size:"xs",onClick:i,children:"Dismiss"})})]}),n[4]=i,n[5]=s.message,n[6]=c,n[7]=P):P=n[7],P}if(e.length===0)return null;const f=e[0],m=e.filter(P=>P.updateCommand!==null&&l),p=Ft;let h;n[8]===Symbol.for("react.memo_cache_sentinel")?(h=Sf("warning"),n[8]=h):h=n[8];let g;n[9]!==t?(g=t?a.jsx(ht,{className:"animate-spin"}):a.jsx(Us,{}),n[9]=t,n[10]=g):g=n[10];let x;n[11]!==f||n[12]!==e?(x=e.length===1?R0(f):`${e.map(mL).join(" and ")} are out of date`,n[11]=f,n[12]=e,n[13]=x):x=n[13];let b;n[14]!==x?(b=a.jsx(on,{children:x}),n[14]=x,n[15]=b):b=n[15];const v=e.length>1?e.map(R0).join(" · "):m.length===1?`Cogpit can run \`${f.updateCommand}\` for you.`:f.updateCommand?`Run \`${f.updateCommand}\` to upgrade.`:"Update it with whatever installed it — Cogpit could not tell.";let y;n[16]!==v?(y=a.jsx(Ut,{className:"text-warning/80",children:v}),n[16]=v,n[17]=y):y=n[17];const k=oo,j="static col-start-3 row-span-2 row-start-1 flex items-center gap-2 self-center";let C;n[18]!==e.length||n[19]!==r||n[20]!==t?(C=P=>a.jsxs(J,{variant:"outline",size:"xs",disabled:t!==null,onClick:()=>void r(P.provider),children:[a.jsx(_p,{"data-icon":"inline-start"}),t===P.provider?"Updating…":e.length===1?"Update":`Update ${P.displayName}`]},P.provider),n[18]=e.length,n[19]=r,n[20]=t,n[21]=C):C=n[21];const _=m.map(C),S=t!==null;let N;n[22]!==o||n[23]!==e?(N=()=>e.forEach(o),n[22]=o,n[23]=e,n[24]=N):N=n[24];let T;n[25]!==S||n[26]!==N?(T=a.jsx(J,{variant:"ghost",size:"xs",disabled:S,onClick:N,className:"whitespace-nowrap text-muted-foreground",children:"Don't show again"}),n[25]=S,n[26]=N,n[27]=T):T=n[27];let E;n[28]!==k||n[29]!==_||n[30]!==T?(E=a.jsxs(k,{className:j,children:[_,T]}),n[28]=k,n[29]=_,n[30]=T,n[31]=E):E=n[31];let A;return n[32]!==p||n[33]!==E||n[34]!==h||n[35]!==g||n[36]!==b||n[37]!==y?(A=a.jsxs(p,{className:h,children:[g,b,y,E]}),n[32]=p,n[33]=E,n[34]=h,n[35]=g,n[36]=b,n[37]=y,n[38]=A):A=n[38],A}function mL(n){return n.displayName}function Vj(){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(_p,{}),n[2]=u):u=n[2];let d;n[3]!==s.version?(d=a.jsxs(on,{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(Ut,{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(oo,{className:"static col-start-3 row-span-2 row-start-1 self-center",children:a.jsx(J,{variant:"ghost",size:"icon-xs",onClick:m,"aria-label":"Dismiss update",children:a.jsx(Wt,{"data-icon":"inline-start"})})}),n[7]=p):p=n[7];let h;return n[8]!==d?(h=a.jsxs(Ft,{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(_p,{}),n[10]=u):u=n[10];let d;n[11]!==e.version?(d=a.jsxs(on,{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(Ut,{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(J,{variant:"outline",size:"xs",render:a.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer"}),nativeButton:!1,children:[a.jsx(_6,{"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(J,{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(oo,{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(Ft,{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 Ja=null,{min:_o,max:bs,abs:O0,floor:pL}=Math,Hj=(n,e,t)=>_o(t,bs(e,n)),Kj=n=>[...n].sort((e,t)=>e-t),Gj=typeof queueMicrotask=="function"?queueMicrotask:n=>{Promise.resolve().then(n)},Gp=()=>{let n;return[new Promise(e=>{n=e}),n]},Zj=n=>{let e;return()=>(n&&(e=n(),n=void 0),e)},Ea=(n,e,t)=>{const s=t?"unshift":"push";for(let r=0;r<e;r++)n[s](-1);return n},Yj=(n,e)=>{const t=n.t[e];return t===-1?n.o:t},hL=(n,e,t)=>{const s=n.t[e]===-1;return n.t[e]=t,n.i=_o(e,n.i),s},Wc=(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+=Yj(n,t),n.u[++t]=s;return n.i=e,s},Vo=(n,e,t=0,s=n.l-1)=>{let r=t;for(;t<=s;){const o=pL((t+s)/2);Wc(n,o)<=e?(r=o,t=o+1):s=o-1}return Hj(r,0,n.l-1)},M0=(n,e,t)=>{const s=e-n.l;return n.i=t?-1:_o(e-1,n.i),n.l=e,s>0?(Ea(n.u,s),Ea(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))},gL=typeof window<"u",xL=n=>n.documentElement,bL=n=>n.ownerDocument,vL=n=>n.defaultView,Xj=Zj(()=>!!/iP(hone|od|ad)/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>0),yL=Zj(()=>"scrollBehavior"in xL(document).style),wL=n=>bs(n.h(),n.p()),SL=(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=Ja,x=[0,o?bs(t-1,0):-1],b=0,v=!1;const y=((P,I,O)=>({o:I,t:O?Ea(O.slice(0,_o(P,O.length)),bs(0,P-O.length)):Ea([],P),l:P,i:-1,u:Ea([],P+1)}))(n,s?s[1]:e,s&&s[0]),k=new Set,j=()=>u-c,C=()=>j()+f+d,_=(P,I)=>((O,R,$,M)=>{if(M=_o(M,O.l-1),Wc(O,M)<=R){const z=Vo(O,$,M);return[Vo(O,R,M,z),z]}{const z=Vo(O,R,void 0,M);return[z,Vo(O,$,z)]}})(y,P,I,x[0]),S=()=>Wc(y,y.l),N=(P,I)=>{const O=Wc(y,P)-f;return I?S()-O-T(P):O},T=P=>Yj(y,P),E=(P,I=-1)=>y.t[P]===I,A=P=>{P&&(Xj()&&p!==0||g&&h===1?f+=P:d+=P)};return{v:()=>{k.clear()},m:()=>i,_:()=>(P=>[P.t.slice(),P.o])(y),S:(P=200)=>{if(!v||o)return x;let I,O;if(m)[I,O]=x;else{let R=bs(0,C()),$=R+l;r||(P=bs(0,P),p!==1&&(R-=P),p!==2&&($+=P)),[I,O]=x=_(bs(0,R),bs(0,$)),g&&(I=_o(I,g[0]),O=bs(O,g[1]))}return[bs(I,0),_o(O,y.l-1)]},$:P=>Vo(y,P-c),I:E,k:N,R:T,T:()=>y.l,C:()=>u,M:()=>p!==0,p:()=>l,O:()=>c,h:S,H:()=>(m=d,d=0,[m,h===2]),W:(P,I)=>{const O=[P,I];return k.add(O),()=>{k.delete(O)}},B:(P,I)=>{let O,R,$=0;switch(P){case 1:{if(I===u&&h===0)break;const M=m;m=0;const z=I-u,F=O0(z);M&&F<O0(M)+1||h!==0||(p=z<0?2:1),o&&(o=!1),u=I,$=4;const D=j();D>=-l&&D<=S()&&($+=1,R=F>l);break}case 2:$=8,p!==0&&(O=!0,$+=1),p=0,h=0,g=Ja;break;case 3:{const M=I.filter(([z,F])=>!E(z,F));if(!M.length)break;A(M.reduce((z,[F,D])=>{let L;if(h===2)L=!0;else if(g&&h===1)L=F<g[0];else{const B=j(),U=N(F),W=T(F);L=p!==1&&h===0?U+W<=B:U<B&&U+W<B+l}return L&&(z+=D-T(F)),z},0));for(const[z,F]of M){const D=T(z),L=hL(y,z,F);r&&(b+=L?F:F-D)}r&&l&&b>l&&(A(((z,F)=>{let D=0;const L=[];z.t.forEach((G,Z)=>{G!==-1&&(L.push(G),Z<F&&D++)}),z.i=-1;const B=Kj(L),U=B.length,W=U/2|0,V=U%2==0?(B[W-1]+B[W])/2:B[W],H=z.o;return((z.o=V)-H)*bs(F-D,0)})(y,Vo(y,C()))),r=!1),$=3,R=!0;break}case 4:l!==I&&(l||(v=R=!0),l=I,$=3);break;case 5:I[1]?(A(M0(y,I[0],!0)),h=2,$=1):(M0(y,I[0]),$=1);break;case 6:c=I;break;case 7:h=1;break;case 8:g=_(I,I+l),$=1}$&&(i=1+(2147483647&i),O&&f&&(d+=f,f=0),k.forEach(([M,z])=>{$&M&&z(R)}))}}},n1=setTimeout,kf=(n,e)=>e?-n:n,kL=(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 v=()=>{b!=Ja&&clearTimeout(b)},y=()=>{v(),b=n1(()=>{b=Ja,(()=>{if(c||u)return c=!1,void m();d=!1,n.B(2)})()},150)};return y.J=v,y})(),p=()=>{l=i(),d&&(f=!0),n.B(1,s()),m()},h=b=>{if(c||!n.M()||b.ctrlKey)return;const v=i()-l;150>v&&50<v&&(t?b.deltaX:b.deltaY)&&(c=!0)},g=()=>{u=!0,d=f=!1},x=()=>{u=!1,Xj()&&(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,v]=n.H();b&&(r(b,v,f),f=!1,v&&n.p()>n.h()&&n.B(1,s()))}}},jL=(n,e,t)=>{let s;return[async(r,o)=>{if(!await e())return;s&&s();const i=()=>{const[l,c]=Gp();return s=()=>{c(!1)},n.p()&&n1(s,150),[l,n.W(2,()=>{c(!0)})]};if(o&&yL())n.B(8,r()),Gj(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()}]},NL=(n,e)=>{let t,s,r=Gp(),o=!1;const i=e?"scrollLeft":"scrollTop",l=e?"overflowX":"overflowY",[c,u]=jL(n,()=>r[0],(d,f)=>{d=kf(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=kL(n,f,e,()=>kf(f[i],o),(m,p,h)=>{if(h){const g=f.style,x=g[l];g[l]="hidden",n1(()=>{g[l]=x})}f[i]=kf(n.C()+m,o),p&&u()}),r[1](!0)},v(){s&&s.A(),r[1](!1),r=Gp()},P:()=>o,V(d){c(()=>d)},X(d){d+=n.C(),c(()=>d)},Y(d,{align:f,smooth:m,offset:p=0}={}){if(d=Hj(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()}}},CL=n=>{let e;return{j(t){(e||(e=new(vL(bL(t))).ResizeObserver(n))).observe(t)},D(t){e.unobserve(t)},A(){e&&e.disconnect()}}},_L=(n,e)=>{let t;const s=e?"width":"height",r=new WeakMap,o=CL(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!=Ja&&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}},hu=gL?w.useLayoutEffect:w.useEffect,Yn="current",Jj=(n,e)=>{if(Array.isArray(n))for(const t of n)Jj(t,e);else n==null||typeof n=="boolean"||e.push(n)},TL=(n,e)=>{const t=n.key;return t??"_"+e},EL=n=>{const e=w.useRef(null);return e[Yn]||(e[Yn]=n())},L0=n=>{const e=w.useRef(n);return hu(()=>{e[Yn]=n},[n]),e},AL=w.memo(({Z:n,ee:e,te:t,oe:s,ne:r,re:o,se:i,ie:l})=>{const c=w.useRef(null);hu(()=>e(c[Yn],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})}),PL=(n,e)=>w.useMemo(()=>{if(typeof n=="function")return[s=>n(e[s],s),e.length];const t=(s=>{const r=[];return Jj(s,r),r})(n);return[s=>t[s],t.length]},[n,e]),IL=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]=PL(n,e),v=w.useRef(null),y=w.useRef(!!u),k=L0(p),j=L0(h),[C,_,S,N]=EL(()=>{const $=!!o,M=SL(b,s,u,l,!s);return[M,_L(M,$),NL(M,$),$]});b!==C.T()&&C.B(5,[b,r]),c!==C.O()&&C.B(6,c);const[T,E]=w.useReducer(C.m,void 0,C.m),A=C.M(),P=C.h(),I=S.P(),O=[],R=$=>{const M=x($);return a.jsx(AL,{ee:_.U,te:$,oe:C.k($,I),ne:C.I($),re:f,Z:M,se:N,ie:y[Yn]},TL(M,$))};if(hu(()=>{y[Yn]=!1,C.W(1,z=>{z?rE.flushSync(E):E()}),C.W(4,()=>{k[Yn]&&k[Yn](C.C())}),C.W(8,()=>{j[Yn]&&j[Yn]()});const $=v[Yn],M=z=>{_.G(z),S.N($,z)};return m?Gj(()=>{m[Yn]&&M(m[Yn])}):M($.parentElement),()=>{C.v(),_.v(),S.v()}},[]),hu(()=>{S.q()},[T]),w.useImperativeHandle(g,()=>({get cache(){return C._()},get scrollOffset(){return C.C()},get scrollSize(){return wL(C)},get viewportSize(){return C.p()},findItemIndex:C.$,getItemOffset:C.k,getItemSize:C.R,scrollToIndex:S.Y,scrollTo:S.V,scrollBy:S.X}),[]),i){const $=new Set(i);for(let[M,z]=C.S(t);M<=z;M++)$.add(M);Kj([...$]).forEach(M=>{O.push(R(M))})}else for(let[$,M]=C.S(t);$<=M;$++)O.push(R($));return a.jsx(d,{ref:v,style:{contain:"size style",overflowAnchor:"none",flex:"none",position:"relative",width:N?P:"100%",height:N?"100%":P,pointerEvents:A?"none":void 0},children:O})});function $L(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(eg,{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(Zt,{orientation:"vertical",className:"h-4"}),e[8]=u):u=e[8];let d;e[9]===Symbol.for("react.memo_cache_sentinel")?(d=a.jsx(T6,{"data-icon":"inline-start"}),e[9]=d):d=e[9];let f;e[10]!==s?(f=a.jsxs(J,{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-background/95 px-4 py-2",role:"status",children:[c,u,f]}),e[12]=c,e[13]=f,e[14]=m):m=e[14],m}const z0=new Map;function RL(n){let e=z0.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},z0.set(n,e)}return e}function Qj(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}=RL(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 gu(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 D0(n){const e=gu(n.lastActivityAt);return e!==Number.NEGATIVE_INFINITY?e:gu(n.lastModified)}function F0(n,e){return n===e?0:e-n}function U0(n){return[n.dirName??"",n.fileName??"",n.sessionId??""].join("/")}function OL(n,e){const t=F0(D0(n),D0(e));if(t!==0)return t;const s=F0(gu(n.lastModified),gu(e.lastModified));return s!==0?s:U0(n).localeCompare(U0(e))}function El(n){return[...n].sort(OL)}function xu(n,e){return e||Ns(t4(n),50)}const ML="Untitled session";function e4(n,e){const t=n.teamName&&n.agentName?n.agentName:"";return e||n.aiTitle||t||n.lastUserMessage||n.firstUserMessage||n.slug||void 0}function t4(n,e){return e4(n,e)??ML}function LL(n,e){return e4(n,e)===void 0}function zL(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 DL(n){return n.find(e=>!od(e.cwd??Rs(e.dirName)))??n[0]}const FL="Unknown project";function s1(n){const e=od(n);return rd(e?e.parentPath:n,2)||FL}function r1(n){return s1(n.cwd||Rs(n.dirName))}function o1(n){return n==="inactive"?"Archived after two weeks without activity":"Archived"}function UL(n,e){return e?n:n.filter(t=>!t.archived)}function BL(n){const e=El(n),t=new Map;for(const s of e){const r=r1(s),o=t.get(r);o?o.push(s):t.set(r,[s])}return t}function i1(n,e){return n.isActive?!0:e?n.agentStatus!=="completed":!1}const a1=new Set(["thinking","tool_use","processing","compacting","awaiting_agents"]),WL=12e4;function qL(n,e=Date.now()){const t=Date.parse(n.lastActivityAt||n.lastModified);return Number.isFinite(t)&&e-t<WL}function n4(n,e,t=Date.now()){return i1(n,e.get(n.sessionId))?!0:n.agentStatus==="completed"||!n.agentStatus?!1:qL(n,t)}function VL(n,e,t=Date.now()){return n.some(s=>n4(s,e,t))}const HL="cogpit:session-list-cache",KL=10080*60*1e3,GL=24,gr={projects:"projects",activeSessions:"active-sessions",runningProcesses:"running-processes"},Zp=new Map;function ZL(){return{version:1,entries:{}}}function s4(){return Rn(HL)}function r4(){const n=s4(),e=Zp.get(n);if(e)return e;let t=ZL();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 Zp.set(n,t),t}function o4(n){const e=r4().entries[n];if(!(!e||Date.now()-e.savedAt>KL))return e.value}function i4(n,e){const t=s4(),r={...r4().entries,[n]:{savedAt:Date.now(),value:e}},o=Object.entries(r).sort(([,l],[,c])=>c.savedAt-l.savedAt),i={version:1,entries:Object.fromEntries(o.slice(0,GL))};Zp.set(t,i);try{localStorage.setItem(t,JSON.stringify(i))}catch{}}function bu(n){const e=o4(n);return Array.isArray(e)?e:void 0}function Aa(n,e){i4(n,e)}function a4(n){return`sessions:${n}`}function YL(n){const e=o4(a4(n));if(!e||typeof e!="object")return;const t=e;if(!(!Array.isArray(t.sessions)||typeof t.total!="number"))return t}function XL(n,e){i4(a4(n),e)}const JL=2e4;function QL(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}const l4=w.createContext(null);function ez({children:n}){const[e]=w.useState(Fn),[t,s]=w.useState(()=>bu(gr.activeSessions)??[]),[r,o]=w.useState(()=>bu(gr.runningProcesses)??[]),[i,l]=w.useState(!1),[c,u]=w.useState(null),[d,f]=w.useState(new Set),[m,p]=Hi(Rn("live-sessions-show-archived"),!1),h=m===!0,[g,x]=w.useState(!1),b=h||g,[v,y]=w.useState(0),k=w.useRef(null),j=w.useRef(t),C=w.useRef(null),_=w.useRef(!1);w.useEffect(()=>(_.current=!0,()=>{var $;_.current=!1,($=C.current)==null||$.abort(),C.current=null}),[]);const S=w.useCallback(async()=>{var z;if(!_.current||Fn()!==e)return;(z=C.current)==null||z.abort();const $=new AbortController;C.current=$;const M=()=>_.current&&!$.signal.aborted&&C.current===$&&Fn()===e;l(!0);try{const[F,D]=await Promise.all([Re(b?"/api/active-sessions?archived=include":"/api/active-sessions",{signal:$.signal}),Re("/api/running-processes",{signal:$.signal})]);if(!M())return;if(!F.ok||!D.ok)throw new Error("Failed to fetch live data");const[L,B]=await Promise.all([F.json(),D.json()]);if(!M())return;const U=Array.isArray(L)?L:[],W=Array.isArray(B)?B:[];j.current=U,s(U),o(W),y(Number(F.headers.get("X-Cogpit-Archived-Count"))||0),Aa(gr.activeSessions,U),Aa(gr.runningProcesses,W),u(null)}catch(F){if(!M())return;u(F instanceof Error?F.message:"Failed to load data")}finally{M()&&l(!1),C.current===$&&(C.current=null)}},[e,b]),N=w.useCallback(()=>{S()},[S]);w.useEffect(()=>{N()},[N]);const T=w.useMemo(()=>QL(r),[r]),E=w.useMemo(()=>VL(t,T),[t,T]);w.useEffect(()=>(window.addEventListener("focus",N),()=>window.removeEventListener("focus",N)),[N]),w.useEffect(()=>{if(!E)return;const $=setInterval(()=>{document.visibilityState==="visible"&&N()},JL);return()=>clearInterval($)},[E,N]),w.useEffect(()=>{if(t.length===0)return;const $=k.current,M=new Map;for(const z of t)z.agentStatus&&T.has(z.sessionId)&&M.set(z.sessionId,z.agentStatus);$!==null&&f(z=>{let F=null;for(const[D,L]of M)L==="completed"&&$.get(D)!=="completed"&&(F??(F=new Set(z)),F.add(D));for(const D of z)M.get(D)!=="completed"&&(F??(F=new Set(z)),F.delete(D));return F??z}),k.current=M},[t,T]);const A=w.useCallback($=>{f(M=>{if(!M.has($))return M;const z=new Set(M);return z.delete($),z})},[]),P=w.useCallback($=>{j.current=$,s($),Fn()===e&&Aa(gr.activeSessions,$)},[e]),I=w.useCallback($=>{P(j.current.filter(M=>M.sessionId!==$))},[P]),O=w.useCallback(($,M)=>{const z=new Set($),F=j.current,D=new Set(F.filter(B=>z.has(B.sessionId)&&!!B.archived!==M).map(B=>B.sessionId));if(D.size===0)return;P(F.map(B=>{if(!D.has(B.sessionId))return B;if(M)return{...B,archived:!0,archivedReason:"manual"};const{archived:U,archivedReason:W,...V}=B;return V}));const L=M?D.size:-D.size;y(B=>Math.max(0,B+L))},[P]),R=w.useMemo(()=>({sessions:t,processes:r,procBySession:T,newlyCompleted:d,loading:i,error:c,refresh:N,removeSession:I,acknowledgeCompleted:A,showArchived:h,setShowArchived:p,setSearchActive:x,archivedCount:v,setArchived:O}),[t,r,T,d,i,c,N,I,A,h,p,v,O]);return a.jsx(l4.Provider,{value:R,children:n})}function c4(){const n=l1();if(!n)throw new Error("useSessionInventory must be used within a SessionInventoryProvider");return n}function l1(){return w.useContext(l4)}const B0=[20,50,80,110,140,170,200,230,260,290,320,350];function tz(n){let e=2166136261;for(let t=0;t<n.length;t++)e^=n.charCodeAt(t),e=Math.imul(e,16777619);return B0[(e>>>0)%B0.length]}function jf(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 nz(n){const e=n.split(`
|
|
92
|
+
`);let t=0;for(;t<e.length&&e[t].trim()==="";)t++;const s=jf(e[t]??"");return s?{subject:s,preview:jf(e.slice(t+1).join(`
|
|
93
|
+
`))}:{subject:jf(n),preview:""}}function Yp(n){if(!n)return null;const e=new Date(n).getTime();return Number.isNaN(e)?null:e}function sz(n,e){return n===null||e===null||e<n?null:e-n}function rz(n){const e=Yp(n);return e===null?null:new Date(e).toLocaleTimeString()}function oz(n){var s;const e=(s=l1())==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=a1.has(o)?"working":"idle"}return t}const iz=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=TO(r),t[0]=r,t[1]=d):d=t[1];const f=d;let m;t[2]!==f?(m=nz(f),t[2]=f,t[3]=m):m=t[3];const{subject:p,preview:h}=m;let g;t[4]!==o?(g=rz(o),t[4]=o,t[5]=g):g=t[5];const x=g,b=oz(s);let v;t[6]!==f?(v=$O(f),t[6]=f,t[7]=v):v=t[7];const y=v,k=y&&!i,j=Yp(o),C=i?sz(j,Yp(i.timestamp)):null,_=!i&&l===!0,S=!!i||y;jk(_&&S);const N=!0;let T;t[8]!==s?(T=tz(s),t[8]=s,t[9]=T):T=t[9];const E=String(T);let A;t[10]!==E?(A={"--agent-hue":E},t[10]=E,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 O;t[12]===Symbol.for("react.memo_cache_sentinel")?(O=a.jsx(E6,{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]=O):O=t[12];let R;t[13]!==s?(R=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]=R):R=t[14];let $;t[15]!==b||t[16]!==s?($=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]=$):$=t[17];let M;t[18]!==R||t[19]!==$?(M=a.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[O,R,$]}),t[18]=R,t[19]=$,t[20]=M):M=t[20];let z;t[21]!==k?(z=k&&a.jsx(Fe,{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 F;t[23]!==x?(F=x&&a.jsx("span",{className:"text-xs text-muted-foreground",children:x}),t[23]=x,t[24]=F):F=t[24];let D;t[25]!==z||t[26]!==F?(D=a.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:[z,F]}),t[25]=z,t[26]=F,t[27]=D):D=t[27];let L;t[28]!==M||t[29]!==D?(L=a.jsxs("div",{className:"flex items-center gap-2",children:[M,D]}),t[28]=M,t[29]=D,t[30]=L):L=t[30];let B;t[31]!==f||t[32]!==c||t[33]!==h||t[34]!==p?(B=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(sr,{components:cr,remarkPlugins:ur,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]=B):B=t[35];const U="mt-1.5 flex items-center justify-end gap-2",W=S&&a.jsx("p",{"data-testid":"agent-message-state",className:`min-w-0 flex-1 truncate text-xs ${_?"text-warning":"text-muted-foreground"}`,children:i?a.jsxs(a.Fragment,{children:[C===null?"You replied":`You replied ${er(C)} later`,i.summary&&` · "${i.summary}"`]}):_?j===null?"Awaiting your reply":`Awaiting your reply · ${er(Math.max(0,Date.now()-j))}`:"Never answered"});let V;t[36]===Symbol.for("react.memo_cache_sentinel")?(V=()=>u(az),t[36]=V):V=t[36];let H;t[37]!==f||t[38]!==c?(H=a.jsx(J,{type:"button",variant:"ghost",size:"xs",onClick:V,className:"-mr-2 text-muted-foreground",children:c?a.jsxs(a.Fragment,{children:[a.jsx(It,{"data-icon":"inline-start"})," Collapse"]}):a.jsxs(a.Fragment,{children:[a.jsx(at,{"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 G;t[40]!==W||t[41]!==H?(G=a.jsxs("div",{className:U,children:[W,H]}),t[40]=W,t[41]=H,t[42]=G):G=t[42];let Z;return t[43]!==L||t[44]!==B||t[45]!==G||t[46]!==P?(Z=a.jsxs("div",{"data-agent-rail":N,style:P,className:I,children:[L,B,G]}),t[43]=L,t[44]=B,t[45]=G,t[46]=P,t[47]=Z):Z=t[47],Z});function az(n){return!n}const lz=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=Rj(s),t[0]=s,t[1]=u):u=t[1];const d=u,[f,m]=Sr();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:Do(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(J,{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(Bt,{"data-icon":"inline-start"}):a.jsx(fs,{"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=K("overflow-hidden break-words text-sm",h),t[10]=h,t[11]=g):g=t[11];let x;t[12]!==d?(x=a.jsx(sr,{components:cr,remarkPlugins:ur,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 v;return t[17]!==p||t[18]!==b?(v=a.jsxs("div",{className:"group",children:[p,b]}),t[17]=p,t[18]=b,t[19]=v):v=t[19],v}),oi=[];function cz(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 uz(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 W0=/"id"\s*:\s*"(msg_[A-Za-z0-9]+)"/g;function dz(n,e){if(n.length===0||e.length===0)return n;const t=new Set;for(const r of e){W0.lastIndex=0;let o;for(;(o=W0.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 fz(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 mz(n){return n.filter(e=>e.parentToolUseId===null)}function pz(n,e){return n.filter(t=>t.parentToolUseId===e)}const u4={},d4=w.createContext(oi),f4=w.createContext(u4);function Nf(n){const e=q.c(6),{value:t,agentProgress:s,children:r}=n,o=s===void 0?u4:s;let i;e[0]!==o||e[1]!==r?(i=a.jsx(f4.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(d4.Provider,{value:t,children:i}),e[3]=i,e[4]=t,e[5]=l):l=e[5],l}function c1(){return w.useContext(d4)}function hz(n){return w.useContext(f4)[n]??null}function Ho(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 m4={...cr,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/30 p-2 font-mono text-xs leading-relaxed",children:a.jsx("code",{children:String(e).replace(/\n$/,"")})})},img:()=>null},gz={...m4,h1:Ho("h1"),h2:Ho("h2"),h3:Ho("h3"),h4:Ho("h4"),h5:Ho("h5"),h6:Ho("h6")},p4=w.memo(function(e){const t=q.c(3),{text:s,compactHeadings:r}=e,i=(r===void 0?!1:r)?gz:m4;let l;return t[0]!==i||t[1]!==s?(l=a.jsx(sr,{components:i,remarkPlugins:ur,children:s}),t[0]=i,t[1]=s,t[2]=l):l=t[2],l}),q0=400,xz=24,u1=w.memo(function(e){const t=q.c(24),{toolUseId:s}=e,r=c1(),o=hz(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=pz(r,s).flatMap(bz).filter(vz).map(yz).join(`
|
|
95
|
+
`);const C=f.split(`
|
|
96
|
+
`);u=l&&C.length>q0,d=u?C.slice(-q0).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 C=i.current;if(!C)return;const _=C.scrollHeight-C.scrollTop-C.clientHeight<xz;c(S=>S===_?S:_)},t[6]=p):p=t[6];const h=p;let g;t[7]!==l?(g=()=>{const C=i.current;if(!C||!l)return;const _=C.scrollHeight-C.clientHeight;C.scrollTop!==_&&(C.scrollTop=_)},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 v;t[12]!==o?(v=o??a.jsx("span",{className:"uppercase tracking-wide",children:"Live"}),t[12]=o,t[13]=v):v=t[13];let y;t[14]!==b||t[15]!==v?(y=a.jsx("div",{"data-testid":b,className:"mb-1 text-xs font-medium text-muted-foreground",children:v}),t[14]=b,t[15]=v,t[16]=y):y=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(p4,{text:m,compactHeadings:!0})]}),t[17]=u,t[18]=m,t[19]=f,t[20]=k):k=t[20];let j;return t[21]!==y||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:[y,k]}),t[21]=y,t[22]=k,t[23]=j):j=t[23],j});function bz(n){return n.blocks}function vz(n){return n.blockType!=="tool_use"&&n.text}function yz(n){return n.text}function V0(n){return n.length>8?n.slice(0,8):n}function d1(n,e,t){const s=e??t;return s?`${s} - ${V0(n)}`:V0(n)}function wz(n){const e=new Map;for(const t of n)e.has(t.agentId)||e.set(t.agentId,d1(t.agentId,t.subagentType,t.agentName));return e}function Sz(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 kz(n){return n?typeof n=="string"?n:n.map(e=>e.type==="text"?e.text:"").filter(Boolean).join(`
|
|
98
|
+
`):""}function h4(n,e){if(cj(n))return Xg(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=kz(f.content),m.isError=f.is_error??!1)}}}return t}const Cf=new Map;function jz(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 N;t[5]!==o?(N=T=>T.text.length>0||T.thinking.length>0||T.toolCalls.length>0?!1:o?T.durationMs!=null:T.status==="async_launched",t[5]=o,t[6]=N):N=t[6],p=n.filter(N),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=ud(window.location.pathname),t[7]=b):b=t[7];const v=b;let y,k;t[8]!==h||t[9]!==g||t[10]!==e||t[11]!==x?(y=()=>{if(v||!e||!g||!x||h.length===0)return;const N=[];for(const A of h){const P=Rn(`${g}/${x}/${A.agentId}`);if(!m.current.has(P)){if(Cf.has(P)){c(I=>{const O=new Map(I);return O.set(A.agentId,Cf.get(P)),O}),m.current.add(P);continue}N.push({agentId:A.agentId,cacheKey:P})}}if(N.length===0)return;let T=!1;return d(!0),async function(){const P=new Map;await Promise.all(N.map(async I=>{const{agentId:O,cacheKey:R}=I;try{const $=`/api/sessions/${encodeURIComponent(g)}/${encodeURIComponent(x)}/subagents/agent-${encodeURIComponent(O)}.jsonl`,M=await Re($);if(!M.ok)return;const z=await M.text(),F=h4(z,O);Cf.set(R,F),m.current.add(R),P.set(O,F)}catch{}})),!T&&P.size>0&&c(I=>{const O=new Map(I);for(const[R,$]of P)O.set(R,$);return O}),T||d(!1)}(),()=>{T=!0}},k=[v,e,g,x,h],t[8]=h,t[9]=g,t[10]=e,t[11]=x,t[12]=y,t[13]=k):(y=t[12],k=t[13]),w.useEffect(y,k);let j;e:{if(l.size===0&&h.length===0){j=n;break e}let N;if(t[14]!==l||t[15]!==n){N=[];for(const T of n){const E=l.get(T.agentId);if(E&&E.length>0&&(T.status==="async_launched"||T.durationMs!=null)){const A={...E[0],durationMs:T.durationMs,toolUseCount:T.toolUseCount,status:T.status,prompt:T.prompt,agentName:T.agentName,subagentType:T.subagentType};N.push(A,...E.slice(1))}else N.push(T)}t[14]=l,t[15]=n,t[16]=N}else N=t[16];j=N}const C=j,_=v&&e&&h.length>0;let S;return t[17]!==C||t[18]!==u||t[19]!==_?(S={enrichedMessages:C,isLoading:u,unavailable:_},t[17]=C,t[18]=u,t[19]=_,t[20]=S):S=t[20],S}const H0=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=ji(m),t[0]=m,t[1]=p):p=t[1];const h=p.subagentTranscripts,{enrichedMessages:g,isLoading:x,unavailable:b}=jz(s,u&&h);let v;e:{if(!(d!=null&&d.fileName)){v=null;break e}let Y;t[2]!==d.fileName?(Y=so(d.fileName),t[2]=d.fileName,t[3]=Y):Y=t[3];const X=Y;if(X){v=X.parentSessionId;break e}let ee;if(t[4]!==d.fileName){let ne;t[6]===Symbol.for("react.memo_cache_sentinel")?(ne=/^([^/]+)\.jsonl$/,t[6]=ne):ne=t[6],ee=d.fileName.match(ne),t[4]=d.fileName,t[5]=ee}else ee=t[5];const Q=ee;v=(Q==null?void 0:Q[1])??null}const y=v;let k;t[7]!==g?(k=new Set(g.map(Cz)),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 C=j;let _;t[11]!==g?(_=wz(g),t[11]=g,t[12]=_):_=t[12];const S=_;let N;if(t[13]!==g||t[14]!==s){N=new Map;for(const Y of[...s,...g]){const X=N.get(Y.agentId)??{};Y.durationMs!=null&&(X.durationMs=Y.durationMs),Y.toolUseCount!=null&&(X.toolUseCount=Y.toolUseCount),Y.status&&(X.status=Y.status),N.set(Y.agentId,X)}t[13]=g,t[14]=s,t[15]=N}else N=t[15];const T=N;let E;t[16]!==g||t[17]!==s?(E=Sz([...s,...g]),t[16]=g,t[17]=s,t[18]=E):E=t[18];const A=E;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 O;if(t[22]!==C||t[23]!==P||t[24]!==I){O=new Map;for(const Y of C){const X=I.get(Y)??P.get(Y);X&&O.set(Y,X)}t[22]=C,t[23]=P,t[24]=I,t[25]=O}else O=t[25];const R=O;let $;e:{let Y=0,X=0,ee=!1,Q=!0;for(const re of s)re.durationMs!=null&&(Y=Y+re.durationMs,ee=!0),re.toolUseCount!=null&&(X=X+re.toolUseCount),re.status&&re.status!=="completed"&&(Q=!1);if(!ee){$=null;break e}let ne;t[26]!==Q||t[27]!==Y||t[28]!==X?(ne={totalDuration:Y,totalToolUses:X,allCompleted:Q},t[26]=Q,t[27]=Y,t[28]=X,t[29]=ne):ne=t[29],$=ne}const 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 F;t[32]!==u?(F=u?a.jsx(It,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}):a.jsx(at,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),t[32]=u,t[33]=F):F=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 B;t[37]!==C.length||t[38]!==i?(B=C.length>1&&a.jsxs(Fe,{variant:"secondary",children:[C.length," ",i]}),t[37]=C.length,t[38]=i,t[39]=B):B=t[39];let U;t[40]!==C||t[41]!==S?(U=C.map(Y=>a.jsx(Fe,{variant:"outline",children:S.get(Y)},Y)),t[40]=C,t[41]=S,t[42]=U):U=t[42];let W;t[43]!==C.length||t[44]!==M?(W=M?a.jsxs("span",{className:"inline-flex items-center gap-2 text-xs text-muted-foreground",children:[M.allCompleted?a.jsx(Tr,{className:"size-3 text-success","data-icon":"inline-start"}):a.jsx(po,{className:"size-3 text-destructive","data-icon":"inline-start"}),a.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[a.jsx(eo,{className:"size-3","data-icon":"inline-start"}),er(M.totalDuration)]}),M.totalToolUses>0&&a.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[a.jsx(Gu,{className:"size-3","data-icon":"inline-start"}),M.totalToolUses]})]}):a.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",C.length," agent",C.length!==1?"s":"",")"]}),t[43]=C.length,t[44]=M,t[45]=W):W=t[45];let V;t[46]!==F||t[47]!==L||t[48]!==B||t[49]!==U||t[50]!==W||t[51]!==z?(V=a.jsxs(J,{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:[F,D,L,B,U,W]}),t[46]=F,t[47]=L,t[48]=B,t[49]=U,t[50]=W,t[51]=z,t[52]=V):V=t[52];let H;t[53]!==C||t[54]!==u||t[55]!==A?(H=!u&&C.map(Y=>{const X=A.get(Y);return X?a.jsx(u1,{toolUseId:X},Y):null}),t[53]=C,t[54]=u,t[55]=A,t[56]=H):H=t[56];let G;t[57]!==f||t[58]!==C||t[59]!==S||t[60]!==R||t[61]!==h||t[62]!==x||t[63]!==u||t[64]!==y||t[65]!==A||t[66]!==d||t[67]!==T||t[68]!==b?(G=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(ht,{className:"size-3 animate-spin"}),"Loading agent output..."]}),C.map(Y=>{const X=R.get(Y),ee=T.get(Y),Q=h&&!!d&&!!y&&!b;return a.jsx(Nz,{agentLabel:S.get(Y)??Y,message:X,stats:ee,parentToolUseId:A.get(Y),canNavigate:Q,onOpen:()=>{Q&&f.handleLoadSession(d.dirName,`${y}/subagents/agent-${Y}.jsonl`)}},Y)})]}),t[57]=f,t[58]=C,t[59]=S,t[60]=R,t[61]=h,t[62]=x,t[63]=u,t[64]=y,t[65]=A,t[66]=d,t[67]=T,t[68]=b,t[69]=G):G=t[69];let Z;return t[70]!==V||t[71]!==H||t[72]!==G?(Z=a.jsxs("div",{children:[V,H,G]}),t[70]=V,t[71]=H,t[72]=G,t[73]=Z):Z=t[73],Z});function Nz(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=Rj((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(Fe,{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(Tr,{className:"size-3 text-success"}),r.durationMs!=null&&a.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[a.jsx(eo,{className:"size-3"}),er(r.durationMs)]}),r.toolUseCount!=null&&r.toolUseCount>0&&a.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[a.jsx(Gu,{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(J,{type:"button",variant:"ghost",size:"xs",onClick:l,className:"ml-auto",title:"Open this sub-agent's full chat session",children:[a.jsx(zS,{"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 v;e[14]!==f||e[15]!==m||e[16]!==d||e[17]!==o?(v=f?a.jsx("div",{className:"text-xs break-words overflow-hidden",children:a.jsx(sr,{components:cr,remarkPlugins:ur,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(ht,{className:"size-3 animate-spin"}),"Working — no return yet"]}):a.jsx(a.Fragment,{children:"No return message from this agent"})}),o&&a.jsx(u1,{toolUseId:o})]}),e[14]=f,e[15]=m,e[16]=d,e[17]=o,e[18]=v):v=e[18];let y;return e[19]!==b||e[20]!==v?(y=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,v]})}),e[19]=b,e[20]=v,e[21]=y):y=e[21],y}function Cz(n){return n.agentId}const _z=new Set(["StopFailure","PermissionDenied","PostToolUseFailure"]),Tz=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(Ez),t[0]=s,t[1]=i):i=t[1];const l=i,c=r?It:at,u=l?"border-destructive/20 bg-destructive/5":"bg-muted/30";let d;t[2]!==u?(d=K("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(J,{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(zs,{className:"size-3 text-destructive","data-icon":"inline-start"}):a.jsx(A6,{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(Az).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 v;t[16]!==b||t[17]!==m||t[18]!==p||t[19]!==g?(v=a.jsxs(ds,{render:f,children:[m,p,g,b]}),t[16]=b,t[17]=m,t[18]=p,t[19]=g,t[20]=v):v=t[20];let y;t[21]!==s?(y=s.map(Pz),t[21]=s,t[22]=y):y=t[22];let k;t[23]!==y?(k=a.jsx(Sn,{children:a.jsx("ul",{className:"ml-5 mt-1 flex flex-col gap-0.5 font-mono",children:y})}),t[23]=y,t[24]=k):k=t[24];let j;return t[25]!==r||t[26]!==v||t[27]!==k||t[28]!==d?(j=a.jsxs(wn,{open:r,onOpenChange:o,className:d,children:[v,k]}),t[25]=r,t[26]=v,t[27]=k,t[28]=d,t[29]=j):j=t[29],j});function Ez(n){return _z.has(n.eventName)||n.exitCode!==void 0&&n.exitCode!==0}function Az(n){return n.eventName}function Pz(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 vu(n){if(!n)return[];const e=n.split(`
|
|
104
|
+
`);return n.endsWith(`
|
|
105
|
+
`)&&e.pop(),e}function Xp(n,e){if(!n&&!e)return{add:0,del:0};const t=vu(n),s=vu(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 _f(n){return n.filter(Boolean).reduce((e,t)=>e+(e&&!e.endsWith(`
|
|
106
|
+
`)?`
|
|
107
|
+
`:"")+t,"")}function Iz(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=_f(e.map(c=>c.current));if(l){const c=Xp("",l);return{originalStr:"",currentStr:l,addCount:c.add,delCount:c.del}}}return{originalStr:"",currentStr:"",addCount:0,delCount:0}}const s=_f(t.map(i=>i.original)),r=_f(t.map(i=>i.current)),o={add:0,del:0};for(const i of t){const l=i.diffLineCounts??Xp(i.original,i.current);o.add+=l.add,o.del+=l.del}return{originalStr:s,currentStr:r,addCount:o.add,delCount:o.del}}const $z=24,ra=[];function Rz(n,e){for(let s=0;s<ra.length;s++){const r=ra[s];if(r.oldStr===n&&r.newStr===e)return r.result}const t=Mz(n,e);return ra.length>=$z&&ra.shift(),ra.push({oldStr:n,newStr:e,result:t}),t}const Oz=25e4;function Mz(n,e){const t=vu(n),s=vu(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>Oz){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],v=x*f,y=v-f;for(let k=1;k<=u;k++)if(b===s[i+k-1])m[v+k]=m[y+k-1]+1;else{const j=m[y+k],C=m[v+k-1];m[v+k]=j>C?j:C}}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 Lz(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=m3(t);if(!m){i(null),c(null);return}const p=s?"github-dark":"github-light";let h=!1;const g=requestAnimationFrame(()=>{h||d3().then(async x=>{if(h||(await f3(x,m),h))return;const b=x.codeToTokens(n,{lang:m,theme:p});if(h)return;i(b.tokens);const v=x.codeToTokens(e,{lang:m,theme:p});h||c(v.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 zz={removed:"bg-destructive/10",added:"bg-success/10",unchanged:""},K0={removed:"border-destructive/20 text-destructive/70",added:"border-success/20 text-success/70",unchanged:"border-border text-muted-foreground"},Dz={removed:"text-destructive",added:"text-success",unchanged:"text-muted-foreground"};function Fz(n,e){return n.map((t,s)=>a.jsx("span",{style:{color:t.color},className:K(e&&"opacity-50"),children:t.content},s))}function Uz(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 Bz(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(LS,{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(Qs,{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 Tf=3;function Wz(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<=Tf*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-Tf);i<=Math.min(n.length-1,o+Tf);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 qz(n){const e=q.c(7),{count:t,onExpand:s}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(dl,{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(J,{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 G0=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=Uz(s,o,i);const x=zz[s.type];t[10]!==x?(u=K("flex",x),t[10]=x,t[11]=u):u=t[11];const b=K0[s.type];let v;t[12]!==b?(v=K("w-8 shrink-0 select-none border-r pr-1 text-right text-xs leading-relaxed tabular-nums",b),t[12]=b,t[13]=v):v=t[13],t[14]!==r||t[15]!==v?(d=a.jsx("span",{className:v,children:r}),t[14]=r,t[15]=v,t[16]=d):d=t[16];const y=K0[s.type];let k;t[17]!==y?(k=K("select-none shrink-0 w-5 text-right pr-1 border-r",y),t[17]=y,t[18]=k):k=t[18];let j;t[19]!==s.type?(j=a.jsx(Bz,{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?Fz(m,s.type==="unchanged"):a.jsx("span",{className:Dz[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}),Z0=120,Y0=60,Vz=120;function X0(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=Wz(t),e[1]=t,e[2]=f):f=e[2];const m=f,p=m.length>Z0,[h,g]=w.useState(p?Y0:m.length);let x;e[3]!==m.length?(x=()=>{g(m.length>Z0?Y0: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 v,y;e[7]!==m.length||e[8]!==h?(v=()=>{if(h>=m.length)return;const A=requestAnimationFrame(()=>{g(P=>Math.min(P+Vz,m.length))});return()=>cancelAnimationFrame(A)},y=[h,m.length],e[7]=m.length,e[8]=h,e[9]=v,e[10]=y):(v=e[9],y=e[10]),w.useEffect(v,y);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 C;e[12]!==m||e[13]!==p||e[14]!==h?(C=p?m.slice(0,h):m,e[12]=m,e[13]=p,e[14]=h,e[15]=C):C=e[15];const _=C,S=o&&"max-h-64 overflow-y-auto";let N;e[16]!==S?(N=K("overflow-x-auto font-mono text-xs leading-relaxed",S),e[16]=S,e[17]=N):N=e[17];let T;if(e[18]!==u||e[19]!==_||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)=>{const z=P.fromIdx+M;return a.jsx(G0,{line:$,lineNum:$.type==="removed"?($.oldIdx??0)+l:($.newIdx??0)+l,oldTokens:s,newTokens:r},`exp-${z}`)}):a.jsx(qz,{count:P.count,onExpand:()=>j(P.fromIdx)},`sep-${I}`);const{line:O}=P,R=O.type==="removed"?(O.oldIdx??0)+l:(O.newIdx??0)+l;return a.jsx(G0,{line:O,lineNum:R,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],T=_.map(A),e[18]=u,e[19]=_,e[20]=t,e[21]=r,e[22]=s,e[23]=l,e[24]=T}else T=e[24];let E;return e[31]!==N||e[32]!==T?(E=a.jsx("div",{className:N,children:T}),e[31]=N,e[32]=T,e[33]=E):E=e[33],E}function J0(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 f1(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=jl();let h;e[0]!==s||e[1]!==t?(h=Rz(t,s),e[0]=s,e[1]=t,e[2]=h):h=e[2];const g=h,{oldTokens:x,newTokens:b}=Lz(t,s,r,p);let v;e[3]!==r?(v=r.split("/").slice(-3).join("/"),e[3]=r,e[4]=v):v=e[4];const y=v,k=c&&"mt-1.5",j=d&&"border-0 rounded-none";let C;e[5]!==k||e[6]!==j?(C=K("overflow-hidden rounded border border-border bg-muted/20",k,j),e[5]=k,e[6]=j,e[7]=C):C=e[7];let _;e[8]!==d||e[9]!==c||e[10]!==g||e[11]!==y?(_=!d&&a.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2 border-b border-border bg-muted/40 px-2 py-1",children:[a.jsx("span",{className:"truncate font-mono text-xs text-muted-foreground",children:y}),a.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[a.jsx(J0,{lines:g}),c&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>m(!0),className:"text-muted-foreground",title:"Expand diff","aria-label":"Expand diff",children:a.jsx(Yu,{"data-icon":"icon"})})]})]}),e[8]=d,e[9]=c,e[10]=g,e[11]=y,e[12]=_):_=e[12];let S;e[13]!==c||e[14]!==g||e[15]!==b||e[16]!==x||e[17]!==u?(S=a.jsx(X0,{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 N;e[19]!==S||e[20]!==C||e[21]!==_?(N=a.jsxs("div",{className:C,children:[_,S]}),e[19]=S,e[20]=C,e[21]=_,e[22]=N):N=e[22];let T;e[23]!==r||e[24]!==c||e[25]!==g||e[26]!==f||e[27]!==b||e[28]!==x||e[29]!==u?(T=c&&a.jsx(or,{open:f,onOpenChange:m,children:a.jsxs(ir,{className:"flex max-h-[85vh] flex-col border-border bg-background sm:max-w-4xl",children:[a.jsxs(ho,{children:[a.jsxs(ar,{className:"font-mono text-sm text-foreground flex min-w-0 flex-wrap items-center gap-3 [overflow-wrap:anywhere]",children:[r,a.jsx(J0,{lines:g})]}),a.jsx(lr,{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(X0,{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]=T):T=e[30];let E;return e[31]!==N||e[32]!==T?(E=a.jsxs(a.Fragment,{children:[N,T]}),e[31]=N,e[32]=T,e[33]=E):E=e[33],E}const yu={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"}},Hz=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 Kz(n){var t;const e=Os(n);return Hz.has(((t=yu[e])==null?void 0:t.styleName)??e)?"mutating":"readOnly"}function g4(n){return typeof n=="object"&&n!==null}function Ht(...n){return n.find(e=>typeof e=="string")??""}function Hr(n){return typeof n!="string"?"":/^gAAAAA[A-Za-z0-9_-]+={0,2}$/.test(n.trim())?"Encrypted message":n}function Fo(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 kr(n,e=140){const t=n.replace(/\s+/g," ").trim();return t.length>e?`${t.slice(0,e-1)}…`:t}function m1(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 Al(n,e=""){const t=m1(n);if(t.length===0)return e;const s=kr(t[0]);return t.length===1?s:`${s} · +${t.length-1} more`}function Sd(n,e){return n===1?`1 ${e}`:`${n} ${e}${/(?:ch|sh|s|x|z)$/.test(e)?"es":"s"}`}const Q0={mcp:"MCP",api:"API",url:"URL",openai:"OpenAI",figma:"Figma",clickup:"ClickUp"};function Qa(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 Q0[o]?Q0[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 Gz(n){if(!n)return null;const e=n.trim(),t=tr(e,0);return(t==null?void 0:t.endIndex)===e.length?t.value:null}function xn(n,...e){for(const t of e){const s=Gz(gd(n,t));if(s)return s;const r=Hg(n,t)[0];if(r)return r}return""}function Zz(n,...e){for(const t of e){const s=U3(n,t)[0];if(s!==void 0)return s}return null}function wu(n){return xn(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 Yz=[{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 ev(n,e){return e.flatMap(t=>Hg(n,t))}function Xz(n,e){const t=e.summaryGroups.map(o=>ev(n,o)),s=e.detail?U3(n,e.detail.property):[],r=e.countProperties?ev(n,e.countProperties):t[0];return{label:e.label,noun:e.noun,summary:[...t.map(o=>Al(o)),e.detail&&s.length>0?e.detail.format(s[0]):""].filter(Boolean).join(" · "),count:Math.max(B3(n),m1(r).length,s.length,1)}}function Jz(n){const e=[];for(const t of Yz){const s=gd(n,t.key);s&&e.push(Xz(s,t))}return e}function x4(n){const e=Jz(n);return e.length===0?{label:"Browse web",summary:wu(n),styleName:"WebSearch"}:e.length===1?{label:e[0].label,summary:e[0].summary,styleName:"WebSearch"}:{label:"Browse web",summary:e.map(t=>Sd(t.count,t.noun)).join(" · "),styleName:"WebSearch"}}function b4(n){if(!n.startsWith("mcp__"))return null;const[,e,...t]=n.split("__");return!e||t.length===0?null:{server:Qa(e,!0),action:Qa(t.join(" "))}}function Qz(n,e){const t=b4(n);if(!t)return{label:Qa(n),summary:wu(e),styleName:"Mcp"};const s=wu(e);return{label:t.server,summary:[t.action,s].filter(Boolean).join(" · "),styleName:"Mcp"}}function v4(n){const e=tr(n.trim(),0),t=(e==null?void 0:e.value)??n,s=m1(Array.from(t.matchAll(/^\*\*\*\s+(?:Update|Add|Delete) File:\s*(.+)$/gm),r=>r[1]));return Al(s,s.length>0?Sd(s.length,"file"):"")}function eD(n){const e=n.argumentSource;switch(Os(n.name)){case"exec_command":return{label:"Run command",summary:xn(e,"cmd","command"),styleName:"Bash"};case"write_stdin":{const t=Zz(e,"session_id"),s=xn(e,"chars");return{label:"Continue command",summary:[t!==null?`session ${t}`:"",s?kr(s,60):""].filter(Boolean).join(" · "),styleName:"Bash"}}case"apply_patch":return{label:"Apply patch",summary:v4(e),styleName:"Edit"};case"web__run":case"web_search":return x4(e);case"view_image":return{label:"View image",summary:xn(e,"path"),styleName:"Read"};case"update_plan":{const t=gd(e,"plan"),s=t?B3(t):0;return{label:"Update plan",summary:s>0?Sd(s,"step"):xn(e,"explanation"),styleName:"TodoWrite"}}case"create_goal":return{label:"Create goal",summary:xn(e,"objective"),styleName:"TodoWrite"};case"get_goal":return{label:"Check goal",summary:"",styleName:"TaskList"};case"update_goal":return{label:"Update goal",summary:xn(e,"status"),styleName:"TodoWrite"};case"list_mcp_resources":return{label:"List MCP resources",summary:xn(e,"server"),styleName:"Mcp"};case"list_mcp_resource_templates":return{label:"List MCP templates",summary:xn(e,"server"),styleName:"Mcp"};case"read_mcp_resource":return{label:"Read MCP resource",summary:[xn(e,"server"),xn(e,"uri")].filter(Boolean).join(" · "),styleName:"Mcp"};case"request_plugin_install":return{label:"Install plugin",summary:xn(e,"plugin_id"),styleName:"Mcp"};case"tool_search":return{label:"Find tools",summary:xn(e,"query"),styleName:"ToolSearch"};case"image_gen__imagegen":return{label:"Generate image",summary:xn(e,"prompt"),styleName:"Image"};case"spawn_agent":return{label:"Spawn agent",summary:Hr(xn(e,"task_name","message")),styleName:"Task"};case"send_message":case"followup_task":return{...yu[Os(n.name)],summary:[xn(e,"target"),Hr(xn(e,"message"))].filter(Boolean).join(" · ")};default:{const t=Os(n.name),s=yu[t];return t.startsWith("mcp__")?Qz(t,e):{label:(s==null?void 0:s.label)??Qa(t),summary:Hr(wu(e)),styleName:(s==null?void 0:s.styleName)??t}}}}function tD(n){const e=z3(n);if(e.length===0)return{label:"Run tool script",summary:"",styleName:"exec"};const t=e.map(eD),s=t[0];if(t.every(o=>o.label===s.label)){const o=Al(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 nD(n){const e=g4(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:Ht(e==null?void 0:e.url,n.query),styleName:"WebSearch"};if(t==="find_in_page"||t==="findInPage")return{label:"Find on page",summary:[Ht(e==null?void 0:e.pattern),Ht(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=Ht(e==null?void 0:e.query,n.query);return{label:"Search web",summary:Al([r,...s]),styleName:"WebSearch"}}const sD=["summary","headline","verdict","title"];function rD(n){const e=Ht(...sD.map(t=>n[t]));if(e)return kr(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 oD(n){const e=Ht(n.description);if(e)return kr(e);const t=Ht(n.script);return(t?Hg(t,"name")[0]??"":"")||Ht(n.scriptPath)}function tv(n){const e=Ht(...["description","summary","query","q","command","cmd","file_path","path","url","uri","pattern","prompt","objective","message","title","name"].map(s=>n[s]));if(e)return kr(e);const t=Object.entries(n).find(([s,r])=>s!=="raw"&&s!=="script"&&typeof r=="string");return t?kr(t[1]):""}function nv(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 Fo(e);case"write_stdin":return[e.session_id!==void 0?`session ${e.session_id}`:"",Ht(e.chars)].filter(Boolean).join(" · ");case"apply_patch":return v4(Ht(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?Sd(t.length,"step"):Ht(e.explanation)}case"Grep":case"Glob":return String(e.pattern??"");case"Task":case"Agent":return Hr(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(g4):null;return Ht(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=Ht(e.to,e.recipient),s=kr(Hr(Ht(e.summary,e.message,e.content)));return[t,s].filter(Boolean).join(" · ")}case"ListAgents":case"TaskList":return"";case"TaskCreate":return kr(Ht(e.subject,e.description));case"TaskUpdate":{const t=String(e.taskId??""),s=Array.isArray(e.addBlockedBy)?e.addBlockedBy.filter(o=>typeof o=="string"):[],r=Ht(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 oD(e);case"SendFeedback":return Ht(e.title,e.details);case"Artifact":return[Ht(e.action),Ht(e.title,e.file_path,e.url),Ht(e.asset_id)].filter(Boolean).join(" · ");case"StructuredOutput":case"ReportFindings":case"DesignSync":case"LSP":return rD(e)||tv(e);case"spawn_agent":return Hr(e.task_name??e.message);case"wait_agent":{const t=Array.isArray(e.ids)?e.ids.filter(s=>typeof s=="string"):[];return Al(t)}case"send_message":case"followup_task":return[e.target,Hr(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 tv(e)}}function Ki(n){if(Kg(n))return tD(n.input.raw);const e=Os(n.name);if(e==="WebSearch"||e==="web_search")return nD(n.input);if(e==="web__run"||e==="web.run")return x4(JSON.stringify(n.input));const t=b4(n.name);if(t)return{label:t.server,summary:[t.action,nv(n)].filter(Boolean).join(" · "),styleName:"Mcp"};const s=yu[e];return{label:(s==null?void 0:s.label)??Qa(e),summary:kr(nv({name:e,input:n.input})),styleName:(s==null?void 0:s.styleName)??e}}function iD(n){return Ki(n).summary}const aD={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 lD(n){return aD[n]??n.replace(/_/g," ").replace(/^./,e=>e.toUpperCase())}function cD(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 el(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=Hr(t);i=p.length>800,l=o;const h=s&&"max-h-96 overflow-auto";e[7]!==h?(c=K("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(J,{type:"button",variant:"ghost",size:"xs","aria-expanded":s,"aria-controls":o,onClick:()=>r(uD),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 uD(n){return!n}function dD(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 fD(n){const e=q.c(4),{steps:t}=n;let s;e[0]!==t?(s=t.map(mD),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 mD(n,e){const t=n.status==="completed",s=n.status==="in_progress",r=t?Bt:s?P6:Qh,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:K("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(el,{value:n.text})}),a.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:o})]},e)}function pD(n){const e=q.c(4),{questions:t}=n;let s;e[0]!==t?(s=t.map(hD),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 hD(n,e){return a.jsxs("div",{className:"min-w-0 text-xs",children:[a.jsx(el,{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(gD)})]},e)}function gD(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(el,{value:t.label}),typeof t.description=="string"&&a.jsx("div",{className:"mt-0.5 text-muted-foreground",children:a.jsx(el,{value:t.description})})]},e)}function y4(n){const e=q.c(21),{input:t}=n;let s;e[0]!==t?(s=dD(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(vD):[],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(bD);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(fD,{steps:r}),e[12]=r,e[13]=c):c=e[13],e[14]!==i?(u=i.length>0&&a.jsx(pD,{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(xD)})}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 xD(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:lD(e)}),a.jsx("dd",{className:"min-w-0 leading-relaxed",children:a.jsx(el,{value:cD(e,t)})})]},e)}function bD(n){const[e,t]=n;return e!=="raw"&&e!=="type"&&(typeof t=="string"?t.length>0:typeof t=="number"||typeof t=="boolean")}function vD(n){return n!==null&&typeof n=="object"&&typeof(n.question??n.title)=="string"}function yD(n){const e=q.c(25),{name:t,input:s}=n;let r;e[0]!==s||e[1]!==t?(r=Ki(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=Fo(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(wD)):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(p3,{code:l,language:"bash",label:"Command"}),e[16]=l,e[17]=p):p=e[17];let h;e[18]!==u?(h=a.jsx(y4,{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 wD(n){const[e]=n;return e!=="command"&&e!=="cmd"}function SD(n){const e=q.c(32),{input:t}=n,s=String(t.raw??"");let r;e[0]!==t?(r=W3(t),e[0]=t,e[1]=r):r=e[1];const o=r,[i,l]=w.useState(!1),[c,u]=Sr(),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(jD)}),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(J,{type:"button",variant:"ghost",size:"xs","aria-expanded":f,"aria-controls":d,onClick:()=>l(kD),children:[a.jsx(at,{"data-icon":"inline-start",className:K(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(Bt,{"data-icon":"icon"}):a.jsx(fs,{"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(J,{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 v;e[17]!==p||e[18]!==b?(v=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]=v):v=e[19];let y;e[20]!==s?(y=a.jsx(p3,{code:s,language:"typescript",label:"Codex exec script"}),e[20]=s,e[21]=y):y=e[21];let k;e[22]!==d||e[23]!==y?(k=a.jsx(Sn,{id:d,children:y}),e[22]=d,e[23]=y,e[24]=k):k=e[24];let j;e[25]!==f||e[26]!==k?(j=a.jsx(wn,{open:f,children:k}),e[25]=f,e[26]=k,e[27]=j):j=e[27];let C;return e[28]!==j||e[29]!==m||e[30]!==v?(C=a.jsxs("section",{className:"mt-2 min-w-0","aria-label":"Tool script",children:[m,v,j]}),e[28]=j,e[29]=m,e[30]=v,e[31]=C):C=e[31],C}function kD(n){return!n}function jD(n,e){return a.jsx(yD,{...n},e)}const ND=/(?:^|;|&&)\s*echo\s+(["']?)---([\w.-]*)\1\s*(?=;|&&|$)/g;function sv(n){return n.replace(/^\s*(?:;|&&)/,"").trim()}function w4(n,e){const t=[],s=[];let r=0;for(const l of n.matchAll(ND)){const c=sv(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=sv(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:CD(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 CD(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 _D=new Set(["mv","cp","rm","mkdir","touch","tee","ln","chmod","chown","install","rsync"]),TD=/(?:^|[^\d&])>{1,2}(?!\s*&|\s*\/dev\/null)/,ED=/\|\||&&|[|;\n]/,AD=new Set(["echo","printf","true","false",":"]),PD=new Set(["find","grep","rg","ag","ack","locate","which","whereis"]),ID=new Set(["cat","head","tail","less","more","wc","stat","file","strings","jq","awk","cut","sort","uniq","tr","sed","diff","xxd","od"]),$D=new Set(["ls","tree","du"]),RD=new Set(["xargs","sudo","env","time","nohup","command"]);function OD(n){const e=n.split(/\s+/);for(;e.length>1&&(RD.has(e[0])||/^-/.test(e[0]));)e.shift();const[t,...s]=e;return _D.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:TD.test(n)}const S4=/<<-?\s*['"]?\w+['"]?/,MD=/'[^']*'|"(?:[^"\\]|\\.)*"/g;function LD(n){return n.split(S4)[0].replace(MD,'""').split(ED).map(e=>e.trim()).filter(Boolean)}function zD(n){const e=LD(n);if(e.some(OD))return"write";let t=!1,s=!1,r=!1;for(const o of e){const i=o.split(/\s+/)[0];if(!(!i||AD.has(i)))if(PD.has(i))t=!0;else if(ID.has(i))s=!0;else if($D.has(i))r=!0;else return"run"}return r?"list":t?"search":s?"read":"run"}const DD=/^["']?((?:~|\.{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 k4(n){const e=new Set;for(const t of n.split(S4)[0].split(/\s+/)){const s=t.match(DD);if(!s)continue;const r=s[1];r.includes("*")||r.includes("{")||r.startsWith("-")||e.add(r)}return[...e]}const FD=/^(?: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 UD(n){const e=n.trim().match(FD);if(!e)return null;const[,t,s,,r]=e;return k4(r).length?t?{path:r,from:Number(t),to:Number(s)}:{path:r}:null}const BD=/(?: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 WD(n,e){return!e||n==="read"&&e.split(`
|
|
109
|
+
`).length>3?!1:BD.test(e)}function j4(n){const e=zD(n.command);return{kind:e,paths:k4(n.command),readFile:e==="read"?UD(n.command):null,failed:WD(e,n.output)}}function qD(n){var e;return n.label||((e=n.command.match(/^[\w.-]+/))==null?void 0:e[0])||"…"}const VD={read:{icon:Ca,label:"Read file"},search:{icon:Bn,label:"Search"},list:{icon:Si,label:"List files"},run:{icon:Li,label:"Run command"},write:{icon:Cp,label:"Update files"}},HD=new Set(["command","cmd","description","timeout","run_in_background"]);function N4(n){const e=Fo(n.input);return w4(e,n.result)??[{label:"",command:e,output:n.result}]}function KD(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 GD(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 ZD(n){return n.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase())}function YD(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 XD(n){const e=[];n.timeout!==void 0&&e.push(GD(n.timeout)),typeof n.run_in_background=="boolean"&&e.push(n.run_in_background?"Background":"Foreground");for(const[t,s]of Object.entries(n))HD.has(t)||s===void 0||e.push(`${ZD(t)} ${YD(s)}`);return e}function JD(n,e){const t=N4(n),s=t.map(j4),r=KD(n,t,s);return{command:Fo(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:XD(n.input)}}function QD(n){return n?n.split(/\r\n|\r|\n/).length:0}function eF(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=QD(n.section.output);return e===1?"1 line":`${e} lines`}function tF(n,e){return n.startsWith("/")?n:n.startsWith("~")||!e?null:`${e.replace(/\/$/,"")}/${n.replace(/^\.\//,"")}`}function C4(n){const e=q.c(12),{path:t,line:s,cwd:r,children:o}=n;let i;e[0]!==r||e[1]!==t?(i=tF(t,r),e[0]=r,e[1]=t,e[2]=i):i=e[2];const l=i;if(!l||!gt("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(),Ka(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 _4(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(C4,{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 nF=/^([^\s:]+):(\d+)([:-])/;function sF(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(nF);return a.jsx("span",{className:"block",children:u?a.jsxs(a.Fragment,{children:[a.jsxs(C4,{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:zg,children:r}),e[5]=r,e[6]=o):o=e[6],o}function T4(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(ht,{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(sF,{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(x3,{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 rF(n){var $;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=qD(t.section),e[0]=t.section,e[1]=u):u=e[1];const d=`${u} section: ${t.section.command}`,{icon:f,label:m}=VD[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=K("shrink-0 text-xs tabular-nums text-muted-foreground",x),e[6]=x,e[7]=b):b=e[7];let v;e[8]!==t?(v=eF(t),e[8]=t,e[9]=v):v=e[9];let y;e[10]!==b||e[11]!==v?(y=a.jsx("span",{className:b,children:v}),e[10]=b,e[11]=v,e[12]=y):y=e[12];let k;e[13]!==c||e[14]!==l?(k=c&&a.jsx(at,{className:K("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]!==y||e[19]!==k?(j=a.jsxs(a.Fragment,{children:[p,g,y,k]}),e[16]=p,e[17]=g,e[18]=y,e[19]=k,e[20]=j):j=e[20];const C=j;let _;e[21]!==s?(_=M=>{s||i(M)},e[21]=s,e[22]=_):_=e[22];let S;e[23]!==C||e[24]!==s||e[25]!==c||e[26]!==d?(S=c?a.jsx(ds,{className:K("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:C}):a.jsx("div",{className:"flex min-h-9 w-full min-w-0 items-center gap-2 text-left","aria-label":d,children:C}),e[23]=C,e[24]=s,e[25]=c,e[26]=d,e[27]=S):S=e[27];const N=l||!c?"whitespace-pre-wrap break-words [overflow-wrap:anywhere]":"truncate";let T;e[28]!==N?(T=K("min-w-0 flex-1 font-mono text-xs leading-relaxed text-foreground/85",N),e[28]=N,e[29]=T):T=e[29];let E;e[30]!==r||e[31]!==t.analysis.paths||e[32]!==t.section.command?(E=a.jsx(_4,{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]=E):E=e[33];let A;e[34]!==T||e[35]!==E?(A=a.jsx("code",{className:T,children:E}),e[34]=T,e[35]=E,e[36]=A):A=e[36];let P;e[37]!==t.analysis.readFile?(P=(($=t.analysis.readFile)==null?void 0:$.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 O;e[42]!==r||e[43]!==c||e[44]!==t?(O=c&&a.jsx(Sn,{children:a.jsx("div",{className:"pb-1 pl-5.5",children:a.jsx(T4,{row:t,cwd:r})})}),e[42]=r,e[43]=c,e[44]=t,e[45]=O):O=e[45];let R;return e[46]!==l||e[47]!==_||e[48]!==S||e[49]!==I||e[50]!==O?(R=a.jsxs(wn,{open:l,onOpenChange:_,className:"min-w-0 py-2",children:[S,I,O]}),e[46]=l,e[47]=_,e[48]=S,e[49]=I,e[50]=O,e[51]=R):R=e[51],R}function oF(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=JD(t,l),e[0]=l,e[1]=t,e[2]=c):c=e[2];const u=c,d=u.rows.length,[f,m]=Sr(),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",v=f?"Copied":d===1?"Copy command":"Copy commands";let y;e[8]!==f?(y=f?a.jsx(Bt,{"data-icon":"inline-start","aria-hidden":"true"}):a.jsx(fs,{"data-icon":"inline-start","aria-hidden":"true"}),e[8]=f,e[9]=y):y=e[9];let k;e[10]!==y||e[11]!==x||e[12]!==b||e[13]!==v?(k=a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:x,"aria-label":b,title:v,children:y}),e[10]=y,e[11]=x,e[12]=b,e[13]=v,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 C;e[18]!==u.options?(C=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(iF)}),e[18]=u.options,e[19]=C):C=e[19];let _;e[20]!==u.command||e[21]!==u.rows||e[22]!==d||e[23]!==s||e[24]!==i?(_=d===1?a.jsxs(a.Fragment,{children:[a.jsx("pre",{className:"min-w-0 whitespace-pre-wrap break-words rounded-md bg-muted/40 p-3 font-mono text-xs leading-relaxed text-foreground [overflow-wrap:anywhere]",children:a.jsx(_4,{command:u.command,paths:u.rows[0].analysis.paths,cwd:s})}),a.jsx(T4,{row:u.rows[0],cwd:s})]}):a.jsx("div",{className:"min-w-0",children:u.rows.map((T,E)=>a.jsxs("div",{className:"min-w-0",children:[E>0&&a.jsx(Zt,{}),a.jsx(rF,{row:T,expandAll:i,cwd:s})]},E))}),e[20]=u.command,e[21]=u.rows,e[22]=d,e[23]=s,e[24]=i,e[25]=_):_=e[25];let S;e[26]!==C||e[27]!==_?(S=a.jsxs("div",{className:"flex min-w-0 flex-col gap-2","aria-label":"Command sections",children:[C,_]}),e[26]=C,e[27]=_,e[28]=S):S=e[28];let N;return e[29]!==j||e[30]!==S||e[31]!==p?(N=a.jsxs("section",{className:"min-w-0","aria-label":p,children:[j,S]}),e[29]=j,e[30]=S,e[31]=p,e[32]=N):N=e[32],N}function iF(n){return a.jsx("span",{children:n},n)}const E4=w.createContext({size:"default",variant:"default",spacing:2,orientation:"horizontal"});function aF(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=K("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(E4.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(I6,{"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 lF(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(E4),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=K("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",bk({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(kS,{"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 A4(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=K("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(Bt,{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(Fe,{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 cF(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(uF)),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 N=o.map(T=>{var A;const E=(A=l[T.question])==null?void 0:A.trim();return E?o.length>1?`${T.question}
|
|
110
|
+
${E}`:E:null}).filter(Boolean).join(`
|
|
111
|
+
|
|
112
|
+
`);N&&h(N),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 N=async T=>{T.preventDefault(),d(!0);try{(await jg(s,t.id,l)).ok?m(!0):x()}catch{x()}d(!1)};b=T=>{N(T)},e[8]=l,e[9]=x,e[10]=s,e[11]=t.id,e[12]=b}else b=e[12];const v=f&&"pointer-events-none opacity-50";let y;e[13]!==v?(y=K("flex flex-col gap-3",v),e[13]=v,e[14]=y):y=e[14];let k;if(e[15]!==l||e[16]!==o||e[17]!==t.id){let N;e[19]!==l||e[20]!==t.id?(N=(T,E)=>{const A=T.options&&T.options.length>0,P=new Set(T.multiSelect?(l[T.question]??"").split(", ").filter(Boolean):[]),I=`ask-user-answer-${t.id}-${E}`;return a.jsxs(_I,{className:"gap-2 border-b border-border pb-3 last:border-b-0 last:pb-0",children:[(T.header||T.question)&&a.jsxs(TI,{variant:"label",className:"flex flex-col items-start gap-1",children:[T.header&&a.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:T.header}),a.jsx("span",{className:"text-sm leading-relaxed text-foreground",children:T.question})]}),A?a.jsx(aF,{multiple:T.multiSelect,orientation:"vertical",variant:"outline",value:T.multiSelect?Array.from(P):l[T.question]?[l[T.question]]:[],onValueChange:O=>{if(!T.multiSelect&&O.length===0)return;const R=T.multiSelect?O.join(", "):O[0];c({...l,[T.question]:R})},className:"grid w-full gap-1.5",children:T.options.map((O,R)=>{const $=T.multiSelect?P.has(O.label):l[T.question]===O.label;return a.jsx(lF,{value:O.label,"aria-label":O.label,className:"h-auto w-full justify-start whitespace-normal px-3 py-2.5 text-left",children:a.jsx(A4,{option:O,multiSelect:T.multiSelect,selected:$})},R)})}):a.jsxs(Lt,{children:[a.jsx(zt,{htmlFor:I,children:"Answer"}),a.jsx(dd,{id:I,value:l[T.question]??"",onChange:O=>{c({...l,[T.question]:O.target.value})},rows:2,placeholder:"Type your answer..."})]})]},E)},e[19]=l,e[20]=t.id,e[21]=N):N=e[21],k=o.map(N),e[15]=l,e[16]=o,e[17]=t.id,e[18]=k}else k=e[18];const j=u||f,C=f?"Sent":u?"Sending...":"Send answer";let _;e[22]!==C||e[23]!==j?(_=a.jsx(J,{type:"submit",size:"sm",disabled:j,children:C}),e[22]=C,e[23]=j,e[24]=_):_=e[24];let S;return e[25]!==_||e[26]!==b||e[27]!==y||e[28]!==k?(S=a.jsxs("form",{onSubmit:b,className:y,children:[k,_]}),e[25]=_,e[26]=b,e[27]=y,e[28]=k,e[29]=S):S=e[29],S}function uF(n){return[n.question,""]}function dF(n){return Array.isArray(n.input.questions)?n.input.questions.filter(e=>typeof e=="object"&&e!==null&&typeof e.question=="string"):[]}function rv(n){try{return JSON.parse(`"${n}"`)}catch{return n.replace(/\\"/g,'"').replace(/\\\\/g,"\\")}}function fF(n){const e={},t=/"((?:\\.|[^"\\])*)"\s*=\s*"((?:\\.|[^"\\])*)"/g;let s;for(;(s=t.exec(n))!==null;)e[rv(s[1])]=rv(s[2]);return e}function mF(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function pF(n,e){const t=(n.options??[]).filter(s=>{const r=s.label.trim();return r?new RegExp(`(^|[^\\p{L}\\p{N}])${mF(r)}(?=$|[^\\p{L}\\p{N}])`,"iu").test(e):!1});return t.length===1?t[0].label:void 0}function hF(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=fF(n.result);for(const r of e)if(s[r.question]===void 0){const o=pF(r,n.result);o!==void 0&&(s[r.question]=o)}return s}function ov(n,e,t){return e===void 0?!1:n.multiSelect?e.split(/,\s*/).includes(t):e===t}function gF(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 y;e[6]!==s||e[7]!==t?(y=k=>ov(t,s,k.label),e[6]=s,e[7]=t,e[8]=y):y=e[8],c=l.filter(y),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(Fe,{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((y,k)=>{const j=ov(t,s,y.label);return a.jsx("div",{className:K("flex items-start gap-2.5 py-2",j?"text-foreground":"text-muted-foreground"),children:a.jsx(A4,{option:y,multiSelect:t.multiSelect,selected:j,showSelectedBadge:!0})},`${y.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 v;return e[25]!==h||e[26]!==g||e[27]!==x||e[28]!==b?(v=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]=v):v=e[29],v}function xF(n){const e=q.c(62),{toolCall:t,expandToolPayloads:s,isAwaitingAnswer:r,sessionId:o}=n,[i,l]=w.useState(!1);let c;e[0]!==t?(c=dF(t),e[0]=t,e[1]=c):c=e[1];const u=c;let d;e[2]!==u||e[3]!==t?(d=hF(t,u),e[2]=u,e[3]=t,e[4]=d):d=e[4];const f=d,m=s||i,p=t.result!==null&&!t.isError&&!t.asyncQuestion,h=!p&&!t.isError&&r&&!!o&&u.length>0;let g;e[5]!==f?(g=Object.keys(f),e[5]=f,e[6]=g):g=e[6];const x=g.length>0,b=t.isError?zs:p?Tr:ru,v=t.isError?"Not answered":p?"Answered":h?"Waiting for answer":"No answer recorded",y=t.isError&&"border-destructive/30";let k;e[7]!==y?(k=K("my-1 overflow-hidden rounded-lg border bg-card",y),e[7]=y,e[8]=k):k=e[8];let j;e[9]===Symbol.for("react.memo_cache_sentinel")?(j=a.jsx(tg,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground","data-icon":"inline-start"}),e[9]=j):j=e[9];let C;e[10]===Symbol.for("react.memo_cache_sentinel")?(C=a.jsx("h3",{className:"text-sm font-medium text-foreground",children:"Decision requested"}),e[10]=C):C=e[10];const _=u.length===1?"question":"questions";let S;e[11]!==u.length||e[12]!==_?(S=a.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[C,a.jsxs("span",{className:"text-xs text-muted-foreground",children:[u.length," ",_]})]}),e[11]=u.length,e[12]=_,e[13]=S):S=e[13];const N=t.isError?"destructive":p?"secondary":"outline";let T;e[14]!==b?(T=a.jsx(b,{"data-icon":"inline-start"}),e[14]=b,e[15]=T):T=e[15];let E;e[16]!==v||e[17]!==N||e[18]!==T?(E=a.jsxs(Fe,{variant:N,children:[T,v]}),e[16]=v,e[17]=N,e[18]=T,e[19]=E):E=e[19];let A;e[20]!==E||e[21]!==S?(A=a.jsxs("div",{className:"min-w-0 flex-1",children:[S,E]}),e[20]=E,e[21]=S,e[22]=A):A=e[22];let P;e[23]!==t.timestamp?(P=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]=P):P=e[24];let I;e[25]!==A||e[26]!==P?(I=a.jsxs("header",{className:"flex items-start gap-2.5 border-b px-3 py-2.5",children:[j,A,P]}),e[25]=A,e[26]=P,e[27]=I):I=e[27];let O;e[28]!==f||e[29]!==h||e[30]!==u||e[31]!==o||e[32]!==t?(O=h&&o?a.jsx(cF,{toolCall:t,sessionId:o}):u.length>0?u.map((U,W)=>a.jsx(gF,{question:U,answer:f[U.question],index:W,completed:t.result!==null&&!t.asyncQuestion},`${U.question}-${W}`)):a.jsx("p",{className:"py-3 text-sm text-muted-foreground",children:"Question details are unavailable."}),e[28]=f,e[29]=h,e[30]=u,e[31]=o,e[32]=t,e[33]=O):O=e[33];let R;e[34]!==x||e[35]!==t.asyncQuestion||e[36]!==t.isError||e[37]!==t.result?(R=t.result!==null&&!t.asyncQuestion&&!x&&a.jsxs("div",{className:K("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[34]=x,e[35]=t.asyncQuestion,e[36]=t.isError,e[37]=t.result,e[38]=R):R=e[38];let $;e[39]!==O||e[40]!==R?($=a.jsxs("div",{className:"px-3",children:[O,R]}),e[39]=O,e[40]=R,e[41]=$):$=e[41];let M;e[42]!==s?(M=()=>{s||l(bF)},e[42]=s,e[43]=M):M=e[43];let z;e[44]!==m?(z=m?a.jsx(It,{"data-icon":"inline-start"}):a.jsx(at,{"data-icon":"inline-start"}),e[44]=m,e[45]=z):z=e[45];let F;e[46]!==m||e[47]!==M||e[48]!==z?(F=a.jsxs(J,{type:"button",variant:"ghost",size:"xs",onClick:M,className:"-ml-2 text-muted-foreground","aria-expanded":m,children:[z,"Raw details"]}),e[46]=m,e[47]=M,e[48]=z,e[49]=F):F=e[49];let D;e[50]!==m||e[51]!==t.input||e[52]!==t.result?(D=m&&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[50]=m,e[51]=t.input,e[52]=t.result,e[53]=D):D=e[53];let L;e[54]!==F||e[55]!==D?(L=a.jsxs("div",{className:"border-t px-3 py-1.5",children:[F,D]}),e[54]=F,e[55]=D,e[56]=L):L=e[56];let B;return e[57]!==I||e[58]!==$||e[59]!==L||e[60]!==k?(B=a.jsxs("section",{className:k,"aria-label":"Question history",children:[I,$,L]}),e[57]=I,e[58]=$,e[59]=L,e[60]=k,e[61]=B):B=e[61],B}function bF(n){return!n}function vF(n){const e=q.c(4),{styleName:t}=n;let s;e[0]!==t?(s={Read:Ca,Write:yr,Edit:yr,Bash:yi,Grep:Bn,Glob:R6,WebFetch:wi,WebSearch:wi,TodoWrite:$6,Task:Bs,SendMessage:Di,AskUserQuestion:tg,Skill:Da}[t]??SS,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 yF={failed:{Icon:po,label:"Failed",description:"failed"},awaitingReview:{Icon:ru,label:"Awaiting review",description:"awaiting review"},running:{Icon:ht,label:"Running",description:"running"},unavailable:{Icon:ru,label:"No result",description:"has no result"},completed:{Icon:Bt,label:"Completed",description:"completed"}};function wF(n,e,t){return e?"failed":n.awaitingReview?"awaitingReview":n.result!==null?"completed":t?"running":"unavailable"}function SF({toolCall:n,failed:e=!!n.isError,isAgentActive:t}){const s=wF(n,e,t),{Icon:r,label:o,description:i}=yF[s],l=s==="running";return a.jsxs("span",{className:K("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:K("size-3.5",l&&"motion-safe:animate-spin")}),a.jsx("span",{className:K(s==="completed"&&"sr-only"),children:o})]})}function kF(n){const e=q.c(7),{fileDiffs:t,additionalFileDiffs:s}=n;let r;e[0]!==t?(r=t==null?void 0:t.map(jF),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 jF(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(b3,{className:"language-diff",children:OO(n)})]},n.filePath)}const NF={"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 p1(n){var t;if(n.isError)return!0;const e=Fo(n.input);return!e||n.result===null||Ki(n).styleName!=="Bash"?!1:((t=w4(e,n.result))==null?void 0:t.some(s=>j4(s).failed))??!1}function CF(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){p1(r)?s.failed++:r.awaitingReview?s.awaitingReview++:r.result!==null?s.completed++:e?s.running++:s.unavailable++;const{label:o}=Ki(r),i=NF[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 _F(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 TF=3;function EF(n,e,t=!1){if(!e)return{visible:[...n],hidden:0};const s=n.length-TF,r=n.filter((o,i)=>i>=s||o.kind==="tool_call"&&(p1(o.toolCall)||o.toolCall.awaitingReview||t&&o.toolCall.result===null));return{visible:r,hidden:n.length-r.length}}function AF(n,e=!1){return e?"text-destructive":Kz(n)==="mutating"?"text-foreground":"text-muted-foreground"}function PF(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"&&Qg(e)?e:null}function IF(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=K("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=K("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 $F(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(f1,{oldString:s,newString:r,filePath:o}),e[0]=s,e[1]=r,e[2]=o,e[3]=i):i=e[3],i}const P4=w.memo(function(e){var ge,be,ue,he;const t=q.c(187),{toolCall:s,expandToolPayloads:r,isAgentActive:o,skillMetadata:i}=e,l=r===void 0?!1:r,{session:c,pendingInteraction:u}=xt(),[d,f]=w.useState(!1),[m,p]=w.useState(!1),h=w.useId(),g=w.useId(),x=w.useId();let b;t[0]!==s?(b=Kg(s),t[0]=s,t[1]=b):b=t[1];const v=b;let y;t[2]!==v||t[3]!==s.input||t[4]!==s.name?(y=!v&&(s.name==="Bash"||/(?:^|[._])exec_command$/.test(s.name))&&!!Fo(s.input),t[2]=v,t[3]=s.input,t[4]=s.name,t[5]=y):y=t[5];const k=y;let j;t[6]!==s?(j=Ki(s),t[6]=s,t[7]=j):j=t[7];const C=j;let _;t[8]!==k||t[9]!==s?(_=k?N4(s):null,t[8]=k,t[9]=s,t[10]=_):_=t[10];const S=_;let N;t[11]!==s?(N=p1(s),t[11]=s,t[12]=N):N=t[12];const T=N,E=C.label,A=C.label===s.name?s.name:`${C.label} (${s.name})`;let P,I,O,R,$,M,z,F,D,L;if(t[13]!==E||t[14]!==l||t[15]!==T||t[16]!==k||t[17]!==o||t[18]!==A||t[19]!==h||t[20]!==d||t[21]!==u||t[22]!==C.styleName||t[23]!==C.summary||t[24]!==S||t[25]!==(c==null?void 0:c.sessionId)||t[26]!==i||t[27]!==x||t[28]!==s){z=Symbol.for("react.early_return_sentinel");e:{const me=AF(C.styleName,T);let xe;t[39]!==s.timestamp?(xe=s.timestamp?new Date(s.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}):void 0,t[39]=s.timestamp,t[40]=xe):xe=t[40];const je=xe;let Le;t[41]!==s.timestamp?(Le=s.timestamp?new Date(s.timestamp).toISOString():void 0,t[41]=s.timestamp,t[42]=Le):Le=t[42];const Se=Le;I=l||d;let Ie;t[43]!==k||t[44]!==C.summary||t[45]!==S||t[46]!==s.input?(Ie=k&&typeof s.input.description=="string"&&s.input.description.trim()?s.input.description:S&&S.length>1?`${S.length} commands · ${S.map(RF).join(", ")}`:C.summary,t[43]=k,t[44]=C.summary,t[45]=S,t[46]=s.input,t[47]=Ie):Ie=t[47];const we=Ie;let Be;t[48]!==i||t[49]!==we||t[50]!==s.name?(Be=s.name==="Skill"&&i?i.get(we)??null:null,t[48]=i,t[49]=we,t[50]=s.name,t[51]=Be):Be=t[51],$=Be,R=$==null?void 0:$.filePath,P=s.name==="Edit"&&typeof s.input.old_string=="string"&&typeof s.input.new_string=="string"&&typeof s.input.file_path=="string";const De=PF(s),Ue=!!((ge=s.resultImages)!=null&&ge.length),We=De!==null&&((be=s.result)==null?void 0:be.trim())===""&&!Ue;let Oe;if(t[52]!==k||t[53]!==P||t[54]!==We||t[55]!==Ue||t[56]!==s.awaitingReview||t[57]!==s.isError||t[58]!==s.result?(Oe=s.result!==null&&!We&&!k&&(!Ue||!!((ue=s.result)!=null&&ue.trim()))&&(!P||s.isError||s.awaitingReview),t[52]=k,t[53]=P,t[54]=We,t[55]=Ue,t[56]=s.awaitingReview,t[57]=s.isError,t[58]=s.result,t[59]=Oe):Oe=t[59],O=Oe,s.name==="AskUserQuestion"){const Gn=(u==null?void 0:u.type)==="question"&&u.toolUseId===s.id,en=c==null?void 0:c.sessionId;let Mn;t[60]!==l||t[61]!==Gn||t[62]!==en||t[63]!==s?(Mn=a.jsx(xF,{toolCall:s,expandToolPayloads:l,isAwaitingAnswer:Gn,sessionId:en}),t[60]=l,t[61]=Gn,t[62]=en,t[63]=s,t[64]=Mn):Mn=t[64],z=Mn;break e}const pe=I&&"bg-muted/25",ke=T&&"bg-destructive/5";t[65]!==pe||t[66]!==ke?(F=K("min-w-0 rounded-lg",pe,ke),t[65]=pe,t[66]=ke,t[67]=F):F=t[67],D=s.id;const _e=`Toggle ${E} details${we?`: ${we}`:""}`;let ye;t[68]!==l?(ye=()=>{l||f(OF)},t[68]=l,t[69]=ye):ye=t[69];const Pe=T&&"text-destructive";let Ye;t[70]!==Pe?(Ye=K("flex size-8 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground",Pe),t[70]=Pe,t[71]=Ye):Ye=t[71];let Xe;t[72]!==C.styleName?(Xe=a.jsx(vF,{styleName:C.styleName}),t[72]=C.styleName,t[73]=Xe):Xe=t[73];let Ee;t[74]!==Ye||t[75]!==Xe?(Ee=a.jsx("span",{className:Ye,children:Xe}),t[74]=Ye,t[75]=Xe,t[76]=Ee):Ee=t[76];const Ze=we&&a.jsx(IF,{summary:we,filePath:[s.input.file_path,s.input.path,s.input.notebook_path].includes(we),monospace:!k||!s.input.description,className:K("text-[13px] font-medium",me)}),fe=K(we?"text-xs text-muted-foreground":K("text-[13px] font-medium",me),"leading-5");let Te;t[77]!==E||t[78]!==A||t[79]!==fe?(Te=a.jsx("span",{className:fe,title:A,children:E}),t[77]=E,t[78]=A,t[79]=fe,t[80]=Te):Te=t[80];let Ve;t[81]!==Ze||t[82]!==Te?(Ve=a.jsxs("span",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[Ze,Te]}),t[81]=Ze,t[82]=Te,t[83]=Ve):Ve=t[83];let He;t[84]!==T||t[85]!==o||t[86]!==s?(He=a.jsx(SF,{toolCall:s,failed:T,isAgentActive:o}),t[84]=T,t[85]=o,t[86]=s,t[87]=He):He=t[87];let $e;t[88]!==s.hookDurationMs?($e=!!(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[88]=s.hookDurationMs,t[89]=$e):$e=t[89];let tt;t[90]!==s.outputReplacedByHook?(tt=s.outputReplacedByHook&&a.jsx("span",{className:"text-xs text-info",title:"Output replaced by hook",children:"hook"}),t[90]=s.outputReplacedByHook,t[91]=tt):tt=t[91];let bt;t[92]!==x||t[93]!==He||t[94]!==$e||t[95]!==tt?(bt=a.jsxs("span",{id:x,className:"flex shrink-0 flex-col items-end gap-1",children:[He,$e,tt]}),t[92]=x,t[93]=He,t[94]=$e,t[95]=tt,t[96]=bt):bt=t[96];const ut=I&&"rotate-90";let vt;t[97]!==ut?(vt=K("size-3.5 shrink-0 text-muted-foreground transition-transform",ut),t[97]=ut,t[98]=vt):vt=t[98];let un;t[99]!==vt?(un=a.jsx(at,{className:vt,"aria-hidden":"true"}),t[99]=vt,t[100]=un):un=t[100];let Nt;t[101]!==Se||t[102]!==je?(Nt=je&&a.jsx("time",{className:"sr-only",dateTime:Se,children:je}),t[101]=Se,t[102]=je,t[103]=Nt):Nt=t[103],t[104]!==h||t[105]!==I||t[106]!==x||t[107]!==_e||t[108]!==ye||t[109]!==Ee||t[110]!==Ve||t[111]!==bt||t[112]!==un||t[113]!==Nt||t[114]!==je?(L=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:je,"aria-label":_e,"aria-expanded":I,"aria-controls":h,"aria-describedby":x,onClick:ye,children:[Ee,Ve,bt,un,Nt]}),t[104]=h,t[105]=I,t[106]=x,t[107]=_e,t[108]=ye,t[109]=Ee,t[110]=Ve,t[111]=bt,t[112]=un,t[113]=Nt,t[114]=je,t[115]=L):L=t[115],M=We&&a.jsx(Kp,{src:De,alt:De.slice(De.lastIndexOf("/")+1),id:`tool-image:${s.id}`,className:"my-1.5",thumbnailClassName:"max-h-40"})}t[13]=E,t[14]=l,t[15]=T,t[16]=k,t[17]=o,t[18]=A,t[19]=h,t[20]=d,t[21]=u,t[22]=C.styleName,t[23]=C.summary,t[24]=S,t[25]=c==null?void 0:c.sessionId,t[26]=i,t[27]=x,t[28]=s,t[29]=P,t[30]=I,t[31]=O,t[32]=R,t[33]=$,t[34]=M,t[35]=z,t[36]=F,t[37]=D,t[38]=L}else P=t[29],I=t[30],O=t[31],R=t[32],$=t[33],M=t[34],z=t[35],F=t[36],D=t[37],L=t[38];if(z!==Symbol.for("react.early_return_sentinel"))return z;let B;t[116]!==s.id||t[117]!==s.resultImages?(B=(he=s.resultImages)==null?void 0:he.map((me,xe)=>a.jsx(Kp,{src:`data:${me.source.media_type};base64,${me.source.data}`,alt:`Tool result image ${xe+1}`,id:`tool-result-image:${s.id}:${xe}`,className:"my-1.5",thumbnailClassName:"max-h-40"},`${me.source.media_type}-${me.source.data.length}-${me.source.data.slice(0,32)}-${me.source.data.slice(-32)}`)),t[116]=s.id,t[117]=s.resultImages,t[118]=B):B=t[118];let U;t[119]!==R||t[120]!==$?(U=$&&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: ",$.source]}),R&&(!Lo()||Lg())&&a.jsxs(J,{type:"button",variant:"link",size:"xs",onClick:()=>Ka(R),title:R,children:[a.jsx(zS,{"data-icon":"inline-start"}),"Open SKILL.md"]})]}),t[119]=R,t[120]=$,t[121]=U):U=t[121];let W;t[122]!==P||t[123]!==s?(W=P&&a.jsx($F,{toolCall:s}),t[122]=P,t[123]=s,t[124]=W):W=t[124];let V;t[125]!==l||t[126]!==k||t[127]!==P||t[128]!==o||t[129]!==v||t[130]!==(c==null?void 0:c.cwd)||t[131]!==s?(V=k?a.jsx(oF,{toolCall:s,cwd:c==null?void 0:c.cwd,expandAll:l,isAgentActive:!!o}):v?a.jsx(SD,{input:s.input}):P?null:a.jsx(y4,{input:s.input}),t[125]=l,t[126]=k,t[127]=P,t[128]=o,t[129]=v,t[130]=c==null?void 0:c.cwd,t[131]=s,t[132]=V):V=t[132];let H;t[133]!==s.additionalFileDiffs||t[134]!==s.fileDiffs?(H=a.jsx(kF,{fileDiffs:s.fileDiffs,additionalFileDiffs:s.additionalFileDiffs}),t[133]=s.additionalFileDiffs,t[134]=s.fileDiffs,t[135]=H):H=t[135];let G;t[136]!==O||t[137]!==s.input||t[138]!==s.isError||t[139]!==s.name||t[140]!==s.result?(G=O&&a.jsx(x3,{result:s.result??"",isError:s.isError,filePath:s.name==="Read"&&typeof s.input.file_path=="string"?s.input.file_path:void 0}),t[136]=O,t[137]=s.input,t[138]=s.isError,t[139]=s.name,t[140]=s.result,t[141]=G):G=t[141];let Z;t[142]===Symbol.for("react.memo_cache_sentinel")?(Z=()=>p(MF),t[142]=Z):Z=t[142];const Y=m&&"rotate-90";let X;t[143]!==Y?(X=K(Y),t[143]=Y,t[144]=X):X=t[144];let ee;t[145]!==X?(ee=a.jsx(at,{"data-icon":"inline-start",className:X}),t[145]=X,t[146]=ee):ee=t[146];let Q;t[147]!==g||t[148]!==m||t[149]!==ee?(Q=a.jsxs(J,{type:"button",variant:"ghost",size:"xs",className:"mt-1","aria-expanded":m,"aria-controls":g,onClick:Z,children:[ee,"Raw input"]}),t[147]=g,t[148]=m,t[149]=ee,t[150]=Q):Q=t[150];let ne;t[151]!==s.input?(ne=JSON.stringify(s.input),t[151]=s.input,t[152]=ne):ne=t[152];let re;t[153]!==ne?(re=a.jsx(g3,{result:ne}),t[153]=ne,t[154]=re):re=t[154];let se;t[155]!==g||t[156]!==re?(se=a.jsx(Sn,{id:g,children:re}),t[155]=g,t[156]=re,t[157]=se):se=t[157];let oe;t[158]!==m||t[159]!==Q||t[160]!==se?(oe=a.jsxs(wn,{open:m,children:[Q,se]}),t[158]=m,t[159]=Q,t[160]=se,t[161]=oe):oe=t[161];let ae;t[162]!==W||t[163]!==V||t[164]!==H||t[165]!==G||t[166]!==oe?(ae=a.jsxs("div",{className:"min-w-0 px-3 pb-3 pt-1 sm:pl-14",children:[W,V,H,G,oe]}),t[162]=W,t[163]=V,t[164]=H,t[165]=G,t[166]=oe,t[167]=ae):ae=t[167];let ie;t[168]!==h||t[169]!==ae?(ie=a.jsx(Sn,{id:h,children:ae}),t[168]=h,t[169]=ae,t[170]=ie):ie=t[170];let ce;t[171]!==I||t[172]!==ie?(ce=a.jsx(wn,{open:I,children:ie}),t[171]=I,t[172]=ie,t[173]=ce):ce=t[173];let te;t[174]!==s.id||t[175]!==s.name||t[176]!==s.result?(te=(s.name==="Task"||s.name==="Agent")&&s.result===null&&a.jsx(u1,{toolUseId:s.id}),t[174]=s.id,t[175]=s.name,t[176]=s.result,t[177]=te):te=t[177];let le;return t[178]!==M||t[179]!==B||t[180]!==U||t[181]!==ce||t[182]!==te||t[183]!==F||t[184]!==D||t[185]!==L?(le=a.jsxs("div",{className:F,"data-tool-call-id":D,children:[L,M,B,U,ce,te]}),t[178]=M,t[179]=B,t[180]=U,t[181]=ce,t[182]=te,t[183]=F,t[184]=D,t[185]=L,t[186]=le):le=t[186],le});function RF(n){return n.label||n.command.split(/\s+/)[0]}function OF(n){return!n}function MF(n){return!n}const LF=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"?Ku:s==="rejected"?po:eo,v=g?It:at,y=x?It:at;return a.jsxs(wn,{open:g,onOpenChange:d,className:K("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(ds,{render:a.jsx(J,{type:"button",variant:"ghost",className:"h-auto w-full justify-start rounded-b-none p-2 text-left"}),children:[a.jsx(v,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),a.jsx(O6,{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:K("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(Sn,{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(sr,{remarkPlugins:ur,components:cr,children:e})}),r.length>0&&a.jsxs(wn,{open:x,onOpenChange:p,className:"mt-2",children:[a.jsxs(ds,{render:a.jsx(J,{type:"button",variant:"ghost",size:"xs",className:"-ml-2 text-muted-foreground"}),children:[a.jsx(y,{"data-icon":"inline-start"}),r.length," call",r.length===1?"":"s"," during planning"]}),a.jsx(Sn,{children:a.jsx("div",{className:"ml-4 mt-1 flex flex-col gap-1",children:r.map(k=>a.jsx(P4,{toolCall:k,expandToolPayloads:i,isAgentActive:l,skillMetadata:c},k.id))})})]})]})})]})}),zF=w.memo(function(e){const t=q.c(13),{content:s}=e,[r,o]=w.useState(!0),i=r?It:at;let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(J,{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(DS,{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(ds,{render:l,children:[c,u,d]}),t[5]=c,t[6]=f):f=t[6];let m;t[7]!==s?(m=a.jsx(Sn,{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(sr,{remarkPlugins:ur,components:cr,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(wn,{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}),DF=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(FF),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 FF(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 iv=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),v=w.useId(),y=w.useId();let k;t[0]!==m||t[1]!==s?(k=CF(s,m),t[0]=m,t[1]=s,t[2]=k):k=t[2];const j=k,C=j.running>0;let _;t[3]!==s?(_=s.some(UF),t[3]=s,t[4]=_):_=t[4];const S=_,N=r||S||(g??C),T=g===null&&C&&!r&&!S;let E;t[5]!==c||t[6]!==s?(E=_F(s,c),t[5]=c,t[6]=s,t[7]=E):E=t[7];const A=E;let P;t[8]!==A||t[9]!==m||t[10]!==T?(P=EF(A,T,m),t[8]=A,t[9]=m,t[10]=T,t[11]=P):P=t[11];const I=P,O=w.useRef(null),R=w.useRef(null);let $,M;t[12]!==i||t[13]!==s?($=()=>{if(!i){O.current=null;return}i!==O.current&&s.some(se=>se.id===i)&&(O.current=i,x(!0),R.current=requestAnimationFrame(()=>{R.current=requestAnimationFrame(()=>{var se;R.current=null,(se=b.current)==null||se.scrollIntoView({behavior:"smooth",block:"nearest"})})}))},M=[i,s],t[12]=i,t[13]=s,t[14]=$,t[15]=M):($=t[14],M=t[15]),w.useEffect($,M);let z,F;t[16]===Symbol.for("react.memo_cache_sentinel")?(z=()=>()=>{R.current!==null&&cancelAnimationFrame(R.current)},F=[],t[16]=z,t[17]=F):(z=t[16],F=t[17]),w.useEffect(z,F);let D,L,B,U,W,V,H,G,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]!==N||t[26]!==v||t[27]!==f||t[28]!==y||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 se=function(Oe){const pe=i===Oe.id;return a.jsx("div",{ref:pe?b:void 0,className:K("min-w-0",pe&&"rounded-lg ring-2 ring-ring"),children:a.jsx(P4,{toolCall:Oe,expandToolPayloads:o,isAgentActive:m&&Oe.result===null,skillMetadata:f})},Oe.id)};if(s.length===1&&p===0&&!c){X=se(s[0]);break e}const oe=s.length>0?`${s.length} tool ${s.length===1?"call":"calls"}`:"Thinking";let ae;t[50]!==p||t[51]!==h?(ae=h>0?`Thought for ${Math.max(1,Math.round(h/1e3))}s`:p>0?"Includes thinking":"",t[50]=p,t[51]=h,t[52]=ae):ae=t[52];const ie=ae;let ce;t[53]!==j.text||t[54]!==ie?(ce=[j.text,ie].filter(Boolean),t[53]=j.text,t[54]=ie,t[55]=ce):ce=t[55];const te=ce.join(" · ");G="min-w-0 rounded-xl border border-border/80 bg-card/50",Z="";const le=`${N?"Collapse":"Expand"} ${oe}${te?`: ${te}`:""}`,ge=r||S||void 0;let be;t[56]!==r||t[57]!==S||t[58]!==N?(be=()=>{!r&&!S&&x(!N)},t[56]=r,t[57]=S,t[58]=N,t[59]=be):be=t[59];let ue;t[60]===Symbol.for("react.memo_cache_sentinel")?(ue=a.jsx(M6,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),t[60]=ue):ue=t[60];let he;t[61]!==oe?(he=a.jsx("span",{className:"text-[13px] font-medium text-foreground",children:oe}),t[61]=oe,t[62]=he):he=t[62];let me;t[63]!==te?(me=te&&a.jsx("span",{className:"text-xs leading-5 text-muted-foreground [overflow-wrap:anywhere]",children:te}),t[63]=te,t[64]=me):me=t[64];let xe;t[65]!==he||t[66]!==me?(xe=a.jsxs("span",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[he,me]}),t[65]=he,t[66]=me,t[67]=xe):xe=t[67];let je;t[68]!==j.running?(je=j.running>0&&a.jsxs("span",{className:"flex items-center gap-1.5 text-info",children:[a.jsx(ht,{className:"size-3.5 motion-safe:animate-spin","aria-hidden":"true"}),j.running," running"]}),t[68]=j.running,t[69]=je):je=t[69];let Le;t[70]!==j.failed?(Le=j.failed>0&&a.jsxs("span",{className:"flex items-center gap-1.5 text-destructive",children:[a.jsx(po,{className:"size-3.5","aria-hidden":"true"}),j.failed," failed"]}),t[70]=j.failed,t[71]=Le):Le=t[71];let Se;t[72]!==j.awaitingReview?(Se=j.awaitingReview>0&&a.jsxs("span",{className:"text-muted-foreground",children:[j.awaitingReview," awaiting review"]}),t[72]=j.awaitingReview,t[73]=Se):Se=t[73];let Ie;t[74]!==j.unavailable?(Ie=j.unavailable>0&&a.jsxs("span",{className:"text-muted-foreground",children:[j.unavailable," no result"]}),t[74]=j.unavailable,t[75]=Ie):Ie=t[75];let we;t[76]!==y||t[77]!==je||t[78]!==Le||t[79]!==Se||t[80]!==Ie?(we=a.jsxs("span",{id:y,className:"flex shrink-0 flex-col items-end gap-1 text-xs",children:[je,Le,Se,Ie]}),t[76]=y,t[77]=je,t[78]=Le,t[79]=Se,t[80]=Ie,t[81]=we):we=t[81];const Be=N&&"rotate-90";let De;t[82]!==Be?(De=K("size-3.5 shrink-0 text-muted-foreground transition-transform",Be),t[82]=Be,t[83]=De):De=t[83];let Ue;t[84]!==De?(Ue=a.jsx(at,{className:De,"aria-hidden":"true"}),t[84]=De,t[85]=Ue):Ue=t[85],t[86]!==N||t[87]!==v||t[88]!==y||t[89]!==le||t[90]!==ge||t[91]!==be||t[92]!==xe||t[93]!==we||t[94]!==Ue?(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":le,"aria-expanded":N,"aria-controls":v,"aria-describedby":y,"aria-disabled":ge,onClick:be,children:[ue,xe,we,Ue]}),t[86]=N,t[87]=v,t[88]=y,t[89]=le,t[90]=ge,t[91]=be,t[92]=xe,t[93]=we,t[94]=Ue,t[95]=Y):Y=t[95],L=wn,H=N,D=Sn,V=v,B="min-w-0 border-t border-border/70 px-1 py-1",t[96]!==I.hidden?(U=I.hidden>0&&a.jsxs(J,{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]=U):U=t[97],W=I.visible.map(We=>We.kind==="tool_call"?se(We.toolCall):a.jsx("div",{className:"px-3 py-1",children:a.jsx(DF,{blocks:We.blocks})},`thinking-${A.filter(BF).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]=N,t[26]=v,t[27]=f,t[28]=y,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]=B,t[42]=U,t[43]=W,t[44]=V,t[45]=H,t[46]=G,t[47]=Z,t[48]=Y,t[49]=X}else D=t[39],L=t[40],B=t[41],U=t[42],W=t[43],V=t[44],H=t[45],G=t[46],Z=t[47],Y=t[48],X=t[49];if(X!==Symbol.for("react.early_return_sentinel"))return X;let ee;t[98]!==B||t[99]!==U||t[100]!==W?(ee=a.jsxs("div",{className:B,children:[U,W]}),t[98]=B,t[99]=U,t[100]=W,t[101]=ee):ee=t[101];let Q;t[102]!==D||t[103]!==V||t[104]!==ee?(Q=a.jsx(D,{id:V,children:ee}),t[102]=D,t[103]=V,t[104]=ee,t[105]=Q):Q=t[105];let ne;t[106]!==L||t[107]!==H||t[108]!==Q?(ne=a.jsx(L,{open:H,children:Q}),t[106]=L,t[107]=H,t[108]=Q,t[109]=ne):ne=t[109];let re;return t[110]!==G||t[111]!==Z||t[112]!==Y||t[113]!==ne?(re=a.jsxs("div",{className:G,"data-tool-activity":Z,children:[Y,ne]}),t[110]=G,t[111]=Z,t[112]=Y,t[113]=ne,t[114]=re):re=t[114],re});function UF(n){return n.name==="AskUserQuestion"}function BF(n){return n.kind==="thinking"}function WF(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=K("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=K("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(at,{"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(J,{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 I4="synthesizedFrom",av=/[.*+?[\]{}()^$|]/,qF=/[$*?`~]|\\\s/,$4=/<<(-?)\s*(?:'([^']+)'|"([^"]+)")/,VF=new RegExp($4,"g");function Su(n,e,t,s){return{id:e,name:t,input:{...s,[I4]:n.name},result:null,isError:!1,timestamp:n.timestamp}}function HF(n){return typeof n.input[I4]=="string"}function KF(n){const e=n[0];return(e==='"'||e==="'")&&n.at(-1)===e?n.slice(1,-1):n}function lv(n){const e=[];for(const t of n.split("/"))!t||t==="."||(t===".."?e.pop():e.push(t));return`/${e.join("/")}`}function kd(n,e){const t=KF(n.trim());return!t||qF.test(t)?null:t.startsWith("/")?lv(t):e?lv(`${e}/${t}`):null}function GF(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 ZF(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(VF)){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 GF(r))t.push({text:i.text,bodies:o,piped:i.piped})}return t}function YF(n,e){const t=n.match(/^cd\s+(?:"([^"]*)"|'([^']*)'|([^\s;&|]+))\s*$/);return t?kd(t[1]??t[2]??t[3]??"",e):null}function XF(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 JF(n,e){if(n.piped||n.bodies.size===0)return null;const t=n.text.match($4);if(!t)return null;const s=n.bodies.get(t[2]??t[3]??"");if(s===void 0)return null;const r=XF(n.text);if(!r)return null;const o=kd(r,e);return o?{name:"Write",input:{file_path:o,content:s}}:null}function cv(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==="|"||!av.test(i)&&!"\\/&#".includes(i))return null;s+=i,r++;continue}if(o==="&"&&t||!t&&av.test(o))return null;s+=o}return s}const QF=/^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 eU(n,e){var m;const t=(m=n.text.match(QF))==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=cv(s,"pattern"),d=cv(r,"replacement");if(!u||d===null)return null;const f=kd(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 R4(n,e=null){if(n.fileDiffs)return MO(n.fileDiffs).map((o,i)=>({...Su(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 ZF(t)){const i=YF(o.text,r);if(i){r=i;continue}const l=JF(o,r)??eU(o,r);l&&s.push(Su(n,`${n.id}:bash-${s.length}`,l.name,l.input))}return s}function O4(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=kd(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(Su(n,`${n.id}:edit-${i}`,"Edit",{file_path:r,old_string:c,new_string:u,replace_all:d===!0}))}return o}function M4(n,e){const t=[n.input.patch,n.input.value,n.input.input].find(s=>typeof s=="string");return t?tj("apply_patch",t,n.id,n.timestamp,e??"").map(s=>Su(n,s.id,s.name,s.input)):[]}function Pa(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(...O4(s,e)):s.name==="Bash"?t.push(...R4(s,e)):s.name==="apply_patch"&&t.push(...M4(s,e)));return t}function ku(n,e=null){for(const t of n)if(!(t.isError||t.awaitingReview)&&(t.name==="Edit"||t.name==="Write"||t.name==="MultiEdit"&&O4(t,e).length>0||t.name==="Bash"&&R4(t,e).length>0||t.name==="apply_patch"&&M4(t,e).length>0))return!0;return!1}const tU=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"]),nU={json:yb,jsonc:yb,md:Ca,mdx:Ca,txt:Ca,png:bo,jpg:bo,jpeg:bo,gif:bo,webp:bo,svg:bo,ico:bo,sh:Xl,bash:Xl,zsh:Xl,fish:Xl};function L4(n){const e=n.split("/").at(-1)??n,t=e.lastIndexOf(".");return t===-1?"":e.slice(t+1).toLowerCase()}function sU(n){const e=L4(n);return nU[e]??(tU.has(e)?fl:ES)}function Ti(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=K("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 uv=5;function h1(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*uv);o=uv-d,i="flex items-center gap-[1px] shrink-0 ml-1",l=Array.from({length:d},oU),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},rU),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 rU(n,e){return a.jsx("span",{className:"inline-block size-1.5 rounded-xs bg-destructive/70"},`d${e}`)}function oU(n,e){return a.jsx("span",{className:"inline-block size-1.5 rounded-xs bg-success/70"},`a${e}`)}const ju="cogpit:open-subagent";function z4(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 g1(n){const e=q.c(2),{agentId:t}=n;let s;return e[0]!==t?(s=a.jsx(J,{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(ju,{detail:{agentId:t}}))},children:"S"}),e[0]=t,e[1]=s):s=e[1],s}const D4=w.memo(function(e){const t=q.c(92),{file:s,defaultOpen:r,isHighlighted:o,diffMode:i}=e,{ref:l,isNear:c}=Qj(),[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=je=>{d(je),je?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 v,y;t[4]!==o?(v=()=>{o&&g(!0)},y=[o,g],t[4]=o,t[5]=v,t[6]=y):(v=t[5],y=t[6]),w.useEffect(v,y);let k;t[7]!==s.filePath?(k=L4(s.filePath),t[7]=s.filePath,t[8]=k):k=t[8];const j=k,C=s.netOriginal,_=s.netCurrent,S=!!(C||_);let N;t[9]!==s.edits?(N=s.edits.some(cU),t[9]=s.edits,t[10]=N):N=t[10];const E=i==="per-edit"?N:S,A=f&&c&&E,[P,I]=w.useState(0);let O;t[11]===Symbol.for("react.memo_cache_sentinel")?(O=je=>{if(!je)return;const Le=je.offsetHeight;I(Se=>Se===Le?Se:Le)},t[11]=O):O=t[11];const R=O,$=s.turnRange[0]===s.turnRange[1]?`T${s.turnRange[0]+1}`:`T${s.turnRange[0]+1}–T${s.turnRange[1]+1}`,M=s.filePath,z=o?"border-ring ring-2 ring-ring/20":"border-border";let F;t[12]!==z?(F=K("rounded-lg border bg-card transition-colors",z),t[12]=z,t[13]=F):F=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(It,{"data-icon":"inline-start",className:"size-3 shrink-0 text-muted-foreground"}):a.jsx(at,{"data-icon":"inline-start",className:"size-3 shrink-0 text-muted-foreground"}),t[16]=u,t[17]=L):L=t[17];let B;t[18]!==j?(B=a.jsx("span",{className:"shrink-0 font-mono text-xs font-bold text-muted-foreground",children:j}),t[18]=j,t[19]=B):B=t[19];let U;t[20]!==s.opTypes?(U=s.opTypes.includes("Edit"),t[20]=s.opTypes,t[21]=U):U=t[21];let W;t[22]!==s.opTypes?(W=s.opTypes.includes("Write"),t[22]=s.opTypes,t[23]=W):W=t[23];let V;t[24]!==U||t[25]!==W?(V=a.jsx(z4,{hasEdit:U,hasWrite:W}),t[24]=U,t[25]=W,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 G;t[29]!==$?(G=a.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:$}),t[29]=$,t[30]=G):G=t[30];let Z;t[31]!==s.editCount?(Z=s.editCount>1&&a.jsxs(Fe,{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]!==B||t[37]!==V||t[38]!==H||t[39]!==G||t[40]!==Z?(Y=a.jsxs(J,{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,B,V,H,G,Z]}),t[33]=u,t[34]=D,t[35]=L,t[36]=B,t[37]=V,t[38]=H,t[39]=G,t[40]=Z,t[41]=Y):Y=t[41];let X;t[42]!==s.subAgentId?(X=s.subAgentId&&a.jsx(g1,{agentId:s.subAgentId}),t[42]=s.subAgentId,t[43]=X):X=t[43];let ee;t[44]!==s.filePath?(ee=a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>Ka(s.filePath),"aria-label":"Open file in editor"}),t[44]=s.filePath,t[45]=ee):ee=t[45];let Q;t[46]===Symbol.for("react.memo_cache_sentinel")?(Q=a.jsx(ng,{"data-icon":"inline-start"}),t[46]=Q):Q=t[46];let ne;t[47]!==ee?(ne=a.jsx(Xt,{render:ee,children:Q}),t[47]=ee,t[48]=ne):ne=t[48];let re;t[49]===Symbol.for("react.memo_cache_sentinel")?(re=a.jsx(Jt,{children:"Open in editor"}),t[49]=re):re=t[49];let se;t[50]!==ne?(se=a.jsxs(Yt,{children:[ne,re]}),t[50]=ne,t[51]=se):se=t[51];let oe;t[52]!==s.filePath?(oe=a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>Ka(s.filePath,{mode:"diff"}),"aria-label":"View git diff"}),t[52]=s.filePath,t[53]=oe):oe=t[53];let ae;t[54]===Symbol.for("react.memo_cache_sentinel")?(ae=a.jsx(L6,{"data-icon":"inline-start"}),t[54]=ae):ae=t[54];let ie;t[55]!==oe?(ie=a.jsx(Xt,{render:oe,children:ae}),t[55]=oe,t[56]=ie):ie=t[56];let ce;t[57]===Symbol.for("react.memo_cache_sentinel")?(ce=a.jsx(Jt,{children:"View git diff"}),t[57]=ce):ce=t[57];let te;t[58]!==ie?(te=a.jsxs(Yt,{children:[ie,ce]}),t[58]=ie,t[59]=te):te=t[59];let le;t[60]!==se||t[61]!==te?(le=a.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[se,te]}),t[60]=se,t[61]=te,t[62]=le):le=t[62];let ge,be;t[63]!==s.addCount||t[64]!==s.delCount?(ge=a.jsx(Ti,{add:s.addCount,del:s.delCount}),be=a.jsx(h1,{add:s.addCount,del:s.delCount}),t[63]=s.addCount,t[64]=s.delCount,t[65]=ge,t[66]=be):(ge=t[65],be=t[66]);let ue;t[67]!==X||t[68]!==le||t[69]!==ge||t[70]!==be?(ue=a.jsxs("div",{className:"flex items-center gap-1.5 pr-2 shrink-0",children:[X,le,ge,be]}),t[67]=X,t[68]=le,t[69]=ge,t[70]=be,t[71]=ue):ue=t[71];let he;t[72]!==Y||t[73]!==ue?(he=a.jsxs("div",{className:"group sticky top-0 z-10 flex w-full items-center rounded-t-lg bg-card transition-colors hover:bg-accent",children:[Y,ue]}),t[72]=Y,t[73]=ue,t[74]=he):he=t[74];let me;t[75]!==i||t[76]!==s.edits||t[77]!==s.filePath||t[78]!==s.netStartLine||t[79]!==E||t[80]!==P||t[81]!==_||t[82]!==C||t[83]!==u||t[84]!==A?(me=a.jsx(iU,{showDiff:A,open:u,hasDiff:E,diffRef:R,lastDiffHeight:P,oldString:C,newString:_,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]=E,t[80]=P,t[81]=_,t[82]=C,t[83]=u,t[84]=A,t[85]=me):me=t[85];let xe;return t[86]!==s.filePath||t[87]!==l||t[88]!==F||t[89]!==he||t[90]!==me?(xe=a.jsxs("div",{ref:l,"data-file-path":M,className:F,children:[he,me]}),t[86]=s.filePath,t[87]=l,t[88]=F,t[89]=he,t[90]=me,t[91]=xe):xe=t[91],xe}),iU=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(lU,{edits:m,filePath:d}):a.jsx(f1,{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}),dv=3,aU=5,lU=w.memo(function(e){const t=q.c(9),{edits:s,filePath:r}=e,o=s.length,i=s.filter(uU),l=i.length>dv,[c,u]=w.useState(l?dv:i.length);w.useEffect(()=>{if(c>=i.length)return;const x=requestAnimationFrame(()=>{u(b=>Math.min(b+aU,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(g1,{agentId:x.agentId})]}),a.jsx(f1,{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 cU(n){return!!(n.oldString||n.newString)}function uU(n){return!!(n.oldString||n.newString)}const Ef=new Map;function dU(n){var v;const e=Wn("hostFiles"),{sessionSource:t}=xt(),s=t==null?void 0:t.dirName,r=sn(s)==="codex",o=n.turns.length,i=((v=n.turns.at(-1))==null?void 0:v.toolCalls.length)??0,l=w.useMemo(()=>{let y=0;for(const k of n.turns){y+=k.toolCalls.length;for(const j of k.subAgentActivity)y+=j.toolCalls.length}return y},[o,i]),c=w.useMemo(()=>{const y=[];for(let k=0;k<n.turns.length;k++)for(const j of n.turns[k].subAgentActivity){const C=r&&(j.status==="completed"||j.status==="failed"||j.status==="interrupted");(j.isBackground||C)&&j.toolCalls.length===0&&y.push({agentId:j.agentId,turnIndex:k})}return y},[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 y=[];for(const{agentId:C}of c){const _=Rn(`${s}/${n.sessionId}/${C}`);if(!f.current.has(_)){if(Ef.has(_)){d(S=>{const N=new Map(S);return N.set(C,Ef.get(_)),N}),f.current.add(_);continue}y.push({agentId:C,cacheKey:_})}}if(y.length===0)return;let k=!1;async function j(){const C=new Map;await Promise.all(y.map(async({agentId:_,cacheKey:S})=>{try{const N=`/api/sessions/${encodeURIComponent(s)}/${encodeURIComponent(n.sessionId)}/subagents/agent-${encodeURIComponent(_)}.jsonl`,T=await Re(N);if(!T.ok)return;const E=await T.text(),P=h4(E,_).flatMap(I=>Pa(I.toolCalls,n.cwd));Ef.set(S,P),f.current.add(S),C.set(_,P)}catch{}})),!k&&C.size>0&&d(_=>{const S=new Map(_);for(const[N,T]of C)S.set(N,T);return S})}return j(),()=>{k=!0}},[s,n.sessionId,n.cwd,c]);const m=w.useMemo(()=>{const y=[],k=new Set;for(let j=0;j<n.turns.length;j++){const C=n.turns[j];for(const _ of Pa(C.toolCalls,n.cwd))y.push({turnIndex:j,toolCall:_});for(const _ of C.subAgentActivity){for(const S of Pa(_.toolCalls,n.cwd))y.push({turnIndex:j,toolCall:S,agentId:_.agentId});if((_.isBackground||r)&&_.toolCalls.length===0&&!k.has(_.agentId)){k.add(_.agentId);const S=u.get(_.agentId);if(S)for(const N of S)y.push({turnIndex:j,toolCall:N,agentId:_.agentId})}}}return y},[l,n.turns,u,r]),p=w.useMemo(()=>{const y=new Set;for(const k of m){const j=F4(k.toolCall);j&&y.add(j)}return[...y]},[m]),[h,g]=w.useState(new Map);w.useEffect(()=>{if(!e||p.length===0){g(new Map);return}let y=!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(y)return;const j=new Map;for(const C of k)C&&j.set(C[0],C[1]);g(j)}),()=>{y=!0}},[e,p]);const x=n.turns.length-1,b=w.useMemo(()=>{const y=new Map;for(const k of n.turns)for(const j of k.subAgentActivity)y.has(j.agentId)||y.set(j.agentId,{name:j.agentName,type:j.subagentType});return y},[n.turns]);return{fileChanges:m,fileContents:h,lastTurnIndex:x,agentMap:b}}function fv(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 F4(n){return String(n.input.file_path??n.input.path??"")}function fU(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 U4(n,e,t){const s=new Map;for(const o of n){if(e!=="all"&&o.turnIndex!==e)continue;const i=F4(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 v=i[b],y=fU(v.toolCall);l.push(y),v.turnIndex<u&&(u=v.turnIndex),v.turnIndex>d&&(d=v.turnIndex),v.toolCall.name==="Edit"?f=!0:m=!0,v.agentId&&(p=v.agentId),c.push({id:v.toolCall.id,oldString:y.oldString,newString:y.newString,toolName:v.toolCall.name,turnIndex:v.turnIndex,agentId:v.agentId,startLine:v.toolCall.name==="Write"?1:fv(h,y.newString||y.oldString)})}const g=Iz(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?fv(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 mU(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=U4(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 tl="cogpit:focus-file",pU="cogpit:file-changes-prefs",hU={expanded:!0,diffMode:"net",scope:"last",groupByAgent:!1};function gU(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(ju,{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(J,{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(Fe,{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(Ti,{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 y;e[27]!==s||e[28]!==o||e[29]!==r?(y=k=>a.jsx(D4,{file:k,defaultOpen:s,isHighlighted:r===k.filePath,diffMode:o},k.filePath),e[27]=s,e[28]=o,e[29]=r,e[30]=y):y=e[30],b=t.files.map(y),e[22]=s,e[23]=o,e[24]=t.files,e[25]=r,e[26]=b}else b=e[26];let v;return e[31]!==b||e[32]!==x?(v=a.jsxs("div",{className:"flex flex-col gap-1",children:[x,b]}),e[31]=b,e[32]=x,e[33]=v):v=e[33],v}const xU=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]=Hi(pU,{}),g={...hU,...p},x=g.expanded,b=g.diffMode,v=g.groupByAgent,[y,k]=w.useState(g.scope),j=w.useCallback(W=>{h(V=>({...V,expanded:W}))},[h]),C=w.useCallback(W=>{h(V=>({...V,diffMode:W}))},[h]),_=w.useCallback(W=>{h(V=>({...V,groupByAgent:W}))},[h]);w.useEffect(()=>{typeof y!="number"&&h(W=>({...W,scope:y}))},[y,h]);const[S,N]=w.useState(null),T=w.useRef(null),{fileChanges:E,fileContents:A,lastTurnIndex:P,agentMap:I}=dU(e),O=w.useMemo(()=>U4(E,typeof y=="number"?y:y==="all"?"all":P,A),[E,y,P,A]),R=w.useMemo(()=>v?mU(E,typeof y=="number"?y:y==="all"?"all":P,I,A):[],[v,E,y,P,I,A]);w.useEffect(()=>{const W=V=>{const H=V.detail;H!=null&&H.filePath&&(k(H.turnIndex),N(H.filePath),T.current&&clearTimeout(T.current),T.current=setTimeout(()=>N(null),3e3),requestAnimationFrame(()=>{var Z;const G=(Z=s.current)==null?void 0:Z.querySelector(`[data-file-path="${CSS.escape(H.filePath)}"]`);G==null||G.scrollIntoView({behavior:"smooth",block:"nearest"})}))};return window.addEventListener(tl,W),()=>{window.removeEventListener(tl,W),T.current&&clearTimeout(T.current)}},[]);const $=w.useCallback(()=>{const W=s.current;W&&(d(W.scrollTop>10),m(W.scrollHeight-W.scrollTop-W.clientHeight>10))},[]),M=w.useCallback(()=>{const W=s.current;W&&(o.current=W.scrollHeight-W.scrollTop-W.clientHeight<50,$())},[$]);if(w.useEffect(()=>{$()},[E.length,O.length,$]),w.useEffect(()=>{const W=s.current;W&&(W.scrollTop=W.scrollHeight),o.current=!0,i.current=!1,l.current=E.length,c.current=e.turns.length,k(g.scope),N(null),$()},[t]),w.useEffect(()=>{const W=e.turns.length;W>c.current&&(i.current=!0),c.current=W},[e.turns.length]),w.useEffect(()=>{if(E.length<=l.current){l.current=E.length;return}l.current=E.length,(i.current||o.current)&&(requestAnimationFrame(()=>{var W;(W=r.current)==null||W.scrollIntoView({behavior:"smooth"})}),i.current=!1)},[E.length]),E.length===0)return null;let z=0,F=0,D=0;if(v)for(const W of R)z+=W.totalAdd,F+=W.totalDel,D+=W.files.length;else{for(const W of O)z+=W.addCount,F+=W.delCount;D=O.length}function L(){k(y==="last"?"all":"last")}function B(){return typeof y=="number"?`Turn ${y+1}`:y==="all"?"All turns":`Last turn (T${P+1})`}const U=B();return a.jsxs("div",{className:"view-transition-file-panel panel-enter-bottom flex h-full min-w-0 flex-col overflow-hidden bg-card",children:[a.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-2 border-b px-3",children:[a.jsx(fl,{"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(Fe,{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(Ti,{add:z,del:F}),a.jsxs(Yt,{children:[a.jsx(Xt,{render:a.jsx(J,{variant:v?"secondary":"ghost",size:"icon-xs",onClick:()=>_(!v),"aria-label":v?"Show all changes":"Group by subagent"}),children:a.jsx(Bs,{"data-icon":"inline-start"})}),a.jsx(Jt,{children:v?"Show all changes":"Group by subagent"})]}),a.jsxs(Yt,{children:[a.jsx(Xt,{render:a.jsx(J,{variant:y==="all"?"secondary":"ghost",size:"icon-xs",onClick:L,"aria-label":y==="last"?"Show all turns":"Show last turn only"}),children:y==="all"?a.jsx(ou,{"data-icon":"inline-start"}):a.jsx(eo,{"data-icon":"inline-start"})}),a.jsx(Jt,{children:y==="last"?"Click for all turns":"Click for last turn only"})]}),a.jsxs(Yt,{children:[a.jsx(Xt,{render:a.jsx(J,{variant:b==="per-edit"?"secondary":"ghost",size:"icon-xs",onClick:()=>C(b==="net"?"per-edit":"net"),"aria-label":b==="net"?"Show per-edit diffs":"Show net diff"}),children:b==="net"?a.jsx(z6,{"data-icon":"inline-start"}):a.jsx(D6,{"data-icon":"inline-start"})}),a.jsx(Jt,{children:b==="net"?"Switch to per-edit diffs":"Switch to net diff"})]}),a.jsxs(Yt,{children:[a.jsx(Xt,{render:a.jsx(J,{variant:"ghost",size:"icon-xs",onClick:()=>j(!x),"aria-label":x?"Collapse all":"Expand all"}),children:x?a.jsx(Ju,{"data-icon":"inline-start"}):a.jsx(dl,{"data-icon":"inline-start"})}),a.jsx(Jt,{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:"}),y!=="all"&&P>0&&a.jsx(J,{variant:"ghost",size:"icon-xs",onClick:()=>{const W=typeof y=="number"?y:P;W>0&&k(W-1)},disabled:(typeof y=="number"?y:P)<=0,"aria-label":"Previous turn",children:a.jsx(Jh,{"data-icon":"inline-start"})}),a.jsx("span",{className:K("text-xs font-medium",typeof y=="number"?"text-foreground":"text-muted-foreground"),children:U}),y!=="all"&&P>0&&a.jsx(J,{variant:"ghost",size:"icon-xs",onClick:()=>{k(W=>typeof W!="number"?W:W+1>=P?"last":W+1)},disabled:y==="last","aria-label":"Next turn",children:a.jsx(at,{"data-icon":"inline-start"})}),typeof y=="number"&&a.jsx(J,{variant:"ghost",size:"icon-xs",onClick:()=>k("last"),"aria-label":"Back to last turn",children:a.jsx(Wt,{"data-icon":"inline-start"})})]}),a.jsxs("div",{className:"relative flex-1 min-h-0",children:[a.jsx("div",{className:K("pointer-events-none absolute inset-x-0 top-0 z-10 h-6 bg-gradient-to-b from-background to-transparent transition-opacity duration-200",u?"opacity-100":"opacity-0")}),a.jsxs("div",{ref:s,onScroll:M,className:"h-full overflow-y-auto",children:[a.jsx("div",{className:"flex flex-col gap-1 p-1.5",children:v?R.length>0?R.map(W=>a.jsx(gU,{group:W,allExpanded:x,highlightPath:S,diffMode:b},W.agentId)):a.jsxs("div",{className:"py-4 text-center text-xs text-muted-foreground",children:["No subagent changes in ",U.toLowerCase()]}):O.length>0?O.map(W=>a.jsx(D4,{file:W,defaultOpen:x,isHighlighted:S===W.filePath,diffMode:b},W.filePath)):a.jsxs("div",{className:"py-4 text-center text-xs text-muted-foreground",children:["No file changes in ",U.toLowerCase()]})}),a.jsx("div",{ref:r})]}),a.jsx("div",{className:K("pointer-events-none absolute inset-x-0 bottom-0 z-10 h-6 bg-gradient-to-t from-background to-transparent transition-opacity duration-200",f?"opacity-100":"opacity-0")})]})]})});function bU(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??Xp(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 Pa(n.toolCalls,e).forEach(r=>s(r)),n.subAgentActivity.forEach(r=>Pa(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 mv(){return{children:new Map,isFile:!1,absPath:"",additions:0,deletions:0,hasEdit:!1,hasWrite:!1,subAgentId:null}}function vU(n,e){if(n.length===0)return[];const t=e.endsWith("/")?e.slice(0,-1):e,s=mv();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=mv(),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,v=f.isFile?f.hasWrite:!1,y=f.isFile?f.subAgentId:null;for(const k of h)g+=k.additions,x+=k.deletions,k.hasEdit&&(b=!0),k.hasWrite&&(v=!0),k.subAgentId&&(y=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:v,subAgentId:y,children:h}})}return r(s,"")}const yU=w.memo(function(e){const t=q.c(45),{turn:s,turnIndex:r,cwd:o}=e,i=Wn("hostFiles");let l;t[0]!==o||t[1]!==s?(l=bU(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=vU(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 v;t[14]!==b?(v=K("size-3 shrink-0 transition-transform duration-150 motion-reduce:transition-none",b),t[14]=b,t[15]=v):v=t[15];let y;t[16]!==v?(y=a.jsx(at,{"data-icon":"inline-start",className:v}),t[16]=v,t[17]=y):y=t[17];let k;t[18]===Symbol.for("react.memo_cache_sentinel")?(k=a.jsx(fl,{className:"size-3.5 shrink-0","data-icon":"inline-start"}),t[18]=k):k=t[18];const j=c.length!==1?"s":"";let C;t[19]!==c.length||t[20]!==j?(C=a.jsxs("span",{className:"font-medium tabular-nums",children:[c.length," file",j]}),t[19]=c.length,t[20]=j,t[21]=C):C=t[21];let _,S;t[22]!==x.add||t[23]!==x.del?(_=a.jsx(Ti,{add:x.add,del:x.del,className:"opacity-80"}),S=a.jsx(h1,{add:x.add,del:x.del}),t[22]=x.add,t[23]=x.del,t[24]=_,t[25]=S):(_=t[24],S=t[25]);let N;t[26]===Symbol.for("react.memo_cache_sentinel")?(N=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]=N):N=t[26];let T;t[27]!==_||t[28]!==S||t[29]!==y||t[30]!==C?(T=a.jsxs(ds,{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:[y,k,C,_,S,N]}),t[27]=_,t[28]=S,t[29]=y,t[30]=C,t[31]=T):T=t[31];let E;if(t[32]!==i||t[33]!==d||t[34]!==r){let I;t[36]!==i||t[37]!==r?(I=O=>a.jsx(wU,{node:O,depth:0,turnIndex:r,canFocusFiles:i},O.fullPath),t[36]=i,t[37]=r,t[38]=I):I=t[38],E=d.map(I),t[32]=i,t[33]=d,t[34]=r,t[35]=E}else E=t[35];let A;t[39]!==E?(A=a.jsx(Sn,{className:"ml-1 border-l border-border/40 pl-3",children:a.jsx("div",{className:"py-0.5",children:E})}),t[39]=E,t[40]=A):A=t[40];let P;return t[41]!==f||t[42]!==T||t[43]!==A?(P=a.jsxs(wn,{open:f,onOpenChange:m,children:[T,A]}),t[41]=f,t[42]=T,t[43]=A,t[44]=P):P=t[44],P}),wU=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=sU(e.name),u=()=>{r&&e.absPath&&window.dispatchEvent(new CustomEvent(tl,{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(J,{type:"button",variant:"ghost",size:"xs",disabled:!r,className:K("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(z4,{hasEdit:e.hasEdit,hasWrite:e.hasWrite}),a.jsx("span",{className:"truncate text-foreground/75",children:e.name})]}),e.subAgentId&&a.jsx(g1,{agentId:e.subAgentId}),a.jsx(Ti,{add:e.additions,del:e.deletions}),a.jsx(h1,{add:e.additions,del:e.deletions})]})}return a.jsxs(a.Fragment,{children:[a.jsxs(J,{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(It,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}):a.jsx(at,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}),a.jsx(Ba,{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(Ti,{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 SU(n){const e=q.c(14),{branchCount:t,onClick:s}=n;if(t===0)return null;let r;e[0]!==s?(r=a.jsx(J,{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(sg,{"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(Xt,{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(Jt,{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(Yt,{children:[l,u]}),e[11]=l,e[12]=u,e[13]=d):d=e[13],d}function jd(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(U6,{"data-slot":"context-menu",...t}),e[2]=t,e[3]=s):s=e[3],s}function Nd(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=K("select-none",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(F6,{"data-slot":"context-menu-trigger",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Cd(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=K("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(AS,{"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($S,{children:a.jsx(RS,{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 To(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(PS,{"data-slot":"context-menu-group",...t}),e[2]=t,e[3]=s):s=e[3],s}function ofe(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=K("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(OS,{"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 jn(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=K("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(IS,{"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 Ei(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=K("-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(qh,{"data-slot":"context-menu-separator",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function kU(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(Nd,{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(eg,{"data-icon":"inline-start"}),e[5]=d):d=e[5];let f;e[6]!==u?(f=a.jsx(To,{children:a.jsxs(jn,{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(Ei,{}),a.jsx(To,{children:a.jsxs(jn,{onClick:()=>i(s),children:[a.jsx(sg,{"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(Ei,{}),a.jsx(To,{children:a.jsxs(jn,{onClick:()=>l(s),children:[a.jsx(fs,{"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(Cd,{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(jd,{children:[c,h]}),e[19]=c,e[20]=h,e[21]=g):g=e[21],g}function B4(n){return wj(n).status(n)}const jU=new Set(["Agent","TaskOutput","spawn_agent","wait_agent"]);function x1(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 Pl(n,e,t,s){switch(n){case"thinking":return"Thinking...";case"tool_use":return e&&jU.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?x1(t):"Done";default:return null}}function NU(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(W6,{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(zi,{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(B6,{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(Ju,{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(ki,{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(Tr,{className:"size-5 text-success"}),e[5]=s):s=e[5],s}default:return null}}const pv=2e3,W4=600;function q4(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=K("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:`${W4}ms`},e[4]=m):m=e[4];let p;e[5]!==t.status?(p=a.jsx(NU,{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=K("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 v;e[11]!==s||e[12]!==b?(v=a.jsx("span",{className:b,children:s}),e[11]=s,e[12]=b,e[13]=v):v=e[13];let y;e[14]!==l||e[15]!==o?(y=!l&&o&&a.jsx(b1,{startTimestamp:o}),e[14]=l,e[15]=o,e[16]=y):y=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 C;return e[21]!==v||e[22]!==y||e[23]!==k||e[24]!==j||e[25]!==f||e[26]!==p?(C=a.jsxs("div",{className:f,style:m,children:[p,v,y,k,j]}),e[21]=v,e[22]=y,e[23]=k,e[24]=j,e[25]=f,e[26]=p,e[27]=C):C=e[27],C}function CU(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"),pv),g=setTimeout(()=>o("ready"),pv+W4);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(Tr,{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=K("text-xs font-medium",g),e[3]=g,e[4]=x):x=e[4];let b;e[5]!==t.terminalReason?(b=t.terminalReason?x1(t.terminalReason):"Waiting for your input",e[5]=t.terminalReason,e[6]=b):b=e[6];let v;e[7]!==x||e[8]!==b?(v=a.jsx("span",{className:x,children:b}),e[7]=x,e[8]=b,e[9]=v):v=e[9];let y;e[10]!==s?(y=s&&a.jsx("span",{className:"font-mono text-xs tabular-nums text-muted-foreground",children:s}),e[10]=s,e[11]=y):y=e[11];let k;return e[12]!==v||e[13]!==y?(k=a.jsxs("div",{className:"flex items-center gap-2.5 py-3 px-4","data-agent-ready":!0,children:[h,v,y]}),e[12]=v,e[13]=y,e[14]=k):k=e[14],k}let c;e[15]!==t.status||e[16]!==t.terminalReason||e[17]!==t.toolName?(c=Pl(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(q4,{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 _U=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=B4(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 v;e:{if(!g){v=null;break e}if(g.status==="compacting"){v=g;break e}if(g.status==="completed"){if(l){v=null;break e}if(!s&&!u){v=null;break e}v=g;break e}if(!s||g.status==="idle"){v=null;break e}v=g}const y=v,k=(y==null?void 0:y.status)==="completed",j=(t==null?void 0:t.turns[t.turns.length-1])??null;let C;e:{if(!k||!j){C=null;break e}let A;if(e[8]!==j){const P=gg(j);A=P!==null?er(P):null,e[8]=j,e[9]=A}else A=e[9];C=A}const _=C;if(i&&r==="connected"){let A;e[10]===Symbol.for("react.memo_cache_sentinel")?(A=a.jsx(tg,{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(!y)return null;if(k){let A;return e[13]!==y||e[14]!==_?(A=a.jsx(CU,{status:y,durationLabel:_}),e[13]=y,e[14]=_,e[15]=A):A=e[15],A}let S;e[16]!==y.pendingAgents||e[17]!==y.status||e[18]!==y.terminalReason||e[19]!==y.toolName?(S=Pl(y.status,y.toolName,y.terminalReason,y.pendingAgents),e[16]=y.pendingAgents,e[17]=y.status,e[18]=y.terminalReason,e[19]=y.toolName,e[20]=S):S=e[20];const N=S;if(!N)return null;const T=j==null?void 0:j.timestamp;let E;return e[21]!==y||e[22]!==N||e[23]!==T?(E=a.jsx("div",{className:"flex items-center gap-2.5 py-3 px-4",children:a.jsx(q4,{status:y,label:N,startTimestamp:T})}),e[21]=y,e[22]=N,e[23]=T,e[24]=E):E=e[24],E});function b1(n){const e=q.c(3),{startTimestamp:t,className:s}=n;let r;return e[0]!==s||e[1]!==t?(r=a.jsx(TU,{startTimestamp:t,className:s},t),e[0]=s,e[1]=t,e[2]=r):r=e[2],r}function TU(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=er(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=K("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=er(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 EU(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 AU=6e5;function PU(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,AU)}function hv(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+=PU(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 V4=w.createContext(null);function qc(n){const e=q.c(3),{value:t,children:s}=n;let r;return e[0]!==s||e[1]!==t?(r=a.jsx(V4.Provider,{value:t,children:s}),e[0]=s,e[1]=t,e[2]=r):r=e[2],r}function hn(){const n=w.useContext(V4);if(!n)throw new Error("useAppContext must be used within an AppProvider");return n}const Jp=new Map,IU=300*1e3;function gv(n){const e=Jp.get(n);return e?Date.now()>e.expiresAt?(Jp.delete(n),null):e.data:null}function $U(n,e){Jp.set(n,{data:e,expiresAt:Date.now()+IU})}function RU(n){const e=q.c(5);let t;e[0]!==n?(t=()=>n?gv(Rn(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||ud(window.location.pathname))return;const c=Rn(n),u=gv(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});$U(c,p),r(p)}).catch(OU),()=>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 OU(){}const MU=new Set(["queued_prompt","agent_message","plan_mode","recap","task_notification"]),LU=new Set(["thinking","tool_calls","sub_agent","background_agent","hook_event"]),zU=new Set(["AskUserQuestion","ExitPlanMode"]),DU=new Set(["text","thinking","tool_calls"]);function FU(n){return n.kind==="tool_calls"&&n.toolCalls.some(e=>zU.has(e.name)&&e.result==null)}function UU(n,e){for(let t=n.length-1;t>=0;t--){if(FU(n[t]))return t;if(DU.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 dc={foldedIndices:[],foldAnchorIndex:-1,foldable:!1,hiddenToolCalls:0};function BU(n,e="settled",t){if(n.length===0||!n.some(l=>LU.has(l.kind)))return dc;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 dc}const r=UU(n,t),o=[];let i=0;for(let l=0;l<n.length;l++){if(l===s||l===r)continue;const c=n[l];MU.has(c.kind)||(o.push(l),c.kind==="tool_calls"&&(i+=c.toolCalls.length))}return o.length===0?dc:{foldedIndices:o,foldAnchorIndex:o[0],foldable:!0,hiddenToolCalls:i}}function WU(n,e){return n!==null&&n>0?`Worked for ${er(n)}`:e>0?`Worked through ${e} step${e===1?"":"s"}`:"Show work"}const H4="border border-border bg-prompt-surface",xv="border-l border-border/40",bv="border-l border-border";function K4(n){const e=q.c(21),{turn:t,index:s,branchCount:r}=n,o=r===void 0?0:r,{state:i,isMobile:l}=hn(),{activeTurnIndex:c,activeToolCallId:u,expandAll:d,expandToolPayloads:f}=i,{session:m,isLive:p,isSubAgentView:h,undoRedo:g,actions:x,pendingInteraction:b}=xt(),v=p&&m!==null,y=v&&s===((m==null?void 0:m.turns.length)??0)-1;let k=!y;if(y&&m){let E;if(e[0]!==m.rawMessages){const{status:A}=B4(m.rawMessages);E=a1.has(A),e[0]=m.rawMessages,e[1]=E}else E=e[1];k=!E}const j=(m==null?void 0:m.cwd)??"",C=RU(j),_=(b==null?void 0:b.type)==="question"?b.toolUseId:void 0,S=c===s,N=!g.enabled||h?void 0:g.requestUndo;let T;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]!==y||e[12]!==l||e[13]!==v||e[14]!==k||e[15]!==_||e[16]!==C||e[17]!==S||e[18]!==N||e[19]!==t?(T=a.jsx(HU,{turn:t,openQuestionId:_,index:s,branchCount:o,isActive:S,activeToolCallId:u,expandAll:d,expandToolPayloads:f,isAgentActive:y,isSessionLive:v,isTurnDone:k,isMobile:l,cwd:j,skillMetadata:C,onRestoreToHere:N,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]=y,e[12]=l,e[13]=v,e[14]=k,e[15]=_,e[16]=C,e[17]=S,e[18]=N,e[19]=t,e[20]=T):T=e[20],T}function qU(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(kU,{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 VU(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=WU(gg(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(b1,{startTimestamp:t.timestamp,className:"text-xs text-inherit"})]}),e[3]=t.timestamp,e[4]=o):o=e[4],o}const HU=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:v}){const{ref:y,isNear:k}=Qj(),j=w.useRef(null),C=w.useRef(0);w.useLayoutEffect(()=>{k&&j.current&&(C.current=j.current.offsetHeight)},[k]);const _=ku(e.toolCalls,m)||e.subAgentActivity.some(R=>ku(R.toolCalls,m)),S=d?"settled":"working",N=w.useMemo(()=>BU(e.contentBlocks,S,v),[S,v,e.contentBlocks]),[T,E]=w.useState(()=>d?void 0:!0),A=T??(i||!d),{leadingBlocks:P,trailingBlocks:I}=w.useMemo(()=>{if(!N.foldable)return{leadingBlocks:[],trailingBlocks:[]};const R=N.foldAnchorIndex,$=new Set(N.foldedIndices);return{leadingBlocks:e.contentBlocks.slice(0,R),trailingBlocks:e.contentBlocks.slice(R).filter((M,z)=>A||!$.has(R+z))}},[N,e.contentBlocks,A]),O={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:y,"data-turn-index":t,className:K("group relative",f?"px-0 py-5":"px-4 py-5",r&&"rounded-lg ring-1 ring-ring/40"),children:[a.jsx(GU,{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(qU,{index:t,children:a.jsx("div",{"data-turn-prompt":!0,className:K("rounded-lg p-3",H4),children:a.jsx(t1,{content:e.userMessage,timestamp:e.timestamp,onEditCommand:x,onExpandCommand:b})})}),N.foldable?a.jsxs(a.Fragment,{children:[P.length>0&&a.jsx(Af,{blocks:P,...O}),a.jsx(WF,{label:a.jsx(VU,{turn:e,isTurnDone:d,hiddenToolCalls:N.hiddenToolCalls}),expanded:A,onToggle:()=>E(!A)}),I.length>0&&a.jsx(Af,{blocks:I,...O})]}):a.jsx(Af,{blocks:e.contentBlocks,...O}),d&&_&&a.jsx(yU,{turn:e,turnIndex:t,cwd:m})]}):a.jsx("div",{style:{minHeight:C.current||KU(e)}})]})});function KU(n){return Math.max(60,(n.userMessage?40:0)+n.contentBlocks.length*60)}function GU(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?gg(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=K("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(ZU,{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(J,{type:"button",variant:"ghost",size:"xs",onClick:()=>l(t),className:K("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(eg,{"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 v;e[15]!==r||e[16]!==t||e[17]!==c||e[18]!==l?(v=r>0&&c&&a.jsx("div",{className:K(!l&&"ml-auto"),children:a.jsx(SU,{branchCount:r,onClick:()=>c(t)})}),e[15]=r,e[16]=t,e[17]=c,e[18]=l,e[19]=v):v=e[19];let y;return e[20]!==p||e[21]!==g||e[22]!==x||e[23]!==b||e[24]!==v?(y=a.jsxs("div",{className:p,children:[g,x,b,v]}),e[20]=p,e[21]=g,e[22]=x,e[23]=b,e[24]=v,e[25]=y):y=e[25],y}function ZU(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(eo,{className:"size-3","data-icon":"inline-start"}),e[0]=o):o=e[0];let i;e[1]!==t?(i=er(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(eo,{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(b1,{startTimestamp:r,className:"tabular-nums"})]}),e[6]=r,e[7]=i):i=e[7],i}return null}function YU(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 Af(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=(v,y)=>{const k=YU(v)??`at-${y}`,j=g.get(k)??0;return g.set(k,j+1),j===0?k:`${k}#${j}`};let b=0;for(;b<t.length;){const v=t[b];if(v.kind==="thinking"||v.kind==="tool_calls"){const{items:y,toolCalls:k,thinkingCount:j,thoughtForMs:C,nextIndex:_}=hv(t,b),S=y.length===1&&y[0].kind==="tool_calls";p.push(a.jsx("div",{className:K(xv,h),children:a.jsx(iv,{toolCalls:k,expandAll:o,expandToolPayloads:i,activeToolCallId:l,isAgentActive:c,activityItems:S?void 0:y,thinkingCount:j,thoughtForMs:C,skillMetadata:f})},x(v,b))),b=_;continue}if(v.kind==="text"){const{items:y,toolCalls:k,thinkingCount:j,thoughtForMs:C,nextIndex:_}=hv(t,b+1);p.push(a.jsxs("div",{children:[a.jsx("div",{className:K("flex flex-col","gap-3"),children:v.text.map((S,N)=>a.jsx(lz,{text:S,model:s,effort:r,timestamp:v.timestamp},N))}),(k.length>0||j>0)&&a.jsx("div",{className:K("mt-1.5",xv,h),children:a.jsx(iv,{toolCalls:k,expandAll:o,expandToolPayloads:i,activeToolCallId:l,isAgentActive:c,activityItems:j>0?y:void 0,thinkingCount:j,thoughtForMs:C,skillMetadata:f})})]},x(v,b))),b=_;continue}if(v.kind==="queued_prompt"){p.push(a.jsxs("div",{className:K("rounded-lg p-3",H4),children:[a.jsx(Fe,{variant:"outline",className:"mb-2",children:"Queued while working"}),a.jsx(t1,{content:v.content,timestamp:v.timestamp??""})]},x(v,b))),b++;continue}if(v.kind==="agent_message"){p.push(a.jsx(iz,{sender:v.sender,body:v.body,reply:v.reply,timestamp:v.timestamp,isLive:u},x(v,b))),b++;continue}if(v.kind==="sub_agent"){p.push(a.jsx("div",{className:K(bv,h),children:a.jsx(H0,{messages:v.messages,expandAll:o,label:"Sub-agent activity",countLabel:"subagents active"})},x(v,b))),b++;continue}if(v.kind==="background_agent"){p.push(a.jsx("div",{className:K(bv,h),children:a.jsx(H0,{messages:v.messages,expandAll:o,label:"Background agent activity",countLabel:"agents active"})},x(v,b))),b++;continue}if(v.kind==="hook_event"){p.push(a.jsx(Tz,{events:v.events},x(v,b))),b++;continue}if(v.kind==="plan_mode"){p.push(a.jsx(LF,{plan:v.plan,planFilePath:v.planFilePath,status:v.status,toolCalls:v.toolCalls,expandAll:o,expandToolPayloads:i,isAgentActive:c,skillMetadata:f},x(v,b))),b++;continue}if(v.kind==="recap"){p.push(a.jsx(zF,{content:v.content},x(v,b))),b++;continue}if(v.kind==="task_notification"){p.push(a.jsx(QM,{content:v.content},x(v,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 XU(n){if(!n)return null;const e=n.trigger==="manual"?"manual":"auto";return n.postTokens!=null?`${e} · ${jt(n.preTokens)} → ${jt(n.postTokens)}`:`${e} · ${jt(n.preTokens)}`}const JU=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=XU(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(It,{className:"size-3","data-icon":"inline-start"}):a.jsx(at,{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(q6,{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 _;t[14]===Symbol.for("react.memo_cache_sentinel")?(_=a.jsx("div",{className:"h-px flex-1 bg-border"}),t[14]=_):_=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 N;return t[16]!==x?(N=a.jsxs("div",{className:"flex items-center gap-3 px-4 py-2",children:[_,x,S]}),t[16]=x,t[17]=N):N=t[17],N}let b,v;t[18]===Symbol.for("react.memo_cache_sentinel")?(b=a.jsx(J,{type:"button",variant:"ghost",className:"group h-auto w-full gap-3 px-0"}),v=a.jsx("div",{className:"h-px flex-1 bg-border"}),t[18]=b,t[19]=v):(b=t[18],v=t[19]);let y;t[20]===Symbol.for("react.memo_cache_sentinel")?(y=a.jsx("div",{className:"h-px flex-1 bg-border"}),t[20]=y):y=t[20];let k;t[21]!==x?(k=a.jsxs(ds,{render:b,children:[v,x,y]}),t[21]=x,t[22]=k):k=t[22];let j;t[23]!==d?(j=a.jsx(Sn,{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(sr,{remarkPlugins:ur,components:cr,children:d})})}),t[23]=d,t[24]=j):j=t[24];let C;return t[25]!==o||t[26]!==k||t[27]!==j?(C=a.jsxs(wn,{open:o,onOpenChange:i,className:"px-4 py-2",children:[k,j]}),t[25]=o,t[26]=k,t[27]=j,t[28]=C):C=t[28],C}),QU=1.5;function eB(n,e){return e<=0?!1:n<e*QU}function tB(n,e){return n===0&&!e}function nB(n,e){return!n||!n.firstKey||e.length<=n.length||e[0]===n.firstKey?!1:e.includes(n.firstKey)}function sB(n,e){return e&&e!=="claude"?n.isFragment===!0:n.userMessage===null}const rB=1e3;function oB(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)<=rB?!1:(e.set(i,o),!0)});return s.length===t.contentBlocks.length?t:{...t,contentBlocks:s}})}function G4(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&&sB(o,t)?[...r.slice(0,-1),aB(i,o),...n.slice(1)]:[...r,...n];return Zg(oB(l))}function iB(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 aB(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:iB(n,e),tokenUsage:e.tokenUsage??n.tokenUsage,model:e.model??n.model,compactionSummary:n.compactionSummary??e.compactionSummary,compactionMeta:n.compactionMeta??e.compactionMeta}}function lB(){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($L,{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(K4,{turn:p,index:u+h}),c&&a.jsxs(J,{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(V6,{"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 cB(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(ht,{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 uB(n){return(n.compactionSummary!=null||n.compactionMeta!=null)&&n.userMessage==null&&n.contentBlocks.length===0}function dB({filteredTurns:n,scrollContainerRef:e,hasMore:t=!1,isLoadingOlder:s=!1,pagingEnabled:r=!1,onLoadMore:o}){const{state:{activeTurnIndex:i}}=hn(),{undoRedo:l}=xt(),c=w.useRef(null),u=w.useRef(null),[d,f]=w.useState(0),m=w.useMemo(()=>{const y=new Map;return n.map(k=>{const j=y.get(k.turn.id)??0;return y.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(()=>nB(p.current,m.map(y=>y.key)),[m]);w.useLayoutEffect(()=>{var y;p.current={firstKey:(y=m[0])==null?void 0:y.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 y=e.current,k=u.current;if(!y||!k)return;const j=k.getBoundingClientRect().top-y.getBoundingClientRect().top+y.scrollTop;f(C=>Math.abs(C-j)<1?C:j)},[e,x]),w.useEffect(()=>{if(!t||!o||!r||s)return;const y=e.current;if(!y)return;const k=()=>{eB(y.scrollTop,y.clientHeight)&&o()};return k(),y.addEventListener("scroll",k,{passive:!0}),()=>y.removeEventListener("scroll",k)},[t,s,r,o,m.length,e]);const b=w.useMemo(()=>{const y=new Map;for(let k=0;k<m.length;k++)y.set(m[k].index,k);return y},[m]),v=w.useRef(null);return w.useEffect(()=>{var k;if(i===null){v.current=null;return}if(i===v.current)return;v.current=i;const y=b.get(i);y!==void 0&&((k=c.current)==null||k.scrollToIndex(y,{align:"start",smooth:!0}))},[i,b]),a.jsxs(a.Fragment,{children:[x&&a.jsx(cB,{hasMore:t,isLoadingOlder:s}),a.jsx("div",{ref:u,className:"motion-session-enter",children:a.jsx(IL,{ref:c,scrollRef:e,startMargin:d,shift:h,children:m.map(({turn:y,index:k,key:j})=>a.jsxs("div",{"data-turn-index":k,children:[(y.compactionSummary||y.compactionMeta)&&a.jsx(JU,{summary:y.compactionSummary,meta:y.compactionMeta}),!uB(y)&&a.jsx(K4,{turn:y,index:k,branchCount:l.branchesAtTurn?l.branchesAtTurn(k).length:0})]},j))})}),a.jsx(lB,{})]})}const fB=w.memo(function(e){const t=q.c(19),{chatScrollRef:s,hasMore:r,isLoadingOlder:o,pagingEnabled:i,onLoadMore:l}=e,{state:c}=hn(),{searchQuery:u,sessionChangeKey:d}=c,{session:f}=xt(),m=f==null?void 0:f.turns;let p;t[0]!==m?(p=m?m.map(mB):[],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 EU(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:tB(x.length,r??!1),t[5]=x.length,t[6]=r,t[7]=u,t[8]=b):b=t[8];const v=b;let y;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]!==v?(y=a.jsx(NM,{children:v?a.jsx(is,{className:"min-h-64 border-0",children:a.jsxs(as,{children:[a.jsx(Is,{variant:"icon",children:u?a.jsx(H6,{}):a.jsx(FS,{})}),a.jsx(ls,{children:u?"No matching turns":"No conversation yet"}),a.jsx(cs,{children:u?"Try a different search term.":"Messages and tool activity will appear here."})]})}):a.jsx(dB,{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]=v,t[18]=y):y=t[18],y});function mB(n,e){return{turn:n,index:e}}const pB="[data-turn-index]",Z4="[data-turn-prompt]",vv=1,hB=120,yv=180;function gB(n){if(!n.userMessage)return null;const e=wd(n.userMessage),{body:t}=Xa(e),{remainingText:s}=e1(t),r=Mj(s);if(!r){const i=Lj(e);if(!i)return null;const l=zj(e);return l?`/${i} ${l}`:`/${i}`}const o=r.split(`
|
|
117
|
+
`)[0];return o.length>yv?`${o.slice(0,yv)}...`:o}function xB(n,e){for(let t=e;t>=0;t--){const s=n[t];if(!s)continue;const r=gB(s);if(r)return{index:t,text:r}}return null}function bB(n){const e=n.getBoundingClientRect().top;let t=null,s=0;for(const l of n.querySelectorAll(pB)){const c=l.getBoundingClientRect().top;if(c>e+vv)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(Z4);return(o?o.getBoundingClientRect().bottom>e+vv:s+hB>e)?null:r}const vB=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 C=()=>{j=null;const T=bB(k);i(E=>T===null?null:(E==null?void 0:E.sessionId)===s.sessionId&&E.index===T?E:{sessionId:s.sessionId,index:T})},_=()=>{j===null&&(j=requestAnimationFrame(C))};i(null),k.addEventListener("scroll",_,{passive:!0});const S=new MutationObserver(_);S.observe(k,{childList:!0,subtree:!0});const N=new ResizeObserver(_);return N.observe(k),k.firstElementChild&&N.observe(k.firstElementChild),_(),()=>{k.removeEventListener("scroll",_),S.disconnect(),N.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=xB(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}"]`),C=(j==null?void 0:j.querySelector(Z4))??j;if(!C)return;const _=k.scrollTop+C.getBoundingClientRect().top-k.getBoundingClientRect().top;k.scrollTo({top:Math.max(0,_),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(FS,{"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 v;t[15]===Symbol.for("react.memo_cache_sentinel")?(v=a.jsx(Hu,{"data-icon":"inline-end",className:"ml-auto"}),t[15]=v):v=t[15];let y;return t[16]!==d.text||t[17]!==m||t[18]!==p||t[19]!==x||t[20]!==b?(y=a.jsxs(J,{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-background px-3 text-left shadow-sm",onClick:m,children:[h,x,b,v]}),t[16]=d.text,t[17]=m,t[18]=p,t[19]=x,t[20]=b,t[21]=y):y=t[21],y});function Qp({path:n,dirName:e,command:t}){return Lo()?(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 yB={five_hour:"5-hour",seven_day:"weekly",seven_day_opus:"weekly Opus",seven_day_sonnet:"weekly Sonnet",seven_day_overage_included:"weekly",overage:"spend"},wB=1440*60*1e3;function SB(n){return(n&&yB[n])??"usage"}function kB(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()>wB;return e.toLocaleString(void 0,{...t?{weekday:"short"}:{},hour:"numeric",minute:"2-digit"})}function jB(n){const e=q.c(32),{block:t,dirName:s,fileName:r,cwd:o}=n;let i,l;e[0]!==o||e[1]!==s||e[2]!==r?(i=Er(s),l=lg(i.kind,lu(r),o??void 0),e[0]=o,e[1]=s,e[2]=r,e[3]=i,e[4]=l):(i=e[3],l=e[4]);const c=l;let u;e[5]!==t.resetsAt?(u=kB(t.resetsAt),e[5]=t.resetsAt,e[6]=u):u=e[6];const d=u,f=t.lowPriority&&i.capabilities.lowPriorityInTerminal;let m;e[7]!==f?(m=f&&!Lo(),e[7]=f,e[8]=m):m=e[8];const p=m;let h;e[9]===Symbol.for("react.memo_cache_sentinel")?(h=a.jsx(eo,{}),e[9]=h):h=e[9];const g=i.displayName;let x;e[10]!==t.limit?(x=SB(t.limit),e[10]=t.limit,e[11]=x):x=e[11];let b;e[12]!==i.displayName||e[13]!==x?(b=a.jsxs(on,{children:[g," hit its ",x," limit"]}),e[12]=i.displayName,e[13]=x,e[14]=b):b=e[14];const v=d?`Resets at ${d}. `:"";let y;e[15]!==c||e[16]!==f?(y=f?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:c}),"."]}):a.jsx(a.Fragment,{children:"Nothing here can lift this one; the session continues once the allowance refills."}),e[15]=c,e[16]=f,e[17]=y):y=e[17];let k;e[18]!==v||e[19]!==y?(k=a.jsxs("span",{children:[v,y]}),e[18]=v,e[19]=y,e[20]=k):k=e[20];let j;e[21]!==p||e[22]!==c||e[23]!==o||e[24]!==s?(j=p&&a.jsx(J,{size:"sm",variant:"outline",onClick:()=>Qp({path:o??void 0,dirName:s,command:c}),children:"Open in terminal"}),e[21]=p,e[22]=c,e[23]=o,e[24]=s,e[25]=j):j=e[25];let C;e[26]!==k||e[27]!==j?(C=a.jsxs(Ut,{className:"flex flex-col items-start gap-2",children:[k,j]}),e[26]=k,e[27]=j,e[28]=C):C=e[28];let _;return e[29]!==C||e[30]!==b?(_=a.jsxs(Ft,{role:"status",className:"rounded-none border-x-0 border-t-0 px-4 py-2",children:[h,b,C]}),e[29]=C,e[30]=b,e[31]=_):_=e[31],_}function NB(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(wv,{}),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(p4,{text:t.text}),e[7]=t.text,e[8]=r):r=e[8];let o;e[9]!==s?(o=s&&a.jsx(wv,{}),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 wv(){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 CB=w.memo(function(){const e=q.c(9),t=c1();let s,r,o,i;if(e[0]!==t){i=Symbol.for("react.early_return_sentinel");e:{const c=mz(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(_B,-1);return a.jsx("div",{children:d.blocks.map((p,h)=>a.jsx(NB,{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 _B(n,e,t){return e.blockType!=="tool_use"&&e.text?t:n}class Y4 extends w.Component{constructor(t){super(t);qt(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(Ft,{variant:"destructive",className:"max-w-md has-data-[slot=alert-action]:pr-2.5",children:[a.jsx(Us,{}),a.jsx(on,{children:a.jsx("h3",{children:this.props.fallbackMessage||"Something went wrong"})}),this.state.error&&a.jsx(Ut,{className:"font-mono text-xs",children:this.state.error.message}),a.jsx(oo,{className:"static col-start-2 mt-2",children:a.jsxs(J,{variant:"outline",size:"sm",onClick:this.handleRetry,children:[a.jsx(Un,{"data-icon":"inline-start"}),"Try again"]})})]})}):this.props.children}}const Sv="find-in-session-highlight",Pf="find-in-session-active";function TB(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 EB=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 re=r.current;if(!re)return;re.querySelectorAll(`mark.${Sv}`).forEach(AB)},s[1]=r,s[2]=g):g=s[2];const x=g;let b;s[3]!==x||s[4]!==r?(b=re=>{if(x(),!re||!r.current){f([]),p(-1);return}const se=r.current,oe=TB(se),ae=re.toLowerCase(),ie=[];for(const ce of oe){const te=ce.nodeValue||"",le=te.toLowerCase();let ge=0;const be=[];for(;;){const xe=le.indexOf(ae,ge);if(xe===-1)break;be.push(xe),ge=xe+1}if(be.length===0)continue;const ue=ce.parentNode;if(!ue)continue;const he=document.createDocumentFragment();let me=0;for(const xe of be){xe>me&&he.appendChild(document.createTextNode(te.slice(me,xe)));const je=document.createElement("mark");je.className=Sv,je.textContent=te.slice(xe,xe+re.length),he.appendChild(je),ie.push(je),me=xe+re.length}me<te.length&&he.appendChild(document.createTextNode(te.slice(me))),ue.replaceChild(he,ce)}f(ie),ie.length>0?(p(0),ie[0].classList.add(Pf),ie[0].scrollIntoView({block:"center",behavior:"smooth"})):p(-1)},s[3]=x,s[4]=r,s[5]=b):b=s[5];const v=b;let y;s[6]!==m||s[7]!==d?(y=re=>{if(d.length===0)return;m>=0&&m<d.length&&d[m].classList.remove(Pf);const se=(re%d.length+d.length)%d.length;d[se].classList.add(Pf),d[se].scrollIntoView({block:"center",behavior:"smooth"}),p(se)},s[6]=m,s[7]=d,s[8]=y):y=s[8];const k=y;let j;s[9]!==x?(j=()=>{i(!1),c(""),x(),f([]),p(-1)},s[9]=x,s[10]=j):j=s[10];const C=j;let _,S;s[11]!==C||s[12]!==o?(_=()=>({open:()=>{i(!0),requestAnimationFrame(()=>{var re;return(re=h.current)==null?void 0:re.focus()})},close:C,isOpen:o}),S=[C,o],s[11]=C,s[12]=o,s[13]=_,s[14]=S):(_=s[13],S=s[14]),w.useImperativeHandle(t,_,S);let N,T;s[15]!==v||s[16]!==l?(N=()=>{const re=setTimeout(()=>v(l),150);return()=>clearTimeout(re)},T=[l,v],s[15]=v,s[16]=l,s[17]=N,s[18]=T):(N=s[17],T=s[18]),w.useEffect(N,T);let E,A;s[19]!==x?(E=()=>()=>x(),A=[x],s[19]=x,s[20]=E,s[21]=A):(E=s[20],A=s[21]),w.useEffect(E,A);let P;s[22]!==m||s[23]!==k||s[24]!==C?(P=re=>{re.key==="Escape"?(re.preventDefault(),re.stopPropagation(),C()):re.key==="Enter"&&(re.preventDefault(),re.shiftKey?k(m-1):k(m+1))},s[22]=m,s[23]=k,s[24]=C,s[25]=P):P=s[25];const I=P;if(!o)return null;let O;s[26]===Symbol.for("react.memo_cache_sentinel")?(O=re=>c(re.target.value),s[26]=O):O=s[26];let R;s[27]!==I||s[28]!==l?(R=a.jsx(Pr,{ref:h,value:l,onChange:O,onKeyDown:I,placeholder:"Find in conversation","aria-label":"Find in conversation",autoFocus:!0}),s[27]=I,s[28]=l,s[29]=R):R=s[29];const $=l?d.length>0?`${m+1}/${d.length}`:"0/0":"";let M;s[30]!==$?(M=a.jsx(Ds,{align:"inline-end",children:a.jsx("span",{className:"min-w-12 text-center text-xs tabular-nums",children:$})}),s[30]=$,s[31]=M):M=s[31];let z;s[32]!==R||s[33]!==M?(z=a.jsxs(Ar,{className:"w-64",children:[R,M]}),s[32]=R,s[33]=M,s[34]=z):z=s[34];let F;s[35]!==m||s[36]!==k?(F=()=>k(m-1),s[35]=m,s[36]=k,s[37]=F):F=s[37];const D=d.length===0,L=d.length>0?"hover:text-foreground":"cursor-default opacity-40";let B;s[38]!==L?(B=K("text-muted-foreground",L),s[38]=L,s[39]=B):B=s[39];let U;s[40]===Symbol.for("react.memo_cache_sentinel")?(U=a.jsx(Hu,{"data-icon":"inline-start"}),s[40]=U):U=s[40];let W;s[41]!==F||s[42]!==D||s[43]!==B?(W=a.jsx(J,{type:"button",variant:"ghost",size:"icon-sm",onClick:F,disabled:D,className:B,"aria-label":"Previous match",children:U}),s[41]=F,s[42]=D,s[43]=B,s[44]=W):W=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,G=d.length>0?"hover:text-foreground":"cursor-default opacity-40";let Z;s[48]!==G?(Z=K("text-muted-foreground",G),s[48]=G,s[49]=Z):Z=s[49];let Y;s[50]===Symbol.for("react.memo_cache_sentinel")?(Y=a.jsx(It,{"data-icon":"inline-start"}),s[50]=Y):Y=s[50];let X;s[51]!==V||s[52]!==H||s[53]!==Z?(X=a.jsx(J,{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 ee;s[55]===Symbol.for("react.memo_cache_sentinel")?(ee=a.jsx(Wt,{"data-icon":"inline-start"}),s[55]=ee):ee=s[55];let Q;s[56]!==C?(Q=a.jsx(J,{type:"button",variant:"ghost",size:"icon-sm",onClick:C,className:"text-muted-foreground hover:text-foreground","aria-label":"Close search",children:ee}),s[56]=C,s[57]=Q):Q=s[57];let ne;return s[58]!==z||s[59]!==W||s[60]!==X||s[61]!==Q?(ne=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,W,X,Q]}),s[58]=z,s[59]=W,s[60]=X,s[61]=Q,s[62]=ne):ne=s[62],ne});function AB(n){const e=n.parentNode;e&&(e.replaceChild(document.createTextNode(n.textContent||""),n),e.normalize())}const X4=[1,2,3,4,5,6,7,8,9],ife=["General","View","Tools"],_d=[{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}},...X4.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}}],J4="cogpit-keybindings";let wo=null;function Q4(n=typeof navigator>"u"?"":navigator.platform){return/Mac|iPhone|iPad/i.test(n)}function nl(n){const e=n.toLowerCase();return e==="esc"?"escape":e}function PB(n){if(!n||typeof n!="object")return!1;const e=n;return e.doubleTapModifier==="mod"||typeof e.key=="string"&&e.key.length>0}function v1(){if(wo)return wo;try{const n=localStorage.getItem(J4);if(!n)return wo={};const e=JSON.parse(n);if(!e||typeof e!="object")return wo={};const t={};for(const s of _d){const r=e[s.command];PB(r)&&(t[s.command]=r)}return wo=t}catch{return wo={}}}function y1(n){wo=n;try{localStorage.setItem(J4,JSON.stringify(n))}catch{}typeof window<"u"&&window.dispatchEvent(new Event("cogpit-keybindings-changed"))}function Il(n){const e=_d.find(t=>t.command===n);if(!e)throw new Error(`Unknown keybinding command: ${n}`);return v1()[n]??e.defaultShortcut}function afe(){return Object.fromEntries(_d.map(n=>[n.command,Il(n.command)]))}function lfe(n,e){const t="doubleTapModifier"in e?{...e}:{...e,key:nl(e.key)};y1({...v1(),[n]:t})}function cfe(n){const e={...v1()};delete e[n],y1(e)}function ufe(){y1({})}function dfe(n){return{key:nl(n.key),metaKey:n.metaKey||void 0,ctrlKey:n.ctrlKey||void 0,shiftKey:n.shiftKey||void 0,altKey:n.altKey||void 0}}function eN(n){const e=n;if(!e)return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||e.isContentEditable===!0}function Vt(n,e){const t=Il(n);return"doubleTapModifier"in t||nl(e.key)!==nl(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 Ko(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 IB(n){const e=Q4();return"doubleTapModifier"in n?e?"Double ⌘":"Double Ctrl":n.modKey?e?`${n.shiftKey?"⇧":""}⌘${Ko(n.key)}`:`Ctrl+${n.shiftKey?"Shift+":""}${Ko(n.key)}`:n.platformChord?e?`⌃⌘${n.shiftKey?"⇧":""}${Ko(n.key)}`:`Ctrl+Alt+${n.shiftKey?"Shift+":""}${Ko(n.key)}`:e?`${n.ctrlKey?"⌃":""}${n.altKey?"⌥":""}${n.shiftKey?"⇧":""}${n.metaKey?"⌘":""}${Ko(n.key)}`:[n.ctrlKey?"Ctrl":null,n.altKey?"Alt":null,n.shiftKey?"Shift":null,n.metaKey?"Meta":null,Ko(n.key)].filter(Boolean).join("+")}function If(n){return IB(Il(n))}function kv(n){if("doubleTapModifier"in n)return[`double-tap:${n.doubleTapModifier}`];const e=(t,s,r,o)=>`${nl(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 ffe(n,e){const t=new Set(kv(n));return _d.find(s=>s.command!==e&&kv(Il(s.command)).some(r=>t.has(r)))??null}function jv(n){return"doubleTapModifier"in Il(n)?Q4()?"Meta":"Control":null}const $B=X4.map(n=>`device.switch.${n}`),RB="device.cycle";function OB(n){const e=$B.findIndex(t=>Vt(t,n));return e===-1?null:e+1}function MB(n){return Vt(RB,n)}const eh="cogpit:find-in-conversation",Td=w.memo(function(e){const t=q.c(80),{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}=hn(),{session:h,sessionSource:g,rateLimit:x}=xt(),{chat:b,scroll:v}=hl(),{searchQuery:y}=f,{pendingMessages:k}=b,{chatScrollRef:j,scrollEndRef:C,handleScroll:_,canScrollDown:S,scrollToBottomInstant:N,initialScrollDone:T}=v,E=w.useRef(null);let A;t[0]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{var he;return(he=E.current)==null?void 0:he.open()},t[0]=A):A=t[0];const P=A;let I,O;t[1]===Symbol.for("react.memo_cache_sentinel")?(I=()=>{const he=function(xe){Vt("findInConversation",xe)&&(xe.preventDefault(),P())};return window.addEventListener("keydown",he),window.addEventListener(eh,P),()=>{window.removeEventListener("keydown",he),window.removeEventListener(eh,P)}},O=[P],t[1]=I,t[2]=O):(I=t[1],O=t[2]),w.useEffect(I,O);let R,$;t[3]!==p||t[4]!==d||t[5]!==s?(R=()=>{!p||!d||requestAnimationFrame(()=>{var he;return(he=s.current)==null?void 0:he.focus()})},$=[p,d,s],t[3]=p,t[4]=d,t[5]=s,t[6]=R,t[7]=$):(R=t[6],$=t[7]),w.useEffect(R,$);let M;t[8]!==m||t[9]!==u?(M=()=>{m({type:"SET_SEARCH_QUERY",value:""}),u==null||u()},t[8]=m,t[9]=u,t[10]=M):M=t[10];const z=M,F=h;let D;t[11]!==x||t[12]!==g?(D=x&&g?{block:x,dirName:g.dirName,fileName:g.fileName}:null,t[11]=x,t[12]=g,t[13]=D):D=t[13];const L=D,B=F.turns.length>0||k.length===0;let U;t[14]!==z||t[15]!==m||t[16]!==p||t[17]!==d||t[18]!==s||t[19]!==y?(U=p&&d&&a.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b bg-background px-3 py-2",children:[a.jsxs(Ar,{className:"h-9 flex-1",children:[a.jsx(Pr,{ref:s,value:y,onChange:he=>m({type:"SET_SEARCH_QUERY",value:he.target.value}),placeholder:"Search conversation...","aria-label":"Search conversation"}),a.jsx(Ds,{align:"inline-start",children:a.jsx(Bn,{})})]}),a.jsx(J,{variant:"ghost",size:"icon-sm",onClick:z,"aria-label":"Close conversation search",children:a.jsx(Wt,{"data-icon":"inline-start"})})]}),t[14]=z,t[15]=m,t[16]=p,t[17]=d,t[18]=s,t[19]=y,t[20]=U):U=t[20];let W;t[21]!==F.cwd||t[22]!==p||t[23]!==L?(W=L&&a.jsx("div",{className:K("shrink-0",!p&&"pt-10"),children:a.jsx(jB,{...L,cwd:F.cwd})}),t[21]=F.cwd,t[22]=p,t[23]=L,t[24]=W):W=t[24];let V;t[25]!==j?(V=a.jsx(EB,{ref:E,scrollContainerRef:j}),t[25]=j,t[26]=V):V=t[26];let H;t[27]!==j||t[28]!==F?(H=a.jsx(vB,{session:F,scrollContainerRef:j}),t[27]=j,t[28]=F,t[29]=H):H=t[29];const G=p&&"mobile-scroll";let Z;t[30]!==G?(Z=K("h-full overflow-x-hidden overflow-y-auto bg-background",G),t[30]=G,t[31]=Z):Z=t[31];let Y;t[32]!==r||t[33]!==p||t[34]!==L?(Y=p?"px-3 py-3 pb-5":K("mx-auto w-full max-w-[var(--chat-width)] px-6",L?"pt-4":"pt-14",r?"pb-48":"pb-32"),t[32]=r,t[33]=p,t[34]=L,t[35]=Y):Y=t[35];let X;t[36]!==j||t[37]!==o||t[38]!==T||t[39]!==i||t[40]!==l||t[41]!==B?(X=B&&a.jsx(fB,{chatScrollRef:j,hasMore:o,isLoadingOlder:i,pagingEnabled:T,onLoadMore:l}),t[36]=j,t[37]=o,t[38]=T,t[39]=i,t[40]=l,t[41]=B,t[42]=X):X=t[42];let ee;t[43]===Symbol.for("react.memo_cache_sentinel")?(ee=a.jsx(CB,{}),t[43]=ee):ee=t[43];let Q;if(t[44]!==F.turns.length||t[45]!==k){let he;t[47]!==F.turns.length?(he=(me,xe)=>a.jsx(Uj,{message:me,turnNumber:F.turns.length+1+xe},xe),t[47]=F.turns.length,t[48]=he):he=t[48],Q=k.map(he),t[44]=F.turns.length,t[45]=k,t[46]=Q}else Q=t[46];let ne;t[49]===Symbol.for("react.memo_cache_sentinel")?(ne=a.jsx(_U,{}),t[49]=ne):ne=t[49];let re;t[50]!==C?(re=a.jsx("div",{ref:C}),t[50]=C,t[51]=re):re=t[51];let se;t[52]!==X||t[53]!==Q||t[54]!==re?(se=a.jsxs(Y4,{fallbackMessage:"Failed to render conversation timeline",children:[X,ee,Q,ne,re]}),t[52]=X,t[53]=Q,t[54]=re,t[55]=se):se=t[55];let oe;t[56]!==Y||t[57]!==se?(oe=a.jsx("div",{className:Y,children:se}),t[56]=Y,t[57]=se,t[58]=oe):oe=t[58];let ae;t[59]!==j||t[60]!==_||t[61]!==Z||t[62]!==oe?(ae=a.jsx("div",{ref:j,onScroll:_,className:Z,children:oe}),t[59]=j,t[60]=_,t[61]=Z,t[62]=oe,t[63]=ae):ae=t[63];const ie=S?"opacity-100 scale-100":"opacity-0 scale-75 pointer-events-none",ce=p?"right-3 bottom-3":"right-5 bottom-5";let te;t[64]!==ie||t[65]!==ce?(te=K("absolute rounded-full shadow-sm transition-[opacity,transform] duration-200 ease-out active:scale-95",ie,ce),t[64]=ie,t[65]=ce,t[66]=te):te=t[66];let le;t[67]===Symbol.for("react.memo_cache_sentinel")?(le=a.jsx(K6,{"data-icon":"inline-start"}),t[67]=le):le=t[67];let ge;t[68]!==N||t[69]!==te?(ge=a.jsx(J,{size:"icon",className:te,onClick:N,"aria-label":"Scroll to bottom",children:le}),t[68]=N,t[69]=te,t[70]=ge):ge=t[70];let be;t[71]!==V||t[72]!==H||t[73]!==ae||t[74]!==ge?(be=a.jsxs("div",{className:"relative min-h-0 flex-1",children:[V,H,ae,ge]}),t[71]=V,t[72]=H,t[73]=ae,t[74]=ge,t[75]=be):be=t[75];let ue;return t[76]!==W||t[77]!==be||t[78]!==U?(ue=a.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col bg-background",children:[U,W,be]}),t[76]=W,t[77]=be,t[78]=U,t[79]=ue):ue=t[79],ue});async function So(n){try{const e=await(n==null?void 0:n.json());return e&&typeof e=="object"?e:null}catch{return null}}async function $f(n,e){const t=await So(n);return typeof(t==null?void 0:t.error)=="string"&&t.error?t.error:e}const th="cogpit-devices-changed",tN="cogpit:devices-changed";function nN(n){typeof n.connectionRevision=="number"&&oP(n.id,n.connectionRevision)}function sN(n,e,t=!1){window.dispatchEvent(new CustomEvent(th,{detail:{deviceId:n,connectionRevision:e,removed:t}}));try{localStorage.setItem(tN,JSON.stringify({deviceId:n,connectionRevision:e,removed:t,nonce:`${Date.now()}:${Math.random()}`}))}catch{}}function Nv(n){nN(n),sN(n.id,n.connectionRevision)}function Rf(n,e=""){return`/api/hub/devices/${encodeURIComponent(n)}${e}`}function rN(n){const e=n.runtime.lastHello;if(e&&typeof e=="object"){const t=e.version;if(typeof t=="string")return t}}function LB(n){const e=n.runtime.lastHello;if(e&&typeof e=="object"){const t=e.edition;if(t==="team"||t==="personal")return t}}function Ed(){const[n,e]=w.useState([]),[t,s]=w.useState(!0),[r,o]=w.useState(()=>Mt()),i=w.useRef(0),l=w.useCallback(async()=>{const h=++i.current;try{const g=await Ur("/api/hub/devices");if(!g.ok)return;const x=await So(g);if(h!==i.current)return;const b=Array.isArray(x==null?void 0:x.devices)?x.devices:[];for(const v of b)nN(v);e(b)}catch{}finally{h===i.current&&s(!1)}},[]);w.useEffect(()=>{l()},[l]),w.useEffect(()=>{const h=()=>o(Mt()),g=()=>void l(),x=y=>{if(y.key===tN){try{const k=JSON.parse(y.newValue??"null");(k==null?void 0:k.removed)===!0&&typeof k.deviceId=="string"&&Mt()===k.deviceId&&to(Qt)}catch{}l()}},b=()=>{i.current+=1,e([]),s(!0),l()},v=()=>{i.current+=1,e([]),s(!1)};return window.addEventListener("cogpit-device-changed",h),window.addEventListener("popstate",h),window.addEventListener(th,g),window.addEventListener("storage",x),window.addEventListener("cogpit-auth-changed",b),window.addEventListener("cogpit-identity-changed",b),window.addEventListener("cogpit-auth-required",v),()=>{window.removeEventListener("cogpit-device-changed",h),window.removeEventListener("popstate",h),window.removeEventListener(th,g),window.removeEventListener("storage",x),window.removeEventListener("cogpit-auth-changed",b),window.removeEventListener("cogpit-identity-changed",b),window.removeEventListener("cogpit-auth-required",v)}},[l]);const c=w.useMemo(()=>r===Qt?void 0:n.find(h=>h.id===r),[n,r]),u=w.useCallback(async(h,g,x,b)=>{try{const v=await Ur("/api/hub/devices/probe",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({host:h,port:g,allowLocalTunnel:x,tls:b})}),y=await So(v);return(y==null?void 0:y.ok)===!0&&y.hello?{ok:!0,hello:y.hello}:{ok:!1,code:(y==null?void 0:y.code)??"UNREACHABLE",error:typeof(y==null?void 0:y.error)=="string"?y.error:void 0}}catch{return{ok:!1,code:"UNREACHABLE",error:"Could not reach the device."}}},[]),d=w.useCallback(async h=>{try{const g=await Ur("/api/hub/devices",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(h)}),x=await So(g);if(g.ok&&(x!=null&&x.device)){const b=x.device;return Nv(b),{ok:!0,device:b}}return{ok:!1,code:(x==null?void 0:x.code)??"ERROR",error:typeof(x==null?void 0:x.error)=="string"?x.error:"Could not add the device."}}catch{return{ok:!1,code:"ERROR",error:"Could not add the device."}}},[]),f=w.useCallback(async(h,g)=>{try{const x=await Ur(Rf(h),{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(g)}),b=await So(x);if(x.ok&&(b!=null&&b.device)){const v=b.device;return Nv(v),{ok:!0,device:v}}return{ok:!1,code:(b==null?void 0:b.code)??"ERROR",error:typeof(b==null?void 0:b.error)=="string"?b.error:"Could not update the device."}}catch{return{ok:!1,code:"ERROR",error:"Could not update the device."}}},[]),m=w.useCallback(async h=>{try{const g=await Ur(Rf(h),{method:"DELETE"});if(g.ok)return Mt()===h&&to(Qt),sN(h,void 0,!0),{ok:!0};const x=await So(g);return{ok:!1,error:typeof(x==null?void 0:x.error)=="string"?x.error:"Could not remove the device."}}catch{return{ok:!1,error:"Could not remove the device."}}},[]),p=w.useCallback(async h=>{try{const g=await Ur(Rf(h,"/test"),{method:"POST"});return await So(g)??{ok:!1,reachable:!1,code:"UNREACHABLE"}}catch{return{ok:!1,reachable:!1,code:"UNREACHABLE"}}},[]);return{devices:n,activeDeviceId:r,activeDevice:c,loading:t,refresh:l,probe:u,addDevice:d,updateDevice:f,removeDevice:m,testDevice:p}}const oN="2.7.4",iN={version:oN},Cv=iN.version,zB=19384,DB=443,FB=450,UB=typeof navigator<"u"&&/Mac|iPhone|iPad/i.test(navigator.platform||""),BB=`${UB?"⌘⇧":"Ctrl+Shift+"}1–9`,WB=new Set(["BAD_PASSWORD","PASSWORD_REQUIRED","USERNAME_REQUIRES_PASSWORD"]),qB=new Set(["ACCOUNT_DISABLED"]);function fc(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 VB(n,e,t){if(n.ok){if(n.hello.edition==="team"&&n.hello.needsBootstrap===!0)return{tone:"info",text:"Reachable team server — create its first admin account before adding it here."};if(n.hello.edition!=="team"&&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 aN={ok:"text-success",warn:"text-warning",info:"text-info",error:"text-destructive"};function HB(n){const e=q.c(10),{tone:t}=n,s=aN[t];let r;e[0]!==s?(r=K("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(Tr,{"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(Us,{"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(Un,{"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(po,{"data-icon":"inline-start",className:o}),e[8]=o,e[9]=i):i=e[9],i}const KB={ok:"bg-success",unknown:"bg-warning","bad-password":"bg-destructive"};function GB({device:n,onRename:e,onCredentials:t,onRemove:s,onTest:r}){const[o,i]=w.useState(!1),[l,c]=w.useState(n.name),[u,d]=w.useState(!1),[f,m]=w.useState(n.username??""),[p,h]=w.useState(""),[g,x]=w.useState(null),[b,v]=w.useState(!1),[y,k]=w.useState(null);w.useEffect(()=>{c(n.name)},[n.name]),w.useEffect(()=>{m(n.username??"")},[n.username]);const j=rN(n),C=j!==void 0&&j!==Cv,_=LB(n)==="team";async function S(){const T=l.trim();if(!T||T===n.name){i(!1),c(n.name);return}k("rename"),await e(n.id,T),k(null),i(!1)}async function N(){const T=f.trim(),E=n.username??"",A=T!==E,P=p.length>0;if(!A&&!P){d(!1),h(""),x(null);return}if(n.auth==="none"&&!P){x("Enter a password when adding an account to an unauthenticated device.");return}const I={};A&&(I.username=T||null),P&&(I.password=p),k("credentials"),x(null);const O=await t(n.id,I);if(k(null),!O.ok){x(O.error);return}d(!1),h("")}return a.jsxs("div",{className:"rounded-lg border bg-card",children:[a.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2",children:[a.jsx("span",{"aria-label":`Status: ${n.runtime.authState}`,className:K("size-2 shrink-0 rounded-full",KB[n.runtime.authState])}),a.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[o?a.jsx(Nn,{value:l,autoFocus:!0,"aria-label":`Rename ${n.name}`,onChange:T=>c(T.target.value),onKeyDown:T=>{T.key==="Enter"&&S(),T.key==="Escape"&&(i(!1),c(n.name))},onBlur:()=>void S(),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:n.name}),j&&a.jsxs("span",{className:K("shrink-0 font-mono text-xs",C?"text-warning":"text-muted-foreground"),title:C?`Device runs v${j}; hub runs v${Cv}`:void 0,children:["v",j,C&&" ≠ hub"]}),n.auth==="none"&&a.jsx(Fe,{variant:"secondary",children:"Unauthenticated"})]}),a.jsxs("span",{className:"truncate font-mono text-xs text-muted-foreground",children:[n.tls?"https://":"",n.host,":",n.port]}),n.username?a.jsxs("span",{className:"truncate text-xs text-muted-foreground",title:n.username,children:["Team account: ",n.username]}):_?a.jsx("span",{className:"text-xs text-warning",children:"Team account not configured"}):null]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[a.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":`Re-test ${n.name}`,disabled:y==="test",onClick:async()=>{k("test"),await r(n.id),k(null)},children:a.jsx(Un,{"data-icon":"inline-start",className:K(y==="test"&&"animate-spin")})}),a.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":`Edit account for ${n.name}`,onClick:()=>{d(T=>!T),m(n.username??""),h(""),x(null)},children:a.jsx(G6,{"data-icon":"inline-start"})}),a.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":`Rename ${n.name}`,onClick:()=>i(!0),children:a.jsx(yr,{"data-icon":"inline-start"})}),a.jsxs(_g,{open:b,onOpenChange:T=>{y!=="remove"&&v(T)},children:[a.jsx(xR,{render:a.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":`Remove ${n.name}`,className:"text-destructive hover:bg-destructive/10 hover:text-destructive"}),children:a.jsx(Zu,{"data-icon":"inline-start"})}),a.jsxs(Tg,{size:"sm",children:[a.jsxs(Eg,{children:[a.jsxs(Pg,{children:["Remove ",n.name,"?"]}),a.jsx(Ig,{children:"This device will disappear from Cogpit. You can add it again later."})]}),a.jsxs(Ag,{children:[a.jsx(Rg,{disabled:y==="remove",children:"Cancel"}),a.jsxs($g,{variant:"destructive",disabled:y==="remove",onClick:async()=>{k("remove");try{await s(n.id)}finally{k(null)}},children:[y==="remove"&&a.jsx(ht,{"data-icon":"inline-start",className:"animate-spin"}),"Remove device"]})]})]})]})]})]}),u&&a.jsxs("div",{className:"flex flex-col gap-3 border-t px-3 py-3",children:[a.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[a.jsxs(Lt,{children:[a.jsxs(zt,{htmlFor:`device-username-${n.id}`,children:["Username ",a.jsx("span",{className:"text-muted-foreground/60",children:"(team devices)"})]}),a.jsx(Nn,{id:`device-username-${n.id}`,"aria-label":`Username for ${n.name}`,value:f,onChange:T=>m(T.target.value),placeholder:"Leave empty for password-only auth",autoComplete:"off",spellCheck:!1})]}),a.jsxs(Lt,{children:[a.jsxs(zt,{htmlFor:`device-password-${n.id}`,children:["New password ",a.jsx("span",{className:"text-muted-foreground/60",children:"(optional)"})]}),a.jsx(Nn,{id:`device-password-${n.id}`,"aria-label":`New password for ${n.name}`,type:"password",value:p,onChange:T=>h(T.target.value),placeholder:"Leave blank to keep the stored password",autoComplete:"new-password"})]})]}),n.username&&f.trim()===""&&a.jsx("p",{className:"text-xs text-warning",children:"Clearing the username switches this device back to password-only authentication."}),g&&a.jsx(Yr,{children:g}),a.jsxs("div",{className:"flex justify-end gap-1.5",children:[a.jsx(J,{variant:"outline",size:"sm",onClick:()=>{d(!1),m(n.username??""),h(""),x(null)},children:"Cancel"}),a.jsx(J,{size:"sm",disabled:y==="credentials",onClick:()=>void N(),children:y==="credentials"?a.jsx(ht,{"data-icon":"inline-start",className:"animate-spin"}):"Save account"})]})]})]})}function lN(n){var Ve,He;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}=Ed(),[m,p]=w.useState(""),[h,g]=w.useState(""),[x,b]=w.useState(""),[v,y]=w.useState(""),[k,j]=w.useState(!1),[C,_]=w.useState(!1),[S,N]=w.useState(null),[T,E]=w.useState(!1),[A,P]=w.useState(null),I=w.useRef(null),O=w.useRef(0);let R,$;e[0]!==s||e[1]!==t?(R=()=>{t&&(p(""),g(""),b(""),y(""),j(!1),_(!1),N(null),P(null),s==="add"&&requestAnimationFrame(()=>{var $e;return($e=I.current)==null?void 0:$e.focus()}))},$=[t,s],e[0]=s,e[1]=t,e[2]=R,e[3]=$):(R=e[2],$=e[3]),w.useEffect(R,$);let M;e[4]!==k||e[5]!==h||e[6]!==l?(M=async()=>{const{host:$e,port:tt,tls:bt}=fc(h);if(!$e){N(null),_(!1);return}const ut=O.current=O.current+1;_(!0);const vt=await l($e,tt,k,bt);ut===O.current&&(N({...VB(vt,$e,tt??(bt?DB:zB)),hello:vt.ok?vt.hello:void 0}),_(!1))},e[4]=k,e[5]=h,e[6]=l,e[7]=M):M=e[7];const z=M;let F,D;e[8]!==h||e[9]!==t||e[10]!==z?(F=()=>{if(!t)return;if(!fc(h).host){N(null),_(!1);return}const $e=window.setTimeout(()=>void z(),FB);return()=>window.clearTimeout($e)},D=[t,h,z],e[8]=h,e[9]=t,e[10]=z,e[11]=F,e[12]=D):(F=e[11],D=e[12]),w.useEffect(F,D);const L=((Ve=S==null?void 0:S.hello)==null?void 0:Ve.edition)==="team",B=L&&((He=S==null?void 0:S.hello)==null?void 0:He.needsBootstrap)===!0,U=L||!k;let W;e:{if(T){W=!1;break e}if(!fc(h).host){W=!1;break e}if(C||!S){W=!1;break e}if(B){W=!1;break e}if(U&&!v){W=!1;break e}if(L&&!x.trim()){W=!1;break e}if((S==null?void 0:S.tone)==="error"){W=!1;break e}W=!0}const V=W;let H;e[13]!==c||e[14]!==k||e[15]!==U||e[16]!==h||e[17]!==m||e[18]!==r||e[19]!==v||e[20]!==L||e[21]!==x?(H=async function(){const{host:tt,port:bt,tls:ut}=fc(h);if(!tt)return;E(!0),P(null);const vt=await c({name:m.trim()||void 0,host:tt,port:bt,tls:ut,username:L?x.trim():void 0,password:U&&v||void 0,allowLocalTunnel:k});if(E(!1),vt.ok){r(),to(vt.device.id);return}P({field:qB.has(vt.code)?"username":WB.has(vt.code)?"password":"host",message:vt.error})},e[13]=c,e[14]=k,e[15]=U,e[16]=h,e[17]=m,e[18]=r,e[19]=v,e[20]=L,e[21]=x,e[22]=H):H=e[22];const G=H;let Z;e[23]!==u?(Z=async($e,tt)=>{await u($e,{name:tt})},e[23]=u,e[24]=Z):Z=e[24];const Y=Z;let X;e[25]!==d?(X=async $e=>{await d($e)},e[25]=d,e[26]=X):X=e[26];const ee=X;let Q;e[27]!==i||e[28]!==f?(Q=async $e=>{await f($e),await i()},e[27]=i,e[28]=f,e[29]=Q):Q=e[29];const ne=Q;let re;e[30]!==r?(re=$e=>{$e||r()},e[30]=r,e[31]=re):re=e[31];let se;e[32]===Symbol.for("react.memo_cache_sentinel")?(se=a.jsxs(ho,{children:[a.jsx(ar,{children:"Devices"}),a.jsxs(lr,{children:["Control another Cogpit device from here. The active device is chosen from the header switcher — ",BB," jumps between devices."]})]}),e[32]=se):se=e[32];let oe;e[33]!==o||e[34]!==ee||e[35]!==Y||e[36]!==ne||e[37]!==u?(oe=o.length>0&&a.jsx("div",{className:"flex flex-col gap-2",children:o.map($e=>a.jsx(GB,{device:$e,onRename:Y,onCredentials:u,onRemove:ee,onTest:ne},$e.id))}),e[33]=o,e[34]=ee,e[35]=Y,e[36]=ne,e[37]=u,e[38]=oe):oe=e[38];let ae;e[39]===Symbol.for("react.memo_cache_sentinel")?(ae=a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Qs,{"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]=ae):ae=e[39];const ie=(A==null?void 0:A.field)==="host";let ce,te;e[40]===Symbol.for("react.memo_cache_sentinel")?(ce=a.jsx(zt,{htmlFor:"device-host",children:"Host"}),te=a.jsx(Ni,{children:"Enter a local address or an HTTPS URL."}),e[40]=ce,e[41]=te):(ce=e[40],te=e[41]);let le;e[42]===Symbol.for("react.memo_cache_sentinel")?(le=$e=>{O.current=O.current+1,g($e.target.value),b(""),N(null),P(null)},e[42]=le):le=e[42];let ge;e[43]!==z?(ge=()=>void z(),e[43]=z,e[44]=ge):ge=e[44];let be;e[45]!==h||e[46]!==ge?(be=a.jsx(Nn,{id:"device-host",ref:I,value:h,onChange:le,onBlur:ge,placeholder:"192.168.1.42, my-mac.local:19384 or https://cogpit.example.com",spellCheck:!1,autoComplete:"off"}),e[45]=h,e[46]=ge,e[47]=be):be=e[47];let ue;e[48]!==C?(ue=C&&a.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[a.jsx(ht,{"data-icon":"inline-start",className:"size-3.5 animate-spin"})," Checking device…"]}),e[48]=C,e[49]=ue):ue=e[49];let he;e[50]!==S||e[51]!==C?(he=!C&&S&&a.jsxs("p",{role:"status",className:K("flex items-center gap-1.5 text-xs",aN[S.tone]),children:[a.jsx(HB,{tone:S.tone}),S.text]}),e[50]=S,e[51]=C,e[52]=he):he=e[52];let me;e[53]!==A?(me=(A==null?void 0:A.field)==="host"&&a.jsx(Yr,{children:A.message}),e[53]=A,e[54]=me):me=e[54];let xe;e[55]!==ie||e[56]!==be||e[57]!==ue||e[58]!==he||e[59]!==me?(xe=a.jsxs(Lt,{"data-invalid":ie,children:[ce,te,be,ue,he,me]}),e[55]=ie,e[56]=be,e[57]=ue,e[58]=he,e[59]=me,e[60]=xe):xe=e[60];let je;e[61]===Symbol.for("react.memo_cache_sentinel")?(je=a.jsxs(zt,{htmlFor:"device-name",children:["Name ",a.jsx("span",{className:"text-muted-foreground/60",children:"(optional)"})]}),e[61]=je):je=e[61];let Le;e[62]===Symbol.for("react.memo_cache_sentinel")?(Le=$e=>p($e.target.value),e[62]=Le):Le=e[62];let Se;e[63]!==m?(Se=a.jsxs(Lt,{children:[je,a.jsx(Nn,{id:"device-name",value:m,onChange:Le,placeholder:"Defaults to the device's own name"})]}),e[63]=m,e[64]=Se):Se=e[64];let Ie;e[65]!==A||e[66]!==L||e[67]!==x?(Ie=L&&a.jsxs(Lt,{"data-invalid":(A==null?void 0:A.field)==="username",children:[a.jsx(zt,{htmlFor:"device-username",children:"Username"}),a.jsx(Nn,{id:"device-username",value:x,onChange:$e=>b($e.target.value),placeholder:"Team account username",autoComplete:"username",spellCheck:!1}),a.jsx(Ni,{children:"Requests through this hub will act as this account on the team server."}),(A==null?void 0:A.field)==="username"&&a.jsx(Yr,{children:A.message})]}),e[65]=A,e[66]=L,e[67]=x,e[68]=Ie):Ie=e[68];let we;e[69]!==U||e[70]!==v||e[71]!==A||e[72]!==L?(we=U&&a.jsxs(Lt,{"data-invalid":(A==null?void 0:A.field)==="password",children:[a.jsx(zt,{htmlFor:"device-password",children:"Password"}),a.jsx(Nn,{id:"device-password",type:"password",value:v,onChange:$e=>y($e.target.value),placeholder:L?"Password for that team account":"Network access password for that device",autoComplete:L?"current-password":"off"}),(A==null?void 0:A.field)==="password"&&a.jsx(Yr,{children:A.message})]}),e[69]=U,e[70]=v,e[71]=A,e[72]=L,e[73]=we):we=e[73];let Be;e[74]!==xe||e[75]!==Se||e[76]!==Ie||e[77]!==we?(Be=a.jsxs(Ui,{children:[xe,Se,Ie,we]}),e[74]=xe,e[75]=Se,e[76]=Ie,e[77]=we,e[78]=Be):Be=e[78];let De;e[79]===Symbol.for("react.memo_cache_sentinel")?(De=$e=>{O.current=O.current+1,j($e===!0),N(null),P(null)},e[79]=De):De=e[79];let Ue;e[80]!==k?(Ue=a.jsx(e3,{id:"device-local-tunnel",name:"device-local-tunnel",checked:k,onCheckedChange:De}),e[80]=k,e[81]=Ue):Ue=e[81];const We=L?"":" — no password";let Oe;e[82]!==We?(Oe=a.jsxs(zt,{htmlFor:"device-local-tunnel",children:["This is a local tunnel",We]}),e[82]=We,e[83]=Oe):Oe=e[83];let pe;e[84]!==Ue||e[85]!==Oe?(pe=a.jsxs(Lt,{orientation:"horizontal",children:[Ue,Oe]}),e[84]=Ue,e[85]=Oe,e[86]=pe):pe=e[86];let ke;e[87]!==k||e[88]!==L?(ke=k&&a.jsxs(Ft,{className:"border-warning/40 bg-warning/10 text-warning",children:[a.jsx(Z6,{}),a.jsx(Ut,{className:"text-warning",children:L?a.jsx(a.Fragment,{children:"The loopback address is allowed because the tunnel is local; team account authentication 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]=ke):ke=e[89];let _e;e[90]!==r?(_e=a.jsx(J,{variant:"outline",onClick:r,children:"Close"}),e[90]=r,e[91]=_e):_e=e[91];const ye=!V;let Pe;e[92]!==G?(Pe=()=>void G(),e[92]=G,e[93]=Pe):Pe=e[93];let Ye;e[94]!==T?(Ye=T?a.jsxs(a.Fragment,{children:[a.jsx(ht,{"data-icon":"inline-start",className:"size-4 animate-spin"})," Adding…"]}):"Add device",e[94]=T,e[95]=Ye):Ye=e[95];let Xe;e[96]!==ye||e[97]!==Pe||e[98]!==Ye?(Xe=a.jsx(J,{disabled:ye,onClick:Pe,children:Ye}),e[96]=ye,e[97]=Pe,e[98]=Ye,e[99]=Xe):Xe=e[99];let Ee;e[100]!==_e||e[101]!==Xe?(Ee=a.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[_e,Xe]}),e[100]=_e,e[101]=Xe,e[102]=Ee):Ee=e[102];let Ze;e[103]!==Be||e[104]!==pe||e[105]!==ke||e[106]!==Ee?(Ze=a.jsxs("div",{className:"flex flex-col gap-4 border-t pt-4",children:[ae,Be,pe,ke,Ee]}),e[103]=Be,e[104]=pe,e[105]=ke,e[106]=Ee,e[107]=Ze):Ze=e[107];let fe;e[108]!==oe||e[109]!==Ze?(fe=a.jsxs(ir,{className:"max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-xl",children:[se,oe,Ze]}),e[108]=oe,e[109]=Ze,e[110]=fe):fe=e[110];let Te;return e[111]!==t||e[112]!==re||e[113]!==fe?(Te=a.jsx(or,{open:t,onOpenChange:re,children:fe}),e[111]=t,e[112]=re,e[113]=fe,e[114]=Te):Te=e[114],Te}const ZB=/^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?$/;function _v(n,e){if(!ZB.test(e))throw new Error(`Invalid Cogpit ${n} id "${e}"`)}function No(n,e){return`${n}.${e}`}function YB(n){const e=new Set,t=new Set,s=[];for(const r of n){if(_v("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??[]){_v("panel",o.id);const i=No(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 $n({className:n,...e}){return a.jsx("div",{"data-slot":"skeleton",className:K("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 ii="cogpit",Ot={worktrees:No(ii,"worktrees"),projectFiles:No(ii,"project-files"),browser:No(ii,"browser"),fileChanges:No(ii,"file-changes"),sessionInfo:No(ii,"session-info")},XB=w.lazy(()=>Qe(()=>import("./CommandPaletteHost-ByD_7YRK.js"),__vite__mapDeps([25,1,2,3,4])).then(n=>({default:n.CommandPaletteHost}))),JB=w.lazy(()=>Qe(()=>import("./index-C-0I_ZqI.js"),__vite__mapDeps([26,1,2,3,4])).then(n=>({default:n.ConfigDialog}))),QB=w.lazy(()=>Qe(()=>import("./KeyboardShortcutsDialog-DQuepxQo.js"),__vite__mapDeps([27,1,2,3,4])).then(n=>({default:n.KeyboardShortcutsDialog}))),eW=w.lazy(()=>Qe(()=>import("./ProjectSwitcherModal-Chi-U3vv.js"),__vite__mapDeps([28,1,2,3,4])).then(n=>({default:n.ProjectSwitcherModal}))),tW=w.lazy(()=>Qe(()=>import("./ThemeSelectorModal-B2m42_1f.js"),__vite__mapDeps([29,1,2,3,4])).then(n=>({default:n.ThemeSelectorModal})));function nW(n){const e=q.c(116),{navigation:t,project:s,chrome:r}=n,{state:o,config:i,theme:l}=hn(),{session:c,sessionSource:u}=xt(),{devices:d,activeDeviceId:f}=Ed(),[m,p]=w.useState(null);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=gt("manageDevices"),e[0]=h):h=e[0];const g=h;let x;e[1]!==o.pendingCwd||e[2]!==o.pendingDirName?(x=o.pendingCwd??(o.pendingDirName?Rs(o.pendingDirName):null),e[1]=o.pendingCwd,e[2]=o.pendingDirName,e[3]=x):x=e[3];const b=x,v=(u==null?void 0:u.dirName)??o.pendingDirName??o.dashboardProject??null,y=r.onKeyboardShortcutsOpenChange;let k,j;e[4]!==y?(k=()=>{const Xe=function(Ze){Vt("keyboardShortcuts",Ze)&&(eN(document.activeElement)||(Ze.preventDefault(),y(!0)))};return window.addEventListener("keydown",Xe),()=>window.removeEventListener("keydown",Xe)},j=[y],e[4]=y,e[5]=k,e[6]=j):(k=e[5],j=e[6]),w.useEffect(k,j);const C=f===Qt;let _;e[7]!==C?(_={id:Qt,name:"This machine",isLocal:!0,isActive:C},e[7]=C,e[8]=_):_=e[8];let S;if(e[9]!==f||e[10]!==d||e[11]!==_){let Xe;e[13]!==f?(Xe=Ee=>({id:Ee.id,name:Ee.name,isLocal:!1,isActive:Ee.id===f}),e[13]=f,e[14]=Xe):Xe=e[14],S=[_,...d.map(Xe)],e[9]=f,e[10]=d,e[11]=_,e[12]=S}else S=e[12];const N=S;let T;e[15]!==c||e[16]!==(u==null?void 0:u.agentKind)||e[17]!==(u==null?void 0:u.dirName)?(T=()=>{if(!c)return;const Xe=(u==null?void 0:u.agentKind)??sn((u==null?void 0:u.dirName)??null);td(lg(Xe,c.sessionId,c.cwd))},e[15]=c,e[16]=u==null?void 0:u.agentKind,e[17]=u==null?void 0:u.dirName,e[18]=T):T=e[18];const E=T,A=sW,P=r.processPanel,I=r.workflowsPanel,O=r.undoDialog,R=r.branchModal,$=i.claudeDir??"";let M;e[19]!==i.handleCloseConfigDialog||e[20]!==i.handleConfigSaved||e[21]!==i.showConfigDialog||e[22]!==$?(M=a.jsx(w.Suspense,{fallback:null,children:a.jsx(JB,{open:i.showConfigDialog,currentPath:$,onClose:i.handleCloseConfigDialog,onSaved:i.handleConfigSaved})}),e[19]=i.handleCloseConfigDialog,e[20]=i.handleConfigSaved,e[21]=i.showConfigDialog,e[22]=$,e[23]=M):M=e[23];const z=(u==null?void 0:u.dirName)??o.pendingDirName??null,F=(c==null?void 0:c.cwd)??o.pendingCwd??null;let D;e[24]!==i.defaultAgentKind||e[25]!==t.onStartNewFolder||e[26]!==t.onStartNewSession||e[27]!==t.panels.handleCloseProjectSwitcher||e[28]!==t.panels.showProjectSwitcher||e[29]!==z||e[30]!==F?(D=a.jsx(w.Suspense,{fallback:null,children:a.jsx(eW,{open:t.panels.showProjectSwitcher,onClose:t.panels.handleCloseProjectSwitcher,onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:i.defaultAgentKind,currentProjectDirName:z,currentProjectCwd:F})}),e[24]=i.defaultAgentKind,e[25]=t.onStartNewFolder,e[26]=t.onStartNewSession,e[27]=t.panels.handleCloseProjectSwitcher,e[28]=t.panels.showProjectSwitcher,e[29]=z,e[30]=F,e[31]=D):D=e[31];let L;e[32]!==t.panels.handleCloseThemeSelector||e[33]!==t.panels.showThemeSelector||e[34]!==l.setPreview||e[35]!==l.setTheme||e[36]!==l.theme?(L=a.jsx(w.Suspense,{fallback:null,children:a.jsx(tW,{open:t.panels.showThemeSelector,onClose:t.panels.handleCloseThemeSelector,currentTheme:l.theme,onSelectTheme:l.setTheme,onPreviewTheme:l.setPreview})}),e[32]=t.panels.handleCloseThemeSelector,e[33]=t.panels.showThemeSelector,e[34]=l.setPreview,e[35]=l.setTheme,e[36]=l.theme,e[37]=L):L=e[37];const B=r.commandPaletteOpen,U=r.onCommandPaletteOpenChange,W=t.actions.handleGoHome,V=t.panels.handleOpenProjectSwitcher,H=t.onOpenPaletteProject,G=t.actions.handleDashboardSelect,Z=t.panels.handleToggleSidebar;let Y,X,ee;e[38]!==t.panels?(Y=()=>t.panels.toggleWorkspacePanel(Ot.sessionInfo),X=()=>t.panels.toggleWorkspacePanel(Ot.fileChanges),ee=()=>t.panels.toggleWorkspacePanel(Ot.worktrees),e[38]=t.panels,e[39]=Y,e[40]=X,e[41]=ee):(Y=e[39],X=e[40],ee=e[41]);const Q=t.panels.handleToggleMission,ne=c?t.handlers.handleDuplicateSession:void 0,re=c?E:void 0,se=c?A:void 0,oe=gt("killAny")?r.onKillAll:void 0,ae=gt("configWrite")?t.panels.handleToggleConfig:void 0,ie=i.openConfigDialog;let ce;e[42]!==y?(ce=()=>y(!0),e[42]=y,e[43]=ce):ce=e[43];const te=s.currentCwd?s.onTogglePreview:void 0,le=gt("hostFiles")&&s.currentCwd?s.onToggleProjectFiles:void 0;let ge;e[44]!==t.panels?(ge=gt("hostFiles")?()=>t.panels.toggleWorkspacePanel(Ot.browser):void 0,e[44]=t.panels,e[45]=ge):ge=e[45];const be=t.panels.handleToggleThemeSelector,ue=s.onOpenTerminal,he=r.onFocusComposer,me=r.onExpandAll,xe=r.onExpandToolPayloads,je=r.onCollapseAll,Le=!!(c||o.pendingDirName);let Se;e[46]!==b||e[47]!==(c==null?void 0:c.cwd)||e[48]!==(u==null?void 0:u.dirName)||e[49]!==o.dashboardProject||e[50]!==o.pendingDirName?(Se=gt("terminal")&&!!((c==null?void 0:c.cwd)??b??(u==null?void 0:u.dirName)??o.pendingDirName??o.dashboardProject),e[46]=b,e[47]=c==null?void 0:c.cwd,e[48]=u==null?void 0:u.dirName,e[49]=o.dashboardProject,e[50]=o.pendingDirName,e[51]=Se):Se=e[51];const Ie=!!c;let we;e[52]!==s.hasFileChanges?(we=gt("hostFiles")&&s.hasFileChanges,e[52]=s.hasFileChanges,e[53]=we):we=e[53];const Be=t.panels.activeWorkspacePanel===Ot.sessionInfo,De=t.panels.activeWorkspacePanel===Ot.browser,Ue=t.panels.activeWorkspacePanel===Ot.fileChanges,We=t.panels.activeWorkspacePanel===Ot.worktrees,Oe=o.mainView==="config",pe=o.mainView==="mission",ke=(c==null?void 0:c.cwd)??b??null;let _e;e[54]!==r.commandPaletteOpen||e[55]!==r.onCollapseAll||e[56]!==r.onCommandPaletteOpenChange||e[57]!==r.onExpandAll||e[58]!==r.onExpandToolPayloads||e[59]!==r.onFocusComposer||e[60]!==i.openConfigDialog||e[61]!==v||e[62]!==t.actions.handleDashboardSelect||e[63]!==t.actions.handleGoHome||e[64]!==t.onOpenPaletteProject||e[65]!==t.panels.handleOpenProjectSwitcher||e[66]!==t.panels.handleToggleMission||e[67]!==t.panels.handleToggleSidebar||e[68]!==t.panels.handleToggleThemeSelector||e[69]!==t.panels.showSidebar||e[70]!==N||e[71]!==s.launchTerminalRequest||e[72]!==s.onOpenTerminal||e[73]!==s.processPanel.addProcess||e[74]!==s.showProjectFiles||e[75]!==s.supportsWorktrees||e[76]!==Y||e[77]!==X||e[78]!==ee||e[79]!==ne||e[80]!==re||e[81]!==se||e[82]!==oe||e[83]!==ae||e[84]!==ce||e[85]!==te||e[86]!==le||e[87]!==ge||e[88]!==Le||e[89]!==Se||e[90]!==Ie||e[91]!==we||e[92]!==Be||e[93]!==De||e[94]!==Ue||e[95]!==We||e[96]!==Oe||e[97]!==pe||e[98]!==ke?(_e=a.jsx(w.Suspense,{fallback:null,children:a.jsx(XB,{open:B,onOpenChange:U,onGoHome:W,onNewSession:V,onOpenProject:H,onOpenSession:G,onToggleSidebar:Z,onToggleStats:Y,onToggleFileChanges:X,onToggleWorktrees:ee,onToggleMissionControl:Q,onDuplicateSession:ne,onCopyResumeCommand:re,onFindInConversation:se,onKillAll:oe,onOpenConfig:ae,onOpenSettings:ie,onOpenKeyboardShortcuts:ce,onTogglePreview:te,onToggleProjectFiles:le,onToggleBrowser:ge,onOpenTheme:be,onOpenTerminal:ue,onOpenDevices:g?p:void 0,onSwitchDevice:to,devices:N,onFocusComposer:he,onExpandAll:me,onExpandToolPayloads:xe,onCollapseAll:je,canFocusComposer:Le,canOpenTerminal:Se,hasSession:Ie,hasFileChanges:we,supportsWorktrees:s.supportsWorktrees,showSidebar:t.panels.showSidebar,showStats:Be,showProjectFiles:s.showProjectFiles,showBrowser:De,showFileChanges:Ue,showWorktrees:We,showConfig:Oe,showMission:pe,currentProjectDirName:v,projectCwd:ke,onProcessStarted:s.processPanel.addProcess,launchTerminalRequest:s.launchTerminalRequest})}),e[54]=r.commandPaletteOpen,e[55]=r.onCollapseAll,e[56]=r.onCommandPaletteOpenChange,e[57]=r.onExpandAll,e[58]=r.onExpandToolPayloads,e[59]=r.onFocusComposer,e[60]=i.openConfigDialog,e[61]=v,e[62]=t.actions.handleDashboardSelect,e[63]=t.actions.handleGoHome,e[64]=t.onOpenPaletteProject,e[65]=t.panels.handleOpenProjectSwitcher,e[66]=t.panels.handleToggleMission,e[67]=t.panels.handleToggleSidebar,e[68]=t.panels.handleToggleThemeSelector,e[69]=t.panels.showSidebar,e[70]=N,e[71]=s.launchTerminalRequest,e[72]=s.onOpenTerminal,e[73]=s.processPanel.addProcess,e[74]=s.showProjectFiles,e[75]=s.supportsWorktrees,e[76]=Y,e[77]=X,e[78]=ee,e[79]=ne,e[80]=re,e[81]=se,e[82]=oe,e[83]=ae,e[84]=ce,e[85]=te,e[86]=le,e[87]=ge,e[88]=Le,e[89]=Se,e[90]=Ie,e[91]=we,e[92]=Be,e[93]=De,e[94]=Ue,e[95]=We,e[96]=Oe,e[97]=pe,e[98]=ke,e[99]=_e):_e=e[99];let ye;e[100]!==r.keyboardShortcutsOpen||e[101]!==y?(ye=a.jsx(w.Suspense,{fallback:null,children:a.jsx(QB,{open:r.keyboardShortcutsOpen,onOpenChange:y})}),e[100]=r.keyboardShortcutsOpen,e[101]=y,e[102]=ye):ye=e[102];let Pe;e[103]!==m?(Pe=g&&a.jsx(lN,{open:m!==null,initialMode:m??"manage",onClose:()=>p(null)}),e[103]=m,e[104]=Pe):Pe=e[104];let Ye;return e[105]!==r.branchModal||e[106]!==r.processPanel||e[107]!==r.undoDialog||e[108]!==r.workflowsPanel||e[109]!==M||e[110]!==D||e[111]!==L||e[112]!==_e||e[113]!==ye||e[114]!==Pe?(Ye=a.jsxs(a.Fragment,{children:[P,I,O,R,M,D,L,_e,ye,Pe]}),e[105]=r.branchModal,e[106]=r.processPanel,e[107]=r.undoDialog,e[108]=r.workflowsPanel,e[109]=M,e[110]=D,e[111]=L,e[112]=_e,e[113]=ye,e[114]=Pe,e[115]=Ye):Ye=e[115],Ye}function sW(){window.dispatchEvent(new Event(eh))}const cN={"github.repository":"cogpit.github.repository","clickup.tasks":"cogpit.clickup.tasks","vercel-deployments.deployments":"cogpit.vercel.deployments"};function Tv(n){return n===null?null:cN[n]??n}function uN(n,e){return n?e.find(t=>t.id===n)??e.find(t=>t.id===cN[n])??null:null}function Of(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(Xt,{render:r,children:s}),e[2]=s,e[3]=r,e[4]=o):o=e[4];let i;e[5]!==t?(i=a.jsx(Jt,{children:t}),e[5]=t,e[6]=i):i=e[6];let l;return e[7]!==o||e[8]!==i?(l=a.jsxs(Yt,{children:[o,i]}),e[7]=o,e[8]=i,e[9]=l):l=e[9],l}const Ev=iN.version,rW={ok:"bg-success",unknown:"bg-warning","bad-password":"bg-destructive"},Av={ok:"Reachable",unknown:"Not reachable","bad-password":"Password rejected"};function oW(n){const e=q.c(6),{state:t}=n,s=Av[t],r=Av[t],o=rW[t];let i;e[0]!==o?(i=K("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 w1(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}=Ed(),[u,d]=w.useState(null),f=(i==null?void 0:i.name)??"This machine",m=o!==Qt;let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=gt("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(aW))).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",v=s&&"h-10";let y;e[5]!==v?(y=K("max-w-40 justify-start",v),e[5]=v,e[6]=y):y=e[6];let k;e[7]!==b||e[8]!==y?(k=a.jsx(J,{variant:"ghost",size:b,"aria-label":"Switch device",className:y}),e[7]=b,e[8]=y,e[9]=k):k=e[9];let j;e[10]!==m?(j=m?a.jsx(MS,{"data-icon":"inline-start"}):a.jsx(wb,{"data-icon":"inline-start"}),e[10]=m,e[11]=j):j=e[11];let C;e[12]!==f?(C=a.jsx("span",{className:"truncate",children:f}),e[12]=f,e[13]=C):C=e[13];let _;e[14]===Symbol.for("react.memo_cache_sentinel")?(_=a.jsx(It,{"data-icon":"inline-end",className:"opacity-60"}),e[14]=_):_=e[14];let S;e[15]!==k||e[16]!==j||e[17]!==C?(S=a.jsxs(qi,{render:k,children:[j,C,_]}),e[15]=k,e[16]=j,e[17]=C,e[18]=S):S=e[18];let N;e[19]===Symbol.for("react.memo_cache_sentinel")?(N=a.jsx(Ok,{children:"Devices"}),e[19]=N):N=e[19];let T,E;e[20]===Symbol.for("react.memo_cache_sentinel")?(T=a.jsx(wb,{}),E=a.jsx("span",{className:"flex-1 truncate",children:"This machine"}),e[20]=T,e[21]=E):(T=e[20],E=e[21]);let A;e[22]!==m?(A=!m&&a.jsx(Bt,{className:"ml-auto text-success"}),e[22]=m,e[23]=A):A=e[23];let P;e[24]!==A?(P=a.jsxs(vn,{onClick:iW,children:[T,E,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 B=rN(L),U=B!==void 0&&B!==Ev,W=L.id===o;return a.jsxs(vn,{onClick:()=>to(L.id),className:K(s&&"min-h-10"),children:[a.jsx(oW,{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}),U&&a.jsxs("span",{className:"shrink-0 font-mono text-xs text-warning",title:`Device runs v${B}; hub runs v${Ev}`,children:["v",B]})]}),a.jsxs("span",{className:"truncate text-xs text-muted-foreground",children:[L.host,":",L.port,L.auth==="none"&&" · unauthenticated"]})]}),W&&a.jsx(Bt,{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 O;e[33]!==P||e[34]!==I?(O=a.jsxs(br,{children:[N,P,I]}),e[33]=P,e[34]=I,e[35]=O):O=e[35];let R;e[36]!==r.length?(R=h&&a.jsxs(a.Fragment,{children:[a.jsx(du,{}),a.jsxs(br,{children:[a.jsxs(vn,{onClick:()=>d("add"),children:[a.jsx(Qs,{}),a.jsx("span",{children:"Add device…"})]}),r.length>0&&a.jsxs(vn,{onClick:()=>d("manage"),children:[a.jsx(Yh,{}),a.jsx("span",{children:"Manage devices…"})]})]})]}),e[36]=r.length,e[37]=R):R=e[37];let $;e[38]!==O||e[39]!==R?($=a.jsxs(Vi,{align:"end",sideOffset:6,className:"w-64",children:[O,R]}),e[38]=O,e[39]=R,e[40]=$):$=e[40];let M;e[41]!==x||e[42]!==S||e[43]!==$?(M=a.jsxs(Wi,{onOpenChange:x,children:[S,$]}),e[41]=x,e[42]=S,e[43]=$,e[44]=M):M=e[44];let z;e[45]!==u?(z=h&&a.jsx(lN,{open:u!==null,initialMode:u??"manage",onClose:()=>d(null)}),e[45]=u,e[46]=z):z=e[46];let F;return e[47]!==M||e[48]!==z?(F=a.jsxs(a.Fragment,{children:[M,z]}),e[47]=M,e[48]=z,e[49]=F):F=e[49],F}function iW(){return to(Qt)}function aW(){return null}const lW=6e4;function cW(){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()},lW);return()=>window.clearInterval(l)},[o]),{leaks:n,killing:t,killLeaks:i,refresh:o}}const uW=6e4;function dW(){const n=q.c(29),{leaks:e,killing:t,killLeaks:s,refresh:r}=cW(),[o,i]=w.useState(!1),l=e.length>0,c=e.reduce(pW,0);let u,d;if(n[0]!==l?(u=()=>{if(l){i(!0);return}const A=window.setTimeout(()=>i(!1),uW);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=Yt,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(mW)):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=K("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(J,{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 v;n[16]===Symbol.for("react.memo_cache_sentinel")?(v=a.jsx(Y6,{"data-icon":"inline-start"}),n[16]=v):v=n[16];const y=t?"…":e.length;let k;n[17]!==y?(k=a.jsx("span",{className:"tabular-nums",children:y}),n[17]=y,n[18]=k):k=n[18];let j;n[19]!==k||n[20]!==b?(j=a.jsxs(Xt,{render:b,children:[v,k]}),n[19]=k,n[20]=b,n[21]=j):j=n[21];const C=Jt,_="bottom",S="p-3",N=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(fW),e.length>6&&a.jsxs("div",{className:"text-xs text-muted-foreground",children:["+",e.length-6," more"]}),a.jsx(Zt,{}),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 T;n[22]!==C||n[23]!==N?(T=a.jsx(C,{side:_,className:S,children:N}),n[22]=C,n[23]=N,n[24]=T):T=n[24];let E;return n[25]!==f||n[26]!==j||n[27]!==T?(E=a.jsxs(f,{children:[j,T]}),n[25]=f,n[26]=j,n[27]=T,n[28]=E):E=n[28],E}function fW(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," · ",hg(n.ageSeconds)]}),a.jsxs("span",{className:"shrink-0 font-semibold text-destructive",children:[n.cpuPercent.toFixed(0),"%"]})]},n.pid)}function mW(n){return n.pid}function pW(n,e){return n+e.cpuPercent}const hW=15e3;function gW(){const n=q.c(12);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=async()=>{try{const b=await Re("/api/notifications?limit=100");if(!b.ok)return;const v=await b.json();Array.isArray(v.notifications)&&s(v.notifications)}catch{}},n[1]=r):r=n[1];const o=r;let i,l;n[2]===Symbol.for("react.memo_cache_sentinel")?(i=()=>{o();const b=window.setInterval(()=>void o(),hW);return()=>window.clearInterval(b)},l=[o],n[2]=i,n[3]=l):(i=n[2],l=n[3]),w.useEffect(i,l);let c;n[4]===Symbol.for("react.memo_cache_sentinel")?(c=async(b,v)=>{const y=new Date().toISOString();s(k=>k.map(j=>j.readAt===null&&v(j)?{...j,readAt:y}:j));try{await Re("/api/notifications/read",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)})}catch{}},n[4]=c):c=n[4];const u=c;let d;n[5]===Symbol.for("react.memo_cache_sentinel")?(d=async b=>u({ids:b},v=>b.includes(v.id)),n[5]=d):d=n[5];const f=d;let m;n[6]===Symbol.for("react.memo_cache_sentinel")?(m=async()=>u({all:!0},bW),n[6]=m):m=n[6];const p=m;let h;n[7]!==t?(h=t.filter(xW),n[7]=t,n[8]=h):h=n[8];const g=h.length;let x;return n[9]!==t||n[10]!==g?(x={notifications:t,unreadCount:g,refresh:o,markRead:f,markAllRead:p},n[9]=t,n[10]=g,n[11]=x):x=n[11],x}function xW(n){return n.readAt===null}function bW(){return!0}function dN(n){window.history.pushState({},"",n),window.dispatchEvent(new PopStateEvent("popstate"))}function vW(){const n=q.c(30),{notifications:e,unreadCount:t,refresh:s,markRead:r,markAllRead:o}=gW(),[i,l]=w.useState(!1);let c;n[0]!==r?(c=function(S){if(r([S.id]),!S.dirName||!S.sessionId)return;const N=Mt(),T=N===Qt?"":`/d/${N}`;dN(`${T}/${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=_=>{l(_),_&&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(J,{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(Sb,{"data-icon":"inline-start"}),n[7]=h):h=n[7];let g;n[8]!==t?(g=t>0&&a.jsx(Fe,{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(qi,{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 v;n[14]!==o||n[15]!==t?(v=t>0&&a.jsxs(J,{variant:"ghost",size:"xs",onClick:()=>void o(),children:[a.jsx(X6,{"data-icon":"inline-start"}),"Mark all read"]}),n[14]=o,n[15]=t,n[16]=v):v=n[16];let y;n[17]!==v?(y=a.jsxs("div",{className:"flex h-11 items-center justify-between border-b px-3",children:[b,v]}),n[17]=v,n[18]=y):y=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(is,{className:"min-h-40 p-6",children:a.jsxs(as,{children:[a.jsx(Is,{variant:"icon",children:a.jsx(Sb,{})}),a.jsx(ls,{children:"No notifications"}),a.jsx(cs,{children:"Session updates will appear here."})]})}):a.jsx(br,{children:e.map(_=>a.jsx(yW,{notification:_,onOpen:u},_.id))})}),n[19]=e,n[20]=u,n[21]=k):k=n[21];let j;n[22]!==y||n[23]!==k?(j=a.jsxs(Vi,{align:"end",sideOffset:6,className:"w-80 overflow-hidden p-0",children:[y,k]}),n[22]=y,n[23]=k,n[24]=j):j=n[24];let C;return n[25]!==i||n[26]!==d||n[27]!==j||n[28]!==x?(C=a.jsxs(Wi,{open:i,onOpenChange:d,children:[x,j]}),n[25]=i,n[26]=d,n[27]=j,n[28]=x,n[29]=C):C=n[29],C}function yW(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=t.kind==="permission"?zs:Di;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=K("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=K("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 v;e[13]!==b?(v=K("truncate text-xs",b),e[13]=b,e[14]=v):v=e[14];let y;e[15]!==t.title||e[16]!==v?(y=a.jsx("span",{className:v,children:t.title}),e[15]=t.title,e[16]=v,e[17]=y):y=e[17];let k;e[18]!==c?(k=hg(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 C;e[22]!==y||e[23]!==j?(C=a.jsxs("span",{className:"flex items-baseline justify-between gap-2",children:[y,j]}),e[22]=y,e[23]=j,e[24]=C):C=e[24];let _;e[25]!==t.body?(_=a.jsx("span",{className:"mt-0.5 block truncate text-xs text-muted-foreground",children:t.body}),e[25]=t.body,e[26]=_):_=e[26];let S;e[27]!==C||e[28]!==_?(S=a.jsxs("span",{className:"min-w-0 flex-1",children:[C,_]}),e[27]=C,e[28]=_,e[29]=S):S=e[29];let N;e[30]!==r?(N=r&&a.jsx("span",{className:"mt-1.5 size-1.5 shrink-0 rounded-full bg-primary"}),e[30]=r,e[31]=N):N=e[31];let T;return e[32]!==S||e[33]!==N||e[34]!==d||e[35]!==p||e[36]!==x?(T=a.jsxs(vn,{onClick:d,className:p,children:[x,S,N]}),e[32]=S,e[33]=N,e[34]=d,e[35]=p,e[36]=x,e[37]=T):T=e[37],T}const wW=2e3;function Ai(n){return`${n.toFixed(n<10?1:0)}%`}function Nu(n){return`${n.toFixed(0)} MB`}function SW(n){return n>=10?`${n.toFixed(0)}/s`:n>=1?`${n.toFixed(1)}/s`:`${n.toFixed(2)}/s`}function kW(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 jW(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(Fe,{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(Fe,{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(Fe,{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(J,{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=K("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=Ai(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=Nu(t.memoryMb),e[30]=t.memoryMb,e[31]=x):x=e[31];let b;e[32]!==t.ageSeconds?(b=hg(t.ageSeconds),e[32]=t.ageSeconds,e[33]=b):b=e[33];let v;e[34]!==x||e[35]!==b?(v=a.jsxs("div",{className:"text-xs text-muted-foreground",children:[x," · ",b]}),e[34]=x,e[35]=b,e[36]=v):v=e[36];let y;e[37]!==g||e[38]!==v?(y=a.jsxs("div",{className:"shrink-0 text-right",children:[g,v]}),e[37]=g,e[38]=v,e[39]=y):y=e[39];let k;return e[40]!==y||e[41]!==d||e[42]!==f?(k=a.jsxs("div",{className:"flex items-start gap-3 py-2.5",children:[d,f,y]}),e[40]=y,e[41]=d,e[42]=f,e[43]=k):k=e[43],k}function NW(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 CW(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 fN(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(Fe,{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=NW(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=K("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=Ai(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=Nu(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 Pv(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(_W)}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 _W(n,e){const t=kW(n.bytesPerSecond);return a.jsxs("div",{children:[e>0&&a.jsx(Zt,{}),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:SW(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(Fe,{variant:"secondary",children:[n.active," open"]})]})]},n.name)}function TW(n){const e=q.c(8),{values:t}=n,s=Math.max(100,...t);let r;e[0]!==t?(r=t.map(EW).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:K("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:Ai(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 EW(n){return Ai(n)}function AW(n){var ge,be,ue,he;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]=Sr();let v;e[1]===Symbol.for("react.memo_cache_sentinel")?(v=async()=>{var we;if(g.current)return;g.current=!0,h(!0);const me=Re("/api/performance").then(MW),xe=((we=window.electronPerformance)==null?void 0:we.getSnapshot())??Promise.resolve(null),[je,Le]=await Promise.allSettled([me,xe]),Se=je.status==="fulfilled"?je.value:null,Ie=Le.status==="fulfilled"?Le.value:null;if(Se&&l(Se),Ie&&o(Ie),!Se&&!Ie)m("Performance data is unavailable.");else{m(null);const Be=Ie&&Ie.processes.length>0?Ie.processes.reduce(OW,0):(Se==null?void 0:Se.cpuPercent)??0;d(De=>[...De.slice(-29),Be])}g.current=!1,h(!1)},e[1]=v):v=e[1];const y=v;let k,j;e[2]!==t?(k=()=>{if(!t)return;y();const me=window.setInterval(()=>void y(),wW);return()=>window.clearInterval(me)},j=[t,y],e[2]=t,e[3]=k,e[4]=j):(k=e[3],j=e[4]),w.useEffect(k,j);let C,_,S,N,T,E,A,P,I,O,R,$,M,z,F,D,L,B,U;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 me=[...(r==null?void 0:r.processes)??[]].sort(RW),xe=me.length>0?me.reduce($W,0):(i==null?void 0:i.cpuPercent)??0,je=me[0];let Le;e[33]!==((ge=i==null?void 0:i.system)==null?void 0:ge.processes)?(Le=((be=i==null?void 0:i.system)==null?void 0:be.processes)??[],e[33]=(ue=i==null?void 0:i.system)==null?void 0:ue.processes,e[34]=Le):Le=e[34],A=Le;const Se=((he=i==null?void 0:i.system)==null?void 0:he.suspectedLeakCount)??0,Ie=Se>0||xe>=80?"High":xe>=15?"Active":"Idle";let we;e[35]===Symbol.for("react.memo_cache_sentinel")?(we=async vt=>{try{await Re("/api/system-processes/kill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pids:[vt]})}),await new Promise(IW)}catch{}y()},e[35]=we):we=e[35],E=we;let Be;e[36]!==b||e[37]!==r||e[38]!==u||e[39]!==i?(Be=()=>{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]=Be):Be=e[40];const De=Be;T=or,M=t,z=s,N=ir,O="h-[min(780px,calc(100vh-2rem))] gap-0 p-0 sm:max-w-3xl";let Ue;e[41]===Symbol.for("react.memo_cache_sentinel")?(Ue=a.jsx(ar,{children:"Power & activity monitor"}),e[41]=Ue):Ue=e[41];const We=Ie==="High"?"destructive":"secondary";let Oe;e[42]!==Ie||e[43]!==We?(Oe=a.jsxs("div",{className:"flex items-center gap-2",children:[Ue,a.jsx(Fe,{variant:We,children:Ie})]}),e[42]=Ie,e[43]=We,e[44]=Oe):Oe=e[44];let pe;e[45]===Symbol.for("react.memo_cache_sentinel")?(pe=a.jsx(lr,{className:"mt-1",children:"Live CPU, memory, and wakeups. Sampling runs only while this window is open."}),e[45]=pe):pe=e[45];let ke;e[46]!==Oe?(ke=a.jsxs("div",{className:"min-w-0 flex-1",children:[Oe,pe]}),e[46]=Oe,e[47]=ke):ke=e[47];let _e;e[48]===Symbol.for("react.memo_cache_sentinel")?(_e=()=>void y(),e[48]=_e):_e=e[48];const ye=p&&"animate-spin";let Pe;e[49]!==ye?(Pe=K(ye),e[49]=ye,e[50]=Pe):Pe=e[50];let Ye;e[51]!==Pe?(Ye=a.jsx(Un,{"data-icon":"inline-start",className:Pe}),e[51]=Pe,e[52]=Ye):Ye=e[52];let Xe;e[53]!==p||e[54]!==Ye?(Xe=a.jsxs(J,{variant:"outline",size:"sm",onClick:_e,disabled:p,children:[Ye,"Refresh"]}),e[53]=p,e[54]=Ye,e[55]=Xe):Xe=e[55];const Ee=!i&&!r;let Ze;e[56]!==x?(Ze=x?a.jsx(Bt,{"data-icon":"inline-start"}):a.jsx(fs,{"data-icon":"inline-start"}),e[56]=x,e[57]=Ze):Ze=e[57];const fe=x?"Copied":"Copy data";let Te;e[58]!==De||e[59]!==Ee||e[60]!==Ze||e[61]!==fe?(Te=a.jsxs(J,{variant:"outline",size:"sm",onClick:De,disabled:Ee,children:[Ze,fe]}),e[58]=De,e[59]=Ee,e[60]=Ze,e[61]=fe,e[62]=Te):Te=e[62];let Ve;e[63]!==Xe||e[64]!==Te?(Ve=a.jsxs("div",{className:"flex shrink-0 gap-1",children:[Xe,Te]}),e[63]=Xe,e[64]=Te,e[65]=Ve):Ve=e[65],e[66]!==ke||e[67]!==Ve?(R=a.jsx(ho,{className:"p-5 pb-4",children:a.jsxs("div",{className:"flex items-start gap-3 pr-8",children:[ke,Ve]})}),e[66]=ke,e[67]=Ve,e[68]=R):R=e[68],e[69]===Symbol.for("react.memo_cache_sentinel")?($=a.jsx(Zt,{}),e[69]=$):$=e[69],S=yl,I="min-h-0 min-w-0 flex-1",B="flex flex-col gap-4 p-5",e[70]!==f?(U=f&&a.jsx(Ft,{variant:"destructive",children:a.jsx(Ut,{children:f})}),e[70]=f,e[71]=U):U=e[71];let He;e[72]===Symbol.for("react.memo_cache_sentinel")?(He=a.jsx(Ss,{children:"Current load"}),e[72]=He):He=e[72];const $e=xe>=80&&"text-destructive";let tt;e[73]!==$e?(tt=K("font-mono text-lg font-semibold tabular-nums",$e),e[73]=$e,e[74]=tt):tt=e[74];const bt=a.jsxs(ws,{children:[He,a.jsx(ks,{children:CW(xe,je,Se)}),a.jsx(jR,{children:a.jsxs("span",{className:tt,children:[Ai(xe)," CPU"]})})]});let ut;e[75]!==u?(ut=a.jsx(ss,{children:a.jsx(TW,{values:u})}),e[75]=u,e[76]=ut):ut=e[76],e[77]!==bt||e[78]!==ut?(P=a.jsxs(ns,{size:"sm",children:[bt,ut]}),e[77]=bt,e[78]=ut,e[79]=P):P=e[79],_=ns,D="sm",e[80]===Symbol.for("react.memo_cache_sentinel")?(L=a.jsxs(ws,{children:[a.jsx(Ss,{children:"Processes"}),a.jsx(ks,{children:"Which part of Cogpit is consuming CPU and memory."})]}),e[80]=L):L=e[80],C=ss,F=me.length>0?me.map(PW):i?a.jsx(fN,{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]=C,e[15]=_,e[16]=S,e[17]=N,e[18]=T,e[19]=E,e[20]=A,e[21]=P,e[22]=I,e[23]=O,e[24]=R,e[25]=$,e[26]=M,e[27]=z,e[28]=F,e[29]=D,e[30]=L,e[31]=B,e[32]=U}else C=e[14],_=e[15],S=e[16],N=e[17],T=e[18],E=e[19],A=e[20],P=e[21],I=e[22],O=e[23],R=e[24],$=e[25],M=e[26],z=e[27],F=e[28],D=e[29],L=e[30],B=e[31],U=e[32];let W;e[81]!==C||e[82]!==F?(W=a.jsx(C,{children:F}),e[81]=C,e[82]=F,e[83]=W):W=e[83];let V;e[84]!==_||e[85]!==W||e[86]!==D||e[87]!==L?(V=a.jsxs(_,{size:D,children:[L,W]}),e[84]=_,e[85]=W,e[86]=D,e[87]=L,e[88]=V):V=e[88];let H;e[89]!==E||e[90]!==A?(H=A.length>0&&a.jsxs(ns,{size:"sm",children:[a.jsxs(ws,{children:[a.jsx(Ss,{children:"Agent processes"}),a.jsx(ks,{children:"Claude sessions, browsers, and scripts running outside Cogpit."})]}),a.jsx(ss,{children:A.map((me,xe)=>a.jsxs("div",{children:[xe>0&&a.jsx(Zt,{}),a.jsx(jW,{metric:me,onKill:je=>void E(je)})]},me.pid))})]}),e[89]=E,e[90]=A,e[91]=H):H=e[91];let G;e[92]===Symbol.for("react.memo_cache_sentinel")?(G=a.jsx(Ss,{children:"Server activity"}),e[92]=G):G=e[92];const Z=(i==null?void 0:i.sampleWindowSeconds)??10;let Y;e[93]!==Z?(Y=a.jsxs(ws,{children:[G,a.jsxs(ks,{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 ee;e[97]!==X?(ee=a.jsx(ss,{children:a.jsx(Pv,{metrics:X,emptyLabel:"No watched-file or stream activity in this sample."})}),e[97]=X,e[98]=ee):ee=e[98];let Q;e[99]!==Y||e[100]!==ee?(Q=a.jsxs(ns,{size:"sm",children:[Y,ee]}),e[99]=Y,e[100]=ee,e[101]=Q):Q=e[101];let ne;e[102]===Symbol.for("react.memo_cache_sentinel")?(ne=a.jsxs(ws,{children:[a.jsx(Ss,{children:"API activity"}),a.jsx(ks,{children:"Requests ranked by recent frequency and time."})]}),e[102]=ne):ne=e[102];let re;e[103]!==(i==null?void 0:i.requests)?(re=(i==null?void 0:i.requests)??[],e[103]=i==null?void 0:i.requests,e[104]=re):re=e[104];let se;e[105]!==re?(se=a.jsxs(ns,{size:"sm",children:[ne,a.jsx(ss,{children:a.jsx(Pv,{metrics:re,emptyLabel:"No API requests in this sample."})})]}),e[105]=re,e[106]=se):se=e[106];let oe;e[107]!==Q||e[108]!==se?(oe=a.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[Q,se]}),e[107]=Q,e[108]=se,e[109]=oe):oe=e[109];let ae;e[110]!==i?(ae=i&&a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Server event loop ",Ai(i.eventLoopPercent)," · heap ",Nu(i.memory.heapUsedMb)," · RSS ",Nu(i.memory.rssMb)]}),e[110]=i,e[111]=ae):ae=e[111];let ie;e[112]!==P||e[113]!==V||e[114]!==H||e[115]!==oe||e[116]!==ae||e[117]!==B||e[118]!==U?(ie=a.jsxs("div",{className:B,children:[U,P,V,H,oe,ae]}),e[112]=P,e[113]=V,e[114]=H,e[115]=oe,e[116]=ae,e[117]=B,e[118]=U,e[119]=ie):ie=e[119];let ce;e[120]!==S||e[121]!==I||e[122]!==ie?(ce=a.jsx(S,{className:I,children:ie}),e[120]=S,e[121]=I,e[122]=ie,e[123]=ce):ce=e[123];let te;e[124]!==N||e[125]!==O||e[126]!==R||e[127]!==$||e[128]!==ce?(te=a.jsxs(N,{className:O,children:[R,$,ce]}),e[124]=N,e[125]=O,e[126]=R,e[127]=$,e[128]=ce,e[129]=te):te=e[129];let le;return e[130]!==T||e[131]!==M||e[132]!==z||e[133]!==te?(le=a.jsx(T,{open:M,onOpenChange:z,children:te}),e[130]=T,e[131]=M,e[132]=z,e[133]=te,e[134]=le):le=e[134],le}function PW(n,e){return a.jsxs("div",{children:[e>0&&a.jsx(Zt,{}),a.jsx(fN,{metric:n})]},n.pid)}function IW(n){return setTimeout(n,1e3)}function $W(n,e){return n+e.cpuPercent}function RW(n,e){return e.cpuPercent-n.cpuPercent}function OW(n,e){return n+e.cpuPercent}async function MW(n){if(!n.ok)throw new Error(`Server monitor returned ${n.status}`);return n.json()}function LW(n){return`${n.title??`Pull request #${n.number}`}
|
|
118
|
+
${n.repo}${n.isDraft?" · draft":""}`}function mN(n){return{href:n.url,target:"_blank",rel:"noreferrer",onClick:e=>e.stopPropagation(),"aria-label":`Pull request #${n.number}`,title:LW(n)}}function $l(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(DW),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(zW).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?US:BS;return a.jsxs(Fe,{variant:p.isDraft?"outline":"secondary",render:a.jsx("a",{...mN(p)}),className:K("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 zW(n){return`#${n.number} ${n.title??n.repo}`}function DW(n){const e=n.isDraft?US:BS;return a.jsxs("a",{...mN(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 FW=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 E=r?so(r.fileName):null;p=E?d1(E.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(WW),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=ji(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 v=b;let y;t[7]===Symbol.for("react.memo_cache_sentinel")?(y=a.jsx("div",{className:K(Gs,"flex h-8 min-w-0 items-center gap-2 pl-1 pr-3")}),t[7]=y):y=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(BW,{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(ld,{"aria-label":"Session is live"}),t[17]=o,t[18]=j):j=t[18];let C;t[19]!==s.model?(C=s.model&&a.jsx("span",{className:"shrink-0 font-mono text-[11px] text-foreground/80",children:Do(s.model)}),t[19]=s.model,t[20]=C):C=t[20];let _;t[21]!==v?(_=a.jsx(Mk,{rawMessages:v}),t[21]=v,t[22]=_):_=t[22];let S;t[23]!==k||t[24]!==j||t[25]!==C||t[26]!==_?(S=a.jsxs(Xt,{delay:200,render:y,children:[k,j,C,_]}),t[23]=k,t[24]=j,t[25]=C,t[26]=_,t[27]=S):S=t[27];let N;t[28]!==i||t[29]!==v||t[30]!==s||t[31]!==h||t[32]!==x?(N=a.jsx(Jt,{role:"tooltip",side:"bottom",align:"start",sideOffset:6,className:"p-3",children:a.jsx(UW,{session:s,thinkingEnabled:x,subAgentLabel:h,pullRequests:i,rawMessages:v})}),t[28]=i,t[29]=v,t[30]=s,t[31]=h,t[32]=x,t[33]=N):N=t[33];let T;return t[34]!==N||t[35]!==S?(T=a.jsxs(Yt,{children:[S,N]}),t[34]=N,t[35]=S,t[36]=T):T=t[36],T});function Go(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 UW(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=gk(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(Go,{label:"Model",children:[a.jsx("span",{children:Do(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(Go,{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(Go,{label:"Pull requests",children:a.jsx($l,{pullRequests:o})}),e[19]=o,e[20]=d):d=e[20],e[21]!==r?(f=r&&a.jsx(Go,{label:"Agent",children:r}),e[21]=r,e[22]=f):f=e[22],e[23]!==x?(m=x&&a.jsxs(Go,{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(Go,{label:"Context",children:[jt(Math.max(0,g.compactAt-g.used))," left before compact ·"," ",jt(g.used)," / ",jt(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 BW(n){const e=q.c(54),{session:t,sessionSource:s,copied:r,creatingSession:o,onCopyResume:i,onNewSession:l,onDuplicateSession:c,onOpenTerminal:u}=n,{dispatch:d}=hn(),f=!!(t.cwd||s.dirName);let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=Lo(),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?`${wr(t.cwd)} / ${g}`:g,e[4]=t.cwd,e[5]=g,e[6]=x):x=e[6];const b=x;let v;e[7]!==t.cwd||e[8]!==s.dirName?(v={path:t.cwd,dirName:s.dirName},e[7]=t.cwd,e[8]=s.dirName,e[9]=v):v=e[9];const y=v;let k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=!p||Lg(),e[10]=k):k=e[10];const j=k;let C;e[11]!==d||e[12]!==s.dirName?(C=function(){w.startTransition(()=>{d({type:"GO_HOME",isMobile:!1}),d({type:"SET_DASHBOARD_PROJECT",dirName:s.dirName})})},e[11]=d,e[12]=s.dirName,e[13]=C):C=e[13];const _=C,S=`Copy resume command for ${b}; open session actions with the context menu`;let N;e[14]!==i||e[15]!==S?(N=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":S,"aria-haspopup":"menu",title:"Click to copy resume command. Right-click for session actions."}),e[14]=i,e[15]=S,e[16]=N):N=e[16];let T;e[17]!==r||e[18]!==t.cwd||e[19]!==g?(T=r?a.jsxs("span",{className:"flex items-center gap-1.5 text-success",children:[a.jsx(Bt,{className:"size-3"})," Copied"]}):a.jsxs(a.Fragment,{children:[t.cwd&&a.jsx("span",{className:"truncate text-muted-foreground",children:wr(t.cwd)}),t.cwd&&a.jsx("span",{className:"text-muted-foreground/50",children:"/"}),a.jsx("span",{className:"truncate",children:g})]}),e[17]=r,e[18]=t.cwd,e[19]=g,e[20]=T):T=e[20];let E;e[21]!==N||e[22]!==T?(E=a.jsx(Nd,{render:N,children:T}),e[21]=N,e[22]=T,e[23]=E):E=e[23];let A;e[24]!==l||e[25]!==t.cwd||e[26]!==s.dirName?(A=()=>l(s.dirName,t.cwd),e[24]=l,e[25]=t.cwd,e[26]=s.dirName,e[27]=A):A=e[27];let P;e[28]!==o?(P=o?a.jsx(Cn,{className:"size-3.5"}):a.jsx(Qs,{className:"size-3.5"}),e[28]=o,e[29]=P):P=e[29];let I;e[30]!==o||e[31]!==A||e[32]!==P?(I=a.jsxs(jn,{disabled:o,onClick:A,children:[P,"New session in this project"]}),e[30]=o,e[31]=A,e[32]=P,e[33]=I):I=e[33];let O;e[34]!==c?(O=c&&a.jsxs(jn,{onClick:c,children:[a.jsx(fs,{className:"size-3.5"}),"Duplicate this session"]}),e[34]=c,e[35]=O):O=e[35];let R;e[36]!==f||e[37]!==y?(R=f&&(j||!p)&&a.jsxs(a.Fragment,{children:[a.jsx(Ei,{}),j&&a.jsxs(jn,{onClick:()=>a3(y),children:[a.jsx(ng,{className:"size-3.5"}),"Open project in editor"]}),!p&&a.jsxs(jn,{onClick:()=>l3(y),children:[a.jsx(WS,{className:"size-3.5"}),"Reveal in file manager"]})]}),e[36]=f,e[37]=y,e[38]=R):R=e[38];let $;e[39]!==u?($=u&&!p&>("terminal")&&a.jsxs(jn,{onClick:u,children:[a.jsx(zi,{className:"size-3.5"}),"Open terminal in project"]}),e[39]=u,e[40]=$):$=e[40];let M;e[41]===Symbol.for("react.memo_cache_sentinel")?(M=a.jsx(Ei,{}),e[41]=M):M=e[41];let z;e[42]===Symbol.for("react.memo_cache_sentinel")?(z=a.jsx(Si,{className:"size-3.5"}),e[42]=z):z=e[42];let F;e[43]!==_?(F=a.jsxs(jn,{onClick:_,children:[z,"View all sessions in this project"]}),e[43]=_,e[44]=F):F=e[44];let D;e[45]!==I||e[46]!==O||e[47]!==R||e[48]!==$||e[49]!==F?(D=a.jsxs(Cd,{className:"min-w-56",children:[I,O,R,$,M,F]}),e[45]=I,e[46]=O,e[47]=R,e[48]=$,e[49]=F,e[50]=D):D=e[50];let L;return e[51]!==E||e[52]!==D?(L=a.jsxs(jd,{children:[E,D]}),e[51]=E,e[52]=D,e[53]=L):L=e[53],L}function WW(n){return n.thinking.length>0}const oa="Could not reach the server";async function mc(n,e){try{return await Re(n,e)}catch{return null}}function qW(){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 C=await mc("/api/shares");if(!(C!=null&&C.ok))return;const _=await C.json().catch(GW);i.current&&Array.isArray(_)&&s(_)},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 C=>{o(null);const _=await mc("/api/shares",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:C})});if(!(_!=null&&_.ok))return i.current&&o(await $f(_,oa)),null;const S=await _.json().catch(KW);if(!(S!=null&&S.passphrase)||!S.share)return i.current&&o(oa),null;const N=S.share;return i.current&&s(T=>[...T.filter(E=>E.sessionId!==N.sessionId),N]),S.passphrase},n[6]=p):p=n[6];const h=p;let g;n[7]===Symbol.for("react.memo_cache_sentinel")?(g=async C=>{o(null);const _=await mc(`/api/shares/${encodeURIComponent(C)}/regenerate`,{method:"POST"});if(!(_!=null&&_.ok))return i.current&&o(await $f(_,oa)),null;const S=await _.json().catch(HW);return S!=null&&S.passphrase?(d(),S.passphrase):(i.current&&o(oa),null)},n[7]=g):g=n[7];const x=g;let b;n[8]===Symbol.for("react.memo_cache_sentinel")?(b=async C=>{o(null);const _=await mc(`/api/shares/${encodeURIComponent(C)}`,{method:"DELETE"});if(!(_!=null&&_.ok)){i.current&&o(await $f(_,oa));return}i.current&&s(S=>S.filter(N=>N.sessionId!==C))},n[8]=b):b=n[8];const v=b;let y;n[9]!==t?(y=async()=>{const C=t.map(VW);for(const _ of C)await v(_)},n[9]=t,n[10]=y):y=n[10];const k=y;let j;return n[11]!==r||n[12]!==k||n[13]!==t?(j={shares:t,error:r,refresh:d,create:h,regenerate:x,revoke:v,revokeAll:k},n[11]=r,n[12]=k,n[13]=t,n[14]=j):j=n[14],j}function VW(n){return n.sessionId}function HW(){return null}function KW(){return null}function GW(){return null}const ZW=5e3,YW="••••";function XW(n){return n===0?"No guests connected":n===1?"1 guest connected":`${n} guests connected`}function JW({sessionId:n}){const{config:{networkAccessDisabled:e}}=hn(),{shares:t,error:s,refresh:r,create:o,regenerate:i,revoke:l}=qW(),[c,u]=w.useState(!1),[d,f]=w.useState(null),[m,p]=w.useState(!1),[h,g]=Sr(),[x,b]=Sr(),v=t.find(C=>C.sessionId===n)??null,y=`${window.location.origin}${S$(n)}`;w.useEffect(()=>f(null),[n]),w.useEffect(()=>{if(!c)return;r();const C=setInterval(()=>void r(),ZW);return()=>clearInterval(C)},[c,r]);async function k(C){p(!0);try{await C()}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(Wi,{open:c,onOpenChange:C=>{u(C),C||f(null)},children:[a.jsx(qi,{render:a.jsx(J,{type:"button",variant:"ghost",size:"icon-sm","aria-label":v?"Session is shared":"Share session",className:K(v&&"bg-primary/15 text-primary hover:bg-primary/25")}),children:a.jsx(J6,{"data-icon":"inline-start"})}),a.jsx(Vi,{align:"end",sideOffset:6,className:"w-80 p-3",children:v?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:y}),a.jsx(J,{variant:"ghost",size:"icon-xs","aria-label":"Copy link",onClick:()=>g(y),children:h?a.jsx(Bt,{"data-icon":"inline-start"}):a.jsx(fs,{"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??YW}),a.jsx(J,{variant:"ghost",size:"icon-xs","aria-label":"Regenerate passphrase",disabled:m,onClick:()=>k(async()=>{f(await i(n))}),children:a.jsx(Un,{"data-icon":"inline-start"})})]}),d?a.jsx(J,{variant:"secondary",size:"xs",onClick:()=>b(`${y}
|
|
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:XW(v.guests)}),a.jsx(J,{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(J,{size:"xs",disabled:m,onClick:()=>k(async()=>{f(await o(n))}),children:"Enable sharing"})]})})]})}function S1(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 St(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 Xr(n){return typeof n=="string"?n:void 0}function Kr(n){return n?S1(Ms(n.utilization),Xr(n.resets_at)):void 0}function pN(n){if(n)return{isEnabled:!!n.is_enabled,monthlyLimit:Ms(n.monthly_limit),usedCredits:Ms(n.used_credits),utilization:Ms(n.utilization)}}function QW(n){return{fiveHour:Kr(St(n.five_hour)),sevenDay:Kr(St(n.seven_day)),sevenDayOpus:Kr(St(n.seven_day_opus)),sevenDaySonnet:Kr(St(n.seven_day_sonnet)),extraUsage:pN(St(n.extra_usage)),subscriptionType:Xr(n.subscriptionType)}}function eq(n){if(n.available!==!0)return null;const e=St(n.usage),t=St(e==null?void 0:e.rate_limits),s=St(n.account),r={fiveHour:Kr(St(t==null?void 0:t.five_hour)),sevenDay:Kr(St(t==null?void 0:t.seven_day)),sevenDayOpus:Kr(St(t==null?void 0:t.seven_day_opus)),sevenDaySonnet:Kr(St(t==null?void 0:t.seven_day_sonnet)),extraUsage:pN(St(t==null?void 0:t.extra_usage)),subscriptionType:Xr(e==null?void 0:e.subscription_type)??Xr(s==null?void 0:s.subscriptionType)};return r.fiveHour||r.sevenDay||r.extraUsage||r.subscriptionType?r:null}function tq(n){const e=Ms(n);if(e!==void 0)return new Date(e<1e10?e*1e3:e).toISOString()}function nq(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 Iv(n,e){if(n)return S1(Ms(n.usedPercent),tq(n.resetsAt),nq(n.windowDurationMins,e))}function sq(n){var u,d,f;if(n.available!==!0)return null;const e=St((u=St(n.rateLimits))==null?void 0:u.rateLimits),t=St((d=St(n.account))==null?void 0:d.account),s=St((f=St(n.usage))==null?void 0:f.summary),r=St(e==null?void 0:e.credits),o=Iv(St(e==null?void 0:e.primary),"Primary"),i=Iv(St(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:Xr(e==null?void 0:e.planType)??Xr(t==null?void 0:t.planType),lifetimeTokens:c,creditBalance:Xr(r==null?void 0:r.balance),creditsUnlimited:(r==null?void 0:r.unlimited)===!0}}function $v(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),S1(o,Xr(n.resetDate),e)}function rq(n){var s;if(n.available!==!0)return null;const e=St((s=St(n.quota))==null?void 0:s.quotaSnapshots),t=$v(St(e==null?void 0:e.chat),"Chat")??$v(St(e==null?void 0:e.premium_interactions),"Premium interactions");return t?{fiveHour:t}:null}const oq={claude:{endpoint:"/api/claude/runtime",read:eq,legacy:{endpoint:"/api/usage",read:QW}},codex:{endpoint:"/api/codex/runtime",read:sq},copilot:{endpoint:"/api/copilot/runtime",read:rq}};function iq(n){return oq[n]}const aq=300*1e3;function lq(n=zo){const e=Wn("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=iq(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 v=await x.json();if(!p())return;const y=b(v);l(y!==null),s(y?{...y,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,aq);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 hN(n){return n>=90?"danger":n>=80?"warning":n>=60?"caution":"nominal"}const gN={nominal:"text-muted-foreground",caution:"text-warning",warning:"text-warning",danger:"text-destructive"};function cq(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?id(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(Fe,{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=hN(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:K("font-semibold",gN[b]),children:[h.pct.toFixed(1),"%"]})]}),a.jsx(vl,{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(Zt,{}),"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(Zt,{}),t.lifetimeTokens!=null&&a.jsxs("div",{children:["Lifetime: ",jt(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 uq(n){var k,j;const e=q.c(22),{agentKind:t}=n,s=t===void 0?zo:t,{usage:r,loading:o,available:i,refresh:l}=lq(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?id(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(J,{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=gN[hN(c)],p=o&&"opacity-50";let h;e[6]!==m||e[7]!==p?(h=K("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(Xt,{render:f,children:x}),e[14]=f,e[15]=x,e[16]=b):b=e[16];let v;e[17]!==r?(v=a.jsx(Jt,{side:"bottom",className:"p-3",children:a.jsx(cq,{usage:r})}),e[17]=r,e[18]=v):v=e[18];let y;return e[19]!==b||e[20]!==v?(y=a.jsxs(Yt,{children:[b,v]}),e[19]=b,e[20]=v,e[21]=y):y=e[21],y}function dq(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(mq);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(fq),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 fq(n){return n+1}function mq(n){return{...n,loading:!0,error:null}}function pq(n){const e=n.trim().toLowerCase().replace(/\[[^\]]*\]$/,""),t=e.lastIndexOf("/");return t===-1?e:e.slice(t+1)}const hq=new Set(["<synthetic>","synthetic","opus","sonnet","haiku","fable"]);function gq(n,e){const t=pq(e);return t.length===0||hq.has(t)?null:n.get(t)??null}function xq(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 bq(n){return n.uncachedInputUsd+n.cachedInputUsd+n.cacheCreationUsd+n.outputUsd}function vq(n,e,t,s=null){const r=gq(n,e);if(r===null)return null;const o=Math.min(t.cacheCreation1hTokens,t.cacheCreationTokens),i=t.cacheCreationTokens-o,l=xq(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 yq(n,e,t,s,r=null){const o=vq(n,e,t,r);return o===null?{costUsd:0,costSource:"unpriced"}:{costUsd:bq(o),costSource:"modelPriced"}}function k1(n){return n.uncachedInputTokens+n.cachedInputTokens+n.cacheCreationTokens+n.outputTokens}function wq(n,e,t){if(!e)return 0;const{costUsd:s,costSource:r}=yq(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 Sq=[{days:7,label:"7 days"},{days:30,label:"30 days"},{days:90,label:"90 days"}],Ia=wk.map(n=>({key:n,label:es(n).displayName,color:gI(n)}));function kq(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 Rv(){return{claude:{costUsd:0,tokens:0},codex:{costUsd:0,tokens:0},copilot:{costUsd:0,tokens:0}}}function jq(n){const e=new Map;for(const r of kq(n.sinceDay,n.untilDay))e.set(r,{day:r,byProvider:Rv(),costUsd:0,tokens:0});const t=new Map,s={costUsd:0,tokens:0,cacheSavingsUsd:0,byProvider:Rv(),days:[],models:[]};for(const r of n.buckets){const o=k1(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 Ov(n){const e=Date.parse(`${n}T00:00:00Z`);return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",timeZone:"UTC"}).format(e)}const Mf=720,Lf=180,Nq=18;function Cq(n){const e=q.c(41),{days:t,metric:s}=n,[r,o]=w.useState(null);let i;e[0]!==s?(i=_=>s==="cost"?_.costUsd:_.tokens,e[0]=s,e[1]=i):i=e[1];const l=i;let c;if(e[2]!==t||e[3]!==l){let _;e[5]!==l?(_=S=>l(S),e[5]=l,e[6]=_):_=e[6],c=Math.max(...t.map(_)),e[2]=t,e[3]=l,e[4]=c}else c=e[4];const u=c;if(u<=0){let _;return e[7]===Symbol.for("react.memo_cache_sentinel")?(_=a.jsx("div",{className:"flex h-32 items-center justify-center text-xs text-muted-foreground",children:"No activity in this window."}),e[7]=_):_=e[7],_}const d=Lf-Nq,f=Mf/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:Ov(p.day)}),Ia.map(_=>{const{key:S,label:N,color:T}=_,E=p.byProvider[S];return l(E)<=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:T}}),N,": ",s==="cost"?rs(E.costUsd):jt(E.tokens)]},S)}),a.jsx("span",{className:"ml-2 font-medium",children:s==="cost"?rs(p.costUsd):jt(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:Mf,y2:d,stroke:"var(--border)",strokeWidth:1}),e[12]=x,e[13]=b):(x=e[12],b=e[13]);let v;if(e[14]!==m||e[15]!==t||e[16]!==r||e[17]!==u||e[18]!==f||e[19]!==l){let _;e[21]!==m||e[22]!==r||e[23]!==u||e[24]!==f||e[25]!==l?(_=(S,N)=>{const T=N*f+(f-m)/2;let E=d;const A=r===N;return a.jsxs("g",{onMouseEnter:()=>o(N),children:[a.jsx("rect",{x:N*f,y:0,width:f,height:d,fill:"transparent"}),A&&a.jsx("rect",{x:N*f,y:0,width:f,height:d,fill:"var(--foreground)",opacity:.05,rx:2}),Ia.map(P=>{const{key:I,color:O}=P,R=l(S.byProvider[I]);if(R<=0)return null;const $=R/u*(d-6);return E=E-$,a.jsx("rect",{x:T,y:E,width:m,height:Math.max(1,$-1.5),rx:1.5,fill:O,opacity:A?1:.85},I)})]},S.day)},e[21]=m,e[22]=r,e[23]=u,e[24]=f,e[25]=l,e[26]=_):_=e[26],v=t.map(_),e[14]=m,e[15]=t,e[16]=r,e[17]=u,e[18]=f,e[19]=l,e[20]=v}else v=e[20];let y;if(e[27]!==t||e[28]!==f){let _;e[30]!==t.length||e[31]!==f?(_=(S,N)=>N===0||N===t.length-1||t.length>10&&N%7===0&&N<t.length-3?a.jsx("text",{x:N*f+f/2,y:Lf-4,textAnchor:"middle",className:"fill-muted-foreground text-[10px]",children:Ov(S.day)},S.day):null,e[30]=t.length,e[31]=f,e[32]=_):_=e[32],y=t.map(_),e[27]=t,e[28]=f,e[29]=y}else y=e[29];let k;e[33]!==g||e[34]!==v||e[35]!==y?(k=a.jsxs("svg",{viewBox:`0 0 ${Mf} ${Lf}`,className:"w-full",role:"img","aria-label":g,onMouseLeave:x,children:[b,v,y]}),e[33]=g,e[34]=v,e[35]=y,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:Ia.map(_q)}),e[37]=j):j=e[37];let C;return e[38]!==h||e[39]!==k?(C=a.jsxs("div",{className:"relative",children:[h,k,j]}),e[38]=h,e[39]=k,e[40]=C):C=e[40],C}function _q(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 zf(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 Tq(n){const e=q.c(68),{days:t}=n,{summary:s,loading:r,error:o,refresh:i}=dq(t),[l,c]=w.useState("cost");let u;e[0]!==s?(u=s?jq(s):null,e[0]=s,e[1]=u):u=e[1];const d=u;if(o){let D;e[2]!==i?(D=a.jsx(J,{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(Cn,{className:"size-4"})," Scanning transcripts…"]}),e[7]=D):D=e[7],D}const f=r&&"opacity-60";let m;e[8]!==f?(m=K("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"?rs(d.costUsd):jt(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 v;e[22]===Symbol.for("react.memo_cache_sentinel")?(v=["cost","tokens"],e[22]=v):v=e[22];let y;e[23]!==l?(y=a.jsx("div",{className:"flex rounded-md border p-0.5",children:v.map(D=>a.jsx(J,{variant:l===D?"secondary":"ghost",size:"xs",onClick:()=>c(D),children:D==="cost"?"Cost":"Tokens"},D))}),e[23]=l,e[24]=y):y=e[24];let k;e[25]!==d.byProvider||e[26]!==l?(k=Ia.map(D=>{const{key:L,label:B}=D,U=d.byProvider[L];return U.costUsd===0&&U.tokens===0?null:a.jsxs("span",{className:"text-xs text-muted-foreground tabular-nums",children:[B,": ",l==="cost"?rs(U.costUsd):jt(U.tokens)]},L)}),e[25]=d.byProvider,e[26]=l,e[27]=k):k=e[27];let j;e[28]!==y||e[29]!==k?(j=a.jsxs("div",{className:"flex flex-col items-end gap-1.5",children:[y,k]}),e[28]=y,e[29]=k,e[30]=j):j=e[30];let C;e[31]!==j||e[32]!==b?(C=a.jsxs("div",{className:"flex items-end justify-between gap-4",children:[b,j]}),e[31]=j,e[32]=b,e[33]=C):C=e[33];let _;e[34]!==d.days||e[35]!==l?(_=a.jsx(Cq,{days:d.days,metric:l}),e[34]=d.days,e[35]=l,e[36]=_):_=e[36];let S;e[37]!==d.tokens?(S=jt(d.tokens),e[37]=d.tokens,e[38]=S):S=e[38];let N;e[39]!==S?(N=a.jsx(zf,{label:"Processed tokens",value:S}),e[39]=S,e[40]=N):N=e[40];let T;e[41]!==d.cacheSavingsUsd?(T=rs(d.cacheSavingsUsd),e[41]=d.cacheSavingsUsd,e[42]=T):T=e[42];let E;e[43]!==T?(E=a.jsx(zf,{label:"Cache savings",value:T}),e[43]=T,e[44]=E):E=e[44];const A=String(s.scannedFiles);let P;e[45]!==A?(P=a.jsx(zf,{label:"Files scanned",value:A}),e[45]=A,e[46]=P):P=e[46];let I;e[47]!==N||e[48]!==E||e[49]!==P?(I=a.jsxs("div",{className:"grid grid-cols-3 gap-x-6 gap-y-3 border-t pt-3",children:[N,E,P]}),e[47]=N,e[48]=E,e[49]=P,e[50]=I):I=e[50];let O;e[51]===Symbol.for("react.memo_cache_sentinel")?(O=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]=O):O=e[51];let R;if(e[52]!==d.costUsd||e[53]!==d.models){let D;e[55]!==d.costUsd?(D=L=>{var B;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:(B=Ia.find(U=>U.key===L.provider))==null?void 0:B.color}}),L.model]})}),a.jsx("td",{className:"py-1.5 text-right text-foreground tabular-nums",children:L.unpriced?"—":rs(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:jt(L.tokens)})]},`${L.provider}:${L.model}`)},e[55]=d.costUsd,e[56]=D):D=e[56],R=d.models.map(D),e[52]=d.costUsd,e[53]=d.models,e[54]=R}else R=e[54];let $;e[57]!==R?($=a.jsxs("table",{className:"w-full text-sm",children:[O,a.jsx("tbody",{children:R})]}),e[57]=R,e[58]=$):$=e[58];const M=s.pricing.status==="unavailable"?" (rate table unavailable — costs incomplete)":"";let z;e[59]!==M?(z=a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Raw API-equivalent prices from LiteLLM rates",M," ","— not what a subscription bills."]}),e[59]=M,e[60]=z):z=e[60];let F;return e[61]!==C||e[62]!==_||e[63]!==I||e[64]!==$||e[65]!==z||e[66]!==m?(F=a.jsxs("div",{className:m,children:[C,_,I,$,z]}),e[61]=C,e[62]=_,e[63]=I,e[64]=$,e[65]=z,e[66]=m,e[67]=F):F=e[67],F}function Eq(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(ar,{children:"API usage"}),a.jsx(lr,{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=Sq.map(m=>a.jsx(J,{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(ho,{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(Tq,{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(ir,{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(or,{open:t,onOpenChange:s,children:d}),e[11]=s,e[12]=t,e[13]=d,e[14]=f):f=e[14],f}const Aq=/https:\/\/github\.com\/([\w.-]+)\/([\w.-]+)\/pull\/(\d+)/,Pq=/(?:^|[\n;&|(`])[ \t]*(?:[A-Za-z_]\w*=\S*[ \t]+)*gh[ \t]+pr[ \t]+create\b/,Df=String.raw`(?:--title|(?:^|\s)-t)(?:=|\s+)`,Iq=[new RegExp(`${Df}"((?:[^"\\\\]|\\\\.)*)"`),new RegExp(`${Df}'([^']*)'`),new RegExp(`${Df}(\\S+)`)];function $q(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 Rq(n){return $q(n).find(e=>Pq.test(e))??null}function Oq(n){for(const e of Iq){const t=e.exec(n);if(t)return t[1].replace(/\\(.)/g,"$1")}return null}function Mq(){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=Aq.exec(s);l&&t({url:l[0],number:Number(l[3]),repo:`${l[1]}/${l[2]}`,title:Oq(r),isDraft:/(?:^|\s)--draft(?:\s|$)/.test(r),toolCallId:o,timestamp:i})}}}function Lq(n){const e=Mq();for(const t of n)for(const s of t.toolCalls){if(s.isError||!s.result)continue;const r=Rq(s.input);r&&e.record(s.result,r,s.id,s.timestamp)}return e.pullRequests}function zq(...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 Zo="flex h-8 items-center px-0.5",Dq=w.memo(function(e){var ke;const t=q.c(98),{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}=e,b=r===void 0?s:r,{config:v}=hn(),{networkUrl:y,defaultAgentKind:k}=v,{session:j,sessionSource:C,isLive:_}=xt(),S=l1(),N=Wn("viewUsage"),[T,E]=w.useState(!1),[A,P]=w.useState(!1),[I,O]=Sr(),R=j==null?void 0:j.turns;let $;t[0]!==(S==null?void 0:S.sessions)||t[1]!==(j==null?void 0:j.sessionId)?($=(ke=S==null?void 0:S.sessions.find(_e=>_e.sessionId===(j==null?void 0:j.sessionId)))==null?void 0:ke.pullRequests,t[0]=S==null?void 0:S.sessions,t[1]=j==null?void 0:j.sessionId,t[2]=$):$=t[2];const M=$;let z;t[3]!==M||t[4]!==R?(z=zq(Lq(R??[]),M),t[3]=M,t[4]=R,t[5]=z):z=t[5];const F=z;let D;t[6]!==k||t[7]!==C?(D=C?C.agentKind??sn(C.dirName):k,t[6]=k,t[7]=C,t[8]=D):D=t[8];const L=D;let B;t[9]!==C?(B=C?so(C.fileName)!==null:!1,t[9]=C,t[10]=B):B=t[10];const U=B;let W;t[11]!==O||t[12]!==j||t[13]!==(C==null?void 0:C.agentKind)||t[14]!==(C==null?void 0:C.dirName)?(W=function(){if(!j)return;const ye=(C==null?void 0:C.agentKind)??sn((C==null?void 0:C.dirName)??null);O(lg(ye,j.sessionId,j.cwd))},t[11]=O,t[12]=j,t[13]=C==null?void 0:C.agentKind,t[14]=C==null?void 0:C.dirName,t[15]=W):W=t[15];const V=W;let H;t[16]!==y?(H=function(){y&&td(y).then(Uq)},t[16]=y,t[17]=H):H=t[17];const G=H;let Z,Y;t[18]===Symbol.for("react.memo_cache_sentinel")?(Y=a.jsx("div",{"aria-hidden":!0,className:"drag-strip absolute inset-x-0 top-0 z-10 h-10"}),Z=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]=Z,t[19]=Y):(Z=t[18],Y=t[19]);const X=!b&&"window-inset-start";let ee;t[20]!==X?(ee=K("electron-no-drag pointer-events-auto flex min-w-0 items-center gap-1.5",X),t[20]=X,t[21]=ee):ee=t[21];let Q;t[22]!==h||t[23]!==s||t[24]!==o?(Q=!s&&a.jsx(Fq,{icon:eA,label:`Show sidebar (${o})`,onClick:h}),t[22]=h,t[23]=s,t[24]=o,t[25]=Q):Q=t[25];let ne;t[26]!==U||t[27]!==f||t[28]!==j?(ne=j&&U&&f&&a.jsxs(J,{type:"button",variant:"ghost",size:"xs",onClick:f,className:K(Gs,"h-8 shrink-0 px-2.5 text-xs text-muted-foreground"),children:[a.jsx(at,{className:"size-3 rotate-180"}),"Main"]}),t[26]=U,t[27]=f,t[28]=j,t[29]=ne):ne=t[29];let re;t[30]!==I||t[31]!==l||t[32]!==V||t[33]!==_||t[34]!==u||t[35]!==c||t[36]!==d||t[37]!==F||t[38]!==j||t[39]!==C?(re=j&&a.jsx(FW,{session:j,sessionSource:C,isLive:_,pullRequests:F,copied:I,creatingSession:l,onCopyResume:V,onNewSession:c,onDuplicateSession:u,onOpenTerminal:d}),t[30]=I,t[31]=l,t[32]=V,t[33]=_,t[34]=u,t[35]=c,t[36]=d,t[37]=F,t[38]=j,t[39]=C,t[40]=re):re=t[40];let se;t[41]!==m||t[42]!==j||t[43]!==p?(se=j&&m&&(p??0)>0&&a.jsxs(J,{variant:"ghost",size:"xs",className:K(Gs,"h-8 shrink-0 gap-1 px-2.5 text-[11px] text-muted-foreground hover:text-foreground"),onClick:m,children:[a.jsx(qS,{className:"size-3"}),"Workflows",a.jsx(Fe,{variant:"outline",className:"h-4 min-w-4 justify-center px-1 text-[9px] font-semibold",children:p})]}),t[41]=m,t[42]=j,t[43]=p,t[44]=se):se=t[44];let oe;t[45]!==ee||t[46]!==Q||t[47]!==ne||t[48]!==re||t[49]!==se?(oe=a.jsxs("div",{className:ee,children:[Q,ne,re,se]}),t[45]=ee,t[46]=Q,t[47]=ne,t[48]=re,t[49]=se,t[50]=oe):oe=t[50];let ae,ie,ce;t[51]===Symbol.for("react.memo_cache_sentinel")?(ae=a.jsx("div",{className:K(Gs,Zo,"empty:hidden"),children:a.jsx(dW,{})}),ie=a.jsx("div",{className:K(Gs,Zo,"empty:hidden"),children:a.jsx(vW,{})}),ce=K(Gs,Zo,"empty:hidden"),t[51]=ae,t[52]=ie,t[53]=ce):(ae=t[51],ie=t[52],ce=t[53]);let te;t[54]!==L?(te=a.jsx("div",{className:ce,children:a.jsx(uq,{agentKind:L})}),t[54]=L,t[55]=te):te=t[55];let le;t[56]===Symbol.for("react.memo_cache_sentinel")?(le=a.jsx("div",{className:K(Gs,Zo,"empty:hidden"),children:a.jsx(w1,{})}),t[56]=le):le=t[56];let ge;t[57]!==L||t[58]!==j?(ge=j&&pn(L).sharing&>("share")&&a.jsx("div",{className:K(Gs,Zo),children:a.jsx(JW,{sessionId:j.sessionId})}),t[57]=L,t[58]=j,t[59]=ge):ge=t[59];let be;t[60]===Symbol.for("react.memo_cache_sentinel")?(be=K(Gs,Zo),t[60]=be):be=t[60];let ue;t[61]===Symbol.for("react.memo_cache_sentinel")?(ue=a.jsx(qi,{render:a.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":"More actions"}),children:a.jsx(VS,{"data-icon":"inline-start"})}),t[61]=ue):ue=t[61];let he;t[62]!==N?(he=N&&a.jsxs(vn,{onClick:()=>E(!0),children:[a.jsx(tA,{}),"Usage & cost…"]}),t[62]=N,t[63]=he):he=t[63];let me;t[64]===Symbol.for("react.memo_cache_sentinel")?(me=a.jsxs(vn,{onClick:()=>P(!0),children:[a.jsx(Tp,{}),"Server monitor…"]}),t[64]=me):me=t[64];let xe;t[65]!==G||t[66]!==y?(xe=y&&a.jsxs(vn,{onClick:G,children:[a.jsx(wi,{className:"text-success"}),"Copy network URL",a.jsx("span",{className:"ml-auto truncate pl-2 font-mono text-[11px] text-muted-foreground",children:y})]}),t[65]=G,t[66]=y,t[67]=xe):xe=t[67];let je;t[68]!==he||t[69]!==xe?(je=a.jsxs(br,{children:[he,me,xe]}),t[68]=he,t[69]=xe,t[70]=je):je=t[70];let Le;t[71]===Symbol.for("react.memo_cache_sentinel")?(Le=a.jsx(du,{}),t[71]=Le):Le=t[71];let Se;t[72]===Symbol.for("react.memo_cache_sentinel")?(Se=a.jsx(nA,{}),t[72]=Se):Se=t[72];let Ie;t[73]!==x?(Ie=a.jsx(br,{children:a.jsxs(vn,{onClick:x,children:[Se,"Settings"]})}),t[73]=x,t[74]=Ie):Ie=t[74];let we;t[75]!==i||t[76]!==g?(we=gt("killAny")&&a.jsxs(a.Fragment,{children:[a.jsx(du,{}),a.jsx(br,{children:a.jsxs(vn,{variant:"destructive",onClick:g,disabled:i,children:[a.jsx(Q6,{}),i?"Stopping processes…":"Stop all agent processes"]})})]}),t[75]=i,t[76]=g,t[77]=we):we=t[77];let Be;t[78]!==je||t[79]!==Ie||t[80]!==we?(Be=a.jsx("div",{className:be,children:a.jsxs(Wi,{children:[ue,a.jsxs(Vi,{align:"end",sideOffset:6,className:"w-64",children:[je,Le,Ie,we]})]})}),t[78]=je,t[79]=Ie,t[80]=we,t[81]=Be):Be=t[81];let De;t[82]!==te||t[83]!==ge||t[84]!==Be?(De=a.jsxs("div",{className:"electron-no-drag window-inset-end pointer-events-auto flex shrink-0 items-center gap-1.5",children:[ae,ie,te,le,ge,Be]}),t[82]=te,t[83]=ge,t[84]=Be,t[85]=De):De=t[85];let Ue;t[86]!==oe||t[87]!==De?(Ue=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:[oe,De]}),t[86]=oe,t[87]=De,t[88]=Ue):Ue=t[88];let We;t[89]!==N||t[90]!==T?(We=N&&a.jsx(Eq,{open:T,onOpenChange:E}),t[89]=N,t[90]=T,t[91]=We):We=t[91];let Oe;t[92]!==A?(Oe=a.jsx(AW,{open:A,onOpenChange:P}),t[92]=A,t[93]=Oe):Oe=t[93];let pe;return t[94]!==Ue||t[95]!==We||t[96]!==Oe?(pe=a.jsxs(a.Fragment,{children:[Y,Z,Ue,We,Oe]}),t[94]=Ue,t[95]=We,t[96]=Oe,t[97]=pe):pe=t[97],pe});function Fq(n){const e=q.c(14),{icon:t,label:s,onClick:r}=n;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=K(Gs,"size-8 shrink-0"),e[0]=o):o=e[0];let i;e[1]!==s||e[2]!==r?(i=a.jsx(J,{variant:"ghost",size:"icon-sm",onClick:r,"aria-label":s,className:o}),e[1]=s,e[2]=r,e[3]=i):i=e[3];let l;e[4]!==t?(l=a.jsx(t,{"data-icon":"inline-start"}),e[4]=t,e[5]=l):l=e[5];let c;e[6]!==i||e[7]!==l?(c=a.jsx(Xt,{render:i,children:l}),e[6]=i,e[7]=l,e[8]=c):c=e[8];let u;e[9]!==s?(u=a.jsx(Jt,{side:"bottom",children:s}),e[9]=s,e[10]=u):u=e[10];let d;return e[11]!==c||e[12]!==u?(d=a.jsxs(Yt,{children:[c,u]}),e[11]=c,e[12]=u,e[13]=d):d=e[13],d}function Uq(n){n&&ys.success("Copied network URL")}const Bq=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(ff,{icon:Mi,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(ff,{icon:Bn,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(ff,{icon:sA,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 Wq(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=K("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(iA,{"data-slot":"resizable-panel-group",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Mv(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(oA,{"data-slot":"resizable-panel",...t}),e[2]=t,e[3]=s):s=e[3],s}function qq(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=K("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(rA,{"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 xN=w.createContext(null);function bN(n){const e=q.c(3),{value:t,children:s}=n;let r;return e[0]!==s||e[1]!==t?(r=a.jsx(xN.Provider,{value:t,children:s}),e[0]=s,e[1]=t,e[2]=r):r=e[2],r}function j1(){const n=w.useContext(xN);if(!n)throw new Error("Built-in workspace panel services are unavailable");return n}function vN(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=K("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(J,{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(Xt,{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(Jt,{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(Yt,{children:[f,m]}),e[15]=f,e[16]=m,e[17]=p):p=e[17],p}function N1(n,e){return n.filter(t=>{var s;return((s=t.when)==null?void 0:s.call(t,e))??!0})}function Vq(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=N1(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(Hq),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=v=>{var C;const y=v.id===r,k=(C=v.badge)==null?void 0:C.call(v,s),j=v.indicator;return a.jsx(vN,{title:v.title,icon:v.icon,active:y,onClick:()=>o(v.id),children:j?a.jsx(j,{...v.indicatorProps,context:s,active:y}):k!=null&&a.jsx(Fe,{className:"absolute -right-1 -top-1 min-w-4 px-1 text-[9px]",variant:"secondary",children:k})},v.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 Hq(n){return a.jsx(vN,{title:n.title,icon:n.icon,active:n.active,onClick:n.onSelect},n.id)}function yN(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,v=b&&l;if(!b&&(!x.keepAlive||!u.has(x.id)))return null;const y=x.component;return a.jsx("div",{className:K("absolute inset-0 min-h-0",!v&&"hidden"),"aria-hidden":!v,children:a.jsx(y,{...x.componentProps,context:s,active:v,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-background",children:p}),e[18]=p,e[19]=h):h=e[19],h}function Kq(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 Gq(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?Kq(o.defaultSize):"100%",e[0]=o,e[1]=d):d=e[1];let f;e[2]!==t||e[3]!==d?(f=a.jsx(Mv,{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(qq,{withHandle:!0}),a.jsx(Mv,{defaultSize:o.defaultSize??"36%",minSize:o.minSize??"300px",maxSize:o.maxSize??"70%",children:a.jsx(bN,{value:i,children:a.jsx(yN,{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(Wq,{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(Vq,{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 nh(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 Lv(n,e="|"){return n.map(t=>NN(t)).join(e)}function sh(n,e){return typeof e=="bigint"?e.toString():e}class Zq{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 Ad(n){return new Zq(n)}function Yq(n){return n==null}function C1(n){const e=n.startsWith("^")?1:0,t=n.endsWith("$")?n.length-1:n.length;return n.slice(e,t)}function Xq(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 Ir(n,e,t){Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0})}function _1(n){const e=Object.getOwnPropertyDescriptor(n,"shape");return e!=null&&e.get?e.get.raw:e==null?void 0:e.value}function jr(n){return _1(n._zod.def)??n._zod.def.shape}function wN(n,e,t){Object.defineProperty(n,e,{get(){const s=t();return Ir(this,e,s),s},enumerable:!0,configurable:!0})}function SN(n,e,t){e in n?Ir(n,e,t):n[e]=t}function Po(n,e,t,s){const r=jr(e);for(const o of t){const i=Object.getOwnPropertyDescriptor(r,o);i.enumerable&&(i.get?wN(n,o,()=>{const l=e._zod.def.shape[o];return s?s(l,o):l}):SN(n,o,s?s(i.value,o):i.value))}}function Jq(n,e){for(const t of Reflect.ownKeys(e)){const s=Object.getOwnPropertyDescriptor(e,t);s.enumerable&&(s.get?wN(n,t,()=>e[t]):SN(n,t,s.value))}}function Jn(...n){const e={};for(const t of n){const s=Object.getOwnPropertyDescriptors(t);Object.assign(e,s)}return Object.defineProperties({},e)}function Qq(n){return JSON.stringify(n)}function eV(n){return n.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const kN="captureStackTrace"in Error?Error.captureStackTrace:(...n)=>{};function sl(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}const tV=Ad(()=>{var n;if(Fs.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 Pi(n){if(sl(n)===!1)return!1;const e=n.constructor;if(e===void 0||typeof e!="function")return!0;const t=e.prototype;return!(sl(t)===!1||Object.prototype.hasOwnProperty.call(t,"isPrototypeOf")===!1)}function jN(n){return Pi(n)?{...n}:Array.isArray(n)?[...n]:n instanceof Map?new Map(n):n instanceof Set?new Set(n):n}const nV=new Set(["string","number","symbol"]);function Ii(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function xo(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 qe(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 NN(n){return typeof n=="bigint"?n.toString()+"n":typeof n=="string"?`"${n}"`:`${n}`}function sV(n){return Object.keys(n).filter(e=>n[e]._zod.optin!==void 0&&n[e]._zod.optout==="optional")}const CN={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]},rV={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function oV(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 Po(o,n,Pd(n,e)),xo(n,Jn(t,{shape:o,checks:[]}))}function Pd(n,e){var r;const t=jr(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 iV(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(Pd(n,e)),i={};return Po(i,n,Reflect.ownKeys(jr(n)).filter(l=>!o.has(l))),xo(n,Jn(t,{shape:i,checks:[]}))}function aV(n,e){if(!Pi(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=jr(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 xo(n,Jn(n._zod.def,{shape:_N(n,e)}))}function _N(n,e){const t={};return Po(t,n,Reflect.ownKeys(jr(n))),Jq(t,e),t}function lV(n,e){if(!Pi(e))throw new Error("Invalid input to safeExtend: expected a plain object");return xo(n,Jn(n._zod.def,{shape:_N(n,e)}))}function cV(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={};Po(t,n,Reflect.ownKeys(jr(n))),Po(t,e,Reflect.ownKeys(jr(e)));const s=Jn(n._zod.def,{shape:t,get catchall(){return e._zod.def.catchall},checks:e._zod.def.checks??[]});return xo(n,s)}function zv(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(Pd(e,t)):void 0,c={};return Po(c,e,Reflect.ownKeys(jr(e)),n&&((u,d)=>l&&!l.has(d)?u:new n({type:"optional",innerType:u}))),xo(e,Jn(e._zod.def,{shape:c,checks:[]}))}function uV(n,e,t){const s=t?new Set(Pd(e,t)):void 0,r={};return Po(r,e,Reflect.ownKeys(jr(e)),(o,i)=>s&&!s.has(i)?o:new n({type:"nonoptional",innerType:o})),xo(e,Jn(e._zod.def,{shape:r}))}function xr(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 dV(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 ui(n,e){return e.map(t=>{var s;return(s=t).path??(s.path=[]),t.path.unshift(n),t})}function ia(n){return typeof n=="string"?n:n==null?void 0:n.message}function Dv(n,e,t){var s;for(let r=e;r<n.length;r++)(s=n[r]).schema??(s.schema=t)}function ao(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:ia((h=(p=(m=n.inst)==null?void 0:m._zod.def)==null?void 0:p.error)==null?void 0:h.call(p,n))??ia(o==null?void 0:o(n))??ia((g=e==null?void 0:e.error)==null?void 0:g.call(e,n))??ia((x=t.customError)==null?void 0:x.call(t,n))??ia((b=t.localeError)==null?void 0:b.call(t,n))??"Invalid input",l={};for(const v of Object.keys(n))v==="inst"||v==="schema"||v==="continue"||v==="input"||v==="__proto__"||(l[v]=n[v]);return l.path??(l.path=[]),l.message=i,e!=null&&e.reportInput&&(l.input=n.input),l}const fV=/[\uD800-\uDBFF]/;function T1(n){const e=n.length;if(!fV.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 E1(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function mV(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 rl(...n){const[e,t,s]=n;return typeof e=="string"?{message:e,code:"custom",input:t,inst:s}:{...e}}function pV(n,e){for(const t in e){const s=Object.getOwnPropertyDescriptor(e,t);s.get?Object.defineProperty(n,t,{...s,enumerable:!1}):hV(n,t,s.value)}}function lo(n,e,t,s=!0){return Object.defineProperty(n,e,{configurable:!0,writable:!0,enumerable:s,value:t}),t}function TN(n,e,t){return lo(n,e,t,!1)}function EN(n,e){for(const t in n){const s=n[t];Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){return lo(this,t,s(this))},set(r){lo(this,t,r)}})}return e}function hV(n,e,t){Object.defineProperty(n,e,{configurable:!0,get(){return this==null?t:lo(this,e,t.bind(this))},set(s){lo(this,e,s)}})}function gV(n,e){const t=Object.getPrototypeOf(n);return e in t?void 0:t}let Ff,Dr=!1;const xV={configurable:!0,get(){Dr=!0}};function mt(n,e,t){const s=Object.getPrototypeOf(n._zod);if(e in s&&Ff!==n._zod){Ff=void 0;return}Ff=n._zod,Object.defineProperty(s,e,{configurable:!0,get(){Object.defineProperty(this,e,xV);const r=Dr;Dr=!1;try{const o=t(this);return Dr?delete this[e]:Object.defineProperty(this,e,{configurable:!0,writable:!0,value:o}),Dr=Dr||r,o}catch(o){throw delete this[e],Dr=Dr||r,o}},set(r){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:r})}})}function bV(n,e,t,s){const r=gV(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 vV="~constantCatch";function yV(n){const e=()=>n;return e[vV]=!0,e}var Fv;const Uf={value:void 0,enumerable:!1};let Uv="captureStackTrace"in Error?Error:null;function wV(n){const e=Uv;if(e){const t=e.stackTraceLimit;if(typeof t=="number"){try{e.stackTraceLimit=0}catch{return Uv=null,new n}try{return new n}finally{e.stackTraceLimit=t}}}return new n}function de(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{Uf.value=new o(p);try{Object.defineProperty(m,"_zod",Uf)}finally{Uf.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 v=b??g;l.has(v)||(l.add(v),pV(v,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?wV(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 Eo extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class AN extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}(Fv=globalThis).__zod_globalConfig??(Fv.__zod_globalConfig={});const Fs=globalThis.__zod_globalConfig;function nr(n){return n&&Object.assign(Fs,n),Fs}function SV(){const n=this._zod;return n.message??(n.message=JSON.stringify(n.def,sh,2)),n.message}function kV(n){this._zod.message=n}const jV={get:SV,set:kV,enumerable:!0,configurable:!0},Bf={value:void 0,enumerable:!1},Bv=new WeakSet([Object.prototype,Error.prototype]),NV=(n,e)=>{n.name="$ZodError",Bf.value=e,Object.defineProperty(n,"issues",Bf),Bf.value=void 0,Object.defineProperty(n,"message",jV);const t=Object.getPrototypeOf(n);Bv.has(t)||(Bv.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})}}))},CV=de("$ZodError",NV);function _V(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 TV(n,e=t=>t.message){const t={},s=[];for(const r of n.issues)r.path.length>0?_V(t,r.path[0],()=>[]).push(e(r)):s.push(e(r));return{formErrors:s,fieldErrors:t}}function EV(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 Id(n,e){return{callee:(e==null?void 0:e.callee)??n,Err:e==null?void 0:e.Err}}const A1=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 Eo;if(l.issues.length){const c=new((o==null?void 0:o.Err)??n)(l.issues.map(u=>ao(u,i,nr())));throw kN(c,(o==null?void 0:o.callee)??e),c}return l.value};return e},P1=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=>ao(u,i,nr())));throw kN(c,(o==null?void 0:o.callee)??e),c}return l.value};return e},I1=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 Eo;return o.issues.length?PN(n,o.issues,r):{success:!0,data:o.value}};function PN(n,e,t){let s;return{success:!1,get error(){return s||(s=new n(e.map(r=>ao(r,t,nr()))),e=void 0,t=void 0),s},set error(r){s=r,e=void 0,t=void 0}}}const $1=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?PN(n,o.issues,r):{success:!0,data:o.value}},AV=Symbol.for("zod.compile.invalid"),PV=Symbol.for("zod.compile.fallback"),IV=((n,e,t)=>{const s=n._zod.bag.validator;if(s!==void 0){if(s(e)!==AV)return!0;if(s.definite===!0&&t===void 0)return!1}return $V(n,e,t)});function $V(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[PV]=!0,o=r({value:e,issues:[]},s)):o=n._zod.run({value:e,issues:[]},s),o instanceof Promise)throw new Eo;return o.issues.length===0}const RV=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},OV=n=>{const e=A1(n),t=(s,r,o,i)=>{const l=o?{...o,direction:"backward"}:{direction:"backward"};return e(s,r,l,Id(t,i))};return t},MV=n=>{const e=A1(n),t=(s,r,o,i)=>e(s,r,o,Id(t,i));return t},LV=n=>{const e=P1(n),t=async(s,r,o,i)=>{const l=o?{...o,direction:"backward"}:{direction:"backward"};return await e(s,r,l,Id(t,i))};return t},zV=n=>{const e=P1(n),t=async(s,r,o,i)=>await e(s,r,o,Id(t,i));return t},DV=n=>(e,t,s)=>{const r=s?{...s,direction:"backward"}:{direction:"backward"};return I1(n)(e,t,r)},FV=n=>(e,t,s)=>I1(n)(e,t,s),UV=n=>async(e,t,s)=>{const r=s?{...s,direction:"backward"}:{direction:"backward"};return $1(n)(e,t,r)},BV=n=>async(e,t,s)=>$1(n)(e,t,s),WV=/^[cC][0-9a-z]{6,}$/,qV=/^[0-9a-z]+$/,VV=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,HV=/^[0-9a-vA-V]{20}$/,KV=/^[A-Za-z0-9]{27}$/,GV=/^[a-zA-Z0-9_-]{21}$/;function ZV(n){return new RegExp(`^[a-zA-Z0-9_-]{${n}}$`)}const YV=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,XV=/^([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})$/,Wv=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)$/,JV=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,QV="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function eH(){return new RegExp(QV,"u")}const tH=/^(?:(?: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])$/,nH=/^(([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}|:))$/,sH=/^((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])$/,rH=/^(([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])$/,oH=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,iH=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,aH=/^https?$/,lH=/^\+[1-9]\d{6,14}$/,IN="(?:(?:\\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 cH(n){return new RegExp(`^${n}$`)}const uH=cH(IN);function rh(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 dH(n){return new RegExp(`^${rh(n)}$`)}function fH(n){const e=["Z"];n.offset&&e.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const t=`${rh({precision:n.precision,seconds:!0})}(?:${e.join("|")})`,s=n.local?`${t}|${rh({precision:n.precision})}`:t;return new RegExp(`^${IN}T(?:${s})$`)}const mH=/^[\s\S]{0,}$/,pH=/^-?\d+$/,R1=/^-?\d+(?:\.\d+)?$/,hH=/^(?:true|false)$/i,gH=/^null$/i,xH=/^[^A-Z]*$/,bH=/^[^a-z]*$/,Vn=de("$ZodCheck",(n,e)=>{var t;n._zod??(n._zod={}),n._zod.def=e,(t=n._zod).onattach??(t.onattach=[])}),O1=n=>{const e=n.value;return!Yq(e)&&e.length!==void 0},Cu={number:"number",bigint:"bigint",object:"date"},$N=de("$ZodCheckLessThan",(n,e)=>{Vn.init(n,e);const t=Cu[typeof e.value];n._zod.check=s=>{(e.inclusive?s.value<=e.value:s.value<e.value)||s.issues.push({origin:Cu[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})}}),RN=de("$ZodCheckGreaterThan",(n,e)=>{Vn.init(n,e);const t=Cu[typeof e.value];n._zod.check=s=>{(e.inclusive?s.value>=e.value:s.value>e.value)||s.issues.push({origin:Cu[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})}}),vH=de("$ZodCheckMultipleOf",(n,e)=>{Vn.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):Xq(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})}}),yH=de("$ZodCheckNumberFormat",(n,e)=>{var i;Vn.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]=CN[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})}}),wH=de("$ZodCheckMaxLength",(n,e)=>{var t;Vn.init(n,e),(t=n._zod.def).when??(t.when=O1),n._zod.check=s=>{const r=s.value,o=r.length;if((typeof r=="string"&&o>e.maximum?T1(r):o)<=e.maximum)return;const l=E1(r);s.issues.push({origin:l,code:"too_big",maximum:e.maximum,inclusive:!0,input:r,inst:n,continue:!e.abort})}}),SH=de("$ZodCheckMinLength",(n,e)=>{var t;Vn.init(n,e),(t=n._zod.def).when??(t.when=O1),n._zod.check=s=>{const r=s.value,o=r.length;if((typeof r=="string"&&o>=e.minimum&&o<e.minimum*2?T1(r):o)>=e.minimum)return;const l=E1(r);s.issues.push({origin:l,code:"too_small",minimum:e.minimum,inclusive:!0,input:r,inst:n,continue:!e.abort})}}),kH=de("$ZodCheckLengthEquals",(n,e)=>{var t;Vn.init(n,e),(t=n._zod.def).when??(t.when=O1),n._zod.check=s=>{const r=s.value,o=r.length,i=typeof r=="string"&&o>=e.length&&o<=e.length*2?T1(r):o;if(i===e.length)return;const l=E1(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})}}),$d=de("$ZodCheckStringFormat",(n,e)=>{var t,s;Vn.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=()=>{})}),jH=de("$ZodCheckRegex",(n,e)=>{$d.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})}}),NH=de("$ZodCheckLowerCase",(n,e)=>{e.pattern??(e.pattern=xH),$d.init(n,e)}),CH=de("$ZodCheckUpperCase",(n,e)=>{e.pattern??(e.pattern=bH),$d.init(n,e)}),_H=de("$ZodCheckIncludes",(n,e)=>{Vn.init(n,e);const t=Ii(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})}}),TH=de("$ZodCheckStartsWith",(n,e)=>{Vn.init(n,e);const t=new RegExp(`^${Ii(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})}}),EH=de("$ZodCheckEndsWith",(n,e)=>{Vn.init(n,e);const t=new RegExp(`.*${Ii(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})}}),AH=de("$ZodCheckOverwrite",(n,e)=>{Vn.init(n,e),n._zod.check=t=>{t.value=e.tx(t.value)}});class PH{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 IH={major:4,minor:6,patch:5},_t=de("$ZodType",(n,e)=>{var o;var t;n??(n={}),n._zod.def=e,n._zod.bag=n._zod.bag||{},n._zod.version=IH;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=xr(c),m;for(const p of u){if(p._zod.def.when){if(dV(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 Eo;if(m||g instanceof Promise)m=(m??Promise.resolve()).then(async()=>{await g,c.issues.length!==h&&(Dv(c.issues,h,n),f||(f=xr(c,h)))});else{if(c.issues.length===h)continue;Dv(c.issues,h,n),f||(f=xr(c,h))}}return m?m.then(()=>c):c},l=(c,u,d)=>{if(xr(c))return c.aborted=!0,c;const f=i(u,r,d);if(f instanceof Promise){if(d.async===!1)throw new Eo;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 Eo;return d.then(f=>i(f,r,u))}return i(d,r,u)}}},{get"~standard"(){return TN(this,"~standard",MN(this))},set"~standard"(n){lo(this,"~standard",n)}}),ON=(n,e)=>n.issues.length?{issues:n.issues.map(t=>ao(t,e,nr()))}:{value:n.value};async function $H(n,e){const t={async:!0};return ON(await n._zod.run({value:e,issues:[]},t),t)}function MN(n){return{validate:e=>{const t={async:!1};try{const s=n._zod.run({value:e,issues:[]},t);if(!(s instanceof Promise))return ON(s,t)}catch{}return $H(n,e)},vendor:"zod",version:1}}const M1=de("$ZodString",(n,e)=>{_t.init(n,e),n._zod.pattern=e.pattern??mH,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}}),Tt=de("$ZodStringFormat",(n,e)=>{$d.init(n,e),M1.init(n,e)}),RH=de("$ZodGUID",(n,e)=>{e.pattern??(e.pattern=XV),Tt.init(n,e)}),OH=de("$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=Wv(s))}else e.pattern??(e.pattern=Wv());Tt.init(n,e)}),MH=de("$ZodEmail",(n,e)=>{e.pattern??(e.pattern=JV),Tt.init(n,e)}),LN=1,_u=2;function zN(n){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(n):(new URL(n),!0)}catch{return!1}}function LH(n,e){return!("normalize"in e)&&!("hostname"in e)&&!("protocol"in e)?zN(n)||_u:zH(n,e)}function zH(n,e){var t;if(!e.normalize&&((t=e.protocol)==null?void 0:t.source)===aH.source&&!/^https?:\/\//i.test(n))return LN;try{if(typeof URL<"u"){const s=URL;if(typeof s.parse=="function")return s.parse(n)??_u}return new URL(n)}catch{return _u}}const DH=/[\t\n\r]/g;function qv(n){return n.replace(DH,"")}function FH(n,e){return e.lastIndex=0,e.test(n.hostname)}function UH(n,e){return e.lastIndex=0,e.test(n.protocol.endsWith(":")?n.protocol.slice(0,-1):n.protocol)}const BH=de("$ZodURL",(n,e)=>{Tt.init(n,e),n._zod.check=t=>{try{const s=t.value.trim(),r=LH(s,e);if(r===LN){t.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:t.value,inst:n,continue:!e.abort});return}if(r===_u){t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:n,continue:!e.abort});return}if(r===!0){t.value=qv(s);return}e.hostname&&!FH(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&&!UH(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:qv(s);return}catch{t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:n,continue:!e.abort})}}}),WH=de("$ZodEmoji",(n,e)=>{e.pattern??(e.pattern=eH()),Tt.init(n,e)}),qH=de("$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?GV:ZV(e.length)),Tt.init(n,e)}),VH=de("$ZodCUID",(n,e)=>{e.pattern??(e.pattern=WV),Tt.init(n,e)}),HH=de("$ZodCUID2",(n,e)=>{e.pattern??(e.pattern=qV),Tt.init(n,e)}),KH=de("$ZodULID",(n,e)=>{e.pattern??(e.pattern=VV),Tt.init(n,e)}),GH=de("$ZodXID",(n,e)=>{e.pattern??(e.pattern=HV),Tt.init(n,e)}),ZH=de("$ZodKSUID",(n,e)=>{e.pattern??(e.pattern=KV),Tt.init(n,e)}),YH=de("$ZodISODateTime",(n,e)=>{e.pattern??(e.pattern=fH(e)),Tt.init(n,e)}),XH=de("$ZodISODate",(n,e)=>{e.pattern??(e.pattern=uH),Tt.init(n,e)}),JH=de("$ZodISOTime",(n,e)=>{e.pattern??(e.pattern=dH(e)),Tt.init(n,e)}),QH=de("$ZodISODuration",(n,e)=>{e.pattern??(e.pattern=YV),Tt.init(n,e)}),eK=de("$ZodIPv4",(n,e)=>{e.pattern??(e.pattern=tH),Tt.init(n,e)}),tK=/^[0-9a-fA-F:.]+$/;function DN(n){return tK.test(n)?zN(`http://[${n}]`):!1}const nK=de("$ZodIPv6",(n,e)=>{e.pattern??(e.pattern=nH),Tt.init(n,e),n._zod.check=t=>{DN(t.value)||t.issues.push({code:"invalid_format",format:"ipv6",input:t.value,inst:n,continue:!e.abort})}}),sK=de("$ZodCIDRv4",(n,e)=>{e.pattern??(e.pattern=sH),Tt.init(n,e)});function rK(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:DN(t)}const oK=de("$ZodCIDRv6",(n,e)=>{e.pattern??(e.pattern=rH),Tt.init(n,e),n._zod.check=t=>{rK(t.value)||t.issues.push({code:"invalid_format",format:"cidrv6",input:t.value,inst:n,continue:!e.abort})}});function FN(n){if(n==="")return!0;if(/\s/.test(n)||n.length%4!==0)return!1;try{return atob(n),!0}catch{return!1}}const UN=/^[0-9a-zA-Z+/]*={0,2}$/,iK=de("$ZodBase64",(n,e)=>{e.pattern??(e.pattern=UN),Tt.init(n,e),n._zod.check=t=>{FN(t.value)||t.issues.push({code:"invalid_format",format:"base64",input:t.value,inst:n,continue:!e.abort})}}),L1=/^[A-Za-z0-9_-]*$/;function aK(n){if(!L1.test(n))return!1;const e=n.replace(/[-_]/g,s=>s==="-"?"+":"/"),t=e.padEnd(Math.ceil(e.length/4)*4,"=");return FN(t)}const lK=de("$ZodBase64URL",(n,e)=>{e.pattern??(e.pattern=L1),Tt.init(n,e),n._zod.check=t=>{aK(t.value)||t.issues.push({code:"invalid_format",format:"base64url",input:t.value,inst:n,continue:!e.abort})}}),cK=de("$ZodE164",(n,e)=>{e.pattern??(e.pattern=lH),Tt.init(n,e)});function uK(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 dK=de("$ZodJWT",(n,e)=>{Tt.init(n,e),n._zod.check=t=>{uK(t.value,e.alg)||t.issues.push({code:"invalid_format",format:"jwt",input:t.value,inst:n,continue:!e.abort})}}),BN=de("$ZodNumber",(n,e)=>{_t.init(n,e),n._zod.pattern=R1,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}}),fK=de("$ZodNumberFormat",(n,e)=>{yH.init(n,e),BN.init(n,e)}),mK=de("$ZodBoolean",(n,e)=>{_t.init(n,e),n._zod.pattern=hH,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}}),pK=de("$ZodNull",(n,e)=>{_t.init(n,e),n._zod.pattern=gH,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}}),hK=de("$ZodUnknown",(n,e)=>{_t.init(n,e),n._zod.parse=t=>t}),gK=de("$ZodNever",(n,e)=>{_t.init(n,e),n._zod.parse=(t,s)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:n}),t)});function Vv(n,e,t){n.issues.length&&e.issues.push(...ui(t,n.issues)),e.value[t]=n.value}const xK=de("$ZodArray",(n,e)=>{_t.init(n,e);const t=Fs.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=>Vv(f,s,c)));else if(Vv(d,s,c),l&&d.issues.length!==0&&xr(d))break}return i.length?Promise.all(i).then(()=>s):s}});function Tu(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(...ui(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 bK=[];function WN(n){var i,l,c,u;const e=Object.keys(n.shape),t=Object.getOwnPropertySymbols(n.shape),s=t.length?t:bK,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=sV(n.shape);return{...n,allKeys:r,symbolKeys:s,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(o)}}function qN(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(xr(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=>Tu(x,t,h,e,f,m))):Tu(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 vK=de("$ZodObject",(n,e)=>{_t.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=Ad(()=>WN(e));mt(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)||Ir(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=sl,i=e.catchall;let l;const c=Fs.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(xr(u,g))break;g=u.issues.length}if(x==="__proto__")continue;const b=p[x],v=b._zod.optin,y=b._zod.optout,k=b._zod.run({value:f[x],issues:[]},d);k instanceof Promise?m.push(k.then(j=>Tu(j,u,x,f,v,y))):Tu(k,u,x,f,v,y)}return i?qN(m,f,u,d,r.value,n,h===!0):m.length?Promise.all(m).then(()=>u):u}}),yK=de("$ZodObjectJIT",(n,e)=>{vK.init(n,e);const t=n._zod.parse,s=Ad(()=>WN(e)),r=Fs.memoizer,o=p=>{var j,C;const h=s.value,g=h.symbolKeys,x=new PH(["payload","ctx"],{shape:p,inst:n,memo:r,syms:g}),b=_=>`shape[${_}]._zod.run({ value: input[${_}], issues: [] }, ctx)`,v=(_,S)=>`
|
|
125
|
+
let ${_}_ab = false;
|
|
126
|
+
for (let i = 0; i < ${_}.issues.length; i++) {
|
|
127
|
+
const iss = ${_}.issues[i];
|
|
128
|
+
iss.path = iss.path ? [${S}, ...iss.path] : [${S}];
|
|
129
|
+
payload.issues.push(iss);
|
|
130
|
+
if (iss.continue !== true) ${_}_ab = true;
|
|
131
|
+
}
|
|
132
|
+
if (${_}_ab && ctx && ctx.abortEarly) {
|
|
133
|
+
payload.value = newResult;
|
|
134
|
+
return payload;
|
|
135
|
+
}`;x.write("const input = payload.value;");const y=Object.create(null);let k=0;for(const _ of h.allKeys)y[_]=`key_${k++}`;x.write(r?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(const _ of h.allKeys){if(_==="__proto__")continue;const S=y[_],N=typeof _=="symbol"?`syms[${g.indexOf(_)}]`:Qq(_),T=`${N} in input`,E=p[_],A=(j=E==null?void 0:E._zod)==null?void 0:j.optin,P=A!==void 0,I=((C=E==null?void 0:E._zod)==null?void 0:C.optout)==="optional";if(x.write(`const ${S} = ${b(N)};`),P&&I){const O=A==="optional"?`${S}_present`:`${S}.value !== undefined || ${S}_present`;x.write(`
|
|
136
|
+
const ${S}_present = ${T};
|
|
137
|
+
if (!${S}.issues.length || ${S}_present) {
|
|
138
|
+
if (${S}.issues.length) {${v(S,N)}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (${O}) {
|
|
142
|
+
newResult[${N}] = ${S}.value;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
`)}else P?(x.write(`
|
|
147
|
+
if (${S}.issues.length) {${v(S,N)}
|
|
148
|
+
}
|
|
149
|
+
`),A==="defaulted"?x.write(`newResult[${N}] = ${S}.value;`):x.write(`
|
|
150
|
+
if (${S}.value !== undefined || ${T}) {
|
|
151
|
+
newResult[${N}] = ${S}.value;
|
|
152
|
+
}
|
|
153
|
+
`)):x.write(`
|
|
154
|
+
const ${S}_present = ${T};
|
|
155
|
+
if (${S}.issues.length) {${v(S,N)}
|
|
156
|
+
}
|
|
157
|
+
if (!${S}_present && !${S}.issues.length) {
|
|
158
|
+
payload.issues.push({
|
|
159
|
+
code: "invalid_type",
|
|
160
|
+
expected: "nonoptional",
|
|
161
|
+
input: undefined,
|
|
162
|
+
path: [${N}]
|
|
163
|
+
});
|
|
164
|
+
if (ctx && ctx.abortEarly) {
|
|
165
|
+
payload.value = newResult;
|
|
166
|
+
return payload;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (${S}_present) {
|
|
171
|
+
newResult[${N}] = ${S}.value;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
`)}return x.write("payload.value = newResult;"),x.write("return payload;"),x.compile()};let i;const l=sl,c=!Fs.jitless,d=c&&tV.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?qN([],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 Hv(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=>!xr(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=>ao(i,s,nr())))}),e)}const VN=de("$ZodUnion",(n,e)=>{_t.init(n,e),mt(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),mt(n,"optout",s=>s.def.options.some(r=>r._zod.optout==="optional")?"optional":void 0),mt(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)))}),mt(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=>C1(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=>Hv(l,s,n,r)):Hv(i,s,n,r)}});function wK(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 SK=de("$ZodDiscriminatedUnion",(n,e)=>{e.inclusive=!1,VN.init(n,e);const t=n._zod.parse;mt(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)||Ir(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=_1(r._zod.def);if(i&&!Object.prototype.hasOwnProperty.call(i,e.discriminator))throw new Error(`Invalid discriminated union option at index "${o}"`)});const s=Ad(()=>wK(e));n._zod.parse=(r,o)=>{const i=r.value;if(!sl(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)}}),kK=de("$ZodIntersection",(n,e)=>{_t.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])=>Kv(t,c,u)):Kv(t,o,i)}});function oh(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(Pi(n)&&Pi(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=oh(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=oh(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 Kv(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=oh(e.value,t.value);if(!c.valid){if(xr(n))return n;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return n.value=c.data,n}const jK=de("$ZodRecord",(n,e)=>{_t.init(n,e);const t=Fs.memoizer;t==null||t.attach(n),n._zod.parse=(s,r)=>{const o=s.value;if(!Pi(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=>ao(h,r,nr())),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(...ui(d,h.issues)),s.value[m]=h.value})):(p.issues.length&&s.issues.push(...ui(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"&&R1.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=>ao(h,r,nr())),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(...ui(u,h.issues)),s.value[m]=h.value})):(p.issues.length&&s.issues.push(...ui(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}}),NK=de("$ZodEnum",(n,e)=>{_t.init(n,e);const t=nh(e.entries),s=new Set(t);n._zod.values=s,mt(n,"pattern",r=>{const o=nh(r.def.entries).filter(i=>nV.has(typeof i));return new RegExp(o.length?`^(${o.map(i=>Ii(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}}),CK=de("$ZodLiteral",(n,e)=>{_t.init(n,e);const t=new Set(e.values);n._zod.values=t,mt(n,"pattern",s=>{const r=s.def.values;return new RegExp(r.length?`^(${r.map(o=>typeof o=="string"?Ii(o):o?Ii(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}}),_K=de("$ZodTransform",(n,e)=>{var t;_t.init(n,e),n._zod.optin="optional",(t=Fs.memoizer)==null||t.guard(n),n._zod.parse=(s,r)=>{if(r.direction==="backward")throw new AN(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 Eo;return s.value=o,s}});function Gv(n,e){return n.value=e.issues.length?void 0:e.value,n}const HN=de("$ZodOptional",(n,e)=>{_t.init(n,e),mt(n,"optin",t=>t.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),n._zod.optout="optional",mt(n,"values",t=>{const s=t.def.innerType._zod.values;return s?new Set([...s,void 0]):void 0}),mt(n,"pattern",t=>{const s=t.def.innerType._zod.pattern;return s?new RegExp(`^(${C1(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=>Gv(t,o)):Gv(t,r)}return e.innerType._zod.run(t,s)}}),TK=de("$ZodExactOptional",(n,e)=>{HN.init(n,e),mt(n,"values",t=>t.def.innerType._zod.values),mt(n,"pattern",t=>t.def.innerType._zod.pattern),n._zod.parse=(t,s)=>e.innerType._zod.run(t,s)}),EK=de("$ZodNullable",(n,e)=>{_t.init(n,e),mt(n,"optin",t=>t.def.innerType._zod.optin),mt(n,"optout",t=>t.def.innerType._zod.optout),mt(n,"pattern",t=>{const s=t.def.innerType._zod.pattern;return s?new RegExp(`^(${C1(s.source)}|null)$`):void 0}),mt(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)}),AK=de("$ZodDefault",(n,e)=>{_t.init(n,e),n._zod.optin="defaulted",mt(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=>Zv(o,e)):Zv(r,e)}});function Zv(n,e){return n.value===void 0&&(n.value=e.defaultValue),n}const PK=de("$ZodPrefault",(n,e)=>{_t.init(n,e),n._zod.optin="defaulted",mt(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))}),IK=de("$ZodNonOptional",(n,e)=>{_t.init(n,e),mt(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=>Yv(o,n)):Yv(r,n)}});function Yv(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 Xv(n,e,t,s){return e.issues.length?(n.value=t.catchValue({...e,value:n.value,error:{issues:e.issues.map(r=>ao(r,s,nr()))},input:n.value}),n):(n.value=e.value,e.memo&&(n.memo=!0),n)}const $K=de("$ZodCatch",(n,e)=>{_t.init(n,e),mt(n,"optin",t=>t.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),mt(n,"optout",t=>t.def.innerType._zod.optout),mt(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=>Xv(t,o,e,s)):Xv(t,r,e,s)}}),RK=de("$ZodPipe",(n,e)=>{_t.init(n,e),mt(n,"values",t=>t.def.in._zod.values),mt(n,"optin",t=>t.def.in._zod.optin),mt(n,"optout",t=>t.def.out._zod.optout),mt(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=>pc(i,e.in,s)):pc(o,e.in,s)}const r=e.in._zod.run(t,s);return r instanceof Promise?r.then(o=>pc(o,e.out,s)):pc(r,e.out,s)}});function pc(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 OK=de("$ZodReadonly",(n,e)=>{_t.init(n,e),mt(n,"propValues",t=>t.def.innerType._zod.propValues),mt(n,"values",t=>t.def.innerType._zod.values),mt(n,"optin",t=>{var s,r;return(r=(s=t.def.innerType)==null?void 0:s._zod)==null?void 0:r.optin}),mt(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(Jv):Jv(r)}});function Jv(n){return n.memo||(n.value=Object.freeze(n.value)),n}const MK=de("$ZodCustom",(n,e)=>{Vn.init(n,e),_t.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=>Qv(o,t,s,n));Qv(r,t,s,n)}});function Qv(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(rl(r))}}class LK extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}const ih="~memo",ey=[];function KN(n){return n!==null&&typeof n=="object"}function Wf(n){return n.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}const GN=new WeakMap,ga=0,Vc=1,$a=2;function Hc(n,e,t){const s=GN.get(n);if(s!==void 0)return s?$a:ga;if(e.has(n))return $a;e.add(n);let r=ga;const o=d=>{if(r!==$a&&(d!=null&&d._zod)){const f=Hc(d,e);f>r&&(r=f)}},i=(d,f)=>{var p;let m=ga;for(const h of Reflect.ownKeys(d)){const g=Object.getOwnPropertyDescriptor(d,h);if(!g.enumerable)continue;const x=g.get?Vc:(p=g.value)!=null&&p._zod?Hc(g.value,e):ga;x>m&&(m=x)}return m},l=d=>{d>r&&(r=d)},c=n._zod.def;switch(c.type){case"object":{const d=_1(c);l(d?i(d):Vc),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?Hc(d,e):Vc);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),zK(n,r)}function zK(n,e){return e!==Vc&&GN.set(n,e===$a),e}function DK(n,e){let t=n.buckets.get(e);return t||(t=new WeakMap,n.buckets.set(e,t)),t}let hc;const gc=[],FK={alloc(n,e,t){const s=hc;if(!s)return t;hc=void 0;const r={value:t,issues:null};return s.set(e.value,r),gc.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"&&BK(o,r.value))throw new LK;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=Hc(n,new Set);if(b===ga)return n._zod.parse=i,n._zod.run===l&&(n._zod.run=i),i(c,u);b===$a||s?t=!0:s=!0}const d=c.value;if(!KN(d))return i(c,u);let f=u[ih];f||(f={buckets:new WeakMap,backEdges:void 0},u[ih]=f);let m;r===u?m=o:(m=DK(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(...Wf(p.issues)):(c.memo=!0,f.backEdges??(f.backEdges=new WeakSet),f.backEdges.add(p.value)),c;hc=m;const h=gc.length,g=i(c,u);hc=void 0;const x=gc.length>h?gc.pop():void 0;return g instanceof Promise?g.then(b=>(x&&(x.issues=b.issues.length?Wf(b.issues):ey),b)):(x&&(x.issues=g.issues.length?Wf(g.issues):ey),g)};n._zod.parse=l,n._zod.run===i&&(n._zod.run=l)})}};function UK(){return FK}function BK(n,e){var s;const t=(s=n[ih])==null?void 0:s.backEdges;return t!==void 0&&KN(e)&&t.has(e)}const WK=()=>{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=mV(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 ${NN(o.values[0])}`:`Invalid option: expected one of ${Lv(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":""}: ${Lv(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 qK(){return{localeError:WK()}}var ty;class VK{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 HK(){return new VK}(ty=globalThis).__zod_globalRegistry??(ty.__zod_globalRegistry=HK());const xa=globalThis.__zod_globalRegistry;function ZN(n){return n.checks&&(n.checks=[...n.checks]),n}function KK(n,e){return new n(ZN({type:"string",...qe(e)}))}function GK(n,e){return new n({type:"string",format:"email",check:"string_format",abort:!1,...qe(e)})}function ZK(n,e){return new n({type:"string",format:"guid",check:"string_format",abort:!1,...qe(e)})}function YK(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,...qe(e)})}function XK(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...qe(e)})}function JK(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...qe(e)})}function QK(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...qe(e)})}function eG(n,e){return new n({type:"string",format:"url",check:"string_format",abort:!1,...qe(e)})}function tG(n,e){return new n({type:"string",format:"emoji",check:"string_format",abort:!1,...qe(e)})}function nG(n,e){return new n({type:"string",format:"nanoid",check:"string_format",abort:!1,...qe(e)})}function sG(n,e){return new n({type:"string",format:"cuid",check:"string_format",abort:!1,...qe(e)})}function rG(n,e){return new n({type:"string",format:"cuid2",check:"string_format",abort:!1,...qe(e)})}function oG(n,e){return new n({type:"string",format:"ulid",check:"string_format",abort:!1,...qe(e)})}function iG(n,e){return new n({type:"string",format:"xid",check:"string_format",abort:!1,...qe(e)})}function aG(n,e){return new n({type:"string",format:"ksuid",check:"string_format",abort:!1,...qe(e)})}function lG(n,e){return new n({type:"string",format:"ipv4",check:"string_format",abort:!1,...qe(e)})}function cG(n,e){return new n({type:"string",format:"ipv6",check:"string_format",abort:!1,...qe(e)})}function uG(n,e){return new n({type:"string",format:"cidrv4",check:"string_format",abort:!1,...qe(e)})}function dG(n,e){return new n({type:"string",format:"cidrv6",check:"string_format",abort:!1,...qe(e)})}function fG(n,e){return new n({type:"string",format:"base64",check:"string_format",abort:!1,...qe(e)})}function mG(n,e){return new n({type:"string",format:"base64url",check:"string_format",abort:!1,...qe(e)})}function pG(n,e){return new n({type:"string",format:"e164",check:"string_format",abort:!1,...qe(e)})}function hG(n,e){return new n({type:"string",format:"jwt",check:"string_format",abort:!1,...qe(e)})}function gG(n,e){return new n({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...qe(e)})}function xG(n,e){return new n({type:"string",format:"date",check:"string_format",...qe(e)})}function bG(n,e){return new n({type:"string",format:"time",check:"string_format",precision:null,...qe(e)})}function vG(n,e){return new n({type:"string",format:"duration",check:"string_format",...qe(e)})}function yG(n,e){return new n(ZN({type:"number",checks:[],...qe(e)}))}function wG(n,e){return new n({type:"number",check:"number_format",abort:!1,format:"safeint",...qe(e)})}function SG(n,e){return new n({type:"boolean",...qe(e)})}function kG(n,e){return new n({type:"null",...qe(e)})}function jG(n){return new n({type:"unknown"})}function NG(n,e){return new n({type:"never",...qe(e)})}function ny(n,e){return new $N({check:"less_than",...qe(e),value:n,inclusive:!1})}function qf(n,e){return new $N({check:"less_than",...qe(e),value:n,inclusive:!0})}function sy(n,e){return new RN({check:"greater_than",...qe(e),value:n,inclusive:!1})}function Vf(n,e){return new RN({check:"greater_than",...qe(e),value:n,inclusive:!0})}function ry(n,e){return new vH({check:"multiple_of",...qe(e),value:n})}function YN(n,e){return new wH({check:"max_length",...qe(e),maximum:n})}function Eu(n,e){return new SH({check:"min_length",...qe(e),minimum:n})}function XN(n,e){return new kH({check:"length_equals",...qe(e),length:n})}function CG(n,e){return new jH({check:"string_format",format:"regex",...qe(e),pattern:n})}function _G(n){return new NH({check:"string_format",format:"lowercase",...qe(n)})}function TG(n){return new CH({check:"string_format",format:"uppercase",...qe(n)})}function EG(n,e){return new _H({check:"string_format",format:"includes",...qe(e),includes:n})}function AG(n,e){return new TH({check:"string_format",format:"starts_with",...qe(e),prefix:n})}function PG(n,e){return new EH({check:"string_format",format:"ends_with",...qe(e),suffix:n})}function Gi(n){return new AH({check:"overwrite",tx:n})}function IG(n){return Gi(e=>e.normalize(n))}function $G(){return Gi(n=>n.trim())}function RG(){return Gi(n=>n.toLowerCase())}function OG(){return Gi(n=>n.toUpperCase())}function MG(){return Gi(n=>eV(n))}function LG(n,e,t){return new n({type:"array",element:e,...qe(t)})}function zG(n,e,t){const s=qe(t);return s.abort??(s.abort=!0),new n({type:"custom",check:"custom",fn:e,...s})}function DG(n,e,t){return new n({type:"custom",check:"custom",fn:e,...qe(t)})}function FG(n,e){const t=UG(s=>(s.addIssue=r=>{if(typeof r=="string")s.issues.push(rl(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(rl(o))}},n(s.value,s)),e);return t}function UG(n,e){const t=new Vn({check:"custom",...qe(e)});return t._zod.check=n,t}function Ra(n,...e){for(const t of e)for(const s of Reflect.ownKeys(t))Object.prototype.propertyIsEnumerable.call(t,s)&&Ir(n,s,t[s]);return n}function JN(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)??xa,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 co(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 nn(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),nn(p,e,m),e.seen.get(p).isParent=!0)}const c=e.metadataRegistry.get(n);return c&&Ra(i.schema,c),e.io==="input"&&An(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 oy(n){return n.replace(/~/g,"~0").replace(/\//g,"~1")}function QN(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??(y=>y);if(x)return{ref:b(x)};const v=d[1].defId??d[1].schema.id??`schema${n.counter++}`;return d[1].defId=v,{defId:v,ref:`${b("__shared")}#/${f}/${oy(v)}`}}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+oy(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 eC(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;eC(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 tC=new Set(["type","properties","required","additionalProperties"]),iy=["oneOf","anyOf"];function ay(n){const e=n.additionalProperties;return e===void 0||e===!1||typeof e!="object"||e===null?null:Object.keys(e).length?e:null}function ah(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(!tC.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])??ay(d);f!=null&&(c.some(m=>JSON.stringify(m)===JSON.stringify(f))||c.push(f))}const u=c.length===1?c[0]:ah(c)??{allOf:c};Ir(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=ay(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 BG(n){const e=n.allOf;if(!Array.isArray(e)||e.length<2)return;for(const r of tC)if(r in n)return;const t=e.filter(r=>iy.some(o=>Array.isArray(r[o])));let s=null;if(!t.length)s=ah(e);else{const r=t[0],o=iy.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=>ah([...i,c]));if(l.some(c=>!c))return;s={[o]:l}}s&&(delete n.allOf,Ra(n,s))}function nC(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),v=b.schema;if(v.$ref&&(n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0")?(p.allOf=p.allOf??[],p.allOf.push(v)):Ra(p,v),Ra(p,h),f._zod.parent===g)for(const k in p)k==="$ref"||k==="allOf"||k in h||delete p[k];if(v.$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 v in p)v==="$ref"||v==="allOf"||v in b.def&&JSON.stringify(p[v])===JSON.stringify(b.def[v])&&delete p[v]}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())eC(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)??[])BG(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)}Ra(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,Ir(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:Au(e,"input",n.processors),output:Au(e,"output",n.processors)}},enumerable:!1,writable:!1}),f}catch{throw new Error("Error converting schema to JSON.")}}function An(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 An(s.element,t);if(s.type==="set")return An(s.valueType,t);if(s.type==="lazy")return An(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 An(s.innerType,t);if(s.type==="intersection")return An(s.left,t)||An(s.right,t);if(s.type==="record"||s.type==="map")return An(s.keyType,t)||An(s.valueType,t);if(s.type==="pipe")return n._zod.traits.has("$ZodCodec")?!0:An(s.in,t)||An(s.out,t);if(s.type==="object"){for(const r in s.shape)if(An(s.shape[r],t))return!0;return!1}if(s.type==="union"){for(const r of s.options)if(An(r,t))return!0;return!1}if(s.type==="tuple"){for(const r of s.items)if(An(r,t))return!0;return!!(s.rest&&An(s.rest,t))}return!1}const WG=(n,e={})=>t=>{const s=JN({...t,processors:e});return nn(n,s),QN(s,n),nC(s,n)},Au=(n,e,t={})=>s=>{const{libraryOptions:r,target:o}=s??{},i=JN({...r??{},target:o,io:e,processors:t});return nn(n,i),QN(i,n),nC(i,n)},$i=(n,e,t)=>{(n[e]===void 0||t>n[e])&&(n[e]=t)},Ri=(n,e,t)=>{(n[e]===void 0||t<n[e])&&(n[e]=t)},ly=(n,e)=>{$i(n,"minimum",e),Ri(n,"maximum",e)},sC=(n,e)=>{n.multipleOf??(n.multipleOf=[]),n.multipleOf.includes(e)||n.multipleOf.push(e)},rC=(n,e)=>{n.patterns??(n.patterns=new Set),n.patterns.add(e)},oC=(n,e)=>{n.mime=n.mime?n.mime.filter(t=>e.includes(t)):[...e]},iC=(n,e)=>{n.format=e,e.includes("int")&&(n.isInt=!0)},cy=(n,e)=>$i(n,"minimum",e.minimum),uy=(n,e)=>Ri(n,"maximum",e.maximum),dy=n=>(e,t)=>{iC(e,t.format);const[s,r]=n[t.format];$i(e,"minimum",s),Ri(e,"maximum",r)},Hf={greater_than:(n,e)=>$i(n,e.inclusive?"minimum":"exclusiveMinimum",e.value),less_than:(n,e)=>Ri(n,e.inclusive?"maximum":"exclusiveMaximum",e.value),multiple_of:(n,e)=>sC(n,e.value),number_format:dy(CN),bigint_format:dy(rV),min_length:cy,max_length:uy,length_equals:(n,e)=>ly(n,e.length),min_size:cy,max_size:uy,size_equals:(n,e)=>ly(n,e.size),string_format:(n,e)=>{iC(n,e.format),e.pattern&&rC(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)=>oC(n,e.mime)};function Cs(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=Hf[i._zod.def.check])==null||o.call(Hf,e,i._zod.def);const r=n._zod.bag;r.minimum!==void 0&&$i(e,"minimum",r.minimum),r.exclusiveMinimum!==void 0&&$i(e,"exclusiveMinimum",r.exclusiveMinimum),r.maximum!==void 0&&Ri(e,"maximum",r.maximum),r.exclusiveMaximum!==void 0&&Ri(e,"exclusiveMaximum",r.exclusiveMaximum),r.multipleOf!==void 0&&sC(e,r.multipleOf),r.format!==void 0&&(e.format??(e.format=r.format),r.format.includes("int")&&(e.isInt=!0)),r.mime&&oC(e,r.mime);for(const i of r.patterns??[])rC(e,i);return e}const qG={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},VG=new Map([[UN,oH],[L1,iH]]),aC=n=>VG.get(n)??n,HG=(n,e,t,s)=>{const r=t;r.type="string";const{minimum:o,maximum:i,format:l,patterns:c,contentEncoding:u,laxFormat:d}=Cs(n);if(typeof o=="number"&&(r.minLength=o),typeof i=="number"&&(r.maxLength=i),l&&(r.format=qG[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(aC);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}))])}},KG=(n,e,t,s)=>{const r=t,{minimum:o,maximum:i,multipleOf:l,exclusiveMaximum:c,exclusiveMinimum:u,isInt:d}=Cs(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)):co(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}))])}},GG=(n,e,t,s)=>{t.type="boolean"},ZG=(n,e,t,s)=>{e.target==="openapi-3.0"?(t.type="string",t.nullable=!0,t.enum=[null]):t.type="null"},YG=(n,e,t,s)=>{t.not={}},XG=(n,e,t,s)=>{},JG=(n,e,t,s)=>{const r=n._zod.def,o=nh(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},QG=(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(co(n,e,t,s,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof i=="bigint"){if(co(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},eZ=(n,e,t,s)=>{co(n,e,t,s,"Custom types cannot be represented in JSON Schema")},tZ=(n,e,t,s)=>{co(n,e,t,s,"Transforms cannot be represented in JSON Schema")},nZ=(n,e,t,s)=>{const r=t,o=n._zod.def,{minimum:i,maximum:l}=Cs(n);typeof i=="number"&&(r.minItems=i),typeof l=="number"&&(r.maxItems=l),r.type="array",r.items=nn(o.element,e,{...s,path:[...s.path,"items"]})};function Pu(n){const e=n._zod.def;return e.type==="pipe"&&e.in._zod.traits.has("$ZodTransform")?Pu(e.out):e.type==="catch"?Pu(e.innerType):n._zod.optin}const sZ=(n,e,t,s)=>{var u;const r=t,o=n._zod.def,i=o.shape;if(Object.getOwnPropertySymbols(i).length&&co(n,e,r,s,"Symbol keys cannot be represented in JSON Schema"))return;r.type="object",r.properties={};for(const d in i)Ir(r.properties,d,nn(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"?Pu(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=nn(o.catchall,e,{...s,path:[...s.path,"additionalProperties"]})):e.io==="output"&&(r.additionalProperties=!1)},rZ=(n,e,t,s)=>{const r=n._zod.def,o=r.inclusive===!1,i=r.options.map((l,c)=>nn(l,e,{...s,path:[...s.path,o?"oneOf":"anyOf",c]}));o?t.oneOf=i:t.anyOf=i},oZ=(n,e,t,s)=>{const r=n._zod.def,o=nn(r.left,e,{...s,path:[...s.path,"allOf",0]}),i=nn(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 lh(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=lh(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(v=>lh(n,v,t));b.some((v,y)=>v!==x[y])&&(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")?R1:pH).source)),p}const ch=new WeakMap;function iZ(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 ch.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=lh(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 aZ=(n,e,t,s)=>{const r=t,o=n._zod.def;r.type="object";const i=o.keyType,l=Cs(i).patterns;if(o.mode==="loose"&&l&&l.size>0){const d=nn(o.valueType,e,{...s,path:[...s.path,"patternProperties","*"]});r.patternProperties={};for(const f of l)Ir(r.patternProperties,aC(f).source,d)}else{if(e.target==="draft-07"||e.target==="draft-2020-12"){r.propertyNames=nn(o.keyType,e,{...s,path:[...s.path,"propertyNames"]});let d=ch.get(e);d||(d=[],ch.set(e,d),e.deferred.push(()=>iZ(e))),d.push(n)}r.additionalProperties=nn(o.valueType,e,{...s,path:[...s.path,"additionalProperties"]})}const c=i._zod.values,u=e.io==="input"&&Pu(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))}},lZ=(n,e,t,s)=>{const r=n._zod.def,o=nn(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"}]},cZ=(n,e,t,s)=>{const r=n._zod.def;nn(r.innerType,e,s);const o=e.seen.get(n);o.ref=r.innerType},z1=Symbol();function lC(n,e,t,s,r){let o=!1;const i=JSON.stringify(n,(l,c)=>typeof c!="bigint"?c:(o=!0,null));return o?(co(e,t,s,r,"BigInt defaults cannot be represented in JSON Schema"),z1):JSON.parse(i)}const uZ=(n,e,t,s)=>{const r=n._zod.def;nn(r.innerType,e,s);const o=e.seen.get(n);o.ref=r.innerType;const i=lC(r.defaultValue,n,e,t,s);i!==z1&&(t.default=i)},dZ=(n,e,t,s)=>{const r=n._zod.def;nn(r.innerType,e,s);const o=e.seen.get(n);if(o.ref=r.innerType,e.io!=="input")return;const i=lC(r.defaultValue,n,e,t,s);i!==z1&&(t._prefault=i)},fZ=(n,e,t,s)=>{const r=n._zod.def;nn(r.innerType,e,s);const o=e.seen.get(n);o.ref=r.innerType;let i;try{i=r.catchValue(void 0)}catch{co(n,e,t,s,"Dynamic catch values are not supported in JSON Schema");return}t.default=i},mZ=(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;nn(i,e,s);const l=e.seen.get(n);l.ref=i},pZ=(n,e,t,s)=>{const r=n._zod.def;nn(r.innerType,e,s);const o=e.seen.get(n);o.ref=r.innerType,t.readOnly=!0},cC=(n,e,t,s)=>{const r=n._zod.def;nn(r.innerType,e,s);const o=e.seen.get(n);o.ref=r.innerType},fy=new WeakSet([Object.prototype,Error.prototype]);function xc(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 hZ=(n,e)=>{CV.init(n,e),n.name="ZodError";const t=Object.getPrototypeOf(n);fy.has(t)||(fy.add(t),xc(t,"format",s=>r=>EV(s,r)),xc(t,"flatten",s=>r=>TV(s,r)),xc(t,"addIssue",s=>r=>{s.issues.push(r),s.message=JSON.stringify(s.issues,sh,2)}),xc(t,"addIssues",s=>r=>{s.issues.push(...r),s.message=JSON.stringify(s.issues,sh,2)}),Object.defineProperty(t,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},ms=de("ZodError",hZ,void 0,{Parent:Error}),gZ=A1(ms),xZ=P1(ms),bZ=I1(ms),vZ=$1(ms),yZ=OV(ms),wZ=MV(ms),SZ=LV(ms),kZ=zV(ms),jZ=DV(ms),NZ=FV(ms),CZ=UV(ms),_Z=BV(ms);function TZ(){Fs.localeError||nr(qK())}function Rd(){Fs.memoizer||nr({memoizer:UK()})}const Et=de("ZodType",(n,e)=>(TZ(),_t.init(n,e),n.def=e,n.type=e.type,n),{check(...n){const e=this.def;return this.clone(Jn(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 xo(this,n,e)},brand(){return this},register(n,e){return n.add(this,e),this},refine(n,e){return this.check(kY(n,e))},superRefine(n,e){return this.check(jY(n,e))},overwrite(n){return this.check(Gi(n))},optional(){return hy(this)},exactOptional(){return dY(this)},nullable(){return gy(this)},nullish(){return hy(gy(this))},nonoptional(n){return xY(this,n)},array(){return ot(this)},or(n){return Io([this,n])},and(n){return aY(this,n)},transform(n){return xy(this,uY(n))},default(n){return pY(this,n)},prefault(n){return gY(this,n)},catch(n){return vY(this,n)},pipe(n){return xy(this,n)},readonly(){return SY(this)},describe(n){const e=this.clone();return xa.add(e,{description:n}),e},meta(...n){if(n.length===0)return xa.get(this);const e=this.clone();return xa.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 TN(this,"~standard",{...MN(this),jsonSchema:{input:Au(this,"input"),output:Au(this,"output")}})},set"~standard"(n){lo(this,"~standard",n)},parse:function n(e,t){return gZ(this,e,t,{callee:n})},parseAsync:async function n(e,t){return await xZ(this,e,t,{callee:n})},safeParse(n,e){return bZ(this,n,e)},async safeParseAsync(n,e){return vZ(this,n,e)},get spa(){return this==null?void 0:this.safeParseAsync},set spa(n){lo(this,"spa",n)},validate(n,e){return IV(this,n,e)},validateAsync(n,e){return RV(this,n,e)},encode:function n(e,t){return yZ(this,e,t,{callee:n})},decode:function n(e,t){return wZ(this,e,t,{callee:n})},encodeAsync:async function n(e,t){return await SZ(this,e,t,{callee:n})},decodeAsync:async function n(e,t){return await kZ(this,e,t,{callee:n})},safeEncode(n,e){return jZ(this,n,e)},safeDecode(n,e){return NZ(this,n,e)},async safeEncodeAsync(n,e){return CZ(this,n,e)},async safeDecodeAsync(n,e){return _Z(this,n,e)},toJSONSchema(n){return WG(this,{})(n)},get description(){var n;return(n=xa.get(this))==null?void 0:n.description},get _def(){return this._zod.def}}),uC=de("_ZodString",(n,e)=>{M1.init(n,e),Et.init(n,e),n._zod.processJSONSchema=(t,s,r)=>HG(n,t,s)},EN({format:n=>Cs(n).format??null,minLength:n=>Cs(n).minimum??null,maxLength:n=>Cs(n).maximum??null},{regex(...n){return this.check(CG(...n))},includes(...n){return this.check(EG(...n))},startsWith(...n){return this.check(AG(...n))},endsWith(...n){return this.check(PG(...n))},min(...n){return this.check(Eu(...n))},max(...n){return this.check(YN(...n))},length(...n){return this.check(XN(...n))},nonempty(...n){return this.check(Eu(1,...n))},lowercase(n){return this.check(_G(n))},uppercase(n){return this.check(TG(n))},trim(){return this.check($G())},normalize(...n){return this.check(IG(...n))},toLowerCase(){return this.check(RG())},toUpperCase(){return this.check(OG())},slugify(){return this.check(MG())}})),EZ=de("ZodString",(n,e)=>{M1.init(n,e),uC.init(n,e)},{email(n){return this.check(GK(RZ,n))},url(n){return this.check(eG(MZ,n))},jwt(n){return this.check(hG(XZ,n))},emoji(n){return this.check(tG(LZ,n))},guid(n){return this.check(ZK(OZ,n))},uuid(n){return this.check(YK(bc,n))},uuidv4(n){return this.check(XK(bc,n))},uuidv6(n){return this.check(JK(bc,n))},uuidv7(n){return this.check(QK(bc,n))},nanoid(n){return this.check(nG(zZ,n))},cuid(n){return this.check(sG(DZ,n))},cuid2(n){return this.check(rG(FZ,n))},ulid(n){return this.check(oG(UZ,n))},base64(n){return this.check(fG(GZ,n))},base64url(n){return this.check(mG(ZZ,n))},xid(n){return this.check(iG(BZ,n))},ksuid(n){return this.check(aG(WZ,n))},ipv4(n){return this.check(lG(qZ,n))},ipv6(n){return this.check(cG(VZ,n))},cidrv4(n){return this.check(uG(HZ,n))},cidrv6(n){return this.check(dG(KZ,n))},e164(n){return this.check(pG(YZ,n))},datetime(n){return this.check(gG(AZ,n))},date(n){return this.check(xG(PZ,n))},time(n){return this.check(bG(IZ,n))},duration(n){return this.check(vG($Z,n))}});function ze(n){return KK(EZ,n)}const $t=de("ZodStringFormat",(n,e)=>{Tt.init(n,e),uC.init(n,e)}),AZ=de("ZodISODateTime",(n,e)=>{YH.init(n,e),$t.init(n,e)}),PZ=de("ZodISODate",(n,e)=>{XH.init(n,e),$t.init(n,e)}),IZ=de("ZodISOTime",(n,e)=>{JH.init(n,e),$t.init(n,e)}),$Z=de("ZodISODuration",(n,e)=>{QH.init(n,e),$t.init(n,e)}),RZ=de("ZodEmail",(n,e)=>{MH.init(n,e),$t.init(n,e)}),OZ=de("ZodGUID",(n,e)=>{RH.init(n,e),$t.init(n,e)}),bc=de("ZodUUID",(n,e)=>{OH.init(n,e),$t.init(n,e)}),MZ=de("ZodURL",(n,e)=>{BH.init(n,e),$t.init(n,e)}),LZ=de("ZodEmoji",(n,e)=>{WH.init(n,e),$t.init(n,e)}),zZ=de("ZodNanoID",(n,e)=>{qH.init(n,e),$t.init(n,e)}),DZ=de("ZodCUID",(n,e)=>{VH.init(n,e),$t.init(n,e)}),FZ=de("ZodCUID2",(n,e)=>{HH.init(n,e),$t.init(n,e)}),UZ=de("ZodULID",(n,e)=>{KH.init(n,e),$t.init(n,e)}),BZ=de("ZodXID",(n,e)=>{GH.init(n,e),$t.init(n,e)}),WZ=de("ZodKSUID",(n,e)=>{ZH.init(n,e),$t.init(n,e)}),qZ=de("ZodIPv4",(n,e)=>{eK.init(n,e),$t.init(n,e)}),VZ=de("ZodIPv6",(n,e)=>{nK.init(n,e),$t.init(n,e)}),HZ=de("ZodCIDRv4",(n,e)=>{sK.init(n,e),$t.init(n,e)}),KZ=de("ZodCIDRv6",(n,e)=>{oK.init(n,e),$t.init(n,e)}),GZ=de("ZodBase64",(n,e)=>{iK.init(n,e),$t.init(n,e)}),ZZ=de("ZodBase64URL",(n,e)=>{lK.init(n,e),$t.init(n,e)}),YZ=de("ZodE164",(n,e)=>{cK.init(n,e),$t.init(n,e)}),XZ=de("ZodJWT",(n,e)=>{dK.init(n,e),$t.init(n,e)}),dC=de("ZodNumber",(n,e)=>{BN.init(n,e),Et.init(n,e),n._zod.processJSONSchema=(t,s,r)=>KG(n,t,s,r),n.isFinite=!0},EN({minValue:n=>{const{minimum:e,exclusiveMinimum:t}=Cs(n);return Math.max(e??Number.NEGATIVE_INFINITY,t??Number.NEGATIVE_INFINITY)},maxValue:n=>{const{maximum:e,exclusiveMaximum:t}=Cs(n);return Math.min(e??Number.POSITIVE_INFINITY,t??Number.POSITIVE_INFINITY)},isInt:n=>{const{isInt:e,multipleOf:t}=Cs(n);return!!e||!!(t!=null&&t.some(Number.isSafeInteger))},format:n=>Cs(n).format??null},{gt(n,e){return this.check(sy(n,e))},gte(n,e){return this.check(Vf(n,e))},min(n,e){return this.check(Vf(n,e))},lt(n,e){return this.check(ny(n,e))},lte(n,e){return this.check(qf(n,e))},max(n,e){return this.check(qf(n,e))},int(n){return this.check(my(n))},safe(n){return this.check(my(n))},positive(n){return this.check(sy(0,n))},nonnegative(n){return this.check(Vf(0,n))},negative(n){return this.check(ny(0,n))},nonpositive(n){return this.check(qf(0,n))},multipleOf(n,e){return this.check(ry(n,e))},step(n,e){return this.check(ry(n,e))},finite(){return this}}));function fn(n){return yG(dC,n)}const JZ=de("ZodNumberFormat",(n,e)=>{fK.init(n,e),dC.init(n,e)});function my(n){return wG(JZ,n)}const QZ=de("ZodBoolean",(n,e)=>{mK.init(n,e),Et.init(n,e),n._zod.processJSONSchema=(t,s,r)=>GG(n,t,s)});function mn(n){return SG(QZ,n)}const eY=de("ZodNull",(n,e)=>{pK.init(n,e),Et.init(n,e),n._zod.processJSONSchema=(t,s,r)=>ZG(n,t,s)});function fC(n){return kG(eY,n)}const tY=de("ZodUnknown",(n,e)=>{hK.init(n,e),Et.init(n,e),n._zod.processJSONSchema=(t,s,r)=>XG()});function Nr(){return jG(tY)}const nY=de("ZodNever",(n,e)=>{gK.init(n,e),Et.init(n,e),n._zod.processJSONSchema=(t,s,r)=>YG(n,t,s)});function mC(n){return NG(nY,n)}const sY=de("ZodArray",(n,e)=>{Rd(),xK.init(n,e),Et.init(n,e),n._zod.processJSONSchema=(t,s,r)=>nZ(n,t,s,r),n.element=e.element},{min(n,e){return this.check(Eu(n,e))},nonempty(n){return this.check(Eu(1,n))},max(n,e){return this.check(YN(n,e))},length(n,e){return this.check(XN(n,e))},unwrap(){return this.element}});function ot(n,e){return LG(sY,n,e)}const pC=de("ZodObject",(n,e)=>{Rd(),yK.init(n,e),Et.init(n,e),n._zod.processJSONSchema=(t,s,r)=>sZ(n,t,s,r),bV(n,"shape",t=>t._zod.def.shape,!1)},{keyof(){return Dt(Object.keys(this._zod.def.shape))},catchall(n){return this.clone(Jn(this._zod.def,{catchall:n}))},passthrough(){return this.clone(Jn(this._zod.def,{catchall:Nr()}))},loose(){return this.clone(Jn(this._zod.def,{catchall:Nr()}))},strict(){return this.clone(Jn(this._zod.def,{catchall:mC()}))},strip(){return this.clone(Jn(this._zod.def,{catchall:void 0}))},extend(n){return aV(this,n)},safeExtend(n){return lV(this,n)},merge(n){return cV(this,n)},pick(n){return oV(this,n)},omit(n){return iV(this,n)},partial(...n){return zv(gC,this,n[0])},exactPartial(...n){return zv(xC,this,n[0],"exactPartial")},required(...n){return uV(bC,this,n[0])}});function rY(n,e){const t={type:"object",shape:n??{},...qe(e)};return new pC(t)}function ve(n,e){return new pC({type:"object",shape:n,catchall:mC(),...qe(e)})}const hC=de("ZodUnion",(n,e)=>{VN.init(n,e),Et.init(n,e),n._zod.processJSONSchema=(t,s,r)=>rZ(n,t,s,r),n.options=e.options});function Io(n,e){return new hC({type:"union",options:n,...qe(e)})}const oY=de("ZodDiscriminatedUnion",(n,e)=>{hC.init(n,e),SK.init(n,e)});function $r(n,e,t){return new oY({type:"union",options:e,discriminator:n,...qe(t)})}const iY=de("ZodIntersection",(n,e)=>{kK.init(n,e),Et.init(n,e),n._zod.processJSONSchema=(t,s,r)=>oZ(n,t,s,r)});function aY(n,e){return new iY({type:"intersection",left:n,right:e})}const py=de("ZodRecord",(n,e)=>{Rd(),jK.init(n,e),Et.init(n,e),n._zod.processJSONSchema=(t,s,r)=>aZ(n,t,s,r),n.keyType=e.keyType,n.valueType=e.valueType});function us(n,e,t){return!e||!e._zod?new py({type:"record",keyType:ze(),valueType:n,...qe(e)}):new py({type:"record",keyType:n,valueType:e,...qe(t)})}const uh=de("ZodEnum",(n,e)=>{NK.init(n,e),Et.init(n,e),n._zod.processJSONSchema=(s,r,o)=>JG(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 uh({...e,checks:[],...qe(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 uh({...e,checks:[],...qe(r),entries:o})}});function Dt(n,e){const t=Array.isArray(n)?Object.fromEntries(n.map(s=>[s,s])):n;return new uh({type:"enum",entries:t,...qe(e)})}const lY=de("ZodLiteral",(n,e)=>{CK.init(n,e),Et.init(n,e),n._zod.processJSONSchema=(t,s,r)=>QG(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 Ke(n,e){return new lY({type:"literal",values:Array.isArray(n)?n:[n],...qe(e)})}const cY=de("ZodTransform",(n,e)=>{Rd(),_K.init(n,e),Et.init(n,e),n._zod.processJSONSchema=(t,s,r)=>tZ(n,t,s,r),n._zod.parse=(t,s)=>{if(s.direction==="backward")throw new AN(n.constructor.name);t.addIssue=o=>{if(typeof o=="string")t.issues.push(rl(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(rl(i))}};const r=e.transform(t.value,t);return r instanceof Promise?r.then(o=>(t.value=o,t)):(t.value=r,t)}});function uY(n){return new cY({type:"transform",transform:n})}const gC=de("ZodOptional",(n,e)=>{HN.init(n,e),Et.init(n,e),n._zod.processJSONSchema=(t,s,r)=>cC(n,t,s,r),n.unwrap=()=>n._zod.def.innerType});function hy(n){return new gC({type:"optional",innerType:n})}const xC=de("ZodExactOptional",(n,e)=>{TK.init(n,e),Et.init(n,e),n._zod.processJSONSchema=(t,s,r)=>cC(n,t,s,r),n.unwrap=()=>n._zod.def.innerType});function dY(n){return new xC({type:"optional",innerType:n})}const fY=de("ZodNullable",(n,e)=>{EK.init(n,e),Et.init(n,e),n._zod.processJSONSchema=(t,s,r)=>lZ(n,t,s,r),n.unwrap=()=>n._zod.def.innerType});function gy(n){return new fY({type:"nullable",innerType:n})}const mY=de("ZodDefault",(n,e)=>{AK.init(n,e),Et.init(n,e),n._zod.processJSONSchema=(t,s,r)=>uZ(n,t,s,r),n.unwrap=()=>n._zod.def.innerType,n.removeDefault=n.unwrap});function pY(n,e){return new mY({type:"default",innerType:n,get defaultValue(){return typeof e=="function"?e():jN(e)}})}const hY=de("ZodPrefault",(n,e)=>{PK.init(n,e),Et.init(n,e),n._zod.processJSONSchema=(t,s,r)=>dZ(n,t,s,r),n.unwrap=()=>n._zod.def.innerType});function gY(n,e){return new hY({type:"prefault",innerType:n,get defaultValue(){return typeof e=="function"?e():jN(e)}})}const bC=de("ZodNonOptional",(n,e)=>{IK.init(n,e),Et.init(n,e),n._zod.processJSONSchema=(t,s,r)=>cZ(n,t,s,r),n.unwrap=()=>n._zod.def.innerType});function xY(n,e){return new bC({type:"nonoptional",innerType:n,...qe(e)})}const bY=de("ZodCatch",(n,e)=>{$K.init(n,e),Et.init(n,e),n._zod.processJSONSchema=(t,s,r)=>fZ(n,t,s,r),n.unwrap=()=>n._zod.def.innerType,n.removeCatch=n.unwrap});function vY(n,e){return new bY({type:"catch",innerType:n,catchValue:typeof e=="function"?e:yV(e)})}const yY=de("ZodPipe",(n,e)=>{RK.init(n,e),Et.init(n,e),n._zod.processJSONSchema=(t,s,r)=>mZ(n,t,s,r),n.in=e.in,n.out=e.out});function xy(n,e){return new yY({type:"pipe",in:n,out:e})}const wY=de("ZodReadonly",(n,e)=>{OK.init(n,e),Et.init(n,e),n._zod.processJSONSchema=(t,s,r)=>pZ(n,t,s,r),n.unwrap=()=>n._zod.def.innerType});function SY(n){return new wY({type:"readonly",innerType:n})}const vC=de("ZodCustom",(n,e)=>{MK.init(n,e),Et.init(n,e),n._zod.processJSONSchema=(t,s,r)=>eZ(n,t,s,r)});function yC(n,e){return zG(vC,n??(()=>!0),e)}function kY(n,e={}){return DG(vC,n,e)}function jY(n,e){return FG(n,e)}class dh extends Error{constructor(t){super(t.map(s=>`${s.path}: ${s.message}`).join("; "));qt(this,"issues");this.issues=t,this.name="ContractValidationError"}}const Kt=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 Kc(n){return new TextEncoder().encode(n).byteLength}function D1(n,e={}){const t=e.maxBytes??Kt.messageBytes,s=e.maxDepth??Kt.depth,r=e.maxNodes??Kt.nodes;if(!Number.isSafeInteger(t)||t<1||!Number.isSafeInteger(s)||s<0||s>Kt.depth||!Number.isSafeInteger(r)||r<1||r>Kt.responseNodes+16)throw new dh([{path:"$",message:"Invalid JSON limits"}]);let o=t,i=r;const l=new Set,c=f=>{throw new dh([{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-=Kc(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(v=>typeof v=="symbol"))return c(p);const x=Object.getOwnPropertyDescriptors(f);for(const v of Object.values(x))if(v.get||v.set||!Object.hasOwn(v,"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},(v,y)=>{const k=x[String(y)];return k!=null&&k.enumerable?u(k.value,m+1,`${p}[${y}]`):c(`${p}[${y}]`)})}else{const v=Object.create(null);for(const[y,k]of Object.entries(x)){if(!k.enumerable||["__proto__","prototype","constructor"].includes(y)||(o-=Kc(y)+3)<0)return c(`${p}.${y}`);v[y]=u(k.value,m+1,`${p}.${y}`)}b=v}return l.delete(f),b}const d=u(n,0,"$");return Kc(JSON.stringify(d))>t?c("$"):d}var vc={exports:{}},Kf,by;function Rl(){if(by)return Kf;by=1;const n="2.0.0",e=256,t=Number.MAX_SAFE_INTEGER||9007199254740991,s=16,r=e-6;return Kf={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},Kf}var Gf,vy;function Od(){if(vy)return Gf;vy=1;var n={};return Gf=typeof process=="object"&&n&&n.NODE_DEBUG&&/\bsemver\b/i.test(n.NODE_DEBUG)?(...t)=>console.error("SEMVER",...t):()=>{},Gf}var yy;function Ol(){return yy||(yy=1,(function(n,e){const{MAX_SAFE_COMPONENT_LENGTH:t,MAX_SAFE_BUILD_LENGTH:s,MAX_LENGTH:r}=Rl(),o=Od();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,v]of p)x=x.split(`${b}*`).join(`${b}{0,${v}}`).split(`${b}+`).join(`${b}{1,${v}}`);return x},g=(x,b,v)=>{const y=h(b),k=f++;o(x,k,b),d[x]=k,c[k]=b,u[k]=y,i[k]=new RegExp(b,v?"g":void 0),l[k]=new RegExp(y,v?"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*$")})(vc,vc.exports)),vc.exports}var Zf,wy;function F1(){if(wy)return Zf;wy=1;const n=Object.freeze({loose:!0}),e=Object.freeze({});return Zf=s=>s?typeof s!="object"?n:s:e,Zf}var Yf,Sy;function wC(){if(Sy)return Yf;Sy=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 Yf={compareIdentifiers:e,rcompareIdentifiers:(s,r)=>e(r,s)},Yf}var Xf,ky;function En(){if(ky)return Xf;ky=1;const n=Od(),{MAX_LENGTH:e,MAX_SAFE_INTEGER:t}=Rl(),{safeRe:s,t:r}=Ol(),o=F1(),{compareIdentifiers:i}=wC(),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 Xf=c,Xf}var Jf,jy;function Uo(){if(jy)return Jf;jy=1;const n=En();return Jf=(t,s,r=!1)=>{if(t instanceof n)return t;try{return new n(t,s)}catch(o){if(!r)return null;throw o}},Jf}var Qf,Ny;function NY(){if(Ny)return Qf;Ny=1;const n=Uo();return Qf=(t,s)=>{const r=n(t,s);return r?r.version:null},Qf}var em,Cy;function CY(){if(Cy)return em;Cy=1;const n=Uo();return em=(t,s)=>{const r=n(t.trim().replace(/^[=v]+/,""),s);return r?r.version:null},em}var tm,_y;function _Y(){if(_y)return tm;_y=1;const n=En();return tm=(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}},tm}var nm,Ty;function TY(){if(Ty)return nm;Ty=1;const n=Uo();return nm=(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"},nm}var sm,Ey;function EY(){if(Ey)return sm;Ey=1;const n=En();return sm=(t,s)=>new n(t,s).major,sm}var rm,Ay;function AY(){if(Ay)return rm;Ay=1;const n=En();return rm=(t,s)=>new n(t,s).minor,rm}var om,Py;function PY(){if(Py)return om;Py=1;const n=En();return om=(t,s)=>new n(t,s).patch,om}var im,Iy;function IY(){if(Iy)return im;Iy=1;const n=Uo();return im=(t,s)=>{const r=n(t,s);return r&&r.prerelease.length?r.prerelease:null},im}var am,$y;function Ws(){if($y)return am;$y=1;const n=En();return am=(t,s,r)=>new n(t,r).compare(new n(s,r)),am}var lm,Ry;function $Y(){if(Ry)return lm;Ry=1;const n=Ws();return lm=(t,s,r)=>n(s,t,r),lm}var cm,Oy;function RY(){if(Oy)return cm;Oy=1;const n=Ws();return cm=(t,s)=>n(t,s,!0),cm}var um,My;function U1(){if(My)return um;My=1;const n=En();return um=(t,s,r)=>{const o=new n(t,r),i=new n(s,r);return o.compare(i)||o.compareBuild(i)},um}var dm,Ly;function OY(){if(Ly)return dm;Ly=1;const n=U1();return dm=(t,s)=>t.sort((r,o)=>n(r,o,s)),dm}var fm,zy;function MY(){if(zy)return fm;zy=1;const n=U1();return fm=(t,s)=>t.sort((r,o)=>n(o,r,s)),fm}var mm,Dy;function Md(){if(Dy)return mm;Dy=1;const n=Ws();return mm=(t,s,r)=>n(t,s,r)>0,mm}var pm,Fy;function B1(){if(Fy)return pm;Fy=1;const n=Ws();return pm=(t,s,r)=>n(t,s,r)<0,pm}var hm,Uy;function SC(){if(Uy)return hm;Uy=1;const n=Ws();return hm=(t,s,r)=>n(t,s,r)===0,hm}var gm,By;function kC(){if(By)return gm;By=1;const n=Ws();return gm=(t,s,r)=>n(t,s,r)!==0,gm}var xm,Wy;function W1(){if(Wy)return xm;Wy=1;const n=Ws();return xm=(t,s,r)=>n(t,s,r)>=0,xm}var bm,qy;function q1(){if(qy)return bm;qy=1;const n=Ws();return bm=(t,s,r)=>n(t,s,r)<=0,bm}var vm,Vy;function jC(){if(Vy)return vm;Vy=1;const n=SC(),e=kC(),t=Md(),s=W1(),r=B1(),o=q1();return vm=(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}`)}},vm}var ym,Hy;function LY(){if(Hy)return ym;Hy=1;const n=En(),e=Uo(),{safeRe:t,t:s}=Ol();return ym=(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)},ym}var wm,Ky;function zY(){if(Ky)return wm;Ky=1;const n=Uo(),e=Rl(),t=En(),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 wm=s,wm}var Sm,Gy;function DY(){if(Gy)return Sm;Gy=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 Sm=n,Sm}var km,Zy;function qs(){if(Zy)return km;Zy=1;const n=/\s+/g;class e{constructor(M,z){if(z=r(z),M instanceof e)return M.loose===!!z.loose&&M.includePrerelease===!!z.includePrerelease?M:new e(M.raw,z);if(M instanceof o)return this.raw=M.value,this.set=[[M]],this.formatted=void 0,this;if(this.options=z,this.loose=!!z.loose,this.includePrerelease=!!z.includePrerelease,this.raw=M.trim().replace(n," "),this.set=this.raw.split("||").map(F=>this.parseRange(F.trim())).filter(F=>F.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const F=this.set[0];if(this.set=this.set.filter(D=>!b(D[0])),this.set.length===0)this.set=[F];else if(this.set.length>1){for(const D of this.set)if(D.length===1&&v(D[0])){this.set=[D];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let M=0;M<this.set.length;M++){M>0&&(this.formatted+="||");const z=this.set[M];for(let F=0;F<z.length;F++)F>0&&(this.formatted+=" "),this.formatted+=z[F].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(M){M=M.replace(x,"");const F=((this.options.includePrerelease&&h)|(this.options.loose&&g))+":"+M,D=s.get(F);if(D)return D;const L=this.options.loose,B=L?c[d.HYPHENRANGELOOSE]:c[d.HYPHENRANGE];M=M.replace(B,O(this.options.includePrerelease)),i("hyphen replace",M),M=M.replace(c[d.COMPARATORTRIM],f),i("comparator trim",M),M=M.replace(c[d.TILDETRIM],m),i("tilde trim",M),M=M.replace(c[d.CARETTRIM],p),i("caret trim",M);let U=M.split(" ").map(G=>k(G,this.options)).join(" ").split(/\s+/).map(G=>I(G,this.options));L&&(U=U.filter(G=>(i("loose invalid filter",G,this.options),!!G.match(c[d.COMPARATORLOOSE])))),i("range list",U);const W=new Map,V=U.map(G=>new o(G,this.options));for(const G of V){if(b(G))return[G];W.set(G.value,G)}W.size>1&&W.has("")&&W.delete("");const H=[...W.values()];return s.set(F,H),H}intersects(M,z){if(!(M instanceof e))throw new TypeError("a Range is required");return this.set.some(F=>y(F,z)&&M.set.some(D=>y(D,z)&&F.every(L=>D.every(B=>L.intersects(B,z)))))}test(M){if(!M)return!1;if(typeof M=="string")try{M=new l(M,this.options)}catch{return!1}for(let z=0;z<this.set.length;z++)if(R(this.set[z],M,this.options))return!0;return!1}}km=e;const t=DY(),s=new t,r=F1(),o=Ld(),i=Od(),l=En(),{safeRe:c,src:u,t:d,comparatorTrimReplace:f,tildeTrimReplace:m,caretTrimReplace:p}=Ol(),{FLAG_INCLUDE_PRERELEASE:h,FLAG_LOOSE:g}=Rl(),x=new RegExp(u[d.BUILD],"g"),b=$=>$.value==="<0.0.0-0",v=$=>$.value==="",y=($,M)=>{let z=!0;const F=$.slice();let D=F.pop();for(;z&&F.length;)z=F.every(L=>D.intersects(L,M)),D=F.pop();return z},k=($,M)=>($=$.replace(c[d.BUILD],""),i("comp",$,M),$=N($,M),i("caret",$),$=_($,M),i("tildes",$),$=E($,M),i("xrange",$),$=P($,M),i("stars",$),$),j=$=>!$||$.toLowerCase()==="x"||$==="*",C=($,M,z)=>j($)&&!j(M)||j(M)&&z&&!j(z),_=($,M)=>$.trim().split(/\s+/).map(z=>S(z,M)).join(" "),S=($,M)=>{const z=M.loose?c[d.TILDELOOSE]:c[d.TILDE],F=M.includePrerelease?"-0":"";return $.replace(z,(D,L,B,U,W)=>{i("tilde",$,D,L,B,U,W);let V;return j(L)?V="":j(B)?V=`>=${L}.0.0${F} <${+L+1}.0.0-0`:j(U)?V=`>=${L}.${B}.0${F} <${L}.${+B+1}.0-0`:W?(i("replaceTilde pr",W),V=`>=${L}.${B}.${U}-${W} <${L}.${+B+1}.0-0`):V=`>=${L}.${B}.${U} <${L}.${+B+1}.0-0`,i("tilde return",V),V})},N=($,M)=>$.trim().split(/\s+/).map(z=>T(z,M)).join(" "),T=($,M)=>{i("caret",$,M);const z=M.loose?c[d.CARETLOOSE]:c[d.CARET],F=M.includePrerelease?"-0":"";return $.replace(z,(D,L,B,U,W)=>{i("caret",$,D,L,B,U,W);let V;return j(L)?V="":j(B)?V=`>=${L}.0.0${F} <${+L+1}.0.0-0`:j(U)?L==="0"?V=`>=${L}.${B}.0${F} <${L}.${+B+1}.0-0`:V=`>=${L}.${B}.0${F} <${+L+1}.0.0-0`:W?(i("replaceCaret pr",W),L==="0"?B==="0"?V=`>=${L}.${B}.${U}-${W} <${L}.${B}.${+U+1}-0`:V=`>=${L}.${B}.${U}-${W} <${L}.${+B+1}.0-0`:V=`>=${L}.${B}.${U}-${W} <${+L+1}.0.0-0`):(i("no pr"),L==="0"?B==="0"?V=`>=${L}.${B}.${U} <${L}.${B}.${+U+1}-0`:V=`>=${L}.${B}.${U} <${L}.${+B+1}.0-0`:V=`>=${L}.${B}.${U} <${+L+1}.0.0-0`),i("caret return",V),V})},E=($,M)=>(i("replaceXRanges",$,M),$.split(/\s+/).map(z=>A(z,M)).join(" ")),A=($,M)=>{$=$.trim();const z=M.loose?c[d.XRANGELOOSE]:c[d.XRANGE];return $.replace(z,(F,D,L,B,U,W)=>{if(i("xRange",$,F,D,L,B,U,W),C(L,B,U))return $;const V=j(L),H=V||j(B),G=H||j(U),Z=G;return D==="="&&Z&&(D=""),W=M.includePrerelease?"-0":"",V?D===">"||D==="<"?F="<0.0.0-0":F="*":D&&Z?(H&&(B=0),U=0,D===">"?(D=">=",H?(L=+L+1,B=0,U=0):(B=+B+1,U=0)):D==="<="&&(D="<",H?L=+L+1:B=+B+1),D==="<"&&(W="-0"),F=`${D+L}.${B}.${U}${W}`):H?F=`>=${L}.0.0${W} <${+L+1}.0.0-0`:G&&(F=`>=${L}.${B}.0${W} <${L}.${+B+1}.0-0`),i("xRange return",F),F})},P=($,M)=>(i("replaceStars",$,M),$.trim().replace(c[d.STAR],"")),I=($,M)=>(i("replaceGTE0",$,M),$.trim().replace(c[M.includePrerelease?d.GTE0PRE:d.GTE0],"")),O=$=>(M,z,F,D,L,B,U,W,V,H,G,Z)=>(j(F)?z="":j(D)?z=`>=${F}.0.0${$?"-0":""}`:j(L)?z=`>=${F}.${D}.0${$?"-0":""}`:B?z=`>=${z}`:z=`>=${z}${$?"-0":""}`,j(V)?W="":j(H)?W=`<${+V+1}.0.0-0`:j(G)?W=`<${V}.${+H+1}.0-0`:Z?W=`<=${V}.${H}.${G}-${Z}`:$?W=`<${V}.${H}.${+G+1}-0`:W=`<=${W}`,`${z} ${W}`.trim()),R=($,M,z)=>{for(let F=0;F<$.length;F++)if(!$[F].test(M))return!1;if(M.prerelease.length&&!z.includePrerelease){for(let F=0;F<$.length;F++)if(i($[F].semver),$[F].semver!==o.ANY&&$[F].semver.prerelease.length>0){const D=$[F].semver;if(D.major===M.major&&D.minor===M.minor&&D.patch===M.patch)return!0}return!1}return!0};return km}var jm,Yy;function Ld(){if(Yy)return jm;Yy=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(">")))}}jm=e;const t=F1(),{safeRe:s,t:r}=Ol(),o=jC(),i=Od(),l=En(),c=qs();return jm}var Nm,Xy;function zd(){if(Xy)return Nm;Xy=1;const n=qs();return Nm=(t,s,r)=>{try{s=new n(s,r)}catch{return!1}return s.test(t)},Nm}var Cm,Jy;function FY(){if(Jy)return Cm;Jy=1;const n=qs();return Cm=(t,s)=>new n(t,s).set.map(r=>r.map(o=>o.value).join(" ").trim().split(" ")),Cm}var _m,Qy;function UY(){if(Qy)return _m;Qy=1;const n=En(),e=qs();return _m=(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},_m}var Tm,e2;function BY(){if(e2)return Tm;e2=1;const n=En(),e=qs();return Tm=(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},Tm}var Em,t2;function WY(){if(t2)return Em;t2=1;const n=En(),e=qs(),t=Md();return Em=(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},Em}var Am,n2;function qY(){if(n2)return Am;n2=1;const n=qs();return Am=(t,s)=>{try{return new n(t,s).range||"*"}catch{return null}},Am}var Pm,s2;function V1(){if(s2)return Pm;s2=1;const n=En(),e=Ld(),{ANY:t}=e,s=qs(),r=zd(),o=Md(),i=B1(),l=q1(),c=W1();return Pm=(d,f,m,p)=>{d=new n(d,p),f=new s(f,p);let h,g,x,b,v;switch(m){case">":h=o,g=l,x=i,b=">",v=">=";break;case"<":h=i,g=c,x=o,b="<",v="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(r(d,f,p))return!1;for(let y=0;y<f.set.length;++y){const k=f.set[y];let j=null,C=null;if(k.forEach(_=>{_.semver===t&&(_=new e(">=0.0.0")),j=j||_,C=C||_,h(_.semver,j.semver,p)?j=_:x(_.semver,C.semver,p)&&(C=_)}),j.operator===b||j.operator===v||(!C.operator||C.operator===b)&&g(d,C.semver))return!1;if(C.operator===v&&x(d,C.semver))return!1}return!0},Pm}var Im,r2;function VY(){if(r2)return Im;r2=1;const n=V1();return Im=(t,s,r)=>n(t,s,">",r),Im}var $m,o2;function HY(){if(o2)return $m;o2=1;const n=V1();return $m=(t,s,r)=>n(t,s,"<",r),$m}var Rm,i2;function KY(){if(i2)return Rm;i2=1;const n=qs();return Rm=(t,s,r)=>(t=new n(t,r),s=new n(s,r),t.intersects(s,r)),Rm}var Om,a2;function GY(){if(a2)return Om;a2=1;const n=zd(),e=Ws();return Om=(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},Om}var Mm,l2;function ZY(){if(l2)return Mm;l2=1;const n=qs(),e=Ld(),{ANY:t}=e,s=zd(),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 N of m)if(!s(S,String(N),p))return!1;return!0}let v,y,k,j,C=x&&!p.includePrerelease&&x.semver.prerelease.length?x.semver:!1,_=g&&!p.includePrerelease&&g.semver.prerelease.length?g.semver:!1;C&&C.prerelease.length===1&&x.operator==="<"&&C.prerelease[0]===0&&(C=!1);for(const S of m){if(j=j||S.operator===">"||S.operator===">=",k=k||S.operator==="<"||S.operator==="<=",g){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=u(g,S,p),v===S&&v!==g)return!1}else if(g.operator===">="&&!S.test(g.semver))return!1}if(x){if(C&&S.semver.prerelease&&S.semver.prerelease.length&&S.semver.major===C.major&&S.semver.minor===C.minor&&S.semver.patch===C.patch&&(C=!1),S.operator==="<"||S.operator==="<="){if(y=d(x,S,p),y===S&&y!==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||_||C)},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 Mm=o,Mm}var Lm,c2;function YY(){if(c2)return Lm;c2=1;const n=Ol(),e=Rl(),t=En(),s=wC(),r=Uo(),o=NY(),i=CY(),l=_Y(),c=TY(),u=EY(),d=AY(),f=PY(),m=IY(),p=Ws(),h=$Y(),g=RY(),x=U1(),b=OY(),v=MY(),y=Md(),k=B1(),j=SC(),C=kC(),_=W1(),S=q1(),N=jC(),T=LY(),E=zY(),A=Ld(),P=qs(),I=zd(),O=FY(),R=UY(),$=BY(),M=WY(),z=qY(),F=V1(),D=VY(),L=HY(),B=KY(),U=GY(),W=ZY();return Lm={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:v,gt:y,lt:k,eq:j,neq:C,gte:_,lte:S,cmp:N,coerce:T,truncate:E,Comparator:A,Range:P,satisfies:I,toComparators:O,maxSatisfying:R,minSatisfying:$,minVersion:M,validRange:z,outside:F,gtr:D,ltr:L,intersects:B,simplifyRange:U,subset:W,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},Lm}var Pn=YY();const pt=ze().min(1).max(64).regex(/^[a-zA-Z][a-zA-Z0-9_.-]*$/u).refine(n=>!["constructor","prototype","__proto__"].includes(n),"Reserved identifier"),$o=ze().min(1).max(128).refine(n=>[...n].every(e=>e.charCodeAt(0)>=32&&e.charCodeAt(0)!==127),"Control characters are forbidden"),ol=n=>ze().refine(e=>Kc(e)<=n,"Text exceeds byte limit"),yc=ze().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 uo(n,e,t,s){const r=n.safeParse(D1(e,{maxBytes:t,maxNodes:s}));if(!r.success)throw new dh(r.error.issues.map(o=>({path:o.path.length?`$.${o.path.map(String).join(".")}`:"$",message:o.message})));return r.data}const XY=["actions","actionJobs","pulls","pullFiles","pullSessions","issues"],JY=["deployments","buildLogs"],QY=["workspace","deployments","version"],zm=n=>ot(Dt(n)).min(1).max(n.length).refine(e=>new Set(e).size===e.length,"Duplicate operation"),eX=$r("id",[ve({id:Ke("github"),operations:zm(XY)}),ve({id:Ke("vercel"),operations:zm(JY)}),ve({id:Ke("cloudflare"),operations:zm(QY)})]),Br=fn().int().positive().max(Number.MAX_SAFE_INTEGER),Yo={integration:Ke("github")},u2={integration:Ke("vercel")},Dm={integration:Ke("cloudflare")},d2=ze().regex(/^[A-Za-z0-9_-]+$/).max(64).optional(),Fm=ze().max(240).regex(/^(?:[^/\\]+\/)*wrangler\.(?:json|jsonc|toml)$/).refine(n=>n.split("/").every(e=>e!=="."&&e!==".."),"Invalid configuration path").optional(),tX=$r("operation",[ve({...Yo,operation:Ke("actions"),limit:Br.max(30).optional()}),ve({...Yo,operation:Ke("actionJobs"),runId:Br}),ve({...Yo,operation:Ke("pulls"),limit:Br.max(50).optional()}),ve({...Yo,operation:Ke("pullFiles"),number:Br}),ve({...Yo,operation:Ke("pullSessions")}),ve({...Yo,operation:Ke("issues"),limit:Br.max(50).optional()})]),nX=$r("operation",[ve({...u2,operation:Ke("deployments"),limit:Br.max(30).optional()}),ve({...u2,operation:Ke("buildLogs"),deploymentId:ze().regex(/^dpl_[A-Za-z0-9]+$/).max(128),limit:Br.max(500).optional()})]),sX=$r("operation",[ve({...Dm,operation:Ke("workspace"),config:Fm}),ve({...Dm,operation:Ke("deployments"),config:Fm,environment:d2,limit:Br.max(30).optional()}),ve({...Dm,operation:Ke("version"),config:Fm,environment:d2,versionId:ze().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/)})]),rX=$r("integration",[tX,nX,sX]),oX=$r("ok",[ve({ok:Ke(!0),data:yC(()=>!0)}),ve({ok:Ke(!1),error:ve({code:ze().min(1).max(64),message:ze().min(1).max(512)})})]),_s=1,iX="1.0.0",NC="browser-iife-v1",fh=ze().max(128).refine(n=>Pn.valid(n)===n,"Expected strict SemVer"),Gc=ze().min(1).max(256).refine(n=>Pn.validRange(n)!==null,"Expected a SemVer range"),f2=us(pt,Gc).refine(n=>Object.keys(n).length<=32,"Too many capabilities"),m2=ve({client:f2,host:f2}),Zc=n=>new Set(n).size===n.length,aX=ot(pt).max(32).refine(Zc,"Duplicate identifier"),p2=ze().min(1).max(64).regex(/^[a-z][a-z0-9-]*$/u),Um=ze().regex(/^(?:[1-9][0-9]{0,3}px|(?:[1-9][0-9]?|100)%)$/u),lX=ve({manifestVersion:Ke(1),id:ze().max(128).regex(/^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*$/u),publisher:p2,name:$o,version:fh,runtime:Ke(NC),entry:yc.refine(n=>n.endsWith(".js"),"Entry must be JavaScript"),style:yc.refine(n=>n.endsWith(".css"),"Style must be CSS").optional(),engines:ve({pluginApi:Gc,client:Gc,host:Gc}),protocol:Ke(_s).default(_s),requires:m2,optional:m2.default({client:{},host:{}}),browser:ot(Dt(["message-channel","blob-script","web-crypto"])).max(3).refine(Zc).default([]),contributes:ve({panels:ot(ve({id:p2,title:$o,icon:yc.refine(n=>/\.(png|jpe?g|webp)$/u.test(n),"Expected a raster icon"),order:fn().int().min(0).max(1e3).optional(),defaultSize:Um.optional(),minSize:Um.optional(),maxSize:Um.optional(),when:Dt(["always","project-selected"]).default("project-selected")})).min(1).max(8)}),permissions:ve({context:ot(Ke("project.identity")).max(1).default([]),composer:ot(Ke("append")).max(1).default([]),navigation:ot(Dt(["external","session"])).max(2).refine(Zc).default([]),connections:ot(ve({id:pt,definition:yc,operations:aX.min(1)})).max(8).default([]),integrations:ot(eX).max(2).default([]),storage:ve({scope:Dt(["project","plugin"]),quotaKiB:fn().int().min(1).max(1024)}).optional()}),stateVersion:fn().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]])Zc(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 CC(n){return uo(lX,n,Kt.manifestBytes)}const _C=ze().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"),Gr=ze().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"),TC=ze().min(1).max(1024).regex(/^[a-zA-Z0-9._~-]+$/u).refine(n=>n!=="."&&n!==".."),cX=$r("type",[ve({type:Ke("string"),required:mn().optional(),maxLength:fn().int().min(1).max(1024),enum:ot($o).min(1).max(32).optional()}),ve({type:Ke("integer"),required:mn().optional(),min:fn().int().min(Number.MIN_SAFE_INTEGER),max:fn().int().max(Number.MAX_SAFE_INTEGER)}),ve({type:Ke("boolean"),required:mn().optional()})]),uX=Io([ve({literal:TC}),ve({resource:pt}),ve({arg:pt})]),dX=Io([pt,ve({literal:Io([ze().max(1024),fn().int().min(Number.MIN_SAFE_INTEGER).max(Number.MAX_SAFE_INTEGER),mn()])}),ve({arg:pt}),ve({resource:pt}),ve({identity:pt})]),fX=ve({audience:Dt(["setup","panel"]),origin:_C,method:Ke("GET"),path:ot(uX).min(1).max(16),args:us(pt,cX).refine(n=>Object.keys(n).length<=16),query:us(ze().max(68).regex(/^[a-zA-Z][a-zA-Z0-9_.-]*(?:\[\])?$/u).refine(n=>!["constructor","prototype","__proto__"].includes(n.replace(/\[\]$/u,""))),dX).refine(n=>Object.keys(n).length<=16)}),h2=ve({operation:pt,items:Gr,nested:Gr.optional(),id:Gr,label:Gr}),mX=ve({label:$o,scope:Dt(["connection","project"]).optional(),dependsOn:ot(pt).max(7).refine(n=>new Set(n).size===n.length).optional(),options:Io([h2,ot(h2).min(1).max(4)]).optional(),input:ve({allowId:mn(),urls:ot(ve({origin:_C,pathMarker:TC})).min(1).max(8).optional(),validation:ve({operation:pt,argument:pt,id:Gr.optional(),label:Gr,parents:us(pt,Gr).refine(n=>Object.keys(n).length<=7).optional()})}).optional()}).refine(n=>!!n.options||!!n.input,"Expected listed or validated entered resources"),pX=ve({version:Ke(1),id:pt,label:$o,secret:ve({id:pt,label:$o}),auth:ve({header:ze().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:Dt(["raw","bearer"])}),validationOperation:pt,identity:us(pt,Gr).refine(n=>Object.keys(n).length<=8).optional(),resources:us(pt,mX).refine(n=>Object.keys(n).length<=8),operations:us(pt,fX).refine(n=>Object.keys(n).length>0&&Object.keys(n).length<=32)});function Iu(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 g2(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=>Iu(n.operations[r.operation])),...Iu(t.input?n.operations[t.input.validation.operation]:void 0)])]}const hX=pX.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)||Iu(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=g2(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=>!Iu(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],v=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)||(v==null?void 0:v.type)!=="string"||!v.required||b.path.filter(y=>"arg"in y&&y.arg===x.argument).length!==1)&&t(["resources",f,"input","validation"],"Validation must request the candidate as one required path argument"),(p.some(y=>!Object.hasOwn(x.parents??{},y))||Object.keys(x.parents??{}).some(y=>!p.includes(y)))&&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 g2(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 mh(n){return uo(hX,n,Kt.definitionBytes)}const EC={appVersion:ze().min(1).max(128),apiVersions:ot(fh).max(16),manifestVersions:ot(fn().int().min(1).max(1024)).max(16),protocolVersions:ot(fn().int().min(1).max(1024)).max(16),runtimes:ot(ze().min(1).max(64)).max(16),capabilities:us(pt,fh).refine(n=>Object.keys(n).length<=64)},gX=ve({...EC,browser:ot(ze().min(1).max(64)).max(16)}),xX=ve({...EC,platform:ze().min(1).max(32),registryRevision:fn().int().min(0).max(Number.MAX_SAFE_INTEGER)});function bX(n){return uo(gX,n,16*1024)}function vX(n){return uo(xX,n,16*1024)}function yX(n,e,t,s={}){var f;const r=[],o=[],i=(m,p)=>!!Pn.valid(m)&&!!Pn.validRange(p)&&Pn.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),Pn.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 Pn.Range(n.engines.pluginApi,{includePrerelease:s.allowPrerelease===!0});for(const m of e.apiVersions.filter(p=>Pn.valid(p)))for(const p of t.apiVersions.filter(h=>Pn.valid(h))){if(Pn.major(m)!==Pn.major(p))continue;const h=Pn.compare(m,p)<=0?m:p;i(h,n.engines.pluginApi)&&c.push(h);for(const g of u.set){const x=`${g.map(v=>v.value).join(" ")} >=${Pn.major(h)}.0.0 <=${h}`,b=(f=Pn.minVersion(x))==null?void 0:f.version;b&&i(b,n.engines.pluginApi)&&c.push(b)}}const d=c.sort(Pn.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 $u=yC(()=>!0),wX=ve({}),SX=ve({id:pt,name:$o}).nullable(),AC=ve({mode:Dt(["light","dark"]),tokens:us(ze().regex(/^--[a-z][a-z0-9-]{0,63}$/u),ol(256)).refine(n=>Object.keys(n).length<=64)}),PC=ve({project:SX,theme:AC,locale:ze().min(1).max(64),reducedMotion:mn(),visible:mn()});function x2(n){return uo(PC,n,Kt.responseBytes)}const IC=["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"],kX=ve({code:Dt(IC),message:ol(512)}),wc=ze().min(1).max(64).regex(/^[a-zA-Z0-9_-]+$/u),jX=ze().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"),Bm=pt,$C={"lifecycle.ready":wX,"connections.request":ve({handle:pt,operationId:pt,args:us(pt,Io([ze(),fn().finite(),mn()]))}),"connections.status":ve({handle:pt}),"integrations.request":rX,"storage.get":ve({key:Bm}),"storage.set":ve({key:Bm,value:$u}),"storage.delete":ve({key:Bm}),"composer.append":ve({text:ol(Kt.composerBytes)}),"navigation.openExternal":ve({url:jX}),"navigation.openSession":ve({handle:pt})},NX=ve({configured:mn(),readOnly:mn(),selected:us(pt,ve({id:ol(1024),label:ol(256)})).refine(n=>Object.keys(n).length<=8)}),CX=$r("event",[ve({protocol:Ke(_s),type:Ke("event"),event:Ke("context"),value:PC}),ve({protocol:Ke(_s),type:Ke("event"),event:Ke("theme"),value:AC}),ve({protocol:Ke(_s),type:Ke("event"),event:Ke("visibility"),value:mn()}),ve({protocol:Ke(_s),type:Ke("event"),event:Ke("dispose"),value:fC()})]),_X=Io([ve({protocol:Ke(_s),type:Ke("request"),id:wc,method:Dt(Object.keys($C)),params:$u}),ve({protocol:Ke(_s),type:Ke("result"),id:wc,value:$u}),ve({protocol:Ke(_s),type:Ke("error"),id:wc,error:kX}),ve({protocol:Ke(_s),type:Ke("cancel"),id:wc}),CX]);function b2(n){var s;const e=n!==null&&typeof n=="object"&&((s=Object.getOwnPropertyDescriptor(n,"type"))==null?void 0:s.value)==="result",t=uo(_X,n,e?Kt.resultMessageBytes:Kt.messageBytes,e?Kt.responseNodes+16:Kt.nodes);if(t.type==="request"){const r=t.method==="composer.append"?Kt.composerBytes+64:t.method==="storage.set"?Kt.storageValueBytes:Kt.argumentBytes,o=uo($C[t.method],t.params,r);return{...t,params:o}}return t.type==="result"?{...t,value:D1(t.value,{maxBytes:Kt.responseBytes,maxNodes:Kt.responseNodes})}:t}function RC(n,e){const t=n==="integrations.request"?oX:n==="connections.status"?NX:n==="connections.request"||n==="storage.get"?$u:fC();return uo(t,e,Kt.responseBytes,Kt.responseNodes)}const Ml=fn().int().min(0).max(Number.MAX_SAFE_INTEGER),Dd=ze().regex(/^[a-f0-9]{64}$/),il=Nr().transform(CC),OC=$r("type",[ve({type:Ke("all")}),ve({type:Ke("projects"),projectIds:ot(ze().min(1).max(512)).max(128).refine(n=>new Set(n).size===n.length)})]),TX=ve({digest:Dd,manifest:il,targetPath:ze().min(1).max(512),installedAt:Ml,unavailableReason:ze().max(1e3).optional()}),EX=ve({id:ze().regex(/^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*$/).max(128),selectedDigest:Dd,manifest:il,enabled:mn(),scope:OC,pinned:mn(),versions:ot(TX).min(1).max(64),lastError:ze().max(1e3).optional()}),AX=ve({id:ze().max(128),label:ze().max(128),kind:Dt(["official","development"]),fingerprint:ze().max(128),verifiedAt:Ml.optional()}),MC=ve({available:mn(),error:ze().max(2e3).optional(),revision:Ml,plugins:ot(EX).max(256),publishers:ot(AX).max(256),legacyPluginIds:ot(Dt(["github","clickup","vercel-deployments"])).max(3).optional(),availableSeeds:ot(ve({manifest:il,digest:Dd})).max(256).optional(),recoveryCode:Dt(["STORE_LOCKED","STORE_VERSION","STORE_CORRUPT","STORE_UNAVAILABLE"]).optional()}),PX=ve({side:Dt(["client","host"]),name:ze().max(128),required:ze().max(256),actual:ze().max(512).nullable()}),IX=ve({compatible:mn(),apiVersion:ze().max(128).nullable(),issues:ot(ve({side:Dt(["client","host","package"]),code:Dt(["APP_VERSION","API_VERSION","MANIFEST_VERSION","PROTOCOL_VERSION","RUNTIME","CAPABILITY","BROWSER","PRERELEASE","REVOKED"]),name:ze().max(128),required:ze().max(256),actual:ze().max(512).nullable()})).max(128),unavailableOptional:ot(PX).max(128)});Nr().transform(bX);const Yc=ve({transactionId:ze().uuid(),manifest:il,digest:Dd,compatibility:IX,connectionDefinitions:ot(Nr().transform(mh)).max(8),oldVersion:ze().max(128).nullable(),registryRevision:Ml,publisherKind:Dt(["official","development"]),scope:OC,operation:Dt(["install","update","rollback"]).optional(),previousManifest:il.optional(),previousConnectionDefinitions:ot(Nr().transform(mh)).max(8).optional(),incompatibleClients:ot(ze().max(256)).max(256).optional()}),LC=ve({id:ze().regex(/^p_[a-f0-9]{40}$/),name:ze().max(512),paths:ot(ze().max(8192)).max(256)}),$X=ve({runtime:Nr().transform(vX),host:ve({name:ze().max(256),instanceId:ze().max(128)}),store:MC,projects:ot(LC).max(1024),safeMode:mn(),connectionRevision:Ml.optional()}),ph=ze().regex(/^[a-zA-Z][a-zA-Z0-9_.-]*$/).max(64),H1=fn().int().nonnegative().max(Number.MAX_SAFE_INTEGER),zC=ve({pluginId:ze().regex(/^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*$/).max(128),projectId:ze().regex(/^p_[a-f0-9]{40}$/).nullable()});zC.extend({expectedRevision:H1});const RX=zC.extend({connectionId:ph});RX.extend({expectedRevision:H1});const DC=ve({id:ze().min(1).max(1024),label:ze().min(1).max(256)}),OX=ot(DC).max(1e3),v2=ve({revision:H1,connections:ot(ve({id:ph,label:ze().min(1).max(128),status:Dt(["disconnected","connected","environment"]),readOnly:mn(),legacyImportAvailable:mn().optional(),selected:us(ph,DC).refine(n=>Object.keys(n).length<=8),definition:Nr().transform(mh)})).max(8)});function ba(n=globalThis){var u,d,f,m,p,h,g,x,b,v,y,k,j,C,_,S,N,T;const e=E=>typeof E=="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((v=(b=n.crypto)==null?void 0:b.subtle)==null?void 0:v.digest)&&e((y=n.crypto)==null?void 0:y.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((_=(C=n.AbortSignal)==null?void 0:C.prototype)==null?void 0:_.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((T=(N=n.ReadableStream)==null?void 0:N.prototype)==null?void 0:T.getReader)],["TextEncoder",e(n.TextEncoder)],["TextDecoder",e(n.TextDecoder)]].filter(([,E])=>!E).map(([E])=>E),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 MX=ve({sessionId:ze().regex(/^[a-f0-9]{64}$/),expiresAt:fn().int().positive()}),y2=ve({id:ze().min(1).max(128),expiresAt:fn().int().positive()}),LX=ve({deadline:fn().int().positive()}),zX=ve({status:Dt(["prepared","trial","committing","committed","cancelled","abandoned"]),preview:Yc,deadline:fn().int().positive().optional()}),hh={status:null,error:null,activation:""};function ai(){const n=ba();return{appVersion:oN,apiVersions:[iX],manifestVersions:[1],protocolVersions:[_s],runtimes:n.supported?[NC]:[],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 gh extends Error{constructor(e,t,s){super(e),this.code=t,this.status=s}}async function FC(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 Sc(n){const e=await FC(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=rY({error:ze().max(2e3),code:ze().max(128).optional()}).safeParse(t);throw new gh(s.success?s.data.error:"Plugin request failed",s.success?s.data.code??"HOST_ERROR":"HOST_ERROR",n.status)}return t}class DX{constructor(){qt(this,"scope",Fn());qt(this,"identity",$s());qt(this,"base",new URL(ig("/api/plugins/"),window.location.origin));qt(this,"lifetimeController");qt(this,"session",null);qt(this,"renewal",null);qt(this,"refreshPromise",null);qt(this,"timer");qt(this,"listeners",new Set);qt(this,"state",hh);qt(this,"running",!1);qt(this,"getSnapshot",()=>this.state);qt(this,"subscribe",e=>(this.listeners.add(e),()=>this.listeners.delete(e)));qt(this,"hostChanged",()=>{(this.scope!==Fn()||this.identity!==$s())&&this.stop()})}get controller(){const e=ba();if(!e.supported)throw new gh(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!==$s())throw new Error("The connected host or signed-in user changed")}start(){if(this.running)return;const e=ba();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(hh),e&&this.releaseSession(e.sessionId)}releaseSession(e){ba().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:ai()}),signal:AbortSignal.any([e,AbortSignal.timeout(2e4)])}),o=MX.parse(await Sc(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 Sc(i);return this.assertCurrent(o),l}refresh(){const e=ba();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=$X.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 gh&&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 Yc.parse(await this.json("stage-seed",{pluginId:e,scope:t,client:ai()}))}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=Yc.parse(await Sc(await this.request("stage",{method:"POST",body:e,headers:{"Content-Type":"application/octet-stream","X-Cogpit-Plugin-Client":JSON.stringify(ai()),"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 Sc(r);const o=await FC(r,4*1024*1024);return this.assertCurrent(s),t==null||t.throwIfAborted(),o}acceptStore(e){const t=MC.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 LX.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 zX.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 Yc.parse(await this.json(`installed/${encodeURIComponent(e)}/rollback`,{digest:t,scope:s,client:ai()}))}async lease(e,t,s,r,o){return y2.parse(await this.json("leases",{pluginId:e,projectId:t,contextEpoch:s,...o?{workspacePath:o}:{},client:ai()},"POST",r))}async renewLease(e,t){return y2.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=ve({value:Nr()}).parse(await this.json(`leases/${encodeURIComponent(e)}/call`,t,"POST",s));return RC(t.method,r.value)}async resolveSession(e,t,s){return ve({dirName:ze().min(1).max(8192),fileName:ze().min(1).max(8192)}).parse(await this.json(`leases/${encodeURIComponent(e)}/session`,{handle:t},"POST",s))}async resolveWorkspace(e,t){return LC.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 v2.parse(await this.json(`connections?${s}`,void 0,"GET",t))}async connectionOptions(e,t,s,r){return OX.parse(await this.json("connections/options",{...e,connectionId:t,resourceId:s},"POST",r))}async changeConnection(e,t,s,r,o,i){const l=v2.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 UC(n){const e=q.c(7),[t]=w.useState(UX),s=w.useSyncExternalStore(t.subscribe,t.getSnapshot,FX);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 FX(){return hh}function UX(){return new DX}function vr(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)?n:null}function tn(n,e=""){return typeof n=="string"?n:e}const BX=new Set(["open","custom","closed","done"]),WX=new Set(["urgent","high","normal","low"]);class qX extends Error{constructor(t,s,r){super(r);qt(this,"status");qt(this,"code");this.status=t,this.code=s}}function w2(n){return typeof n=="number"?String(n):tn(n)}function vo(n){const e=typeof n=="string"?Number(n):n;return typeof e=="number"&&Number.isFinite(e)&&e>0?e:null}function VX(n){const e=vr(n);return e&&e.hidden!==!0&&tn(e.name)||null}function HX(n){return new qX(502,"invalid_response",`ClickUp returned an invalid ${n} response`)}function KX(n){const e=vr(n);if(!e||typeof e.id!="number")return null;const t=tn(e.username)||tn(e.email);return{id:e.id,username:t,initials:tn(e.initials)||t.slice(0,2).toUpperCase(),color:tn(e.color)||null}}function GX(n){const e=vr(n);if(!e)return null;const t=tn(e.status);if(!t)return null;const s=tn(e.type);return{name:t,type:BX.has(s)?s:"custom",color:tn(e.color,"#d3d3d3"),order:typeof e.orderindex=="number"?e.orderindex:0}}function ZX(n){const e=vr(n),t=tn(e==null?void 0:e.name);return t?{name:t,background:tn(e==null?void 0:e.tag_bg)||null}:null}function YX(n){var t;const e=tn((t=vr(n))==null?void 0:t.priority);return WX.has(e)?e:null}function XX(n){var i;const e=vr(n);if(!e)return null;const t=tn(e.id),s=GX(e.status),r=vr(e.list);if(!t||!s||!r)return null;const o=tn(e.custom_id);return{id:t,customId:o||null,name:tn(e.name,"Untitled task"),description:tn(e.markdown_description)||tn(e.description),status:s,priority:YX(e.priority),url:tn(e.url)||`https://app.clickup.com/t/${t}`,assignees:Array.isArray(e.assignees)?e.assignees.map(KX).filter(l=>l!==null):[],tags:Array.isArray(e.tags)?e.tags.map(ZX).filter(l=>l!==null):[],parentId:tn(e.parent)||null,listId:w2(r.id),listName:tn(r.name,"List"),folderName:VX(e.folder),spaceId:w2((i=vr(e.space))==null?void 0:i.id),createdAt:vo(e.date_created)??0,updatedAt:vo(e.date_updated)??vo(e.date_created)??0,dueAt:vo(e.due_date),startAt:vo(e.start_date),closedAt:vo(e.date_closed)??vo(e.date_done)}}function JX(n){const e=vr(n);if(!e||!Array.isArray(e.tasks))throw HX("task list");return{tasks:e.tasks.map(XX).filter(t=>t!==null),lastPage:e.last_page!==!1}}const QX="absolute -right-1 -top-1 min-w-4 px-1 text-[9px]",eJ="absolute -right-0.5 -top-0.5 size-3 p-0 text-[8px]",tJ=new Set(["cogpit.github","cogpit.vercel","cogpit.clickup"]),nJ=new Set(["action_required","failure","startup_failure","timed_out"]),sJ=new Set(["BUILDING","INITIALIZING","QUEUED"]),rJ=new Set(["BLOCKED","CANCELED","ERROR"]);function Ru(n,e,t="default"){return n?{text:String(n),label:e,variant:t}:null}function oJ(n,e){var r;const t=n.filter(o=>o.status!=="completed").length;if(t)return Ru(t,`${t} active GitHub Actions run${t===1?"":"s"}`);if((r=n[0])!=null&&r.conclusion&&nJ.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 Ru(s,`${s} pull request${s===1?"":"s"} waiting for your review`,"secondary")}function iJ(n){const e=n.filter(t=>sJ.has(t.state)).length;return e?Ru(e,`${e} active Vercel deployment${e===1?"":"s"}`):n[0]&&rJ.has(n[0].state)?{text:"!",label:"Latest Vercel deployment failed",variant:"destructive",compact:!0}:null}function aJ(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 Ru(t,`${t} overdue ClickUp task${t===1?"":"s"}`,"destructive")}class S2 extends Error{}function lJ(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 S2("Integration unavailable");return f.data}if(n==="cogpit.vercel"){const d=await l({integration:"vercel",operation:"deployments",limit:20});return iJ(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 S2))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()),oJ(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=JX(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 aJ([...u.values()])}}function cJ({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||!tJ.has(e)||e!=="cogpit.clickup"&&(!t||!s))return;const f=new AbortController,m=lJ(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 v(){const j=x;x=null,j&&n.revokeLease(j).catch(()=>{})}async function y(){if(b||f.signal.aborted)return;if(document.visibilityState==="hidden"){g=setTimeout(()=>{y()},p);return}b=!0;const j=new AbortController,C=Date.now()+2e4;let _=setTimeout(()=>{j.abort(),v()},2e4);const S=AbortSignal.any([f.signal,j.signal]);try{const N=await n.lease(e,t,h,S,s);x=N.id,S.throwIfAborted();const T=Math.min(C,N.expiresAt)-Date.now();if(T<=0)throw new Error("Plugin lease expired");clearTimeout(_),_=setTimeout(()=>{j.abort(),v()},T);const E=await m(A=>(S.throwIfAborted(),n.call(N.id,A,S)),S);S.throwIfAborted(),u({client:n,identity:l,indicator:E})}catch{f.signal.aborted||u({client:n,identity:l,indicator:null})}finally{clearTimeout(_),v(),b=!1,f.signal.aborted||(g=setTimeout(()=>{y()},p))}}function k(){document.visibilityState==="visible"&&!b&&(clearTimeout(g),y())}return y(),document.addEventListener("visibilitychange",k),()=>{f.abort(),clearTimeout(g),document.removeEventListener("visibilitychange",k),v()}},[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(Fe,{variant:d.variant,className:d.compact?eJ:QX,"aria-label":d.label,children:d.text}):null}const Wr=0,Ce=1,et=2,Gt=3,kt=4,Qn=5,Ll=6,bn=7,In=8,rt=9,Je=10,Pt=11,st=12,Ct=13,zl=14,zn=15,_n=16,Tn=17,Hn=18,Kn=19,qn=20,lt=21,Ge=22,cn=23,On=24,ln=25,uJ=0;function yn(n){return n>=48&&n<=57}function fo(n){return yn(n)||n>=65&&n<=70||n>=97&&n<=102}function K1(n){return n>=65&&n<=90}function dJ(n){return n>=97&&n<=122}function fJ(n){return K1(n)||dJ(n)}function mJ(n){return n>=128}function Ou(n){return fJ(n)||mJ(n)||n===95}function BC(n){return Ou(n)||yn(n)||n===45}function pJ(n){return n>=0&&n<=8||n===11||n>=14&&n<=31||n===127}function Mu(n){return n===10||n===13||n===12}function Ro(n){return Mu(n)||n===32||n===9}function Ts(n,e){return!(n!==92||Mu(e)||e===uJ)}function Xc(n,e,t){return n===45?Ou(e)||e===45||Ts(e,t):Ou(n)?!0:n===92?Ts(n,e):!1}function Wm(n,e,t){return n===43||n===45?yn(e)?2:e===46&&yn(t)?3:0:n===46?yn(e)?2:0:yn(n)?1:0}function WC(n){return n===65279||n===65534?1:0}const xh=new Array(128),hJ=128,Jc=130,qC=131,G1=132,VC=133;for(let n=0;n<xh.length;n++)xh[n]=Ro(n)&&Jc||yn(n)&&qC||Ou(n)&&G1||pJ(n)&&VC||n||hJ;function qm(n){return n<128?xh[n]:G1}function bi(n,e){return e<n.length?n.charCodeAt(e):0}function bh(n,e,t){return t===13&&bi(n,e+1)===10?2:1}function vi(n,e,t){let s=n.charCodeAt(e);return K1(s)&&(s=s|32),s===t}function al(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(K1(i)&&(i=i|32),i!==o)return!1}return!0}function gJ(n,e){for(;e>=0&&Ro(n.charCodeAt(e));e--);return e+1}function kc(n,e){for(;e<n.length&&Ro(n.charCodeAt(e));e++);return e}function Vm(n,e){for(;e<n.length&&yn(n.charCodeAt(e));e++);return e}function Oo(n,e){if(e+=2,fo(bi(n,e-1))){for(const s=Math.min(n.length,e+5);e<s&&fo(bi(n,e));e++);const t=bi(n,e);Ro(t)&&(e+=bh(n,e,t))}return e}function jc(n,e){for(;e<n.length;e++){const t=n.charCodeAt(e);if(!BC(t)){if(Ts(t,bi(n,e+1))){e=Oo(n,e)-1;continue}break}}return e}function Fd(n,e){let t=n.charCodeAt(e);if((t===43||t===45)&&(t=n.charCodeAt(e+=1)),yn(t)&&(e=Vm(n,e+1),t=n.charCodeAt(e)),t===46&&yn(n.charCodeAt(e+1))&&(e+=2,e=Vm(n,e)),vi(n,e,101)){let s=0;t=n.charCodeAt(e+1),(t===45||t===43)&&(s=1,t=n.charCodeAt(e+2)),yn(t)&&(e=Vm(n,e+1+s+1))}return e}function Hm(n,e){for(;e<n.length;e++){const t=n.charCodeAt(e);if(t===41){e++;break}Ts(t,bi(n,e+1))&&(e=Oo(n,e))}return e}function Z1(n){if(n.length===1&&!fo(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 vh=["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"],xJ=16*1024;function Lu(n=null,e){return n===null||n.length<e?new Uint32Array(Math.max(e+1024,xJ)):n}const k2=10,bJ=12,j2=13;function N2(n){const e=n.source,t=e.length,s=e.length>0?WC(e.charCodeAt(0)):0,r=Lu(n.lines,t),o=Lu(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===k2||u===j2||u===bJ)&&(u===j2&&c+1<t&&e.charCodeAt(c+1)===k2&&(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 vJ{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||N2(this),{source:t,offset:this.startOffset+e,line:this.lines[e],column:this.columns[e]}}getLocationRange(e,t,s){return this.computed||N2(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 hs=16777215,gs=24,Dl=1,Ud=2,Zr=new Uint8Array(32);Zr[et]=Ge;Zr[lt]=Ge;Zr[Kn]=qn;Zr[cn]=On;const Es=new Uint8Array(32);Es[et]=Dl;Es[lt]=Dl;Es[Kn]=Dl;Es[cn]=Dl;Es[Ge]=Ud;Es[qn]=Ud;Es[On]=Ud;function C2(n,e,t){return n<e?e:n>t?t:n}class yJ{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=Lu(this.offsetAndType,e.length+1),o=Lu(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<<gs|m,l===-1&&(l=f),o[p]=u,d===c){const h=o[u];o[u]=p,u=h,c=Zr[r[h]>>gs]}else this.isBlockOpenerTokenType(d)&&(u=p,c=Zr[d])}),r[i]=Wr<<gs|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]>>gs:Wr}lookupTypeNonSC(e){for(let t=this.tokenIndex;t<this.tokenCount;t++){const s=this.offsetAndType[t]>>gs;if(s!==Ct&&s!==ln&&e--===0)return s}return Wr}lookupOffset(e){return e+=this.tokenIndex,e<this.tokenCount?this.offsetAndType[e-1]&hs:this.source.length}lookupOffsetNonSC(e){for(let t=this.tokenIndex;t<this.tokenCount;t++){const s=this.offsetAndType[t]>>gs;if(s!==Ct&&s!==ln&&e--===0)return t-this.tokenIndex}return Wr}lookupValue(e,t){return e+=this.tokenIndex,e<this.tokenCount?al(this.source,this.offsetAndType[e-1]&hs,this.offsetAndType[e]&hs,t):!1}getTokenStart(e){return e===this.tokenIndex?this.tokenStart:e>0?e<this.tokenCount?this.offsetAndType[e-1]&hs:this.offsetAndType[this.tokenCount]&hs:this.firstCharOffset}getTokenEnd(e){return e===this.tokenIndex?this.tokenEnd:this.offsetAndType[C2(e,0,this.tokenCount)]&hs}getTokenType(e){return e===this.tokenIndex?this.tokenType:this.offsetAndType[C2(e,0,this.tokenCount)]>>gs}substrToCursor(e){return this.source.substring(e,this.tokenStart)}isBlockOpenerTokenType(e){return Es[e]===Dl}isBlockCloserTokenType(e){return Es[e]===Ud}getBlockTokenPairIndex(e){const t=this.getTokenType(e);if(Es[t]===1){const s=this.balance[e],r=this.getTokenType(s);return Zr[t]===r?s:-1}else if(Es[t]===2){const s=this.balance[e],r=this.getTokenType(s);return Zr[r]===t?s:-1}return-1}isBalanceEdge(e){return this.balance[this.tokenIndex]<e}isDelim(e,t){return t?this.lookupType(t)===rt&&this.source.charCodeAt(this.lookupOffset(t))===e:this.tokenType===rt&&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]&hs,t=this.offsetAndType[t],this.tokenType=t>>gs,this.tokenEnd=t&hs):(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>>gs,this.tokenEnd=e&hs):(this.eof=!0,this.tokenIndex=this.tokenCount,this.tokenType=Wr,this.tokenStart=this.tokenEnd=this.source.length)}skipSC(){for(;this.tokenType===Ct||this.tokenType===ln;)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]&hs:this.firstCharOffset,t(this.source.charCodeAt(o))){case 1:break e;case 2:s++;break e;default:this.isBlockOpenerTokenType(this.offsetAndType[s]>>gs)&&(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&hs,l=o>>gs;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:vh[t],chunk:this.source.substring(s,r),balance:this.balance[o]}}),e}}function Bd(n,e){function t(f){return f<l?n.charCodeAt(f):0}function s(){if(u=Fd(n,u),Xc(t(u),t(u+1),t(u+2))){d=st,u=jc(n,u);return}if(t(u)===37){d=Pt,u++;return}d=Je}function r(){const f=u;if(u=jc(n,u),al(n,f,u,"url")&&t(u)===40){if(u=kc(n,u+1),t(u)===34||t(u)===39){d=et,u=f+4;return}i();return}if(t(u)===40){d=et,u++;return}d=Ce}function o(f){for(f||(f=t(u++)),d=Qn;u<n.length;u++){const m=n.charCodeAt(u);switch(qm(m)){case f:u++;return;case Jc:if(Mu(m)){u+=bh(n,u,m),d=Ll;return}break;case 92:if(u===n.length-1)break;const p=t(u+1);Mu(p)?u+=bh(n,u+1,p):Ts(m,p)&&(u=Oo(n,u)-1);break}}}function i(){for(d=bn,u=kc(n,u);u<n.length;u++){const f=n.charCodeAt(u);switch(qm(f)){case 41:u++;return;case Jc:if(u=kc(n,u),t(u)===41||u>=n.length){u<n.length&&u++;return}u=Hm(n,u),d=In;return;case 34:case 39:case 40:case VC:u=Hm(n,u),d=In;return;case 92:if(Ts(f,t(u+1))){u=Oo(n,u)-1;break}u=Hm(n,u),d=In;return}}}n=String(n||"");const l=n.length;let c=WC(t(0)),u=c,d;for(;u<l;){const f=n.charCodeAt(u);switch(qm(f)){case Jc:d=Ct,u=kc(n,u+1);break;case 34:o();break;case 35:BC(t(u+1))||Ts(t(u+1),t(u+2))?(d=kt,u=jc(n,u+1)):(d=rt,u++);break;case 39:o();break;case 40:d=lt,u++;break;case 41:d=Ge,u++;break;case 43:Wm(f,t(u+1),t(u+2))?s():(d=rt,u++);break;case 44:d=Hn,u++;break;case 45:Wm(f,t(u+1),t(u+2))?s():t(u+1)===45&&t(u+2)===62?(d=zn,u=u+3):Xc(f,t(u+1),t(u+2))?r():(d=rt,u++);break;case 46:Wm(f,t(u+1),t(u+2))?s():(d=rt,u++);break;case 47:t(u+1)===42?(d=ln,u=n.indexOf("*/",u+2),u=u===-1?n.length:u+2):(d=rt,u++);break;case 58:d=_n,u++;break;case 59:d=Tn,u++;break;case 60:t(u+1)===33&&t(u+2)===45&&t(u+3)===45?(d=zl,u=u+4):(d=rt,u++);break;case 64:Xc(t(u+1),t(u+2),t(u+3))?(d=Gt,u=jc(n,u+1)):(d=rt,u++);break;case 91:d=Kn,u++;break;case 92:Ts(f,t(u+1))?r():(d=rt,u++);break;case 93:d=qn,u++;break;case 123:d=cn,u++;break;case 125:d=On,u++;break;case qC:s();break;case G1:r();break;default:d=rt,u++}e(d,c,c=u)}}let Xo=null;class dn{static createItem(e){return{prev:null,next:null,data:e}}constructor(){this.head=null,this.tail=null,this.cursor=null}createItem(e){return dn.createItem(e)}allocateCursor(e,t){let s;return Xo!==null?(s=Xo,Xo=Xo.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=Xo,Xo=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=dn.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 dn;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 dn;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 dn;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(dn.createItem(e))}append(e){return this.insert(e)}appendData(e){return this.insert(dn.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(dn.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(dn.createItem(e))}pop(){return this.tail!==null?this.remove(this.tail):null}unshift(e){this.prepend(dn.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 Wd(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 Km=100,_2=60,T2=" ";function E2({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+=(T2.length-1)*(u[e-1].substr(0,t-1).match(/\t/g)||[]).length,t>Km&&(p=t-_2+3,t=_2-2);for(let h=d;h<=f;h++)h>=0&&h<u.length&&(u[h]=u[h].replace(/\t/g,T2),u[h]=(p>0&&u[h].length>p?"…":"")+u[h].substr(p,Km-2)+(u[h].length>p+Km-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 A2(n,e,t,s,r,o=1,i=1){return Object.assign(Wd("SyntaxError",n),{source:e,offset:t,line:s,column:r,sourceFragment(c){return E2({source:e,line:s,column:r,baseLine:o,baseColumn:i},isNaN(c)?0:c)},get formattedMessage(){return`Parse error: ${n}
|
|
181
|
+
`+E2({source:e,line:s,column:r,baseLine:o,baseColumn:i},2)}})}function wJ(n){const e=this.createList();let t=!1;const s={recognizer:n};for(;!this.eof;){switch(this.tokenType){case ln:this.next();continue;case Ct: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 Jo=()=>{},SJ=33,kJ=35,Gm=59,P2=123,I2=0,jJ={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}},NJ={createList(){return new dn},createSingleNodeList(n){return new dn().appendData(n)},getFirstListNode(n){return n&&n.first},getLastListNode(n){return n&&n.last}};function CJ(n){return function(){return this[n]()}}function Zm(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 _J(n){const e={context:Object.create(null),features:Object.assign(Object.create(null),n.features),scope:Object.assign(Object.create(null),n.scope),atrule:Zm(n.atrule),pseudo:Zm(n.pseudo),node:Zm(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]=CJ(s);break}return{config:e,...e,...e.node}}function TJ(n){let e="",t="<unknown>",s=!1,r=Jo,o=!1;const i=new vJ,l=Object.assign(new yJ,_J(n||{}),{parseAtrulePrelude:!0,parseRulePrelude:!0,parseValue:!0,parseCustomProperty:!1,readSequence:wJ,consumeUntilBalanceEnd:()=>0,consumeUntilLeftCurlyBracket(d){return d===P2?1:0},consumeUntilLeftCurlyBracketOrSemicolon(d){return d===P2||d===Gm?1:0},consumeUntilExclamationMarkOrSemicolon(d){return d===SJ||d===Gm?1:0},consumeUntilSemicolonIncluded(d){return d===Gm?2:0},createList:Jo,createSingleNodeList:Jo,getFirstListNode:Jo,getLastListNode:Jo,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!==Ct&&f!==ln)return f;while(f!==I2);return I2},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 vi(e,d,f)},cmpStr(d,f,m){return al(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(et),d},consumeNumber(d){const f=e.substring(this.tokenStart,Fd(e,this.tokenStart));return this.eat(d),f},eat(d){if(this.tokenType!==d){const f=vh[d].slice(0,-6).replace(/-/g," ").replace(/^./,h=>h.toUpperCase());let m=`${/[[\](){}]/.test(f)?`"${f}"`:f} is expected`,p=this.tokenStart;switch(d){case Ce:this.tokenType===et||this.tokenType===bn?(p=this.tokenEnd-1,m="Identifier is expected but function found"):m="Identifier is expected";break;case kt:this.isDelim(kJ)&&(this.next(),p++,m="Name is expected");break;case Pt:this.tokenType===Je&&(p=this.tokenEnd,m="Percent sign is expected");break}this.error(m,p)}this.next()},eatIdent(d){(this.tokenType!==Ce||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(gJ(e,e.length-1)):i.getLocation(this.tokenStart);throw new A2(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=>vh[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,Bd),i.setSource(e,f.offset,f.line,f.column),t=f.filename||"<unknown>",s=!!f.positions,r=typeof f.onParseError=="function"?f.onParseError:Jo,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?NJ:jJ),Array.isArray(g)?l.forEachToken((b,v,y)=>{g.push({type:b,start:v,end:y})}):typeof g=="function"&&l.forEachToken(g.bind(c())),typeof h=="function"&&l.forEachToken((b,v,y)=>{if(b===ln){const k=l.getLocation(v,y),j=al(e,y-2,y,"*/")?e.slice(v+2,y-2):e.slice(v+2,y);h(j,k)}});const x=l.context[m].call(l,f);return l.eof||l.error(),x},{SyntaxError:A2,config:l.config})}var Ym={},Nc={},Cc={},$2;function EJ(){if($2)return Cc;$2=1;var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");return Cc.encode=function(e){if(0<=e&&e<n.length)return n[e];throw new TypeError("Must be between 0 and 63: "+e)},Cc.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},Cc}var R2;function AJ(){if(R2)return Nc;R2=1;var n=EJ(),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 Nc.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},Nc.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},Nc}var Xm={},O2;function Y1(){return O2||(O2=1,(function(n){function e(S,N,T){if(N in S)return S[N];if(arguments.length===3)return T;throw new Error('"'+N+'" is a required argument.')}n.getArg=e;var t=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,s=/^data:.+\,.+$/;function r(S){var N=S.match(t);return N?{scheme:N[1],auth:N[2],host:N[3],port:N[4],path:N[5]}:null}n.urlParse=r;function o(S){var N="";return S.scheme&&(N+=S.scheme+":"),N+="//",S.auth&&(N+=S.auth+"@"),S.host&&(N+=S.host),S.port&&(N+=":"+S.port),S.path&&(N+=S.path),N}n.urlGenerate=o;var i=32;function l(S){var N=[];return function(T){for(var E=0;E<N.length;E++)if(N[E].input===T){var A=N[0];return N[0]=N[E],N[E]=A,N[0].result}var P=S(T);return N.unshift({input:T,result:P}),N.length>i&&N.pop(),P}}var c=l(function(N){var T=N,E=r(N);if(E){if(!E.path)return N;T=E.path}for(var A=n.isAbsolute(T),P=[],I=0,O=0;;)if(I=O,O=T.indexOf("/",I),O===-1){P.push(T.slice(I));break}else for(P.push(T.slice(I,O));O<T.length&&T[O]==="/";)O++;for(var R,$=0,O=P.length-1;O>=0;O--)R=P[O],R==="."?P.splice(O,1):R===".."?$++:$>0&&(R===""?(P.splice(O+1,$),$=0):(P.splice(O,2),$--));return T=P.join("/"),T===""&&(T=A?"/":"."),E?(E.path=T,o(E)):T});n.normalize=c;function u(S,N){S===""&&(S="."),N===""&&(N=".");var T=r(N),E=r(S);if(E&&(S=E.path||"/"),T&&!T.scheme)return E&&(T.scheme=E.scheme),o(T);if(T||N.match(s))return N;if(E&&!E.host&&!E.path)return E.host=N,o(E);var A=N.charAt(0)==="/"?N:c(S.replace(/\/+$/,"")+"/"+N);return E?(E.path=A,o(E)):A}n.join=u,n.isAbsolute=function(S){return S.charAt(0)==="/"||t.test(S)};function d(S,N){S===""&&(S="."),S=S.replace(/\/$/,"");for(var T=0;N.indexOf(S+"/")!==0;){var E=S.lastIndexOf("/");if(E<0||(S=S.slice(0,E),S.match(/^([^\/]+:\/)?\/*$/)))return N;++T}return Array(T+1).join("../")+N.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 N=S.length;if(N<9||S.charCodeAt(N-1)!==95||S.charCodeAt(N-2)!==95||S.charCodeAt(N-3)!==111||S.charCodeAt(N-4)!==116||S.charCodeAt(N-5)!==111||S.charCodeAt(N-6)!==114||S.charCodeAt(N-7)!==112||S.charCodeAt(N-8)!==95||S.charCodeAt(N-9)!==95)return!1;for(var T=N-10;T>=0;T--)if(S.charCodeAt(T)!==36)return!1;return!0}function x(S,N,T){var E=k(S.source,N.source);return E!==0||(E=S.originalLine-N.originalLine,E!==0)||(E=S.originalColumn-N.originalColumn,E!==0||T)||(E=S.generatedColumn-N.generatedColumn,E!==0)||(E=S.generatedLine-N.generatedLine,E!==0)?E:k(S.name,N.name)}n.compareByOriginalPositions=x;function b(S,N,T){var E;return E=S.originalLine-N.originalLine,E!==0||(E=S.originalColumn-N.originalColumn,E!==0||T)||(E=S.generatedColumn-N.generatedColumn,E!==0)||(E=S.generatedLine-N.generatedLine,E!==0)?E:k(S.name,N.name)}n.compareByOriginalPositionsNoSource=b;function v(S,N,T){var E=S.generatedLine-N.generatedLine;return E!==0||(E=S.generatedColumn-N.generatedColumn,E!==0||T)||(E=k(S.source,N.source),E!==0)||(E=S.originalLine-N.originalLine,E!==0)||(E=S.originalColumn-N.originalColumn,E!==0)?E:k(S.name,N.name)}n.compareByGeneratedPositionsDeflated=v;function y(S,N,T){var E=S.generatedColumn-N.generatedColumn;return E!==0||T||(E=k(S.source,N.source),E!==0)||(E=S.originalLine-N.originalLine,E!==0)||(E=S.originalColumn-N.originalColumn,E!==0)?E:k(S.name,N.name)}n.compareByGeneratedPositionsDeflatedNoLine=y;function k(S,N){return S===N?0:S===null?1:N===null?-1:S>N?1:-1}function j(S,N){var T=S.generatedLine-N.generatedLine;return T!==0||(T=S.generatedColumn-N.generatedColumn,T!==0)||(T=k(S.source,N.source),T!==0)||(T=S.originalLine-N.originalLine,T!==0)||(T=S.originalColumn-N.originalColumn,T!==0)?T:k(S.name,N.name)}n.compareByGeneratedPositionsInflated=j;function C(S){return JSON.parse(S.replace(/^\)]}'[^\n]*\n/,""))}n.parseSourceMapInput=C;function _(S,N,T){if(N=N||"",S&&(S[S.length-1]!=="/"&&N[0]!=="/"&&(S+="/"),N=S+N),T){var E=r(T);if(!E)throw new Error("sourceMapURL could not be parsed");if(E.path){var A=E.path.lastIndexOf("/");A>=0&&(E.path=E.path.substring(0,A+1))}N=u(o(E),N)}return c(N)}n.computeSourceURL=_})(Xm)),Xm}var Jm={},M2;function PJ(){if(M2)return Jm;M2=1;var n=Y1(),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()},Jm.ArraySet=s,Jm}var Qm={},L2;function IJ(){if(L2)return Qm;L2=1;var n=Y1();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},Qm.MappingList=t,Qm}var z2;function $J(){if(z2)return Ym;z2=1;var n=AJ(),e=Y1(),t=PJ().ArraySet,s=IJ().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(),v=0,y=b.length;v<y;v++){if(h=b[v],p="",h.generatedLine!==l)for(i=0;h.generatedLine!==l;)p+=";",l++;else if(v>0){if(!e.compareByGeneratedPositionsInflated(h,b[v-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())},Ym.SourceMapGenerator=r,Ym}var RJ=$J();const D2=new Set(["Atrule","Selector","Declaration"]);function OJ(n){const e=new RJ.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&&D2.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&&D2.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 MJ=43,LJ=45,ep=(n,e)=>(n===rt&&(n=e),typeof n=="string"&&(n=Math.min(n.charCodeAt(0),128)<<6),n<<1),HC=[[Ce,Ce],[Ce,et],[Ce,bn],[Ce,In],[Ce,"-"],[Ce,Je],[Ce,Pt],[Ce,st],[Ce,zn],[Ce,lt],[Gt,Ce],[Gt,et],[Gt,bn],[Gt,In],[Gt,"-"],[Gt,Je],[Gt,Pt],[Gt,st],[Gt,zn],[kt,Ce],[kt,et],[kt,bn],[kt,In],[kt,"-"],[kt,Je],[kt,Pt],[kt,st],[kt,zn],[st,Ce],[st,et],[st,bn],[st,In],[st,"-"],[st,Je],[st,Pt],[st,st],[st,zn],["#",Ce],["#",et],["#",bn],["#",In],["#","-"],["#",Je],["#",Pt],["#",st],["#",zn],["-",Ce],["-",et],["-",bn],["-",In],["-","-"],["-",Je],["-",Pt],["-",st],["-",zn],[Je,Ce],[Je,et],[Je,bn],[Je,In],[Je,Je],[Je,Pt],[Je,st],[Je,"%"],[Je,zn],["@",Ce],["@",et],["@",bn],["@",In],["@","-"],["@",zn],[".",Je],[".",Pt],[".",st],["+",Je],["+",Pt],["+",st],["/","*"]],zJ=HC.concat([[Ce,kt],[st,kt],[kt,kt],[Gt,lt],[Gt,Qn],[Gt,_n],[Pt,Pt],[Pt,st],[Pt,et],[Pt,"-"],[Ge,Ce],[Ge,et],[Ge,Pt],[Ge,st],[Ge,kt],[Ge,"-"]]);function KC(n){const e=new Set(n.map(([t,s])=>ep(t)<<16|ep(s)));return function(t,s,r){const o=ep(s,r),i=r.charCodeAt(0),l=i===LJ&&s!==Ce&&s!==et&&s!==zn||i===MJ?e.has((t&65534)<<16|i<<7):e.has((t&65534)<<16|o);return o|l}}const DJ=KC(HC),GC=KC(zJ),F2=Object.freeze(Object.defineProperty({__proto__:null,safe:GC,spec:DJ},Symbol.toStringTag,{value:"Module"})),FJ=92;function UJ(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 BJ(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:GC,token(c,u,d){o=this.tokenBefore(o,c,u),!d&&o&1&&this.emit(" ",Ct,!0),this.emit(u,c,!1),c===rt&&u.charCodeAt(0)===FJ&&this.emit(`
|
|
182
|
+
`,Ct,!0)},emit(c){r+=c},result(){return r}};s&&(typeof s.decorator=="function"&&(i=s.decorator(i)),s.sourceMap&&(i=OJ(i)),s.mode in F2&&(i.tokenBefore=F2[s.mode]));const l={node:c=>i.node(c),children:UJ,token:(c,u)=>i.token(c,u),tokenize:c=>Bd(c,(u,d,f)=>{i.token(u,c.slice(d,f),d!==0)})};return i.node(t),i.result()}}function WJ(n){return{fromPlainObject(e){return n(e,{enter(t){t.children&&!(t.children instanceof dn)&&(t.children=new dn().fromArray(t.children))}}),e},toPlainObject(e){return n(e,{leave(t){t.children&&t.children instanceof dn&&(t.children=t.children.toArray())}}),e}}}const{hasOwnProperty:X1}=Object.prototype,va=function(){};function U2(n){return typeof n=="function"?n:va}function B2(n,e){return function(t,s,r){t.type===e&&n.call(this,t,s,r)}}function qJ(n,e){const t=e.structure,s=[];for(const r in t){if(X1.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 VJ(n){const e={};for(const t in n.node)if(X1.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]=qJ(t,s)}return e}function W2(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 q2({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 HJ(n){const e=VJ(n),t={},s={},r=Symbol("break-walk"),o=Symbol("skip-node");for(const u in e)X1.call(e,u)&&e[u]!==null&&(t[u]=W2(e[u],!1),s[u]=W2(e[u],!0));const i=q2(t),l=q2(s),c=function(u,d){function f(b,v,y){const k=m.call(x,b,v,y);return k===r?!0:k===o?!1:!!(h.hasOwnProperty(b.type)&&h[b.type](b,x,f,g)||p.call(x,b,v,y)===r)}let m=va,p=va,h=t,g=(b,v,y,k)=>b||f(v,y,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=U2(d.enter),p=U2(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=B2(m,d.visit),p=B2(p,d.visit)}if(m===va&&p===va)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 KJ(n){return n}function GJ(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 ZJ(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 YJ(n,e,t,s){const r=n.combinator===" "||s?n.combinator:" "+n.combinator+" ",o=n.terms.map(i=>zu(i,e,t,s)).join(r);return n.explicit||t?(s||o[0]===","?"[":"[ ")+o+(s?"]":" ]"):o}function zu(n,e,t,s){let r;switch(n.type){case"Group":r=YJ(n,e,t,s)+(n.disallowEmpty?"!":"");break;case"Multiplier":return zu(n.term,e,t,s)+e(GJ(n),n);case"Boolean":r="<boolean-expr["+zu(n.term,e,t,s)+"]>";break;case"Type":r="<"+n.name+(n.opts?e(ZJ(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 J1(n,e){let t=KJ,s=!1,r=!1;return typeof e=="function"?t=e:e&&(s=!!e.forceBraces,r=!!e.compact,typeof e.decorate=="function"&&(t=e.decorate)),zu(n,t,s,r)}const V2={offset:0,line:1,column:1};function XJ(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=_c(o||e,"end")||ya(V2,u),f=ya(d)):(d=_c(o,"start")||ya(_c(e,"start")||V2,u.slice(0,i)),f=_c(o,"end")||ya(d,u.substr(i,l))),{css:u,mismatchOffset:i,mismatchLength:l,start:d,end:f}}function _c(n,e){const t=n&&n.loc&&n.loc[e];return t?"line"in t?ya(t):t:null}function ya({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 aa=function(n,e){const t=Wd("SyntaxReferenceError",n+(e?" `"+e+"`":""));return t.reference=e,t},JJ=function(n,e,t,s){const r=Wd("SyntaxMatchError",n),{css:o,mismatchOffset:i,mismatchLength:l,start:c,end:u}=XJ(s,t);return r.rawMessage=n,r.syntax=e?J1(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},Tc=new Map,Qo=new Map,Du=45,tp=QJ,H2=eQ;function Q1(n,e){return e=e||0,n.length-e>=2&&n.charCodeAt(e)===Du&&n.charCodeAt(e+1)===Du}function ZC(n,e){if(e=e||0,n.length-e>=3&&n.charCodeAt(e)===Du&&n.charCodeAt(e+1)!==Du){const t=n.indexOf("-",e+2);if(t!==-1)return n.substring(e,t+1)}return""}function QJ(n){if(Tc.has(n))return Tc.get(n);const e=n.toLowerCase();let t=Tc.get(e);if(t===void 0){const s=Q1(e,0),r=s?"":ZC(e,0);t=Object.freeze({basename:e.substr(r.length),name:e,prefix:r,vendor:r,custom:s})}return Tc.set(n,t),t}function eQ(n){if(Qo.has(n))return Qo.get(n);let e=n,t=n[0];t==="/"?t=n[1]==="/"?"//":"/":t!=="_"&&t!=="*"&&t!=="$"&&t!=="#"&&t!=="+"&&t!=="&"&&(t="");const s=Q1(e,t.length);if(!s&&(e=e.toLowerCase(),Qo.has(e))){const l=Qo.get(e);return Qo.set(n,l),l}const r=s?"":ZC(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 Qo.set(n,i),i}const ex=["initial","inherit","unset","revert","revert-layer"],ll=43,Ys=45,np=110,ei=!0,tQ=!1;function yh(n,e){return n!==null&&n.type===rt&&n.value.charCodeAt(0)===e}function Oa(n,e,t){for(;n!==null&&(n.type===Ct||n.type===ln);)n=t(++e);return e}function Fr(n,e,t,s){if(!n)return 0;const r=n.value.charCodeAt(e);if(r===ll||r===Ys){if(t)return 0;e++}for(;e<n.value.length;e++)if(!yn(n.value.charCodeAt(e)))return 0;return s+1}function sp(n,e,t){let s=!1,r=Oa(n,e,t);if(n=t(r),n===null)return e;if(n.type!==Je)if(yh(n,ll)||yh(n,Ys)){if(s=!0,r=Oa(t(++r),r,t),n=t(r),n===null||n.type!==Je)return 0}else return e;if(!s){const o=n.value.charCodeAt(0);if(o!==ll&&o!==Ys)return 0}return Fr(n,s?0:1,s,r)}function nQ(n,e){let t=0;if(!n)return 0;if(n.type===Je)return Fr(n,0,tQ,t);if(n.type===Ce&&n.value.charCodeAt(0)===Ys){if(!vi(n.value,1,np))return 0;switch(n.value.length){case 2:return sp(e(++t),t,e);case 3:return n.value.charCodeAt(2)!==Ys?0:(t=Oa(e(++t),t,e),n=e(t),Fr(n,0,ei,t));default:return n.value.charCodeAt(2)!==Ys?0:Fr(n,3,ei,t)}}else if(n.type===Ce||yh(n,ll)&&e(t+1).type===Ce){if(n.type!==Ce&&(n=e(++t)),n===null||!vi(n.value,0,np))return 0;switch(n.value.length){case 1:return sp(e(++t),t,e);case 2:return n.value.charCodeAt(1)!==Ys?0:(t=Oa(e(++t),t,e),n=e(t),Fr(n,0,ei,t));default:return n.value.charCodeAt(1)!==Ys?0:Fr(n,2,ei,t)}}else if(n.type===st){let s=n.value.charCodeAt(0),r=s===ll||s===Ys?1:0,o=r;for(;o<n.value.length&&yn(n.value.charCodeAt(o));o++);return o===r||!vi(n.value,o,np)?0:o+1===n.value.length?sp(e(++t),t,e):n.value.charCodeAt(o+1)!==Ys?0:o+2===n.value.length?(t=Oa(e(++t),t,e),n=e(t),Fr(n,0,ei,t)):Fr(n,o+2,ei,t)}return 0}const sQ=43,YC=45,XC=63,rQ=117;function wh(n,e){return n!==null&&n.type===rt&&n.value.charCodeAt(0)===e}function oQ(n,e){return n.value.charCodeAt(0)===e}function wa(n,e,t){let s=0;for(let r=e;r<n.value.length;r++){const o=n.value.charCodeAt(r);if(o===YC&&t&&s!==0)return wa(n,e+s+1,!1),6;if(!fo(o)||++s>6)return 0}return s}function Ec(n,e,t){if(!n)return 0;for(;wh(t(e),XC);){if(++n>6)return 0;e++}return e}function iQ(n,e){let t=0;if(n===null||n.type!==Ce||!vi(n.value,0,rQ)||(n=e(++t),n===null))return 0;if(wh(n,sQ))return n=e(++t),n===null?0:n.type===Ce?Ec(wa(n,0,!0),++t,e):wh(n,XC)?Ec(1,++t,e):0;if(n.type===Je){const s=wa(n,1,!0);return s===0?0:(n=e(++t),n===null?t:n.type===st||n.type===Je?!oQ(n,YC)||!wa(n,1,!1)?0:t+1:Ec(s,t,e))}return n.type===st?Ec(wa(n,1,!0),++t,e):0}const tx=["calc(","-moz-calc(","-webkit-calc("],nx=["min(","max(","clamp("],sx=["round(","mod(","rem("],aQ=["sin(","cos(","tan("],lQ=["asin(","acos(","atan(","atan2("],cQ=["pow(","sqrt(","log(","exp(","sign("],rx=["hypot("],ox=["abs("],K2=[...tx,...nx,...sx,...aQ,...cQ,...rx,...ox],uQ=[...tx,...nx,...sx,...rx,...ox],mr=[...tx,...nx,...sx,...lQ,...rx,...ox],ix=new Map([[et,Ge],[lt,Ge],[Kn,qn],[cn,On]]);function Ls(n,e){return e<n.length?n.charCodeAt(e):0}function JC(n,e){return al(n,0,n.length,e)}function QC(n,e){for(let t=0;t<e.length;t++)if(JC(n,e[t]))return!0;return!1}function e_(n,e){return e!==n.length-2?!1:Ls(n,e)===92&&yn(Ls(n,e+1))}function qd(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 dQ(n,e){let t=0,s=[],r=0;e:do{switch(n.type){case On:case Ge:case qn:if(n.type!==t)break e;if(t=s.pop(),s.length===0){r++;break e}break;case et:case lt:case Kn:case cn:s.push(t),t=ix.get(n.type);break}r++}while(n=e(r));return r}function ts(n,e){return function(t,s,r){return t===null?0:t.type===et&&QC(t.value,e)?dQ(t,s):n(t,s,r)}}function wt(n){return function(e){return e===null||e.type!==n?0:1}}function fQ(n){if(n===null||n.type!==Ce)return 0;const e=n.value.toLowerCase();return QC(e,ex)||JC(e,"default")?0:1}function t_(n){return n===null||n.type!==Ce||Ls(n.value,0)!==45||Ls(n.value,1)!==45?0:1}function mQ(n){return!t_(n)||n.value==="--"?0:1}function pQ(n){if(n===null||n.type!==kt)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(!fo(Ls(n.value,t)))return 0;return 1}function hQ(n){return n===null||n.type!==kt||!Xc(Ls(n.value,1),Ls(n.value,2),Ls(n.value,3))?0:1}function gQ(n,e){if(!n)return 0;let t=0,s=[],r=0;e:do{switch(n.type){case Ll:case In:break e;case On:case Ge:case qn:if(n.type!==t)break e;t=s.pop();break;case Tn:if(t===0)break e;break;case rt:if(t===0&&n.value==="!")break e;break;case et:case lt:case Kn:case cn:s.push(t),t=ix.get(n.type);break}r++}while(n=e(r));return r}function xQ(n,e){if(!n)return 0;let t=0,s=[],r=0;e:do{switch(n.type){case Ll:case In:break e;case On:case Ge:case qn:if(n.type!==t)break e;t=s.pop();break;case et:case lt:case Kn:case cn:s.push(t),t=ix.get(n.type);break}r++}while(n=e(r));return r}function pr(n){return n&&(n=new Set(n)),function(e,t,s){if(e===null||e.type!==st)return 0;const r=Fd(e.value,0);if(n!==null){const o=e.value.indexOf("\\",r),i=o===-1||!e_(e.value,o)?e.value.substr(r):e.value.substring(r,o);if(n.has(i.toLowerCase())===!1)return 0}return qd(s,e.value,r)?0:1}}function bQ(n,e,t){return n===null||n.type!==Pt||qd(t,n.value,n.value.length-1)?0:1}function n_(n){return typeof n!="function"&&(n=function(){return 0}),function(e,t,s){return e!==null&&e.type===Je&&Number(e.value)===0?1:n(e,t,s)}}function vQ(n,e,t){if(n===null)return 0;const s=Fd(n.value,0);return!(s===n.value.length)&&!e_(n.value,s)||qd(t,n.value,s)?0:1}function yQ(n,e,t){if(n===null||n.type!==Je)return 0;let s=Ls(n.value,0)===43||Ls(n.value,0)===45?1:0;for(;s<n.value.length;s++)if(!yn(Ls(n.value,s)))return 0;return qd(t,n.value,s)?0:1}const wQ={"ident-token":wt(Ce),"function-token":wt(et),"at-keyword-token":wt(Gt),"hash-token":wt(kt),"string-token":wt(Qn),"bad-string-token":wt(Ll),"url-token":wt(bn),"bad-url-token":wt(In),"delim-token":wt(rt),"number-token":wt(Je),"percentage-token":wt(Pt),"dimension-token":wt(st),"whitespace-token":wt(Ct),"CDO-token":wt(zl),"CDC-token":wt(zn),"colon-token":wt(_n),"semicolon-token":wt(Tn),"comma-token":wt(Hn),"[-token":wt(Kn),"]-token":wt(qn),"(-token":wt(lt),")-token":wt(Ge),"{-token":wt(cn),"}-token":wt(On)},SQ={string:wt(Qn),ident:wt(Ce),percentage:ts(bQ,uQ),zero:n_(),number:ts(vQ,K2),integer:ts(yQ,K2),"custom-ident":fQ,"dashed-ident":t_,"custom-property-name":mQ,"hex-color":pQ,"id-selector":hQ,"an-plus-b":nQ,urange:iQ,"declaration-value":gQ,"any-value":xQ},kQ=["length","angle","time","frequency","resolution","flex","decibel","semitones"];function jQ(n){const{angle:e,decibel:t,frequency:s,flex:r,length:o,resolution:i,semitones:l,time:c}=n||{};return{dimension:ts(pr(null),mr),angle:ts(pr(e),mr),decibel:ts(pr(t),mr),frequency:ts(pr(s),mr),flex:ts(pr(r),mr),length:ts(n_(pr(o)),mr),resolution:ts(pr(i),mr),semitones:ts(pr(l),mr),time:ts(pr(c),mr)}}function NQ(n){const e=new Set;for(const t of kQ)if(Array.isArray(n[t]))for(const s of n[t])e.add(s.toLowerCase());return function(s){return s===null?0:s.type===rt&&s.value==="%"||s.type===Ce&&e.has(s.value.toLowerCase())?1:0}}function CQ(n){return{...wQ,...SQ,...jQ(n),"attr-unit":NQ(n)}}const _Q=["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"],TQ=["deg","grad","rad","turn"],EQ=["s","ms"],AQ=["hz","khz"],PQ=["dpi","dpcm","dppx","x"],IQ=["fr"],$Q=["db"],RQ=["st"],G2=Object.freeze(Object.defineProperty({__proto__:null,angle:TQ,decibel:$Q,flex:IQ,frequency:AQ,length:_Q,resolution:PQ,semitones:RQ,time:EQ},Symbol.toStringTag,{value:"Module"}));function OQ(n,e,t){return Object.assign(Wd("SyntaxError",n),{input:e,offset:t,rawMessage:n,message:n+`
|
|
186
|
+
`+e+`
|
|
187
|
+
--`+new Array((t||e.length)+1).join("-")+"^"})}const MQ=9,LQ=10,zQ=12,DQ=13,FQ=32,Z2=new Uint8Array(128).map((n,e)=>/[a-zA-Z0-9\-]/.test(String.fromCharCode(e))?1:0);class UQ{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&&Z2[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!==DQ&&t!==LQ&&t!==zQ&&t!==FQ&&t!==MQ)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 OQ(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||Z2[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 BQ=9,WQ=10,qQ=12,VQ=13,HQ=32,s_=33,ax=35,Y2=38,Fu=39,r_=40,o_=41,i_=42,lx=43,cx=44,X2=45,ux=60,Sh=62,Uu=63,KQ=64,cl=91,Oi=93,Bu=123,J2=124,kh=125,Q2=8734,ew={" ":1,"&&":2,"||":3,"|":4};function tw(n){let e=null,t=null;return n.eat(Bu),n.skipWs(),e=n.scanNumber(n),n.skipWs(),n.charCode()===cx?(n.pos++,n.skipWs(),n.charCode()!==kh&&(t=n.scanNumber(n),n.skipWs())):t=e,n.eat(kh),{min:Number(e),max:t?Number(t):0}}function GQ(n){let e=null,t=!1;switch(n.charCode()){case i_:n.pos++,e={min:0,max:0};break;case lx:n.pos++,e={min:1,max:0};break;case Uu:n.pos++,e={min:0,max:1};break;case ax:n.pos++,t=!0,n.charCode()===Bu?e=tw(n):n.charCode()===Uu?(n.pos++,e={min:0,max:0}):e={min:1,max:0};break;case Bu:e=tw(n);break;default:return null}return{type:"Multiplier",comma:t,min:e.min,max:e.max,term:null}}function Cr(n,e){const t=GQ(n);return t!==null?(t.term=e,n.charCode()===ax&&n.charCodeAt(n.pos-1)===lx||n.charCode()===Uu&&n.charCodeAt(n.pos-1)===kh?Cr(n,t):t):e}function rp(n){const e=n.peek();return e===""?null:Cr(n,{type:"Token",value:e})}function ZQ(n){let e;return n.eat(ux),n.eat(Fu),e=n.scanWord(),n.eat(Fu),n.eat(Sh),Cr(n,{type:"Property",name:e})}function YQ(n){let e=null,t=null,s=1;return n.eat(cl),n.charCode()===X2&&(n.peek(),s=-1),s==-1&&n.charCode()===Q2?n.peek():(e=s*Number(n.scanNumber(n)),n.isNameCharCode()&&(e+=n.scanWord())),n.skipWs(),n.eat(cx),n.skipWs(),n.charCode()===Q2?n.peek():(s=1,n.charCode()===X2&&(n.peek(),s=-1),t=s*Number(n.scanNumber(n)),n.isNameCharCode()&&(t+=n.scanWord())),n.eat(Oi),{type:"Range",min:e,max:t}}function XQ(n){let e,t=null;if(n.eat(ux),e=n.scanWord(),e==="boolean-expr"){n.eat(cl);const s=Vd(n,Oi);return n.eat(Oi),n.eat(Sh),Cr(n,{type:"Boolean",term:s.terms.length===1?s.terms[0]:s})}return n.charCode()===r_&&n.nextCharCode()===o_&&(n.pos+=2,e+="()"),n.charCodeAt(n.findWsEnd(n.pos))===cl&&(n.skipWs(),t=YQ(n)),n.eat(Sh),Cr(n,{type:"Type",name:e,opts:t})}function JQ(n){const e=n.scanWord();return n.charCode()===r_?(n.pos++,{type:"Function",name:e}):Cr(n,{type:"Keyword",name:e})}function QQ(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)=>ew[r]-ew[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 Vd(n,e=-1){const t=Object.create(null),s=[];let r=null,o=n.pos,i=!1;for(;n.charCode()!==e;){let l=i?Vd(n,o_):tee(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:QQ(s,t)||" ",disallowEmpty:!1,explicit:!1}}function eee(n){let e;return n.eat(cl),e=Vd(n,Oi),n.eat(Oi),e.explicit=!0,n.charCode()===s_&&(n.pos++,e.disallowEmpty=!0),e}function tee(n){let e=n.charCode();switch(e){case Oi:break;case cl:return Cr(n,eee(n));case ux:return n.nextCharCode()===Fu?ZQ(n):XQ(n);case J2:return{type:"Combinator",value:n.substringToPos(n.pos+(n.nextCharCode()===J2?2:1))};case Y2:return n.pos++,n.eat(Y2),{type:"Combinator",value:"&&"};case cx:return n.pos++,{type:"Comma"};case Fu:return Cr(n,{type:"String",value:n.scanString()});case HQ:case BQ:case WQ:case VQ:case qQ:return{type:"Spaces",value:n.scanSpaces()};case KQ:return e=n.nextCharCode(),n.isNameCharCode(e)?(n.pos++,{type:"AtKeyword",name:n.scanWord()}):rp(n);case i_:case lx:case Uu:case ax:case s_:break;case Bu:if(e=n.nextCharCode(),e<48||e>57)return rp(n);break;default:return n.isNameCharCode(e)?JQ(n):rp(n)}}function a_(n){const e=new UQ(n),t=Vd(e);return e.pos!==n.length&&e.error("Unexpected input"),t.terms.length===1&&t.terms[0].type==="Group"?t.terms[0]:t}const Sa=function(){};function nw(n){return typeof n=="function"?n:Sa}function nee(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=Sa,o=Sa;if(typeof e=="function"?r=e:e&&(r=nw(e.enter),o=nw(e.leave)),r===Sa&&o===Sa)throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");s(n)}const see={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 ree(n){const e=[];return Bd(n,(t,s,r)=>e.push({type:t,value:n.slice(s,r),node:null})),e}function oee(n,e){return typeof n=="string"?ree(n):e.generate(n,see)}const dt={type:"Match"},yt={type:"Mismatch"},dx={type:"DisallowEmpty"},iee=40,aee=41;function kn(n,e,t){return e===dt&&t===yt||n===dt&&e===dt&&t===dt?n:(n.type==="If"&&n.else===yt&&e===dt&&(e=n.then,n=n.match),{type:"If",match:n,then:e,else:t})}function l_(n){return n.length>2&&n.charCodeAt(n.length-2)===iee&&n.charCodeAt(n.length-1)===aee}function sw(n){return n.type==="Keyword"||n.type==="AtKeyword"||n.type==="Function"||n.type==="Type"&&l_(n.name)}function Mr(n,e=" ",t=!1){return{type:"Group",terms:n,combinator:e,disallowEmpty:!1,explicit:t}}function Ma(n,e,t=new Set){if(!t.has(n))switch(t.add(n),n.type){case"If":n.match=Ma(n.match,e,t),n.then=Ma(n.then,e,t),n.else=Ma(n.else,e,t);break;case"Type":return e[n.name]||n}return n}function jh(n,e,t){switch(n){case" ":{let s=dt;for(let r=e.length-1;r>=0;r--){const o=e[r];s=kn(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(sw(i)&&(r===null&&o>0&&sw(e[o-1])&&(r=Object.create(null),s=kn({type:"Enum",map:r},dt,s)),r!==null)){const l=(l_(i.name)?i.name.slice(0,-1):i.name).toLowerCase();if(!(l in r)){r[l]=i;continue}}r=null,s=kn(i,dt,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=jh(n,e.filter(function(l){return l!==o}),!1):i=dt,s=kn(o,i,s)}return s}case"||":{if(e.length>5)return{type:"MatchOnce",terms:e,all:!1};let s=t?dt:yt;for(let r=e.length-1;r>=0;r--){const o=e[r];let i;e.length>1?i=jh(n,e.filter(function(l){return l!==o}),!0):i=dt,s=kn(o,i,s)}return s}}}function lee(n){let e=dt,t=di(n.term);if(n.max===0)t=kn(t,dx,yt),e=kn(t,null,yt),e.then=kn(dt,dt,e),n.comma&&(e.then.else=kn({type:"Comma",syntax:n},e,yt));else for(let s=n.min||1;s<=n.max;s++)n.comma&&e!==dt&&(e=kn({type:"Comma",syntax:n},e,yt)),e=kn(t,kn(dt,dt,e),yt);if(n.min===0)e=kn(dt,dt,e);else for(let s=0;s<n.min-1;s++)n.comma&&e!==dt&&(e=kn({type:"Comma",syntax:n},e,yt)),e=kn(t,e,yt);return e}function di(n){if(typeof n=="function")return{type:"Generic",fn:n};switch(n.type){case"Group":{let e=jh(n.combinator,n.terms.map(di),!1);return n.disallowEmpty&&(e=kn(e,dx,yt)),e}case"Multiplier":return lee(n);case"Boolean":{const e=di(n.term),t=di(Mr([Mr([{type:"Keyword",name:"not"},{type:"Type",name:"!boolean-group"}]),Mr([{type:"Type",name:"!boolean-group"},Mr([{type:"Multiplier",comma:!1,min:0,max:0,term:Mr([{type:"Keyword",name:"and"},{type:"Type",name:"!boolean-group"}])},{type:"Multiplier",comma:!1,min:0,max:0,term:Mr([{type:"Keyword",name:"or"},{type:"Type",name:"!boolean-group"}])}],"|")])],"|")),s=di(Mr([{type:"Type",name:"!term"},Mr([{type:"Token",value:"("},{type:"Type",name:"!self"},{type:"Token",value:")"}]),{type:"Type",name:"general-enclosed"}],"|"));return Ma(s,{"!term":e,"!self":t}),Ma(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 Ac(n,e){return typeof n=="string"&&(n=a_(n)),{type:"MatchGraph",match:di(n),syntax:e||null,source:n}}const{hasOwnProperty:rw}=Object.prototype,cee=0,uee=1,Nh=2,c_=3,ow="Match",dee="Mismatch",fee="Maximum iteration number exceeded (please fill an issue on https://github.com/csstree/csstree/issues)",iw=15e3;function mee(n){let e=null,t=null,s=n;for(;s!==null;)t=s.prev,s.prev=e,e=s,s=t;return e}function op(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 pee(n){return n.type!==rt?!1:n.value!=="?"}function aw(n){return n===null?!0:n.type===Hn||n.type===et||n.type===lt||n.type===Kn||n.type===cn||pee(n)}function lw(n){return n===null?!0:n.type===Ge||n.type===qn||n.type===On||n.type===rt&&n.value==="/"}function hee(n,e,t){function s(){do v++,b=v<n.length?n[v]:null;while(b!==null&&(b.type===Ct||b.type===ln))}function r(j){const C=v+j;return C<n.length?n[C]:null}function o(j,C){return{nextState:j,matchStack:k,syntaxStack:f,thenStack:m,tokenIndex:v,prev:C}}function i(j){m={nextState:j,matchStack:k,syntaxStack:f,prev:m}}function l(j){p=o(j,p)}function c(){k={type:uee,syntax:e.syntax,token:b,prev:k},s(),h=null,v>y&&(y=v)}function u(){f={syntax:e.syntax,opts:e.syntax.opts||f!==null&&f.opts||null,prev:f},k={type:Nh,syntax:e.syntax,token:k.token,prev:k}}function d(){k.type===Nh?k=k.prev:k={type:c_,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,v=-1,y=0,k={type:cee,syntax:null,token:null,prev:null};for(s();x===null&&++g<iw;)switch(e.type){case"Match":if(m===null){if(b!==null&&(v!==n.length-1||b.value!=="\\0"&&b.value!=="\\9")){e=yt;break}x=ow;break}if(e=m.nextState,e===dx)if(m.matchStack===k){e=yt;break}else e=dt;for(;m.syntaxStack!==f;)d();m=m.prev;break;case"Mismatch":if(h!==null&&h!==!1)(p===null||v>p.tokenIndex)&&(p=h,h=!1);else if(p===null){x=dee;break}e=p.nextState,m=p.thenStack,f=p.syntaxStack,k=p.matchStack,v=p.tokenIndex,b=v<n.length?n[v]:null,p=p.prev;break;case"MatchGraph":e=e.match;break;case"If":e.else!==yt&&l(e.else),e.then!==dt&&i(e.then),e=e.match;break;case"MatchOnce":e={type:"MatchOnceBuffer",syntax:e,index:0,mask:0};break;case"MatchOnceBuffer":{const _=e.syntax.terms;if(e.index===_.length){if(e.mask===0||e.syntax.all){e=yt;break}e=dt;break}if(e.mask===(1<<_.length)-1){e=dt;break}for(;e.index<_.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=_[e.index++];break}}break}case"AddMatchOnce":e={type:"MatchOnceBuffer",syntax:e.syntax,index:0,mask:e.mask};break;case"Enum":if(b!==null){let _=b.value.toLowerCase();if(_.indexOf("\\")!==-1&&(_=_.replace(/\\[09].*$/,"")),rw.call(e.map,_)){e=e.map[_];break}}e=yt;break;case"Generic":{const _=f!==null?f.opts:null,S=v+Math.floor(e.fn(b,r,_));if(!isNaN(S)&&S>v){for(;v<S;)c();e=dt}else e=yt;break}case"Type":case"Property":{const _=e.type==="Type"?"types":"properties",S=rw.call(t,_)?t[_][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===Ce||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 _=e.name;if(b!==null){let S=b.value;if(S.indexOf("\\")!==-1&&(S=S.replace(/\\[09].*$/,"")),op(S,_)){c(),e=dt;break}}e=yt;break}case"AtKeyword":case"Function":if(b!==null&&op(b.value,e.name)){c(),e=dt;break}e=yt;break;case"Token":if(b!==null&&b.value===e.value){c(),e=dt;break}e=yt;break;case"Comma":b!==null&&b.type===Hn?aw(k.token)?e=yt:(c(),e=lw(b)?yt:dt):e=aw(k.token)||lw(b)?dt:yt;break;case"String":let j="",C=v;for(;C<n.length&&j.length<e.value.length;C++)j+=n[C].value;if(op(j,e.value)){for(;v<C;)c();e=dt}else e=yt;break;default:throw new Error("Unknown node type: "+e.type)}switch(x){case null:console.warn("[csstree-match] BREAK after "+iw+" iterations"),x=fee,k=null;break;case ow:for(;f!==null;)d();break;default:k=null}return{tokens:n,reason:x,iterations:g,match:k,longestMatch:y}}function cw(n,e,t){const s=hee(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=mee(r).prev;r!==null;){switch(r.type){case Nh:o.match.push(o={syntax:r.syntax,match:[]}),i.push(o);break;case c_: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 u_(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 gee(n,e){return fx(this,n,t=>t.type==="Type"&&t.name===e)}function xee(n,e){return fx(this,n,t=>t.type==="Property"&&t.name===e)}function bee(n){return fx(this,n,e=>e.type==="Keyword")}function fx(n,e,t){const s=u_.call(n,e);return s===null?!1:s.some(t)}const vee=Object.freeze(Object.defineProperty({__proto__:null,getTrace:u_,isKeyword:bee,isProperty:xee,isType:gee},Symbol.toStringTag,{value:"Module"}));function d_(n){return"node"in n?n.node:d_(n.match[0])}function f_(n){return"node"in n?n.node:f_(n.match[n.match.length-1])}function uw(n,e,t,s,r){function o(l){if(l.syntax!==null&&l.syntax.type===s&&l.syntax.name===r){const c=d_(l),u=f_(l);n.syntax.walk(e,function(d,f,m){if(d===c){const p=new dn;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:La}=Object.prototype;function ip(n){return typeof n=="number"&&isFinite(n)&&Math.floor(n)===n&&n>=0}function dw(n){return!!n&&ip(n.offset)&&ip(n.line)&&ip(n.column)}function yee(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(La.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(!dw(s.loc.start))o+=".start";else if(!dw(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 dn)}}}else r(s,"Unknown field `"+o+"` for "+n+" node type");i||r(s,"Bad value for `"+n+"."+o+"`")}}for(const o in e)La.call(e,o)&&La.call(s,o)===!1&&r(s,"Field `"+n+"."+o+"` is missed")}}function m_(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<"+(m_(r,e)||"any")+">");else throw new Error("Wrong value `"+r+"` in `"+e+"` structure definition")}return t.join(" | ")}function wee(n,e){const t=e.structure,s={type:String,loc:!0},r={type:'"'+n+'"'};for(const o in t){if(La.call(t,o)===!1)continue;const i=s[o]=Array.isArray(t[o])?t[o].slice():[t[o]];r[o]=m_(i,n+"."+o)}return{docs:r,check:yee(n,s)}}function See(n){const e={};if(n.node){for(const t in n.node)if(La.call(n.node,t)){const s=n.node[t];if(s.structure)e[t]=wee(t,s);else throw new Error("Missed `structure` field in `"+t+"` node type definition")}}return e}function Ch(n,e,t){const s={};for(const r in n)n[r].syntax&&(s[r]=t?n[r].syntax:J1(n[r].syntax,{compact:e}));return s}function kee(n,e,t){const s={};for(const[r,o]of Object.entries(n))s[r]={prelude:o.prelude&&(t?o.prelude.syntax:J1(o.prelude.syntax,{compact:e})),descriptors:o.descriptors&&Ch(o.descriptors,e,t)};return s}function jee(n){for(let e=0;e<n.length;e++)if(n[e].value.toLowerCase()==="var(")return!0;return!1}function Nee(n){const e=n.terms[0];return n.explicit===!1&&n.terms.length===1&&e.type==="Multiplier"&&e.comma===!0}function vs(n,e,t){return{matched:n,iterations:t,error:e,...vee}}function ti(n,e,t,s){const r=oee(t,n.syntax);let o;return jee(r)?vs(null,new Error("Matching for a tree with var() is not supported")):(s&&(o=cw(r,n.cssWideKeywordsSyntax,n)),(!s||!o.match)&&(o=cw(r,e.match,n),!o.match)?vs(null,new JJ(o.reason,e.syntax,t,o),o.iterations):vs(o.match,null,o.iterations))}class fw{constructor(e,t,s){if(this.cssWideKeywords=ex,this.syntax=t,this.generic=!1,this.units={...G2},this.atrules=Object.create(null),this.properties=Object.create(null),this.types=Object.create(null),this.structure=s||See(e),e){if(e.cssWideKeywords&&(this.cssWideKeywords=e.cssWideKeywords),e.units)for(const r of Object.keys(G2))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(CQ(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=Ac(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=Ac(e,o):(typeof e=="string"?Object.defineProperty(i,"syntax",{get(){return Object.defineProperty(i,"syntax",{value:a_(e)}),i.syntax}}):i.syntax=e,Object.defineProperty(i,"match",{get(){return Object.defineProperty(i,"match",{value:Ac(i.syntax,o)}),i.match}}),t==="Property"&&Object.defineProperty(i,"matchRef",{get(){const l=i.syntax,c=Nee(l)?Ac({...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 aa("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&&!ti(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=tp(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 aa("Unknown at-rule descriptor",t)}checkPropertyName(e){if(!this.getProperty(e))return new aa("Unknown property",e)}matchAtrulePrelude(e,t){const s=this.checkAtrulePrelude(e,t);if(s)return vs(null,s);const r=this.getAtrule(e);return r.prelude?ti(this,r.prelude,t||"",!1):vs(null,null)}matchAtruleDescriptor(e,t,s){const r=this.checkAtruleDescriptorName(e,t);if(r)return vs(null,r);const o=this.getAtrule(e),i=tp(t);return ti(this,o.descriptors[i.name]||o.descriptors[i.basename],s,!1)}matchDeclaration(e){return e.type!=="Declaration"?vs(null,new Error("Not a Declaration node")):this.matchProperty(e.property,e.value)}matchProperty(e,t){if(H2(e).custom)return vs(null,new Error("Lexer matching doesn't applicable for custom properties"));const s=this.checkPropertyName(e);return s?vs(null,s):ti(this,this.getProperty(e),t,!0)}matchType(e,t){const s=this.getType(e);return s?ti(this,s,t,!1):vs(null,new aa("Unknown type",e))}match(e,t){return typeof e!="string"&&(!e||!e.type)?vs(null,new aa("Bad syntax")):((typeof e=="string"||!e.match)&&(e=this.createDescriptor(e,"Type","anonymous")),ti(this,e,t,!1))}findValueFragments(e,t,s,r){return uw(this,t,this.matchProperty(e,t),s,r)}findDeclarationValueFragments(e,t,s){return uw(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=tp(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=H2(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&&nee(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:Ch(this.types,!t,e),properties:Ch(this.properties,!t,e),atrules:kee(this.atrules,!t,e)}}toString(){return JSON.stringify(this.dump())}}function ap(n,e){return typeof e=="string"&&/^\s*\|/.test(e)?typeof n=="string"?n+e:e.replace(/^\s*\|\s*/,""):e||null}function Cee(n,e){const t=Object.create(null);for(const s of Object.keys(n))e.includes(s)&&(t[s]=n[s]);return t}function lp(n,e,t){const s={...n};for(const[r,o]of Object.entries(e))s[r]={...s[r],...t?Cee(o,t):o};return s}function _h(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?ap(c.prelude,i.prelude):c.prelude||null;for(const[u,d]of Object.entries(i.descriptors||{}))c.descriptors[u]=d?ap(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]=ap(t[s][o],i);break;case"parseContext":t[s]={...n[s],...r};break;case"scope":case"features":t[s]=lp(n[s],r);break;case"atrule":case"pseudo":t[s]=lp(n[s],r,["parse"]);break;case"node":t[s]=lp(n[s],r,["name","structure","parse","generate","walkContext"]);break}return t}function p_(n){const e=TJ(n),t=HJ(n),s=BJ(n),{fromPlainObject:r,toPlainObject:o}=WJ(t),i={lexer:null,createLexer:l=>new fw(l,i,i.lexer.structure),tokenize:Bd,parse:e,generate:s,walk:t,find:t.find,findLast:t.findLast,findAll:t.findAll,fromPlainObject:r,toPlainObject:o,fork(l){const c=_h({},n);return p_(typeof l=="function"?l(c):_h(c,l))}};return i.lexer=new fw({generic:n.generic,cssWideKeywords:n.cssWideKeywords,units:n.units,types:n.types,atrules:n.atrules,properties:n.properties,node:n.node},i),i}const _ee=n=>p_(_h({},n)),Tee={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"}}}},Xs=43,Xn=45,Qc=110,ko=!0,Eee=!1;function eu(n,e){let t=this.tokenStart+n;const s=this.charCodeAt(t);for((s===Xs||s===Xn)&&(e&&this.error("Number sign is not allowed"),t++);t<this.tokenEnd;t++)yn(this.charCodeAt(t))||this.error("Integer is expected",t)}function fi(n){return eu.call(this,0,n)}function Lr(n,e){if(!this.cmpChar(this.tokenStart+n,e)){let t="";switch(e){case Qc:t="N is expected";break;case Xn:t="HyphenMinus is expected";break}this.error(t,this.tokenStart+n)}}function cp(){let n=0,e=0,t=this.tokenType;for(;t===Ct||t===ln;)t=this.lookupType(++n);if(t!==Je)if(this.isDelim(Xs,n)||this.isDelim(Xn,n)){e=this.isDelim(Xs,n)?Xs:Xn;do t=this.lookupType(++n);while(t===Ct||t===ln);t!==Je&&(this.skip(n),fi.call(this,ko))}else return null;return n>0&&this.skip(n),e===0&&(t=this.charCodeAt(this.tokenStart),t!==Xs&&t!==Xn&&this.error("Number sign is expected")),fi.call(this,e!==0),e===Xn?"-"+this.consume(Je):this.consume(Je)}const Aee="AnPlusB",Pee={a:[String,null],b:[String,null]};function h_(){const n=this.tokenStart;let e=null,t=null;if(this.tokenType===Je)fi.call(this,Eee),t=this.consume(Je);else if(this.tokenType===Ce&&this.cmpChar(this.tokenStart,Xn))switch(e="-1",Lr.call(this,1,Qc),this.tokenEnd-this.tokenStart){case 2:this.next(),t=cp.call(this);break;case 3:Lr.call(this,2,Xn),this.next(),this.skipSC(),fi.call(this,ko),t="-"+this.consume(Je);break;default:Lr.call(this,2,Xn),eu.call(this,3,ko),this.next(),t=this.substrToCursor(n+2)}else if(this.tokenType===Ce||this.isDelim(Xs)&&this.lookupType(1)===Ce){let s=0;switch(e="1",this.isDelim(Xs)&&(s=1,this.next()),Lr.call(this,0,Qc),this.tokenEnd-this.tokenStart){case 1:this.next(),t=cp.call(this);break;case 2:Lr.call(this,1,Xn),this.next(),this.skipSC(),fi.call(this,ko),t="-"+this.consume(Je);break;default:Lr.call(this,1,Xn),eu.call(this,2,ko),this.next(),t=this.substrToCursor(n+s+1)}}else if(this.tokenType===st){const s=this.charCodeAt(this.tokenStart),r=s===Xs||s===Xn;let o=this.tokenStart+r;for(;o<this.tokenEnd&&yn(this.charCodeAt(o));o++);o===this.tokenStart+r&&this.error("Integer is expected",this.tokenStart+r),Lr.call(this,o-this.tokenStart,Qc),e=this.substring(n,o),o+1===this.tokenEnd?(this.next(),t=cp.call(this)):(Lr.call(this,o-this.tokenStart+1,Xn),o+2===this.tokenEnd?(this.next(),this.skipSC(),fi.call(this,ko),t="-"+this.consume(Je)):(eu.call(this,o-this.tokenStart+2,ko),this.next(),t=this.substrToCursor(o+1)))}else this.error();return e!==null&&e.charCodeAt(0)===Xs&&(e=e.substr(1)),t!==null&&t.charCodeAt(0)===Xs&&(t=t.substr(1)),{type:"AnPlusB",loc:this.getLocation(n,this.tokenStart),a:e,b:t}}function Iee(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 $ee=Object.freeze(Object.defineProperty({__proto__:null,generate:Iee,name:Aee,parse:h_,structure:Pee},Symbol.toStringTag,{value:"Module"}));function mw(){return this.Raw(this.consumeUntilLeftCurlyBracketOrSemicolon,!0)}function Ree(){for(let n=1,e;e=this.lookupType(n);n++){if(e===On)return!0;if(e===cn||e===Gt)return!1}return!1}const Oee="Atrule",Mee="atrule",Lee={name:String,prelude:["AtrulePrelude","Raw",null],block:["Block",null]};function g_(n=!1){const e=this.tokenStart;let t,s,r=null,o=null;switch(this.eat(Gt),t=this.substrToCursor(e+1),s=t.toLowerCase(),this.skipSC(),this.eof===!1&&this.tokenType!==cn&&this.tokenType!==Tn&&(this.parseAtrulePrelude?r=this.parseWithFallback(this.AtrulePrelude.bind(this,t,n),mw):r=mw.call(this,this.tokenIndex),this.skipSC()),this.tokenType){case Tn:this.next();break;case cn:hasOwnProperty.call(this.atrule,s)&&typeof this.atrule[s].block=="function"?o=this.atrule[s].block.call(this,n):o=this.Block(Ree.call(this));break}return{type:"Atrule",loc:this.getLocation(e,this.tokenStart),name:t,prelude:r,block:o}}function zee(n){this.token(Gt,"@"+n.name),n.prelude!==null&&this.node(n.prelude),n.block?this.node(n.block):this.token(Tn,";")}const Dee=Object.freeze(Object.defineProperty({__proto__:null,generate:zee,name:Oee,parse:g_,structure:Lee,walkContext:Mee},Symbol.toStringTag,{value:"Module"})),Fee="AtrulePrelude",Uee="atrulePrelude",Bee={children:[[]]};function x_(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!==cn&&this.tokenType!==Tn&&this.error("Semicolon or block is expected"),{type:"AtrulePrelude",loc:this.getLocationFromList(e),children:e}}function Wee(n){this.children(n)}const qee=Object.freeze(Object.defineProperty({__proto__:null,generate:Wee,name:Fee,parse:x_,structure:Bee,walkContext:Uee},Symbol.toStringTag,{value:"Module"})),Vee=36,b_=42,tu=61,Hee=94,Th=124,Kee=126;function Gee(){this.eof&&this.error("Unexpected end of input");const n=this.tokenStart;let e=!1;return this.isDelim(b_)?(e=!0,this.next()):this.isDelim(Th)||this.eat(Ce),this.isDelim(Th)?this.charCodeAt(this.tokenStart+1)!==tu?(this.next(),this.eat(Ce)):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 Zee(){const n=this.tokenStart,e=this.charCodeAt(n);return e!==tu&&e!==Kee&&e!==Hee&&e!==Vee&&e!==b_&&e!==Th&&this.error("Attribute selector (=, ~=, ^=, $=, *=, |=) is expected"),this.next(),e!==tu&&(this.isDelim(tu)||this.error("Equal sign is expected"),this.next()),this.substrToCursor(n)}const Yee="AttributeSelector",Xee={name:"Identifier",matcher:[String,null],value:["String","Identifier",null],flags:[String,null]};function v_(){const n=this.tokenStart;let e,t=null,s=null,r=null;return this.eat(Kn),this.skipSC(),e=Gee.call(this),this.skipSC(),this.tokenType!==qn&&(this.tokenType!==Ce&&(t=Zee.call(this),this.skipSC(),s=this.tokenType===Qn?this.String():this.Identifier(),this.skipSC()),this.tokenType===Ce&&(r=this.consume(Ce),this.skipSC())),this.eat(qn),{type:"AttributeSelector",loc:this.getLocation(n,this.tokenStart),name:e,matcher:t,value:s,flags:r}}function Jee(n){this.token(rt,"["),this.node(n.name),n.matcher!==null&&(this.tokenize(n.matcher),this.node(n.value)),n.flags!==null&&this.token(Ce,n.flags),this.token(rt,"]")}const Qee=Object.freeze(Object.defineProperty({__proto__:null,generate:Jee,name:Yee,parse:v_,structure:Xee},Symbol.toStringTag,{value:"Module"})),ete=38;function y_(){return this.Raw(null,!0)}function pw(){return this.parseWithFallback(this.Rule,y_)}function hw(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}function tte(){if(this.tokenType===Tn)return hw.call(this,this.tokenIndex);const n=this.parseWithFallback(this.Declaration,hw);return this.tokenType===Tn&&this.next(),n}const nte="Block",ste="block",rte={children:[["Atrule","Rule","Declaration"]]};function w_(n){const e=n?tte:pw,t=this.tokenStart;let s=this.createList();this.eat(cn);e:for(;!this.eof;)switch(this.tokenType){case On:break e;case Ct:case ln:this.next();break;case Gt:s.push(this.parseWithFallback(this.Atrule.bind(this,n),y_));break;default:n&&this.isDelim(ete)?s.push(pw.call(this)):s.push(e.call(this))}return this.eof||this.eat(On),{type:"Block",loc:this.getLocation(t,this.tokenStart),children:s}}function ote(n){this.token(cn,"{"),this.children(n,e=>{e.type==="Declaration"&&this.token(Tn,";")}),this.token(On,"}")}const ite=Object.freeze(Object.defineProperty({__proto__:null,generate:ote,name:nte,parse:w_,structure:rte,walkContext:ste},Symbol.toStringTag,{value:"Module"})),ate="Brackets",lte={children:[[]]};function S_(n,e){const t=this.tokenStart;let s=null;return this.eat(Kn),s=n.call(this,e),this.eof||this.eat(qn),{type:"Brackets",loc:this.getLocation(t,this.tokenStart),children:s}}function cte(n){this.token(rt,"["),this.children(n),this.token(rt,"]")}const ute=Object.freeze(Object.defineProperty({__proto__:null,generate:cte,name:ate,parse:S_,structure:lte},Symbol.toStringTag,{value:"Module"})),dte="CDC",fte=[];function k_(){const n=this.tokenStart;return this.eat(zn),{type:"CDC",loc:this.getLocation(n,this.tokenStart)}}function mte(){this.token(zn,"-->")}const pte=Object.freeze(Object.defineProperty({__proto__:null,generate:mte,name:dte,parse:k_,structure:fte},Symbol.toStringTag,{value:"Module"})),hte="CDO",gte=[];function j_(){const n=this.tokenStart;return this.eat(zl),{type:"CDO",loc:this.getLocation(n,this.tokenStart)}}function xte(){this.token(zl,"<!--")}const bte=Object.freeze(Object.defineProperty({__proto__:null,generate:xte,name:hte,parse:j_,structure:gte},Symbol.toStringTag,{value:"Module"})),vte=46,yte="ClassSelector",wte={name:String};function N_(){return this.eatDelim(vte),{type:"ClassSelector",loc:this.getLocation(this.tokenStart-1,this.tokenEnd),name:this.consume(Ce)}}function Ste(n){this.token(rt,"."),this.token(Ce,n.name)}const kte=Object.freeze(Object.defineProperty({__proto__:null,generate:Ste,name:yte,parse:N_,structure:wte},Symbol.toStringTag,{value:"Module"})),jte=43,gw=47,Nte=62,Cte=126,_te="Combinator",Tte={name:String};function C_(){const n=this.tokenStart;let e;switch(this.tokenType){case Ct:e=" ";break;case rt:switch(this.charCodeAt(this.tokenStart)){case Nte:case jte:case Cte:this.next();break;case gw:this.next(),this.eatIdent("deep"),this.eatDelim(gw);break;default:this.error("Combinator is expected")}e=this.substrToCursor(n);break}return{type:"Combinator",loc:this.getLocation(n,this.tokenStart),name:e}}function Ete(n){this.tokenize(n.name)}const Ate=Object.freeze(Object.defineProperty({__proto__:null,generate:Ete,name:_te,parse:C_,structure:Tte},Symbol.toStringTag,{value:"Module"})),Pte=42,Ite=47,$te="Comment",Rte={value:String};function __(){const n=this.tokenStart;let e=this.tokenEnd;return this.eat(ln),e-n+2>=2&&this.charCodeAt(e-2)===Pte&&this.charCodeAt(e-1)===Ite&&(e-=2),{type:"Comment",loc:this.getLocation(n,this.tokenStart),value:this.substring(n+2,e)}}function Ote(n){this.token(ln,"/*"+n.value+"*/")}const Mte=Object.freeze(Object.defineProperty({__proto__:null,generate:Ote,name:$te,parse:__,structure:Rte},Symbol.toStringTag,{value:"Module"})),Lte=new Set([_n,Ge,Wr]),zte="Condition",Dte={kind:String,children:[["Identifier","Feature","FeatureFunction","FeatureRange","SupportsDeclaration"]]};function xw(n){return this.lookupTypeNonSC(1)===Ce&&Lte.has(this.lookupTypeNonSC(2))?this.Feature(n):this.FeatureRange(n)}const Fte={media:xw,container:xw,supports(){return this.SupportsDeclaration()}};function T_(n="media"){const e=this.createList();e:for(;!this.eof;)switch(this.tokenType){case ln:case Ct:this.next();continue;case Ce:e.push(this.Identifier());break;case lt:{let t=this.parseWithFallback(()=>Fte[n].call(this,n),()=>null);t||(t=this.parseWithFallback(()=>{this.eat(lt);const s=this.Condition(n);return this.eat(Ge),s},()=>this.GeneralEnclosed(n))),e.push(t);break}case et:{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 Ute(n){n.children.forEach(e=>{e.type==="Condition"?(this.token(lt,"("),this.node(e),this.token(Ge,")")):this.node(e)})}const Bte=Object.freeze(Object.defineProperty({__proto__:null,generate:Ute,name:zte,parse:T_,structure:Dte},Symbol.toStringTag,{value:"Module"})),E_=33,Wte=35,qte=36,Vte=38,Hte=42,Kte=43,bw=47;function Gte(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!0)}function Zte(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!1)}function Yte(){const n=this.tokenIndex,e=this.Value();return e.type!=="Raw"&&this.eof===!1&&this.tokenType!==Tn&&this.isDelim(E_)===!1&&this.isBalanceEdge(n)===!1&&this.error(),e}const Xte="Declaration",Jte="declaration",Qte={important:[Boolean,String],property:String,value:["Value","Raw"]};function A_(){const n=this.tokenStart,e=this.tokenIndex,t=tne.call(this),s=Q1(t),r=s?this.parseCustomProperty:this.parseValue,o=s?Zte:Gte;let i=!1,l;this.skipSC(),this.eat(_n);const c=this.tokenIndex;if(s||this.skipSC(),r?l=this.parseWithFallback(Yte,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)===Ct){l.children.appendData({type:"WhiteSpace",loc:null,value:" "});break}}return this.isDelim(E_)&&(i=nne.call(this),this.skipSC()),this.eof===!1&&this.tokenType!==Tn&&this.isBalanceEdge(e)===!1&&this.error(),{type:"Declaration",loc:this.getLocation(n,this.tokenStart),important:i,property:t,value:l}}function ene(n){this.token(Ce,n.property),this.token(_n,":"),this.node(n.value),n.important&&(this.token(rt,"!"),this.token(Ce,n.important===!0?"important":n.important))}function tne(){const n=this.tokenStart;if(this.tokenType===rt)switch(this.charCodeAt(this.tokenStart)){case Hte:case qte:case Kte:case Wte:case Vte:this.next();break;case bw:this.next(),this.isDelim(bw)&&this.next();break}return this.tokenType===kt?this.eat(kt):this.eat(Ce),this.substrToCursor(n)}function nne(){this.eat(rt),this.skipSC();const n=this.consume(Ce);return n==="important"?!0:n}const sne=Object.freeze(Object.defineProperty({__proto__:null,generate:ene,name:Xte,parse:A_,structure:Qte,walkContext:Jte},Symbol.toStringTag,{value:"Module"})),rne=38;function up(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}const one="DeclarationList",ine={children:[["Declaration","Atrule","Rule"]]};function P_(){const n=this.createList();for(;!this.eof;)switch(this.tokenType){case Ct:case ln:case Tn:this.next();break;case Gt:n.push(this.parseWithFallback(this.Atrule.bind(this,!0),up));break;default:this.isDelim(rne)?n.push(this.parseWithFallback(this.Rule,up)):n.push(this.parseWithFallback(this.Declaration,up))}return{type:"DeclarationList",loc:this.getLocationFromList(n),children:n}}function ane(n){this.children(n,e=>{e.type==="Declaration"&&this.token(Tn,";")})}const lne=Object.freeze(Object.defineProperty({__proto__:null,generate:ane,name:one,parse:P_,structure:ine},Symbol.toStringTag,{value:"Module"})),cne="Dimension",une={value:String,unit:String};function I_(){const n=this.tokenStart,e=this.consumeNumber(st);return{type:"Dimension",loc:this.getLocation(n,this.tokenStart),value:e,unit:this.substring(n+e.length,this.tokenStart)}}function dne(n){this.token(st,n.value+n.unit)}const fne=Object.freeze(Object.defineProperty({__proto__:null,generate:dne,name:cne,parse:I_,structure:une},Symbol.toStringTag,{value:"Module"})),mne=47,pne="Feature",hne={kind:String,name:String,value:["Identifier","Number","Dimension","Ratio","Function",null]};function $_(n){const e=this.tokenStart;let t,s=null;if(this.eat(lt),this.skipSC(),t=this.consume(Ce),this.skipSC(),this.tokenType!==Ge){switch(this.eat(_n),this.skipSC(),this.tokenType){case Je:this.lookupNonWSType(1)===rt?s=this.Ratio():s=this.Number();break;case st:s=this.Dimension();break;case Ce:s=this.Identifier();break;case et:s=this.parseWithFallback(()=>{const r=this.Function(this.readSequence,this.scope.Value);return this.skipSC(),this.isDelim(mne)&&this.error(),r},()=>this.Ratio());break;default:this.error("Number, dimension, ratio or identifier is expected")}this.skipSC()}return this.eof||this.eat(Ge),{type:"Feature",loc:this.getLocation(e,this.tokenStart),kind:n,name:t,value:s}}function gne(n){this.token(lt,"("),this.token(Ce,n.name),n.value!==null&&(this.token(_n,":"),this.node(n.value)),this.token(Ge,")")}const xne=Object.freeze(Object.defineProperty({__proto__:null,generate:gne,name:pne,parse:$_,structure:hne},Symbol.toStringTag,{value:"Module"})),bne="FeatureFunction",vne={kind:String,feature:String,value:["Declaration","Selector"]};function yne(n,e){const s=(this.features[n]||{})[e];return typeof s!="function"&&this.error(`Unknown feature ${e}()`),s}function R_(n="unknown"){const e=this.tokenStart,t=this.consumeFunctionName(),s=yne.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(Ge),{type:"FeatureFunction",loc:this.getLocation(e,this.tokenStart),kind:n,feature:t,value:r}}function wne(n){this.token(et,n.feature+"("),this.node(n.value),this.token(Ge,")")}const Sne=Object.freeze(Object.defineProperty({__proto__:null,generate:wne,name:bne,parse:R_,structure:vne},Symbol.toStringTag,{value:"Module"})),vw=47,kne=60,yw=61,jne=62,Nne="FeatureRange",Cne={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 dp(){switch(this.skipSC(),this.tokenType){case Je:return this.isDelim(vw,this.lookupOffsetNonSC(1))?this.Ratio():this.Number();case st:return this.Dimension();case Ce:return this.Identifier();case et:return this.parseWithFallback(()=>{const n=this.Function(this.readSequence,this.scope.Value);return this.skipSC(),this.isDelim(vw)&&this.error(),n},()=>this.Ratio());default:this.error("Number, dimension, ratio or identifier is expected")}}function ww(n){if(this.skipSC(),this.isDelim(kne)||this.isDelim(jne)){const e=this.source[this.tokenStart];return this.next(),this.isDelim(yw)?(this.next(),e+"="):e}if(this.isDelim(yw))return"=";this.error(`Expected ${n?'":", ':""}"<", ">", "=" or ")"`)}function O_(n="unknown"){const e=this.tokenStart;this.skipSC(),this.eat(lt);const t=dp.call(this),s=ww.call(this,t.type==="Identifier"),r=dp.call(this);let o=null,i=null;return this.lookupNonWSType(0)!==Ge&&(o=ww.call(this),i=dp.call(this)),this.skipSC(),this.eat(Ge),{type:"FeatureRange",loc:this.getLocation(e,this.tokenStart),kind:n,left:t,leftComparison:s,middle:r,rightComparison:o,right:i}}function _ne(n){this.token(lt,"("),this.node(n.left),this.tokenize(n.leftComparison),this.node(n.middle),n.right&&(this.tokenize(n.rightComparison),this.node(n.right)),this.token(Ge,")")}const Tne=Object.freeze(Object.defineProperty({__proto__:null,generate:_ne,name:Nne,parse:O_,structure:Cne},Symbol.toStringTag,{value:"Module"})),Ene="Function",Ane="function",Pne={name:String,children:[[]]};function M_(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(Ge),{type:"Function",loc:this.getLocation(t,this.tokenStart),name:s,children:o}}function Ine(n){this.token(et,n.name+"("),this.children(n),this.token(Ge,")")}const $ne=Object.freeze(Object.defineProperty({__proto__:null,generate:Ine,name:Ene,parse:M_,structure:Pne,walkContext:Ane},Symbol.toStringTag,{value:"Module"})),Rne="GeneralEnclosed",One={kind:String,function:[String,null],children:[[]]};function L_(n){const e=this.tokenStart;let t=null;this.tokenType===et?t=this.consumeFunctionName():this.eat(lt);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(Ge),{type:"GeneralEnclosed",loc:this.getLocation(e,this.tokenStart),kind:n,function:t,children:s}}function Mne(n){n.function?this.token(et,n.function+"("):this.token(lt,"("),this.children(n),this.token(Ge,")")}const Lne=Object.freeze(Object.defineProperty({__proto__:null,generate:Mne,name:Rne,parse:L_,structure:One},Symbol.toStringTag,{value:"Module"})),zne="XXX",Dne="Hash",Fne={value:String};function z_(){const n=this.tokenStart;return this.eat(kt),{type:"Hash",loc:this.getLocation(n,this.tokenStart),value:this.substrToCursor(n+1)}}function Une(n){this.token(kt,"#"+n.value)}const Bne=Object.freeze(Object.defineProperty({__proto__:null,generate:Une,name:Dne,parse:z_,structure:Fne,xxx:zne},Symbol.toStringTag,{value:"Module"})),Wne="Identifier",qne={name:String};function D_(){return{type:"Identifier",loc:this.getLocation(this.tokenStart,this.tokenEnd),name:this.consume(Ce)}}function Vne(n){this.token(Ce,n.name)}const Hne=Object.freeze(Object.defineProperty({__proto__:null,generate:Vne,name:Wne,parse:D_,structure:qne},Symbol.toStringTag,{value:"Module"})),Kne="IdSelector",Gne={name:String};function F_(){const n=this.tokenStart;return this.eat(kt),{type:"IdSelector",loc:this.getLocation(n,this.tokenStart),name:this.substrToCursor(n+1)}}function Zne(n){this.token(rt,"#"+n.name)}const Yne=Object.freeze(Object.defineProperty({__proto__:null,generate:Zne,name:Kne,parse:F_,structure:Gne},Symbol.toStringTag,{value:"Module"})),Xne=46,Jne="Layer",Qne={name:String};function U_(){let n=this.tokenStart,e=this.consume(Ce);for(;this.isDelim(Xne);)this.eat(rt),e+="."+this.consume(Ce);return{type:"Layer",loc:this.getLocation(n,this.tokenStart),name:e}}function ese(n){this.tokenize(n.name)}const tse=Object.freeze(Object.defineProperty({__proto__:null,generate:ese,name:Jne,parse:U_,structure:Qne},Symbol.toStringTag,{value:"Module"})),nse="LayerList",sse={children:[["Layer"]]};function B_(){const n=this.createList();for(this.skipSC();!this.eof&&(n.push(this.Layer()),this.lookupTypeNonSC(0)===Hn);)this.skipSC(),this.next(),this.skipSC();return{type:"LayerList",loc:this.getLocationFromList(n),children:n}}function rse(n){this.children(n,()=>this.token(Hn,","))}const ose=Object.freeze(Object.defineProperty({__proto__:null,generate:rse,name:nse,parse:B_,structure:sse},Symbol.toStringTag,{value:"Module"})),ise="MediaQuery",ase={modifier:[String,null],mediaType:[String,null],condition:["Condition",null]};function W_(){const n=this.tokenStart;let e=null,t=null,s=null;if(this.skipSC(),this.tokenType===Ce&&this.lookupTypeNonSC(1)!==lt){const r=this.consume(Ce),o=r.toLowerCase();switch(o==="not"||o==="only"?(this.skipSC(),e=o,t=this.consume(Ce)):t=r,this.lookupTypeNonSC(0)){case Ce:{this.skipSC(),this.eatIdent("and"),s=this.Condition("media");break}case cn:case Tn:case Hn:case Wr:break;default:this.error("Identifier or parenthesis is expected")}}else switch(this.tokenType){case Ce:case lt:case et:{s=this.Condition("media");break}case cn:case Tn:case Wr: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 lse(n){n.mediaType?(n.modifier&&this.token(Ce,n.modifier),this.token(Ce,n.mediaType),n.condition&&(this.token(Ce,"and"),this.node(n.condition))):n.condition&&this.node(n.condition)}const cse=Object.freeze(Object.defineProperty({__proto__:null,generate:lse,name:ise,parse:W_,structure:ase},Symbol.toStringTag,{value:"Module"})),use="MediaQueryList",dse={children:[["MediaQuery"]]};function q_(){const n=this.createList();for(this.skipSC();!this.eof&&(n.push(this.MediaQuery()),this.tokenType===Hn);)this.next();return{type:"MediaQueryList",loc:this.getLocationFromList(n),children:n}}function fse(n){this.children(n,()=>this.token(Hn,","))}const mse=Object.freeze(Object.defineProperty({__proto__:null,generate:fse,name:use,parse:q_,structure:dse},Symbol.toStringTag,{value:"Module"})),pse=38,hse="NestingSelector",gse={};function V_(){const n=this.tokenStart;return this.eatDelim(pse),{type:"NestingSelector",loc:this.getLocation(n,this.tokenStart)}}function xse(){this.token(rt,"&")}const bse=Object.freeze(Object.defineProperty({__proto__:null,generate:xse,name:hse,parse:V_,structure:gse},Symbol.toStringTag,{value:"Module"})),vse="Nth",yse={nth:["AnPlusB","Identifier"],selector:["SelectorList",null]};function H_(){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 wse(n){this.node(n.nth),n.selector!==null&&(this.token(Ce,"of"),this.node(n.selector))}const Sse=Object.freeze(Object.defineProperty({__proto__:null,generate:wse,name:vse,parse:H_,structure:yse},Symbol.toStringTag,{value:"Module"})),kse="Number",jse={value:String};function K_(){return{type:"Number",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consume(Je)}}function Nse(n){this.token(Je,n.value)}const Cse=Object.freeze(Object.defineProperty({__proto__:null,generate:Nse,name:kse,parse:K_,structure:jse},Symbol.toStringTag,{value:"Module"})),_se="Operator",Tse={value:String};function G_(){const n=this.tokenStart;return this.next(),{type:"Operator",loc:this.getLocation(n,this.tokenStart),value:this.substrToCursor(n)}}function Ese(n){this.tokenize(n.value)}const Ase=Object.freeze(Object.defineProperty({__proto__:null,generate:Ese,name:_se,parse:G_,structure:Tse},Symbol.toStringTag,{value:"Module"})),Pse="Parentheses",Ise={children:[[]]};function Z_(n,e){const t=this.tokenStart;let s=null;return this.eat(lt),s=n.call(this,e),this.eof||this.eat(Ge),{type:"Parentheses",loc:this.getLocation(t,this.tokenStart),children:s}}function $se(n){this.token(lt,"("),this.children(n),this.token(Ge,")")}const Rse=Object.freeze(Object.defineProperty({__proto__:null,generate:$se,name:Pse,parse:Z_,structure:Ise},Symbol.toStringTag,{value:"Module"})),Ose="Percentage",Mse={value:String};function Y_(){return{type:"Percentage",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consumeNumber(Pt)}}function Lse(n){this.token(Pt,n.value+"%")}const zse=Object.freeze(Object.defineProperty({__proto__:null,generate:Lse,name:Ose,parse:Y_,structure:Mse},Symbol.toStringTag,{value:"Module"})),Dse="PseudoClassSelector",Fse="function",Use={name:String,children:[["Raw"],null]};function X_(){const n=this.tokenStart;let e=null,t,s;return this.eat(_n),this.tokenType===et?(t=this.consumeFunctionName(),s=t.toLowerCase(),this.lookupNonWSType(0)==Ge?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(Ge)):t=this.consume(Ce),{type:"PseudoClassSelector",loc:this.getLocation(n,this.tokenStart),name:t,children:e}}function Bse(n){this.token(_n,":"),n.children===null?this.token(Ce,n.name):(this.token(et,n.name+"("),this.children(n),this.token(Ge,")"))}const Wse=Object.freeze(Object.defineProperty({__proto__:null,generate:Bse,name:Dse,parse:X_,structure:Use,walkContext:Fse},Symbol.toStringTag,{value:"Module"})),qse="PseudoElementSelector",Vse="function",Hse={name:String,children:[["Raw"],null]};function J_(){const n=this.tokenStart;let e=null,t,s;return this.eat(_n),this.eat(_n),this.tokenType===et?(t=this.consumeFunctionName(),s=t.toLowerCase(),this.lookupNonWSType(0)==Ge?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(Ge)):t=this.consume(Ce),{type:"PseudoElementSelector",loc:this.getLocation(n,this.tokenStart),name:t,children:e}}function Kse(n){this.token(_n,":"),this.token(_n,":"),n.children===null?this.token(Ce,n.name):(this.token(et,n.name+"("),this.children(n),this.token(Ge,")"))}const Gse=Object.freeze(Object.defineProperty({__proto__:null,generate:Kse,name:qse,parse:J_,structure:Hse,walkContext:Vse},Symbol.toStringTag,{value:"Module"})),Sw=47;function kw(){switch(this.skipSC(),this.tokenType){case Je:return this.Number();case et:return this.Function(this.readSequence,this.scope.Value);default:this.error("Number of function is expected")}}const Zse="Ratio",Yse={left:["Number","Function"],right:["Number","Function",null]};function Q_(){const n=this.tokenStart,e=kw.call(this);let t=null;return this.skipSC(),this.isDelim(Sw)&&(this.eatDelim(Sw),t=kw.call(this)),{type:"Ratio",loc:this.getLocation(n,this.tokenStart),left:e,right:t}}function Xse(n){this.node(n.left),this.token(rt,"/"),n.right?this.node(n.right):this.node(Je,1)}const Jse=Object.freeze(Object.defineProperty({__proto__:null,generate:Xse,name:Zse,parse:Q_,structure:Yse},Symbol.toStringTag,{value:"Module"}));function Qse(){return this.tokenIndex>0&&this.lookupType(-1)===Ct?this.tokenIndex>1?this.getTokenStart(this.tokenIndex-1):this.firstCharOffset:this.tokenStart}const ere="Raw",tre={value:String};function e5(n,e){const t=this.getTokenStart(this.tokenIndex);let s;return this.skipUntilBalanced(this.tokenIndex,n||this.consumeUntilBalanceEnd),e&&this.tokenStart>t?s=Qse.call(this):s=this.tokenStart,{type:"Raw",loc:this.getLocation(t,s),value:this.substring(t,s)}}function nre(n){this.tokenize(n.value)}const sre=Object.freeze(Object.defineProperty({__proto__:null,generate:nre,name:ere,parse:e5,structure:tre},Symbol.toStringTag,{value:"Module"}));function jw(){return this.Raw(this.consumeUntilLeftCurlyBracket,!0)}function rre(){const n=this.SelectorList();return n.type!=="Raw"&&this.eof===!1&&this.tokenType!==cn&&this.error(),n}const ore="Rule",ire="rule",are={prelude:["SelectorList","Raw"],block:["Block"]};function t5(){const n=this.tokenIndex,e=this.tokenStart;let t,s;return this.parseRulePrelude?t=this.parseWithFallback(rre,jw):t=jw.call(this,n),s=this.Block(!0),{type:"Rule",loc:this.getLocation(e,this.tokenStart),prelude:t,block:s}}function lre(n){this.node(n.prelude),this.node(n.block)}const cre=Object.freeze(Object.defineProperty({__proto__:null,generate:lre,name:ore,parse:t5,structure:are,walkContext:ire},Symbol.toStringTag,{value:"Module"})),ure="Scope",dre={root:["SelectorList","Raw",null],limit:["SelectorList","Raw",null]};function n5(){let n=null,e=null;this.skipSC();const t=this.tokenStart;return this.tokenType===lt&&(this.next(),this.skipSC(),n=this.parseWithFallback(this.SelectorList,()=>this.Raw(!1,!0)),this.skipSC(),this.eat(Ge)),this.lookupNonWSType(0)===Ce&&(this.skipSC(),this.eatIdent("to"),this.skipSC(),this.eat(lt),this.skipSC(),e=this.parseWithFallback(this.SelectorList,()=>this.Raw(!1,!0)),this.skipSC(),this.eat(Ge)),{type:"Scope",loc:this.getLocation(t,this.tokenStart),root:n,limit:e}}function fre(n){n.root&&(this.token(lt,"("),this.node(n.root),this.token(Ge,")")),n.limit&&(this.token(Ce,"to"),this.token(lt,"("),this.node(n.limit),this.token(Ge,")"))}const mre=Object.freeze(Object.defineProperty({__proto__:null,generate:fre,name:ure,parse:n5,structure:dre},Symbol.toStringTag,{value:"Module"})),pre="Selector",hre={children:[["TypeSelector","IdSelector","ClassSelector","AttributeSelector","PseudoClassSelector","PseudoElementSelector","Combinator"]]};function s5(){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 gre(n){this.children(n)}const xre=Object.freeze(Object.defineProperty({__proto__:null,generate:gre,name:pre,parse:s5,structure:hre},Symbol.toStringTag,{value:"Module"})),bre="SelectorList",vre="selector",yre={children:[["Selector","Raw"]]};function r5(){const n=this.createList();for(;!this.eof;){if(n.push(this.Selector()),this.tokenType===Hn){this.next();continue}break}return{type:"SelectorList",loc:this.getLocationFromList(n),children:n}}function wre(n){this.children(n,()=>this.token(Hn,","))}const Sre=Object.freeze(Object.defineProperty({__proto__:null,generate:wre,name:bre,parse:r5,structure:yre,walkContext:vre},Symbol.toStringTag,{value:"Module"})),Eh=92,o5=34,kre=39;function Wu(n){const e=n.length,t=n.charCodeAt(0),s=t===o5||t===kre?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===Eh){if(i===r){i!==e-1&&(o=n.substr(i+1));break}if(l=n.charCodeAt(++i),Ts(Eh,l)){const c=i-1,u=Oo(n,c);i=u-1,o+=Z1(n.substring(c+1,u))}else l===13&&n.charCodeAt(i+1)===10&&i++}else o+=n[i]}return o}function i5(n,e){const s=o5;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===Eh?(r+="\\"+n.charAt(i),o=!1):(o&&(fo(l)||Ro(l))&&(r+=" "),r+=n.charAt(i),o=!1)}return'"'+r+'"'}const jre="String",Nre={value:String};function a5(){return{type:"String",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:Wu(this.consume(Qn))}}function Cre(n){this.token(Qn,i5(n.value))}const _re=Object.freeze(Object.defineProperty({__proto__:null,generate:Cre,name:jre,parse:a5,structure:Nre},Symbol.toStringTag,{value:"Module"})),Tre=33;function Nw(){return this.Raw(null,!1)}const Ere="StyleSheet",Are="stylesheet",Pre={children:[["Comment","CDO","CDC","Atrule","Rule","Raw"]]};function l5(){const n=this.tokenStart,e=this.createList();let t;for(;!this.eof;){switch(this.tokenType){case Ct:this.next();continue;case ln:if(this.charCodeAt(this.tokenStart+2)!==Tre){this.next();continue}t=this.Comment();break;case zl:t=this.CDO();break;case zn:t=this.CDC();break;case Gt:t=this.parseWithFallback(this.Atrule,Nw);break;default:t=this.parseWithFallback(this.Rule,Nw)}e.push(t)}return{type:"StyleSheet",loc:this.getLocation(n,this.tokenStart),children:e}}function Ire(n){this.children(n)}const $re=Object.freeze(Object.defineProperty({__proto__:null,generate:Ire,name:Ere,parse:l5,structure:Pre,walkContext:Are},Symbol.toStringTag,{value:"Module"})),Rre="SupportsDeclaration",Ore={declaration:"Declaration"};function c5(){const n=this.tokenStart;this.eat(lt),this.skipSC();const e=this.Declaration();return this.eof||this.eat(Ge),{type:"SupportsDeclaration",loc:this.getLocation(n,this.tokenStart),declaration:e}}function Mre(n){this.token(lt,"("),this.node(n.declaration),this.token(Ge,")")}const Lre=Object.freeze(Object.defineProperty({__proto__:null,generate:Mre,name:Rre,parse:c5,structure:Ore},Symbol.toStringTag,{value:"Module"})),zre=42,Cw=124;function fp(){this.tokenType!==Ce&&this.isDelim(zre)===!1&&this.error("Identifier or asterisk is expected"),this.next()}const Dre="TypeSelector",Fre={name:String};function u5(){const n=this.tokenStart;return this.isDelim(Cw)?(this.next(),fp.call(this)):(fp.call(this),this.isDelim(Cw)&&(this.next(),fp.call(this))),{type:"TypeSelector",loc:this.getLocation(n,this.tokenStart),name:this.substrToCursor(n)}}function Ure(n){this.tokenize(n.name)}const Bre=Object.freeze(Object.defineProperty({__proto__:null,generate:Ure,name:Dre,parse:u5,structure:Fre},Symbol.toStringTag,{value:"Module"})),d5=43,f5=45,Ah=63;function ka(n,e){let t=0;for(let s=this.tokenStart+n;s<this.tokenEnd;s++){const r=this.charCodeAt(s);if(r===f5&&e&&t!==0)return ka.call(this,n+t+1,!1),-1;fo(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 Pc(n){let e=0;for(;this.isDelim(Ah);)++e>n&&this.error("Too many question marks"),this.next()}function Wre(n){this.charCodeAt(this.tokenStart)!==n&&this.error((n===d5?"Plus sign":"Hyphen minus")+" is expected")}function qre(){let n=0;switch(this.tokenType){case Je:if(n=ka.call(this,1,!0),this.isDelim(Ah)){Pc.call(this,6-n);break}if(this.tokenType===st||this.tokenType===Je){Wre.call(this,f5),ka.call(this,1,!1);break}break;case st:n=ka.call(this,1,!0),n>0&&Pc.call(this,6-n);break;default:if(this.eatDelim(d5),this.tokenType===Ce){n=ka.call(this,0,!0),n>0&&Pc.call(this,6-n);break}if(this.isDelim(Ah)){this.next(),Pc.call(this,5);break}this.error("Hex digit or question mark is expected")}}const Vre="UnicodeRange",Hre={value:String};function m5(){const n=this.tokenStart;return this.eatIdent("u"),qre.call(this),{type:"UnicodeRange",loc:this.getLocation(n,this.tokenStart),value:this.substrToCursor(n)}}function Kre(n){this.tokenize(n.value)}const Gre=Object.freeze(Object.defineProperty({__proto__:null,generate:Kre,name:Vre,parse:m5,structure:Hre},Symbol.toStringTag,{value:"Module"})),Zre=32,Ph=92,Yre=34,Xre=39,Jre=40,p5=41;function h5(n){const e=n.length;let t=4,s=n.charCodeAt(e-1)===p5?e-2:e-1,r="";for(;t<s&&Ro(n.charCodeAt(t));)t++;for(;t<s&&Ro(n.charCodeAt(s));)s--;for(let o=t;o<=s;o++){let i=n.charCodeAt(o);if(i===Ph){if(o===s){o!==e-1&&(r=n.substr(o+1));break}if(i=n.charCodeAt(++o),Ts(Ph,i)){const l=o-1,c=Oo(n,l);o=c-1,r+=Z1(n.substring(l+1,c))}else i===13&&n.charCodeAt(o+1)===10&&o++}else r+=n[o]}return r}function Qre(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===Zre||r===Ph||r===Yre||r===Xre||r===Jre||r===p5?(e+="\\"+n.charAt(s),t=!1):(t&&fo(r)&&(e+=" "),e+=n.charAt(s),t=!1)}return"url("+e+")"}const eoe="Url",toe={value:String};function g5(){const n=this.tokenStart;let e;switch(this.tokenType){case bn:e=h5(this.consume(bn));break;case et:this.cmpStr(this.tokenStart,this.tokenEnd,"url(")||this.error("Function name must be `url`"),this.eat(et),this.skipSC(),e=Wu(this.consume(Qn)),this.skipSC(),this.eof||this.eat(Ge);break;default:this.error("Url or Function is expected")}return{type:"Url",loc:this.getLocation(n,this.tokenStart),value:e}}function noe(n){this.token(bn,Qre(n.value))}const soe=Object.freeze(Object.defineProperty({__proto__:null,generate:noe,name:eoe,parse:g5,structure:toe},Symbol.toStringTag,{value:"Module"})),roe="Value",ooe={children:[[]]};function x5(){const n=this.tokenStart,e=this.readSequence(this.scope.Value);return{type:"Value",loc:this.getLocation(n,this.tokenStart),children:e}}function ioe(n){this.children(n)}const aoe=Object.freeze(Object.defineProperty({__proto__:null,generate:ioe,name:roe,parse:x5,structure:ooe},Symbol.toStringTag,{value:"Module"})),loe=Object.freeze({type:"WhiteSpace",loc:null,value:" "}),coe="WhiteSpace",uoe={value:String};function b5(){return this.eat(Ct),loe}function doe(n){this.token(Ct,n.value)}const foe=Object.freeze(Object.defineProperty({__proto__:null,generate:doe,name:coe,parse:b5,structure:uoe},Symbol.toStringTag,{value:"Module"})),v5=Object.freeze(Object.defineProperty({__proto__:null,AnPlusB:$ee,Atrule:Dee,AtrulePrelude:qee,AttributeSelector:Qee,Block:ite,Brackets:ute,CDC:pte,CDO:bte,ClassSelector:kte,Combinator:Ate,Comment:Mte,Condition:Bte,Declaration:sne,DeclarationList:lne,Dimension:fne,Feature:xne,FeatureFunction:Sne,FeatureRange:Tne,Function:$ne,GeneralEnclosed:Lne,Hash:Bne,IdSelector:Yne,Identifier:Hne,Layer:tse,LayerList:ose,MediaQuery:cse,MediaQueryList:mse,NestingSelector:bse,Nth:Sse,Number:Cse,Operator:Ase,Parentheses:Rse,Percentage:zse,PseudoClassSelector:Wse,PseudoElementSelector:Gse,Ratio:Jse,Raw:sre,Rule:cre,Scope:mre,Selector:xre,SelectorList:Sre,String:_re,StyleSheet:$re,SupportsDeclaration:Lre,TypeSelector:Bre,UnicodeRange:Gre,Url:soe,Value:aoe,WhiteSpace:foe},Symbol.toStringTag,{value:"Module"})),moe={generic:!0,cssWideKeywords:ex,...Tee,node:v5},poe=35,hoe=42,_w=43,goe=45,xoe=47,boe=117;function y5(n){switch(this.tokenType){case kt:return this.Hash();case Hn:return this.Operator();case lt:return this.Parentheses(this.readSequence,n.recognizer);case Kn:return this.Brackets(this.readSequence,n.recognizer);case Qn:return this.String();case st:return this.Dimension();case Pt:return this.Percentage();case Je:return this.Number();case et:return this.cmpStr(this.tokenStart,this.tokenEnd,"url(")?this.Url():this.Function(this.readSequence,n.recognizer);case bn:return this.Url();case Ce:return this.cmpChar(this.tokenStart,boe)&&this.cmpChar(this.tokenStart+1,_w)?this.UnicodeRange():this.Identifier();case rt:{const e=this.charCodeAt(this.tokenStart);if(e===xoe||e===hoe||e===_w||e===goe)return this.Operator();e===poe&&this.error("Hex or identifier is expected",this.tokenStart+1);break}}}const voe={getNode:y5},yoe=35,woe=38,Soe=42,koe=43,joe=47,Tw=46,Noe=62,Coe=124,_oe=126;function Toe(n,e){e.last!==null&&e.last.type!=="Combinator"&&n!==null&&n.type!=="Combinator"&&e.push({type:"Combinator",loc:null,name:" "})}function Eoe(){switch(this.tokenType){case Kn:return this.AttributeSelector();case kt:return this.IdSelector();case _n:return this.lookupType(1)===_n?this.PseudoElementSelector():this.PseudoClassSelector();case Ce:return this.TypeSelector();case Je:case Pt:return this.Percentage();case st:this.charCodeAt(this.tokenStart)===Tw&&this.error("Identifier is expected",this.tokenStart+1);break;case rt:{switch(this.charCodeAt(this.tokenStart)){case koe:case Noe:case _oe:case joe:return this.Combinator();case Tw:return this.ClassSelector();case Soe:case Coe:return this.TypeSelector();case yoe:return this.IdSelector();case woe:return this.NestingSelector()}break}}}const Aoe={onWhiteSpace:Toe,getNode:Eoe};function Poe(){return this.createSingleNodeList(this.Raw(null,!1))}function Ioe(){const n=this.createList();if(this.skipSC(),n.push(this.Identifier()),this.skipSC(),this.tokenType===Hn){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)===Ct){t.children.appendData({type:"WhiteSpace",loc:null,value:" "});break}}n.push(t)}return n}function Ew(n){return n!==null&&n.type==="Operator"&&(n.value[n.value.length-1]==="-"||n.value[n.value.length-1]==="+")}const $oe={getNode:y5,onWhiteSpace(n,e){Ew(n)&&(n.value=" "+n.value),Ew(e.last)&&(e.last.value+=" ")},expression:Poe,var:Ioe},Roe=Object.freeze(Object.defineProperty({__proto__:null,AtrulePrelude:voe,Selector:Aoe,Value:$oe},Symbol.toStringTag,{value:"Module"})),Ooe=new Set(["none","and","not","or"]),Moe={parse:{prelude(){const n=this.createList();if(this.tokenType===Ce){const e=this.substring(this.tokenStart,this.tokenEnd);Ooe.has(e.toLowerCase())||n.push(this.Identifier())}return n.push(this.Condition("container")),n},block(n=!1){return this.Block(n)}}},Loe={parse:{prelude:null,block(){return this.Block(!0)}}};function mp(n,e){return this.parseWithFallback(()=>{try{return n.call(this)}finally{this.skipSC(),this.lookupNonWSType(0)!==Ge&&this.error()}},e||(()=>this.Raw(null,!0)))}const Aw={layer(){this.skipSC();const n=this.createList(),e=mp.call(this,this.Layer);return(e.type!=="Raw"||e.value!=="")&&n.push(e),n},supports(){this.skipSC();const n=this.createList(),e=mp.call(this,this.Declaration,()=>mp.call(this,()=>this.Condition("supports")));return(e.type!=="Raw"||e.value!=="")&&n.push(e),n}},zoe={parse:{prelude(){const n=this.createList();switch(this.tokenType){case Qn:n.push(this.String());break;case bn:case et:n.push(this.Url());break;default:this.error("String or url() is expected")}return this.skipSC(),this.tokenType===Ce&&this.cmpStr(this.tokenStart,this.tokenEnd,"layer")?n.push(this.Identifier()):this.tokenType===et&&this.cmpStr(this.tokenStart,this.tokenEnd,"layer(")&&n.push(this.Function(null,Aw)),this.skipSC(),this.tokenType===et&&this.cmpStr(this.tokenStart,this.tokenEnd,"supports(")&&n.push(this.Function(null,Aw)),(this.lookupNonWSType(0)===Ce||this.lookupNonWSType(0)===lt)&&n.push(this.MediaQueryList()),n},block:null}},Doe={parse:{prelude(){return this.createSingleNodeList(this.LayerList())},block(){return this.Block(!1)}}},Foe={parse:{prelude(){return this.createSingleNodeList(this.MediaQueryList())},block(n=!1){return this.Block(n)}}},Uoe={parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}},Boe={parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}},Woe={parse:{prelude(){return this.createSingleNodeList(this.Scope())},block(n=!1){return this.Block(n)}}},qoe={parse:{prelude:null,block(n=!1){return this.Block(n)}}},Voe={parse:{prelude(){return this.createSingleNodeList(this.Condition("supports"))},block(n=!1){return this.Block(n)}}},Hoe={container:Moe,"font-face":Loe,import:zoe,layer:Doe,media:Foe,nest:Uoe,page:Boe,scope:Woe,"starting-style":qoe,supports:Voe};function Koe(){const n=this.createList();this.skipSC();e:for(;!this.eof;){switch(this.tokenType){case Ce:n.push(this.Identifier());break;case Qn:n.push(this.String());break;case Hn:n.push(this.Operator());break;case Ge:break e;default:this.error("Identifier, string or comma is expected")}this.skipSC()}return n}const yo={parse(){return this.createSingleNodeList(this.SelectorList())}},pp={parse(){return this.createSingleNodeList(this.Selector())}},Goe={parse(){return this.createSingleNodeList(this.Identifier())}},Zoe={parse:Koe},Ic={parse(){return this.createSingleNodeList(this.Nth())}},Yoe={dir:Goe,has:yo,lang:Zoe,matches:yo,is:yo,"-moz-any":yo,"-webkit-any":yo,where:yo,not:yo,"nth-child":Ic,"nth-last-child":Ic,"nth-last-of-type":Ic,"nth-of-type":Ic,slotted:pp,host:pp,"host-context":pp},Xoe=Object.freeze(Object.defineProperty({__proto__:null,AnPlusB:h_,Atrule:g_,AtrulePrelude:x_,AttributeSelector:v_,Block:w_,Brackets:S_,CDC:k_,CDO:j_,ClassSelector:N_,Combinator:C_,Comment:__,Condition:T_,Declaration:A_,DeclarationList:P_,Dimension:I_,Feature:$_,FeatureFunction:R_,FeatureRange:O_,Function:M_,GeneralEnclosed:L_,Hash:z_,IdSelector:F_,Identifier:D_,Layer:U_,LayerList:B_,MediaQuery:W_,MediaQueryList:q_,NestingSelector:V_,Nth:H_,Number:K_,Operator:G_,Parentheses:Z_,Percentage:Y_,PseudoClassSelector:X_,PseudoElementSelector:J_,Ratio:Q_,Raw:e5,Rule:t5,Scope:n5,Selector:s5,SelectorList:r5,String:a5,StyleSheet:l5,SupportsDeclaration:c5,TypeSelector:u5,UnicodeRange:m5,Url:g5,Value:x5,WhiteSpace:b5},Symbol.toStringTag,{value:"Module"})),Joe={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:Roe,atrule:Hoe,pseudo:Yoe,node:Xoe},Qoe={node:v5},eie=_ee({...moe,...Joe,...Qoe}),Pw=92;function Iw(n){const e=n.length-1;let t="";for(let s=0;s<n.length;s++){let r=n.charCodeAt(s);if(r===Pw){if(s===e)break;if(r=n.charCodeAt(++s),Ts(Pw,r)){const o=s-1,i=Oo(n,o);s=i-1,t+=Z1(n.substring(o+1,i))}else r===13&&n.charCodeAt(s+1)===10&&s++}else t+=n[s]}return t}const{tokenize:tie,parse:mfe,generate:pfe,lexer:hfe,createLexer:gfe,walk:xfe,find:bfe,findLast:vfe,findAll:yfe,toPlainObject:wfe,fromPlainObject:Sfe,fork:kfe}=eie,nie=4*1024*1024,mx=16*1024*1024,sie=ve({archiveVersion:Ke(1),files:ot(ve({path:ze().min(1).max(240),mime:ze().max(80),content:ze().max(mx)})).min(2).max(256)});function rie(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 w5(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 oie(n){if(n.length>mx||!/^(?:[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 $w(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(w5(r),!t.has(r))throw new Error("Stylesheet references an unavailable raster asset");return`url("${r}")`}function iie(n,e,t){var l,c;const s=[],r=[];if(tie(n,(u,d,f)=>{if(s.length>=2e5)throw new Error("Stylesheet exceeds its token limit");const m=n.slice(d,f);if(u===Ll||u===In)throw new Error("Malformed stylesheet resource");if(u===et||u===lt)r.push(Ge);else if(u===cn)r.push(On);else if(u===Kn)r.push(qn);else if([Ge,On,qn].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)===Ct||((f=s[u])==null?void 0:f.type)===ln;)u++;return u};for(let u=0;u<s.length;u++){const{type:d,value:f}=s[u];if(d===Gt&&["import","font-face"].includes(Iw(f.slice(1)).toLowerCase()))throw new Error("Stylesheet imports and font sources are unsupported");if(d===et){const m=Iw(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)!==Qn||((c=s[h])==null?void 0:c.type)!==Ge)throw new Error("Malformed stylesheet URL");o.push($w(Wu(s[p].value),e,t)),u=h;continue}}if(d===bn){if(!f.endsWith(")"))throw new Error("Malformed stylesheet URL");o.push($w(h5(f),e,t))}else if(d===Qn){if(f.length<2||f.at(-1)!==f[0])throw new Error("Unterminated stylesheet string");o.push(i5(Wu(f)))}else if(d===ln){if(!f.endsWith("*/"))throw new Error("Unterminated stylesheet comment");o.push(" ")}else o.push(f)}return o.join("")}async function aie(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>nie)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=sie.parse(JSON.parse(o.decode(s))),l=new Map,c=new Set;let u=s.byteLength;for(const x of i.files){if(w5(x.path),c.has(x.path.toLowerCase()))throw new Error("Duplicate package asset path");c.add(x.path.toLowerCase());const b=oie(x.content);if(u+=b.byteLength,u>mx)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((v,y)=>c.has(b.slice(0,y+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=CC(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(!rie(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?iie(o.decode(g.bytes),f.style,h):null,assets:p}}const lie="/api/plugins/shell/v1",Rw=1e4,cie=120;function uie(n){const{frame:e}=n,t=n.crypto??globalThis.crypto,s=n.now??(()=>performance.now());let r=x2(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 v=setTimeout(()=>C(new Error("Plugin runtime shell did not load")),Rw);const y=(P,I)=>{if(!(i||!m))try{m.port1.postMessage(P,I??[])}catch{C(new Error("Plugin message channel became unavailable"))}},k=(P=!0,I=!1)=>{for(const[O,R]of b)!P&&O===f||(R.abort(),b.delete(O),I&&T(O,"CANCELED","Plugin request was canceled"))};function j(){var P;if(!i){if(i=!0,clearTimeout(v),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",N),m.port1.close(),m.port2.close()}e.removeAttribute("src"),(P=n.onDispose)==null||P.call(n)}}function C(P){var I;i||(j(),(I=n.onError)==null||I.call(n,P))}function _(){if(i||!c||!h||u)return;u=!0,clearTimeout(v),v=setTimeout(()=>C(new Error("Plugin did not become ready within 10 seconds")),Rw);const P=h.assets.map(I=>({...I,bytes:I.bytes.slice(0)}));y({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){C(new Error("Plugin frame navigated or reloaded"));return}if(l=!0,!e.contentWindow||!(t!=null&&t.subtle)){C(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",N),m.port1.start(),e.contentWindow.postMessage({type:"cogpit-plugin-connect",nonce:p},"*",[m.port2])}catch{C(new Error("Unable to connect the plugin runtime"))}}}function N(){C(new Error("Plugin sent an unreadable message"))}function T(P,I,O){y({protocol:1,type:"error",id:P,error:{code:I,message:O}})}async function E(P){var O;if(b.has(P.id)||b.size>=Kt.outstandingRequests){C(new Error("Plugin exceeded its outstanding request limit"));return}if(P.method==="lifecycle.ready"){if(d){C(new Error("Plugin signaled readiness more than once"));return}d=!0,f=P.id}else if(!o){T(P.id,"RATE_LIMITED","Plugin panel is hidden");return}const I=new AbortController;b.set(P.id,I);try{const R=RC(P.method,await n.execute(P,I.signal));if(i||I.signal.aborted||b.get(P.id)!==I||(y(b2({protocol:1,type:"result",id:P.id,value:R})),i))return;P.method==="lifecycle.ready"&&(clearTimeout(v),(O=n.onReady)==null||O.call(n))}catch(R){if(i||I.signal.aborted)return;const $=R&&typeof R=="object"&&"code"in R?R.code:null,M=IC.includes($)?$:"UPSTREAM_FAILED";T(P.id,M,"The host could not complete this operation"),P.method==="lifecycle.ready"&&C(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>cie){C(new Error("Plugin exceeded its message rate limit"));return}try{const O=D1(P.data);if(!c){if(!O||typeof O!="object"||Array.isArray(O)||Object.keys(O).length!==2||O.type!=="cogpit-plugin-connected"||O.nonce!==p)throw new Error("Invalid plugin handshake");c=!0,_();return}if(O&&typeof O=="object"&&!Array.isArray(O)&&Object.keys(O).length===1&&O.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 R=b2(O);if(R.type==="cancel"){(I=b.get(R.id))==null||I.abort(),b.delete(R.id);return}if(R.type!=="request")throw new Error("Invalid plugin message direction");E(R)}catch(O){C(O instanceof Error?O:new Error("Invalid plugin message"))}}}return aie(n.payload,n.digest,t).then(P=>{i||(h=P,_())}).catch(P=>C(P instanceof Error?P:new Error("Plugin package could not be loaded"))),e.addEventListener("load",S),e.src=lie,{dispose:j,setActive(P){i||o===P||(o=P,o||k(!1,!0),u&&y({protocol:1,type:"event",event:"visibility",value:o}))},updateContext(P){if(i)return;const I=x2(P);if(JSON.stringify(I.project)!==JSON.stringify(r.project)){j();return}if(JSON.stringify(I)===JSON.stringify(r))return;const O=r;r=I,u&&(O.locale!==I.locale||O.reducedMotion!==I.reducedMotion?(k(!1,!0),y({protocol:1,type:"event",event:"context",value:{...I,visible:o}})):JSON.stringify(O.theme)!==JSON.stringify(I.theme)&&y({protocol:1,type:"event",event:"theme",value:I.theme}))}}}function die(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 N=r.current,T=uie({frame:t.current,payload:n.payload,digest:n.digest,context:N.context,active:N.active,execute:N.execute,onReady:()=>{var E;l({key:d,error:null,ready:!0}),(E=N.onReady)==null||E.call(N)},onError:E=>{var A;l({key:d,error:E.message,ready:!1}),(A=N.onError)==null||A.call(N,E)},onDispose:N.onDispose});return s.current=T,()=>{T.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 N,T;(N=s.current)==null||N.setActive(n.active??!0),(T=s.current)==null||T.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,v=n.title??"Plugin panel";let y;e[17]!==b.error||e[18]!==b.ready?(y=!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]=y):y=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",C=!b.ready||!!b.error||n.active===!1;let _;e[22]!==j||e[23]!==C?(_=a.jsx("iframe",{ref:t,title:j,sandbox:"allow-scripts",referrerPolicy:"no-referrer",className:"h-full w-full border-0",hidden:C}),e[22]=j,e[23]=C,e[24]=_):_=e[24];let S;return e[25]!==k||e[26]!==_||e[27]!==v||e[28]!==y?(S=a.jsxs("section",{className:"relative h-full min-h-0 w-full","aria-label":v,children:[y,k,_]}),e[25]=k,e[26]=_,e[27]=v,e[28]=y,e[29]=S):S=e[29],S}const fie=["--background","--foreground","--card","--card-foreground","--popover","--popover-foreground","--primary","--primary-foreground","--secondary","--secondary-foreground","--muted","--muted-foreground","--accent","--accent-foreground","--destructive","--destructive-foreground","--success","--success-foreground","--warning","--warning-foreground","--info","--info-foreground","--border","--input","--ring","--radius"];function Ow(){const n=document.documentElement,e=getComputedStyle(n),t={};for(const s of fie){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 mie(n,e,t,s){let r="";for(const o of(e==null?void 0:e.name.trim())??""){if(r.length+o.length>128)break;o.charCodeAt(0)>=32&&o.charCodeAt(0)!==127&&(r+=o)}return{...s,project:e&&n.permissions.context.includes("project.identity")?{id:e.id,name:r.trim()||"Project"}:null,visible:t}}function pie(){const n=q.c(2),[e,t]=w.useState(Ow);let s,r;return n[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>{const o=()=>{const c=Ow();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 hie(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 v=x.method==="composer.append"||x.method.startsWith("navigation."),y=AbortSignal.any([b,e.signal,...x.method==="lifecycle.ready"?[]:[t.signal],...v?[s.signal]:[]]);if(y.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,y);if(y.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,y),y.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,y);y.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 gie(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=()=>v.finish(!1),v={url:h.href,finish(y){t.current===v&&(t.current=null,p.removeEventListener("abort",b),r(null),y&&!p.aborted?g():x(Object.assign(new Error("Opening the link was canceled"),{code:"CANCELED"})))}};t.current=v,p.addEventListener("abort",b,{once:!0}),r(v)})},e[2]=l):l=e[2];const c=l;let u;e[3]!==s||e[4]!==n?(u=s?a.jsx(or,{open:!0,onOpenChange:m=>{var p;m||(p=t.current)==null||p.finish(!1)},children:a.jsxs(ir,{children:[a.jsxs(ar,{children:["Open link from ",n,"?"]}),a.jsx(lr,{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(yg,{children:[a.jsx(J,{variant:"outline",onClick:()=>{var m;return(m=t.current)==null?void 0:m.finish(!1)},children:"Cancel"}),a.jsx(J,{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 S5=()=>new URLSearchParams(window.location.search).get("pluginSafeMode")==="1",xie=n=>(window.addEventListener("popstate",n),()=>window.removeEventListener("popstate",n)),k5=()=>w.useSyncExternalStore(xie,S5,bie);function jfe(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 bie(){return!0}function vie(n){const e=q.c(20),t=k5();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(J,{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(Wt,{className:"size-4"}),e[7]=l):l=e[7];let c;e[8]!==n.closePanel||e[9]!==i?(c=a.jsx(J,{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(yie,{...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 yie(n){var p,h,g,x,b,v;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]=(v=n.project)==null?void 0:v.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 y;if(e[15]!==u.recent||e[16]!==s){let j;e[18]!==s?(j=C=>C!==s,e[18]=s,e[19]=j):j=e[19],y=[...u.recent.filter(j),s].slice(-3),e[15]=u.recent,e[16]=s,e[17]=y}else y=e[17];const k=y;if(e[20]!==u.entries||e[21]!==o||e[22]!==s||e[23]!==k){let j;e[25]!==k?(j=_=>k.includes(_.key),e[25]=k,e[26]=j):j=e[26],f=u.entries.filter(j);let C;e[27]!==s?(C=_=>_.key===s,e[27]=s,e[28]=C):C=e[28],f.some(C)||(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 y;e[33]!==s||e[34]!==n?(y=k=>a.jsx("div",{className:"h-full min-h-0",hidden:k.key!==s,children:a.jsx(wie,{...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]=y):y=e[35],m=f.map(y),e[29]=f,e[30]=s,e[31]=n,e[32]=m}else m=e[32];return m}function wie(n){var Q,ne,re;const e=q.c(66),{client:t,plugin:s,project:r,active:o,title:i,epoch:l,context:c}=n,u=pie(),{openExternal:d,dialog:f}=gie(s.manifest.name),[m]=w.useState(Sie),p=w.useRef(o),h=w.useRef(c.composePrompt),g=w.useRef(c.openSession),x=w.useRef(null);let b;e[0]!==((Q=c.session)==null?void 0:Q.sessionId)||e[1]!==c.sessionChangeKey?(b=JSON.stringify([(ne=c.session)==null?void 0:ne.sessionId,c.sessionChangeKey]),e[0]=(re=c.session)==null?void 0:re.sessionId,e[1]=c.sessionChangeKey,e[2]=b):b=e[2];const v=b,[y,k]=w.useState(null),[j,C]=w.useState(null);let _,S;e[3]!==o?(_=()=>{var se;p.current=o,(se=x.current)==null||se.setActive(o)},S=[o],e[3]=o,e[4]=_,e[5]=S):(_=e[4],S=e[5]),w.useLayoutEffect(_,S);let N;e[6]===Symbol.for("react.memo_cache_sentinel")?(N=()=>{var se;(se=x.current)==null||se.resetSession()},e[6]=N):N=e[6];let T;e[7]!==v?(T=[v],e[7]=v,e[8]=T):T=e[8],w.useLayoutEffect(N,T);let E,A;e[9]!==c.composePrompt?(E=()=>{h.current=c.composePrompt},A=[c.composePrompt],e[9]=c.composePrompt,e[10]=E,e[11]=A):(E=e[10],A=e[11]),w.useLayoutEffect(E,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 O=s.id,R=s.selectedDigest,$=(r==null?void 0:r.id)??null;let M;e[15]!==c.composePrompt||e[16]!==s.manifest.permissions.composer?(M=s.manifest.permissions.composer.includes("append")&&!!c.composePrompt,e[15]=c.composePrompt,e[16]=s.manifest.permissions.composer,e[17]=M):M=e[17];const z=M;let F;e[18]!==c.openSession||e[19]!==s.manifest.permissions.navigation?(F=s.manifest.permissions.navigation.includes("session")&&!!c.openSession,e[18]=c.openSession,e[19]=s.manifest.permissions.navigation,e[20]=F):F=e[20];const D=F,L=r?c.projectPath:null;let B;e[21]!==s.manifest.permissions.navigation?(B=s.manifest.permissions.navigation.includes("external"),e[21]=s.manifest.permissions.navigation,e[22]=B):B=e[22];const U=B;let W;e[23]!==z||e[24]!==U||e[25]!==D||e[26]!==t||e[27]!==m||e[28]!==R||e[29]!==d||e[30]!==O||e[31]!==$||e[32]!==L?(W=()=>{const se=hie({client:t,pluginId:O,digest:R,projectId:$,workspacePath:L,contextEpoch:m,active:p.current,...z?{appendDraft:oe=>{var ae;return(ae=h.current)==null?void 0:ae.call(h,oe)}}:{},...D?{openSession:(oe,ae)=>{var ie;return(ie=g.current)==null?void 0:ie.call(g,oe,ae)}}:{},...U?{openExternal:d}:{},onLoaded:(oe,ae)=>k({payload:oe,leaseId:ae,runtime:se}),onError:oe=>C(oe.message)});return x.current=se,()=>{se.dispose(),x.current=null}},e[23]=z,e[24]=U,e[25]=D,e[26]=t,e[27]=m,e[28]=R,e[29]=d,e[30]=O,e[31]=$,e[32]=L,e[33]=W):W=e[33];let V;if(e[34]!==z||e[35]!==U||e[36]!==D||e[37]!==t||e[38]!==m||e[39]!==R||e[40]!==l||e[41]!==d||e[42]!==O||e[43]!==$||e[44]!==L?(V=[t,O,R,$,l,m,z,U,d,D,L],e[34]=z,e[35]=U,e[36]=D,e[37]=t,e[38]=m,e[39]=R,e[40]=l,e[41]=d,e[42]=O,e[43]=$,e[44]=L,e[45]=V):V=e[45],w.useLayoutEffect(W,V),j){let se;return e[46]!==j?(se=a.jsx("p",{role:"alert",className:"p-4 text-sm text-destructive",children:j}),e[46]=j,e[47]=se):se=e[47],se}if(!y){let se;return e[48]===Symbol.for("react.memo_cache_sentinel")?(se=a.jsx("p",{role:"status",className:"p-4 text-sm text-muted-foreground",children:"Loading plugin…"}),e[48]=se):se=e[48],se}const H=y.payload,G=`${l}:${y.leaseId}`;let Z;e[49]!==o||e[50]!==s.manifest||e[51]!==u||e[52]!==r?(Z=mie(s.manifest,r,o,u),e[49]=o,e[50]=s.manifest,e[51]=u,e[52]=r,e[53]=Z):Z=e[53];const Y=i??s.manifest.name;let X;e[54]!==o||e[55]!==R||e[56]!==y.payload||e[57]!==y.runtime.execute||e[58]!==y.runtime.fail||e[59]!==G||e[60]!==Z||e[61]!==Y?(X=a.jsx(die,{payload:H,digest:R,activationKey:G,context:Z,active:o,title:Y,execute:y.runtime.execute,onError:y.runtime.fail}),e[54]=o,e[55]=R,e[56]=y.payload,e[57]=y.runtime.execute,e[58]=y.runtime.fail,e[59]=G,e[60]=Z,e[61]=Y,e[62]=X):X=e[62];let ee;return e[63]!==f||e[64]!==X?(ee=a.jsxs(a.Fragment,{children:[X,f]}),e[63]=f,e[64]=X,e[65]=ee):ee=e[65],ee}function Sie(){return Array.from(crypto.getRandomValues(new Uint8Array(16)),kie).join("")}function kie(n){return n.toString(16).padStart(2,"0")}function jie(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(Cie);const b=new URLSearchParams({dirName:n,fileName:e});return Re(`/api/usage-cost/session?${b}`,{signal:x.signal}).then(async v=>{if(!v.ok)throw new Error(`Cost scan failed (${v.status})`);const y=await v.json();i({summary:y,loading:!1,error:null})}).catch(v=>{x.signal.aborted||i(y=>({...y,loading:!1,error:v instanceof Error?v.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(Nie),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 Nie(n){return n+1}function Cie(n){return{...n,loading:!0,error:null}}function _ie(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 Tie(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 Eie(){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($n,{className:"h-4 w-24"}),a.jsx($n,{className:"h-10 w-32"}),a.jsx($n,{className:"h-3 w-44"})]}),t=a.jsx($n,{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($n,{className:"h-8 w-full"}),a.jsx($n,{className:"h-8 w-full"}),a.jsx($n,{className:"h-8 w-full"})]})]}),n[2]=s):s=n[2],s}function Aie(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(Wh,{}),o=a.jsx(on,{children:"Cost unavailable"}),e[0]=r,e[1]=o):(r=e[0],o=e[1]);let i;e[2]!==t?(i=a.jsx(Ut,{children:t}),e[2]=t,e[3]=i):i=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(Un,{"data-icon":"inline-start"}),e[4]=l):l=e[4];let c;e[5]!==s?(c=a.jsxs(J,{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(Ft,{variant:"destructive",className:"mt-2",children:[r,o,i,c]}),e[7]=i,e[8]=c,e[9]=u):u=e[9],u}function $c(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 Pie(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(Fk,{children:t.label}),e[0]=t.label,e[1]=o):o=e[1];let i;e[2]!==t.costUsd?(i=a.jsx(Uk,{children:()=>rs(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(vl,{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?jt(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 Iie(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(vl,{value:c,children:[a.jsx(Fk,{title:l.model,children:Do(l.model)}),a.jsx(Uk,{children:()=>l.costSource==="unpriced"?"Unpriced":rs(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:[jt(k1(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 $ie(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 Rie(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(Oie),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 Oie(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," · ",Do(n.model)]}),n.isSubagent&&a.jsx(Fe,{variant:"outline",children:"Agent"}),a.jsx("span",{className:"shrink-0 font-mono text-xs text-foreground tabular-nums",children:rs(n.costUsd)})]},`${n.timestamp}:${n.call}`)}function Mie(n){const e=q.c(74),{summary:t}=n;let s;e[0]!==t.provider?(s=mI(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=k1(t.totals),x=Tie(t);let b;e[10]!==t.calls?(b=$ie(t.calls),e[10]=t.calls,e[11]=b):b=e[11],d=b;const v=t.providerReportedRecords+t.modelPricedRecords>0;o="flex flex-col gap-5 pt-2";let y;e[12]===Symbol.for("react.memo_cache_sentinel")?(y=a.jsx("p",{id:"session-cost-heading",className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"API equivalent"}),e[12]=y):y=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=es(t.provider),e[15]=t.provider,e[16]=j):j=e[16];let C;e[17]!==j.displayName||e[18]!==k?(C=a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[y,a.jsxs(Fe,{variant:"outline",children:[k,j.displayName]})]}),e[17]=j.displayName,e[18]=k,e[19]=C):C=e[19];let _;e[20]!==v||e[21]!==t.costUsd?(_=v?rs(t.costUsd):"—",e[20]=v,e[21]=t.costUsd,e[22]=_):_=e[22];let S;e[23]!==_?(S=a.jsx("span",{className:"text-4xl font-semibold tracking-tight text-foreground tabular-nums",children:_}),e[23]=_,e[24]=S):S=e[24];const N=t.unpricedRecords>0?"secondary":"outline";let T;e[25]!==t?(T=_ie(t),e[25]=t,e[26]=T):T=e[26];let E;e[27]!==N||e[28]!==T?(E=a.jsx(Fe,{variant:N,children:T}),e[27]=N,e[28]=T,e[29]=E):E=e[29];let A;e[30]!==S||e[31]!==E?(A=a.jsxs("div",{className:"flex items-end justify-between gap-3",children:[S,E]}),e[30]=S,e[31]=E,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 O;e[33]!==t.records||e[34]!==P||e[35]!==I?(O=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]=O):O=e[36],e[37]!==C||e[38]!==A||e[39]!==O?(i=a.jsxs("section",{"aria-labelledby":"session-cost-heading",className:"flex flex-col gap-2",children:[C,A,O]}),e[37]=C,e[38]=A,e[39]=O,e[40]=i):i=e[40],e[41]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(Zt,{}),e[41]=l):l=e[41];const R=jt(g);let $;e[42]!==R?($=a.jsx($c,{label:"Processed tokens",value:R}),e[42]=R,e[43]=$):$=e[43];let M;e[44]!==t.cacheSavingsUsd?(M=rs(t.cacheSavingsUsd),e[44]=t.cacheSavingsUsd,e[45]=M):M=e[45];let z;e[46]!==M?(z=a.jsx($c,{label:"Cache savings",value:M}),e[46]=M,e[47]=z):z=e[47];let F;e[48]!==t.totals.cachedInputTokens?(F=jt(t.totals.cachedInputTokens),e[48]=t.totals.cachedInputTokens,e[49]=F):F=e[49];let D;e[50]!==F?(D=a.jsx($c,{label:"Cached input",value:F}),e[50]=F,e[51]=D):D=e[51];let L;e[52]!==t.totals.reasoningTokens?(L=jt(t.totals.reasoningTokens),e[52]=t.totals.reasoningTokens,e[53]=L):L=e[53];let B;e[54]!==L?(B=a.jsx($c,{label:"Reasoning",value:L}),e[54]=L,e[55]=B):B=e[55],e[56]!==$||e[57]!==z||e[58]!==D||e[59]!==B?(c=a.jsxs("dl",{className:"grid grid-cols-2 gap-x-4 gap-y-3",children:[$,z,D,B]}),e[56]=$,e[57]=z,e[58]=D,e[59]=B,e[60]=c):c=e[60],u=x.length>0&&a.jsxs(a.Fragment,{children:[a.jsx(Zt,{}),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(U=>a.jsx(Pie,{row:U,totalCost:t.costUsd},U.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(Zt,{}),a.jsx(Iie,{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(Zt,{}),a.jsx(Rie,{rows:d})]}),e[63]=d,e[64]=m):m=e[64];let p;e[65]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsxs(Ft,{children:[a.jsx(Wh,{}),a.jsx(on,{children:"How this is calculated"}),a.jsx(Ut,{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 Lie(n){const e=q.c(7),{dirName:t,fileName:s,revision:r}=n,{summary:o,loading:i,error:l,refresh:c}=jie(t,s,r);if(l){let d;return e[0]!==l||e[1]!==c?(d=a.jsx(Aie,{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(Eie,{}),e[3]=f):f=e[3],f}let d;return e[4]===Symbol.for("react.memo_cache_sentinel")?(d=a.jsx(is,{className:"mt-2 min-h-52",children:a.jsxs(as,{children:[a.jsx(Is,{variant:"icon",children:a.jsx(aA,{})}),a.jsx(ls,{children:"No transcript cost yet"}),a.jsx(cs,{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(Mie,{summary:o}),e[5]=o,e[6]=u):u=e[6],u}function zie(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 Die(n){const e=q.c(14),{turns:t,onJumpToTurn:s}=n;let r;e[0]!==t?(r=zie(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(wl,{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(J,{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 Mw(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||d1(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 v;e[6]!==c?(v=c==="running"?a.jsx(ht,{className:"size-3 shrink-0 animate-spin text-success","data-icon":"inline-start"}):c==="done"?a.jsx(Tr,{className:"size-3 shrink-0 text-success","data-icon":"inline-start"}):c==="failed"?a.jsx(po,{className:"size-3 shrink-0 text-destructive","data-icon":"inline-start"}):a.jsx(Qh,{className:"size-2.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),e[6]=c,e[7]=v):v=e[7];const y=v,k=i?"bg-accent":"hover:bg-muted/40";let j;e[8]!==k?(j=K("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 C;e[10]!==g?(C=a.jsx(Fe,{variant:"outline",children:g}),e[10]=g,e[11]=C):C=e[11];let _;e[12]!==l?(_=l&&a.jsx(Fe,{variant:"outline",children:"Background"}),e[12]=l,e[13]=_):_=e[13];let S;e[14]!==i?(S=i&&a.jsx(Fe,{children:"Viewing"}),e[14]=i,e[15]=S):S=e[15];const N=c==="running"?"active":c;let T;e[16]!==N?(T=a.jsx("span",{className:"ml-auto text-xs uppercase tracking-wide text-muted-foreground",children:N}),e[16]=N,e[17]=T):T=e[17];let E;e[18]!==y||e[19]!==T||e[20]!==C||e[21]!==_||e[22]!==S?(E=a.jsxs("div",{className:"flex items-center gap-1.5",children:[y,C,_,S,T]}),e[18]=y,e[19]=T,e[20]=C,e[21]=_,e[22]=S,e[23]=E):E=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(ru,{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(Gu,{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]!==E||e[32]!==A||e[33]!==P?(I=a.jsxs(J,{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:[E,A,P]}),e[29]=f,e[30]=m,e[31]=E,e[32]=A,e[33]=P,e[34]=I):I=e[34];let O;e[35]!==g||e[36]!==p?(O=p&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-sm",className:"m-1",onClick:p,"aria-label":`Stop ${g}`,children:a.jsx(Wt,{"data-icon":"inline-start"})}),e[35]=g,e[36]=p,e[37]=O):O=e[37];let R;return e[38]!==I||e[39]!==O||e[40]!==j?(R=a.jsxs("div",{className:j,children:[I,O]}),e[38]=I,e[39]=O,e[40]=j,e[41]=R):R=e[41],R}function Fie(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 Ih(n){return n.split(`
|
|
188
|
+
`).map(e=>e.trim()).find(Boolean)??""}function Uie(n){return n.name==="Task"||n.name==="Agent"}function Bie(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=Fie(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:Ih(((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(!Uie(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:Ih(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 Wie({session:n,sessionSource:e,bgAgents:t,onLoadSession:s}){const r=c1(),o=w.useMemo(()=>{if(!e)return null;const v=so(e.fileName);return v?{...v,dirName:e.dirName}:null},[e]),i=w.useMemo(()=>Bie(n,r),[n,r]),l=w.useRef(i);w.useEffect(()=>{!o&&i.length>0&&(l.current=i)},[o,i]);const c=o&&i.length===0?l.current:i,u=w.useMemo(()=>{if(o)return o.parentSessionId;if(e!=null&&e.fileName){const v=e.fileName.match(/^([^/]+)\.jsonl$/);if(v)return v[1]}return null},[o,e]),d=w.useMemo(()=>u?t.filter(v=>v.parentSessionId===u):t,[t,u]),f=w.useMemo(()=>new Map(c.map(v=>[v.agentId,v])),[c]),m=w.useMemo(()=>{const v=new Set(d.map(y=>y.agentId));return c.filter(y=>!v.has(y.agentId))},[d,c]),p=w.useMemo(()=>[...d].sort((v,y)=>y.modifiedAt-v.modifiedAt),[d]),h=w.useMemo(()=>[...m].reverse(),[m]),g=d.length+m.length;if(g===0)return null;const x=v=>{Re(`/api/claude/tasks/${encodeURIComponent(n.sessionId)}/${encodeURIComponent(v)}`,{method:"DELETE"})},b=(o==null?void 0:o.agentId)??null;return a.jsxs("section",{children:[a.jsxs(wl,{children:["Agents (",g,")"]}),o&&s&&a.jsxs(J,{type:"button",variant:"outline",size:"sm",onClick:()=>s(o.dirName,o.parentFileName),className:"mb-2 w-full justify-start",children:[a.jsx(at,{"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:[p.map(v=>{const y=Ih(v.preview??""),k=f.get(v.agentId);return a.jsx(Mw,{agentId:v.agentId,subagentType:(k==null?void 0:k.subagentType)??null,agentName:(k==null?void 0:k.agentName)??null,preview:(k==null?void 0:k.preview)||(y!==v.agentId?y:""),isViewing:b===v.agentId,isBackground:!0,status:v.isActive?"running":(k==null?void 0:k.status)==="failed"?"failed":"done",durationMs:k==null?void 0:k.durationMs,toolUseCount:k==null?void 0:k.toolUseCount,disabled:!s,onStop:v.isActive?()=>x(v.agentId):void 0,onClick:()=>s==null?void 0:s(v.dirName,v.fileName)},v.agentId)}),h.map(v=>{const y=!!s&&!!u&&!!e&&!v.agentId.startsWith("tool:");return a.jsx(Mw,{agentId:v.agentId,subagentType:v.subagentType,agentName:v.agentName,preview:v.preview,isViewing:b===v.agentId,isBackground:v.isBackground,status:v.status,durationMs:v.durationMs,toolUseCount:v.toolUseCount,disabled:!y,onClick:()=>{y&&s(e.dirName,`${u}/subagents/agent-${v.agentId}.jsonl`)}},v.agentId)})]})]})}function qie(n,e){return`${n.id}-${e}`}function Vie(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(wl,{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=wd(f.userMessage),h=r===m;return a.jsxs(J,{type:"button",variant:"ghost",onClick:()=>{o(m),s==null||s(m)},className:K("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?Ns(p,50):"(no message)"}),a.jsx("span",{className:"flex shrink-0 items-center gap-1",children:f.toolCalls.length>0&&a.jsx(Fe,{variant:"secondary",className:"font-normal",children:f.toolCalls.length})})]},qie(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 $h=new Map;let hp=null,gp=null;async function Hie(){try{const n=await Re("/api/usage-cost/rates");if(!n.ok)return $h;const e=await n.json();return new Map(Object.entries(e.rates??{}))}catch{return $h}}function Kie(){const[n,e]=w.useState(hp??$h);return w.useEffect(()=>{if(hp!==null)return;let t=!0;return gp??(gp=Hie().then(s=>(s.size>0&&(hp=s),gp=null,s))),gp.then(s=>{t&&e(s)}),()=>{t=!1}},[]),n}function Gie(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"?Ns(e.command,40):e.pattern&&typeof e.pattern=="string"?e.pattern:e.query&&typeof e.query=="string"?Ns(e.query,40):e.url&&typeof e.url=="string"?Ns(e.url,40):Ns(iD(n),40)}function Zie(n,e){return n.map(t=>{const s=t.tokenUsage;return!s||t.toolCalls.length===0?0:wq(e,t.model,s)/t.toolCalls.length})}function Yie(n,e){const t=new Map;for(let s=0;s<n.length;s++)for(const r of n[s].toolCalls){const o=Ki(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 Xie(n){const e=q.c(14),{turns:t,onJumpToTurn:s}=n,r=Kie();let o;e[0]!==r||e[1]!==t?(o=Zie(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=Yie(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(wl,{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(wn,{children:[a.jsxs(ds,{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(at,{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:rs(g.estimatedCost)}),a.jsx(Fe,{variant:"secondary",className:"font-normal",children:g.count})]})]}),a.jsx(Sn,{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:v,turnIndex:y}=x,k=Gie(v);return a.jsx("div",{children:a.jsxs(J,{type:"button",variant:"ghost",size:"xs",onClick:()=>s==null?void 0:s(y,v.id),className:K("h-auto w-full justify-start gap-1 px-1.5 py-0.5 text-left font-mono text-xs font-normal",v.isError?"text-destructive hover:bg-destructive/10":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:[v.isError&&a.jsx(Us,{className:"size-2.5 shrink-0 text-destructive","data-icon":"inline-start"}),a.jsx("span",{className:"truncate",children:k||v.id.slice(0,8)})]})},`${v.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 Jie(n){const e=q.c(19),{searchInputRef:t}=n,{state:s,dispatch:r}=hn(),{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(Ju,{"data-icon":"inline-start"}):a.jsx(dl,{"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(J,{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=y=>r({type:"SET_SEARCH_QUERY",value:y.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(Pr,{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(Ds,{align:"inline-start",children:a.jsx(Bn,{})}),e[13]=x):x=e[13];let b;e[14]!==g?(b=a.jsxs(Ar,{children:[g,x]}),e[14]=g,e[15]=b):b=e[15];let v;return e[16]!==b||e[17]!==m?(v=a.jsxs("div",{className:"sticky top-0 border-b bg-background px-3 py-3",children:[m,b]}),e[16]=b,e[17]=m,e[18]=v):v=e[18],v}const Qie=w.memo(function(e){const t=q.c(48),{onJumpToTurn:s,onToggleServer:r,onServersChanged:o,searchInputRef:i,onLoadSession:l,backgroundAgents:c}=e,{isMobile:u}=hn(),{session:d,sessionSource:f}=xt(),m=d,{turns:p}=m;let h;t[0]!==m.stats.totalCacheCreationTokens||t[1]!==m.stats.totalCacheReadTokens||t[2]!==m.stats.totalInputTokens||t[3]!==m.stats.totalOutputTokens||t[4]!==p.length?(h=[m.stats.totalInputTokens,m.stats.totalOutputTokens,m.stats.totalCacheCreationTokens,m.stats.totalCacheReadTokens,p.length],t[0]=m.stats.totalCacheCreationTokens,t[1]=m.stats.totalCacheReadTokens,t[2]=m.stats.totalInputTokens,t[3]=m.stats.totalOutputTokens,t[4]=p.length,t[5]=h):h=t[5];const g=h.join(":"),x=u?"mobile-scroll w-full flex-1":"w-full";let b;t[6]!==x?(b=K("h-full min-h-0 shrink-0 overflow-y-auto bg-background",x),t[6]=x,t[7]=b):b=t[7];let v;t[8]!==i?(v=i&&a.jsx(Jie,{searchInputRef:i}),t[8]=i,t[9]=v):v=t[9];const y=u?"p-4":"p-3";let k;t[10]!==y?(k=K(y),t[10]=y,t[11]=k):k=t[11];let j;t[12]===Symbol.for("react.memo_cache_sentinel")?(j=a.jsxs(Zk,{variant:"line",className:"grid w-full grid-cols-4",children:[a.jsx(da,{value:"activity",children:"Activity"}),a.jsx(da,{value:"agents",children:"Agents"}),a.jsx(da,{value:"cost",children:"Cost"}),a.jsx(da,{value:"issues",children:"Issues"})]}),t[12]=j):j=t[12];let C;t[13]!==s||t[14]!==p?(C=a.jsxs(fa,{value:"activity",className:"flex flex-col gap-6 pt-3",children:[a.jsx(Vie,{turns:p,onJumpToTurn:s}),a.jsx(Xie,{turns:p,onJumpToTurn:s})]}),t[13]=s,t[14]=p,t[15]=C):C=t[15];let _;t[16]!==o||t[17]!==r||t[18]!==m.cwd||t[19]!==p?(_=a.jsx(Qk,{cwd:m.cwd,turns:p,onToggleServer:r,onServersChanged:o}),t[16]=o,t[17]=r,t[18]=m.cwd,t[19]=p,t[20]=_):_=t[20];let S;t[21]!==c?(S=c??[],t[21]=c,t[22]=S):S=t[22];let N;t[23]!==l||t[24]!==m||t[25]!==f||t[26]!==S?(N=a.jsx(Wie,{session:m,sessionSource:f,bgAgents:S,onLoadSession:l}),t[23]=l,t[24]=m,t[25]=f,t[26]=S,t[27]=N):N=t[27];let T;t[28]!==N||t[29]!==_?(T=a.jsxs(fa,{value:"agents",className:"flex flex-col gap-6 pt-3",children:[_,N]}),t[28]=N,t[29]=_,t[30]=T):T=t[30];const E=(f==null?void 0:f.dirName)??null,A=(f==null?void 0:f.fileName)??null;let P;t[31]!==g||t[32]!==E||t[33]!==A?(P=a.jsx(fa,{value:"cost",className:"pt-3",children:a.jsx(Lie,{dirName:E,fileName:A,revision:g})}),t[31]=g,t[32]=E,t[33]=A,t[34]=P):P=t[34];let I;t[35]!==s||t[36]!==p?(I=a.jsx(fa,{value:"issues",className:"flex flex-col gap-6 pt-3",children:a.jsx(Die,{turns:p,onJumpToTurn:s})}),t[35]=s,t[36]=p,t[37]=I):I=t[37];let O;t[38]!==T||t[39]!==P||t[40]!==I||t[41]!==k||t[42]!==C?(O=a.jsxs(Gk,{defaultValue:"activity",className:k,children:[j,C,T,P,I]}),t[38]=T,t[39]=P,t[40]=I,t[41]=k,t[42]=C,t[43]=O):O=t[43];let R;return t[44]!==O||t[45]!==b||t[46]!==v?(R=a.jsxs("aside",{className:b,children:[v,O]}),t[44]=O,t[45]=b,t[46]=v,t[47]=R):R=t[47],R}),eae="default",tae="tmp-",nae=/^[a-z0-9][a-z0-9_-]{0,39}$/;function sae(n){return nae.test(n)}function rae(n){return n.startsWith(tae)}function Lw(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!==`
|
|
189
|
+
`&&(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 oae(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]===`
|
|
190
|
+
`){i+=2;continue}if(l==="#"){const d=n.indexOf(`
|
|
191
|
+
`,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!==`
|
|
192
|
+
`||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=Lw(n,i);if(!d||d.end===i)return o();i=d.end;continue}const u=Lw(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 ja="agent-browser",iae=new Map([["env",new Set(["-i","--ignore-environment","--"])],["command",new Set(["--"])],["exec",new Set(["--"])],["npx",new Set(["-y","--yes","--"])],["bunx",new Set(["--bun","--"])]]),aae=new Set(["echo","printf","rg","grep","cat","head","tail","wc","ls","stat","file","basename","dirname","cp","mv","rm","mkdir","rmdir","touch"]),lae=new Set(["commit","log","show","diff","status","add","grep","ls-files","rev-parse"]),cae=/^(?:if|then|else|elif|fi|while|until|for|select|case|esac|do|done|function|\{|\}|!)$/,uae=/^[A-Za-z_][A-Za-z_\d]*=/;function j5(n){return n.slice(n.lastIndexOf("/")+1)}function dae(n,e){var s,r;let t=0;for(;t<n.length;){const o=n[t];if(uae.test(e.slice(o.start,o.end))){t++;continue}if(!o.literal||cae.test(o.value))return null;const i=j5(o.value);if(i==="command"&&["-v","-V"].includes((s=n[t+1])==null?void 0:s.value))return-1;const l=iae.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 fae(n,e,t){const[s,...r]=n;if(r.some(l=>!l.literal))return null;let o=eae,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||!sae(o)||u!==c&&!/^(?:\s|\\\n)*$/.test(t.slice(c.end,u.start)))return null;i={start:c.start,end:u.end}}return{text:ja+t.slice(s.end,e).trimEnd(),binaryEnd:s.end,browser:o,sessionFlag:i}}function mae(n){var l;const{commands:e,complete:t}=oae(n),s=[],r=e.some(({words:c})=>c.some(({value:u})=>u.includes(ja)));if(!t)return{invocations:s,ambiguous:r||n.includes(ja)};const o=new Set(e.filter(({words:c})=>c.some(({value:u})=>u.includes(ja))).map(({pipeline:c})=>c));let i=!1;for(const{words:c,end:u,pipeline:d}of e){const f=dae(c,n);if(f===null){i||(i=r);continue}if(f<0)continue;const m=j5(c[f].value);if(m!==ja){!(aae.has(m)||m==="git"&&lae.has((l=c[f+1])==null?void 0:l.value))&&o.has(d)&&(i=!0);continue}const p=fae(c.slice(f),u,n);p===null?i=!0:s.push(p)}return{invocations:s,ambiguous:i}}function pae(n){return mae(n).invocations}const zw=120,hae=/(?:^|[._])exec_command$/;function gae(n){return n==="Bash"||hae.test(n)}function xae(n){return pM(n).filter(e=>gae(e.name)).map(e=>Fo(e.input))}function bae(n){for(const e of xae(n)){const[t]=pae(e);if(t===void 0||rae(t.browser))continue;const{text:s}=t;return{session:t.browser,command:s.length>zw?`${s.slice(0,zw-1)}…`:s,timestamp:n.timestamp,toolCallId:n.id,done:n.result!==null}}return null}function vae(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=bae(s[r]);if(o)return o}}return null}const Dw=1e4,yae=w.lazy(()=>Qe(()=>import("./ProjectFilesPanel-CO6Znhgi.js"),__vite__mapDeps([30,1,31,2,4,3])).then(n=>({default:n.ProjectFilesPanel}))),wae=w.lazy(()=>Qe(()=>import("./WorktreePanel-CldMZY3n.js"),__vite__mapDeps([32,1,2,3,4])).then(n=>({default:n.WorktreePanel}))),Sae=w.lazy(()=>Qe(()=>import("./index-QH_v3Ygj.js"),__vite__mapDeps([33,1,2,3,4])).then(n=>({default:n.BrowserPanel})));function px(){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(Cn,{}),"Loading panel…"]}),n[0]=e):e=n[0],e}function kae(n){const e=q.c(6),{context:t,closePanel:s}=n,r=j1(),o=r.projectFilesRoot??t.projectPath;if(!o)return null;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsx(px,{}),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(yae,{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 jae(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(xU,{session:t.session,sessionChangeKey:t.sessionChangeKey}),e[0]=t.session,e[1]=t.sessionChangeKey,e[2]=s):s=e[2],s}function Nae(){const n=q.c(7),e=j1();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(Qie,{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 Cae(n){const e=q.c(3);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=a.jsx(px,{}),e[0]=t):t=e[0];let s;return e[1]!==n?(s=a.jsx(w.Suspense,{fallback:t,children:a.jsx(Sae,{...n})}),e[1]=n,e[2]=s):s=e[2],s}function _ae(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=vae(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+Dw-Date.now();if(Number.isNaN(d)||d<=0)return;const f=setTimeout(()=>s(Tae),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>=Dw)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 Tae(n){return n+1}function Eae(n){const e=q.c(8),{closePanel:t}=n,s=j1();let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(px,{}),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(wae,{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 Aae={id:ii,workspacePanels:[{id:"worktrees",title:"Worktrees",icon:Qr,component:Eae,order:5,defaultSize:"36%",minSize:"320px",when:n=>n.supportsWorktrees===!0},{id:"project-files",title:"Project files",icon:lA,component:kae,order:10,defaultSize:"55%",minSize:"340px",maxSize:"75%",keepAlive:!0,when:n=>n.canAccessHostFiles&&n.projectPath!==null},{id:"browser",title:"Browser",icon:wi,component:Cae,indicator:_ae,order:15,defaultSize:"46%",minSize:"360px",maxSize:"75%",keepAlive:!0,when:n=>n.canAccessHostFiles},{id:"file-changes",title:"File changes",icon:fl,component:jae,order:20,defaultSize:"36%",minSize:"320px",when:n=>n.canAccessHostFiles&&n.hasFileChanges&&n.session!==null},{id:"session-info",title:"Session details",icon:cA,component:Nae,order:30,defaultSize:"36%",minSize:"320px",when:n=>n.session!==null}]},Pae=YB([Aae]);function Iae(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 $ae(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?Iae(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(v=>{b.signal.aborted||p({key:f,project:v})}).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 Fw={"cogpit.github":jS,"cogpit.clickup":fA,"cogpit.vercel":dA,"cogpit.cloudflare":uA};function Rae(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(vie,{...t,...s}):null,e[3]=t,e[4]=s,e[5]=r):r=e[5],r}function Oae(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(cJ,{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 Mae({client:n,status:e,activation:t,project:s,legacyPanels:r=Pae,openSettings:o}){const i=[...r];if(!(e!=null&&e.store.available)||e.safeMode||!t||S5())return i;const l=new Set(i.map(u=>u.id)),c=ai();for(const u of e.store.plugins)if(!(!u.enabled||u.scope.type==="projects"&&(!s||!u.scope.projectIds.includes(s.id)))&&yX(u.manifest,c,e.runtime,{allowPrerelease:u.manifest.publisher.startsWith("dev-")}).compatible)for(const d of u.manifest.contributes.panels){const f=No(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:Fw[u.id]??rg,order:d.order,defaultSize:d.defaultSize,minSize:d.minSize,maxSize:d.maxSize,keepAlive:!0,...Fw[u.id]?{indicator:Oae,indicatorProps:{runtime:m}}:{},component:Rae,componentProps:{runtime:m}})}return i.sort((u,d)=>(u.order??100)-(d.order??100)||u.title.localeCompare(d.title))}function N5(n){const e=q.c(11),{client:t,status:s,activation:r,projectPath:o,openSettings:i}=n,l=k5();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}=$ae(c),f=l||d?"":r;let m;return e[5]!==t||e[6]!==i||e[7]!==u||e[8]!==s||e[9]!==f?(m=Mae({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 Hd(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-background via-background/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 C5(n){const e=q.c(11),{projectPath:t}=n;let s;e[0]!==t?(s=t?wr(t):null,e[0]=t,e[1]=s):s=e[1];const r=s;let o;e[2]!==r?(o=r?a.jsxs(a.Fragment,{children:["What should we build in"," ",a.jsx("span",{children:r}),"?"]}):"What should we build?",e[2]=r,e[3]=o):o=e[3];let i;e[4]!==o?(i=a.jsx("h1",{className:"text-balance text-2xl font-semibold tracking-tight text-foreground",children:o}),e[4]=o,e[5]=i):i=e[5];let l;e[6]!==t?(l=t&&a.jsx("p",{className:"font-mono text-xs text-muted-foreground",children:rd(t)}),e[6]=t,e[7]=l):l=e[7];let c;return e[8]!==i||e[9]!==l?(c=a.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 text-center",children:[i,l]}),e[8]=i,e[9]=l,e[10]=c):c=e[10],c}function Lae(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=K(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 zae(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=K("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 Uw(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=K("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 Dae(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=TS,s="a",r=_S({className:K("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 Fae(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=K("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 Uae(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=K("[&>svg]:size-3.5",s),e[4]=s,e[5]=o):o=e[5];let i;e[6]!==t?(i=t??a.jsx(at,{}),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}function hx(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(""),v=w.useRef(null);let y;e[0]!==r?(y=function(){b(r||""),g(!0),requestAnimationFrame(()=>{var H;return(H=v.current)==null?void 0:H.select()})},e[0]=r,e[1]=y):y=e[1];const k=y;let j;e[2]===Symbol.for("react.memo_cache_sentinel")?(j=a.jsx("div",{className:"w-full"}),e[2]=j):j=e[2];let C;e[3]!==t?(C=a.jsx(Nd,{render:j,children:t}),e[3]=t,e[4]=C):C=e[4];let _;e[5]!==f||e[6]!==c||e[7]!==o||e[8]!==l||e[9]!==u||e[10]!==k?(_=(l||o||c||u)&&a.jsxs(To,{children:[l&&a.jsxs(jn,{onClick:k,children:[a.jsx(yr,{"data-icon":"inline-start"}),"Rename session"]}),o&&a.jsxs(jn,{onClick:o,children:[a.jsx(fs,{"data-icon":"inline-start"}),"Duplicate session"]}),u?a.jsxs(jn,{onClick:u,children:[a.jsx(og,{"data-icon":"inline-start"}),"Restore from archive"]}):c&&a.jsxs(jn,{onClick:c,disabled:f,children:[a.jsx(Ps,{"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]=_):_=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(Ei,{}),a.jsx(To,{children:a.jsxs(jn,{variant:"destructive",onClick:()=>p(!0),children:[a.jsx(Zu,{"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 N;e[18]!==_||e[19]!==S?(N=a.jsxs(Cd,{className:"min-w-44",children:[_,S]}),e[18]=_,e[19]=S,e[20]=N):N=e[20];let T;e[21]!==C||e[22]!==N?(T=a.jsxs(jd,{children:[C,N]}),e[21]=C,e[22]=N,e[23]=T):T=e[23];let E;e[24]===Symbol.for("react.memo_cache_sentinel")?(E=a.jsx(Pg,{children:"Delete session?"}),e[24]=E):E=e[24];let A;e[25]!==s?(A=a.jsxs(Eg,{children:[E,a.jsxs(Ig,{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(Rg,{size:"sm",children:"Cancel"}),e[27]=P):P=e[27];let I;e[28]!==i?(I=a.jsxs(Ag,{children:[P,a.jsx($g,{variant:"destructive",size:"sm",onClick:()=>{i==null||i(),p(!1)},children:"Delete"})]}),e[28]=i,e[29]=I):I=e[29];let O;e[30]!==A||e[31]!==I?(O=a.jsxs(Tg,{children:[A,I]}),e[30]=A,e[31]=I,e[32]=O):O=e[32];let R;e[33]!==m||e[34]!==O?(R=a.jsx(_g,{open:m,onOpenChange:p,children:O}),e[33]=m,e[34]=O,e[35]=R):R=e[35];let $;e[36]===Symbol.for("react.memo_cache_sentinel")?($=a.jsxs(ho,{children:[a.jsx(ar,{className:"text-foreground",children:"Rename session"}),a.jsx(lr,{className:"text-muted-foreground",children:"Give this session a custom name. Clear to reset to default."})]}),e[36]=$):$=e[36];let M;e[37]!==l||e[38]!==x?(M=V=>{V.preventDefault(),l==null||l(x),g(!1)},e[37]=l,e[38]=x,e[39]=M):M=e[39];let z;e[40]===Symbol.for("react.memo_cache_sentinel")?(z=a.jsx(zt,{htmlFor:"session-rename",children:"Session name"}),e[40]=z):z=e[40];let F;e[41]===Symbol.for("react.memo_cache_sentinel")?(F=V=>b(V.target.value),e[41]=F):F=e[41];let D;e[42]!==x||e[43]!==s?(D=a.jsxs(Lt,{children:[z,a.jsx(Nn,{id:"session-rename",ref:v,value:x,onChange:F,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(yg,{children:[a.jsx(J,{type:"button",variant:"ghost",size:"sm",onClick:()=>g(!1),children:"Cancel"}),a.jsx(J,{type:"submit",size:"sm",children:"Save"})]}),e[45]=L):L=e[45];let B;e[46]!==M||e[47]!==D?(B=a.jsxs(ir,{className:"sm:max-w-md",children:[$,a.jsxs("form",{className:"flex flex-col gap-4",onSubmit:M,children:[D,L]})]}),e[46]=M,e[47]=D,e[48]=B):B=e[48];let U;e[49]!==h||e[50]!==B?(U=a.jsx(or,{open:h,onOpenChange:g,children:B}),e[49]=h,e[50]=B,e[51]=U):U=e[51];let W;return e[52]!==R||e[53]!==U||e[54]!==T?(W=a.jsxs(a.Fragment,{children:[T,R,U]}),e[52]=R,e[53]=U,e[54]=T,e[55]=W):W=e[55],W}function _5(n){function e(){try{const i=localStorage.getItem(Rn(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(Rn(n),JSON.stringify(c)),t=c,r()}}}const Rh=_5("session-custom-names"),Oh=Rh.rename;function T5(){const n=q.c(2),e=w.useSyncExternalStore(Rh.subscribe,Rh.getSnapshot);let t;return n[0]!==e?(t={names:e,rename:Oh},n[0]=e,n[1]=t):t=n[1],t}function E5(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(Ds,{children:i?a.jsx(ht,{className:"animate-spin","aria-label":"Searching session history"}):a.jsx(Bn,{"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(Pr,{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(Ds,{align:"inline-end",children:a.jsx(kl,{"aria-label":"Clear search",onClick:()=>s(""),size:"icon-xs",children:a.jsx(Wt,{})})}),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(Ar,{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 A5(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(Us,{"aria-hidden":"true"}),o=a.jsx(on,{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(Ut,{children:t}),e[2]=t,e[3]=i):i=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(Un,{"data-icon":"inline-start"}),e[4]=l):l=e[4];let c;e[5]!==s?(c=a.jsx(oo,{children:a.jsxs(J,{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(Ft,{variant:"destructive",children:[r,o,i,c]}),e[7]=i,e[8]=c,e[9]=u):u=e[9],u}function P5(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(Zt,{}),a.jsxs("div",{className:"flex items-center gap-3 px-4 py-3.5",children:[a.jsx($n,{className:"size-8 shrink-0 rounded-md"}),a.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:[a.jsx($n,{className:"h-4 w-40 max-w-full"}),o&&a.jsx($n,{className:"h-3 w-72 max-w-full"}),a.jsx($n,{className:"h-3 w-52 max-w-full"})]}),a.jsx($n,{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 Fl(n){return n==="idle"||n==="completed"}function Kd(n){return Fl(n)?"text-success":n==="thinking"||n==="deferred"?"text-warning":"text-info"}const Jr={attention:"bg-warning",working:"bg-success ring-2 ring-success/30",idle:"bg-success/40"},Bae=/(?:https?:\/\/)?github\.com\/([\w.-]+)\/([\w.-]+)\/pull\/(\d+)/i,Wae=/^([\w.-]+(?:\/[\w.-]+)?)#(\d+)$/,qae=/(?:^|\s)#(\d+)(?=\s|$)/,Vae=/^(?:pr|pull\s+request)\s*#?(\d+)$/i;function Rc(n){const e=Number(n);return Number.isSafeInteger(e)&&e>0?e:null}function Hae(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 I5(n){const e=n.trim();if(!e)return null;const t=Bae.exec(e);if(t){const l=Rc(t[3]);return l===null?null:{number:l,repoHint:`${t[1]}/${t[2]}`.toLowerCase()}}const s=Wae.exec(e);if(s){const l=Rc(s[2]);return l===null?null:{number:l,repoHint:s[1].toLowerCase()}}const r=qae.exec(e);if(r){const l=Rc(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:Hae(c)}}const o=Vae.exec(e);if(!o)return null;const i=Rc(o[1]);return i===null?null:{number:i,repoHint:null}}function Bw(n,e){if(!n)return!1;const t=n.toLowerCase().replace(/\.git$/,"");return t===e||t.endsWith(`/${e}`)||e.endsWith(`/${t}`)}function Kae(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 Gae(n,e,t=[]){if(n.number!==e.number)return!1;const s=e.repoHint;return s?n.repo&&s.includes("/")?Bw(n.repo,s):Bw(n.repo,s)?!0:t.some(r=>Kae(r,s)):!0}function $5(n,e,t=[]){var o;const s=I5(e);if(s){const i=[n.cwd,n.projectShortName,...t];return((o=n.pullRequests)==null?void 0:o.some(l=>Gae(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 Zae=120*1e3;function R5(n){return n?Date.now()-new Date(n).getTime()<Zae:!1}function O5(n,e){const t=n.teamName?n.agentName:"",s=e||n.aiTitle||n.name||t||n.slug||n.firstUserMessage||n.customTitle;return s?Ns(s,70):Ns(n.sessionId,16)}function Ww(n){return n.trim().replace(/\s+/g," ").slice(0,40).toLowerCase()}function Yae(n,e){const t=(n.lastUserMessage||n.firstUserMessage||"").trim();return!t||Ww(t)===Ww(e)?null:Ns(t,220)}function Xae(n,e){return $5(n,e)}function Jae(n,e){if(!n||!e)return null;const t=new Date(e).getTime()-new Date(n).getTime();return t>=6e4?er(t):null}function Qae(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(`
|
|
193
|
+
`)}function ele(n){var t;const e=n.cwd?(t=od(n.cwd))==null?void 0:t.worktreeName:void 0;return e?{icon:mA,label:e,title:n.cwd}:n.gitBranch?{icon:Qr,label:n.gitBranch}:null}function tle(n,e){return n.agentStatus==="deferred"?"attention":e?Fl(n.agentStatus)?"idle":"working":null}function nle(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(Fe,{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=Fl(t.agentStatus);let o;e[1]!==t.agentPendingAgents||e[2]!==t.agentStatus||e[3]!==t.agentTerminalReason||e[4]!==t.agentToolName?(o=Pl(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=Kd(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=K("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(Fe,{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=x1(t.agentTerminalReason),e[16]=t.agentTerminalReason,e[17]=r):r=e[17];let o;return e[18]!==r?(o=a.jsx(Fe,{variant:"outline",className:"max-w-44 truncate text-warning",children:r}),e[18]=r,e[19]=o):o=e[19],o}return null}function xp(n){const e=q.c(9),{icon:t,title:s,className:r,children:o}=n;let i;e[0]!==r?(i=K("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 sle(n){const e=q.c(99),{session:t,customName:s,onSelect:r}=n,o=t.lastActivityAt||t.lastModified;let i,l;e[0]!==o||e[1]!==t?(i=R5(o),l=tle(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,v,y,k,j,C,_;if(e[4]!==s||e[5]!==c||e[6]!==o||e[7]!==i||e[8]!==r||e[9]!==t||e[10]!==u){const $=ele(t);let M;e[25]!==o||e[26]!==t.timestamp?(M=Jae(t.timestamp,o),e[25]=o,e[26]=t.timestamp,e[27]=M):M=e[27];const z=M,F=t.turnCount??0;let D,L;e[28]!==s||e[29]!==t?(L=O5(t,s),D=Yae(t,L),e[28]=s,e[29]=t,e[30]=D,e[31]=L):(D=e[30],L=e[31]);const B=D;g="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",d="button",f=r,e[32]!==t?(m=Qae(t),e[32]=t,e[33]=m):m=e[33],p="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 U;e[34]===Symbol.for("react.memo_cache_sentinel")?(U=a.jsx(kb,{className:"size-4"}),e[34]=U):U=e[34];let W;e[35]!==c?(W=c&&a.jsx("span",{"aria-hidden":"true","data-status-dot":c,className:K("absolute -top-1 -right-1 size-2 rounded-full ring-2 ring-card",Jr[c])}),e[35]=c,e[36]=W):W=e[36],e[37]!==W?(h=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:[U,W]}),e[37]=W,e[38]=h):h=e[38],j="flex min-w-0 flex-1 flex-col gap-1";let V;e[39]!==L?(V=a.jsx("span",{className:"truncate text-sm font-medium",children:L}),e[39]=L,e[40]=V):V=e[40];let H;e[41]!==u?(H=u&&a.jsxs(Fe,{variant:"outline",className:"shrink-0",children:[a.jsx(ki,{"data-icon":"inline-start"}),Ns(u,18)]}),e[41]=u,e[42]=H):H=e[42];let G;e[43]!==t.branchedFrom?(G=t.branchedFrom&&a.jsxs(Fe,{variant:"outline",className:"shrink-0",title:"Branched from another session",children:[a.jsx(sg,{"data-icon":"inline-start"}),"branch"]}),e[43]=t.branchedFrom,e[44]=G):G=e[44];let Z;e[45]!==i||e[46]!==t?(Z=a.jsx(nle,{session:t,live:i}),e[45]=i,e[46]=t,e[47]=Z):Z=e[47];let Y;e[48]!==o?(Y=o&&a.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:Fi(o)}),e[48]=o,e[49]=Y):Y=e[49];let X;e[50]!==Z||e[51]!==Y?(X=a.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-2",children:[Z,Y]}),e[50]=Z,e[51]=Y,e[52]=X):X=e[52],e[53]!==V||e[54]!==H||e[55]!==G||e[56]!==X?(C=a.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[V,H,G,X]}),e[53]=V,e[54]=H,e[55]=G,e[56]=X,e[57]=C):C=e[57],e[58]!==B?(_=B&&a.jsx("span",{className:"line-clamp-1 text-sm text-muted-foreground",children:B}),e[58]=B,e[59]=_):_=e[59],x="flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",e[60]!==t.model?(b=t.model&&a.jsx(Fe,{variant:"outline",children:Do(t.model)}),e[60]=t.model,e[61]=b):b=e[61],e[62]!==F?(v=F>0&&a.jsxs(xp,{icon:kb,children:[F," ",F===1?"turn":"turns"]}),e[62]=F,e[63]=v):v=e[63],e[64]!==z?(y=z&&a.jsx(xp,{icon:eo,title:"First prompt to last activity",children:z}),e[64]=z,e[65]=y):y=e[65],k=$&&a.jsx(xp,{icon:$.icon,className:"max-w-40 truncate",title:$.title,children:Ns($.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]=v,e[20]=y,e[21]=k,e[22]=j,e[23]=C,e[24]=_}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],v=e[19],y=e[20],k=e[21],j=e[22],C=e[23],_=e[24];let S;e[66]!==t.size?(S=hk(t.size),e[66]=t.size,e[67]=S):S=e[67];let N;e[68]!==S?(N=a.jsx("span",{children:S}),e[68]=S,e[69]=N):N=e[69];let T;e[70]!==N||e[71]!==x||e[72]!==b||e[73]!==v||e[74]!==y||e[75]!==k?(T=a.jsxs("span",{className:x,children:[b,v,y,k,N]}),e[70]=N,e[71]=x,e[72]=b,e[73]=v,e[74]=y,e[75]=k,e[76]=T):T=e[76];let E;e[77]!==T||e[78]!==j||e[79]!==C||e[80]!==_?(E=a.jsxs("span",{className:j,children:[C,_,T]}),e[77]=T,e[78]=j,e[79]=C,e[80]=_,e[81]=E):E=e[81];let A;e[82]!==d||e[83]!==f||e[84]!==m||e[85]!==p||e[86]!==h||e[87]!==E?(A=a.jsxs("button",{type:d,onClick:f,title:m,className:p,children:[h,E]}),e[82]=d,e[83]=f,e[84]=m,e[85]=p,e[86]=h,e[87]=E,e[88]=A):A=e[88];let P;e[89]!==t.matchedPullRequestNumber||e[90]!==t.pullRequests?(P=t.matchedPullRequestNumber?a.jsxs(Fe,{variant:"outline",children:["Matched #",t.matchedPullRequestNumber]}):a.jsx($l,{pullRequests:t.pullRequests,max:2,compact:!0}),e[89]=t.matchedPullRequestNumber,e[90]=t.pullRequests,e[91]=P):P=e[91];let I;e[92]===Symbol.for("react.memo_cache_sentinel")?(I=a.jsx(at,{className:"size-4 text-muted-foreground transition-transform group-hover:translate-x-0.5"}),e[92]=I):I=e[92];let O;e[93]!==P?(O=a.jsxs("span",{className:"flex shrink-0 items-center gap-2 pt-1.5",children:[P,I]}),e[93]=P,e[94]=O):O=e[94];let R;return e[95]!==g||e[96]!==A||e[97]!==O?(R=a.jsxs("div",{className:g,children:[A,O]}),e[95]=g,e[96]=A,e[97]=O,e[98]=R):R=e[98],R}function rle(n){const e=q.c(61),{selectedProject:t,sessions:s,sessionsTotal:r,sessionsLoading:o,searchLoading:i,searchFilter:l,setSearchFilter:c,filteredSessions:u,fetchError:d,onSelectSession:f,onNewSession:m,creatingSession:p,onDuplicateSession:h,onDeleteSession:g,onBack:x,onRetryFetch:b,loadMoreSessions:v}=n,{names:y,rename:k}=T5();let j;e[0]!==t.path?(j=wr(t.path),e[0]=t.path,e[1]=j):j=e[1];const C=j;let _;e[2]!==x?(_=a.jsx(Uw,{children:a.jsx(Dae,{render:a.jsx("button",{type:"button",onClick:x}),children:"Projects"})}),e[2]=x,e[3]=_):_=e[3];let S;e[4]===Symbol.for("react.memo_cache_sentinel")?(S=a.jsx(Uae,{}),e[4]=S):S=e[4];let N;e[5]!==C?(N=a.jsx(Uw,{className:"min-w-0",children:a.jsx(Fae,{className:"truncate",children:C})}),e[5]=C,e[6]=N):N=e[6];let T;e[7]!==_||e[8]!==N?(T=a.jsx(Lae,{children:a.jsxs(zae,{children:[_,S,N]})}),e[7]=_,e[8]=N,e[9]=T):T=e[9];let E;e[10]!==C?(E=a.jsx("h1",{className:"truncate text-2xl font-semibold tracking-tight",children:C}),e[10]=C,e[11]=E):E=e[11];let A;e[12]!==r?(A=a.jsx(Fe,{variant:"secondary",children:r}),e[12]=r,e[13]=A):A=e[13];let P;e[14]!==E||e[15]!==A?(P=a.jsxs("div",{className:"flex items-center gap-2",children:[E,A]}),e[14]=E,e[15]=A,e[16]=P):P=e[16];let I;e[17]!==t.path?(I=rd(t.path),e[17]=t.path,e[18]=I):I=e[18];let O;e[19]!==I?(O=a.jsx("p",{className:"truncate text-sm text-muted-foreground",children:I}),e[19]=I,e[20]=O):O=e[20];let R;e[21]!==O||e[22]!==P?(R=a.jsxs("header",{className:"flex min-w-0 flex-col gap-1",children:[P,O]}),e[21]=O,e[22]=P,e[23]=R):R=e[23];let $;e[24]!==l||e[25]!==i||e[26]!==c?($=a.jsx(E5,{value:l,onChange:c,placeholder:"Search sessions or PRs...",loading:i}),e[24]=l,e[25]=i,e[26]=c,e[27]=$):$=e[27];let M;e[28]!==p||e[29]!==m||e[30]!==t.dirName||e[31]!==t.path?(M=m&&a.jsxs(J,{size:"sm",disabled:p,onClick:()=>m(t.dirName,t.path),children:[p?a.jsx(Cn,{"data-icon":"inline-start"}):a.jsx(Qs,{"data-icon":"inline-start"}),"New Session"]}),e[28]=p,e[29]=m,e[30]=t.dirName,e[31]=t.path,e[32]=M):M=e[32];let z;e[33]!==$||e[34]!==M?(z=a.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[$,M]}),e[33]=$,e[34]=M,e[35]=z):z=e[35];let F;e[36]!==d||e[37]!==b?(F=d&&a.jsx(A5,{message:d,onRetry:b}),e[36]=d,e[37]=b,e[38]=F):F=e[38];let D;e[39]!==u||e[40]!==v||e[41]!==g||e[42]!==h||e[43]!==f||e[44]!==k||e[45]!==l||e[46]!==i||e[47]!==t.dirName||e[48]!==y||e[49]!==s||e[50]!==o||e[51]!==r?(D=(o||i)&&u.length===0?a.jsx(P5,{includeMessagePlaceholder:!0}):u.length===0?a.jsx(is,{className:"min-h-72 border",children:a.jsxs(as,{children:[a.jsx(Is,{variant:"icon",children:a.jsx(Di,{})}),a.jsx(ls,{children:l?"No sessions match your search":"No sessions yet"}),a.jsx(cs,{children:l?"Try #157, honest-cms #157, or paste a PR URL.":"Start a session in this project and it will appear here."})]})}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"overflow-hidden rounded-lg border bg-card",children:u.map((U,W)=>a.jsxs(w.Fragment,{children:[W>0&&a.jsx(Zt,{}),a.jsx(hx,{sessionLabel:O5(U),customName:y[U.sessionId],onRename:V=>k(U.sessionId,V),onDuplicate:h?()=>h(t.dirName,U.fileName):void 0,onDelete:g?()=>g(t.dirName,U.fileName):void 0,children:a.jsx(sle,{session:U,customName:y[U.sessionId],onSelect:()=>f(t.dirName,U.fileName)})})]},U.fileName))}),s.length<r&&!l&&a.jsx("div",{className:"flex justify-center",children:a.jsxs(J,{variant:"outline",size:"sm",disabled:o,onClick:v,children:[o&&a.jsx(Cn,{"data-icon":"inline-start"}),o?"Loading...":"Load more sessions"]})})]}),e[39]=u,e[40]=v,e[41]=g,e[42]=h,e[43]=f,e[44]=k,e[45]=l,e[46]=i,e[47]=t.dirName,e[48]=y,e[49]=s,e[50]=o,e[51]=r,e[52]=D):D=e[52];let L;e[53]!==z||e[54]!==F||e[55]!==D?(L=a.jsxs("section",{className:"flex flex-col gap-4","aria-label":"Sessions",children:[z,F,D]}),e[53]=z,e[54]=F,e[55]=D,e[56]=L):L=e[56];let B;return e[57]!==R||e[58]!==L||e[59]!==T?(B=a.jsx(yl,{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:[T,R,L]})}),e[57]=R,e[58]=L,e[59]=T,e[60]=B):B=e[60],B}function qu(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=ml(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=K("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 M5(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=K("w-full",o),e[2]=o,e[3]=b):b=e[3];let v;e[4]!==b?(v=a.jsx("div",{className:b}),e[4]=b,e[5]=v):v=e[5];let y;e[6]!==t||e[7]!==v?(y=a.jsx(Nd,{render:v,children:t}),e[6]=t,e[7]=v,e[8]=y):y=e[8];let k;e[9]===Symbol.for("react.memo_cache_sentinel")?(k=a.jsx(yr,{"data-icon":"inline-start"}),e[9]=k):k=e[9];let j;e[10]!==x?(j=a.jsx(To,{children:a.jsxs(jn,{onClick:x,children:[k,"Rename project"]})}),e[10]=x,e[11]=j):j=e[11];let C;e[12]!==u||e[13]!==c?(C=c&&a.jsxs(a.Fragment,{children:[a.jsx(Ei,{}),a.jsx(To,{children:a.jsxs(jn,{onClick:c,disabled:u===0,children:[a.jsx(Ps,{"data-icon":"inline-start"}),u>0?`Archive ${u} idle ${u===1?"session":"sessions"}`:"Archive idle sessions"]})})]}),e[12]=u,e[13]=c,e[14]=C):C=e[14];let _;e[15]!==j||e[16]!==C?(_=a.jsxs(Cd,{className:"min-w-44",children:[j,C]}),e[15]=j,e[16]=C,e[17]=_):_=e[17];let S;e[18]!==y||e[19]!==_?(S=a.jsxs(jd,{children:[y,_]}),e[18]=y,e[19]=_,e[20]=S):S=e[20];let N;e[21]===Symbol.for("react.memo_cache_sentinel")?(N=a.jsxs(ho,{children:[a.jsx(ar,{className:"text-foreground",children:"Rename project"}),a.jsx(lr,{className:"text-muted-foreground",children:"Give this project a custom name. Clear to reset to default."})]}),e[21]=N):N=e[21];let T;e[22]!==i||e[23]!==m?(T=M=>{M.preventDefault(),i(m),f(!1)},e[22]=i,e[23]=m,e[24]=T):T=e[24];let E;e[25]===Symbol.for("react.memo_cache_sentinel")?(E=a.jsx(zt,{htmlFor:"project-rename",children:"Project name"}),e[25]=E):E=e[25];let A;e[26]===Symbol.for("react.memo_cache_sentinel")?(A=M=>p(M.target.value),e[26]=A):A=e[26];let P;e[27]!==s||e[28]!==m?(P=a.jsxs(Lt,{children:[E,a.jsx(Nn,{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(yg,{children:[a.jsx(J,{type:"button",variant:"ghost",size:"sm",onClick:()=>f(!1),children:"Cancel"}),a.jsx(J,{type:"submit",size:"sm",children:"Save"})]}),e[30]=I):I=e[30];let O;e[31]!==T||e[32]!==P?(O=a.jsxs(ir,{className:"sm:max-w-md",children:[N,a.jsxs("form",{className:"flex flex-col gap-4",onSubmit:T,children:[P,I]})]}),e[31]=T,e[32]=P,e[33]=O):O=e[33];let R;e[34]!==d||e[35]!==O?(R=a.jsx(or,{open:d,onOpenChange:f,children:O}),e[34]=d,e[35]=O,e[36]=R):R=e[36];let $;return e[37]!==S||e[38]!==R?($=a.jsxs(a.Fragment,{children:[S,R]}),e[37]=S,e[38]=R,e[39]=$):$=e[39],$}const Mh=_5("project-custom-names"),ole=Mh.rename;function L5(){const n=q.c(2),e=w.useSyncExternalStore(Mh.subscribe,Mh.getSnapshot);let t;return n[0]!==e?(t={names:e,rename:ole},n[0]=e,n[1]=t):t=n[1],t}function ile(n){const e=q.c(45),{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)R5(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}=L5();let x;e:{if(!i){x=t;break e}let R;if(e[2]!==h||e[3]!==t||e[4]!==i){const $=i.toLowerCase();R=t.filter(M=>{var z;return M.path.toLowerCase().includes($)||M.shortName.toLowerCase().includes($)||((z=h[M.dirName])==null?void 0:z.toLowerCase().includes($))}),e[2]=h,e[3]=t,e[4]=i,e[5]=R}else R=e[5];x=R}const b=x;let v;e[6]===Symbol.for("react.memo_cache_sentinel")?(v=a.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Projects"}),e[6]=v):v=e[6];let y;e[7]!==t.length?(y=a.jsxs("div",{className:"flex items-center gap-2",children:[v,a.jsx(Fe,{variant:"secondary",children:t.length})]}),e[7]=t.length,e[8]=y):y=e[8];let k;e[9]===Symbol.for("react.memo_cache_sentinel")?(k=a.jsx("p",{className:"text-sm text-muted-foreground",children:"Open a project to browse and resume its sessions."}),e[9]=k):k=e[9];let j;e[10]!==y?(j=a.jsxs("header",{className:"flex flex-col gap-1",children:[y,k]}),e[10]=y,e[11]=j):j=e[11];let C;e[12]!==i||e[13]!==l?(C=a.jsx(E5,{value:i,onChange:l,placeholder:"Filter projects..."}),e[12]=i,e[13]=l,e[14]=C):C=e[14];const _=o&&"animate-spin";let S;e[15]!==_?(S=K(_),e[15]=_,e[16]=S):S=e[16];let N;e[17]!==S?(N=a.jsx(Un,{"data-icon":"inline-start",className:S}),e[17]=S,e[18]=N):N=e[18];let T;e[19]!==f||e[20]!==o||e[21]!==N?(T=a.jsxs(J,{variant:"outline",size:"sm",onClick:f,disabled:o,"aria-label":"Refresh projects",children:[N,"Refresh"]}),e[19]=f,e[20]=o,e[21]=N,e[22]=T):T=e[22];let E;e[23]!==T||e[24]!==C?(E=a.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[C,T]}),e[23]=T,e[24]=C,e[25]=E):E=e[25];let A;e[26]!==c||e[27]!==f||e[28]!==u?(A=c&&!u&&a.jsx(A5,{message:c,onRetry:f}),e[26]=c,e[27]=f,e[28]=u,e[29]=A):A=e[29];let P;e[30]!==p||e[31]!==b||e[32]!==r||e[33]!==d||e[34]!==h||e[35]!==g||e[36]!==i?(P=r?a.jsx(P5,{}):b.length===0?a.jsx(is,{className:"min-h-72 border",children:a.jsxs(as,{children:[a.jsx(Is,{variant:"icon",children:a.jsx(Si,{})}),a.jsx(ls,{children:i?"No projects match your search":"No projects yet"}),a.jsx(cs,{children:i?"Try a project name or path.":"Start Claude Code, Codex, or Copilot and its project will appear here."})]})}):a.jsx("div",{className:"overflow-hidden rounded-lg border bg-card",children:b.map((R,$)=>{const M=p[R.dirName]||0,z=h[R.dirName],F=pI(sn(R.dirName));return a.jsxs(w.Fragment,{children:[$>0&&a.jsx(Zt,{}),a.jsx(M5,{projectLabel:wr(R.path),customName:z,onRename:D=>g(R.dirName,D),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(qu,{projectPath:R.path,className:"size-4",fallback:a.jsx(Si,{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:z||wr(R.path)}),F&&a.jsx(Fe,{variant:"outline",className:"h-5 shrink-0 px-1.5 text-[10px]",children:F})]}),a.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:rd(R.path)})]})]}),a.jsxs("span",{className:"flex items-center gap-4 pl-11 text-sm text-muted-foreground sm:pl-0",children:[M>0&&a.jsxs(Fe,{variant:"secondary",children:[a.jsx("span",{"aria-hidden":"true","data-icon":"inline-start",className:"size-1.5 rounded-full bg-success"}),M," 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:Fi(R.lastModified)}),a.jsx(at,{className:"size-4 shrink-0 transition-transform group-hover:translate-x-0.5"})]})]})})]},R.dirName)})}),e[30]=p,e[31]=b,e[32]=r,e[33]=d,e[34]=h,e[35]=g,e[36]=i,e[37]=P):P=e[37];let I;e[38]!==E||e[39]!==A||e[40]!==P?(I=a.jsxs("section",{className:"flex flex-col gap-4","aria-label":"Projects",children:[E,A,P]}),e[38]=E,e[39]=A,e[40]=P,e[41]=I):I=e[41];let O;return e[42]!==I||e[43]!==j?(O=a.jsx(yl,{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:[j,I]})}),e[42]=I,e[43]=j,e[44]=O):O=e[44],O}const ale=250,lle=400,qw={results:null,loading:!1,error:null};function z5(n,e){const t=w.useMemo(()=>I5(n),[n]),[s,r]=w.useState(0),[o,i]=w.useState(qw);w.useEffect(()=>{if(!t){i(qw);return}const c=new AbortController;i({results:null,loading:!0,error:null});let u=null;const d=async()=>{const m=new URLSearchParams({search:n.trim(),limit:"200"});e&&m.set("project",e);try{const p=await Re(`/api/active-sessions?${m}`,{signal:c.signal});if(!p.ok)throw new Error(`Search failed (${p.status})`);const h=await p.json();if(c.signal.aborted)return;const g=Number(p.headers.get("X-Cogpit-PR-Index-Pending")??"0");if(Number.isFinite(g)&&g>0){u=setTimeout(()=>{d()},lle);return}i({results:Array.isArray(h)?h:[],loading:!1,error:null})}catch(p){if(c.signal.aborted)return;i({results:[],loading:!1,error:p instanceof Error?p.message:"Search failed"})}},f=setTimeout(()=>{d()},ale);return()=>{clearTimeout(f),u&&clearTimeout(u),c.abort()}},[e,t,n,s]);const l=w.useCallback(()=>r(c=>c+1),[]);return{...o,active:t!==null,refresh:l}}const cle=w.memo(function({onSelectSession:e,onNewSession:t,creatingSession:s,selectedProjectDirName:r,onSelectProject:o,onDuplicateSession:i,onDeleteSession:l}){const[c]=w.useState(()=>({projects:bu(gr.projects),activeSessions:bu(gr.activeSessions)})),[u,d]=w.useState(c.projects??[]),[f,m]=w.useState(c.activeSessions??[]),[p,h]=w.useState(c.projects===void 0),[g,x]=w.useState(!1),[b,v]=w.useState([]),[y,k]=w.useState(0),[j,C]=w.useState(1),[_,S]=w.useState(!1),[N,T]=w.useState(""),[E,A]=w.useState(null),P=w.useRef(0),I=w.useRef(null),O=w.useCallback(async(U=!1)=>{U&&x(!0);try{const[W,V]=await Promise.all([Re("/api/projects"),Re("/api/active-sessions")]);if(!W.ok||!V.ok)throw new Error("Failed to fetch dashboard data");const H=await W.json(),G=await V.json(),Z=Array.isArray(H)?H:[],Y=Array.isArray(G)?G:[];d(Z),m(Y),Aa(gr.projects,Z),Aa(gr.activeSessions,Y),A(null)}catch(W){A(W instanceof Error?W.message:"Failed to load data")}finally{h(!1),x(!1)}},[]);w.useEffect(()=>{O()},[O]);const R=w.useCallback(async(U,W=1,V=!1)=>{var Y;const H=++P.current;(Y=I.current)==null||Y.abort();const G=new AbortController;I.current=G;const Z=()=>H===P.current;if(S(!0),A(null),!V){const X=YL(U);X?(v(X.sessions),k(X.total),C(1)):v([])}try{const X=await Re(`/api/sessions/${encodeURIComponent(U)}?page=${W}&limit=20`,{signal:G.signal});if(!X.ok)throw new Error(`Failed to load sessions (${X.status})`);const ee=await X.json();if(!Z())return;const Q=Array.isArray(ee.sessions)?ee.sessions:[],ne=typeof ee.total=="number"?ee.total:Q.length;v(re=>V?[...re,...Q]:Q),k(ne),C(W),V||XL(U,{sessions:Q,total:ne})}catch(X){if(!Z()||G.signal.aborted)return;A(X instanceof Error?X.message:"Failed to load sessions")}finally{Z()&&(I.current=null,S(!1))}},[]);w.useEffect(()=>{var U;if(!r){P.current+=1,(U=I.current)==null||U.abort(),I.current=null,v([]),k(0),C(1),T(""),S(!1);return}T(""),R(r)},[r,R]),w.useEffect(()=>()=>{var U;P.current+=1,(U=I.current)==null||U.abort()},[]);const $=w.useMemo(()=>{if(!r)return null;const U=u.find(V=>V.dirName===r);if(U)return U;const W=Rs(r);return{dirName:r,path:W,shortName:wr(W),sessionCount:y,lastModified:null}},[r,u,y]),M=w.useCallback(()=>{o==null||o(null)},[o]),z=w.useCallback(()=>{r&&R(r,j+1,!0)},[r,j,R]),F=z5(r?N:"",r??void 0),D=w.useMemo(()=>N?b.filter(U=>Xae(U,N)):b,[b,N]),L=F.results??D;function B(U,W){l==null||l(U,W),v(V=>V.filter(H=>H.fileName!==W)),k(V=>V-1)}return $?a.jsx(rle,{selectedProject:$,sessions:b,sessionsTotal:y,sessionsLoading:_,searchLoading:F.loading,searchFilter:N,setSearchFilter:T,filteredSessions:L,fetchError:F.error??E,onSelectSession:e,onNewSession:t,creatingSession:s,onDuplicateSession:i,onDeleteSession:B,onBack:M,onRetryFetch:()=>{if(F.error){F.refresh();return}A(null),r&&R(r)},loadMoreSessions:z}):a.jsx(ile,{projects:u,activeSessions:f,loading:p,refreshing:g,searchFilter:N,setSearchFilter:T,fetchError:E,selectedProjectDirName:r??null,onSelectProject:o,onRefresh:()=>O(!0)})});async function D5(n,e,t){return(await rr(`/api/permissions/${encodeURIComponent(n)}/respond`,{requestId:e,behavior:t})).ok}async function ule(n,e){return(await rr(`/api/permissions/${encodeURIComponent(n)}/respond-all`,{behavior:e})).ok}function dle(n,e,t){return kg("/api/elicitation-answer",{sessionId:n,requestId:e,...t})}function fle(n,e,t){return kg("/api/user-dialog-answer",{sessionId:n,requestId:e,choice:t})}const mle=3e3,F5=w.createContext(null);async function bp(n,e){try{const t=await Re(n);if(!t.ok)return;const s=await t.text();return s===e.current?void 0:(e.current=s,JSON.parse(s))}catch{return}}function la(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 Oc(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 ple({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=w.useCallback(async()=>{const[A,P,I]=await Promise.all([bp("/api/permissions",p),bp("/api/user-questions",h),bp("/api/agent-prompts",g)]);A&&(t(la(A.bySession)),d(new Set(la(A.plansBySession).keys()))),P&&r(la(P.bySession)),I&&(i(la(I.elicitationsBySession)),c(la(I.dialogsBySession)))},[]);w.useEffect(()=>{const A=()=>{document.visibilityState==="visible"&&x()};A();const P=setInterval(A,mle);return document.addEventListener("visibilitychange",A),()=>{clearInterval(P),document.removeEventListener("visibilitychange",A)}},[x]);const b=w.useCallback(async(A,P)=>{m(I=>new Set(I).add(A));try{return await P()}finally{m(I=>{const O=new Set(I);return O.delete(A),O}),x()}},[x]),v=w.useCallback((A,P,I)=>b(P,async()=>{await D5(A,P,I).catch(()=>!1)&&(t(R=>Oc(R,A,$=>$.requestId===P)),p.current="")}),[b]),y=w.useCallback((A,P,I)=>b(P,async()=>{const O=await jg(A,P,I);return O.ok&&(r(R=>Oc(R,A,$=>$.toolUseId===P)),h.current=""),O}),[b]),k=w.useCallback((A,P,I)=>b(P,async()=>{const O=await dle(A,P,I);return O.ok&&(i(R=>Oc(R,A,$=>$.requestId===P)),g.current=""),O}),[b]),j=w.useCallback((A,P,I)=>b(P,async()=>{const O=await fle(A,P,I);return O.ok&&(c(R=>Oc(R,A,$=>$.requestId===P)),g.current=""),O}),[b]),C=w.useMemo(()=>new Set(e.keys()),[e]),_=w.useMemo(()=>new Set(s.keys()),[s]),S=w.useMemo(()=>new Set(o.keys()),[o]),N=w.useMemo(()=>new Set(l.keys()),[l]),T=w.useCallback(()=>{x()},[x]),E=w.useMemo(()=>({permissionsBySession:e,questionsBySession:s,elicitationsBySession:o,dialogsBySession:l,awaitingPermission:C,awaitingQuestion:_,awaitingElicitation:S,awaitingDialog:N,awaitingPlan:u,responding:f,respond:v,answerQuestion:y,answerElicitation:k,answerDialog:j,refresh:T}),[e,s,o,l,C,_,S,N,u,f,v,y,k,j,T]);return a.jsx(F5.Provider,{value:E,children:n})}function hle(){const n=w.useContext(F5);if(!n)throw new Error("usePendingHumanInput must be used within a PendingHumanInputProvider");return n}const Vw=768;function gx(){const n=q.c(2),[e,t]=w.useState(typeof window<"u"?window.innerWidth<Vw:!1);let s,r;return n[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>{const o=window.matchMedia(`(max-width: ${Vw-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 U5=typeof navigator<"u"&&"vibrate"in navigator;function Lh(){U5&&navigator.vibrate(10)}function gle(){U5&&navigator.vibrate(20)}async function xle(n,e){try{return(await rr("/api/archive-sessions",{sessionIds:n,archived:e})).ok}catch{return!1}}function ble(n){return!!(n.teamName&&n.agentName)}function vle(n,e,t,s,r,o,i){const l=[],c=[];for(const u of El(n)){if(s!=null&&s.has(u.sessionId)){l.push({session:u,reason:"permission"});continue}if(r!=null&&r.has(u.sessionId)){l.push({session:u,reason:"question"});continue}if(o!=null&&o.has(u.sessionId)){l.push({session:u,reason:"prompt"});continue}if(i!=null&&i.has(u.sessionId)){l.push({session:u,reason:"plan"});continue}if(u.agentStatus==="deferred"){l.push({session:u,reason:"deferred"});continue}if(ble(u))continue;const d=n4(u,e);if(u.agentStatus==="completed"||!d){t.has(u.sessionId)&&l.push({session:u,reason:"done"});continue}if(u.agentStatus==="idle"){l.push({session:u,reason:"waiting"});continue}(!u.agentStatus||a1.has(u.agentStatus))&&c.push(u)}return{needsYou:l,working:c}}function yle(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 xx(n,e){return n?pn(n).externalProcesses&&(e==null?void 0:e.managed)===!1:!1}const B5="aw:turnCounts",wle=200,Gd=new Map;try{const n=localStorage.getItem(B5);if(n){const e=JSON.parse(n);for(const[t,s]of e)Gd.set(t,s)}}catch{}function Sle(){try{const n=[...Gd.entries()].slice(-wle);localStorage.setItem(B5,JSON.stringify(n))}catch{}}function kle(n,e){Gd.set(Rn(n),e),Sle()}function W5(n,e){const t=Gd.get(Rn(n));return Math.max(t??0,e??0)}function bx(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=W5(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(Ba,{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:K("font-medium",Kd(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(Ps,{className:"size-3"}),o1(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 v;e[16]!==d?(v=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]=v):v=e[17];let y;e[18]!==t.pullRequests?(y=a.jsx($l,{pullRequests:t.pullRequests,layout:"list"}),e[18]=t.pullRequests,e[19]=y):y=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(Qr,{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(Di,{className:"size-2.5"}),f," ",f===1?"turn":"turns"]}),e[23]=f,e[24]=j):j=e[24];let C;e[25]!==t.size?(C=hk(t.size),e[25]=t.size,e[26]=C):C=e[26];let _;e[27]!==C?(_=a.jsx("span",{children:C}),e[27]=C,e[28]=_):_=e[28];let S;e[29]!==s?(S=s&&a.jsxs("span",{className:"flex items-center gap-0.5 text-success",children:[a.jsx(pA,{className:"size-2.5"}),s.memMB," MB"]}),e[29]=s,e[30]=S):S=e[30];const N=t.lastActivityAt||t.lastModified;let T;e[31]!==N?(T=Fi(N),e[31]=N,e[32]=T):T=e[32];let E;e[33]!==T?(E=a.jsx("span",{children:T}),e[33]=T,e[34]=E):E=e[34];let A;e[35]!==j||e[36]!==_||e[37]!==S||e[38]!==E||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,_,S,E]}),e[35]=j,e[36]=_,e[37]=S,e[38]=E,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]!==v||e[49]!==y?(P=a.jsxs("div",{className:"flex w-72 flex-col gap-2 text-xs",children:[m,p,h,g,x,b,v,y,A]}),e[41]=m,e[42]=A,e[43]=p,e[44]=h,e[45]=g,e[46]=x,e[47]=b,e[48]=v,e[49]=y,e[50]=P):P=e[50],P}const jle=120;function vx(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,jle))},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 Nle=6;function Cle(n){const e=q.c(7),{iso:t}=n,[,s]=w.useState(0);let r;e[0]!==s?(r=()=>{const c=setInterval(()=>s(_le),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=Fi(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 _le(n){return n+1}const Tle={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"}},Ele={permission:Jr.attention,deferred:Jr.attention,waiting:Jr.attention,question:"bg-warning",prompt:"bg-warning",plan:"bg-warning",done:"bg-success"};function Hw(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=xx(sn(t.dirName),l),e[0]=l,e[1]=t.dirName,e[2]=b):b=e[2];const v=b;let y;e[3]!==s||e[4]!==v||e[5]!==t.agentPendingAgents||e[6]!==t.agentStatus||e[7]!==t.agentTerminalReason||e[8]!==t.agentToolName?(y=v?"Read-only":Pl(t.agentStatus,t.agentToolName,t.agentTerminalReason,t.agentPendingAgents)??s.label,e[3]=s,e[4]=v,e[5]=t.agentPendingAgents,e[6]=t.agentStatus,e[7]=t.agentTerminalReason,e[8]=t.agentToolName,e[9]=y):y=e[9];const k=y,j=!!h&&!v,{onHoverStart:C,onHoverEnd:_}=vx(g),S=x?"px-2.5 py-2":"border px-2 py-2",N=i&&!x&&"ring-1 ring-ring";let T;e[10]!==o||e[11]!==S||e[12]!==N?(T=K("group relative w-full rounded-md text-left transition-colors",S,o,N),e[10]=o,e[11]=S,e[12]=N,e[13]=T):T=e[13];let E;e[14]!==x||e[15]!==i?(E=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]=E):E=e[16];const A=j&&"pr-20";let P;e[17]!==A?(P=K("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]!==_||e[20]!==C||e[21]!==m||e[22]!==P?(I=a.jsx("button",{type:"button","data-attention-session":!0,onClick:m,onMouseEnter:C,onMouseLeave:_,onFocus:C,onBlur:_,className:P}),e[19]=_,e[20]=C,e[21]=m,e[22]=P,e[23]=I):I=e[23];const O=x&&"ring-0";let R;e[24]!==r||e[25]!==O?(R=K("size-1.5 shrink-0 rounded-full",r,O),e[24]=r,e[25]=O,e[26]=R):R=e[26];let $;e[27]!==R?($=a.jsx("span",{className:R,"aria-hidden":"true"}),e[27]=R,e[28]=$):$=e[28];let M;e[29]!==u||e[30]!==t?(M=xu(t,u),e[29]=u,e[30]=t,e[31]=M):M=e[31];let z;e[32]!==M?(z=a.jsx("span",{className:"min-w-0 flex-1 truncate text-xs leading-tight text-foreground",children:M}),e[32]=M,e[33]=z):z=e[33];const F=x?"text-muted-foreground":s.className;let D;e[34]!==F?(D=K("shrink-0",F),e[34]=F,e[35]=D):D=e[35];const L=v?"Read-only":s.label;let B;e[36]!==D||e[37]!==L?(B=a.jsx(Fe,{variant:"outline",className:D,children:L}),e[36]=D,e[37]=L,e[38]=B):B=e[38];let U;e[39]!==x||e[40]!==t.lastActivityAt||e[41]!==t.lastModified?(U=!x&&a.jsx(Cle,{iso:t.lastActivityAt||t.lastModified}),e[39]=x,e[40]=t.lastActivityAt,e[41]=t.lastModified,e[42]=U):U=e[42];let W;e[43]!==$||e[44]!==z||e[45]!==B||e[46]!==U?(W=a.jsxs("span",{className:"flex items-center gap-1.5",children:[$,z,B,U]}),e[43]=$,e[44]=z,e[45]=B,e[46]=U,e[47]=W):W=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]!==W||e[52]!==V?(H=a.jsxs(Xt,{render:I,children:[W,V]}),e[50]=I,e[51]=W,e[52]=V,e[53]=H):H=e[53];let G;e[54]!==u||e[55]!==l||e[56]!==t||e[57]!==k?(G=a.jsx(Jt,{side:"right",className:"max-w-[280px]",children:a.jsx(bx,{session:t,proc:l,statusLabel:k,customName:u})}),e[54]=u,e[55]=l,e[56]=t,e[57]=k,e[58]=G):G=e[58];let Z;e[59]!==H||e[60]!==G?(Z=a.jsxs(Yt,{children:[H,G]}),e[59]=H,e[60]=G,e[61]=Z):Z=e[61];let Y;e[62]!==j||e[63]!==h?(Y=j&&a.jsxs(J,{type:"button",variant:"outline",size:"xs",onClick:h,className:"absolute bottom-1 right-1 text-warning","aria-label":"Resume to evaluate",children:[a.jsx(Li,{"data-icon":"inline-start"}),"Resume"]}),e[62]=j,e[63]=h,e[64]=Y):Y=e[64];let X;e[65]!==v||e[66]!==c||e[67]!==p||e[68]!==l?(X=l&&p&&!v&&a.jsx(J,{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(Wt,{"data-icon":"inline-start"})}),e[65]=v,e[66]=c,e[67]=p,e[68]=l,e[69]=X):X=e[69];let ee;return e[70]!==Z||e[71]!==Y||e[72]!==X||e[73]!==T||e[74]!==E?(ee=a.jsxs("div",{className:T,children:[E,Z,Y,X]}),e[70]=Z,e[71]=Y,e[72]=X,e[73]=T,e[74]=E,e[75]=ee):ee=e[75],ee}function Ale(n){const e=q.c(15),{dotClassName:t,labelClassName:s,label:r,count:o}=n;let i;e[0]!==t?(i=K("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=K("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 Ple(n){const e=q.c(27),{groups:t,activeSessionKey:s,procBySession:r,killingPids:o,sessionNames:i,projectNames:l,onSelectSession:c,onKill:u,onResumeSession:d,onPrefetchSession:f}=n,[m,p]=w.useState(!1);let h;e[0]!==t.working||e[1]!==m?(h=m?t.working:t.working.slice(0,Nle),e[0]=t.working,e[1]=m,e[2]=h):h=e[2];const g=h,x=t.working.length-g.length;let b;e[3]!==l?(b=S=>l[S.dirName]||s1(S.cwd||Rs(S.dirName)),e[3]=l,e[4]=b):b=e[4];const v=b;let y;e[5]!==s||e[6]!==o||e[7]!==f||e[8]!==c||e[9]!==r||e[10]!==v||e[11]!==i?(y=S=>{const N=s===`${S.dirName}/${S.fileName}`;return{session:S,isActiveSession:N,proc:r.get(S.sessionId),killingPids:o,customName:i[S.sessionId],projectLabel:v(S),onSelect:()=>c(S.dirName,S.fileName),onPrefetch:f&&!N?()=>f(S.dirName,S.fileName):void 0}},e[5]=s,e[6]=o,e[7]=f,e[8]=c,e[9]=r,e[10]=v,e[11]=i,e[12]=y):y=e[12];const k=y;let j;e[13]!==t.needsYou||e[14]!==u||e[15]!==d||e[16]!==k?(j=t.needsYou.length>0&&a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsx(Ale,{dotClassName:Jr.attention,labelClassName:"text-warning",label:"Needs you",count:t.needsYou.length}),t.needsYou.map(S=>{const{session:N,reason:T}=S;return a.jsx(Hw,{...k(N),chip:Tle[T],dotClassName:Ele[T],cardClassName:"border-warning/20 bg-warning/5 hover:bg-warning/10",onKill:u,onResume:T==="deferred"&&d?()=>d(N.sessionId,N.cwd,N.dirName):void 0},`${N.dirName}/${N.fileName}`)})]}),e[13]=t.needsYou,e[14]=u,e[15]=d,e[16]=k,e[17]=j):j=e[17];let C;e[18]!==t.working.length||e[19]!==x||e[20]!==u||e[21]!==k||e[22]!==g?(C=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:g.map(S=>a.jsx(Hw,{...k(S),chip:{label:yle(S),className:""},dotClassName:Jr.working,cardClassName:"hover:bg-accent/50",compact:!0,onKill:u},`${S.dirName}/${S.fileName}`))}),x>0&&a.jsxs(J,{type:"button",variant:"ghost",size:"xs",onClick:()=>p(!0),className:"justify-start",children:[a.jsx(It,{"data-icon":"inline-start"}),"Show ",x," more"]})]}),e[18]=t.working.length,e[19]=x,e[20]=u,e[21]=k,e[22]=g,e[23]=C):C=e[23];let _;return e[24]!==j||e[25]!==C?(_=a.jsxs("div",{className:"flex flex-col gap-2","data-attention-strip":!0,children:[j,C]}),e[24]=j,e[25]=C,e[26]=_):_=e[26],_}function Ile(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=$=>c($.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(Pr,{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(Ds,{align:"inline-start",children:o?a.jsx(ht,{className:"animate-spin"}):a.jsx(Bn,{})}),e[6]=o,e[7]=h):h=e[7];let g;e[8]!==c||e[9]!==r?(g=r&&a.jsx(Ds,{align:"inline-end",children:a.jsx(kl,{size:"icon-xs",onClick:()=>c(""),"aria-label":"Clear session search",children:a.jsx(Wt,{"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(Ar,{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",v=i?"Hide archived sessions":"Show archived sessions",y=i&&"bg-accent text-accent-foreground";let k;e[15]!==y?(k=K(y),e[15]=y,e[16]=k):k=e[16];let j;e[17]!==u||e[18]!==i||e[19]!==b||e[20]!==v||e[21]!==k?(j=a.jsx(J,{variant:"ghost",size:b,onClick:u,"aria-pressed":i,"aria-label":v,className:k}),e[17]=u,e[18]=i,e[19]=b,e[20]=v,e[21]=k,e[22]=j):j=e[22];let C;e[23]===Symbol.for("react.memo_cache_sentinel")?(C=a.jsx(Ps,{"data-icon":"inline-start"}),e[23]=C):C=e[23];let _;e[24]!==j?(_=a.jsx(Xt,{render:j,children:C}),e[24]=j,e[25]=_):_=e[25];const S=i?"Hide archived":"Show archived";let N;e[26]!==f||e[27]!==S?(N=a.jsxs(Jt,{side:"bottom",children:[S," · ",f]}),e[26]=f,e[27]=S,e[28]=N):N=e[28];let T;e[29]!==_||e[30]!==N?(T=a.jsxs(Yt,{children:[_,N]}),e[29]=_,e[30]=N,e[31]=T):T=e[31];const E=s?"icon-sm":"icon-xs",A=t&&"animate-spin";let P;e[32]!==A?(P=K(A),e[32]=A,e[33]=P):P=e[33];let I;e[34]!==P?(I=a.jsx(Un,{"data-icon":"inline-start",className:P}),e[34]=P,e[35]=I):I=e[35];let O;e[36]!==d||e[37]!==E||e[38]!==I?(O=a.jsx(J,{variant:"ghost",size:E,onClick:d,"aria-label":"Refresh sessions",children:I}),e[36]=d,e[37]=E,e[38]=I,e[39]=O):O=e[39];let R;return e[40]!==T||e[41]!==O||e[42]!==x?(R=a.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b px-2.5 py-2",children:[x,T,O]}),e[40]=T,e[41]=O,e[42]=x,e[43]=R):R=e[43],R}const $le=["first","second","third","fourth","fifth"];function Rle(n){const e=q.c(31),{fetchError:t,showEmpty:s,searching:r,loading:o,sessionCount:i,hiddenArchivedCount:l,focusedProject:c,onShowAllProjects:u,onShowArchived:d,onRetry:f}=n,m=c===void 0?null:c;let p;e[0]!==m||e[1]!==l||e[2]!==r||e[3]!==s?(p=Mle({showEmpty:s,searching:r,focusedProject:m,hiddenArchivedCount:l}),e[0]=m,e[1]=l,e[2]=r,e[3]=s,e[4]=p):p=e[4];const h=p;let g;e[5]!==t||e[6]!==f?(g=t&&a.jsxs(Ft,{variant:"destructive",children:[a.jsx(Us,{}),a.jsx(on,{children:"Could not load sessions"}),a.jsx(Ut,{className:"truncate",children:t}),a.jsx(oo,{children:a.jsx(J,{variant:"outline",size:"xs",onClick:f,children:"Retry"})})]}),e[5]=t,e[6]=f,e[7]=g):g=e[7];let x;e[8]!==h||e[9]!==l||e[10]!==d?(x=h==="archived"&&a.jsxs(is,{className:"min-h-56 px-4 py-8",children:[a.jsxs(as,{children:[a.jsx(Is,{variant:"icon",children:a.jsx(Ps,{})}),a.jsx(ls,{children:"Everything is archived"}),a.jsx(cs,{children:l===1?"1 archived session is hidden.":`${l} archived sessions are hidden.`})]}),a.jsxs(J,{variant:"outline",size:"sm",onClick:d,children:[a.jsx(Ps,{"data-icon":"inline-start"}),"Show archived"]})]}),e[8]=h,e[9]=l,e[10]=d,e[11]=x):x=e[11];let b;e[12]!==h||e[13]!==m||e[14]!==l||e[15]!==u||e[16]!==d||e[17]!==r?(b=h==="focused"&&a.jsxs(is,{className:"min-h-56 px-4 py-8",children:[a.jsxs(as,{children:[a.jsx(Is,{variant:"icon",children:r?a.jsx(Bn,{}):a.jsx(Tp,{})}),a.jsx(ls,{children:r?`No matching sessions in ${m}`:`No sessions in ${m}`}),a.jsx(cs,{children:Lle(r,l)})]}),a.jsxs("div",{className:"flex flex-wrap justify-center gap-2",children:[a.jsxs(J,{variant:"outline",size:"sm",onClick:u,children:[a.jsx(ou,{"data-icon":"inline-start"}),"All projects"]}),!r&&l>0&&a.jsxs(J,{variant:"ghost",size:"sm",onClick:d,children:[a.jsx(Ps,{"data-icon":"inline-start"}),"Show archived"]})]})]}),e[12]=h,e[13]=m,e[14]=l,e[15]=u,e[16]=d,e[17]=r,e[18]=b):b=e[18];let v;e[19]!==h||e[20]!==r?(v=h==="plain"&&a.jsx(is,{className:"min-h-56 px-4 py-8",children:a.jsxs(as,{children:[a.jsx(Is,{variant:"icon",children:r?a.jsx(Bn,{}):a.jsx(Tp,{})}),a.jsx(ls,{children:r?"No matching sessions":"No sessions yet"}),a.jsx(cs,{children:r?"Try #157, honest-cms #157, or paste a PR URL.":"Start Claude Code, Codex, or Copilot to see recent work here."})]})}),e[19]=h,e[20]=r,e[21]=v):v=e[21];let y;e[22]!==o||e[23]!==i?(y=o&&i===0&&a.jsx("div",{className:"flex flex-col gap-2 px-2 py-4","aria-label":"Loading sessions",children:$le.map(Ole)}),e[22]=o,e[23]=i,e[24]=y):y=e[24];let k;return e[25]!==g||e[26]!==x||e[27]!==b||e[28]!==v||e[29]!==y?(k=a.jsxs(a.Fragment,{children:[g,x,b,v,y]}),e[25]=g,e[26]=x,e[27]=b,e[28]=v,e[29]=y,e[30]=k):k=e[30],k}function Ole(n){return a.jsxs("div",{className:"flex items-center gap-2 py-1",children:[a.jsx($n,{className:"size-2 shrink-0 rounded-full"}),a.jsx($n,{className:"h-4 flex-1"}),a.jsx($n,{className:"h-4 w-10"})]},n)}function Mle({showEmpty:n,searching:e,focusedProject:t,hiddenArchivedCount:s}){return n?t!==null?"focused":!e&&s>0?"archived":"plain":null}function Lle(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 vp=864e5;function zle(n){const e=new Date(n);return e.setHours(0,0,0,0),e.getTime()}function Dle(n,e=Date.now()){const t=Date.parse(n);if(!Number.isFinite(t))return"Older";const s=zle(e);return t>=s?"Today":t>=s-vp?"Yesterday":t>=s-6*vp?"Last 7 days":t>=s-29*vp?"Last 30 days":"Older"}function q5(n,e,t=!1){const s=e!==void 0,r=n.isActive===!0,o=s||r,i=r&&Fl(n.agentStatus),l=n.agentStatus==="deferred",c=xx(sn(n.dirName),e);return{hasProcess:s,isLive:o,isRunning:i1(n,e),isNativeIdle:i,isDeferred:l,isReadOnly:c,isTeammate:!!(n.teamName&&n.agentName),isArchived:n.archived===!0,statusLabel:Fle(n,{isReadOnly:c,isLive:o,isNativeIdle:i}),dotState:Ule(n,{isDeferred:l,isLive:o}),justFinished:!r&&s&&n.agentStatus==="completed"&&t}}function Fle(n,{isReadOnly:e,isLive:t,isNativeIdle:s}){return e?"Read-only":t?s?"Running":Pl(n.agentStatus,n.agentToolName,n.agentTerminalReason,n.agentPendingAgents)??"Running":null}function Ule(n,{isDeferred:e,isLive:t}){return e?"attention":t?Fl(n.agentStatus)?"idle":"working":null}function Ble(n){var ut,vt;const e=q.c(156),{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:v,onArchiveSession:y,onUnarchiveSession:k,onRenameSession:j,onPrefetchSession:C,onResumeSession:_}=n,{isLive:S,isRunning:N,isNativeIdle:T,isDeferred:E,isReadOnly:A,isTeammate:P,isArchived:I,statusLabel:O,dotState:R,justFinished:$}=q5(t,l,u),[M,z]=w.useState(!1);let F;e[0]!==d||e[1]!==t?(F=t4(t,d),e[0]=d,e[1]=t,e[2]=F):F=e[2];const D=F,L=LL(t,d),B=o?s:void 0,U=t.lastUserMessage||t.firstUserMessage,W=!!U&&U!==D,V=W5(t.sessionId,t.turnCount);let H;e[3]!==t.archivedReason?(H=o1(t.archivedReason),e[3]=t.archivedReason,e[4]=H):H=e[4];const G=H,Z=I?k&&{label:"Restore from archive",icon:og,run:()=>k(t)}:y&&!N&&{label:"Archive session",icon:Ps,run:()=>y(t)},Y=E&&!!_&&!A,X=!!m&&!!h,ee=!!t.matchedPullRequestNumber||!!((ut=t.pullRequests)!=null&&ut.length),Q=Y||X||ee;let ne;e[5]!==i||e[6]!==C||e[7]!==t.dirName||e[8]!==t.fileName?(ne=C&&!i?()=>C(t.dirName,t.fileName):void 0,e[5]=i,e[6]=C,e[7]=t.dirName,e[8]=t.fileName,e[9]=ne):ne=e[9];const{onHoverStart:re,onHoverEnd:se}=vx(ne);let oe;e[10]!==_||e[11]!==M||e[12]!==t.cwd||e[13]!==t.dirName||e[14]!==t.sessionId?(oe=()=>{!_||M||(z(!0),_(t.sessionId,t.cwd,t.dirName),setTimeout(()=>z(!1),3e3))},e[10]=_,e[11]=M,e[12]=t.cwd,e[13]=t.dirName,e[14]=t.sessionId,e[15]=oe):oe=e[15];const ae=oe,ie=!0,ce=I||void 0,te=K("motion-list-item group relative flex flex-col rounded-lg border transition-colors",Wle(i,$),I&&"opacity-60 hover:opacity-100 focus-within:opacity-100");let le;e[16]!==g||e[17]!==t.dirName||e[18]!==t.fileName?(le=()=>g(t.dirName,t.fileName),e[16]=g,e[17]=t.dirName,e[18]=t.fileName,e[19]=le):le=e[19];const ge=i?"true":void 0,be=Q?"pb-1.5":"pb-2.5";let ue;e[20]!==be?(ue=K("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",be),e[20]=be,e[21]=ue):ue=e[21];let he;e[22]!==se||e[23]!==re||e[24]!==ue||e[25]!==le||e[26]!==ge?(he=a.jsx("button",{type:"button","data-live-session":!0,onClick:le,onMouseEnter:re,onMouseLeave:se,onFocus:re,onBlur:se,"aria-current":ge,className:ue}),e[22]=se,e[23]=re,e[24]=ue,e[25]=le,e[26]=ge,e[27]=he):he=e[27];let me;e[28]!==B||e[29]!==r?(me=B&&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(qu,{projectPath:r,fallback:a.jsx(Ba,{className:"size-3 shrink-0","aria-hidden":"true"}),className:"size-3"}),a.jsx("span",{className:"truncate",children:B})]}),e[28]=B,e[29]=r,e[30]=me):me=e[30];let xe;e[31]!==R?(xe=R&&a.jsx("span",{"data-status-dot":R,className:K("size-1.5 rounded-full",Jr[R])}),e[31]=R,e[32]=xe):xe=e[32];let je;e[33]!==xe?(je=a.jsx("span",{className:"mt-[7px] flex w-1.5 shrink-0 justify-center","aria-hidden":"true",children:xe}),e[33]=xe,e[34]=je):je=e[34];const Le=L?"text-muted-foreground":"font-medium text-foreground";let Se;e[35]!==Le?(Se=K("line-clamp-2 flex-1 text-sm leading-snug",Le),e[35]=Le,e[36]=Se):Se=e[36];let Ie;e[37]!==D||e[38]!==Se?(Ie=a.jsx("span",{className:Se,children:D}),e[37]=D,e[38]=Se,e[39]=Ie):Ie=e[39];let we;e[40]!==je||e[41]!==Ie?(we=a.jsxs("span",{className:"flex items-start gap-2",children:[je,Ie]}),e[40]=je,e[41]=Ie,e[42]=we):we=e[42];let Be;e[43]!==U||e[44]!==W?(Be=W&&a.jsx("span",{className:"line-clamp-2 pl-3.5 text-xs leading-relaxed text-muted-foreground",children:U}),e[43]=U,e[44]=W,e[45]=Be):Be=e[45];let De;e[46]!==E||e[47]!==S||e[48]!==T||e[49]!==t.agentStatus||e[50]!==O?(De=S&&!E&&O&&a.jsx(Fe,{variant:"secondary","data-session-live-state":!0,className:K(T?"text-success":Kd(t.agentStatus)),children:O}),e[46]=E,e[47]=S,e[48]=T,e[49]=t.agentStatus,e[50]=O,e[51]=De):De=e[51];let Ue;e[52]!==E?(Ue=E&&a.jsx(Fe,{variant:"outline",className:"border-warning/30 bg-warning/10 text-warning",children:"deferred"}),e[52]=E,e[53]=Ue):Ue=e[53];let We;e[54]!==D||e[55]!==P||e[56]!==t.agentName?(We=P&&a.jsxs(Fe,{variant:"outline",children:[a.jsx(ki,{"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 Oe;e[58]!==f?(Oe=f&&a.jsxs(Fe,{variant:"outline",children:[a.jsx(Qr,{"data-icon":"inline-start"}),f]}),e[58]=f,e[59]=Oe):Oe=e[59];let pe;e[60]!==t.gitBranch||e[61]!==f?(pe=t.gitBranch&&!f&&a.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[a.jsx(Qr,{className:"size-3 shrink-0","aria-hidden":"true"}),a.jsx("span",{className:"truncate",children:t.gitBranch})]}),e[60]=t.gitBranch,e[61]=f,e[62]=pe):pe=e[62];let ke;e[63]!==V?(ke=V>0&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Di,{className:"size-3 shrink-0","aria-hidden":"true"}),V," ",V===1?"turn":"turns"]}),e[63]=V,e[64]=ke):ke=e[64];let _e;e[65]!==G||e[66]!==I?(_e=I&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Ps,{className:"size-3 shrink-0","aria-label":G,role:"img"}),"Archived"]}),e[65]=G,e[66]=I,e[67]=_e):_e=e[67];const ye=t.lastActivityAt||t.lastModified;let Pe;e[68]!==ye?(Pe=Fi(ye),e[68]=ye,e[69]=Pe):Pe=e[69];let Ye;e[70]!==Pe?(Ye=a.jsx("span",{className:"ml-auto tabular-nums",children:Pe}),e[70]=Pe,e[71]=Ye):Ye=e[71];let Xe;e[72]!==De||e[73]!==Ue||e[74]!==We||e[75]!==Oe||e[76]!==pe||e[77]!==ke||e[78]!==_e||e[79]!==Ye?(Xe=a.jsxs("span",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 pl-3.5 text-[11px] text-muted-foreground",children:[De,Ue,We,Oe,pe,ke,_e,Ye]}),e[72]=De,e[73]=Ue,e[74]=We,e[75]=Oe,e[76]=pe,e[77]=ke,e[78]=_e,e[79]=Ye,e[80]=Xe):Xe=e[80];let Ee;e[81]!==he||e[82]!==me||e[83]!==we||e[84]!==Be||e[85]!==Xe?(Ee=a.jsxs(Xt,{render:he,children:[me,we,Be,Xe]}),e[81]=he,e[82]=me,e[83]=we,e[84]=Be,e[85]=Xe,e[86]=Ee):Ee=e[86];const Ze=B?void 0:s;let fe;e[87]!==d||e[88]!==l||e[89]!==t||e[90]!==O||e[91]!==Ze||e[92]!==f?(fe=a.jsx(Jt,{side:"right",className:"max-w-[320px]",children:a.jsx(bx,{session:t,proc:l,statusLabel:O,customName:d,worktreeName:f,projectLabel:Ze})}),e[87]=d,e[88]=l,e[89]=t,e[90]=O,e[91]=Ze,e[92]=f,e[93]=fe):fe=e[93];let Te;e[94]!==Ee||e[95]!==fe?(Te=a.jsxs(Yt,{children:[Ee,fe]}),e[94]=Ee,e[95]=fe,e[96]=Te):Te=e[96];let Ve;e[97]!==Y||e[98]!==ae||e[99]!==Q||e[100]!==X||e[101]!==h||e[102]!==M||e[103]!==t.matchedPullRequestNumber||e[104]!==t.pullRequests||e[105]!==m||e[106]!==p?(Ve=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(Fe,{variant:"outline",className:"px-1",children:["Matched #",t.matchedPullRequestNumber]}):a.jsx($l,{pullRequests:t.pullRequests,max:2,compact:!0}),X&&a.jsxs(J,{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(at,{"data-icon":"inline-end",className:K("transition-transform duration-150",!p&&"rotate-90")})]}),Y&&a.jsxs(J,{type:"button",variant:"outline",size:"xs",onClick:ae,disabled:M,className:"text-warning",title:"Resume to evaluate deferred permission","aria-label":"Resume to evaluate",children:[a.jsx(Li,{"data-icon":"inline-start"}),"Resume"]})]}),e[97]=Y,e[98]=ae,e[99]=Q,e[100]=X,e[101]=h,e[102]=M,e[103]=t.matchedPullRequestNumber,e[104]=t.pullRequests,e[105]=m,e[106]=p,e[107]=Ve):Ve=e[107];let He;e[108]!==Z?(He=Z&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:Z.run,className:"absolute bottom-1.5 right-1.5 bg-background/80 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[108]=Z,e[109]=He):He=e[109];let $e;e[110]!==I||e[111]!==A||e[112]!==N||e[113]!==c||e[114]!==x||e[115]!==l?($e=l&&x&&N&&!I&&!A&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:un=>x(l.pid,un),disabled:c.has(l.pid),className:"absolute bottom-1.5 right-1.5 bg-background/80 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(Wt,{"data-icon":"inline-start"})}),e[110]=I,e[111]=A,e[112]=N,e[113]=c,e[114]=x,e[115]=l,e[116]=$e):$e=e[116];let tt;e[117]!==Te||e[118]!==Ve||e[119]!==He||e[120]!==$e||e[121]!==ce||e[122]!==te?(tt=a.jsxs("div",{"data-session-card":ie,"data-archived":ce,className:te,children:[Te,Ve,He,$e]}),e[117]=Te,e[118]=Ve,e[119]=He,e[120]=$e,e[121]=ce,e[122]=te,e[123]=tt):tt=e[123];const bt=tt;if(b||v||j||y||k){let un;e[124]!==t.firstUserMessage||e[125]!==t.sessionId||e[126]!==t.slug?(un=t.slug||((vt=t.firstUserMessage)==null?void 0:vt.slice(0,30))||t.sessionId.slice(0,12),e[124]=t.firstUserMessage,e[125]=t.sessionId,e[126]=t.slug,e[127]=un):un=e[127];let Nt;e[128]!==b||e[129]!==t.dirName||e[130]!==t.fileName?(Nt=b?()=>b(t.dirName,t.fileName):void 0,e[128]=b,e[129]=t.dirName,e[130]=t.fileName,e[131]=Nt):Nt=e[131];let Gn;e[132]!==v||e[133]!==t?(Gn=v?()=>v(t):void 0,e[132]=v,e[133]=t,e[134]=Gn):Gn=e[134];let en;e[135]!==j||e[136]!==t.sessionId?(en=j?Zi=>j(t.sessionId,Zi):void 0,e[135]=j,e[136]=t.sessionId,e[137]=en):en=e[137];let Mn;e[138]!==I||e[139]!==y||e[140]!==t?(Mn=y&&!I?()=>y(t):void 0,e[138]=I,e[139]=y,e[140]=t,e[141]=Mn):Mn=e[141];let ps;e[142]!==I||e[143]!==k||e[144]!==t?(ps=k&&I?()=>k(t):void 0,e[142]=I,e[143]=k,e[144]=t,e[145]=ps):ps=e[145];let Rr;return e[146]!==bt||e[147]!==d||e[148]!==N||e[149]!==un||e[150]!==Nt||e[151]!==Gn||e[152]!==en||e[153]!==Mn||e[154]!==ps?(Rr=a.jsx(hx,{sessionLabel:un,customName:d,onDuplicate:Nt,onDelete:Gn,onRename:en,onArchive:Mn,onUnarchive:ps,archiveDisabled:N,children:bt}),e[146]=bt,e[147]=d,e[148]=N,e[149]=un,e[150]=Nt,e[151]=Gn,e[152]=en,e[153]=Mn,e[154]=ps,e[155]=Rr):Rr=e[155],Rr}return bt}function Wle(n,e){return n?"border-foreground/15 bg-accent":e?"border-success/30 bg-success/10":"border-border/70 hover:border-border hover:bg-accent/50"}function qle(n){var be;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:v,onPrefetchSession:y,onResumeSession:k}=n,{isLive:j,isRunning:C,isNativeIdle:_,isDeferred:S,isReadOnly:N,isTeammate:T,isArchived:E,statusLabel:A,dotState:P,justFinished:I}=q5(t,r,i),[O,R]=w.useState(!1);let $;e[0]!==t.archivedReason?($=o1(t.archivedReason),e[0]=t.archivedReason,e[1]=$):$=e[1];const M=$;let z;e[2]!==l||e[3]!==t?(z=xu(t,l),e[2]=l,e[3]=t,e[4]=z):z=e[4];const F=z,D=E?b&&{label:"Restore from archive",icon:og,run:()=>b(t)}:x&&!C&&{label:"Archive session",icon:Ps,run:()=>x(t)};let L;e[5]!==s||e[6]!==y||e[7]!==t.dirName||e[8]!==t.fileName?(L=y&&!s?()=>y(t.dirName,t.fileName):void 0,e[5]=s,e[6]=y,e[7]=t.dirName,e[8]=t.fileName,e[9]=L):L=e[9];const{onHoverStart:B,onHoverEnd:U}=vx(L);let W;e[10]!==k||e[11]!==O||e[12]!==t.cwd||e[13]!==t.dirName||e[14]!==t.sessionId?(W=ue=>{ue.stopPropagation(),!(!k||O)&&(R(!0),k(t.sessionId,t.cwd,t.dirName),setTimeout(()=>R(!1),3e3))},e[10]=k,e[11]=O,e[12]=t.cwd,e[13]=t.dirName,e[14]=t.sessionId,e[15]=W):W=e[15];const V=W,H=K("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",Vle(s,I),E&&"opacity-60 hover:opacity-100 focus-within:opacity-100");let G;e[16]!==m||e[17]!==t.dirName||e[18]!==t.fileName?(G=()=>m(t.dirName,t.fileName),e[16]=m,e[17]=t.dirName,e[18]=t.fileName,e[19]=G):G=e[19];let Z;e[20]!==U||e[21]!==B||e[22]!==G?(Z=a.jsx("button",{type:"button","data-live-session":!0,onClick:G,onMouseEnter:B,onMouseLeave:U,onFocus:B,onBlur:U,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]=U,e[21]=B,e[22]=G,e[23]=Z):Z=e[23];let Y;e[24]!==F?(Y=a.jsx("span",{className:"flex-1 truncate text-sm leading-tight text-foreground",children:F}),e[24]=F,e[25]=Y):Y=e[25];let X;e[26]!==S?(X=S&&a.jsx(Fe,{variant:"outline",className:"border-warning/30 bg-warning/10 text-warning",children:"deferred"}),e[26]=S,e[27]=X):X=e[27];let ee;e[28]!==c?(ee=c&&a.jsxs(Fe,{variant:"outline",children:[a.jsx(Qr,{"data-icon":"inline-start"}),c]}),e[28]=c,e[29]=ee):ee=e[29];let Q;e[30]!==l||e[31]!==r||e[32]!==t||e[33]!==A||e[34]!==c?(Q=a.jsx(Jt,{side:"right",className:"max-w-[280px]",children:a.jsx(bx,{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 ne;e[36]!==f||e[37]!==u||e[38]!==d?(ne=!!u&&f&&a.jsxs(J,{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(at,{"data-icon":"inline-end",className:K("transition-transform duration-150",!d&&"rotate-90")})]}),e[36]=f,e[37]=u,e[38]=d,e[39]=ne):ne=e[39];let re;e[40]!==V||e[41]!==S||e[42]!==N||e[43]!==k||e[44]!==O?(re=S&&k&&!N&&a.jsxs(J,{type:"button",variant:"outline",size:"xs",onClick:V,disabled:O,className:"shrink-0 text-warning",title:"Resume to evaluate deferred permission","aria-label":"Resume to evaluate",children:[a.jsx(Li,{"data-icon":"inline-start"}),"Resume"]}),e[40]=V,e[41]=S,e[42]=N,e[43]=k,e[44]=O,e[45]=re):re=e[45];let se;e[46]!==t.matchedPullRequestNumber||e[47]!==t.pullRequests?(se=t.matchedPullRequestNumber?a.jsxs(Fe,{variant:"outline",className:"shrink-0 px-1",children:["Matched #",t.matchedPullRequestNumber]}):a.jsx($l,{pullRequests:t.pullRequests,max:1,compact:!0}),e[46]=t.matchedPullRequestNumber,e[47]=t.pullRequests,e[48]=se):se=e[48];let oe;e[49]!==M||e[50]!==E?(oe=E&&a.jsx(Ps,{className:"size-3 shrink-0 text-muted-foreground","aria-label":M,role:"img"}),e[49]=M,e[50]=E,e[51]=oe):oe=e[51];const ae=t.lastActivityAt||t.lastModified;let ie;e[52]!==ae?(ie=Fi(ae),e[52]=ae,e[53]=ie):ie=e[53];let ce;e[54]!==ie?(ce=a.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:ie}),e[54]=ie,e[55]=ce):ce=e[55];let te;e[56]!==D?(te=D&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:ue=>{ue.stopPropagation(),D.run()},className:"absolute right-0 top-0 bg-background/80 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]=te):te=e[57];let le;e[58]!==E||e[59]!==N||e[60]!==C||e[61]!==o||e[62]!==p||e[63]!==r?(le=r&&p&&C&&!E&&!N&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:ue=>p(r.pid,ue),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(Wt,{"data-icon":"inline-start"})}),e[58]=E,e[59]=N,e[60]=C,e[61]=o,e[62]=p,e[63]=r,e[64]=le):le=e[64];const ge=a.jsxs("div",{className:H,"data-archived":E||void 0,children:[a.jsxs(Yt,{children:[a.jsxs(Xt,{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:K("size-1.5 rounded-full",Jr[P])})}),Y,T&&a.jsxs(Fe,{variant:"outline",children:[a.jsx(ki,{"data-icon":"inline-start"}),F!==t.agentName?t.agentName:"Agent"]}),j&&!S&&A&&a.jsx(Fe,{variant:"secondary","data-session-live-state":!0,className:K("shrink-0",_&&"text-success",!_&&Kd(t.agentStatus)),children:A}),X,ee]}),Q]}),ne,re,se,oe,ce,te,le]});if(h||g||v||x||b){let ue;e[65]!==t.firstUserMessage||e[66]!==t.sessionId||e[67]!==t.slug?(ue=t.slug||((be=t.firstUserMessage)==null?void 0:be.slice(0,30))||t.sessionId.slice(0,12),e[65]=t.firstUserMessage,e[66]=t.sessionId,e[67]=t.slug,e[68]=ue):ue=e[68];let he;e[69]!==h||e[70]!==t.dirName||e[71]!==t.fileName?(he=h?()=>h(t.dirName,t.fileName):void 0,e[69]=h,e[70]=t.dirName,e[71]=t.fileName,e[72]=he):he=e[72];let me;e[73]!==g||e[74]!==t?(me=g?()=>g(t):void 0,e[73]=g,e[74]=t,e[75]=me):me=e[75];let xe;e[76]!==v||e[77]!==t.sessionId?(xe=v?Se=>v(t.sessionId,Se):void 0,e[76]=v,e[77]=t.sessionId,e[78]=xe):xe=e[78];let je;e[79]!==E||e[80]!==x||e[81]!==t?(je=x&&!E?()=>x(t):void 0,e[79]=E,e[80]=x,e[81]=t,e[82]=je):je=e[82];let Le;return e[83]!==E||e[84]!==b||e[85]!==t?(Le=b&&E?()=>b(t):void 0,e[83]=E,e[84]=b,e[85]=t,e[86]=Le):Le=e[86],a.jsx(hx,{sessionLabel:ue,customName:l,onDuplicate:he,onDelete:me,onRename:xe,onArchive:je,onUnarchive:Le,archiveDisabled:C,children:ge})}return ge}function Vle(n,e){return n?"bg-accent":e?"bg-success/10":"hover:bg-accent/60"}function Hle(n){const e=q.c(50),{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:v,onPrefetchSession:y,onResumeSession:k}=n;let j,C,_;if(e[0]!==t){j=zL(t),_=El(j.topLevelSessions);const U=Date.now(),W=_.map(V=>Dle(V.lastActivityAt||V.lastModified,U));C=W.map((V,H)=>V===W[H-1]?null:V),e[0]=t,e[1]=j,e[2]=C,e[3]=_}else j=e[1],C=e[2],_=e[3];const S=C;let N;e[4]!==S||e[5]!==j.teammatesByLead||e[6]!==_?(N={topLevelSessions:_,teammatesByLead:j.teammatesByLead,shelves:S},e[4]=S,e[5]=j.teammatesByLead,e[6]=_,e[7]=N):N=e[7];const{topLevelSessions:T,teammatesByLead:E,shelves:A}=N;let P;e[8]===Symbol.for("react.memo_cache_sentinel")?(P=new Set,e[8]=P):P=e[8];const[I,O]=w.useState(P);let R;e[9]===Symbol.for("react.memo_cache_sentinel")?(R=U=>{O(W=>{const V=new Set(W);return V.has(U)?V.delete(U):V.add(U),V})},e[9]=R):R=e[9];const $=R;let M;e[10]!==i||e[11]!==c||e[12]!==u||e[13]!==x||e[14]!==g||e[15]!==h||e[16]!==p||e[17]!==y||e[18]!==v||e[19]!==k||e[20]!==m||e[21]!==b||e[22]!==l||e[23]!==d?(M=U=>({session:U,isActiveSession:i===yp(U),proc:l.get(U.sessionId),killingPids:c,isNewlyCompleted:u.has(U.sessionId),customName:d[U.sessionId],onSelectSession:m,onKill:p,onDuplicateSession:h,onDeleteSession:g,onArchiveSession:x,onUnarchiveSession:b,onRenameSession:v,onPrefetchSession:y,onResumeSession:k}),e[10]=i,e[11]=c,e[12]=u,e[13]=x,e[14]=g,e[15]=h,e[16]=p,e[17]=y,e[18]=v,e[19]=k,e[20]=m,e[21]=b,e[22]=l,e[23]=d,e[24]=M):M=e[24];const z=M;let F;e[25]!==s?(F=s&&a.jsx(Gle,{firstMessage:s.firstMessage}),e[25]=s,e[26]=F):F=e[26];let D;if(e[27]!==I||e[28]!==f||e[29]!==z||e[30]!==A||e[31]!==o||e[32]!==E||e[33]!==T){let U;e[35]!==I||e[36]!==f||e[37]!==z||e[38]!==A||e[39]!==o||e[40]!==E?(U=(W,V)=>{const H=yp(W),G=W.cwd??Rs(W.dirName),Z=od(G),Y=f[W.dirName]??r1(W),X=E.get(W.sessionId),ee=I.has(W.sessionId),Q=A[V],ne=a.jsx(Ble,{...z(W),worktreeName:Z==null?void 0:Z.worktreeName,projectLabel:Y,projectPath:(Z==null?void 0:Z.parentPath)??G,showProject:o,teammateCount:X==null?void 0:X.length,teammatesCollapsed:X?ee:void 0,onToggleTeammates:X?()=>$(W.sessionId):void 0});return a.jsxs(w.Fragment,{children:[Q&&a.jsx(Kle,{label:Q}),X&&!ee?a.jsxs("div",{className:"flex flex-col gap-px",children:[ne,a.jsx("div",{className:"ml-3 flex flex-col gap-px border-l pl-1",children:X.map(re=>a.jsx(qle,{...z(re)},yp(re)))})]}):ne]},H)},e[35]=I,e[36]=f,e[37]=z,e[38]=A,e[39]=o,e[40]=E,e[41]=U):U=e[41],D=T.map(U),e[27]=I,e[28]=f,e[29]=z,e[30]=A,e[31]=o,e[32]=E,e[33]=T,e[34]=D}else D=e[34];let L;e[42]!==r.canLoad||e[43]!==r.load||e[44]!==r.loading?(L=r.canLoad&&a.jsxs(J,{type:"button",variant:"ghost",size:"xs",onClick:r.load,disabled:r.loading,className:"justify-start text-muted-foreground",children:[r.loading?a.jsx(ht,{"data-icon":"inline-start",className:"animate-spin"}):a.jsx(DS,{"data-icon":"inline-start"}),"Load older sessions"]}),e[42]=r.canLoad,e[43]=r.load,e[44]=r.loading,e[45]=L):L=e[45];let B;return e[46]!==F||e[47]!==D||e[48]!==L?(B=a.jsxs("div",{className:"flex flex-col gap-1.5","data-session-card-list":!0,children:[F,D,L]}),e[46]=F,e[47]=D,e[48]=L,e[49]=B):B=e[49],B}function Kle(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 Gle(n){const e=q.c(3),{firstMessage:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(ht,{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 yp(n){return`${n.dirName}/${n.fileName}`}function Na(n,e){return`${n} ${n===1?e:`${e}s`}`}function Zle(n){if(!n)return"No sessions listed";const e=Na(n.total,"session");return n.live>0?`${e}, ${n.live} live`:e}function Kw(n){const e=q.c(7),{count:t,label:s,className:r}=n;let o;e[0]!==r?(o=K("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 Yle(n,e){return e===null?0:n.reduce((t,s)=>s.key===e?t:t+s.needsYou,0)}function Xle(n){const e=q.c(67),{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?`${Na(t.length,"project")}, ${Na(o,"session")}`:Zle(r),e[0]=r,e[1]=t.length,e[2]=o,e[3]=s,e[4]=g):g=e[4];const x=g,b=Yle(t,s);let v;e[5]!==i?(v=Z=>{i(Z),p(!1)},e[5]=i,e[6]=v):v=e[6];const y=v,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(ou,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}):a.jsx(qu,{projectPath:(r==null?void 0:r.cwd)??null,fallback:a.jsx(Ba,{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 C=s===null?"All projects":h;let _;e[10]!==C?(_=a.jsx("span",{className:"truncate text-sm font-medium leading-tight text-foreground",children:C}),e[10]=C,e[11]=_):_=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 N;e[14]!==_||e[15]!==S?(N=a.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[_,S]}),e[14]=_,e[15]=S,e[16]=N):N=e[16];let T;e[17]!==b?(T=b>0&&a.jsx(Kw,{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]=T):T=e[18];let E;e[19]===Symbol.for("react.memo_cache_sentinel")?(E=a.jsx(dl,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),e[19]=E):E=e[19];let A;e[20]!==k||e[21]!==j||e[22]!==N||e[23]!==T?(A=a.jsxs(sd,{"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,N,T,E]}),e[20]=k,e[21]=j,e[22]=N,e[23]=T,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(M5,{projectLabel:r.key,customName:r.customName,className:"flex min-w-0 flex-1",archivableCount:d,onArchiveIdle:f,onRename:Z=>u(r.dirName,Z),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 O;e[31]===Symbol.for("react.memo_cache_sentinel")?(O=a.jsx(P7,{placeholder:"Find a project",autoFocus:!0}),e[31]=O):O=e[31];let R;e[32]===Symbol.for("react.memo_cache_sentinel")?(R=a.jsx(I7,{children:"No project matches."}),e[32]=R):R=e[32];const $=s===null;let M;e[33]!==y?(M=()=>y(null),e[33]=y,e[34]=M):M=e[34];let z,F;e[35]===Symbol.for("react.memo_cache_sentinel")?(z=a.jsx(ou,{className:"text-muted-foreground","aria-hidden":"true"}),F=a.jsx("span",{className:"flex-1 truncate",children:"All projects"}),e[35]=z,e[36]=F):(z=e[35],F=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]!==$||e[40]!==M||e[41]!==D?(L=a.jsx(cu,{children:a.jsxs(uu,{value:"all-projects","data-checked":$,onSelect:M,className:"gap-2.5",children:[z,F,D]})}),e[39]=$,e[40]=M,e[41]=D,e[42]=L):L=e[42];let B;if(e[43]!==t||e[44]!==y||e[45]!==s){let Z;e[47]!==y||e[48]!==s?(Z=Y=>a.jsxs(uu,{value:Y.key,keywords:Y.customName?[Y.customName]:void 0,"data-checked":s===Y.key,onSelect:()=>y(Y.key),className:"gap-2.5",children:[a.jsx(qu,{projectPath:Y.cwd??null,fallback:a.jsx(Ba,{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:Y.customName??Y.key}),Y.customName&&a.jsx("span",{className:"truncate text-[11px] text-muted-foreground",children:Y.key})]}),Y.needsYou>0&&a.jsx(Kw,{count:Y.needsYou,label:`${Na(Y.needsYou,"session")} waiting for you`,className:"text-xs"}),Y.live>0&&a.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs font-medium text-success","aria-label":Na(Y.live,"live session"),children:[a.jsx(ld,{className:"size-1.5","aria-hidden":"true"}),Y.live]}),a.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:Y.total})]},Y.key),e[47]=y,e[48]=s,e[49]=Z):Z=e[49],B=t.map(Z),e[43]=t,e[44]=y,e[45]=s,e[46]=B}else B=e[46];let U;e[50]!==B?(U=a.jsx(cu,{heading:"Projects",children:B}),e[50]=B,e[51]=U):U=e[51];let W;e[52]!==L||e[53]!==U?(W=a.jsx(mk,{className:"w-(--anchor-width) min-w-72 p-0",children:a.jsxs(wg,{children:[O,a.jsxs(Sg,{children:[R,L,U]})]})}),e[52]=L,e[53]=U,e[54]=W):W=e[54];let V;e[55]!==m||e[56]!==I||e[57]!==W?(V=a.jsxs(nd,{open:m,onOpenChange:p,children:[I,W]}),e[55]=m,e[56]=I,e[57]=W,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(J,{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(ht,{"data-icon":"inline-start",className:"animate-spin"}):a.jsx(Qs,{"data-icon":"inline-start"})}),e[59]=c,e[60]=r,e[61]=h,e[62]=l,e[63]=H):H=e[63];let G;return e[64]!==V||e[65]!==H?(G=a.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b px-2 py-1.5",children:[V,H]}),e[64]=V,e[65]=H,e[66]=G):G=e[66],G}function Jle(n,e){return n.reduce((t,s)=>s.isActive?t+1:e.has(s.sessionId)?s.agentStatus==="completed"?t:t+1:t,0)}function Qle(n,e,t,s){return[...BL(n).entries()].map(([r,o])=>{const i=DL(o);return{key:r,customName:t[i.dirName],dirName:i.dirName,cwd:i.cwd,dirNames:[...new Set(o.map(l=>l.dirName))],total:o.length,live:Jle(o,e),needsYou:o.filter(l=>s.has(l.sessionId)).length}})}function Gw(n,e){return e===null?n:n.filter(t=>r1(t)===e)}function ece(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:El([...n,...s])}const Zw={key:null,sessions:[],loading:!1,loaded:!1};function tce(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 nce(n,e){const t=q.c(9),s=n?`${e?"a":"l"}:${n.key}`:null,[r,o]=w.useState(Zw),i=r.key===s?r:Zw;let l;t[0]!==e||t[1]!==s||t[2]!==n?(l=async()=>{if(!(s===null||!n)){o({key:s,sessions:[],loading:!0,loaded:!1});try{const d=await Promise.all(tce(n,e).map(sce));o(f=>f.key===s?{key:s,sessions:d.flat(),loading:!1,loaded:!0}:f)}catch(d){const f=d;o(m=>m.key===s?{...m,loading:!1}:m),ys.error(f instanceof Error?f.message:"Could not load older sessions")}}},t[0]=e,t[1]=s,t[2]=n,t[3]=l):l=t[3];const c=l;let u;return t[4]!==i.loaded||t[5]!==i.loading||t[6]!==i.sessions||t[7]!==c?(u={sessions:i.sessions,loading:i.loading,loaded:i.loaded,load:c},t[4]=i.loaded,t[5]=i.loading,t[6]=i.sessions,t[7]=c,t[8]=u):u=t[8],u}async function sce(n){const e=await Re(`/api/active-sessions?${n}`);if(!e.ok)throw new Error(`Could not load older sessions (${e.status})`);const t=await e.json();return Array.isArray(t)?t:[]}const rce={key:"all"},oce=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}=T5(),{names:m,rename:p}=L5(),h=Cg(),g=Wn("terminal"),x=Wn("killAny"),{sessions:b,procBySession:v,newlyCompleted:y,loading:k,error:j,refresh:C,removeSession:_,acknowledgeCompleted:S,showArchived:N,setShowArchived:T,setSearchActive:E,archivedCount:A,setArchived:P}=c4(),{awaitingPermission:I,awaitingQuestion:O,awaitingElicitation:R,awaitingDialog:$,awaitingPlan:M}=hle(),z=w.useMemo(()=>new Set([...R,...$]),[R,$]),[F,D]=w.useState(new Set),[L,B]=w.useState(""),[U,W]=Hi(Rn("live-sessions-project-scope"),null),V=!!L.trim(),H=N||V;w.useEffect(()=>(E(V),()=>E(!1)),[V,E]);const G=w.useRef(b),Z=w.useRef(new Set),Y=w.useRef(!1),X=w.useCallback((pe,ke)=>{if(!Y.current)return;const _e=setTimeout(()=>{Z.current.delete(_e),Y.current&&pe()},ke);Z.current.add(_e)},[]);w.useEffect(()=>{const pe=Z.current;return Y.current=!0,()=>{Y.current=!1;for(const ke of pe)clearTimeout(ke);pe.clear()}},[]),w.useEffect(()=>{G.current=b},[b]),w.useEffect(()=>{if(c)return c.current=C,()=>{c.current===C&&(c.current=null)}},[C,c]);const ee=gx(),Q=z5(L),ne=w.useMemo(()=>UL(b,H),[b,H]),re=H?0:A,se=w.useMemo(()=>vle(ne,v,y,I,O,z,M),[ne,v,y,I,O,z,M]),oe=w.useMemo(()=>new Set(se.needsYou.map(pe=>pe.session.sessionId)),[se]),ae=w.useMemo(()=>Qle(ne,v,m,oe),[ne,v,m,oe]),ie=U===null?null:ae.find(pe=>pe.key===U)??null,ce=(ie==null?void 0:ie.customName)??U,te=nce(U===null?rce:ie,H),le=w.useMemo(()=>ece(Gw(ne,U),te.sessions),[ne,U,te.sessions]),ge=w.useMemo(()=>V?le.filter(pe=>{const ke=d[pe.sessionId],_e=m[pe.dirName];return $5(pe,L,[ke,_e])}):le,[le,V,L,d,m]),be=w.useMemo(()=>Q.results?Gw(Q.results,U):ge,[Q.results,U,ge]),ue=se.needsYou.length>0||se.working.length>0,he=!V&&ue&&U===null,me=w.useMemo(()=>U===null?[]:le.filter(pe=>!pe.archived&&!i1(pe,v.get(pe.sessionId))),[U,le,v]),xe=U===null||l!=null&&s1(l.cwd||Rs(l.dirName))===U,je=w.useRef(!1);w.useEffect(()=>{if(je.current||!u||b.length===0)return;je.current=!0;const pe=El(b).slice(0,3),ke=globalThis,_e=()=>{for(const Ye of pe)u(Ye.dirName,Ye.fileName)};let ye=null,Pe=null;return typeof ke.requestIdleCallback=="function"?ye=ke.requestIdleCallback(_e,{timeout:1500}):Pe=setTimeout(_e,300),()=>{ye!=null&&typeof ke.cancelIdleCallback=="function"&&ke.cancelIdleCallback(ye),Pe!=null&&clearTimeout(Pe)}},[b,u]);const Le=w.useCallback(async(pe,ke)=>{ke.stopPropagation(),D(_e=>new Set(_e).add(pe));try{if(!(await Re("/api/kill-process",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pid:pe})})).ok)throw new Error("Could not stop session");X(C,1500)}catch{ys.error("Could not stop session")}X(()=>{D(_e=>{const ye=new Set(_e);return ye.delete(pe),ye})},2e3)},[C,X]),Se=w.useCallback((pe,ke)=>{const _e=G.current.find(ye=>ye.dirName===pe&&ye.fileName===ke);_e&&S(_e.sessionId),t(pe,ke)},[t,S]),Ie=w.useCallback(pe=>{r==null||r(pe.dirName,pe.fileName),_(pe.sessionId)},[r,_]),we=w.useCallback(async(pe,ke,_e)=>{if(P(pe,ke),!await xle(pe,ke)){P(pe,!ke),ys.error(ke?"Could not archive session":"Could not restore session");return}C(),_e&&ys(_e,{action:{label:"Undo",onClick:()=>{we(pe,!ke,null)}}})},[P,C]),Be=w.useCallback(pe=>{we([pe.sessionId],!0,`Archived “${xu(pe,d[pe.sessionId])}”`)},[we,d]),De=w.useCallback(pe=>{we([pe.sessionId],!1,`Restored “${xu(pe,d[pe.sessionId])}”`)},[we,d]),Ue=w.useCallback(pe=>{if(pe.length===0)return;const ke=pe.map(_e=>_e.sessionId);we(ke,!0,`Archived ${ke.length} ${ke.length===1?"session":"sessions"}`)},[we]),We=w.useCallback((pe,ke,_e)=>{const{command:ye,args:Pe}=vP(sn(_e),pe),Ye=`resume_${crypto.randomUUID().slice(0,8)}`;h.send({type:"spawn",id:Ye,name:`Resume ${pe.slice(0,8)}`,command:ye,args:Pe,cwd:ke??void 0,metadata:{type:"terminal"}}),X(C,3e3)},[h,C,X]),Oe={activeSessionKey:e,procBySession:v,killingPids:F,newlyCompleted:y,sessionNames:d,projectNames:m,onSelectSession:Se,onKill:x?Le:void 0,onDuplicateSession:s,onDeleteSession:r?Ie:void 0,onArchiveSession:Be,onUnarchiveSession:De,onRenameSession:f,onPrefetchSession:u,onResumeSession:g?We:void 0};return a.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[a.jsx(Ile,{loading:k,isMobile:ee,searchQuery:L,searchLoading:Q.loading,showArchived:N,archivedCount:A,onSearchQueryChange:B,onToggleShowArchived:()=>T(!N),onRefresh:()=>{gle(),C()}}),a.jsx(Xle,{options:ae,value:U,focused:ie,totalSessions:ne.length,onChange:W,onNewSession:o,creatingSession:i,onRenameProject:p,archivableCount:me.length,onArchiveIdle:()=>Ue(me)}),a.jsx(yl,{className:"flex-1",children:a.jsxs("div",{className:"flex flex-col gap-4 p-2",children:[a.jsx(Rle,{fetchError:Q.error??j,showEmpty:be.length===0&&!(l&&xe)&&!k&&!Q.loading&&!j&&!Q.error,searching:V,loading:k||Q.loading,sessionCount:Q.active?be.length:ne.length,hiddenArchivedCount:re,focusedProject:ce,onShowAllProjects:()=>W(null),onShowArchived:()=>T(!0),onRetry:Q.error?Q.refresh:C}),he&&a.jsx(Ple,{groups:se,activeSessionKey:e,procBySession:v,killingPids:F,sessionNames:d,projectNames:m,onSelectSession:Se,onKill:x?Le:void 0,onResumeSession:g?We:void 0,onPrefetchSession:u}),a.jsx(Hle,{...Oe,sessions:be,pendingSession:xe?l:null,showProject:U===null,older:{canLoad:(U===null||!!ie)&&!te.loaded&&!V,loading:te.loading,load:te.load}})]})})]})}),ice=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=K("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(oce,{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}),ace=w.lazy(()=>Qe(()=>import("./index-CYN2JttE.js"),__vite__mapDeps([34,1,2,3,4])).then(n=>({default:n.MissionControl})));function yx(n){const e=q.c(3),{label:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(Cn,{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 V5(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(ice,{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 H5(n){const e=q.c(8),{navigation:t}=n,{state:s}=hn();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(cle,{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 K5(n){const e=q.c(3),{navigation:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(yx,{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(ace,{onSelectSession:t.actions.handleDashboardSelect})})}),e[1]=t.actions.handleDashboardSelect,e[2]=r):r=e[2],r}function lce({mainView:n,hasSession:e,pendingDirName:t}){return n==="config"?"config":n==="mission"?"mission":e?"session":t?"pending":"dashboard"}function cce({sessionCwd:n,pendingPath:e,sessionDirPath:t,dashboardProjectPath:s}){return n??e??t??s??null}function G5({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}
|
|
194
|
+
`:""}${n} (${i})
|
|
195
|
+
${o}
|
|
196
|
+
${e}
|
|
197
|
+
${o}`}const uce=w.lazy(()=>Qe(()=>import("./ConfigBrowser-vXK8JNMg.js"),__vite__mapDeps([35,1,2,31,3,4])).then(n=>({default:n.ConfigBrowser}))),dce=w.lazy(()=>Qe(()=>import("./PreviewPanel-BaXxki5D.js"),__vite__mapDeps([36,1,2,3,4])).then(n=>({default:n.PreviewPanel}))),fce=w.lazy(()=>Qe(()=>import("./PluginsDialog-DTF9NnK7.js"),__vite__mapDeps([37,1,2,3,4])).then(n=>({default:n.PluginsDialog})));function mce(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(Td,{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(Bj,{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(Hd,{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 bg-background",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 pce(n){const e=q.c(36),{navigation:t,sessionView:s,project:r,view:o,floatingChrome:i}=n,{state:l}=hn(),{session:c,sessionSource:u}=xt();let d,f;if(e[0]!==(c==null?void 0:c.cwd)||e[1]!==u||e[2]!==l.configFilePath||e[3]!==l.dashboardProject||e[4]!==l.pendingCwd||e[5]!==l.pendingDirName||e[6]!==o){f=Symbol.for("react.early_return_sentinel");e:if(d=l.pendingCwd??(l.pendingDirName?Rs(l.pendingDirName):null),o==="config"){let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsx(yx,{label:"Loading configuration…"}),e[9]=p):p=e[9];const h=a.jsx(uce,{projectPath:cce({sessionCwd:c==null?void 0:c.cwd,pendingPath:d,sessionDirPath:u!=null&&u.dirName?Rs(u.dirName):null,dashboardProjectPath:l.dashboardProject?Rs(l.dashboardProject):null}),initialFilePath:l.configFilePath});let g;e[10]!==h?(g=a.jsx(w.Suspense,{fallback:p,children:a.jsx("div",{className:"motion-session-enter flex min-h-0 flex-1 pt-10",children:h})}),e[10]=h,e[11]=g):g=e[11],f=g;break e}e[0]=c==null?void 0:c.cwd,e[1]=u,e[2]=l.configFilePath,e[3]=l.dashboardProject,e[4]=l.pendingCwd,e[5]=l.pendingDirName,e[6]=o,e[7]=d,e[8]=f}else d=e[7],f=e[8];if(f!==Symbol.for("react.early_return_sentinel"))return f;if(o==="mission"){let p;return e[12]!==t?(p=a.jsx("div",{className:"flex min-h-0 flex-1 flex-col pt-10",children:a.jsx(K5,{navigation:t})}),e[12]=t,e[13]=p):p=e[13],p}if(o==="session"){let p;return e[14]!==i||e[15]!==s?(p=a.jsx(mce,{sessionView:s,floatingChrome:i}),e[14]=i,e[15]=s,e[16]=p):p=e[16],p}if(o==="pending"){const p=s.pendingTurns.length>0,h=Lo()?"Only on the machine running this session":void 0;let g;e[17]===Symbol.for("react.memo_cache_sentinel")?(g=Lg()?void 0:h,e[17]=g):g=e[17];const x=g,b=!p&&"justify-center gap-4";let v;e[18]!==b?(v=K("flex min-h-0 min-w-0 flex-1 flex-col bg-background",b),e[18]=b,e[19]=v):v=e[19];let y;e[20]!==p||e[21]!==d||e[22]!==s.pendingTurns?(y=p?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(C5,{projectPath:d}),e[20]=p,e[21]=d,e[22]=s.pendingTurns,e[23]=y):y=e[23];let k;e[24]!==s.pendingComposer?(k=a.jsx(Hd,{children:s.pendingComposer}),e[24]=s.pendingComposer,e[25]=k):k=e[25];let j;e[26]!==p||e[27]!==r?(j=!p&&a.jsxs("div",{className:"flex items-center justify-center gap-2",children:[gt("terminal")&&a.jsx(Of,{reason:h,children:a.jsxs(J,{variant:"outline",size:"xs",disabled:!!h,onClick:r.onOpenTerminal,children:[a.jsx(zi,{"data-icon":"inline-start"}),"Terminal"]})}),gt("hostFiles")&&a.jsxs(a.Fragment,{children:[a.jsx(Of,{reason:x,children:a.jsxs(J,{variant:"outline",size:"xs",disabled:!!x,onClick:()=>a3(r.pendingProject),children:[a.jsx(ng,{"data-icon":"inline-start"}),"Open in editor"]})}),a.jsx(Of,{reason:h,children:a.jsxs(J,{variant:"outline",size:"xs",disabled:!!h,onClick:()=>l3(r.pendingProject),children:[a.jsx(WS,{"data-icon":"inline-start"}),"Reveal in files"]})})]})]}),e[26]=p,e[27]=r,e[28]=j):j=e[28];let C;return e[29]!==v||e[30]!==y||e[31]!==k||e[32]!==j?(C=a.jsxs("div",{className:v,children:[y,k,j]}),e[29]=v,e[30]=y,e[31]=k,e[32]=j,e[33]=C):C=e[33],C}let m;return e[34]!==t?(m=a.jsx(H5,{navigation:t}),e[34]=t,e[35]=m):m=e[35],m}function hce(n){const e=q.c(113),{navigation:t,sessionView:s,project:r,chrome:o}=n,{state:i,config:l}=hn(),{session:c,sessionSource:u}=xt(),[d,f]=w.useState(gce),[m,p]=w.useState();let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=Le=>{p(Le),f(!0)},e[0]=h):h=e[0];const g=h;let x;e[1]===Symbol.for("react.memo_cache_sentinel")?(x=gt("configWrite"),e[1]=x):x=e[1];const b=UC(x),v=r.currentCwd??null;let y;e[2]!==b||e[3]!==v?(y={...b,projectPath:v,openSettings:g},e[2]=b,e[3]=v,e[4]=y):y=e[4];const k=N5(y);let j;e[5]!==s.chatInputRef?(j=function(Se){var we,Be,De;const Ie=((we=s.chatInputRef.current)==null?void 0:we.getText().trimEnd())??"";(Be=s.chatInputRef.current)==null||Be.setText(Ie?`${Ie}
|
|
198
|
+
|
|
199
|
+
${Se}
|
|
200
|
+
`:`${Se}
|
|
201
|
+
`),(De=s.chatInputRef.current)==null||De.focus()},e[5]=s.chatInputRef,e[6]=j):j=e[6];const C=j;let _;e[7]!==C?(_=function(Se){const{path:Ie,text:we,startLine:Be,endLine:De,comment:Ue}=Se;C(G5({path:Ie,text:we,startLine:Be,endLine:De,comment:Ue}))},e[7]=C,e[8]=_):_=e[8];const S=_,N=i.mainView,T=!!c;let E;e[9]!==i.mainView||e[10]!==i.pendingDirName||e[11]!==T?(E=lce({mainView:N,hasSession:T,pendingDirName:i.pendingDirName}),e[9]=i.mainView,e[10]=i.pendingDirName,e[11]=T,e[12]=E):E=e[12];const A=E,P=t.panels.handleToggleSidebar,I=t.actions.handleGoHome,O=o.onOpenCommandPalette;let R,$;e[13]===Symbol.for("react.memo_cache_sentinel")?(R=If("toggleSidebar"),$=If("commandPalette"),e[13]=R,e[14]=$):(R=e[13],$=e[14]);let M;e[15]!==o.onOpenCommandPalette||e[16]!==t.actions.handleGoHome||e[17]!==t.panels.handleToggleSidebar?(M=a.jsx(Bq,{onToggleSidebar:P,onGoHome:I,onOpenCommandPalette:O,sidebarShortcut:R,commandPaletteShortcut:$}),e[15]=o.onOpenCommandPalette,e[16]=t.actions.handleGoHome,e[17]=t.panels.handleToggleSidebar,e[18]=M):M=e[18];const z=M,F=t.panels.showSidebar&&i.mainView!=="config",D=r.currentCwd??null;let L,B,U;e[19]!==C||e[20]!==t.handlers.handleLoadSessionScrollAware||e[21]!==t.panels.activeWorkspacePanel||e[22]!==r.hasFileChanges||e[23]!==r.supportsWorktrees||e[24]!==c||e[25]!==i.mainView||e[26]!==i.sessionChangeKey||e[27]!==D||e[28]!==k?(L={session:c,sessionChangeKey:i.sessionChangeKey,projectPath:D,hasFileChanges:r.hasFileChanges,canAccessHostFiles:gt("hostFiles"),supportsWorktrees:r.supportsWorktrees,openSession:t.handlers.handleLoadSessionScrollAware,composePrompt:C},U=N1(k,L),B=i.mainView==="sessions"?uN(t.panels.activeWorkspacePanel,U):null,e[19]=C,e[20]=t.handlers.handleLoadSessionScrollAware,e[21]=t.panels.activeWorkspacePanel,e[22]=r.hasFileChanges,e[23]=r.supportsWorktrees,e[24]=c,e[25]=i.mainView,e[26]=i.sessionChangeKey,e[27]=D,e[28]=k,e[29]=L,e[30]=B,e[31]=U):(L=e[29],B=e[30],U=e[31]);const W=B,V=(u==null?void 0:u.dirName)??i.pendingDirName??i.dashboardProject??null;let H;e[32]!==t.panels||e[33]!==r?(H=function(Se){r.showPreview&&r.onCloseRightWorkspace(),t.panels.toggleWorkspacePanel(Se)},e[32]=t.panels,e[33]=r,e[34]=H):H=e[34];const G=H;let Z;e[35]!==t.actions||e[36]!==t.panels||e[37]!==V?(Z=function(Se){V&&(t.actions.handleDashboardSelect(V,`${Se}.jsonl`),t.panels.closeWorkspacePanel())},e[35]=t.actions,e[36]=t.panels,e[37]=V,e[38]=Z):Z=e[38];const Y=Z,X=t.panels.showSidebar;let ee;e[39]===Symbol.for("react.memo_cache_sentinel")?(ee=If("toggleSidebar"),e[39]=ee):ee=e[39];let Q;e[40]!==o.killing||e[41]!==o.onKillAll||e[42]!==l.openConfigDialog||e[43]!==t.creatingSession||e[44]!==t.handlers.handleDuplicateSession||e[45]!==t.onStartNewSession||e[46]!==t.panels.handleToggleSidebar||e[47]!==t.panels.showSidebar||e[48]!==r.onOpenTerminal||e[49]!==s.onBackToMain||e[50]!==s.onShowWorkflows||e[51]!==s.workflowCount||e[52]!==F?(Q=a.jsx(Dq,{showSidebar:X,sidebarRendered:F,sidebarShortcut:ee,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}),e[40]=o.killing,e[41]=o.onKillAll,e[42]=l.openConfigDialog,e[43]=t.creatingSession,e[44]=t.handlers.handleDuplicateSession,e[45]=t.onStartNewSession,e[46]=t.panels.handleToggleSidebar,e[47]=t.panels.showSidebar,e[48]=r.onOpenTerminal,e[49]=s.onBackToMain,e[50]=s.onShowWorkflows,e[51]=s.workflowCount,e[52]=F,e[53]=Q):Q=e[53];const ne=Q;let re;e[54]!==t||e[55]!==z||e[56]!==F?(re=F&&a.jsx("div",{className:"view-transition-sidebar panel-enter w-80 shrink-0 border-r bg-sidebar text-sidebar-foreground",children:a.jsx(V5,{navigation:t,header:z})}),e[54]=t,e[55]=z,e[56]=F,e[57]=re):re=e[57];const se=W??null,oe=r.projectFilesRoot??r.currentCwd??null;let ae;e[58]!==S||e[59]!==t.actions.handleJumpToTurn||e[60]!==t.handlers.handleLoadSessionScrollAware||e[61]!==Y||e[62]!==r.backgroundAgents||e[63]!==r.processPanel.handleServersChanged||e[64]!==r.processPanel.handleToggleServer||e[65]!==r.projectFilesRequest||e[66]!==r.worktrees||e[67]!==s.searchInputRef||e[68]!==oe||e[69]!==V?(ae={projectFilesRoot:oe,projectFilesRequest:r.projectFilesRequest,backgroundAgents:r.backgroundAgents,searchInputRef:s.searchInputRef,addProjectContext:S,jumpToTurn:t.actions.handleJumpToTurn,toggleServer:r.processPanel.handleToggleServer,serversChanged:r.processPanel.handleServersChanged,loadSession:t.handlers.handleLoadSessionScrollAware,worktrees:r.worktrees,worktreeDirName:V,openWorktreeSession:Y},e[58]=S,e[59]=t.actions.handleJumpToTurn,e[60]=t.handlers.handleLoadSessionScrollAware,e[61]=Y,e[62]=r.backgroundAgents,e[63]=r.processPanel.handleServersChanged,e[64]=r.processPanel.handleToggleServer,e[65]=r.projectFilesRequest,e[66]=r.worktrees,e[67]=s.searchInputRef,e[68]=oe,e[69]=V,e[70]=ae):ae=e[70];const ie=i.mainView==="mission";let ce;e[71]!==t.panels.handleToggleMission||e[72]!==ie?(ce={id:"mission-control",title:"Mission Control",icon:HS,active:ie,onSelect:t.panels.handleToggleMission},e[71]=t.panels.handleToggleMission,e[72]=ie,e[73]=ce):ce=e[73];let te;e[74]!==t.panels.handleToggleConfig||e[75]!==d||e[76]!==i.mainView?(te=gt("configWrite")?[{id:"plugins",title:"Plugins",icon:rg,active:d,onSelect:()=>f(!0)},{id:"config",title:"Config",icon:KS,active:i.mainView==="config",onSelect:t.panels.handleToggleConfig}]:[],e[74]=t.panels.handleToggleConfig,e[75]=d,e[76]=i.mainView,e[77]=te):te=e[77];let le;e[78]!==ce||e[79]!==te?(le=[ce,...te],e[78]=ce,e[79]=te,e[80]=le):le=e[80];const ge=A!=="session"&≠let be;e[81]!==ne||e[82]!==t||e[83]!==r||e[84]!==s||e[85]!==A?(be=a.jsx(pce,{navigation:t,sessionView:s,project:r,view:A,floatingChrome:ne}),e[81]=ne,e[82]=t,e[83]=r,e[84]=s,e[85]=A,e[86]=be):be=e[86];let ue;e[87]!==ge||e[88]!==be?(ue=a.jsxs("main",{className:"app-view-transition relative flex size-full min-w-0 flex-col overflow-hidden",children:[ge,be]}),e[87]=ge,e[88]=be,e[89]=ue):ue=e[89];let he;e[90]!==t.panels.closeWorkspacePanel||e[91]!==L||e[92]!==se||e[93]!==ae||e[94]!==le||e[95]!==ue||e[96]!==G||e[97]!==U?(he=a.jsx(Gq,{panels:U,context:L,activePanel:se,services:ae,onClosePanel:t.panels.closeWorkspacePanel,onTogglePanel:G,actions:le,children:ue}),e[90]=t.panels.closeWorkspacePanel,e[91]=L,e[92]=se,e[93]=ae,e[94]=le,e[95]=ue,e[96]=G,e[97]=U,e[98]=he):he=e[98];let me;e[99]!==r.currentCwd||e[100]!==r.onCloseRightWorkspace||e[101]!==r.showPreview?(me=r.showPreview&&r.currentCwd&&a.jsx(w.Suspense,{fallback:null,children:a.jsx(dce,{cwd:r.currentCwd,onClose:r.onCloseRightWorkspace})}),e[99]=r.currentCwd,e[100]=r.onCloseRightWorkspace,e[101]=r.showPreview,e[102]=me):me=e[102];let xe;e[103]!==m||e[104]!==d||e[105]!==r.currentCwd||e[106]!==b?(xe=d&>("configWrite")&&a.jsx(w.Suspense,{fallback:null,children:a.jsx(fce,{client:b.client,state:b,currentPath:r.currentCwd??null,initialPluginId:m,onClose:()=>{f(!1),p(void 0)}})}),e[103]=m,e[104]=d,e[105]=r.currentCwd,e[106]=b,e[107]=xe):xe=e[107];let je;return e[108]!==re||e[109]!==he||e[110]!==me||e[111]!==xe?(je=a.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden bg-background",children:[re,he,me,xe]}),e[108]=re,e[109]=he,e[110]=me,e[111]=xe,e[112]=je):je=e[112],je}function gce(){return new URLSearchParams(window.location.search).get("pluginSafeMode")==="1"}function xce(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(Vj,{}),l=a.jsx(qj,{}),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(hce,{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(nW,{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-background 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 bce=[{id:"sessions",label:"Sessions",icon:Si},{id:"chat",label:"Chat",icon:Di},{id:"workspace",label:"Workspace",icon:hA}],vce=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=bce.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:()=>{Lh(),r(c.id)},className:K("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:K("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:K("size-[18px] transition-transform duration-150 ease-out motion-reduce:transition-none",d&&"scale-110"),"aria-hidden":"true"}),c.id==="chat"&&o&&a.jsx(ld,{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 yce(n){const e=q.c(63),{session:t,sessionSource:s,isSubAgentView:r,claudeRawMessages:o,creatingSession:i,onNewSession:l,onDuplicateSession:c,onBackToMain:u,onShowFileChanges:d,hasFileChanges:f,onShowWorkflows:m,workflowCount:p,onSearch:h,expandAll:g,onToggleExpandAll:x}=n;let b;e[0]!==l||e[1]!==t.cwd||e[2]!==s?(b=()=>{s&&l(s.dirName,t.cwd)},e[0]=l,e[1]=t.cwd,e[2]=s,e[3]=b):b=e[3];const v=b;let y;e[4]!==r||e[5]!==u?(y=r&&u&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-sm",onClick:u,"aria-label":"Back to main agent",children:a.jsx(Jh,{"data-icon":"inline-start"})}),e[4]=r,e[5]=u,e[6]=y):y=e[6];let k,j;e[7]===Symbol.for("react.memo_cache_sentinel")?(k=a.jsx(w1,{compact:!0}),j=a.jsx(Zt,{orientation:"vertical",className:"h-4"}),e[7]=k,e[8]=j):(k=e[7],j=e[8]);let C;e[9]!==o?(C=a.jsx(Mk,{rawMessages:o,warnOnly:!0}),e[9]=o,e[10]=C):C=e[10];let _;e[11]!==t.cwd?(_=t.cwd?wr(t.cwd):"Session",e[11]=t.cwd,e[12]=_):_=e[12];let S;e[13]!==_?(S=a.jsx("span",{className:"min-w-0 flex-1 truncate text-center text-xs font-medium text-muted-foreground",children:_}),e[13]=_,e[14]=S):S=e[14];let N;e[15]===Symbol.for("react.memo_cache_sentinel")?(N=a.jsx(qi,{render:a.jsx(J,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"Session actions"}),children:a.jsx(VS,{"data-icon":"inline-start"})}),e[15]=N):N=e[15];let T;e[16]!==t.cwd?(T=t.cwd?wr(t.cwd):"Current session",e[16]=t.cwd,e[17]=T):T=e[17];let E;e[18]!==T?(E=a.jsx("span",{className:"truncate text-foreground",children:T}),e[18]=T,e[19]=E):E=e[19];let A;e[20]!==t.gitBranch||e[21]!==t.model?(A=[t.model,t.gitBranch].filter(Boolean).join(" · ")||"Session actions",e[20]=t.gitBranch,e[21]=t.model,e[22]=A):A=e[22];let P;e[23]!==A?(P=a.jsx("span",{className:"truncate font-normal",children:A}),e[23]=A,e[24]=P):P=e[24];let I;e[25]!==E||e[26]!==P?(I=a.jsxs(Ok,{className:"flex flex-col gap-0.5",children:[E,P]}),e[25]=E,e[26]=P,e[27]=I):I=e[27];let O;e[28]!==i||e[29]!==v||e[30]!==s?(O=s&&a.jsxs(vn,{onClick:v,disabled:i,children:[i?a.jsx(Cn,{}):a.jsx(Qs,{}),a.jsx("span",{children:"New session"})]}),e[28]=i,e[29]=v,e[30]=s,e[31]=O):O=e[31];let R;e[32]!==c?(R=c&&a.jsxs(vn,{onClick:c,children:[a.jsx(fs,{}),a.jsx("span",{children:"Duplicate session"})]}),e[32]=c,e[33]=R):R=e[33];let $;e[34]!==I||e[35]!==O||e[36]!==R?($=a.jsxs(br,{children:[I,O,R]}),e[34]=I,e[35]=O,e[36]=R,e[37]=$):$=e[37];let M;e[38]===Symbol.for("react.memo_cache_sentinel")?(M=a.jsx(du,{}),e[38]=M):M=e[38];let z;e[39]!==h?(z=h&&a.jsxs(vn,{onClick:h,children:[a.jsx(Bn,{}),a.jsx("span",{children:"Search conversation"})]}),e[39]=h,e[40]=z):z=e[40];let F;e[41]!==g||e[42]!==x?(F=x&&a.jsxs(vn,{onClick:x,children:[g?a.jsx(Ju,{}):a.jsx(dl,{}),a.jsx("span",{children:g?"Collapse tool calls":"Expand tool calls"})]}),e[41]=g,e[42]=x,e[43]=F):F=e[43];let D;e[44]!==f||e[45]!==d?(D=f&&d&&a.jsxs(vn,{onClick:d,children:[a.jsx(fl,{}),a.jsx("span",{children:"File changes"})]}),e[44]=f,e[45]=d,e[46]=D):D=e[46];let L;e[47]!==m||e[48]!==p?(L=m&&(p??0)>0&&a.jsxs(vn,{onClick:m,children:[a.jsx(qS,{}),a.jsx("span",{className:"flex-1",children:"Workflows"}),a.jsx(Fe,{variant:"secondary",children:p})]}),e[47]=m,e[48]=p,e[49]=L):L=e[49];let B;e[50]!==z||e[51]!==F||e[52]!==D||e[53]!==L?(B=a.jsxs(br,{children:[z,F,D,L]}),e[50]=z,e[51]=F,e[52]=D,e[53]=L,e[54]=B):B=e[54];let U;e[55]!==$||e[56]!==B?(U=a.jsxs(Wi,{children:[N,a.jsxs(Vi,{align:"end",sideOffset:6,className:"w-72",children:[$,M,B]})]}),e[55]=$,e[56]=B,e[57]=U):U=e[57];let W;return e[58]!==y||e[59]!==U||e[60]!==C||e[61]!==S?(W=a.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-1.5 border-b bg-background px-2",children:[y,k,j,C,S,U]}),e[58]=y,e[59]=U,e[60]=C,e[61]=S,e[62]=W):W=e[62],W}const wce=w.memo(function(e){const t=q.c(11),{isMobile:s}=hn(),{session:r,sessionSource:o}=xt();if(!s||!r)return null;let i;t[0]!==o?(i=o?so(o.fileName):null,t[0]=o,t[1]=i):i=t[1];const l=i;let c;t[2]!==r||t[3]!==(o==null?void 0:o.dirName)?(c=ji(o==null?void 0:o.dirName).contextWindow?r.rawMessages:[],t[2]=r,t[3]=o==null?void 0:o.dirName,t[4]=c):c=t[4];const u=c,d=l!==null;let f;return t[5]!==u||t[6]!==e||t[7]!==r||t[8]!==o||t[9]!==d?(f=a.jsx(yce,{...e,session:r,sessionSource:o,isSubAgentView:d,claudeRawMessages:u}),t[5]=u,t[6]=e,t[7]=r,t[8]=o,t[9]=d,t[10]=f):f=t[10],f}),Sce=50;function kce({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)<Sce||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 Yw=["sessions","chat","workspace"];function Xw(n,e,t){const s=n.indexOf(e);return s===-1?null:n[s+t]??null}function jce(n){var O;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,v,y;if(e[2]!==f||e[3]!==r||e[4]!==s||e[5]!==l||e[6]!==i||e[7]!==t){p=N1(t,s);let R;e[16]!==r?(R=D=>D.id===r,e[16]=r,e[17]=R):R=e[17],h=p.find(R);let $;e[18]!==f?($=f.find(Cce),e[18]=f,e[19]=$):$=e[19],m=$,y=(m==null?void 0:m.title)??(h==null?void 0:h.title);let M;e[20]!==s.projectPath?(M=(O=s.projectPath)==null?void 0:O.split(/[/\\]/).filter(Boolean).at(-1),e[20]=s.projectPath,e[21]=M):M=e[21];const z=M;g="Workspace",x="flex min-h-0 min-w-0 flex-1 flex-col";const F=y?a.jsxs(a.Fragment,{children:[a.jsx(J,{variant:"ghost",size:"icon-lg",onClick:l,"aria-label":"All workspace tools",children:a.jsx(gA,{"data-icon":"inline-start"})}),a.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:y}),a.jsx(J,{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]!==F?(b=a.jsx("header",{className:"flex min-h-14 shrink-0 items-center gap-2 border-b px-3",children:F}),e[22]=F,e[23]=b):b=e[23],v=!y&&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 W;const L=D.icon,B=D.indicator,U=(W=D.badge)==null?void 0:W.call(D,s);return a.jsxs(J,{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"}),B&&a.jsx(B,{context:s,active:!1})]}),U!=null&&a.jsx(Fe,{variant:"secondary",children:U})]}),a.jsxs("span",{className:"flex w-full items-center justify-between gap-2",children:[a.jsx("span",{children:D.title}),a.jsx(at,{"data-icon":"inline-end"})]})]},D.id)}),f.map(Nce)]})}),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]=v,e[15]=y}else m=e[8],p=e[9],h=e[10],g=e[11],x=e[12],b=e[13],v=e[14],y=e[15];const k=y?"relative min-h-0 flex-1":"hidden",j=(m==null?void 0:m.id)??(h==null?void 0:h.id)??"workspace",C=m&&u;let _;e[24]!==j||e[25]!==C?(_=a.jsx(Y4,{fallbackMessage:"Couldn't open this workspace tool",children:C},j),e[24]=j,e[25]=C,e[26]=_):_=e[26];const S=m?"hidden":"h-full min-h-0",N=(h==null?void 0:h.id)??"",T=o&&!m;let E;e[27]!==p||e[28]!==s||e[29]!==l||e[30]!==N||e[31]!==T?(E=a.jsx(yN,{panels:p,context:s,activePanelId:N,active:T,onClosePanel:l}),e[27]=p,e[28]=s,e[29]=l,e[30]=N,e[31]=T,e[32]=E):E=e[32];let A;e[33]!==S||e[34]!==E?(A=a.jsx("div",{className:S,children:E}),e[33]=S,e[34]=E,e[35]=A):A=e[35];let P;e[36]!==_||e[37]!==A||e[38]!==k?(P=a.jsxs("div",{className:k,children:[_,A]}),e[36]=_,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]!==v?(I=a.jsxs("section",{"aria-label":g,className:x,children:[b,v,P]}),e[40]=P,e[41]=g,e[42]=x,e[43]=b,e[44]=v,e[45]=I):I=e[45],I}function Nce(n){const{id:e,title:t,icon:s,onSelect:r}=n;return a.jsxs(J,{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(at,{"data-icon":"inline-end"})]})]},e)}function Cce(n){return n.active}const _ce=w.lazy(()=>Qe(()=>import("./PluginsDialog-DTF9NnK7.js"),__vite__mapDeps([37,1,2,3,4])).then(n=>({default:n.PluginsDialog}))),Tce=w.lazy(()=>Qe(()=>import("./ConfigBrowser-vXK8JNMg.js"),__vite__mapDeps([35,1,2,31,3,4])).then(n=>({default:n.ConfigBrowser})));function Ece(n){var se;const e=q.c(86),{navigation:t,sessionView:s,project:r,active:o}=n,{state:i}=hn(),{session:l,sessionSource:c}=xt(),u=Wn("hostFiles"),d=Wn("configWrite"),[f,m]=w.useState(Ace),[p,h]=w.useState();let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=oe=>{h(oe),m(!0)},e[0]=g):g=e[0];const x=g,b=UC(d),v=r.currentCwd??null;let y;e[1]!==b||e[2]!==v?(y={...b,projectPath:v,openSettings:x},e[1]=b,e[2]=v,e[3]=y):y=e[3];const k=N5(y),[j,C]=w.useState(null),{panels:_}=t,S=_.activeWorkspacePanel===null?j:null,N=(c==null?void 0:c.dirName)??i.pendingDirName??i.dashboardProject;let T;e[4]!==_?(T=function(){C(null),_.closeWorkspacePanel()},e[4]=_,e[5]=T):T=e[5];const E=T;let A;e[6]!==_?(A=function(ae){_.closeWorkspacePanel(),C(ae)},e[6]=_,e[7]=A):A=e[7];const P=A;let I;e[8]!==t.actions||e[9]!==s.chatInputRef?(I=function(ae){const ie=s.chatInputRef.current,ce=(ie==null?void 0:ie.getText().trimEnd())??"";ie==null||ie.setText(ce?`${ce}
|
|
202
|
+
|
|
203
|
+
${ae}
|
|
204
|
+
`:`${ae}
|
|
205
|
+
`),t.actions.handleMobileTabChange("chat"),requestAnimationFrame(()=>ie==null?void 0:ie.focus())},e[8]=t.actions,e[9]=s.chatInputRef,e[10]=I):I=e[10];const O=I,R=r.currentCwd??null;let $;e[11]!==u||e[12]!==O||e[13]!==t.handlers.handleLoadSessionScrollAware||e[14]!==r.hasFileChanges||e[15]!==r.supportsWorktrees||e[16]!==l||e[17]!==i.sessionChangeKey||e[18]!==R?($={session:l,sessionChangeKey:i.sessionChangeKey,projectPath:R,hasFileChanges:r.hasFileChanges,canAccessHostFiles:u,supportsWorktrees:r.supportsWorktrees,openSession:t.handlers.handleLoadSessionScrollAware,composePrompt:O},e[11]=u,e[12]=O,e[13]=t.handlers.handleLoadSessionScrollAware,e[14]=r.hasFileChanges,e[15]=r.supportsWorktrees,e[16]=l,e[17]=i.sessionChangeKey,e[18]=R,e[19]=$):$=e[19];const M=$,z=r.projectFilesRoot??r.currentCwd??null;let F;e[20]!==O?(F=oe=>O(G5(oe)),e[20]=O,e[21]=F):F=e[21];let D;e[22]!==t.actions||e[23]!==r.processPanel?(D=(...oe)=>{const ae=oe;r.processPanel.handleToggleServer(...ae),t.actions.handleMobileTabChange("chat")},e[22]=t.actions,e[23]=r.processPanel,e[24]=D):D=e[24];let L;e[25]!==t.actions||e[26]!==N?(L=oe=>{N&&t.actions.handleDashboardSelect(N,`${oe}.jsonl`)},e[25]=t.actions,e[26]=N,e[27]=L):L=e[27];let B;e[28]!==t.handlers.handleLoadSessionScrollAware||e[29]!==t.handlers.handleMobileJumpToTurn||e[30]!==r.backgroundAgents||e[31]!==r.processPanel.handleServersChanged||e[32]!==r.projectFilesRequest||e[33]!==r.worktrees||e[34]!==s.searchInputRef||e[35]!==F||e[36]!==D||e[37]!==L||e[38]!==z||e[39]!==N?(B={projectFilesRoot:z,projectFilesRequest:r.projectFilesRequest,backgroundAgents:r.backgroundAgents,searchInputRef:s.searchInputRef,addProjectContext:F,jumpToTurn:t.handlers.handleMobileJumpToTurn,toggleServer:D,serversChanged:r.processPanel.handleServersChanged,loadSession:t.handlers.handleLoadSessionScrollAware,worktrees:r.worktrees,worktreeDirName:N,openWorktreeSession:L},e[28]=t.handlers.handleLoadSessionScrollAware,e[29]=t.handlers.handleMobileJumpToTurn,e[30]=r.backgroundAgents,e[31]=r.processPanel.handleServersChanged,e[32]=r.projectFilesRequest,e[33]=r.worktrees,e[34]=s.searchInputRef,e[35]=F,e[36]=D,e[37]=L,e[38]=z,e[39]=N,e[40]=B):B=e[40];let U;e[41]!==_.activeWorkspacePanel||e[42]!==k?(U=((se=uN(_.activeWorkspacePanel,k))==null?void 0:se.id)??_.activeWorkspacePanel,e[41]=_.activeWorkspacePanel,e[42]=k,e[43]=U):U=e[43];let W;e[44]!==_?(W=oe=>{C(null),_.openWorkspacePanel(oe)},e[44]=_,e[45]=W):W=e[45];let V;e[46]!==d?(V=d?[{id:"plugins",title:"Plugins",icon:rg,active:!1,onSelect:()=>m(!0)}]:[],e[46]=d,e[47]=V):V=e[47];const H=S==="mission";let G;e[48]!==P?(G=()=>P("mission"),e[48]=P,e[49]=G):G=e[49];let Z;e[50]!==H||e[51]!==G?(Z={id:"mission",title:"Mission Control",icon:HS,active:H,onSelect:G},e[50]=H,e[51]=G,e[52]=Z):Z=e[52];let Y;e[53]!==d||e[54]!==P||e[55]!==S?(Y=d?[{id:"config",title:"Config",icon:KS,active:S==="config",onSelect:()=>P("config")}]:[],e[53]=d,e[54]=P,e[55]=S,e[56]=Y):Y=e[56];let X;e[57]!==V||e[58]!==Z||e[59]!==Y?(X=[...V,Z,...Y],e[57]=V,e[58]=Z,e[59]=Y,e[60]=X):X=e[60];let ee;e[61]!==d||e[62]!==t||e[63]!==r.currentCwd||e[64]!==S||e[65]!==i.configFilePath?(ee=S==="mission"?a.jsx("div",{className:"flex h-full min-h-0 flex-col",children:a.jsx(K5,{navigation:t})}):S==="config"&&d?a.jsx(w.Suspense,{fallback:a.jsx(yx,{label:"Loading configuration…"}),children:a.jsx("div",{className:"flex h-full min-h-0",children:a.jsx(Tce,{projectPath:r.currentCwd??null,initialFilePath:i.configFilePath})})}):null,e[61]=d,e[62]=t,e[63]=r.currentCwd,e[64]=S,e[65]=i.configFilePath,e[66]=ee):ee=e[66];let Q;e[67]!==o||e[68]!==E||e[69]!==M||e[70]!==U||e[71]!==W||e[72]!==X||e[73]!==ee||e[74]!==k?(Q=a.jsx(jce,{panels:k,context:M,activePanelId:U,active:o,onSelectPanel:W,onClosePanel:E,actions:X,actionContent:ee}),e[67]=o,e[68]=E,e[69]=M,e[70]=U,e[71]=W,e[72]=X,e[73]=ee,e[74]=k,e[75]=Q):Q=e[75];let ne;e[76]!==d||e[77]!==p||e[78]!==f||e[79]!==r.currentCwd||e[80]!==b?(ne=f&&d&&a.jsx(w.Suspense,{fallback:null,children:a.jsx(_ce,{client:b.client,state:b,currentPath:r.currentCwd??null,initialPluginId:p,onClose:()=>{m(!1),h(void 0)}})}),e[76]=d,e[77]=p,e[78]=f,e[79]=r.currentCwd,e[80]=b,e[81]=ne):ne=e[81];let re;return e[82]!==B||e[83]!==Q||e[84]!==ne?(re=a.jsxs(bN,{value:B,children:[Q,ne]}),e[82]=B,e[83]=Q,e[84]=ne,e[85]=re):re=e[85],re}function Ace(){return new URLSearchParams(window.location.search).get("pluginSafeMode")==="1"}const Pce=w.lazy(()=>Qe(()=>import("./MobileFileChanges-B6rggNR6.js"),__vite__mapDeps([38,1,2,3,4])).then(n=>({default:n.MobileFileChanges})));function Ice(n){const e=q.c(61),{navigation:t,sessionView:s,project:r,chrome:o}=n,{state:i}=hn(),{session:l}=xt(),[c,u]=w.useState(!1);let d;e[0]!==t.actions||e[1]!==i.mobileTab?(d={onSwipeLeft:()=>{if(i.mobileTab==="workspace")return;const F=Xw(Yw,i.mobileTab,1);F&&(Lh(),t.actions.handleMobileTabChange(F))},onSwipeRight:()=>{if(i.mobileTab==="workspace")return;const F=Xw(Yw,i.mobileTab,-1);F&&(Lh(),t.actions.handleMobileTabChange(F))}},e[0]=t.actions,e[1]=i.mobileTab,e[2]=d):d=e[2];const f=kce(d);let m;e[3]!==t.actions?(m=F=>{u(!1),t.actions.handleMobileTabChange(F)},e[3]=t.actions,e[4]=m):m=e[4];const p=m,h=o.backgroundServers;let g,x;e[5]===Symbol.for("react.memo_cache_sentinel")?(g=a.jsx(Vj,{}),x=a.jsx(qj,{}),e[5]=g,e[6]=x):(g=e[5],x=e[6]);let b;e[7]!==l||e[8]!==i.mobileTab?(b=!(i.mobileTab==="chat"&&l)&&a.jsx("div",{className:"motion-slide-down-in flex h-12 shrink-0 items-center border-b bg-background px-2",children:a.jsx(w1,{compact:!0})}),e[7]=l,e[8]=i.mobileTab,e[9]=b):b=e[9];let v;e[10]!==t||e[11]!==i.mobileTab?(v=i.mobileTab==="sessions"&&a.jsx(V5,{navigation:t,mobile:!0}),e[10]=t,e[11]=i.mobileTab,e[12]=v):v=e[12];const y=i.mobileTab!=="chat",k=i.mobileTab!=="chat",j=i.mobileTab!=="chat"&&"invisible pointer-events-none";let C;e[13]!==j?(C=K("absolute inset-0 flex min-h-0 min-w-0 flex-col",j),e[13]=j,e[14]=C):C=e[14];let _;e[15]!==o||e[16]!==t||e[17]!==r||e[18]!==c||e[19]!==s?(_=a.jsx($ce,{navigation:t,sessionView:s,project:r,chrome:o,searchOpen:c,onSearchOpenChange:u}),e[15]=o,e[16]=t,e[17]=r,e[18]=c,e[19]=s,e[20]=_):_=e[20];let S;e[21]!==C||e[22]!==_||e[23]!==y||e[24]!==k?(S=a.jsx("div",{"aria-hidden":y,inert:k,className:C,children:_}),e[21]=C,e[22]=_,e[23]=y,e[24]=k,e[25]=S):S=e[25];const N=i.mobileTab!=="workspace",T=i.mobileTab!=="workspace",E=i.mobileTab!=="workspace"&&"hidden";let A;e[26]!==E?(A=K("absolute inset-0 flex min-h-0 min-w-0 flex-col",E),e[26]=E,e[27]=A):A=e[27];const P=i.mobileTab==="workspace";let I;e[28]!==o||e[29]!==t||e[30]!==r||e[31]!==s||e[32]!==P?(I=a.jsx(Ece,{navigation:t,sessionView:s,project:r,chrome:o,active:P}),e[28]=o,e[29]=t,e[30]=r,e[31]=s,e[32]=P,e[33]=I):I=e[33];let O;e[34]!==N||e[35]!==T||e[36]!==A||e[37]!==I?(O=a.jsx("div",{"aria-hidden":N,inert:T,className:A,children:I}),e[34]=N,e[35]=T,e[36]=A,e[37]=I,e[38]=O):O=e[38];let R;e[39]!==f||e[40]!==S||e[41]!==O||e[42]!==v?(R=a.jsxs("main",{ref:f,className:"app-view-transition relative flex flex-1 min-h-0 overflow-hidden",children:[v,S,O]}),e[39]=f,e[40]=S,e[41]=O,e[42]=v,e[43]=R):R=e[43];let $;e[44]!==p||e[45]!==i.mobileTab?($=a.jsx(vce,{activeTab:i.mobileTab,onTabChange:p}),e[44]=p,e[45]=i.mobileTab,e[46]=$):$=e[46];let M;e[47]!==o||e[48]!==r||e[49]!==l||e[50]!==i.sessionChangeKey?(M=l&&r.hasFileChanges&&a.jsx(w.Suspense,{fallback:null,children:a.jsx(Pce,{open:o.fileChangesOpen,onClose:()=>o.onFileChangesOpenChange(!1),session:l,sessionChangeKey:i.sessionChangeKey})}),e[47]=o,e[48]=r,e[49]=l,e[50]=i.sessionChangeKey,e[51]=M):M=e[51];let z;return e[52]!==o.backgroundServers||e[53]!==o.branchModal||e[54]!==o.undoDialog||e[55]!==o.workflowsPanel||e[56]!==R||e[57]!==$||e[58]!==M||e[59]!==b?(z=a.jsxs("div",{className:"flex h-dvh flex-col bg-background text-foreground",children:[h,g,x,b,R,o.workflowsPanel,$,o.undoDialog,o.branchModal,M]}),e[52]=o.backgroundServers,e[53]=o.branchModal,e[54]=o.undoDialog,e[55]=o.workflowsPanel,e[56]=R,e[57]=$,e[58]=M,e[59]=b,e[60]=z):z=e[60],z}function $ce(n){const e=q.c(21),{navigation:t,sessionView:s,project:r,chrome:o,searchOpen:i,onSearchOpenChange:l}=n,{state:c}=hn(),{session:u,isSubAgentView:d}=xt();let f;e[0]!==o||e[1]!==d||e[2]!==t||e[3]!==l||e[4]!==r||e[5]!==i||e[6]!==u||e[7]!==s||e[8]!==c.expandAll||e[9]!==c.pendingDirName?(f=u?a.jsxs("div",{className:"flex flex-1 min-h-0 flex-col",children:[s.teamMembersBar,a.jsx(wce,{creatingSession:t.creatingSession,onNewSession:t.onStartNewSession,onDuplicateSession:t.handlers.handleDuplicateSession,onBackToMain:d?s.onBackToMain:void 0,onShowFileChanges:()=>o.onFileChangesOpenChange(!0),hasFileChanges:r.hasFileChanges,onShowWorkflows:s.onShowWorkflows,workflowCount:s.workflowCount,onSearch:()=>l(!0),expandAll:c.expandAll,onToggleExpandAll:s.onToggleExpandAll}),a.jsx(Td,{searchInputRef:s.searchInputRef,hasMore:s.hasMoreTurns,isLoadingOlder:s.isLoadingOlderTurns,onLoadMore:s.onLoadMoreTurns,mobileSearchOpen:i,onMobileSearchClose:()=>l(!1)})]}):c.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(C5,{projectPath:s.pendingPath??null}),gt("terminal")&&a.jsxs(J,{variant:"outline",size:"xs",onClick:r.onOpenTerminal,children:[a.jsx(zi,{"data-icon":"inline-start"}),"Terminal"]})]})}):a.jsx(H5,{navigation:t}),e[0]=o,e[1]=d,e[2]=t,e[3]=l,e[4]=r,e[5]=i,e[6]=u,e[7]=s,e[8]=c.expandAll,e[9]=c.pendingDirName,e[10]=f):f=e[10];let m;e[11]!==u||e[12]!==s||e[13]!==c.pendingDirName?(m=(u||c.pendingDirName)&&a.jsxs(a.Fragment,{children:[s.todoProgress,u?s.activeComposer:s.pendingComposer]}),e[11]=u,e[12]=s,e[13]=c.pendingDirName,e[14]=m):m=e[14];let p;e[15]!==o.processPanel||e[16]!==m?(p=a.jsxs("div",{className:"shrink-0",children:[o.processPanel,m]}),e[15]=o.processPanel,e[16]=m,e[17]=p):p=e[17];let h;return e[18]!==f||e[19]!==p?(h=a.jsxs(a.Fragment,{children:[f,p]}),e[18]=f,e[19]=p,e[20]=h):h=e[20],h}function Rce(n){const e=q.c(10),{sessionId:t,loadError:s,searchInputRef:r,activeComposer:o,hasMoreTurns:i,isLoadingOlderTurns:l,onLoadMoreTurns:c}=n,{isMobile:u}=hn(),{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-background text-foreground",children:d?a.jsxs("main",{className:"relative flex min-h-0 flex-1 flex-col",children:[a.jsx(Td,{searchInputRef:r,hasMore:i,isLoadingOlder:l,onLoadMore:c}),u?o:a.jsx(Hd,{floating:!0,children:o})]}):a.jsx("main",{className:"flex min-h-0 flex-1 items-center justify-center p-6",children:a.jsx(is,{className:"max-w-md",children:a.jsxs(as,{children:[a.jsx(Is,{variant:"icon",children:s?a.jsx(zs,{}):a.jsx(ht,{className:"animate-spin"})}),a.jsx(ls,{children:s?"Unable to open session":"Opening session"}),a.jsx(cs,{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 Oce=5;function Mc(n,e){const t=Fn(),s=$s();return`${s===null?t:`${t}:${s}`}:${n}/${e}`}class Mce{constructor(){qt(this,"cache",new Map)}get(e,t){const s=Mc(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=Mc(e,t);!this.cache.has(u)&&this.cache.size>=Oce&&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=Mc(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(Mc(e,t)):this.evictLRU()}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 As=new Mce,Jw={};function Z5(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(Jw),[x,b]=w.useState(null),[v,y]=w.useState(null),[k,j]=w.useState(oi),C=w.useRef(""),_=w.useRef(null),S=w.useRef(oi),N=w.useRef("disconnected"),T=w.useRef(e);T.current=e;const E=w.useRef(r);E.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 O=w.useRef(!1),R=(n==null?void 0:n.dirName)??null,$=(n==null?void 0:n.fileName)??null,M=(n==null?void 0:n.rawText)??"",z=(n==null?void 0:n.watchOffset)??new TextEncoder().encode(M).byteLength;return w.useEffect(()=>{if(C.current=M,!M){_.current=null,l(!1);return}const F=I.current;if(F){_.current=F;return}A.current(M).then(D=>{_.current=D})},[M]),w.useEffect(()=>{if(b(null),y(null),!R||!$){l(!1),u("disconnected");return}u("connecting");const F=`/api/watch/${encodeURIComponent(R)}/${encodeURIComponent($)}?offset=${z}`,D=new EventSource(ml(F));let L=null;const B=(ce=3e4)=>{L&&clearTimeout(L),L=setTimeout(()=>{l(!1),f(!1)},ce)};let U="",W=z,V=!1,H=!1,G=!1,Z=null;const Y=()=>{G=!1,Z=null,_.current&&T.current(_.current)},X=()=>{G||(G=!0,Z=requestAnimationFrame(Y))};let ee=!1,Q=null,ne=null;const re=()=>{ee=!1,Q=null,j(S.current)},se=()=>{ee||(ee=!0,Q=requestAnimationFrame(re))},oe=ce=>{ce!==S.current&&(S.current=ce,se(),ce.length>0&&!ne&&(ne=setInterval(()=>{const te=fz(S.current);te!==S.current&&(S.current=te,se()),S.current.length===0&&ne&&(clearInterval(ne),ne=null)},5e3)))},ae=()=>{oe(oi),g(Jw)},ie=()=>{if(H||V||!U)return;const ce=U;U="",V=!0;const te=_.current;(te?P.current(te,ce):A.current(C.current)).then(ge=>{H||(_.current=ge,R&&$&&As.update(R,$,{parsed:ge,source:{rawText:C.current,watchOffset:W}}),X())}).catch(ge=>{console.error("[useLiveSession] worker parse failed:",ge)}).finally(()=>{V=!1,!H&&U&&ie()})};return D.onopen=()=>{var ce;if(N.current!=="connected"){const te=O.current;O.current=!1,N.current="connected",u("connected"),te&&((ce=E.current)==null||ce.call(E))}},D.onmessage=ce=>{try{N.current!=="connected"&&(N.current="connected",u("connected"));const te=JSON.parse(ce.data);if(te.type==="init")te.recentlyActive?(l(!0),B(5e3)):B();else if(te.type==="compacting")te.active&&(l(!0),ae(),B()),f(te.active===!0);else if(te.type==="subagent_activity")l(!0),B();else if(te.type==="runtime_activity")l(!0),B();else if(te.type==="stream_snapshot")l(!0),B(),oe(cz(te.messages??[]));else if(te.type==="stream_delta")l(!0),B(),p(null),b(null),y(null),oe(uz(S.current,te.events??[]));else if(te.type==="rate_limit")y(te.block??null);else if(te.type==="agent_progress")l(!0),B(),g(le=>({...le,[te.toolUseId]:te.summary}));else if(te.type==="prompt_suggestion")b(typeof te.suggestion=="string"?te.suggestion:null);else if(te.type==="turn_error")p(typeof te.message=="string"?te.message:"The turn failed");else if(te.type==="stream_clear")ae(),f(!1);else if(te.type==="lines"&&te.lines.length>0){l(!0),f(!1),B(),oe(dz(S.current,te.lines));const le=te.lines.join(`
|
|
206
|
+
`)+`
|
|
207
|
+
`;W+=new TextEncoder().encode(le).byteLength,C.current+=le,U+=le,ie()}}catch(te){console.error("[useLiveSession] Error processing SSE message:",te)}},D.onerror=()=>{l(!1),f(!1),O.current=N.current==="connected",N.current="disconnected",u("disconnected"),ae()},()=>{H=!0,D.close(),l(!1),N.current="disconnected",u("disconnected"),L&&clearTimeout(L),Z!==null&&cancelAnimationFrame(Z),Q!==null&&cancelAnimationFrame(Q),ne&&clearInterval(ne),S.current=oi,j(oi)}},[R,$,M,z]),{isLive:i,sseState:c,isCompacting:d,streamingOverlay:k,turnError:m,agentProgress:h,promptSuggestion:x,rateLimit:v}}const Lce=3e4;function Y5(n,e,t){const s=q.c(9),r=Lce,[o,i]=w.useState(!1),l=w.useRef(e);let c,u;s[0]!==e?(c=()=>{l.current=e},u=[e],s[0]=e,s[1]=c,s[2]=u):(c=s[1],u=s[2]),w.useEffect(c,u);let d,f;s[3]!==r||s[4]!==n?(d=()=>{if(!n){i(!1);return}let p=!0,h=null;const g=new EventSource(ml(n));i(!1);const x=()=>{h&&clearTimeout(h),h=setTimeout(()=>{p&&i(!1)},r)};return g.onmessage=b=>{if(p)try{const v=JSON.parse(b.data);v.type==="init"?x():v.type==="update"&&(i(!0),x(),l.current())}catch{}},g.onerror=()=>{p&&i(!1)},()=>{p=!1,g.close(),h&&clearTimeout(h)}},f=[n,r],s[3]=r,s[4]=n,s[5]=d,s[6]=f):(d=s[5],f=s[6]),w.useEffect(d,f);let m;return s[7]!==o?(m={isLive:o},s[7]=o,s[8]=m):m=s[8],m}function zce(n,e){const t=n?`/api/team-watch/${encodeURIComponent(n)}`:null;return Y5(t,e)}function Dce(n,e){const[t,s]=w.useState(null),r=w.useRef(null),o=(()=>{if(!n)return null;let l,c=null;const u=n.match(/^([^/]+)\/subagents\/(.+)$/);u?(l=u[1],c=u[2]):l=n.replace(".jsonl","");const d=new URLSearchParams({leadSessionId:l});return c&&d.set("subagentFile",c),e&&d.set("dirName",e),d.toString()})();r.current=o;const i=w.useCallback(async()=>{const l=r.current;if(l)try{const c=await Re(`/api/session-team?${l}`);if(!c.ok){s(null);return}const u=await c.json();s(u?{teamName:u.teamName,config:u.config,currentMemberName:u.currentMemberName||null}:null)}catch{s(null)}},[]);return w.useEffect(()=>{if(!n){s(null);return}i()},[n,i]),zce((t==null?void 0:t.teamName)??null,i),t}function Fce(n,e,t,s){let r=null;return n&&e&&(r=`/api/workflow-watch/${encodeURIComponent(n)}/${encodeURIComponent(e)}`,t&&(r=r+`/${encodeURIComponent(t)}`)),Y5(r,s)}function Uce(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}=Fce(d?n:null,d?e:null,null,u);return{workflows:s,loading:o,isLive:f,refetch:u}}const zh={mode:"bypassPermissions",allowedTools:[],disallowedTools:[]},Bce="cogpit:permissions";function Wce(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 Qw(n,e){const t=await n.json().catch(()=>({error:e}));return typeof t.error=="string"&&t.error?t.error:e}async function X5(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 Qw(l,o(l));return!l.ok&&t==="codex"&&e&&Wce(c)&&(r==null||r(e),l=await n(void 0),c=l.ok?null:await Qw(l,o(l))),{res:l,errorMessage:c}}function qce({sessionSource:n,parsedSessionId:e,cwd:t,permissions:s,onPermissionsApplied:r,model:o,effort:i,contextWindowTokens:l,fastMode:c,ultracode:u,mcpConfig:d,onModelRejected:f,readOnly:m=!1,onCreateSession:p}){const[h,g]=w.useState("idle"),[x,b]=w.useState(),[v,y]=w.useState([]),k=w.useRef(null),j=w.useRef(null),C=w.useRef(!1),_=n!=null&&n.fileName?lu(n.fileName):null,S=e||_,N=n?sn(n.dirName):null,T=w.useCallback(()=>{var $;($=k.current)==null||$.abort(),k.current=null,C.current=!1,g("idle"),b(void 0),y([])},[]);w.useEffect(()=>{var $;j.current!==S&&(C.current?(C.current=!1,($=k.current)==null||$.abort(),k.current=null,g("idle"),b(void 0)):T(),j.current=S)},[S,T]),w.useEffect(()=>()=>{var $;($=k.current)==null||$.abort()},[]),w.useEffect(()=>{m&&T()},[m,T]);const E=w.useCallback(async($,M)=>{if(m)return;if(!S&&p){y(D=>[...D,$]),g("connected"),b(void 0),C.current=!0,r==null||r();try{if(!await p($,M)){C.current=!1,g("idle"),y([]);return}g("idle")}catch(D){C.current=!1,b(D instanceof Error?D.message:"Failed to create session"),g("error"),y([])}return}if(!S)return;y(D=>[...D,$]),g("connected"),b(void 0);const z=s??zh;r==null||r();const F=new AbortController;k.current=F;try{const D={sessionId:S,message:$,images:M||void 0,cwd:t||void 0,permissions:z,effort:i||void 0,contextWindowTokens:l,fastMode:c?!0:void 0,ultracode:u?!0:void 0,mcpConfig:d||void 0},{res:L,errorMessage:B}=await X5(U=>Re("/api/send-message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...D,model:U}),signal:F.signal}),{model:o,agentKind:N,errorFallback:U=>`Request failed (${U.status})`,onModelRejected:f});k.current===F&&(L.ok?g("idle"):(b(B||`Request failed (${L.status})`),g("error"),y(U=>U.slice(0,-1))))}catch(D){if(D instanceof Error&&D.name==="AbortError")return;k.current===F&&(b(D instanceof Error?D.message:"Unknown error"),g("error"),y(L=>L.slice(0,-1)))}},[S,N,t,s,r,o,i,l,c,u,d,f,m,p]),A=w.useCallback(()=>{T()},[T]),P=w.useCallback(()=>{!S||m||Re("/api/interrupt-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:S})}).catch(()=>{})},[S,m]),I=w.useCallback(()=>{var $;($=k.current)==null||$.abort(),k.current=null,P(),g("idle"),y([])},[P]),O=I,R=w.useCallback(($=1)=>{y(M=>M.slice($))},[]);return{status:h,error:x,pendingMessages:v,sendMessage:E,disconnect:A,interrupt:I,stopAgent:O,consumePending:R,isConnected:h==="connected"}}const li={expandAll:!1,expandToolPayloads:!1},Vce={session:null,windowTurns:[],olderTurns:[],sessionSource:null,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...li,sessionChangeKey:0,currentMemberName:null,loadingMember:null,mainView:"sessions",configFilePath:null,mobileTab:"sessions",dashboardProject:null};function eS(n,e,t,s){const r=G4(e,t,s);return r===n.turns?n:{...n,turns:r}}function Lc(n){return{session:n,windowTurns:(n==null?void 0:n.turns)??[],olderTurns:[]}}function Hce(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,...Lc(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:"",...li,mainView:"sessions",currentMemberName:null,dashboardProject:null,sessionChangeKey:n.sessionChangeKey+1,mobileTab:e.isMobile?"chat":n.mobileTab}}case"GO_HOME":return{...n,...Lc(null),sessionSource:null,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...li,mainView:"sessions",currentMemberName:null,dashboardProject:null,mobileTab:e.isMobile?"sessions":n.mobileTab};case"SWITCH_TEAM_MEMBER":return{...n,...Lc(e.session),sessionSource:e.source,activeTurnIndex:null,searchQuery:"",...li,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,...li};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,...li}:{...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:eS(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:eS(n.session,n.windowTurns,e.turns,(s=n.sessionSource)==null?void 0:s.agentKind)};case"RELOAD_SESSION_CONTENT":return{...n,...Lc(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"};default:return n}}function J5(){return w.useReducer(Hce,Vce)}function tS(n){n(),requestAnimationFrame(()=>{n(),requestAnimationFrame(n)})}function Q5({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(R=>R.contentBlocks.flatMap($=>$.kind==="queued_prompt"?[{id:JSON.stringify([$.timestamp??"",$.content]),content:$.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),v=w.useCallback(()=>{requestAnimationFrame(()=>{var R;(R=l.current)==null||R.scrollIntoView({behavior:"smooth"})})},[]),y=w.useCallback(()=>{tS(()=>{const R=i.current;R&&(R.scrollTop=R.scrollHeight),c.current=!0,u.current=!1})},[]),k=w.useCallback(()=>{p.current=!0},[]),j=w.useRef(!1),C=w.useCallback(()=>{const R=i.current;if(!R)return;const $=R.scrollHeight-R.scrollTop-R.clientHeight>10;$!==j.current&&(j.current=$,g($))},[]),_=w.useCallback(()=>{const R=i.current;R&&(c.current=R.scrollHeight-R.scrollTop-R.clientHeight<150,C())},[C]),S=w.useCallback(R=>{d.current=R},[]),N=w.useRef(r);w.useEffect(()=>{if(r===N.current)return;N.current=r;const R=p.current;p.current=!1;const $=()=>{const z=i.current;z&&(R?(z.scrollTop=0,c.current=!1):(z.scrollTop=z.scrollHeight,c.current=!0),u.current=!1)};tS($);const M=setTimeout(()=>{$(),b(r)},150);return()=>clearTimeout(M)},[r]);const T=t.length;w.useEffect(()=>{T>0&&(u.current=!0,v())},[T,v]),w.useEffect(()=>{const R=(n==null?void 0:n.sessionId)??null,$=m.current,M=new Set(f.map(D=>D.id));if(!$||$.sessionId!==R){m.current={sessionId:R,ids:M};return}const z=f.filter(D=>!$.ids.has(D.id));if(m.current={sessionId:R,ids:M},z.length===0||T===0)return;let F=0;for(const D of z){const L=t[F];(L===D.content||(L==null?void 0:L.trim())===""&&D.content.length>0)&&F++}F>0&&s(F)},[n==null?void 0:n.sessionId,f,t,T,s]);const E=(n==null?void 0:n.turns.length)??0;w.useEffect(()=>{if(E===0)return;const R=E-d.current;R>0&&(T>0&&s(Math.min(R,T)),(u.current||c.current)&&(v(),u.current=!1)),d.current=E},[E,T,s,v]);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 R=i.current;R&&(R.scrollTop=R.scrollHeight)}requestAnimationFrame(C)}},[E,P,I,o,e,C]);const O=x===r;return w.useMemo(()=>({chatScrollRef:i,scrollEndRef:l,canScrollDown:h,initialScrollDone:O,handleScroll:_,scrollToBottomInstant:y,requestScrollToTop:k,resetTurnCount:S}),[h,O,_,y,k,S])}async function eT(n,e,t,s){const r=await Re(`/api/sessions/${encodeURIComponent(n)}/${encodeURIComponent(e)}?tail=30`);if(!r.ok)throw new Error(`Failed to load ${s} (${r.status})`);const o=await r.json(),i=new Set(o.headerLines),l=o.tailLines.filter(d=>!i.has(d)),c=[...o.headerLines,...l].join(`
|
|
208
|
+
`);return{parsed:await t(c),source:{dirName:n,fileName:e,rawText:c,agentKind:sn(n),watchOffset:o.totalSize},byteOffset:o.byteOffset,hasMore:o.hasMore}}async function Mo(n,e,t,s){const r=As.get(n,e);if(r)return{parsed:r.parsed,source:r.source};const o=Fn(),i=$s(),{parsed:l,source:c,byteOffset:u,hasMore:d}=await eT(n,e,t,s);if(Fn()!==o||$s()!==i)return{parsed:l,source:c};const f=As.get(n,e);return f?{parsed:f.parsed,source:f.source}:(As.set(n,e,l,c.rawText,u,d,c.agentKind,c.watchOffset),{parsed:l,source:c})}async function tT(n,e,t,s){As.evict(n,e);const r=Fn(),o=$s(),{parsed:i,source:l,byteOffset:c,hasMore:u}=await eT(n,e,t,s);return Fn()===r&&$s()===o&&As.set(n,e,i,l.rawText,c,u,l.agentKind,l.watchOffset),{parsed:i,source:l}}function Kce({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((b,v)=>{u(null),w.startTransition(()=>{n({type:"LOAD_SESSION",session:b,source:v,isMobile:e})}),o(b.turns.length),kle(b.sessionId,b.turns.length),r()},[n,e,o,r]),f=w.useCallback(async(b,v)=>{l==null||l(),u(null);try{const{parsed:y,source:k}=await Mo(b,v,i,"session");d(y,k)}catch(y){u(y instanceof Error?y.message:"Failed to load session")}},[d,i,l]),m=w.useCallback(async b=>{if(s){l==null||l(),u(null),n({type:"SET_LOADING_MEMBER",name:b.name});try{const v=await Re(`/api/team-member-session/${encodeURIComponent(s.teamName)}/${encodeURIComponent(b.name)}`);if(!v.ok)throw new Error(`Failed to find session for ${b.name}`);const{dirName:y,fileName:k}=await v.json(),{parsed:j,source:C}=await Mo(y,k,i,`session for ${b.name}`);w.startTransition(()=>{n({type:"SWITCH_TEAM_MEMBER",session:j,source:C,memberName:b.name})}),o(j.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((b,v)=>{n({type:"JUMP_TO_TURN",index:b,toolCallId:v})},[n]),x=w.useCallback(b=>{b!==t&&n({type:"SET_MOBILE_TAB",tab:b})},[n,t]);return{loadError:c,clearLoadError:p,handleLoadSession:d,handleDashboardSelect:f,handleTeamMemberSwitch:m,handleGoHome:h,handleJumpToTurn:g,handleMobileTabChange:x}}const Gce=/^\/preview\/([^/]+)\/?$/;function wx(n){const e=Gce.exec(n);if(!e)return null;try{const t=decodeURIComponent(e[1]);return t.length>0?t:null}catch{return null}}function nT(){const n=Mt();return n===Qt?"":`/d/${n}`}function Dh(){const n=nT();return n?`${n}/`:"/"}function sT(n){const e=/^\/d\/[^/]+(\/.*)?$/.exec(n);return e?e[1]||"/":n}function Zce(n,e){return bP(n,e)}function Yce(n){const e=nT();if(n.sessionSource){const{dirName:t,fileName:s}=n.sessionSource,r=xP(t,s);return`${e}/${encodeURIComponent(t)}/${encodeURIComponent(r)}`}return n.pendingDirName?`${e}/${encodeURIComponent(n.pendingDirName)}`:n.dashboardProject?`${e}/${encodeURIComponent(n.dashboardProject)}`:Dh()}function nS(n){const e=sT(n),t=wx(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 Xce({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 Mo(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=Zce(m.dirName,m.sessionId);let h;try{h=await Mo(m.dirName,p,o,"session")}catch{e({type:"GO_HOME",isMobile:t});const g=Dh();window.history.replaceState(null,"",g),u.current=g,Ji(Mt(),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=Dh();window.history.replaceState(null,"",p),u.current=p,Ji(Mt(),p)}}finally{c.current--}},[e,t,s,r,o]);return w.useEffect(()=>{if(d.current)return;d.current=!0,Ji(Mt(),window.location.pathname);const m=nS(window.location.pathname);(m.type!=="home"||m.normalizeHome)&&f(m)},[f]),w.useEffect(()=>{if(c.current>0||wx(sT(window.location.pathname)))return;const m=Yce(n);m!==u.current&&(window.history.pushState(null,"",m),u.current=m,Ji(Mt(),m))},[n.sessionSource,n.pendingDirName,n.mainView,n.dashboardProject]),w.useEffect(()=>{const m=()=>{const p=nS(window.location.pathname);u.current=window.location.pathname,Ji(Mt(),window.location.pathname),f(p)};return window.addEventListener("popstate",m),()=>window.removeEventListener("popstate",m)},[f]),{previewLoadError:i}}const Jce=400;function sS(){return Array.from(document.querySelectorAll("[data-live-session]"))}function Qce(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 rS(n){n.focus({preventScroll:!0});const e=Qce(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 eue(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:v,onCommitNavigation:y}=n;let k,j;e[0]!==r||e[1]!==o||e[2]!==t||e[3]!==y||e[4]!==x||e[5]!==b||e[6]!==v||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 C=!1,_=!1,S=null;const N=function(P){var $,M;const I=jv("missionControl");if(I){if(P.key===I){P.repeat||(C=!0,_=P.shiftKey||P.altKey||(I==="Meta"?P.ctrlKey:P.metaKey));return}C&&(_=!0),S=null}if(Vt("commandPalette",P)){P.preventDefault(),u==null||u();return}if(Vt("integratedTerminal",P)){if(!gt("terminal"))return;P.preventDefault(),p();return}if(Vt("preview",P)){P.preventDefault(),h();return}if(Vt("projectFiles",P)){if(!gt("hostFiles"))return;P.preventDefault(),g();return}if(Vt("expandAll",P)){P.preventDefault(),o({type:"SET_EXPAND_ALL",value:!0});return}if(Vt("expandToolPayloads",P)){P.preventDefault(),o({type:"SET_EXPAND_TOOL_PAYLOADS",value:!0});return}if(Vt("toggleSidebar",P)){P.preventDefault(),i();return}if(Vt("toggleStats",P)){P.preventDefault(),l();return}if(Vt("missionControl",P)){P.preventDefault(),c();return}if(Vt("newSession",P)&&(P.preventDefault(),d()),Vt("themeSelector",P)&&(P.preventDefault(),f()),Vt("systemTerminal",P)){if(!gt("terminal"))return;P.preventDefault(),m()}if(P.key==="Escape"&&(o({type:"SET_SEARCH_QUERY",value:""}),($=s.current)==null||$.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=sS()[z-1];D&&(rS(D),D.click())}}const O=Vt("recentSessionForward",P);if(O||Vt("recentSessionBack",P)){P.preventDefault();const z=O?b():x();z&&v(z.dirName,z.fileName)}Vt("focusComposer",P)&&!eN(document.activeElement)&&(P.preventDefault(),(M=r.current)==null||M.focus());const R=Vt("nextLiveSession",P);if(R||Vt("prevLiveSession",P)){P.preventDefault();const z=sS();if(z.length===0)return;const F=z.findIndex(tue);let D;F===-1?D=R?0:z.length-1:D=Math.max(0,Math.min(z.length-1,F+(R?1:-1))),rS(z[D])}},T=function(P){const I=jv("missionControl");if(I&&P.key===I&&C){const O=!_;if(C=!1,_=!1,O){const R=Date.now();S!==null&&R-S<=Jce?(S=null,P.preventDefault(),c()):S=R}else S=null}P.key==="Control"&&(y==null||y())},E=function(){C=!1,_=!1,S=null};return window.addEventListener("keydown",N),window.addEventListener("keyup",T),window.addEventListener("blur",E),()=>{window.removeEventListener("keydown",N),window.removeEventListener("keyup",T),window.removeEventListener("blur",E)}},j=[t,s,r,o,i,l,c,u,d,f,m,p,h,g,x,b,v,y],e[0]=r,e[1]=o,e[2]=t,e[3]=y,e[4]=x,e[5]=b,e[6]=v,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 tue(n){return n===document.activeElement}const oS="cogpit-theme",Nfe=[{id:"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",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",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)"]}];function rT(){const[n,e]=w.useState(()=>{try{const i=localStorage.getItem(oS);if(i==="dark"||i==="oled"||i==="light")return i}catch{}return"dark"}),[t,s]=w.useState(null),r=w.useCallback(i=>{localStorage.setItem(oS,i),e(i),s(null)},[]),o=t??n;return w.useEffect(()=>{const i=document.documentElement.classList;i.remove("dark","theme-oled"),o==="dark"?i.add("dark"):o==="oled"&&i.add("dark","theme-oled")},[o]),{theme:n,activeTheme:o,setTheme:r,setPreview:s}}const nue="cogpit-session-history",Fh=50;function oT(){return Rn(nue)}function sue(){try{const n=localStorage.getItem(oT());if(!n)return[];const e=JSON.parse(n);if(Array.isArray(e))return e.slice(0,Fh)}catch{}return[]}function iS(n){try{localStorage.setItem(oT(),JSON.stringify(n))}catch{}}function rue(){const n=q.c(6);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=sue(),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=(h,g)=>{if(r.current){r.current=!1;return}const x=`${h}/${g}`;t.current=t.current.filter(b=>`${b.dirName}/${b.fileName}`!==x),t.current.unshift({dirName:h,fileName:g}),t.current.length>Fh&&(t.current.length=Fh),s.current=0,iS(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 h=(s.current+1)%t.current.length;return s.current=h,r.current=!0,t.current[h]},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 h=(s.current-1+t.current.length)%t.current.length;return s.current=h,r.current=!0,t.current[h]},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 h=t.current[s.current];h&&(t.current.splice(s.current,1),t.current.unshift(h),iS(t.current)),s.current=0,r.current=!1},n[4]=f):f=n[4];const m=f;let p;return n[5]===Symbol.for("react.memo_cache_sentinel")?(p={push:i,goBack:c,goForward:d,commitNavigation:m},n[5]=p):p=n[5],p}function iT(){return Rn(Bce)}function aS(){try{const n=localStorage.getItem(iT());if(n){const e=JSON.parse(n);return{mode:e.mode||zh.mode,allowedTools:Array.isArray(e.allowedTools)?e.allowedTools:[],disallowedTools:Array.isArray(e.disallowedTools)?e.disallowedTools:[]}}}catch{}return zh}function oue(n){localStorage.setItem(iT(),JSON.stringify(n))}function iue(){const n=q.c(17),[e,t]=w.useState(aS),[s,r]=w.useState(aS),o=w.useRef(!0);let i,l;n[0]!==e?(i=()=>{if(o.current){o.current=!1;return}oue(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 aue=2e3;function lue(n,e){return n.length!==e.length?!1:JSON.stringify(n)===JSON.stringify(e)}function cue(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=>lue(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,aue);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 D5(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 ule(n,u)&&t([])}catch{}},[n]);return{requests:e,plan:s,responding:o,respond:l,respondAll:c}}async function uue(n,e){const t=await rr(`/api/copilot-history/${encodeURIComponent(n)}/preview`,{eventId:e});return t.ok?await t.json():null}async function due(n,e,t){const s=await rr(`/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 fue(n){return n.file_path??n.path??""}function aT(n){const e=[];for(const t of n.toolCalls){if(t.isError||t.awaitingReview||HF(t))continue;const s=fue(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 mue(n,e){return{index:e,id:n.id,userMessage:wd(n.userMessage),toolCalls:aT(n),thinkingBlocks:n.thinking.map(t=>t.thinking),assistantText:[...n.assistantText],timestamp:n.timestamp,model:n.model}}function Vu(n,e,t){const s=[];for(let r=e;r>t;r--){const o=n[r];if(!o)continue;const i=aT(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 pue(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 za(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(...pue(o.toolCalls,o.index))}return t}function lT(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(mue(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 hue=-2;function gue(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)??hue;return l===o.branchPointTurnIndex?o:(s=!0,{...o,branchPointTurnIndex:l})});return s?r:n}function xue(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 cT(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 bue(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 vue(n){const e=new Set(n.map(t=>t.filePath));return{fileCount:e.size,filePaths:[...e],operationCount:n.length}}function yue(n){return{sessionId:n,branches:[],activeBranchId:null}}function zc(n,e){return{...vue(n),turnCount:e}}function wue(n,e,t){return Sj(vj(sn(t)),n,e)}function Sue(n,e,t,s,r,o){var c,u;const i=vj(sn(o)),l=mM(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 Jg(i,n).length>r?null:{cutoffLine:Sj(i,n,s),branchPointTurnId:void 0}}class mi extends Error{constructor(){super("abort")}}const uT="Unable to locate the selected turn in the current session file";function dT(n,e,t,s,r){const o=Sue(t,n.turns[s-1],n.turns[s],s,n.turns.length,e.dirName);if(!o)throw r(uT),new mi;return o}async function kue(n,e,t,s,r,o,i){var y;const l=n.targetTurnIndex,c=Vu(e.turns,e.turns.length-1,l),u=l+1,d=r.split(`
|
|
209
|
+
`).filter(Boolean),{cutoffLine:f,branchPointTurnId:m}=dT(e,t,d,u,i),p=d.slice(f);if(p.length===0)throw i(uT),new mi;const{retained:h,scooped:g}=cT(s.branches,l),x=lT(e.turns,l,p,g,m),b={...s,branches:[...h,x],activeBranchId:null},v=ji(t.dirName).fileCheckpoints?(y=e.turns[l+1])==null?void 0:y.id:void 0;await o({operations:c,sessionSource:t,sessionMutation:{type:"truncate",keepLines:f,expectedLineCount:d.length},state:b,...v?{checkpoint:{sessionId:e.sessionId,userMessageId:v,cwd:e.cwd}}:{}})}function fT(n,e,t){var d,f;const s=e+1,r=xue(n),o=e<n.turns.length-1?wue(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}=bue(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 jue(n,e,t,s,r,o){const i=n.redoUpToArchiveIndex??s.turns.length-1,{restoredLines:l,replacement:c}=fT(s,i,e.dirName),u=za(s.turns,i),d={...t,branches:[...t.branches.filter(m=>m.id!==s.id),...c],activeBranchId:null},f=r.split(`
|
|
210
|
+
`).filter(Boolean);await o({operations:u,sessionSource:e,sessionMutation:{type:"append",lines:l,expectedLineCount:f.length},state:d})}async function Nue(n,e,t,s,r,o,i,l){let c=[...t.branches],u=r.split(`
|
|
211
|
+
`).filter(Boolean);const d=[];if(n.turns.length>s.branchPointTurnIndex+1){const g=Vu(n.turns,n.turns.length-1,s.branchPointTurnIndex);d.push(...g);const{retained:x,scooped:b}=cT(c,s.branchPointTurnIndex);c=x;const v=s.branchPointTurnIndex+1,{cutoffLine:y,branchPointTurnId:k}=dT(n,e,u,v,l),j=u.slice(y);if(j.length>0){const C=lT(n.turns,s.branchPointTurnIndex,j,b,k);c=[...c,C],u=u.slice(0,y)}}const f=o.branchTurnIndex??s.turns.length-1,{restoredLines:m,replacement:p}=fT(s,f,e.dirName);d.push(...za(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(`
|
|
212
|
+
`).filter(Boolean).length},state:h})}const Cue=[];function mT(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,!ji(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(O=>O.ok?O.json():null).then(O=>{m.current===P&&o(O??null)}).catch(O=>{O instanceof Error&&O.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})}),O=await I.json().catch(()=>null);if(!I.ok)throw f((O==null?void 0:O.error)||"Undo transaction failed"),new mi;o(P.state)}catch(I){throw I instanceof mi?I:(f(String(I)),new mi)}},[]),g=(r==null?void 0:r.branches)??Cue,x=n==null?void 0:n.turns,b=w.useMemo(()=>x?gue(g,x):g,[g,x]),{canRedo:v,redoTurnCount:y,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 yd(k.jsonlLines.join(`
|
|
213
|
+
`)).turns}catch{return[]}},[k]),C=w.useCallback(P=>b.filter(I=>I.branchPointTurnIndex===P),[b]),_=w.useCallback(P=>{if(!s||!n)return;const I=P-1;if(I>=n.turns.length-1||I<-1)return;if(ji(e==null?void 0:e.dirName).nativeRewind){const R=n.turns[P];if(!R)return;const $=n.sessionId,M=++p.current,z=()=>p.current===M&&m.current===$,F=R.id.includes("@")?R.id.slice(R.id.lastIndexOf("@")+1):R.id,D=n.turns.length-P;uue(n.sessionId,F).then(L=>{var W;if(!z())return;const B=((W=L==null?void 0:L.files)==null?void 0:W.map(({path:V})=>V).filter(V=>typeof V=="string"))??[],U=L!=null&&L.available?L.fileCount??B.length:0;l({type:"undo",summary:{turnCount:D,fileCount:U,filePaths:B,operationCount:U},targetTurnIndex:I,nativeRewind:{eventId:F,mode:"conversation",filesAvailable:!!(L!=null&&L.available&&U>0)}})}).catch(()=>{z()&&l({type:"undo",summary:{turnCount:D,fileCount:0,filePaths:[],operationCount:0},targetTurnIndex:I,nativeRewind:{eventId:F,mode:"conversation"}})});return}const O=Vu(n.turns,n.turns.length-1,I);l({type:"undo",summary:zc(O,n.turns.length-1-I),targetTurnIndex:I})},[s,n,e==null?void 0:e.dirName]),S=w.useCallback(()=>{if(!s||!v||!k||!n)return;const P=za(k.turns);l({type:"redo",summary:zc(P,k.turns.length),targetTurnIndex:k.branchPointTurnIndex+k.turns.length,branchId:k.id})},[s,v,k,n]),N=w.useCallback(P=>{if(!s||!v||!k||!n)return;const I=P+1,O=za(k.turns,P);l({type:"redo",summary:zc(O,I),targetTurnIndex:k.branchPointTurnIndex+I,branchId:k.id,redoUpToArchiveIndex:P})},[s,v,k,n]),T=w.useCallback((P,I)=>{if(!s||!n)return;const O=b.find(z=>z.id===P);if(!O)return;const R=I??O.turns.length-1,$=n.turns.length>O.branchPointTurnIndex+1?Vu(n.turns,n.turns.length-1,O.branchPointTurnIndex):[],M=za(O.turns,R);l({type:"branch-switch",summary:zc([...$,...M],R+1),targetTurnIndex:O.branchPointTurnIndex,branchId:P,branchTurnIndex:R})},[s,n,b]),E=w.useCallback(async(P=!1)=>{if(!s||!i||!n||!e){l(null);return}u(!0),f(null);try{if(i.nativeRewind){const $=P&&i.nativeRewind.filesAvailable?"conversation-and-files":"conversation",M=await due(n.sessionId,i.nativeRewind.eventId,$);if(!M.ok){f(M.error);return}await t(),l(null);return}const I={...r??yue(n.sessionId),branches:b},O=await Re(`/api/sessions/${encodeURIComponent(e.dirName)}/${encodeURIComponent(e.fileName)}`);if(!O.ok){f("Failed to read session file");return}const R=await O.text();if(i.type==="undo")await kue(i,n,e,I,R,h,f);else if(i.type==="redo"){const $=b.find(M=>M.id===i.branchId);if(!$){l(null);return}await jue(i,e,I,$,R,h)}else if(i.type==="branch-switch"){const $=b.find(M=>M.id===i.branchId);if(!$){l(null);return}await Nue(n,e,I,$,R,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 mi))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:v,redoTurnCount:y,redoGhostTurns:j,branches:b,branchesAtTurn:C,requestUndo:_,requestRedoAll:S,requestRedoUpTo:N,requestBranchSwitch:T,confirmState:i,confirmApply:E,confirmCancel:A,isApplying:c,applyError:d}}async function _ue(n){try{const t=await(await Ur("/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 Tue(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:gP(t==null?void 0:t.mode,zo),useBuiltInEditor:(t==null?void 0:t.useBuiltInEditor)===!0}}function Eue(){const n=q.c(26),[e,t]=w.useState(!0),[s,r]=w.useState(null),[o,i]=w.useState(null),[l,c]=w.useState(zo),[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 v;n[0]===Symbol.for("react.memo_cache_sentinel")?(v=B=>{i(B.claudeDir),c(B.defaultAgentKind),RR(B.useBuiltInEditor)},n[0]=v):v=n[0];const y=v;let k;n[1]===Symbol.for("react.memo_cache_sentinel")?(k=async()=>{var W;(W=b.current)==null||W.abort();const B=new AbortController;b.current=B;const U=await _ue(B.signal);B.signal.aborted||b.current!==B||(m(U.url),h(U.disabled))},n[1]=k):k=n[1];const j=k;let C,_;n[2]===Symbol.for("react.memo_cache_sentinel")?(C=()=>()=>{var B;(B=b.current)==null||B.abort()},_=[],n[2]=C,n[3]=_):(C=n[2],_=n[3]),w.useEffect(C,_);let S;n[4]===Symbol.for("react.memo_cache_sentinel")?(S=()=>{const B=new AbortController;return t(!0),r(null),Tue(B.signal).then(y).catch(U=>{U instanceof Error&&U.name==="AbortError"||(i(null),r(U instanceof Error?U.message:"Failed to load configuration"))}).finally(()=>{B.signal.aborted||t(!1)}),()=>B.abort()},n[4]=S):S=n[4];let N;n[5]!==g?(N=[y,g],n[5]=g,n[6]=N):N=n[6],w.useEffect(S,N);let T,E;n[7]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{const B=()=>x(Iue);return window.addEventListener("cogpit-auth-changed",B),()=>window.removeEventListener("cogpit-auth-changed",B)},E=[],n[7]=T,n[8]=E):(T=n[7],E=n[8]),w.useEffect(T,E);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 O=I;let R;n[13]!==o?(R=B=>{if(d(!1),B!==o){i(B),window.location.reload();return}x(Pue),j()},n[13]=o,n[14]=R):R=n[14];const $=R;let M;n[15]===Symbol.for("react.memo_cache_sentinel")?(M=()=>d(!0),n[15]=M):M=n[15];const z=M;let F;n[16]===Symbol.for("react.memo_cache_sentinel")?(F=()=>x(Aue),n[16]=F):F=n[16];const D=F;let L;return n[17]!==o||n[18]!==s||n[19]!==e||n[20]!==l||n[21]!==$||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:O,handleConfigSaved:$,retryConfig:D,networkUrl:f,networkAccessDisabled:p},n[17]=o,n[18]=s,n[19]=e,n[20]=l,n[21]=$,n[22]=p,n[23]=f,n[24]=u,n[25]=L):L=n[25],L}function Aue(n){return n+1}function Pue(n){return n+1}function Iue(n){return n+1}const lS={authenticated:!0,edition:"personal",user:null,capabilities:cd},xs={authenticated:!1,edition:"personal",user:null,capabilities:xl},pT=Object.keys(cd);function cS(n,e){return n!==null&&n.edition===e&&n.authenticated&&(e==="personal"?n.user===null:n.user!==null)&&pT.every(t=>{var s;return typeof((s=n.capabilities)==null?void 0:s[t])=="boolean"})}function $ue(n,e){const t={...xl};for(const s of pT)t[s]=n[s]&&e[s];return t}async function uS(n,e){try{const t=await n("/api/me",{signal:e});return t.ok?await t.json():null}catch{return null}}async function Rue(n){try{const e=await Re("/api/hello",{signal:n});return e.ok?(await e.json()).edition==="team"?"team":"personal":null}catch{return null}}function ca(n){var e;return ci(n),XS(((e=n.user)==null?void 0:e.id)??null),n}function Oue(n){const e=q.c(8);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={...xs,checked:!1},e[0]=t):t=e[0];const[s,r]=w.useState(t),[o,i]=w.useState(0),l=w.useRef(null),c=w.useRef(!1);let u;e[1]!==n?(u=()=>{var y;if((y=l.current)==null||y.abort(),n===null){c.current=!1,ci(xs),r({...xs,checked:!1});return}const p=c.current;c.current=!1,ci(xs),r(k=>p?{...k,capabilities:xl,checked:!1}:{...xs,checked:!1});const h=new AbortController;l.current=h;const g=Lo(),x=uS(Ur,h.signal),b=g?Rue(h.signal):Promise.resolve(n),v=g?uS(Re,h.signal):Promise.resolve(null);return Promise.all([x,b,v]).then(k=>{const[j,C,_]=k;if(h.signal.aborted)return;const S=cS(j,n)?j:n==="personal"?lS:null;if(!S||C===null){r({...ca(xs),checked:!1});return}if(!g){r({...ca(S),checked:!0});return}const N=cS(_,C)?_:C==="personal"?lS:null;if(!N){r({...ca(xs),checked:!1});return}r({...ca({authenticated:S.authenticated,edition:S.edition,user:S.user,capabilities:$ue(S.capabilities,N.capabilities)}),checked:!0})}).catch(()=>{h.signal.aborted||r({...ca(xs),checked:!1})}),()=>{h.abort(),l.current===h&&(l.current=null)}},e[1]=n,e[2]=u):u=e[2];let d;e[3]!==n||e[4]!==o?(d=[n,o],e[3]=n,e[4]=o,e[5]=d):d=e[5],w.useEffect(u,d);let f,m;return e[6]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{const p=()=>{var g;(g=l.current)==null||g.abort(),c.current=!1,ci(xs),XS(null),r({...xs,checked:!1}),i(zue)},h=g=>{var v,y;const x=Mt();if(x===Qt)return;const b=(v=g.detail)==null?void 0:v.deviceId;b&&b!==x||((y=l.current)==null||y.abort(),c.current=!0,ci(xs),r(Lue),i(Mue))};return window.addEventListener("cogpit-auth-changed",p),window.addEventListener("cogpit-devices-changed",h),()=>{window.removeEventListener("cogpit-auth-changed",p),window.removeEventListener("cogpit-devices-changed",h)}},m=[],e[6]=f,e[7]=m):(f=e[6],m=e[7]),w.useEffect(f,m),s}function Mue(n){return n+1}function Lue(n){return{...n,capabilities:xl,checked:!1}}function zue(n){return n+1}const Due=3e4;function Fue(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(),Due);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 Uue(){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 Bue(n,e){return n?`${n}.jsonl`:e??null}async function hT(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 Wue=300,wp=new Map;function Uh(n,e){const t=Rn(n),s=wp.get(t),r=s?{...s.patch,...e}:e;s&&clearTimeout(s.timer);const o=setTimeout(()=>{wp.delete(t),Rn(n)===t&&(async()=>{try{await rr(`/api/session-config/${encodeURIComponent(n)}`,r,{method:"PUT"})}catch{}})()},Wue);wp.set(t,{patch:r,timer:o})}function Bh(n){return new Set(n.filter(e=>e.status==="connected").map(e=>e.name))}async function dS(n){const e=await hT(n);return Array.isArray(e==null?void 0:e.mcpServers)?e.mcpServers:null}function Sp(n,e){Uh(n,{mcpServers:e})}async function que(n){if(!n.ok)return null;const e=await n.json();return{servers:e.servers??[],configs:e.configs??{}}}async function fS(n,e){try{const t=await Re(n,{signal:e});if(e.aborted)return null;const s=await que(t);return e.aborted?null:s}catch{return null}}async function mS(n,e,t){const s=Bh(t);if(s.size===0)return[];if(n){const r=await dS(n);if(r)return r.filter(o=>s.has(o))}if(e&&n!==e){const r=await dS(e);if(r)return r.filter(o=>s.has(o))}return[...s]}function Vue(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 v=w.useRef(void 0);w.useEffect(()=>{var S,N;if(!s||!n){(S=h.current)==null||S.abort(),v.current=void 0,o([]),l({}),u([]),f(!1),p(!1);return}const _=new AbortController;return(N=h.current)==null||N.abort(),o([]),l({}),u([]),f(!0),p(!1),v.current=n,fS(`/api/mcp-servers?cwd=${encodeURIComponent(n)}`,_.signal).then(async T=>{if(_.signal.aborted||v.current!==n||!T)return;o(T.servers),l(T.configs);const E=await mS(b.current,g.current,T.servers);_.signal.aborted||v.current!==n||u(E)}).finally(()=>{_.signal.aborted||v.current!==n||(f(!1),p(!0))}),()=>_.abort()},[n,s]),w.useEffect(()=>()=>{var _;return(_=h.current)==null?void 0:_.abort()},[]),w.useEffect(()=>{if(r.length===0||!x)return;let _=!1;return mS(x,e,r).then(S=>{_||b.current!==x||u(S)}),()=>{_=!0}},[x]);const y=w.useCallback(_=>{u(S=>{const N=S.includes(_)?S.filter(T=>T!==_):[...S,_];return b.current&&Sp(b.current,N),N})},[]),k=w.useCallback(_=>{u(()=>(b.current&&Sp(b.current,_),_))},[]),j=w.useCallback(()=>{var S;if(!s||!n)return;(S=h.current)==null||S.abort();const _=new AbortController;h.current=_,f(!0),fS(`/api/mcp-servers?cwd=${encodeURIComponent(n)}&refresh=1`,_.signal).then(N=>{if(_.signal.aborted||v.current!==n||!N)return;o(N.servers),l(N.configs);const T=Bh(N.servers);u(E=>{const A=E.filter(P=>T.has(P));return b.current&&Sp(b.current,A),A})}).finally(()=>{_.signal.aborted||h.current!==_||f(!1)})},[n,s]),C=w.useMemo(()=>{if(r.length===0)return null;const _=Bh(r);if(c.length===_.size&&_.size>0&&c.every(T=>_.has(T))||!c.every(T=>i[T]))return null;const N=Object.fromEntries(c.map(T=>[T,i[T]]));return JSON.stringify({mcpServers:N})},[c,i,r]);return{servers:r,selectedServers:c,mcpConfigJson:C,loading:d,loaded:m,toggleServer:y,setSelection:k,refresh:j}}function Hue(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 y=((r=(s=x.result)==null?void 0:s.match(/(?:Task\s*#?|task[_ ]?id["': ]+)(\d+)/i))==null?void 0:r[1])??String(h);p.set(y,{id:y,content:b.subject||b.description||`Task ${y}`,activeForm:b.activeForm||b.subject||`Working on task ${y}`,status:"pending",owner:b.owner});continue}if(x.name==="TaskUpdate"){const b=x.input,v=String(b.taskId??"");if(!v)continue;if(b.status==="deleted"){p.delete(v);continue}const y=p.get(v)??{id:v,content:b.subject||b.description||`Task ${v}`,activeForm:b.activeForm||b.subject||`Working on task ${v}`,status:"pending"};p.set(v,{...y,content:b.subject||b.description||y.content,activeForm:b.activeForm||y.activeForm,status:b.status||y.status,owner:b.owner??y.owner,blockedBy:b.addBlockedBy?[...new Set([...y.blockedBy??[],...b.addBlockedBy])]:y.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(Gue),e[4]=l,e[5]=c):c=e[5];const u=c.length;let d;e[6]!==l?(d=l.find(Kue)??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 Kue(n){return n.status==="in_progress"}function Gue(n){return n.status==="completed"}function Zue(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 Yue(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(Xue).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 Xue(n){return n.json()}function pS(n,e){const t=q.c(6),[s,r]=Hi(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}function hS(){if(typeof window>"u")return Ot.fileChanges;try{if(JSON.parse(localStorage.getItem("panel-worktrees-visible")??"false")===!0)return Ot.worktrees;if(JSON.parse(localStorage.getItem("panel-stats-visible")??"false")===!0)return Ot.sessionInfo;if(JSON.parse(localStorage.getItem("panel-file-changes-visible")??"true")===!1)return null}catch{}return Ot.fileChanges}function Jue(n,e){const t=q.c(42),[s,r]=pS("panel-sidebar-visible",!0),[o,i]=pS("panel-workflows-visible",!1);let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l=hS(),t[0]=l):l=t[0];const[c,u]=Hi("workspace-panel-active",l);let d;t[1]!==c?(d=typeof c=="string"||c===null?c:hS(),t[1]=c,t[2]=d):d=t[2];const f=d,[m,p]=w.useState(!1),[h,g]=w.useState(!1);let x;t[3]!==r||t[4]!==s?(x=()=>{w.startTransition(()=>r(!s))},t[3]=r,t[4]=s,t[5]=x):x=t[5];const b=x;let v;t[6]!==e||t[7]!==u||t[8]!==n.mainView?(v=B=>{w.startTransition(()=>{const U=n.mainView==="config"||n.mainView==="mission";n.mainView==="config"&&e({type:"CLOSE_CONFIG"}),n.mainView==="mission"&&e({type:"CLOSE_MISSION"}),u(W=>U||Tv(W)!==Tv(B)?B:null)})},t[6]=e,t[7]=u,t[8]=n.mainView,t[9]=v):v=t[9];const y=v;let k;t[10]!==e||t[11]!==u||t[12]!==n.mainView?(k=B=>{w.startTransition(()=>{n.mainView==="config"&&e({type:"CLOSE_CONFIG"}),n.mainView==="mission"&&e({type:"CLOSE_MISSION"}),u(B)})},t[10]=e,t[11]=u,t[12]=n.mainView,t[13]=k):k=t[13];const j=k;let C;t[14]!==u?(C=()=>{w.startTransition(()=>u(null))},t[14]=u,t[15]=C):C=t[15];const _=C;let S;t[16]!==e||t[17]!==n.mainView?(S=()=>{const B=n.mainView==="config";w.startTransition(()=>{e({type:B?"CLOSE_CONFIG":"OPEN_CONFIG"})})},t[16]=e,t[17]=n.mainView,t[18]=S):S=t[18];const N=S;let T;t[19]!==e||t[20]!==n.mainView?(T=()=>{const B=n.mainView==="mission";w.startTransition(()=>{e({type:B?"CLOSE_MISSION":"OPEN_MISSION"})})},t[19]=e,t[20]=n.mainView,t[21]=T):T=t[21];const E=T;let A;t[22]!==e?(A=B=>{w.startTransition(()=>{e({type:"OPEN_CONFIG",filePath:B})})},t[22]=e,t[23]=A):A=t[23];const P=A;let I;t[24]===Symbol.for("react.memo_cache_sentinel")?(I=()=>p(!0),t[24]=I):I=t[24];const O=I;let R;t[25]===Symbol.for("react.memo_cache_sentinel")?(R=()=>p(!1),t[25]=R):R=t[25];const $=R;let M;t[26]===Symbol.for("react.memo_cache_sentinel")?(M=()=>g(Que),t[26]=M):M=t[26];const z=M;let F;t[27]===Symbol.for("react.memo_cache_sentinel")?(F=()=>g(!1),t[27]=F):F=t[27];const D=F;let L;return t[28]!==f||t[29]!==_||t[30]!==P||t[31]!==N||t[32]!==E||t[33]!==b||t[34]!==j||t[35]!==i||t[36]!==m||t[37]!==s||t[38]!==h||t[39]!==o||t[40]!==y?(L={showSidebar:s,showWorkflows:o,activeWorkspacePanel:f,showProjectSwitcher:m,showThemeSelector:h,handleToggleSidebar:b,toggleWorkspacePanel:y,openWorkspacePanel:j,closeWorkspacePanel:_,handleToggleConfig:N,handleToggleMission:E,handleEditConfig:P,handleOpenProjectSwitcher:O,handleCloseProjectSwitcher:$,handleToggleThemeSelector:z,handleCloseThemeSelector:D,setShowWorkflows:i},t[28]=f,t[29]=_,t[30]=P,t[31]=N,t[32]=E,t[33]=b,t[34]=j,t[35]=i,t[36]=m,t[37]=s,t[38]=h,t[39]=o,t[40]=y,t[41]=L):L=t[41],L}function Que(n){return!n}function ede(n){var V;const{state:e,dispatch:t,isMobile:s,handleJumpToTurn:r,markPermissionsApplied:o,hasPermsPendingChanges:i,permissionsConfig:l,selectedModel:c,selectedEffort:u,fastMode:d,ultracode:f,mcpConfig:m,scrollRequestScrollToTop:p,handleDashboardSelect:h,workerParse:g}=n,x=w.useCallback(async()=>{if(!e.sessionSource)return;const{dirName:H,fileName:G}=e.sessionSource;try{const{parsed:Z,source:Y}=await tT(H,G,g,"session");t({type:"RELOAD_SESSION_CONTENT",session:Z,source:Y})}catch{}},[e.sessionSource,t,g]),[b,v]=w.useState(null),y=w.useCallback(H=>v(H),[]),k=w.useCallback(()=>v(null),[]),j=w.useCallback(async(H,G)=>{try{const Z=await Re("/api/branch-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dirName:H,fileName:G})});if(!Z.ok)return;const Y=await Z.json(),{parsed:X,source:ee}=await Mo(Y.dirName,Y.fileName,g,"session");t({type:"LOAD_SESSION",session:X,source:ee,isMobile:s})}catch{}},[t,s,g]),C=w.useCallback(()=>{e.sessionSource&&j(e.sessionSource.dirName,e.sessionSource.fileName)},[e.sessionSource,j]),_=w.useCallback(async(H,G)=>{try{await Re("/api/delete-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dirName:H,fileName:G})})}catch{}},[]),S=w.useCallback(async H=>{var X,ee;if(!e.sessionSource)return;const{dirName:G,fileName:Z}=e.sessionSource,Y=(ee=(X=e.session)==null?void 0:X.turns[H])==null?void 0:ee.id;try{const Q=await Re("/api/branch-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dirName:G,fileName:Z,turnIndex:H,turnUuid:Y})});if(!Q.ok)return;const ne=await Q.json(),{parsed:re,source:se}=await Mo(ne.dirName,ne.fileName,g,"session");t({type:"LOAD_SESSION",session:re,source:se,isMobile:s})}catch{}},[e.sessionSource,e.session,t,s,g]),N=w.useCallback((H,G)=>{r(H,G),t({type:"SET_MOBILE_TAB",tab:"chat"})},[r,t]),[T,E]=w.useState({}),A=w.useRef(c);A.current=c;const P=w.useRef(u);P.current=u;const I=w.useRef(m);I.current=m;const O=w.useRef(d);O.current=d;const R=w.useRef(f);R.current=f;const $=w.useRef(l);$.current=l;const M=((V=e.session)==null?void 0:V.sessionId)??null,z=w.useRef(null);w.useEffect(()=>{M!==z.current&&(z.current=M,M&&E(H=>M in H?H:{...H,[M]:{model:A.current,effort:P.current,fastMode:O.current,ultracode:R.current,mcpConfig:I.current}}))},[M]);const F=M?T[M]:void 0,D=m!==((F==null?void 0:F.mcpConfig)??null),L=F!=null&&(c!==F.model||u!==F.effort||d!==F.fastMode||f!==F.ultracode||i||D),B=w.useCallback(async()=>{var ne,re;if(!M)return;const H=A.current,G=P.current,Z=O.current,Y=R.current,X=I.current,ee=$.current,Q=((ne=e.sessionSource)==null?void 0:ne.agentKind)??sn(((re=e.sessionSource)==null?void 0:re.dirName)??null);pn(Q).settingsApply==="live"&&await Re(`/api/claude/settings/${encodeURIComponent(M)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:H,effort:G,fastMode:Z,ultracode:Y,mcpConfig:X,permissionMode:ee.mode,allowedTools:ee.allowedTools,disallowedTools:ee.disallowedTools})}),E(se=>({...se,[M]:{model:H,effort:G,fastMode:Z,ultracode:Y,mcpConfig:X}})),o()},[M,e.sessionSource,o]),U=w.useCallback(async()=>{if(M)try{await Re("/api/stop-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:M})})}catch{}},[M]),W=w.useCallback((H,G)=>{so(G)&&p(),h(H,G)},[p,h]);return{reloadSession:x,branchModalTurn:b,setBranchModalTurn:v,handleOpenBranches:y,handleCloseBranchModal:k,handleDuplicateSessionByPath:j,handleDuplicateSession:C,handleDeleteSession:_,handleBranchFromHere:S,handleMobileJumpToTurn:N,hasSettingsChanges:L,handleApplySettings:B,handleStopSession:U,handleLoadSessionScrollAware:W}}function gT(){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-CnA52U1J.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(()=>yd(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(()=>wM(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 tde=30;function xT({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?As.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=As.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=${tde}`);if(!x.ok)return 0;const b=await x.json(),v=b.lines.length>0&&b.hasMore;if(u.current===p&&i(v),b.lines.length===0)return As.update(n,e,{hasMore:v,nextByteOffset:b.byteOffset}),0;const y=new Set(b.headerLines),k=b.lines.filter(_=>!y.has(_)),j=await s([...b.headerLines,...k].join(`
|
|
214
|
+
`)),C=G4(h.olderTurns,j.turns,h.source.agentKind);return As.update(n,e,{hasMore:v,nextByteOffset:b.byteOffset,olderTurns:C}),u.current!==p?0:(r(C),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 nde(n){const e=q.c(47),{agentKind:t,session:s,sessionSource:r,pendingDirName:o,isLive:i}=n,l=t??zo,[c,u]=w.useState(""),[d,f]=w.useState(""),[m,p]=w.useState(null),[h,g]=w.useState(!1),[x,b]=w.useState(!1),{options:v,fastTier:y,imageInput:k,normalizeEffort:j}=fk(l,c),C=c||(s==null?void 0:s.model);let _;e[0]!==l||e[1]!==C?(_=$P(l,C),e[0]=l,e[1]=C,e[2]=_):_=e[2];const S=_,N=x&&S;let T;e[3]!==j||e[4]!==d||e[5]!==N?(T=N?"xhigh":j(d),e[3]=j,e[4]=d,e[5]=N,e[6]=T):T=e[6];const E=T,A=!!y,P=A&&h,[I,O]=w.useState(null),R=w.useRef(null),$=(r==null?void 0:r.fileName)??null,M=w.useRef($);let z,F;e[7]!==$?(z=()=>{const se=M.current;M.current=$,!(se===null||se===$)&&(b(!1),p(null))},F=[$],e[7]=$,e[8]=z,e[9]=F):(z=e[8],F=e[9]),w.useEffect(z,F);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 B;e[13]!==l?(B=se=>{u(oe=>oe===se?"":oe),O(`${se} is unavailable for this account. Cogpit retried the turn with ${es(l).displayName}'s default model.`)},e[13]=l,e[14]=B):B=e[14];const U=B;let W;e[15]===Symbol.for("react.memo_cache_sentinel")?(W=()=>{O(null)},e[15]=W):W=e[15];const V=W;let H,G;e[16]!==v||e[17]!==o||e[18]!==c||e[19]!==r?(H=()=>{c&&(!r&&!o||v.some(se=>se.value===c)||u(""))},G=[v,c,r,o],e[16]=v,e[17]=o,e[18]=c,e[19]=r,e[20]=H,e[21]=G):(H=e[20],G=e[21]),w.useEffect(H,G);let Z,Y;e[22]!==I?(Z=()=>{if(!I)return;const se=setTimeout(()=>O(null),12e3);return()=>clearTimeout(se)},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 ee,Q;e[25]!==l||e[26]!==i||e[27]!==X?(ee=()=>{if(!i||!X||!pn(l).modelFallbackNotices)return;let se;for(let te=X.length-1;te>=0;te=te-1,te){const le=X[te];if(le.type==="system"&&le.subtype==="model_refusal_fallback"){se=le;break}}if(!se)return;const oe=typeof se.uuid=="string"?se.uuid:`${String(se.original_model)}:${String(se.fallback_model)}:${String(se.request_id)}`;if(R.current===oe)return;R.current=oe;const ae=typeof se.original_model=="string"?se.original_model:"Fable",ie=typeof se.fallback_model=="string"?se.fallback_model:"Opus",ce=typeof se.api_refusal_explanation=="string"?` ${se.api_refusal_explanation}`:"";O(`${ae} could not handle this request, so Claude continued with ${ie}.${ce}`)},Q=[i,X,l],e[25]=l,e[26]=i,e[27]=X,e[28]=ee,e[29]=Q):(ee=e[28],Q=e[29]),w.useEffect(ee,Q);let ne;e[30]!==l?(ne=pn(l),e[30]=l,e[31]=ne):ne=e[31];let re;return e[32]!==m||e[33]!==E||e[34]!==P||e[35]!==A||e[36]!==h||e[37]!==U||e[38]!==k||e[39]!==I||e[40]!==d||e[41]!==c||e[42]!==ne.configurableContextWindow||e[43]!==N||e[44]!==S||e[45]!==x?(re={contextWindowTokens:m,setContextWindowTokens:p,contextWindowAvailable:ne.configurableContextWindow,selectedModel:c,setSelectedModel:u,selectedEffort:d,setSelectedEffort:f,fastModeEnabled:h,ultracodeEnabled:x,effectiveEffort:E,fastModeAvailable:A,fastModeActive:P,setFastModeEnabled:g,ultracodeAvailable:S,ultracodeActive:N,setUltracodeEnabled:b,imageInputAvailable:k,modelFallbackNotice:I,dismissModelFallbackNotice:V,handleModelRejected:U},e[32]=m,e[33]=E,e[34]=P,e[35]=A,e[36]=h,e[37]=U,e[38]=k,e[39]=I,e[40]=d,e[41]=c,e[42]=ne.configurableContextWindow,e[43]=N,e[44]=S,e[45]=x,e[46]=re):re=e[46],re}const bT=["model","effort","contextWindowTokens","fastMode","ultracode","permissionMode"];function kp(n){return JSON.stringify(n,[...bT])}function sde({sessionKey:n,values:e,onHydrate:t}){const s=w.useRef(null),r=w.useRef(null),o=w.useRef(t);o.current=t;const i=w.useRef(e);i.current=e,w.useEffect(()=>{if(s.current=null,r.current=null,!n)return;let c=!1;return hT(n).then(u=>{if(c||u===null)return;if(bT.some(f=>u[f]!==void 0)){o.current(u);const f=i.current,m={model:u.model??f.model,effort:u.effort??f.effort,contextWindowTokens:u.contextWindowTokens??null,fastMode:u.fastMode??f.fastMode,ultracode:u.ultracode??f.ultracode,permissionMode:u.permissionMode??f.permissionMode};r.current=kp(m)}else Uh(n,i.current),r.current=kp(i.current);s.current=n}),()=>{c=!0}},[n]);const l=kp(e);w.useEffect(()=>{!n||s.current!==n||l!==r.current&&(r.current=l,Uh(n,i.current))},[l,n])}function rde(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 v=x?l.current.get(x):null;v?(r(v.activeId),i(v.collapsed)):(r(null),i(!0))}c.current=x},[n]);const u=w.useCallback(()=>i(x=>!x),[]),d=w.useCallback(x=>{t(b=>{const v=new Map(b);return v.set(x.id,x),v}),r(x.id),i(!1)},[]),f=w.useCallback(x=>{t(b=>{const v=new Map(b);return v.delete(x),r(y=>{if(y!==x)return y;const k=[...v.keys()];return k.length>0?k[k.length-1]:null}),v})},[]),m=w.useCallback(x=>{r(x),i(!1)},[]),p=w.useCallback((x,b)=>{t(v=>{const y=v.get(x);if(!y||y.status===b)return v;const k=new Map(v);return k.set(x,{...y,status:b}),k})},[]),h=w.useCallback(x=>{t(b=>{let v=!1;const y=new Map(b),k=new Set(x.map(j=>j.id));for(const[j,C]of y)C.type==="task"&&!k.has(j)&&(y.delete(j),v=!0);for(const j of x){const C=y.get(j.id);C?(C.name!==j.title||C.outputPath!==j.outputPath)&&(y.set(j.id,{...C,name:j.title,outputPath:j.outputPath}),v=!0):(y.set(j.id,{id:j.id,name:j.title,type:"task",status:"running",outputPath:j.outputPath}),v=!0)}return v?y:b})},[]),g=w.useCallback((x,b,v)=>{b&&v&&t(y=>{if(y.has(x))return y;const k=new Map(y);return k.set(x,{id:x,name:v,type:"task",status:"running",outputPath:b}),k}),r(y=>y===x?(i(!0),y):(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 ode(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=rde(t),[p,h]=w.useState(null),[g,x]=w.useState(0),b=w.useRef(0),v=s??r??void 0,y=!!(v&&(p==null?void 0:p.kind)==="preview"&&p.cwd===v),k=(p==null?void 0:p.kind)==="project-files"&&p.anchorCwd===(v??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 C=j;let _;e[3]!==l||e[4]!==i||e[5]!==r||e[6]!==s||e[7]!==o?(_=()=>({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]=_):_=e[8];const S=_;let N;e[9]!==S?(N=()=>{Qp(S())},e[9]=S,e[10]=N):N=e[10];const T=N;let E;e[11]!==S?(E=X=>{Qp({...S(),command:"claude /mcp"})},e[11]=S,e[12]=E):E=e[12];const A=E;let P;e[13]!==r||e[14]!==m||e[15]!==s?(P=()=>{const ee=[...m.processes.values()].filter(lde).at(-1);if(!ee){(s??r)&&x(ade);return}m.activeProcessId===ee.id&&!m.collapsed?m.toggleCollapse():m.setActive(ee.id)},e[13]=r,e[14]=m,e[15]=s,e[16]=P):P=e[16];const I=P;let O;e[17]!==r||e[18]!==s?(O=()=>{(s??r)&&x(ide)},e[17]=r,e[18]=s,e[19]=O):O=e[19];const R=O;let $;e[20]!==f||e[21]!==v||e[22]!==y?($=()=>{v&&w.startTransition(()=>{f(),h(y?null:{kind:"preview",cwd:v})})},e[20]=f,e[21]=v,e[22]=y,e[23]=$):$=e[23];const M=$;let z;e[24]!==u||e[25]!==f||e[26]!==v||e[27]!==d?(z=()=>{if(v){if(u===Ot.projectFiles){f();return}w.startTransition(()=>{h({kind:"project-files",root:v,anchorCwd:v,request:null}),d(Ot.projectFiles)})}},e[24]=u,e[25]=f,e[26]=v,e[27]=d,e[28]=z):z=e[28];const F=z;let D;e[29]!==v||e[30]!==d||e[31]!==c?(D=X=>{if(!c)return!1;const ee=MR(X,v);if(!ee)return!1;b.current=b.current+1;const Q=b.current;return w.startTransition(()=>h({kind:"project-files",root:ee.root,anchorCwd:v??null,request:ee.file?{file:ee.file,mode:ee.mode,line:ee.line,token:Q}:null})),d(Ot.projectFiles),!0},e[29]=v,e[30]=d,e[31]=c,e[32]=D):D=e[32];const L=D;let B,U;e[33]!==L?(B=()=>OR(L),U=[L],e[33]=L,e[34]=B,e[35]=U):(B=e[34],U=e[35]),w.useEffect(B,U);let W;e[36]===Symbol.for("react.memo_cache_sentinel")?(W=()=>{w.startTransition(()=>h(null))},e[36]=W):W=e[36];const V=W,H=!!(v&&u===Ot.projectFiles),G=k==null?void 0:k.root,Z=(k==null?void 0:k.request)??null;let Y;return e[37]!==v||e[38]!==A||e[39]!==R||e[40]!==T||e[41]!==I||e[42]!==M||e[43]!==F||e[44]!==g||e[45]!==C||e[46]!==m||e[47]!==y||e[48]!==H||e[49]!==G||e[50]!==Z?(Y={processPanel:m,currentCwd:v,showPreview:y,showProjectFiles:H,projectFilesRoot:G,projectFilesRequest:Z,launchTerminalRequest:g,pendingProject:C,handleOpenTerminal:T,handleMcpAuth:A,handleToggleIntegratedTerminal:I,handleNewIntegratedTerminal:R,handleTogglePreview:M,handleToggleProjectFiles:F,closeRightWorkspace:V},e[37]=v,e[38]=A,e[39]=R,e[40]=T,e[41]=I,e[42]=M,e[43]=F,e[44]=g,e[45]=C,e[46]=m,e[47]=y,e[48]=H,e[49]=G,e[50]=Z,e[51]=Y):Y=e[51],Y}function ide(n){return n+1}function ade(n){return n+1}function lde(n){return n.type==="terminal"}function cde(n){const e=n.replace(/<[^>]+>[\s\S]*?<\/[^>]+>/g,"").trim();if(!e)return"";const t=e.split(`
|
|
215
|
+
`)[0].trim();return t.length<=60?t:t.slice(0,57)+"..."}const ude={totalInputTokens:0,totalOutputTokens:0,totalCacheCreationTokens:0,totalCacheReadTokens:0,toolCallCounts:{},errorCount:0,totalDurationMs:0,turnCount:0};function vT(n,e){return{dirName:n.dirName,fileName:n.fileName,rawText:e,agentKind:sn(n.dirName)}}function dde(n){return{sessionId:n.sessionId,version:"",gitBranch:"",cwd:"",slug:"",name:"",model:"",turns:[],stats:{...ude},rawMessages:[],agentKind:sn(n.dirName)}}function yT(n){if(!(n!=null&&n.trim()))return null;try{return{rawText:n,parsed:yd(n)}}catch{return null}}async function fde(n,e,t=3,s=100,r=!0){if(r){const o=yT(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:yd(l)}}catch{}}o<t-1&&await new Promise(l=>setTimeout(l,s))}return null}async function mde(n,e,t,s){let r=s;for(let o=0;o<30;o++){if(e.signal.aborted)return;const i=await fde(n,e,1,0,!1);if(i&&i.rawText!==r){t({type:"RELOAD_SESSION_CONTENT",session:i.parsed,source:vT(n,i.rawText)});return}r=(i==null?void 0:i.rawText)??r,await new Promise(l=>setTimeout(l,200))}}async function gS(n,e,t,s,r){const o=yT(n.initialContent),i=(o==null?void 0:o.rawText)??"",l=(o==null?void 0:o.parsed)??dde(n),c=vT(n,i);return t({type:"FINALIZE_SESSION",session:l,source:c,isMobile:s}),r(l,c),mde(n,e,t,i),n.sessionId}async function pde(n,e,t,s){const r=await Re(`/api/sessions/${encodeURIComponent(n)}?page=1&limit=10`,{signal:s.signal});if(!r.ok)return null;const o=await r.json(),i=t-3e4,l=e.trim(),c=(o.sessions??[]).filter(d=>{const f=d.lastModified?new Date(d.lastModified).getTime():0;return Number.isFinite(f)&&f>=i}),u=c.find(d=>{var f,m;return((f=d.firstUserMessage)==null?void 0:f.trim())===l||((m=d.lastUserMessage)==null?void 0:m.trim())===l})??c[0];return u?{dirName:n,fileName:u.fileName,sessionId:u.sessionId}:null}function hde({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),v=w.useRef(null),y=w.useRef(null),k=w.useRef(null),j=w.useCallback((N,T)=>{y.current=N,k.current=T??null,g(null),p(!1),e({type:"INIT_PENDING_SESSION",dirName:N,cwd:T,isMobile:t})},[e,t]),C=w.useCallback(async(N,T)=>{var R;const E=y.current;if(!E)return null;const A=sn(E),P=k.current;(R=v.current)==null||R.abort();const I=new AbortController;v.current=I,p(!0),g(null),r==null||r(N);const O=Date.now();try{const $=cde(N),M=es(A),{capabilities:z}=M,F={dirName:E,cwd:M.dirName.lossy?P??void 0:void 0,message:N,images:T,permissions:n,effort:l||void 0,contextWindowTokens:c,fastMode:u?!0:void 0,ultracode:z.ultracode&&d?!0:void 0,name:z.namedSessions&&$||void 0,worktreeName:z.worktrees&&x?OP(N):void 0,mcpConfig:z.mcp&&f||void 0},{res:D,errorMessage:L}=await X5(W=>Re("/api/create-and-send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...F,model:W}),signal:I.signal}),{model:i,agentKind:A,errorFallback:"Unknown error",onModelRejected:o});if(!D.ok){if(A==="codex"){const W=await pde(E,N,O,I);if(W){y.current=null,k.current=null;const V=await gS(W,I,e,t,s);return $&&V&&Oh(V,$),V}}return g(L||`Failed to create session (${D.status})`),null}const B=await D.json();y.current=null,k.current=null;const U=await gS(B,I,e,t,s);return $&&U&&Oh(U,$),U}catch($){return I.signal.aborted||g($ instanceof Error?$.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]),_=w.useCallback(()=>g(null),[]),S=w.useCallback(()=>{var N;(N=v.current)==null||N.abort(),v.current=null,y.current=null,k.current=null,p(!1),g(null)},[]);return{creatingSession:m,createError:h,clearCreateError:_,handleNewSession:j,createAndSend:C,cancelCreation:S,worktreeEnabled:x,setWorktreeEnabled:b}}function gde(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,v]=w.useState(null);let y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y=V=>{var H;(H=g.current)==null||H.call(g,V),setTimeout(()=>{var G;return(G=x.current)==null?void 0:G.call(x)},300),setTimeout(()=>{var G;return(G=x.current)==null?void 0:G.call(x)},2e3)},e[0]=y):y=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:y,onCreateStarted:v,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=hde(k),C=j.handleNewSession,[_,S]=w.useState(null);let N;e[12]===Symbol.for("react.memo_cache_sentinel")?(N=new Map,e[12]=N):N=e[12];const T=w.useRef(N),E=xde;let A;e[13]===Symbol.for("react.memo_cache_sentinel")?(A=async V=>{if(Ql===null)return null;const H=T.current;if(H.has(V))return H.get(V)??null;const G=yP(await E(),V,Ql);return H.set(V,G),G},e[13]=A):A=e[13];const P=A;let I;e[14]!==C?(I=async(V,H)=>{var X;const G=H??((X=(await E()).find(ee=>ee.dirName===V))==null?void 0:X.path)??null;if(!G){S(null),C(V);return}const Z=sn(V)===Ql?Ql:null,Y=Z?lf(Z,G):await P(G);S({discoveredDirName:Y,cwd:G}),C(Z&&Y?Y:V,G)},e[14]=C,e[15]=I):I=e[15];const O=I;let R;e[16]!==o||e[17]!==O?(R=V=>{const H=lf(o,V);O(H,V)},e[16]=o,e[17]=O,e[18]=R):R=e[18];const $=R;let M;e[19]!==C||e[20]!==_?(M=V=>{if(!_)return;const H=lf(V,_.cwd,_.discoveredDirName??void 0);C(H,_.cwd)},e[19]=C,e[20]=_,e[21]=M):M=e[21];const z=M;let F;e:{if(!j.creatingSession||!i){F=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],F=H}const D=F;let L,B;e[26]!==i?(B=()=>{i||(v(null),S(null))},L=[i],e[26]=i,e[27]=L,e[28]=B):(L=e[27],B=e[28]),w.useEffect(B,L);const U=_?z:void 0;let W;return e[29]!==$||e[30]!==O||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]!==U?(W={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:U,handleStartNewSession:O,handleStartNewFolder:$},e[29]=$,e[30]=O,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]=U,e[40]=W):W=e[40],W}async function xde(){try{const n=await Re("/api/projects");return n.ok?await n.json():[]}catch{return[]}}const jp=new Set;function bde(n,e){const t=Fn(),s=$s();return`${s===null?t:`${t}:${s}`}:${n}/${e}`}async function vde(n,e,t){const s=bde(n,e);if(!jp.has(s)&&!As.get(n,e)){jp.add(s);try{await Mo(n,e,t,"session prefetch")}catch{}finally{jp.delete(s)}}}function yde({onAuthenticated:n}){const[e,t]=w.useState(null),[s,r]=w.useState(""),[o,i]=w.useState(""),[l,c]=w.useState(!1),[u,d]=w.useState(null),[f,m]=w.useState(!1),p=e==="team";w.useEffect(()=>{let x=!1;return ek().then(b=>{x||t(b)}),()=>{x=!0}},[]);const h=w.useCallback(async x=>{if(x.preventDefault(),!(!o.trim()||p&&!s.trim())){m(!0),d(null);try{const b=await fetch("/api/auth/verify",p?{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"Content-Type":"application/json","X-Cogpit-Client":"1"},body:JSON.stringify({username:s.trim(),password:o})}:{method:"POST",credentials:"same-origin",cache:"no-store",headers:{Authorization:`Bearer ${o}`,"Content-Type":"application/json","X-Cogpit-Client":"1"}}),v=await b.json();b.ok&&v.valid?(Qu(),i(""),r(""),n()):d(v.error||(p?"Invalid credentials":"Invalid password"))}catch{d("Failed to connect to server")}finally{m(!1)}}},[p,n,o,s]),g=f||!o.trim()||p&&!s.trim();return a.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-4 py-8",children:a.jsx("form",{onSubmit:h,className:"w-full max-w-sm",children:a.jsxs(ns,{children:[a.jsxs(ws,{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(xA,{className:"size-4"})}),a.jsx(Ss,{children:"Sign in to Cogpit"}),a.jsx(ks,{children:p?"Use your team account to continue.":"Enter the server password to continue."})]}),e===null?a.jsx(ss,{children:a.jsx("div",{className:"flex min-h-24 items-center justify-center",role:"status","aria-label":"Checking server",children:a.jsx(Cn,{className:"size-5 text-muted-foreground"})})}):a.jsxs(a.Fragment,{children:[a.jsxs(ss,{className:"flex flex-col gap-4",children:[a.jsxs(Ui,{children:[p&&a.jsxs(Lt,{children:[a.jsx(zt,{htmlFor:"login-username",children:"Username"}),a.jsx(Nn,{id:"login-username",type:"text",value:s,onChange:x=>r(x.target.value),placeholder:"Username",autoComplete:"username",autoFocus:!0})]}),a.jsxs(Lt,{children:[a.jsx(zt,{htmlFor:"login-password",children:"Password"}),a.jsxs(Ar,{children:[a.jsx(Pr,{id:"login-password",type:l?"text":"password",value:o,onChange:x=>i(x.target.value),placeholder:"Password",autoComplete:"current-password",autoFocus:!p}),a.jsx(Ds,{align:"inline-end",children:a.jsx(kl,{size:"icon-xs",onClick:()=>c(x=>!x),"aria-label":l?"Hide password":"Show password",children:l?a.jsx(Xu,{}):a.jsx(Mi,{})})})]})]})]}),u&&a.jsxs(Ft,{variant:"destructive",children:[a.jsx(zs,{"aria-hidden":"true"}),a.jsx(on,{children:"Sign in failed"}),a.jsx(Ut,{children:u})]})]}),a.jsx(Sl,{children:a.jsxs(J,{type:"submit",className:"w-full",disabled:g,children:[f&&a.jsx(Cn,{"data-icon":"inline-start"}),"Connect"]})})]})]})})})}const xS=16,nu="__cogpitBootstrapToken";function wde(){const e=new URLSearchParams(window.location.hash.replace(/^#/,"")).get("bootstrap")||"",t=window.history.state||{},s=e||(typeof t[nu]=="string"?t[nu]:"");return e&&window.history.replaceState({...t,[nu]:e},"",`${window.location.pathname}${window.location.search}`),s}function bS(){const n={...window.history.state||{}};delete n[nu],window.history.replaceState(n,"",`${window.location.pathname}${window.location.search}`)}function Sde({onAuthenticated:n,onBootstrapClosed:e}){const[t]=w.useState(wde),[s,r]=w.useState(""),[o,i]=w.useState(""),[l,c]=w.useState(""),[u,d]=w.useState(""),[f,m]=w.useState(!1),[p,h]=w.useState(null),[g,x]=w.useState(!1),b=u.length>0&&u!==l,v=!t||!s.trim()||l.length<xS||u!==l,y=w.useCallback(async k=>{if(k.preventDefault(),!v){x(!0),h(null);try{const j=await fetch("/api/team/bootstrap",{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"Content-Type":"application/json","X-Cogpit-Client":"1","X-Cogpit-Bootstrap-Token":t},body:JSON.stringify({username:s.trim(),password:l,...o.trim()?{displayName:o.trim()}:{}})}),C=await j.json();if(j.ok){bS(),c(""),d(""),r(""),i(""),await e(),n();return}if(j.status===410){bS(),await e();return}h(C.error||"Could not create the admin account")}catch{h("Failed to connect to server")}finally{x(!1)}}},[t,o,v,n,e,l,s]);return a.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-4 py-8",children:a.jsx("form",{onSubmit:y,className:"w-full max-w-md",children:a.jsxs(ns,{children:[a.jsxs(ws,{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(bA,{className:"size-4"})}),a.jsx(Ss,{children:"Create the first admin"}),a.jsx(ks,{children:"Set up the account that will manage this Cogpit team server."})]}),a.jsxs(ss,{className:"flex flex-col gap-4",children:[!t&&a.jsxs(Ft,{children:[a.jsx(Us,{"aria-hidden":"true"}),a.jsx(on,{children:"Setup link required"}),a.jsx(Ut,{children:"Open the one-time setup URL shown in the Cogpit server log."})]}),a.jsxs(Ui,{children:[a.jsxs(Lt,{children:[a.jsx(zt,{htmlFor:"bootstrap-username",children:"Username"}),a.jsx(Nn,{id:"bootstrap-username",type:"text",value:s,onChange:k=>r(k.target.value),placeholder:"Username",autoComplete:"username",autoFocus:!0}),a.jsx(Ni,{children:"Use 2 to 32 lowercase letters, numbers, dots, underscores, or hyphens."})]}),a.jsxs(Lt,{children:[a.jsxs(zt,{htmlFor:"bootstrap-display-name",children:["Display name ",a.jsx("span",{className:"font-normal text-muted-foreground",children:"Optional"})]}),a.jsx(Nn,{id:"bootstrap-display-name",type:"text",value:o,onChange:k=>i(k.target.value),placeholder:"Display name (optional)",autoComplete:"name"})]}),a.jsxs(Lt,{children:[a.jsx(zt,{htmlFor:"bootstrap-password",children:"Password"}),a.jsxs(Ar,{children:[a.jsx(Pr,{id:"bootstrap-password",type:f?"text":"password",value:l,onChange:k=>c(k.target.value),placeholder:"Password",autoComplete:"new-password"}),a.jsx(Ds,{align:"inline-end",children:a.jsx(kl,{size:"icon-xs",onClick:()=>m(k=>!k),"aria-label":f?"Hide password":"Show password",children:f?a.jsx(Xu,{}):a.jsx(Mi,{})})})]}),a.jsxs(Ni,{children:["Use at least ",xS," characters."]})]}),a.jsxs(Lt,{"data-invalid":b,children:[a.jsx(zt,{htmlFor:"bootstrap-confirm-password",children:"Confirm password"}),a.jsx(Nn,{id:"bootstrap-confirm-password",type:f?"text":"password",value:u,onChange:k=>d(k.target.value),placeholder:"Confirm password",autoComplete:"new-password","aria-invalid":b}),b&&a.jsx(Yr,{children:"Passwords do not match"})]})]}),p&&a.jsxs(Ft,{variant:"destructive",children:[a.jsx(zs,{"aria-hidden":"true"}),a.jsx(on,{children:"Could not create the account"}),a.jsx(Ut,{children:p})]})]}),a.jsx(Sl,{children:a.jsxs(J,{type:"submit",className:"w-full",disabled:g||v,children:[g&&a.jsx(Cn,{"data-icon":"inline-start"}),"Create admin account"]})})]})})})}function kde(){const n=q.c(18);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=ag(),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 QS().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.edition==="team";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 lP().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.edition)?(g=()=>{let A=!1;const P=()=>{const I=u.current=u.current+1,O=()=>{A||u.current!==I||(i(!1),c(!0))};if(t||(s==null?void 0:s.edition)==="team"){O();return}Eb().then(R=>{A||u.current!==I||(r(R),R.edition==="team"&&O())})};return window.addEventListener("cogpit-auth-required",P),()=>{A=!0,window.removeEventListener("cogpit-auth-required",P)}},n[6]=s==null?void 0:s.edition,n[7]=g):g=n[7];const x=s==null?void 0:s.edition;let b;n[8]!==x?(b=[x,t],n[8]=x,n[9]=b):b=n[9],w.useEffect(g,b);let v;n[10]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{u.current=u.current+1,i(!0),c(!0),window.dispatchEvent(new Event("cogpit-auth-changed"))},n[10]=v):v=n[10];const y=v;let k;n[11]===Symbol.for("react.memo_cache_sentinel")?(k=async()=>{r(await Eb())},n[11]=k):k=n[11];const j=k;let C;n[12]===Symbol.for("react.memo_cache_sentinel")?(C=()=>{u.current=u.current+1,i(!1),c(!0),cP().finally(jde)},n[12]=C):C=n[12];const _=C,S=(s==null?void 0:s.edition)??null,N=l&&s!==null,T=(s==null?void 0:s.needsBootstrap)===!0;let E;return n[13]!==o||n[14]!==S||n[15]!==N||n[16]!==T?(E={isRemote:t,edition:S,authChecked:N,authenticated:o,needsBootstrap:T,handleAuthenticated:y,refreshServerState:j,logout:_},n[13]=o,n[14]=S,n[15]=N,n[16]=T,n[17]=E):E=n[17],E}function jde(){window.dispatchEvent(new Event("cogpit-auth-changed"))}const Nde=w.lazy(()=>Qe(()=>import("./index-BA1eUNuR.js"),__vite__mapDeps([39,1,2,3,4])).then(n=>({default:n.BranchModal}))),Cde=w.lazy(()=>Qe(()=>import("./WorkflowsPanel-CiYzHaQg.js"),__vite__mapDeps([40,1,4,2,3])).then(n=>({default:n.WorkflowsPanel})));function _de(){var Xx,Jx,Qx,eb,tb,nb,sb,rb,ob,ib,ab,lb,cb,ub,db,fb,mb,pb,hb,gb;const n=wx(window.location.pathname),e=Eue(),t=kde(),s=Oue(t.edition),r=s.checked&&(t.edition!=="team"||s.authenticated&&s.edition==="team"&&s.user!==null),o=r&&s.capabilities.configWrite,i=r&&s.capabilities.hostFiles,l=r&&s.capabilities.terminal,c=gx(),u=rT(),[d,f]=J5(),{procBySession:m}=c4(),{parse:p,append:h}=gT(),g=w.useCallback(Me=>{f({type:"SET_OLDER_TURNS",turns:Me})},[f]),x=w.useCallback((Me,nt)=>{vde(Me,nt,p)},[p]),b=xT({dirName:((Xx=d.sessionSource)==null?void 0:Xx.dirName)??null,fileName:((Jx=d.sessionSource)==null?void 0:Jx.fileName)??null,sessionChangeKey:d.sessionChangeKey,workerParse:p,onOlderTurns:g}),{loadMore:v}=b,y=!!d.searchQuery&&b.hasMore,k=((Qx=d.session)==null?void 0:Qx.turns.length)??0;w.useEffect(()=>{y&&v()},[y,v,k]);const j=Jue(d,f),C=w.useRef(null),_=w.useRef(null),[S,N]=w.useState(!1),[T,E]=w.useState(!1),A=w.useCallback(()=>f({type:"TOGGLE_EXPAND_ALL"}),[f]),P=w.useCallback(()=>N(!0),[]),I=w.useCallback(()=>{var Me;return(Me=_.current)==null?void 0:Me.focus()},[]),O=w.useCallback(()=>f({type:"SET_EXPAND_ALL",value:!0}),[f]),R=w.useCallback(()=>f({type:"SET_EXPAND_TOOL_PAYLOADS",value:!0}),[f]),$=w.useCallback(()=>f({type:"SET_EXPAND_ALL",value:!1}),[f]),M=j.toggleWorkspacePanel,z=w.useCallback(()=>M(Ot.sessionInfo),[M]),F=w.useCallback(Me=>{w.startTransition(()=>{f({type:"SET_DASHBOARD_PROJECT",dirName:Me})})},[f]),D=d.pendingCwd??(d.pendingDirName?Rs(d.pendingDirName):null),L=((eb=d.sessionSource)==null?void 0:eb.agentKind)??sn(((tb=d.sessionSource)==null?void 0:tb.dirName)??d.pendingDirName??null),B=(nb=d.session)!=null&&nb.sessionId?m.get(d.session.sessionId):void 0,U=pn(L),W=xx(L,B),V=U.worktrees,H=U.mcp,G=Yue(o?((sb=d.session)==null?void 0:sb.cwd)??D??void 0:void 0,o&&U.slashCommands),Z=w.useCallback(Me=>{if(!o)return;const nt=G.suggestions.find(rn=>rn.name===Me);w.startTransition(()=>{f({type:"OPEN_CONFIG",filePath:nt==null?void 0:nt.filePath})})},[o,f,G.suggestions]),Y=w.useCallback(async(Me,nt)=>{if(!o)return null;const rn=G.suggestions.find(fr=>fr.name===Me);if(!(rn!=null&&rn.filePath))return null;try{const fr=await Re("/api/expand-command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:rn.filePath,args:nt||""})});return fr.ok?(await fr.json()).content??null:null}catch{return null}},[o,G.suggestions]),X=j.openWorkspacePanel,ee=w.useCallback(Me=>{X(Me),c&&f({type:"SET_MOBILE_TAB",tab:"workspace"})},[X,c,f]),{processPanel:Q,currentCwd:ne,showPreview:re,showProjectFiles:se,projectFilesRoot:oe,projectFilesRequest:ae,launchTerminalRequest:ie,pendingProject:ce,handleOpenTerminal:te,handleMcpAuth:le,handleToggleIntegratedTerminal:ge,handleNewIntegratedTerminal:be,handleTogglePreview:ue,handleToggleProjectFiles:he,closeRightWorkspace:me}=ode({sessionId:(rb=d.session)==null?void 0:rb.sessionId,sessionCwd:(ob=d.session)==null?void 0:ob.cwd,pendingPath:D,sessionDirName:(ib=d.sessionSource)==null?void 0:ib.dirName,pendingDirName:d.pendingDirName,dashboardProject:d.dashboardProject,supportsFileWorkspace:i,activeWorkspacePanel:j.activeWorkspacePanel,openWorkspacePanel:ee,closeWorkspacePanel:j.closeWorkspacePanel}),xe=Hue(d.session??null),[je,Le]=w.useState(!1),Se=((ab=d.sessionSource)==null?void 0:ab.dirName)??d.pendingDirName??d.dashboardProject??null,{activeWorkspacePanel:Ie,closeWorkspacePanel:we,showWorkflows:Be}=j,De=Fue(r&&V&&d.mainView==="sessions"&&Ie===Ot.worktrees?Se:null),Ue=w.useMemo(()=>{const Me=d.session;return Me?Me.turns.some(nt=>ku(nt.toolCalls,Me.cwd)||nt.subAgentActivity.some(rn=>ku(rn.toolCalls,Me.cwd))):!1},[d.session]),We=w.useMemo(()=>{if(!d.session||!U.workflows)return 0;let Me=0;for(const nt of d.session.turns)for(const rn of nt.toolCalls)rn.name==="Workflow"&&Me++;return Me},[d.session,U.workflows]),Oe=We>0,pe=w.useMemo(()=>{const Me=d.sessionSource;return!Me||!U.workflows||so(Me.fileName)?{dirName:null,sessionId:null}:{dirName:Me.dirName,sessionId:lu(Me.fileName)}},[d.sessionSource,U.workflows]),ke=Uce(pe.dirName,pe.sessionId,Oe),_e=Oe||ke.workflows.length>0,ye=ke.workflows.length||We,Pe=j.setShowWorkflows,Ye=w.useCallback(()=>Pe(!0),[Pe]),[Xe,Ee]=w.useState(!1);w.useEffect(()=>{if(!i)return;const Me=()=>{c?Ee(!0):X(Ot.fileChanges)};return window.addEventListener(tl,Me),()=>window.removeEventListener(tl,Me)},[i,X,c]);const Ze=w.useMemo(()=>d.session?kj(d.session):null,[d.session]),fe=w.useRef(null),{isLive:Te,sseState:Ve,isCompacting:He,streamingOverlay:$e,turnError:tt,agentProgress:bt,promptSuggestion:ut,rateLimit:vt}=Z5(d.sessionSource,Me=>{w.startTransition(()=>{f({type:"UPDATE_SESSION",session:Me})})},p,h,()=>{var Me;return(Me=fe.current)==null?void 0:Me.call(fe)},d.session),un=Zue(((lb=d.session)==null?void 0:lb.cwd)??null),Nt=iue(),Gn=Nt.setMode,en=cue(W?null:((cb=d.session)==null?void 0:cb.sessionId)??null),Mn=W?null:en.plan??Ze,{contextWindowTokens:ps,setContextWindowTokens:Rr,contextWindowAvailable:Zi,selectedModel:Yi,setSelectedModel:Zd,selectedEffort:ST,setSelectedEffort:Yd,fastModeEnabled:kT,ultracodeEnabled:jT,effectiveEffort:Ul,fastModeAvailable:NT,fastModeActive:Bl,setFastModeEnabled:Xd,ultracodeAvailable:CT,ultracodeActive:Wl,setUltracodeEnabled:Jd,imageInputAvailable:Sx,modelFallbackNotice:_T,dismissModelFallbackNotice:TT,handleModelRejected:kx}=nde({agentKind:L,session:d.session,sessionSource:d.sessionSource,pendingDirName:d.pendingDirName,isLive:Te}),jx=Bue((ub=d.session)==null?void 0:ub.sessionId,(db=d.sessionSource)==null?void 0:db.fileName);sde({sessionKey:jx,values:{model:Yi,effort:ST,contextWindowTokens:ps,fastMode:kT,ultracode:jT,permissionMode:Nt.config.mode},onHydrate:w.useCallback(Me=>{Rr(Me.contextWindowTokens??null),Me.model!==void 0&&Zd(Me.model),Me.effort!==void 0&&Yd(Me.effort),Me.fastMode!==void 0&&Xd(Me.fastMode),Me.ultracode!==void 0&&Jd(Me.ultracode),Me.permissionMode&&Gn(Me.permissionMode)},[Rr,Zd,Yd,Xd,Jd,Gn])});const Zn=Vue(H&&o?ne:void 0,H&&o?Se??void 0:void 0,H&&o?jx??void 0:void 0,o);w.useEffect(()=>{!V&&Ie===Ot.worktrees&&we()},[V,Ie,we]),w.useEffect(()=>{Be&&!_e&&Pe(!1)},[Be,_e,Pe]);const{creatingSession:Nx,createError:Cx,clearCreateError:ET,createAndSend:AT,cancelCreation:_x,worktreeEnabled:PT,setWorktreeEnabled:IT,sessionFinalizedRef:ql,liveSessionsRefreshRef:Tx,pendingSessionInfo:Ex,pendingAgentKindChange:$T,handleStartNewSession:Ax,handleStartNewFolder:RT}=gde({permissionsConfig:Nt.config,dispatch:f,isMobile:c,defaultAgentKind:e.defaultAgentKind,pendingDirName:d.pendingDirName,pendingCwd:d.pendingCwd,onModelRejected:kx,model:Yi,effort:Ul,contextWindowTokens:Zi?ps:void 0,fastMode:Bl,ultracode:Wl,mcpConfig:H&&o?Zn.mcpConfigJson:null}),Rt=qce({sessionSource:d.sessionSource,parsedSessionId:((fb=d.session)==null?void 0:fb.sessionId)??null,cwd:(mb=d.session)==null?void 0:mb.cwd,permissions:Nt.config,onPermissionsApplied:Nt.markApplied,model:Yi,effort:Ul,contextWindowTokens:Zi?ps:void 0,fastMode:Bl,ultracode:Wl,mcpConfig:H&&o?Zn.mcpConfigJson:null,onModelRejected:kx,readOnly:W,onCreateSession:d.pendingDirName?AT:void 0}),gn=Dce(U.agentTeams?((pb=d.sessionSource)==null?void 0:pb.fileName)??null:null,((hb=d.sessionSource)==null?void 0:hb.dirName)??null);w.useEffect(()=>{gn!=null&&gn.currentMemberName?f({type:"SET_CURRENT_MEMBER_NAME",name:gn.currentMemberName}):gn||f({type:"SET_CURRENT_MEMBER_NAME",name:null})},[gn==null?void 0:gn.currentMemberName,gn,f]),w.useEffect(()=>{c&&f({type:"GUARD_MOBILE_TAB",hasSession:!!d.session||!!d.pendingDirName})},[d.session,d.pendingDirName,d.mobileTab,c,f]);const Vs=Q5({session:d.session,isLive:Te,pendingMessages:Rt.pendingMessages,consumePending:Rt.consumePending,sessionChangeKey:d.sessionChangeKey,partialSignal:$e}),Px=Vs.chatScrollRef,Ix=Vs.resetTurnCount,$x=Vs.scrollToBottomInstant,OT=w.useCallback(Me=>{Le(Me),requestAnimationFrame(()=>{const nt=Px.current;nt&&nt.scrollTo({top:nt.scrollTop+(Me?64:-64),behavior:"smooth"})})},[Px]);w.useLayoutEffect(()=>{const Me=nt=>{Ix(0),$x()};return ql.current=Me,()=>{ql.current===Me&&(ql.current=null)}},[Ix,$x,ql]);const MT=w.useCallback(()=>{Rt.disconnect(),_x()},[Rt.disconnect,_x]),Hs=Kce({dispatch:f,isMobile:c,mobileTab:d.mobileTab,teamContext:gn,scrollToBottomInstant:Vs.scrollToBottomInstant,resetTurnCount:Vs.resetTurnCount,workerParse:p,onBeforeSwitch:MT}),LT=w.useCallback(Me=>{w.startTransition(()=>{f({type:"GO_HOME",isMobile:c}),f({type:"SET_DASHBOARD_PROJECT",dirName:Me})})},[f,c]),{previewLoadError:zT}=Xce({state:d,dispatch:f,isMobile:c,resetTurnCount:Vs.resetTurnCount,scrollToBottomInstant:Vs.scrollToBottomInstant,workerParse:p}),Vl=rue(),Rx=Vl.push;w.useEffect(()=>{d.sessionSource&&Rx(d.sessionSource.dirName,d.sessionSource.fileName)},[d.sessionSource,Rx]);const At=ede({state:{session:d.session,sessionSource:d.sessionSource},dispatch:f,isMobile:c,handleJumpToTurn:Hs.handleJumpToTurn,markPermissionsApplied:Nt.markApplied,hasPermsPendingChanges:Nt.hasPendingChanges,permissionsConfig:Nt.config,selectedModel:Yi,selectedEffort:Ul,fastMode:Bl,ultracode:Wl,mcpConfig:H&&o?Zn.mcpConfigJson:null,scrollRequestScrollToTop:Vs.requestScrollToTop,handleDashboardSelect:Hs.handleDashboardSelect,workerParse:p}),{hasSettingsChanges:Ox,handleApplySettings:Mx}=At,Lx=H&&o&&Zn.mcpConfigJson!==null,zx=w.useRef(!1);w.useEffect(()=>{var rn;const Me=Zn.loaded&&!zx.current;zx.current=Zn.loaded;const nt=(rn=d.session)==null?void 0:rn.sessionId;Me&&nt&&Lx&&Ox&&Mx()},[Zn.loaded,Lx,Ox,Mx,(gb=d.session)==null?void 0:gb.sessionId]),w.useLayoutEffect(()=>(fe.current=At.reloadSession,()=>{fe.current===At.reloadSession&&(fe.current=null)}),[At.reloadSession]);const dr=mT(d.session,d.sessionSource,At.reloadSession,i),Hl=dr.requestBranchSwitch,Kl=At.setBranchModalTurn,DT=w.useCallback((Me,nt)=>{Hl(Me,nt),Kl(null)},[Hl,Kl]),FT=w.useCallback(Me=>{Hl(Me),Kl(null)},[Hl,Kl]);eue({isMobile:c,searchInputRef:C,chatInputRef:_,dispatch:f,onToggleSidebar:j.handleToggleSidebar,onToggleRightSidebar:z,onToggleMissionControl:j.handleToggleMission,onOpenCommandPalette:P,onOpenProjectSwitcher:j.handleOpenProjectSwitcher,onOpenThemeSelector:j.handleToggleThemeSelector,onOpenTerminal:te,onToggleIntegratedTerminal:ge,onTogglePreview:ue,onToggleProjectFiles:he,onHistoryBack:Vl.goBack,onHistoryForward:Vl.goForward,onNavigateToSession:Hs.handleDashboardSelect,onCommitNavigation:Vl.commitNavigation});const{killing:UT,handleKillAll:BT}=Uue(),Or=d.sessionSource?so(d.sessionSource.fileName):null,WT=Or!==null&&!!(gn!=null&&gn.currentMemberName),Qd=Or!==null&&!WT,Gl=Hs.handleDashboardSelect,Dx=w.useCallback(()=>{!d.sessionSource||!Or||Gl(d.sessionSource.dirName,Or.parentFileName)},[d.sessionSource,Or,Gl]);w.useEffect(()=>{const Me=nt=>{const{agentId:rn}=nt.detail??{};if(!rn||!d.sessionSource||!U.subagentTranscripts)return;const fr=Or?Or.parentSessionId:lu(d.sessionSource.fileName);Gl(d.sessionSource.dirName,`${fr}/subagents/agent-${rn}.jsonl`)};return window.addEventListener(ju,Me),()=>window.removeEventListener(ju,Me)},[d.sessionSource,Or,Gl,U.subagentTranscripts]);const[qT,Fx]=w.useState(null),VT=At.branchModalTurn!==null,Bo=At.branchModalTurn??qT;w.useEffect(()=>{At.branchModalTurn!==null&&Fx(At.branchModalTurn)},[At.branchModalTurn]);const Ux=Bo!==null?dr.branchesAtTurn(Bo):[],HT=Qd?a.jsxs("div",{className:"flex shrink-0 items-center justify-center gap-2 border-t bg-card px-4 py-2.5",children:[a.jsx(ki,{"data-icon":"inline-start",className:"size-3.5 text-muted-foreground"}),a.jsx("span",{className:"text-xs text-muted-foreground",children:"Viewing sub-agent session (read-only)"})]}):null,KT=W?a.jsxs("div",{role:"status",className:"flex shrink-0 items-center justify-center gap-2 border-t bg-card px-4 py-2.5",children:[a.jsx(ki,{"data-icon":"inline-start",className:"size-3.5 text-muted-foreground"}),a.jsx("span",{className:"text-xs text-muted-foreground",children:xI(L)})]}):null,ef=HT||KT,GT=Hs.loadError||Cx||null;let tf;Hs.loadError?tf=Hs.clearLoadError:Cx&&(tf=ET);const ZT=!!(d.session&&d.sessionSource&&Ve==="disconnected"),nf=w.useMemo(()=>({state:d,dispatch:f,config:e,theme:u,isMobile:c}),[d.activeTurnIndex,d.activeToolCallId,d.searchQuery,d.expandAll,d.expandToolPayloads,d.mainView,d.mobileTab,d.dashboardProject,d.pendingDirName,d.pendingCwd,d.currentMemberName,d.loadingMember,d.configFilePath,d.sessionChangeKey,f,e,u,c]),sf=w.useMemo(()=>({session:d.session,sessionSource:d.sessionSource,isLive:Te,sseState:Ve,isCompacting:He,turnError:tt,promptSuggestion:ut,rateLimit:vt,undoRedo:dr,pendingInteraction:Mn,permissionRequests:en.requests,permissionResponding:en.responding,respondPermission:en.respond,respondAllPermissions:en.respondAll,isSubAgentView:Qd,slashSuggestions:G.suggestions,slashSuggestionsLoading:G.loading,actions:{handleStopSession:At.handleStopSession,handleEditConfig:o?j.handleEditConfig:void 0,handleEditCommand:o?Z:void 0,handleExpandCommand:o?Y:void 0,handleOpenBranches:At.handleOpenBranches,handleBranchFromHere:At.handleBranchFromHere,handleToggleExpandAll:A,handleLoadSession:At.handleLoadSessionScrollAware}}),[d.session,d.sessionSource,Te,Ve,He,tt,ut,vt,dr,Mn,Qd,en.requests,en.responding,en.respond,en.respondAll,G.suggestions,G.loading,At.handleStopSession,o,j.handleEditConfig,Z,Y,At.handleOpenBranches,At.handleBranchFromHere,A,At.handleLoadSessionScrollAware]),rf=w.useMemo(()=>({chat:{status:Rt.status,error:Rt.error,pendingMessages:Rt.pendingMessages,isConnected:Rt.isConnected,sendMessage:Rt.sendMessage,interrupt:Rt.interrupt,stopAgent:Rt.stopAgent,consumePending:Rt.consumePending},scroll:Vs}),[Rt.status,Rt.error,Rt.pendingMessages,Rt.isConnected,Rt.sendMessage,Rt.interrupt,Rt.stopAgent,Rt.consumePending,Vs]),Xi=!!d.pendingDirName&&!d.session;if(w.useEffect(()=>{if(!Xi||c)return;const Me=requestAnimationFrame(()=>{var nt;return(nt=_.current)==null?void 0:nt.focus()});return()=>cancelAnimationFrame(Me)},[Xi,c,d.pendingDirName]),!t.authChecked)return a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-background",role:"status","aria-label":"Checking authentication",children:a.jsx(ht,{"data-icon":"inline-start",className:"size-6 animate-spin text-muted-foreground"})});if(!t.authenticated)return t.needsBootstrap?a.jsx(Sde,{onAuthenticated:t.handleAuthenticated,onBootstrapClosed:t.refreshServerState}):a.jsx(yde,{onAuthenticated:t.handleAuthenticated});if(!r)return a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-background",role:"status","aria-label":"Loading identity",children:a.jsx(ht,{"data-icon":"inline-start",className:"size-6 animate-spin text-muted-foreground"})});if(e.configLoading)return a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-background",role:"status","aria-label":"Loading",children:a.jsx(ht,{"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-background text-foreground",children:a.jsxs(is,{children:[a.jsxs(as,{children:[a.jsx(Is,{variant:"icon",children:a.jsx(Us,{className:"text-destructive"})}),a.jsx(ls,{children:"Failed to connect"}),a.jsx(cs,{children:e.configError})]}),a.jsx(GS,{children:a.jsxs(J,{variant:"outline",size:"sm",onClick:e.retryConfig,children:[a.jsx(Un,{"data-icon":"inline-start"}),"Retry"]})})]})});if(!e.claudeDir)return o?a.jsx(IR,{onConfigured:e.setClaudeDir}):a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-background text-sm text-muted-foreground",children:"Cogpit is waiting for an administrator to finish server setup."});const of=a.jsx(rP,{activeError:GT,clearActiveError:tf,modelFallbackNotice:_T,dismissModelFallbackNotice:TT,connectionLost:ZT,theme:u.activeTheme}),Bx=i?a.jsx(kR,{state:dr.confirmState,isApplying:dr.isApplying,applyError:dr.applyError,onConfirm:dr.confirmApply,onCancel:dr.confirmCancel}):null,YT=Bo!==null&&d.session?d.session.turns.slice(Bo):[],Wx=i&&Bo!==null&&Ux.length>0&&a.jsx(w.Suspense,{fallback:null,children:a.jsx(Nde,{open:VT,branches:Ux,branchPointTurnIndex:Bo,currentTurns:YT,onClose:At.handleCloseBranchModal,onCloseComplete:()=>Fx(null),onRedoToTurn:DT,onRedoEntireBranch:FT})}),qx=l&&a.jsx(fR,{processes:Q.processes,activeProcessId:Q.activeProcessId,collapsed:Q.collapsed,onSetActive:Q.setActive,onRemove:Q.removeProcess,onToggleCollapse:Q.toggleCollapse,onRequestTerminal:gt("terminal")?be:void 0,onAddTerminalContext:Me=>{var xb,bb,vb;const nt=Me.trim();if(!nt)return;const rn=nt.includes("```")?"````":"```",fr=`${rn}terminal
|
|
216
|
+
${nt}
|
|
217
|
+
${rn}`,af=((xb=_.current)==null?void 0:xb.getText().trimEnd())??"";(bb=_.current)==null||bb.setText(af?`${af}
|
|
218
|
+
|
|
219
|
+
${fr}
|
|
220
|
+
`:`${fr}
|
|
221
|
+
`),(vb=_.current)==null||vb.focus()},onUpdateStatus:Q.updateProcessStatus,projectDir:ne,onProcessStarted:Q.addProcess,mobile:c}),Vx=gn&&a.jsx(s7,{teamName:gn.config.name||gn.teamName,members:gn.config.members,currentMemberName:d.currentMemberName,loadingMember:d.loadingMember,onMemberClick:Hs.handleTeamMemberSwitch}),Hx=_e&&a.jsx(w.Suspense,{fallback:null,children:a.jsx(Cde,{open:j.showWorkflows,onOpenChange:j.setShowWorkflows,dirName:pe.dirName,sessionId:pe.sessionId,workflows:ke.workflows,isLive:ke.isLive,onRefetchList:ke.refetch},`${pe.dirName??""}:${pe.sessionId??""}`)}),Zl=U.goals?d.session:null,Kx=Me=>{var nt;return a.jsx(QI,{mobile:c,agentKind:L,onAgentKindChange:Xi?$T:void 0,selectedModel:Yi,onModelChange:Zd,selectedEffort:Ul,onEffortChange:Yd,contextWindowTokens:ps,onContextWindowTokensChange:Zi?Rr:void 0,fastModeEnabled:Bl,onFastModeEnabledChange:NT?Xd:void 0,isNewSession:Xi,worktreeEnabled:PT,onWorktreeEnabledChange:Xi&&V?IT:void 0,ultracodeEnabled:Wl,onUltracodeEnabledChange:CT?Jd:void 0,onApplySettings:At.handleApplySettings,activeModelId:(nt=d.session)==null?void 0:nt.model,mcpServers:H&&o?Zn.servers:void 0,selectedMcpServers:H&&o?Zn.selectedServers:void 0,onToggleMcpServer:H&&o?Zn.toggleServer:void 0,onSetMcpServers:H&&o?Zn.setSelection:void 0,onRefreshMcpServers:H&&o?Zn.refresh:void 0,mcpLoading:H&&o?Zn.loading:void 0,onMcpAuth:H&&o?le:void 0,permissionMode:Nt.config.mode,onPermissionModeChange:Nt.setMode,mobileExtra:Me&&Zl?a.jsx(Kb,{}):void 0,trailingExtra:Me&&Zl?a.jsx(Kb,{}):void 0})},XT=Kx(!0),JT=Kx(!1),Gx=a.jsxs("div",{className:K("shrink-0",c&&"bg-background"),children:[a.jsx(U$,{}),a.jsx(Dp,{ref:_,allowImages:Sx,agentKind:L,projectCwd:ne,footer:XT})]}),Yl=Zl?a.jsx(F$,{agentKind:L,session:Zl,onSendCommand:Rt.sendMessage,children:Gx}):Gx,QT=a.jsx("div",{className:K("shrink-0",c&&"bg-background"),children:a.jsx(Dp,{ref:_,allowImages:Sx,agentKind:L,projectCwd:ne,footer:JT})}),Zx=Rt.pendingMessages.map((Me,nt)=>a.jsx(Uj,{message:Me,turnNumber:nt+1},nt)),eE=c?d.mobileTab==="workspace"&&j.activeWorkspacePanel===Ot.sessionInfo:j.activeWorkspacePanel===Ot.sessionInfo,Yx=d.session&&!eE&&a.jsx("div",{className:"hidden",children:a.jsx(Qk,{cwd:d.session.cwd,turns:d.session.turns,onServersChanged:Q.handleServersChanged})});return n?a.jsxs(qc,{value:nf,children:[a.jsx(mf,{children:a.jsx(Uc,{value:sf,chatValue:rf,children:a.jsx(Nf,{value:$e,agentProgress:bt,children:a.jsx(Rce,{sessionId:n,loadError:zT,searchInputRef:C,activeComposer:ef||QT,hasMoreTurns:b.hasMore,isLoadingOlderTurns:b.isLoadingOlder,onLoadMoreTurns:b.loadMore})})})}),of]}):c?a.jsxs(qc,{value:nf,children:[a.jsx(mf,{enabled:l,children:a.jsx(Uc,{value:sf,chatValue:rf,children:a.jsx(Nf,{value:$e,agentProgress:bt,children:a.jsx(Ice,{navigation:{panels:j,actions:Hs,handlers:At,creatingSession:Nx,pendingSession:Ex,onStartNewSession:Ax,onSelectProject:F,liveSessionsRefreshRef:Tx,onPrefetchSession:x},sessionView:{chatInputRef:_,searchInputRef:C,teamMembersBar:Vx,activeComposer:ef||Yl,pendingComposer:Yl,pendingTurns:Zx,todoProgress:xe&&a.jsx(Bj,{progress:xe}),hasMoreTurns:b.hasMore,isLoadingOlderTurns:b.isLoadingOlder,onLoadMoreTurns:b.loadMore,onBackToMain:Dx,onShowWorkflows:Ye,onToggleExpandAll:A,workflowCount:ye,pendingPath:D},project:{currentCwd:ne,supportsWorktrees:V,worktrees:De,projectFilesRoot:oe,projectFilesRequest:ae,processPanel:Q,backgroundAgents:un,hasFileChanges:i&&Ue,onOpenTerminal:te},chrome:{backgroundServers:Yx,processPanel:qx,workflowsPanel:Hx,undoDialog:Bx,branchModal:Wx,fileChangesOpen:Xe,onFileChangesOpenChange:Ee}})})})}),of]}):a.jsxs(qc,{value:nf,children:[a.jsx(mf,{enabled:l,children:a.jsx(Uc,{value:sf,chatValue:rf,children:a.jsx(Nf,{value:$e,agentProgress:bt,children:a.jsx(xce,{navigation:{panels:j,actions:Hs,handlers:At,creatingSession:Nx,pendingSession:Ex,onStartNewSession:Ax,onStartNewFolder:RT,onSelectProject:F,onOpenPaletteProject:LT,liveSessionsRefreshRef:Tx,onPrefetchSession:x},sessionView:{searchInputRef:C,chatInputRef:_,teamMembersBar:Vx,activeComposer:ef||Yl,pendingComposer:Yl,pendingTurns:Zx,todoProgress:xe,todosExpanded:je,onTodosExpandedChange:OT,hasMoreTurns:b.hasMore,isLoadingOlderTurns:b.isLoadingOlder,onLoadMoreTurns:b.loadMore,onBackToMain:Dx,onShowWorkflows:Ye,workflowCount:ye},project:{processPanel:Q,worktrees:De,backgroundAgents:un,supportsWorktrees:V,hasFileChanges:i&&Ue,currentCwd:ne,showPreview:re,showProjectFiles:i&&se,projectFilesRoot:oe,projectFilesRequest:ae,launchTerminalRequest:ie,pendingProject:ce,onOpenTerminal:te,onTogglePreview:ue,onToggleProjectFiles:he,onCloseRightWorkspace:me},chrome:{backgroundServers:Yx,processPanel:qx,workflowsPanel:Hx,undoDialog:Bx,branchModal:Wx,killing:UT,onKillAll:BT,commandPaletteOpen:S,onCommandPaletteOpenChange:N,onOpenCommandPalette:P,onFocusComposer:I,onExpandAll:O,onExpandToolPayloads:R,onCollapseAll:$,keyboardShortcutsOpen:T,onKeyboardShortcutsOpenChange:E}})})})}),of]})}function Tde(){var v;const[n,e]=w.useState(Mt),[t,s]=w.useState(()=>Dc(Mt())),[r,o]=w.useState($s),[i,l]=w.useState(0),[c,u]=w.useState(!1),[d,f]=w.useState(!1),[m,p]=w.useState(!1),{devices:h,testDevice:g}=Ed();w.useEffect(()=>{const y=()=>{const k=Mt();e(j=>j===k?j:k),s(Dc(k))};return window.addEventListener("cogpit-device-changed",y),window.addEventListener("popstate",y),()=>{window.removeEventListener("cogpit-device-changed",y),window.removeEventListener("popstate",y)}},[]),w.useEffect(()=>{const y=k=>{const j=k.detail;(j==null?void 0:j.deviceId)===Mt()&&s(Dc(j.deviceId))};return window.addEventListener("cogpit-device-scope-changed",y),()=>window.removeEventListener("cogpit-device-scope-changed",y)},[]),w.useEffect(()=>{const y=()=>o($s());return window.addEventListener("cogpit-identity-changed",y),()=>window.removeEventListener("cogpit-identity-changed",y)},[]),w.useEffect(()=>(window.__cogpitRevealSession=dN,()=>{delete window.__cogpitRevealSession}),[]),w.useEffect(()=>{const y=k=>{const j=[Qt,...h.map(N=>N.id)],C=Mt();let _;const S=OB(k);if(S!==null)_=j[S-1];else if(MB(k)){const N=j.indexOf(C);_=j[(N+1)%j.length]}!_||_===C||(k.preventDefault(),to(_))};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[h]),w.useEffect(()=>{const y=k=>{const j=k.detail;!(j!=null&&j.deviceId)||j.deviceId!==Mt()||(u(!0),j.reason==="DEVICE_AUTH_FAILED"&&f(!0))};return window.addEventListener("cogpit-device-unreachable",y),()=>window.removeEventListener("cogpit-device-unreachable",y)},[]),w.useEffect(()=>{u(!1),f(!1),p(!1)},[n,t]);const x=w.useCallback(async()=>{p(!0);try{const y=await g(n);y.reachable&&y.authState==="bad-password"?f(!0):y.ok&&(u(!1),f(!1),l(k=>k+1))}finally{p(!1)}},[n,g]);w.useEffect(()=>{if(!c||d)return;const y=setInterval(()=>void x(),1e4);return()=>clearInterval(y)},[c,d,x]);const b=((v=h.find(y=>y.id===n))==null?void 0:v.name)??n;return a.jsxs(a.Fragment,{children:[c&&n!==Qt&&a.jsxs(Ft,{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(vA,{"data-icon":"inline-start",className:"text-warning"}),a.jsx(on,{children:d?"Device credentials need attention":"Remote device unavailable"}),a.jsx(Ut,{children:d?`${b} rejected the stored password. Update it in Devices.`:`Can’t reach ${b}. Cogpit will keep retrying.`}),a.jsxs("div",{className:"col-start-2 mt-2 flex flex-wrap gap-2",children:[!d&&a.jsxs(J,{variant:"outline",size:"xs",onClick:()=>void x(),disabled:m,children:[m&&a.jsx(ht,{"data-icon":"inline-start",className:"animate-spin"}),m?"Retrying":"Retry now"]}),a.jsx(J,{variant:"outline",size:"xs",onClick:()=>to(Qt),children:"Switch to this machine"})]})]}),a.jsx(ez,{children:a.jsx(ple,{children:a.jsx(_de,{})})},`${n}:${t}:${i}:${r??""}`)]})}const vS="Invalid link or passphrase.";function Ede(n,e){return n===401?vS: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||vS}function Ade({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(Ede(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-background px-4 py-8",children:a.jsx("form",{onSubmit:d,className:"w-full max-w-sm",children:a.jsxs(ns,{children:[a.jsxs(ws,{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(Ss,{children:"Join this session"}),a.jsx(ks,{children:"Enter the passphrase you were given to join the shared session."})]}),a.jsxs(ss,{className:"flex flex-col gap-4",children:[a.jsx(Ui,{children:a.jsxs(Lt,{children:[a.jsx(zt,{htmlFor:"share-passphrase",children:"Passphrase"}),a.jsxs(Ar,{children:[a.jsx(Pr,{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(Ds,{align:"inline-end",children:a.jsx(kl,{size:"icon-xs",onClick:()=>o(f=>!f),"aria-label":r?"Hide passphrase":"Show passphrase",children:r?a.jsx(Xu,{}):a.jsx(Mi,{})})})]})]})}),i&&a.jsxs(Ft,{variant:"destructive",children:[a.jsx(zs,{"aria-hidden":"true"}),a.jsx(on,{children:"Could not join"}),a.jsx(Ut,{children:i})]})]}),a.jsx(Sl,{children:a.jsxs(J,{type:"submit",className:"w-full",disabled:c||!t.trim(),children:[c&&a.jsx(Cn,{"data-icon":"inline-start"}),"Connect"]})})]})})})}function Pde(){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(v=>[...v,x]),t("connected"),r(void 0),h$(x,b).then(v=>{if(v.ok){t("idle");return}r(`Request failed (${v.status})`),t("error"),l(Rde)}).catch(v=>{r(v instanceof Error?v.message:"Unknown error"),t("error"),l($de)})},n[1]=c):c=n[1];const u=c;let d;n[2]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{g$().catch(Ide),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(v=>v.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 Ide(){}function $de(n){return n.slice(0,-1)}function Rde(n){return n.slice(0,-1)}const Ode=2e3;function Mde(n,e){return n.length!==e.length?!1:JSON.stringify(n)===JSON.stringify(e)}function Lde(){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 v=await y$();h||v===null||s(y=>Mde(y,v)?y:v)},x=()=>{document.visibilityState==="visible"&&g()};x();const b=setInterval(x,Ode);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)),b$(h,g).then(x=>{x&&s(b=>b.filter(v=>v.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 zde={capabilities:xl};function Dde(n){var te,le;const e=q.c(77),{info:t,children:s}=n,r=gx(),o=rT(),[i,l]=J5(),{parse:c,append:u}=gT(),[d,f]=w.useState("loading");let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=[],e[0]=m):m=e[0],w.useEffect(Wde,m);const p=Pde(),h=Lde();let g;e[1]!==l||e[2]!==t.dirName||e[3]!==t.fileName||e[4]!==r||e[5]!==c?(g=async()=>{try{const{parsed:ge,source:be}=await tT(t.dirName,t.fileName,c,"shared session");l({type:"LOAD_SESSION",session:ge,source:be,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 v,y;e[7]!==x?(v=()=>{b.current||(b.current=!0,x())},y=[x],e[7]=x,e[8]=v,e[9]=y):(v=e[8],y=e[9]),w.useEffect(v,y);let k;e[10]!==l?(k=ge=>{l({type:"UPDATE_SESSION",session:ge})},e[10]=l,e[11]=k):k=e[11];const j=k,{isLive:C,sseState:_,isCompacting:S,turnError:N}=Z5(i.sessionSource,j,c,u,void 0,i.session);let T;e[12]!==l?(T=ge=>{l({type:"SET_OLDER_TURNS",turns:ge})},e[12]=l,e[13]=T):T=e[13];const E=T,A=((te=i.sessionSource)==null?void 0:te.dirName)??null,P=((le=i.sessionSource)==null?void 0:le.fileName)??null;let I;e[14]!==E||e[15]!==i.sessionChangeKey||e[16]!==A||e[17]!==P||e[18]!==c?(I={dirName:A,fileName:P,sessionChangeKey:i.sessionChangeKey,workerParse:c,onOlderTurns:E},e[14]=E,e[15]=i.sessionChangeKey,e[16]=A,e[17]=P,e[18]=c,e[19]=I):I=e[19];const O=xT(I);let R;e[20]!==p.consumePending||e[21]!==p.pendingMessages||e[22]!==C||e[23]!==i.session||e[24]!==i.sessionChangeKey?(R={session:i.session,isLive:C,pendingMessages:p.pendingMessages,consumePending:p.consumePending,sessionChangeKey:i.sessionChangeKey},e[20]=p.consumePending,e[21]=p.pendingMessages,e[22]=C,e[23]=i.session,e[24]=i.sessionChangeKey,e[25]=R):R=e[25];const $=Q5(R),M=mT(i.session,i.sessionSource,x,!1);let z;e[26]!==i.session?(z=i.session?kj(i.session):null,e[26]=i.session,e[27]=z):z=e[27];const F=z;let D;e[28]!==l?(D=()=>{l({type:"TOGGLE_EXPAND_ALL"})},e[28]=l,e[29]=D):D=e[29];const L=D,B=Ude,U=Fde;let W;e[30]!==t.dirName?(W=sn(t.dirName),e[30]=t.dirName,e[31]=W):W=e[31];let V;e[32]!==W?(V={configLoading:!1,configError:null,claudeDir:null,defaultAgentKind:W,setClaudeDir:U,showConfigDialog:!1,openConfigDialog:U,handleCloseConfigDialog:U,handleConfigSaved:U,retryConfig:U,networkUrl:null,networkAccessDisabled:!1},e[32]=W,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 G=H;let Z;e[40]===Symbol.for("react.memo_cache_sentinel")?(Z=[],e[40]=Z):Z=e[40];let Y;e[41]!==L?(Y={handleStopSession:B,handleOpenBranches:U,handleBranchFromHere:U,handleToggleExpandAll:L,handleLoadSession:U},e[41]=L,e[42]=Y):Y=e[42];let X;e[43]!==S||e[44]!==C||e[45]!==F||e[46]!==h.requests||e[47]!==h.respond||e[48]!==h.respondAll||e[49]!==h.responding||e[50]!==_||e[51]!==i.session||e[52]!==i.sessionSource||e[53]!==Y||e[54]!==N||e[55]!==M?(X={session:i.session,sessionSource:i.sessionSource,isLive:C,sseState:_,isCompacting:S,turnError:N,undoRedo:M,pendingInteraction:F,permissionRequests:h.requests,permissionResponding:h.responding,respondPermission:h.respond,respondAllPermissions:h.respondAll,isSubAgentView:!1,slashSuggestions:Z,slashSuggestionsLoading:!1,promptSuggestion:null,rateLimit:null,actions:Y},e[43]=S,e[44]=C,e[45]=F,e[46]=h.requests,e[47]=h.respond,e[48]=h.respondAll,e[49]=h.responding,e[50]=_,e[51]=i.session,e[52]=i.sessionSource,e[53]=Y,e[54]=N,e[55]=M,e[56]=X):X=e[56];const ee=X;let Q;e[57]!==p||e[58]!==$?(Q={chat:p,scroll:$},e[57]=p,e[58]=$,e[59]=Q):Q=e[59];const ne=Q;let re;e[60]!==O?(re=()=>{O.loadMore()},e[60]=O,e[61]=re):re=e[61];let se;e[62]!==d||e[63]!==O.hasMore||e[64]!==O.isLoadingOlder||e[65]!==re?(se={loadState:d,hasMore:O.hasMore,isLoadingOlder:O.isLoadingOlder,loadMore:re},e[62]=d,e[63]=O.hasMore,e[64]=O.isLoadingOlder,e[65]=re,e[66]=se):se=e[66];const oe=se;let ae;e[67]!==s||e[68]!==oe?(ae=s(oe),e[67]=s,e[68]=oe,e[69]=ae):ae=e[69];let ie;e[70]!==ne||e[71]!==ee||e[72]!==ae?(ie=a.jsx(Uc,{value:ee,chatValue:ne,children:ae}),e[70]=ne,e[71]=ee,e[72]=ae,e[73]=ie):ie=e[73];let ce;return e[74]!==G||e[75]!==ie?(ce=a.jsx(qc,{value:G,children:ie}),e[74]=G,e[75]=ie,e[76]=ce):ce=e[76],ce}function Fde(){}async function Ude(){await x$().catch(Bde)}function Bde(){}function Wde(){ci(zde)}function qde(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-background",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(Ft,{variant:"destructive",className:"max-w-sm",children:[a.jsx(zs,{"aria-hidden":"true"}),a.jsx(on,{children:"Session unavailable"}),a.jsx(Ut,{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(Cn,{className:"size-5 text-muted-foreground"})}):a.jsxs(a.Fragment,{children:[a.jsx(Td,{searchInputRef:s,hasMore:i.hasMore,isLoadingOlder:i.isLoadingOlder,onLoadMore:i.loadMore}),a.jsx(Hd,{children:a.jsx(Dp,{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(Dde,{info:t,children:r}),e[3]=t,e[4]=r,e[5]=o):o=e[5],o}function Np(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-background 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 Vde(){const n=q.c(19);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=Dk(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 p$();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(Hde)};return window.addEventListener(zp,p),window.addEventListener("cogpit-auth-required",p),()=>{window.removeEventListener(zp,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(qde,{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(Ade,{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(Np,{children:a.jsx(ns,{children:a.jsxs(ws,{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(yA,{className:"size-4"})}),a.jsx(Ss,{children:"Sharing has ended"}),a.jsx(ks,{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(zs,{"aria-hidden":"true"}),h=a.jsx(on,{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(Ft,{variant:"destructive",children:[p,h,a.jsx(Ut,{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(J,{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(Np,{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(Np,{children:a.jsx(ns,{children:a.jsxs(ss,{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(Cn,{className:"size-5 text-muted-foreground"})]})})}),n[18]=m):m=n[18],m}function Hde(n){return n.kind==="ready"?{kind:"ended"}:n}class Kde extends w.Component{constructor(){super(...arguments);qt(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-background p-6 text-foreground",children:a.jsxs(ns,{className:"w-full max-w-lg text-center",children:[a.jsxs(ws,{className:"justify-items-center",children:[a.jsx(Us,{"aria-hidden":"true",className:"mb-2 size-8 text-destructive"}),a.jsx(Ss,{children:a.jsx("h1",{children:"Cogpit hit a render error"})}),a.jsx(ks,{children:"Reload the app to recover. Your sessions and project files are unchanged."})]}),a.jsx(ss,{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(Sl,{className:"justify-center",children:a.jsxs(J,{onClick:()=>window.location.reload(),children:[a.jsx(Un,{"data-icon":"inline-start"}),"Reload Cogpit"]})})]})})}}const wT=document.getElementById("root");if(!wT)throw new Error("Root element not found");oE.createRoot(wT).render(a.jsx(w.StrictMode,{children:a.jsx(Kde,{children:ud(window.location.pathname)?a.jsx(Vde,{}):a.jsx(Tde,{})})}));export{Rn as $,Ft as A,J as B,P7 as C,or as D,is as E,xU as F,ls as G,cs as H,Ds as I,uu as J,_d as K,Qde as L,rd as M,Sg as N,cu as O,wg as P,Vt as Q,yP as R,HI as S,Ed as T,Ui as U,Lt as V,kl as W,Yr as X,aF as Y,lF as Z,K as _,KI as a,es as a$,jl as a0,m3 as a1,FR as a2,Wn as a3,Fe as a4,Fi as a5,wn as a6,ds as a7,Ti as a8,Sn as a9,Kp as aA,Xp as aB,f1 as aC,ur as aD,dd as aE,yg as aF,Ki as aG,ws as aH,Ss as aI,ss as aJ,Sl as aK,ns as aL,yd as aM,T$ as aN,Rj as aO,Sr as aP,jt as aQ,er as aR,on as aS,ks as aT,jR as aU,vl as aV,Fce as aW,ld as aX,zt as aY,Ni as aZ,qW as a_,_g as aa,Tg as ab,Eg as ac,yR as ad,Pg as ae,Ig as af,Ag as ag,Rg as ah,$g as ai,ys as aj,If as ak,$B as al,Cn as am,$7 as an,sfe as ao,Cg as ap,Lo as aq,gt as ar,Lg as as,a3 as at,l3 as au,td as av,Nfe as aw,sU as ax,d$ as ay,cr as az,GI as b,tfe as b0,Nn as b1,$f as b2,TR as b3,ed as b4,e3 as b5,TI as b6,_I as b7,die as b8,MI as b9,xR as bA,$n as bB,CI as bC,rfe as bD,El as bE,n4 as bF,a1 as bG,xu as bH,Do as bI,c4 as bJ,hle as bK,T5 as bL,Hi as bM,oo as bN,r1 as bO,ig as bP,So as bQ,YS as bR,GS as bS,nd as bT,sd as bU,mk as bV,nI as bW,nfe as bX,vae as bY,$I as ba,LI as bb,RI as bc,OI as bd,II as be,g2 as bf,ai as bg,yX as bh,k5 as bi,$ae as bj,jfe as bk,Gk as bl,Zk as bm,da as bn,fa as bo,efe as bp,Yt as bq,Xt as br,Jt as bs,jd as bt,Nd as bu,Cd as bv,To as bw,ofe as bx,jn as by,Ei as bz,VI as c,FI as d,ife as e,IB as f,afe as g,ir as h,ho as i,ar as j,lr as k,Zt as l,Ar as m,Pr as n,ufe as o,Ut as p,yl as q,cfe as r,dfe as s,ffe as t,lfe as u,L5 as v,Re as w,I7 as x,as as y,Is as z};
|