remote-codex 0.11.35 → 0.11.36

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.
@@ -3650,7 +3650,7 @@ url = ${JSON.stringify(r.trim())}
3650
3650
  `).concat(`
3651
3651
  `)}const u=a.trimEnd();return u?`${u}
3652
3652
 
3653
- ${o}`:o}function nl(e){return typeof e!="number"||Number.isNaN(e)?0:Math.max(0,Math.min(100,Math.round(e)))}function jn(e){const r=e/1e3;return Number.isInteger(r)?`${r}k`:`${Number(r.toFixed(1))}k`}function Lu(e,r){if(!e)return"Select model";if((r==null?void 0:r.availability)!=="available"||typeof r.tokensInContextWindow!="number"||typeof r.modelContextWindow!="number")return`${e} · context unavailable`;const n=Math.max(r.tokensInContextWindow,0),a=Math.max(r.modelContextWindow,0),o=Math.max(a-n,0);return[e,`${jn(n)} used / ${jn(a)}`,`${jn(o)} left`,`${nl(r.remainingPercent)}% context left`].join(" · ")}function Iu(e,r){const n=e.name.trim();if(n)return n;const a=r==="photo"?e.type.includes("png")?".png":e.type.includes("heic")?".heic":e.type.includes("heif")?".heif":e.type.includes("webp")?".webp":".jpg":"";return`${r==="photo"?"photo":"file"}-${Date.now()}${a}`}function zu(e){return e.replace(/[\r\n[\]]+/g," ").replace(/\s+/g," ").trim()||"attachment"}function Hn(e){return e.type.startsWith("image/")?"photo":"file"}function On(e,r){const n=[];if(e)for(const a of Array.from(e)){if(a.kind!=="file")continue;const o=a.getAsFile();o&&n.push(o)}return n.length>0?n:r?Array.from(r):[]}function ns(e,r){return On(e,r).length>0}function Pu(e){const r=e.replace(/[\\/]+$/,"").trim();return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function as(e){const r=e.placeholder.match(/^\[(?:PHOTO|FILE)\s+(.+)\]$/);return r!=null&&r[1]?r[1]:Pu(e.originalName)}var Xr=[{value:"preToolUse",label:"PreToolUse",matcherHint:"Bash"},{value:"permissionRequest",label:"PermissionRequest",matcherHint:"Bash"},{value:"postToolUse",label:"PostToolUse",matcherHint:"Bash"},{value:"sessionStart",label:"SessionStart",matcherHint:"startup|resume"},{value:"userPromptSubmit",label:"UserPromptSubmit",matcherHint:""},{value:"stop",label:"Stop",matcherHint:""},{value:"preCompact",label:"PreCompact",matcherHint:""},{value:"postCompact",label:"PostCompact",matcherHint:""}];function Ru({goalComposeMode:e,goalBusy:r,threadConnected:n,busy:a,isShellView:o,disabledPlaceholder:s,settingsBusy:l,supportedEffortCount:i,fastMode:d}){const h=e?"Describe the goal the backend should continue working toward...":s??(o?"Send shell input to the attached terminal...":"Ask the backend to inspect, modify, or explain code..."),u=e?r?"Setting...":"Set goal":!n&&a?"Connecting...":n&&a&&!o?"Sending...":"Send",m=n?e?"ui-action-info":"ui-action-primary":"ui-action-danger",f=l;return{promptPlaceholder:h,interruptLabel:o?"Send Ctrl-C":"Stop Current Turn",sendButtonLabel:u,sendButtonClassName:m,modelControlsDisabled:f,effortControlsDisabled:f||i===0,effortControlTitle:d?"Fast mode is on. Turn it off from the slash toolbox to edit reasoning.":i===0?"The selected model does not expose adjustable reasoning effort.":"Select reasoning effort"}}function Mu({isShellView:e,edgeToEdgeMobile:r,isMobileShell:n,openMenu:a,isDragTargetActive:o,busy:s}){const l=e?"thread-composer-layer thread-shell-composer-layer":"thread-graph-composer-layer",i=e?"thread-composer-form":"thread-graph-composer-form",d=e?"thread-composer-form-floating":"thread-graph-composer-form-floating",h=e?"thread-composer-input":"thread-graph-composer-input";return{composerLayerClassName:a?`${l} relative z-[80] shrink-0`:`${l} relative z-20 shrink-0`,formClassName:e?r||n?`${i} ${d} relative z-20 shrink-0 border-t border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 py-2 pb-[calc(env(safe-area-inset-bottom)+0.5rem)] sm:px-4 sm:py-3`:`${i} relative z-20 shrink-0 border-t border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 py-2 pb-[calc(env(safe-area-inset-bottom)+0.5rem)] sm:px-4 sm:py-3`:`${i} ${r?d:""} relative z-20 shrink-0 border-t px-3 py-2 pb-[calc(env(safe-area-inset-bottom)+0.5rem)] sm:px-4 sm:py-3`,composerShellClassName:e?"thread-composer-shell":"thread-graph-composer-shell",composerToolbarClassName:e?"thread-composer-toolbar":"thread-graph-composer-toolbar",composerInputClassName:h,composerIconButtonClassName:e?"thread-composer-icon-button":"thread-graph-composer-icon-button",composerMenuClassName:e?"thread-composer-menu":"thread-graph-composer-menu",composerMenuItemClassName:e?"thread-composer-menu-item":"thread-graph-composer-menu-item",composerInlineToggleClassName:e?"thread-composer-inline-toggle":"thread-graph-composer-inline-toggle",composerPanelButtonClassName:e?"thread-composer-panel-button":"thread-graph-composer-panel-button",composerChipButtonClassName:e?"thread-composer-chip-button":"thread-graph-composer-chip-button",composerPlanToggleActiveClassName:e?"thread-composer-plan-toggle-active":"thread-graph-composer-plan-toggle-active",composerSendButtonClassName:e?"thread-composer-send-button":"thread-graph-composer-send-button",composerPromptRegionClassName:e?"thread-composer-prompt-region":"thread-graph-composer-prompt-region",promptInputClassName:`${h} min-h-[5.25rem] w-full px-4 pr-14 pt-3 outline-none transition sm:min-h-[5.75rem] ${o?"is-drag-target border-sky-300/80 bg-sky-300/[0.08] shadow-[0_0_0_1px_rgba(125,211,252,0.2)]":""}`,graphChatInputGroupClassName:`thread-graph-composer-input-group relative border-0 bg-transparent shadow-none ring-0 ${s?"bg-amber-50/40 dark:bg-amber-400/10":"bg-transparent"}`,graphChatInputClassName:`${h} min-h-[68px] max-h-32 w-full overflow-y-auto px-3 pt-3 text-[16px] leading-relaxed text-slate-800 outline-none transition sm:min-h-[92px] sm:max-h-40 sm:px-4 sm:pt-4 sm:text-[14px] dark:text-slate-100 ${o?"is-drag-target bg-sky-300/[0.08] shadow-[0_0_0_1px_rgba(125,211,252,0.2)]":""}`}}function Au(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"m4 5 2 2-2 2"}),t.jsx("path",{d:"M7.75 9.5h4.25"})]})}function _u(){return t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",children:t.jsx("path",{d:"M8 3.25v9.5M3.25 8h9.5"})})}function $u(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M10.75 2.5 5.25 13.5"}),t.jsx("path",{d:"M4.25 5.25h2.25"}),t.jsx("path",{d:"M9.5 10.75h2.25"})]})}function Du(){return t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M3 4.5A1.75 1.75 0 0 1 4.75 2.75h6.5A1.75 1.75 0 0 1 13 4.5v4A1.75 1.75 0 0 1 11.25 10.25H8l-2.75 2v-2H4.75A1.75 1.75 0 0 1 3 8.5v-4Z"})})}function Bu(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",className:"h-3.5 w-3.5 fill-current",children:[t.jsx("path",{fillRule:"evenodd",d:"M14.5 10C16.9853 10 19 7.98528 19 5.5C19 5.01783 18.9242 4.55338 18.7838 4.11791C18.6792 3.79367 18.2734 3.72683 18.0325 3.96772L15.3402 6.66002C15.2098 6.79041 15.0168 6.84163 14.8466 6.77074C14.1172 6.46695 13.5334 5.88351 13.2292 5.15431C13.1582 4.98403 13.2094 4.79088 13.3398 4.66042L16.0327 1.9676C16.2735 1.72672 16.2067 1.32092 15.8825 1.21636C15.4469 1.07588 14.9823 1 14.5 1C12.0147 1 10 3.01472 10 5.5C10 5.59783 10.0031 5.69494 10.0093 5.79122C10.065 6.66418 9.88174 7.59855 9.20974 8.15855L1.98017 14.1832C1.3591 14.7008 1 15.4674 1 16.2759C1 17.7804 2.21962 19 3.7241 19C4.53256 19 5.29925 18.6409 5.81681 18.0198L11.8414 10.7903C12.4014 10.1183 13.3358 9.93497 14.2088 9.99073C14.3051 9.99688 14.4022 10 14.5 10ZM5 16C5 16.5523 4.55228 17 4 17C3.44772 17 3 16.5523 3 16C3 15.4477 3.44772 15 4 15C4.55228 15 5 15.4477 5 16Z",clipRule:"evenodd"}),t.jsx("path",{d:"M14.5 11.5C14.6731 11.5 14.8445 11.4927 15.0138 11.4783L18.7678 15.2323C19.7441 16.2086 19.7441 17.7915 18.7678 18.7678C17.7915 19.7441 16.2086 19.7441 15.2323 18.7678L10.8216 14.3571L12.9938 11.7505C13.0455 11.6885 13.1413 11.6131 13.3357 11.5552C13.5378 11.4951 13.805 11.468 14.1132 11.4877C14.2413 11.4959 14.3702 11.5 14.5 11.5Z"}),t.jsx("path",{d:"M6.00003 4.58582L8.33056 6.91635C8.3027 6.95627 8.27496 6.98497 8.24946 7.00622L6.79994 8.21415L4.58582 6.00003H3.30905C3.11966 6.00003 2.94653 5.89303 2.86184 5.72364L1.1612 2.32237C1.06495 2.12987 1.10268 1.89739 1.25486 1.74521L1.74521 1.25486C1.89739 1.10268 2.12987 1.06495 2.32237 1.1612L5.72364 2.86184C5.89303 2.94653 6.00003 3.11966 6.00003 3.30905V4.58582Z"})]})}function Wn(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M5.5 3.25h5"}),t.jsx("path",{d:"M6.4 2h3.2a.9.9 0 0 1 .9.9v.35h1.3a1.2 1.2 0 0 1 1.2 1.2v7.35a1.2 1.2 0 0 1-1.2 1.2H4.2A1.2 1.2 0 0 1 3 11.8V4.45a1.2 1.2 0 0 1 1.2-1.2h1.3V2.9a.9.9 0 0 1 .9-.9Z"})]})}function Gu(e){switch(e){case"bearerToken":return"Token";case"oAuth":return"OAuth";case"notLoggedIn":return"Login";case"unsupported":return"Public";default:return"Unknown"}}function Fu(e){switch(e){case"repo":return"Repo";case"system":return"System";case"admin":return"Admin";case"user":default:return"User"}}function Hu(e){var r;return((r=Xr.find(n=>n.value===e))==null?void 0:r.label)??e}function Ou(e){var r;switch(e){case"cloudRequirements":return"Cloud";case"legacyManagedConfigFile":case"legacyManagedConfigMdm":return"Managed";case"sessionFlags":return"Session";default:return((r=e[0])==null?void 0:r.toUpperCase())+e.slice(1)}}function Wu(e){switch(e){case"managed":return"Managed";case"modified":return"Modified";case"trusted":return"Trusted";case"untrusted":return"Review"}}function Uu(e){switch(e){case"preToolUse":return"PreToolUse";case"permissionRequest":return"PermissionRequest";case"postToolUse":return"PostToolUse";case"preCompact":return"PreCompact";case"postCompact":return"PostCompact";case"sessionStart":return"SessionStart";case"userPromptSubmit":return"UserPromptSubmit";case"stop":return"Stop"}}function Vu(e){return e.source==="user"?"global":e.source==="project"?"project":null}function al(e){const r=Vu(e);return!r||e.handlerType!=="command"||!e.command||e.isManaged?null:{scope:r,eventName:e.eventName,matcher:e.matcher,command:e.command,timeoutSec:e.timeoutSec,statusMessage:e.statusMessage}}function Ku(e){switch(e){case"active":return"Active";case"paused":return"Paused";case"budgetLimited":return"Budget";case"complete":return"Complete";default:return e}}function qu({contextUsage:e}){const r=(e==null?void 0:e.availability)??"unavailable",n=nl(e==null?void 0:e.remainingPercent);if(r!=="available")return null;const a=n<=20?"rgba(251,113,133,0.90)":n<=40?"rgba(252,211,77,0.85)":"rgba(125,211,252,0.80)";return t.jsx("span",{"aria-hidden":"true",className:"thread-context-progress-track pointer-events-none mt-0.5 block",children:t.jsx("span",{className:"thread-context-progress-fill block",style:{width:`${n}%`,backgroundColor:a}})})}function Bt({label:e,tone:r="stone"}){const n=r==="rose"?"border-rose-300/35 bg-rose-300/14 text-rose-50":r==="sky"?"border-sky-300/35 bg-sky-300/14 text-sky-50":"border-stone-700/90 bg-stone-900/80 text-stone-100";return t.jsx("span",{className:`inline-flex min-w-[3rem] items-center justify-center rounded-full border px-2 py-1.5 text-[10px] font-medium tracking-[0.12em] ${n}`,children:e})}function Xu(e,r){return(e??[]).filter(n=>{switch(n.action){case"fast":return r.fast;case"compact":return r.compact;case"goal":return r.goal;case"fork":return r.fork;case"skills":return r.skills;case"mcp":return r.mcp;case"hooks":return r.hooks;case"prompt":case"unsupported":return!0;default:return!1}})}function Yu(e,{fastMode:r,goalComposeMode:n}){switch(e.action){case"fast":return{type:"toggleFast",fastMode:!r};case"compact":return{type:"runCompact"};case"goal":return n?{type:"exitGoalCompose"}:{type:"enterGoalCompose"};case"fork":case"skills":case"mcp":case"hooks":return{type:"openPanel",panel:e.action};case"prompt":return{type:"insertPrompt",text:`${e.command} `};default:return{type:"noop"}}}function Zu(e,{fastMode:r,compactBusy:n,goalComposeMode:a,goalStatus:o,busy:s}){switch(e.action){case"fast":return r?"On":"Off";case"compact":return n?"Busy":"Run";case"goal":return a?"Composing":o?Ku(o):"Open";case"fork":return s?"Idle only":"Open";case"skills":case"mcp":case"hooks":return"View";case"prompt":return"Compose";case"unsupported":return"Unavailable";default:return""}}function Ju(e,{settingsBusy:r,compactBusy:n,busy:a,forkBusy:o}){switch(e.action){case"fast":return r;case"compact":return n||a;case"fork":return a||o;case"unsupported":return!0;default:return!1}}function Qu(e,{fastMode:r,goalComposeMode:n,goalStatus:a,menuItemClassName:o}){return`${e.action==="fast"&&r||e.action==="goal"&&(n||a==="active")?"ui-status-warning":o} mt-1 block w-full rounded-xl px-3 py-2 text-left text-sm transition disabled:cursor-not-allowed disabled:opacity-60`}function em(e){if(!e)return"";const r=document.createElement("div");return r.innerHTML=e,r.textContent??""}function tm(e){return!!e.querySelector("[style], font")}function Ft(e){return e instanceof HTMLElement&&e.dataset.segmentType==="attachment"&&e.dataset.placeholder?e.dataset.placeholder:e.textContent??""}function sl(e){let r="";for(const n of Array.from(e.childNodes))r+=Ft(n);return r.replace(/\u00a0/g," ")}function ss(e,r,n){var i;let a=null,o=n;if(r===e){const d=Array.from(e.childNodes);let h=0;for(let u=0;u<Math.min(n,d.length);u+=1){const m=d[u];m&&(h+=Ft(m).length)}return h}if(r.nodeType===Node.TEXT_NODE)a=r;else{const d=Array.from(e.childNodes).find(h=>h.contains(r));if(!d)return sl(e).length;if(a=d,d instanceof HTMLElement&&d.dataset.segmentType==="attachment"){const h=document.createRange();h.selectNodeContents(d);const u=Ft(d).length;try{h.setEnd(r,n);const m=h.toString().length,f=((i=d.textContent)==null?void 0:i.length)??0;f===0?o=u:o=Math.round(Math.min(1,m/f)*u)}catch{o=u}}else{const h=document.createRange();h.selectNodeContents(d);try{h.setEnd(r,n),o=h.toString().length}catch{o=Ft(d).length}}}const s=Array.from(e.childNodes);let l=0;for(const d of s){if(d===a)return d.nodeType===Node.TEXT_NODE?l+o:l+Math.min(o,Ft(d).length);l+=Ft(d).length}return l}function rm(e){const r=window.getSelection();if(!r||r.rangeCount===0)return null;const n=r.getRangeAt(0);return!e.contains(n.startContainer)||!e.contains(n.endContainer)?null:{start:ss(e,n.startContainer,n.startOffset),end:ss(e,n.endContainer,n.endOffset)}}function os(e,r){let n=Math.max(0,r);const a=Array.from(e.childNodes);for(const[o,s]of a.entries()){const i=Ft(s).length;if(s.nodeType===Node.TEXT_NODE){if(n<=i)return{node:s,offset:n};n-=i;continue}if(s instanceof HTMLElement&&s.dataset.segmentType==="attachment"){if(n===0)return{node:e,offset:o};if(n<=i){const d=a[o+1];return n===i&&(d==null?void 0:d.nodeType)===Node.TEXT_NODE?{node:d,offset:0}:{node:e,offset:o+1}}n-=i;continue}if(n<=i)return{node:e,offset:o+1};n-=i}return{node:e,offset:e.childNodes.length}}function nm(e,r){const n=os(e,r.start),a=os(e,r.end),o=document.createRange();o.setStart(n.node,n.offset),o.setEnd(a.node,a.offset);const s=window.getSelection();s==null||s.removeAllRanges(),s==null||s.addRange(o)}function am(e,r){if(r.length===0)return!1;const n=r.at(-1);if(!n)return!1;const a=Array.from(e.childNodes).find(i=>i instanceof HTMLElement&&i.dataset.segmentType==="attachment"&&i.dataset.clientId===n);if(!(a instanceof HTMLElement))return!1;const o=document.createRange(),s=a.nextSibling;(s==null?void 0:s.nodeType)===Node.TEXT_NODE?o.setStart(s,0):o.setStartAfter(a),o.collapse(!0);const l=window.getSelection();return l==null||l.removeAllRanges(),l==null||l.addRange(o),!0}rn();Pt();function sm({className:e,...r}){return t.jsx("div",{"data-slot":"input-group",role:"group",className:rt("group/input-group relative flex w-full min-w-0 items-center rounded-md border shadow-xs outline-none transition-[color,box-shadow]","h-9 has-[>textarea]:h-auto","has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col","has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col",e),...r})}var om=Cr("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium select-none [&>svg:not([class*=size-])]:size-4",{variants:{align:{"inline-start":"order-first pl-3 has-[>button]:ml-[-0.45rem]","inline-end":"order-last pr-3 has-[>button]:mr-[-0.45rem]","block-start":"order-first w-full justify-start px-3 pt-3","block-end":"order-last w-full justify-start px-3 pb-3"}},defaultVariants:{align:"inline-start"}});function lm({className:e,align:r="inline-start",...n}){return t.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":r,className:rt(om({align:r}),e),onClick:a=>{var s;if(a.target.closest("button"))return;const o=(s=a.currentTarget.parentElement)==null?void 0:s.querySelector('[data-slot="input-group-control"] [contenteditable="true"], [data-slot="input-group-control"] textarea, [data-slot="input-group-control"] input, [data-slot="input-group-control"]');o==null||o.focus()},...n})}var im=Cr("flex items-center gap-2 text-sm shadow-none",{variants:{size:{xs:"h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*=size-])]:size-3.5",sm:"h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5","icon-xs":"size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function jt({className:e,type:r="button",variant:n="ghost",size:a="xs",...o}){return t.jsx(Nr,{type:r,"data-size":a,variant:n,className:rt(im({size:a}),e),...o})}function dm({className:e,...r}){return t.jsx("span",{className:rt("flex items-center gap-2 text-sm [&_svg]:pointer-events-none [&_svg:not([class*=size-])]:size-4",e),...r})}function cm({photoInputRef:e,fileInputRef:r,onAppendAttachments:n}){function a(o,s){n(o.target.files,s),o.target.value=""}return t.jsxs(t.Fragment,{children:[t.jsx("input",{ref:e,type:"file",accept:"image/*",multiple:!0,tabIndex:-1,className:"sr-only",onChange:o=>a(o,"photo")}),t.jsx("input",{ref:r,type:"file",multiple:!0,tabIndex:-1,className:"sr-only",onChange:o=>a(o,"file")})]})}function hm(e){if(!e)return"reset time unavailable";const r=new Date(e);return Number.isNaN(r.getTime())?"reset time unavailable":`resets ${r.toLocaleString()}`}function um({usage:e}){if(!e||e.authKind!=="subscription"||e.windows.length===0)return null;const r=e.windows.slice(0,2),n=r.map(a=>{const o=Math.max(0,100-a.usedPercent);return`${a.label}: ${o}% remaining, ${hm(a.resetsAt)}`}).join(". ");return t.jsx("button",{type:"button",className:"thread-subscription-usage pointer-events-auto absolute bottom-1 right-2 inline-flex h-4 items-center gap-1 rounded-[0.55rem] border border-stone-500/50 bg-stone-950/20 px-1 text-[8px] font-normal leading-none text-stone-200/90 opacity-80 shadow-sm transition hover:border-sky-300/45 hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-sky-200/70 sm:right-3","aria-label":`${e.provider} subscription usage. ${n}`,title:`${n}${e.stale?". Last known values.":""}`,children:r.map(a=>{const o=Math.max(0,Math.min(100,100-a.usedPercent)),s=o<=10?"bg-rose-400":o<=25?"bg-amber-300":"bg-sky-300";return t.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[t.jsx("span",{children:a.label}),t.jsx("span",{className:"h-0.5 w-3.5 overflow-hidden rounded-full bg-stone-600/60",children:t.jsx("span",{className:`block h-full rounded-full ${s}`,style:{width:`${o}%`}})}),t.jsxs("span",{className:"tabular-nums",children:[Math.round(o),"%"]})]},a.id)})})}function mm({activeView:e,followTail:r,onToggleFollow:n,canJumpToPreviousTurn:a,onJumpToPreviousTurn:o,canJumpToNextTurn:s,onJumpToNextTurn:l,subscriptionUsage:i}){return e!=="chat"?null:t.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-[90] h-11 -translate-y-full bg-transparent touch-manipulation sm:h-10",children:[t.jsxs("span",{role:"group","aria-label":"Timeline navigation",className:`thread-jump-latest-badge pointer-events-auto absolute bottom-1 left-1/2 inline-flex h-5 min-w-[7.5rem] -translate-x-1/2 overflow-hidden rounded-[0.7rem] border shadow-sm transition ${r?"is-active border-sky-300/36 bg-sky-300/[0.03] text-sky-100/86":"border-stone-500/70 bg-stone-950/[0.08] text-stone-200/86"}`,children:[t.jsx("button",{type:"button","aria-label":"Jump to previous turn",title:a?"Jump to the start of the previous turn":"No earlier turn",disabled:!a,onClick:()=>o==null?void 0:o(),className:"inline-flex w-10 items-center justify-center transition hover:bg-sky-300/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-sky-200/70 disabled:cursor-default disabled:opacity-35",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M3.5 12h9M8 10V5M6 7l2-2 2 2"})})}),t.jsx("span",{"aria-hidden":"true",className:"w-px bg-current opacity-20"}),t.jsx("button",{type:"button","aria-label":"Jump to latest",title:r?"Latest messages are in view":"Jump to the bottom",onClick:()=>n==null?void 0:n(),className:"inline-flex w-10 items-center justify-center transition hover:bg-sky-300/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-sky-200/70",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"m4 5.5 4 4 4-4M3.5 12.5h9"})})}),t.jsx("span",{"aria-hidden":"true",className:"w-px bg-current opacity-20"}),t.jsx("button",{type:"button","aria-label":"Jump to next turn",title:s?"Jump to the start of the next turn":"No later turn",disabled:!s,onClick:()=>l==null?void 0:l(),className:"inline-flex w-10 items-center justify-center transition hover:bg-sky-300/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-sky-200/70 disabled:cursor-default disabled:opacity-35",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M3.5 4h9M8 6v5m-2-2 2 2 2-2"})})})]}),t.jsx(um,{usage:i})]})}function pm({activeView:e,layerClassName:r,formClassName:n,shellClassName:a,inputGroupClassName:o,error:s,followTail:l,photoInputRef:i,fileInputRef:d,onAppendAttachments:h,onToggleFollow:u,canJumpToPreviousTurn:m,onJumpToPreviousTurn:f,canJumpToNextTurn:p,onJumpToNextTurn:g,subscriptionUsage:b,onSubmit:k,formRef:x,promptSlot:j,toolbarSlot:w,goalSlot:y,shellPromptSlot:v}){return t.jsxs("div",{className:r,children:[t.jsx(cm,{photoInputRef:i,fileInputRef:d,onAppendAttachments:h}),t.jsx(mm,{activeView:e,followTail:l,onToggleFollow:u,canJumpToPreviousTurn:m,onJumpToPreviousTurn:f,canJumpToNextTurn:p,onJumpToNextTurn:g,subscriptionUsage:b}),t.jsxs("form",{ref:x,"data-testid":e==="chat"?"chat-composer":void 0,onSubmit:k,className:n,children:[t.jsxs("div",{className:`${a} flex w-full flex-col overflow-visible rounded-[16px] sm:rounded-[18px]`,children:[t.jsxs(sm,{className:o,children:[j,w]}),y,v]}),s?t.jsx("div",{className:"mt-2 rounded-2xl border border-rose-500/40 bg-rose-500/10 px-4 py-3 text-sm text-rose-200",children:s}):null]})]})}function fm({open:e,iconButtonClassName:r,menuClassName:n,menuItemClassName:a,onToggle:o,onPickPhoto:s,onPickFile:l}){return t.jsxs("div",{className:"relative",children:[t.jsx(jt,{type:"button",variant:"ghost",size:"icon-xs","data-composer-menu-trigger":"true","aria-label":"Add attachment",title:"Add attachment",onClick:o,className:`${r} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:t.jsx(_u,{})}),e&&t.jsx("div",{"data-composer-menu-surface":"true",className:`${n} absolute bottom-full left-0 mb-2 w-32 overflow-hidden rounded-2xl border bg-stone-900/72 shadow-2xl shadow-stone-950/20`,children:t.jsxs("div",{className:"p-2",children:[t.jsx("button",{type:"button",onClick:s,className:`${a} block w-full rounded-xl px-3 py-2 text-left text-sm transition`,children:"Photo"}),t.jsx("button",{type:"button",onClick:l,className:`${a} mt-1 block w-full rounded-xl px-3 py-2 text-left text-sm transition`,children:"File"})]})})]})}var ol=[{mode:"read-only",label:"Read only"},{mode:"workspace-write",label:"Workspace write"},{mode:"danger-full-access",label:"Danger"}];function ls(e){var r;return((r=ol.find(n=>n.mode===e))==null?void 0:r.label)??"Default"}function gm({openMenu:e,model:r,modelOptions:n,modelContextTitle:a,contextUsage:o,reasoningEffort:s,supportedEfforts:l,displayedCollaborationMode:i,sandboxMode:d,planModeAvailable:h,sandboxModeAvailable:u,settingsBusy:m,goalComposeMode:f,goalBusy:p,activeView:g,disabled:b,fastMode:k,sendButtonLabel:x,sendButtonClassName:j,modelControlsDisabled:w,effortControlsDisabled:y,effortControlTitle:v,inlineToggleClassName:S,menuItemClassName:N,planToggleActiveClassName:I,sendButtonBaseClassName:M,onSetOpenMenu:R,onUpdateSettings:Q}){return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative min-w-0",children:[t.jsx(jt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="model","aria-label":r??"Select model",disabled:w||n.length===0,onClick:()=>R($=>$==="model"?null:"model"),title:k?`Fast mode is on. Turn it off from the slash toolbox to edit model. ${a}`:a,className:`${S} relative min-w-0 max-w-[8.75rem] overflow-hidden rounded-full px-2.5 text-left text-stone-300 disabled:cursor-not-allowed disabled:text-stone-600 sm:max-w-[11rem]`,children:t.jsx("span",{className:"relative z-[1] block min-w-0 truncate whitespace-nowrap [direction:rtl]",children:r??"Select model"})}),r?t.jsx(qu,{contextUsage:o}):null,e==="model"&&t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full left-0 mb-2 w-max min-w-[9rem] max-w-[14rem] overflow-hidden rounded-2xl border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:t.jsx("div",{className:"max-h-72 overflow-auto p-2",children:n.map($=>t.jsx("button",{type:"button",onClick:()=>Q({model:$.model,reasoningEffort:$.defaultReasoningEffort}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${$.model===r?"ui-status-warning":`${N} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:$.model})},$.id))})})]}),t.jsxs("div",{className:"relative",children:[t.jsx(jt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="effort",disabled:y,onClick:()=>R($=>$==="effort"?null:"effort"),title:v,className:`${S} rounded-full px-2 disabled:cursor-not-allowed disabled:text-stone-700 ${y?"text-stone-500":"text-stone-300 hover:text-stone-100"}`,children:ts(s)}),e==="effort"&&t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full left-0 mb-2 w-max min-w-[8rem] max-w-[12rem] overflow-hidden rounded-2xl border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:t.jsx("div",{className:"max-h-72 overflow-auto p-2",children:l.map($=>t.jsx("button",{type:"button",onClick:()=>Q({reasoningEffort:$.reasoningEffort}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${$.reasoningEffort===s?"ui-status-warning":`${N} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:ts($.reasoningEffort)})},$.reasoningEffort))})})]}),u&&t.jsxs("div",{className:"relative",children:[t.jsx(jt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="sandbox","aria-label":`Sandbox: ${ls(d)}`,disabled:m,onClick:()=>R($=>$==="sandbox"?null:"sandbox"),title:`Sandbox: ${ls(d)}`,className:`${S} rounded-full px-2.5 text-stone-300 disabled:cursor-not-allowed disabled:text-stone-700`,children:"Sandbox"}),e==="sandbox"&&t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full left-0 mb-2 w-max min-w-[9rem] max-w-[13rem] overflow-hidden rounded-2xl border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:t.jsx("div",{className:"max-h-72 overflow-auto p-2",children:ol.map($=>t.jsx("button",{type:"button",onClick:()=>Q({sandboxMode:$.mode}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${$.mode===d?"ui-status-warning":`${N} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:$.label})},$.mode))})})]}),h&&t.jsx(jt,{type:"button",variant:"ghost",size:"xs","aria-pressed":i==="plan",disabled:m,onClick:()=>Q({collaborationMode:i==="plan"?"default":"plan"}),className:`${S} rounded-full px-2.5 ${i==="plan"?`${I} border !border-[oklch(0.78_0.16_86_/_0.76)] !bg-[oklch(0.44_0.095_82_/_0.72)] !text-[oklch(0.96_0.055_92)] shadow-[0_0_0_1px_oklch(0.78_0.16_86_/_0.24),0_0_18px_oklch(0.78_0.16_86_/_0.42),inset_0_0_0_1px_oklch(0.98_0.04_96_/_0.18)]`:"text-stone-500"} disabled:cursor-not-allowed disabled:opacity-60`,children:"Plan"}),t.jsx(jt,{type:"submit",variant:"default",size:"icon-xs","aria-label":f?"Set goal":"Send Prompt",title:x,disabled:p||(g==="chat"?b:!1),className:`${M} h-9 w-9 rounded-full text-sm font-medium disabled:cursor-not-allowed sm:h-8 sm:w-8 ${j}`,children:t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-none stroke-current",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M8 13V3"}),t.jsx("path",{d:"m4 7 4-4 4 4"})]})})]})}function xm({busy:e,shellControlState:r,onPaste:n,onCopy:a,onClear:o,onShellControl:s}){const l=!!(r!=null&&r.shellInputEnabled),i=!!(r!=null&&r.isCommandRunning);return t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute right-0 top-full z-40 mt-2 w-[11.5rem] max-w-[calc(100vw-1.5rem)] rounded-[1rem] border border-stone-700/90 bg-stone-950/96 p-2 shadow-2xl shadow-stone-950/40 sm:w-48",onMouseDown:d=>{d.stopPropagation()},onPointerDown:d=>{d.stopPropagation()},onTouchStart:d=>{d.stopPropagation()},children:t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsx("button",{type:"button",onClick:n,className:"inline-flex items-center justify-center rounded-full border border-sky-300/35 bg-sky-300/12 px-2 py-2 text-sky-50",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(Wn,{}),t.jsx("span",{className:"text-[10px] font-medium tracking-[0.12em]",children:"Paste"})]})}),t.jsx("button",{type:"button",onClick:a,className:"inline-flex items-center justify-center rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-2 text-stone-100",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(Wn,{}),t.jsx("span",{className:"text-[10px] font-medium tracking-[0.12em]",children:"Copy"})]})}),t.jsx("button",{type:"button",disabled:e,onClick:o,className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"CLEAR",tone:"sky"})}),t.jsx("button",{type:"button",disabled:!l||!i,onClick:()=>s("ctrl_c"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"CTRL-C",tone:"rose"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("ctrl_d"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"CTRL-D"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("esc"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"ESC"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("tab"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"TAB"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("up"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"UP"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("down"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"DOWN"})})]})})}function bm({busy:e,forkBusy:r,composerMenuItemClassName:n,onForkLatest:a,onSelectForkTurnPanel:o}){return t.jsxs("div",{className:"p-2",children:[t.jsx("button",{type:"button",disabled:e||r,onClick:()=>void a(),className:`${n} block w-full rounded-xl px-3 py-2 text-left text-sm transition disabled:cursor-not-allowed disabled:opacity-60`,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:"Fork from latest"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:r?"Forking":"Run"})]})}),t.jsx("button",{type:"button",disabled:e||r,onClick:s=>{s.stopPropagation(),o()},className:`${n} mt-1 block w-full rounded-xl px-3 py-2 text-left text-sm transition disabled:cursor-not-allowed disabled:opacity-60`,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:"Fork from selected turn"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:"Pick"})]})}),e?t.jsx("p",{className:"mt-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Fork is only available while the thread is idle."}):null]})}function vm({forkTurnOptionsState:e,forkBusy:r,composerPanelButtonClassName:n,onForkTurn:a}){var o,s;return t.jsxs("div",{className:"p-2",children:[e.status==="loading"&&!e.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading turns..."}):null,e.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:e.error}):null,(o=e.data)!=null&&o.length?t.jsx("div",{className:"space-y-2",children:e.data.map(l=>t.jsx("button",{type:"button",disabled:r,onClick:()=>void a(l.turnId),className:`${n} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition disabled:cursor-not-allowed disabled:opacity-60`,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("span",{className:"text-sm text-stone-100",children:["Turn ",l.turnIndex]}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:r?"Forking":l.status})]})},l.turnId))}):null,e.status!=="loading"&&!e.error&&(((s=e.data)==null?void 0:s.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No turns available to fork yet."}):null]})}function km({hooksPanelMode:e,hooksState:r,hostConfigFilesAvailable:n,hookTrustAvailable:a,hookConfigBusy:o,hookConfigError:s,hookConfigSuccess:l,editingHookTarget:i,hookScope:d,hookEventName:h,hookMatcher:u,hookCommand:m,hookTimeoutSec:f,hookStatusMessage:p,composerChipButtonClassName:g,onResetHookForm:b,onSetHooksPanelMode:k,onClearHookConfigStatus:x,onSetEditingHookTarget:j,onSetHookScope:w,onSetHookEventName:y,onSetHookMatcher:v,onSetHookCommand:S,onSetHookTimeoutSec:N,onSetHookStatusMessage:I,onSaveHook:M,onStartEditingHook:R,onTrustHook:Q,onUntrustHook:$}){var Y,Z,P,te,oe;return t.jsxs("div",{className:"p-2",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs text-stone-400",children:"Hook config sources"}),t.jsx("p",{className:"truncate text-[11px] text-stone-500",children:((Y=r.data)==null?void 0:Y.projectHooksPath)??"<workspace hooks config>"})]}),e==="list"&&n?t.jsx("button",{type:"button",onClick:T=>{T.stopPropagation(),b(),k("add"),x()},className:"shrink-0 rounded-full border border-sky-300/35 px-3 py-1.5 text-xs text-sky-100 transition hover:bg-sky-300/10",children:"Add Hook"}):null]}),r.status==="loading"&&!r.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading hooks..."}):null,r.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:r.error}):null,s?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:s}):null,l?t.jsx("p",{className:"mb-2 rounded-xl border border-emerald-500/35 bg-emerald-500/10 px-3 py-3 text-sm text-emerald-100/90",children:l}):null,e==="add"||e==="edit"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[e==="edit"?t.jsxs("p",{className:"rounded-lg border border-stone-800 bg-stone-950 px-3 py-2 text-[11px] text-stone-400",children:["Editing"," ",Uu((i==null?void 0:i.eventName)??h)," ","in ",(i==null?void 0:i.scope)==="global"?"global":"project"," ","hooks.json"]}):null,t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsxs("label",{className:"block text-xs text-stone-400",children:["Scope",t.jsxs("select",{"aria-label":"Hook scope",value:d,onChange:T=>w(T.target.value),disabled:e==="edit",className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-2.5 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50",children:[t.jsx("option",{value:"project",children:"Project"}),t.jsx("option",{value:"global",children:"Global"})]})]}),t.jsxs("label",{className:"block text-xs text-stone-400",children:["Event",t.jsx("select",{"aria-label":"Hook event",value:h,onChange:T=>y(T.target.value),className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-2.5 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50",children:Xr.map(T=>t.jsx("option",{value:T.value,children:T.label},T.value))})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"Matcher"}),t.jsx("input",{"aria-label":"Hook matcher",value:u,onChange:T=>v(T.target.value),placeholder:"Bash",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"Command"}),t.jsx("textarea",{"aria-label":"Hook command",value:m,onChange:T=>S(T.target.value),rows:3,className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 font-mono text-xs text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsxs("label",{className:"block text-xs text-stone-400",children:["Timeout",t.jsx("input",{"aria-label":"Hook timeout seconds",value:f,onChange:T=>N(T.target.value),inputMode:"numeric",className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50"})]}),t.jsxs("label",{className:"block text-xs text-stone-400",children:["Status message",t.jsx("input",{"aria-label":"Hook status message",value:p,onChange:T=>I(T.target.value),className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50"})]})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>{k("list"),j(null)},className:`${g} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void M(),disabled:o,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:o?"Saving...":e==="edit"?"Update Hook":"Write Hook"})]})]}):null,e==="list"&&((Z=r.data)!=null&&Z.warnings.length)?t.jsx("div",{className:"mb-2 space-y-2",children:r.data.warnings.map(T=>t.jsx("p",{className:"rounded-xl border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-xs text-amber-100/85",children:T},T))}):null,e==="list"&&((P=r.data)!=null&&P.errors.length)?t.jsx("div",{className:"mb-2 space-y-2",children:r.data.errors.map(T=>t.jsxs("div",{className:"rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-2 text-xs text-rose-100/90",children:[t.jsx("p",{className:"font-medium",children:T.message}),t.jsx("p",{className:"mt-1 break-all text-rose-100/60",children:T.path})]},`${T.path}:${T.message}`))}):null,e==="list"&&((te=r.data)!=null&&te.hooks.length)?t.jsx("div",{className:"space-y-2",children:r.data.hooks.map(T=>t.jsxs("div",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-2.5",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("p",{className:"truncate text-sm font-medium text-stone-100",children:[Hu(T.eventName),T.matcher?` · ${T.matcher}`:""]}),t.jsx("p",{className:"mt-0.5 truncate font-mono text-[11px] text-stone-400",children:T.command??T.handlerType}),T.statusMessage?t.jsx("p",{className:"mt-1 truncate text-[11px] text-stone-500",children:T.statusMessage}):null]}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-1.5 text-[10px] uppercase tracking-[0.08em] text-stone-500",children:[al(T)?t.jsx("button",{type:"button",onClick:re=>{re.stopPropagation(),R(T)},className:`${g} rounded-full border border-stone-700 px-2 py-0.5 text-[10px] normal-case tracking-normal text-sky-100 transition hover:border-sky-300/35 hover:bg-sky-300/10`,children:"Edit"}):null,a&&T.trustStatus==="trusted"&&!T.isManaged?t.jsx("button",{type:"button",disabled:o,onClick:re=>{re.stopPropagation(),$(T)},className:`${g} rounded-full border border-stone-700 px-2 py-0.5 text-[10px] normal-case tracking-normal text-amber-100 transition hover:border-amber-300/35 hover:bg-amber-300/10 disabled:cursor-not-allowed disabled:opacity-50`,children:"Untrust"}):null,(T.trustStatus==="untrusted"||T.trustStatus==="modified")&&!T.isManaged&&a?t.jsx("button",{type:"button",disabled:o||!T.currentHash,onClick:re=>{re.stopPropagation(),Q(T)},className:`${g} rounded-full border border-stone-700 px-2 py-0.5 text-[10px] normal-case tracking-normal text-emerald-100 transition hover:border-emerald-300/35 hover:bg-emerald-300/10 disabled:cursor-not-allowed disabled:opacity-50`,children:"Trust"}):null,t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-0.5 text-stone-300",children:Wu(T.trustStatus)})]}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-1.5 text-[10px] uppercase tracking-[0.14em] text-stone-500",children:[t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:Ou(T.source)}),t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:T.enabled?"Enabled":"Disabled"}),t.jsxs("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:[T.timeoutSec,"s"]})]})]},T.key))}):null,e==="list"&&r.status!=="loading"&&!r.error&&(((oe=r.data)==null?void 0:oe.hooks.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No hooks configured for this workspace."}):null]})}function Wr(e){return e.localGoalId??`${e.createdAt}:${e.objective}`}function wm(e,r){const n=e?[e,...r]:r,a=new Set;return n.filter(o=>{const s=Wr(o);return a.has(s)?!1:(a.add(s),!0)})}function ym(e){if(e<60)return`${e}s`;const r=Math.floor(e/60);return r<60?`${r}m`:`${Math.floor(r/60)}h ${r%60}m`}function jm(e){switch(e){case"budgetLimited":return"Budget limited";case"complete":return"Complete";case"terminated":return"Terminated";case"paused":return"Paused";default:return"Active"}}function Nm({goalState:e,goalHistory:r,busy:n,onBack:a,onUpdateGoal:o}){const s=wm(e.data,r),l=e.data?Wr(e.data):null;return t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-h-11 items-center justify-between gap-3 border-b border-[var(--theme-border)] px-3 py-2",children:[t.jsx("button",{type:"button",onClick:a,className:"min-h-9 rounded-lg px-2 text-xs font-medium text-[var(--theme-fg-muted)] transition hover:bg-[var(--theme-hover)] hover:text-[var(--theme-fg)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--theme-accent-border)]",children:"Back"}),t.jsx("span",{className:"text-xs font-semibold text-[var(--theme-fg)]",children:"Goals"})]}),e.error?t.jsx("p",{className:"m-3 rounded-lg border border-[var(--status-danger-border)] bg-[var(--status-danger-bg)] px-3 py-2 text-xs text-[var(--status-danger-fg)]",children:e.error}):null,e.status==="loading"&&s.length===0?t.jsxs("div",{className:"space-y-2 p-3",role:"status","aria-label":"Loading goals",children:[t.jsx("div",{className:"h-12 animate-pulse rounded-lg bg-[var(--theme-muted)] motion-reduce:animate-none"}),t.jsx("div",{className:"h-12 animate-pulse rounded-lg bg-[var(--theme-muted)] motion-reduce:animate-none"})]}):s.length===0?t.jsx("p",{className:"px-4 py-5 text-center text-sm text-[var(--theme-fg-muted)]",children:"No goals in this thread yet."}):t.jsx("div",{className:"max-h-72 divide-y divide-[var(--theme-border)] overflow-y-auto",children:s.map(i=>{const d=Wr(i)===l&&["active","paused","budgetLimited"].includes(i.status);return t.jsxs("div",{className:"px-3 py-3",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsx("p",{className:"min-w-0 flex-1 text-sm font-medium leading-5 text-[var(--theme-fg)]",children:i.objective}),t.jsx("span",{className:"shrink-0 rounded-full border border-[var(--theme-border)] px-2 py-1 text-[10px] font-medium text-[var(--theme-fg-muted)]",children:jm(i.status)})]}),t.jsxs("p",{className:"mt-1.5 text-[11px] text-[var(--theme-fg-muted)]",children:[ym(i.timeUsedSeconds)," · ",i.tokensUsed.toLocaleString()," tokens"]}),d&&o?t.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[t.jsx("button",{type:"button",disabled:n||i.status==="active",onClick:()=>void o({status:"active"}),className:"min-h-9 rounded-lg border border-[var(--theme-border)] px-3 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:opacity-45",children:"Continue"}),t.jsx("button",{type:"button",disabled:n||i.status==="paused",onClick:()=>void o({status:"paused"}),className:"min-h-9 rounded-lg border border-[var(--theme-border)] px-3 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:opacity-45",children:"Pause"}),t.jsx("button",{type:"button",disabled:n,onClick:()=>void o({status:"terminated"}),className:"min-h-9 rounded-lg px-3 text-xs font-medium text-[var(--status-danger-fg)] transition hover:bg-[var(--status-danger-bg)] disabled:cursor-not-allowed disabled:opacity-45",children:"Terminate"})]}):null]},Wr(i))})})]})}function Cm({mcpPanelMode:e,mcpState:r,mcpConfigEditing:n,mcpConfigPath:a,mcpConfigError:o,mcpConfigSuccess:s,mcpConfigBusy:l,mcpHttpName:i,mcpHttpUrl:d,mcpRawBlock:h,composerPanelButtonClassName:u,composerChipButtonClassName:m,onSetMcpPanelMode:f,onClearMcpConfigStatus:p,onSetMcpHttpName:g,onSetMcpHttpUrl:b,onSetMcpRawBlock:k,onPrepareRawMcpBlock:x,onSaveHttpMcp:j,onSaveRawMcpBlock:w}){var y,v;return t.jsxs("div",{className:"p-2",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs text-stone-400",children:"MCP config source"}),t.jsx("p",{className:"truncate text-[11px] text-stone-500",children:a??"<provider config>"})]}),e==="list"&&n?t.jsx("button",{type:"button",onClick:S=>{S.stopPropagation(),f("add"),p()},className:"shrink-0 rounded-full border border-sky-300/35 px-3 py-1.5 text-xs text-sky-100 transition hover:bg-sky-300/10",children:"Add MCP"}):null]}),r.status==="loading"&&!r.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading MCP servers..."}):null,r.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:r.error}):null,o?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:o}):null,s?t.jsx("p",{className:"mb-2 rounded-xl border border-emerald-500/35 bg-emerald-500/10 px-3 py-3 text-sm text-emerald-100/90",children:s}):null,e==="add"?t.jsxs("div",{className:"space-y-2",children:[t.jsxs("button",{type:"button",onClick:S=>{S.stopPropagation(),f("http"),p()},className:`${u} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{className:"text-sm text-stone-100",children:"HTTP / Streamable HTTP"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:"Form"})]}),t.jsx("p",{className:"mt-1 text-xs text-stone-400",children:"Add an MCP server with a name and URL, then write the matching block into provider config."})]}),t.jsxs("button",{type:"button",onClick:S=>{S.stopPropagation(),x()},className:`${u} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{className:"text-sm text-stone-100",children:"stdio / raw block"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:"TOML"})]}),t.jsx("p",{className:"mt-1 text-xs text-stone-400",children:"Write a single `[mcp_servers.name]` block, then save it back into provider config."})]})]}):null,e==="http"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"MCP name"}),t.jsx("input",{"aria-label":"MCP name",value:i,onChange:S=>g(S.target.value),placeholder:"openaiDeveloperDocs",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"URL"}),t.jsx("input",{"aria-label":"URL",value:d,onChange:S=>b(S.target.value),placeholder:"https://developers.openai.com/mcp",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>f("add"),className:`${m} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void j(),disabled:l,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:l?"Saving...":"Write HTTP MCP"})]})]}):null,e==="stdio"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[t.jsx("label",{className:"block text-xs text-stone-400",children:"MCP block for provider config"}),t.jsx("textarea",{"aria-label":"MCP block for provider config",value:h,onChange:S=>k(S.target.value),rows:8,className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>f("add"),className:`${m} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void w(),disabled:l,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:l?"Saving...":"Write raw block"})]})]}):null,e==="list"&&((y=r.data)!=null&&y.servers.length)?t.jsx("div",{className:"space-y-2",children:r.data.servers.map(S=>t.jsxs("div",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-2.5",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate text-sm font-medium text-stone-100",children:S.name}),t.jsxs("p",{className:"mt-0.5 text-xs text-stone-400",children:[S.tools.length," tools · ",S.resourceCount," ","resources · ",S.resourceTemplateCount," templates"]})]}),t.jsx("span",{className:"shrink-0 rounded-full border border-stone-700 px-2 py-1 text-[10px] uppercase tracking-[0.14em] text-stone-300",children:Gu(S.authStatus)})]}),S.tools.length>0?t.jsx("p",{className:"mt-2 line-clamp-2 text-xs text-stone-500",children:S.tools.slice(0,4).map(N=>N.title??N.name).join(" · ")}):null]},S.name))}):null,e==="list"&&r.status!=="loading"&&!r.error&&(((v=r.data)==null?void 0:v.servers.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No MCP servers available right now."}):null]})}function Sm({skillsState:e,copiedSkillName:r,composerChipButtonClassName:n,onCopySkillInvokeName:a}){var o,s,l,i;return t.jsxs("div",{className:"p-2",children:[e.status==="loading"&&!e.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading skills..."}):null,e.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:e.error}):null,(o=e.data)!=null&&o.skills.length?t.jsx("div",{className:"space-y-2",children:e.data.skills.map(d=>{var h,u;return t.jsx("div",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-2.5",children:t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"truncate text-sm font-medium text-stone-100",children:((h=d.interface)==null?void 0:h.displayName)??d.name}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 text-[10px] uppercase tracking-[0.14em]",children:[t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-1 text-stone-400",children:Fu(d.scope)}),t.jsxs("button",{type:"button",className:`inline-flex items-center gap-1 rounded-full border px-2 py-1 normal-case tracking-normal transition ${r===d.name?"border-emerald-400/45 bg-emerald-400/12 text-emerald-100":`${n} border-stone-700 text-stone-300 hover:border-stone-500`}`,onClick:()=>void a(d.name),title:`Copy $${d.name}`,"aria-label":`Copy $${d.name}`,children:[t.jsx(Wn,{}),"$",d.name]})]}),t.jsx("p",{className:"text-xs leading-5 text-stone-400",children:((u=d.interface)==null?void 0:u.shortDescription)??d.shortDescription??d.description})]})},d.path)})}):null,(s=e.data)!=null&&s.errors.length?t.jsx("div",{className:"mt-2 space-y-2",children:e.data.errors.map(d=>t.jsxs("div",{className:"rounded-xl border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-xs text-amber-100/85",children:[t.jsx("p",{className:"font-medium",children:d.message}),t.jsx("p",{className:"mt-1 break-all text-amber-100/60",children:d.path})]},`${d.path}:${d.message}`))}):null,e.status!=="loading"&&!e.error&&(((l=e.data)==null?void 0:l.skills.length)??0)===0&&(((i=e.data)==null?void 0:i.errors.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No skills available right now."}):null]})}function Tm({open:e,slashPanelView:r,availableToolboxItems:n,busy:a,forkBusy:o,forkTurnOptionsState:s,skillsState:l,goalState:i,goalHistory:d,goalBusy:h,copiedSkillName:u,hooksPanelMode:m,hooksState:f,hostConfigFilesAvailable:p,hookTrustAvailable:g,hookConfigBusy:b,hookConfigError:k,hookConfigSuccess:x,editingHookTarget:j,hookScope:w,hookEventName:y,hookMatcher:v,hookCommand:S,hookTimeoutSec:N,hookStatusMessage:I,mcpPanelMode:M,mcpState:R,mcpConfigEditing:Q,mcpConfigPath:$,mcpConfigError:Y,mcpConfigSuccess:Z,mcpConfigBusy:P,mcpHttpName:te,mcpHttpUrl:oe,mcpRawBlock:T,iconButtonClassName:re,menuClassName:B,menuItemClassName:J,panelButtonClassName:K,chipButtonClassName:L,onToggle:q,onToolboxItemClick:G,toolboxItemDisabled:E,toolboxItemClassName:C,toolboxItemStatus:W,onSetSlashPanelView:H,onViewGoals:se,onUpdateGoal:V,onOpenForkTurns:de,onForkLatest:ee,onForkTurn:be,onCopySkillInvokeName:ie,onResetHookForm:ye,onSetHooksPanelMode:Ae,onClearHookConfigStatus:ce,onSetEditingHookTarget:Ce,onSetHookScope:Le,onSetHookEventName:X,onSetHookMatcher:ue,onSetHookCommand:ve,onSetHookTimeoutSec:ke,onSetHookStatusMessage:$e,onSaveHook:He,onStartEditingHook:_e,onTrustHook:ze,onUntrustHook:F,onSetMcpPanelMode:le,onClearMcpConfigStatus:we,onSetMcpHttpName:z,onSetMcpHttpUrl:O,onSetMcpRawBlock:ne,onPrepareRawMcpBlock:ge,onSaveHttpMcp:Te,onSaveRawMcpBlock:Ee}){return t.jsxs("div",{className:"relative",children:[t.jsx(jt,{type:"button",variant:"ghost",size:"icon-xs","data-composer-menu-trigger":"true","aria-label":"Open slash toolbox",title:"Open slash toolbox",onClick:q,className:`${re} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:t.jsx($u,{})}),e&&t.jsx("div",{"data-composer-menu-surface":"true",className:`${B} absolute bottom-full left-0 z-40 mb-2 w-72 overflow-hidden rounded-2xl border bg-stone-900/72 shadow-2xl shadow-stone-950/20 backdrop-blur-xl`,onClick:fe=>{fe.stopPropagation()},onMouseDown:fe=>{fe.stopPropagation()},onPointerDown:fe=>{fe.stopPropagation()},onTouchStart:fe=>{fe.stopPropagation()},children:r==="root"?t.jsxs("div",{className:"p-2",children:[n.map((fe,De)=>fe.action==="goal"?t.jsxs("div",{className:`mt-1 flex min-h-11 overflow-hidden rounded-xl border border-[var(--theme-border)] ${De===0?"mt-0":""}`,title:fe.description??fe.label,children:[t.jsx("button",{type:"button",disabled:E(fe),onClick:()=>{H("goals"),se==null||se()},className:"min-w-0 flex-1 px-3 py-2.5 text-left text-sm text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--theme-accent-border)] disabled:cursor-not-allowed disabled:opacity-45","aria-label":"View goals",children:t.jsx("span",{children:fe.command})}),t.jsx("button",{type:"button",disabled:E(fe),onClick:Be=>G(fe,Be),className:"min-w-14 border-l border-[var(--theme-border)] px-3 text-xs font-semibold text-[var(--theme-fg-muted)] transition hover:bg-[var(--theme-hover)] hover:text-[var(--theme-fg)] focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--theme-accent-border)] disabled:cursor-not-allowed disabled:opacity-45","aria-label":"Open goal composer",children:"Open"})]},`${fe.action}:${fe.command}`):t.jsx("button",{type:"button",disabled:E(fe),onClick:Be=>G(fe,Be),className:`${C(fe)} ${De===0?"mt-0":""}`,title:fe.description??fe.label,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:fe.command}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:W(fe)})]})},`${fe.action}:${fe.command}`)),n.length===0?t.jsx("p",{className:"px-3 py-2 text-sm text-stone-400",children:"No backend tools are available for this thread."}):null]}):t.jsx("div",{className:"max-h-80 overflow-auto",children:r==="goals"?t.jsx(Nm,{goalState:i,goalHistory:d,busy:h,onBack:()=>H("root"),onUpdateGoal:V}):r==="fork"?t.jsx(bm,{busy:a,forkBusy:o,composerMenuItemClassName:J,onForkLatest:ee,onSelectForkTurnPanel:()=>(H("forkTurns"),de())}):r==="forkTurns"?t.jsx(vm,{forkTurnOptionsState:s,forkBusy:o,composerPanelButtonClassName:K,onForkTurn:be}):r==="skills"?t.jsx(Sm,{skillsState:l,copiedSkillName:u,composerChipButtonClassName:L,onCopySkillInvokeName:ie}):r==="hooks"?t.jsx(km,{hooksPanelMode:m,hooksState:f,hostConfigFilesAvailable:p,hookTrustAvailable:g,hookConfigBusy:b,hookConfigError:k,hookConfigSuccess:x,editingHookTarget:j,hookScope:w,hookEventName:y,hookMatcher:v,hookCommand:S,hookTimeoutSec:N,hookStatusMessage:I,composerChipButtonClassName:L,onResetHookForm:ye,onSetHooksPanelMode:Ae,onClearHookConfigStatus:ce,onSetEditingHookTarget:Ce,onSetHookScope:Le,onSetHookEventName:X,onSetHookMatcher:ue,onSetHookCommand:ve,onSetHookTimeoutSec:ke,onSetHookStatusMessage:$e,onSaveHook:He,onStartEditingHook:_e,onTrustHook:ze,onUntrustHook:F}):t.jsx(Cm,{mcpPanelMode:M,mcpState:R,mcpConfigEditing:Q,mcpConfigPath:$,mcpConfigError:Y,mcpConfigSuccess:Z,mcpConfigBusy:P,mcpHttpName:te,mcpHttpUrl:oe,mcpRawBlock:T,composerPanelButtonClassName:K,composerChipButtonClassName:L,onSetMcpPanelMode:le,onClearMcpConfigStatus:we,onSetMcpHttpName:z,onSetMcpHttpUrl:O,onSetMcpRawBlock:ne,onPrepareRawMcpBlock:ge,onSaveHttpMcp:Te,onSaveRawMcpBlock:Ee})})})]})}function Em({isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:o,toolbarClassName:s,iconButtonClassName:l,slashToolboxProps:i,attachmentMenuProps:d,settingsToolbarProps:h,shellToolsPanelProps:u,onToggleView:m,onDismissPromptFocus:f,onSetOpenMenu:p}){return t.jsxs(lm,{align:"block-end",className:`${s} relative z-30 mb-0 flex items-center gap-2 text-xs`,children:[t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[!e&&i?t.jsx(Tm,{...i}):null,!e&&d?t.jsx(fm,{...d}):null,r&&t.jsx(jt,{type:"button",variant:"ghost",size:"icon-xs","aria-label":e?"Switch to chat":"Switch to shell",title:e?"Switch to chat":"Switch to shell",onClick:()=>m==null?void 0:m(),className:`${l} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:e?t.jsx(Du,{}):t.jsx(Au,{})})]}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-end gap-1.5",children:[!e&&h?t.jsx(gm,{...h}):null,e&&a?t.jsx(dm,{className:"min-w-0 max-w-[12rem] truncate rounded-full px-1.5 py-1 text-stone-400",title:a,children:a}):null,n&&t.jsxs("div",{className:"relative",children:[t.jsx("button",{type:"button","data-composer-menu-trigger":"true","aria-label":o==="shellTools"?"Close shell tools":"Open shell tools","aria-haspopup":"menu","aria-expanded":o==="shellTools",title:o==="shellTools"?"Close shell tools":"Open shell tools",onClick:()=>{f(),p(g=>g==="shellTools"?null:"shellTools")},className:"inline-flex h-7 w-7 items-center justify-center rounded-full border border-stone-700 bg-stone-900/92 text-stone-200 transition hover:bg-stone-800",children:t.jsx(Bu,{})}),o==="shellTools"&&u?t.jsx(xm,{...u}):null]})]})]})}function Lm(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`attachment-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function Im(e){return[...e.filter(r=>Hn(r)==="photo"),...e.filter(r=>Hn(r)==="file")]}function zm({prompt:e,attachments:r,updateDraft:n,getSelection:a,selectionSnapshotRef:o,pendingSelectionRef:s,pendingInsertedAttachmentIdsRef:l,onInserted:i,buildClientId:d=Lm}){const h=c.useCallback((f,p)=>{if(f.length===0)return!1;const g=bu({prompt:e,attachments:r,files:f,selection:a()??o.current,kindForFile:p,buildClientId:d});return n(()=>g.draft),s.current=g.selection,o.current=g.selection,l.current=g.insertedAttachmentIds,i==null||i(),!0},[r,d,a,i,l,s,e,o,n]),u=c.useCallback((f,p)=>!f||f.length===0?!1:h(Array.from(f),()=>p),[h]),m=c.useCallback(f=>h(Im(f),Hn),[h]);return{appendAttachments:u,appendDroppedAttachments:m}}function is(e){for(const r of e.values())URL.revokeObjectURL(r);e.clear()}function Pm({attachments:e,isShellView:r}){const n=c.useRef(new Map),[a,o]=c.useState({});return c.useEffect(()=>{const s=n.current;if(r){is(s),o({});return}const l={},i=new Set;for(const d of e){if(d.kind!=="photo")continue;i.add(d.clientId);let h=s.get(d.clientId);h||(h=URL.createObjectURL(d.file),s.set(d.clientId,h)),l[d.clientId]=h}for(const[d,h]of s.entries())i.has(d)||(URL.revokeObjectURL(h),s.delete(d));o(l)},[e,r]),c.useEffect(()=>{const s=n.current;return()=>{is(s)}},[]),a}var Rm=180;function Nn(e,r){return{prompt:e??"",attachments:r??[]}}function Mm({isShellView:e,draftPrompt:r,draftAttachments:n,onDraftChange:a}){const[o,s]=c.useState({prompt:"",attachments:[]}),[l,i]=c.useState(()=>Nn(r,n)),d=c.useRef(null),h=c.useRef(l),u=c.useRef(Mr(l)),m=!e&&r!==void 0&&n!==void 0&&typeof a=="function",f=m?Mr(Nn(r,n)):"",p=c.useRef(f);c.useLayoutEffect(()=>{if(!m){p.current="";return}const w=Nn(r,n),y=Mr(w);y!==p.current&&(p.current=y,u.current=y,h.current=w,d.current!==null&&(window.clearTimeout(d.current),d.current=null),i(w))},[n,r,m]);const g=c.useCallback(w=>{if(!m||!a)return;const y=Mr(w);y!==u.current&&(u.current=y,a(()=>({prompt:w.prompt,attachments:w.attachments})))},[m,a]);c.useEffect(()=>()=>{g(h.current),d.current!==null&&window.clearTimeout(d.current)},[g]);const b=c.useCallback((w,y)=>{if(m){if(d.current!==null&&(window.clearTimeout(d.current),d.current=null),y==="immediate"){g(w);return}d.current=window.setTimeout(()=>{d.current=null,g(h.current)},Rm)}},[m,g]),k=c.useCallback((w=h.current)=>{b(w,"immediate")},[b]),x=c.useCallback((w,y="immediate")=>{if(m){const v=w(h.current);h.current=v,i(v),b(v,y);return}s(v=>w(v))},[m,b]),j=m?l:o;return{prompt:j.prompt,attachments:j.attachments,isDraftControlled:m,updateDraft:x,flushControlledDraftToHost:k}}function Am({slashPanelView:e,onForkLatest:r,onForkTurn:n,closeMenu:a}){const[o,s]=c.useState(!1);c.useEffect(()=>{e!=="forkTurns"&&s(!1)},[e]);const l=c.useCallback(async()=>{if(r){s(!0);try{await r(),a()}finally{s(!1)}}},[a,r]),i=c.useCallback(async d=>{if(n){s(!0);try{await n(d),a()}finally{s(!1)}}},[a,n]);return{forkBusy:o,forkLatest:l,forkTurn:i}}function _m({prompt:e,goalTokenBudgetSource:r,promptRef:n,onOpenGoal:a,onPrepareGoalSubmit:o,onUpdateGoal:s,updateDraft:l,closeMenu:i,resetSlashPanel:d}){const[h,u]=c.useState(!1),[m,f]=c.useState(""),[p,g]=c.useState(!1),[b,k]=c.useState(null),x=c.useCallback(async()=>{const y=e.trim();if(!y)return k("Goal objective cannot be empty."),!1;const v=m.trim(),S=Nu(v);if(v.length>0&&(S===null||!Number.isInteger(S)||S<=0))return k("Token budget must be a positive number in thousands."),!1;if(!s)return k("/goal is unavailable in this view."),!1;g(!0),k(null);try{return o&&await o({objective:y,tokenBudget:S})===!1?!1:(await s({objective:y,status:"active",tokenBudget:S}),f(""),u(!1),l(()=>({prompt:"",attachments:[]})),!0)}catch(N){return k(N instanceof Error?N.message:"Unable to set goal."),!1}finally{g(!1)}},[m,o,s,e,l]),j=c.useCallback(()=>{i(),d(),u(!0),f(Cu(r==null?void 0:r.tokenBudget)),k(null),a==null||a(),requestAnimationFrame(()=>{var y;(y=n.current)==null||y.focus()})},[i,r==null?void 0:r.tokenBudget,a,n,d]),w=c.useCallback(()=>{u(!1),k(null)},[]);return{goalComposeMode:h,goalTokenBudget:m,goalBusy:p,goalLocalError:b,setGoalTokenBudget:f,submitGoal:x,enterGoalComposeMode:j,exitGoalComposeMode:w}}var Cn=`node -e "process.stdin.resume(); process.stdin.on('end', () => console.error('hook ran'))"`;function $m(e){const r=new Map;for(const n of e??[])r.set(n.eventName,n.command);return r}function Dm({slashPanelView:e,hookCommandTemplates:r,onCreateHook:n,onUpdateHook:a,onTrustHook:o,onUntrustHook:s}){const[l,i]=c.useState("list"),[d,h]=c.useState("project"),[u,m]=c.useState("preToolUse"),[f,p]=c.useState("Bash"),[g,b]=c.useState(Cn),[k,x]=c.useState("30"),[j,w]=c.useState("Running hook"),[y,v]=c.useState(null),[S,N]=c.useState(!1),[I,M]=c.useState(null),[R,Q]=c.useState(null),$=c.useMemo(()=>$m(r),[r]),Y=c.useCallback(J=>$.get(J)??$.get("preToolUse")??Cn,[$]),Z=c.useMemo(()=>new Set([Cn,...$.values()]),[$]),P=c.useCallback(()=>{M(null),Q(null)},[]);c.useEffect(()=>{e!=="hooks"&&(i("list"),P())},[P,e]),c.useEffect(()=>{const J=Xr.find(K=>K.value===u);p(K=>{const L=K.trim(),q=new Set(Xr.map(G=>G.matcherHint).filter(Boolean));return L&&!q.has(L)?K:(J==null?void 0:J.matcherHint)??""}),b(K=>Z.has(K.trim())?Y(u):K)},[Y,Z,u]);const te=c.useCallback(()=>{v(null),h("project"),m("preToolUse"),p("Bash"),b(Y("preToolUse")),x("30"),w("Running hook")},[Y]),oe=c.useCallback(J=>{const K=al(J);if(!K){M("Only command hooks in global or project hooks.json can be edited here.");return}v(K),h(K.scope),m(K.eventName),p(K.matcher??""),b(K.command),x(K.timeoutSec?String(K.timeoutSec):""),w(K.statusMessage??""),M(null),Q(null),i("edit")},[]),T=c.useCallback(async()=>{if(l==="edit"&&!a){M("Hook editing is unavailable in this view.");return}if(l!=="edit"&&!n){M("Hook editing is unavailable in this view.");return}if(l==="edit"&&!y){M("Select a hook to edit first.");return}const J=g.trim();if(!J){M("Hook command cannot be empty.");return}const K=k.trim(),L=K?Number(K):null;if(K&&(L===null||!Number.isInteger(L)||L<=0)){M("Timeout must be a positive number of seconds.");return}N(!0),M(null),Q(null);try{const q={scope:d,eventName:u,matcher:f.trim()||null,command:J,timeoutSec:L,statusMessage:j.trim()||null};l==="edit"?await(a==null?void 0:a({...q,target:y})):await(n==null?void 0:n(q)),Q(`${d==="project"?"Project":"Global"} hook ${l==="edit"?"updated":"written"} in hooks.json and trusted.`),i("list"),v(null)}catch(q){M(q instanceof Error?q.message:"Unable to write hooks.json.")}finally{N(!1)}},[y,g,u,f,d,j,k,l,n,a]),re=c.useCallback(async J=>{if(!o||!J.currentHash){M("Hook trust is unavailable in this view.");return}N(!0),M(null),Q(null);try{await o({key:J.key,currentHash:J.currentHash}),Q("Hook trusted.")}catch(K){M(K instanceof Error?K.message:"Unable to trust hook.")}finally{N(!1)}},[o]),B=c.useCallback(async J=>{if(!s){M("Hook trust is unavailable in this view.");return}N(!0),M(null),Q(null);try{await s({key:J.key}),Q("Hook untrusted.")}catch(K){M(K instanceof Error?K.message:"Unable to untrust hook.")}finally{N(!1)}},[s]);return{hooksPanelMode:l,hookScope:d,hookEventName:u,hookMatcher:f,hookCommand:g,hookTimeoutSec:k,hookStatusMessage:j,editingHookTarget:y,hookConfigBusy:S,hookConfigError:I,hookConfigSuccess:R,setHooksPanelMode:i,setEditingHookTarget:v,setHookScope:h,setHookEventName:m,setHookMatcher:p,setHookCommand:b,setHookTimeoutSec:x,setHookStatusMessage:w,clearHookConfigStatus:P,resetHookForm:te,startEditingHook:oe,saveHook:T,trustHook:re,untrustHook:B}}var Bm=`[mcp_servers.example_stdio]
3653
+ ${o}`:o}function nl(e){return typeof e!="number"||Number.isNaN(e)?0:Math.max(0,Math.min(100,Math.round(e)))}function jn(e){const r=e/1e3;return Number.isInteger(r)?`${r}k`:`${Number(r.toFixed(1))}k`}function Lu(e,r){if(!e)return"Select model";if((r==null?void 0:r.availability)!=="available"||typeof r.tokensInContextWindow!="number"||typeof r.modelContextWindow!="number")return`${e} · context unavailable`;const n=Math.max(r.tokensInContextWindow,0),a=Math.max(r.modelContextWindow,0),o=Math.max(a-n,0);return[e,`${jn(n)} used / ${jn(a)}`,`${jn(o)} left`,`${nl(r.remainingPercent)}% context left`].join(" · ")}function Iu(e,r){const n=e.name.trim();if(n)return n;const a=r==="photo"?e.type.includes("png")?".png":e.type.includes("heic")?".heic":e.type.includes("heif")?".heif":e.type.includes("webp")?".webp":".jpg":"";return`${r==="photo"?"photo":"file"}-${Date.now()}${a}`}function zu(e){return e.replace(/[\r\n[\]]+/g," ").replace(/\s+/g," ").trim()||"attachment"}function Hn(e){return e.type.startsWith("image/")?"photo":"file"}function On(e,r){const n=[];if(e)for(const a of Array.from(e)){if(a.kind!=="file")continue;const o=a.getAsFile();o&&n.push(o)}return n.length>0?n:r?Array.from(r):[]}function ns(e,r){return On(e,r).length>0}function Pu(e){const r=e.replace(/[\\/]+$/,"").trim();return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function as(e){const r=e.placeholder.match(/^\[(?:PHOTO|FILE)\s+(.+)\]$/);return r!=null&&r[1]?r[1]:Pu(e.originalName)}var Xr=[{value:"preToolUse",label:"PreToolUse",matcherHint:"Bash"},{value:"permissionRequest",label:"PermissionRequest",matcherHint:"Bash"},{value:"postToolUse",label:"PostToolUse",matcherHint:"Bash"},{value:"sessionStart",label:"SessionStart",matcherHint:"startup|resume"},{value:"userPromptSubmit",label:"UserPromptSubmit",matcherHint:""},{value:"stop",label:"Stop",matcherHint:""},{value:"preCompact",label:"PreCompact",matcherHint:""},{value:"postCompact",label:"PostCompact",matcherHint:""}];function Ru({goalComposeMode:e,goalBusy:r,threadConnected:n,busy:a,isShellView:o,disabledPlaceholder:s,settingsBusy:l,supportedEffortCount:i,fastMode:d}){const h=e?"Describe the goal the backend should continue working toward...":s??(o?"Send shell input to the attached terminal...":"Ask the backend to inspect, modify, or explain code..."),u=e?r?"Setting...":"Set goal":!n&&a?"Connecting...":n&&a&&!o?"Sending...":"Send",m=n?e?"ui-action-info":"ui-action-primary":"ui-action-danger",f=l;return{promptPlaceholder:h,interruptLabel:o?"Send Ctrl-C":"Stop Current Turn",sendButtonLabel:u,sendButtonClassName:m,modelControlsDisabled:f,effortControlsDisabled:f||i===0,effortControlTitle:d?"Fast mode is on. Turn it off from the slash toolbox to edit reasoning.":i===0?"The selected model does not expose adjustable reasoning effort.":"Select reasoning effort"}}function Mu({isShellView:e,edgeToEdgeMobile:r,isMobileShell:n,openMenu:a,isDragTargetActive:o,busy:s}){const l=e?"thread-composer-layer thread-shell-composer-layer":"thread-graph-composer-layer",i=e?"thread-composer-form":"thread-graph-composer-form",d=e?"thread-composer-form-floating":"thread-graph-composer-form-floating",h=e?"thread-composer-input":"thread-graph-composer-input";return{composerLayerClassName:a?`${l} relative z-[80] shrink-0`:`${l} relative z-20 shrink-0`,formClassName:e?r||n?`${i} ${d} relative z-20 shrink-0 border-t border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 py-2 pb-[calc(env(safe-area-inset-bottom)+0.5rem)] sm:px-4 sm:py-3`:`${i} relative z-20 shrink-0 border-t border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 py-2 pb-[calc(env(safe-area-inset-bottom)+0.5rem)] sm:px-4 sm:py-3`:`${i} ${r?d:""} relative z-20 shrink-0 border-t px-3 py-2 pb-[calc(env(safe-area-inset-bottom)+0.5rem)] sm:px-4 sm:py-3`,composerShellClassName:e?"thread-composer-shell":"thread-graph-composer-shell",composerToolbarClassName:e?"thread-composer-toolbar":"thread-graph-composer-toolbar",composerInputClassName:h,composerIconButtonClassName:e?"thread-composer-icon-button":"thread-graph-composer-icon-button",composerMenuClassName:e?"thread-composer-menu":"thread-graph-composer-menu",composerMenuItemClassName:e?"thread-composer-menu-item":"thread-graph-composer-menu-item",composerInlineToggleClassName:e?"thread-composer-inline-toggle":"thread-graph-composer-inline-toggle",composerPanelButtonClassName:e?"thread-composer-panel-button":"thread-graph-composer-panel-button",composerChipButtonClassName:e?"thread-composer-chip-button":"thread-graph-composer-chip-button",composerPlanToggleActiveClassName:e?"thread-composer-plan-toggle-active":"thread-graph-composer-plan-toggle-active",composerSendButtonClassName:e?"thread-composer-send-button":"thread-graph-composer-send-button",composerPromptRegionClassName:e?"thread-composer-prompt-region":"thread-graph-composer-prompt-region",promptInputClassName:`${h} min-h-[5.25rem] w-full px-4 pr-14 pt-3 outline-none transition sm:min-h-[5.75rem] ${o?"is-drag-target border-sky-300/80 bg-sky-300/[0.08] shadow-[0_0_0_1px_rgba(125,211,252,0.2)]":""}`,graphChatInputGroupClassName:`thread-graph-composer-input-group relative border-0 bg-transparent shadow-none ring-0 ${s?"bg-amber-50/40 dark:bg-amber-400/10":"bg-transparent"}`,graphChatInputClassName:`${h} min-h-[68px] max-h-32 w-full overflow-y-auto px-3 pt-3 text-[16px] leading-relaxed text-slate-800 outline-none transition sm:min-h-[92px] sm:max-h-40 sm:px-4 sm:pt-4 sm:text-[14px] dark:text-slate-100 ${o?"is-drag-target bg-sky-300/[0.08] shadow-[0_0_0_1px_rgba(125,211,252,0.2)]":""}`}}function Au(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"m4 5 2 2-2 2"}),t.jsx("path",{d:"M7.75 9.5h4.25"})]})}function _u(){return t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",children:t.jsx("path",{d:"M8 3.25v9.5M3.25 8h9.5"})})}function $u(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M10.75 2.5 5.25 13.5"}),t.jsx("path",{d:"M4.25 5.25h2.25"}),t.jsx("path",{d:"M9.5 10.75h2.25"})]})}function Du(){return t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M3 4.5A1.75 1.75 0 0 1 4.75 2.75h6.5A1.75 1.75 0 0 1 13 4.5v4A1.75 1.75 0 0 1 11.25 10.25H8l-2.75 2v-2H4.75A1.75 1.75 0 0 1 3 8.5v-4Z"})})}function Bu(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",className:"h-3.5 w-3.5 fill-current",children:[t.jsx("path",{fillRule:"evenodd",d:"M14.5 10C16.9853 10 19 7.98528 19 5.5C19 5.01783 18.9242 4.55338 18.7838 4.11791C18.6792 3.79367 18.2734 3.72683 18.0325 3.96772L15.3402 6.66002C15.2098 6.79041 15.0168 6.84163 14.8466 6.77074C14.1172 6.46695 13.5334 5.88351 13.2292 5.15431C13.1582 4.98403 13.2094 4.79088 13.3398 4.66042L16.0327 1.9676C16.2735 1.72672 16.2067 1.32092 15.8825 1.21636C15.4469 1.07588 14.9823 1 14.5 1C12.0147 1 10 3.01472 10 5.5C10 5.59783 10.0031 5.69494 10.0093 5.79122C10.065 6.66418 9.88174 7.59855 9.20974 8.15855L1.98017 14.1832C1.3591 14.7008 1 15.4674 1 16.2759C1 17.7804 2.21962 19 3.7241 19C4.53256 19 5.29925 18.6409 5.81681 18.0198L11.8414 10.7903C12.4014 10.1183 13.3358 9.93497 14.2088 9.99073C14.3051 9.99688 14.4022 10 14.5 10ZM5 16C5 16.5523 4.55228 17 4 17C3.44772 17 3 16.5523 3 16C3 15.4477 3.44772 15 4 15C4.55228 15 5 15.4477 5 16Z",clipRule:"evenodd"}),t.jsx("path",{d:"M14.5 11.5C14.6731 11.5 14.8445 11.4927 15.0138 11.4783L18.7678 15.2323C19.7441 16.2086 19.7441 17.7915 18.7678 18.7678C17.7915 19.7441 16.2086 19.7441 15.2323 18.7678L10.8216 14.3571L12.9938 11.7505C13.0455 11.6885 13.1413 11.6131 13.3357 11.5552C13.5378 11.4951 13.805 11.468 14.1132 11.4877C14.2413 11.4959 14.3702 11.5 14.5 11.5Z"}),t.jsx("path",{d:"M6.00003 4.58582L8.33056 6.91635C8.3027 6.95627 8.27496 6.98497 8.24946 7.00622L6.79994 8.21415L4.58582 6.00003H3.30905C3.11966 6.00003 2.94653 5.89303 2.86184 5.72364L1.1612 2.32237C1.06495 2.12987 1.10268 1.89739 1.25486 1.74521L1.74521 1.25486C1.89739 1.10268 2.12987 1.06495 2.32237 1.1612L5.72364 2.86184C5.89303 2.94653 6.00003 3.11966 6.00003 3.30905V4.58582Z"})]})}function Wn(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M5.5 3.25h5"}),t.jsx("path",{d:"M6.4 2h3.2a.9.9 0 0 1 .9.9v.35h1.3a1.2 1.2 0 0 1 1.2 1.2v7.35a1.2 1.2 0 0 1-1.2 1.2H4.2A1.2 1.2 0 0 1 3 11.8V4.45a1.2 1.2 0 0 1 1.2-1.2h1.3V2.9a.9.9 0 0 1 .9-.9Z"})]})}function Gu(e){switch(e){case"bearerToken":return"Token";case"oAuth":return"OAuth";case"notLoggedIn":return"Login";case"unsupported":return"Public";default:return"Unknown"}}function Fu(e){switch(e){case"repo":return"Repo";case"system":return"System";case"admin":return"Admin";case"user":default:return"User"}}function Hu(e){var r;return((r=Xr.find(n=>n.value===e))==null?void 0:r.label)??e}function Ou(e){var r;switch(e){case"cloudRequirements":return"Cloud";case"legacyManagedConfigFile":case"legacyManagedConfigMdm":return"Managed";case"sessionFlags":return"Session";default:return((r=e[0])==null?void 0:r.toUpperCase())+e.slice(1)}}function Wu(e){switch(e){case"managed":return"Managed";case"modified":return"Modified";case"trusted":return"Trusted";case"untrusted":return"Review"}}function Uu(e){switch(e){case"preToolUse":return"PreToolUse";case"permissionRequest":return"PermissionRequest";case"postToolUse":return"PostToolUse";case"preCompact":return"PreCompact";case"postCompact":return"PostCompact";case"sessionStart":return"SessionStart";case"userPromptSubmit":return"UserPromptSubmit";case"stop":return"Stop"}}function Vu(e){return e.source==="user"?"global":e.source==="project"?"project":null}function al(e){const r=Vu(e);return!r||e.handlerType!=="command"||!e.command||e.isManaged?null:{scope:r,eventName:e.eventName,matcher:e.matcher,command:e.command,timeoutSec:e.timeoutSec,statusMessage:e.statusMessage}}function Ku(e){switch(e){case"active":return"Active";case"paused":return"Paused";case"budgetLimited":return"Budget";case"complete":return"Complete";default:return e}}function qu({contextUsage:e}){const r=(e==null?void 0:e.availability)??"unavailable",n=nl(e==null?void 0:e.remainingPercent);if(r!=="available")return null;const a=n<=20?"rgba(251,113,133,0.90)":n<=40?"rgba(252,211,77,0.85)":"rgba(125,211,252,0.80)";return t.jsx("span",{"aria-hidden":"true",className:"thread-context-progress-track pointer-events-none mt-0.5 block",children:t.jsx("span",{className:"thread-context-progress-fill block",style:{width:`${n}%`,backgroundColor:a}})})}function Bt({label:e,tone:r="stone"}){const n=r==="rose"?"border-rose-300/35 bg-rose-300/14 text-rose-50":r==="sky"?"border-sky-300/35 bg-sky-300/14 text-sky-50":"border-stone-700/90 bg-stone-900/80 text-stone-100";return t.jsx("span",{className:`inline-flex min-w-[3rem] items-center justify-center rounded-full border px-2 py-1.5 text-[10px] font-medium tracking-[0.12em] ${n}`,children:e})}function Xu(e,r){return(e??[]).filter(n=>{switch(n.action){case"fast":return r.fast;case"compact":return r.compact;case"goal":return r.goal;case"fork":return r.fork;case"skills":return r.skills;case"mcp":return r.mcp;case"hooks":return r.hooks;case"prompt":case"unsupported":return!0;default:return!1}})}function Yu(e,{fastMode:r,goalComposeMode:n}){switch(e.action){case"fast":return{type:"toggleFast",fastMode:!r};case"compact":return{type:"runCompact"};case"goal":return n?{type:"exitGoalCompose"}:{type:"enterGoalCompose"};case"fork":case"skills":case"mcp":case"hooks":return{type:"openPanel",panel:e.action};case"prompt":return{type:"insertPrompt",text:`${e.command} `};default:return{type:"noop"}}}function Zu(e,{fastMode:r,compactBusy:n,goalComposeMode:a,goalStatus:o,busy:s}){switch(e.action){case"fast":return r?"On":"Off";case"compact":return n?"Busy":"Run";case"goal":return a?"Composing":o?Ku(o):"Open";case"fork":return s?"Idle only":"Open";case"skills":case"mcp":case"hooks":return"View";case"prompt":return"Compose";case"unsupported":return"Unavailable";default:return""}}function Ju(e,{settingsBusy:r,compactBusy:n,busy:a,forkBusy:o}){switch(e.action){case"fast":return r;case"compact":return n||a;case"fork":return a||o;case"unsupported":return!0;default:return!1}}function Qu(e,{fastMode:r,goalComposeMode:n,goalStatus:a,menuItemClassName:o}){return`${e.action==="fast"&&r||e.action==="goal"&&(n||a==="active")?"ui-status-warning":o} mt-1 block w-full rounded-xl px-3 py-2 text-left text-sm transition disabled:cursor-not-allowed disabled:opacity-60`}function em(e){if(!e)return"";const r=document.createElement("div");return r.innerHTML=e,r.textContent??""}function tm(e){return!!e.querySelector("[style], font")}function Ft(e){return e instanceof HTMLElement&&e.dataset.segmentType==="attachment"&&e.dataset.placeholder?e.dataset.placeholder:e.textContent??""}function sl(e){let r="";for(const n of Array.from(e.childNodes))r+=Ft(n);return r.replace(/\u00a0/g," ")}function ss(e,r,n){var i;let a=null,o=n;if(r===e){const d=Array.from(e.childNodes);let h=0;for(let u=0;u<Math.min(n,d.length);u+=1){const m=d[u];m&&(h+=Ft(m).length)}return h}if(r.nodeType===Node.TEXT_NODE)a=r;else{const d=Array.from(e.childNodes).find(h=>h.contains(r));if(!d)return sl(e).length;if(a=d,d instanceof HTMLElement&&d.dataset.segmentType==="attachment"){const h=document.createRange();h.selectNodeContents(d);const u=Ft(d).length;try{h.setEnd(r,n);const m=h.toString().length,f=((i=d.textContent)==null?void 0:i.length)??0;f===0?o=u:o=Math.round(Math.min(1,m/f)*u)}catch{o=u}}else{const h=document.createRange();h.selectNodeContents(d);try{h.setEnd(r,n),o=h.toString().length}catch{o=Ft(d).length}}}const s=Array.from(e.childNodes);let l=0;for(const d of s){if(d===a)return d.nodeType===Node.TEXT_NODE?l+o:l+Math.min(o,Ft(d).length);l+=Ft(d).length}return l}function rm(e){const r=window.getSelection();if(!r||r.rangeCount===0)return null;const n=r.getRangeAt(0);return!e.contains(n.startContainer)||!e.contains(n.endContainer)?null:{start:ss(e,n.startContainer,n.startOffset),end:ss(e,n.endContainer,n.endOffset)}}function os(e,r){let n=Math.max(0,r);const a=Array.from(e.childNodes);for(const[o,s]of a.entries()){const i=Ft(s).length;if(s.nodeType===Node.TEXT_NODE){if(n<=i)return{node:s,offset:n};n-=i;continue}if(s instanceof HTMLElement&&s.dataset.segmentType==="attachment"){if(n===0)return{node:e,offset:o};if(n<=i){const d=a[o+1];return n===i&&(d==null?void 0:d.nodeType)===Node.TEXT_NODE?{node:d,offset:0}:{node:e,offset:o+1}}n-=i;continue}if(n<=i)return{node:e,offset:o+1};n-=i}return{node:e,offset:e.childNodes.length}}function nm(e,r){const n=os(e,r.start),a=os(e,r.end),o=document.createRange();o.setStart(n.node,n.offset),o.setEnd(a.node,a.offset);const s=window.getSelection();s==null||s.removeAllRanges(),s==null||s.addRange(o)}function am(e,r){if(r.length===0)return!1;const n=r.at(-1);if(!n)return!1;const a=Array.from(e.childNodes).find(i=>i instanceof HTMLElement&&i.dataset.segmentType==="attachment"&&i.dataset.clientId===n);if(!(a instanceof HTMLElement))return!1;const o=document.createRange(),s=a.nextSibling;(s==null?void 0:s.nodeType)===Node.TEXT_NODE?o.setStart(s,0):o.setStartAfter(a),o.collapse(!0);const l=window.getSelection();return l==null||l.removeAllRanges(),l==null||l.addRange(o),!0}rn();Pt();function sm({className:e,...r}){return t.jsx("div",{"data-slot":"input-group",role:"group",className:rt("group/input-group relative flex w-full min-w-0 items-center rounded-md border shadow-xs outline-none transition-[color,box-shadow]","h-9 has-[>textarea]:h-auto","has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col","has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col",e),...r})}var om=Cr("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium select-none [&>svg:not([class*=size-])]:size-4",{variants:{align:{"inline-start":"order-first pl-3 has-[>button]:ml-[-0.45rem]","inline-end":"order-last pr-3 has-[>button]:mr-[-0.45rem]","block-start":"order-first w-full justify-start px-3 pt-3","block-end":"order-last w-full justify-start px-3 pb-3"}},defaultVariants:{align:"inline-start"}});function lm({className:e,align:r="inline-start",...n}){return t.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":r,className:rt(om({align:r}),e),onClick:a=>{var s;if(a.target.closest("button"))return;const o=(s=a.currentTarget.parentElement)==null?void 0:s.querySelector('[data-slot="input-group-control"] [contenteditable="true"], [data-slot="input-group-control"] textarea, [data-slot="input-group-control"] input, [data-slot="input-group-control"]');o==null||o.focus()},...n})}var im=Cr("flex items-center gap-2 text-sm shadow-none",{variants:{size:{xs:"h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*=size-])]:size-3.5",sm:"h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5","icon-xs":"size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function jt({className:e,type:r="button",variant:n="ghost",size:a="xs",...o}){return t.jsx(Nr,{type:r,"data-size":a,variant:n,className:rt(im({size:a}),e),...o})}function dm({className:e,...r}){return t.jsx("span",{className:rt("flex items-center gap-2 text-sm [&_svg]:pointer-events-none [&_svg:not([class*=size-])]:size-4",e),...r})}function cm({photoInputRef:e,fileInputRef:r,onAppendAttachments:n}){function a(o,s){n(o.target.files,s),o.target.value=""}return t.jsxs(t.Fragment,{children:[t.jsx("input",{ref:e,type:"file",accept:"image/*",multiple:!0,tabIndex:-1,className:"sr-only",onChange:o=>a(o,"photo")}),t.jsx("input",{ref:r,type:"file",multiple:!0,tabIndex:-1,className:"sr-only",onChange:o=>a(o,"file")})]})}function hm(e){if(!e)return"reset time unavailable";const r=new Date(e);return Number.isNaN(r.getTime())?"reset time unavailable":`resets ${r.toLocaleString()}`}function um({usage:e}){const[r,n]=c.useState(!1);if(!e||e.authKind!=="subscription"||e.windows.length===0)return null;const a=e.windows.slice(0,2),o=a.map(s=>{const l=Math.max(0,100-s.usedPercent);return`${s.label}: ${l}% remaining, ${hm(s.resetsAt)}`}).join(". ");return t.jsxs("button",{type:"button",className:`thread-subscription-usage group pointer-events-auto absolute bottom-1 right-2 inline-flex h-5 items-center gap-1.5 rounded-full border border-stone-500/45 bg-stone-950/20 px-1.5 text-[8px] font-normal leading-none text-stone-200/90 shadow-sm transition-[border-color,background-color,opacity] duration-200 hover:border-stone-400/70 hover:bg-stone-900/40 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-sky-200/70 sm:right-3 ${e.stale?"opacity-60":"opacity-90"}`,"aria-label":`${e.provider} subscription usage. ${o}`,"aria-expanded":r,onClick:()=>n(s=>!s),children:[a.map(s=>{const l=Math.max(0,Math.min(100,100-s.usedPercent)),i=Math.round(18+l/100*190);return t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx("span",{children:s.label}),t.jsx("span",{"data-subscription-window-track":"true",className:"h-[3px] w-8 overflow-hidden rounded-full bg-stone-600/55 sm:w-10",children:t.jsx("span",{className:"block h-full rounded-full transition-[width] duration-500 ease-out",style:{width:`${l}%`,backgroundImage:`linear-gradient(90deg, oklch(68% 0.17 ${i}), oklch(82% 0.13 ${Math.min(i+18,235)}))`}})})]},s.id)}),t.jsxs("span",{"aria-hidden":!r,className:`pointer-events-none absolute right-0 bottom-full mb-1 whitespace-nowrap rounded-md border border-stone-600/65 bg-stone-950/95 px-1.5 py-1 text-[9px] font-normal leading-none text-stone-100 shadow-lg transition-[opacity,transform] duration-200 group-hover:translate-y-0 group-hover:opacity-100 group-focus-visible:translate-y-0 group-focus-visible:opacity-100 ${r?"translate-y-0 opacity-100":"translate-y-0.5 opacity-0"}`,children:[a.map((s,l)=>t.jsxs("span",{children:[l>0?" · ":"",s.label," ",Math.round(100-s.usedPercent),"%"]},s.id)),e.stale?" · last known":""]})]})}function mm({activeView:e,followTail:r,onToggleFollow:n,canJumpToPreviousTurn:a,onJumpToPreviousTurn:o,canJumpToNextTurn:s,onJumpToNextTurn:l,subscriptionUsage:i}){return e!=="chat"?null:t.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-[90] h-11 -translate-y-full bg-transparent touch-manipulation sm:h-10",children:[t.jsxs("span",{role:"group","aria-label":"Timeline navigation",className:`thread-jump-latest-badge pointer-events-auto absolute bottom-1 left-1/2 inline-flex h-5 min-w-[7.5rem] -translate-x-1/2 overflow-hidden rounded-[0.7rem] border shadow-sm transition ${r?"is-active border-sky-300/36 bg-sky-300/[0.03] text-sky-100/86":"border-stone-500/70 bg-stone-950/[0.08] text-stone-200/86"}`,children:[t.jsx("button",{type:"button","aria-label":"Jump to previous turn",title:a?"Jump to the start of the previous turn":"No earlier turn",disabled:!a,onClick:()=>o==null?void 0:o(),className:"inline-flex w-10 items-center justify-center transition hover:bg-sky-300/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-sky-200/70 disabled:cursor-default disabled:opacity-35",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M3.5 12h9M8 10V5M6 7l2-2 2 2"})})}),t.jsx("span",{"aria-hidden":"true",className:"w-px bg-current opacity-20"}),t.jsx("button",{type:"button","aria-label":"Jump to latest",title:r?"Latest messages are in view":"Jump to the bottom",onClick:()=>n==null?void 0:n(),className:"inline-flex w-10 items-center justify-center transition hover:bg-sky-300/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-sky-200/70",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"m4 5.5 4 4 4-4M3.5 12.5h9"})})}),t.jsx("span",{"aria-hidden":"true",className:"w-px bg-current opacity-20"}),t.jsx("button",{type:"button","aria-label":"Jump to next turn",title:s?"Jump to the start of the next turn":"No later turn",disabled:!s,onClick:()=>l==null?void 0:l(),className:"inline-flex w-10 items-center justify-center transition hover:bg-sky-300/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-sky-200/70 disabled:cursor-default disabled:opacity-35",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M3.5 4h9M8 6v5m-2-2 2 2 2-2"})})})]}),t.jsx(um,{usage:i})]})}function pm({activeView:e,layerClassName:r,formClassName:n,shellClassName:a,inputGroupClassName:o,error:s,followTail:l,photoInputRef:i,fileInputRef:d,onAppendAttachments:h,onToggleFollow:u,canJumpToPreviousTurn:m,onJumpToPreviousTurn:f,canJumpToNextTurn:p,onJumpToNextTurn:g,subscriptionUsage:b,onSubmit:k,formRef:x,promptSlot:j,toolbarSlot:w,goalSlot:y,shellPromptSlot:v}){return t.jsxs("div",{className:r,children:[t.jsx(cm,{photoInputRef:i,fileInputRef:d,onAppendAttachments:h}),t.jsx(mm,{activeView:e,followTail:l,onToggleFollow:u,canJumpToPreviousTurn:m,onJumpToPreviousTurn:f,canJumpToNextTurn:p,onJumpToNextTurn:g,subscriptionUsage:b}),t.jsxs("form",{ref:x,"data-testid":e==="chat"?"chat-composer":void 0,onSubmit:k,className:n,children:[t.jsxs("div",{className:`${a} flex w-full flex-col overflow-visible rounded-[16px] sm:rounded-[18px]`,children:[t.jsxs(sm,{className:o,children:[j,w]}),y,v]}),s?t.jsx("div",{className:"mt-2 rounded-2xl border border-rose-500/40 bg-rose-500/10 px-4 py-3 text-sm text-rose-200",children:s}):null]})]})}function fm({open:e,iconButtonClassName:r,menuClassName:n,menuItemClassName:a,onToggle:o,onPickPhoto:s,onPickFile:l}){return t.jsxs("div",{className:"relative",children:[t.jsx(jt,{type:"button",variant:"ghost",size:"icon-xs","data-composer-menu-trigger":"true","aria-label":"Add attachment",title:"Add attachment",onClick:o,className:`${r} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:t.jsx(_u,{})}),e&&t.jsx("div",{"data-composer-menu-surface":"true",className:`${n} absolute bottom-full left-0 mb-2 w-32 overflow-hidden rounded-2xl border bg-stone-900/72 shadow-2xl shadow-stone-950/20`,children:t.jsxs("div",{className:"p-2",children:[t.jsx("button",{type:"button",onClick:s,className:`${a} block w-full rounded-xl px-3 py-2 text-left text-sm transition`,children:"Photo"}),t.jsx("button",{type:"button",onClick:l,className:`${a} mt-1 block w-full rounded-xl px-3 py-2 text-left text-sm transition`,children:"File"})]})})]})}var ol=[{mode:"read-only",label:"Read only"},{mode:"workspace-write",label:"Workspace write"},{mode:"danger-full-access",label:"Danger"}];function ls(e){var r;return((r=ol.find(n=>n.mode===e))==null?void 0:r.label)??"Default"}function gm({openMenu:e,model:r,modelOptions:n,modelContextTitle:a,contextUsage:o,reasoningEffort:s,supportedEfforts:l,displayedCollaborationMode:i,sandboxMode:d,planModeAvailable:h,sandboxModeAvailable:u,settingsBusy:m,goalComposeMode:f,goalBusy:p,activeView:g,disabled:b,fastMode:k,sendButtonLabel:x,sendButtonClassName:j,modelControlsDisabled:w,effortControlsDisabled:y,effortControlTitle:v,inlineToggleClassName:S,menuItemClassName:N,planToggleActiveClassName:I,sendButtonBaseClassName:M,onSetOpenMenu:R,onUpdateSettings:Q}){return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative min-w-0",children:[t.jsx(jt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="model","aria-label":r??"Select model",disabled:w||n.length===0,onClick:()=>R($=>$==="model"?null:"model"),title:k?`Fast mode is on. Turn it off from the slash toolbox to edit model. ${a}`:a,className:`${S} relative min-w-0 max-w-[8.75rem] overflow-hidden rounded-full px-2.5 text-left text-stone-300 disabled:cursor-not-allowed disabled:text-stone-600 sm:max-w-[11rem]`,children:t.jsx("span",{className:"relative z-[1] block min-w-0 truncate whitespace-nowrap [direction:rtl]",children:r??"Select model"})}),r?t.jsx(qu,{contextUsage:o}):null,e==="model"&&t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full left-0 mb-2 w-max min-w-[9rem] max-w-[14rem] overflow-hidden rounded-2xl border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:t.jsx("div",{className:"max-h-72 overflow-auto p-2",children:n.map($=>t.jsx("button",{type:"button",onClick:()=>Q({model:$.model,reasoningEffort:$.defaultReasoningEffort}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${$.model===r?"ui-status-warning":`${N} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:$.model})},$.id))})})]}),t.jsxs("div",{className:"relative",children:[t.jsx(jt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="effort",disabled:y,onClick:()=>R($=>$==="effort"?null:"effort"),title:v,className:`${S} rounded-full px-2 disabled:cursor-not-allowed disabled:text-stone-700 ${y?"text-stone-500":"text-stone-300 hover:text-stone-100"}`,children:ts(s)}),e==="effort"&&t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full left-0 mb-2 w-max min-w-[8rem] max-w-[12rem] overflow-hidden rounded-2xl border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:t.jsx("div",{className:"max-h-72 overflow-auto p-2",children:l.map($=>t.jsx("button",{type:"button",onClick:()=>Q({reasoningEffort:$.reasoningEffort}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${$.reasoningEffort===s?"ui-status-warning":`${N} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:ts($.reasoningEffort)})},$.reasoningEffort))})})]}),u&&t.jsxs("div",{className:"relative",children:[t.jsx(jt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="sandbox","aria-label":`Sandbox: ${ls(d)}`,disabled:m,onClick:()=>R($=>$==="sandbox"?null:"sandbox"),title:`Sandbox: ${ls(d)}`,className:`${S} rounded-full px-2.5 text-stone-300 disabled:cursor-not-allowed disabled:text-stone-700`,children:"Sandbox"}),e==="sandbox"&&t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full left-0 mb-2 w-max min-w-[9rem] max-w-[13rem] overflow-hidden rounded-2xl border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:t.jsx("div",{className:"max-h-72 overflow-auto p-2",children:ol.map($=>t.jsx("button",{type:"button",onClick:()=>Q({sandboxMode:$.mode}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${$.mode===d?"ui-status-warning":`${N} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:$.label})},$.mode))})})]}),h&&t.jsx(jt,{type:"button",variant:"ghost",size:"xs","aria-pressed":i==="plan",disabled:m,onClick:()=>Q({collaborationMode:i==="plan"?"default":"plan"}),className:`${S} rounded-full px-2.5 ${i==="plan"?`${I} border !border-[oklch(0.78_0.16_86_/_0.76)] !bg-[oklch(0.44_0.095_82_/_0.72)] !text-[oklch(0.96_0.055_92)] shadow-[0_0_0_1px_oklch(0.78_0.16_86_/_0.24),0_0_18px_oklch(0.78_0.16_86_/_0.42),inset_0_0_0_1px_oklch(0.98_0.04_96_/_0.18)]`:"text-stone-500"} disabled:cursor-not-allowed disabled:opacity-60`,children:"Plan"}),t.jsx(jt,{type:"submit",variant:"default",size:"icon-xs","aria-label":f?"Set goal":"Send Prompt",title:x,disabled:p||(g==="chat"?b:!1),className:`${M} h-9 w-9 rounded-full text-sm font-medium disabled:cursor-not-allowed sm:h-8 sm:w-8 ${j}`,children:t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-none stroke-current",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M8 13V3"}),t.jsx("path",{d:"m4 7 4-4 4 4"})]})})]})}function xm({busy:e,shellControlState:r,onPaste:n,onCopy:a,onClear:o,onShellControl:s}){const l=!!(r!=null&&r.shellInputEnabled),i=!!(r!=null&&r.isCommandRunning);return t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute right-0 top-full z-40 mt-2 w-[11.5rem] max-w-[calc(100vw-1.5rem)] rounded-[1rem] border border-stone-700/90 bg-stone-950/96 p-2 shadow-2xl shadow-stone-950/40 sm:w-48",onMouseDown:d=>{d.stopPropagation()},onPointerDown:d=>{d.stopPropagation()},onTouchStart:d=>{d.stopPropagation()},children:t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsx("button",{type:"button",onClick:n,className:"inline-flex items-center justify-center rounded-full border border-sky-300/35 bg-sky-300/12 px-2 py-2 text-sky-50",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(Wn,{}),t.jsx("span",{className:"text-[10px] font-medium tracking-[0.12em]",children:"Paste"})]})}),t.jsx("button",{type:"button",onClick:a,className:"inline-flex items-center justify-center rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-2 text-stone-100",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(Wn,{}),t.jsx("span",{className:"text-[10px] font-medium tracking-[0.12em]",children:"Copy"})]})}),t.jsx("button",{type:"button",disabled:e,onClick:o,className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"CLEAR",tone:"sky"})}),t.jsx("button",{type:"button",disabled:!l||!i,onClick:()=>s("ctrl_c"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"CTRL-C",tone:"rose"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("ctrl_d"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"CTRL-D"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("esc"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"ESC"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("tab"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"TAB"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("up"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"UP"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("down"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"DOWN"})})]})})}function bm({busy:e,forkBusy:r,composerMenuItemClassName:n,onForkLatest:a,onSelectForkTurnPanel:o}){return t.jsxs("div",{className:"p-2",children:[t.jsx("button",{type:"button",disabled:e||r,onClick:()=>void a(),className:`${n} block w-full rounded-xl px-3 py-2 text-left text-sm transition disabled:cursor-not-allowed disabled:opacity-60`,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:"Fork from latest"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:r?"Forking":"Run"})]})}),t.jsx("button",{type:"button",disabled:e||r,onClick:s=>{s.stopPropagation(),o()},className:`${n} mt-1 block w-full rounded-xl px-3 py-2 text-left text-sm transition disabled:cursor-not-allowed disabled:opacity-60`,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:"Fork from selected turn"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:"Pick"})]})}),e?t.jsx("p",{className:"mt-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Fork is only available while the thread is idle."}):null]})}function vm({forkTurnOptionsState:e,forkBusy:r,composerPanelButtonClassName:n,onForkTurn:a}){var o,s;return t.jsxs("div",{className:"p-2",children:[e.status==="loading"&&!e.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading turns..."}):null,e.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:e.error}):null,(o=e.data)!=null&&o.length?t.jsx("div",{className:"space-y-2",children:e.data.map(l=>t.jsx("button",{type:"button",disabled:r,onClick:()=>void a(l.turnId),className:`${n} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition disabled:cursor-not-allowed disabled:opacity-60`,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("span",{className:"text-sm text-stone-100",children:["Turn ",l.turnIndex]}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:r?"Forking":l.status})]})},l.turnId))}):null,e.status!=="loading"&&!e.error&&(((s=e.data)==null?void 0:s.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No turns available to fork yet."}):null]})}function km({hooksPanelMode:e,hooksState:r,hostConfigFilesAvailable:n,hookTrustAvailable:a,hookConfigBusy:o,hookConfigError:s,hookConfigSuccess:l,editingHookTarget:i,hookScope:d,hookEventName:h,hookMatcher:u,hookCommand:m,hookTimeoutSec:f,hookStatusMessage:p,composerChipButtonClassName:g,onResetHookForm:b,onSetHooksPanelMode:k,onClearHookConfigStatus:x,onSetEditingHookTarget:j,onSetHookScope:w,onSetHookEventName:y,onSetHookMatcher:v,onSetHookCommand:S,onSetHookTimeoutSec:N,onSetHookStatusMessage:I,onSaveHook:M,onStartEditingHook:R,onTrustHook:Q,onUntrustHook:$}){var Y,Z,P,te,oe;return t.jsxs("div",{className:"p-2",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs text-stone-400",children:"Hook config sources"}),t.jsx("p",{className:"truncate text-[11px] text-stone-500",children:((Y=r.data)==null?void 0:Y.projectHooksPath)??"<workspace hooks config>"})]}),e==="list"&&n?t.jsx("button",{type:"button",onClick:T=>{T.stopPropagation(),b(),k("add"),x()},className:"shrink-0 rounded-full border border-sky-300/35 px-3 py-1.5 text-xs text-sky-100 transition hover:bg-sky-300/10",children:"Add Hook"}):null]}),r.status==="loading"&&!r.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading hooks..."}):null,r.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:r.error}):null,s?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:s}):null,l?t.jsx("p",{className:"mb-2 rounded-xl border border-emerald-500/35 bg-emerald-500/10 px-3 py-3 text-sm text-emerald-100/90",children:l}):null,e==="add"||e==="edit"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[e==="edit"?t.jsxs("p",{className:"rounded-lg border border-stone-800 bg-stone-950 px-3 py-2 text-[11px] text-stone-400",children:["Editing"," ",Uu((i==null?void 0:i.eventName)??h)," ","in ",(i==null?void 0:i.scope)==="global"?"global":"project"," ","hooks.json"]}):null,t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsxs("label",{className:"block text-xs text-stone-400",children:["Scope",t.jsxs("select",{"aria-label":"Hook scope",value:d,onChange:T=>w(T.target.value),disabled:e==="edit",className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-2.5 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50",children:[t.jsx("option",{value:"project",children:"Project"}),t.jsx("option",{value:"global",children:"Global"})]})]}),t.jsxs("label",{className:"block text-xs text-stone-400",children:["Event",t.jsx("select",{"aria-label":"Hook event",value:h,onChange:T=>y(T.target.value),className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-2.5 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50",children:Xr.map(T=>t.jsx("option",{value:T.value,children:T.label},T.value))})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"Matcher"}),t.jsx("input",{"aria-label":"Hook matcher",value:u,onChange:T=>v(T.target.value),placeholder:"Bash",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"Command"}),t.jsx("textarea",{"aria-label":"Hook command",value:m,onChange:T=>S(T.target.value),rows:3,className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 font-mono text-xs text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsxs("label",{className:"block text-xs text-stone-400",children:["Timeout",t.jsx("input",{"aria-label":"Hook timeout seconds",value:f,onChange:T=>N(T.target.value),inputMode:"numeric",className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50"})]}),t.jsxs("label",{className:"block text-xs text-stone-400",children:["Status message",t.jsx("input",{"aria-label":"Hook status message",value:p,onChange:T=>I(T.target.value),className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50"})]})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>{k("list"),j(null)},className:`${g} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void M(),disabled:o,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:o?"Saving...":e==="edit"?"Update Hook":"Write Hook"})]})]}):null,e==="list"&&((Z=r.data)!=null&&Z.warnings.length)?t.jsx("div",{className:"mb-2 space-y-2",children:r.data.warnings.map(T=>t.jsx("p",{className:"rounded-xl border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-xs text-amber-100/85",children:T},T))}):null,e==="list"&&((P=r.data)!=null&&P.errors.length)?t.jsx("div",{className:"mb-2 space-y-2",children:r.data.errors.map(T=>t.jsxs("div",{className:"rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-2 text-xs text-rose-100/90",children:[t.jsx("p",{className:"font-medium",children:T.message}),t.jsx("p",{className:"mt-1 break-all text-rose-100/60",children:T.path})]},`${T.path}:${T.message}`))}):null,e==="list"&&((te=r.data)!=null&&te.hooks.length)?t.jsx("div",{className:"space-y-2",children:r.data.hooks.map(T=>t.jsxs("div",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-2.5",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("p",{className:"truncate text-sm font-medium text-stone-100",children:[Hu(T.eventName),T.matcher?` · ${T.matcher}`:""]}),t.jsx("p",{className:"mt-0.5 truncate font-mono text-[11px] text-stone-400",children:T.command??T.handlerType}),T.statusMessage?t.jsx("p",{className:"mt-1 truncate text-[11px] text-stone-500",children:T.statusMessage}):null]}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-1.5 text-[10px] uppercase tracking-[0.08em] text-stone-500",children:[al(T)?t.jsx("button",{type:"button",onClick:re=>{re.stopPropagation(),R(T)},className:`${g} rounded-full border border-stone-700 px-2 py-0.5 text-[10px] normal-case tracking-normal text-sky-100 transition hover:border-sky-300/35 hover:bg-sky-300/10`,children:"Edit"}):null,a&&T.trustStatus==="trusted"&&!T.isManaged?t.jsx("button",{type:"button",disabled:o,onClick:re=>{re.stopPropagation(),$(T)},className:`${g} rounded-full border border-stone-700 px-2 py-0.5 text-[10px] normal-case tracking-normal text-amber-100 transition hover:border-amber-300/35 hover:bg-amber-300/10 disabled:cursor-not-allowed disabled:opacity-50`,children:"Untrust"}):null,(T.trustStatus==="untrusted"||T.trustStatus==="modified")&&!T.isManaged&&a?t.jsx("button",{type:"button",disabled:o||!T.currentHash,onClick:re=>{re.stopPropagation(),Q(T)},className:`${g} rounded-full border border-stone-700 px-2 py-0.5 text-[10px] normal-case tracking-normal text-emerald-100 transition hover:border-emerald-300/35 hover:bg-emerald-300/10 disabled:cursor-not-allowed disabled:opacity-50`,children:"Trust"}):null,t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-0.5 text-stone-300",children:Wu(T.trustStatus)})]}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-1.5 text-[10px] uppercase tracking-[0.14em] text-stone-500",children:[t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:Ou(T.source)}),t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:T.enabled?"Enabled":"Disabled"}),t.jsxs("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:[T.timeoutSec,"s"]})]})]},T.key))}):null,e==="list"&&r.status!=="loading"&&!r.error&&(((oe=r.data)==null?void 0:oe.hooks.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No hooks configured for this workspace."}):null]})}function Wr(e){return e.localGoalId??`${e.createdAt}:${e.objective}`}function wm(e,r){const n=e?[e,...r]:r,a=new Set;return n.filter(o=>{const s=Wr(o);return a.has(s)?!1:(a.add(s),!0)})}function ym(e){if(e<60)return`${e}s`;const r=Math.floor(e/60);return r<60?`${r}m`:`${Math.floor(r/60)}h ${r%60}m`}function jm(e){switch(e){case"budgetLimited":return"Budget limited";case"complete":return"Complete";case"terminated":return"Terminated";case"paused":return"Paused";default:return"Active"}}function Nm({goalState:e,goalHistory:r,busy:n,onBack:a,onUpdateGoal:o}){const s=wm(e.data,r),l=e.data?Wr(e.data):null;return t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-h-11 items-center justify-between gap-3 border-b border-[var(--theme-border)] px-3 py-2",children:[t.jsx("button",{type:"button",onClick:a,className:"min-h-9 rounded-lg px-2 text-xs font-medium text-[var(--theme-fg-muted)] transition hover:bg-[var(--theme-hover)] hover:text-[var(--theme-fg)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--theme-accent-border)]",children:"Back"}),t.jsx("span",{className:"text-xs font-semibold text-[var(--theme-fg)]",children:"Goals"})]}),e.error?t.jsx("p",{className:"m-3 rounded-lg border border-[var(--status-danger-border)] bg-[var(--status-danger-bg)] px-3 py-2 text-xs text-[var(--status-danger-fg)]",children:e.error}):null,e.status==="loading"&&s.length===0?t.jsxs("div",{className:"space-y-2 p-3",role:"status","aria-label":"Loading goals",children:[t.jsx("div",{className:"h-12 animate-pulse rounded-lg bg-[var(--theme-muted)] motion-reduce:animate-none"}),t.jsx("div",{className:"h-12 animate-pulse rounded-lg bg-[var(--theme-muted)] motion-reduce:animate-none"})]}):s.length===0?t.jsx("p",{className:"px-4 py-5 text-center text-sm text-[var(--theme-fg-muted)]",children:"No goals in this thread yet."}):t.jsx("div",{className:"max-h-72 divide-y divide-[var(--theme-border)] overflow-y-auto",children:s.map(i=>{const d=Wr(i)===l&&["active","paused","budgetLimited"].includes(i.status);return t.jsxs("div",{className:"px-3 py-3",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsx("p",{className:"min-w-0 flex-1 text-sm font-medium leading-5 text-[var(--theme-fg)]",children:i.objective}),t.jsx("span",{className:"shrink-0 rounded-full border border-[var(--theme-border)] px-2 py-1 text-[10px] font-medium text-[var(--theme-fg-muted)]",children:jm(i.status)})]}),t.jsxs("p",{className:"mt-1.5 text-[11px] text-[var(--theme-fg-muted)]",children:[ym(i.timeUsedSeconds)," · ",i.tokensUsed.toLocaleString()," tokens"]}),d&&o?t.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[t.jsx("button",{type:"button",disabled:n||i.status==="active",onClick:()=>void o({status:"active"}),className:"min-h-9 rounded-lg border border-[var(--theme-border)] px-3 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:opacity-45",children:"Continue"}),t.jsx("button",{type:"button",disabled:n||i.status==="paused",onClick:()=>void o({status:"paused"}),className:"min-h-9 rounded-lg border border-[var(--theme-border)] px-3 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:opacity-45",children:"Pause"}),t.jsx("button",{type:"button",disabled:n,onClick:()=>void o({status:"terminated"}),className:"min-h-9 rounded-lg px-3 text-xs font-medium text-[var(--status-danger-fg)] transition hover:bg-[var(--status-danger-bg)] disabled:cursor-not-allowed disabled:opacity-45",children:"Terminate"})]}):null]},Wr(i))})})]})}function Cm({mcpPanelMode:e,mcpState:r,mcpConfigEditing:n,mcpConfigPath:a,mcpConfigError:o,mcpConfigSuccess:s,mcpConfigBusy:l,mcpHttpName:i,mcpHttpUrl:d,mcpRawBlock:h,composerPanelButtonClassName:u,composerChipButtonClassName:m,onSetMcpPanelMode:f,onClearMcpConfigStatus:p,onSetMcpHttpName:g,onSetMcpHttpUrl:b,onSetMcpRawBlock:k,onPrepareRawMcpBlock:x,onSaveHttpMcp:j,onSaveRawMcpBlock:w}){var y,v;return t.jsxs("div",{className:"p-2",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs text-stone-400",children:"MCP config source"}),t.jsx("p",{className:"truncate text-[11px] text-stone-500",children:a??"<provider config>"})]}),e==="list"&&n?t.jsx("button",{type:"button",onClick:S=>{S.stopPropagation(),f("add"),p()},className:"shrink-0 rounded-full border border-sky-300/35 px-3 py-1.5 text-xs text-sky-100 transition hover:bg-sky-300/10",children:"Add MCP"}):null]}),r.status==="loading"&&!r.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading MCP servers..."}):null,r.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:r.error}):null,o?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:o}):null,s?t.jsx("p",{className:"mb-2 rounded-xl border border-emerald-500/35 bg-emerald-500/10 px-3 py-3 text-sm text-emerald-100/90",children:s}):null,e==="add"?t.jsxs("div",{className:"space-y-2",children:[t.jsxs("button",{type:"button",onClick:S=>{S.stopPropagation(),f("http"),p()},className:`${u} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{className:"text-sm text-stone-100",children:"HTTP / Streamable HTTP"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:"Form"})]}),t.jsx("p",{className:"mt-1 text-xs text-stone-400",children:"Add an MCP server with a name and URL, then write the matching block into provider config."})]}),t.jsxs("button",{type:"button",onClick:S=>{S.stopPropagation(),x()},className:`${u} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{className:"text-sm text-stone-100",children:"stdio / raw block"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:"TOML"})]}),t.jsx("p",{className:"mt-1 text-xs text-stone-400",children:"Write a single `[mcp_servers.name]` block, then save it back into provider config."})]})]}):null,e==="http"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"MCP name"}),t.jsx("input",{"aria-label":"MCP name",value:i,onChange:S=>g(S.target.value),placeholder:"openaiDeveloperDocs",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"URL"}),t.jsx("input",{"aria-label":"URL",value:d,onChange:S=>b(S.target.value),placeholder:"https://developers.openai.com/mcp",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>f("add"),className:`${m} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void j(),disabled:l,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:l?"Saving...":"Write HTTP MCP"})]})]}):null,e==="stdio"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[t.jsx("label",{className:"block text-xs text-stone-400",children:"MCP block for provider config"}),t.jsx("textarea",{"aria-label":"MCP block for provider config",value:h,onChange:S=>k(S.target.value),rows:8,className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>f("add"),className:`${m} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void w(),disabled:l,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:l?"Saving...":"Write raw block"})]})]}):null,e==="list"&&((y=r.data)!=null&&y.servers.length)?t.jsx("div",{className:"space-y-2",children:r.data.servers.map(S=>t.jsxs("div",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-2.5",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate text-sm font-medium text-stone-100",children:S.name}),t.jsxs("p",{className:"mt-0.5 text-xs text-stone-400",children:[S.tools.length," tools · ",S.resourceCount," ","resources · ",S.resourceTemplateCount," templates"]})]}),t.jsx("span",{className:"shrink-0 rounded-full border border-stone-700 px-2 py-1 text-[10px] uppercase tracking-[0.14em] text-stone-300",children:Gu(S.authStatus)})]}),S.tools.length>0?t.jsx("p",{className:"mt-2 line-clamp-2 text-xs text-stone-500",children:S.tools.slice(0,4).map(N=>N.title??N.name).join(" · ")}):null]},S.name))}):null,e==="list"&&r.status!=="loading"&&!r.error&&(((v=r.data)==null?void 0:v.servers.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No MCP servers available right now."}):null]})}function Sm({skillsState:e,copiedSkillName:r,composerChipButtonClassName:n,onCopySkillInvokeName:a}){var o,s,l,i;return t.jsxs("div",{className:"p-2",children:[e.status==="loading"&&!e.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading skills..."}):null,e.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:e.error}):null,(o=e.data)!=null&&o.skills.length?t.jsx("div",{className:"space-y-2",children:e.data.skills.map(d=>{var h,u;return t.jsx("div",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-2.5",children:t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"truncate text-sm font-medium text-stone-100",children:((h=d.interface)==null?void 0:h.displayName)??d.name}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 text-[10px] uppercase tracking-[0.14em]",children:[t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-1 text-stone-400",children:Fu(d.scope)}),t.jsxs("button",{type:"button",className:`inline-flex items-center gap-1 rounded-full border px-2 py-1 normal-case tracking-normal transition ${r===d.name?"border-emerald-400/45 bg-emerald-400/12 text-emerald-100":`${n} border-stone-700 text-stone-300 hover:border-stone-500`}`,onClick:()=>void a(d.name),title:`Copy $${d.name}`,"aria-label":`Copy $${d.name}`,children:[t.jsx(Wn,{}),"$",d.name]})]}),t.jsx("p",{className:"text-xs leading-5 text-stone-400",children:((u=d.interface)==null?void 0:u.shortDescription)??d.shortDescription??d.description})]})},d.path)})}):null,(s=e.data)!=null&&s.errors.length?t.jsx("div",{className:"mt-2 space-y-2",children:e.data.errors.map(d=>t.jsxs("div",{className:"rounded-xl border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-xs text-amber-100/85",children:[t.jsx("p",{className:"font-medium",children:d.message}),t.jsx("p",{className:"mt-1 break-all text-amber-100/60",children:d.path})]},`${d.path}:${d.message}`))}):null,e.status!=="loading"&&!e.error&&(((l=e.data)==null?void 0:l.skills.length)??0)===0&&(((i=e.data)==null?void 0:i.errors.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No skills available right now."}):null]})}function Tm({open:e,slashPanelView:r,availableToolboxItems:n,busy:a,forkBusy:o,forkTurnOptionsState:s,skillsState:l,goalState:i,goalHistory:d,goalBusy:h,copiedSkillName:u,hooksPanelMode:m,hooksState:f,hostConfigFilesAvailable:p,hookTrustAvailable:g,hookConfigBusy:b,hookConfigError:k,hookConfigSuccess:x,editingHookTarget:j,hookScope:w,hookEventName:y,hookMatcher:v,hookCommand:S,hookTimeoutSec:N,hookStatusMessage:I,mcpPanelMode:M,mcpState:R,mcpConfigEditing:Q,mcpConfigPath:$,mcpConfigError:Y,mcpConfigSuccess:Z,mcpConfigBusy:P,mcpHttpName:te,mcpHttpUrl:oe,mcpRawBlock:T,iconButtonClassName:re,menuClassName:B,menuItemClassName:J,panelButtonClassName:K,chipButtonClassName:L,onToggle:q,onToolboxItemClick:G,toolboxItemDisabled:E,toolboxItemClassName:C,toolboxItemStatus:W,onSetSlashPanelView:H,onViewGoals:se,onUpdateGoal:V,onOpenForkTurns:de,onForkLatest:ee,onForkTurn:be,onCopySkillInvokeName:ie,onResetHookForm:ye,onSetHooksPanelMode:Ae,onClearHookConfigStatus:ce,onSetEditingHookTarget:Ce,onSetHookScope:Le,onSetHookEventName:X,onSetHookMatcher:ue,onSetHookCommand:ve,onSetHookTimeoutSec:ke,onSetHookStatusMessage:$e,onSaveHook:He,onStartEditingHook:_e,onTrustHook:ze,onUntrustHook:F,onSetMcpPanelMode:le,onClearMcpConfigStatus:we,onSetMcpHttpName:z,onSetMcpHttpUrl:O,onSetMcpRawBlock:ne,onPrepareRawMcpBlock:ge,onSaveHttpMcp:Te,onSaveRawMcpBlock:Ee}){return t.jsxs("div",{className:"relative",children:[t.jsx(jt,{type:"button",variant:"ghost",size:"icon-xs","data-composer-menu-trigger":"true","aria-label":"Open slash toolbox",title:"Open slash toolbox",onClick:q,className:`${re} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:t.jsx($u,{})}),e&&t.jsx("div",{"data-composer-menu-surface":"true",className:`${B} absolute bottom-full left-0 z-40 mb-2 w-72 overflow-hidden rounded-2xl border bg-stone-900/72 shadow-2xl shadow-stone-950/20 backdrop-blur-xl`,onClick:fe=>{fe.stopPropagation()},onMouseDown:fe=>{fe.stopPropagation()},onPointerDown:fe=>{fe.stopPropagation()},onTouchStart:fe=>{fe.stopPropagation()},children:r==="root"?t.jsxs("div",{className:"p-2",children:[n.map((fe,De)=>fe.action==="goal"?t.jsxs("div",{className:`mt-1 flex min-h-11 overflow-hidden rounded-xl border border-[var(--theme-border)] ${De===0?"mt-0":""}`,title:fe.description??fe.label,children:[t.jsx("button",{type:"button",disabled:E(fe),onClick:()=>{H("goals"),se==null||se()},className:"min-w-0 flex-1 px-3 py-2.5 text-left text-sm text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--theme-accent-border)] disabled:cursor-not-allowed disabled:opacity-45","aria-label":"View goals",children:t.jsx("span",{children:fe.command})}),t.jsx("button",{type:"button",disabled:E(fe),onClick:Be=>G(fe,Be),className:"min-w-14 border-l border-[var(--theme-border)] px-3 text-xs font-semibold text-[var(--theme-fg-muted)] transition hover:bg-[var(--theme-hover)] hover:text-[var(--theme-fg)] focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--theme-accent-border)] disabled:cursor-not-allowed disabled:opacity-45","aria-label":"Open goal composer",children:"Open"})]},`${fe.action}:${fe.command}`):t.jsx("button",{type:"button",disabled:E(fe),onClick:Be=>G(fe,Be),className:`${C(fe)} ${De===0?"mt-0":""}`,title:fe.description??fe.label,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:fe.command}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:W(fe)})]})},`${fe.action}:${fe.command}`)),n.length===0?t.jsx("p",{className:"px-3 py-2 text-sm text-stone-400",children:"No backend tools are available for this thread."}):null]}):t.jsx("div",{className:"max-h-80 overflow-auto",children:r==="goals"?t.jsx(Nm,{goalState:i,goalHistory:d,busy:h,onBack:()=>H("root"),onUpdateGoal:V}):r==="fork"?t.jsx(bm,{busy:a,forkBusy:o,composerMenuItemClassName:J,onForkLatest:ee,onSelectForkTurnPanel:()=>(H("forkTurns"),de())}):r==="forkTurns"?t.jsx(vm,{forkTurnOptionsState:s,forkBusy:o,composerPanelButtonClassName:K,onForkTurn:be}):r==="skills"?t.jsx(Sm,{skillsState:l,copiedSkillName:u,composerChipButtonClassName:L,onCopySkillInvokeName:ie}):r==="hooks"?t.jsx(km,{hooksPanelMode:m,hooksState:f,hostConfigFilesAvailable:p,hookTrustAvailable:g,hookConfigBusy:b,hookConfigError:k,hookConfigSuccess:x,editingHookTarget:j,hookScope:w,hookEventName:y,hookMatcher:v,hookCommand:S,hookTimeoutSec:N,hookStatusMessage:I,composerChipButtonClassName:L,onResetHookForm:ye,onSetHooksPanelMode:Ae,onClearHookConfigStatus:ce,onSetEditingHookTarget:Ce,onSetHookScope:Le,onSetHookEventName:X,onSetHookMatcher:ue,onSetHookCommand:ve,onSetHookTimeoutSec:ke,onSetHookStatusMessage:$e,onSaveHook:He,onStartEditingHook:_e,onTrustHook:ze,onUntrustHook:F}):t.jsx(Cm,{mcpPanelMode:M,mcpState:R,mcpConfigEditing:Q,mcpConfigPath:$,mcpConfigError:Y,mcpConfigSuccess:Z,mcpConfigBusy:P,mcpHttpName:te,mcpHttpUrl:oe,mcpRawBlock:T,composerPanelButtonClassName:K,composerChipButtonClassName:L,onSetMcpPanelMode:le,onClearMcpConfigStatus:we,onSetMcpHttpName:z,onSetMcpHttpUrl:O,onSetMcpRawBlock:ne,onPrepareRawMcpBlock:ge,onSaveHttpMcp:Te,onSaveRawMcpBlock:Ee})})})]})}function Em({isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:o,toolbarClassName:s,iconButtonClassName:l,slashToolboxProps:i,attachmentMenuProps:d,settingsToolbarProps:h,shellToolsPanelProps:u,onToggleView:m,onDismissPromptFocus:f,onSetOpenMenu:p}){return t.jsxs(lm,{align:"block-end",className:`${s} relative z-30 mb-0 flex items-center gap-2 text-xs`,children:[t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[!e&&i?t.jsx(Tm,{...i}):null,!e&&d?t.jsx(fm,{...d}):null,r&&t.jsx(jt,{type:"button",variant:"ghost",size:"icon-xs","aria-label":e?"Switch to chat":"Switch to shell",title:e?"Switch to chat":"Switch to shell",onClick:()=>m==null?void 0:m(),className:`${l} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:e?t.jsx(Du,{}):t.jsx(Au,{})})]}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-end gap-1.5",children:[!e&&h?t.jsx(gm,{...h}):null,e&&a?t.jsx(dm,{className:"min-w-0 max-w-[12rem] truncate rounded-full px-1.5 py-1 text-stone-400",title:a,children:a}):null,n&&t.jsxs("div",{className:"relative",children:[t.jsx("button",{type:"button","data-composer-menu-trigger":"true","aria-label":o==="shellTools"?"Close shell tools":"Open shell tools","aria-haspopup":"menu","aria-expanded":o==="shellTools",title:o==="shellTools"?"Close shell tools":"Open shell tools",onClick:()=>{f(),p(g=>g==="shellTools"?null:"shellTools")},className:"inline-flex h-7 w-7 items-center justify-center rounded-full border border-stone-700 bg-stone-900/92 text-stone-200 transition hover:bg-stone-800",children:t.jsx(Bu,{})}),o==="shellTools"&&u?t.jsx(xm,{...u}):null]})]})]})}function Lm(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`attachment-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function Im(e){return[...e.filter(r=>Hn(r)==="photo"),...e.filter(r=>Hn(r)==="file")]}function zm({prompt:e,attachments:r,updateDraft:n,getSelection:a,selectionSnapshotRef:o,pendingSelectionRef:s,pendingInsertedAttachmentIdsRef:l,onInserted:i,buildClientId:d=Lm}){const h=c.useCallback((f,p)=>{if(f.length===0)return!1;const g=bu({prompt:e,attachments:r,files:f,selection:a()??o.current,kindForFile:p,buildClientId:d});return n(()=>g.draft),s.current=g.selection,o.current=g.selection,l.current=g.insertedAttachmentIds,i==null||i(),!0},[r,d,a,i,l,s,e,o,n]),u=c.useCallback((f,p)=>!f||f.length===0?!1:h(Array.from(f),()=>p),[h]),m=c.useCallback(f=>h(Im(f),Hn),[h]);return{appendAttachments:u,appendDroppedAttachments:m}}function is(e){for(const r of e.values())URL.revokeObjectURL(r);e.clear()}function Pm({attachments:e,isShellView:r}){const n=c.useRef(new Map),[a,o]=c.useState({});return c.useEffect(()=>{const s=n.current;if(r){is(s),o({});return}const l={},i=new Set;for(const d of e){if(d.kind!=="photo")continue;i.add(d.clientId);let h=s.get(d.clientId);h||(h=URL.createObjectURL(d.file),s.set(d.clientId,h)),l[d.clientId]=h}for(const[d,h]of s.entries())i.has(d)||(URL.revokeObjectURL(h),s.delete(d));o(l)},[e,r]),c.useEffect(()=>{const s=n.current;return()=>{is(s)}},[]),a}var Rm=180;function Nn(e,r){return{prompt:e??"",attachments:r??[]}}function Mm({isShellView:e,draftPrompt:r,draftAttachments:n,onDraftChange:a}){const[o,s]=c.useState({prompt:"",attachments:[]}),[l,i]=c.useState(()=>Nn(r,n)),d=c.useRef(null),h=c.useRef(l),u=c.useRef(Mr(l)),m=!e&&r!==void 0&&n!==void 0&&typeof a=="function",f=m?Mr(Nn(r,n)):"",p=c.useRef(f);c.useLayoutEffect(()=>{if(!m){p.current="";return}const w=Nn(r,n),y=Mr(w);y!==p.current&&(p.current=y,u.current=y,h.current=w,d.current!==null&&(window.clearTimeout(d.current),d.current=null),i(w))},[n,r,m]);const g=c.useCallback(w=>{if(!m||!a)return;const y=Mr(w);y!==u.current&&(u.current=y,a(()=>({prompt:w.prompt,attachments:w.attachments})))},[m,a]);c.useEffect(()=>()=>{g(h.current),d.current!==null&&window.clearTimeout(d.current)},[g]);const b=c.useCallback((w,y)=>{if(m){if(d.current!==null&&(window.clearTimeout(d.current),d.current=null),y==="immediate"){g(w);return}d.current=window.setTimeout(()=>{d.current=null,g(h.current)},Rm)}},[m,g]),k=c.useCallback((w=h.current)=>{b(w,"immediate")},[b]),x=c.useCallback((w,y="immediate")=>{if(m){const v=w(h.current);h.current=v,i(v),b(v,y);return}s(v=>w(v))},[m,b]),j=m?l:o;return{prompt:j.prompt,attachments:j.attachments,isDraftControlled:m,updateDraft:x,flushControlledDraftToHost:k}}function Am({slashPanelView:e,onForkLatest:r,onForkTurn:n,closeMenu:a}){const[o,s]=c.useState(!1);c.useEffect(()=>{e!=="forkTurns"&&s(!1)},[e]);const l=c.useCallback(async()=>{if(r){s(!0);try{await r(),a()}finally{s(!1)}}},[a,r]),i=c.useCallback(async d=>{if(n){s(!0);try{await n(d),a()}finally{s(!1)}}},[a,n]);return{forkBusy:o,forkLatest:l,forkTurn:i}}function _m({prompt:e,goalTokenBudgetSource:r,promptRef:n,onOpenGoal:a,onPrepareGoalSubmit:o,onUpdateGoal:s,updateDraft:l,closeMenu:i,resetSlashPanel:d}){const[h,u]=c.useState(!1),[m,f]=c.useState(""),[p,g]=c.useState(!1),[b,k]=c.useState(null),x=c.useCallback(async()=>{const y=e.trim();if(!y)return k("Goal objective cannot be empty."),!1;const v=m.trim(),S=Nu(v);if(v.length>0&&(S===null||!Number.isInteger(S)||S<=0))return k("Token budget must be a positive number in thousands."),!1;if(!s)return k("/goal is unavailable in this view."),!1;g(!0),k(null);try{return o&&await o({objective:y,tokenBudget:S})===!1?!1:(await s({objective:y,status:"active",tokenBudget:S}),f(""),u(!1),l(()=>({prompt:"",attachments:[]})),!0)}catch(N){return k(N instanceof Error?N.message:"Unable to set goal."),!1}finally{g(!1)}},[m,o,s,e,l]),j=c.useCallback(()=>{i(),d(),u(!0),f(Cu(r==null?void 0:r.tokenBudget)),k(null),a==null||a(),requestAnimationFrame(()=>{var y;(y=n.current)==null||y.focus()})},[i,r==null?void 0:r.tokenBudget,a,n,d]),w=c.useCallback(()=>{u(!1),k(null)},[]);return{goalComposeMode:h,goalTokenBudget:m,goalBusy:p,goalLocalError:b,setGoalTokenBudget:f,submitGoal:x,enterGoalComposeMode:j,exitGoalComposeMode:w}}var Cn=`node -e "process.stdin.resume(); process.stdin.on('end', () => console.error('hook ran'))"`;function $m(e){const r=new Map;for(const n of e??[])r.set(n.eventName,n.command);return r}function Dm({slashPanelView:e,hookCommandTemplates:r,onCreateHook:n,onUpdateHook:a,onTrustHook:o,onUntrustHook:s}){const[l,i]=c.useState("list"),[d,h]=c.useState("project"),[u,m]=c.useState("preToolUse"),[f,p]=c.useState("Bash"),[g,b]=c.useState(Cn),[k,x]=c.useState("30"),[j,w]=c.useState("Running hook"),[y,v]=c.useState(null),[S,N]=c.useState(!1),[I,M]=c.useState(null),[R,Q]=c.useState(null),$=c.useMemo(()=>$m(r),[r]),Y=c.useCallback(J=>$.get(J)??$.get("preToolUse")??Cn,[$]),Z=c.useMemo(()=>new Set([Cn,...$.values()]),[$]),P=c.useCallback(()=>{M(null),Q(null)},[]);c.useEffect(()=>{e!=="hooks"&&(i("list"),P())},[P,e]),c.useEffect(()=>{const J=Xr.find(K=>K.value===u);p(K=>{const L=K.trim(),q=new Set(Xr.map(G=>G.matcherHint).filter(Boolean));return L&&!q.has(L)?K:(J==null?void 0:J.matcherHint)??""}),b(K=>Z.has(K.trim())?Y(u):K)},[Y,Z,u]);const te=c.useCallback(()=>{v(null),h("project"),m("preToolUse"),p("Bash"),b(Y("preToolUse")),x("30"),w("Running hook")},[Y]),oe=c.useCallback(J=>{const K=al(J);if(!K){M("Only command hooks in global or project hooks.json can be edited here.");return}v(K),h(K.scope),m(K.eventName),p(K.matcher??""),b(K.command),x(K.timeoutSec?String(K.timeoutSec):""),w(K.statusMessage??""),M(null),Q(null),i("edit")},[]),T=c.useCallback(async()=>{if(l==="edit"&&!a){M("Hook editing is unavailable in this view.");return}if(l!=="edit"&&!n){M("Hook editing is unavailable in this view.");return}if(l==="edit"&&!y){M("Select a hook to edit first.");return}const J=g.trim();if(!J){M("Hook command cannot be empty.");return}const K=k.trim(),L=K?Number(K):null;if(K&&(L===null||!Number.isInteger(L)||L<=0)){M("Timeout must be a positive number of seconds.");return}N(!0),M(null),Q(null);try{const q={scope:d,eventName:u,matcher:f.trim()||null,command:J,timeoutSec:L,statusMessage:j.trim()||null};l==="edit"?await(a==null?void 0:a({...q,target:y})):await(n==null?void 0:n(q)),Q(`${d==="project"?"Project":"Global"} hook ${l==="edit"?"updated":"written"} in hooks.json and trusted.`),i("list"),v(null)}catch(q){M(q instanceof Error?q.message:"Unable to write hooks.json.")}finally{N(!1)}},[y,g,u,f,d,j,k,l,n,a]),re=c.useCallback(async J=>{if(!o||!J.currentHash){M("Hook trust is unavailable in this view.");return}N(!0),M(null),Q(null);try{await o({key:J.key,currentHash:J.currentHash}),Q("Hook trusted.")}catch(K){M(K instanceof Error?K.message:"Unable to trust hook.")}finally{N(!1)}},[o]),B=c.useCallback(async J=>{if(!s){M("Hook trust is unavailable in this view.");return}N(!0),M(null),Q(null);try{await s({key:J.key}),Q("Hook untrusted.")}catch(K){M(K instanceof Error?K.message:"Unable to untrust hook.")}finally{N(!1)}},[s]);return{hooksPanelMode:l,hookScope:d,hookEventName:u,hookMatcher:f,hookCommand:g,hookTimeoutSec:k,hookStatusMessage:j,editingHookTarget:y,hookConfigBusy:S,hookConfigError:I,hookConfigSuccess:R,setHooksPanelMode:i,setEditingHookTarget:v,setHookScope:h,setHookEventName:m,setHookMatcher:p,setHookCommand:b,setHookTimeoutSec:x,setHookStatusMessage:w,clearHookConfigStatus:P,resetHookForm:te,startEditingHook:oe,saveHook:T,trustHook:re,untrustHook:B}}var Bm=`[mcp_servers.example_stdio]
3654
3654
  command = "npx"
3655
3655
  args = ["-y", "your-mcp-server"]
3656
3656
  `,ds="MCP entry written to provider config. Restart the backend if it does not appear immediately.";function Gm({hostConfigFilesAvailable:e,onReadProviderConfig:r,onWriteProviderConfig:n,setMcpPanelMode:a,onOpenMcp:o}){const[s,l]=c.useState(""),[i,d]=c.useState(""),[h,u]=c.useState(""),[m,f]=c.useState(null),[p,g]=c.useState(!1),[b,k]=c.useState(null),[x,j]=c.useState(null),w=c.useCallback(()=>{k(null),j(null)},[]),y=c.useCallback(async()=>{if(!e||!r)throw new Error("Provider config editing is unavailable for this thread.");const M=await r();return f(M.path),M},[e,r]),v=c.useCallback(async M=>{if(!e||!n)throw new Error("Provider config editing is unavailable for this thread.");const R=await n(M);return f(R.path),R},[e,n]),S=c.useCallback(async()=>{const M=Su(s),R=i.trim();if(!M){k("MCP name must use only letters, numbers, underscore, or hyphen.");return}if(!/^https?:\/\//i.test(R)){k("HTTP MCP URL must start with http:// or https://");return}g(!0),k(null),j(null);try{const Q=await y(),$=rs(Q.content,M,Eu(M,R));await v($),j(ds),a("list"),l(""),d(""),o==null||o()}catch(Q){k(Q instanceof Error?Q.message:"Unable to update provider config.")}finally{g(!1)}},[y,s,i,o,a,v]),N=c.useCallback(async()=>{g(!0),k(null),j(null);try{await y(),u(M=>M||Bm),a("stdio")}catch(M){k(M instanceof Error?M.message:"Unable to load provider config.")}finally{g(!1)}},[y,a]),I=c.useCallback(async()=>{const M=Tu(h);if(!M){k("The raw MCP block must start with a header like [mcp_servers.name].");return}g(!0),k(null),j(null);try{const R=await y(),Q=rs(R.content,M,h);await v(Q),j(ds),a("list"),o==null||o()}catch(R){k(R instanceof Error?R.message:"Unable to update provider config.")}finally{g(!1)}},[y,h,o,a,v]);return{mcpHttpName:s,mcpHttpUrl:i,mcpRawBlock:h,mcpConfigPath:m,mcpConfigBusy:p,mcpConfigError:b,mcpConfigSuccess:x,setMcpHttpName:l,setMcpHttpUrl:d,setMcpRawBlock:u,clearMcpConfigStatus:w,prepareRawMcpBlock:N,saveHttpMcp:S,saveRawMcpBlock:I}}function Fm({openMenu:e,setOpenMenu:r,slashPanelView:n,setSlashPanelView:a,setMcpPanelMode:o,clearMcpConfigStatus:s,clearHookConfigStatus:l}){const[i,d]=c.useState(null);c.useEffect(()=>{e!=="slash"&&(a("root"),o("list"),s(),l())},[l,s,e,o,a]),c.useEffect(()=>{n!=="mcp"&&(o("list"),s())},[s,o,n]),c.useEffect(()=>{if(!i)return;const u=window.setTimeout(()=>{d(m=>m===i?null:m)},1400);return()=>{window.clearTimeout(u)}},[i]),c.useEffect(()=>{function u(m){(typeof m.composedPath=="function"?m.composedPath():[]).some(g=>g instanceof HTMLElement&&(g.dataset.composerMenuSurface==="true"||g.dataset.composerMenuTrigger==="true"))||e&&r(null)}if(e)return window.addEventListener("pointerdown",u),()=>{window.removeEventListener("pointerdown",u)}},[e,r]);const h=c.useCallback(async u=>{try{await navigator.clipboard.writeText(`$${u}`),d(u)}catch{d(null)}},[]);return{copiedSkillName:i,copySkillInvokeName:h}}function Hm(e,r){const{attachment:n}=e,a=document.createElement("span");if(a.dataset.segmentType="attachment",a.dataset.clientId=n.clientId,a.dataset.placeholder=n.placeholder,a.contentEditable="false",a.className="thread-composer-attachment-chip mx-[0.12rem] inline-flex max-w-full align-baseline",n.kind==="photo"){a.classList.add("thread-composer-attachment-chip-photo","rounded-[0.95rem]","border","border-sky-300/35","bg-sky-300/10","p-1","shadow-sm","shadow-stone-950/20");const l=r[n.clientId];if(l){const d=document.createElement("img");d.src=l,d.alt=n.originalName||"Pasted image",d.className="thread-composer-attachment-thumb h-[4.5rem] w-[6rem] rounded-[0.7rem] bg-stone-950 object-contain",d.draggable=!1,a.append(d)}else{const d=document.createElement("span");d.className="thread-composer-attachment-thumb inline-block h-[4.5rem] w-[6rem] rounded-[0.7rem] bg-stone-900/80",d.setAttribute("aria-hidden","true"),a.append(d)}const i=document.createElement("span");return i.className="thread-composer-attachment-caption ml-2 inline-flex max-w-[8rem] items-center text-[10px] font-medium tracking-[0.08em] text-sky-50",i.textContent=as(n),a.append(i),a}a.classList.add("items-center","gap-2","rounded-[0.95rem]","border","border-emerald-300/35","bg-emerald-300/10","px-2.5","py-2","text-[10px]","font-medium","tracking-[0.08em]","text-emerald-50","shadow-sm","shadow-stone-950/20");const o=document.createElement("span");o.className="inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full border border-emerald-200/25 bg-emerald-300/12 text-[9px]",o.textContent="FILE";const s=document.createElement("span");return s.className="inline-flex max-w-[10rem] truncate",s.textContent=as(n),a.append(o,s),a}function Om(e,r){const n=document.createDocumentFragment();for(const a of e){if(a.type==="text"){n.append(document.createTextNode(a.text===" "?" ":a.text));continue}n.append(Hm(a,r))}return n}function Wm({promptRef:e,isShellView:r,prompt:n,promptSegments:a,attachmentPreviewUrls:o,previewSignature:s,editorSanitizeNonce:l,pendingSelectionRef:i,pendingInsertedAttachmentIdsRef:d,selectionSnapshotRef:h,renderedPreviewSignatureRef:u,renderedSanitizeNonceRef:m,serializeEditorPrompt:f,restoreSelection:p}){c.useLayoutEffect(()=>{const g=e.current;if(!g||r)return;const b=i.current,k=f()!==n||u.current!==s||m.current!==l;k&&(g.replaceChildren(Om(a,o)),u.current=s,m.current=l),b!==null?(g.focus(),am(g,d.current)||p(b),h.current=b):document.activeElement===g&&k&&p(h.current),i.current=null,d.current=[]},[o,l,r,s,n,e,a,d,i,u,m,p,h,f])}function Um({tokenBudget:e,error:r,onTokenBudgetChange:n,onCancel:a}){return t.jsxs("div",{className:"thread-goal-compose-card relative z-20 mb-1.5 flex flex-wrap items-center gap-2 rounded-2xl border px-3 py-2 text-xs shadow-sm",children:[t.jsx("span",{className:"thread-goal-compose-label font-medium uppercase tracking-[0.16em]",children:"Goal"}),t.jsxs("label",{className:"thread-goal-compose-field flex items-center gap-2",children:[t.jsx("span",{children:"Max tokens (k)"}),t.jsx("input",{"aria-label":"Goal token budget",value:e,onChange:o=>n(o.target.value),inputMode:"numeric",placeholder:"Optional",className:"thread-goal-compose-input h-7 w-24 rounded-full border px-3 text-xs outline-none"})]}),r?t.jsx("span",{className:"thread-goal-compose-error min-w-0 flex-1",children:r}):null,t.jsx("button",{type:"button",onClick:a,className:"thread-goal-compose-cancel rounded-full border px-2.5 py-1 text-[11px] transition",children:"Cancel"})]})}function Vm({promptRef:e,prompt:r,disabled:n,promptPlaceholder:a,canInterrupt:o,interruptLabel:s,composerPromptRegionClassName:l,graphChatInputClassName:i,onInterrupt:d,onInput:h,onPaste:u,onKeyDown:m,onKeyUp:f,onMouseUp:p,onBlur:g,onDragEnter:b,onDragOver:k,onDragLeave:x,onDrop:j}){return t.jsxs("div",{"data-slot":"input-group-control",className:`${l} relative w-full`,children:[t.jsxs("div",{className:i,children:[r.length===0&&t.jsx("span",{className:`pointer-events-none absolute left-3 top-3 truncate text-slate-500 sm:left-4 sm:top-4 dark:text-slate-400 ${o?"right-12":"right-3 sm:right-4"}`,children:a}),t.jsx("div",{ref:e,role:"textbox","aria-label":"Prompt","aria-multiline":"true",contentEditable:!n,suppressContentEditableWarning:!0,onInput:h,onPaste:u,onKeyDown:m,onKeyUp:f,onMouseUp:p,onBlur:g,onDragEnter:b,onDragOver:k,onDragLeave:x,onDrop:j,className:`relative z-[1] min-h-[4.25rem] whitespace-pre-wrap break-words pb-2 outline-none sm:min-h-[4.25rem] ${o?"pr-12":""} ${n?"cursor-not-allowed text-slate-500":""}`})]}),o?t.jsx(jt,{type:"button",variant:"ghost",size:"icon-xs","aria-label":s,title:s,onClick:w=>{w.preventDefault(),d==null||d()},className:"thread-graph-composer-stop-button ui-action-danger absolute right-2 top-2 z-30 h-8 w-8 rounded-full text-sm font-medium",children:t.jsx("span",{"aria-hidden":"true",className:"block h-2.5 w-2.5 rounded-[2px] bg-current"})}):null]})}function Km({prompt:e,promptPlaceholder:r,promptRegionClassName:n,promptInputClassName:a,interruptLabel:o,canInterrupt:s,sendButtonLabel:l,sendButtonClassName:i,sendDisabled:d,onPromptChange:h,onPromptKeyDown:u,onInterrupt:m}){return t.jsxs("div",{className:`${n} relative`,children:[t.jsx("textarea",{"aria-label":"Prompt",disabled:!1,value:e,onChange:f=>h(f.target.value),onKeyDown:u,rows:2,placeholder:r,className:`${a} resize-y pb-10`}),t.jsx("button",{type:"button","aria-label":o,title:o,onClick:()=>void(m==null?void 0:m()),disabled:!s,className:`absolute right-2.5 top-2.5 inline-flex h-8 w-8 items-center justify-center rounded-full border transition ${s?"border-rose-300/55 bg-rose-300/[0.14] text-rose-50 shadow-lg shadow-rose-950/20 hover:bg-rose-300/[0.22]":"cursor-not-allowed border-stone-700/30 bg-stone-400/[0.02] text-stone-500/55 opacity-55"}`,children:t.jsx("span",{"aria-hidden":"true",className:"block h-2.5 w-2.5 rounded-[2px] bg-current"})}),t.jsx("button",{type:"submit","aria-label":"Send Shell Input",onMouseDown:f=>{f.preventDefault()},onPointerDown:f=>{f.preventDefault()},onTouchStart:f=>{f.preventDefault()},disabled:d,className:`absolute bottom-2.5 right-2.5 rounded-full px-3.5 py-1.5 text-sm font-medium shadow-lg shadow-stone-950/30 transition disabled:cursor-not-allowed disabled:bg-stone-700 disabled:text-stone-300 ${i}`,children:l})]})}function qm({isShellView:e,promptRef:r,prompt:n,disabled:a,promptPlaceholder:o,canInterrupt:s,interruptLabel:l,composerPromptRegionClassName:i,graphChatInputClassName:d,promptInputClassName:h,goalComposeMode:u,goalTokenBudget:m,goalLocalError:f,goalBusy:p,busy:g,sendButtonLabel:b,sendButtonClassName:k,onInterrupt:x,onPromptInput:j,onPromptPaste:w,onPromptKeyDown:y,onPromptKeyUp:v,onPromptMouseUp:S,onPromptBlur:N,onPromptDragEnter:I,onPromptDragOver:M,onPromptDragLeave:R,onPromptDrop:Q,onGoalTokenBudgetChange:$,onCancelGoal:Y,onShellPromptChange:Z}){return{promptSlot:e?null:t.jsx(Vm,{promptRef:r,prompt:n,disabled:a,promptPlaceholder:o,canInterrupt:s,interruptLabel:l,composerPromptRegionClassName:i,graphChatInputClassName:d,onInterrupt:x,onInput:j,onPaste:w,onKeyDown:y,onKeyUp:v,onMouseUp:S,onBlur:N,onDragEnter:I,onDragOver:M,onDragLeave:R,onDrop:Q}),goalSlot:u&&!e?t.jsx(Um,{tokenBudget:m,error:f,onTokenBudgetChange:$,onCancel:Y}):null,shellPromptSlot:e?t.jsx(Km,{prompt:n,promptPlaceholder:o,promptRegionClassName:i,promptInputClassName:h,interruptLabel:l,canInterrupt:s,sendButtonLabel:b,sendButtonClassName:k,sendDisabled:p||g,onPromptChange:Z,onPromptKeyDown:y,onInterrupt:x}):null}}function Xm({collaborationMode:e,onUpdateSettings:r,closeMenu:n}){const[a,o]=c.useState(null),s=a??e;c.useEffect(()=>{o(null)},[e]);const l=c.useCallback(async i=>{const d=ju({nextMode:i.collaborationMode,previousOptimisticMode:a});d.optimisticMode&&o(d.optimisticMode);try{await(r==null?void 0:r(i)),d.closeMenuOnSuccess&&n()}catch(h){throw d.shouldRollbackMode&&o(d.rollbackMode),h}},[n,r,a]);return{displayedCollaborationMode:s,updateSettings:l}}function Ym({isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:o,toolbarClassName:s,iconButtonClassName:l,menuClassName:i,menuItemClassName:d,panelButtonClassName:h,chipButtonClassName:u,inlineToggleClassName:m,planToggleActiveClassName:f,sendButtonBaseClassName:p,slashPanelView:g,availableToolboxItems:b,busy:k,settingsBusy:x,compactBusy:j,forkBusy:w,fastMode:y,goalComposeMode:v,goalBusy:S,goalStatus:N,activeView:I,disabled:M,model:R,modelOptions:Q,modelContextTitle:$,contextUsage:Y,reasoningEffort:Z,supportedEfforts:P,displayedCollaborationMode:te,sandboxMode:oe,sendButtonLabel:T,sendButtonClassName:re,modelControlsDisabled:B,effortControlsDisabled:J,effortControlTitle:K,forkTurnOptionsState:L,skillsState:q,goalState:G,goalHistory:E,copiedSkillName:C,hooksPanelMode:W,hooksState:H,hookConfigBusy:se,hookConfigError:V,hookConfigSuccess:de,editingHookTarget:ee,hookScope:be,hookEventName:ie,hookMatcher:ye,hookCommand:Ae,hookTimeoutSec:ce,hookStatusMessage:Ce,mcpPanelMode:Le,mcpState:X,mcpConfigPath:ue,mcpConfigError:ve,mcpConfigSuccess:ke,mcpConfigBusy:$e,mcpHttpName:He,mcpHttpUrl:_e,mcpRawBlock:ze,capabilities:F,shellControlState:le,onToggleView:we,onDismissPromptFocus:z,onSetOpenMenu:O,onToolboxItemClick:ne,onSetSlashPanelView:ge,onViewGoals:Te,onUpdateGoal:Ee,onOpenForkTurns:fe,onForkLatest:De,onForkTurn:Be,onCopySkillInvokeName:et,onResetHookForm:Ve,onSetHooksPanelMode:pt,onClearHookConfigStatus:nt,onSetEditingHookTarget:We,onSetHookScope:ot,onSetHookEventName:ht,onSetHookMatcher:ut,onSetHookCommand:A,onSetHookTimeoutSec:U,onSetHookStatusMessage:xe,onSaveHook:je,onStartEditingHook:Ne,onTrustHook:Ye,onUntrustHook:tt,onSetMcpPanelMode:Fe,onClearMcpConfigStatus:Ke,onSetMcpHttpName:lt,onSetMcpHttpUrl:vt,onSetMcpRawBlock:it,onPrepareRawMcpBlock:Nt,onSaveHttpMcp:Rt,onSaveRawMcpBlock:Ct,onPickPhoto:_,onPickFile:pe,onUpdateSettings:Re,onPasteShell:Ge,onCopyShell:Ue,onClearShell:ct,onShellControl:kt}){const qt=e?null:{open:o==="slash",slashPanelView:g,availableToolboxItems:b,busy:k,forkBusy:w,forkTurnOptionsState:L,skillsState:q,goalState:G,goalHistory:E,goalBusy:S,copiedSkillName:C,hooksPanelMode:W,hooksState:H,hostConfigFilesAvailable:F.hostConfigFiles,hookTrustAvailable:F.hookTrust,hookConfigBusy:se,hookConfigError:V,hookConfigSuccess:de,editingHookTarget:ee,hookScope:be,hookEventName:ie,hookMatcher:ye,hookCommand:Ae,hookTimeoutSec:ce,hookStatusMessage:Ce,mcpPanelMode:Le,mcpState:X,mcpConfigEditing:F.mcpConfigEditing,mcpConfigPath:ue,mcpConfigError:ve,mcpConfigSuccess:ke,mcpConfigBusy:$e,mcpHttpName:He,mcpHttpUrl:_e,mcpRawBlock:ze,iconButtonClassName:l,menuClassName:i,menuItemClassName:d,panelButtonClassName:h,chipButtonClassName:u,onToggle:()=>O(at=>at==="slash"?null:"slash"),onToolboxItemClick:ne,toolboxItemDisabled:at=>Ju(at,{settingsBusy:x,compactBusy:j,busy:k,forkBusy:w}),toolboxItemClassName:at=>Qu(at,{fastMode:y,goalComposeMode:v,goalStatus:N,menuItemClassName:d}),toolboxItemStatus:at=>Zu(at,{fastMode:y,compactBusy:j,goalComposeMode:v,goalStatus:N,busy:k}),onSetSlashPanelView:ge,onViewGoals:Te,onUpdateGoal:Ee,onOpenForkTurns:fe,onForkLatest:De,onForkTurn:Be,onCopySkillInvokeName:et,onResetHookForm:Ve,onSetHooksPanelMode:pt,onClearHookConfigStatus:nt,onSetEditingHookTarget:We,onSetHookScope:ot,onSetHookEventName:ht,onSetHookMatcher:ut,onSetHookCommand:A,onSetHookTimeoutSec:U,onSetHookStatusMessage:xe,onSaveHook:je,onStartEditingHook:Ne,onTrustHook:Ye,onUntrustHook:tt,onSetMcpPanelMode:Fe,onClearMcpConfigStatus:Ke,onSetMcpHttpName:lt,onSetMcpHttpUrl:vt,onSetMcpRawBlock:it,onPrepareRawMcpBlock:Nt,onSaveHttpMcp:Rt,onSaveRawMcpBlock:Ct},Xt=e?null:{open:o==="attachments",iconButtonClassName:l,menuClassName:i,menuItemClassName:d,onToggle:()=>O(at=>at==="attachments"?null:"attachments"),onPickPhoto:_,onPickFile:pe},Mt=e?null:{openMenu:o,model:R,modelOptions:Q,modelContextTitle:$,contextUsage:Y,reasoningEffort:Z,supportedEfforts:P,displayedCollaborationMode:te,sandboxMode:oe,planModeAvailable:F.planMode,sandboxModeAvailable:F.sandboxMode,settingsBusy:x,goalComposeMode:v,goalBusy:S,activeView:I,disabled:M,fastMode:y,sendButtonLabel:T,sendButtonClassName:re,modelControlsDisabled:B,effortControlsDisabled:J,effortControlTitle:K,inlineToggleClassName:m,menuItemClassName:d,planToggleActiveClassName:f,sendButtonBaseClassName:p,onSetOpenMenu:O,onUpdateSettings:Re};return{isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:o,toolbarClassName:s,iconButtonClassName:l,slashToolboxProps:qt,attachmentMenuProps:Xt,settingsToolbarProps:Mt,shellToolsPanelProps:o==="shellTools"?{busy:k,shellControlState:le,onPaste:Ge,onCopy:Ue,onClear:ct,onShellControl:kt}:null,shellControlState:le,onToggleView:we,onDismissPromptFocus:z,onSetOpenMenu:O}}function Un({activeView:e,edgeToEdgeMobile:r=!1,busy:n=!1,settingsBusy:a=!1,compactBusy:o=!1,error:s,model:l=null,reasoningEffort:i=null,fastMode:d=!1,collaborationMode:h="default",sandboxMode:u=null,hideSandboxModeControl:m=!1,modelOptions:f=[],contextUsage:p=null,capabilities:g=null,toolboxItems:b=null,hookCommandTemplates:k=null,mcpConfigFormat:x="none",followTail:j=!1,threadConnected:w=!0,shellAvailable:y=!0,disabled:v=!1,disabledPlaceholder:S,shellControlState:N=null,draftPrompt:I,draftAttachments:M,onPickAttachment:R,skillsState:Q={status:"idle",data:null,error:null},mcpState:$={status:"idle",data:null,error:null},hooksState:Y={status:"idle",data:null,error:null},goalState:Z={status:"idle",data:null,error:null},goalHistory:P=[],forkTurnOptionsState:te={status:"idle",data:null,error:null},onDraftChange:oe,onSubmit:T,onInterrupt:re,onCompact:B,onOpenSkills:J,onOpenMcp:K,onOpenHooks:L,onCreateHook:q,onUpdateHook:G,onTrustHook:E,onUntrustHook:C,onOpenGoal:W,onPrepareGoalSubmit:H,onUpdateGoal:se,onOpenForkTurns:V,onForkLatest:de,onForkTurn:ee,onReadProviderConfig:be,onWriteProviderConfig:ie,onToggleFollow:ye,canJumpToPreviousTurn:Ae,onJumpToPreviousTurn:ce,canJumpToNextTurn:Ce,onJumpToNextTurn:Le,subscriptionUsage:X,onUpdateSettings:ue,onToggleView:ve,onShellCopy:ke,onShellControl:$e,canInterrupt:He=!1}){var ja;const[_e,ze]=c.useState(null),[F,le]=c.useState("root"),we=c.useRef(!1),[z,O]=c.useState("list"),ne=c.useMemo(()=>({fast:(g==null?void 0:g.controls.performanceMode)??!1,compact:(g==null?void 0:g.turns.compact)??!1,goal:(g==null?void 0:g.controls.goals)??!1,fork:(g==null?void 0:g.branching.fork)??!1,skills:(g==null?void 0:g.management.skills)??!1,mcp:(g==null?void 0:g.management.mcpStatus)??!1,hooks:(g==null?void 0:g.management.hooks)??!1,hostConfigFiles:(g==null?void 0:g.management.hostConfigFiles)??!1,mcpConfigEditing:x==="codex-toml"&&!!(g!=null&&g.management.hostConfigFiles)&&!!be&&!!ie,hookTrust:(g==null?void 0:g.management.hookTrust)??!1,planMode:(g==null?void 0:g.controls.planMode)??!1,sandboxMode:(g==null?void 0:g.controls.sandboxMode)??!1}),[g,x,be,ie]),ge=c.useMemo(()=>Xu(b,ne),[ne,b]),Te=c.useRef(null),Ee=c.useRef(null),fe=c.useRef(null),De=c.useRef(null),Be=c.useRef(null),et=c.useRef([]),Ve=c.useRef(null),pt=c.useRef(""),nt=c.useRef(0),We=e==="shell",ot=y||We,ht=!!(We&&(N!=null&&N.isMobileShell)),ut=(N==null?void 0:N.promptLabel)??null,[A,U]=c.useState(!1),[xe,je]=c.useState(0),{prompt:Ne,attachments:Ye,isDraftControlled:tt,updateDraft:Fe,flushControlledDraftToHost:Ke}=Mm({isShellView:We,draftPrompt:I,draftAttachments:M,onDraftChange:oe}),lt=Pm({attachments:Ye,isShellView:We}),{displayedCollaborationMode:vt,updateSettings:it}=Xm({collaborationMode:h,onUpdateSettings:ue,closeMenu:()=>ze(null)}),{forkBusy:Nt,forkLatest:Rt,forkTurn:Ct}=Am({slashPanelView:F,onForkLatest:de,onForkTurn:ee,closeMenu:()=>ze(null)}),{hooksPanelMode:_,hookScope:pe,hookEventName:Re,hookMatcher:Ge,hookCommand:Ue,hookTimeoutSec:ct,hookStatusMessage:kt,editingHookTarget:qt,hookConfigBusy:Xt,hookConfigError:Mt,hookConfigSuccess:cr,setHooksPanelMode:at,setEditingHookTarget:dn,setHookScope:cn,setHookEventName:Il,setHookMatcher:zl,setHookCommand:Pl,setHookTimeoutSec:Rl,setHookStatusMessage:Ml,clearHookConfigStatus:pa,resetHookForm:Al,startEditingHook:_l,saveHook:$l,trustHook:Dl,untrustHook:Bl}=Dm({slashPanelView:F,hookCommandTemplates:k,onCreateHook:q,onUpdateHook:G,onTrustHook:E,onUntrustHook:C}),{goalComposeMode:hr,goalTokenBudget:Gl,goalBusy:hn,goalLocalError:Fl,setGoalTokenBudget:Hl,submitGoal:Ol,enterGoalComposeMode:Wl,exitGoalComposeMode:fa}=_m({prompt:Ne,goalTokenBudgetSource:Z.data,promptRef:Ee,onOpenGoal:W,onPrepareGoalSubmit:H,onUpdateGoal:se,updateDraft:Fe,closeMenu:()=>ze(null),resetSlashPanel:()=>le("root")}),{mcpHttpName:Ul,mcpHttpUrl:Vl,mcpRawBlock:Kl,mcpConfigPath:ql,mcpConfigBusy:Xl,mcpConfigError:Yl,mcpConfigSuccess:Zl,setMcpHttpName:Jl,setMcpHttpUrl:Ql,setMcpRawBlock:ei,clearMcpConfigStatus:ga,prepareRawMcpBlock:ti,saveHttpMcp:ri,saveRawMcpBlock:ni}=Gm({hostConfigFilesAvailable:ne.hostConfigFiles,onReadProviderConfig:be,onWriteProviderConfig:ie,setMcpPanelMode:O,onOpenMcp:K}),{copiedSkillName:ai,copySkillInvokeName:si}=Fm({openMenu:_e,setOpenMenu:ze,slashPanelView:F,setSlashPanelView:le,setMcpPanelMode:O,clearMcpConfigStatus:ga,clearHookConfigStatus:pa}),oi=c.useCallback(ae=>{Fe(Se=>{if(typeof ae=="function"){const Me=ae(Se.prompt,Se.attachments);return{prompt:Me.prompt,attachments:Me.attachments??Se.attachments}}return{prompt:ae,attachments:Se.attachments}})},[Fe]),un=c.useMemo(()=>f.find(ae=>ae.model===l)??null,[l,f]),li=Lu(l,p),xa=(un==null?void 0:un.supportedReasoningEfforts)??[],ii=c.useMemo(()=>pu(Ne,Ye),[Ye,Ne]),di=c.useMemo(()=>Object.entries(lt).sort(([ae],[Se])=>ae.localeCompare(Se)).map(([ae,Se])=>`${ae}:${Se}`).join("|"),[lt]);function ci(ae,Se){Se.stopPropagation();const Me=Yu(ae,{fastMode:d,goalComposeMode:hr});switch(Me.type){case"toggleFast":it({fastMode:Me.fastMode});break;case"runCompact":ze(null),B==null||B();break;case"enterGoalCompose":Wl();break;case"exitGoalCompose":fa(),ze(null);break;case"openPanel":le(Me.panel),Me.panel==="skills"?J==null||J():Me.panel==="mcp"?K==null||K():Me.panel==="hooks"&&(L==null||L());break;case"insertPrompt":fn(Me.text),le("root"),ze(null);break}}function Yt(){const ae=Ee.current;return ae?rm(ae):null}const hi=c.useCallback(ae=>{const Se=Ee.current;!Se||!ae||nm(Se,ae)},[]),mn=c.useCallback(()=>{const ae=Ee.current;return ae?sl(ae):Ne},[Ne]),{appendAttachments:pn,appendDroppedAttachments:ba}=zm({prompt:Ne,attachments:Ye,updateDraft:Fe,getSelection:Yt,selectionSnapshotRef:Ve,pendingSelectionRef:Be,pendingInsertedAttachmentIdsRef:et,onInserted:()=>ze(null)}),va=c.useCallback((ae,Se)=>{var Me;if(At(),R){R({kind:ae,appendAttachments:(Je,st=ae)=>pn(Je,st),defaultPick:()=>{var Je;return(Je=Se.current)==null?void 0:Je.click()}});return}(Me=Se.current)==null||Me.click()},[pn,At,R]);function fn(ae){if(!ae)return;const Se=Yt()??Ve.current,Me=(Se==null?void 0:Se.start)??Ne.length,Je=(Se==null?void 0:Se.end)??Me,st=mu(ae),Zt=`${Ne.slice(0,Me)}${st}${Ne.slice(Je)}`;Fe(Vi=>({prompt:Zt,attachments:Vi.attachments}));const _t=Me+st.length;Be.current={start:_t,end:_t},Ve.current={start:_t,end:_t}}Wm({promptRef:Ee,isShellView:We,prompt:Ne,promptSegments:ii,attachmentPreviewUrls:lt,previewSignature:di,editorSanitizeNonce:xe,pendingSelectionRef:Be,pendingInsertedAttachmentIdsRef:et,selectionSnapshotRef:Ve,renderedPreviewSignatureRef:pt,renderedSanitizeNonceRef:nt,serializeEditorPrompt:mn,restoreSelection:hi});function At(){var ae;(ae=Ee.current)==null||ae.blur(),document.activeElement instanceof HTMLElement&&document.activeElement!==document.body&&document.activeElement.blur()}async function ui(){var ae;if(At(),ze(null),!!((ae=navigator.clipboard)!=null&&ae.readText))try{const Se=await navigator.clipboard.readText();fn(Se)}catch{return}}async function ka(){if(!we.current){we.current=!0;try{if(tt&&Ke(),hr&&!We){await Ol();return}const ae=vu({prompt:Ne,attachments:Ye,isShellView:We});if(!ae||await T(ae)===!1)return;Fe(()=>({prompt:"",attachments:[]}))}finally{we.current=!1}}}async function mi(ae){ae.preventDefault(),await ka()}function pi(){const ae=mn(),Se=Yt();Ve.current=Se;const Me=Ee.current;(Me?tm(Me):!1)&&(Be.current=Se,je(st=>st+1)),Fe(st=>({prompt:ae,attachments:st.attachments.filter(Zt=>ae.includes(Zt.placeholder))}),"deferred")}function fi(ae){var Je,st,Zt,_t;const Se=On((Je=ae.clipboardData)==null?void 0:Je.items,(st=ae.clipboardData)==null?void 0:st.files),Me=ku({files:Se,plainText:((Zt=ae.clipboardData)==null?void 0:Zt.getData("text/plain"))??"",htmlText:((_t=ae.clipboardData)==null?void 0:_t.getData("text/html"))??"",htmlToText:em});Me.preventDefault&&ae.preventDefault(),Me.type==="insert-text"?fn(Me.text):Me.type==="append-files"&&ba(Me.files)}function gi(ae){var Me,Je;const Se=es(ns((Me=ae.dataTransfer)==null?void 0:Me.items,(Je=ae.dataTransfer)==null?void 0:Je.files));Se.preventDefault&&ae.preventDefault(),Se.activateDragTarget&&U(!0)}function xi(ae){var Me,Je;const Se=es(ns((Me=ae.dataTransfer)==null?void 0:Me.items,(Je=ae.dataTransfer)==null?void 0:Je.files));Se.preventDefault&&ae.preventDefault(),Se.activateDragTarget&&ae.dataTransfer&&(ae.dataTransfer.dropEffect="copy"),Se.activateDragTarget&&U(!0)}function bi(ae){ae.currentTarget.contains(ae.relatedTarget)||U(!1)}function vi(ae){var Je,st;const Se=On((Je=ae.dataTransfer)==null?void 0:Je.items,(st=ae.dataTransfer)==null?void 0:st.files),Me=wu(Se);Me.preventDefault&&ae.preventDefault(),Me.type==="accept-files"&&(U(!1),ba(Me.files??[]))}function ki(ae){if(ae.key==="Enter"&&ae.repeat){ae.preventDefault();return}if(e==="chat"&&ae.key==="/"&&!ae.metaKey&&!ae.ctrlKey&&!ae.altKey&&!n&&!v&&ge.length>0&&mn().trim().length===0){ae.preventDefault(),le("root"),ze("slash");return}const Se=yu({key:ae.key,metaKey:ae.metaKey,ctrlKey:ae.ctrlKey,busy:n,disabled:v});Se.preventDefault&&ae.preventDefault(),Se.submit&&ka()}const{promptPlaceholder:wi,interruptLabel:yi,sendButtonLabel:wa,sendButtonClassName:ya,modelControlsDisabled:ji,effortControlsDisabled:Ni,effortControlTitle:Ci}=Ru({goalComposeMode:hr,goalBusy:hn,threadConnected:w,busy:n,isShellView:We,disabledPlaceholder:S,settingsBusy:a,supportedEffortCount:xa.length,fastMode:d}),{composerLayerClassName:Si,formClassName:Ti,composerShellClassName:Ei,composerToolbarClassName:Li,composerIconButtonClassName:Ii,composerMenuClassName:zi,composerMenuItemClassName:Pi,composerInlineToggleClassName:Ri,composerPanelButtonClassName:Mi,composerChipButtonClassName:Ai,composerPlanToggleActiveClassName:_i,composerSendButtonClassName:$i,composerPromptRegionClassName:Di,promptInputClassName:Bi,graphChatInputGroupClassName:Gi,graphChatInputClassName:Fi}=Mu({isShellView:We,edgeToEdgeMobile:r,isMobileShell:ht,openMenu:_e!==null,isDragTargetActive:A,busy:n}),Hi=Ym({isShellView:We,canToggleShellView:ot,isMobileShell:ht,shellPromptLabel:ut,openMenu:_e,toolbarClassName:Li,iconButtonClassName:Ii,menuClassName:zi,menuItemClassName:Pi,panelButtonClassName:Mi,chipButtonClassName:Ai,inlineToggleClassName:Ri,planToggleActiveClassName:_i,sendButtonBaseClassName:$i,slashPanelView:F,availableToolboxItems:ge,busy:n,settingsBusy:a,compactBusy:o,forkBusy:Nt,fastMode:d,goalComposeMode:hr,goalBusy:hn,goalStatus:(ja=Z.data)==null?void 0:ja.status,activeView:e,disabled:v,model:l,modelOptions:f,modelContextTitle:li,contextUsage:p,reasoningEffort:i,supportedEfforts:xa,displayedCollaborationMode:vt,sandboxMode:u,sendButtonLabel:wa,sendButtonClassName:ya,modelControlsDisabled:ji,effortControlsDisabled:Ni,effortControlTitle:Ci,forkTurnOptionsState:te,skillsState:Q,goalState:Z,goalHistory:P,copiedSkillName:ai,hooksPanelMode:_,hooksState:Y,hookConfigBusy:Xt,hookConfigError:Mt,hookConfigSuccess:cr,editingHookTarget:qt,hookScope:pe,hookEventName:Re,hookMatcher:Ge,hookCommand:Ue,hookTimeoutSec:ct,hookStatusMessage:kt,mcpPanelMode:z,mcpState:$,mcpConfigPath:ql,mcpConfigError:Yl,mcpConfigSuccess:Zl,mcpConfigBusy:Xl,mcpHttpName:Ul,mcpHttpUrl:Vl,mcpRawBlock:Kl,capabilities:{hostConfigFiles:ne.hostConfigFiles,hookTrust:ne.hookTrust,mcpConfigEditing:ne.mcpConfigEditing,planMode:ne.planMode,sandboxMode:m?!1:ne.sandboxMode},shellControlState:N,onToggleView:ve,onDismissPromptFocus:At,onSetOpenMenu:ze,onToolboxItemClick:ci,onSetSlashPanelView:le,onViewGoals:W,onUpdateGoal:se,onOpenForkTurns:()=>V==null?void 0:V(),onForkLatest:Rt,onForkTurn:Ct,onCopySkillInvokeName:si,onResetHookForm:Al,onSetHooksPanelMode:at,onClearHookConfigStatus:pa,onSetEditingHookTarget:dn,onSetHookScope:cn,onSetHookEventName:Il,onSetHookMatcher:zl,onSetHookCommand:Pl,onSetHookTimeoutSec:Rl,onSetHookStatusMessage:Ml,onSaveHook:$l,onStartEditingHook:_l,onTrustHook:Dl,onUntrustHook:Bl,onSetMcpPanelMode:O,onClearMcpConfigStatus:ga,onSetMcpHttpName:Jl,onSetMcpHttpUrl:Ql,onSetMcpRawBlock:ei,onPrepareRawMcpBlock:ti,onSaveHttpMcp:ri,onSaveRawMcpBlock:ni,onPickPhoto:()=>va("photo",fe),onPickFile:()=>va("file",De),onUpdateSettings:ae=>void it(ae),onPasteShell:()=>void ui(),onCopyShell:()=>{At(),ze(null),ke==null||ke()},onClearShell:()=>{At(),ze(null),T({prompt:"clear"})},onShellControl:ae=>{At(),ze(null),$e==null||$e(ae)}}),{promptSlot:Oi,goalSlot:Wi,shellPromptSlot:Ui}=qm({isShellView:We,promptRef:Ee,prompt:Ne,disabled:v,promptPlaceholder:wi,canInterrupt:He,interruptLabel:yi,composerPromptRegionClassName:Di,graphChatInputClassName:Fi,promptInputClassName:Bi,goalComposeMode:hr,goalTokenBudget:Gl,goalLocalError:Fl,goalBusy:hn,busy:n,sendButtonLabel:wa,sendButtonClassName:ya,onInterrupt:re,onPromptInput:pi,onPromptPaste:fi,onPromptKeyDown:ki,onPromptKeyUp:()=>{Ve.current=Yt()},onPromptMouseUp:()=>{Ve.current=Yt()},onPromptBlur:()=>{Ve.current=Yt(),U(!1),tt&&Ke()},onPromptDragEnter:gi,onPromptDragOver:xi,onPromptDragLeave:bi,onPromptDrop:vi,onGoalTokenBudgetChange:Hl,onCancelGoal:fa,onShellPromptChange:oi});return t.jsx(pm,{activeView:e,layerClassName:Si,formClassName:Ti,shellClassName:Ei,inputGroupClassName:Gi,error:s,followTail:j,photoInputRef:fe,fileInputRef:De,onAppendAttachments:pn,onToggleFollow:ye,canJumpToPreviousTurn:Ae,onJumpToPreviousTurn:ce,canJumpToNextTurn:Ce,onJumpToNextTurn:Le,subscriptionUsage:X,onSubmit:mi,formRef:Te,promptSlot:Oi,toolbarSlot:t.jsx(Em,{...Hi}),goalSlot:Wi,shellPromptSlot:Ui})}var Zm=c.createContext(null);function ll(){return c.useContext(Zm)}function xt(e){return e?new Date(e).toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit"}):"Time unavailable"}function Wt(e){return e?new Date(e).toLocaleString():"Time unavailable"}function Jm(e){switch(e){case"idle":return"Idle";case"running":return"Running";case"interrupted":return"Interrupted";case"failed":return"Failed";case"not_loaded":return"Not Loaded";case"system_error":return"System Error"}}function Qm(e){switch(e){case"idle":return"ui-status-neutral";case"running":return"ui-status-info";case"interrupted":return"ui-status-warning";case"failed":case"system_error":return"ui-status-danger";case"not_loaded":return"ui-status-neutral"}}function il(e){switch(e){case"sending":return"Sending";case"completed":return"Completed";case"interrupted":return"Interrupted";case"failed":return"Failed";case"inProgress":return"Running"}}function ep({open:e,title:r,label:n,value:a,busy:o=!1,onChange:s,onCancel:l,onSubmit:i}){if(c.useEffect(()=>{if(!e)return;function h(u){u.key==="Escape"&&!o&&l()}return window.addEventListener("keydown",h),()=>{window.removeEventListener("keydown",h)}},[o,l,e]),!e)return null;function d(h){h.preventDefault(),i()}return Yr.createPortal(t.jsxs("div",{className:"fixed inset-0 z-[95] flex items-center justify-center p-4 sm:p-6",children:[t.jsx("button",{type:"button","aria-label":"Close rename dialog",onClick:l,disabled:o,className:"absolute inset-0 bg-stone-950/78 backdrop-blur-sm disabled:cursor-not-allowed"}),t.jsxs("form",{role:"dialog","aria-modal":"true","aria-label":r,onSubmit:d,className:"relative z-[1] w-full max-w-md rounded-[1.6rem] border border-stone-700 bg-stone-900 p-5 shadow-2xl shadow-stone-950/40 sm:p-6",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"text-sm font-medium text-stone-100",children:r}),t.jsx("p",{className:"mt-1 text-sm text-stone-500",children:"Changes are saved only after confirmation."})]}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:l,disabled:o,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full border border-stone-700 text-stone-300 transition hover:bg-stone-800 disabled:cursor-not-allowed disabled:opacity-60",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:t.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})})]}),t.jsxs("div",{className:"mt-5",children:[t.jsx("label",{htmlFor:"rename-dialog-input",className:"text-sm font-medium text-stone-200",children:n}),t.jsx("input",{id:"rename-dialog-input","aria-label":n,autoFocus:!0,value:a,onChange:h=>s(h.target.value),className:"mt-2 w-full rounded-2xl border border-stone-700 bg-stone-950 px-4 py-3 text-stone-100 outline-none transition focus:border-amber-300"})]}),t.jsxs("div",{className:"mt-5 flex items-center justify-end gap-2",children:[t.jsx("button",{type:"button",onClick:l,disabled:o,className:"rounded-full border border-stone-700 px-4 py-2 text-sm font-medium text-stone-300 transition hover:bg-stone-800 disabled:cursor-not-allowed disabled:opacity-60",children:"Cancel"}),t.jsx("button",{type:"submit",disabled:o||!a.trim(),className:"ui-action-success rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed",children:"Save"})]})]})]}),document.body)}function tp({children:e,effectiveTheme:r,layoutMode:n,themeMode:a,viewportConstrained:o}){return t.jsx("div",{className:`thread-ui-shell ${r==="dark"?"thread-ui-theme-dark dark":""} ${o?"thread-ui-viewport-constrained":""} ${o?"h-[100svh] max-h-[100svh] min-h-0 overflow-hidden overscroll-none":"min-h-[100svh] overflow-hidden"} bg-[#f6f8fb] text-slate-900 transition-colors duration-200 sm:p-2`,"data-theme-effective":r,"data-theme-mode":a??r,"data-thread-layout":n,children:e})}function rp({children:e,roomsRailCollapsed:r}){return t.jsx("div",{className:`thread-shell-frame relative h-full min-h-0 ${r?"is-rail-collapsed sm:grid-cols-[56px_minmax(0,1fr)]":"sm:grid-cols-[264px_minmax(0,1fr)]"}`,children:e})}function np({onClose:e,open:r}){return r?t.jsx("button",{type:"button","aria-hidden":"true",tabIndex:-1,className:"thread-mobile-only-block thread-mobile-scrim fixed inset-0 z-40 bg-slate-950/35 backdrop-blur-[1px]",onClick:e}):null}function ap({children:e,collapsed:r,mobileOpen:n}){return t.jsx("aside",{className:`thread-graph-rooms-surface thread-rooms-rail fixed inset-y-0 left-0 z-50 flex min-h-0 min-w-0 w-[min(20rem,calc(100vw-2rem))] flex-col overflow-x-hidden border-r border-slate-200/80 bg-white shadow-[0_20px_50px_rgba(15,23,42,0.18)] transition-transform duration-200 ease-out sm:static sm:z-auto sm:w-auto sm:translate-x-0 sm:rounded-[12px] sm:border sm:shadow-[0_10px_30px_rgba(15,23,42,0.04)] ${n?"translate-x-0":"pointer-events-none -translate-x-full sm:pointer-events-auto"} ${r?"thread-ui-rail-collapsed sm:items-center":""}`,style:{paddingTop:"var(--android-safe-area-top, 0px)"},children:e})}function sp({children:e}){return t.jsx("main",{className:"thread-shell-main h-full min-h-0 min-w-0 overflow-hidden",children:t.jsx("div",{className:"thread-main-panel thread-shell-card flex h-full min-h-0 flex-col overflow-hidden bg-white shadow-[0_10px_30px_rgba(15,23,42,0.04)] sm:rounded-[12px] sm:border sm:border-slate-200/80",children:e})})}function op({children:e}){return t.jsx("div",{className:"thread-topbar-surface flex shrink-0 flex-col border-b border-slate-200 bg-white pt-[env(safe-area-inset-top)] sm:pt-0",children:e})}function lp({children:e}){return t.jsx("div",{className:"thread-split-region min-h-0 flex-1 overflow-hidden p-0 sm:p-2",children:e})}Lo();Pt();function cs({...e}){return t.jsx(Ji,{"data-slot":"dialog",...e})}function hs({...e}){return t.jsx(Qi,{"data-slot":"dialog-trigger",...e})}function ip({...e}){return t.jsx(ad,{"data-slot":"dialog-portal",...e})}function dp({className:e,...r}){return t.jsx(sd,{"data-slot":"dialog-overlay",className:rt("fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",e),...r})}function us({children:e,className:r,showCloseButton:n=!0,...a}){return t.jsxs(ip,{"data-slot":"dialog-portal",children:[t.jsx(dp,{}),t.jsxs(ed,{"data-slot":"dialog-content",className:rt("fixed left-[50%] top-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg",r),...a,children:[e,n?t.jsxs(td,{"data-slot":"dialog-close",className:"absolute right-4 top-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[t.jsx(D.XIcon,{}),t.jsx("span",{className:"sr-only",children:"Close"})]}):null]})]})}function ms({className:e,...r}){return t.jsx("div",{"data-slot":"dialog-header",className:rt("flex flex-col gap-2 text-center sm:text-left",e),...r})}function ps({className:e,...r}){return t.jsx(rd,{"data-slot":"dialog-title",className:rt("text-lg font-semibold leading-none",e),...r})}function fs({className:e,...r}){return t.jsx(nd,{"data-slot":"dialog-description",className:rt("text-sm text-muted-foreground",e),...r})}var cp=[{value:"system",label:"Follow system",icon:D.Monitor},{value:"dark",label:"Dark",icon:D.Moon},{value:"light",label:"Light",icon:D.Sun}];function hp({thread:e,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a={},onOpenThread:o,getThreadHref:s,renderThreadLink:l,onBeginRenameThread:i,onDeleteThread:d,showDeleteButton:h=!1,showSessionCopyButton:u=!1,collapsed:m=!1}){const[f,p]=c.useState("idle"),g=c.useRef(null),b=a[e.workspaceId],k=b&&!n?b:null,x=r===e.id;c.useEffect(()=>()=>{g.current!==null&&window.clearTimeout(g.current)},[]);async function j(){const N=e.providerSessionId;if(N)try{await navigator.clipboard.writeText(N),p("copied"),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>p("idle"),1200)}catch{p("failed"),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>p("idle"),1600)}}const w=()=>o(e.id),y=`thread-graph-room-card group flex w-full items-center gap-3 rounded-xl border text-left transition ${x?"is-active":""} ${m?"justify-center px-2 py-2":"px-3 py-2.5"}`,v=t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`thread-graph-room-card-icon flex h-8 w-8 shrink-0 items-center justify-center rounded-full ${x?"is-active":""}`,children:t.jsx(D.MessageSquare,{className:"h-4 w-4"})}),t.jsxs("div",{className:`min-w-0 flex-1 ${m?"thread-desktop-collapsed-hidden":""}`,children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[t.jsx("p",{className:"thread-graph-room-card-title min-w-0 flex-1 truncate text-sm font-medium",title:e.title,children:e.title}),i&&!m?t.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),N.preventDefault(),i(e)},"aria-label":`Rename thread ${e.title}`,title:"Rename thread",className:"thread-card-quiet-button inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full transition",children:t.jsx(D.Pencil,{className:"h-3 w-3"})}):null,u&&e.providerSessionId?t.jsx("button",{type:"button","aria-label":"Copy session ID",title:f==="copied"?"Copied":f==="failed"?"Copy failed":"Copy session ID",onClick:N=>{N.stopPropagation(),N.preventDefault(),j()},className:"thread-card-quiet-button thread-card-session-copy-button inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full transition",children:t.jsx(D.Copy,{className:"h-3.5 w-3.5"})}):null]}),t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-2",children:[k?t.jsx("p",{className:"thread-graph-room-card-meta min-w-0 flex-1 truncate text-[11px] text-[var(--theme-fg-muted)]",title:k,children:k}):t.jsx("span",{className:"min-w-0 flex-1","aria-hidden":"true"}),t.jsx("span",{className:`shrink-0 rounded-full border px-1.5 py-0.5 text-[9px] uppercase tracking-normal ${Qm(e.status)}`,children:Jm(e.status)}),t.jsx("time",{className:"shrink-0 text-[11px] text-[var(--theme-fg-muted)]",dateTime:e.lastTurnStartedAt??e.updatedAt,children:xt(e.lastTurnStartedAt??e.updatedAt)})]})]}),h&&d&&!m?t.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),N.preventDefault(),d(e)},"aria-label":`Delete thread ${e.title}`,className:"thread-card-danger-button shrink-0 rounded-full p-1 transition",title:"Delete thread",children:t.jsx(D.Trash2,{className:"h-3.5 w-3.5"})}):null]}),S=s==null?void 0:s(e.id);return l?t.jsx(t.Fragment,{children:l({thread:e,children:v,className:y,onClick:w})}):S?t.jsx("a",{href:S,onClick:N=>{N.preventDefault(),w()},title:m?e.title:void 0,className:y,children:v}):t.jsx("div",{role:"link",tabIndex:0,onClick:w,onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),w())},title:m?e.title:void 0,className:y,children:v})}function up({threads:e,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a={},onOpenThread:o,getThreadHref:s,renderThreadLink:l,onBeginRenameThread:i,onDeleteThread:d,scrollable:h=!1,maxHeightClassName:u="max-h-full",showDeleteButton:m=!1,showSessionCopyButton:f=!1,collapsed:p=!1}){const g=h?`min-h-0 min-w-0 overflow-x-hidden overflow-y-auto overscroll-contain pr-1 ${u}`:"";return t.jsx("div",{className:g,children:t.jsx("div",{className:"min-w-0 space-y-1",children:e.map(b=>t.jsx(hp,{thread:b,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a,onOpenThread:o,showDeleteButton:m,showSessionCopyButton:f,collapsed:p,...s?{getThreadHref:s}:{},...l?{renderThreadLink:l}:{},...i?{onBeginRenameThread:i}:{},...d?{onDeleteThread:d}:{}},b.id))})})}function mp({threads:e,status:r,loading:n=!1,error:a,viewportConstrained:o=!1,layoutMode:s="responsive",effectiveTheme:l,themeMode:i,onThemeModeChange:d,showMobileNewThreadShortcut:h=!0,settingsDialogOpen:u,onSettingsDialogOpenChange:m,mobileHeaderAction:f,currentThreadId:p,currentThreadLabel:g=null,currentWorkspaceId:b=null,currentWorkspaceLabel:k=null,sessionLabel:x=null,usageLabel:j=null,threadActionsButton:w,topbarActions:y,metaContent:v,settingsContent:S,globalSettingsContent:N,workspaceLabels:I={},workspaceReturnHref:M,onWorkspaceReturn:R,getThreadHref:Q,onOpenThread:$,getNewThreadHref:Y,newThreadHref:Z,newThreadLabel:P="New Chat",onNewThread:te,onNewThreadTitle:oe,renderNewThreadDialogContent:T,renderThreadLink:re,onCloseAppNavigation:B,onRenameThread:J,onDeleteThread:K,workspaceContent:L,workspaceTitle:q="Workspace",workspaceActions:G,children:E}){const C=ll(),W=typeof window<"u"?window.matchMedia("(max-width: 639px)").matches:s==="mobile",[H,se]=c.useState(()=>typeof window<"u"?window.matchMedia("(prefers-color-scheme: dark)").matches:!1),V=i??(C==null?void 0:C.themeMode)??"system",de=l??(C==null?void 0:C.effectiveTheme)??(V==="system"?H?"dark":"light":V),[ee,be]=c.useState(!1),[ie,ye]=c.useState(!1),[Ae,ce]=c.useState(!W),[Ce,Le]=c.useState(W),[X,ue]=c.useState("chat"),[ve,ke]=c.useState(null),[$e,He]=c.useState(""),[_e,ze]=c.useState(null),[F,le]=c.useState(!1),[we,z]=c.useState(""),[O,ne]=c.useState(!1),[ge,Te]=c.useState(!1),[Ee,fe]=c.useState("session");c.useEffect(()=>{if(typeof window>"u")return;const _=window.matchMedia("(max-width: 639px)"),pe=()=>{Le(_.matches)};return pe(),_.addEventListener("change",pe),()=>{_.removeEventListener("change",pe)}},[]),c.useEffect(()=>{if(typeof window>"u")return;const _=window.matchMedia("(prefers-color-scheme: dark)"),pe=()=>{se(_.matches)};return pe(),_.addEventListener("change",pe),()=>{_.removeEventListener("change",pe)}},[]);const De=c.useMemo(()=>[...b?e.filter(pe=>pe.workspaceId===b):e].sort((pe,Re)=>{if(pe.id===p)return-1;if(Re.id===p)return 1;const Ge=Date.parse(pe.lastTurnStartedAt??pe.updatedAt);return Date.parse(Re.lastTurnStartedAt??Re.updatedAt)-Ge}),[p,b,e]),Be=Z??(Y==null?void 0:Y(b)),et=k??b??"all",Ve=x??g??p??"default_session",pt=j??(r!=null&&r.state?`runtime ${r.state}`:"waiting for agent usage"),nt=d??(C==null?void 0:C.setThemeMode),We=!!nt,ot=()=>{be(!1),B==null||B()};async function ht(_){if(!J)return;const pe=$e.trim();if(pe){ze(_);try{await J(_,pe),ke(null),He("")}finally{ze(null)}}}function ut(_){ke(_.id),He(_.title)}function A(){ke(null),He("")}function U(_){$==null||$(_),ot()}function xe(){le(!1),z("")}function je(_){if(!Be||!_.trim())return Be;try{const pe=new URL(Be,window.location.origin);return pe.searchParams.set("title",_.trim()),`${pe.pathname}${pe.search}${pe.hash}`}catch{const pe=Be.includes("?")?"&":"?";return`${Be}${pe}title=${encodeURIComponent(_.trim())}`}}async function Ne(){const _=we.trim();ne(!0);try{if(_&&oe){await oe(_),z(""),le(!1),ot();return}if(Be){window.location.assign(je(_)??Be);return}await(te==null?void 0:te()),z(""),le(!1),ot()}finally{ne(!1)}}function Ye(_,pe=!1){const Re=pe?t.jsxs(t.Fragment,{children:[t.jsx(D.Plus,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:P})]}):t.jsxs(t.Fragment,{children:[t.jsx(D.Plus,{className:"h-4 w-4"}),t.jsx("span",{children:P})]});return t.jsxs(cs,{open:F,onOpenChange:Ge=>{O||le(Ge)},children:[t.jsx(hs,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":pe?P:void 0,title:P,className:_,children:Re})}),t.jsx(us,{"data-testid":"create-thread-dialog","data-theme-effective":de,"data-theme-mode":V,className:"thread-graph-create-thread-dialog thread-graph-dialog max-h-[min(86vh,42rem)] overflow-hidden p-4 sm:max-w-[34rem]",children:T?T({close:xe,closeNavigation:ot,currentWorkspaceId:b}):t.jsxs(t.Fragment,{children:[t.jsxs(ms,{children:[t.jsx(ps,{children:"Create New Chat"}),t.jsx(fs,{children:"Name the room so it is easy to find later."})]}),t.jsxs("div",{className:"grid gap-3",children:[t.jsx("input",{id:"thread-graph-create-thread-title",name:"thread-title",value:we,onChange:Ge=>z(Ge.target.value),onKeyDown:Ge=>{Ge.key==="Enter"&&(Ge.preventDefault(),Ne())},placeholder:"Chat name","aria-label":"Chat name",autoComplete:"off",className:"thread-graph-create-thread-input h-10 rounded-md border px-3 text-sm outline-none transition"}),t.jsx("button",{type:"button",onClick:()=>void Ne(),disabled:O,className:"thread-graph-create-thread-submit inline-flex h-10 items-center justify-center rounded-md px-4 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:O?"Creating...":"Create"})]})]})})]})}function tt(){if(!S&&!v&&!N&&!We)return null;const _=!!(S||v),pe=!!N,Re=_&&pe,Ge=Ee==="global"&&pe||!_&&pe?"global":"session";return t.jsxs(cs,{...u!==void 0?{open:u}:{},...m?{onOpenChange:m}:{},children:[t.jsx(hs,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":"Open settings",title:"Settings",className:"thread-icon-button inline-flex h-10 w-10 items-center justify-center rounded-full sm:h-9 sm:w-9",children:t.jsx(D.Settings,{className:"h-4 w-4"})})}),t.jsxs(us,{"data-testid":"settings-dialog","data-theme-effective":de,"data-theme-mode":V,className:"thread-graph-settings-dialog thread-graph-dialog",children:[t.jsxs(ms,{children:[t.jsx(ps,{children:"Settings"}),t.jsx(fs,{children:"Manage this session and host-wide preferences."})]}),We?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:t.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"font-medium text-[var(--theme-fg)]",children:"Appearance"}),t.jsxs("p",{className:"mt-1 text-xs leading-5 text-[var(--theme-fg-muted)]",children:["Current theme: ",de]})]}),t.jsx("div",{className:"thread-graph-theme-mode-group grid grid-cols-3 gap-1 rounded-lg border p-1",role:"group","aria-label":"Theme mode",children:cp.map(Ue=>{const ct=Ue.icon,kt=V===Ue.value;return t.jsxs("button",{type:"button","data-testid":`theme-mode-${Ue.value}`,"aria-pressed":kt,disabled:!We,onClick:()=>nt==null?void 0:nt(Ue.value),className:`thread-graph-theme-mode-button inline-flex min-h-9 items-center justify-center gap-1.5 rounded-md px-2 text-xs font-medium transition ${kt?"is-selected":""}`,children:[t.jsx(ct,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:"truncate",children:Ue.label})]},Ue.value)})})]})}):null,Re?t.jsxs("div",{className:"thread-graph-settings-tabs grid grid-cols-2 gap-1 rounded-lg border p-1",children:[t.jsx("button",{type:"button","aria-pressed":Ge==="session",onClick:()=>fe("session"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${Ge==="session"?"is-active":""}`,children:"Session"}),t.jsx("button",{type:"button","aria-pressed":Ge==="global",onClick:()=>fe("global"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${Ge==="global"?"is-active":""}`,children:"Global"})]}):null,t.jsx("div",{className:"thread-graph-settings-body mt-4 min-h-0 overflow-y-auto pr-1 text-sm",children:Ge==="session"?t.jsxs("div",{className:"grid gap-4",children:[S?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:S}):null,v?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:v}):null,_?null:t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3 text-[var(--theme-fg-muted)]",children:"No session settings are available."})]}):t.jsx("div",{className:"thread-graph-settings-global-content",children:N})})]})]})}function Fe(_=!1){return t.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:t.jsxs("section",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsxs("div",{className:`mb-3 flex items-center gap-2 px-2 text-xs font-medium tracking-normal text-[var(--theme-fg-muted)] ${_?"justify-center":""}`,children:[t.jsx(D.Rows3,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:_?"sr-only":"",children:"Rooms"}),!_&&n?t.jsx("span",{className:"ml-auto text-xs text-[var(--theme-fg-muted)]",children:"Refreshing..."}):null]}),t.jsxs("div",{className:"min-h-0 min-w-0 flex-1 overflow-x-hidden overflow-y-auto px-1",children:[a?t.jsx("div",{className:"rounded-xl border border-rose-500/30 bg-rose-500/10 px-3 py-3 text-sm text-rose-900 dark:text-rose-100",children:a}):null,!a&&De.length===0&&!n?t.jsx("div",{className:"rounded-xl border border-dashed border-[var(--theme-border)] bg-[var(--theme-surface)] px-4 py-6 text-sm text-[var(--theme-fg-muted)]",children:"No threads available in this view."}):null,De.length>0?t.jsx(up,{threads:De,currentThreadId:p,currentWorkspaceId:b,workspaceLabels:I,onOpenThread:U,collapsed:_,...J?{onBeginRenameThread:ut}:{},showDeleteButton:!!K,...Q?{getThreadHref:Q}:{},...re?{renderThreadLink:re}:{},...K?{onDeleteThread:K}:{}}):null]})]})})}function Ke(){return L?t.jsxs("div",{className:"thread-workspace-panel relative flex h-full min-h-0 flex-col overflow-hidden rounded-[12px] border",children:[t.jsx("button",{type:"button",onClick:()=>ce(!0),className:"thread-workspace-collapse-tab thread-desktop-only-inline-flex",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx(D.ChevronsRight,{className:"h-4 w-4"})}),G?t.jsx("div",{className:"pointer-events-none absolute right-12 top-2 z-20 flex items-center gap-1",children:t.jsx("div",{className:"pointer-events-auto",children:G})}):null,t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:L})]}):t.jsxs("div",{className:"thread-workspace-panel flex h-full min-h-0 flex-col overflow-hidden rounded-[12px] border",children:[t.jsxs("div",{className:"thread-workspace-panel-header flex h-12 shrink-0 items-center justify-between gap-3 border-b border-[var(--theme-border)] px-3 sm:h-[60px] sm:px-4",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate text-base font-semibold text-[var(--theme-fg)] sm:text-[18px]",children:q}),t.jsx("p",{className:"truncate text-xs text-[var(--theme-fg-muted)]",children:k??b??"Current context"})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[G,t.jsx("button",{type:"button",onClick:()=>ce(!0),className:"thread-workspace-small-toggle thread-desktop-only-inline-flex",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx(D.ChevronsRight,{className:"h-4 w-4"})})]})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:L??t.jsxs("div",{className:"grid h-full min-h-0 gap-3 overflow-y-auto p-3 text-sm text-[var(--theme-fg-soft)]",children:[t.jsxs("div",{className:"thread-workspace-card rounded-lg border p-3",children:[t.jsx("p",{className:"text-xs font-medium uppercase tracking-[0.14em] text-[var(--theme-fg-muted)]",children:"Runtime"}),t.jsx("p",{className:"mt-2 text-[var(--theme-fg)]",children:(r==null?void 0:r.state)??"unknown"})]}),t.jsxs("div",{className:"thread-workspace-card rounded-lg border p-3",children:[t.jsx("p",{className:"text-xs font-medium uppercase tracking-[0.14em] text-[var(--theme-fg-muted)]",children:"Workspace"}),t.jsx("p",{className:"mt-2 break-words text-[var(--theme-fg)]",children:k??b??"All threads"})]})]})})]})}const lt=!!L,vt=s==="mobile"||s==="responsive"&&Ce,it=vt,Nt=it&&!ee,Ct=!!(M||R)?t.jsx("a",{href:M??"#",onClick:_=>{R&&(_.preventDefault(),R())},className:"thread-icon-button inline-flex h-10 w-10 items-center justify-center rounded-full sm:h-9 sm:w-9",title:"Back to workspace","aria-label":"Back to workspace",children:t.jsx(D.ArrowLeft,{className:"h-4 w-4"})}):null;return t.jsxs(t.Fragment,{children:[t.jsx(tp,{effectiveTheme:de,layoutMode:s,themeMode:V,viewportConstrained:o,children:t.jsxs(rp,{roomsRailCollapsed:ie,children:[t.jsx(np,{open:ee,onClose:()=>be(!1)}),t.jsxs(ap,{collapsed:ie,mobileOpen:ee,children:[t.jsx("div",{className:`thread-rooms-rail-header flex h-[calc(3rem+env(safe-area-inset-top))] shrink-0 items-end border-b border-[var(--theme-border)] px-4 pb-2 sm:h-16 sm:items-center sm:pb-0 ${ie?"sm:w-full sm:justify-center sm:px-2":""}`,children:t.jsxs("div",{className:`flex w-full items-center gap-3 ${ie?"sm:justify-center":"justify-between"}`,children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[t.jsx("button",{type:"button",onClick:()=>ye(_=>!_),className:"thread-icon-button thread-desktop-only-flex h-9 w-9 shrink-0 items-center justify-center rounded-full",title:ie?"Expand rooms":"Collapse rooms","aria-label":ie?"Expand rooms":"Collapse rooms",children:ie?t.jsx(D.PanelLeftOpen,{className:"h-4 w-4"}):t.jsx(D.PanelLeftClose,{className:"h-4 w-4"})}),t.jsx("div",{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-[var(--theme-accent-solid)] text-sm font-semibold text-[var(--theme-accent-solid-fg)] ${ie?"thread-desktop-collapsed-hidden":""}`,children:(k??"R").charAt(0).toUpperCase()}),t.jsxs("div",{className:`min-w-0 ${ie?"thread-desktop-collapsed-hidden":""}`,children:[t.jsx("p",{className:"truncate text-sm font-semibold text-[var(--theme-fg)]",children:k??"Remote Codex"}),t.jsx("p",{className:"truncate text-xs text-[var(--theme-fg-muted)]",children:b??"Thread workspace"})]})]}),t.jsxs("div",{className:`flex shrink-0 items-center gap-1 ${ie?"thread-desktop-collapsed-hidden":""}`,children:[tt(),Ct,t.jsx("button",{type:"button",onClick:()=>be(!1),"aria-label":"Close rooms",title:"Close rooms",className:"thread-icon-button thread-mobile-only-inline-flex h-10 w-10 items-center justify-center rounded-full",children:t.jsx(D.X,{className:"h-4 w-4"})})]})]})}),t.jsx("div",{className:`thread-graph-new-room-strip flex shrink-0 items-center border-b ${ie?"h-12 w-full justify-center px-2 sm:h-12":"h-[68px] px-4"}`,children:Ye(`thread-graph-new-room-button inline-flex items-center justify-center rounded-xl font-medium transition ${ie?"h-9 w-9 p-0":"h-11 w-full gap-2 px-3 text-sm sm:h-9"}`,ie)}),t.jsx("div",{className:`flex min-h-0 flex-1 flex-col ${ie?"w-full px-2 py-2":"px-3 py-3"}`,children:Fe(ie)})]}),t.jsxs(sp,{children:[t.jsx(op,{children:t.jsx("div",{className:"thread-topbar-row flex min-h-12 items-center px-3 py-1.5 sm:min-h-12 sm:px-4",children:t.jsxs("div",{className:"flex w-full items-center justify-between gap-3 sm:gap-4",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 sm:gap-3",children:[Nt?t.jsx("button",{type:"button",onClick:()=>be(!0),"aria-label":"Open rooms",title:"Open rooms",className:"thread-icon-button thread-mobile-only-inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-full",children:t.jsx(D.Menu,{className:"h-4 w-4"})}):null,t.jsxs("div",{className:"min-w-0",children:[t.jsx("h1",{className:"min-w-0 truncate text-sm font-semibold leading-tight text-[var(--theme-fg)] sm:text-base",title:g??"Shared Workspace",children:g??"Shared Workspace"}),t.jsxs("div",{className:"relative mt-0.5 flex min-w-0 items-center gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{Te(_=>!_)},"aria-expanded":ge,"aria-haspopup":"dialog",className:"thread-topbar-meta-row flex min-w-0 max-w-full items-center gap-1 text-left text-[11px] leading-none sm:text-xs",title:"Session and usage",children:[t.jsx("span",{className:"shrink-0",children:"Room"}),t.jsx("span",{className:"truncate font-mono",children:et})]}),ge?t.jsxs("div",{className:"thread-topbar-details-popover absolute left-0 top-[calc(100%+0.5rem)] z-50 w-[min(28rem,calc(100vw-1.5rem))] rounded-lg border p-2.5 shadow-lg",role:"dialog","aria-label":"Session and usage",children:[t.jsxs("button",{type:"button",onClick:()=>{var _;Ve&&((_=navigator.clipboard)==null||_.writeText(Ve))},className:"thread-topbar-meta-row flex min-w-0 max-w-full items-center gap-2 text-left text-xs leading-5",title:"Copy session ID",children:[t.jsx("span",{className:"w-14 shrink-0",children:"Session"}),t.jsx("span",{className:"truncate font-mono",children:Ve})]}),t.jsxs("div",{className:"thread-topbar-meta-row mt-1 flex min-w-0 max-w-full items-start gap-2 text-xs leading-5",title:"Session token usage and estimated cost",children:[t.jsx("span",{className:"w-14 shrink-0",children:"Usage"}),t.jsx("span",{className:"min-w-0 whitespace-normal break-words font-mono",children:pt})]})]}):null]})]})]}),t.jsxs("div",{className:"relative z-[1] inline-flex shrink-0 items-center gap-2",children:[w||y?t.jsxs("div",{className:"thread-graph-topbar-actions thread-desktop-only-inline-flex items-center rounded-lg border p-0.5 shadow-none",children:[w,y]}):null,it&&w?t.jsx("div",{className:"thread-mobile-only-inline-flex",children:w}):null,it&&lt?t.jsx("button",{type:"button",onClick:()=>ue(_=>_==="workspace"?"chat":"workspace"),"aria-label":X==="workspace"?"Show chat":"Show workspace",title:X==="workspace"?"Show chat":"Show workspace",className:"thread-icon-button thread-mobile-only-inline-flex h-10 w-10 items-center justify-center rounded-full",children:X==="workspace"?t.jsx(D.MessageSquare,{className:"h-4 w-4"}):t.jsx(D.Folder,{className:"h-4 w-4"})}):null,it?f:null,it&&h?Ye("thread-secondary-action inline-flex h-10 items-center justify-center gap-2 rounded-lg border px-3 text-sm font-medium sm:h-9"):null]})]})})}),t.jsx(lp,{children:lt&&!Ae?vt?t.jsxs("div",{className:"thread-split-container thread-graph-shell-mobile-split h-full min-h-0 overflow-hidden",children:[t.jsx("div",{className:`h-full min-h-0 overflow-hidden ${X==="chat"?"block":"thread-mobile-chat-hidden"}`,children:E}),t.jsx("div",{className:`h-full min-h-0 overflow-hidden ${X==="workspace"?"block":"thread-mobile-workspace-hidden"}`,children:Ke()})]}):t.jsxs(Mn,{direction:"horizontal",className:"thread-split-container thread-graph-shell-resizable thread-graph-shell-desktop-split h-full min-h-0 overflow-hidden",children:[t.jsx(sr,{defaultSize:47,minSize:30,maxSize:75,className:"thread-split-chat-pane min-w-0 overflow-hidden",children:E}),t.jsx(An,{className:"thread-resize-handle w-2 bg-transparent after:w-px after:bg-slate-200/80 after:transition-colors hover:after:bg-slate-300 dark:after:bg-[#303642] dark:hover:after:bg-[#475063]"}),t.jsx(sr,{defaultSize:53,minSize:30,maxSize:70,className:"thread-split-workspace-pane min-w-0 overflow-hidden",children:Ke()})]}):t.jsxs("div",{className:"thread-split-container relative h-full min-h-0 overflow-hidden",children:[lt&&Ae?t.jsx("button",{type:"button",onClick:()=>ce(!1),className:"thread-workspace-expand-fab thread-desktop-only-inline-flex",title:"Expand workspace","aria-label":"Expand workspace",children:t.jsx(D.ChevronsLeft,{className:"h-4 w-4"})}):null,E]})})]})]})}),t.jsx(ep,{open:ve!==null,title:"Rename Thread",label:"Thread Title",value:$e,busy:_e!==null,onChange:He,onCancel:A,onSubmit:()=>ve?ht(ve):void 0})]})}function pp({open:e,title:r,text:n,onClose:a}){return c.useEffect(()=>{if(!e)return;function o(s){s.key==="Escape"&&a()}return window.addEventListener("keydown",o),()=>{window.removeEventListener("keydown",o)}},[a,e]),e?Yr.createPortal(t.jsxs("div",{className:"fixed inset-0 z-[90] flex items-center justify-center p-4 sm:p-6",children:[t.jsx("button",{type:"button","aria-label":"Close full text",onClick:a,className:"absolute inset-0 bg-stone-950/78 backdrop-blur-sm"}),t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":r,className:"relative z-[1] flex max-h-[min(82vh,52rem)] w-full max-w-4xl flex-col overflow-hidden rounded-[1.8rem] border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-stone-800 px-4 py-3 sm:px-5",children:[t.jsx("p",{className:"truncate text-sm font-medium text-stone-100",children:r}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:a,className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-stone-700 text-stone-300 transition hover:bg-stone-800",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:t.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-4 py-4 sm:px-5",children:t.jsx("pre",{className:"whitespace-pre-wrap break-words text-sm leading-6 text-stone-200",children:n})})]})]}),document.body):null}var fp=[/^(?: {0,3})#{1,6}\s+\S/m,/^(?: {0,3})>{1,}\s*\S/m,/^(?: {0,3})(?:[-+*]|\d{1,9}[.)])\s+(?:\[[ xX]\]\s+)?\S/m,/^(?: {0,3})(?:```|~~~)/m,/^(?: {0,3})(?:[-*_]\s*){3,}$/m],gp=/^(?:\|?[^|\n]+\|[^|\n]+(?:\|[^|\n]+)*\|?\s*\n\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$)/m,xp=/!?\[[^\]\n]+\]\([^)]+\)/,bp=/`[^`\n]+`/,vp=/(?:\*\*[^*\n]+\*\*|__[^_\n]+__)/,kp=/(^|[^\w])(?:\*[^*\n]+\*|_[^_\n]+_)(?=[^\w]|$)/,wp=/~~[^~\n]+~~/;function yp(e){const r=e.trim();return r?fp.some(n=>n.test(r))||gp.test(r)?!0:/[`[\]*_~!]/.test(r)?xp.test(r)||bp.test(r)||vp.test(r)||kp.test(r)||wp.test(r):!1:!1}rn();function Vn(e,r){const n=new Map(r.map(s=>[s.id,s])),a=e.map(s=>{var l,i;return{...s.manifest,enabled:((l=n.get(s.manifest.id))==null?void 0:l.enabled)??!0,source:((i=n.get(s.manifest.id))==null?void 0:i.source)??"builtin"}}),o=new Set(e.map(s=>s.manifest.id));for(const s of r)o.has(s.id)||a.push(s);return a}function ia(e=[]){const r=Vn(e,[]),n=e;return{plugins:r,loading:!1,error:null,async refresh(){},async importPluginManifest(){},async setPluginEnabled(){},async uninstallPlugin(){},renderArtifact:s=>{var i;const l=n.find(d=>d.renderArtifact&&d.manifest.capabilities.artifactTypes.some(h=>h.type===s.artifact.type));return((i=l==null?void 0:l.renderArtifact)==null?void 0:i.call(l,s))??null},renderInlineCode:s=>{for(const l of n)for(const i of l.inlineCodeRenderers??[]){if(!i.languages.includes(s.language.trim().toLowerCase()))continue;const d=i.render(s);if(d)return d}return null},hasRendererForArtifact:s=>n.some(l=>!!l.renderArtifact&&l.manifest.capabilities.artifactTypes.some(i=>i.type===s.type)),getThreadPanels:()=>n.flatMap(s=>s.threadPanels??[])}}var da=c.createContext(ia());function ca(){return c.useContext(da)??ia()}Lr();function dl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function gs(e){return dl(e)?Object.entries(e):e==null||e===""?[]:[["value",e]]}function cl(e){return typeof e=="string"?t.jsxs("span",{className:"thread-graph-tool-string",children:['"',e,'"']}):typeof e=="number"?t.jsx("span",{className:"thread-graph-tool-number",children:e}):typeof e=="boolean"?t.jsx("span",{className:"thread-graph-tool-boolean",children:String(e)}):e===null?t.jsx("span",{className:"thread-graph-tool-null",children:"null"}):typeof e=="object"?t.jsx("span",{className:"thread-graph-tool-object",children:JSON.stringify(e)}):t.jsx("span",{children:String(e)})}function jp(e,r){return typeof r=="string"&&(e==="stdout"||e==="stderr"||e==="result")?t.jsx("pre",{className:"thread-graph-tool-output",children:r||"(empty)"}):typeof r=="object"&&r!==null?t.jsx("pre",{className:"thread-graph-tool-output",children:JSON.stringify(r,null,2)}):cl(r)}function xs({callId:e,toolName:r,status:n,parameters:a,result:o}){const s=c.useMemo(()=>{switch(n){case"completed":return{className:"is-completed",icon:t.jsx(D.CheckCircle2,{className:"h-3.5 w-3.5"}),label:"Completed"};case"failed":return{className:"is-failed",icon:t.jsx(D.XCircle,{className:"h-3.5 w-3.5"}),label:"Failed"};default:return{className:"is-pending",icon:t.jsx(D.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),label:"Running"}}},[n]),l=c.useMemo(()=>gs(o),[o]),i=c.useMemo(()=>gs(a),[a]),d=c.useMemo(()=>typeof o=="string"?o.length>0:dl(o)?["stdout","stderr","result"].some(f=>{const p=o[f];return typeof p=="string"&&p.length>0}):!1,[o]),h=n==="pending"||d,[u,m]=c.useState(h?"item-1":void 0);return c.useEffect(()=>{h&&m("item-1")},[e,h]),t.jsx("div",{className:"thread-graph-tool-call my-2 w-full font-sans not-prose",children:t.jsx(Sr,{type:"single",collapsible:!0,onValueChange:f=>m(f||void 0),className:"thread-graph-tool-accordion w-full overflow-hidden rounded-lg border",...u!==void 0?{value:u}:{},children:t.jsxs(Tr,{value:"item-1",className:"border-0",children:[t.jsx(nn,{className:"thread-graph-tool-trigger px-4 py-3 hover:no-underline",children:t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(D.Wrench,{className:"h-4 w-4 shrink-0"}),t.jsx("span",{className:"min-w-0 truncate font-mono text-sm font-semibold",children:r}),t.jsxs("span",{className:`thread-graph-tool-badge ${s.className}`,title:s.label,"aria-label":`Status: ${s.label}`,children:[s.icon,t.jsx("span",{className:"thread-graph-status-label",children:s.label})]})]})}),t.jsxs(Er,{className:"thread-graph-tool-content px-4 pb-4 pt-1",children:[t.jsxs("section",{children:[t.jsx("h4",{children:"Parameters"}),t.jsxs("div",{className:"thread-graph-tool-json",children:["{",t.jsx("br",{}),i.length>0?i.map(([f,p],g)=>t.jsxs("div",{children:[t.jsxs("span",{className:"thread-graph-tool-key",children:['"',f,'"']}),t.jsx("span",{className:"thread-graph-tool-punctuation",children:": "}),cl(p),g<i.length-1?t.jsx("span",{className:"thread-graph-tool-punctuation",children:","}):null]},f)):t.jsx("div",{children:t.jsx("span",{className:"thread-graph-tool-null",children:"empty"})}),"}"]})]}),l.length>0?t.jsxs("section",{children:[t.jsx("h4",{children:"Result"}),t.jsxs("div",{className:"thread-graph-tool-json",children:["{",t.jsx("br",{}),l.map(([f,p],g)=>t.jsxs("div",{children:[t.jsxs("span",{className:"thread-graph-tool-key",children:['"',f,'"']}),t.jsx("span",{className:"thread-graph-tool-punctuation",children:": "}),jp(f,p),g<l.length-1?t.jsx("span",{className:"thread-graph-tool-punctuation",children:","}):null]},f)),"}"]})]}):null]})]})})})}var bs=null;function Np(){return bs??(bs=Promise.all([Xe(()=>import("./core-DODVy7wn.js"),__vite__mapDeps([0,1,2])),Xe(()=>import("./engine-javascript-DBd1bXLz.js"),[]),Xe(()=>import("./ayu-light-BA47KaF1.js"),[]),Xe(()=>import("./ayu-dark-DYE7WIF3.js"),[]),Xe(()=>import("./javascript-wDzz0qaB.js"),[]),Xe(()=>import("./typescript-BPQ3VLAy.js"),[]),Xe(()=>import("./tsx-COt5Ahok.js"),[]),Xe(()=>import("./jsx-g9-lgVsj.js"),[]),Xe(()=>import("./python-B6aJPvgy.js"),[]),Xe(()=>import("./json-Cp-IABpG.js"),[]),Xe(()=>import("./shellscript-CEILq0vU.js").then(e=>e.b),[]),Xe(()=>import("./shellscript-CEILq0vU.js").then(e=>e.s),[]),Xe(()=>import("./yaml-Buea-lGh.js"),[]),Xe(()=>import("./toml-vGWfd6FD.js"),[]),Xe(()=>import("./markdown-Cvjx9yec.js"),[]),Xe(()=>import("./html-pp8916En.js"),__vite__mapDeps([3,4,5])),Xe(()=>import("./css-CLj8gQPS.js"),[]),Xe(()=>import("./sql-CRqJ_cUM.js"),[]),Xe(()=>import("./csv-fuZLfV_i.js"),[])]).then(([{createHighlighterCore:e},{createJavaScriptRegexEngine:r},n,a,o,s,l,i,d,h,u,m,f,p,g,b,k,x,j])=>e({engine:r(),themes:[n.default,a.default],langs:[o.default,s.default,l.default,i.default,d.default,h.default,u.default,m.default,f.default,p.default,g.default,b.default,k.default,x.default,j.default]}))),bs}function an(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Kn(e){if(!e)return{};if(an(e)&&Object.prototype.hasOwnProperty.call(e,"0"))try{const r=Object.keys(e).map(Number).filter(n=>Number.isFinite(n)).sort((n,a)=>n-a).map(n=>String(e[String(n)]??"")).join("");return JSON.parse(r)}catch{return e}if(typeof e=="string")try{return JSON.parse(e)}catch{return e}return e}function qn(){return{finalResult:null,stdout:"",stderr:""}}function Cp(e){return typeof e=="string"?{result:e}:e}function hl(e){const r=an(e.finalResult)?{...e.finalResult}:e.finalResult!=null?{result:e.finalResult}:{};return e.stdout&&(r.stdout=e.stdout),e.stderr&&(r.stderr=e.stderr),!("status"in r)&&(e.stdout||e.stderr)&&(r.status="pending"),r}function vs(e){if(!e)return"pending";if(!an(e))return"completed";const r=e.status;return r==="stream"||r==="pending"||r==="running"?"pending":r==="failed"||r==="error"||r==="timed_out"||typeof e.exit_code=="number"&&e.exit_code!==0?"failed":"completed"}function Sp(e){const r=new Map,n=/```tool-result\s*([\s\S]*?)\s*```/g,a=e.replace(n,(l,i)=>{try{const d=JSON.parse(i),h=d.call_id;if(typeof h!="string")return l;const u=Cp(d.result),m=r.get(h)??qn();return an(u)&&u.status==="stream"&&typeof u.chunk=="string"?u.stream==="stderr"?m.stderr+=u.chunk:m.stdout+=u.chunk:m.finalResult=u,r.set(h,m),""}catch{return l}}),o=/```tool-call\s*([\s\S]*?)\s*```/g;return{processedContent:a.replace(o,(l,i)=>{try{const d=JSON.parse(i),h=d.call_id,u=d.tool;if(typeof u!="string")return l;const m=Kn(d.args);if(typeof h=="string"&&r.has(h)){const f=hl(r.get(h)??qn());return`\`\`\`tool-merged