midsomar 0.1.10 → 0.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/index.js +20 -4
  2. package/package.json +1 -1
  3. package/web-ui/_headers 2 +17 -0
  4. package/web-ui/_headers 3 +17 -0
  5. package/web-ui/apple-touch-icon 2.png +0 -0
  6. package/web-ui/apple-touch-icon 3.png +0 -0
  7. package/web-ui/apple-touch-icon-v3 2.png +0 -0
  8. package/web-ui/apple-touch-icon-v3 3.png +0 -0
  9. package/web-ui/assets/dialog-settings-C0ClHN8Q.js +1 -1
  10. package/web-ui/assets/index-BfNxi3ev.js +4 -4
  11. package/web-ui/favicon 2.ico +0 -0
  12. package/web-ui/favicon 2.svg +0 -0
  13. package/web-ui/favicon 3.ico +0 -0
  14. package/web-ui/favicon 3.svg +0 -0
  15. package/web-ui/favicon-96x96 2.png +0 -0
  16. package/web-ui/favicon-96x96 3.png +0 -0
  17. package/web-ui/favicon-96x96-v3 2.png +0 -0
  18. package/web-ui/favicon-96x96-v3 3.png +0 -0
  19. package/web-ui/favicon-v3 2.ico +0 -0
  20. package/web-ui/favicon-v3 2.svg +0 -0
  21. package/web-ui/favicon-v3 3.ico +0 -0
  22. package/web-ui/favicon-v3 3.svg +0 -0
  23. package/web-ui/index 2.html +81 -0
  24. package/web-ui/index 3.html +82 -0
  25. package/web-ui/index.html +17 -1
  26. package/web-ui/midsomar_black 2.png +0 -0
  27. package/web-ui/midsomar_black 3.png +0 -0
  28. package/web-ui/midsomar_logo 2.png +0 -0
  29. package/web-ui/midsomar_logo 3.png +0 -0
  30. package/web-ui/midsomar_white 2.png +0 -0
  31. package/web-ui/midsomar_white 3.png +0 -0
  32. package/web-ui/oc-theme-preload 2.js +40 -0
  33. package/web-ui/oc-theme-preload 3.js +40 -0
  34. package/web-ui/site 2.webmanifest +24 -0
  35. package/web-ui/site 3.webmanifest +24 -0
  36. package/web-ui/social-share 2.png +0 -0
  37. package/web-ui/social-share 3.png +0 -0
  38. package/web-ui/social-share-zen 2.png +0 -0
  39. package/web-ui/social-share-zen 3.png +0 -0
  40. package/web-ui/web-app-manifest-192x192 2.png +0 -0
  41. package/web-ui/web-app-manifest-192x192 3.png +0 -0
  42. package/web-ui/web-app-manifest-512x512 2.png +0 -0
  43. package/web-ui/web-app-manifest-512x512 3.png +0 -0
@@ -1155,14 +1155,14 @@ $$`:`${e}$$`},IHe=e=>_He(e)%2===0?e:EHe(e),DHe=e=>THe(e)%2===1?`${e}$`:e,LHe=(e,
1155
1155
  `&&(t+=1,t>=QKe))return!0;return!1}function eGe(e){return e.includes("\r")?e.replace(/\r\n?/g,`
1156
1156
  `):e}function tGe(e){return JKe(e)||e.includes(`
1157
1157
  `)||e.includes("\r")?"manual":"native"}function nGe(e,t){return new Promise(n=>{const r=new FileReader;r.addEventListener("error",()=>n("")),r.addEventListener("load",()=>{const i=typeof r.result=="string"?r.result:"",s=i.indexOf(",");if(s===-1){n(i);return}n(`data:${t};base64,${i.slice(s+1)}`)}),r.readAsDataURL(e)})}function rGe(e){const t=()=>{const l=e.capture(),c=e.editor();if(c)return{prompt:l,cursor:l.cursor()??Ac(c)}},n=async(l,c=!0,u=t())=>{if(!u)return!1;const d=await YKe(l);if(!d)return c&&e.warn?.(),!1;const f=await nGe(l,d);if(!f)return!1;const m={type:"image",id:oT(),filename:l.name,sourcePath:e.getPathForFile?.(l)||void 0,mime:d,dataUrl:f};return u.prompt.set([...u.prompt.current(),m],u.cursor),!0},r=l=>n(l),i=async(l,c=!0,u=t())=>{let d=!1;for(const f of l)await n(f,!1,u)&&(d=!0);return!d&&l.length>0&&c&&e.warn?.(),d},s=async(l,c=t())=>{const u=await l;return u?n(u,!0,c):!1};return{addAttachment:r,addAttachments:i,addClipboardAttachment:s,removeAttachment:l=>{const c=e.capture(),d=c.current().filter(f=>f.type!=="image"||f.id!==l);c.set(d,c.cursor())},handlePaste:async l=>{const c=l.clipboardData;if(!c)return;const u=t();if(!u)return;l.preventDefault(),l.stopPropagation();const d=Array.from(c.items).flatMap(y=>{if(y.kind!=="file")return[];const v=y.getAsFile();return v?[v]:[]});if(d.length>0){await i(d,!0,u);return}const f=c.getData("text/plain")??"";if(e.readClipboardImage&&!f&&await s(e.readClipboardImage(),u)||!f)return;const m=eGe(f),g=()=>e.addPart?.({type:"text",content:m,start:0,end:0})?!0:(e.focusEditor?.(),e.addPart?.({type:"text",content:m,start:0,end:0})??!1);if(tGe(m)==="manual"){g();return}typeof document.execCommand=="function"&&document.execCommand("insertText",!1,m)||g()}}}function iGe(e){const t=wt(),n=rGe({...e,capture:e.prompt.capture,warn:()=>{tn({title:t.t("prompt.toast.pasteUnsupported.title"),description:t.t("prompt.toast.pasteUnsupported.description")})}}),r=o=>{if(e.isDialogActive())return;o.preventDefault();const a=o.dataTransfer?.types.includes("Files"),l=o.dataTransfer?.types.includes("text/plain");a?e.setDraggingType("image"):l&&e.setDraggingType("@mention")},i=o=>{e.isDialogActive()||o.relatedTarget||e.setDraggingType(null)},s=async o=>{if(e.isDialogActive())return;o.preventDefault(),e.setDraggingType(null);const a=o.dataTransfer?.getData("text/plain"),l="file:";if(a?.startsWith(l)){const u=a.slice(l.length);e.focusEditor(),e.addPart({type:"file",path:u,content:"@"+u,start:0,end:0});return}const c=o.dataTransfer?.files;c&&await n.addAttachments(Array.from(c))};return sn(()=>{an(document,"dragover",r),an(document,"dragleave",i),an(document,"drop",s)}),n}const sGe=[{type:"text",content:"",start:0,end:0}],oGe=100;function aGe(e,t,n,r=!1){const i=Math.max(0,Math.min(n,t.length)),s=i===0,o=i===t.length;return r?s||o:e==="up"?i===0&&t.length===0:i===t.length}function Vx(e){return e.map(t=>t.type==="text"?{...t}:t.type==="image"?{...t}:t.type==="agent"?{...t}:{...t,selection:t.selection?{...t.selection}:void 0})}function lGe(e){return{start:e.start,end:e.end,...e.side?{side:e.side}:{},...e.endSide?{endSide:e.endSide}:{}}}function II(e){return e.map(t=>({...t,selection:lGe(t.selection)}))}function Gm(e){return Array.isArray(e)?{prompt:Vx(e),comments:[]}:{prompt:Vx(e.prompt),comments:II(e.comments)}}function Ho(e){return e.reduce((t,n)=>t+("content"in n?n.content.length:0),0)}function cGe(e,t,n=[],r=oGe){const i=t.map(c=>"content"in c?c.content:"").join("").trim(),s=t.some(c=>c.type==="image"),o=n.some(c=>!!c.comment.trim());if(!i&&!s&&!o)return e;const a={prompt:Vx(t),comments:II(n)},l=e[0];return l&&dGe(l,a)?e:[a,...e].slice(0,r)}function uGe(e,t){return e.path===t.path&&e.comment===t.comment&&e.origin===t.origin&&e.preview===t.preview&&e.selection.start===t.selection.start&&e.selection.end===t.selection.end&&e.selection.side===t.selection.side&&e.selection.endSide===t.selection.endSide}function dGe(e,t){const n=Gm(e),r=Gm(t);if(n.prompt.length!==r.prompt.length)return!1;for(let i=0;i<n.prompt.length;i++){const s=n.prompt[i],o=r.prompt[i];if(s.type!==o.type||s.type==="text"&&s.content!==(o.type==="text"?o.content:""))return!1;if(s.type==="file"){if(s.path!==(o.type==="file"?o.path:""))return!1;const a=s.selection,l=o.type==="file"?o.selection:void 0;if(!(!a&&!l||!!a&&!!l&&a.startLine===l.startLine&&a.startChar===l.startChar&&a.endLine===l.endLine&&a.endChar===l.endChar))return!1}if(s.type==="agent"&&s.name!==(o.type==="agent"?o.name:"")||s.type==="image"&&s.id!==(o.type==="image"?o.id:""))return!1}if(n.comments.length!==r.comments.length)return!1;for(let i=0;i<n.comments.length;i++){const s=n.comments[i],o=r.comments[i];if(!s||!o||!uGe(s,o))return!1}return!0}function fGe(e){if(e.direction==="up"){if(e.entries.length===0)return{handled:!1,historyIndex:e.historyIndex,savedPrompt:e.savedPrompt};if(e.historyIndex===-1){const t=Gm(e.entries[0]);return{handled:!0,historyIndex:0,savedPrompt:{prompt:Vx(e.currentPrompt),comments:II(e.currentComments)},entry:t,cursor:"start"}}if(e.historyIndex<e.entries.length-1){const t=e.historyIndex+1,n=Gm(e.entries[t]);return{handled:!0,historyIndex:t,savedPrompt:e.savedPrompt,entry:n,cursor:"start"}}return{handled:!1,historyIndex:e.historyIndex,savedPrompt:e.savedPrompt}}if(e.historyIndex>0){const t=e.historyIndex-1,n=Gm(e.entries[t]);return{handled:!0,historyIndex:t,savedPrompt:e.savedPrompt,entry:n,cursor:"end"}}return e.historyIndex===0?e.savedPrompt?{handled:!0,historyIndex:-1,savedPrompt:null,entry:e.savedPrompt,cursor:"end"}:{handled:!0,historyIndex:-1,savedPrompt:null,entry:{prompt:sGe,comments:[]},cursor:"end"}:{handled:!1,historyIndex:e.historyIndex,savedPrompt:e.savedPrompt}}function hGe(e,t,n,r){return{entries:i=>i==="shell"?n.entries:e.entries,add(i,s,o){const a=s==="shell"?n:e,l=s==="shell"?r:t,c=cGe(a.entries,i,o);c!==a.entries&&l("entries",c)}}}function ine(){const[e,t]=_r(Jn.global("prompt-history",["prompt-history.v1"]),Ze({entries:[]})),[n,r]=_r(Jn.global("prompt-history-shell",["prompt-history-shell.v1"]),Ze({entries:[]}));return hGe(e,t,n,r)}const AC={session:"ses",message:"msg",permission:"per",user:"usr",part:"prt",pty:"pty"},mGe=26;let PF=0,YS=0;var wo;(e=>{function t(r,i){return OF(r,!1,i)}e.ascending=t;function n(r,i){return OF(r,!0,i)}e.descending=n})(wo||(wo={}));function OF(e,t,n){if(!n)return gGe(e,t);if(!n.startsWith(AC[e]))throw new Error(`ID ${n} does not start with ${AC[e]}`);return n}function gGe(e,t,n){const r=Date.now();r!==PF&&(PF=r,YS=0),YS+=1;let i=BigInt(r)*BigInt(4096)+BigInt(YS);t&&(i=~i);const s=new Uint8Array(6);for(let o=0;o<6;o+=1)s[o]=Number(i>>BigInt(40-8*o)&BigInt(255));return AC[e]+"_"+pGe(s)+vGe(mGe-12)}function pGe(e){let t="";for(let n=0;n<e.length;n+=1)t+=e[n].toString(16).padStart(2,"0");return t}function vGe(e){const t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",n=yGe(e);let r="";for(let i=0;i<e;i+=1)r+=t[n[i]%62];return r}function yGe(e){const t=new Uint8Array(e),n=typeof globalThis<"u"?globalThis.crypto:void 0;if(n&&typeof n.getRandomValues=="function")return n.getRandomValues(t),t;for(let r=0;r<e;r+=1)t[r]=Math.floor(Math.random()*256);return t}function bGe(e){if(!e||typeof e!="object")return;const t=Number(e.startLine),n=Number(e.startChar),r=Number(e.endLine),i=Number(e.endChar);if([t,n,r,i].every(Number.isFinite))return{startLine:t,startChar:n,endLine:r,endChar:i}}function wGe(e){return{opencodeComment:{path:e.path,selection:e.selection,comment:e.comment,preview:e.preview,origin:e.origin}}}function xGe(e){if(!e||typeof e!="object")return;const t=e.opencodeComment;if(!t||typeof t!="object")return;const n=t.path,r=t.comment;if(typeof n!="string"||typeof r!="string")return;const i=t.preview,s=t.origin;return{path:n,selection:bGe(t.selection),comment:r,preview:typeof i=="string"?i:void 0,origin:s==="review"||s==="file"?s:void 0}}function kGe(e){const t=e.selection?Math.min(e.selection.startLine,e.selection.endLine):void 0,n=e.selection?Math.max(e.selection.startLine,e.selection.endLine):void 0;return`The user made the following comment regarding ${t===void 0||n===void 0?"this file":t===n?`line ${t}`:`lines ${t} through ${n}`} of ${e.path}: ${e.comment}`}function SGe(e){const t=e.match(/^The user made the following comment regarding (this file|line (\d+)|lines (\d+) through (\d+)) of (.+?): ([\s\S]+)$/);if(!t)return;const n=t[2]?Number(t[2]):t[3]?Number(t[3]):void 0,r=t[2]?Number(t[2]):t[4]?Number(t[4]):void 0;return{path:t[5],selection:n!==void 0&&r!==void 0?{startLine:n,startChar:0,endLine:r,endChar:0}:void 0,comment:t[6]}}const XS=(e,t)=>t.startsWith("/")||/^[A-Za-z]:[\\/]/.test(t)||/^[A-Za-z]:$/.test(t)||t.startsWith("\\\\")||t.startsWith("//")?t:`${e.replace(/[\\/]+$/,"")}/${t}`,RF=e=>e?`?start=${e.startLine}&end=${e.endLine}`:"",CGe=/(^|[\s([{"'])@(\S+)/g,_Ge=e=>Array.from(e.matchAll(CGe)).flatMap(t=>{const n=(t[2]??"").replace(/[.,!?;:)}\]"']+$/,"");return n?[n]:[]}),TGe=e=>e.type==="file",EGe=e=>e.type==="agent",IGe=(e,t,n)=>e.type==="text"?{id:e.id,type:"text",text:e.text,synthetic:e.synthetic,ignored:e.ignored,time:e.time,metadata:e.metadata,sessionID:t,messageID:n}:e.type==="file"?{id:e.id,type:"file",mime:e.mime,filename:e.filename,url:e.url,source:e.source,sessionID:t,messageID:n}:{id:e.id,type:"agent",name:e.name,source:e.source,sessionID:t,messageID:n};function DGe(e){const t=e.text.trim()?[{id:wo.ascending("part"),type:"text",text:e.text}]:[],n=e.prompt.filter(TGe).map(a=>{const l=XS(e.sessionDirectory,a.path),c=a.source?{...a.source,text:{value:a.content,start:a.start,end:a.end}}:{type:"file",text:{value:a.content,start:a.start,end:a.end},path:l};return{id:wo.ascending("part"),type:"file",mime:a.mime??"text/plain",url:a.url??`file://${Up(l)}${RF(a.selection)}`,filename:a.filename??fn(a.path),source:c}}),r=e.prompt.filter(EGe).map(a=>({id:wo.ascending("part"),type:"agent",name:a.name,source:{value:a.content,start:a.start,end:a.end}})),i=new Set(n.map(a=>a.url)),s=e.context.flatMap(a=>{const l=XS(e.sessionDirectory,a.path),c=`file://${Up(l)}${RF(a.selection)}`,u=a.comment?.trim();if(!u&&i.has(c))return[];i.add(c);const d={id:wo.ascending("part"),type:"file",mime:"text/plain",url:c,filename:fn(a.path)};if(!u)return[d];const f=_Ge(u).flatMap(m=>{const g=`file://${Up(XS(e.sessionDirectory,m))}`;return i.has(g)?[]:(i.add(g),[{id:wo.ascending("part"),type:"file",mime:"text/plain",url:g,filename:fn(m)}])});return[{id:wo.ascending("part"),type:"text",text:kGe({path:a.path,selection:a.selection,comment:u}),synthetic:!0,metadata:wGe({path:a.path,selection:a.selection,comment:u,preview:a.preview,origin:a.commentOrigin})},d,...f]}),o=e.images.map(a=>({id:wo.ascending("part"),type:"file",mime:a.mime,url:a.dataUrl,filename:a.sourcePath??a.filename}));return t.push(...n,...s,...r,...o),{requestParts:t,optimisticParts:t.map(a=>IGe(a,e.sessionID,e.messageID))}}function LGe(e){const t=e.target;let n=e.target,r;return{prompt:e.prompt,context:e.context,target:()=>n,clear(){t!==n&&t.reset(),n.reset(),r=n.current()},retarget(i){e.context.forEach(i.context.add),n=i},current:i=>n===i,restore(){if(!(r!==void 0&&n.current()!==r))return{target:n,prompt:e.prompt,context:e.context}}}}CW.check($ke(0));CW.check(Pke(0));Ad.pipe(Og("RelativePath"));const MC=Ad.pipe(Og("AbsolutePath")),sne=e=>wW(e).pipe(q4(Ske(Cke(e)),{decode:Hw(),encode:BU(p2e(t=>t!==void 0))})),DI=e=>t=>Object.assign(t,e(t));Vke.pipe(q4(zke,{decode:rc(e=>Qxe(e)),encode:rc(e=>n4e(e))}));const AGe=26,MGe="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";let FF=0,QS=0;function one(){return $Ge()}function $Ge(e,t=Date.now()){t!==FF&&(FF=t,QS=0),QS++;const r=BigInt(t)*0x1000n+BigInt(QS),i=Array.from({length:6},(o,a)=>Number(r>>BigInt(40-8*a)&0xffn).toString(16).padStart(2,"0")).join(""),s=crypto.getRandomValues(new Uint8Array(AGe-12));return i+Array.from(s,o=>MGe[o%62]).join("")}const PGe=Ad.pipe(Og("Project.ID"),DI(e=>({global:e.make("global")}))),ane=Ad.check(SW("wrk")).pipe(Og("WorkspaceV2.ID"),DI(e=>{const t=()=>e.make("wrk_"+one());return{ascending:n=>{if(!n)return t();if(!n.startsWith("wrk"))throw new Error(`ID ${n} does not start with wrk`);return e.make(n)},create:t}}));K9({directory:MC,workspaceID:sne(ane)}).annotate({identifier:"Location.Ref"});class Qut extends Uke("Location.Info")({directory:MC,workspaceID:sne(ane),project:K9({id:PGe,directory:MC})}){}const OGe=Ad.check(SW("evt_")).pipe(Og("Event.ID"),DI(e=>({create:()=>e.make("evt_"+one())}))),H0=new Map,RGe=e=>e.map(t=>"content"in t?t.content:"").join(""),FGe=e=>e.filter(t=>t.type==="image");async function lne(e){const t=RGe(e.draft.prompt),n=FGe(e.draft.prompt),r=()=>{e.optimisticBusy&&e.serverSync.session.set("session_status",e.draft.sessionID,{type:"busy"})},i=()=>{e.optimisticBusy&&e.serverSync.session.set("session_status",e.draft.sessionID,{type:"idle"})},s=async()=>await e.before?.()!==!1,[o,...a]=t.split(" "),l=o?.startsWith("/")?o.slice(1):void 0;if(l&&e.sync.data.command.find(p=>p.name===l)){r();try{if(!await s())return i(),!1;const p=wo.ascending("message");return await e.api.command({sessionID:e.draft.sessionID,id:p,command:l,arguments:a.join(" "),agent:e.draft.agent,model:{id:e.draft.model.modelID,providerID:e.draft.model.providerID,variant:e.draft.variant},files:n.map(y=>({uri:y.dataUrl,name:y.filename}))}),!0}catch(p){throw i(),p}}const c=e.messageID??wo.ascending("message"),{requestParts:u,optimisticParts:d}=DGe({prompt:e.draft.prompt,context:e.draft.context,images:n,text:t,sessionID:e.draft.sessionID,messageID:c,sessionDirectory:e.draft.sessionDirectory}),f={id:c,sessionID:e.draft.sessionID,role:"user",time:{created:Date.now()},agent:e.draft.agent,model:{...e.draft.model,variant:e.draft.variant}},m=()=>e.sync.session.optimistic.add({directory:e.draft.sessionDirectory,sessionID:e.draft.sessionID,message:f,parts:d}),g=()=>e.sync.session.optimistic.remove({directory:e.draft.sessionDirectory,sessionID:e.draft.sessionID,messageID:c});qt(()=>{r(),m()});try{return await s()?(await e.api.prompt({sessionID:e.draft.sessionID,id:c,agent:e.draft.agent,model:e.draft.model,variant:e.draft.variant,legacyParts:u,text:u.flatMap(p=>p.type==="text"?[p.text]:[]).join(`
1158
- `),files:u.flatMap(p=>{if(p.type!=="file")return[];const y=p.source?.text;return[{uri:p.url,name:p.filename,mention:y?{start:y.start,end:y.end,text:y.value}:void 0}]}),agents:u.flatMap(p=>p.type==="agent"?[{name:p.name,mention:p.source?{start:p.source.start,end:p.source.end,text:p.source.value}:void 0}]:[])}),!0):(qt(()=>{i(),g()}),!1)}catch(p){throw qt(()=>{i(),g()}),p}}function cne(e){const t=fs(),n=kr(),r=Ji(),i=Di(),s=El(),o=mu(),a=e.prompt,l=li(),c=wt(),u=Br(),[d]=Id(),f=ks(),m=x=>fc.from(n().scope,x),g=x=>{if(x&&typeof x=="object"&&"message"in x&&typeof x.message=="string")return x.message;if(x&&typeof x=="object"&&"data"in x){const k=x.data;if(k?.message)return k.message}return x instanceof Error?x.message:c.t("common.requestFailed")},p=async()=>{const x=u.id;if(!x)return Promise.resolve();i().session.set("todo",x,[]),e.onAbort?.();const k=m(x),C=H0.get(k);return C?(C.abort.abort(),C.cleanup(),H0.delete(k),Promise.resolve()):n().api.session.interrupt({sessionID:x}).catch(()=>{})},y=(x,k)=>{for(const C of k)x.context.add({type:"file",path:C.path,selection:C.selection,comment:C.comment,commentID:C.commentID,commentOrigin:C.commentOrigin,preview:C.preview})},v=x=>{for(const k of x.context.items())x.context.remove(k.key)},b=(x,k)=>{i().session.remember(k);const[,C]=i().child(x);C("session",E=>{const _=Kn.search(E,k.id,O=>O.id),L=[...E];return _.found?(L[_.index]=k,L):(L.splice(_.index,0,k),L)})};return{abort:p,handleSubmit:async x=>{x.preventDefault();const k=a.capture(),C=LGe({target:k,prompt:k.current(),context:k.context.items().slice()}),E=C.prompt,_=C.context,L=E.map(de=>"content"in de?de.content:"").join(""),O=e.imageAttachments().slice(),$=e.mode();if(L.trim().length===0&&O.length===0&&e.commentCount()===0){e.working()&&p();return}const V=e.model??s.model,P=V.current(),T=s.agent.current(),D=V.variant.current();if(!P||!T){tn({title:c.t("prompt.toast.modelAgentRequired.title"),description:c.t("prompt.toast.modelAgentRequired.description")});return}e.addToHistory(E,$),e.resetHistoryNavigation();const N=n().directory,M=o.currentServerState(),F=!u.id,j=F&&e.autoAccept(),z=e.newSessionWorktree?.()||"main";let W=N,J=n().client;if(F){if(z==="create"){const de=await J.worktree.create({directory:N}).then(U=>U.data).catch(U=>{tn({title:c.t("prompt.toast.worktreeCreateFailed.title"),description:g(U)})});if(!de?.directory){tn({title:c.t("prompt.toast.worktreeCreateFailed.title"),description:c.t("common.requestFailed")});return}Sf.pending(n().scope,de.directory),W=de.directory}z!=="main"&&z!=="create"&&(W=z),W!==N&&(J=n().createClient({directory:W,throwOnError:!0}),i().child(W)),e.onNewSessionWorktreeReset?.()}let K=e.info();if(!K&&F){const de=await n().api.session.create({agent:T.name,model:{id:P.id,providerID:P.provider.id,variant:D},location:{directory:W}}).then(hh).catch(U=>{tn({title:c.t("prompt.toast.sessionCreateFailed.title"),description:g(U)})});de&&(b(W,de),K=de,await Zs(()=>{if(!K)return;j&&M.enableAutoAccept(K.id,W),s.session.promote(W,K.id,{agent:T.name,model:{providerID:P.provider.id,modelID:P.id},variant:D??null}),l.handoff.setTabs(yn(W),K.id);const U=d.draftId;U?f.promoteDraft(U,{server:f.draft(U).server,sessionId:K.id}):t(`/${yn(W)}/session/${K.id}`),C.retarget(a.capture({dir:yn(W),id:K.id}))}))}if(!K){tn({title:c.t("prompt.toast.promptSendFailed.title"),description:c.t("prompt.toast.promptSendFailed.description")});return}const X={modelID:P.id,providerID:P.provider.id},te=T.name,ve={sessionID:K.id,sessionDirectory:W,prompt:E,context:_,agent:te,model:X,variant:D},ne=()=>{C.clear(),e.setMode("normal"),e.setPopover(null)},ie=()=>{const de=C.restore();return de?(de.target.set(de.prompt,e.promptLength(de.prompt)),C.current(a.capture())&&(e.setMode($),e.setPopover(null),requestAnimationFrame(()=>{const U=e.editor();U&&(U.focus(),rl(U,e.promptLength(E)),e.queueScroll())})),!0):!1};if(!F&&$==="normal"&&e.shouldQueue?.()){e.onQueue?.(ve),v(C.target()),ne();return}if(e.onSubmit?.(),$==="shell"){ne();const de=OGe.create();n().api.session.shell({sessionID:K.id,id:de,command:L,agent:te,model:X}).catch(U=>{tn({title:c.t("prompt.toast.shellSendFailed.title"),description:g(U)}),ie()});return}if(L.startsWith("/")){const[de,...U]=L.split(" "),He=de.slice(1);if(r().data.command.find(Z=>Z.name===He)){ne();const Z=wo.ascending("message");i().session.set("session_status",K.id,{type:"busy"}),n().api.session.command({sessionID:K.id,id:Z,command:He,arguments:U.join(" "),agent:te,model:{id:X.modelID,providerID:X.providerID,variant:D},files:O.map(ce=>({uri:ce.dataUrl,name:ce.filename}))}).catch(ce=>{i().session.set("session_status",K.id,{type:"idle"}),tn({title:c.t("prompt.toast.commandSendFailed.title"),description:Uf(ce,c.t,c.t("common.requestFailed"))}),ie()});return}}const ke=_.filter(de=>de.type==="file"&&!!de.comment?.trim()),ge=wo.ascending("message"),Pe=()=>{r().session.optimistic.remove({directory:W,sessionID:K.id,messageID:ge})};for(const de of ke)C.target().context.remove(de.key);ne();const Me=async()=>{const de=Sf.get(n().scope,W);if(!de||de.status!=="pending")return!0;W===N&&r().set("session_status",K.id,{type:"busy"});const U=new AbortController,He=()=>{W===N&&r().set("session_status",K.id,{type:"idle"}),Pe(),ie()&&y(C.target(),ke)};H0.set(m(K.id),{abort:U,cleanup:He});const Ue=new Promise(xe=>{if(U.signal.aborted){xe({status:"failed",message:"aborted"});return}U.signal.addEventListener("abort",()=>{xe({status:"failed",message:"aborted"})},{once:!0})}),Z=300*1e3,ce={id:void 0},G=new Promise(xe=>{ce.id=window.setTimeout(()=>{xe({status:"failed",message:c.t("workspace.error.stillPreparing")})},Z)}),fe=await Promise.race([Sf.wait(n().scope,W),Ue,G]).finally(()=>{ce.id!==void 0&&clearTimeout(ce.id)});if(H0.delete(m(K.id)),U.signal.aborted)return!1;if(fe.status==="failed")throw new Error(fe.message);return!0};lne({api:n().api.session,sync:r(),serverSync:i(),draft:ve,messageID:ge,optimisticBusy:W===N,before:Me}).catch(de=>{H0.delete(m(K.id)),W===N&&r().set("session_status",K.id,{type:"idle"}),tn({title:c.t("prompt.toast.promptSendFailed.title"),description:g(de)}),Pe(),ie()&&y(C.target(),ke)})}}}var NGe=A('<div class="px-2 py-1"><input placeholder=/ class="w-full bg-transparent outline-none text-[13px] leading-5 text-v2-text-text-base placeholder:text-v2-text-text-faint">'),VGe=A('<div class="absolute inset-x-0 -top-2 -translate-y-full origin-bottom-left max-h-80 min-h-10 overflow-auto no-scrollbar flex flex-col p-2">'),NF=A('<div class="px-2 py-1">'),zGe=A('<button class="w-full flex items-center gap-x-2 px-2 py-0.5"><span class=whitespace-nowrap>@'),HGe=A('<button class="w-full flex items-center gap-x-2 px-2 py-0.5"><div class="flex items-center min-w-0"><span class="text-text-strong whitespace-nowrap">@'),jGe=A('<span class="whitespace-nowrap truncate min-w-0 ml-2">'),qGe=A('<button class="w-full flex items-center gap-x-2 px-2 py-0.5"><div class="flex items-center min-w-0"><span class="text-text-strong whitespace-nowrap">@</span><span class="whitespace-nowrap truncate min-w-0 ml-2">'),BGe=A("<span class=whitespace-nowrap>"),UGe=A('<button class="w-full flex items-center gap-x-2 px-2 py-0.5"><div class="flex items-center min-w-0"><span class="whitespace-nowrap truncate min-w-0">'),WGe=A("<span class=truncate>"),KGe=A('<button><div class="flex items-center gap-2 min-w-0"><span class=whitespace-nowrap>/</span></div><div class="flex items-center gap-2 shrink-0">'),GGe=A('<span class="text-11-regular px-1.5 py-0.5 rounded bg-surface-base text-text-subtle">'),ZGe=A('<span class="text-12-regular text-text-subtle">');const YGe=e=>h(q,{get when(){return e.popover},get children(){var t=VGe();return t.$$mousedown=n=>n.preventDefault(),pt(n=>{e.popover==="slash"&&e.setSlashPopoverRef(n)},t),S(t,h(Rr,{get children(){return[h(zt,{get when(){return e.popover==="at"},get children(){return h(q,{get when(){return e.atFlat.length>0},get fallback(){return(()=>{var n=NF();return S(n,()=>e.t("prompt.popover.emptyResults")),he(r=>{var i=!!e.newLayoutDesigns,s=!e.newLayoutDesigns;return i!==r.e&&n.classList.toggle("text-v2-text-text-muted",r.e=i),s!==r.t&&n.classList.toggle("text-text-weak",r.t=s),r},{e:void 0,t:void 0}),n})()},get children(){return h(Dt,{get each(){return e.atFlat.slice(0,10)},children:n=>{const r=e.atKey(n);if(n.type==="agent")return(()=>{var a=zGe(),l=a.firstChild;return l.firstChild,a.$$pointermove=()=>e.setAtActive(r),a.$$click=()=>e.onAtSelect(n),S(a,h(Yt,{name:"brain",size:"small",class:"text-icon-info-active shrink-0"}),l),S(l,()=>n.name,null),he(c=>{var u=!!e.newLayoutDesigns,d=!e.newLayoutDesigns,f=!!(e.newLayoutDesigns&&e.atActive===r),m=!e.newLayoutDesigns&&e.atActive===r,g={"text-[13px] leading-[calc(var(--font-size-base)*1.8)] tracking-[-0.04px] [font-weight:440]":e.newLayoutDesigns,"text-v2-text-text-base":e.newLayoutDesigns,"text-14-regular":!e.newLayoutDesigns,"text-text-strong":!e.newLayoutDesigns};return u!==c.e&&a.classList.toggle("rounded-[4px]",c.e=u),d!==c.t&&a.classList.toggle("rounded-md",c.t=d),f!==c.a&&a.classList.toggle("bg-v2-overlay-simple-overlay-hover",c.a=f),m!==c.o&&a.classList.toggle("bg-surface-raised-base-hover",c.o=m),c.i=ct(l,g,c.i),c},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),a})();if(n.type==="resource")return(()=>{var a=HGe(),l=a.firstChild,c=l.firstChild;return c.firstChild,a.$$pointermove=()=>e.setAtActive(r),a.$$click=()=>e.onAtSelect(n),S(a,h(Dr,{get node(){return{path:n.uri,type:"file"}},class:"shrink-0 size-4"}),l),S(c,()=>n.name,null),S(l,h(q,{get when(){return n.description},children:u=>(()=>{var d=jGe();return S(d,u),he(f=>{var m=!!e.newLayoutDesigns,g=!e.newLayoutDesigns;return m!==f.e&&d.classList.toggle("text-v2-text-text-muted",f.e=m),g!==f.t&&d.classList.toggle("text-text-weak",f.t=g),f},{e:void 0,t:void 0}),d})()}),null),he(u=>{var d=!!e.newLayoutDesigns,f=!e.newLayoutDesigns,m=!!(e.newLayoutDesigns&&e.atActive===r),g=!e.newLayoutDesigns&&e.atActive===r,p={"text-[13px] leading-[calc(var(--font-size-base)*1.8)] tracking-[-0.04px] [font-weight:440]":e.newLayoutDesigns,"text-14-regular":!e.newLayoutDesigns},y=!!e.newLayoutDesigns;return d!==u.e&&a.classList.toggle("rounded-[4px]",u.e=d),f!==u.t&&a.classList.toggle("rounded-md",u.t=f),m!==u.a&&a.classList.toggle("bg-v2-overlay-simple-overlay-hover",u.a=m),g!==u.o&&a.classList.toggle("bg-surface-raised-base-hover",u.o=g),u.i=ct(l,p,u.i),y!==u.n&&c.classList.toggle("text-v2-text-text-base",u.n=y),u},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),a})();if(n.type==="reference")return(()=>{var a=qGe(),l=a.firstChild,c=l.firstChild;c.firstChild;var u=c.nextSibling;return a.$$pointermove=()=>e.setAtActive(r),a.$$click=()=>e.onAtSelect(n),S(a,h(Dr,{get node(){return{path:n.path,type:"directory"}},class:"shrink-0 size-4"}),l),S(c,()=>n.name,null),S(u,()=>n.description),he(d=>{var f=!!e.newLayoutDesigns,m=!e.newLayoutDesigns,g=!!(e.newLayoutDesigns&&e.atActive===r),p=!e.newLayoutDesigns&&e.atActive===r,y={"text-[13px] leading-[calc(var(--font-size-base)*1.8)] tracking-[-0.04px] [font-weight:440]":e.newLayoutDesigns,"text-14-regular":!e.newLayoutDesigns},v=!!e.newLayoutDesigns,b=!!e.newLayoutDesigns,w=!e.newLayoutDesigns;return f!==d.e&&a.classList.toggle("rounded-[4px]",d.e=f),m!==d.t&&a.classList.toggle("rounded-md",d.t=m),g!==d.a&&a.classList.toggle("bg-v2-overlay-simple-overlay-hover",d.a=g),p!==d.o&&a.classList.toggle("bg-surface-raised-base-hover",d.o=p),d.i=ct(l,y,d.i),v!==d.n&&c.classList.toggle("text-v2-text-text-base",d.n=v),b!==d.s&&u.classList.toggle("text-v2-text-text-muted",d.s=b),w!==d.h&&u.classList.toggle("text-text-weak",d.h=w),d},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0}),a})();const i=n.path.endsWith("/"),s=i?n.path:hc(n.path),o=i?"":fn(n.path);return(()=>{var a=UGe(),l=a.firstChild,c=l.firstChild;return a.$$pointermove=()=>e.setAtActive(r),a.$$click=()=>e.onAtSelect(n),S(a,h(Dr,{get node(){return{path:n.path,type:"file"}},class:"shrink-0 size-4"}),l),S(c,s),S(l,h(q,{when:!i,get children(){var u=BGe();return S(u,o),he(d=>{var f=!!e.newLayoutDesigns,m=!e.newLayoutDesigns;return f!==d.e&&u.classList.toggle("text-v2-text-text-base",d.e=f),m!==d.t&&u.classList.toggle("text-text-strong",d.t=m),d},{e:void 0,t:void 0}),u}}),null),he(u=>{var d=!!e.newLayoutDesigns,f=!e.newLayoutDesigns,m=!!(e.newLayoutDesigns&&e.atActive===r),g=!e.newLayoutDesigns&&e.atActive===r,p={"text-[13px] leading-[calc(var(--font-size-base)*1.8)] tracking-[-0.04px] [font-weight:440]":e.newLayoutDesigns,"text-14-regular":!e.newLayoutDesigns},y=!!e.newLayoutDesigns,v=!e.newLayoutDesigns;return d!==u.e&&a.classList.toggle("rounded-[4px]",u.e=d),f!==u.t&&a.classList.toggle("rounded-md",u.t=f),m!==u.a&&a.classList.toggle("bg-v2-overlay-simple-overlay-hover",u.a=m),g!==u.o&&a.classList.toggle("bg-surface-raised-base-hover",u.o=g),u.i=ct(l,p,u.i),y!==u.n&&c.classList.toggle("text-v2-text-text-muted",u.n=y),v!==u.s&&c.classList.toggle("text-text-weak",u.s=v),u},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0}),a})()}})}})}}),h(zt,{get when(){return e.popover==="slash"},get children(){return[h(q,{get when(){return e.slashMenu},get children(){var n=NGe(),r=n.firstChild;return r.$$mousedown=i=>i.stopPropagation(),cn(r,"keydown",e.onSlashMenuKeyDown,!0),r.$$input=i=>e.onSlashMenuInput(i.currentTarget.value),pt(i=>requestAnimationFrame(()=>i.focus()),r),he(()=>me(r,"aria-label",e.t("prompt.menu.commands"))),he(()=>r.value=e.slashMenuQuery),n}}),h(q,{get when(){return e.slashFlat.length>0},get fallback(){return(()=>{var n=NF();return S(n,()=>e.t("prompt.popover.emptyCommands")),he(r=>{var i=!!e.newLayoutDesigns,s=!e.newLayoutDesigns;return i!==r.e&&n.classList.toggle("text-v2-text-text-muted",r.e=i),s!==r.t&&n.classList.toggle("text-text-weak",r.t=s),r},{e:void 0,t:void 0}),n})()},get children(){return h(Dt,{get each(){return e.slashFlat},children:n=>{const r=()=>e.commandKeybind(n.id),i=()=>e.commandKeybindParts(n.id);return(()=>{var s=KGe(),o=s.firstChild,a=o.firstChild;a.firstChild;var l=o.nextSibling;return s.$$pointermove=()=>e.setSlashActive(n.id),s.$$click=()=>e.onSlashSelect(n),S(a,()=>n.trigger,null),S(o,h(q,{get when(){return n.description},get children(){var c=WGe();return S(c,()=>n.description),he(u=>ct(c,{"text-[13px] leading-[calc(var(--font-size-base)*1.8)] tracking-[-0.04px] [font-weight:440]":e.newLayoutDesigns,"text-v2-text-text-muted":e.newLayoutDesigns,"text-14-regular":!e.newLayoutDesigns,"text-text-weak":!e.newLayoutDesigns},u)),c}}),null),S(l,h(q,{get when(){return we(()=>n.type==="custom")()&&n.source!=="command"},get children(){return h(q,{get when(){return e.newLayoutDesigns},get fallback(){return(()=>{var c=GGe();return S(c,(()=>{var u=we(()=>n.source==="skill");return()=>u()?e.t("prompt.slash.badge.skill"):we(()=>n.source==="mcp")()?e.t("prompt.slash.badge.mcp"):e.t("prompt.slash.badge.custom")})()),c})()},get children(){return h(m1,{get children(){return we(()=>n.source==="skill")()?e.t("prompt.slash.badge.skill"):we(()=>n.source==="mcp")()?e.t("prompt.slash.badge.mcp"):e.t("prompt.slash.badge.custom")}})}})}}),null),S(l,h(q,{get when(){return we(()=>!!e.newLayoutDesigns)()?i().length>0:r()},get children(){return h(q,{get when(){return e.newLayoutDesigns},get fallback(){return(()=>{var c=ZGe();return S(c,r),c})()},get children(){return h(Eo,{get keys(){return i()},variant:"neutral"})}})}}),null),he(c=>{var u=n.id,d={"w-full flex items-center justify-between gap-4 px-2 py-1":!0,"rounded-[4px] scroll-my-2":e.newLayoutDesigns,"rounded-md":!e.newLayoutDesigns,"bg-v2-overlay-simple-overlay-hover":e.newLayoutDesigns&&e.slashActive===n.id,"bg-surface-raised-base-hover":!e.newLayoutDesigns&&e.slashActive===n.id},f={"text-[13px] leading-[calc(var(--font-size-base)*1.8)] tracking-[-0.04px] [font-weight:440]":e.newLayoutDesigns,"text-v2-text-text-base":e.newLayoutDesigns,"text-14-regular":!e.newLayoutDesigns,"text-text-strong":!e.newLayoutDesigns};return u!==c.e&&me(s,"data-slash-id",c.e=u),c.t=ct(s,d,c.t),c.a=ct(a,f,c.a),c},{e:void 0,t:void 0,a:void 0}),s})()}})}})]}})]}})),he(n=>ct(t,{"z-[70] rounded-[10px] bg-v2-background-bg-base shadow-[var(--v2-elevation-raised)]":e.newLayoutDesigns,"rounded-[12px] bg-surface-raised-stronger-non-alpha shadow-[var(--shadow-lg-border-base)]":!e.newLayoutDesigns},n)),t}});dn(["mousedown","input","keydown","click","pointermove"]);var XGe=A('<div class="flex flex-nowrap items-start gap-2 p-2 overflow-x-auto no-scrollbar">'),QGe=A('<div><div class="flex items-center gap-1.5"><div class="flex items-center text-[12px] min-w-0 font-medium leading-5"><span class="text-text-strong whitespace-nowrap">'),JGe=A('<span class="flex max-w-[300px]"><span></span><span class=shrink-0>'),eZe=A('<span class="text-text-weak whitespace-nowrap shrink-0">'),tZe=A('<div class="text-12-regular text-text-strong ml-5 pr-1 truncate">');const nZe=e=>h(q,{get when(){return e.items.length>0},get children(){var t=XGe();return S(t,h(Dt,{get each(){return e.items},children:n=>{const r=hc(n.path),i=fn(n.path),s=yK(n.path,14),o=e.active(n);return h(Gi,{get component(){return e.newLayoutDesigns?Qn:Ar},get value(){return(()=>{var a=JGe(),l=a.firstChild,c=l.nextSibling;return S(l,r),S(c,i),he(u=>ct(l,{"truncate-start [unicode-bidi:plaintext] min-w-0":!0,"text-v2-text-text-muted":e.newLayoutDesigns,"text-text-invert-base":!e.newLayoutDesigns},u)),a})()},placement:"top",openDelay:800,get children(){var a=QGe(),l=a.firstChild,c=l.firstChild,u=c.firstChild;return a.$$click=()=>e.openComment(n),S(l,h(Dr,{get node(){return{path:n.path,type:"file"}},class:"shrink-0 size-3.5"}),c),S(u,s),S(c,h(q,{get when(){return n.selection},children:d=>(()=>{var f=eZe();return S(f,(()=>{var m=we(()=>d().startLine===d().endLine);return()=>m()?`:${d().startLine}`:`:${d().startLine}-${d().endLine}`})()),f})()}),null),S(l,h(Ln,{type:"button",icon:"close-small",variant:"ghost",class:"ml-auto size-3.5 text-text-weak hover:text-text-strong transition-all",onClick:d=>{d.stopPropagation(),e.remove(n)},get"aria-label"(){return e.t("prompt.context.removeFile")}}),null),S(a,h(q,{get when(){return n.comment},children:d=>(()=>{var f=tZe();return S(f,d),f})()}),null),he(d=>ct(a,{"group shrink-0 flex flex-col rounded-[6px] pl-2 pr-1 py-1 max-w-[200px] h-12 cursor-default transition-all transition-transform shadow-xs-border hover:shadow-xs-border-hover":!0,"hover:bg-surface-interactive-weak":!!n.commentID&&!o,"bg-surface-interactive-hover hover:bg-surface-interactive-hover shadow-xs-border-hover":o,"bg-background-stronger":!o},d)),a}})}})),t}});dn(["click"]);var rZe=A("<div data-component=attachment-card-v2><span data-slot=attachment-card-v2-title></span><span data-slot=attachment-card-v2-subtitle>");function t3(e){return(()=>{var t=rZe(),n=t.firstChild,r=n.nextSibling;return t.$$click=()=>e.onClick?.(),pt(i=>e.titleRef?.(i),n),S(n,()=>e.title),S(r,()=>e.children),he(i=>{var s=e.active?"true":void 0,o=e.clickable?"true":void 0,a=e.wide?"true":void 0,l=e.surface,c=e.hover;return s!==i.e&&me(t,"data-active",i.e=s),o!==i.t&&me(t,"data-clickable",i.t=o),a!==i.a&&me(t,"data-wide",i.a=a),l!==i.o&&me(t,"data-surface",i.o=l),c!==i.i&&me(t,"title",i.i=c),i},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),t})()}dn(["click"]);var iZe=A("<span>");function LI(e){let t;const[n,r]=De(!1);return sn(()=>{const i=t;if(!i)return;const s=()=>r(i.scrollWidth>i.clientWidth),o=()=>requestAnimationFrame(s),a=new ResizeObserver(s);a.observe(i),o(),document.fonts?.ready.then(o),Te(()=>a.disconnect())}),h(Qn,{placement:"top",openDelay:1e3,get value(){return e.title??e.comment},get disabled(){return!e.tooltip||!n()},get class(){return e.wide?"w-full":void 0},contentStyle:{"max-width":"320px","white-space":"pre-wrap"},get children(){return h(t3,{get title(){return e.comment},get active(){return e.active},get clickable(){return!!e.onClick},get wide(){return e.wide},surface:"base",titleRef:i=>{t=i},get onClick(){return e.onClick},get children(){return[h(Dr,{get node(){return{path:e.path,type:"file"}}}),(()=>{var i=iZe();return S(i,()=>yK(e.path,14),null),S(i,h(q,{get when(){return e.selection},children:s=>s().startLine===s().endLine?`:${s().startLine}`:`:${s().startLine}-${s().endLine}`}),null),i})()]}})}})}function sZe(e){return e.url.startsWith("data:")&&!une(e)}function une(e){return e.source?.text?.start!==void 0&&e.source?.text?.end!==void 0}function oZe(e){return e.mime.startsWith("image/")?"image":"file"}const aZe=new Map(D1.flatMap(e=>[e.id,...e.aliases??[]].map(t=>[t,e.name])));function AI(e,t){if(t==="application/pdf")return"PDF";const n=fn(e),r=n.lastIndexOf("."),i=r<=0?"":n.slice(r+1).toLowerCase();return i?aZe.get(i)??i.toUpperCase():"File"}var lZe=A('<div data-slot=prompt-attachments-fade-left class="pointer-events-none absolute inset-y-0 left-0 z-10 w-6 bg-[linear-gradient(to_right,var(--v2-background-bg-base),transparent)]">'),cZe=A('<div data-slot=prompt-attachments-fade-right class="pointer-events-none absolute inset-y-0 right-0 z-10 w-6 bg-[linear-gradient(to_left,var(--v2-background-bg-base),transparent)]">'),uZe=A("<div data-slot=prompt-attachments><div data-slot=prompt-attachments-scroll>"),dZe=A('<div class="relative group shrink-0"><button type=button class="absolute -top-1 -right-1 size-4 rounded-full bg-v2-icon-icon-muted outline-solid outline-1 outline-v2-icon-icon-contrast flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity">'),fZe=A("<img>"),hZe=A('<div class="size-16 rounded-md bg-surface-base flex items-center justify-center border border-border-base">'),mZe=A('<div class="absolute bottom-0 left-0 right-0 px-1 py-0.5 bg-black/50 rounded-b-md"><span class="text-10-regular text-white truncate block">'),gZe=A("<button type=button>"),pZe=A('<div class="absolute inset-0 rounded-[6px] shadow-[inset_0_0_0_0.5px_var(--v2-border-border-base)] pointer-events-none">'),vZe=A('<div class="relative group shrink-0">'),yZe=A('<div class="relative group">');const bZe="size-16 rounded-md object-cover border border-border-base hover:border-border-strong-base transition-colors",wZe="w-[58px] h-[46px] rounded-[6px] object-cover",xZe="absolute -top-1.5 -right-1.5 size-5 rounded-full bg-surface-raised-stronger-non-alpha border border-border-base flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity hover:bg-surface-raised-base-hover",kZe="absolute -top-1 -right-1 size-4 rounded-full bg-v2-icon-icon-muted outline-solid outline-1 outline-v2-icon-icon-contrast flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",SZe=e=>h(q,{get when(){return e.attachments.length>0||e.newLayoutDesigns&&(e.comments?.length??0)>0},get children(){var t=uZe(),n=t.firstChild;return S(n,h(q,{get when(){return e.newLayoutDesigns},get children(){return h(Dt,{get each(){return e.comments??[]},children:r=>(()=>{var i=dZe(),s=i.firstChild;return S(i,h(Qn,{get value(){return r.comment},placement:"top",openDelay:800,contentClass:"max-w-[300px] break-words",get children(){return h(LI,{get comment(){return r.comment??""},get path(){return r.path},get selection(){return r.selection},get active(){return e.commentActive?.(r)},onClick:()=>e.onOpenComment?.(r)})}}),s),s.$$click=()=>e.onRemoveComment?.(r),S(s,h(on,{name:"outline-xmark",class:"text-v2-icon-icon-contrast"})),he(()=>me(s,"aria-label",e.removeLabel)),i})()})}}),null),S(n,h(Dt,{get each(){return e.attachments},children:r=>{const i=r.mime.startsWith("image/"),s=()=>h(q,{when:i,get fallback(){return h(q,{get when(){return e.newLayoutDesigns},get fallback(){return(()=>{var l=hZe();return S(l,h(Yt,{name:"folder",class:"size-6 text-text-weak"})),l})()},get children(){return h(t3,{get title(){return r.filename},get children(){return AI(r.filename,r.mime)}})}})},get children(){var l=fZe();return l.$$click=()=>e.onOpen(r),he(c=>{var u=r.dataUrl,d=r.filename,f=e.newLayoutDesigns?wZe:bZe;return u!==c.e&&me(l,"src",c.e=u),d!==c.t&&me(l,"alt",c.t=d),f!==c.a&&xr(l,c.a=f),c},{e:void 0,t:void 0,a:void 0}),l}}),o=()=>(()=>{var l=mZe(),c=l.firstChild;return S(c,()=>r.filename),l})(),a=()=>(()=>{var l=gZe();return l.$$click=()=>e.onRemove(r.id),S(l,h(q,{get when(){return e.newLayoutDesigns},get fallback(){return h(Yt,{name:"close",class:"size-3 text-text-weak"})},get children(){return h(on,{name:"outline-xmark",class:"text-v2-icon-icon-contrast"})}})),he(c=>{var u=e.newLayoutDesigns?kZe:xZe,d=e.removeLabel;return u!==c.e&&xr(l,c.e=u),d!==c.t&&me(l,"aria-label",c.t=d),c},{e:void 0,t:void 0}),l})();return h(q,{get when(){return e.newLayoutDesigns},get fallback(){return h(Ar,{get value(){return r.filename},placement:"top",contentClass:"break-all",get children(){var l=yZe();return S(l,s,null),S(l,o,null),S(l,a,null),l}})},get children(){var l=vZe();return S(l,h(Qn,{get value(){return r.filename},placement:"top",contentClass:"break-all",get children(){return[we(()=>s()),h(q,{when:i,get children(){return pZe()}})]}}),null),S(l,a,null),l}})}}),null),S(t,h(q,{get when(){return e.newLayoutDesigns},get children(){return[lZe(),cZe()]}}),null),he(r=>{var i=!!e.newLayoutDesigns,s={"flex gap-2":!0,"flex-nowrap overflow-x-auto no-scrollbar px-2 pt-2 pb-1":e.newLayoutDesigns,"flex-wrap px-3 pt-3":!e.newLayoutDesigns};return i!==r.e&&t.classList.toggle("relative",r.e=i),r.t=ct(n,s,r.t),r},{e:void 0,t:void 0}),t}});dn(["click"]);var CZe=A('<div class="absolute inset-0 z-10 flex items-center justify-center bg-surface-raised-stronger-non-alpha/90 pointer-events-none"><div class="flex flex-col items-center gap-2 text-text-weak"><span class=text-14-regular>');const VF={image:"photo","@mention":"link"},_Ze=e=>h(q,{get when(){return e.type!==null},get children(){var t=CZe(),n=t.firstChild,r=n.firstChild;return S(n,h(Yt,{get name(){return we(()=>!!e.type)()?VF[e.type]:VF.image},class:"size-8"}),r),S(r,()=>e.label),t}});function dne(e){return e.mode==="shell"?e.t("prompt.placeholder.shell",{example:e.example}):e.commentCount>1?e.t("prompt.placeholder.summarizeComments"):e.commentCount===1?e.t("prompt.placeholder.summarizeComment"):e.suggest?e.t("prompt.placeholder.normal",{example:e.example}):e.t("prompt.placeholder.simple")}function TZe(e,t){return e==="shell"?t:"Ask anything, / for commands, @ for context..."}function EZe(e){e({popover:null,slashMenu:!1,slashMenuQuery:"",historyIndex:-1,savedPrompt:null,draggingType:null,mode:"normal",applyingHistory:!1})}function IZe(e,t){const[n,r]=Ze({popover:null,slashMenu:!1,slashMenuQuery:"",historyIndex:-1,savedPrompt:null,placeholder:t,draggingType:null,mode:"normal",applyingHistory:!1});return Fs(vt(e,()=>EZe(r),{defer:!0})),[n,r]}var DZe=A("<div data-slot=image-preview-header>"),LZe=A("<div data-slot=image-preview-body><img data-slot=image-preview-image>"),AZe=A("<div data-component=image-preview><div data-slot=image-preview-container>");function MI(e){const t=Mn();return(()=>{var n=AZe(),r=n.firstChild;return S(r,h(Qs.Content,{"data-slot":"image-preview-content",get children(){return[(()=>{var i=DZe();return S(i,h(Qs.CloseButton,{"data-slot":"image-preview-close",as:Ln,icon:"close",variant:"ghost",get"aria-label"(){return t.t("ui.common.close")}})),i})(),(()=>{var i=LZe(),s=i.firstChild;return he(o=>{var a=e.src,l=e.alt??t.t("ui.imagePreview.alt");return a!==o.e&&me(s,"src",o.e=a),l!==o.t&&me(s,"alt",o.t=l),o},{e:void 0,t:void 0}),i})()]}})),n})()}var MZe=A('<div class="flex items-center gap-2"><span></span><span class="text-icon-base text-12-medium text-[10px]!">'),$Ze=A('<div class="flex items-center gap-2"><span>'),PZe=A('<div class=relative><div class="relative max-h-[240px] overflow-y-auto no-scrollbar"style=scroll-padding-bottom:56px><div data-component=prompt-input role=textbox aria-multiline=true contenteditable=true inputmode=text autocomplete=off style=padding-bottom:56px></div><div class="absolute top-0 inset-x-0 pl-3 pr-2 pt-2 text-14-regular text-text-weak pointer-events-none whitespace-nowrap truncate"style=padding-bottom:56px></div></div><div aria-hidden=true class="pointer-events-none absolute inset-x-0 bottom-0"style="height:56px;background:linear-gradient(to top, var(--surface-raised-stronger-non-alpha) calc(100% - 20px), transparent)"></div><div class="pointer-events-none absolute bottom-2 right-2 flex items-center gap-2"><input type=file multiple class=hidden><div class="flex items-center gap-1 pointer-events-auto"></div></div><div class="pointer-events-none absolute bottom-2 left-2"><div class=pointer-events-auto>'),OZe=A("<div data-component=prompt-agent-control>"),zF=A("<span class=truncate>"),RZe=A("<div data-component=prompt-model-control>"),FZe=A("<div data-component=prompt-variant-control>"),NZe=A('<div class="px-1.75 pt-5.5 pb-2 flex items-center gap-2 min-w-0"><div class="flex items-center gap-1.5 min-w-0 flex-1 relative"><div class="h-7 flex items-center gap-1.5 min-w-0 absolute inset-0"style="padding:0 0px 0 8px"><span class="truncate text-13-medium text-text-base"></span><div class=flex-1></div></div><div class="flex items-center gap-1.5 min-w-0 flex-1 h-7">'),VZe=A('<div class="relative size-full flex flex-col gap-0">');const JS=["prompt.example.1","prompt.example.2","prompt.example.3","prompt.example.4","prompt.example.5","prompt.example.6","prompt.example.7","prompt.example.8","prompt.example.9","prompt.example.10","prompt.example.11","prompt.example.12","prompt.example.13","prompt.example.14","prompt.example.15","prompt.example.16","prompt.example.17","prompt.example.18","prompt.example.19","prompt.example.20","prompt.example.21","prompt.example.22","prompt.example.23","prompt.example.24","prompt.example.25"],zZe=e=>{const t=kr(),n=Ji(),r=ua(),i=e.state??Hg(),s=li(),o=q1(),a=Mr(),l=Qi(),c=mu(),u=wt(),d=Tr(),f=()=>e.controls.session.tabs;let m,g,p,y,v=!0,b=null;const w={input:!1},x=56,k=()=>{const Y=p,Ce=window.getSelection();if(!Y||!Ce||Ce.rangeCount===0)return;const Fe=Ce.getRangeAt(0);if(!m.contains(Fe.startContainer))return;const qe=Ac(m),_t=Ho(i.current().filter(di=>di.type!=="image"));if(qe>=_t){Y.scrollTop=Y.scrollHeight;return}const Zt=Fe.getClientRects().item(0)??Fe.getBoundingClientRect();if(!Zt.height)return;const It=Y.getBoundingClientRect(),jt=Zt.top-It.top+Y.scrollTop,Pt=Zt.bottom-It.top+Y.scrollTop,Tn=12;if(jt<Y.scrollTop+Tn){Y.scrollTop=Math.max(0,jt-Tn);return}Pt>Y.scrollTop+Y.clientHeight-x&&(Y.scrollTop=Pt-Y.clientHeight+x)},C=(Y=2)=>{requestAnimationFrame(()=>{k(),Y>1&&C(Y-1)})},E=Nd({tabs:f,pathFromTab:r.pathFromTab,normalizeTab:Y=>Y.startsWith("file://")?r.tab(Y):Y}).activeFileTab,_=Y=>{const Ce=e.controls.session.id;if(!Ce)return!1;const Fe=n().data.session_diff[Ce];return Fe?Fe.some(qe=>qe.file===Y):!1},L=Y=>{if(!Y.commentID)return;const Ce={file:Y.path,id:Y.commentID};o.setActive(Ce);const Fe=(Zt=6)=>{const It=jt=>{requestAnimationFrame(()=>{o.setFocus({...Ce}),!(jt<=0)&&requestAnimationFrame(()=>{const Pt=o.focus();Pt&&(Pt.file!==Ce.file||Pt.id!==Ce.id||It(jt-1))})})};It(Zt)};if(Y.commentOrigin==="review"||Y.commentOrigin!=="file"&&_(Y.path)){e.controls.session.reviewPanel.opened()||e.controls.session.reviewPanel.open(),s.fileTree.setTab("changes"),f().setActive("review"),Fe();return}e.controls.session.reviewPanel.opened()||e.controls.session.reviewPanel.open(),s.fileTree.setTab("all");const _t=r.tab(Y.path);f().open(_t),f().setActive(_t),Promise.resolve(r.load(Y.path)).finally(()=>Fe())},O=I(()=>{const Y=f().all(),Ce=E(),Fe=Ce?[Ce,...Y.filter(Zt=>Zt!==Ce)]:Y,qe=new Set,_t=[];for(const Zt of Fe){const It=r.pathFromTab(Zt);It&&(qe.has(It)||(qe.add(It),_t.push(It)))}return _t}),$=I(()=>e.controls.session.id?n().session.get(e.controls.session.id):void 0),V=I(()=>n().data.session_working(e.controls.session.id??"")),P=I(()=>i.current().filter(Y=>Y.type==="image")),[T,D]=IZe(()=>i.capture(),Math.floor(Math.random()*JS.length)),N=vy(()=>T.mode==="normal"?1:0,{visualDuration:.2,bounce:0}),M=Y=>({opacity:Y,transform:`scale(${.98+Y*.02})`,filter:`blur(${(1-Y)*2}px)`,"pointer-events":Y>.5?"auto":"none"}),F=I(()=>M(N())),j=I(()=>M(1-N())),z=I(()=>({height:"28px",...F()})),W=I(()=>T.mode==="shell"?0:i.context.items().filter(Y=>!!Y.comment?.trim()).length),J=I(()=>i.current().map(Ce=>"content"in Ce?Ce.content:"").join("").trim().length===0&&P().length===0&&W()===0),K=I(()=>V()&&J()),X=()=>K()?(()=>{var Y=MZe(),Ce=Y.firstChild,Fe=Ce.nextSibling;return S(Ce,()=>u.t("prompt.action.stop")),S(Fe,()=>u.t("common.key.esc")),Y})():(()=>{var Y=$Ze(),Ce=Y.firstChild;return S(Ce,()=>u.t("prompt.action.send")),S(Y,h(Yt,{name:"enter",size:"small",class:"text-icon-base"}),null),Y})(),te=I(()=>{const Y=i.context.items();return T.mode!=="shell"?Y:Y.filter(Ce=>!Ce.comment?.trim())}),ve=I(()=>{const Y=e.controls.session.id;if(!Y)return!1;const Ce=n().data.message[Y];return Ce?Ce.some(Fe=>Fe.role==="user"):!1}),ne=e.history??ine(),ie=I(()=>!ve()),ke=I(()=>dne({mode:T.mode,commentCount:W(),example:ie()?T.mode==="shell"?"git status":u.t(JS[T.placeholder]):"",suggest:ie(),t:(Y,Ce)=>u.t(Y,Ce)})),ge=()=>{const Y=new Map(o.all().map(Ce=>[`${Ce.file}
1158
+ `),files:u.flatMap(p=>{if(p.type!=="file")return[];const y=p.source?.text;return[{uri:p.url,name:p.filename,mention:y?{start:y.start,end:y.end,text:y.value}:void 0}]}),agents:u.flatMap(p=>p.type==="agent"?[{name:p.name,mention:p.source?{start:p.source.start,end:p.source.end,text:p.source.value}:void 0}]:[])}),!0):(qt(()=>{i(),g()}),!1)}catch(p){throw qt(()=>{i(),g()}),p}}function cne(e){const t=fs(),n=kr(),r=Ji(),i=Di(),s=El(),o=mu(),a=e.prompt,l=li(),c=wt(),u=Br(),[d]=Id(),f=ks(),m=x=>fc.from(n().scope,x),g=x=>{if(x&&typeof x=="object"&&"message"in x&&typeof x.message=="string")return x.message;if(x&&typeof x=="object"&&"data"in x){const k=x.data;if(k?.message)return k.message}return x instanceof Error?x.message:c.t("common.requestFailed")},p=async()=>{const x=u.id;if(!x)return Promise.resolve();i().session.set("todo",x,[]),e.onAbort?.();const k=m(x),C=H0.get(k);return C?(C.abort.abort(),C.cleanup(),H0.delete(k),Promise.resolve()):n().api.session.interrupt({sessionID:x}).catch(()=>{})},y=(x,k)=>{for(const C of k)x.context.add({type:"file",path:C.path,selection:C.selection,comment:C.comment,commentID:C.commentID,commentOrigin:C.commentOrigin,preview:C.preview})},v=x=>{for(const k of x.context.items())x.context.remove(k.key)},b=(x,k)=>{i().session.remember(k);const[,C]=i().child(x);C("session",E=>{const _=Kn.search(E,k.id,O=>O.id),L=[...E];return _.found?(L[_.index]=k,L):(L.splice(_.index,0,k),L)})};return{abort:p,handleSubmit:async x=>{x.preventDefault();const k=a.capture(),C=LGe({target:k,prompt:k.current(),context:k.context.items().slice()}),E=C.prompt,_=C.context,L=E.map(de=>"content"in de?de.content:"").join(""),O=e.imageAttachments().slice(),$=e.mode();if(L.trim().length===0&&O.length===0&&e.commentCount()===0){e.working()&&p();return}const V=e.model??s.model,P=V.current(),T=s.agent.current(),D=V.variant.current();if(!P||!T){tn({title:c.t("prompt.toast.modelAgentRequired.title"),description:c.t("prompt.toast.modelAgentRequired.description")});return}e.addToHistory(E,$),e.resetHistoryNavigation();const N=n().directory,M=o.currentServerState(),F=!u.id,j=F&&e.autoAccept(),z=e.newSessionWorktree?.()||"main";let W=N,J=n().client;if(F){if(z==="create"){const de=await J.worktree.create({directory:N}).then(U=>U.data).catch(U=>{tn({title:c.t("prompt.toast.worktreeCreateFailed.title"),description:g(U)})});if(!de?.directory){tn({title:c.t("prompt.toast.worktreeCreateFailed.title"),description:c.t("common.requestFailed")});return}Sf.pending(n().scope,de.directory),W=de.directory}z!=="main"&&z!=="create"&&(W=z),W!==N&&(J=n().createClient({directory:W,throwOnError:!0}),i().child(W)),e.onNewSessionWorktreeReset?.()}let K=e.info();if(!K&&F){const de=await n().api.session.create({agent:T.name,model:{id:P.id,providerID:P.provider.id,variant:D},location:{directory:W}}).then(hh).catch(U=>{tn({title:c.t("prompt.toast.sessionCreateFailed.title"),description:g(U)})});de&&(b(W,de),K=de,await Zs(()=>{if(!K)return;j&&M.enableAutoAccept(K.id,W),s.session.promote(W,K.id,{agent:T.name,model:{providerID:P.provider.id,modelID:P.id},variant:D??null}),l.handoff.setTabs(yn(W),K.id);const U=d.draftId;U?f.promoteDraft(U,{server:f.draft(U).server,sessionId:K.id}):t(`/${yn(W)}/session/${K.id}`),C.retarget(a.capture({dir:yn(W),id:K.id}))}))}if(!K){tn({title:c.t("prompt.toast.promptSendFailed.title"),description:c.t("prompt.toast.promptSendFailed.description")});return}const X={modelID:P.id,providerID:P.provider.id},te=T.name,ve={sessionID:K.id,sessionDirectory:W,prompt:E,context:_,agent:te,model:X,variant:D},ne=()=>{C.clear(),e.setMode("normal"),e.setPopover(null)},ie=()=>{const de=C.restore();return de?(de.target.set(de.prompt,e.promptLength(de.prompt)),C.current(a.capture())&&(e.setMode($),e.setPopover(null),requestAnimationFrame(()=>{const U=e.editor();U&&(U.focus(),rl(U,e.promptLength(E)),e.queueScroll())})),!0):!1};if(!F&&$==="normal"&&e.shouldQueue?.()){e.onQueue?.(ve),v(C.target()),ne();return}if(e.onSubmit?.(),$==="shell"){ne();const de=OGe.create();n().api.session.shell({sessionID:K.id,id:de,command:L,agent:te,model:X}).catch(U=>{tn({title:c.t("prompt.toast.shellSendFailed.title"),description:g(U)}),ie()});return}if(L.startsWith("/")){const[de,...U]=L.split(" "),He=de.slice(1);if(r().data.command.find(Z=>Z.name===He)){ne();const Z=wo.ascending("message");i().session.set("session_status",K.id,{type:"busy"}),n().api.session.command({sessionID:K.id,id:Z,command:He,arguments:U.join(" "),agent:te,model:{id:X.modelID,providerID:X.providerID,variant:D},files:O.map(ce=>({uri:ce.dataUrl,name:ce.filename}))}).catch(ce=>{i().session.set("session_status",K.id,{type:"idle"}),tn({title:c.t("prompt.toast.commandSendFailed.title"),description:Uf(ce,c.t,c.t("common.requestFailed"))}),ie()});return}}const ke=_.filter(de=>de.type==="file"&&!!de.comment?.trim()),ge=wo.ascending("message"),Pe=()=>{r().session.optimistic.remove({directory:W,sessionID:K.id,messageID:ge})};for(const de of ke)C.target().context.remove(de.key);ne();const Me=async()=>{const de=Sf.get(n().scope,W);if(!de||de.status!=="pending")return!0;W===N&&r().set("session_status",K.id,{type:"busy"});const U=new AbortController,He=()=>{W===N&&r().set("session_status",K.id,{type:"idle"}),Pe(),ie()&&y(C.target(),ke)};H0.set(m(K.id),{abort:U,cleanup:He});const Ue=new Promise(xe=>{if(U.signal.aborted){xe({status:"failed",message:"aborted"});return}U.signal.addEventListener("abort",()=>{xe({status:"failed",message:"aborted"})},{once:!0})}),Z=300*1e3,ce={id:void 0},G=new Promise(xe=>{ce.id=window.setTimeout(()=>{xe({status:"failed",message:c.t("workspace.error.stillPreparing")})},Z)}),fe=await Promise.race([Sf.wait(n().scope,W),Ue,G]).finally(()=>{ce.id!==void 0&&clearTimeout(ce.id)});if(H0.delete(m(K.id)),U.signal.aborted)return!1;if(fe.status==="failed")throw new Error(fe.message);return!0};lne({api:n().api.session,sync:r(),serverSync:i(),draft:ve,messageID:ge,optimisticBusy:W===N,before:Me}).catch(de=>{H0.delete(m(K.id)),W===N&&r().set("session_status",K.id,{type:"idle"}),tn({title:c.t("prompt.toast.promptSendFailed.title"),description:g(de)}),Pe(),ie()&&y(C.target(),ke)})}}}var NGe=A('<div class="px-2 py-1"><input placeholder=/ class="w-full bg-transparent outline-none text-[13px] leading-5 text-v2-text-text-base placeholder:text-v2-text-text-faint">'),VGe=A('<div class="absolute inset-x-0 -top-2 -translate-y-full origin-bottom-left max-h-80 min-h-10 overflow-auto no-scrollbar flex flex-col p-2">'),NF=A('<div class="px-2 py-1">'),zGe=A('<button class="w-full flex items-center gap-x-2 px-2 py-0.5"><span class=whitespace-nowrap>@'),HGe=A('<button class="w-full flex items-center gap-x-2 px-2 py-0.5"><div class="flex items-center min-w-0"><span class="text-text-strong whitespace-nowrap">@'),jGe=A('<span class="whitespace-nowrap truncate min-w-0 ml-2">'),qGe=A('<button class="w-full flex items-center gap-x-2 px-2 py-0.5"><div class="flex items-center min-w-0"><span class="text-text-strong whitespace-nowrap">@</span><span class="whitespace-nowrap truncate min-w-0 ml-2">'),BGe=A("<span class=whitespace-nowrap>"),UGe=A('<button class="w-full flex items-center gap-x-2 px-2 py-0.5"><div class="flex items-center min-w-0"><span class="whitespace-nowrap truncate min-w-0">'),WGe=A("<span class=truncate>"),KGe=A('<button><div class="flex items-center gap-2 min-w-0"><span class=whitespace-nowrap>/</span></div><div class="flex items-center gap-2 shrink-0">'),GGe=A('<span class="text-11-regular px-1.5 py-0.5 rounded bg-surface-base text-text-subtle">'),ZGe=A('<span class="text-12-regular text-text-subtle">');const YGe=e=>h(q,{get when(){return e.popover},get children(){var t=VGe();return t.$$mousedown=n=>n.preventDefault(),pt(n=>{e.popover==="slash"&&e.setSlashPopoverRef(n)},t),S(t,h(Rr,{get children(){return[h(zt,{get when(){return e.popover==="at"},get children(){return h(q,{get when(){return e.atFlat.length>0},get fallback(){return(()=>{var n=NF();return S(n,()=>e.t("prompt.popover.emptyResults")),he(r=>{var i=!!e.newLayoutDesigns,s=!e.newLayoutDesigns;return i!==r.e&&n.classList.toggle("text-v2-text-text-muted",r.e=i),s!==r.t&&n.classList.toggle("text-text-weak",r.t=s),r},{e:void 0,t:void 0}),n})()},get children(){return h(Dt,{get each(){return e.atFlat.slice(0,10)},children:n=>{const r=e.atKey(n);if(n.type==="agent")return(()=>{var a=zGe(),l=a.firstChild;return l.firstChild,a.$$pointermove=()=>e.setAtActive(r),a.$$click=()=>e.onAtSelect(n),S(a,h(Yt,{name:"brain",size:"small",class:"text-icon-info-active shrink-0"}),l),S(l,()=>n.name,null),he(c=>{var u=!!e.newLayoutDesigns,d=!e.newLayoutDesigns,f=!!(e.newLayoutDesigns&&e.atActive===r),m=!e.newLayoutDesigns&&e.atActive===r,g={"text-[13px] leading-[calc(var(--font-size-base)*1.8)] tracking-[-0.04px] [font-weight:440]":e.newLayoutDesigns,"text-v2-text-text-base":e.newLayoutDesigns,"text-14-regular":!e.newLayoutDesigns,"text-text-strong":!e.newLayoutDesigns};return u!==c.e&&a.classList.toggle("rounded-[4px]",c.e=u),d!==c.t&&a.classList.toggle("rounded-md",c.t=d),f!==c.a&&a.classList.toggle("bg-v2-overlay-simple-overlay-hover",c.a=f),m!==c.o&&a.classList.toggle("bg-surface-raised-base-hover",c.o=m),c.i=ct(l,g,c.i),c},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),a})();if(n.type==="resource")return(()=>{var a=HGe(),l=a.firstChild,c=l.firstChild;return c.firstChild,a.$$pointermove=()=>e.setAtActive(r),a.$$click=()=>e.onAtSelect(n),S(a,h(Dr,{get node(){return{path:n.uri,type:"file"}},class:"shrink-0 size-4"}),l),S(c,()=>n.name,null),S(l,h(q,{get when(){return n.description},children:u=>(()=>{var d=jGe();return S(d,u),he(f=>{var m=!!e.newLayoutDesigns,g=!e.newLayoutDesigns;return m!==f.e&&d.classList.toggle("text-v2-text-text-muted",f.e=m),g!==f.t&&d.classList.toggle("text-text-weak",f.t=g),f},{e:void 0,t:void 0}),d})()}),null),he(u=>{var d=!!e.newLayoutDesigns,f=!e.newLayoutDesigns,m=!!(e.newLayoutDesigns&&e.atActive===r),g=!e.newLayoutDesigns&&e.atActive===r,p={"text-[13px] leading-[calc(var(--font-size-base)*1.8)] tracking-[-0.04px] [font-weight:440]":e.newLayoutDesigns,"text-14-regular":!e.newLayoutDesigns},y=!!e.newLayoutDesigns;return d!==u.e&&a.classList.toggle("rounded-[4px]",u.e=d),f!==u.t&&a.classList.toggle("rounded-md",u.t=f),m!==u.a&&a.classList.toggle("bg-v2-overlay-simple-overlay-hover",u.a=m),g!==u.o&&a.classList.toggle("bg-surface-raised-base-hover",u.o=g),u.i=ct(l,p,u.i),y!==u.n&&c.classList.toggle("text-v2-text-text-base",u.n=y),u},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),a})();if(n.type==="reference")return(()=>{var a=qGe(),l=a.firstChild,c=l.firstChild;c.firstChild;var u=c.nextSibling;return a.$$pointermove=()=>e.setAtActive(r),a.$$click=()=>e.onAtSelect(n),S(a,h(Dr,{get node(){return{path:n.path,type:"directory"}},class:"shrink-0 size-4"}),l),S(c,()=>n.name,null),S(u,()=>n.description),he(d=>{var f=!!e.newLayoutDesigns,m=!e.newLayoutDesigns,g=!!(e.newLayoutDesigns&&e.atActive===r),p=!e.newLayoutDesigns&&e.atActive===r,y={"text-[13px] leading-[calc(var(--font-size-base)*1.8)] tracking-[-0.04px] [font-weight:440]":e.newLayoutDesigns,"text-14-regular":!e.newLayoutDesigns},v=!!e.newLayoutDesigns,b=!!e.newLayoutDesigns,w=!e.newLayoutDesigns;return f!==d.e&&a.classList.toggle("rounded-[4px]",d.e=f),m!==d.t&&a.classList.toggle("rounded-md",d.t=m),g!==d.a&&a.classList.toggle("bg-v2-overlay-simple-overlay-hover",d.a=g),p!==d.o&&a.classList.toggle("bg-surface-raised-base-hover",d.o=p),d.i=ct(l,y,d.i),v!==d.n&&c.classList.toggle("text-v2-text-text-base",d.n=v),b!==d.s&&u.classList.toggle("text-v2-text-text-muted",d.s=b),w!==d.h&&u.classList.toggle("text-text-weak",d.h=w),d},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0}),a})();const i=n.path.endsWith("/"),s=i?n.path:hc(n.path),o=i?"":fn(n.path);return(()=>{var a=UGe(),l=a.firstChild,c=l.firstChild;return a.$$pointermove=()=>e.setAtActive(r),a.$$click=()=>e.onAtSelect(n),S(a,h(Dr,{get node(){return{path:n.path,type:"file"}},class:"shrink-0 size-4"}),l),S(c,s),S(l,h(q,{when:!i,get children(){var u=BGe();return S(u,o),he(d=>{var f=!!e.newLayoutDesigns,m=!e.newLayoutDesigns;return f!==d.e&&u.classList.toggle("text-v2-text-text-base",d.e=f),m!==d.t&&u.classList.toggle("text-text-strong",d.t=m),d},{e:void 0,t:void 0}),u}}),null),he(u=>{var d=!!e.newLayoutDesigns,f=!e.newLayoutDesigns,m=!!(e.newLayoutDesigns&&e.atActive===r),g=!e.newLayoutDesigns&&e.atActive===r,p={"text-[13px] leading-[calc(var(--font-size-base)*1.8)] tracking-[-0.04px] [font-weight:440]":e.newLayoutDesigns,"text-14-regular":!e.newLayoutDesigns},y=!!e.newLayoutDesigns,v=!e.newLayoutDesigns;return d!==u.e&&a.classList.toggle("rounded-[4px]",u.e=d),f!==u.t&&a.classList.toggle("rounded-md",u.t=f),m!==u.a&&a.classList.toggle("bg-v2-overlay-simple-overlay-hover",u.a=m),g!==u.o&&a.classList.toggle("bg-surface-raised-base-hover",u.o=g),u.i=ct(l,p,u.i),y!==u.n&&c.classList.toggle("text-v2-text-text-muted",u.n=y),v!==u.s&&c.classList.toggle("text-text-weak",u.s=v),u},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0}),a})()}})}})}}),h(zt,{get when(){return e.popover==="slash"},get children(){return[h(q,{get when(){return e.slashMenu},get children(){var n=NGe(),r=n.firstChild;return r.$$mousedown=i=>i.stopPropagation(),cn(r,"keydown",e.onSlashMenuKeyDown,!0),r.$$input=i=>e.onSlashMenuInput(i.currentTarget.value),pt(i=>requestAnimationFrame(()=>i.focus()),r),he(()=>me(r,"aria-label",e.t("prompt.menu.commands"))),he(()=>r.value=e.slashMenuQuery),n}}),h(q,{get when(){return e.slashFlat.length>0},get fallback(){return(()=>{var n=NF();return S(n,()=>e.t("prompt.popover.emptyCommands")),he(r=>{var i=!!e.newLayoutDesigns,s=!e.newLayoutDesigns;return i!==r.e&&n.classList.toggle("text-v2-text-text-muted",r.e=i),s!==r.t&&n.classList.toggle("text-text-weak",r.t=s),r},{e:void 0,t:void 0}),n})()},get children(){return h(Dt,{get each(){return e.slashFlat},children:n=>{const r=()=>e.commandKeybind(n.id),i=()=>e.commandKeybindParts(n.id);return(()=>{var s=KGe(),o=s.firstChild,a=o.firstChild;a.firstChild;var l=o.nextSibling;return s.$$pointermove=()=>e.setSlashActive(n.id),s.$$click=()=>e.onSlashSelect(n),S(a,()=>n.trigger,null),S(o,h(q,{get when(){return n.description},get children(){var c=WGe();return S(c,()=>n.description),he(u=>ct(c,{"text-[13px] leading-[calc(var(--font-size-base)*1.8)] tracking-[-0.04px] [font-weight:440]":e.newLayoutDesigns,"text-v2-text-text-muted":e.newLayoutDesigns,"text-14-regular":!e.newLayoutDesigns,"text-text-weak":!e.newLayoutDesigns},u)),c}}),null),S(l,h(q,{get when(){return we(()=>n.type==="custom")()&&n.source!=="command"},get children(){return h(q,{get when(){return e.newLayoutDesigns},get fallback(){return(()=>{var c=GGe();return S(c,(()=>{var u=we(()=>n.source==="skill");return()=>u()?e.t("prompt.slash.badge.skill"):we(()=>n.source==="mcp")()?e.t("prompt.slash.badge.mcp"):e.t("prompt.slash.badge.custom")})()),c})()},get children(){return h(m1,{get children(){return we(()=>n.source==="skill")()?e.t("prompt.slash.badge.skill"):we(()=>n.source==="mcp")()?e.t("prompt.slash.badge.mcp"):e.t("prompt.slash.badge.custom")}})}})}}),null),S(l,h(q,{get when(){return we(()=>!!e.newLayoutDesigns)()?i().length>0:r()},get children(){return h(q,{get when(){return e.newLayoutDesigns},get fallback(){return(()=>{var c=ZGe();return S(c,r),c})()},get children(){return h(Eo,{get keys(){return i()},variant:"neutral"})}})}}),null),he(c=>{var u=n.id,d={"w-full flex items-center justify-between gap-4 px-2 py-1":!0,"rounded-[4px] scroll-my-2":e.newLayoutDesigns,"rounded-md":!e.newLayoutDesigns,"bg-v2-overlay-simple-overlay-hover":e.newLayoutDesigns&&e.slashActive===n.id,"bg-surface-raised-base-hover":!e.newLayoutDesigns&&e.slashActive===n.id},f={"text-[13px] leading-[calc(var(--font-size-base)*1.8)] tracking-[-0.04px] [font-weight:440]":e.newLayoutDesigns,"text-v2-text-text-base":e.newLayoutDesigns,"text-14-regular":!e.newLayoutDesigns,"text-text-strong":!e.newLayoutDesigns};return u!==c.e&&me(s,"data-slash-id",c.e=u),c.t=ct(s,d,c.t),c.a=ct(a,f,c.a),c},{e:void 0,t:void 0,a:void 0}),s})()}})}})]}})]}})),he(n=>ct(t,{"z-[70] rounded-[10px] bg-v2-background-bg-base shadow-[var(--v2-elevation-raised)]":e.newLayoutDesigns,"rounded-[12px] bg-surface-raised-stronger-non-alpha shadow-[var(--shadow-lg-border-base)]":!e.newLayoutDesigns},n)),t}});dn(["mousedown","input","keydown","click","pointermove"]);var XGe=A('<div class="flex flex-nowrap items-start gap-2 p-2 overflow-x-auto no-scrollbar">'),QGe=A('<div><div class="flex items-center gap-1.5"><div class="flex items-center text-[12px] min-w-0 font-medium leading-5"><span class="text-text-strong whitespace-nowrap">'),JGe=A('<span class="flex max-w-[300px]"><span></span><span class=shrink-0>'),eZe=A('<span class="text-text-weak whitespace-nowrap shrink-0">'),tZe=A('<div class="text-12-regular text-text-strong ml-5 pr-1 truncate">');const nZe=e=>h(q,{get when(){return e.items.length>0},get children(){var t=XGe();return S(t,h(Dt,{get each(){return e.items},children:n=>{const r=hc(n.path),i=fn(n.path),s=yK(n.path,14),o=e.active(n);return h(Gi,{get component(){return e.newLayoutDesigns?Qn:Ar},get value(){return(()=>{var a=JGe(),l=a.firstChild,c=l.nextSibling;return S(l,r),S(c,i),he(u=>ct(l,{"truncate-start [unicode-bidi:plaintext] min-w-0":!0,"text-v2-text-text-muted":e.newLayoutDesigns,"text-text-invert-base":!e.newLayoutDesigns},u)),a})()},placement:"top",openDelay:800,get children(){var a=QGe(),l=a.firstChild,c=l.firstChild,u=c.firstChild;return a.$$click=()=>e.openComment(n),S(l,h(Dr,{get node(){return{path:n.path,type:"file"}},class:"shrink-0 size-3.5"}),c),S(u,s),S(c,h(q,{get when(){return n.selection},children:d=>(()=>{var f=eZe();return S(f,(()=>{var m=we(()=>d().startLine===d().endLine);return()=>m()?`:${d().startLine}`:`:${d().startLine}-${d().endLine}`})()),f})()}),null),S(l,h(Ln,{type:"button",icon:"close-small",variant:"ghost",class:"ml-auto size-3.5 text-text-weak hover:text-text-strong transition-all",onClick:d=>{d.stopPropagation(),e.remove(n)},get"aria-label"(){return e.t("prompt.context.removeFile")}}),null),S(a,h(q,{get when(){return n.comment},children:d=>(()=>{var f=tZe();return S(f,d),f})()}),null),he(d=>ct(a,{"group shrink-0 flex flex-col rounded-[6px] pl-2 pr-1 py-1 max-w-[200px] h-12 cursor-default transition-all transition-transform shadow-xs-border hover:shadow-xs-border-hover":!0,"hover:bg-surface-interactive-weak":!!n.commentID&&!o,"bg-surface-interactive-hover hover:bg-surface-interactive-hover shadow-xs-border-hover":o,"bg-background-stronger":!o},d)),a}})}})),t}});dn(["click"]);var rZe=A("<div data-component=attachment-card-v2><span data-slot=attachment-card-v2-title></span><span data-slot=attachment-card-v2-subtitle>");function t3(e){return(()=>{var t=rZe(),n=t.firstChild,r=n.nextSibling;return t.$$click=()=>e.onClick?.(),pt(i=>e.titleRef?.(i),n),S(n,()=>e.title),S(r,()=>e.children),he(i=>{var s=e.active?"true":void 0,o=e.clickable?"true":void 0,a=e.wide?"true":void 0,l=e.surface,c=e.hover;return s!==i.e&&me(t,"data-active",i.e=s),o!==i.t&&me(t,"data-clickable",i.t=o),a!==i.a&&me(t,"data-wide",i.a=a),l!==i.o&&me(t,"data-surface",i.o=l),c!==i.i&&me(t,"title",i.i=c),i},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),t})()}dn(["click"]);var iZe=A("<span>");function LI(e){let t;const[n,r]=De(!1);return sn(()=>{const i=t;if(!i)return;const s=()=>r(i.scrollWidth>i.clientWidth),o=()=>requestAnimationFrame(s),a=new ResizeObserver(s);a.observe(i),o(),document.fonts?.ready.then(o),Te(()=>a.disconnect())}),h(Qn,{placement:"top",openDelay:1e3,get value(){return e.title??e.comment},get disabled(){return!e.tooltip||!n()},get class(){return e.wide?"w-full":void 0},contentStyle:{"max-width":"320px","white-space":"pre-wrap"},get children(){return h(t3,{get title(){return e.comment},get active(){return e.active},get clickable(){return!!e.onClick},get wide(){return e.wide},surface:"base",titleRef:i=>{t=i},get onClick(){return e.onClick},get children(){return[h(Dr,{get node(){return{path:e.path,type:"file"}}}),(()=>{var i=iZe();return S(i,()=>yK(e.path,14),null),S(i,h(q,{get when(){return e.selection},children:s=>s().startLine===s().endLine?`:${s().startLine}`:`:${s().startLine}-${s().endLine}`}),null),i})()]}})}})}function sZe(e){return e.url.startsWith("data:")&&!une(e)}function une(e){return e.source?.text?.start!==void 0&&e.source?.text?.end!==void 0}function oZe(e){return e.mime.startsWith("image/")?"image":"file"}const aZe=new Map(D1.flatMap(e=>[e.id,...e.aliases??[]].map(t=>[t,e.name])));function AI(e,t){if(t==="application/pdf")return"PDF";const n=fn(e),r=n.lastIndexOf("."),i=r<=0?"":n.slice(r+1).toLowerCase();return i?aZe.get(i)??i.toUpperCase():"File"}var lZe=A('<div data-slot=prompt-attachments-fade-left class="pointer-events-none absolute inset-y-0 left-0 z-10 w-6 bg-[linear-gradient(to_right,var(--v2-background-bg-base),transparent)]">'),cZe=A('<div data-slot=prompt-attachments-fade-right class="pointer-events-none absolute inset-y-0 right-0 z-10 w-6 bg-[linear-gradient(to_left,var(--v2-background-bg-base),transparent)]">'),uZe=A("<div data-slot=prompt-attachments><div data-slot=prompt-attachments-scroll>"),dZe=A('<div class="relative group shrink-0"><button type=button class="absolute -top-1 -right-1 size-4 rounded-full bg-v2-icon-icon-muted outline-solid outline-1 outline-v2-icon-icon-contrast flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity">'),fZe=A("<img>"),hZe=A('<div class="size-16 rounded-md bg-surface-base flex items-center justify-center border border-border-base">'),mZe=A('<div class="absolute bottom-0 left-0 right-0 px-1 py-0.5 bg-black/50 rounded-b-md"><span class="text-10-regular text-white truncate block">'),gZe=A("<button type=button>"),pZe=A('<div class="absolute inset-0 rounded-[6px] shadow-[inset_0_0_0_0.5px_var(--v2-border-border-base)] pointer-events-none">'),vZe=A('<div class="relative group shrink-0">'),yZe=A('<div class="relative group">');const bZe="size-16 rounded-md object-cover border border-border-base hover:border-border-strong-base transition-colors",wZe="w-[58px] h-[46px] rounded-[6px] object-cover",xZe="absolute -top-1.5 -right-1.5 size-5 rounded-full bg-surface-raised-stronger-non-alpha border border-border-base flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity hover:bg-surface-raised-base-hover",kZe="absolute -top-1 -right-1 size-4 rounded-full bg-v2-icon-icon-muted outline-solid outline-1 outline-v2-icon-icon-contrast flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",SZe=e=>h(q,{get when(){return e.attachments.length>0||e.newLayoutDesigns&&(e.comments?.length??0)>0},get children(){var t=uZe(),n=t.firstChild;return S(n,h(q,{get when(){return e.newLayoutDesigns},get children(){return h(Dt,{get each(){return e.comments??[]},children:r=>(()=>{var i=dZe(),s=i.firstChild;return S(i,h(Qn,{get value(){return r.comment},placement:"top",openDelay:800,contentClass:"max-w-[300px] break-words",get children(){return h(LI,{get comment(){return r.comment??""},get path(){return r.path},get selection(){return r.selection},get active(){return e.commentActive?.(r)},onClick:()=>e.onOpenComment?.(r)})}}),s),s.$$click=()=>e.onRemoveComment?.(r),S(s,h(on,{name:"outline-xmark",class:"text-v2-icon-icon-contrast"})),he(()=>me(s,"aria-label",e.removeLabel)),i})()})}}),null),S(n,h(Dt,{get each(){return e.attachments},children:r=>{const i=r.mime.startsWith("image/"),s=()=>h(q,{when:i,get fallback(){return h(q,{get when(){return e.newLayoutDesigns},get fallback(){return(()=>{var l=hZe();return S(l,h(Yt,{name:"folder",class:"size-6 text-text-weak"})),l})()},get children(){return h(t3,{get title(){return r.filename},get children(){return AI(r.filename,r.mime)}})}})},get children(){var l=fZe();return l.$$click=()=>e.onOpen(r),he(c=>{var u=r.dataUrl,d=r.filename,f=e.newLayoutDesigns?wZe:bZe;return u!==c.e&&me(l,"src",c.e=u),d!==c.t&&me(l,"alt",c.t=d),f!==c.a&&xr(l,c.a=f),c},{e:void 0,t:void 0,a:void 0}),l}}),o=()=>(()=>{var l=mZe(),c=l.firstChild;return S(c,()=>r.filename),l})(),a=()=>(()=>{var l=gZe();return l.$$click=()=>e.onRemove(r.id),S(l,h(q,{get when(){return e.newLayoutDesigns},get fallback(){return h(Yt,{name:"close",class:"size-3 text-text-weak"})},get children(){return h(on,{name:"outline-xmark",class:"text-v2-icon-icon-contrast"})}})),he(c=>{var u=e.newLayoutDesigns?kZe:xZe,d=e.removeLabel;return u!==c.e&&xr(l,c.e=u),d!==c.t&&me(l,"aria-label",c.t=d),c},{e:void 0,t:void 0}),l})();return h(q,{get when(){return e.newLayoutDesigns},get fallback(){return h(Ar,{get value(){return r.filename},placement:"top",contentClass:"break-all",get children(){var l=yZe();return S(l,s,null),S(l,o,null),S(l,a,null),l}})},get children(){var l=vZe();return S(l,h(Qn,{get value(){return r.filename},placement:"top",contentClass:"break-all",get children(){return[we(()=>s()),h(q,{when:i,get children(){return pZe()}})]}}),null),S(l,a,null),l}})}}),null),S(t,h(q,{get when(){return e.newLayoutDesigns},get children(){return[lZe(),cZe()]}}),null),he(r=>{var i=!!e.newLayoutDesigns,s={"flex gap-2":!0,"flex-nowrap overflow-x-auto no-scrollbar px-2 pt-2 pb-1":e.newLayoutDesigns,"flex-wrap px-3 pt-3":!e.newLayoutDesigns};return i!==r.e&&t.classList.toggle("relative",r.e=i),r.t=ct(n,s,r.t),r},{e:void 0,t:void 0}),t}});dn(["click"]);var CZe=A('<div class="absolute inset-0 z-10 flex items-center justify-center bg-surface-raised-stronger-non-alpha/90 pointer-events-none"><div class="flex flex-col items-center gap-2 text-text-weak"><span class=text-14-regular>');const VF={image:"photo","@mention":"link"},_Ze=e=>h(q,{get when(){return e.type!==null},get children(){var t=CZe(),n=t.firstChild,r=n.firstChild;return S(n,h(Yt,{get name(){return we(()=>!!e.type)()?VF[e.type]:VF.image},class:"size-8"}),r),S(r,()=>e.label),t}});function dne(e){return e.mode==="shell"?e.t("prompt.placeholder.shell",{example:e.example}):e.commentCount>1?e.t("prompt.placeholder.summarizeComments"):e.commentCount===1?e.t("prompt.placeholder.summarizeComment"):e.suggest?e.t("prompt.placeholder.normal",{example:e.example}):e.t("prompt.placeholder.simple")}function TZe(e,t){return e==="shell"?t:"Ask anything, @ for context..."}function EZe(e){e({popover:null,slashMenu:!1,slashMenuQuery:"",historyIndex:-1,savedPrompt:null,draggingType:null,mode:"normal",applyingHistory:!1})}function IZe(e,t){const[n,r]=Ze({popover:null,slashMenu:!1,slashMenuQuery:"",historyIndex:-1,savedPrompt:null,placeholder:t,draggingType:null,mode:"normal",applyingHistory:!1});return Fs(vt(e,()=>EZe(r),{defer:!0})),[n,r]}var DZe=A("<div data-slot=image-preview-header>"),LZe=A("<div data-slot=image-preview-body><img data-slot=image-preview-image>"),AZe=A("<div data-component=image-preview><div data-slot=image-preview-container>");function MI(e){const t=Mn();return(()=>{var n=AZe(),r=n.firstChild;return S(r,h(Qs.Content,{"data-slot":"image-preview-content",get children(){return[(()=>{var i=DZe();return S(i,h(Qs.CloseButton,{"data-slot":"image-preview-close",as:Ln,icon:"close",variant:"ghost",get"aria-label"(){return t.t("ui.common.close")}})),i})(),(()=>{var i=LZe(),s=i.firstChild;return he(o=>{var a=e.src,l=e.alt??t.t("ui.imagePreview.alt");return a!==o.e&&me(s,"src",o.e=a),l!==o.t&&me(s,"alt",o.t=l),o},{e:void 0,t:void 0}),i})()]}})),n})()}var MZe=A('<div class="flex items-center gap-2"><span></span><span class="text-icon-base text-12-medium text-[10px]!">'),$Ze=A('<div class="flex items-center gap-2"><span>'),PZe=A('<div class=relative><div class="relative max-h-[240px] overflow-y-auto no-scrollbar"style=scroll-padding-bottom:56px><div data-component=prompt-input role=textbox aria-multiline=true contenteditable=true inputmode=text autocomplete=off style=padding-bottom:56px></div><div class="absolute top-0 inset-x-0 pl-3 pr-2 pt-2 text-14-regular text-text-weak pointer-events-none whitespace-nowrap truncate"style=padding-bottom:56px></div></div><div aria-hidden=true class="pointer-events-none absolute inset-x-0 bottom-0"style="height:56px;background:linear-gradient(to top, var(--surface-raised-stronger-non-alpha) calc(100% - 20px), transparent)"></div><div class="pointer-events-none absolute bottom-2 right-2 flex items-center gap-2"><input type=file multiple class=hidden><div class="flex items-center gap-1 pointer-events-auto"></div></div><div class="pointer-events-none absolute bottom-2 left-2"><div class=pointer-events-auto>'),OZe=A("<div data-component=prompt-agent-control>"),zF=A("<span class=truncate>"),RZe=A("<div data-component=prompt-model-control>"),FZe=A("<div data-component=prompt-variant-control>"),NZe=A('<div class="px-1.75 pt-5.5 pb-2 flex items-center gap-2 min-w-0"><div class="flex items-center gap-1.5 min-w-0 flex-1 relative"><div class="h-7 flex items-center gap-1.5 min-w-0 absolute inset-0"style="padding:0 0px 0 8px"><span class="truncate text-13-medium text-text-base"></span><div class=flex-1></div></div><div class="flex items-center gap-1.5 min-w-0 flex-1 h-7">'),VZe=A('<div class="relative size-full flex flex-col gap-0">');const JS=["prompt.example.1","prompt.example.2","prompt.example.3","prompt.example.4","prompt.example.5","prompt.example.6","prompt.example.7","prompt.example.8","prompt.example.9","prompt.example.10","prompt.example.11","prompt.example.12","prompt.example.13","prompt.example.14","prompt.example.15","prompt.example.16","prompt.example.17","prompt.example.18","prompt.example.19","prompt.example.20","prompt.example.21","prompt.example.22","prompt.example.23","prompt.example.24","prompt.example.25"],zZe=e=>{const t=kr(),n=Ji(),r=ua(),i=e.state??Hg(),s=li(),o=q1(),a=Mr(),l=Qi(),c=mu(),u=wt(),d=Tr(),f=()=>e.controls.session.tabs;let m,g,p,y,v=!0,b=null;const w={input:!1},x=56,k=()=>{const Y=p,Ce=window.getSelection();if(!Y||!Ce||Ce.rangeCount===0)return;const Fe=Ce.getRangeAt(0);if(!m.contains(Fe.startContainer))return;const qe=Ac(m),_t=Ho(i.current().filter(di=>di.type!=="image"));if(qe>=_t){Y.scrollTop=Y.scrollHeight;return}const Zt=Fe.getClientRects().item(0)??Fe.getBoundingClientRect();if(!Zt.height)return;const It=Y.getBoundingClientRect(),jt=Zt.top-It.top+Y.scrollTop,Pt=Zt.bottom-It.top+Y.scrollTop,Tn=12;if(jt<Y.scrollTop+Tn){Y.scrollTop=Math.max(0,jt-Tn);return}Pt>Y.scrollTop+Y.clientHeight-x&&(Y.scrollTop=Pt-Y.clientHeight+x)},C=(Y=2)=>{requestAnimationFrame(()=>{k(),Y>1&&C(Y-1)})},E=Nd({tabs:f,pathFromTab:r.pathFromTab,normalizeTab:Y=>Y.startsWith("file://")?r.tab(Y):Y}).activeFileTab,_=Y=>{const Ce=e.controls.session.id;if(!Ce)return!1;const Fe=n().data.session_diff[Ce];return Fe?Fe.some(qe=>qe.file===Y):!1},L=Y=>{if(!Y.commentID)return;const Ce={file:Y.path,id:Y.commentID};o.setActive(Ce);const Fe=(Zt=6)=>{const It=jt=>{requestAnimationFrame(()=>{o.setFocus({...Ce}),!(jt<=0)&&requestAnimationFrame(()=>{const Pt=o.focus();Pt&&(Pt.file!==Ce.file||Pt.id!==Ce.id||It(jt-1))})})};It(Zt)};if(Y.commentOrigin==="review"||Y.commentOrigin!=="file"&&_(Y.path)){e.controls.session.reviewPanel.opened()||e.controls.session.reviewPanel.open(),s.fileTree.setTab("changes"),f().setActive("review"),Fe();return}e.controls.session.reviewPanel.opened()||e.controls.session.reviewPanel.open(),s.fileTree.setTab("all");const _t=r.tab(Y.path);f().open(_t),f().setActive(_t),Promise.resolve(r.load(Y.path)).finally(()=>Fe())},O=I(()=>{const Y=f().all(),Ce=E(),Fe=Ce?[Ce,...Y.filter(Zt=>Zt!==Ce)]:Y,qe=new Set,_t=[];for(const Zt of Fe){const It=r.pathFromTab(Zt);It&&(qe.has(It)||(qe.add(It),_t.push(It)))}return _t}),$=I(()=>e.controls.session.id?n().session.get(e.controls.session.id):void 0),V=I(()=>n().data.session_working(e.controls.session.id??"")),P=I(()=>i.current().filter(Y=>Y.type==="image")),[T,D]=IZe(()=>i.capture(),Math.floor(Math.random()*JS.length)),N=vy(()=>T.mode==="normal"?1:0,{visualDuration:.2,bounce:0}),M=Y=>({opacity:Y,transform:`scale(${.98+Y*.02})`,filter:`blur(${(1-Y)*2}px)`,"pointer-events":Y>.5?"auto":"none"}),F=I(()=>M(N())),j=I(()=>M(1-N())),z=I(()=>({height:"28px",...F()})),W=I(()=>T.mode==="shell"?0:i.context.items().filter(Y=>!!Y.comment?.trim()).length),J=I(()=>i.current().map(Ce=>"content"in Ce?Ce.content:"").join("").trim().length===0&&P().length===0&&W()===0),K=I(()=>V()&&J()),X=()=>K()?(()=>{var Y=MZe(),Ce=Y.firstChild,Fe=Ce.nextSibling;return S(Ce,()=>u.t("prompt.action.stop")),S(Fe,()=>u.t("common.key.esc")),Y})():(()=>{var Y=$Ze(),Ce=Y.firstChild;return S(Ce,()=>u.t("prompt.action.send")),S(Y,h(Yt,{name:"enter",size:"small",class:"text-icon-base"}),null),Y})(),te=I(()=>{const Y=i.context.items();return T.mode!=="shell"?Y:Y.filter(Ce=>!Ce.comment?.trim())}),ve=I(()=>{const Y=e.controls.session.id;if(!Y)return!1;const Ce=n().data.message[Y];return Ce?Ce.some(Fe=>Fe.role==="user"):!1}),ne=e.history??ine(),ie=I(()=>!ve()),ke=I(()=>dne({mode:T.mode,commentCount:W(),example:ie()?T.mode==="shell"?"git status":u.t(JS[T.placeholder]):"",suggest:ie(),t:(Y,Ce)=>u.t(Y,Ce)})),ge=()=>{const Y=new Map(o.all().map(Ce=>[`${Ce.file}
1159
1159
  ${Ce.id}`,Ce]));return i.context.items().flatMap(Ce=>{if(Ce.type!=="file")return[];const Fe=Ce.comment?.trim();if(!Fe)return[];const _t=(Ce.commentID?Y.get(`${Ce.path}
1160
1160
  ${Ce.commentID}`)?.selection:void 0)??(Ce.selection?{start:Ce.selection.startLine,end:Ce.selection.endLine}:void 0);return _t?[{id:Ce.commentID??Ce.key,path:Ce.path,selection:{..._t},comment:Fe,time:Ce.commentID?Y.get(`${Ce.path}
1161
1161
  ${Ce.commentID}`)?.time??Date.now():Date.now(),origin:Ce.commentOrigin,preview:Ce.preview}]:[]})},Pe=Y=>{o.replace(Y.map(Ce=>({id:Ce.id,file:Ce.path,selection:{...Ce.selection},comment:Ce.comment,time:Ce.time}))),i.context.replaceComments(Y.map(Ce=>({type:"file",path:Ce.path,selection:md(Ce.selection),comment:Ce.comment,commentID:Ce.id,commentOrigin:Ce.origin,preview:Ce.preview})))},Me=(Y,Ce)=>{const Fe=Y.prompt,qe=Ce==="start"?0:Ho(Fe);D("applyingHistory",!0),Pe(Y.comments),i.set(Fe,qe),requestAnimationFrame(()=>{m.focus(),rl(m,qe),D("applyingHistory",!1),C()})},de=()=>{const Y=window.getSelection(),Ce=Ho(i.current());if(!Y||Y.rangeCount===0)return{collapsed:!1,cursorPosition:0,textLength:Ce};const Fe=Y.anchorNode;return!Fe||!m.contains(Fe)?{collapsed:!1,cursorPosition:0,textLength:Ce}:{collapsed:Y.isCollapsed,cursorPosition:Ac(m),textLength:Ce}},U=()=>d.platform==="desktop"&&d.os==="macos",He=()=>{HKe({picker:d.openAttachmentPickerDialog,directory:()=>t().directory,fallback:()=>g?.click(),onFile:Za,onError:Y=>tn({variant:"error",title:u.t("common.requestFailed"),description:Y instanceof Error?Y.message:String(Y)})})},Ue=Y=>{D("mode",Y),D({popover:null,slashMenu:!1,slashMenuQuery:""}),requestAnimationFrame(()=>m?.focus())},Z="mod+shift+x",ce="mod+shift+e";l.register("prompt-input",()=>[{id:"file.attach",title:u.t("prompt.action.attachFile"),category:u.t("command.category.file"),keybind:"mod+u",disabled:T.mode!=="normal",onSelect:He},{id:"prompt.mode.shell",title:u.t("command.prompt.mode.shell"),category:u.t("command.category.session"),keybind:Z,disabled:T.mode==="shell",onSelect:()=>Ue("shell")},{id:"prompt.mode.normal",title:u.t("command.prompt.mode.normal"),category:u.t("command.category.session"),keybind:ce,disabled:T.mode==="normal",onSelect:()=>Ue("normal")}]);const G=()=>D({popover:null,slashMenu:!1,slashMenuQuery:""}),fe=(Y=!1)=>{!Y&&(T.historyIndex<0||T.applyingHistory)||(D("historyIndex",-1),D("savedPrompt",null))},xe=()=>{m.innerHTML=""},Oe=Y=>{xe(),m.textContent=Y},re=()=>{requestAnimationFrame(()=>{m.focus();const Y=document.createRange(),Ce=window.getSelection();Y.selectNodeContents(m),Y.collapse(!1),Ce?.removeAllRanges(),Ce?.addRange(Y)})},pe=()=>{const Y=window.getSelection();return!Y||Y.rangeCount===0||!m.contains(Y.anchorNode)?null:Ac(m)},ye=()=>{requestAnimationFrame(()=>{const Y=b??i.cursor()??Ho(i.current());m.focus(),rl(m,Y),C()})},Re=()=>{v&&(v=!1,requestAnimationFrame(()=>{document.activeElement===m&&(rl(m,i.cursor()??Ho(i.current())),C())}))},Je=Y=>{const Ce=pe();lr(Y),Ce!==null&&rl(m,Ce)};ae(()=>{if(e.controls.session.id,e.controls.session.id||!ie())return;const Y=setInterval(()=>{D("placeholder",Ce=>(Ce+1)%JS.length)},6500);Te(()=>clearInterval(Y))});const[Xe,je]=De(!1),mt=Y=>Y.isComposing||Xe()||Y.keyCode===229,Et=()=>{const Y=pe();b=Y,Y!==null&&Y!==i.cursor()&&i.set(i.current(),Y),G(),je(!1)},Bt=()=>{je(!0)},Qe=()=>{je(!1),requestAnimationFrame(()=>{Xe()||Ss(i.current().filter(Y=>Y.type!=="image"))})},Be=Y=>Y.source.type==="git"?Y.source.repository:Y.source.path,et=I(()=>n().data.reference.filter(Y=>!Y.hidden).map(Y=>({type:"reference",name:Y.name,path:Y.path,display:Y.name,description:Y.description??Be(Y)}))),un=I(()=>e.controls.agents.available.filter(Y=>!Y.hidden&&Y.mode!=="primary").map(Y=>({type:"agent",name:Y.name,display:Y.name}))),xn=I(()=>Object.values(n().data.mcp_resource).map(Y=>({type:"resource",name:Y.name,uri:Y.uri,client:Y.server,display:Y.name,description:Y.description,mime:Y.mimeType}))),In=Y=>{if(Y){if(Y.type==="agent"){Pr({type:"agent",name:Y.name,content:"@"+Y.name});return}if(Y.type==="reference"){Pr({type:"file",path:Y.path,content:"@"+Y.name,mime:"application/x-directory",filename:Y.name});return}if(Y.type==="resource"){Pr({type:"file",path:Y.uri,content:"@"+Y.name,mime:Y.mime??"text/plain",filename:Y.name,url:Y.uri,source:{type:"resource",text:{value:"@"+Y.name,start:0,end:0},clientName:Y.client,uri:Y.uri}});return}Pr({type:"file",path:Y.path,content:"@"+Y.path})}},Hn=Y=>Y?Y.type==="agent"?`agent:${Y.name}`:Y.type==="reference"?`reference:${Y.name}`:Y.type==="resource"?`resource:${Y.client}:${Y.uri}`:`file:${Y.path}`:"",{flat:er,active:Lt,setActive:Nn,onInput:Vn,onKeyDown:$r}=th({items:async Y=>{const Ce=et(),Fe=un(),qe=xn(),_t=O(),Zt=new Set(_t),It=_t.map(Tn=>({type:"file",path:Tn,display:Tn,recent:!0}));if(!Y.trim())return[...Ce,...Fe,...qe,...It];const Pt=(await r.searchFilesAndDirectories(Y)).filter(Tn=>!Zt.has(Tn)).map(Tn=>({type:"file",path:Tn,display:Tn}));return[...Ce,...Fe,...qe,...It,...Pt]},key:Hn,filterKeys:["display"],skipFilter:Y=>Y.type==="file"&&!Y.recent,groupBy:Y=>Y.type==="reference"?"reference":Y.type==="agent"?"agent":Y.type==="resource"?"resource":Y.recent?"recent":"file",sortGroupsBy:(Y,Ce)=>{const Fe=qe=>qe==="reference"?0:qe==="agent"?1:qe==="resource"?2:qe==="recent"?3:4;return Fe(Y.category)-Fe(Ce.category)},onSelect:In}),gs=I(()=>{const Y=l.options.filter(Fe=>!Fe.disabled&&!Fe.id.startsWith("suggested.")&&Fe.slash).map(Fe=>({id:Fe.id,trigger:Fe.slash,title:Fe.title,description:Fe.description,keybind:Fe.keybind,type:"builtin"}));return[...n().data.command.map(Fe=>({id:`custom.${Fe.name}`,trigger:Fe.name,title:Fe.name,description:Fe.description,type:"custom"})),...Y]}),$n=Y=>{if(!Y)return;const Ce=T.slashMenu;G();const Fe=P();if(Y.type==="custom"){const qe=`/${Y.trigger} `;if(Ce){m.focus(),rl(m,0),Pr({type:"text",content:qe}),re();return}Oe(qe),i.set([{type:"text",content:qe,start:0,end:qe.length},...Fe],qe.length),re();return}if(Ce){l.trigger(Y.id,"slash");return}xe(),i.set([...Vm,...Fe],0),l.trigger(Y.id,"slash")},{flat:Ur,active:es,setActive:go,onInput:Li,onKeyDown:Wr}=th({items:gs,key:Y=>Y?.id,filterKeys:["trigger","title"],onSelect:$n}),Zr=Y=>{const Ce=document.createElement("span");return Ce.textContent=Y.content,Ce.setAttribute("data-type",Y.type),Y.type==="file"&&(Ce.setAttribute("data-path",Y.path),Y.mime&&Ce.setAttribute("data-mime",Y.mime),Y.filename&&Ce.setAttribute("data-filename",Y.filename),Y.url&&Ce.setAttribute("data-url",Y.url),Y.source?.type==="resource"&&(Ce.setAttribute("data-source-type",Y.source.type),Ce.setAttribute("data-source-client-name",Y.source.clientName),Ce.setAttribute("data-source-uri",Y.source.uri))),Y.type==="agent"&&Ce.setAttribute("data-name",Y.name),Ce.setAttribute("contenteditable","false"),Ce.style.userSelect="text",Ce.style.cursor="default",Ce},bi=()=>Array.from(m.childNodes).every(Y=>{if(Y.nodeType===Node.TEXT_NODE){const Fe=Y.textContent??"";if(!Fe.includes("​"))return!0;if(Fe!=="​")return!1;const qe=Y.previousSibling,_t=Y.nextSibling;return!!(qe?.nodeType===Node.ELEMENT_NODE&&qe.tagName==="BR")&&!_t}if(Y.nodeType!==Node.ELEMENT_NODE)return!1;const Ce=Y;return Ce.dataset.type==="file"||Ce.dataset.type==="agent"?!0:Ce.tagName==="BR"}),lr=Y=>{xe();for(const Fe of Y){if(Fe.type==="text"){m.appendChild(MF(Fe.content));continue}(Fe.type==="file"||Fe.type==="agent")&&m.appendChild(Zr(Fe))}const Ce=m.lastChild;Ce?.nodeType===Node.ELEMENT_NODE&&Ce.tagName==="BR"&&m.appendChild(document.createTextNode("​"))},ui=()=>{const Y=es();!Y||!y||requestAnimationFrame(()=>{y.querySelector(`[data-slash-id="${Y}"]`)?.scrollIntoView({block:"nearest",behavior:"smooth"})})},js=()=>{if(T.popover==="at"){const Y=er();if(Y.length===0)return;const Ce=Lt(),Fe=Y.find(qe=>Hn(qe)===Ce)??Y[0];In(Fe);return}if(T.popover==="slash"){const Y=Ur();if(Y.length===0)return;const Ce=es(),Fe=Y.find(qe=>qe.id===Ce)??Y[0];$n(Fe)}},Ss=Y=>{if(w.input){if(w.input=!1,bi())return;Je(Y);return}const Ce=Ni();bi()&&UK(Y,Ce)||Je(Y)};ae(vt(()=>i.current(),Y=>{Xe()||Ss(Y.filter(Ce=>Ce.type!=="image"))}));const Ni=()=>{const Y=[];let Ce=0,Fe="";const qe=()=>{let Pt=Fe;Pt.includes("\r")&&(Pt=Pt.replace(/\r\n?/g,`
1162
1162
  `)),Pt.includes("​")&&(Pt=Pt.replace(/\u200B/g,"")),Fe="",Pt&&(Y.push({type:"text",content:Pt,start:Ce,end:Ce+Pt.length}),Ce+=Pt.length)},_t=Pt=>{const Tn=Pt.textContent??"",di=Pt.dataset.sourceType==="resource"&&Pt.dataset.sourceClientName&&Pt.dataset.sourceUri?{type:"resource",text:{value:Tn,start:Ce,end:Ce+Tn.length},clientName:Pt.dataset.sourceClientName,uri:Pt.dataset.sourceUri}:void 0;Y.push({type:"file",path:Pt.dataset.path,content:Tn,start:Ce,end:Ce+Tn.length,...Pt.dataset.mime?{mime:Pt.dataset.mime}:{},...Pt.dataset.filename?{filename:Pt.dataset.filename}:{},...Pt.dataset.url?{url:Pt.dataset.url}:{},...di?{source:di}:{}}),Ce+=Tn.length},Zt=Pt=>{const Tn=Pt.textContent??"";Y.push({type:"agent",name:Pt.dataset.name,content:Tn,start:Ce,end:Ce+Tn.length}),Ce+=Tn.length},It=Pt=>{if(Pt.nodeType===Node.TEXT_NODE){Fe+=Pt.textContent??"";return}if(Pt.nodeType!==Node.ELEMENT_NODE)return;const Tn=Pt;if(Tn.dataset.type==="file"){qe(),_t(Tn);return}if(Tn.dataset.type==="agent"){qe(),Zt(Tn);return}if(Tn.tagName==="BR"){Fe+=`
1163
1163
  `;return}for(const di of Array.from(Tn.childNodes))It(di)},jt=Array.from(m.childNodes);return jt.forEach((Pt,Tn)=>{const di=Pt.nodeType===Node.ELEMENT_NODE&&["DIV","P"].includes(Pt.tagName);It(Pt),di&&Tn<jt.length-1&&(Fe+=`
1164
1164
  `)}),qe(),Y.length===0&&Y.push(...Vm),Y},$o=()=>{const Y=Ni(),Ce=P(),Fe=Ac(m),qe=Y.length===1&&Y[0]?.type==="text"?Y[0].content:Y.map(Pt=>"content"in Pt?Pt.content:"").join(""),_t=Y.some(Pt=>Pt.type!=="text");if((m.textContent??"").replace(/\u200B/g,"").length===0&&qe.replace(/\n/g,"").length===0&&!_t&&Ce.length===0){G(),fe(),i.dirty()&&(w.input=!0,i.set(Vm,0)),C();return}if(T.mode==="shell")G();else{const Pt=qe.substring(0,Fe).match(/@(\S*)$/),Tn=qe.match(/^\/(\S*)$/);Pt?(Vn(Pt[1]),D({popover:"at",slashMenu:!1,slashMenuQuery:""})):Tn?(Li(Tn[1]),D({popover:"slash",slashMenu:!1,slashMenuQuery:""})):G()}fe(),w.input=!0,i.set([...Y,...Ce],Fe),C()},Pr=Y=>{if(Y.type==="image")return!1;const Ce=window.getSelection();if(!Ce)return!1;if(Ce.rangeCount===0||!m.contains(Ce.anchorNode)){m.focus();const qe=i.cursor()??Ho(i.current());rl(m,qe)}if(Ce.rangeCount===0)return!1;const Fe=Ce.getRangeAt(0);if(!m.contains(Fe.startContainer))return!1;if(Y.type==="file"||Y.type==="agent"){const qe=Ac(m),It=i.current().map(Tn=>"content"in Tn?Tn.content:"").join("").substring(0,qe).match(/@(\S*)$/),jt=Zr(Y),Pt=document.createTextNode(" ");if(It){const Tn=It.index??qe-It[0].length;$F(m,Fe,"start",Tn),$F(m,Fe,"end",qe)}Fe.deleteContents(),Fe.insertNode(Pt),Fe.insertNode(jt),Fe.setStartAfter(Pt),Fe.collapse(!0),Ce.removeAllRanges(),Ce.addRange(Fe)}if(Y.type==="text"){const qe=MF(Y.content),_t=qe.lastChild;if(Fe.deleteContents(),Fe.insertNode(qe),_t){if(_t.nodeType===Node.TEXT_NODE){const Zt=_t.textContent??"";Zt==="​"&&Fe.setStart(_t,0),Zt!=="​"&&Fe.setStart(_t,Zt.length)}if(_t.nodeType!==Node.TEXT_NODE){const Zt=_t.nodeType===Node.ELEMENT_NODE&&_t.tagName==="BR",It=_t.nextSibling,jt=It?.nodeType===Node.TEXT_NODE&&(It.textContent??"")==="";if(Zt&&(!It||jt)){const Pt=It&&jt?It:document.createTextNode("​");It||_t.parentNode?.insertBefore(Pt,null),Pt.textContent="​",Fe.setStart(Pt,0)}else Fe.setStartAfter(_t)}}Fe.collapse(!0),Ce.removeAllRanges(),Ce.addRange(Fe)}return $o(),G(),!0},Po=(Y,Ce)=>{ne.add(Y,Ce,Ce==="shell"?[]:ge())};ae(vt(()=>e.edit?.id,Y=>{const Ce=e.edit;if(!(!Y||!Ce)){for(const Fe of i.context.items())i.context.remove(Fe.key);for(const Fe of Ce.context)i.context.add({type:Fe.type,path:Fe.path,selection:Fe.selection,comment:Fe.comment,commentID:Fe.commentID,commentOrigin:Fe.commentOrigin,preview:Fe.preview});D("mode","normal"),G(),D("historyIndex",-1),D("savedPrompt",null),i.set(Ce.prompt,Ho(Ce.prompt)),requestAnimationFrame(()=>{m.focus(),rl(m,Ho(Ce.prompt)),C()}),e.onEditLoaded?.()}},{defer:!0}));const pa=Y=>{const Ce=fGe({direction:Y,entries:ne.entries(T.mode),historyIndex:T.historyIndex,currentPrompt:i.current(),currentComments:ge(),savedPrompt:T.savedPrompt});return Ce.handled?(D("historyIndex",Ce.historyIndex),D("savedPrompt",Ce.savedPrompt),Me(Ce.entry,Ce.cursor),!0):!1},{addAttachment:Za,addAttachments:Oo,removeAttachment:Ya,handlePaste:Ht}=iGe({prompt:i,editor:()=>m,isDialogActive:()=>!!a.active,setDraggingType:Y=>D("draggingType",Y),focusEditor:()=>{m.focus(),rl(m,Ho(i.current()))},addPart:Pr,readClipboardImage:d.readClipboardImage,getPathForFile:d.getPathForFile}),Ie=I(()=>["default",...e.controls.model.selection.variant.list()]),st=I(()=>e.controls.model.selection.variant.list().length>0),Ft=I(()=>{const Y=e.controls.session.id;return Y?c.isAutoAccepting(Y,t().directory):c.isAutoAcceptingDirectory(t().directory)}),{abort:Rn,handleSubmit:_n}=e.submission??cne({prompt:i,info:$,imageAttachments:P,commentCount:W,autoAccept:()=>Ft(),mode:()=>T.mode,working:V,editor:()=>m,queueScroll:C,promptLength:Ho,addToHistory:Po,resetHistoryNavigation:()=>{fe(!0)},setMode:Y=>D("mode",Y),setPopover:Y=>{if(!Y)return G();D({popover:Y,slashMenu:!1,slashMenuQuery:""})},newSessionWorktree:()=>e.newSessionWorktree,onNewSessionWorktreeReset:e.onNewSessionWorktreeReset,shouldQueue:e.shouldQueue,onQueue:e.onQueue,onAbort:e.onAbort,onSubmit:e.onSubmit,model:e.controls.model.selection}),pr=Y=>{if((Y.metaKey||Y.ctrlKey)&&!Y.altKey&&!Y.shiftKey&&Y.key.toLowerCase()==="u"){if(Y.preventDefault(),T.mode!=="normal")return;He();return}if(Y.key==="Backspace"){const Fe=window.getSelection();if(Fe&&Fe.isCollapsed){const qe=Fe.anchorNode,_t=Fe.anchorOffset;if(qe&&qe.nodeType===Node.TEXT_NODE){const Zt=qe.textContent??"";if(/^\u200B+$/.test(Zt)&&_t>0){const It=document.createRange();It.setStart(qe,0),It.collapse(!0),Fe.removeAllRanges(),Fe.addRange(It)}}}}if(Y.key==="!"&&T.mode==="normal"&&Ac(m)===0){D("mode","shell"),G(),Y.preventDefault();return}if(Y.key==="Escape"){if(T.popover){G(),Y.preventDefault(),Y.stopPropagation();return}if(T.mode==="shell"){D("mode","normal"),Y.preventDefault(),Y.stopPropagation();return}if(V()){Rn(),Y.preventDefault(),Y.stopPropagation();return}if(U()){m.blur(),Y.preventDefault(),Y.stopPropagation();return}}if(T.mode==="shell"){const{collapsed:Fe,cursorPosition:qe,textLength:_t}=de();if(Y.key==="Backspace"&&Fe&&qe===0&&_t===0){D("mode","normal"),Y.preventDefault();return}}if(Y.key==="Enter"&&Y.shiftKey){Pr({type:"text",content:`
1165
- `}),Y.preventDefault();return}if(Y.key==="Enter"&&mt(Y))return;const Ce=Y.ctrlKey&&!Y.metaKey&&!Y.altKey&&!Y.shiftKey;if(T.popover){if(Y.key==="Tab"){js(),Y.preventDefault();return}const Fe=Y.key==="ArrowUp"||Y.key==="ArrowDown"||Y.key==="Enter",qe=Ce&&(Y.key==="n"||Y.key==="p");if(Fe||qe){if(T.popover==="at"){$r(Y),Y.preventDefault();return}T.popover==="slash"&&(Wr(Y),(Y.key==="ArrowUp"||Y.key==="ArrowDown"||qe)&&ui()),Y.preventDefault();return}}if(Ce&&Y.code==="KeyG"){if(T.popover){G(),Y.preventDefault();return}V()&&(Rn(),Y.preventDefault());return}if(Y.key==="ArrowUp"||Y.key==="ArrowDown"){if(Y.altKey||Y.ctrlKey||Y.metaKey)return;const{collapsed:Fe}=de();if(!Fe)return;const qe=Ac(m),_t=i.current().map(It=>"content"in It?It.content:"").join(""),Zt=Y.key==="ArrowUp"?"up":"down";if(!aGe(Zt,_t,qe,T.historyIndex>=0))return;pa(Zt)&&Y.preventDefault();return}if(Y.key==="Enter"&&!Y.shiftKey){if(Y.preventDefault(),Y.repeat||V()&&i.current().map(Fe=>"content"in Fe?Fe.content:"").join("").trim().length===0&&P().length===0&&W()===0)return;_n(Y)}},ti=Y=>{if(Y.key==="Escape"){G(),requestAnimationFrame(()=>m.focus()),Y.preventDefault();return}if(Y.key==="Tab"){js(),Y.preventDefault();return}const Ce=Y.ctrlKey&&!Y.metaKey&&!Y.altKey&&!Y.shiftKey,Fe=Y.key==="ArrowUp"||Y.key==="ArrowDown"||Y.key==="Enter",qe=Ce&&(Y.key==="n"||Y.key==="p");!Fe&&!qe||(Wr(Y),(Y.key==="ArrowUp"||Y.key==="ArrowDown"||qe)&&ui(),Y.preventDefault())},_e=()=>e.controls.agents.loading,nt=I(Y=>Y??_e()),Ge=()=>e.controls.model.loading,Ye=I(Y=>Y??Ge()),[$t]=ai(()=>i.ready.promise,Y=>Y),Rt=Y=>{m=Y,v=!0,e.ref?.(Y)};return(()=>{var Y=VZe();return S(Y,()=>($t(),null),null),S(Y,h(YGe,{get popover(){return T.popover},setSlashPopoverRef:Ce=>y=Ce,get atFlat(){return er()},get atActive(){return Lt()??void 0},atKey:Hn,setAtActive:Nn,onAtSelect:In,get slashFlat(){return Ur()},get slashActive(){return es()??void 0},setSlashActive:go,onSlashSelect:$n,get slashMenu(){return T.slashMenu},get slashMenuQuery(){return T.slashMenuQuery},onSlashMenuInput:Ce=>{D("slashMenuQuery",Ce),Li(Ce)},onSlashMenuKeyDown:ti,get commandKeybind(){return l.keybind},get commandKeybindParts(){return l.keybindParts},newLayoutDesigns:!1,t:Ce=>u.t(Ce)}),null),S(Y,h(jWe,{"data-dock-border-underlay":"legacy",onSubmit:_n,get classList(){return{"group/prompt-input":!0,"border-icon-info-active border-dashed":T.draggingType!==null,[e.class??""]:!!e.class}},get children(){return[h(_Ze,{get type(){return T.draggingType},get label(){return u.t(T.draggingType==="@mention"?"prompt.dropzone.file.label":"prompt.dropzone.label")}}),h(nZe,{get items(){return te()},active:Ce=>{const Fe=o.active();return!!Ce.commentID&&Ce.commentID===Fe?.id&&Ce.path===Fe?.file},openComment:L,remove:Ce=>{Ce.commentID&&o.remove(Ce.path,Ce.commentID),i.context.remove(Ce.key)},newLayoutDesigns:!1,t:Ce=>u.t(Ce)}),h(SZe,{get attachments(){return P()},onOpen:Ce=>a.show(()=>h(MI,{get src(){return Ce.dataUrl},get alt(){return Ce.filename}})),onRemove:Ya,get removeLabel(){return u.t("prompt.attachment.remove")},newLayoutDesigns:!1}),(()=>{var Ce=PZe(),Fe=Ce.firstChild,qe=Fe.firstChild,_t=qe.nextSibling,Zt=Fe.nextSibling,It=Zt.nextSibling,jt=It.firstChild,Pt=jt.nextSibling,Tn=It.nextSibling,di=Tn.firstChild;Ce.$$mousedown=Yn=>{const Cs=Yn.target;Cs instanceof HTMLElement&&(Cs.closest('[data-action="prompt-attach"], [data-action="prompt-submit"]')||m?.focus())},pt(Yn=>p=Yn,Fe),qe.$$keydown=pr,qe.addEventListener("blur",Et),qe.addEventListener("focus",Re),qe.addEventListener("compositionend",Qe),qe.addEventListener("compositionstart",Bt),cn(qe,"paste",Ht),qe.$$input=$o,pt(Rt,qe),S(_t,ke),jt.addEventListener("change",Yn=>{const Cs=Yn.currentTarget.files;Cs&&Oo(Array.from(Cs)),Yn.currentTarget.value=""});var qs=g;return typeof qs=="function"?pt(qs,jt):g=jt,S(Pt,h(Ar,{placement:"top",get inactive(){return we(()=>!V())()&&J()},get value(){return X()},get children(){return h(Ln,{"data-action":"prompt-submit",type:"submit",get disabled(){return we(()=>!V())()&&J()},get tabIndex(){return T.mode==="normal"?void 0:-1},get icon(){return we(()=>!!K())()?"stop":T.mode==="shell"?"arrow-undo-down":"arrow-up"},variant:"primary",class:"size-8",get"aria-label"(){return we(()=>!!K())()?u.t("prompt.action.stop"):u.t("prompt.action.send")}})}})),S(di,h(ws,{placement:"top",get title(){return u.t("prompt.action.attachFile")},get keybind(){return l.keybind("file.attach")},get children(){return h(Kt,{"data-action":"prompt-attach",type:"button",variant:"ghost",class:"size-8 p-0",get style(){return F()},onClick:He,get disabled(){return T.mode!=="normal"},get tabIndex(){return T.mode==="normal"?void 0:-1},get"aria-label"(){return u.t("prompt.action.attachFile")},get children(){return h(Yt,{name:"plus",class:"size-4.5"})}})}})),he(Yn=>{var Cs=ke(),Ih=T.mode==="normal"?"sentences":"off",zd=T.mode==="normal"?"on":"off",yu=T.mode==="normal",c0={"select-text":!0,"w-full pl-3 pr-2 pt-2 text-14-regular text-text-strong focus:outline-none whitespace-pre-wrap":!0,"[&_[data-type=file]]:text-syntax-property":!0,"[&_[data-type=agent]]:text-syntax-type":!0,"font-mono!":T.mode==="shell"},bu=T.mode==="shell",wu=i.dirty()?"none":void 0,Dh=EI.join(","),Xa=T.mode!=="normal",oe=N()>.5?"auto":"none";return Cs!==Yn.e&&me(qe,"aria-label",Yn.e=Cs),Ih!==Yn.t&&me(qe,"autocapitalize",Yn.t=Ih),zd!==Yn.a&&me(qe,"autocorrect",Yn.a=zd),yu!==Yn.o&&me(qe,"spellcheck",Yn.o=yu),Yn.i=ct(qe,c0,Yn.i),bu!==Yn.n&&_t.classList.toggle("font-mono!",Yn.n=bu),wu!==Yn.s&&Ct(_t,"display",Yn.s=wu),Dh!==Yn.h&&me(jt,"accept",Yn.h=Dh),Xa!==Yn.r&&me(di,"aria-hidden",Yn.r=Xa),oe!==Yn.d&&Ct(di,"pointer-events",Yn.d=oe),Yn},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0}),Ce})()]}}),null),S(Y,h(q,{get when(){return T.mode==="normal"||T.mode==="shell"},get children(){return h(yy,{attach:"top",get children(){var Ce=NZe(),Fe=Ce.firstChild,qe=Fe.firstChild,_t=qe.firstChild;_t.nextSibling;var Zt=qe.nextSibling;return S(qe,h(Yt,{name:"console"}),_t),S(_t,()=>u.t("prompt.mode.shell")),S(qe,h(Kt,{variant:"ghost",class:"text-text-base",onClick:()=>{D("mode","normal")},get children(){return u.t("common.cancel")}}),null),S(Zt,h(q,{get when(){return!_e()},get children(){var It=OZe();return S(It,h(ws,{placement:"top",gutter:4,get title(){return u.t("command.agent.cycle")},get keybind(){return l.keybind("agent.cycle")},get children(){return h(aC,{size:"normal",get options(){return e.controls.agents.options},get current(){return e.controls.agents.current},onSelect:jt=>{e.controls.agents.select(jt),ye()},class:"capitalize max-w-[160px] text-text-base",valueClass:"truncate text-13-regular text-text-base",get triggerStyle(){return z()},triggerProps:{"data-action":"prompt-agent"},variant:"ghost"})}})),he(jt=>ct(It,{"animate-in fade-in duration-300":nt()},jt)),It}}),null),S(Zt,h(q,{get when(){return!Ge()},get children(){return h(q,{get when(){return T.mode!=="shell"},get children(){return[(()=>{var It=RZe();return S(It,h(q,{get when(){return e.controls.model.paid},get fallback(){return h(ws,{placement:"top",gutter:4,get title(){return u.t("command.model.choose")},get keybind(){return l.keybind("model.choose")},get children(){return h(Kt,{"data-action":"prompt-model",as:"div",variant:"ghost",size:"normal",class:"min-w-0 max-w-[320px] text-13-regular text-text-base group",get style(){return z()},onClick:()=>{a.show(()=>h(FKe,{get model(){return e.controls.model.selection}}))},get children(){return[h(q,{get when(){return e.controls.model.selection.current()?.provider?.id},get children(){return h(wg,{get id(){return e.controls.model.selection.current()?.provider?.id??""},class:"size-4 shrink-0 opacity-40 group-hover:opacity-100 transition-opacity duration-150",style:{"will-change":"opacity",transform:"translateZ(0)"}})}}),(()=>{var jt=zF();return S(jt,()=>e.controls.model.selection.current()?.name??u.t("dialog.model.select.title")),jt})(),h(Yt,{name:"chevron-down",size:"small",class:"shrink-0"})]}})}})},get children(){return h(ws,{placement:"top",gutter:4,get title(){return u.t("command.model.choose")},get keybind(){return l.keybind("model.choose")},get children(){return h(Jte,{get model(){return e.controls.model.selection},triggerAs:Kt,get triggerProps(){return{variant:"ghost",size:"normal",style:z(),class:"min-w-0 max-w-[320px] text-13-regular text-text-base group","data-action":"prompt-model"}},onClose:ye,get children(){return[h(q,{get when(){return e.controls.model.selection.current()?.provider?.id},get children(){return h(wg,{get id(){return e.controls.model.selection.current()?.provider?.id??""},class:"size-4 shrink-0 opacity-40 group-hover:opacity-100 transition-opacity duration-150",style:{"will-change":"opacity",transform:"translateZ(0)"}})}}),(()=>{var jt=zF();return S(jt,()=>e.controls.model.selection.current()?.name??u.t("dialog.model.select.title")),jt})(),h(Yt,{name:"chevron-down",size:"small",class:"shrink-0"})]}})}})}})),he(jt=>ct(It,{"animate-in fade-in duration-300":Ye()},jt)),It})(),h(q,{get when(){return st()},get children(){var It=FZe();return S(It,h(ws,{placement:"top",gutter:4,get title(){return u.t("command.model.variant.cycle")},get keybind(){return l.keybind("model.variant.cycle")},get children(){return h(aC,{size:"normal",get options(){return Ie()},get current(){return e.controls.model.selection.variant.current()??"default"},label:jt=>jt==="default"?u.t("common.default"):jt,onSelect:jt=>{e.controls.model.selection.variant.set(jt==="default"?void 0:jt),ye()},class:"capitalize max-w-[160px] text-text-base",valueClass:"truncate text-13-regular text-text-base",get triggerStyle(){return z()},triggerProps:{"data-action":"prompt-model-variant"},variant:"ghost"})}})),he(jt=>ct(It,{"animate-in fade-in duration-300":Ye()},jt)),It}})]}})}}),null),he(It=>So(qe,{...j()},It)),Ce}})}}),null),Y})()};dn(["mousedown","input","keydown"]);var HZe=A("<div data-slot=dialog-footer>"),jZe=A("<div data-slot=dialog-body>"),qZe=A("<div data-slot=dialog-title-group>"),BZe=A("<div data-slot=dialog-header>"),UZe=A('<svg width=16 height=16 viewBox="0 0 16 16"fill=none xmlns=http://www.w3.org/2000/svg aria-hidden=true><path d="M12.4446 3.55469L3.55566 12.4436M3.55566 3.55469L12.4446 12.4436"stroke=currentColor stroke-linejoin=round>'),WZe=A("<div data-component=dialog-v2><div data-slot=dialog-container>");function fne(e){return(()=>{var t=HZe();return S(t,()=>e.children),t})()}function hne(e){const[t]=Ee(e,["class","children"]);return(()=>{var n=jZe();return S(n,()=>t.children),he(()=>xr(n,t.class)),n})()}function mne(e){return h(Qs.Title,{"data-slot":"dialog-header-title",get children(){return e.children}})}function KZe(e){const t=Jl(()=>e.title),n=Jl(()=>e.description);return(()=>{var r=qZe();return S(r,h(q,{get when(){return t()},children:i=>h(Qs.Title,{"data-slot":"dialog-title",get children(){return i()}})}),null),S(r,h(Qs.Description,{"data-slot":"dialog-description",get children(){return n()}}),null),r})()}function $I(e){const[t]=Ee(e,["closeLabel","hideClose","children"]),n=()=>t.hideClose===!0;return(()=>{var r=BZe();return S(r,()=>t.children,null),S(r,(()=>{var i=we(()=>!n());return()=>i()&&h(Qs.CloseButton,{"data-slot":"dialog-close-button",get"aria-label"(){return t.closeLabel??"Close"},get children(){return UZe()}})})(),null),he(()=>me(r,"data-hide-close",n()?"":void 0)),r})()}function gne(e){const[t]=Ee(e,["size","variant","class","containerClass","classList","fit","children"]);return(()=>{var n=WZe(),r=n.firstChild;return S(r,h(Qs.Content,{"data-slot":"dialog-content",get classList(){return{...t.classList,[t.class??""]:!!t.class}},onOpenAutoFocus:i=>{const o=i.currentTarget?.querySelector("[autofocus]");o&&(i.preventDefault(),o.focus({preventScroll:!0}))},get children(){return t.children}})),he(i=>{var s=t.variant==="settings"?"settings":void 0,o=t.fit?!0:void 0,a=t.size||"normal",l=t.containerClass;return s!==i.e&&me(n,"data-variant",i.e=s),o!==i.t&&me(n,"data-fit",i.t=o),a!==i.a&&me(n,"data-size",i.a=a),l!==i.o&&xr(r,i.o=l),i},{e:void 0,t:void 0,a:void 0,o:void 0}),n})()}const pne=gne;var GZe=A(`<div class="flex min-h-0 flex-col"><div data-section=free-models class="flex w-full flex-col items-start pb-3"><div class="flex h-8 w-full flex-none select-none flex-row items-center px-3 pb-2"><div class="flex h-5 items-center text-[13px] font-[440] leading-5 tracking-[-0.04px] text-v2-text-text-muted [font-family:var(--v2-font-family-sans)] [font-variant-numeric:tabular-nums] [font-variation-settings:'slnt'_0]"></div></div></div><div class="flex w-full flex-col"><div class="flex w-full flex-col items-start rounded-lg border-[0.5px] border-v2-border-border-muted bg-v2-background-bg-layer-02 p-2.5 pt-2"><div class="flex h-8 w-full select-none items-center px-0.5 pb-2"><div class="flex h-5 items-center text-[13px] font-[440] leading-5 tracking-[-0.04px] text-v2-text-text-muted [font-family:var(--v2-font-family-sans)] [font-variant-numeric:tabular-nums] [font-variation-settings:'slnt'_0]"></div></div><div class="grid w-full grid-cols-1 gap-y-1.5 gap-x-2 sm:grid-cols-2"><button type=button class="col-span-full flex h-8 w-full scroll-my-3.5 items-center justify-start rounded-md px-3 text-left text-[13px] font-[440] leading-5 tracking-[-0.04px] text-v2-text-text-muted [font-family:var(--v2-font-family-sans)] [font-variation-settings:'slnt'_0] hover:bg-v2-overlay-simple-overlay-hover focus:bg-v2-overlay-simple-overlay-hover focus:outline-none">`),ZZe=A(`<button type=button class="flex w-full scroll-my-3.5 flex-row items-center gap-1.5 rounded-md px-3 py-2 text-left text-[13px] font-[530] leading-5 tracking-[-0.04px] text-v2-text-text-base [font-family:var(--v2-font-family-sans)] [font-variation-settings:'slnt'_0] hover:bg-v2-overlay-simple-overlay-hover focus:bg-v2-overlay-simple-overlay-hover focus:outline-none"><span class="min-w-0 truncate">`),YZe=A('<span class="truncate font-[440] text-v2-text-text-muted">'),XZe=A(`<button type=button class="flex min-h-11 w-full scroll-my-3.5 flex-row items-start gap-2 rounded-md bg-v2-background-bg-base px-3 py-2.5 text-left text-[13px] font-[530] leading-5 tracking-[-0.04px] text-v2-text-text-base [font-family:var(--v2-font-family-sans)] [font-variation-settings:'slnt'_0] hover:bg-v2-background-bg-layer-01 focus:bg-v2-background-bg-layer-01 focus:outline-none"><span class="flex min-w-0 flex-col"><span class=truncate>`);const e6=["opencode","opencode-go","openai","anthropic","google","github-copilot"],HF=e=>e.replace(/\s+(?:\(free\)|free)$/i,""),QZe=e=>{const t=El(),n=e.model??t.model,r=Mr(),i=h9(),s=()=>Ns(t.slug()),o=$d(s),a=wt(),l=p=>`${p.provider.id}:${p.id}`,c=I(()=>{const p=n.current();return p?`${p.provider.id}:${p.id}`:void 0}),u=p=>p.provider.id==="opencode"&&(!p.cost||p.cost.input===0),d=I(()=>n.list().filter(u)),f=p=>{B(()=>import("./dialog-connect-provider-DLnpNUTc.js").then(y=>y.d),[]).then(y=>{const v=y.useProviderConnectController();v.select(p),r.show(()=>h(y.DialogConnectProvider,{controller:v,directory:s}))})},m=p=>{n.set({modelID:p.id,providerID:p.provider.id},{recent:!0}),r.close()};let g;return sn(()=>{const p=y=>{if(y.key!=="ArrowDown"&&y.key!=="ArrowUp"||!g)return;const v=Array.from(g.querySelectorAll("button"));if(v.length===0)return;const b=v.indexOf(document.activeElement),w=b<0?y.key==="ArrowDown"?0:v.length-1:b+(y.key==="ArrowDown"?1:-1);v[(w+v.length)%v.length]?.focus(),y.preventDefault()};document.addEventListener("keydown",p),Te(()=>document.removeEventListener("keydown",p))}),h(pne,{fit:!0,containerClass:"!h-auto max-h-[calc(100vh_-_16px)] !w-[min(calc(100vw_-_16px),640px)]",class:"[font-family:var(--v2-font-family-sans)] [&_[data-slot=dialog-header]]:!px-5 [&_[data-slot=dialog-header-title]]:!text-[15px] [&_[data-slot=dialog-header-title]]:!tracking-[-0.13px]",get children(){return[h($I,{get closeLabel(){return a.t("common.close")},get children(){return h(mne,{get children(){return a.t("dialog.model.select.title")}})}}),h(hne,{class:"max-h-[calc(100vh_-_68px)] min-h-0 flex-none gap-0 overflow-y-auto px-2 pb-2",get children(){var p=GZe(),y=p.firstChild,v=y.firstChild,b=v.firstChild,w=y.nextSibling,x=w.firstChild,k=x.firstChild,C=k.firstChild,E=k.nextSibling,_=E.firstChild,L=g;return typeof L=="function"?pt(L,p):g=p,S(b,()=>a.t("dialog.model.unpaid.freeModels.title")),S(y,h(Dt,{get each(){return d()},children:O=>h(Qn,{class:"w-full",placement:"right-start",gutter:6,openDelay:0,contentStyle:{"font-family":"var(--v2-font-family-sans)"},get value(){return h(e3,{get model(){return{...O,name:HF(O.name)}},get latest(){return O.latest},get free(){return u(O)},v2:!0})},get children(){var $=ZZe(),V=$.firstChild;return $.$$click=()=>m(O),S(V,()=>HF(O.name)),S($,h(m1,{class:"shrink-0",get children(){return a.t("model.tag.free")}}),null),S($,h(q,{get when(){return O.latest},get children(){return h(m1,{class:"shrink-0",get children(){return a.t("model.tag.latest")}})}}),null),S($,h(q,{get when(){return c()===l(O)},get children(){return h(on,{name:"check",class:"ml-auto size-4 shrink-0 text-v2-icon-icon-base"})}}),null),$}})}),null),S(C,()=>a.t("dialog.model.unpaid.addMore.title")),S(E,h(Dt,{get each(){return[...o.popular()].filter(O=>e6.includes(O.id)).sort((O,$)=>e6.indexOf(O.id)-e6.indexOf($.id))},children:O=>(()=>{var $=XZe(),V=$.firstChild,P=V.firstChild;return $.$$click=()=>f(O.id),S($,h(wg,{get id(){return O.id},class:"mt-0.5 size-4 shrink-0 text-v2-icon-icon-base"}),V),S(P,()=>O.name),S(V,h(q,{get when(){return O.id==="opencode"||O.id==="opencode-go"},get children(){var T=YZe();return S(T,()=>a.t(O.id==="opencode"?"dialog.provider.opencode.tagline":"dialog.provider.opencodeGo.tagline")),T}}),null),he(T=>{var D=O.id,N={"border-[0.5px] border-transparent shadow-[var(--v2-elevation-raised)]":i.mode()!=="dark","border-[0.5px] border-v2-border-border-strong":i.mode()==="dark"};return D!==T.e&&me($,"data-provider-id",T.e=D),T.t=ct($,N,T.t),T},{e:void 0,t:void 0}),$})()}),_),_.$$click=()=>f(),S(_,()=>a.t("dialog.model.unpaid.viewMoreProviders")),p}})]}})};dn(["click"]);var JZe=A('<div class="pointer-events-none absolute inset-0 z-20 grid place-items-center rounded-xl bg-v2-background-bg-base/90 text-v2-text-text-base">Drop files to attach'),eYe=A('<div class="pointer-events-none absolute inset-x-0 top-0 px-4 pt-4 text-[13px] font-[440] leading-5 text-v2-text-text-faint">'),tYe=A(`<div><input type=file multiple accept=image/png,image/jpeg,image/gif,image/webp,application/pdf,text/*,application/json,application/ld+json,application/toml,application/x-toml,application/x-yaml,application/xml,application/yaml,.c,.cc,.cjs,.conf,.cpp,.css,.csv,.cts,.env,.go,.gql,.graphql,.h,.hh,.hpp,.htm,.html,.ini,.java,.js,.json,.jsx,.log,.md,.mdx,.mjs,.mts,.py,.rb,.rs,.sass,.scss,.sh,.sql,.toml,.ts,.tsx,.txt,.xml,.yaml,.yml,.zsh class=hidden><form data-component=prompt-input-v2 class="group/prompt-input relative min-h-[96px] w-full rounded-xl bg-v2-background-bg-base"><div class="relative min-h-[60px]"><div data-component=prompt-input role=textbox aria-multiline=true aria-label=Prompt autocomplete=off class="relative z-10 block min-h-[60px] max-h-[180px] w-full overflow-y-auto whitespace-pre-wrap bg-transparent px-4 pt-4 pb-2 text-[13px] font-[440] leading-5 text-v2-text-text-base focus:outline-none empty:before:content-['\\200B'] [&amp;_[data-mention=file]]:text-syntax-property [&amp;_[data-mention=agent]]:text-syntax-type [&amp;_[data-mention=reference]]:text-syntax-keyword"></div></div><div class="flex h-11 items-center px-2"><div class="flex min-w-0 flex-1 items-center gap-1">`),nYe=A('<div data-slot=prompt-attachments class=relative><div data-slot=prompt-attachments-scroll class="flex flex-nowrap gap-2 overflow-x-auto no-scrollbar px-2 pt-2 pb-1"></div><div class="pointer-events-none absolute inset-y-0 left-0 z-10 w-6 bg-[linear-gradient(to_right,var(--v2-background-bg-base),transparent)]"></div><div class="pointer-events-none absolute inset-y-0 right-0 z-10 w-6 bg-[linear-gradient(to_left,var(--v2-background-bg-base),transparent)]">'),jF=A('<div class="relative group shrink-0"><button type=button class="absolute -top-1 -right-1 size-4 rounded-full bg-v2-icon-icon-muted outline-solid outline-1 outline-v2-icon-icon-contrast flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity">'),rYe=A('<img class="w-[58px] h-[46px] rounded-[6px] object-cover">'),iYe=A('<div class="absolute inset-0 rounded-[6px] shadow-[inset_0_0_0_0.5px_var(--v2-border-border-base)] pointer-events-none">'),sYe=A('<span class="truncate capitalize leading-5">'),oYe=A('<span class="-ml-0.5 -mr-1 flex shrink-0">'),aYe=A('<div class="absolute inset-x-0 -top-2 z-40 flex max-h-80 -translate-y-full flex-col overflow-auto rounded-xl bg-v2-background-bg-base p-2 shadow-[var(--v2-elevation-raised)] no-scrollbar">'),lYe=A('<div class="px-2 py-1"><input class="w-full bg-transparent text-[13px] leading-5 text-v2-text-text-base outline-none placeholder:text-v2-text-text-faint">'),cYe=A('<div class="px-2 py-1 text-v2-text-text-muted">'),uYe=A('<span class="min-w-0 truncate text-v2-text-text-muted">'),dYe=A('<span class="shrink-0 text-v2-text-text-muted">'),fYe=A('<button type=button class="flex w-full items-center gap-2 rounded-md px-2 py-1 text-left hover:bg-v2-overlay-simple-overlay-hover"><div class="flex min-w-0 flex-1 items-center gap-2"><span class="shrink-0 text-v2-text-text-base">');function hYe(e){const t=e.controller.state,n=e.controller.view;let r,i=!1;const s=()=>{!r||!window.getSelection()?.isCollapsed||e.controller.onCursor(BF(r))},o=I(()=>t.mode),a=I(()=>({opacity:o()==="normal"?1:0,"pointer-events":o()==="normal"?"auto":"none",transition:"opacity 200ms ease"}));return ae(()=>{const l=e.controller.parts();if(r){if(i){i=!1;return}qF(r,l)}}),(()=>{var l=tYe(),c=l.firstChild,u=c.nextSibling,d=u.firstChild,f=d.firstChild,m=d.nextSibling,g=m.firstChild;c.addEventListener("change",y=>{const v=y.currentTarget.files;v&&e.controller.addAttachments(Array.from(v)),y.currentTarget.value=""});var p=e.controller.setFileInput;return typeof p=="function"?pt(p,c):e.controller.setFileInput=c,S(l,h(q,{get when(){return t.popover.type!=="closed"},get children(){return h(yYe,{emptyLabel:"No matching items",get items(){return e.controller.suggestions()},get activeID(){return we(()=>t.popover.type==="closed")()?void 0:t.popover.activeID},get search(){return we(()=>t.popover.type==="command-menu")()?{value:t.popover.query,label:"Commands",placeholder:"/",onValueChange:e.controller.setQuery,onKeyDown:e.controller.onKeyDown}:void 0},onActiveChange:y=>e.controller.dispatch({type:"popover.active",id:y.id}),onSelect:y=>e.controller.dispatch({type:"popover.select",item:y})})}}),u),cn(u,"drop",e.controller.onDrop),cn(u,"dragleave",e.controller.onDragLeave),cn(u,"dragover",e.controller.onDragOver),cn(u,"dragenter",e.controller.onDragEnter),u.addEventListener("submit",y=>{y.preventDefault(),e.disabled||e.controller.submit()}),S(u,h(q,{get when(){return t.drag==="active"},get children(){return JZe()}}),d),S(u,h(q,{get when(){return t.mode==="normal"},get children(){return h(gYe,{get attachments(){return e.controller.attachments()},get comments(){return e.controller.comments()},get activeCommentID(){return t.activeContextID},removeLabel:"Remove attachment",get onAttachmentClick(){return e.controller.openAttachment},onAttachmentRemove:y=>e.controller.removeAttachment(y.id),onCommentClick:y=>e.controller.toggleContext(y.key),onCommentRemove:y=>e.controller.removeContext(y.key)})}}),d),f.addEventListener("focus",()=>e.controller.dispatch({type:"focus.editor"})),cn(f,"paste",e.controller.onPaste),f.$$pointerup=s,f.$$keyup=s,f.$$keydown=y=>{if(!e.controller.onKeyDown(y)&&y.key==="Enter"&&!y.shiftKey&&!y.isComposing){if(y.preventDefault(),y.repeat)return;e.controller.submit()}},f.$$input=y=>{const v=BF(y.currentTarget),b=mYe(y.currentTarget),w=e.controller.parts().filter(x=>x.type==="image");i=!0,e.controller.onInput(b.map(x=>x.content).join(""),[...b,...w],v)},pt(y=>{r=y,e.controller.setEditor(y),qF(y,e.controller.parts())},f),S(d,h(q,{get when(){return!e.controller.value()},get children(){var y=eYe();return S(y,()=>n.placeholder?.()??(t.mode==="shell"?"Enter shell command...":"Ask anything, / for commands, @ for context...")),he(()=>y.classList.toggle("font-mono!",t.mode==="shell")),y}}),null),S(g,h(pYe,{get disabled(){return t.mode==="shell"},title:"Add images and files",get keybind(){return e.attachKeybind??["Mod","U"]},attachLabel:"Images and files",get attachShortcut(){return e.attachShortcut??"Mod+U"},commandsLabel:"Commands",contextLabel:"Context",shellLabel:"Shell command",get onAttach(){return e.controller.attach},get onCommands(){return e.controller.openCommands},get onContext(){return e.controller.openContext},get onShell(){return e.controller.openShell}}),null),S(g,h(q,{get when(){return n.agent},children:y=>h(t6,{title:"Choose agent",keybind:["Mod","."],get control(){return y()}})}),null),S(g,h(q,{get when(){return e.modelControl},get fallback(){return h(q,{get when(){return n.model},children:y=>h(t6,{title:"Choose model",keybind:["Mod","M"],get control(){return y()},model:!0})})},get children(){return e.modelControl}}),null),S(g,h(q,{get when(){return n.variant},children:y=>h(q,{get when(){return y().options().length>1},get children(){return h(t6,{title:"Choose model variant",keybind:["Shift","Mod","D"],get control(){return y()}})}})}),null),S(m,h(bYe,{get mode(){return t.mode},get stopping(){return n.submit.stopping()},get disabled(){return!e.controller.canSubmit()},sendLabel:"Send",stopLabel:"Stop",get onSubmit(){return e.controller.submit},get onStop(){return e.controller.stop}}),null),he(y=>{var v=`relative size-full flex flex-col gap-0 ${e.class??""}`,b=e.borderUnderlay?"v2":void 0,w={"shadow-[var(--v2-elevation-raised)]":!e.borderUnderlay,"border border-v2-icon-icon-info border-dashed":t.drag==="active"},x=!e.disabled&&!e.readOnly,k=t.mode==="normal"?"sentences":"off",C=t.mode==="normal"?"on":"off",E=t.mode==="normal",_=t.mode==="shell",L=!!e.disabled,O=t.mode==="shell",$=t.mode==="shell"?!0:void 0,V=a();return v!==y.e&&xr(l,y.e=v),b!==y.t&&me(u,"data-dock-border-underlay",y.t=b),y.a=ct(u,w,y.a),x!==y.o&&me(f,"contenteditable",y.o=x),k!==y.i&&me(f,"autocapitalize",y.i=k),C!==y.n&&me(f,"autocorrect",y.n=C),E!==y.s&&me(f,"spellcheck",y.s=E),_!==y.h&&f.classList.toggle("font-mono!",y.h=_),L!==y.r&&f.classList.toggle("opacity-50",y.r=L),O!==y.d&&me(g,"aria-hidden",y.d=O),$!==y.l&&(g.inert=y.l=$),y.u=So(g,V,y.u),y},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0,l:void 0,u:void 0}),l})()}function qF(e,t){const n=document.activeElement===e;if(e.replaceChildren(...t.flatMap(s=>{if(s.type==="image")return[];if(s.type==="text")return[document.createTextNode(s.content)];const o=document.createElement("span");return o.textContent=s.content,o.contentEditable="false",o.dataset.mention=s.type==="file"&&s.mime==="application/x-directory"?"reference":s.type,s.type==="agent"&&(o.dataset.name=s.name),s.type==="file"&&(o.dataset.path=s.path,s.mime&&(o.dataset.mime=s.mime),s.filename&&(o.dataset.filename=s.filename)),[o]})),!n)return;const r=window.getSelection(),i=document.createRange();i.selectNodeContents(e),i.collapse(!1),r?.removeAllRanges(),r?.addRange(i)}function mYe(e){const t=[];let n="",r=0;const i=()=>{n&&(t.push({type:"text",content:n,start:r,end:r+n.length}),r+=n.length,n="")},s=a=>{i();const l=a.textContent??"";if(a.dataset.mention==="agent"){t.push({type:"agent",name:a.dataset.name??l.slice(1),content:l,start:r,end:r+l.length}),r+=l.length;return}t.push({type:"file",path:a.dataset.path??l.slice(1),content:l,start:r,end:r+l.length,...a.dataset.mime?{mime:a.dataset.mime}:{},...a.dataset.filename?{filename:a.dataset.filename}:{}}),r+=l.length},o=a=>{if(a.nodeType===Node.TEXT_NODE){n+=a.textContent??"";return}if(a instanceof HTMLElement){if(a.dataset.mention){s(a);return}if(a.tagName==="BR"){n+=`
1165
+ `}),Y.preventDefault();return}if(Y.key==="Enter"&&mt(Y))return;const Ce=Y.ctrlKey&&!Y.metaKey&&!Y.altKey&&!Y.shiftKey;if(T.popover){if(Y.key==="Tab"){js(),Y.preventDefault();return}const Fe=Y.key==="ArrowUp"||Y.key==="ArrowDown"||Y.key==="Enter",qe=Ce&&(Y.key==="n"||Y.key==="p");if(Fe||qe){if(T.popover==="at"){$r(Y),Y.preventDefault();return}T.popover==="slash"&&(Wr(Y),(Y.key==="ArrowUp"||Y.key==="ArrowDown"||qe)&&ui()),Y.preventDefault();return}}if(Ce&&Y.code==="KeyG"){if(T.popover){G(),Y.preventDefault();return}V()&&(Rn(),Y.preventDefault());return}if(Y.key==="ArrowUp"||Y.key==="ArrowDown"){if(Y.altKey||Y.ctrlKey||Y.metaKey)return;const{collapsed:Fe}=de();if(!Fe)return;const qe=Ac(m),_t=i.current().map(It=>"content"in It?It.content:"").join(""),Zt=Y.key==="ArrowUp"?"up":"down";if(!aGe(Zt,_t,qe,T.historyIndex>=0))return;pa(Zt)&&Y.preventDefault();return}if(Y.key==="Enter"&&!Y.shiftKey){if(Y.preventDefault(),Y.repeat||V()&&i.current().map(Fe=>"content"in Fe?Fe.content:"").join("").trim().length===0&&P().length===0&&W()===0)return;_n(Y)}},ti=Y=>{if(Y.key==="Escape"){G(),requestAnimationFrame(()=>m.focus()),Y.preventDefault();return}if(Y.key==="Tab"){js(),Y.preventDefault();return}const Ce=Y.ctrlKey&&!Y.metaKey&&!Y.altKey&&!Y.shiftKey,Fe=Y.key==="ArrowUp"||Y.key==="ArrowDown"||Y.key==="Enter",qe=Ce&&(Y.key==="n"||Y.key==="p");!Fe&&!qe||(Wr(Y),(Y.key==="ArrowUp"||Y.key==="ArrowDown"||qe)&&ui(),Y.preventDefault())},_e=()=>e.controls.agents.loading,nt=I(Y=>Y??_e()),Ge=()=>e.controls.model.loading,Ye=I(Y=>Y??Ge()),[$t]=ai(()=>i.ready.promise,Y=>Y),Rt=Y=>{m=Y,v=!0,e.ref?.(Y)};return(()=>{var Y=VZe();return S(Y,()=>($t(),null),null),S(Y,h(YGe,{get popover(){return T.popover},setSlashPopoverRef:Ce=>y=Ce,get atFlat(){return er()},get atActive(){return Lt()??void 0},atKey:Hn,setAtActive:Nn,onAtSelect:In,get slashFlat(){return Ur()},get slashActive(){return es()??void 0},setSlashActive:go,onSlashSelect:$n,get slashMenu(){return T.slashMenu},get slashMenuQuery(){return T.slashMenuQuery},onSlashMenuInput:Ce=>{D("slashMenuQuery",Ce),Li(Ce)},onSlashMenuKeyDown:ti,get commandKeybind(){return l.keybind},get commandKeybindParts(){return l.keybindParts},newLayoutDesigns:!1,t:Ce=>u.t(Ce)}),null),S(Y,h(jWe,{"data-dock-border-underlay":"legacy",onSubmit:_n,get classList(){return{"group/prompt-input":!0,"border-icon-info-active border-dashed":T.draggingType!==null,[e.class??""]:!!e.class}},get children(){return[h(_Ze,{get type(){return T.draggingType},get label(){return u.t(T.draggingType==="@mention"?"prompt.dropzone.file.label":"prompt.dropzone.label")}}),h(nZe,{get items(){return te()},active:Ce=>{const Fe=o.active();return!!Ce.commentID&&Ce.commentID===Fe?.id&&Ce.path===Fe?.file},openComment:L,remove:Ce=>{Ce.commentID&&o.remove(Ce.path,Ce.commentID),i.context.remove(Ce.key)},newLayoutDesigns:!1,t:Ce=>u.t(Ce)}),h(SZe,{get attachments(){return P()},onOpen:Ce=>a.show(()=>h(MI,{get src(){return Ce.dataUrl},get alt(){return Ce.filename}})),onRemove:Ya,get removeLabel(){return u.t("prompt.attachment.remove")},newLayoutDesigns:!1}),(()=>{var Ce=PZe(),Fe=Ce.firstChild,qe=Fe.firstChild,_t=qe.nextSibling,Zt=Fe.nextSibling,It=Zt.nextSibling,jt=It.firstChild,Pt=jt.nextSibling,Tn=It.nextSibling,di=Tn.firstChild;Ce.$$mousedown=Yn=>{const Cs=Yn.target;Cs instanceof HTMLElement&&(Cs.closest('[data-action="prompt-attach"], [data-action="prompt-submit"]')||m?.focus())},pt(Yn=>p=Yn,Fe),qe.$$keydown=pr,qe.addEventListener("blur",Et),qe.addEventListener("focus",Re),qe.addEventListener("compositionend",Qe),qe.addEventListener("compositionstart",Bt),cn(qe,"paste",Ht),qe.$$input=$o,pt(Rt,qe),S(_t,ke),jt.addEventListener("change",Yn=>{const Cs=Yn.currentTarget.files;Cs&&Oo(Array.from(Cs)),Yn.currentTarget.value=""});var qs=g;return typeof qs=="function"?pt(qs,jt):g=jt,S(Pt,h(Ar,{placement:"top",get inactive(){return we(()=>!V())()&&J()},get value(){return X()},get children(){return h(Ln,{"data-action":"prompt-submit",type:"submit",get disabled(){return we(()=>!V())()&&J()},get tabIndex(){return T.mode==="normal"?void 0:-1},get icon(){return we(()=>!!K())()?"stop":T.mode==="shell"?"arrow-undo-down":"arrow-up"},variant:"primary",class:"size-8",get"aria-label"(){return we(()=>!!K())()?u.t("prompt.action.stop"):u.t("prompt.action.send")}})}})),S(di,h(ws,{placement:"top",get title(){return u.t("prompt.action.attachFile")},get keybind(){return l.keybind("file.attach")},get children(){return h(Kt,{"data-action":"prompt-attach",type:"button",variant:"ghost",class:"size-8 p-0",get style(){return F()},onClick:He,get disabled(){return T.mode!=="normal"},get tabIndex(){return T.mode==="normal"?void 0:-1},get"aria-label"(){return u.t("prompt.action.attachFile")},get children(){return h(Yt,{name:"plus",class:"size-4.5"})}})}})),he(Yn=>{var Cs=ke(),Ih=T.mode==="normal"?"sentences":"off",zd=T.mode==="normal"?"on":"off",yu=T.mode==="normal",c0={"select-text":!0,"w-full pl-3 pr-2 pt-2 text-14-regular text-text-strong focus:outline-none whitespace-pre-wrap":!0,"[&_[data-type=file]]:text-syntax-property":!0,"[&_[data-type=agent]]:text-syntax-type":!0,"font-mono!":T.mode==="shell"},bu=T.mode==="shell",wu=i.dirty()?"none":void 0,Dh=EI.join(","),Xa=T.mode!=="normal",oe=N()>.5?"auto":"none";return Cs!==Yn.e&&me(qe,"aria-label",Yn.e=Cs),Ih!==Yn.t&&me(qe,"autocapitalize",Yn.t=Ih),zd!==Yn.a&&me(qe,"autocorrect",Yn.a=zd),yu!==Yn.o&&me(qe,"spellcheck",Yn.o=yu),Yn.i=ct(qe,c0,Yn.i),bu!==Yn.n&&_t.classList.toggle("font-mono!",Yn.n=bu),wu!==Yn.s&&Ct(_t,"display",Yn.s=wu),Dh!==Yn.h&&me(jt,"accept",Yn.h=Dh),Xa!==Yn.r&&me(di,"aria-hidden",Yn.r=Xa),oe!==Yn.d&&Ct(di,"pointer-events",Yn.d=oe),Yn},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0}),Ce})()]}}),null),S(Y,h(q,{get when(){return T.mode==="normal"||T.mode==="shell"},get children(){return h(yy,{attach:"top",get children(){var Ce=NZe(),Fe=Ce.firstChild,qe=Fe.firstChild,_t=qe.firstChild;_t.nextSibling;var Zt=qe.nextSibling;return S(qe,h(Yt,{name:"console"}),_t),S(_t,()=>u.t("prompt.mode.shell")),S(qe,h(Kt,{variant:"ghost",class:"text-text-base",onClick:()=>{D("mode","normal")},get children(){return u.t("common.cancel")}}),null),S(Zt,h(q,{get when(){return!_e()},get children(){var It=OZe();return S(It,h(ws,{placement:"top",gutter:4,get title(){return u.t("command.agent.cycle")},get keybind(){return l.keybind("agent.cycle")},get children(){return h(aC,{size:"normal",get options(){return e.controls.agents.options},get current(){return e.controls.agents.current},onSelect:jt=>{e.controls.agents.select(jt),ye()},class:"capitalize max-w-[160px] text-text-base",valueClass:"truncate text-13-regular text-text-base",get triggerStyle(){return z()},triggerProps:{"data-action":"prompt-agent"},variant:"ghost"})}})),he(jt=>ct(It,{"animate-in fade-in duration-300":nt()},jt)),It}}),null),S(Zt,h(q,{get when(){return!Ge()},get children(){return h(q,{get when(){return T.mode!=="shell"},get children(){return[(()=>{var It=RZe();return S(It,h(q,{get when(){return e.controls.model.paid},get fallback(){return h(ws,{placement:"top",gutter:4,get title(){return u.t("command.model.choose")},get keybind(){return l.keybind("model.choose")},get children(){return h(Kt,{"data-action":"prompt-model",as:"div",variant:"ghost",size:"normal",class:"min-w-0 max-w-[320px] text-13-regular text-text-base group",get style(){return z()},onClick:()=>{a.show(()=>h(FKe,{get model(){return e.controls.model.selection}}))},get children(){return[h(q,{get when(){return e.controls.model.selection.current()?.provider?.id},get children(){return h(wg,{get id(){return e.controls.model.selection.current()?.provider?.id??""},class:"size-4 shrink-0 opacity-40 group-hover:opacity-100 transition-opacity duration-150",style:{"will-change":"opacity",transform:"translateZ(0)"}})}}),(()=>{var jt=zF();return S(jt,()=>e.controls.model.selection.current()?.name??u.t("dialog.model.select.title")),jt})(),h(Yt,{name:"chevron-down",size:"small",class:"shrink-0"})]}})}})},get children(){return h(ws,{placement:"top",gutter:4,get title(){return u.t("command.model.choose")},get keybind(){return l.keybind("model.choose")},get children(){return h(Jte,{get model(){return e.controls.model.selection},triggerAs:Kt,get triggerProps(){return{variant:"ghost",size:"normal",style:z(),class:"min-w-0 max-w-[320px] text-13-regular text-text-base group","data-action":"prompt-model"}},onClose:ye,get children(){return[h(q,{get when(){return e.controls.model.selection.current()?.provider?.id},get children(){return h(wg,{get id(){return e.controls.model.selection.current()?.provider?.id??""},class:"size-4 shrink-0 opacity-40 group-hover:opacity-100 transition-opacity duration-150",style:{"will-change":"opacity",transform:"translateZ(0)"}})}}),(()=>{var jt=zF();return S(jt,()=>e.controls.model.selection.current()?.name??u.t("dialog.model.select.title")),jt})(),h(Yt,{name:"chevron-down",size:"small",class:"shrink-0"})]}})}})}})),he(jt=>ct(It,{"animate-in fade-in duration-300":Ye()},jt)),It})(),h(q,{get when(){return st()},get children(){var It=FZe();return S(It,h(ws,{placement:"top",gutter:4,get title(){return u.t("command.model.variant.cycle")},get keybind(){return l.keybind("model.variant.cycle")},get children(){return h(aC,{size:"normal",get options(){return Ie()},get current(){return e.controls.model.selection.variant.current()??"default"},label:jt=>jt==="default"?u.t("common.default"):jt,onSelect:jt=>{e.controls.model.selection.variant.set(jt==="default"?void 0:jt),ye()},class:"capitalize max-w-[160px] text-text-base",valueClass:"truncate text-13-regular text-text-base",get triggerStyle(){return z()},triggerProps:{"data-action":"prompt-model-variant"},variant:"ghost"})}})),he(jt=>ct(It,{"animate-in fade-in duration-300":Ye()},jt)),It}})]}})}}),null),he(It=>So(qe,{...j()},It)),Ce}})}}),null),Y})()};dn(["mousedown","input","keydown"]);var HZe=A("<div data-slot=dialog-footer>"),jZe=A("<div data-slot=dialog-body>"),qZe=A("<div data-slot=dialog-title-group>"),BZe=A("<div data-slot=dialog-header>"),UZe=A('<svg width=16 height=16 viewBox="0 0 16 16"fill=none xmlns=http://www.w3.org/2000/svg aria-hidden=true><path d="M12.4446 3.55469L3.55566 12.4436M3.55566 3.55469L12.4446 12.4436"stroke=currentColor stroke-linejoin=round>'),WZe=A("<div data-component=dialog-v2><div data-slot=dialog-container>");function fne(e){return(()=>{var t=HZe();return S(t,()=>e.children),t})()}function hne(e){const[t]=Ee(e,["class","children"]);return(()=>{var n=jZe();return S(n,()=>t.children),he(()=>xr(n,t.class)),n})()}function mne(e){return h(Qs.Title,{"data-slot":"dialog-header-title",get children(){return e.children}})}function KZe(e){const t=Jl(()=>e.title),n=Jl(()=>e.description);return(()=>{var r=qZe();return S(r,h(q,{get when(){return t()},children:i=>h(Qs.Title,{"data-slot":"dialog-title",get children(){return i()}})}),null),S(r,h(Qs.Description,{"data-slot":"dialog-description",get children(){return n()}}),null),r})()}function $I(e){const[t]=Ee(e,["closeLabel","hideClose","children"]),n=()=>t.hideClose===!0;return(()=>{var r=BZe();return S(r,()=>t.children,null),S(r,(()=>{var i=we(()=>!n());return()=>i()&&h(Qs.CloseButton,{"data-slot":"dialog-close-button",get"aria-label"(){return t.closeLabel??"Close"},get children(){return UZe()}})})(),null),he(()=>me(r,"data-hide-close",n()?"":void 0)),r})()}function gne(e){const[t]=Ee(e,["size","variant","class","containerClass","classList","fit","children"]);return(()=>{var n=WZe(),r=n.firstChild;return S(r,h(Qs.Content,{"data-slot":"dialog-content",get classList(){return{...t.classList,[t.class??""]:!!t.class}},onOpenAutoFocus:i=>{const o=i.currentTarget?.querySelector("[autofocus]");o&&(i.preventDefault(),o.focus({preventScroll:!0}))},get children(){return t.children}})),he(i=>{var s=t.variant==="settings"?"settings":void 0,o=t.fit?!0:void 0,a=t.size||"normal",l=t.containerClass;return s!==i.e&&me(n,"data-variant",i.e=s),o!==i.t&&me(n,"data-fit",i.t=o),a!==i.a&&me(n,"data-size",i.a=a),l!==i.o&&xr(r,i.o=l),i},{e:void 0,t:void 0,a:void 0,o:void 0}),n})()}const pne=gne;var GZe=A(`<div class="flex min-h-0 flex-col"><div data-section=free-models class="flex w-full flex-col items-start pb-3"><div class="flex h-8 w-full flex-none select-none flex-row items-center px-3 pb-2"><div class="flex h-5 items-center text-[13px] font-[440] leading-5 tracking-[-0.04px] text-v2-text-text-muted [font-family:var(--v2-font-family-sans)] [font-variant-numeric:tabular-nums] [font-variation-settings:'slnt'_0]"></div></div></div><div class="flex w-full flex-col"><div class="flex w-full flex-col items-start rounded-lg border-[0.5px] border-v2-border-border-muted bg-v2-background-bg-layer-02 p-2.5 pt-2"><div class="flex h-8 w-full select-none items-center px-0.5 pb-2"><div class="flex h-5 items-center text-[13px] font-[440] leading-5 tracking-[-0.04px] text-v2-text-text-muted [font-family:var(--v2-font-family-sans)] [font-variant-numeric:tabular-nums] [font-variation-settings:'slnt'_0]"></div></div><div class="grid w-full grid-cols-1 gap-y-1.5 gap-x-2 sm:grid-cols-2"><button type=button class="col-span-full flex h-8 w-full scroll-my-3.5 items-center justify-start rounded-md px-3 text-left text-[13px] font-[440] leading-5 tracking-[-0.04px] text-v2-text-text-muted [font-family:var(--v2-font-family-sans)] [font-variation-settings:'slnt'_0] hover:bg-v2-overlay-simple-overlay-hover focus:bg-v2-overlay-simple-overlay-hover focus:outline-none">`),ZZe=A(`<button type=button class="flex w-full scroll-my-3.5 flex-row items-center gap-1.5 rounded-md px-3 py-2 text-left text-[13px] font-[530] leading-5 tracking-[-0.04px] text-v2-text-text-base [font-family:var(--v2-font-family-sans)] [font-variation-settings:'slnt'_0] hover:bg-v2-overlay-simple-overlay-hover focus:bg-v2-overlay-simple-overlay-hover focus:outline-none"><span class="min-w-0 truncate">`),YZe=A('<span class="truncate font-[440] text-v2-text-text-muted">'),XZe=A(`<button type=button class="flex min-h-11 w-full scroll-my-3.5 flex-row items-start gap-2 rounded-md bg-v2-background-bg-base px-3 py-2.5 text-left text-[13px] font-[530] leading-5 tracking-[-0.04px] text-v2-text-text-base [font-family:var(--v2-font-family-sans)] [font-variation-settings:'slnt'_0] hover:bg-v2-background-bg-layer-01 focus:bg-v2-background-bg-layer-01 focus:outline-none"><span class="flex min-w-0 flex-col"><span class=truncate>`);const e6=["opencode","opencode-go","openai","anthropic","google","github-copilot"],HF=e=>e.replace(/\s+(?:\(free\)|free)$/i,""),QZe=e=>{const t=El(),n=e.model??t.model,r=Mr(),i=h9(),s=()=>Ns(t.slug()),o=$d(s),a=wt(),l=p=>`${p.provider.id}:${p.id}`,c=I(()=>{const p=n.current();return p?`${p.provider.id}:${p.id}`:void 0}),u=p=>p.provider.id==="opencode"&&(!p.cost||p.cost.input===0),d=I(()=>n.list().filter(u)),f=p=>{B(()=>import("./dialog-connect-provider-DLnpNUTc.js").then(y=>y.d),[]).then(y=>{const v=y.useProviderConnectController();v.select(p),r.show(()=>h(y.DialogConnectProvider,{controller:v,directory:s}))})},m=p=>{n.set({modelID:p.id,providerID:p.provider.id},{recent:!0}),r.close()};let g;return sn(()=>{const p=y=>{if(y.key!=="ArrowDown"&&y.key!=="ArrowUp"||!g)return;const v=Array.from(g.querySelectorAll("button"));if(v.length===0)return;const b=v.indexOf(document.activeElement),w=b<0?y.key==="ArrowDown"?0:v.length-1:b+(y.key==="ArrowDown"?1:-1);v[(w+v.length)%v.length]?.focus(),y.preventDefault()};document.addEventListener("keydown",p),Te(()=>document.removeEventListener("keydown",p))}),h(pne,{fit:!0,containerClass:"!h-auto max-h-[calc(100vh_-_16px)] !w-[min(calc(100vw_-_16px),640px)]",class:"[font-family:var(--v2-font-family-sans)] [&_[data-slot=dialog-header]]:!px-5 [&_[data-slot=dialog-header-title]]:!text-[15px] [&_[data-slot=dialog-header-title]]:!tracking-[-0.13px]",get children(){return[h($I,{get closeLabel(){return a.t("common.close")},get children(){return h(mne,{get children(){return a.t("dialog.model.select.title")}})}}),h(hne,{class:"max-h-[calc(100vh_-_68px)] min-h-0 flex-none gap-0 overflow-y-auto px-2 pb-2",get children(){var p=GZe(),y=p.firstChild,v=y.firstChild,b=v.firstChild,w=y.nextSibling,x=w.firstChild,k=x.firstChild,C=k.firstChild,E=k.nextSibling,_=E.firstChild,L=g;return typeof L=="function"?pt(L,p):g=p,S(b,()=>a.t("dialog.model.unpaid.freeModels.title")),S(y,h(Dt,{get each(){return d()},children:O=>h(Qn,{class:"w-full",placement:"right-start",gutter:6,openDelay:0,contentStyle:{"font-family":"var(--v2-font-family-sans)"},get value(){return h(e3,{get model(){return{...O,name:HF(O.name)}},get latest(){return O.latest},get free(){return u(O)},v2:!0})},get children(){var $=ZZe(),V=$.firstChild;return $.$$click=()=>m(O),S(V,()=>HF(O.name)),S($,h(m1,{class:"shrink-0",get children(){return a.t("model.tag.free")}}),null),S($,h(q,{get when(){return O.latest},get children(){return h(m1,{class:"shrink-0",get children(){return a.t("model.tag.latest")}})}}),null),S($,h(q,{get when(){return c()===l(O)},get children(){return h(on,{name:"check",class:"ml-auto size-4 shrink-0 text-v2-icon-icon-base"})}}),null),$}})}),null),S(C,()=>a.t("dialog.model.unpaid.addMore.title")),S(E,h(Dt,{get each(){return[...o.popular()].filter(O=>e6.includes(O.id)).sort((O,$)=>e6.indexOf(O.id)-e6.indexOf($.id))},children:O=>(()=>{var $=XZe(),V=$.firstChild,P=V.firstChild;return $.$$click=()=>f(O.id),S($,h(wg,{get id(){return O.id},class:"mt-0.5 size-4 shrink-0 text-v2-icon-icon-base"}),V),S(P,()=>O.name),S(V,h(q,{get when(){return O.id==="opencode"||O.id==="opencode-go"},get children(){var T=YZe();return S(T,()=>a.t(O.id==="opencode"?"dialog.provider.opencode.tagline":"dialog.provider.opencodeGo.tagline")),T}}),null),he(T=>{var D=O.id,N={"border-[0.5px] border-transparent shadow-[var(--v2-elevation-raised)]":i.mode()!=="dark","border-[0.5px] border-v2-border-border-strong":i.mode()==="dark"};return D!==T.e&&me($,"data-provider-id",T.e=D),T.t=ct($,N,T.t),T},{e:void 0,t:void 0}),$})()}),_),_.$$click=()=>f(),S(_,()=>a.t("dialog.model.unpaid.viewMoreProviders")),p}})]}})};dn(["click"]);var JZe=A('<div class="pointer-events-none absolute inset-0 z-20 grid place-items-center rounded-xl bg-v2-background-bg-base/90 text-v2-text-text-base">Drop files to attach'),eYe=A('<div class="pointer-events-none absolute inset-x-0 top-0 px-4 pt-4 text-[13px] font-[440] leading-5 text-v2-text-text-faint">'),tYe=A(`<div><input type=file multiple accept=image/png,image/jpeg,image/gif,image/webp,application/pdf,text/*,application/json,application/ld+json,application/toml,application/x-toml,application/x-yaml,application/xml,application/yaml,.c,.cc,.cjs,.conf,.cpp,.css,.csv,.cts,.env,.go,.gql,.graphql,.h,.hh,.hpp,.htm,.html,.ini,.java,.js,.json,.jsx,.log,.md,.mdx,.mjs,.mts,.py,.rb,.rs,.sass,.scss,.sh,.sql,.toml,.ts,.tsx,.txt,.xml,.yaml,.yml,.zsh class=hidden><form data-component=prompt-input-v2 class="group/prompt-input relative min-h-[96px] w-full rounded-xl bg-v2-background-bg-base"><div class="relative min-h-[60px]"><div data-component=prompt-input role=textbox aria-multiline=true aria-label=Prompt autocomplete=off class="relative z-10 block min-h-[60px] max-h-[180px] w-full overflow-y-auto whitespace-pre-wrap bg-transparent px-4 pt-4 pb-2 text-[13px] font-[440] leading-5 text-v2-text-text-base focus:outline-none empty:before:content-['\\200B'] [&amp;_[data-mention=file]]:text-syntax-property [&amp;_[data-mention=agent]]:text-syntax-type [&amp;_[data-mention=reference]]:text-syntax-keyword"></div></div><div class="flex h-11 items-center px-2"><div class="flex min-w-0 flex-1 items-center gap-1">`),nYe=A('<div data-slot=prompt-attachments class=relative><div data-slot=prompt-attachments-scroll class="flex flex-nowrap gap-2 overflow-x-auto no-scrollbar px-2 pt-2 pb-1"></div><div class="pointer-events-none absolute inset-y-0 left-0 z-10 w-6 bg-[linear-gradient(to_right,var(--v2-background-bg-base),transparent)]"></div><div class="pointer-events-none absolute inset-y-0 right-0 z-10 w-6 bg-[linear-gradient(to_left,var(--v2-background-bg-base),transparent)]">'),jF=A('<div class="relative group shrink-0"><button type=button class="absolute -top-1 -right-1 size-4 rounded-full bg-v2-icon-icon-muted outline-solid outline-1 outline-v2-icon-icon-contrast flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity">'),rYe=A('<img class="w-[58px] h-[46px] rounded-[6px] object-cover">'),iYe=A('<div class="absolute inset-0 rounded-[6px] shadow-[inset_0_0_0_0.5px_var(--v2-border-border-base)] pointer-events-none">'),sYe=A('<span class="truncate capitalize leading-5">'),oYe=A('<span class="-ml-0.5 -mr-1 flex shrink-0">'),aYe=A('<div class="absolute inset-x-0 -top-2 z-40 flex max-h-80 -translate-y-full flex-col overflow-auto rounded-xl bg-v2-background-bg-base p-2 shadow-[var(--v2-elevation-raised)] no-scrollbar">'),lYe=A('<div class="px-2 py-1"><input class="w-full bg-transparent text-[13px] leading-5 text-v2-text-text-base outline-none placeholder:text-v2-text-text-faint">'),cYe=A('<div class="px-2 py-1 text-v2-text-text-muted">'),uYe=A('<span class="min-w-0 truncate text-v2-text-text-muted">'),dYe=A('<span class="shrink-0 text-v2-text-text-muted">'),fYe=A('<button type=button class="flex w-full items-center gap-2 rounded-md px-2 py-1 text-left hover:bg-v2-overlay-simple-overlay-hover"><div class="flex min-w-0 flex-1 items-center gap-2"><span class="shrink-0 text-v2-text-text-base">');function hYe(e){const t=e.controller.state,n=e.controller.view;let r,i=!1;const s=()=>{!r||!window.getSelection()?.isCollapsed||e.controller.onCursor(BF(r))},o=I(()=>t.mode),a=I(()=>({opacity:o()==="normal"?1:0,"pointer-events":o()==="normal"?"auto":"none",transition:"opacity 200ms ease"}));return ae(()=>{const l=e.controller.parts();if(r){if(i){i=!1;return}qF(r,l)}}),(()=>{var l=tYe(),c=l.firstChild,u=c.nextSibling,d=u.firstChild,f=d.firstChild,m=d.nextSibling,g=m.firstChild;c.addEventListener("change",y=>{const v=y.currentTarget.files;v&&e.controller.addAttachments(Array.from(v)),y.currentTarget.value=""});var p=e.controller.setFileInput;return typeof p=="function"?pt(p,c):e.controller.setFileInput=c,S(l,h(q,{get when(){return t.popover.type!=="closed"},get children(){return h(yYe,{emptyLabel:"No matching items",get items(){return e.controller.suggestions()},get activeID(){return we(()=>t.popover.type==="closed")()?void 0:t.popover.activeID},get search(){return we(()=>t.popover.type==="command-menu")()?{value:t.popover.query,label:"Commands",placeholder:"/",onValueChange:e.controller.setQuery,onKeyDown:e.controller.onKeyDown}:void 0},onActiveChange:y=>e.controller.dispatch({type:"popover.active",id:y.id}),onSelect:y=>e.controller.dispatch({type:"popover.select",item:y})})}}),u),cn(u,"drop",e.controller.onDrop),cn(u,"dragleave",e.controller.onDragLeave),cn(u,"dragover",e.controller.onDragOver),cn(u,"dragenter",e.controller.onDragEnter),u.addEventListener("submit",y=>{y.preventDefault(),e.disabled||e.controller.submit()}),S(u,h(q,{get when(){return t.drag==="active"},get children(){return JZe()}}),d),S(u,h(q,{get when(){return t.mode==="normal"},get children(){return h(gYe,{get attachments(){return e.controller.attachments()},get comments(){return e.controller.comments()},get activeCommentID(){return t.activeContextID},removeLabel:"Remove attachment",get onAttachmentClick(){return e.controller.openAttachment},onAttachmentRemove:y=>e.controller.removeAttachment(y.id),onCommentClick:y=>e.controller.toggleContext(y.key),onCommentRemove:y=>e.controller.removeContext(y.key)})}}),d),f.addEventListener("focus",()=>e.controller.dispatch({type:"focus.editor"})),cn(f,"paste",e.controller.onPaste),f.$$pointerup=s,f.$$keyup=s,f.$$keydown=y=>{if(!e.controller.onKeyDown(y)&&y.key==="Enter"&&!y.shiftKey&&!y.isComposing){if(y.preventDefault(),y.repeat)return;e.controller.submit()}},f.$$input=y=>{const v=BF(y.currentTarget),b=mYe(y.currentTarget),w=e.controller.parts().filter(x=>x.type==="image");i=!0,e.controller.onInput(b.map(x=>x.content).join(""),[...b,...w],v)},pt(y=>{r=y,e.controller.setEditor(y),qF(y,e.controller.parts())},f),S(d,h(q,{get when(){return!e.controller.value()},get children(){var y=eYe();return S(y,()=>n.placeholder?.()??(t.mode==="shell"?"Enter shell command...":"Ask anything, @ for context...")),he(()=>y.classList.toggle("font-mono!",t.mode==="shell")),y}}),null),S(g,h(pYe,{get disabled(){return t.mode==="shell"},title:"Add images and files",get keybind(){return e.attachKeybind??["Mod","U"]},attachLabel:"Images and files",get attachShortcut(){return e.attachShortcut??"Mod+U"},commandsLabel:"Commands",contextLabel:"Context",shellLabel:"Shell command",get onAttach(){return e.controller.attach},get onCommands(){return e.controller.openCommands},get onContext(){return e.controller.openContext},get onShell(){return e.controller.openShell}}),null),S(g,h(q,{get when(){return n.agent},children:y=>h(t6,{title:"Choose agent",keybind:["Mod","."],get control(){return y()}})}),null),S(g,h(q,{get when(){return e.modelControl},get fallback(){return h(q,{get when(){return n.model},children:y=>h(t6,{title:"Choose model",keybind:["Mod","M"],get control(){return y()},model:!0})})},get children(){return e.modelControl}}),null),S(g,h(q,{get when(){return n.variant},children:y=>h(q,{get when(){return y().options().length>1},get children(){return h(t6,{title:"Choose model variant",keybind:["Shift","Mod","D"],get control(){return y()}})}})}),null),S(m,h(bYe,{get mode(){return t.mode},get stopping(){return n.submit.stopping()},get disabled(){return!e.controller.canSubmit()},sendLabel:"Send",stopLabel:"Stop",get onSubmit(){return e.controller.submit},get onStop(){return e.controller.stop}}),null),he(y=>{var v=`relative size-full flex flex-col gap-0 ${e.class??""}`,b=e.borderUnderlay?"v2":void 0,w={"shadow-[var(--v2-elevation-raised)]":!e.borderUnderlay,"border border-v2-icon-icon-info border-dashed":t.drag==="active"},x=!e.disabled&&!e.readOnly,k=t.mode==="normal"?"sentences":"off",C=t.mode==="normal"?"on":"off",E=t.mode==="normal",_=t.mode==="shell",L=!!e.disabled,O=t.mode==="shell",$=t.mode==="shell"?!0:void 0,V=a();return v!==y.e&&xr(l,y.e=v),b!==y.t&&me(u,"data-dock-border-underlay",y.t=b),y.a=ct(u,w,y.a),x!==y.o&&me(f,"contenteditable",y.o=x),k!==y.i&&me(f,"autocapitalize",y.i=k),C!==y.n&&me(f,"autocorrect",y.n=C),E!==y.s&&me(f,"spellcheck",y.s=E),_!==y.h&&f.classList.toggle("font-mono!",y.h=_),L!==y.r&&f.classList.toggle("opacity-50",y.r=L),O!==y.d&&me(g,"aria-hidden",y.d=O),$!==y.l&&(g.inert=y.l=$),y.u=So(g,V,y.u),y},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0,l:void 0,u:void 0}),l})()}function qF(e,t){const n=document.activeElement===e;if(e.replaceChildren(...t.flatMap(s=>{if(s.type==="image")return[];if(s.type==="text")return[document.createTextNode(s.content)];const o=document.createElement("span");return o.textContent=s.content,o.contentEditable="false",o.dataset.mention=s.type==="file"&&s.mime==="application/x-directory"?"reference":s.type,s.type==="agent"&&(o.dataset.name=s.name),s.type==="file"&&(o.dataset.path=s.path,s.mime&&(o.dataset.mime=s.mime),s.filename&&(o.dataset.filename=s.filename)),[o]})),!n)return;const r=window.getSelection(),i=document.createRange();i.selectNodeContents(e),i.collapse(!1),r?.removeAllRanges(),r?.addRange(i)}function mYe(e){const t=[];let n="",r=0;const i=()=>{n&&(t.push({type:"text",content:n,start:r,end:r+n.length}),r+=n.length,n="")},s=a=>{i();const l=a.textContent??"";if(a.dataset.mention==="agent"){t.push({type:"agent",name:a.dataset.name??l.slice(1),content:l,start:r,end:r+l.length}),r+=l.length;return}t.push({type:"file",path:a.dataset.path??l.slice(1),content:l,start:r,end:r+l.length,...a.dataset.mime?{mime:a.dataset.mime}:{},...a.dataset.filename?{filename:a.dataset.filename}:{}}),r+=l.length},o=a=>{if(a.nodeType===Node.TEXT_NODE){n+=a.textContent??"";return}if(a instanceof HTMLElement){if(a.dataset.mention){s(a);return}if(a.tagName==="BR"){n+=`
1166
1166
  `;return}Array.from(a.childNodes).forEach(o)}};return Array.from(e.childNodes).forEach((a,l,c)=>{o(a),a instanceof HTMLElement&&["DIV","P"].includes(a.tagName)&&l<c.length-1&&(n+=`
1167
1167
  `)}),i(),t.every(a=>a.type==="text")&&t.every(a=>a.content.replace(/[\n\u200B]/g,"")==="")?[{type:"text",content:"",start:0,end:0}]:t.length>0?t:[{type:"text",content:"",start:0,end:0}]}function BF(e){const t=window.getSelection();if(!t?.rangeCount||!e.contains(t.anchorNode))return e.textContent?.length??0;const n=t.getRangeAt(0).cloneRange();return n.selectNodeContents(e),n.setEnd(t.anchorNode,t.anchorOffset),n.toString().length}function gYe(e){return h(q,{get when(){return e.attachments.length>0||(e.comments?.length??0)>0},get children(){var t=nYe(),n=t.firstChild;return S(n,h(Dt,{get each(){return e.comments??[]},children:r=>(()=>{var i=jF(),s=i.firstChild;return S(i,h(Qn,{get value(){return r.comment},placement:"top",openDelay:800,contentClass:"max-w-[300px] break-words",get children(){return h(LI,{get comment(){return r.comment??""},get path(){return r.path},get selection(){return r.selection},get active(){return r.key===e.activeCommentID},onClick:()=>e.onCommentClick?.(r)})}}),s),s.$$click=()=>e.onCommentRemove?.(r),S(s,h(on,{name:"outline-xmark",class:"text-v2-icon-icon-contrast"})),he(()=>me(s,"aria-label",e.removeLabel)),i})()}),null),S(n,h(Dt,{get each(){return e.attachments},children:r=>(()=>{var i=jF(),s=i.firstChild;return S(i,h(Qn,{get value(){return r.filename},placement:"top",contentClass:"break-all",get children(){return h(q,{get when(){return r.mime.startsWith("image/")},get fallback(){return h(t3,{get title(){return r.filename},get children(){return AI(r.filename,r.mime)}})},get children(){return[(()=>{var o=rYe();return o.$$click=()=>e.onAttachmentClick?.(r),he(a=>{var l=r.dataUrl,c=r.filename;return l!==a.e&&me(o,"src",a.e=l),c!==a.t&&me(o,"alt",a.t=c),a},{e:void 0,t:void 0}),o})(),iYe()]}})}}),s),s.$$click=()=>e.onAttachmentRemove(r),S(s,h(on,{name:"outline-xmark",class:"text-v2-icon-icon-contrast"})),he(()=>me(s,"aria-label",e.removeLabel)),i})()}),null),t}})}function pYe(e){return h(Qn,{placement:"top",get value(){return[we(()=>e.title),h(Eo,{get keys(){return e.keybind??[]},variant:"neutral"})]},get children(){return h(Tt,{gutter:6,modal:!1,placement:"top-start",get children(){return[h(Tt.Trigger,{as:Lr,"data-action":"prompt-attach",type:"button",get icon(){return h(on,{name:"plus"})},variant:"ghost-muted",size:"large",get disabled(){return e.disabled},get"aria-label"(){return e.title}}),h(Tt.Portal,{get children(){return h(Tt.Content,{style:{"min-width":"180px"},get children(){return[h(Tt.Item,{get onSelect(){return e.onAttach},get shortcut(){return e.attachShortcut},get children(){return e.attachLabel}}),h(Tt.Separator,{}),h(Tt.Item,{get onSelect(){return e.onCommands},shortcut:"/",get children(){return e.commandsLabel}}),h(Tt.Item,{get onSelect(){return e.onContext},shortcut:"@",get children(){return e.contextLabel}}),h(Tt.Item,{get onSelect(){return e.onShell},shortcut:"!",get children(){return e.shellLabel}})]}})}})]}})}})}function t6(e){const t=()=>e.control.current(),n=()=>e.control.options().find(r=>r.id===t())?.providerID;return h(vYe,{get title(){return e.title},get keybind(){return e.control.keybind?.()??e.keybind},get options(){return e.control.options()},get current(){return t()},get currentIcon(){return h(q,{get when(){return we(()=>!!e.model)()&&n()},get children(){return h(wg,{get id(){return n()},class:"size-4 shrink-0 opacity-60"})}})},get onSelect(){return e.control.onSelect}})}function vYe(e){return h(Qn,{placement:"top",get value(){return[we(()=>e.title),h(Eo,{get keys(){return e.keybind??[]},variant:"neutral"})]},get children(){return h(Tt,{gutter:6,modal:!1,placement:"top-start",get onOpenChange(){return e.onOpenChange},get children(){return[h(Tt.Trigger,{as,variant:"ghost-muted",size:"normal",get class(){return`max-w-[220px] justify-start ![font-weight:440] ${e.class??""}`},get"aria-label"(){return e.title},get children(){return[we(()=>e.currentIcon),(()=>{var t=sYe();return S(t,()=>e.options.find(n=>n.id===e.current)?.label??e.current),t})(),(()=>{var t=oYe();return S(t,h(on,{name:"chevron-down"})),t})()]}}),h(Tt.Portal,{get children(){return h(Tt.Content,{get children(){return h(Tt.RadioGroup,{get value(){return e.current},get onChange(){return e.onSelect},get children(){return h(Dt,{get each(){return e.options},children:t=>h(Tt.RadioItem,{get value(){return t.id},class:"capitalize",closeOnSelect:!0,get children(){return t.label}})})}})}})}})]}})}})}function yYe(e){return(()=>{var t=aYe();return t.$$mousedown=n=>n.preventDefault(),S(t,h(q,{get when(){return e.search},children:n=>(()=>{var r=lYe(),i=r.firstChild;return i.$$mousedown=s=>s.stopPropagation(),i.$$keydown=s=>n().onKeyDown(s),i.$$input=s=>n().onValueChange(s.currentTarget.value),pt(s=>requestAnimationFrame(()=>s.focus()),i),he(s=>{var o=n().label,a=n().placeholder;return o!==s.e&&me(i,"aria-label",s.e=o),a!==s.t&&me(i,"placeholder",s.t=a),s},{e:void 0,t:void 0}),he(()=>i.value=n().value),r})()}),null),S(t,h(q,{get when(){return e.items.length>0},get fallback(){return(()=>{var n=cYe();return S(n,()=>e.emptyLabel),n})()},get children(){return h(Dt,{get each(){return e.items},children:n=>(()=>{var r=fYe(),i=r.firstChild,s=i.firstChild;return r.$$click=()=>e.onSelect(n),r.$$pointermove=()=>e.onActiveChange(n),S(i,h(wYe,{item:n}),s),S(s,()=>n.label),S(i,h(q,{get when(){return n.description},get children(){var o=uYe();return S(o,()=>n.description),o}}),null),S(r,h(q,{get when(){return n.keybind?.length},get children(){var o=dYe();return S(o,()=>n.keybind?.join("+")),o}}),null),he(o=>{var a=n.id,l=e.activeID===n.id;return a!==o.e&&me(r,"data-suggestion-id",o.e=a),l!==o.t&&r.classList.toggle("bg-v2-overlay-simple-overlay-hover",o.t=l),o},{e:void 0,t:void 0}),r})()})}}),null),t})()}function bYe(e){return h(Qn,{placement:"top",get inactive(){return we(()=>!e.stopping)()&&e.disabled},get value(){return we(()=>!!e.stopping)()?e.stopLabel:e.sendLabel},get children(){return h(Ln,{"data-action":"prompt-submit",type:"button",get disabled(){return we(()=>!e.stopping)()&&e.disabled},get tabIndex(){return e.mode==="normal"?void 0:-1},get icon(){return we(()=>!!e.stopping)()?"stop":e.mode==="shell"?"arrow-undo-down":"arrow-up"},variant:"primary",class:"size-7 rounded-md p-[6px] text-v2-icon-icon-muted shadow-[var(--v2-elevation-button-contrast)] disabled:opacity-50",style:{"background-image":"linear-gradient(180deg,var(--v2-alpha-light-20) 0%,var(--v2-alpha-light-0) 100%),linear-gradient(90deg,var(--v2-background-bg-contrast) 0%,var(--v2-background-bg-contrast) 100%)"},get"aria-label"(){return we(()=>!!e.stopping)()?e.stopLabel:e.sendLabel},onClick:t=>{if(t.preventDefault(),t.stopPropagation(),e.stopping){e.onStop();return}e.onSubmit()}})}})}function wYe(e){return e.item.kind==="agent"?h(Yt,{name:"brain",size:"small",class:"shrink-0 text-icon-info-active"}):e.item.kind==="command"?null:h(Dr,{get node(){return{path:e.item.path??e.item.label,type:e.item.kind==="reference"?"directory":"file"}},class:"size-4 shrink-0"})}dn(["input","keydown","keyup","pointerup","click","mousedown","pointermove"]);const xYe=["image/png","image/jpeg","image/gif","image/webp","application/pdf","text/*","application/json","application/ld+json","application/toml","application/x-toml","application/x-yaml","application/xml","application/yaml",".c",".cc",".cjs",".conf",".cpp",".css",".csv",".cts",".env",".go",".gql",".graphql",".h",".hh",".hpp",".htm",".html",".ini",".java",".js",".json",".jsx",".log",".md",".mdx",".mjs",".mts",".py",".rb",".rs",".sass",".scss",".sh",".sql",".toml",".ts",".tsx",".txt",".xml",".yaml",".yml",".zsh"];function kYe(e){const t=()=>{const o=e.capture(),a=e.editor();if(a)return{prompt:o,cursor:o.cursor()??IYe(a)}},n=async(o,a=!0,l=t())=>{if(!l)return!1;const c=await EYe(o);if(!c)return a&&e.warn(),!1;const u=await SYe(o,c);if(!u)return!1;const d={type:"image",id:globalThis.crypto?.randomUUID?.()??Math.random().toString(16).slice(2),filename:o.name,sourcePath:e.getPathForFile?.(o)||void 0,mime:c,dataUrl:u};return l.prompt.set([...l.prompt.current(),d],l.cursor),!0},r=async(o,a=!0,l=t())=>{const c=await o.reduce(async(u,d)=>{const f=await u;return await n(d,!1,l)||f},Promise.resolve(!1));return!c&&o.length>0&&a&&e.warn(),c},i=async o=>{const a=o.clipboardData;if(!a)return;const l=t();if(!l)return;o.preventDefault(),o.stopPropagation();const c=Array.from(a.items).flatMap(m=>{if(m.kind!=="file")return[];const g=m.getAsFile();return g?[g]:[]});if(c.length>0){await r(c,!0,l);return}const u=a.getData("text/plain")??"";if(e.readClipboardImage&&!u){const m=await e.readClipboardImage();if(m&&await n(m,!0,l))return}if(!u)return;const d=u.includes("\r")?u.replace(/\r\n?/g,`
1168
1168
  `):u,f=()=>e.addPart({type:"text",content:d,start:0,end:0})?!0:(e.focusEditor(),e.addPart({type:"text",content:d,start:0,end:0}));if(d.includes(`
@@ -1170,7 +1170,7 @@ ${Ce.commentID}`)?.time??Date.now():Date.now(),origin:Ce.commentOrigin,preview:C
1170
1170
  `).length-1>=120}function LYe(e){const t=()=>typeof e=="function"?e():e,n=()=>{const i=t()[0];return typeof i=="function"?i():i},r=()=>t()[1];return{get state(){return n()},setPrompt(i,s){qt(()=>{r()("prompt",i),s!==void 0&&r()("cursor",s)})},setCursor(i){r()("cursor",i)},setText(i){qt(()=>{r()("prompt",s=>[{type:"text",content:i,start:0,end:i.length},...s.filter(o=>o.type!=="text")]),r()("cursor",i.length)})},addText(i){const s=n().cursor??$Ye(n().prompt);qt(()=>{r()("prompt",o=>AYe(o,s,i)),r()("cursor",s+i.length)})},reset(){qt(()=>{r()("prompt",[{type:"text",content:"",start:0,end:0}]),r()("cursor",0)})},setModel(i){r()("model",i)},setVariant(i){n().model&&r()("model","variant",i)},addContext(i){n().context.items.some(s=>s.key===i.key)||r()("context","items",s=>[...s,i])},removeContext(i){r()("context","items",s=>s.filter(o=>o.key!==i))},addMention(i){const s=n().prompt.map(l=>"content"in l?l.content:"").join(""),o=n().cursor??s.length,a=s.slice(0,o).lastIndexOf("@");r()("prompt",MYe(n().prompt,a<0?o:a,o,i)),r()("cursor",(a<0?o:a)+i.content.length+1)},addAttachment(i){r()("prompt",s=>[...s,i])},removeAttachment(i){r()("prompt",s=>s.filter(o=>o.type!=="image"||o.id!==i))}}}function AYe(e,t,n){let r=0,i=!1;const s=e.flatMap(o=>{if(o.type==="image")return[o];const a=r;if(r+=o.content.length,i)return[o];if(o.type==="text"&&t>=a&&t<=r){i=!0;const l=t-a;return[{...o,content:o.content.slice(0,l)+n+o.content.slice(l)}]}return t>a?[o]:(i=!0,[{type:"text",content:n,start:0,end:0},o])});return i||s.push({type:"text",content:n,start:0,end:0}),vne(s)}function MYe(e,t,n,r){let i=0;const s=e.flatMap(o=>{if(o.type==="image")return[o];const a=i;if(i+=o.content.length,o.type!=="text"||t<a||n>i)return[o];const l=o.content.slice(0,t-a),c=o.content.slice(n-a);return[...l?[{type:"text",content:l,start:0,end:0}]:[],r,{type:"text",content:` ${c}`,start:0,end:0}]});return vne(s)}function vne(e){let t=0;return e.map(n=>{if(n.type==="image")return n;const r={...n,start:t,end:t+n.content.length};return t=r.end,r})}function $Ye(e){return e.reduce((t,n)=>t+("content"in n?n.content.length:0),0)}function yne(){return{mode:"normal",popover:{type:"closed"},drag:"idle",focus:"external",historyIndex:-1}}function PYe(e,t,n){return t.type==="input.changed"?OYe(e,t.value,t.persist!==!1,n.cursor):t.type==="commands.open"?RYe(e,n):t.type==="context.open"?FYe(e,n):t.type==="popover.query"?NYe(e,t.value):t.type==="popover.results"?VYe(e,t.ids):t.type==="popover.active"?zYe(e,t.id):t.type==="popover.close"?si({...e,popover:{type:"closed"}}):t.type==="popover.select"?HYe(e,t.item,n):t.type==="key.down"?jYe(e,t):t.type==="mode.shell"?si({...e,mode:"shell",popover:{type:"closed"}}):t.type==="mode.normal"?si({...e,mode:"normal"}):t.type==="drag.enter"?si({...e,drag:"active"}):t.type==="drag.leave"?si({...e,drag:"idle"}):t.type==="focus.editor"?si({...e,focus:"editor"}):t.type==="context.active"?si({...e,activeContextID:e.activeContextID===t.id?void 0:t.id}):si({...e,focus:"external"})}function OYe(e,t,n,r){const i=n?[{type:"draft.setText",value:t}]:[];if(e.mode==="normal"&&t==="!")return si({...e,mode:"shell",popover:{type:"closed"},focus:"editor"},[{type:"draft.setText",value:""}]);const s=t.slice(0,r??t.length).match(/(?:^|\s)@([^\s@]*)$/);if(s){const a=s[1]??"";return si({...e,popover:{type:"context",query:a},focus:"editor"},[...i,{type:"popover.filter",popover:"context",query:a}])}const o=t.match(/^\/(\S*)$/);if(o){const a=o[1]??"";return si({...e,popover:{type:"command-inline",query:a},focus:"editor"},[...i,{type:"popover.filter",popover:"command",query:a}])}return si({...e,popover:e.popover.type==="command-menu"?e.popover:{type:"closed"},focus:"editor"},i)}function RYe(e,t){return qYe(t)?si({...e,popover:{type:"command-menu",query:""},focus:"command-search"},[{type:"popover.filter",popover:"command",query:""},{type:"focus.command-search"}]):si({...e,popover:{type:"command-inline",query:""},focus:"editor"},[{type:"draft.setText",value:n3(t)+"/"},{type:"popover.filter",popover:"command",query:""},{type:"focus.editor"}])}function FYe(e,t){return si({...e,popover:{type:"context",query:""},focus:"editor"},[{type:"draft.setText",value:n3(t)+"@"},{type:"popover.filter",popover:"context",query:""},{type:"focus.editor"}])}function NYe(e,t){if(e.popover.type==="closed")return Oc(e);const n=e.popover.type==="context"?"context":"command";return si({...e,popover:{...e.popover,query:t,activeID:void 0}},[{type:"popover.filter",popover:n,query:t}])}function VYe(e,t){if(e.popover.type==="closed")return Oc(e);const n=e.popover.activeID&&t.includes(e.popover.activeID)?e.popover.activeID:t[0];return n===e.popover.activeID?Oc(e):si({...e,popover:{...e.popover,activeID:n}})}function zYe(e,t){return e.popover.type==="closed"||e.popover.activeID===t?Oc(e):si({...e,popover:{...e.popover,activeID:t}})}function HYe(e,t,n){const r=n3(n),i=[];return t.kind==="command"?i.push({type:"draft.setText",value:e.popover.type==="command-menu"?r.trim()?`${t.label} ${r.trim()}`:`${t.label} `:BYe(r,"/",`${t.label} `)}):i.push({type:"mention.add",item:t}),i.push({type:"focus.editor"}),si({...e,popover:{type:"closed"},focus:"editor"},i)}function jYe(e,t){if(t.ctrl&&t.key.toLowerCase()==="g")return e.popover.type==="closed"?Oc(e):si({...e,popover:{type:"closed"},focus:"editor"},[{type:"focus.editor"}],!0);if(e.popover.type==="closed")return e.mode==="shell"&&(t.key==="Escape"||t.key==="Backspace"&&t.empty)?si({...e,mode:"normal"},[],!0):Oc(e);if(t.key==="Escape")return si({...e,popover:{type:"closed"},focus:"editor"},[{type:"focus.editor"}],!0);if(t.key==="Tab"||t.key==="Enter"&&!t.composing)return e.popover.activeID?Oc(e,!0,[{type:"suggestion.select",id:e.popover.activeID}]):Oc(e,!0);const n=t.key==="ArrowDown"||t.ctrl&&t.key==="n"?1:t.key==="ArrowUp"||t.ctrl&&t.key==="p"?-1:0;if(!n||t.ids.length===0)return Oc(e);const r=e.popover.activeID?t.ids.indexOf(e.popover.activeID):-1,i=r<0?n===1?0:t.ids.length-1:(r+n+t.ids.length)%t.ids.length;return si({...e,popover:{...e.popover,activeID:t.ids[i]}},[],!0)}function n3(e){return e.prompt.map(t=>t.type==="text"?t.content:"").join("")}function qYe(e){return!!n3(e).trim()||e.context.items.length>0||e.prompt.some(t=>t.type==="file"||t.type==="image")}function BYe(e,t,n){const r=e.indexOf(t);return r<0?n:e.slice(0,r)+n}function si(e,t=[],n=!1){return{state:e,commands:t,handled:n}}function Oc(e,t=!1,n=[]){return{state:e,commands:n,handled:t}}function bne(){return Ze(yne())}function UYe(e){let t,n;const r=LYe(e.store),[i,s]=e.state??bne();e.identity&&ae(vt(e.identity,()=>s(kn(yne())),{defer:!0}));function o(w){return w.type==="image"?!1:w.type==="file"||w.type==="agent"?(r.addMention(w),!0):(r.addText(w.content),!0)}const a=e.attachments?kYe({...e.attachments,capture:()=>({current:()=>r.state.prompt,cursor:()=>r.state.cursor,set:r.setPrompt}),editor:()=>t,focusEditor:()=>t?.focus(),addPart:o,setDraggingType:w=>g({type:w?"drag.enter":"drag.leave"})}):void 0,l=()=>{if(!a){e.view.add?.onAttach();return}a.pick(()=>n?.click())},c=th({items:async w=>{const x=e.context().filter(_=>_.kind!=="file"),k=e.context().filter(_=>_.kind==="file"&&_.recent);if(!w.trim())return[...x,...k];const C=new Set(k.map(_=>_.id)),E=(await e.searchContextFiles(w)).filter(_=>!C.has(_.id));return[...x,...k,...E]},key:w=>w.id,filterKeys:["label"],skipFilter:w=>w.kind==="file"&&!w.recent,groupBy:w=>w.kind==="reference"?"reference":w.kind==="agent"?"agent":w.kind==="resource"?"resource":w.recent?"recent":"file",sortGroupsBy:(w,x)=>{const k=["reference","agent","resource","recent","file"];return k.indexOf(w.category)-k.indexOf(x.category)}}),u=th({items:()=>e.commands(),key:w=>w.id,filterKeys:["trigger","title"]}),d=()=>i.popover.type==="context"?c:u,f=()=>d().flat(),m=w=>{if(w.type==="draft.setText"){r.setText(w.value);return}if(w.type==="mention.add"){w.item.mention&&r.addMention(w.item.mention);return}if(w.type==="popover.filter"){(w.popover==="command"?u:c).onInput(w.query);return}if(w.type==="suggestion.select"){const x=f().find(k=>k.id===w.id);x&&g({type:"popover.select",item:x});return}w.type==="focus.editor"&&requestAnimationFrame(()=>t?.focus())};function g(w){const x=i.mode,k=PYe(i,w,r.state),C=w.type==="popover.select"?e.onSuggestionSelect?.(w.item):void 0;if(w.type==="popover.select"&&((!C||i.popover.type!=="command-menu")&&k.commands.forEach(m),C&&w.item.kind==="command"&&i.popover.type!=="command-menu"&&r.setPrompt(r.state.prompt.filter(E=>E.type==="image"),0)),s(kn(k.state)),w.type!=="popover.select"&&k.commands.forEach(m),x!==k.state.mode&&(k.state.mode==="shell"&&e.view.shell?.onOpen(),k.state.mode==="normal"&&e.view.shell?.onClose()),w.type==="popover.select"){if(!C)return k.handled;C()}return k.handled}const p=w=>{if(i.mode==="normal"&&(w.metaKey||w.ctrlKey)&&!w.altKey&&!w.shiftKey&&w.key.toLowerCase()==="u")return w.preventDefault(),l(),!0;const x=g({type:"key.down",key:w.key,ctrl:w.ctrlKey&&!w.metaKey&&!w.altKey&&!w.shiftKey,composing:w.isComposing,ids:f().map(C=>C.id),empty:r.state.prompt.every(C=>!("content"in C)||C.content.length===0)});if(x&&w.preventDefault(),x&&w.key!=="Enter"&&w.key!=="Tab"&&i.popover.type!=="closed"){const C=i.popover.activeID??"";requestAnimationFrame(()=>document.querySelector(`[data-suggestion-id="${CSS.escape(C)}"]`)?.scrollIntoView({block:"nearest"}))}return x?!0:e.view.submit.working?.()&&(w.ctrlKey&&!w.metaKey&&!w.altKey&&!w.shiftKey&&w.key.toLowerCase()==="g"||w.key==="Escape")?(w.preventDefault(),e.view.submit.onStop(),!0):!w.altKey&&!w.ctrlKey&&!w.metaKey&&(w.key==="ArrowUp"||w.key==="ArrowDown")&&b(w.key==="ArrowUp"?"up":"down")?(w.preventDefault(),!0):(e.view.onKeyDown?.(w),w.defaultPrevented)};ae(()=>{if(i.popover.type==="closed")return;const w=f().map(x=>x.id);(i.popover.activeID?w.includes(i.popover.activeID):w.length===0)||g({type:"popover.results",ids:w})});const y=(w=r.state.cursor??WF(r.state.prompt))=>{requestAnimationFrame(()=>{t?.focus(),GYe(t,w)})},v=(w,x)=>{e.history?.restore?.(w.metadata);const k=x==="start"?0:WF(w.prompt);r.setPrompt(UF(w.prompt),k),y(k)},b=w=>{if(!e.history||!t)return!1;const x=window.getSelection();if(!x?.isCollapsed||!t.contains(x.anchorNode))return!1;const k=r.state.prompt.map(_=>"content"in _?_.content:"").join("");if(!WYe(w,k,KYe(t),i.historyIndex>=0))return!1;const C=e.history.entries(i.mode);if(w==="up"){if(C.length===0||i.historyIndex>=C.length-1)return!1;i.historyIndex===-1&&s("savedHistory",{prompt:UF(r.state.prompt),metadata:e.history.capture?.()});const _=i.historyIndex+1;return s("historyIndex",_),v(C[_],"start"),!0}if(i.historyIndex<0)return!1;if(i.historyIndex>0){const _=i.historyIndex-1;return s("historyIndex",_),v(C[_],"end"),!0}const E=i.savedHistory??{prompt:[{type:"text",content:"",start:0,end:0}]};return s({historyIndex:-1,savedHistory:void 0}),v(E,"end"),!0};return{state:i,view:e.view,suggestions:f,dispatch:g,onKeyDown:p,value(){return r.state.prompt.map(w=>"content"in w?w.content:"").join("")},parts(){return r.state.prompt},addPart:o,contextItem(w){return r.state.context.items.find(x=>x.key===w)},comments(){return r.state.context.items.filter(w=>!!w.comment?.trim())},attachments(){return r.state.prompt.filter(w=>w.type==="image")},toggleContext(w){g({type:"context.active",id:w}),e.openContext?.(w)},removeContext(w){const x=r.state.context.items.find(k=>k.key===w);x&&e.onContextRemove?.(x),r.removeContext(w),i.activeContextID===w&&g({type:"context.active",id:w})},openAttachment(w){e.openAttachment?.(w)},removeAttachment(w){r.removeAttachment(w)},canSubmit(){const w=r.state;return w.prompt.some(x=>x.type==="image")||w.context.items.some(x=>!!x.comment?.trim())?!0:w.prompt.some(x=>"content"in x&&!!x.content.trim())},setEditor(w){t=w,e.onEditor?.(w)},restoreFocus:y,onInput(w,x,k){x&&r.setPrompt(x,k),g({type:"input.changed",value:w,persist:!x})},onCursor(w){r.setCursor(w)},openCommands(){g({type:"commands.open"})},openContext(){g({type:"context.open"})},openShell(){g({type:"mode.shell"})},closeShell(){g({type:"mode.normal"})},submit(){e.view.submit.onSubmit(),g({type:"popover.close"})},stop(){e.view.submit.onStop()},addHistory(w,x){e.history?.add(w,x),s({historyIndex:-1,savedHistory:void 0})},resetHistory(){s({historyIndex:-1,savedHistory:void 0})},onPaste(w){const x=w.clipboardData;if(a&&(Array.from(x?.items??[]).some(O=>O.kind==="file")||!x?.getData("text/plain"))){a.handlePaste(w);return}if(e.view.onPaste?.(w),w.defaultPrevented)return;const k=x?.getData("text/plain");if(!k||(w.preventDefault(),typeof document.execCommand=="function"&&document.execCommand("insertText",!1,k)))return;const C=w.currentTarget,E=window.getSelection();if(!(C instanceof HTMLElement)||!E?.rangeCount||!C.contains(E.anchorNode))return;const _=E.getRangeAt(0);_.deleteContents();const L=document.createTextNode(k);_.insertNode(L),_.setStartAfter(L),_.collapse(!0),E.removeAllRanges(),E.addRange(_),C.dispatchEvent(new InputEvent("input",{bubbles:!0,inputType:"insertFromPaste",data:k}))},onDragEnter(w){w.preventDefault(),g({type:"drag.enter"})},onDragOver(w){w.preventDefault()},onDragLeave(){g({type:"drag.leave"})},onDrop(w){if(w.preventDefault(),g({type:"drag.leave"}),a){w.stopPropagation(),a.handleDrop(w);return}e.view.onDrop?.(w)},attach:l,setFileInput(w){n=w},addAttachments(w){a&&a.addAttachments(w)},setQuery(w){g({type:"popover.query",value:w})}}}function WYe(e,t,n,r){const i=Math.max(0,Math.min(n,t.length));return r?i===0||i===t.length:e==="up"?i===0&&t.length===0:i===t.length}function UF(e){return e.map(t=>t.type==="file"?{...t,selection:t.selection?{...t.selection}:void 0}:{...t})}function WF(e){return e.reduce((t,n)=>t+("content"in n?n.content.length:0),0)}function KYe(e){const t=window.getSelection();if(!t?.rangeCount||!e.contains(t.anchorNode))return e.textContent?.length??0;const n=t.getRangeAt(0).cloneRange();return n.selectNodeContents(e),n.setEnd(t.anchorNode,t.anchorOffset),n.toString().length}function GYe(e,t){if(!e)return;const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let r=t,i=n.nextNode();for(;i;){const s=i.textContent?.length??0;if(r<=s){const o=document.createRange();o.setStart(i,r),o.collapse(!0);const a=window.getSelection();a?.removeAllRanges(),a?.addRange(o);return}r-=s,i=n.nextNode()}}var ZYe=A('<div class="flex flex-col gap-3">'),YYe=A('<span class="truncate leading-4">'),XYe=A('<span class="-ml-0.5 -mr-1 flex shrink-0">');function QYe(e){const t=Mr(),n=Qi(),r=wt();return(()=>{var i=ZYe();return S(i,h(hYe,{get controller(){return e.controller},get borderUnderlay(){return e.borderUnderlay},get class(){return e.class},get attachKeybind(){return n.keybindParts("file.attach")},get attachShortcut(){return n.keybind("file.attach")},get modelControl(){return h(eXe,{get loading(){return e.controller.model.loading},get paid(){return e.controller.model.paid},get title(){return r.t("command.model.choose")},get keybind(){return n.keybindParts("model.choose")},get model(){return e.controller.model.selection},get providerID(){return e.controller.model.selection.current()?.provider?.id},get modelName(){return e.controller.model.selection.current()?.name??r.t("dialog.model.select.title")},get onClose(){return e.controller.restoreFocus},onUnpaidClick:()=>t.show(()=>h(QZe,{get model(){return e.controller.model.selection}}))})}})),i})()}function JYe(e){const t=kr(),n=Ji(),r=ua(),i=li(),s=q1(),o=Mr(),a=Qi(),l=mu(),c=wt(),u=Tr(),d=e.state??Hg();let f;const m=bne(),g=()=>m[0].mode,p=e.history??ine(),y=()=>e.controls.session.tabs,v=Nd({tabs:y,pathFromTab:r.pathFromTab,normalizeTab:K=>K.startsWith("file://")?r.tab(K):K}).activeFileTab,b=I(()=>{const K=y().all(),X=v();return(X?[X,...K.filter(ve=>ve!==X)]:K).reduce((ve,ne)=>{const ie=r.pathFromTab(ne);return!ie||ve.includes(ie)?ve:[...ve,ie]},[])}),w=I(()=>e.controls.session.id?n().session.get(e.controls.session.id):void 0),x=I(()=>n().data.session_working(e.controls.session.id??"")),k=I(()=>d.current().filter(K=>K.type==="image")),C=I(()=>g()==="shell"?0:d.context.items().filter(K=>!!K.comment?.trim()).length),E=I(()=>d.current().map(X=>"content"in X?X.content:"").join("").trim().length===0&&k().length===0&&C()===0),_=I(()=>x()&&E()),L=I(()=>dne({mode:g(),commentCount:C(),example:g()==="shell"?"git status":"",suggest:!1,t:(K,X)=>c.t(K,X)})),O=()=>TZe(g(),L()),$=()=>{const K=new Map(s.all().map(X=>[`${X.file}
1171
1171
  ${X.id}`,X]));return d.context.items().flatMap(X=>{const te=X.comment?.trim();if(!te)return[];const ne=(X.commentID?K.get(`${X.path}
1172
1172
  ${X.commentID}`)?.selection:void 0)??(X.selection?{start:X.selection.startLine,end:X.selection.endLine}:void 0);return ne?[{id:X.commentID??X.key,path:X.path,selection:{...ne},comment:te,time:X.commentID?K.get(`${X.path}
1173
- ${X.commentID}`)?.time??Date.now():Date.now(),origin:X.commentOrigin,preview:X.preview}]:[]})},V=K=>{s.replace(K.map(X=>({id:X.id,file:X.path,selection:{...X.selection},comment:X.comment,time:X.time}))),d.context.replaceComments(K.map(X=>({type:"file",path:X.path,selection:md(X.selection),comment:X.comment,commentID:X.id,commentOrigin:X.origin,preview:X.preview})))},P=I(()=>{const K=e.controls.session.id;return K?l.isAutoAccepting(K,t().directory):l.isAutoAcceptingDirectory(t().directory)}),T=cne({prompt:d,info:w,imageAttachments:k,commentCount:C,autoAccept:P,mode:g,working:x,editor:()=>f,queueScroll:()=>requestAnimationFrame(()=>f?.scrollIntoView({block:"nearest"})),promptLength:Ho,addToHistory:(K,X)=>J.addHistory(K,X),resetHistoryNavigation:()=>J.resetHistory(),setMode:K=>J.dispatch({type:K==="shell"?"mode.shell":"mode.normal"}),setPopover:K=>{K||J.dispatch({type:"popover.close"})},newSessionWorktree:()=>e.newSessionWorktree,onNewSessionWorktreeReset:e.onNewSessionWorktreeReset,shouldQueue:e.shouldQueue,onQueue:e.onQueue,onAbort:e.onAbort,onSubmit:e.onSubmit,model:e.controls.model.selection}),D=K=>K.source.type==="git"?K.source.repository:K.source.path,N=I(()=>n().data.reference.filter(K=>!K.hidden).map(K=>({id:`reference:${K.name}`,kind:"reference",label:`@${K.name}`,path:K.path,description:K.description??D(K),mention:{type:"file",path:K.path,content:`@${K.name}`,start:0,end:0,mime:"application/x-directory",filename:K.name}}))),M=I(()=>Object.values(n().data.mcp_resource).map(K=>({id:`resource:${K.server}:${K.uri}`,kind:"resource",label:`@${K.name}`,path:K.uri,description:K.description,mention:{type:"file",path:K.uri,content:`@${K.name}`,start:0,end:0,mime:K.mimeType??"text/plain",filename:K.name,url:K.uri,source:{type:"resource",text:{value:`@${K.name}`,start:0,end:K.name.length+1},clientName:K.server,uri:K.uri}},resource:K}))),F=I(()=>[...N(),...e.controls.agents.available.filter(K=>!K.hidden&&K.mode!=="primary").map(K=>({id:`agent:${K.name}`,kind:"agent",label:`@${K.name}`,mention:{type:"agent",name:K.name,content:`@${K.name}`,start:0,end:0}})),...M(),...b().map(K=>({id:`file:${K}`,kind:"file",label:K,path:K,recent:!0,mention:{type:"file",path:K,content:`@${K}`,start:0,end:0}}))]),j=I(()=>[...n().data.command.map(K=>({id:`custom.${K.name}`,trigger:K.name,title:K.name,description:K.description,type:"custom"})),...a.options.filter(K=>!K.disabled&&!K.id.startsWith("suggested.")&&K.slash).map(K=>({id:K.id,trigger:K.slash,title:K.title,description:K.description,type:"builtin"}))]),z=I(()=>j().map(K=>({id:K.id,kind:"command",label:`/${K.trigger}`,trigger:K.trigger,title:K.title,description:K.description,keybind:a.keybindParts(K.id)}))),W=I(()=>["default",...e.controls.model.selection.variant.list()]),J=UYe({store:()=>d.capture().store,state:m,identity:()=>d.capture(),history:{entries:K=>p.entries(K).map(X=>{const te=Gm(X);return{prompt:te.prompt,metadata:te.comments}}),add:(K,X)=>p.add(K,X,X==="shell"?[]:$()),capture:$,restore:K=>V(K)},commands:z,context:F,searchContextFiles:async K=>(await r.searchFilesAndDirectories(K)).map(X=>({id:`file:${X}`,kind:"file",label:X,path:X,mention:{type:"file",path:X,content:`@${X}`,start:0,end:0}})),onContextRemove(K){K?.commentID&&s.remove(K.path,K.commentID)},openAttachment:K=>o.show(()=>h(MI,{get src(){return K.dataUrl},get alt(){return K.filename}})),openContext(K){const X=J.contextItem(K);X&&tXe(X,e,n,i,r,s)},onEditor(K){f=K,e.ref?.(f)},onSuggestionSelect(K){if(K.kind!=="command")return;const X=j().find(te=>te.id===K.id);if(!(!X||X.type==="custom"))return()=>a.trigger(X.id,"slash")},attachments:{picker:u.openAttachmentPickerDialog,directory:()=>t().directory,isDialogActive:()=>!!o.active,warn:()=>tn({title:c.t("prompt.toast.pasteUnsupported.title"),description:c.t("prompt.toast.pasteUnsupported.description")}),onError:K=>tn({variant:"error",title:c.t("common.requestFailed"),description:K instanceof Error?K.message:String(K)}),readClipboardImage:u.readClipboardImage,getPathForFile:u.getPathForFile},view:{placeholder:O,get agent(){return e.controls.agents.visible&&e.controls.agents.options.length>0?{options:()=>e.controls.agents.options.map(K=>({id:K,label:K})),current:()=>e.controls.agents.current,onSelect:K=>e.controls.agents.select(K),keybind:()=>a.keybindParts("agent.cycle")}:void 0},variant:{options:()=>W().map(K=>({id:K,label:K})),current:()=>e.controls.model.selection.variant.current()??"default",onSelect:K=>e.controls.model.selection.variant.set(K==="default"?void 0:K),keybind:()=>a.keybindParts("model.variant.cycle")},submit:{stopping:_,working:x,onSubmit:()=>void T.handleSubmit(new Event("submit")),onStop:()=>void T.abort()}}});return Object.defineProperty(J,"model",{get:()=>e.controls.model}),a.register("prompt-input",()=>[{id:"file.attach",title:c.t("prompt.action.attachFile"),category:c.t("command.category.file"),keybind:"mod+u",disabled:J.state.mode!=="normal",onSelect:()=>J.attach()},{id:"prompt.mode.shell",title:c.t("command.prompt.mode.shell"),category:c.t("command.category.session"),keybind:"mod+shift+x",disabled:J.state.mode==="shell",onSelect:()=>J.dispatch({type:"mode.shell"})},{id:"prompt.mode.normal",title:c.t("command.prompt.mode.normal"),category:c.t("command.category.session"),keybind:"mod+shift+e",disabled:J.state.mode==="normal",onSelect:()=>J.dispatch({type:"mode.normal"})}]),ae(vt(()=>e.edit?.id,K=>{const X=e.edit;!K||!X||(d.context.items().forEach(te=>d.context.remove(te.key)),X.context.forEach(te=>d.context.add({type:te.type,path:te.path,selection:te.selection,comment:te.comment,commentID:te.commentID,commentOrigin:te.commentOrigin,preview:te.preview})),J.dispatch({type:"mode.normal"}),J.resetHistory(),d.set(X.prompt,Ho(X.prompt)),J.restoreFocus(),e.onEditLoaded?.())},{defer:!0})),J}function eXe(e){const t=I(r=>r??e.loading),n=()=>[h(q,{get when(){return e.providerID},children:r=>h(wg,{get id(){return r()},class:"size-4 shrink-0 opacity-40 group-hover:opacity-100 transition-opacity duration-150",style:{"will-change":"opacity",transform:"translateZ(0)"}})}),(()=>{var r=YYe();return S(r,()=>e.modelName),r})(),(()=>{var r=XYe();return S(r,h(on,{name:"chevron-down"})),r})()];return h(q,{get when(){return!e.loading},get children(){return h(Qn,{placement:"top",gutter:4,get value(){return[we(()=>e.title),h(Eo,{get keys(){return e.keybind},variant:"neutral"})]},get children(){return h(q,{get when(){return e.paid},get fallback(){return h(as,{"data-action":"prompt-model","data-control-type":"dialog",variant:"ghost-muted",size:"normal",class:"min-w-0 max-w-[220px] justify-start ![font-weight:440] group",get classList(){return{"animate-in fade-in":t()}},style:{height:"28px"},get onClick(){return e.onUnpaidClick},get children(){return n()}})},get children(){return h(ene,{get model(){return e.model},triggerAs:as,get triggerProps(){return{variant:"ghost-muted",size:"normal",style:{height:"28px"},class:"min-w-0 max-w-[220px] justify-start ![font-weight:440] group",classList:{"animate-in fade-in":t()},"data-action":"prompt-model","data-control-type":"popover"}},get onClose(){return e.onClose},get children(){return n()}})}})}})}})}function tXe(e,t,n,r,i,s){if(!e.commentID)return;const o={file:e.path,id:e.commentID};s.setActive(o);const a=(d=6)=>{requestAnimationFrame(()=>{s.setFocus({...o}),!(d<=0)&&requestAnimationFrame(()=>{const f=s.focus();f?.file===o.file&&f.id===o.id&&a(d-1)})})},l=t.controls.session.id?n().data.session_diff[t.controls.session.id]:void 0,c=e.commentOrigin==="review"||e.commentOrigin!=="file"&&l?.some(d=>d.file===e.path);if(t.controls.session.reviewPanel.opened()||t.controls.session.reviewPanel.open(),c){r.fileTree.setTab("changes"),t.controls.session.tabs.setActive("review"),a();return}r.fileTree.setTab("all");const u=i.tab(e.path);t.controls.session.tabs.open(u),t.controls.session.tabs.setActive(u),Promise.resolve(i.load(e.path)).finally(()=>a())}function nXe(e){const t=Mr(),n=Br();let r=0,i=!1;return Te(()=>{i=!0}),()=>{const s=++r,o=n.id;B(()=>import("./index-wflYMX4p.js"),__vite__mapDeps([103,104,105,106,107,108,109,110])).then(a=>{i||r!==s||t.show(()=>h(a.DialogSettings,{sessionID:o,defaultValue:e}))})}}function wne(){const e=Qi(),t=wt(),n=nXe();return e.register("settings",()=>[{id:"settings.open",title:t.t("command.settings.open"),category:t.t("command.category.settings"),keybind:"mod+comma",onSelect:n}]),n}var KF=A("<div>"),rXe=A("<div data-component=dock-prompt>");function xne(e){const t=n=>`${e.kind}-${n}`;return(()=>{var n=rXe();cn(n,"keydown",e.onKeyDown,!0);var r=e.ref;return typeof r=="function"?pt(r,n):e.ref=n,S(n,h(HWe,{get"data-slot"(){return t("body")},get children(){return[(()=>{var i=KF();return S(i,()=>e.header),he(()=>me(i,"data-slot",t("header"))),i})(),(()=>{var i=KF();return S(i,()=>e.children),he(()=>me(i,"data-slot",t("content"))),i})()]}}),null),S(n,h(yy,{get"data-slot"(){return t("footer")},get children(){return e.footer}}),null),he(()=>me(n,"data-kind",e.kind)),n})()}dn(["keydown"]);var iXe=A("<div data-slot=permission-row><span data-slot=permission-spacer aria-hidden=true></span><div data-slot=permission-hint>"),sXe=A("<div data-slot=permission-row><span data-slot=permission-spacer aria-hidden=true></span><div data-slot=permission-patterns>"),oXe=A("<div data-slot=permission-row data-variant=header><span data-slot=permission-icon></span><div data-slot=permission-header-title>"),aXe=A("<div>"),lXe=A("<div data-slot=permission-footer-actions>"),cXe=A('<code class="text-12-regular text-text-base break-all">');function uXe(e){const t=wt(),n=()=>{const r=`settings.permissions.tool.${e.request.permission}.description`,i=t.t(r);return i===r?"":i};return h(xne,{kind:"permission",get header(){return(()=>{var r=oXe(),i=r.firstChild,s=i.nextSibling;return S(i,h(Yt,{name:"warning",size:"normal"})),S(s,()=>t.t("notification.permission.title")),r})()},get footer(){return[aXe(),(()=>{var r=lXe();return S(r,h(Kt,{variant:"ghost",size:"normal",onClick:()=>e.onDecide("reject"),get disabled(){return e.responding},get children(){return t.t("ui.permission.deny")}}),null),S(r,h(Kt,{variant:"secondary",size:"normal",onClick:()=>e.onDecide("always"),get disabled(){return e.responding},get children(){return t.t("ui.permission.allowAlways")}}),null),S(r,h(Kt,{variant:"primary",size:"normal",onClick:()=>e.onDecide("once"),get disabled(){return e.responding},get children(){return t.t("ui.permission.allowOnce")}}),null),r})()]},get children(){return[h(q,{get when(){return n()},get children(){var r=iXe(),i=r.firstChild,s=i.nextSibling;return S(s,n),r}}),h(q,{get when(){return e.request.patterns.length>0},get children(){var r=sXe(),i=r.firstChild,s=i.nextSibling;return S(s,h(Dt,{get each(){return e.request.patterns},children:o=>(()=>{var a=cXe();return S(a,o),a})()})),r}})]}})}var dXe=A("<span data-slot=question-option-check aria-hidden=true><span data-slot=question-option-box>"),fXe=A("<span data-slot=question-option-radio-dot>"),hXe=A("<span data-slot=option-description>"),mXe=A("<button type=button data-slot=question-option><span data-slot=question-option-main><span data-slot=option-label>"),gXe=A("<div data-slot=question-text>"),GF=A("<div data-slot=question-hint>"),pXe=A("<form data-slot=question-option data-custom=true><span data-slot=question-option-main><span data-slot=option-label></span><textarea data-slot=question-custom-input rows=1>"),vXe=A("<div data-slot=question-options>"),yXe=A("<div data-component=session-question-dock>"),bXe=A("<div data-slot=question-header-title>"),wXe=A("<div data-slot=question-progress>"),xXe=A("<div data-slot=question-header-actions><button type=button data-component=icon-button data-icon=chevron-down data-size=normal data-variant=ghost>"),kXe=A("<button type=button data-slot=question-progress-segment>"),SXe=A("<div data-slot=question-footer-actions>"),CXe=A("<button type=button data-slot=question-option data-custom=true><span data-slot=question-option-main><span data-slot=option-label></span><span data-slot=option-description>");const e2=new Map;function $C(e){return(()=>{var t=dXe(),n=t.firstChild;return cn(t,"click",e.onClick,!0),S(n,h(q,{get when(){return e.multi},get fallback(){return fXe()},get children(){return h(Yt,{name:"check-small",size:"small"})}})),he(r=>{var i=e.multi?"checkbox":"radio",s=e.picked;return i!==r.e&&me(n,"data-type",r.e=i),s!==r.t&&me(n,"data-picked",r.t=s),r},{e:void 0,t:void 0}),t})()}function _Xe(e){return(()=>{var t=mXe(),n=t.firstChild,r=n.firstChild;cn(t,"click",e.onClick,!0),cn(t,"focus",e.onFocus);var i=e.ref;return typeof i=="function"?pt(i,t):e.ref=t,S(t,h($C,{get multi(){return e.multi},get picked(){return e.picked}}),n),S(r,()=>e.label),S(n,h(q,{get when(){return e.description},get children(){var s=hXe();return S(s,()=>e.description),s}}),null),he(s=>{var o=e.picked,a=e.multi?"checkbox":"radio",l=e.picked,c=e.disabled;return o!==s.e&&me(t,"data-picked",s.e=o),a!==s.t&&me(t,"role",s.t=a),l!==s.a&&me(t,"aria-checked",s.a=l),c!==s.o&&(t.disabled=s.o=c),s},{e:void 0,t:void 0,a:void 0,o:void 0}),t})()}const TXe=e=>{const t=kr(),n=xs(),r=wt(),i=fc.from(n().scope,e.request.id),s=I(()=>e.request.questions),o=I(()=>s().length),a=e2.get(i),[l,c]=Ze({tab:a?.tab??0,answers:a?.answers??[],custom:a?.custom??[],customOn:a?.customOn??[],editing:!1,focus:0,minimized:!1,optionsHeight:180});let u,d,f,m=[],g=!1,p;const y=I(()=>s()[l.tab]),v=I(()=>y()?.options??[]),b=I(()=>l.custom[l.tab]??""),w=I(()=>l.customOn[l.tab]===!0),x=I(()=>y()?.multiple===!0),k=I(()=>v().length+1),C=I(()=>{const re=Math.min(l.tab+1,o());return r.t("session.question.progress",{current:re,total:o()})}),E=()=>r.t("ui.messagePart.option.typeOwnAnswer"),_=()=>r.t("ui.question.custom.placeholder"),L=I(()=>l.tab>=o()-1),O=vy(()=>l.minimized?1:0,{visualDuration:.3,bounce:0}),$=I(()=>Math.max(0,Math.min(1,O()))),V=I(()=>$()>.98),P=(re,pe=w())=>{const ye=b().trim(),Re=re.trim();if(c("custom",l.tab,re),!!pe){if(x()){c("answers",l.tab,(Je=[])=>{const Xe=ye?Je.filter(je=>je.trim()!==ye):Je;return!Re||Xe.some(je=>je.trim()===Re)?Xe:[...Xe,Re]});return}c("answers",l.tab,Re?[Re]:[])}},T=()=>{if(!u)return;const re=document.querySelector(".scroll-view__viewport"),pe=re instanceof HTMLElement?re.firstElementChild:void 0,ye=pe instanceof HTMLElement&&pe.classList.contains("sticky")?pe.getBoundingClientRect().bottom:0;if(!ye){u.style.removeProperty("--question-prompt-max-height");return}const Re=u.closest('[data-component="session-prompt-dock"]');if(!(Re instanceof HTMLElement))return;const Je=Re.getBoundingClientRect().bottom,Xe=Math.max(0,Je-u.getBoundingClientRect().bottom),mt=Math.max(240,Math.floor(Je-ye-8-Xe));u.style.setProperty("--question-prompt-max-height",`${mt}px`)},D=re=>Math.max(0,Math.min(k()-1,re)),N=(re=l.tab)=>{const pe=s()[re]?.options??[];return l.customOn[re]===!0?pe.length:Math.max(0,pe.findIndex(ye=>l.answers[re]?.includes(ye.label)??!1))},M=re=>{const pe=D(re);c("focus",pe),!l.editing&&(p!==void 0&&cancelAnimationFrame(p),p=requestAnimationFrame(()=>{p=void 0,(pe===v().length?f:m[pe])?.focus()}))};sn(()=>{let re;const pe=()=>{re!==void 0&&cancelAnimationFrame(re),re=requestAnimationFrame(()=>{re=void 0,T()})};pe(),an(window,"resize",pe);const ye=u?.closest('[data-component="session-prompt-dock"]'),Re=document.querySelector(".scroll-view__viewport");Oa([ye,Re],pe),Te(()=>{re!==void 0&&cancelAnimationFrame(re)}),M(N())}),ae(()=>{const re=d;if(!re)return;const pe=()=>c("optionsHeight",ye=>Math.max(ye,re.scrollHeight));pe(),Oa(re,pe)}),Te(()=>{p!==void 0&&cancelAnimationFrame(p),!g&&e2.set(i,{tab:l.tab,answers:l.answers.map(re=>re?[...re]:[]),custom:l.custom.map(re=>re??""),customOn:l.customOn.map(re=>re??!1)})});const F=re=>{const pe=re instanceof Error?re.message:String(re);tn({title:r.t("common.requestFailed"),description:pe})},j=Yo(()=>({mutationFn:re=>t().api.question.reply({sessionID:e.request.sessionID,requestID:e.request.id,answers:re}),onMutate:()=>{e.onSubmit()},onSuccess:()=>{g=!0,e2.delete(i)},onError:F})),z=Yo(()=>({mutationFn:()=>t().api.question.reject({sessionID:e.request.sessionID,requestID:e.request.id}),onMutate:()=>{e.onSubmit()},onSuccess:()=>{g=!0,e2.delete(i)},onError:F})),W=I(()=>j.isPending||z.isPending),J=async re=>{W()||await j.mutateAsync(re)},K=async()=>{W()||await z.mutateAsync()},X=()=>void J(s().map((re,pe)=>l.answers[pe]??[])),te=re=>(l.answers[re]?.length??0)>0?!0:l.customOn[re]===!0&&(l.custom[re]??"").trim().length>0,ve=re=>l.answers[l.tab]?.includes(re)??!1,ne=(re,pe=!1)=>{c("answers",l.tab,[re]),pe&&c("custom",l.tab,re),pe||c("customOn",l.tab,!1),c("editing",!1)},ie=re=>{c("answers",l.tab,(pe=[])=>pe.includes(re)?pe.filter(ye=>ye!==re):[...pe,re])},ke=()=>{if(W())return;if(c("focus",v().length),!x()){c("customOn",l.tab,!0),c("editing",!0),P(b(),!0);return}const re=!w();if(c("customOn",l.tab,re),re){c("editing",!0),P(b(),!0);return}const pe=b().trim();pe&&c("answers",l.tab,(ye=[])=>ye.filter(Re=>Re.trim()!==pe)),c("editing",!1),M(v().length)},ge=()=>{W()||(c("focus",v().length),w()||c("customOn",l.tab,!0),c("editing",!0),P(b(),!0))},Pe=re=>{l.editing||W()||M(l.focus+re)},Me=re=>{if(re.defaultPrevented)return;if(re.key==="Escape"){re.preventDefault(),K();return}if((re.metaKey||re.ctrlKey)&&!re.altKey&&re.key==="Enter"){if(re.repeat)return;re.preventDefault(),ce();return}const ye=re.target instanceof HTMLElement?re.target.closest('[data-slot="question-options"]'):void 0;if(!l.editing&&ye instanceof HTMLElement&&!(re.altKey||re.ctrlKey||re.metaKey)){if(re.key==="ArrowDown"||re.key==="ArrowRight"){re.preventDefault(),Pe(1);return}if(re.key==="ArrowUp"||re.key==="ArrowLeft"){re.preventDefault(),Pe(-1);return}if(re.key==="Home"){re.preventDefault(),M(0);return}re.key==="End"&&(re.preventDefault(),M(k()-1))}},de=re=>{if(W())return;if(re===v().length){ge();return}const pe=v()[re];if(pe){if(x()){c("editing",!1),ie(pe.label);return}ne(pe.label)}},U=()=>{c("editing",!1),P(b()),M(v().length)},He=re=>{re.style.height="0px",re.style.height=`${re.scrollHeight}px`},Ue=re=>{setTimeout(()=>{re.focus(),He(re)},0)},Z=re=>{re.preventDefault(),re.stopPropagation(),ke()},ce=()=>{if(W())return;if(l.editing&&U(),l.tab>=o()-1){X();return}const re=l.tab+1;c("tab",re),c("editing",!1),l.minimized||M(N(re))},G=()=>{if(W()||l.tab<=0)return;const re=l.tab-1;c("tab",re),c("editing",!1),l.minimized||M(N(re))},fe=re=>{W()||(c("tab",re),c("editing",!1),l.minimized||M(N(re)))},xe=()=>{W()||(c("editing",!1),c("minimized",!0))},Oe=()=>{W()||(c("minimized",!1),M(N()))};return(()=>{var re=yXe();return S(re,h(xne,{kind:"question",ref:pe=>u=pe,onKeyDown:Me,get header(){return[(()=>{var pe=bXe();return S(pe,C),pe})(),(()=>{var pe=xXe(),ye=pe.firstChild;return S(pe,h(q,{get when(){return o()>1},get children(){var Re=wXe();return S(Re,h(Dt,{get each(){return s()},children:(Je,Xe)=>(()=>{var je=kXe();return je.$$click=()=>fe(Xe()),he(mt=>{var Et=Xe()===l.tab,Bt=te(Xe()),Qe=W(),Be=`${r.t("ui.tool.questions")} ${Xe()+1}`;return Et!==mt.e&&me(je,"data-active",mt.e=Et),Bt!==mt.t&&me(je,"data-answered",mt.t=Bt),Qe!==mt.a&&(je.disabled=mt.a=Qe),Be!==mt.o&&me(je,"aria-label",mt.o=Be),mt},{e:void 0,t:void 0,a:void 0,o:void 0}),je})()})),Re}}),ye),cn(ye,"click",l.minimized?Oe:xe,!0),S(ye,h(Yt,{name:"chevron-down",size:"small"})),he(Re=>{var Je=W(),Xe=`rotate(${$()*180}deg)`,je=r.t(l.minimized?"session.question.restore":"session.question.minimize");return Je!==Re.e&&(ye.disabled=Re.e=Je),Xe!==Re.t&&Ct(ye,"transform",Re.t=Xe),je!==Re.a&&me(ye,"aria-label",Re.a=je),Re},{e:void 0,t:void 0,a:void 0}),pe})()]},get footer(){return[h(Kt,{variant:"ghost",size:"large",get disabled(){return W()},onClick:K,"aria-keyshortcuts":"Escape",get children(){return r.t("ui.common.dismiss")}}),(()=>{var pe=SXe();return S(pe,h(q,{get when(){return l.tab>0},get children(){return h(Kt,{variant:"secondary",size:"large",get disabled(){return W()},onClick:G,get children(){return r.t("ui.common.back")}})}}),null),S(pe,h(Kt,{get variant(){return L()?"primary":"secondary"},size:"large",get disabled(){return W()},onClick:ce,"aria-keyshortcuts":"Meta+Enter Control+Enter",get children(){return we(()=>!!L())()?r.t("ui.common.submit"):r.t("ui.common.next")}}),null),pe})()]},get children(){return[(()=>{var pe=gXe();return S(pe,()=>y()?.question),he(ye=>{var Re=l.minimized?"-webkit-box":void 0,Je=l.minimized?"3":void 0,Xe=l.minimized?"vertical":void 0,je=l.minimized?"hidden":void 0;return Re!==ye.e&&Ct(pe,"display",ye.e=Re),Je!==ye.t&&Ct(pe,"-webkit-line-clamp",ye.t=Je),Xe!==ye.a&&Ct(pe,"-webkit-box-orient",ye.a=Xe),je!==ye.o&&Ct(pe,"overflow",ye.o=je),ye},{e:void 0,t:void 0,a:void 0,o:void 0}),pe})(),h(q,{get when(){return!l.minimized},get children(){return h(q,{get when(){return x()},get fallback(){return(()=>{var pe=GF();return S(pe,()=>r.t("ui.question.singleHint")),pe})()},get children(){var pe=GF();return S(pe,()=>r.t("ui.question.multiHint")),pe}})}}),(()=>{var pe=vXe();return pt(ye=>d=ye,pe),S(pe,h(Dt,{get each(){return v()},children:(ye,Re)=>h(_Xe,{get multi(){return x()},get picked(){return ve(ye.label)},get label(){return ye.label},get description(){return ye.description},get disabled(){return W()},ref:Je=>m[Re()]=Je,onFocus:()=>c("focus",Re()),onClick:()=>de(Re())})}),null),S(pe,h(q,{get when(){return l.editing},get fallback(){return(()=>{var ye=CXe(),Re=ye.firstChild,Je=Re.firstChild,Xe=Je.nextSibling;ye.$$click=ge,ye.addEventListener("focus",()=>c("focus",v().length));var je=f;return typeof je=="function"?pt(je,ye):f=ye,S(ye,h($C,{get multi(){return x()},get picked(){return w()},onClick:Z}),Re),S(Je,E),S(Xe,()=>b()||_()),he(mt=>{var Et=w(),Bt=x()?"checkbox":"radio",Qe=w(),Be=W();return Et!==mt.e&&me(ye,"data-picked",mt.e=Et),Bt!==mt.t&&me(ye,"role",mt.t=Bt),Qe!==mt.a&&me(ye,"aria-checked",mt.a=Qe),Be!==mt.o&&(ye.disabled=mt.o=Be),mt},{e:void 0,t:void 0,a:void 0,o:void 0}),ye})()},get children(){var ye=pXe(),Re=ye.firstChild,Je=Re.firstChild,Xe=Je.nextSibling;return ye.addEventListener("submit",je=>{je.preventDefault(),U()}),ye.$$mousedown=je=>{if(W()){je.preventDefault();return}if(je.target instanceof HTMLTextAreaElement)return;const mt=je.currentTarget.querySelector('[data-slot="question-custom-input"]');mt instanceof HTMLTextAreaElement&&mt.focus()},S(ye,h($C,{get multi(){return x()},get picked(){return w()},onClick:Z}),Re),S(Je,E),Xe.$$input=je=>{P(je.currentTarget.value),He(je.currentTarget)},Xe.$$keydown=je=>{if(je.key==="Escape"){je.preventDefault(),c("editing",!1),M(v().length);return}(je.metaKey||je.ctrlKey)&&!je.altKey||je.key!=="Enter"||je.shiftKey||(je.preventDefault(),U())},pt(Ue,Xe),he(je=>{var mt=w(),Et=x()?"checkbox":"radio",Bt=w(),Qe=_(),Be=W();return mt!==je.e&&me(ye,"data-picked",je.e=mt),Et!==je.t&&me(ye,"role",je.t=Et),Bt!==je.a&&me(ye,"aria-checked",je.a=Bt),Qe!==je.o&&me(Xe,"placeholder",je.o=Qe),Be!==je.i&&(Xe.disabled=je.i=Be),je},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),he(()=>Xe.value=b()),ye}}),null),he(ye=>{var Re=l.minimized||V()?"true":void 0,Je=$()>.1,Xe=`${Math.max(0,l.optionsHeight*(1-$()))}px`,je=`${Math.max(0,Math.min(1,1-$()))}`,mt=V()?"hidden":"visible";return Re!==ye.e&&me(pe,"aria-hidden",ye.e=Re),Je!==ye.t&&pe.classList.toggle("pointer-events-none",ye.t=Je),Xe!==ye.a&&Ct(pe,"max-height",ye.a=Xe),je!==ye.o&&Ct(pe,"opacity",ye.o=je),mt!==ye.i&&Ct(pe,"visibility",ye.i=mt),ye},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),pe})()]}})),re})()};dn(["click","mousedown","keydown","input"]);var EXe=A('<span class="min-w-0 flex-1 truncate text-13-regular text-text-base cursor-default">'),IXe=A('<div class="pl-3 pr-2 py-2 flex items-center gap-2"role=button tabindex=0><span class="shrink-0 text-13-medium text-text-strong cursor-default"></span><div class="ml-auto shrink-0">'),DXe=A("<div class=h-5 aria-hidden=true>"),LXe=A('<div class="px-3 pb-7 flex flex-col gap-1.5 max-h-42 overflow-y-auto no-scrollbar">'),AXe=A('<div class="flex items-center gap-2 min-w-0 py-1"><span class="min-w-0 flex-1 truncate text-13-regular text-text-strong">');function MXe(e){const t=wt(),[n,r]=Ze({collapsed:!1}),i=()=>r("collapsed",l=>!l),s=I(()=>e.items.length),o=I(()=>t.t(s()===1?"session.followupDock.summary.one":"session.followupDock.summary.other",{count:s()})),a=I(()=>e.items[0]?.text??"");return h(yy,{"data-component":"session-followup-dock",style:{"margin-bottom":"-0.875rem","border-bottom-left-radius":0,"border-bottom-right-radius":0},get children(){return[(()=>{var l=IXe(),c=l.firstChild,u=c.nextSibling;return l.$$keydown=d=>{d.key!=="Enter"&&d.key!==" "||(d.preventDefault(),i())},l.$$click=i,S(c,o),S(l,h(q,{get when(){return we(()=>!!n.collapsed)()&&a()},get children(){var d=EXe();return S(d,a),d}}),u),S(u,h(Ln,{get"data-collapsed"(){return n.collapsed?"true":"false"},icon:"chevron-down",size:"normal",variant:"ghost",get style(){return{transform:`rotate(${n.collapsed?180:0}deg)`}},onMouseDown:d=>{d.preventDefault(),d.stopPropagation()},onClick:d=>{d.stopPropagation(),i()},get"aria-label"(){return we(()=>!!n.collapsed)()?t.t("session.followupDock.expand"):t.t("session.followupDock.collapse")}})),l})(),h(q,{get when(){return n.collapsed},get children(){return DXe()}}),h(q,{get when(){return!n.collapsed},get children(){var l=LXe();return S(l,h(Dt,{get each(){return e.items},children:c=>(()=>{var u=AXe(),d=u.firstChild;return S(d,()=>c.text),S(u,h(Kt,{size:"small",variant:"secondary",class:"shrink-0",get disabled(){return!!e.sending},onClick:()=>e.onSend(c.id),get children(){return t.t("session.followupDock.sendNow")}}),null),S(u,h(Kt,{size:"small",variant:"ghost",class:"shrink-0",get disabled(){return!!e.sending},onClick:()=>e.onEdit(c.id),get children(){return t.t("session.followupDock.edit")}}),null),u})()})),l}})]}})}dn(["click","keydown"]);var $Xe=A('<span class="min-w-0 flex-1 truncate cursor-default text-[13px] font-[440] leading-5 tracking-[-0.04px] text-v2-text-text-faint">'),ZF=A("<div class=h-[18px] aria-hidden=true>"),PXe=A('<div class="flex max-h-42 flex-col gap-2 overflow-y-auto px-4 pt-px pb-3 no-scrollbar">'),OXe=A('<div data-component=session-revert-dock class="w-full overflow-hidden rounded-xl border-[0.5px] border-v2-border-border-base bg-v2-background-bg-layer-01"><div class="flex h-[42px] items-center gap-2 pl-4 pr-2"role=button tabindex=0><span></span><div class="ml-auto shrink-0">'),RXe=A('<span class="min-w-0 flex-1 truncate text-14-regular text-text-base cursor-default">'),FXe=A('<div class="pl-3 pr-2 py-2 flex items-center gap-2"role=button tabindex=0><span class="shrink-0 text-14-regular text-text-strong cursor-default"></span><div class="ml-auto shrink-0">'),NXe=A("<div class=h-5 aria-hidden=true>"),VXe=A('<div class="px-3 pb-7 flex flex-col gap-1.5 max-h-42 overflow-y-auto no-scrollbar">'),zXe=A('<div class="flex items-center gap-2 min-w-0 py-1"><span class="min-w-0 flex-1 truncate text-13-regular text-text-strong">'),HXe=A('<div class="flex h-6 min-w-0 items-center gap-2"><span class="min-w-0 flex-1 truncate text-[13px] font-[400] leading-5 tracking-[-0.04px] text-v2-text-text-muted">');function YF(e){const t=wt(),n=ar(),[r,i]=Ze({collapsed:!0});ae(()=>{e.items.length,e.items[0]?.id,i("collapsed",!0)});const s=()=>i("collapsed",u=>!u),o=I(()=>e.items.length),a=I(()=>t.t(o()===1?"session.revertDock.summary.one":"session.revertDock.summary.other",{count:o()})),l=I(()=>e.items[0]?.text??""),c=u=>{u.key!=="Enter"&&u.key!==" "||(u.preventDefault(),s())};return h(q,{get when(){return n.general.newLayoutDesigns()},get fallback(){return h(yy,{"data-component":"session-revert-dock",get children(){return[(()=>{var u=FXe(),d=u.firstChild,f=d.nextSibling;return u.$$keydown=c,u.$$click=s,S(d,a),S(u,h(q,{get when(){return we(()=>!!r.collapsed)()&&l()},get children(){var m=RXe();return S(m,l),m}}),f),S(f,h(Ln,{icon:"chevron-down",size:"normal",variant:"ghost",get style(){return{transform:`rotate(${r.collapsed?180:0}deg)`}},onMouseDown:m=>{m.preventDefault(),m.stopPropagation()},onClick:m=>{m.stopPropagation(),s()},get"aria-label"(){return we(()=>!!r.collapsed)()?t.t("session.revertDock.expand"):t.t("session.revertDock.collapse")}})),u})(),h(q,{get when(){return r.collapsed},get children(){return NXe()}}),h(q,{get when(){return!r.collapsed},get children(){var u=VXe();return S(u,h(Dt,{get each(){return e.items},children:d=>(()=>{var f=zXe(),m=f.firstChild;return S(m,()=>d.text),S(f,h(Kt,{size:"small",variant:"secondary",class:"shrink-0",get disabled(){return e.disabled||!!e.restoring},onClick:()=>e.onRestore(d.id),get children(){return t.t("session.revertDock.restore")}}),null),f})()})),u}})]}})},get children(){var u=OXe(),d=u.firstChild,f=d.firstChild,m=f.nextSibling;return d.$$keydown=c,d.$$click=s,S(d,h(on,{name:"outline-reset",size:"normal",class:"text-v2-icon-icon-muted"}),f),S(f,a),S(d,h(q,{get when(){return we(()=>!!r.collapsed)()&&l()},get children(){var g=$Xe();return S(g,l),g}}),m),S(m,h(Lr,{get icon(){return h(on,{name:"outline-chevron-down",size:"small"})},size:"large",variant:"ghost-muted",get style(){return{transform:`rotate(${r.collapsed?180:0}deg)`}},onMouseDown:g=>{g.preventDefault(),g.stopPropagation()},onClick:g=>{g.stopPropagation(),s()},get"aria-label"(){return we(()=>!!r.collapsed)()?t.t("session.revertDock.expand"):t.t("session.revertDock.collapse")}})),S(u,h(q,{get when(){return r.collapsed},get children(){return ZF()}}),null),S(u,h(q,{get when(){return!r.collapsed},get children(){return[(()=>{var g=PXe();return S(g,h(Dt,{get each(){return e.items},children:p=>(()=>{var y=HXe(),v=y.firstChild;return S(v,()=>p.text),S(y,h(as,{size:"small",variant:"neutral",class:"shrink-0",get disabled(){return e.disabled||!!e.restoring},onClick:()=>e.onRestore(p.id),get children(){return t.t("session.revertDock.restore")}}),null),y})()})),g})(),ZF()]}}),null),he(g=>ct(f,{"font-[440] shrink-0 cursor-default text-[13px] leading-5 tracking-[-0.04px]":!0,"text-v2-text-text-base":!r.collapsed,"text-v2-text-text-muted":r.collapsed},g)),u}})}dn(["click","keydown"]);var jXe=A('<span data-slot=animated-number-digit><span data-slot=animated-number-strip style="--animated-number-duration:var(--tool-motion-odometer-ms, 600ms)">'),qXe=A("<span data-slot=animated-number-cell>"),BXe=A("<span data-component=animated-number><span data-slot=animated-number-value>");const UXe=Array.from({length:30},(e,t)=>t%10);function WXe(e){return(e%10+10)%10}function KXe(e,t,n){return e===t?0:n>0?(t-e+10)%10:-((e-t+10)%10)}function GXe(e){const[t,n]=Ze({step:e.value+10,animating:!1}),r=()=>t.step,i=()=>t.animating;let s=e.value;return ae(vt(()=>e.value,o=>{const a=KXe(s,o,e.direction);if(s=o,!a){n("animating",!1),n("step",o+10);return}n("animating",!0),n("step",l=>l+a)},{defer:!0})),(()=>{var o=jXe(),a=o.firstChild;return a.addEventListener("transitionend",()=>{n("animating",!1),n("step",l=>WXe(l)+10)}),S(a,h(Dt,{each:UXe,children:l=>(()=>{var c=qXe();return S(c,l),c})()})),he(l=>{var c=i()?"true":"false",u=`${r()}`;return c!==l.e&&me(a,"data-animating",l.e=c),u!==l.t&&Ct(a,"--animated-number-offset",l.t=u),l},{e:void 0,t:void 0}),o})()}function PC(e){const t=I(()=>Number.isFinite(e.value)?Math.max(0,Math.round(e.value)):0),[n,r]=Ze({value:t(),direction:1}),i=()=>n.value,s=()=>n.direction;ae(vt(t,c=>{const u=i();c!==u&&(r("direction",c>u?1:-1),r("value",c))},{defer:!0}));const o=I(()=>i().toString()),a=I(()=>Array.from(o(),c=>{const u=c.charCodeAt(0)-48;return u<0||u>9?0:u}).reverse()),l=I(()=>`${a().length}ch`);return(()=>{var c=BXe(),u=c.firstChild;return S(u,h(nh,{get each(){return a()},children:d=>h(GXe,{get value(){return d()},get direction(){return s()}})})),he(d=>{var f=e.class,m=o(),g=l();return f!==d.e&&xr(c,d.e=f),m!==d.t&&me(c,"aria-label",d.t=m),g!==d.a&&Ct(u,"--animated-number-width",d.a=g),d},{e:void 0,t:void 0,a:void 0}),c})()}var ZXe={};ds(ZXe,{Checkbox:()=>zu,Control:()=>Sne,Description:()=>Cne,ErrorMessage:()=>_ne,Indicator:()=>Tne,Input:()=>Ene,Label:()=>Ine,Root:()=>Dne,useCheckboxContext:()=>Eh});var kne=bn();function Eh(){const e=hn(kne);if(e===void 0)throw new Error("[kobalte]: `useCheckboxContext` must be used within a `Checkbox` component");return e}function Sne(e){const t=ma(),n=Eh(),r=Mt({id:n.generateId("control")},e),[i,s]=Ee(r,["onClick","onKeyDown"]);return h(Xt,le({as:"div",onClick:l=>{Nt(l,i.onClick),n.toggle(),n.inputRef()?.focus()},onKeyDown:l=>{Nt(l,i.onKeyDown),l.key===Kx.Space&&(n.toggle(),n.inputRef()?.focus())}},()=>t.dataset(),()=>n.dataset(),s))}function Cne(e){const t=Eh();return h(Od,le(()=>t.dataset(),e))}function _ne(e){const t=Eh();return h(Rd,le(()=>t.dataset(),e))}function Tne(e){const t=ma(),n=Eh(),[r,i]=De(),s=Mt({id:n.generateId("indicator")},e),[o,a]=Ee(s,["ref","forceMount"]),{present:l}=Va({show:()=>o.forceMount||n.indeterminate()||n.checked(),element:()=>r()??null});return h(q,{get when(){return l()},get children(){return h(Xt,le({as:"div",ref(c){var u=Cn(i,o.ref);typeof u=="function"&&u(c)}},()=>t.dataset(),()=>n.dataset(),a))}})}function Ene(e){let t;const n=ma(),r=Eh(),i=Mt({id:r.generateId("input")},e),[s,o,a]=Ee(i,["ref","style","onChange","onFocus","onBlur"],jE),{fieldProps:l}=qE(o),[c,u]=De(!1),d=g=>{if(Nt(g,s.onChange),g.stopPropagation(),!c()){const p=g.target;r.setIsChecked(p.checked),p.checked=r.checked()}u(!1)},f=g=>{Nt(g,s.onFocus),r.setIsFocused(!0)},m=g=>{Nt(g,s.onBlur),r.setIsFocused(!1)};return ae(vt([()=>r.checked(),()=>r.value()],()=>{u(!0),t?.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!0})),t?.dispatchEvent(new Event("change",{bubbles:!0,cancelable:!0}))},{defer:!0})),ae(vt([()=>t,()=>r.indeterminate(),()=>r.checked()],([g,p])=>{g&&(g.indeterminate=p)})),h(Xt,le({as:"input",ref(g){var p=Cn(y=>{r.setInputRef(y),t=y},s.ref);typeof p=="function"&&p(g)},type:"checkbox",get id(){return l.id()},get name(){return n.name()},get value(){return r.value()},get checked(){return r.checked()},get required(){return n.isRequired()},get disabled(){return n.isDisabled()},get readonly(){return n.isReadOnly()},get style(){return cs(Gx,s.style)},get"aria-label"(){return l.ariaLabel()},get"aria-labelledby"(){return l.ariaLabelledBy()},get"aria-describedby"(){return l.ariaDescribedBy()},get"aria-invalid"(){return n.validationState()==="invalid"||void 0},get"aria-required"(){return n.isRequired()},get"aria-disabled"(){return n.isDisabled()},get"aria-readonly"(){return n.isReadOnly()},onChange:d,onFocus:f,onBlur:m},()=>n.dataset(),()=>r.dataset(),a))}function Ine(e){const t=Eh();return h(cy,le(()=>t.dataset(),e))}function Dne(e){let t;const n=`checkbox-${nr()}`,r=Mt({value:"on",id:n},e),[i,s,o]=Ee(r,["ref","children","value","checked","defaultChecked","indeterminate","onChange","onPointerDown"],jk),[a,l]=De(),[c,u]=De(!1),{formControlContext:d}=qk(s),f=HZ({isSelected:()=>i.checked,defaultIsSelected:()=>i.defaultChecked,onSelectedChange:y=>i.onChange?.(y),isDisabled:()=>d.isDisabled(),isReadOnly:()=>d.isReadOnly()});uy(()=>t,()=>f.setIsSelected(i.defaultChecked??!1));const m=y=>{Nt(y,i.onPointerDown),c()&&y.preventDefault()},g=I(()=>({"data-checked":f.isSelected()?"":void 0,"data-indeterminate":i.indeterminate?"":void 0})),p={value:()=>i.value,dataset:g,checked:()=>f.isSelected(),indeterminate:()=>i.indeterminate??!1,inputRef:a,generateId:us(()=>We(s.id)),toggle:()=>f.toggle(),setIsChecked:y=>f.setIsSelected(y),setIsFocused:u,setInputRef:l};return h(ly.Provider,{value:d,get children(){return h(kne.Provider,{value:p,get children(){return h(Xt,le({as:"div",ref(y){var v=Cn(b=>t=b,i.ref);typeof v=="function"&&v(y)},role:"group",get id(){return We(s.id)},onPointerDown:m},()=>d.dataset(),g,o,{get children(){return h(YXe,{state:p,get children(){return i.children}})}}))}})}})}function YXe(e){const t=Jl(()=>{const n=e.children;return w1(n)?n(e.state):n});return we(t)}var zu=Object.assign(Dne,{Control:Sne,Description:Cne,ErrorMessage:_ne,Indicator:Tne,Input:Ene,Label:Ine}),XXe=A("<div data-slot=checkbox-checkbox-content>"),QXe=A('<svg viewBox="0 0 12 12"fill=none width=10 height=10 xmlns=http://www.w3.org/2000/svg><path d="M3 7.17905L5.02703 8.85135L9 3.5"stroke=currentColor stroke-width=1.5 stroke-linecap=square>');function Lne(e){const[t,n]=Ee(e,["children","class","label","hideLabel","description","icon"]);return h(zu,le(n,{"data-component":"checkbox",get children(){return[h(zu.Input,{"data-slot":"checkbox-checkbox-input"}),h(zu.Control,{"data-slot":"checkbox-checkbox-control",get children(){return h(zu.Indicator,{"data-slot":"checkbox-checkbox-indicator",get children(){return t.icon||QXe()}})}}),(()=>{var r=XXe();return S(r,h(q,{get when(){return e.children},get children(){return h(zu.Label,{"data-slot":"checkbox-checkbox-label",get classList(){return{"sr-only":t.hideLabel}},get children(){return e.children}})}}),null),S(r,h(q,{get when(){return t.description},get children(){return h(zu.Description,{"data-slot":"checkbox-checkbox-description",get children(){return t.description}})}}),null),S(r,h(zu.ErrorMessage,{"data-slot":"checkbox-checkbox-error"}),null),r})()]}}))}var JXe=A("<span data-component=text-reveal><span data-slot=text-reveal-track><span data-slot=text-reveal-entering></span><span data-slot=text-reveal-leaving>");const eQe=(e,t)=>typeof e=="number"?`${e}px`:typeof e=="string"?e:`${t}px`,tQe=(e,t)=>typeof e=="number"?`${e}ms`:typeof e=="string"?e:`${t}ms`,nQe=(e,t)=>`${e??t}%`;function Ane(e){const[t,n]=Ze({cur:e.text,old:void 0,width:"auto",ready:!1,swapping:!1}),r=()=>t.cur,i=()=>t.old,s=()=>t.width,o=()=>t.ready,a=()=>t.swapping;let l,c,u,d;const f=()=>l?.scrollWidth??0,m=()=>c?.scrollWidth??0,g=p=>{if(!(p<=0)){if(e.growOnly??!0){const y=Number.parseFloat(s());if(Number.isFinite(y)&&p<=y)return}n("width",`${p}px`)}};return ae(vt(()=>e.text,(p,y)=>{if(p!==y){if(typeof p=="string"&&typeof y=="string"&&p.startsWith(y)){n("cur",p),g(f());return}if(n("swapping",!0),n("old",y),n("cur",p),typeof requestAnimationFrame!="function"){g(Math.max(f(),m())),u?.offsetHeight,n("swapping",!1);return}d!==void 0&&typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(d),d=requestAnimationFrame(()=>{g(Math.max(f(),m())),u?.offsetHeight,n("swapping",!1),d=void 0})}})),sn(()=>{g(f());const p=typeof document<"u"?document.fonts:void 0;if(typeof requestAnimationFrame!="function"){n("ready",!0);return}if(!p){requestAnimationFrame(()=>n("ready",!0));return}p.ready.finally(()=>{g(f()),requestAnimationFrame(()=>n("ready",!0))})}),Te(()=>{d===void 0||typeof cancelAnimationFrame!="function"||cancelAnimationFrame(d)}),(()=>{var p=JXe(),y=p.firstChild,v=y.firstChild,b=v.nextSibling,w=u;typeof w=="function"?pt(w,p):u=p;var x=l;typeof x=="function"?pt(x,v):l=v,S(v,()=>r()??" ");var k=c;return typeof k=="function"?pt(k,b):c=b,S(b,()=>i()??" "),he(C=>{var E=o()?"true":"false",_=a()?"true":"false",L=e.truncate?"true":"false",O=e.class,$=e.text??"",V=tQe(e.duration,450),P=nQe(e.edge,17),T=eQe(e.travel,0),D=e.spring??"cubic-bezier(0.34, 1.08, 0.64, 1)",N=e.springSoft??"cubic-bezier(0.34, 1, 0.64, 1)",M=e.truncate?"100%":s();return E!==C.e&&me(p,"data-ready",C.e=E),_!==C.t&&me(p,"data-swapping",C.t=_),L!==C.a&&me(p,"data-truncate",C.a=L),O!==C.o&&xr(p,C.o=O),$!==C.i&&me(p,"aria-label",C.i=$),V!==C.n&&Ct(p,"--text-reveal-duration",C.n=V),P!==C.s&&Ct(p,"--text-reveal-edge",C.s=P),T!==C.h&&Ct(p,"--text-reveal-travel",C.h=T),D!==C.r&&Ct(p,"--text-reveal-spring",C.r=D),N!==C.d&&Ct(p,"--text-reveal-spring-soft",C.d=N),M!==C.l&&Ct(y,"width",C.l=M),C},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0,l:void 0}),p})()}var rQe=A('<span data-component=text-strikethrough style=display:grid><span style="grid-area:1 / 1"></span><span aria-hidden=true style="grid-area:1 / 1;text-decoration:line-through;pointer-events:none">');function iQe(e){const t=vy(()=>e.active?1:0,()=>({visualDuration:e.visualDuration??.35,bounce:0}));let n,r;const[i,s]=Ze({textWidth:0,containerWidth:0}),o=()=>i.textWidth,a=()=>i.containerWidth,l=()=>{n&&s("textWidth",n.scrollWidth),r&&s("containerWidth",r.offsetWidth)};sn(l),k4(()=>r,l);const c=()=>{const f=o();return f>0?t()*f:0},u=()=>{const f=a(),m=o();return f<=0||m<=0?`inset(0 ${(1-t())*100}% 0 0)`:`inset(0 ${Math.max(0,f-c())}px 0 0)`},d=()=>{const f=c();return f<=.5?"none":`inset(0 0 0 ${f}px)`};return(()=>{var f=rQe(),m=f.firstChild,g=m.nextSibling,p=r;typeof p=="function"?pt(p,f):r=f;var y=n;return typeof y=="function"?pt(y,m):n=m,S(m,()=>e.text),S(g,()=>e.text),he(v=>{var b=e.class,w={...e.style},x=d(),k=u();return b!==v.e&&xr(f,v.e=b),v.t=So(f,w,v.t),x!==v.a&&Ct(m,"clip-path",v.a=x),k!==v.o&&Ct(g,"clip-path",v.o=k),v},{e:void 0,t:void 0,a:void 0,o:void 0}),f})()}var sQe=A('<svg viewBox="0 0 12 12"width=12 height=12 fill=currentColor xmlns=http://www.w3.org/2000/svg class=block><circle cx=6 cy=6 r=3 style=animation:var(--animate-pulse-scale);transform-origin:center;transform-box:fill-box>'),oQe=A('<div><div data-action=session-todo-toggle role=button tabindex=0><span style=--tool-motion-odometer-ms:600ms;--tool-motion-mask:18%;--tool-motion-mask-height:0px;--tool-motion-spring-ms:560ms;white-space:pre></span><div data-slot=session-todo-preview class="ml-1 min-w-0 overflow-hidden"style="flex:1 1 auto;max-width:100%"></div><div class=ml-auto></div></div><div data-slot=session-todo-list>'),aQe=A("<span>"),lQe=A('<div class=relative><div class="px-3 pb-11 flex flex-col gap-1.5 max-h-42 overflow-y-auto no-scrollbar"style=overflow-anchor:none></div><div class="pointer-events-none absolute top-0 left-0 right-0 h-4 transition-opacity duration-150"style="background:linear-gradient(to bottom, var(--background-base), transparent)">');const XF="\0done\0",QF="\0total\0";function cQe(e){if(e==="in_progress")return(()=>{var t=sQe();return t.firstChild,t})()}function uQe(e){const t=wt(),n=ar(),[r,i]=Ze({height:78}),s=I(()=>e.todos.length),o=I(()=>e.todos.filter(x=>x.status==="completed").length),a=I(()=>t.t("session.todo.progress",{done:o(),total:s()})),l=I(()=>t.t("session.todo.progress",{done:XF,total:QF}).split(/(\u0000done\u0000|\u0000total\u0000)/)),c=I(()=>e.todos.find(x=>x.status==="in_progress")??e.todos.find(x=>x.status==="pending")??e.todos.filter(x=>x.status==="completed").at(-1)??e.todos[0]),u=I(()=>c()?.content??""),d=vy(()=>e.collapsed?1:0,{visualDuration:.3,bounce:0}),f=I(()=>Math.max(0,Math.min(1,e.dockProgress))),m=I(()=>1-f()),g=I(()=>Math.max(0,Math.min(1,d()))),p=I(()=>Math.max(g(),m())),y=I(()=>p()>.98),v=I(()=>Math.max(0,Math.min(1,g()))),b=I(()=>Math.max(78,r.height));let w;return ae(()=>{const x=w;if(!x)return;const k=()=>{i("height",C=>Math.max(C,x.scrollHeight))};k(),Oa(x,k)}),h(Gi,{get component(){return n.general.newLayoutDesigns()?"div":yy},"data-component":"session-todo-dock",get classList(){return{"w-full overflow-hidden rounded-xl border-[0.5px] border-v2-border-border-base bg-v2-background-bg-layer-01":n.general.newLayoutDesigns()}},get style(){return{"overflow-x":"visible","overflow-y":"hidden","max-height":`${Math.max(78,b()-g()*(b()-78))}px`}},get children(){var x=oQe(),k=x.firstChild,C=k.firstChild,E=C.nextSibling,_=E.nextSibling,L=k.nextSibling,O=w;return typeof O=="function"?pt(O,x):w=x,k.$$keydown=$=>{$.key!=="Enter"&&$.key!==" "||($.preventDefault(),e.onToggle())},cn(k,"click",e.onToggle,!0),S(C,h(nh,{get each(){return l()},children:$=>$()===XF?h(PC,{get value(){return o()}}):$()===QF?h(PC,{get value(){return s()}}):(()=>{var V=aQe();return S(V,$),V})()})),S(E,h(Ane,{get class(){return n.general.newLayoutDesigns()?"cursor-default text-[13px] font-[440] leading-5 tracking-[-0.04px] text-v2-text-text-faint":"text-14-regular text-text-base cursor-default"},get text(){return we(()=>!!e.collapsed)()?u():void 0},duration:600,travel:25,edge:17,spring:"cubic-bezier(0.34, 1, 0.64, 1)",springSoft:"cubic-bezier(0.34, 1, 0.64, 1)",growOnly:!0,truncate:!0})),S(_,h(Ln,{"data-action":"session-todo-toggle-button",get"data-collapsed"(){return e.collapsed?"true":"false"},icon:"chevron-down",size:"normal",variant:"ghost",get style(){return{transform:`rotate(${v()*180}deg)`}},onMouseDown:$=>{$.preventDefault(),$.stopPropagation()},onClick:$=>{$.stopPropagation(),e.onToggle()},get"aria-label"(){return we(()=>!!e.collapsed)()?e.expandLabel:e.collapseLabel}})),S(L,h(dQe,{get todos(){return e.todos}})),he($=>{var V={"flex items-center gap-2 overflow-visible":!0,"h-[42px] pl-4 pr-2":n.general.newLayoutDesigns(),"pl-3 pr-2 py-2":!n.general.newLayoutDesigns()},P={"cursor-default inline-flex items-baseline shrink-0 overflow-visible":!0,"font-[440] text-[13px] leading-5 tracking-[-0.04px] text-v2-text-text-muted":n.general.newLayoutDesigns(),"text-14-regular text-text-strong":!n.general.newLayoutDesigns()},T=a(),D=`${Math.max(0,Math.min(1,1-m()))}`,N=e.collapsed||y(),M=p()>.1,F=y()?"hidden":"visible",j=`${Math.max(0,Math.min(1,1-p()))}`;return $.e=ct(k,V,$.e),$.t=ct(C,P,$.t),T!==$.a&&me(C,"aria-label",$.a=T),D!==$.o&&Ct(C,"opacity",$.o=D),N!==$.i&&me(L,"aria-hidden",$.i=N),M!==$.n&&L.classList.toggle("pointer-events-none",$.n=M),F!==$.s&&Ct(L,"visibility",$.s=F),j!==$.h&&Ct(L,"opacity",$.h=j),$},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0}),x}})}function dQe(e){const[t,n]=Ze({stuck:!1});return(()=>{var r=lQe(),i=r.firstChild,s=i.nextSibling;return i.addEventListener("scroll",o=>{n("stuck",o.currentTarget.scrollTop>0)}),S(i,h(nh,{get each(){return e.todos},children:o=>h(Lne,{readOnly:!0,get checked(){return o().status==="completed"},get indeterminate(){return o().status==="in_progress"},get"data-in-progress"(){return o().status==="in_progress"?"":void 0},get"data-state"(){return o().status},get icon(){return cQe(o().status)},get style(){return{"--checkbox-align":"flex-start","--checkbox-offset":"1px",transition:"opacity 220ms var(--tool-motion-ease, cubic-bezier(0.22, 1, 0.36, 1))",opacity:o().status==="pending"?"0.94":"1"}},get children(){return h(iQe,{get active(){return o().status==="completed"||o().status==="cancelled"},get text(){return o().content},class:"text-14-regular min-w-0 break-words",get style(){return{"line-height":"var(--line-height-normal)",transition:"color 220ms var(--tool-motion-ease, cubic-bezier(0.22, 1, 0.36, 1)), opacity 220ms var(--tool-motion-ease, cubic-bezier(0.22, 1, 0.36, 1))",color:o().status==="completed"||o().status==="cancelled"?"var(--text-weak)":"var(--text-strong)",opacity:o().status==="pending"?"0.92":"1"}}})}})})),he(o=>Ct(s,"opacity",t.stuck?1:0)),r})()}dn(["click","keydown"]);var fQe=A("<div class=overflow-hidden><div>"),hQe=A('<button type=button class="text-text-base transition-colors hover:text-text-strong">'),mQe=A('<div class="w-full rounded-[12px] border border-border-weak-base bg-background-base p-3 text-16-regular text-text-weak"><span> '),t2=A("<div>"),gQe=A("<div data-component=session-prompt-dock><div>"),pQe=A('<div class="w-full min-h-32 md:min-h-40 rounded-md border border-border-weak-base bg-background-base/50 px-4 py-3 text-text-weak whitespace-pre-wrap pointer-events-none">'),vQe=A("<div class=pb-2>");function yQe(e){const t=wt(),n=e.controller,r=ar(),i=()=>{const s=n.revert();return s?.items.length?s:void 0};return(()=>{var s=gQe(),o=s.firstChild,a=n.setDockRef;return typeof a=="function"?pt(a,s):n.setDockRef=s,S(o,h(q,{get when(){return n.state.questionRequest()},keyed:!0,children:l=>(()=>{var c=t2();return S(c,h(TXe,{request:l,get onSubmit(){return n.onResponseSubmit}})),c})()}),null),S(o,h(q,{get when(){return n.state.permissionRequest()},keyed:!0,children:l=>(()=>{var c=t2();return S(c,h(uXe,{request:l,get responding(){return n.state.permissionResponding()},onDecide:u=>{n.onResponseSubmit(),n.state.decide(u)}})),c})()}),null),S(o,h(q,{get when(){return n.showComposer()},get children(){return[h(q,{get when(){return n.dock()},get children(){var l=fQe(),c=l.firstChild,u=n.setDockBodyRef;return typeof u=="function"?pt(u,c):n.setDockBodyRef=c,S(c,h(uQe,{get todos(){return n.state.todos()},get collapsed(){return n.todo.collapsed()},get onToggle(){return n.todo.onToggle},get collapseLabel(){return t.t("session.todo.collapse")},get expandLabel(){return t.t("session.todo.expand")},get dockProgress(){return n.dockProgress()}})),he(d=>{var f=n.dockProgress()<.98,m=`${n.dockHeight()*n.dockProgress()}px`;return f!==d.e&&l.classList.toggle("pointer-events-none",d.e=f),m!==d.t&&Ct(l,"max-height",d.t=m),d},{e:void 0,t:void 0}),l}}),h(q,{get when(){return n.promptReady()},get fallback(){return[h(q,{get when(){return i()},keyed:!0,children:l=>(()=>{var c=vQe();return S(c,h(YF,{get items(){return l.items},get restoring(){return l.restoring},get disabled(){return l.disabled},get onRestore(){return l.onRestore}})),c})()}),(()=>{var l=pQe();return S(l,()=>n.handoffPrompt()||t.t("prompt.loading")),he(c=>Ct(l,"margin-top",`${-36*n.dockProgress()}px`)),l})()]},get children(){return[h(q,{get when(){return i()},keyed:!0,children:l=>(()=>{var c=t2();return S(c,h(YF,{get items(){return l.items},get restoring(){return l.restoring},get disabled(){return l.disabled},get onRestore(){return l.onRestore}})),he(u=>Ct(c,"margin-top",`${-36*n.dockProgress()}px`)),c})()}),(()=>{var l=t2();return ct(l,{"relative z-[70]":!0}),S(l,h(q,{get when(){return n.followup()?.items.length},get children(){return h(MXe,{get items(){return n.followup().items},get sending(){return n.followup().sending},get onSend(){return n.followup().onSend},get onEdit(){return n.followup().onEdit}})}}),null),S(l,h(q,{get when(){return n.child()},get fallback(){return h(q,{get when(){return!n.state.blocked()},get children(){return e.promptInput}})},get children(){var c=mQe(),u=c.firstChild,d=u.firstChild,f=n.setPromptRef;return typeof f=="function"?pt(f,c):n.setPromptRef=c,S(u,()=>t.t("session.child.promptDisabled"),d),S(c,h(q,{get when(){return n.parentID()},get children(){var m=hQe();return cn(m,"click",n.openParent,!0),S(m,()=>t.t("session.child.backToParent")),m}}),null),c}}),null),he(c=>Ct(l,"margin-top",`${-n.lift()}px`)),l})()]}})]}}),null),he(l=>{var c={"w-full shrink-0 flex flex-col justify-center items-center pb-3 pointer-events-none":!0,"bg-v2-background-bg-base":r.general.newLayoutDesigns(),"bg-background-stronger":!r.general.newLayoutDesigns()},u={"w-full px-3 pointer-events-auto":!0,"md:max-w-200 md:mx-auto 2xl:max-w-[1000px]":n.centered()};return l.e=ct(s,c,l.e),l.t=ct(o,u,l.t),l},{e:void 0,t:void 0}),s})()}dn(["click"]);function bQe(e){const t=li(),n=El(),r=kr(),i=Ji(),s=$d(()=>r().directory),o=t.view(e.sessionKey),a=zp(()=>e.queryOptions.agents(rt(r().directory))),l=zp(()=>e.queryOptions.providers(null)),c=zp(()=>e.queryOptions.providers(rt(r().directory)));return I(()=>({agents:{available:i().data.agent,options:n.agent.list().map(u=>u.name),current:n.agent.current()?.name??"",loading:a.isLoading,visible:n.agent.visible(),select:n.agent.set},model:{selection:e.model??n.model,paid:s.paid().length>0,loading:n.agent.visible()&&a.isLoading||c.isLoading||l.isLoading},session:{id:e.sessionID(),tabs:t.tabs(e.sessionKey),reviewPanel:o.reviewPanel}}))}function Jut(){const e=fs(),t=li(),n=ci(),r=xs(),i=kr(),s=ks(),o=ms(),a=Bk(),[l]=Id(),c=()=>r().server,u=I(()=>o.ensureServerCtx(c())),d=I(()=>n.list.length<=1?l.draftId?u().projects.list():t.projects.list():n.list.flatMap(g=>{const p={key:ut.key(g),name:hd(g)};return o.ensureServerCtx(g).projects.list().map(y=>({...y,server:p}))})),f=(g,p)=>{const y=p?n.list.find(b=>ut.key(b)===p):c();if(l.draftId){if(!y)return;const b=o.ensureServerCtx(y);b.projects.open(g),b.projects.touch(g),s.updateDraft(l.draftId,{server:ut.key(y),directory:g});return}if(!p){t.projects.open(g),n.projects.touch(g),e(`/${yn(g)}/session`);return}if(!y)return;const v=o.ensureServerCtx(y);v.projects.open(g),v.projects.touch(g),n.setActive(ut.key(y)),e(`/${yn(g)}/session`)},m=(g,p)=>{const y=p?n.list.find(v=>ut.key(v)===p):c();y&&a({server:y,title:g,onSelect:v=>{const b=Array.isArray(v)?v[0]:v;b&&f(b,p)}})};return I(()=>({available:d(),directory:i().directory,server:n.list.length>1?ut.key(c()):void 0,select:f,add:m}))}const JF=e=>e.count===0?"hide":e.live?e.done?"close":"open":"clear",eN=e=>e==="open";function wQe(e){const t=Br(),n=kr(),r=Ji(),i=Di(),s=wt(),o=mu(),a=I(()=>WQ(r().data.session,r().data.question,t.id)),l=I(()=>zE(r().data.session,r().data.permission,t.id,C=>!o.autoResponds(C,n().directory))),c=I(()=>t.id?!!l()||!!a():!1),u=I(()=>{const C=t.id;return C?i().session.data.todo[C]??[]:[]}),d=I(()=>u().length>0&&u().every(C=>C.status==="completed"||C.status==="cancelled")),f=I(()=>r().data.session_working(t.id??"")||c()),[m,g]=Ze({sessionID:t.id,responding:void 0,dock:u().length>0&&!d()&&f(),closing:!1,opening:!1}),p=I(()=>{const C=l();return C?m.responding===C.id:!1}),y=C=>{const E=l();E&&m.responding!==E.id&&(g("responding",E.id),n().api.permission.reply({sessionID:E.sessionID,requestID:E.id,reply:C}).catch(_=>{const L=_ instanceof Error?_.message:String(_);tn({title:s.t("common.requestFailed"),description:L})}).finally(()=>{g("responding",_=>_===E.id?void 0:_)}))};let v,b;const w=()=>400,x=()=>{v&&window.clearTimeout(v),v=window.setTimeout(()=>{g({dock:!1,closing:!1}),v=void 0},w())},k=()=>{const C=t.id;C&&r().set("todo",C,[])};return ae(vt(()=>[t.id,u().length,d(),f()],([C,E,_,L],O)=>{b&&cancelAnimationFrame(b),b=void 0;const $=JF({count:E,done:_,live:L});if(!O||O[0]!==C){v&&window.clearTimeout(v),v=void 0,g({sessionID:C,dock:eN($),closing:!1,opening:!1}),$==="clear"&&k();return}if($==="hide"){v&&window.clearTimeout(v),v=void 0,g({dock:!1,closing:!1,opening:!1});return}if($==="clear"){v&&window.clearTimeout(v),v=void 0,k();return}if($==="open"){v&&window.clearTimeout(v),v=void 0;const V=!m.dock||m.closing;if(g({dock:!0,closing:!1}),V){g("opening",!0),b=requestAnimationFrame(()=>{g("opening",!1),b=void 0});return}g("opening",!1);return}g({dock:!0,opening:!1,closing:!0}),v||x()})),Te(()=>{v&&window.clearTimeout(v)}),Te(()=>{b&&cancelAnimationFrame(b)}),{blocked:c,questionRequest:a,permissionRequest:l,permissionResponding:p,decide:y,todos:u,dock:()=>m.sessionID===t.id?m.dock:eN(JF({count:u().length,done:d(),live:f()})),closing:()=>m.sessionID===t.id&&m.closing,opening:()=>m.sessionID===t.id&&m.opening}}function xQe(e){const t=Ji(),[n,r]=Ze({ready:e.ready()||e.state.dock(),height:320,body:void 0});let i,s;const o=()=>{i!==void 0&&window.clearTimeout(i),s!==void 0&&cancelAnimationFrame(s),i=void 0,s=void 0};ae(()=>{e.sessionKey();const m=e.ready(),g=e.state.dock();if(o(),!(n.ready||!m&&!g)){if(g){r("ready",!0);return}s=requestAnimationFrame(()=>{s=void 0,i=window.setTimeout(()=>{r("ready",!0),i=void 0},140)})}}),ae(()=>{e.prompt.ready()&&PT(e.sessionKey(),{prompt:e.prompt.current().map(m=>m.type==="file"?`[file:${m.path}]`:m.type==="agent"?`@${m.name}`:m.type==="image"?`[image:${m.filename}]`:m.content).join("").trim()})}),ae(()=>{const m=n.body;if(!m)return;const g=()=>r("height",m.getBoundingClientRect().height);Oa(m,g),g()}),Te(o);const a=I(()=>{const m=e.sessionID();return m?t().session.get(m)?.parentID:void 0}),l=I(()=>n.ready&&e.state.dock()&&!e.state.closing()),c=vy(()=>l()?1:0,{visualDuration:.3,bounce:0},()=>`${e.sessionKey()}\0${n.ready}`),u=I(()=>Math.max(0,Math.min(1,c()))),d=Promise.resolve(),[f]=ai(()=>e.prompt.ready.promise??d,m=>m.then(()=>!0));return{state:e.state,centered:e.centered,todo:e.todo,followup:e.followup,revert:e.revert,onResponseSubmit:e.onResponseSubmit,openParent:e.openParent,setPromptRef:e.setPromptRef,setDockRef:e.setDockRef,parentID:a,child:()=>!!a(),showComposer:()=>!e.state.blocked()||!!a(),handoffPrompt:()=>OT(e.sessionKey())?.prompt,promptReady:()=>e.prompt.ready()||f(),dock:()=>n.ready&&e.state.dock()||u()>.001,dockProgress:u,dockHeight:()=>Math.max(78,n.height),lift:()=>e.revert()?.items.length?18:36*u(),setDockBodyRef:m=>r("body",m)}}function kQe(e,t,n){const r=new Array(e);return new Proxy(r,{get(i,s,o){if(typeof s=="string"){const a=s.charCodeAt(0);if(a>=48&&a<=57){const l=+s;if(Number.isInteger(l)&&l>=0&&l<e){let c=i[l];if(!c){const u=t[l*2];c=i[l]={index:l,key:n(l),start:u,size:t[l*2+1],end:u+t[l*2+1],lane:0}}return c}}if(s==="length")return e}return Reflect.get(i,s,o)}})}function em(e,t,n){let r=n.initialDeps??[],i,s=!0;function o(){const a=e();return(a.length!==r.length||a.some((c,u)=>r[u]!==c))&&(r=a,i=t(...a),n?.onChange&&!(s&&n.skipInitialOnChange)&&n.onChange(i),s=!1),i}return o.updateDeps=a=>{r=a},o}function tN(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const SQe=(e,t)=>Math.abs(e-t)<1.01,CQe=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}};let j0;const n6=()=>{if(j0!==void 0)return j0;if(typeof navigator>"u")return j0=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return j0=!0;const e=navigator.maxTouchPoints;return j0=navigator.platform==="MacIntel"&&e!==void 0&&e>0},nN=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},_Qe=e=>e,r3=e=>{const t=Math.max(e.startIndex-e.overscan,0),r=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,i=new Array(r);for(let s=0;s<r;s++)i[s]=t+s;return i},TQe=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;const i=o=>{const{width:a,height:l}=o;t({width:Math.round(a),height:Math.round(l)})};if(i(nN(n)),!r.ResizeObserver)return()=>{};const s=new r.ResizeObserver(o=>{const a=()=>{const l=o[0];if(l?.borderBoxSize){const c=l.borderBoxSize[0];if(c){i({width:c.inlineSize,height:c.blockSize});return}}i(nN(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return s.observe(n,{box:"border-box"}),()=>{s.unobserve(n)}},zx={passive:!0},EQe=typeof window>"u"?!0:"onscrollend"in window,IQe=(e,t,n)=>{const r=e.scrollElement;if(!r)return;const i=e.targetWindow;if(!i)return;const s=e.options.useScrollendEvent&&EQe;let o=0;const a=s?null:CQe(i,()=>t(o,!1),e.options.isScrollingResetDelay),l=d=>()=>{o=n(r),a?.(),t(o,d)},c=l(!0),u=l(!1);return r.addEventListener("scroll",c,zx),s&&r.addEventListener("scrollend",u,zx),()=>{r.removeEventListener("scroll",c),s&&r.removeEventListener("scrollend",u)}},Mne=(e,t)=>IQe(e,t,n=>{const{horizontal:r,isRtl:i}=e.options;return r?n.scrollLeft*(i&&-1||1):n.scrollTop}),DQe=(e,t,n)=>{if(n.options.useCachedMeasurements){const r=n.indexFromElement(e),i=n.options.getItemKey(r);return n.itemSizeCache.get(i)??n.options.estimateSize(r)}if(t?.borderBoxSize){const r=t.borderBoxSize[0];if(r)return Math.round(r[n.options.horizontal?"inlineSize":"blockSize"])}if(!t){const r=n.indexFromElement(e),i=n.options.getItemKey(r),s=n.itemSizeCache.get(i);if(s!==void 0)return s}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},LQe=(e,{adjustments:t=0,behavior:n},r)=>{var i,s;(s=(i=r.scrollElement)==null?void 0:i.scrollTo)==null||s.call(i,{[r.options.horizontal?"left":"top"]:e+t,behavior:n})},$ne=LQe;class AQe{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var n,r,i;return((i=(r=(n=this.targetWindow)==null?void 0:n.performance)==null?void 0:r.now)==null?void 0:i.call(r))??Date.now()},this.observer=(()=>{let n=null;const r=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(i=>{i.forEach(s=>{const o=()=>{const a=s.target,l=this.indexFromElement(a);if(!a.isConnected){this.observer.unobserve(a);for(const[c,u]of this.elementsCache)if(u===a){this.elementsCache.delete(c);break}return}this.shouldMeasureDuringScroll(l)&&this.resizeItem(l,this.options.measureElement(a,s,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()})}));return{disconnect:()=>{var i;(i=r())==null||i.disconnect(),n=null},observe:i=>{var s;return(s=r())==null?void 0:s.observe(i,{box:"border-box"})},unobserve:i=>{var s;return(s=r())==null?void 0:s.unobserve(i)}}})(),this.range=null,this.setOptions=n=>{var r,i;const s={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:_Qe,rangeExtractor:r3,onChange:()=>{},measureElement:DQe,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const f in n){const m=n[f];m!==void 0&&(s[f]=m)}const o=this.options;let a=null,l=null,c=!1;if(o!==void 0&&o.enabled&&s.enabled&&s.anchorTo==="end"&&this.scrollElement!==null){const f=o.count,m=s.count,g=this.getMeasurements(),p=f>0?((r=g[0])==null?void 0:r.key)??o.getItemKey(0):null,y=f>0?((i=g[f-1])==null?void 0:i.key)??o.getItemKey(f-1):null;if(m!==f||f>0&&m>0&&(s.getItemKey(0)!==p||s.getItemKey(m-1)!==y)){c=!0;const w=f>0?this.getVirtualItemForOffset(this.getScrollOffset())??g[0]:null;w&&(a=[w.key,this.getScrollOffset()-w.start]);const x=s.followOnAppend===!0?"auto":s.followOnAppend||null;x&&m>f&&this.isAtEnd(o.scrollEndThreshold)&&(f===0||s.getItemKey(m-1)!==y)&&(l=x)}}this.options=s,c&&(this.pendingMin=0,this.itemSizeCacheVersion++);let u=!1,d=0;if(a&&this.scrollOffset!==null){const[f,m]=a,g=this.getMeasurements(),{count:p,getItemKey:y}=this.options;let v=0;for(;v<p&&y(v)!==f;)v++;if(v<p){const b=g[v];if(b){const w=b.start+m;w!==this.scrollOffset&&(d=w-this.scrollOffset,this.scrollOffset=w,u=!0)}}}(u||l)&&(this.pendingScrollAnchor=[u?a[0]:null,u?a[1]:0,l,d])},this.notify=n=>{var r,i;(i=(r=this.options).onChange)==null||i.call(r,this,n)},this.maybeNotify=em(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}if(this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(s=>{this.observer.observe(s)}),this.unsubs.push(this.options.observeElementRect(this,s=>{this.scrollRect=s,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(s,o)=>{if(o&&this._intendedScrollOffset===null&&s===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(s-this._intendedScrollOffset)<1.5&&(s=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;const a=this.getScrollOffset();this.scrollDirection=o?a===s?this.scrollDirection:a<s?"forward":"backward":null,this.scrollOffset=s,this.isScrolling=o,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const s=this.scrollElement,o=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},a=()=>{this._iosTouching=!1,!(!n6()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};s.addEventListener("touchstart",o,zx),s.addEventListener("touchend",a,zx),this.unsubs.push(()=>{s.removeEventListener("touchstart",o),s.removeEventListener("touchend",a),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const i=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,i&&this.scrollElement&&this.options.enabled){const[s,o,a,l]=i;s!==null&&!a&&(n6()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?l!==0&&(this._iosDeferredAdjustment+=l):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),a&&this.scrollToEnd({behavior:a})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const n=this.getScrollOffset(),r=this.getMaxScrollOffset();if(n<0||n>r)return;const i=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(n,{adjustments:this.scrollAdjustments+=i,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(n,r)=>{const i=new Map,s=new Map;for(let o=r-1;o>=0;o--){const a=n[o];if(i.has(a.lane))continue;const l=s.get(a.lane);if(l==null||a.end>l.end?s.set(a.lane,a):a.end<l.end&&i.set(a.lane,!0),i.size===this.options.lanes)break}return s.size===this.options.lanes?Array.from(s.values()).sort((o,a)=>o.end===a.end?o.index-a.index:o.end-a.end)[0]:void 0},this.getMeasurementOptions=em(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(n,r,i,s,o,a,l)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:n,paddingStart:r,scrollMargin:i,getItemKey:s,enabled:o,lanes:a,laneAssignmentMode:l}),{key:!1}),this.getMeasurements=em(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:n,paddingStart:r,scrollMargin:i,getItemKey:s,enabled:o,lanes:a,laneAssignmentMode:l},c)=>{const u=this.itemSizeCache;if(!o)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>n)for(const g of this.laneAssignments.keys())g>=n&&this.laneAssignments.delete(g);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(g=>{this.itemSizeCache.set(g.key,g.size)}));const d=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===n&&(this.lanesSettling=!1),a===1){const g=this.options.gap,p=n*2;let y=this._flatMeasurements;if(!y||y.length<p){const w=new Float64Array(p);y&&d>0&&w.set(y.subarray(0,d*2)),y=w,this._flatMeasurements=y}let v;if(d===0)v=r+i;else{const w=d-1;v=y[w*2]+y[w*2+1]+g}for(let w=d;w<n;w++){const x=s(w),k=u.get(x),C=typeof k=="number"?k:this.options.estimateSize(w);y[w*2]=v,y[w*2+1]=C,v+=C+g}const b=kQe(n,y,s);return this.measurementsCache=b,b}const f=this.measurementsCache.slice(0,d),m=new Array(a).fill(void 0);for(let g=0;g<d;g++){const p=f[g];p&&(m[p.lane]=g)}for(let g=d;g<n;g++){const p=s(g),y=this.laneAssignments.get(g);let v,b;const w=l==="estimate"||u.has(p);if(y!==void 0&&this.options.lanes>1){v=y;const E=m[v],_=E!==void 0?f[E]:void 0;b=_?_.end+this.options.gap:r+i}else{const E=this.options.lanes===1?f[g-1]:this.getFurthestMeasurement(f,g);b=E?E.end+this.options.gap:r+i,v=E?E.lane:g%this.options.lanes,this.options.lanes>1&&w&&this.laneAssignments.set(g,v)}const x=u.get(p),k=typeof x=="number"?x:this.options.estimateSize(g),C=b+k;f[g]={index:g,start:b,size:k,end:C,key:p,lane:v},m[v]=g}return this.measurementsCache=f,f},{key:!1,debug:()=>this.options.debug}),this.calculateRange=em(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes,this.options.paddingEnd],(n,r,i,s,o)=>{if(n.length===0||r===0)return this.range=null,null;const a=Math.max(this.options.scrollMargin+this.getTotalSize()-r,0),l=Math.min(Math.max(i,0),a);return this.range=$Qe(n,r,l,s,s===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range},{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=em(()=>{let n=null,r=null;const i=this.calculateRange();return i&&(n=i.startIndex,r=i.endIndex),this.maybeNotify.updateDeps([this.isScrolling,n,r]),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,r]},(n,r,i,s,o)=>s===null||o===null?[]:n({startIndex:s,endIndex:o,overscan:r,count:i}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=n=>{const r=this.options.indexAttribute,i=n.getAttribute(r);return i?parseInt(i,10):(console.warn(`Missing attribute name '${r}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=n=>{var r;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const i=this.scrollState.index??((r=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:r.index);if(i!==void 0&&this.range){const s=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),o=Math.max(0,i-s),a=Math.min(this.options.count-1,i+s);return n>=o&&n<=a}return!0},this.measureElement=n=>{if(!n){this.elementsCache.forEach((o,a)=>{o.isConnected||(this.observer.unobserve(o),this.elementsCache.delete(a))});return}const r=this.indexFromElement(n),i=this.options.getItemKey(r),s=this.elementsCache.get(i);s!==n&&(s&&this.observer.unobserve(s),this.observer.observe(n),this.elementsCache.set(i,n)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(r)&&this.resizeItem(r,this.options.measureElement(n,void 0,this))},this.resizeItem=(n,r)=>{var i,s;if(n<0||n>=this.options.count)return;let o,a,l;const c=this._flatMeasurements;if(this.options.lanes===1&&c!==null)l=this.options.getItemKey(n),a=c[n*2],o=c[n*2+1];else{const f=this.measurementsCache[n];if(!f)return;l=f.key,a=f.start,o=f.size}const u=this.itemSizeCache.get(l)??o,d=r-u;if(d!==0){const f=this.options.anchorTo==="end"&&((i=this.scrollState)==null?void 0:i.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,m=f?this.getTotalSize():0,g=((s=this.scrollState)==null?void 0:s.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[n]??{index:n,key:l,start:a,size:o,end:a+o,lane:0},d,this):a<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(l)||this.scrollDirection!=="backward"));(this.pendingMin===null||n<this.pendingMin)&&(this.pendingMin=n),this.itemSizeCache.set(l,r),this.itemSizeCacheVersion++,f?this.applyScrollAdjustment(this.getTotalSize()-m):g&&this.applyScrollAdjustment(d),this.notify(!1)}},this.getVirtualItems=em(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,r)=>{const i=[];for(let s=0,o=n.length;s<o;s++){const a=n[s],l=r[a];i.push(l)}return i},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{const r=this.getMeasurements();if(r.length===0)return;const i=this._flatMeasurements,s=this.options.lanes===1&&i!=null,o=Pne(0,r.length-1,s?a=>i[a*2]:a=>tN(r[a]).start,n);return tN(r[o])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const n=this.scrollElement.document.documentElement;return this.options.horizontal?n.scrollWidth-this.scrollElement.innerWidth:n.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(n=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=n,this.getOffsetForAlignment=(n,r,i=0)=>{if(!this.scrollElement)return 0;const s=this.getSize(),o=this.getScrollOffset();r==="auto"&&(r=n>=o+s?"end":"start"),r==="center"?n+=(i-s)/2:r==="end"&&(n-=s);const a=this.getMaxScrollOffset();return Math.max(Math.min(a,n),0)},this.getOffsetForIndex=(n,r="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const i=this.getSize(),s=this.getScrollOffset(),o=this.measurementsCache[n];if(!o)return;if(r==="auto")if(o.end>=s+i-this.options.scrollPaddingEnd)r="end";else if(o.start<=s+this.options.scrollPaddingStart)r="start";else return[s,r];if(r==="end"&&n===this.options.count-1)return[this.getMaxScrollOffset(),r];const a=r==="end"?o.end+this.options.scrollPaddingEnd:o.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,r,o.size),r]},this.scrollToOffset=(n,{align:r="start",behavior:i="auto"}={})=>{const s=this.getOffsetForAlignment(n,r),o=this.now();this.scrollState={index:null,align:r,behavior:i,startedAt:o,lastTargetOffset:s,stableFrames:0},this._scrollToOffset(s,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.scrollToIndex=(n,{align:r="auto",behavior:i="auto"}={})=>{n=Math.max(0,Math.min(n,this.options.count-1));const s=this.getOffsetForIndex(n,r);if(!s)return;const[o,a]=s,l=this.now();this.scrollState={index:n,align:a,behavior:i,startedAt:l,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.scrollBy=(n,{behavior:r="auto"}={})=>{const i=this.getScrollOffset()+n,s=this.now();this.scrollState={index:null,align:"start",behavior:r,startedAt:s,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:n="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:n});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:n})},this.getTotalSize=()=>{var n;const r=this.getMeasurements();let i;if(r.length===0)i=this.options.paddingStart;else if(this.options.lanes===1){const s=r.length-1,o=this._flatMeasurements;o!=null?i=o[s*2]+o[s*2+1]:i=((n=r[s])==null?void 0:n.end)??0}else{const s=Array(this.options.lanes).fill(null);let o=r.length-1;for(;o>=0&&s.some(a=>a===null);){const a=r[o];s[a.lane]===null&&(s[a.lane]=a.end),o--}i=Math.max(...s.filter(a=>a!==null))}return Math.max(i-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const n=[];if(this.itemSizeCache.size===0)return n;const r=this.getMeasurements();for(const i of r)i&&this.itemSizeCache.has(i.key)&&n.push({index:i.index,key:i.key,start:i.start,size:i.size,end:i.end,lane:i.lane});return n},this._scrollToOffset=(n,{adjustments:r,behavior:i})=>{this._intendedScrollOffset=n+(r??0),this.options.scrollToFn(n,{behavior:i,adjustments:r},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(t)}applyScrollAdjustment(t,n){t!==0&&(n6()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=t:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=t,behavior:n}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollAdjustments=0)))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const r=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,i=r?r[0]:this.scrollState.lastTargetOffset,s=1,o=i!==this.scrollState.lastTargetOffset;if(!o&&SQe(i,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=s){this.getScrollOffset()!==i&&this._scrollToOffset(i,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,o){const a=this.getSize()||600,l=Math.abs(i-this.getScrollOffset()),c=this.scrollState.behavior==="smooth"&&l>a;this.scrollState.lastTargetOffset=i,c||(this.scrollState.behavior="auto"),this._scrollToOffset(i,{adjustments:void 0,behavior:c?"smooth":"auto"})}this.scheduleScrollReconcile()}}const Pne=(e,t,n,r)=>{for(;e<=t;){const i=(e+t)/2|0,s=n(i);if(s<r)e=i+1;else if(s>r)t=i-1;else return i}return e>0?e-1:0};function MQe(e,t,n){let r=0;for(;r<=t;){const i=(r+t)/2|0,s=e[i*2];if(s<n)r=i+1;else if(s>n)t=i-1;else return i}return r>0?r-1:0}function $Qe(e,t,n,r,i){const s=e.length-1;if(e.length<=r)return{startIndex:0,endIndex:s};if(r===1&&i!==null){const c=MQe(i,s,n);let u=c;const d=n+t;for(;u<s&&i[u*2]+i[u*2+1]<d;)u++;return{startIndex:c,endIndex:u}}let a=Pne(0,s,c=>e[c].start,n),l=a;if(r===1)for(;l<s&&e[l].end<n+t;)l++;else if(r>1){const c=Array(r).fill(0);for(;l<s&&c.some(d=>d<n+t);){const d=e[l];c[d.lane]=d.end,l++}const u=Array(r).fill(n+t);for(;a>=0&&u.some(d=>d>=n);){const d=e[a];u[d.lane]=d.start,a--}a=Math.max(0,a-a%r),l=Math.min(s,l+(r-1-l%r))}return{startIndex:a,endIndex:l}}function PQe(e){const t=le(e),n=new AQe(t),[r,i]=Ze(n.getVirtualItems()),[s,o]=De(n.getTotalSize()),a={get(c,u){switch(u){case"getVirtualItems":return()=>r;case"getTotalSize":return()=>s();default:return Reflect.get(c,u)}}},l=new Proxy(n,a);return l.setOptions(t),sn(()=>{const c=l._didMount();l._willUpdate(),Te(c)}),Fs(()=>{l.setOptions(le(t,e,{onChange:(c,u)=>{var d;c._willUpdate(),i(kn(c.getVirtualItems(),{key:"index"})),o(c.getTotalSize()),(d=e.onChange)==null||d.call(e,c,u)}})),l._willUpdate(),i(kn(n.getVirtualItems(),{key:"index"})),o(n.getTotalSize())}),l}function PI(e){return PQe(le({observeElementRect:TQe,observeElementOffset:Mne,scrollToFn:$ne},e))}var One=A("<div>");function OQe(e,t){return t?e?typeof e=="string"?`${e};--card-accent:${t};`:{...e,"--card-accent":t}:{"--card-accent":t}:e}function OI(e){const[t,n]=Ee(e,["variant","style","class","classList"]),r=()=>t.variant??"normal",i=()=>{const s=r();if(s==="error")return"var(--v2-state-fg-danger)";if(s==="warning")return"var(--icon-warning-active)";if(s==="success")return"var(--icon-success-active)";if(s==="info")return"var(--icon-info-active)"};return(()=>{var s=One();return An(s,le(n,{"data-component":"card",get"data-variant"(){return r()},get style(){return OQe(t.style,i())},get classList(){return{...t.classList,[t.class??""]:!!t.class}}}),!1,!0),S(s,()=>e.children),s})()}function RQe(e){const[t,n]=Ee(e,["class","classList","children"]);return(()=>{var r=One();return An(r,le(n,{"data-slot":"card-description",get classList(){return{...t.classList,[t.class??""]:!!t.class}}}),!1,!0),S(r,()=>t.children),r})()}function FQe({onlyFirst:e=!1}={}){const i="(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";return new RegExp(i,e?void 0:"g")}const NQe=FQe();function VQe(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(NQe,"")}var zQe=A("<span data-slot=text-shimmer-char><span data-slot=text-shimmer-char-base aria-hidden=true></span><span data-slot=text-shimmer-char-shimmer aria-hidden=true>");const xo=e=>{const t=I(()=>e.text??""),n=I(()=>e.active??!0),r=I(()=>e.offset??0),[i,s]=De(n()),o=220;let a;return ae(()=>{if(a&&(clearTimeout(a),a=void 0),n()){s(!0);return}a=setTimeout(()=>{a=void 0,s(!1)},o)}),Te(()=>{a&&clearTimeout(a)}),h(Gi,{get component(){return e.as??"span"},"data-component":"text-shimmer",get"data-active"(){return n()?"true":"false"},get class(){return e.class},get"aria-label"(){return t()},get style(){return{"--text-shimmer-swap":`${o}ms`,"--text-shimmer-index":`${r()}`}},get children(){var l=zQe(),c=l.firstChild,u=c.nextSibling;return S(c,t),S(u,t),he(()=>me(u,"data-run",i()?"true":"false")),l}})};var HQe=A("<div data-component=tool-trigger><div data-slot=basic-tool-tool-trigger-content><div data-slot=basic-tool-tool-info>"),jQe=A("<span data-slot=basic-tool-tool-subtitle>"),qQe=A("<span data-slot=basic-tool-tool-action>"),BQe=A("<div data-slot=basic-tool-tool-info-structured><div data-slot=basic-tool-tool-info-main><span data-slot=basic-tool-tool-title>"),UQe=A("<span data-slot=basic-tool-tool-arg>"),WQe=A("<div data-slot=collapsible-content data-animated>");const KQe=e=>typeof e=="object"&&e!==null&&"title"in e&&(typeof Node>"u"||!(e instanceof Node)),rN={type:"spring",visualDuration:.35,bounce:0},B2=[];let rv;function Rne(){for(;B2.length>0;){const e=B2.pop();if(e.active){rv=B2.length>0?requestAnimationFrame(Rne):void 0,e.fn();return}}rv=void 0}function GQe(){rv===void 0&&(rv=requestAnimationFrame(()=>{rv=requestAnimationFrame(Rne)}))}function ZQe(e){const t={active:!0,fn:e};return B2.push(t),GQe(),()=>{t.active=!1}}function YQe(e){const t=requestAnimationFrame(e);return()=>cancelAnimationFrame(t)}function Hs(e){const[t,n]=Ze({open:e.defaultOpen??!1,ready:!e.defer&&(e.defaultOpen??!1)}),r=()=>e.open??t.open,i=()=>t.ready,s=()=>e.status==="pending"||e.status==="running",o=()=>e.defer?"children"in e:e.children,a=typeof e.trigger=="function"?e.trigger(r):void 0;let l;const c=()=>{l?.(),l=void 0},u=(v=!1)=>{c(),l=(v?ZQe:YQe)(()=>{l=void 0,r()&&n("ready",!0)})};Te(c),sn(()=>{e.defer&&r()&&u(!0)});const d=v=>{e.open===void 0&&n("open",v),e.onOpenChange?.(v)};ae(()=>{e.forceOpen&&(r()||d(!0))}),ae(vt(r,v=>{if(e.defer){if(!v){c(),n("ready",!1);return}u()}},{defer:!0}));let f,m;const g=r();ae(vt(r,v=>{!e.animated||!f||(m?.stop(),v?(f.style.overflow="hidden",m=Fx(f,{height:"auto"},rN),m.finished.then(()=>{!f||!r()||(f.style.overflow="visible",f.style.height="auto")})):(f.style.overflow="hidden",m=Fx(f,{height:"0px"},rN)))},{defer:!0})),Te(()=>{m?.stop()});const p=v=>{s()&&!e.allowOpenWhilePending||e.locked&&!v||d(v)},y=()=>(()=>{var v=HQe(),b=v.firstChild,w=b.firstChild;return S(w,h(Rr,{get children(){return[h(zt,{when:a!==void 0,children:a}),h(zt,{get when(){return we(()=>!!KQe(e.trigger))()&&e.trigger},children:x=>(()=>{var k=BQe(),C=k.firstChild,E=C.firstChild;return S(E,h(xo,{get text(){return x().title},get active(){return s()}})),S(C,h(q,{get when(){return!s()},get children(){return[h(q,{get when(){return x().subtitle},get children(){var _=jQe();return _.$$click=L=>{e.onSubtitleClick&&(L.stopPropagation(),e.onSubtitleClick())},S(_,()=>x().subtitle),he(L=>ct(_,{[x().subtitleClass??""]:!!x().subtitleClass,clickable:!!e.onSubtitleClick},L)),_}}),h(q,{get when(){return x().args?.length},get children(){return h(Dt,{get each(){return x().args},children:_=>(()=>{var L=UQe();return S(L,_),he(O=>ct(L,{[x().argsClass??""]:!!x().argsClass},O)),L})()})}})]}}),null),S(k,h(q,{get when(){return we(()=>!s())()&&x().action},get children(){var _=qQe();return S(_,()=>x().action),_}}),null),he(_=>ct(E,{[x().titleClass??""]:!!x().titleClass},_)),k})()}),h(zt,{when:!0,get children(){return e.trigger}})]}})),S(v,h(q,{get when(){return we(()=>!!(o()&&!e.hideDetails&&!e.locked))()&&(!s()||e.allowOpenWhilePending)},get children(){return h(Wi.Arrow,{})}}),null),he(x=>{var k=e.clickable?"true":void 0,C=e.hideDetails?"true":void 0;return k!==x.e&&me(v,"data-clickable",x.e=k),C!==x.t&&me(v,"data-hide-details",x.t=C),x},{e:void 0,t:void 0}),v})();return h(Wi,{get open(){return r()},onOpenChange:p,class:"tool-collapsible",get children(){return[h(q,{get when(){return e.triggerAsLink||e.triggerHref},get fallback(){return h(Wi.Trigger,{get"data-hide-details"(){return e.hideDetails?"true":void 0},get onClick(){return e.onTriggerClick},get children(){return y()}})},get children(){return h(Wi.Trigger,{as:"a",get href(){return e.triggerHref},get role(){return!e.triggerHref&&e.clickable?"button":void 0},get tabIndex(){return!e.triggerHref&&e.clickable?0:void 0},get"data-hide-details"(){return e.hideDetails?"true":void 0},get onClick(){return e.onTriggerClick},get onKeyDown(){return e.onTriggerKeyDown},get children(){return y()}})}}),h(q,{get when(){return we(()=>!!(e.animated&&o()))()&&!e.hideDetails},get children(){var v=WQe(),b=f;return typeof b=="function"?pt(b,v):f=v,Ct(v,"height",g?"auto":"0px"),Ct(v,"overflow",g?"visible":"hidden"),S(v,h(q,{get when(){return!e.defer||i()},get children(){return e.children}})),v}}),h(q,{get when(){return we(()=>!!(!e.animated&&o()))()&&!e.hideDetails},get children(){return h(Wi.Content,{get children(){return h(q,{get when(){return!e.defer||i()},get children(){return e.children}})}})}})]}})}function XQe(e){return["description","query","url","filePath","path","pattern","name"].map(n=>e?.[n]).find(n=>typeof n=="string"&&n.length>0)}function QQe(e){if(!e)return[];const t=new Set(["description","query","url","filePath","path","pattern","name"]);return Object.entries(e).filter(([n])=>!t.has(n)).flatMap(([n,r])=>typeof r=="string"?[`${n}=${r}`]:typeof r=="number"?[`${n}=${r}`]:typeof r=="boolean"?[`${n}=${r}`]:[]).slice(0,3)}function JQe(e){const t=Mn();return h(Hs,{icon:"mcp",get status(){return e.status},get trigger(){return{title:t.t("ui.basicTool.called",{tool:e.tool}),subtitle:XQe(e.input),args:QQe(e.input)}},get hideDetails(){return e.hideDetails}})}dn(["click"]);var eJe=A('<a data-slot=basic-tool-tool-subtitle class="clickable subagent-link">'),tJe=A("<div data-component=tool-trigger><div data-slot=basic-tool-tool-trigger-content><span data-slot=basic-tool-tool-indicator data-component=tool-error-card-icon></span><div data-slot=basic-tool-tool-info><div data-slot=basic-tool-tool-info-structured><div data-slot=basic-tool-tool-info-main><span data-slot=basic-tool-tool-title>"),nJe=A("<div data-slot=tool-error-card-copy>"),rJe=A("<div data-slot=tool-error-card-content>"),iJe=A("<span data-slot=basic-tool-tool-subtitle>");function sJe(e){const t=Mn(),[n,r]=Ze({open:e.defaultOpen??!1,copied:!1}),i=()=>e.open??n.open,s=()=>n.copied,[o,a]=Ee(e,["tool","error","title","defaultOpen","open","onOpenChange","subtitle","href"]),l=p=>{e.open===void 0&&r("open",p),e.onOpenChange?.(p)},c=I(()=>{if(o.title)return o.title;const y={read:"ui.tool.read",list:"ui.tool.list",glob:"ui.tool.glob",grep:"ui.tool.grep",task:"ui.tool.task",webfetch:"ui.tool.webfetch",websearch:"ui.tool.websearch",bash:"ui.tool.shell",shell:"ui.tool.shell",patch:"ui.tool.patch",apply_patch:"ui.tool.patch",question:"ui.tool.questions"}[o.tool];return y?y.includes(".")?t.t(y):y:o.tool}),u=I(()=>o.error.replace(/^Error:\s*/,"").trim()),d=I(()=>{const p=u(),y=`${o.tool} `;return p.startsWith(y)?p.slice(y.length):p}),f=I(()=>{if(o.subtitle)return o.subtitle;const p=d().split(": ");if(p.length<=1)return t.t("ui.toolErrorCard.failed");const y=(p[0]??"").trim();return y&&y[0]?y[0].toUpperCase()+y.slice(1):t.t("ui.toolErrorCard.failed")}),m=I(()=>{const p=d().split(": ");return p.length<=1?u():p.slice(1).join(": ").trim()||u()}),g=async()=>{const p=u();p&&(await navigator.clipboard.writeText(p),r("copied",!0),setTimeout(()=>r("copied",!1),2e3))};return h(OI,le(a,{"data-kind":"tool-error-card",get"data-open"(){return i()?"true":"false"},variant:"error",get children(){return h(Wi,{class:"tool-collapsible",get"data-open"(){return i()?"true":"false"},get open(){return i()},onOpenChange:l,get children(){return[h(Wi.Trigger,{get children(){var p=tJe(),y=p.firstChild,v=y.firstChild,b=v.nextSibling,w=b.firstChild,x=w.firstChild,k=x.firstChild;return S(v,h(Yt,{name:"circle-ban-sign",size:"small",style:{"stroke-width":1.5}})),S(k,c),S(x,h(q,{get when(){return we(()=>!!o.href)()&&o.subtitle},get fallback(){return(()=>{var C=iJe();return S(C,f),C})()},get children(){var C=eJe();return C.$$click=E=>E.stopPropagation(),S(C,f),he(()=>me(C,"href",o.href)),C}}),null),S(p,h(Wi.Arrow,{}),null),p}}),h(Wi.Content,{get children(){var p=rJe();return S(p,h(q,{get when(){return i()},get children(){var y=nJe();return S(y,h(Ar,{get value(){return we(()=>!!s())()?t.t("ui.message.copied"):t.t("ui.toolErrorCard.copyError")},placement:"top",gutter:4,get children(){return h(Ln,{get icon(){return s()?"check":"copy"},size:"normal",variant:"ghost",onMouseDown:v=>v.preventDefault(),onClick:v=>{v.stopPropagation(),g()},get"aria-label"(){return we(()=>!!s())()?t.t("ui.message.copied"):t.t("ui.toolErrorCard.copyError")}})}})),y}}),null),S(p,h(q,{get when(){return m()},children:y=>h(RQe,{get children(){return y()}})}),null),p}})]}})}}))}dn(["click"]);var oJe=A('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 18 14"fill=none><g>'),aJe=A("<span data-slot=diff-changes-additions>"),lJe=A("<span data-slot=diff-changes-deletions>"),cJe=A("<div data-component=diff-changes>"),uJe=A("<svg><rect width=2 height=14 rx=1></svg>",!1,!0,!1);function Qc(e){const t=()=>e.variant??"default",n=I(()=>Array.isArray(e.changes)?e.changes.reduce((u,d)=>u+(d.additions??0),0):e.changes.additions),r=I(()=>Array.isArray(e.changes)?e.changes.reduce((u,d)=>u+(d.deletions??0),0):e.changes.deletions),i=I(()=>(n()??0)+(r()??0)),s=I(()=>{const d=n()??0,f=r()??0;if(d===0&&f===0)return{added:0,deleted:0,neutral:5};const m=d+f;if(m<5){const _=d>0?1:0,L=f>0?1:0,O=5-_-L;return{added:_,deleted:L,neutral:O}}const g=d>f?d/f:f/d;let p=5;(m<20||g<4)&&(p=4);const y=d/m,v=f/m,b=y*p,w=v*p;let x=d>0?Math.max(1,Math.round(b)):0,k=f>0?Math.max(1,Math.round(w)):0;d>0&&d<=5&&(x=Math.min(x,1)),d>5&&d<=10&&(x=Math.min(x,2)),f>0&&f<=5&&(k=Math.min(k,1)),f>5&&f<=10&&(k=Math.min(k,2));let C=x+k;C>p&&(b>w?x=p-k:k=p-x,C=x+k);const E=Math.max(0,5-C);return{added:x,deleted:k,neutral:E}}),o="var(--icon-diff-add-base)",a="var(--icon-diff-delete-base)",l="var(--icon-weak-base)",c=I(()=>{const u=s();return[...Array(u.added).fill(o),...Array(u.deleted).fill(a),...Array(u.neutral).fill(l)].slice(0,5)});return h(q,{get when(){return we(()=>t()==="default")()?i()>0:!0},get children(){var u=cJe();return S(u,h(Rr,{get children(){return[h(zt,{get when(){return t()==="bars"},get children(){var d=oJe(),f=d.firstChild;return S(f,h(Dt,{get each(){return c()},children:(m,g)=>(()=>{var p=uJe();return me(p,"fill",m),he(()=>me(p,"x",g()*4)),p})()})),d}}),h(zt,{get when(){return t()==="default"},get children(){return[(()=>{var d=aJe();return S(d,()=>`+${n()}`),d})(),(()=>{var d=lJe();return S(d,()=>`-${r()}`),d})()]}})]}})),he(d=>{var f=t(),m={[e.class??""]:!0};return f!==d.e&&me(u,"data-variant",d.e=f),d.t=ct(u,m,d.t),d},{e:void 0,t:void 0}),u}})}var dJe=A("<span data-component=tool-count-label><span data-slot=tool-count-label-before></span><span data-slot=tool-count-label-word><span data-slot=tool-count-label-stem></span><span data-slot=tool-count-label-suffix><span data-slot=tool-count-label-suffix-inner>");function iN(e){const t=/{{\s*count\s*}}/.exec(e);return t?t.index===void 0?{before:"",after:e}:{before:e.slice(0,t.index),after:e.slice(t.index+t[0].length)}:{before:"",after:e}}function fJe(e,t){const n=Array.from(e),r=Array.from(t);let i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;return{stem:n.slice(0,i).join(""),one:n.slice(i).join(""),other:r.slice(i).join("")}}function hJe(e){const t=I(()=>iN(e.one)),n=I(()=>iN(e.other)),r=I(()=>Math.round(e.count)===1),i=I(()=>r()?t():n()),s=I(()=>fJe(t().after,n().after)),o=I(()=>t().before===n().before&&(t().after.startsWith(n().after)||n().after.startsWith(t().after))),a=I(()=>o()?t().before:i().before),l=I(()=>o()?s().stem:i().after),c=I(()=>o()?r()?s().one:s().other:""),u=I(()=>o()&&c().length>0);return(()=>{var d=dJe(),f=d.firstChild,m=f.nextSibling,g=m.firstChild,p=g.nextSibling,y=p.firstChild;return S(f,a),S(d,h(PC,{get value(){return e.count}}),m),S(g,l),S(y,c),he(v=>{var b=e.class,w=u()?"true":"false";return b!==v.e&&xr(d,v.e=b),w!==v.t&&me(p,"data-active",v.t=w),v},{e:void 0,t:void 0}),d})()}var mJe=A("<span data-component=tool-count-summary><span data-slot=tool-count-summary-empty><span data-slot=tool-count-summary-empty-inner>"),gJe=A("<span data-slot=tool-count-summary-prefix>,"),pJe=A("<span data-slot=tool-count-summary-item><span data-slot=tool-count-summary-item-inner>");function vJe(e){const t=I(()=>e.items.filter(i=>i.count>0)),n=I(()=>e.fallback??""),r=I(()=>t().length===0&&n().length>0);return(()=>{var i=mJe(),s=i.firstChild,o=s.firstChild;return S(o,n),S(i,h(nh,{get each(){return e.items},children:(a,l)=>{const c=I(()=>a().count>0),u=I(()=>{for(let d=l-1;d>=0;d--)if(e.items[d].count>0)return!0;return!1});return[(()=>{var d=gJe();return he(()=>me(d,"data-active",c()&&u()?"true":"false")),d})(),(()=>{var d=pJe(),f=d.firstChild;return S(f,h(hJe,{get one(){return a().one},get other(){return a().other},get count(){return Math.max(0,Math.round(a().count))}})),he(()=>me(d,"data-active",c()?"true":"false")),d})()]}}),null),he(a=>{var l=e.class,c=r()?"true":"false";return l!==a.e&&xr(i,a.e=l),c!==a.t&&me(s,"data-active",a.t=c),a},{e:void 0,t:void 0}),i})()}var sN=A("<span data-slot=tool-status-active>"),oN=A("<span data-slot=tool-status-done>"),yJe=A("<span data-slot=tool-status-suffix><span data-slot=tool-status-prefix></span><span data-slot=tool-status-tail>"),bJe=A("<span data-component=tool-status-title>"),wJe=A("<span data-slot=tool-status-swap>");function xJe(e,t){const n=Array.from(e),r=Array.from(t);let i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;return{prefix:n.slice(0,i).join(""),active:n.slice(i).join(""),done:r.slice(i).join("")}}function aN(e){if(e)return`${Math.ceil(e.getBoundingClientRect().width)}px`}function kJe(e){const t=I(()=>xJe(e.activeText,e.doneText)),n=I(()=>(e.split??!0)&&t().prefix.length>=2&&t().active.length>0&&t().done.length>0),r=I(()=>Array.from(t().prefix).length),i=I(()=>n()?t().active:e.activeText),s=I(()=>n()?t().done:e.doneText),[o,a]=Ze({active:e.active,animating:!1,width:void 0}),l=()=>o.width,c=()=>o.active,u=()=>o.animating;let d,f,m,g,p;const y=()=>{g!==void 0&&cancelAnimationFrame(g),p!==void 0&&clearTimeout(p),g=void 0,p=void 0,a("animating",!1),a("width",void 0)},v=()=>{const b=aN(m),w=e.active;y(),a("active",w),b&&(a("animating",!0),a("width",b),g=requestAnimationFrame(()=>{g=void 0;const x=aN(w?d:f);if(!x){y();return}b!==x&&a("width",x),p=setTimeout(y,600)}))};return ae(vt([()=>e.active,i,s],()=>v(),{defer:!0})),Te(()=>{y()}),(()=>{var b=bJe();return S(b,h(q,{get when(){return n()},get fallback(){return(()=>{var w=wJe(),x=m;return typeof x=="function"?pt(x,w):m=w,S(w,h(q,{get when(){return u()||c()},get children(){var k=sN(),C=d;return typeof C=="function"?pt(C,k):d=k,S(k,h(xo,{get text(){return i()},get active(){return c()},offset:0})),k}}),null),S(w,h(q,{get when(){return u()||!c()},get children(){var k=oN(),C=f;return typeof C=="function"?pt(C,k):f=k,S(k,h(xo,{get text(){return s()},active:!1,offset:0})),k}}),null),he(k=>Ct(w,"width",l())),w})()},get children(){var w=yJe(),x=w.firstChild,k=x.nextSibling;S(x,h(xo,{get text(){return t().prefix},get active(){return c()},offset:0}));var C=m;return typeof C=="function"?pt(C,k):m=k,S(k,h(q,{get when(){return u()||c()},get children(){var E=sN(),_=d;return typeof _=="function"?pt(_,E):d=E,S(E,h(xo,{get text(){return i()},get active(){return c()},get offset(){return r()}})),E}}),null),S(k,h(q,{get when(){return u()||!c()},get children(){var E=oN(),_=f;return typeof _=="function"?pt(_,E):f=E,S(E,h(xo,{get text(){return s()},active:!1,get offset(){return r()}})),E}}),null),he(E=>Ct(k,"width",l())),w}})),he(w=>{var x=c()?"true":"false",k=u()?"true":"false",C=n()?"suffix":"swap",E=e.class,_=c()?e.activeText:e.doneText;return x!==w.e&&me(b,"data-active",w.e=x),k!==w.t&&me(b,"data-ready",w.t=k),C!==w.a&&me(b,"data-mode",w.a=C),E!==w.o&&xr(b,w.o=E),_!==w.i&&me(b,"aria-label",w.i=_),w},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),b})()}function Fne(e){const t=e.split(/\n/),n=[];let r=0;function i(){const a={};for(n.push(a);r<t.length;){const l=t[r];if(/^(---|\+\+\+|@@)\s/.test(l))break;const c=/^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(l);c&&(a.index=c[1]),r++}for(s(a),s(a),a.hunks=[];r<t.length;){const l=t[r];if(/^(Index:\s|diff\s|---\s|\+\+\+\s|===================================================================)/.test(l))break;if(/^@@/.test(l))a.hunks.push(o());else{if(l)throw new Error("Unknown line "+(r+1)+" "+JSON.stringify(l));r++}}}function s(a){const l=/^(---|\+\+\+)\s+(.*)\r?$/.exec(t[r]);if(l){const c=l[2].split(" ",2),u=(c[1]||"").trim();let d=c[0].replace(/\\\\/g,"\\");/^".*"$/.test(d)&&(d=d.substr(1,d.length-2)),l[1]==="---"?(a.oldFileName=d,a.oldHeader=u):(a.newFileName=d,a.newHeader=u),r++}}function o(){var a;const l=r,c=t[r++],u=c.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/),d={oldStart:+u[1],oldLines:typeof u[2]>"u"?1:+u[2],newStart:+u[3],newLines:typeof u[4]>"u"?1:+u[4],lines:[]};d.oldLines===0&&(d.oldStart+=1),d.newLines===0&&(d.newStart+=1);let f=0,m=0;for(;r<t.length&&(m<d.oldLines||f<d.newLines||!((a=t[r])===null||a===void 0)&&a.startsWith("\\"));r++){const g=t[r].length==0&&r!=t.length-1?" ":t[r][0];if(g==="+"||g==="-"||g===" "||g==="\\")d.lines.push(t[r]),g==="+"?f++:g==="-"?m++:g===" "&&(f++,m++);else throw new Error(`Hunk at line ${l+1} contained invalid line ${t[r]}`)}if(!f&&d.newLines===1&&(d.newLines=0),!m&&d.oldLines===1&&(d.oldLines=0),f!==d.newLines)throw new Error("Added line count did not match for hunk at line "+(l+1));if(m!==d.oldLines)throw new Error("Removed line count did not match for hunk at line "+(l+1));return d}for(;r<t.length;)i();return n}const SJe=16,Jd=new Map;function Nne(e){return typeof e.patch=="string"?CJe(e.file,e.patch):Vne(e.file,typeof e.before=="string"?e.before:"",typeof e.after=="string"?e.after:"")}function i3(e){return{file:e.file,additions:e.additions,deletions:e.deletions,status:e.status,fileDiff:Nne(e)}}function U2(e,t){return t==="deletions"?e.fileDiff.deletionLines.join(""):e.fileDiff.additionLines.join("")}function CJe(e,t){const n=`${e}\0${t}`,r=Jd.get(n);if(r)return Jd.delete(n),Jd.set(n,r),r;const i=_Je(t),s=i?void 0:TJe(e,t),o=i?Vne(e,i.before,i.after):(s?V0e(s)[0]?.files[0]:void 0)??zne(e);for(Jd.set(n,o);Jd.size>SJe;)Jd.delete(Jd.keys().next().value);return o}function _Je(e){try{const t=Fne(e)[0];if(!t||!t.index&&!t.oldFileName&&!t.newFileName||!e.startsWith("diff --git ")&&!/^--- [^\n]*\t\r?\n\+\+\+ [^\n]*\t(?:\r?\n|$)/m.test(e)||t.hunks.length!==1)return;const n=t.hunks[0];if(!n||n.oldStart>1||n.newStart>1)return;const r=[],i=[];let s;for(const a of n.lines){if(a.startsWith("\\")){if(s==="-"||s===" "){const l=r.at(-1);l&&(l.newline=!1)}if(s==="+"||s===" "){const l=i.at(-1);l&&(l.newline=!1)}continue}if(a.startsWith("-")){r.push({text:a.slice(1),newline:!0}),s="-";continue}if(a.startsWith("+")){i.push({text:a.slice(1),newline:!0}),s="+";continue}if(!a.startsWith(" "))return;r.push({text:a.slice(1),newline:!0}),i.push({text:a.slice(1),newline:!0}),s=" "}const o=a=>a.map(l=>l.text+(l.newline?`
1173
+ ${X.commentID}`)?.time??Date.now():Date.now(),origin:X.commentOrigin,preview:X.preview}]:[]})},V=K=>{s.replace(K.map(X=>({id:X.id,file:X.path,selection:{...X.selection},comment:X.comment,time:X.time}))),d.context.replaceComments(K.map(X=>({type:"file",path:X.path,selection:md(X.selection),comment:X.comment,commentID:X.id,commentOrigin:X.origin,preview:X.preview})))},P=I(()=>{const K=e.controls.session.id;return K?l.isAutoAccepting(K,t().directory):l.isAutoAcceptingDirectory(t().directory)}),T=cne({prompt:d,info:w,imageAttachments:k,commentCount:C,autoAccept:P,mode:g,working:x,editor:()=>f,queueScroll:()=>requestAnimationFrame(()=>f?.scrollIntoView({block:"nearest"})),promptLength:Ho,addToHistory:(K,X)=>J.addHistory(K,X),resetHistoryNavigation:()=>J.resetHistory(),setMode:K=>J.dispatch({type:K==="shell"?"mode.shell":"mode.normal"}),setPopover:K=>{K||J.dispatch({type:"popover.close"})},newSessionWorktree:()=>e.newSessionWorktree,onNewSessionWorktreeReset:e.onNewSessionWorktreeReset,shouldQueue:e.shouldQueue,onQueue:e.onQueue,onAbort:e.onAbort,onSubmit:e.onSubmit,model:e.controls.model.selection}),D=K=>K.source.type==="git"?K.source.repository:K.source.path,N=I(()=>n().data.reference.filter(K=>!K.hidden).map(K=>({id:`reference:${K.name}`,kind:"reference",label:`@${K.name}`,path:K.path,description:K.description??D(K),mention:{type:"file",path:K.path,content:`@${K.name}`,start:0,end:0,mime:"application/x-directory",filename:K.name}}))),M=I(()=>Object.values(n().data.mcp_resource).map(K=>({id:`resource:${K.server}:${K.uri}`,kind:"resource",label:`@${K.name}`,path:K.uri,description:K.description,mention:{type:"file",path:K.uri,content:`@${K.name}`,start:0,end:0,mime:K.mimeType??"text/plain",filename:K.name,url:K.uri,source:{type:"resource",text:{value:`@${K.name}`,start:0,end:K.name.length+1},clientName:K.server,uri:K.uri}},resource:K}))),F=I(()=>[...N(),...e.controls.agents.available.filter(K=>!K.hidden&&K.mode!=="primary").map(K=>({id:`agent:${K.name}`,kind:"agent",label:`@${K.name}`,mention:{type:"agent",name:K.name,content:`@${K.name}`,start:0,end:0}})),...M(),...b().map(K=>({id:`file:${K}`,kind:"file",label:K,path:K,recent:!0,mention:{type:"file",path:K,content:`@${K}`,start:0,end:0}}))]),j=I(()=>[...n().data.command.map(K=>({id:`custom.${K.name}`,trigger:K.name,title:K.name,description:K.description,type:"custom"})),...a.options.filter(K=>!K.disabled&&!K.id.startsWith("suggested.")&&K.slash).map(K=>({id:K.id,trigger:K.slash,title:K.title,description:K.description,type:"builtin"}))]),z=I(()=>[]),W=I(()=>["default",...e.controls.model.selection.variant.list()]),J=UYe({store:()=>d.capture().store,state:m,identity:()=>d.capture(),history:{entries:K=>p.entries(K).map(X=>{const te=Gm(X);return{prompt:te.prompt,metadata:te.comments}}),add:(K,X)=>p.add(K,X,X==="shell"?[]:$()),capture:$,restore:K=>V(K)},commands:z,context:F,searchContextFiles:async K=>(await r.searchFilesAndDirectories(K)).map(X=>({id:`file:${X}`,kind:"file",label:X,path:X,mention:{type:"file",path:X,content:`@${X}`,start:0,end:0}})),onContextRemove(K){K?.commentID&&s.remove(K.path,K.commentID)},openAttachment:K=>o.show(()=>h(MI,{get src(){return K.dataUrl},get alt(){return K.filename}})),openContext(K){const X=J.contextItem(K);X&&tXe(X,e,n,i,r,s)},onEditor(K){f=K,e.ref?.(f)},onSuggestionSelect(K){if(K.kind!=="command")return;const X=j().find(te=>te.id===K.id);if(!(!X||X.type==="custom"))return()=>a.trigger(X.id,"slash")},attachments:{picker:u.openAttachmentPickerDialog,directory:()=>t().directory,isDialogActive:()=>!!o.active,warn:()=>tn({title:c.t("prompt.toast.pasteUnsupported.title"),description:c.t("prompt.toast.pasteUnsupported.description")}),onError:K=>tn({variant:"error",title:c.t("common.requestFailed"),description:K instanceof Error?K.message:String(K)}),readClipboardImage:u.readClipboardImage,getPathForFile:u.getPathForFile},view:{placeholder:O,get agent(){return e.controls.agents.visible&&e.controls.agents.options.length>0?{options:()=>e.controls.agents.options.map(K=>({id:K,label:K})),current:()=>e.controls.agents.current,onSelect:K=>e.controls.agents.select(K),keybind:()=>a.keybindParts("agent.cycle")}:void 0},variant:{options:()=>W().map(K=>({id:K,label:K})),current:()=>e.controls.model.selection.variant.current()??"default",onSelect:K=>e.controls.model.selection.variant.set(K==="default"?void 0:K),keybind:()=>a.keybindParts("model.variant.cycle")},submit:{stopping:_,working:x,onSubmit:()=>void T.handleSubmit(new Event("submit")),onStop:()=>void T.abort()}}});return Object.defineProperty(J,"model",{get:()=>e.controls.model}),a.register("prompt-input",()=>[{id:"file.attach",title:c.t("prompt.action.attachFile"),category:c.t("command.category.file"),keybind:"mod+u",disabled:J.state.mode!=="normal",onSelect:()=>J.attach()},{id:"prompt.mode.shell",title:c.t("command.prompt.mode.shell"),category:c.t("command.category.session"),keybind:"mod+shift+x",disabled:J.state.mode==="shell",onSelect:()=>J.dispatch({type:"mode.shell"})},{id:"prompt.mode.normal",title:c.t("command.prompt.mode.normal"),category:c.t("command.category.session"),keybind:"mod+shift+e",disabled:J.state.mode==="normal",onSelect:()=>J.dispatch({type:"mode.normal"})}]),ae(vt(()=>e.edit?.id,K=>{const X=e.edit;!K||!X||(d.context.items().forEach(te=>d.context.remove(te.key)),X.context.forEach(te=>d.context.add({type:te.type,path:te.path,selection:te.selection,comment:te.comment,commentID:te.commentID,commentOrigin:te.commentOrigin,preview:te.preview})),J.dispatch({type:"mode.normal"}),J.resetHistory(),d.set(X.prompt,Ho(X.prompt)),J.restoreFocus(),e.onEditLoaded?.())},{defer:!0})),J}function eXe(e){const t=I(r=>r??e.loading),n=()=>[h(q,{get when(){return e.providerID},children:r=>h(wg,{get id(){return r()},class:"size-4 shrink-0 opacity-40 group-hover:opacity-100 transition-opacity duration-150",style:{"will-change":"opacity",transform:"translateZ(0)"}})}),(()=>{var r=YYe();return S(r,()=>e.modelName),r})(),(()=>{var r=XYe();return S(r,h(on,{name:"chevron-down"})),r})()];return h(q,{get when(){return!e.loading},get children(){return h(Qn,{placement:"top",gutter:4,get value(){return[we(()=>e.title),h(Eo,{get keys(){return e.keybind},variant:"neutral"})]},get children(){return h(q,{get when(){return e.paid},get fallback(){return h(as,{"data-action":"prompt-model","data-control-type":"dialog",variant:"ghost-muted",size:"normal",class:"min-w-0 max-w-[220px] justify-start ![font-weight:440] group",get classList(){return{"animate-in fade-in":t()}},style:{height:"28px"},get onClick(){return e.onUnpaidClick},get children(){return n()}})},get children(){return h(ene,{get model(){return e.model},triggerAs:as,get triggerProps(){return{variant:"ghost-muted",size:"normal",style:{height:"28px"},class:"min-w-0 max-w-[220px] justify-start ![font-weight:440] group",classList:{"animate-in fade-in":t()},"data-action":"prompt-model","data-control-type":"popover"}},get onClose(){return e.onClose},get children(){return n()}})}})}})}})}function tXe(e,t,n,r,i,s){if(!e.commentID)return;const o={file:e.path,id:e.commentID};s.setActive(o);const a=(d=6)=>{requestAnimationFrame(()=>{s.setFocus({...o}),!(d<=0)&&requestAnimationFrame(()=>{const f=s.focus();f?.file===o.file&&f.id===o.id&&a(d-1)})})},l=t.controls.session.id?n().data.session_diff[t.controls.session.id]:void 0,c=e.commentOrigin==="review"||e.commentOrigin!=="file"&&l?.some(d=>d.file===e.path);if(t.controls.session.reviewPanel.opened()||t.controls.session.reviewPanel.open(),c){r.fileTree.setTab("changes"),t.controls.session.tabs.setActive("review"),a();return}r.fileTree.setTab("all");const u=i.tab(e.path);t.controls.session.tabs.open(u),t.controls.session.tabs.setActive(u),Promise.resolve(i.load(e.path)).finally(()=>a())}function nXe(e){const t=Mr(),n=Br();let r=0,i=!1;return Te(()=>{i=!0}),()=>{const s=++r,o=n.id;B(()=>import("./index-wflYMX4p.js"),__vite__mapDeps([103,104,105,106,107,108,109,110])).then(a=>{i||r!==s||t.show(()=>h(a.DialogSettings,{sessionID:o,defaultValue:e}))})}}function wne(){const e=Qi(),t=wt(),n=nXe();return e.register("settings",()=>[{id:"settings.open",title:t.t("command.settings.open"),category:t.t("command.category.settings"),keybind:"mod+comma",onSelect:n}]),n}var KF=A("<div>"),rXe=A("<div data-component=dock-prompt>");function xne(e){const t=n=>`${e.kind}-${n}`;return(()=>{var n=rXe();cn(n,"keydown",e.onKeyDown,!0);var r=e.ref;return typeof r=="function"?pt(r,n):e.ref=n,S(n,h(HWe,{get"data-slot"(){return t("body")},get children(){return[(()=>{var i=KF();return S(i,()=>e.header),he(()=>me(i,"data-slot",t("header"))),i})(),(()=>{var i=KF();return S(i,()=>e.children),he(()=>me(i,"data-slot",t("content"))),i})()]}}),null),S(n,h(yy,{get"data-slot"(){return t("footer")},get children(){return e.footer}}),null),he(()=>me(n,"data-kind",e.kind)),n})()}dn(["keydown"]);var iXe=A("<div data-slot=permission-row><span data-slot=permission-spacer aria-hidden=true></span><div data-slot=permission-hint>"),sXe=A("<div data-slot=permission-row><span data-slot=permission-spacer aria-hidden=true></span><div data-slot=permission-patterns>"),oXe=A("<div data-slot=permission-row data-variant=header><span data-slot=permission-icon></span><div data-slot=permission-header-title>"),aXe=A("<div>"),lXe=A("<div data-slot=permission-footer-actions>"),cXe=A('<code class="text-12-regular text-text-base break-all">');function uXe(e){const t=wt(),n=()=>{const r=`settings.permissions.tool.${e.request.permission}.description`,i=t.t(r);return i===r?"":i};return h(xne,{kind:"permission",get header(){return(()=>{var r=oXe(),i=r.firstChild,s=i.nextSibling;return S(i,h(Yt,{name:"warning",size:"normal"})),S(s,()=>t.t("notification.permission.title")),r})()},get footer(){return[aXe(),(()=>{var r=lXe();return S(r,h(Kt,{variant:"ghost",size:"normal",onClick:()=>e.onDecide("reject"),get disabled(){return e.responding},get children(){return t.t("ui.permission.deny")}}),null),S(r,h(Kt,{variant:"secondary",size:"normal",onClick:()=>e.onDecide("always"),get disabled(){return e.responding},get children(){return t.t("ui.permission.allowAlways")}}),null),S(r,h(Kt,{variant:"primary",size:"normal",onClick:()=>e.onDecide("once"),get disabled(){return e.responding},get children(){return t.t("ui.permission.allowOnce")}}),null),r})()]},get children(){return[h(q,{get when(){return n()},get children(){var r=iXe(),i=r.firstChild,s=i.nextSibling;return S(s,n),r}}),h(q,{get when(){return e.request.patterns.length>0},get children(){var r=sXe(),i=r.firstChild,s=i.nextSibling;return S(s,h(Dt,{get each(){return e.request.patterns},children:o=>(()=>{var a=cXe();return S(a,o),a})()})),r}})]}})}var dXe=A("<span data-slot=question-option-check aria-hidden=true><span data-slot=question-option-box>"),fXe=A("<span data-slot=question-option-radio-dot>"),hXe=A("<span data-slot=option-description>"),mXe=A("<button type=button data-slot=question-option><span data-slot=question-option-main><span data-slot=option-label>"),gXe=A("<div data-slot=question-text>"),GF=A("<div data-slot=question-hint>"),pXe=A("<form data-slot=question-option data-custom=true><span data-slot=question-option-main><span data-slot=option-label></span><textarea data-slot=question-custom-input rows=1>"),vXe=A("<div data-slot=question-options>"),yXe=A("<div data-component=session-question-dock>"),bXe=A("<div data-slot=question-header-title>"),wXe=A("<div data-slot=question-progress>"),xXe=A("<div data-slot=question-header-actions><button type=button data-component=icon-button data-icon=chevron-down data-size=normal data-variant=ghost>"),kXe=A("<button type=button data-slot=question-progress-segment>"),SXe=A("<div data-slot=question-footer-actions>"),CXe=A("<button type=button data-slot=question-option data-custom=true><span data-slot=question-option-main><span data-slot=option-label></span><span data-slot=option-description>");const e2=new Map;function $C(e){return(()=>{var t=dXe(),n=t.firstChild;return cn(t,"click",e.onClick,!0),S(n,h(q,{get when(){return e.multi},get fallback(){return fXe()},get children(){return h(Yt,{name:"check-small",size:"small"})}})),he(r=>{var i=e.multi?"checkbox":"radio",s=e.picked;return i!==r.e&&me(n,"data-type",r.e=i),s!==r.t&&me(n,"data-picked",r.t=s),r},{e:void 0,t:void 0}),t})()}function _Xe(e){return(()=>{var t=mXe(),n=t.firstChild,r=n.firstChild;cn(t,"click",e.onClick,!0),cn(t,"focus",e.onFocus);var i=e.ref;return typeof i=="function"?pt(i,t):e.ref=t,S(t,h($C,{get multi(){return e.multi},get picked(){return e.picked}}),n),S(r,()=>e.label),S(n,h(q,{get when(){return e.description},get children(){var s=hXe();return S(s,()=>e.description),s}}),null),he(s=>{var o=e.picked,a=e.multi?"checkbox":"radio",l=e.picked,c=e.disabled;return o!==s.e&&me(t,"data-picked",s.e=o),a!==s.t&&me(t,"role",s.t=a),l!==s.a&&me(t,"aria-checked",s.a=l),c!==s.o&&(t.disabled=s.o=c),s},{e:void 0,t:void 0,a:void 0,o:void 0}),t})()}const TXe=e=>{const t=kr(),n=xs(),r=wt(),i=fc.from(n().scope,e.request.id),s=I(()=>e.request.questions),o=I(()=>s().length),a=e2.get(i),[l,c]=Ze({tab:a?.tab??0,answers:a?.answers??[],custom:a?.custom??[],customOn:a?.customOn??[],editing:!1,focus:0,minimized:!1,optionsHeight:180});let u,d,f,m=[],g=!1,p;const y=I(()=>s()[l.tab]),v=I(()=>y()?.options??[]),b=I(()=>l.custom[l.tab]??""),w=I(()=>l.customOn[l.tab]===!0),x=I(()=>y()?.multiple===!0),k=I(()=>v().length+1),C=I(()=>{const re=Math.min(l.tab+1,o());return r.t("session.question.progress",{current:re,total:o()})}),E=()=>r.t("ui.messagePart.option.typeOwnAnswer"),_=()=>r.t("ui.question.custom.placeholder"),L=I(()=>l.tab>=o()-1),O=vy(()=>l.minimized?1:0,{visualDuration:.3,bounce:0}),$=I(()=>Math.max(0,Math.min(1,O()))),V=I(()=>$()>.98),P=(re,pe=w())=>{const ye=b().trim(),Re=re.trim();if(c("custom",l.tab,re),!!pe){if(x()){c("answers",l.tab,(Je=[])=>{const Xe=ye?Je.filter(je=>je.trim()!==ye):Je;return!Re||Xe.some(je=>je.trim()===Re)?Xe:[...Xe,Re]});return}c("answers",l.tab,Re?[Re]:[])}},T=()=>{if(!u)return;const re=document.querySelector(".scroll-view__viewport"),pe=re instanceof HTMLElement?re.firstElementChild:void 0,ye=pe instanceof HTMLElement&&pe.classList.contains("sticky")?pe.getBoundingClientRect().bottom:0;if(!ye){u.style.removeProperty("--question-prompt-max-height");return}const Re=u.closest('[data-component="session-prompt-dock"]');if(!(Re instanceof HTMLElement))return;const Je=Re.getBoundingClientRect().bottom,Xe=Math.max(0,Je-u.getBoundingClientRect().bottom),mt=Math.max(240,Math.floor(Je-ye-8-Xe));u.style.setProperty("--question-prompt-max-height",`${mt}px`)},D=re=>Math.max(0,Math.min(k()-1,re)),N=(re=l.tab)=>{const pe=s()[re]?.options??[];return l.customOn[re]===!0?pe.length:Math.max(0,pe.findIndex(ye=>l.answers[re]?.includes(ye.label)??!1))},M=re=>{const pe=D(re);c("focus",pe),!l.editing&&(p!==void 0&&cancelAnimationFrame(p),p=requestAnimationFrame(()=>{p=void 0,(pe===v().length?f:m[pe])?.focus()}))};sn(()=>{let re;const pe=()=>{re!==void 0&&cancelAnimationFrame(re),re=requestAnimationFrame(()=>{re=void 0,T()})};pe(),an(window,"resize",pe);const ye=u?.closest('[data-component="session-prompt-dock"]'),Re=document.querySelector(".scroll-view__viewport");Oa([ye,Re],pe),Te(()=>{re!==void 0&&cancelAnimationFrame(re)}),M(N())}),ae(()=>{const re=d;if(!re)return;const pe=()=>c("optionsHeight",ye=>Math.max(ye,re.scrollHeight));pe(),Oa(re,pe)}),Te(()=>{p!==void 0&&cancelAnimationFrame(p),!g&&e2.set(i,{tab:l.tab,answers:l.answers.map(re=>re?[...re]:[]),custom:l.custom.map(re=>re??""),customOn:l.customOn.map(re=>re??!1)})});const F=re=>{const pe=re instanceof Error?re.message:String(re);tn({title:r.t("common.requestFailed"),description:pe})},j=Yo(()=>({mutationFn:re=>t().api.question.reply({sessionID:e.request.sessionID,requestID:e.request.id,answers:re}),onMutate:()=>{e.onSubmit()},onSuccess:()=>{g=!0,e2.delete(i)},onError:F})),z=Yo(()=>({mutationFn:()=>t().api.question.reject({sessionID:e.request.sessionID,requestID:e.request.id}),onMutate:()=>{e.onSubmit()},onSuccess:()=>{g=!0,e2.delete(i)},onError:F})),W=I(()=>j.isPending||z.isPending),J=async re=>{W()||await j.mutateAsync(re)},K=async()=>{W()||await z.mutateAsync()},X=()=>void J(s().map((re,pe)=>l.answers[pe]??[])),te=re=>(l.answers[re]?.length??0)>0?!0:l.customOn[re]===!0&&(l.custom[re]??"").trim().length>0,ve=re=>l.answers[l.tab]?.includes(re)??!1,ne=(re,pe=!1)=>{c("answers",l.tab,[re]),pe&&c("custom",l.tab,re),pe||c("customOn",l.tab,!1),c("editing",!1)},ie=re=>{c("answers",l.tab,(pe=[])=>pe.includes(re)?pe.filter(ye=>ye!==re):[...pe,re])},ke=()=>{if(W())return;if(c("focus",v().length),!x()){c("customOn",l.tab,!0),c("editing",!0),P(b(),!0);return}const re=!w();if(c("customOn",l.tab,re),re){c("editing",!0),P(b(),!0);return}const pe=b().trim();pe&&c("answers",l.tab,(ye=[])=>ye.filter(Re=>Re.trim()!==pe)),c("editing",!1),M(v().length)},ge=()=>{W()||(c("focus",v().length),w()||c("customOn",l.tab,!0),c("editing",!0),P(b(),!0))},Pe=re=>{l.editing||W()||M(l.focus+re)},Me=re=>{if(re.defaultPrevented)return;if(re.key==="Escape"){re.preventDefault(),K();return}if((re.metaKey||re.ctrlKey)&&!re.altKey&&re.key==="Enter"){if(re.repeat)return;re.preventDefault(),ce();return}const ye=re.target instanceof HTMLElement?re.target.closest('[data-slot="question-options"]'):void 0;if(!l.editing&&ye instanceof HTMLElement&&!(re.altKey||re.ctrlKey||re.metaKey)){if(re.key==="ArrowDown"||re.key==="ArrowRight"){re.preventDefault(),Pe(1);return}if(re.key==="ArrowUp"||re.key==="ArrowLeft"){re.preventDefault(),Pe(-1);return}if(re.key==="Home"){re.preventDefault(),M(0);return}re.key==="End"&&(re.preventDefault(),M(k()-1))}},de=re=>{if(W())return;if(re===v().length){ge();return}const pe=v()[re];if(pe){if(x()){c("editing",!1),ie(pe.label);return}ne(pe.label)}},U=()=>{c("editing",!1),P(b()),M(v().length)},He=re=>{re.style.height="0px",re.style.height=`${re.scrollHeight}px`},Ue=re=>{setTimeout(()=>{re.focus(),He(re)},0)},Z=re=>{re.preventDefault(),re.stopPropagation(),ke()},ce=()=>{if(W())return;if(l.editing&&U(),l.tab>=o()-1){X();return}const re=l.tab+1;c("tab",re),c("editing",!1),l.minimized||M(N(re))},G=()=>{if(W()||l.tab<=0)return;const re=l.tab-1;c("tab",re),c("editing",!1),l.minimized||M(N(re))},fe=re=>{W()||(c("tab",re),c("editing",!1),l.minimized||M(N(re)))},xe=()=>{W()||(c("editing",!1),c("minimized",!0))},Oe=()=>{W()||(c("minimized",!1),M(N()))};return(()=>{var re=yXe();return S(re,h(xne,{kind:"question",ref:pe=>u=pe,onKeyDown:Me,get header(){return[(()=>{var pe=bXe();return S(pe,C),pe})(),(()=>{var pe=xXe(),ye=pe.firstChild;return S(pe,h(q,{get when(){return o()>1},get children(){var Re=wXe();return S(Re,h(Dt,{get each(){return s()},children:(Je,Xe)=>(()=>{var je=kXe();return je.$$click=()=>fe(Xe()),he(mt=>{var Et=Xe()===l.tab,Bt=te(Xe()),Qe=W(),Be=`${r.t("ui.tool.questions")} ${Xe()+1}`;return Et!==mt.e&&me(je,"data-active",mt.e=Et),Bt!==mt.t&&me(je,"data-answered",mt.t=Bt),Qe!==mt.a&&(je.disabled=mt.a=Qe),Be!==mt.o&&me(je,"aria-label",mt.o=Be),mt},{e:void 0,t:void 0,a:void 0,o:void 0}),je})()})),Re}}),ye),cn(ye,"click",l.minimized?Oe:xe,!0),S(ye,h(Yt,{name:"chevron-down",size:"small"})),he(Re=>{var Je=W(),Xe=`rotate(${$()*180}deg)`,je=r.t(l.minimized?"session.question.restore":"session.question.minimize");return Je!==Re.e&&(ye.disabled=Re.e=Je),Xe!==Re.t&&Ct(ye,"transform",Re.t=Xe),je!==Re.a&&me(ye,"aria-label",Re.a=je),Re},{e:void 0,t:void 0,a:void 0}),pe})()]},get footer(){return[h(Kt,{variant:"ghost",size:"large",get disabled(){return W()},onClick:K,"aria-keyshortcuts":"Escape",get children(){return r.t("ui.common.dismiss")}}),(()=>{var pe=SXe();return S(pe,h(q,{get when(){return l.tab>0},get children(){return h(Kt,{variant:"secondary",size:"large",get disabled(){return W()},onClick:G,get children(){return r.t("ui.common.back")}})}}),null),S(pe,h(Kt,{get variant(){return L()?"primary":"secondary"},size:"large",get disabled(){return W()},onClick:ce,"aria-keyshortcuts":"Meta+Enter Control+Enter",get children(){return we(()=>!!L())()?r.t("ui.common.submit"):r.t("ui.common.next")}}),null),pe})()]},get children(){return[(()=>{var pe=gXe();return S(pe,()=>y()?.question),he(ye=>{var Re=l.minimized?"-webkit-box":void 0,Je=l.minimized?"3":void 0,Xe=l.minimized?"vertical":void 0,je=l.minimized?"hidden":void 0;return Re!==ye.e&&Ct(pe,"display",ye.e=Re),Je!==ye.t&&Ct(pe,"-webkit-line-clamp",ye.t=Je),Xe!==ye.a&&Ct(pe,"-webkit-box-orient",ye.a=Xe),je!==ye.o&&Ct(pe,"overflow",ye.o=je),ye},{e:void 0,t:void 0,a:void 0,o:void 0}),pe})(),h(q,{get when(){return!l.minimized},get children(){return h(q,{get when(){return x()},get fallback(){return(()=>{var pe=GF();return S(pe,()=>r.t("ui.question.singleHint")),pe})()},get children(){var pe=GF();return S(pe,()=>r.t("ui.question.multiHint")),pe}})}}),(()=>{var pe=vXe();return pt(ye=>d=ye,pe),S(pe,h(Dt,{get each(){return v()},children:(ye,Re)=>h(_Xe,{get multi(){return x()},get picked(){return ve(ye.label)},get label(){return ye.label},get description(){return ye.description},get disabled(){return W()},ref:Je=>m[Re()]=Je,onFocus:()=>c("focus",Re()),onClick:()=>de(Re())})}),null),S(pe,h(q,{get when(){return l.editing},get fallback(){return(()=>{var ye=CXe(),Re=ye.firstChild,Je=Re.firstChild,Xe=Je.nextSibling;ye.$$click=ge,ye.addEventListener("focus",()=>c("focus",v().length));var je=f;return typeof je=="function"?pt(je,ye):f=ye,S(ye,h($C,{get multi(){return x()},get picked(){return w()},onClick:Z}),Re),S(Je,E),S(Xe,()=>b()||_()),he(mt=>{var Et=w(),Bt=x()?"checkbox":"radio",Qe=w(),Be=W();return Et!==mt.e&&me(ye,"data-picked",mt.e=Et),Bt!==mt.t&&me(ye,"role",mt.t=Bt),Qe!==mt.a&&me(ye,"aria-checked",mt.a=Qe),Be!==mt.o&&(ye.disabled=mt.o=Be),mt},{e:void 0,t:void 0,a:void 0,o:void 0}),ye})()},get children(){var ye=pXe(),Re=ye.firstChild,Je=Re.firstChild,Xe=Je.nextSibling;return ye.addEventListener("submit",je=>{je.preventDefault(),U()}),ye.$$mousedown=je=>{if(W()){je.preventDefault();return}if(je.target instanceof HTMLTextAreaElement)return;const mt=je.currentTarget.querySelector('[data-slot="question-custom-input"]');mt instanceof HTMLTextAreaElement&&mt.focus()},S(ye,h($C,{get multi(){return x()},get picked(){return w()},onClick:Z}),Re),S(Je,E),Xe.$$input=je=>{P(je.currentTarget.value),He(je.currentTarget)},Xe.$$keydown=je=>{if(je.key==="Escape"){je.preventDefault(),c("editing",!1),M(v().length);return}(je.metaKey||je.ctrlKey)&&!je.altKey||je.key!=="Enter"||je.shiftKey||(je.preventDefault(),U())},pt(Ue,Xe),he(je=>{var mt=w(),Et=x()?"checkbox":"radio",Bt=w(),Qe=_(),Be=W();return mt!==je.e&&me(ye,"data-picked",je.e=mt),Et!==je.t&&me(ye,"role",je.t=Et),Bt!==je.a&&me(ye,"aria-checked",je.a=Bt),Qe!==je.o&&me(Xe,"placeholder",je.o=Qe),Be!==je.i&&(Xe.disabled=je.i=Be),je},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),he(()=>Xe.value=b()),ye}}),null),he(ye=>{var Re=l.minimized||V()?"true":void 0,Je=$()>.1,Xe=`${Math.max(0,l.optionsHeight*(1-$()))}px`,je=`${Math.max(0,Math.min(1,1-$()))}`,mt=V()?"hidden":"visible";return Re!==ye.e&&me(pe,"aria-hidden",ye.e=Re),Je!==ye.t&&pe.classList.toggle("pointer-events-none",ye.t=Je),Xe!==ye.a&&Ct(pe,"max-height",ye.a=Xe),je!==ye.o&&Ct(pe,"opacity",ye.o=je),mt!==ye.i&&Ct(pe,"visibility",ye.i=mt),ye},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),pe})()]}})),re})()};dn(["click","mousedown","keydown","input"]);var EXe=A('<span class="min-w-0 flex-1 truncate text-13-regular text-text-base cursor-default">'),IXe=A('<div class="pl-3 pr-2 py-2 flex items-center gap-2"role=button tabindex=0><span class="shrink-0 text-13-medium text-text-strong cursor-default"></span><div class="ml-auto shrink-0">'),DXe=A("<div class=h-5 aria-hidden=true>"),LXe=A('<div class="px-3 pb-7 flex flex-col gap-1.5 max-h-42 overflow-y-auto no-scrollbar">'),AXe=A('<div class="flex items-center gap-2 min-w-0 py-1"><span class="min-w-0 flex-1 truncate text-13-regular text-text-strong">');function MXe(e){const t=wt(),[n,r]=Ze({collapsed:!1}),i=()=>r("collapsed",l=>!l),s=I(()=>e.items.length),o=I(()=>t.t(s()===1?"session.followupDock.summary.one":"session.followupDock.summary.other",{count:s()})),a=I(()=>e.items[0]?.text??"");return h(yy,{"data-component":"session-followup-dock",style:{"margin-bottom":"-0.875rem","border-bottom-left-radius":0,"border-bottom-right-radius":0},get children(){return[(()=>{var l=IXe(),c=l.firstChild,u=c.nextSibling;return l.$$keydown=d=>{d.key!=="Enter"&&d.key!==" "||(d.preventDefault(),i())},l.$$click=i,S(c,o),S(l,h(q,{get when(){return we(()=>!!n.collapsed)()&&a()},get children(){var d=EXe();return S(d,a),d}}),u),S(u,h(Ln,{get"data-collapsed"(){return n.collapsed?"true":"false"},icon:"chevron-down",size:"normal",variant:"ghost",get style(){return{transform:`rotate(${n.collapsed?180:0}deg)`}},onMouseDown:d=>{d.preventDefault(),d.stopPropagation()},onClick:d=>{d.stopPropagation(),i()},get"aria-label"(){return we(()=>!!n.collapsed)()?t.t("session.followupDock.expand"):t.t("session.followupDock.collapse")}})),l})(),h(q,{get when(){return n.collapsed},get children(){return DXe()}}),h(q,{get when(){return!n.collapsed},get children(){var l=LXe();return S(l,h(Dt,{get each(){return e.items},children:c=>(()=>{var u=AXe(),d=u.firstChild;return S(d,()=>c.text),S(u,h(Kt,{size:"small",variant:"secondary",class:"shrink-0",get disabled(){return!!e.sending},onClick:()=>e.onSend(c.id),get children(){return t.t("session.followupDock.sendNow")}}),null),S(u,h(Kt,{size:"small",variant:"ghost",class:"shrink-0",get disabled(){return!!e.sending},onClick:()=>e.onEdit(c.id),get children(){return t.t("session.followupDock.edit")}}),null),u})()})),l}})]}})}dn(["click","keydown"]);var $Xe=A('<span class="min-w-0 flex-1 truncate cursor-default text-[13px] font-[440] leading-5 tracking-[-0.04px] text-v2-text-text-faint">'),ZF=A("<div class=h-[18px] aria-hidden=true>"),PXe=A('<div class="flex max-h-42 flex-col gap-2 overflow-y-auto px-4 pt-px pb-3 no-scrollbar">'),OXe=A('<div data-component=session-revert-dock class="w-full overflow-hidden rounded-xl border-[0.5px] border-v2-border-border-base bg-v2-background-bg-layer-01"><div class="flex h-[42px] items-center gap-2 pl-4 pr-2"role=button tabindex=0><span></span><div class="ml-auto shrink-0">'),RXe=A('<span class="min-w-0 flex-1 truncate text-14-regular text-text-base cursor-default">'),FXe=A('<div class="pl-3 pr-2 py-2 flex items-center gap-2"role=button tabindex=0><span class="shrink-0 text-14-regular text-text-strong cursor-default"></span><div class="ml-auto shrink-0">'),NXe=A("<div class=h-5 aria-hidden=true>"),VXe=A('<div class="px-3 pb-7 flex flex-col gap-1.5 max-h-42 overflow-y-auto no-scrollbar">'),zXe=A('<div class="flex items-center gap-2 min-w-0 py-1"><span class="min-w-0 flex-1 truncate text-13-regular text-text-strong">'),HXe=A('<div class="flex h-6 min-w-0 items-center gap-2"><span class="min-w-0 flex-1 truncate text-[13px] font-[400] leading-5 tracking-[-0.04px] text-v2-text-text-muted">');function YF(e){const t=wt(),n=ar(),[r,i]=Ze({collapsed:!0});ae(()=>{e.items.length,e.items[0]?.id,i("collapsed",!0)});const s=()=>i("collapsed",u=>!u),o=I(()=>e.items.length),a=I(()=>t.t(o()===1?"session.revertDock.summary.one":"session.revertDock.summary.other",{count:o()})),l=I(()=>e.items[0]?.text??""),c=u=>{u.key!=="Enter"&&u.key!==" "||(u.preventDefault(),s())};return h(q,{get when(){return n.general.newLayoutDesigns()},get fallback(){return h(yy,{"data-component":"session-revert-dock",get children(){return[(()=>{var u=FXe(),d=u.firstChild,f=d.nextSibling;return u.$$keydown=c,u.$$click=s,S(d,a),S(u,h(q,{get when(){return we(()=>!!r.collapsed)()&&l()},get children(){var m=RXe();return S(m,l),m}}),f),S(f,h(Ln,{icon:"chevron-down",size:"normal",variant:"ghost",get style(){return{transform:`rotate(${r.collapsed?180:0}deg)`}},onMouseDown:m=>{m.preventDefault(),m.stopPropagation()},onClick:m=>{m.stopPropagation(),s()},get"aria-label"(){return we(()=>!!r.collapsed)()?t.t("session.revertDock.expand"):t.t("session.revertDock.collapse")}})),u})(),h(q,{get when(){return r.collapsed},get children(){return NXe()}}),h(q,{get when(){return!r.collapsed},get children(){var u=VXe();return S(u,h(Dt,{get each(){return e.items},children:d=>(()=>{var f=zXe(),m=f.firstChild;return S(m,()=>d.text),S(f,h(Kt,{size:"small",variant:"secondary",class:"shrink-0",get disabled(){return e.disabled||!!e.restoring},onClick:()=>e.onRestore(d.id),get children(){return t.t("session.revertDock.restore")}}),null),f})()})),u}})]}})},get children(){var u=OXe(),d=u.firstChild,f=d.firstChild,m=f.nextSibling;return d.$$keydown=c,d.$$click=s,S(d,h(on,{name:"outline-reset",size:"normal",class:"text-v2-icon-icon-muted"}),f),S(f,a),S(d,h(q,{get when(){return we(()=>!!r.collapsed)()&&l()},get children(){var g=$Xe();return S(g,l),g}}),m),S(m,h(Lr,{get icon(){return h(on,{name:"outline-chevron-down",size:"small"})},size:"large",variant:"ghost-muted",get style(){return{transform:`rotate(${r.collapsed?180:0}deg)`}},onMouseDown:g=>{g.preventDefault(),g.stopPropagation()},onClick:g=>{g.stopPropagation(),s()},get"aria-label"(){return we(()=>!!r.collapsed)()?t.t("session.revertDock.expand"):t.t("session.revertDock.collapse")}})),S(u,h(q,{get when(){return r.collapsed},get children(){return ZF()}}),null),S(u,h(q,{get when(){return!r.collapsed},get children(){return[(()=>{var g=PXe();return S(g,h(Dt,{get each(){return e.items},children:p=>(()=>{var y=HXe(),v=y.firstChild;return S(v,()=>p.text),S(y,h(as,{size:"small",variant:"neutral",class:"shrink-0",get disabled(){return e.disabled||!!e.restoring},onClick:()=>e.onRestore(p.id),get children(){return t.t("session.revertDock.restore")}}),null),y})()})),g})(),ZF()]}}),null),he(g=>ct(f,{"font-[440] shrink-0 cursor-default text-[13px] leading-5 tracking-[-0.04px]":!0,"text-v2-text-text-base":!r.collapsed,"text-v2-text-text-muted":r.collapsed},g)),u}})}dn(["click","keydown"]);var jXe=A('<span data-slot=animated-number-digit><span data-slot=animated-number-strip style="--animated-number-duration:var(--tool-motion-odometer-ms, 600ms)">'),qXe=A("<span data-slot=animated-number-cell>"),BXe=A("<span data-component=animated-number><span data-slot=animated-number-value>");const UXe=Array.from({length:30},(e,t)=>t%10);function WXe(e){return(e%10+10)%10}function KXe(e,t,n){return e===t?0:n>0?(t-e+10)%10:-((e-t+10)%10)}function GXe(e){const[t,n]=Ze({step:e.value+10,animating:!1}),r=()=>t.step,i=()=>t.animating;let s=e.value;return ae(vt(()=>e.value,o=>{const a=KXe(s,o,e.direction);if(s=o,!a){n("animating",!1),n("step",o+10);return}n("animating",!0),n("step",l=>l+a)},{defer:!0})),(()=>{var o=jXe(),a=o.firstChild;return a.addEventListener("transitionend",()=>{n("animating",!1),n("step",l=>WXe(l)+10)}),S(a,h(Dt,{each:UXe,children:l=>(()=>{var c=qXe();return S(c,l),c})()})),he(l=>{var c=i()?"true":"false",u=`${r()}`;return c!==l.e&&me(a,"data-animating",l.e=c),u!==l.t&&Ct(a,"--animated-number-offset",l.t=u),l},{e:void 0,t:void 0}),o})()}function PC(e){const t=I(()=>Number.isFinite(e.value)?Math.max(0,Math.round(e.value)):0),[n,r]=Ze({value:t(),direction:1}),i=()=>n.value,s=()=>n.direction;ae(vt(t,c=>{const u=i();c!==u&&(r("direction",c>u?1:-1),r("value",c))},{defer:!0}));const o=I(()=>i().toString()),a=I(()=>Array.from(o(),c=>{const u=c.charCodeAt(0)-48;return u<0||u>9?0:u}).reverse()),l=I(()=>`${a().length}ch`);return(()=>{var c=BXe(),u=c.firstChild;return S(u,h(nh,{get each(){return a()},children:d=>h(GXe,{get value(){return d()},get direction(){return s()}})})),he(d=>{var f=e.class,m=o(),g=l();return f!==d.e&&xr(c,d.e=f),m!==d.t&&me(c,"aria-label",d.t=m),g!==d.a&&Ct(u,"--animated-number-width",d.a=g),d},{e:void 0,t:void 0,a:void 0}),c})()}var ZXe={};ds(ZXe,{Checkbox:()=>zu,Control:()=>Sne,Description:()=>Cne,ErrorMessage:()=>_ne,Indicator:()=>Tne,Input:()=>Ene,Label:()=>Ine,Root:()=>Dne,useCheckboxContext:()=>Eh});var kne=bn();function Eh(){const e=hn(kne);if(e===void 0)throw new Error("[kobalte]: `useCheckboxContext` must be used within a `Checkbox` component");return e}function Sne(e){const t=ma(),n=Eh(),r=Mt({id:n.generateId("control")},e),[i,s]=Ee(r,["onClick","onKeyDown"]);return h(Xt,le({as:"div",onClick:l=>{Nt(l,i.onClick),n.toggle(),n.inputRef()?.focus()},onKeyDown:l=>{Nt(l,i.onKeyDown),l.key===Kx.Space&&(n.toggle(),n.inputRef()?.focus())}},()=>t.dataset(),()=>n.dataset(),s))}function Cne(e){const t=Eh();return h(Od,le(()=>t.dataset(),e))}function _ne(e){const t=Eh();return h(Rd,le(()=>t.dataset(),e))}function Tne(e){const t=ma(),n=Eh(),[r,i]=De(),s=Mt({id:n.generateId("indicator")},e),[o,a]=Ee(s,["ref","forceMount"]),{present:l}=Va({show:()=>o.forceMount||n.indeterminate()||n.checked(),element:()=>r()??null});return h(q,{get when(){return l()},get children(){return h(Xt,le({as:"div",ref(c){var u=Cn(i,o.ref);typeof u=="function"&&u(c)}},()=>t.dataset(),()=>n.dataset(),a))}})}function Ene(e){let t;const n=ma(),r=Eh(),i=Mt({id:r.generateId("input")},e),[s,o,a]=Ee(i,["ref","style","onChange","onFocus","onBlur"],jE),{fieldProps:l}=qE(o),[c,u]=De(!1),d=g=>{if(Nt(g,s.onChange),g.stopPropagation(),!c()){const p=g.target;r.setIsChecked(p.checked),p.checked=r.checked()}u(!1)},f=g=>{Nt(g,s.onFocus),r.setIsFocused(!0)},m=g=>{Nt(g,s.onBlur),r.setIsFocused(!1)};return ae(vt([()=>r.checked(),()=>r.value()],()=>{u(!0),t?.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!0})),t?.dispatchEvent(new Event("change",{bubbles:!0,cancelable:!0}))},{defer:!0})),ae(vt([()=>t,()=>r.indeterminate(),()=>r.checked()],([g,p])=>{g&&(g.indeterminate=p)})),h(Xt,le({as:"input",ref(g){var p=Cn(y=>{r.setInputRef(y),t=y},s.ref);typeof p=="function"&&p(g)},type:"checkbox",get id(){return l.id()},get name(){return n.name()},get value(){return r.value()},get checked(){return r.checked()},get required(){return n.isRequired()},get disabled(){return n.isDisabled()},get readonly(){return n.isReadOnly()},get style(){return cs(Gx,s.style)},get"aria-label"(){return l.ariaLabel()},get"aria-labelledby"(){return l.ariaLabelledBy()},get"aria-describedby"(){return l.ariaDescribedBy()},get"aria-invalid"(){return n.validationState()==="invalid"||void 0},get"aria-required"(){return n.isRequired()},get"aria-disabled"(){return n.isDisabled()},get"aria-readonly"(){return n.isReadOnly()},onChange:d,onFocus:f,onBlur:m},()=>n.dataset(),()=>r.dataset(),a))}function Ine(e){const t=Eh();return h(cy,le(()=>t.dataset(),e))}function Dne(e){let t;const n=`checkbox-${nr()}`,r=Mt({value:"on",id:n},e),[i,s,o]=Ee(r,["ref","children","value","checked","defaultChecked","indeterminate","onChange","onPointerDown"],jk),[a,l]=De(),[c,u]=De(!1),{formControlContext:d}=qk(s),f=HZ({isSelected:()=>i.checked,defaultIsSelected:()=>i.defaultChecked,onSelectedChange:y=>i.onChange?.(y),isDisabled:()=>d.isDisabled(),isReadOnly:()=>d.isReadOnly()});uy(()=>t,()=>f.setIsSelected(i.defaultChecked??!1));const m=y=>{Nt(y,i.onPointerDown),c()&&y.preventDefault()},g=I(()=>({"data-checked":f.isSelected()?"":void 0,"data-indeterminate":i.indeterminate?"":void 0})),p={value:()=>i.value,dataset:g,checked:()=>f.isSelected(),indeterminate:()=>i.indeterminate??!1,inputRef:a,generateId:us(()=>We(s.id)),toggle:()=>f.toggle(),setIsChecked:y=>f.setIsSelected(y),setIsFocused:u,setInputRef:l};return h(ly.Provider,{value:d,get children(){return h(kne.Provider,{value:p,get children(){return h(Xt,le({as:"div",ref(y){var v=Cn(b=>t=b,i.ref);typeof v=="function"&&v(y)},role:"group",get id(){return We(s.id)},onPointerDown:m},()=>d.dataset(),g,o,{get children(){return h(YXe,{state:p,get children(){return i.children}})}}))}})}})}function YXe(e){const t=Jl(()=>{const n=e.children;return w1(n)?n(e.state):n});return we(t)}var zu=Object.assign(Dne,{Control:Sne,Description:Cne,ErrorMessage:_ne,Indicator:Tne,Input:Ene,Label:Ine}),XXe=A("<div data-slot=checkbox-checkbox-content>"),QXe=A('<svg viewBox="0 0 12 12"fill=none width=10 height=10 xmlns=http://www.w3.org/2000/svg><path d="M3 7.17905L5.02703 8.85135L9 3.5"stroke=currentColor stroke-width=1.5 stroke-linecap=square>');function Lne(e){const[t,n]=Ee(e,["children","class","label","hideLabel","description","icon"]);return h(zu,le(n,{"data-component":"checkbox",get children(){return[h(zu.Input,{"data-slot":"checkbox-checkbox-input"}),h(zu.Control,{"data-slot":"checkbox-checkbox-control",get children(){return h(zu.Indicator,{"data-slot":"checkbox-checkbox-indicator",get children(){return t.icon||QXe()}})}}),(()=>{var r=XXe();return S(r,h(q,{get when(){return e.children},get children(){return h(zu.Label,{"data-slot":"checkbox-checkbox-label",get classList(){return{"sr-only":t.hideLabel}},get children(){return e.children}})}}),null),S(r,h(q,{get when(){return t.description},get children(){return h(zu.Description,{"data-slot":"checkbox-checkbox-description",get children(){return t.description}})}}),null),S(r,h(zu.ErrorMessage,{"data-slot":"checkbox-checkbox-error"}),null),r})()]}}))}var JXe=A("<span data-component=text-reveal><span data-slot=text-reveal-track><span data-slot=text-reveal-entering></span><span data-slot=text-reveal-leaving>");const eQe=(e,t)=>typeof e=="number"?`${e}px`:typeof e=="string"?e:`${t}px`,tQe=(e,t)=>typeof e=="number"?`${e}ms`:typeof e=="string"?e:`${t}ms`,nQe=(e,t)=>`${e??t}%`;function Ane(e){const[t,n]=Ze({cur:e.text,old:void 0,width:"auto",ready:!1,swapping:!1}),r=()=>t.cur,i=()=>t.old,s=()=>t.width,o=()=>t.ready,a=()=>t.swapping;let l,c,u,d;const f=()=>l?.scrollWidth??0,m=()=>c?.scrollWidth??0,g=p=>{if(!(p<=0)){if(e.growOnly??!0){const y=Number.parseFloat(s());if(Number.isFinite(y)&&p<=y)return}n("width",`${p}px`)}};return ae(vt(()=>e.text,(p,y)=>{if(p!==y){if(typeof p=="string"&&typeof y=="string"&&p.startsWith(y)){n("cur",p),g(f());return}if(n("swapping",!0),n("old",y),n("cur",p),typeof requestAnimationFrame!="function"){g(Math.max(f(),m())),u?.offsetHeight,n("swapping",!1);return}d!==void 0&&typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(d),d=requestAnimationFrame(()=>{g(Math.max(f(),m())),u?.offsetHeight,n("swapping",!1),d=void 0})}})),sn(()=>{g(f());const p=typeof document<"u"?document.fonts:void 0;if(typeof requestAnimationFrame!="function"){n("ready",!0);return}if(!p){requestAnimationFrame(()=>n("ready",!0));return}p.ready.finally(()=>{g(f()),requestAnimationFrame(()=>n("ready",!0))})}),Te(()=>{d===void 0||typeof cancelAnimationFrame!="function"||cancelAnimationFrame(d)}),(()=>{var p=JXe(),y=p.firstChild,v=y.firstChild,b=v.nextSibling,w=u;typeof w=="function"?pt(w,p):u=p;var x=l;typeof x=="function"?pt(x,v):l=v,S(v,()=>r()??" ");var k=c;return typeof k=="function"?pt(k,b):c=b,S(b,()=>i()??" "),he(C=>{var E=o()?"true":"false",_=a()?"true":"false",L=e.truncate?"true":"false",O=e.class,$=e.text??"",V=tQe(e.duration,450),P=nQe(e.edge,17),T=eQe(e.travel,0),D=e.spring??"cubic-bezier(0.34, 1.08, 0.64, 1)",N=e.springSoft??"cubic-bezier(0.34, 1, 0.64, 1)",M=e.truncate?"100%":s();return E!==C.e&&me(p,"data-ready",C.e=E),_!==C.t&&me(p,"data-swapping",C.t=_),L!==C.a&&me(p,"data-truncate",C.a=L),O!==C.o&&xr(p,C.o=O),$!==C.i&&me(p,"aria-label",C.i=$),V!==C.n&&Ct(p,"--text-reveal-duration",C.n=V),P!==C.s&&Ct(p,"--text-reveal-edge",C.s=P),T!==C.h&&Ct(p,"--text-reveal-travel",C.h=T),D!==C.r&&Ct(p,"--text-reveal-spring",C.r=D),N!==C.d&&Ct(p,"--text-reveal-spring-soft",C.d=N),M!==C.l&&Ct(y,"width",C.l=M),C},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0,l:void 0}),p})()}var rQe=A('<span data-component=text-strikethrough style=display:grid><span style="grid-area:1 / 1"></span><span aria-hidden=true style="grid-area:1 / 1;text-decoration:line-through;pointer-events:none">');function iQe(e){const t=vy(()=>e.active?1:0,()=>({visualDuration:e.visualDuration??.35,bounce:0}));let n,r;const[i,s]=Ze({textWidth:0,containerWidth:0}),o=()=>i.textWidth,a=()=>i.containerWidth,l=()=>{n&&s("textWidth",n.scrollWidth),r&&s("containerWidth",r.offsetWidth)};sn(l),k4(()=>r,l);const c=()=>{const f=o();return f>0?t()*f:0},u=()=>{const f=a(),m=o();return f<=0||m<=0?`inset(0 ${(1-t())*100}% 0 0)`:`inset(0 ${Math.max(0,f-c())}px 0 0)`},d=()=>{const f=c();return f<=.5?"none":`inset(0 0 0 ${f}px)`};return(()=>{var f=rQe(),m=f.firstChild,g=m.nextSibling,p=r;typeof p=="function"?pt(p,f):r=f;var y=n;return typeof y=="function"?pt(y,m):n=m,S(m,()=>e.text),S(g,()=>e.text),he(v=>{var b=e.class,w={...e.style},x=d(),k=u();return b!==v.e&&xr(f,v.e=b),v.t=So(f,w,v.t),x!==v.a&&Ct(m,"clip-path",v.a=x),k!==v.o&&Ct(g,"clip-path",v.o=k),v},{e:void 0,t:void 0,a:void 0,o:void 0}),f})()}var sQe=A('<svg viewBox="0 0 12 12"width=12 height=12 fill=currentColor xmlns=http://www.w3.org/2000/svg class=block><circle cx=6 cy=6 r=3 style=animation:var(--animate-pulse-scale);transform-origin:center;transform-box:fill-box>'),oQe=A('<div><div data-action=session-todo-toggle role=button tabindex=0><span style=--tool-motion-odometer-ms:600ms;--tool-motion-mask:18%;--tool-motion-mask-height:0px;--tool-motion-spring-ms:560ms;white-space:pre></span><div data-slot=session-todo-preview class="ml-1 min-w-0 overflow-hidden"style="flex:1 1 auto;max-width:100%"></div><div class=ml-auto></div></div><div data-slot=session-todo-list>'),aQe=A("<span>"),lQe=A('<div class=relative><div class="px-3 pb-11 flex flex-col gap-1.5 max-h-42 overflow-y-auto no-scrollbar"style=overflow-anchor:none></div><div class="pointer-events-none absolute top-0 left-0 right-0 h-4 transition-opacity duration-150"style="background:linear-gradient(to bottom, var(--background-base), transparent)">');const XF="\0done\0",QF="\0total\0";function cQe(e){if(e==="in_progress")return(()=>{var t=sQe();return t.firstChild,t})()}function uQe(e){const t=wt(),n=ar(),[r,i]=Ze({height:78}),s=I(()=>e.todos.length),o=I(()=>e.todos.filter(x=>x.status==="completed").length),a=I(()=>t.t("session.todo.progress",{done:o(),total:s()})),l=I(()=>t.t("session.todo.progress",{done:XF,total:QF}).split(/(\u0000done\u0000|\u0000total\u0000)/)),c=I(()=>e.todos.find(x=>x.status==="in_progress")??e.todos.find(x=>x.status==="pending")??e.todos.filter(x=>x.status==="completed").at(-1)??e.todos[0]),u=I(()=>c()?.content??""),d=vy(()=>e.collapsed?1:0,{visualDuration:.3,bounce:0}),f=I(()=>Math.max(0,Math.min(1,e.dockProgress))),m=I(()=>1-f()),g=I(()=>Math.max(0,Math.min(1,d()))),p=I(()=>Math.max(g(),m())),y=I(()=>p()>.98),v=I(()=>Math.max(0,Math.min(1,g()))),b=I(()=>Math.max(78,r.height));let w;return ae(()=>{const x=w;if(!x)return;const k=()=>{i("height",C=>Math.max(C,x.scrollHeight))};k(),Oa(x,k)}),h(Gi,{get component(){return n.general.newLayoutDesigns()?"div":yy},"data-component":"session-todo-dock",get classList(){return{"w-full overflow-hidden rounded-xl border-[0.5px] border-v2-border-border-base bg-v2-background-bg-layer-01":n.general.newLayoutDesigns()}},get style(){return{"overflow-x":"visible","overflow-y":"hidden","max-height":`${Math.max(78,b()-g()*(b()-78))}px`}},get children(){var x=oQe(),k=x.firstChild,C=k.firstChild,E=C.nextSibling,_=E.nextSibling,L=k.nextSibling,O=w;return typeof O=="function"?pt(O,x):w=x,k.$$keydown=$=>{$.key!=="Enter"&&$.key!==" "||($.preventDefault(),e.onToggle())},cn(k,"click",e.onToggle,!0),S(C,h(nh,{get each(){return l()},children:$=>$()===XF?h(PC,{get value(){return o()}}):$()===QF?h(PC,{get value(){return s()}}):(()=>{var V=aQe();return S(V,$),V})()})),S(E,h(Ane,{get class(){return n.general.newLayoutDesigns()?"cursor-default text-[13px] font-[440] leading-5 tracking-[-0.04px] text-v2-text-text-faint":"text-14-regular text-text-base cursor-default"},get text(){return we(()=>!!e.collapsed)()?u():void 0},duration:600,travel:25,edge:17,spring:"cubic-bezier(0.34, 1, 0.64, 1)",springSoft:"cubic-bezier(0.34, 1, 0.64, 1)",growOnly:!0,truncate:!0})),S(_,h(Ln,{"data-action":"session-todo-toggle-button",get"data-collapsed"(){return e.collapsed?"true":"false"},icon:"chevron-down",size:"normal",variant:"ghost",get style(){return{transform:`rotate(${v()*180}deg)`}},onMouseDown:$=>{$.preventDefault(),$.stopPropagation()},onClick:$=>{$.stopPropagation(),e.onToggle()},get"aria-label"(){return we(()=>!!e.collapsed)()?e.expandLabel:e.collapseLabel}})),S(L,h(dQe,{get todos(){return e.todos}})),he($=>{var V={"flex items-center gap-2 overflow-visible":!0,"h-[42px] pl-4 pr-2":n.general.newLayoutDesigns(),"pl-3 pr-2 py-2":!n.general.newLayoutDesigns()},P={"cursor-default inline-flex items-baseline shrink-0 overflow-visible":!0,"font-[440] text-[13px] leading-5 tracking-[-0.04px] text-v2-text-text-muted":n.general.newLayoutDesigns(),"text-14-regular text-text-strong":!n.general.newLayoutDesigns()},T=a(),D=`${Math.max(0,Math.min(1,1-m()))}`,N=e.collapsed||y(),M=p()>.1,F=y()?"hidden":"visible",j=`${Math.max(0,Math.min(1,1-p()))}`;return $.e=ct(k,V,$.e),$.t=ct(C,P,$.t),T!==$.a&&me(C,"aria-label",$.a=T),D!==$.o&&Ct(C,"opacity",$.o=D),N!==$.i&&me(L,"aria-hidden",$.i=N),M!==$.n&&L.classList.toggle("pointer-events-none",$.n=M),F!==$.s&&Ct(L,"visibility",$.s=F),j!==$.h&&Ct(L,"opacity",$.h=j),$},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0}),x}})}function dQe(e){const[t,n]=Ze({stuck:!1});return(()=>{var r=lQe(),i=r.firstChild,s=i.nextSibling;return i.addEventListener("scroll",o=>{n("stuck",o.currentTarget.scrollTop>0)}),S(i,h(nh,{get each(){return e.todos},children:o=>h(Lne,{readOnly:!0,get checked(){return o().status==="completed"},get indeterminate(){return o().status==="in_progress"},get"data-in-progress"(){return o().status==="in_progress"?"":void 0},get"data-state"(){return o().status},get icon(){return cQe(o().status)},get style(){return{"--checkbox-align":"flex-start","--checkbox-offset":"1px",transition:"opacity 220ms var(--tool-motion-ease, cubic-bezier(0.22, 1, 0.36, 1))",opacity:o().status==="pending"?"0.94":"1"}},get children(){return h(iQe,{get active(){return o().status==="completed"||o().status==="cancelled"},get text(){return o().content},class:"text-14-regular min-w-0 break-words",get style(){return{"line-height":"var(--line-height-normal)",transition:"color 220ms var(--tool-motion-ease, cubic-bezier(0.22, 1, 0.36, 1)), opacity 220ms var(--tool-motion-ease, cubic-bezier(0.22, 1, 0.36, 1))",color:o().status==="completed"||o().status==="cancelled"?"var(--text-weak)":"var(--text-strong)",opacity:o().status==="pending"?"0.92":"1"}}})}})})),he(o=>Ct(s,"opacity",t.stuck?1:0)),r})()}dn(["click","keydown"]);var fQe=A("<div class=overflow-hidden><div>"),hQe=A('<button type=button class="text-text-base transition-colors hover:text-text-strong">'),mQe=A('<div class="w-full rounded-[12px] border border-border-weak-base bg-background-base p-3 text-16-regular text-text-weak"><span> '),t2=A("<div>"),gQe=A("<div data-component=session-prompt-dock><div>"),pQe=A('<div class="w-full min-h-32 md:min-h-40 rounded-md border border-border-weak-base bg-background-base/50 px-4 py-3 text-text-weak whitespace-pre-wrap pointer-events-none">'),vQe=A("<div class=pb-2>");function yQe(e){const t=wt(),n=e.controller,r=ar(),i=()=>{const s=n.revert();return s?.items.length?s:void 0};return(()=>{var s=gQe(),o=s.firstChild,a=n.setDockRef;return typeof a=="function"?pt(a,s):n.setDockRef=s,S(o,h(q,{get when(){return n.state.questionRequest()},keyed:!0,children:l=>(()=>{var c=t2();return S(c,h(TXe,{request:l,get onSubmit(){return n.onResponseSubmit}})),c})()}),null),S(o,h(q,{get when(){return n.state.permissionRequest()},keyed:!0,children:l=>(()=>{var c=t2();return S(c,h(uXe,{request:l,get responding(){return n.state.permissionResponding()},onDecide:u=>{n.onResponseSubmit(),n.state.decide(u)}})),c})()}),null),S(o,h(q,{get when(){return n.showComposer()},get children(){return[h(q,{get when(){return n.dock()},get children(){var l=fQe(),c=l.firstChild,u=n.setDockBodyRef;return typeof u=="function"?pt(u,c):n.setDockBodyRef=c,S(c,h(uQe,{get todos(){return n.state.todos()},get collapsed(){return n.todo.collapsed()},get onToggle(){return n.todo.onToggle},get collapseLabel(){return t.t("session.todo.collapse")},get expandLabel(){return t.t("session.todo.expand")},get dockProgress(){return n.dockProgress()}})),he(d=>{var f=n.dockProgress()<.98,m=`${n.dockHeight()*n.dockProgress()}px`;return f!==d.e&&l.classList.toggle("pointer-events-none",d.e=f),m!==d.t&&Ct(l,"max-height",d.t=m),d},{e:void 0,t:void 0}),l}}),h(q,{get when(){return n.promptReady()},get fallback(){return[h(q,{get when(){return i()},keyed:!0,children:l=>(()=>{var c=vQe();return S(c,h(YF,{get items(){return l.items},get restoring(){return l.restoring},get disabled(){return l.disabled},get onRestore(){return l.onRestore}})),c})()}),(()=>{var l=pQe();return S(l,()=>n.handoffPrompt()||t.t("prompt.loading")),he(c=>Ct(l,"margin-top",`${-36*n.dockProgress()}px`)),l})()]},get children(){return[h(q,{get when(){return i()},keyed:!0,children:l=>(()=>{var c=t2();return S(c,h(YF,{get items(){return l.items},get restoring(){return l.restoring},get disabled(){return l.disabled},get onRestore(){return l.onRestore}})),he(u=>Ct(c,"margin-top",`${-36*n.dockProgress()}px`)),c})()}),(()=>{var l=t2();return ct(l,{"relative z-[70]":!0}),S(l,h(q,{get when(){return n.followup()?.items.length},get children(){return h(MXe,{get items(){return n.followup().items},get sending(){return n.followup().sending},get onSend(){return n.followup().onSend},get onEdit(){return n.followup().onEdit}})}}),null),S(l,h(q,{get when(){return n.child()},get fallback(){return h(q,{get when(){return!n.state.blocked()},get children(){return e.promptInput}})},get children(){var c=mQe(),u=c.firstChild,d=u.firstChild,f=n.setPromptRef;return typeof f=="function"?pt(f,c):n.setPromptRef=c,S(u,()=>t.t("session.child.promptDisabled"),d),S(c,h(q,{get when(){return n.parentID()},get children(){var m=hQe();return cn(m,"click",n.openParent,!0),S(m,()=>t.t("session.child.backToParent")),m}}),null),c}}),null),he(c=>Ct(l,"margin-top",`${-n.lift()}px`)),l})()]}})]}}),null),he(l=>{var c={"w-full shrink-0 flex flex-col justify-center items-center pb-3 pointer-events-none":!0,"bg-v2-background-bg-base":r.general.newLayoutDesigns(),"bg-background-stronger":!r.general.newLayoutDesigns()},u={"w-full px-3 pointer-events-auto":!0,"md:max-w-200 md:mx-auto 2xl:max-w-[1000px]":n.centered()};return l.e=ct(s,c,l.e),l.t=ct(o,u,l.t),l},{e:void 0,t:void 0}),s})()}dn(["click"]);function bQe(e){const t=li(),n=El(),r=kr(),i=Ji(),s=$d(()=>r().directory),o=t.view(e.sessionKey),a=zp(()=>e.queryOptions.agents(rt(r().directory))),l=zp(()=>e.queryOptions.providers(null)),c=zp(()=>e.queryOptions.providers(rt(r().directory)));return I(()=>({agents:{available:i().data.agent,options:n.agent.list().map(u=>u.name),current:n.agent.current()?.name??"",loading:a.isLoading,visible:n.agent.visible(),select:n.agent.set},model:{selection:e.model??n.model,paid:s.paid().length>0,loading:n.agent.visible()&&a.isLoading||c.isLoading||l.isLoading},session:{id:e.sessionID(),tabs:t.tabs(e.sessionKey),reviewPanel:o.reviewPanel}}))}function Jut(){const e=fs(),t=li(),n=ci(),r=xs(),i=kr(),s=ks(),o=ms(),a=Bk(),[l]=Id(),c=()=>r().server,u=I(()=>o.ensureServerCtx(c())),d=I(()=>n.list.length<=1?l.draftId?u().projects.list():t.projects.list():n.list.flatMap(g=>{const p={key:ut.key(g),name:hd(g)};return o.ensureServerCtx(g).projects.list().map(y=>({...y,server:p}))})),f=(g,p)=>{const y=p?n.list.find(b=>ut.key(b)===p):c();if(l.draftId){if(!y)return;const b=o.ensureServerCtx(y);b.projects.open(g),b.projects.touch(g),s.updateDraft(l.draftId,{server:ut.key(y),directory:g});return}if(!p){t.projects.open(g),n.projects.touch(g),e(`/${yn(g)}/session`);return}if(!y)return;const v=o.ensureServerCtx(y);v.projects.open(g),v.projects.touch(g),n.setActive(ut.key(y)),e(`/${yn(g)}/session`)},m=(g,p)=>{const y=p?n.list.find(v=>ut.key(v)===p):c();y&&a({server:y,title:g,onSelect:v=>{const b=Array.isArray(v)?v[0]:v;b&&f(b,p)}})};return I(()=>({available:d(),directory:i().directory,server:n.list.length>1?ut.key(c()):void 0,select:f,add:m}))}const JF=e=>e.count===0?"hide":e.live?e.done?"close":"open":"clear",eN=e=>e==="open";function wQe(e){const t=Br(),n=kr(),r=Ji(),i=Di(),s=wt(),o=mu(),a=I(()=>WQ(r().data.session,r().data.question,t.id)),l=I(()=>zE(r().data.session,r().data.permission,t.id,C=>!o.autoResponds(C,n().directory))),c=I(()=>t.id?!!l()||!!a():!1),u=I(()=>{const C=t.id;return C?i().session.data.todo[C]??[]:[]}),d=I(()=>u().length>0&&u().every(C=>C.status==="completed"||C.status==="cancelled")),f=I(()=>r().data.session_working(t.id??"")||c()),[m,g]=Ze({sessionID:t.id,responding:void 0,dock:u().length>0&&!d()&&f(),closing:!1,opening:!1}),p=I(()=>{const C=l();return C?m.responding===C.id:!1}),y=C=>{const E=l();E&&m.responding!==E.id&&(g("responding",E.id),n().api.permission.reply({sessionID:E.sessionID,requestID:E.id,reply:C}).catch(_=>{const L=_ instanceof Error?_.message:String(_);tn({title:s.t("common.requestFailed"),description:L})}).finally(()=>{g("responding",_=>_===E.id?void 0:_)}))};let v,b;const w=()=>400,x=()=>{v&&window.clearTimeout(v),v=window.setTimeout(()=>{g({dock:!1,closing:!1}),v=void 0},w())},k=()=>{const C=t.id;C&&r().set("todo",C,[])};return ae(vt(()=>[t.id,u().length,d(),f()],([C,E,_,L],O)=>{b&&cancelAnimationFrame(b),b=void 0;const $=JF({count:E,done:_,live:L});if(!O||O[0]!==C){v&&window.clearTimeout(v),v=void 0,g({sessionID:C,dock:eN($),closing:!1,opening:!1}),$==="clear"&&k();return}if($==="hide"){v&&window.clearTimeout(v),v=void 0,g({dock:!1,closing:!1,opening:!1});return}if($==="clear"){v&&window.clearTimeout(v),v=void 0,k();return}if($==="open"){v&&window.clearTimeout(v),v=void 0;const V=!m.dock||m.closing;if(g({dock:!0,closing:!1}),V){g("opening",!0),b=requestAnimationFrame(()=>{g("opening",!1),b=void 0});return}g("opening",!1);return}g({dock:!0,opening:!1,closing:!0}),v||x()})),Te(()=>{v&&window.clearTimeout(v)}),Te(()=>{b&&cancelAnimationFrame(b)}),{blocked:c,questionRequest:a,permissionRequest:l,permissionResponding:p,decide:y,todos:u,dock:()=>m.sessionID===t.id?m.dock:eN(JF({count:u().length,done:d(),live:f()})),closing:()=>m.sessionID===t.id&&m.closing,opening:()=>m.sessionID===t.id&&m.opening}}function xQe(e){const t=Ji(),[n,r]=Ze({ready:e.ready()||e.state.dock(),height:320,body:void 0});let i,s;const o=()=>{i!==void 0&&window.clearTimeout(i),s!==void 0&&cancelAnimationFrame(s),i=void 0,s=void 0};ae(()=>{e.sessionKey();const m=e.ready(),g=e.state.dock();if(o(),!(n.ready||!m&&!g)){if(g){r("ready",!0);return}s=requestAnimationFrame(()=>{s=void 0,i=window.setTimeout(()=>{r("ready",!0),i=void 0},140)})}}),ae(()=>{e.prompt.ready()&&PT(e.sessionKey(),{prompt:e.prompt.current().map(m=>m.type==="file"?`[file:${m.path}]`:m.type==="agent"?`@${m.name}`:m.type==="image"?`[image:${m.filename}]`:m.content).join("").trim()})}),ae(()=>{const m=n.body;if(!m)return;const g=()=>r("height",m.getBoundingClientRect().height);Oa(m,g),g()}),Te(o);const a=I(()=>{const m=e.sessionID();return m?t().session.get(m)?.parentID:void 0}),l=I(()=>n.ready&&e.state.dock()&&!e.state.closing()),c=vy(()=>l()?1:0,{visualDuration:.3,bounce:0},()=>`${e.sessionKey()}\0${n.ready}`),u=I(()=>Math.max(0,Math.min(1,c()))),d=Promise.resolve(),[f]=ai(()=>e.prompt.ready.promise??d,m=>m.then(()=>!0));return{state:e.state,centered:e.centered,todo:e.todo,followup:e.followup,revert:e.revert,onResponseSubmit:e.onResponseSubmit,openParent:e.openParent,setPromptRef:e.setPromptRef,setDockRef:e.setDockRef,parentID:a,child:()=>!!a(),showComposer:()=>!e.state.blocked()||!!a(),handoffPrompt:()=>OT(e.sessionKey())?.prompt,promptReady:()=>e.prompt.ready()||f(),dock:()=>n.ready&&e.state.dock()||u()>.001,dockProgress:u,dockHeight:()=>Math.max(78,n.height),lift:()=>e.revert()?.items.length?18:36*u(),setDockBodyRef:m=>r("body",m)}}function kQe(e,t,n){const r=new Array(e);return new Proxy(r,{get(i,s,o){if(typeof s=="string"){const a=s.charCodeAt(0);if(a>=48&&a<=57){const l=+s;if(Number.isInteger(l)&&l>=0&&l<e){let c=i[l];if(!c){const u=t[l*2];c=i[l]={index:l,key:n(l),start:u,size:t[l*2+1],end:u+t[l*2+1],lane:0}}return c}}if(s==="length")return e}return Reflect.get(i,s,o)}})}function em(e,t,n){let r=n.initialDeps??[],i,s=!0;function o(){const a=e();return(a.length!==r.length||a.some((c,u)=>r[u]!==c))&&(r=a,i=t(...a),n?.onChange&&!(s&&n.skipInitialOnChange)&&n.onChange(i),s=!1),i}return o.updateDeps=a=>{r=a},o}function tN(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const SQe=(e,t)=>Math.abs(e-t)<1.01,CQe=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}};let j0;const n6=()=>{if(j0!==void 0)return j0;if(typeof navigator>"u")return j0=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return j0=!0;const e=navigator.maxTouchPoints;return j0=navigator.platform==="MacIntel"&&e!==void 0&&e>0},nN=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},_Qe=e=>e,r3=e=>{const t=Math.max(e.startIndex-e.overscan,0),r=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,i=new Array(r);for(let s=0;s<r;s++)i[s]=t+s;return i},TQe=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;const i=o=>{const{width:a,height:l}=o;t({width:Math.round(a),height:Math.round(l)})};if(i(nN(n)),!r.ResizeObserver)return()=>{};const s=new r.ResizeObserver(o=>{const a=()=>{const l=o[0];if(l?.borderBoxSize){const c=l.borderBoxSize[0];if(c){i({width:c.inlineSize,height:c.blockSize});return}}i(nN(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return s.observe(n,{box:"border-box"}),()=>{s.unobserve(n)}},zx={passive:!0},EQe=typeof window>"u"?!0:"onscrollend"in window,IQe=(e,t,n)=>{const r=e.scrollElement;if(!r)return;const i=e.targetWindow;if(!i)return;const s=e.options.useScrollendEvent&&EQe;let o=0;const a=s?null:CQe(i,()=>t(o,!1),e.options.isScrollingResetDelay),l=d=>()=>{o=n(r),a?.(),t(o,d)},c=l(!0),u=l(!1);return r.addEventListener("scroll",c,zx),s&&r.addEventListener("scrollend",u,zx),()=>{r.removeEventListener("scroll",c),s&&r.removeEventListener("scrollend",u)}},Mne=(e,t)=>IQe(e,t,n=>{const{horizontal:r,isRtl:i}=e.options;return r?n.scrollLeft*(i&&-1||1):n.scrollTop}),DQe=(e,t,n)=>{if(n.options.useCachedMeasurements){const r=n.indexFromElement(e),i=n.options.getItemKey(r);return n.itemSizeCache.get(i)??n.options.estimateSize(r)}if(t?.borderBoxSize){const r=t.borderBoxSize[0];if(r)return Math.round(r[n.options.horizontal?"inlineSize":"blockSize"])}if(!t){const r=n.indexFromElement(e),i=n.options.getItemKey(r),s=n.itemSizeCache.get(i);if(s!==void 0)return s}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},LQe=(e,{adjustments:t=0,behavior:n},r)=>{var i,s;(s=(i=r.scrollElement)==null?void 0:i.scrollTo)==null||s.call(i,{[r.options.horizontal?"left":"top"]:e+t,behavior:n})},$ne=LQe;class AQe{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var n,r,i;return((i=(r=(n=this.targetWindow)==null?void 0:n.performance)==null?void 0:r.now)==null?void 0:i.call(r))??Date.now()},this.observer=(()=>{let n=null;const r=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(i=>{i.forEach(s=>{const o=()=>{const a=s.target,l=this.indexFromElement(a);if(!a.isConnected){this.observer.unobserve(a);for(const[c,u]of this.elementsCache)if(u===a){this.elementsCache.delete(c);break}return}this.shouldMeasureDuringScroll(l)&&this.resizeItem(l,this.options.measureElement(a,s,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()})}));return{disconnect:()=>{var i;(i=r())==null||i.disconnect(),n=null},observe:i=>{var s;return(s=r())==null?void 0:s.observe(i,{box:"border-box"})},unobserve:i=>{var s;return(s=r())==null?void 0:s.unobserve(i)}}})(),this.range=null,this.setOptions=n=>{var r,i;const s={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:_Qe,rangeExtractor:r3,onChange:()=>{},measureElement:DQe,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const f in n){const m=n[f];m!==void 0&&(s[f]=m)}const o=this.options;let a=null,l=null,c=!1;if(o!==void 0&&o.enabled&&s.enabled&&s.anchorTo==="end"&&this.scrollElement!==null){const f=o.count,m=s.count,g=this.getMeasurements(),p=f>0?((r=g[0])==null?void 0:r.key)??o.getItemKey(0):null,y=f>0?((i=g[f-1])==null?void 0:i.key)??o.getItemKey(f-1):null;if(m!==f||f>0&&m>0&&(s.getItemKey(0)!==p||s.getItemKey(m-1)!==y)){c=!0;const w=f>0?this.getVirtualItemForOffset(this.getScrollOffset())??g[0]:null;w&&(a=[w.key,this.getScrollOffset()-w.start]);const x=s.followOnAppend===!0?"auto":s.followOnAppend||null;x&&m>f&&this.isAtEnd(o.scrollEndThreshold)&&(f===0||s.getItemKey(m-1)!==y)&&(l=x)}}this.options=s,c&&(this.pendingMin=0,this.itemSizeCacheVersion++);let u=!1,d=0;if(a&&this.scrollOffset!==null){const[f,m]=a,g=this.getMeasurements(),{count:p,getItemKey:y}=this.options;let v=0;for(;v<p&&y(v)!==f;)v++;if(v<p){const b=g[v];if(b){const w=b.start+m;w!==this.scrollOffset&&(d=w-this.scrollOffset,this.scrollOffset=w,u=!0)}}}(u||l)&&(this.pendingScrollAnchor=[u?a[0]:null,u?a[1]:0,l,d])},this.notify=n=>{var r,i;(i=(r=this.options).onChange)==null||i.call(r,this,n)},this.maybeNotify=em(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}if(this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(s=>{this.observer.observe(s)}),this.unsubs.push(this.options.observeElementRect(this,s=>{this.scrollRect=s,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(s,o)=>{if(o&&this._intendedScrollOffset===null&&s===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(s-this._intendedScrollOffset)<1.5&&(s=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;const a=this.getScrollOffset();this.scrollDirection=o?a===s?this.scrollDirection:a<s?"forward":"backward":null,this.scrollOffset=s,this.isScrolling=o,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const s=this.scrollElement,o=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},a=()=>{this._iosTouching=!1,!(!n6()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};s.addEventListener("touchstart",o,zx),s.addEventListener("touchend",a,zx),this.unsubs.push(()=>{s.removeEventListener("touchstart",o),s.removeEventListener("touchend",a),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const i=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,i&&this.scrollElement&&this.options.enabled){const[s,o,a,l]=i;s!==null&&!a&&(n6()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?l!==0&&(this._iosDeferredAdjustment+=l):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),a&&this.scrollToEnd({behavior:a})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const n=this.getScrollOffset(),r=this.getMaxScrollOffset();if(n<0||n>r)return;const i=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(n,{adjustments:this.scrollAdjustments+=i,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(n,r)=>{const i=new Map,s=new Map;for(let o=r-1;o>=0;o--){const a=n[o];if(i.has(a.lane))continue;const l=s.get(a.lane);if(l==null||a.end>l.end?s.set(a.lane,a):a.end<l.end&&i.set(a.lane,!0),i.size===this.options.lanes)break}return s.size===this.options.lanes?Array.from(s.values()).sort((o,a)=>o.end===a.end?o.index-a.index:o.end-a.end)[0]:void 0},this.getMeasurementOptions=em(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(n,r,i,s,o,a,l)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:n,paddingStart:r,scrollMargin:i,getItemKey:s,enabled:o,lanes:a,laneAssignmentMode:l}),{key:!1}),this.getMeasurements=em(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:n,paddingStart:r,scrollMargin:i,getItemKey:s,enabled:o,lanes:a,laneAssignmentMode:l},c)=>{const u=this.itemSizeCache;if(!o)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>n)for(const g of this.laneAssignments.keys())g>=n&&this.laneAssignments.delete(g);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(g=>{this.itemSizeCache.set(g.key,g.size)}));const d=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===n&&(this.lanesSettling=!1),a===1){const g=this.options.gap,p=n*2;let y=this._flatMeasurements;if(!y||y.length<p){const w=new Float64Array(p);y&&d>0&&w.set(y.subarray(0,d*2)),y=w,this._flatMeasurements=y}let v;if(d===0)v=r+i;else{const w=d-1;v=y[w*2]+y[w*2+1]+g}for(let w=d;w<n;w++){const x=s(w),k=u.get(x),C=typeof k=="number"?k:this.options.estimateSize(w);y[w*2]=v,y[w*2+1]=C,v+=C+g}const b=kQe(n,y,s);return this.measurementsCache=b,b}const f=this.measurementsCache.slice(0,d),m=new Array(a).fill(void 0);for(let g=0;g<d;g++){const p=f[g];p&&(m[p.lane]=g)}for(let g=d;g<n;g++){const p=s(g),y=this.laneAssignments.get(g);let v,b;const w=l==="estimate"||u.has(p);if(y!==void 0&&this.options.lanes>1){v=y;const E=m[v],_=E!==void 0?f[E]:void 0;b=_?_.end+this.options.gap:r+i}else{const E=this.options.lanes===1?f[g-1]:this.getFurthestMeasurement(f,g);b=E?E.end+this.options.gap:r+i,v=E?E.lane:g%this.options.lanes,this.options.lanes>1&&w&&this.laneAssignments.set(g,v)}const x=u.get(p),k=typeof x=="number"?x:this.options.estimateSize(g),C=b+k;f[g]={index:g,start:b,size:k,end:C,key:p,lane:v},m[v]=g}return this.measurementsCache=f,f},{key:!1,debug:()=>this.options.debug}),this.calculateRange=em(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes,this.options.paddingEnd],(n,r,i,s,o)=>{if(n.length===0||r===0)return this.range=null,null;const a=Math.max(this.options.scrollMargin+this.getTotalSize()-r,0),l=Math.min(Math.max(i,0),a);return this.range=$Qe(n,r,l,s,s===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range},{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=em(()=>{let n=null,r=null;const i=this.calculateRange();return i&&(n=i.startIndex,r=i.endIndex),this.maybeNotify.updateDeps([this.isScrolling,n,r]),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,r]},(n,r,i,s,o)=>s===null||o===null?[]:n({startIndex:s,endIndex:o,overscan:r,count:i}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=n=>{const r=this.options.indexAttribute,i=n.getAttribute(r);return i?parseInt(i,10):(console.warn(`Missing attribute name '${r}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=n=>{var r;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const i=this.scrollState.index??((r=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:r.index);if(i!==void 0&&this.range){const s=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),o=Math.max(0,i-s),a=Math.min(this.options.count-1,i+s);return n>=o&&n<=a}return!0},this.measureElement=n=>{if(!n){this.elementsCache.forEach((o,a)=>{o.isConnected||(this.observer.unobserve(o),this.elementsCache.delete(a))});return}const r=this.indexFromElement(n),i=this.options.getItemKey(r),s=this.elementsCache.get(i);s!==n&&(s&&this.observer.unobserve(s),this.observer.observe(n),this.elementsCache.set(i,n)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(r)&&this.resizeItem(r,this.options.measureElement(n,void 0,this))},this.resizeItem=(n,r)=>{var i,s;if(n<0||n>=this.options.count)return;let o,a,l;const c=this._flatMeasurements;if(this.options.lanes===1&&c!==null)l=this.options.getItemKey(n),a=c[n*2],o=c[n*2+1];else{const f=this.measurementsCache[n];if(!f)return;l=f.key,a=f.start,o=f.size}const u=this.itemSizeCache.get(l)??o,d=r-u;if(d!==0){const f=this.options.anchorTo==="end"&&((i=this.scrollState)==null?void 0:i.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,m=f?this.getTotalSize():0,g=((s=this.scrollState)==null?void 0:s.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[n]??{index:n,key:l,start:a,size:o,end:a+o,lane:0},d,this):a<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(l)||this.scrollDirection!=="backward"));(this.pendingMin===null||n<this.pendingMin)&&(this.pendingMin=n),this.itemSizeCache.set(l,r),this.itemSizeCacheVersion++,f?this.applyScrollAdjustment(this.getTotalSize()-m):g&&this.applyScrollAdjustment(d),this.notify(!1)}},this.getVirtualItems=em(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,r)=>{const i=[];for(let s=0,o=n.length;s<o;s++){const a=n[s],l=r[a];i.push(l)}return i},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{const r=this.getMeasurements();if(r.length===0)return;const i=this._flatMeasurements,s=this.options.lanes===1&&i!=null,o=Pne(0,r.length-1,s?a=>i[a*2]:a=>tN(r[a]).start,n);return tN(r[o])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const n=this.scrollElement.document.documentElement;return this.options.horizontal?n.scrollWidth-this.scrollElement.innerWidth:n.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(n=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=n,this.getOffsetForAlignment=(n,r,i=0)=>{if(!this.scrollElement)return 0;const s=this.getSize(),o=this.getScrollOffset();r==="auto"&&(r=n>=o+s?"end":"start"),r==="center"?n+=(i-s)/2:r==="end"&&(n-=s);const a=this.getMaxScrollOffset();return Math.max(Math.min(a,n),0)},this.getOffsetForIndex=(n,r="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const i=this.getSize(),s=this.getScrollOffset(),o=this.measurementsCache[n];if(!o)return;if(r==="auto")if(o.end>=s+i-this.options.scrollPaddingEnd)r="end";else if(o.start<=s+this.options.scrollPaddingStart)r="start";else return[s,r];if(r==="end"&&n===this.options.count-1)return[this.getMaxScrollOffset(),r];const a=r==="end"?o.end+this.options.scrollPaddingEnd:o.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,r,o.size),r]},this.scrollToOffset=(n,{align:r="start",behavior:i="auto"}={})=>{const s=this.getOffsetForAlignment(n,r),o=this.now();this.scrollState={index:null,align:r,behavior:i,startedAt:o,lastTargetOffset:s,stableFrames:0},this._scrollToOffset(s,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.scrollToIndex=(n,{align:r="auto",behavior:i="auto"}={})=>{n=Math.max(0,Math.min(n,this.options.count-1));const s=this.getOffsetForIndex(n,r);if(!s)return;const[o,a]=s,l=this.now();this.scrollState={index:n,align:a,behavior:i,startedAt:l,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.scrollBy=(n,{behavior:r="auto"}={})=>{const i=this.getScrollOffset()+n,s=this.now();this.scrollState={index:null,align:"start",behavior:r,startedAt:s,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:n="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:n});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:n})},this.getTotalSize=()=>{var n;const r=this.getMeasurements();let i;if(r.length===0)i=this.options.paddingStart;else if(this.options.lanes===1){const s=r.length-1,o=this._flatMeasurements;o!=null?i=o[s*2]+o[s*2+1]:i=((n=r[s])==null?void 0:n.end)??0}else{const s=Array(this.options.lanes).fill(null);let o=r.length-1;for(;o>=0&&s.some(a=>a===null);){const a=r[o];s[a.lane]===null&&(s[a.lane]=a.end),o--}i=Math.max(...s.filter(a=>a!==null))}return Math.max(i-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const n=[];if(this.itemSizeCache.size===0)return n;const r=this.getMeasurements();for(const i of r)i&&this.itemSizeCache.has(i.key)&&n.push({index:i.index,key:i.key,start:i.start,size:i.size,end:i.end,lane:i.lane});return n},this._scrollToOffset=(n,{adjustments:r,behavior:i})=>{this._intendedScrollOffset=n+(r??0),this.options.scrollToFn(n,{behavior:i,adjustments:r},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(t)}applyScrollAdjustment(t,n){t!==0&&(n6()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=t:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=t,behavior:n}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollAdjustments=0)))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const r=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,i=r?r[0]:this.scrollState.lastTargetOffset,s=1,o=i!==this.scrollState.lastTargetOffset;if(!o&&SQe(i,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=s){this.getScrollOffset()!==i&&this._scrollToOffset(i,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,o){const a=this.getSize()||600,l=Math.abs(i-this.getScrollOffset()),c=this.scrollState.behavior==="smooth"&&l>a;this.scrollState.lastTargetOffset=i,c||(this.scrollState.behavior="auto"),this._scrollToOffset(i,{adjustments:void 0,behavior:c?"smooth":"auto"})}this.scheduleScrollReconcile()}}const Pne=(e,t,n,r)=>{for(;e<=t;){const i=(e+t)/2|0,s=n(i);if(s<r)e=i+1;else if(s>r)t=i-1;else return i}return e>0?e-1:0};function MQe(e,t,n){let r=0;for(;r<=t;){const i=(r+t)/2|0,s=e[i*2];if(s<n)r=i+1;else if(s>n)t=i-1;else return i}return r>0?r-1:0}function $Qe(e,t,n,r,i){const s=e.length-1;if(e.length<=r)return{startIndex:0,endIndex:s};if(r===1&&i!==null){const c=MQe(i,s,n);let u=c;const d=n+t;for(;u<s&&i[u*2]+i[u*2+1]<d;)u++;return{startIndex:c,endIndex:u}}let a=Pne(0,s,c=>e[c].start,n),l=a;if(r===1)for(;l<s&&e[l].end<n+t;)l++;else if(r>1){const c=Array(r).fill(0);for(;l<s&&c.some(d=>d<n+t);){const d=e[l];c[d.lane]=d.end,l++}const u=Array(r).fill(n+t);for(;a>=0&&u.some(d=>d>=n);){const d=e[a];u[d.lane]=d.start,a--}a=Math.max(0,a-a%r),l=Math.min(s,l+(r-1-l%r))}return{startIndex:a,endIndex:l}}function PQe(e){const t=le(e),n=new AQe(t),[r,i]=Ze(n.getVirtualItems()),[s,o]=De(n.getTotalSize()),a={get(c,u){switch(u){case"getVirtualItems":return()=>r;case"getTotalSize":return()=>s();default:return Reflect.get(c,u)}}},l=new Proxy(n,a);return l.setOptions(t),sn(()=>{const c=l._didMount();l._willUpdate(),Te(c)}),Fs(()=>{l.setOptions(le(t,e,{onChange:(c,u)=>{var d;c._willUpdate(),i(kn(c.getVirtualItems(),{key:"index"})),o(c.getTotalSize()),(d=e.onChange)==null||d.call(e,c,u)}})),l._willUpdate(),i(kn(n.getVirtualItems(),{key:"index"})),o(n.getTotalSize())}),l}function PI(e){return PQe(le({observeElementRect:TQe,observeElementOffset:Mne,scrollToFn:$ne},e))}var One=A("<div>");function OQe(e,t){return t?e?typeof e=="string"?`${e};--card-accent:${t};`:{...e,"--card-accent":t}:{"--card-accent":t}:e}function OI(e){const[t,n]=Ee(e,["variant","style","class","classList"]),r=()=>t.variant??"normal",i=()=>{const s=r();if(s==="error")return"var(--v2-state-fg-danger)";if(s==="warning")return"var(--icon-warning-active)";if(s==="success")return"var(--icon-success-active)";if(s==="info")return"var(--icon-info-active)"};return(()=>{var s=One();return An(s,le(n,{"data-component":"card",get"data-variant"(){return r()},get style(){return OQe(t.style,i())},get classList(){return{...t.classList,[t.class??""]:!!t.class}}}),!1,!0),S(s,()=>e.children),s})()}function RQe(e){const[t,n]=Ee(e,["class","classList","children"]);return(()=>{var r=One();return An(r,le(n,{"data-slot":"card-description",get classList(){return{...t.classList,[t.class??""]:!!t.class}}}),!1,!0),S(r,()=>t.children),r})()}function FQe({onlyFirst:e=!1}={}){const i="(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";return new RegExp(i,e?void 0:"g")}const NQe=FQe();function VQe(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(NQe,"")}var zQe=A("<span data-slot=text-shimmer-char><span data-slot=text-shimmer-char-base aria-hidden=true></span><span data-slot=text-shimmer-char-shimmer aria-hidden=true>");const xo=e=>{const t=I(()=>e.text??""),n=I(()=>e.active??!0),r=I(()=>e.offset??0),[i,s]=De(n()),o=220;let a;return ae(()=>{if(a&&(clearTimeout(a),a=void 0),n()){s(!0);return}a=setTimeout(()=>{a=void 0,s(!1)},o)}),Te(()=>{a&&clearTimeout(a)}),h(Gi,{get component(){return e.as??"span"},"data-component":"text-shimmer",get"data-active"(){return n()?"true":"false"},get class(){return e.class},get"aria-label"(){return t()},get style(){return{"--text-shimmer-swap":`${o}ms`,"--text-shimmer-index":`${r()}`}},get children(){var l=zQe(),c=l.firstChild,u=c.nextSibling;return S(c,t),S(u,t),he(()=>me(u,"data-run",i()?"true":"false")),l}})};var HQe=A("<div data-component=tool-trigger><div data-slot=basic-tool-tool-trigger-content><div data-slot=basic-tool-tool-info>"),jQe=A("<span data-slot=basic-tool-tool-subtitle>"),qQe=A("<span data-slot=basic-tool-tool-action>"),BQe=A("<div data-slot=basic-tool-tool-info-structured><div data-slot=basic-tool-tool-info-main><span data-slot=basic-tool-tool-title>"),UQe=A("<span data-slot=basic-tool-tool-arg>"),WQe=A("<div data-slot=collapsible-content data-animated>");const KQe=e=>typeof e=="object"&&e!==null&&"title"in e&&(typeof Node>"u"||!(e instanceof Node)),rN={type:"spring",visualDuration:.35,bounce:0},B2=[];let rv;function Rne(){for(;B2.length>0;){const e=B2.pop();if(e.active){rv=B2.length>0?requestAnimationFrame(Rne):void 0,e.fn();return}}rv=void 0}function GQe(){rv===void 0&&(rv=requestAnimationFrame(()=>{rv=requestAnimationFrame(Rne)}))}function ZQe(e){const t={active:!0,fn:e};return B2.push(t),GQe(),()=>{t.active=!1}}function YQe(e){const t=requestAnimationFrame(e);return()=>cancelAnimationFrame(t)}function Hs(e){const[t,n]=Ze({open:e.defaultOpen??!1,ready:!e.defer&&(e.defaultOpen??!1)}),r=()=>e.open??t.open,i=()=>t.ready,s=()=>e.status==="pending"||e.status==="running",o=()=>e.defer?"children"in e:e.children,a=typeof e.trigger=="function"?e.trigger(r):void 0;let l;const c=()=>{l?.(),l=void 0},u=(v=!1)=>{c(),l=(v?ZQe:YQe)(()=>{l=void 0,r()&&n("ready",!0)})};Te(c),sn(()=>{e.defer&&r()&&u(!0)});const d=v=>{e.open===void 0&&n("open",v),e.onOpenChange?.(v)};ae(()=>{e.forceOpen&&(r()||d(!0))}),ae(vt(r,v=>{if(e.defer){if(!v){c(),n("ready",!1);return}u()}},{defer:!0}));let f,m;const g=r();ae(vt(r,v=>{!e.animated||!f||(m?.stop(),v?(f.style.overflow="hidden",m=Fx(f,{height:"auto"},rN),m.finished.then(()=>{!f||!r()||(f.style.overflow="visible",f.style.height="auto")})):(f.style.overflow="hidden",m=Fx(f,{height:"0px"},rN)))},{defer:!0})),Te(()=>{m?.stop()});const p=v=>{s()&&!e.allowOpenWhilePending||e.locked&&!v||d(v)},y=()=>(()=>{var v=HQe(),b=v.firstChild,w=b.firstChild;return S(w,h(Rr,{get children(){return[h(zt,{when:a!==void 0,children:a}),h(zt,{get when(){return we(()=>!!KQe(e.trigger))()&&e.trigger},children:x=>(()=>{var k=BQe(),C=k.firstChild,E=C.firstChild;return S(E,h(xo,{get text(){return x().title},get active(){return s()}})),S(C,h(q,{get when(){return!s()},get children(){return[h(q,{get when(){return x().subtitle},get children(){var _=jQe();return _.$$click=L=>{e.onSubtitleClick&&(L.stopPropagation(),e.onSubtitleClick())},S(_,()=>x().subtitle),he(L=>ct(_,{[x().subtitleClass??""]:!!x().subtitleClass,clickable:!!e.onSubtitleClick},L)),_}}),h(q,{get when(){return x().args?.length},get children(){return h(Dt,{get each(){return x().args},children:_=>(()=>{var L=UQe();return S(L,_),he(O=>ct(L,{[x().argsClass??""]:!!x().argsClass},O)),L})()})}})]}}),null),S(k,h(q,{get when(){return we(()=>!s())()&&x().action},get children(){var _=qQe();return S(_,()=>x().action),_}}),null),he(_=>ct(E,{[x().titleClass??""]:!!x().titleClass},_)),k})()}),h(zt,{when:!0,get children(){return e.trigger}})]}})),S(v,h(q,{get when(){return we(()=>!!(o()&&!e.hideDetails&&!e.locked))()&&(!s()||e.allowOpenWhilePending)},get children(){return h(Wi.Arrow,{})}}),null),he(x=>{var k=e.clickable?"true":void 0,C=e.hideDetails?"true":void 0;return k!==x.e&&me(v,"data-clickable",x.e=k),C!==x.t&&me(v,"data-hide-details",x.t=C),x},{e:void 0,t:void 0}),v})();return h(Wi,{get open(){return r()},onOpenChange:p,class:"tool-collapsible",get children(){return[h(q,{get when(){return e.triggerAsLink||e.triggerHref},get fallback(){return h(Wi.Trigger,{get"data-hide-details"(){return e.hideDetails?"true":void 0},get onClick(){return e.onTriggerClick},get children(){return y()}})},get children(){return h(Wi.Trigger,{as:"a",get href(){return e.triggerHref},get role(){return!e.triggerHref&&e.clickable?"button":void 0},get tabIndex(){return!e.triggerHref&&e.clickable?0:void 0},get"data-hide-details"(){return e.hideDetails?"true":void 0},get onClick(){return e.onTriggerClick},get onKeyDown(){return e.onTriggerKeyDown},get children(){return y()}})}}),h(q,{get when(){return we(()=>!!(e.animated&&o()))()&&!e.hideDetails},get children(){var v=WQe(),b=f;return typeof b=="function"?pt(b,v):f=v,Ct(v,"height",g?"auto":"0px"),Ct(v,"overflow",g?"visible":"hidden"),S(v,h(q,{get when(){return!e.defer||i()},get children(){return e.children}})),v}}),h(q,{get when(){return we(()=>!!(!e.animated&&o()))()&&!e.hideDetails},get children(){return h(Wi.Content,{get children(){return h(q,{get when(){return!e.defer||i()},get children(){return e.children}})}})}})]}})}function XQe(e){return["description","query","url","filePath","path","pattern","name"].map(n=>e?.[n]).find(n=>typeof n=="string"&&n.length>0)}function QQe(e){if(!e)return[];const t=new Set(["description","query","url","filePath","path","pattern","name"]);return Object.entries(e).filter(([n])=>!t.has(n)).flatMap(([n,r])=>typeof r=="string"?[`${n}=${r}`]:typeof r=="number"?[`${n}=${r}`]:typeof r=="boolean"?[`${n}=${r}`]:[]).slice(0,3)}function JQe(e){const t=Mn();return h(Hs,{icon:"mcp",get status(){return e.status},get trigger(){return{title:t.t("ui.basicTool.called",{tool:e.tool}),subtitle:XQe(e.input),args:QQe(e.input)}},get hideDetails(){return e.hideDetails}})}dn(["click"]);var eJe=A('<a data-slot=basic-tool-tool-subtitle class="clickable subagent-link">'),tJe=A("<div data-component=tool-trigger><div data-slot=basic-tool-tool-trigger-content><span data-slot=basic-tool-tool-indicator data-component=tool-error-card-icon></span><div data-slot=basic-tool-tool-info><div data-slot=basic-tool-tool-info-structured><div data-slot=basic-tool-tool-info-main><span data-slot=basic-tool-tool-title>"),nJe=A("<div data-slot=tool-error-card-copy>"),rJe=A("<div data-slot=tool-error-card-content>"),iJe=A("<span data-slot=basic-tool-tool-subtitle>");function sJe(e){const t=Mn(),[n,r]=Ze({open:e.defaultOpen??!1,copied:!1}),i=()=>e.open??n.open,s=()=>n.copied,[o,a]=Ee(e,["tool","error","title","defaultOpen","open","onOpenChange","subtitle","href"]),l=p=>{e.open===void 0&&r("open",p),e.onOpenChange?.(p)},c=I(()=>{if(o.title)return o.title;const y={read:"ui.tool.read",list:"ui.tool.list",glob:"ui.tool.glob",grep:"ui.tool.grep",task:"ui.tool.task",webfetch:"ui.tool.webfetch",websearch:"ui.tool.websearch",bash:"ui.tool.shell",shell:"ui.tool.shell",patch:"ui.tool.patch",apply_patch:"ui.tool.patch",question:"ui.tool.questions"}[o.tool];return y?y.includes(".")?t.t(y):y:o.tool}),u=I(()=>o.error.replace(/^Error:\s*/,"").trim()),d=I(()=>{const p=u(),y=`${o.tool} `;return p.startsWith(y)?p.slice(y.length):p}),f=I(()=>{if(o.subtitle)return o.subtitle;const p=d().split(": ");if(p.length<=1)return t.t("ui.toolErrorCard.failed");const y=(p[0]??"").trim();return y&&y[0]?y[0].toUpperCase()+y.slice(1):t.t("ui.toolErrorCard.failed")}),m=I(()=>{const p=d().split(": ");return p.length<=1?u():p.slice(1).join(": ").trim()||u()}),g=async()=>{const p=u();p&&(await navigator.clipboard.writeText(p),r("copied",!0),setTimeout(()=>r("copied",!1),2e3))};return h(OI,le(a,{"data-kind":"tool-error-card",get"data-open"(){return i()?"true":"false"},variant:"error",get children(){return h(Wi,{class:"tool-collapsible",get"data-open"(){return i()?"true":"false"},get open(){return i()},onOpenChange:l,get children(){return[h(Wi.Trigger,{get children(){var p=tJe(),y=p.firstChild,v=y.firstChild,b=v.nextSibling,w=b.firstChild,x=w.firstChild,k=x.firstChild;return S(v,h(Yt,{name:"circle-ban-sign",size:"small",style:{"stroke-width":1.5}})),S(k,c),S(x,h(q,{get when(){return we(()=>!!o.href)()&&o.subtitle},get fallback(){return(()=>{var C=iJe();return S(C,f),C})()},get children(){var C=eJe();return C.$$click=E=>E.stopPropagation(),S(C,f),he(()=>me(C,"href",o.href)),C}}),null),S(p,h(Wi.Arrow,{}),null),p}}),h(Wi.Content,{get children(){var p=rJe();return S(p,h(q,{get when(){return i()},get children(){var y=nJe();return S(y,h(Ar,{get value(){return we(()=>!!s())()?t.t("ui.message.copied"):t.t("ui.toolErrorCard.copyError")},placement:"top",gutter:4,get children(){return h(Ln,{get icon(){return s()?"check":"copy"},size:"normal",variant:"ghost",onMouseDown:v=>v.preventDefault(),onClick:v=>{v.stopPropagation(),g()},get"aria-label"(){return we(()=>!!s())()?t.t("ui.message.copied"):t.t("ui.toolErrorCard.copyError")}})}})),y}}),null),S(p,h(q,{get when(){return m()},children:y=>h(RQe,{get children(){return y()}})}),null),p}})]}})}}))}dn(["click"]);var oJe=A('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 18 14"fill=none><g>'),aJe=A("<span data-slot=diff-changes-additions>"),lJe=A("<span data-slot=diff-changes-deletions>"),cJe=A("<div data-component=diff-changes>"),uJe=A("<svg><rect width=2 height=14 rx=1></svg>",!1,!0,!1);function Qc(e){const t=()=>e.variant??"default",n=I(()=>Array.isArray(e.changes)?e.changes.reduce((u,d)=>u+(d.additions??0),0):e.changes.additions),r=I(()=>Array.isArray(e.changes)?e.changes.reduce((u,d)=>u+(d.deletions??0),0):e.changes.deletions),i=I(()=>(n()??0)+(r()??0)),s=I(()=>{const d=n()??0,f=r()??0;if(d===0&&f===0)return{added:0,deleted:0,neutral:5};const m=d+f;if(m<5){const _=d>0?1:0,L=f>0?1:0,O=5-_-L;return{added:_,deleted:L,neutral:O}}const g=d>f?d/f:f/d;let p=5;(m<20||g<4)&&(p=4);const y=d/m,v=f/m,b=y*p,w=v*p;let x=d>0?Math.max(1,Math.round(b)):0,k=f>0?Math.max(1,Math.round(w)):0;d>0&&d<=5&&(x=Math.min(x,1)),d>5&&d<=10&&(x=Math.min(x,2)),f>0&&f<=5&&(k=Math.min(k,1)),f>5&&f<=10&&(k=Math.min(k,2));let C=x+k;C>p&&(b>w?x=p-k:k=p-x,C=x+k);const E=Math.max(0,5-C);return{added:x,deleted:k,neutral:E}}),o="var(--icon-diff-add-base)",a="var(--icon-diff-delete-base)",l="var(--icon-weak-base)",c=I(()=>{const u=s();return[...Array(u.added).fill(o),...Array(u.deleted).fill(a),...Array(u.neutral).fill(l)].slice(0,5)});return h(q,{get when(){return we(()=>t()==="default")()?i()>0:!0},get children(){var u=cJe();return S(u,h(Rr,{get children(){return[h(zt,{get when(){return t()==="bars"},get children(){var d=oJe(),f=d.firstChild;return S(f,h(Dt,{get each(){return c()},children:(m,g)=>(()=>{var p=uJe();return me(p,"fill",m),he(()=>me(p,"x",g()*4)),p})()})),d}}),h(zt,{get when(){return t()==="default"},get children(){return[(()=>{var d=aJe();return S(d,()=>`+${n()}`),d})(),(()=>{var d=lJe();return S(d,()=>`-${r()}`),d})()]}})]}})),he(d=>{var f=t(),m={[e.class??""]:!0};return f!==d.e&&me(u,"data-variant",d.e=f),d.t=ct(u,m,d.t),d},{e:void 0,t:void 0}),u}})}var dJe=A("<span data-component=tool-count-label><span data-slot=tool-count-label-before></span><span data-slot=tool-count-label-word><span data-slot=tool-count-label-stem></span><span data-slot=tool-count-label-suffix><span data-slot=tool-count-label-suffix-inner>");function iN(e){const t=/{{\s*count\s*}}/.exec(e);return t?t.index===void 0?{before:"",after:e}:{before:e.slice(0,t.index),after:e.slice(t.index+t[0].length)}:{before:"",after:e}}function fJe(e,t){const n=Array.from(e),r=Array.from(t);let i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;return{stem:n.slice(0,i).join(""),one:n.slice(i).join(""),other:r.slice(i).join("")}}function hJe(e){const t=I(()=>iN(e.one)),n=I(()=>iN(e.other)),r=I(()=>Math.round(e.count)===1),i=I(()=>r()?t():n()),s=I(()=>fJe(t().after,n().after)),o=I(()=>t().before===n().before&&(t().after.startsWith(n().after)||n().after.startsWith(t().after))),a=I(()=>o()?t().before:i().before),l=I(()=>o()?s().stem:i().after),c=I(()=>o()?r()?s().one:s().other:""),u=I(()=>o()&&c().length>0);return(()=>{var d=dJe(),f=d.firstChild,m=f.nextSibling,g=m.firstChild,p=g.nextSibling,y=p.firstChild;return S(f,a),S(d,h(PC,{get value(){return e.count}}),m),S(g,l),S(y,c),he(v=>{var b=e.class,w=u()?"true":"false";return b!==v.e&&xr(d,v.e=b),w!==v.t&&me(p,"data-active",v.t=w),v},{e:void 0,t:void 0}),d})()}var mJe=A("<span data-component=tool-count-summary><span data-slot=tool-count-summary-empty><span data-slot=tool-count-summary-empty-inner>"),gJe=A("<span data-slot=tool-count-summary-prefix>,"),pJe=A("<span data-slot=tool-count-summary-item><span data-slot=tool-count-summary-item-inner>");function vJe(e){const t=I(()=>e.items.filter(i=>i.count>0)),n=I(()=>e.fallback??""),r=I(()=>t().length===0&&n().length>0);return(()=>{var i=mJe(),s=i.firstChild,o=s.firstChild;return S(o,n),S(i,h(nh,{get each(){return e.items},children:(a,l)=>{const c=I(()=>a().count>0),u=I(()=>{for(let d=l-1;d>=0;d--)if(e.items[d].count>0)return!0;return!1});return[(()=>{var d=gJe();return he(()=>me(d,"data-active",c()&&u()?"true":"false")),d})(),(()=>{var d=pJe(),f=d.firstChild;return S(f,h(hJe,{get one(){return a().one},get other(){return a().other},get count(){return Math.max(0,Math.round(a().count))}})),he(()=>me(d,"data-active",c()?"true":"false")),d})()]}}),null),he(a=>{var l=e.class,c=r()?"true":"false";return l!==a.e&&xr(i,a.e=l),c!==a.t&&me(s,"data-active",a.t=c),a},{e:void 0,t:void 0}),i})()}var sN=A("<span data-slot=tool-status-active>"),oN=A("<span data-slot=tool-status-done>"),yJe=A("<span data-slot=tool-status-suffix><span data-slot=tool-status-prefix></span><span data-slot=tool-status-tail>"),bJe=A("<span data-component=tool-status-title>"),wJe=A("<span data-slot=tool-status-swap>");function xJe(e,t){const n=Array.from(e),r=Array.from(t);let i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;return{prefix:n.slice(0,i).join(""),active:n.slice(i).join(""),done:r.slice(i).join("")}}function aN(e){if(e)return`${Math.ceil(e.getBoundingClientRect().width)}px`}function kJe(e){const t=I(()=>xJe(e.activeText,e.doneText)),n=I(()=>(e.split??!0)&&t().prefix.length>=2&&t().active.length>0&&t().done.length>0),r=I(()=>Array.from(t().prefix).length),i=I(()=>n()?t().active:e.activeText),s=I(()=>n()?t().done:e.doneText),[o,a]=Ze({active:e.active,animating:!1,width:void 0}),l=()=>o.width,c=()=>o.active,u=()=>o.animating;let d,f,m,g,p;const y=()=>{g!==void 0&&cancelAnimationFrame(g),p!==void 0&&clearTimeout(p),g=void 0,p=void 0,a("animating",!1),a("width",void 0)},v=()=>{const b=aN(m),w=e.active;y(),a("active",w),b&&(a("animating",!0),a("width",b),g=requestAnimationFrame(()=>{g=void 0;const x=aN(w?d:f);if(!x){y();return}b!==x&&a("width",x),p=setTimeout(y,600)}))};return ae(vt([()=>e.active,i,s],()=>v(),{defer:!0})),Te(()=>{y()}),(()=>{var b=bJe();return S(b,h(q,{get when(){return n()},get fallback(){return(()=>{var w=wJe(),x=m;return typeof x=="function"?pt(x,w):m=w,S(w,h(q,{get when(){return u()||c()},get children(){var k=sN(),C=d;return typeof C=="function"?pt(C,k):d=k,S(k,h(xo,{get text(){return i()},get active(){return c()},offset:0})),k}}),null),S(w,h(q,{get when(){return u()||!c()},get children(){var k=oN(),C=f;return typeof C=="function"?pt(C,k):f=k,S(k,h(xo,{get text(){return s()},active:!1,offset:0})),k}}),null),he(k=>Ct(w,"width",l())),w})()},get children(){var w=yJe(),x=w.firstChild,k=x.nextSibling;S(x,h(xo,{get text(){return t().prefix},get active(){return c()},offset:0}));var C=m;return typeof C=="function"?pt(C,k):m=k,S(k,h(q,{get when(){return u()||c()},get children(){var E=sN(),_=d;return typeof _=="function"?pt(_,E):d=E,S(E,h(xo,{get text(){return i()},get active(){return c()},get offset(){return r()}})),E}}),null),S(k,h(q,{get when(){return u()||!c()},get children(){var E=oN(),_=f;return typeof _=="function"?pt(_,E):f=E,S(E,h(xo,{get text(){return s()},active:!1,get offset(){return r()}})),E}}),null),he(E=>Ct(k,"width",l())),w}})),he(w=>{var x=c()?"true":"false",k=u()?"true":"false",C=n()?"suffix":"swap",E=e.class,_=c()?e.activeText:e.doneText;return x!==w.e&&me(b,"data-active",w.e=x),k!==w.t&&me(b,"data-ready",w.t=k),C!==w.a&&me(b,"data-mode",w.a=C),E!==w.o&&xr(b,w.o=E),_!==w.i&&me(b,"aria-label",w.i=_),w},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),b})()}function Fne(e){const t=e.split(/\n/),n=[];let r=0;function i(){const a={};for(n.push(a);r<t.length;){const l=t[r];if(/^(---|\+\+\+|@@)\s/.test(l))break;const c=/^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(l);c&&(a.index=c[1]),r++}for(s(a),s(a),a.hunks=[];r<t.length;){const l=t[r];if(/^(Index:\s|diff\s|---\s|\+\+\+\s|===================================================================)/.test(l))break;if(/^@@/.test(l))a.hunks.push(o());else{if(l)throw new Error("Unknown line "+(r+1)+" "+JSON.stringify(l));r++}}}function s(a){const l=/^(---|\+\+\+)\s+(.*)\r?$/.exec(t[r]);if(l){const c=l[2].split(" ",2),u=(c[1]||"").trim();let d=c[0].replace(/\\\\/g,"\\");/^".*"$/.test(d)&&(d=d.substr(1,d.length-2)),l[1]==="---"?(a.oldFileName=d,a.oldHeader=u):(a.newFileName=d,a.newHeader=u),r++}}function o(){var a;const l=r,c=t[r++],u=c.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/),d={oldStart:+u[1],oldLines:typeof u[2]>"u"?1:+u[2],newStart:+u[3],newLines:typeof u[4]>"u"?1:+u[4],lines:[]};d.oldLines===0&&(d.oldStart+=1),d.newLines===0&&(d.newStart+=1);let f=0,m=0;for(;r<t.length&&(m<d.oldLines||f<d.newLines||!((a=t[r])===null||a===void 0)&&a.startsWith("\\"));r++){const g=t[r].length==0&&r!=t.length-1?" ":t[r][0];if(g==="+"||g==="-"||g===" "||g==="\\")d.lines.push(t[r]),g==="+"?f++:g==="-"?m++:g===" "&&(f++,m++);else throw new Error(`Hunk at line ${l+1} contained invalid line ${t[r]}`)}if(!f&&d.newLines===1&&(d.newLines=0),!m&&d.oldLines===1&&(d.oldLines=0),f!==d.newLines)throw new Error("Added line count did not match for hunk at line "+(l+1));if(m!==d.oldLines)throw new Error("Removed line count did not match for hunk at line "+(l+1));return d}for(;r<t.length;)i();return n}const SJe=16,Jd=new Map;function Nne(e){return typeof e.patch=="string"?CJe(e.file,e.patch):Vne(e.file,typeof e.before=="string"?e.before:"",typeof e.after=="string"?e.after:"")}function i3(e){return{file:e.file,additions:e.additions,deletions:e.deletions,status:e.status,fileDiff:Nne(e)}}function U2(e,t){return t==="deletions"?e.fileDiff.deletionLines.join(""):e.fileDiff.additionLines.join("")}function CJe(e,t){const n=`${e}\0${t}`,r=Jd.get(n);if(r)return Jd.delete(n),Jd.set(n,r),r;const i=_Je(t),s=i?void 0:TJe(e,t),o=i?Vne(e,i.before,i.after):(s?V0e(s)[0]?.files[0]:void 0)??zne(e);for(Jd.set(n,o);Jd.size>SJe;)Jd.delete(Jd.keys().next().value);return o}function _Je(e){try{const t=Fne(e)[0];if(!t||!t.index&&!t.oldFileName&&!t.newFileName||!e.startsWith("diff --git ")&&!/^--- [^\n]*\t\r?\n\+\+\+ [^\n]*\t(?:\r?\n|$)/m.test(e)||t.hunks.length!==1)return;const n=t.hunks[0];if(!n||n.oldStart>1||n.newStart>1)return;const r=[],i=[];let s;for(const a of n.lines){if(a.startsWith("\\")){if(s==="-"||s===" "){const l=r.at(-1);l&&(l.newline=!1)}if(s==="+"||s===" "){const l=i.at(-1);l&&(l.newline=!1)}continue}if(a.startsWith("-")){r.push({text:a.slice(1),newline:!0}),s="-";continue}if(a.startsWith("+")){i.push({text:a.slice(1),newline:!0}),s="+";continue}if(!a.startsWith(" "))return;r.push({text:a.slice(1),newline:!0}),i.push({text:a.slice(1),newline:!0}),s=" "}const o=a=>a.map(l=>l.text+(l.newline?`
1174
1174
  `:"")).join("");return{before:o(r),after:o(i)}}catch{return}}function TJe(e,t){try{const n=Fne(t)[0];return n?n.index||n.oldFileName||n.newFileName?t:n.hunks.length?`Index: ${e}
1175
1175
  ===================================================================
1176
1176
  --- ${e}
@@ -1178,7 +1178,7 @@ ${X.commentID}`)?.time??Date.now():Date.now(),origin:X.commentOrigin,preview:X.p
1178
1178
  ${t}`:void 0:void 0}catch{return}}function Vne(e,t,n){return!t&&!n?zne(e):Cv({name:e,contents:t},{name:e,contents:n})}function zne(e){return Cv({name:e,contents:""},{name:e,contents:""})}function EJe(e){if(e==="add"||e==="update"||e==="delete"||e==="move")return e}function IJe(e){return e==="add"?"added":e==="delete"?"deleted":"modified"}function DJe(e){if(!e||typeof e!="object")return;const t=e,n=EJe(t.type),r=typeof t.filePath=="string"?t.filePath:void 0,i=typeof t.relativePath=="string"?t.relativePath:r,s=typeof t.patch=="string"?t.patch:typeof t.diff=="string"?t.diff:void 0,o=typeof t.before=="string"?t.before:void 0,a=typeof t.after=="string"?t.after:void 0;if(!n||!r||!i||!s&&o===void 0&&a===void 0)return;const l=typeof t.additions=="number"?t.additions:0,c=typeof t.deletions=="number"?t.deletions:0,u=typeof t.movePath=="string"?t.movePath:void 0;return{filePath:r,relativePath:i,type:n,additions:l,deletions:c,movePath:u,view:i3({file:i,patch:s,before:o,after:a,additions:l,deletions:c,status:IJe(n)})}}function LJe(e){return Array.isArray(e)?e.map(DJe).filter(t=>!!t):[]}function Hne(e,t){return(e?.[t.id]??t.text??"").trim()}var AJe=A("<span data-component=shell-submessage><span data-slot=shell-submessage-width><span data-slot=basic-tool-tool-subtitle><span data-slot=shell-submessage-value>"),MJe=A("<div data-component=diagnostics>"),$Je=A("<div data-slot=diagnostic><span data-slot=diagnostic-label></span><span data-slot=diagnostic-location>[<!>:<!>]</span><span data-slot=diagnostic-message>"),PJe=A("<div data-component=exa-tool-output><div data-slot=exa-tool-links>"),OJe=A('<a data-slot=exa-tool-link target=_blank rel="noopener noreferrer">'),RJe=A('<div data-component=context-tool-group-trigger><span data-slot=context-tool-group-title class="min-w-0 flex items-center gap-2 text-14-medium text-text-strong"><span data-slot=context-tool-group-label class=shrink-0></span><span data-slot=context-tool-group-summary class="min-w-0 overflow-hidden text-ellipsis whitespace-nowrap font-normal text-text-base">'),FJe=A("<div data-component=context-tool-group-list>"),jne=A("<span data-slot=basic-tool-tool-subtitle>"),NJe=A("<div data-slot=context-tool-group-item><div data-component=tool-trigger><div data-slot=basic-tool-tool-trigger-content><div data-slot=basic-tool-tool-info><div data-slot=basic-tool-tool-info-structured><div data-slot=basic-tool-tool-info-main><span data-slot=basic-tool-tool-title>"),VJe=A("<span data-slot=basic-tool-tool-arg>"),zJe=A("<div data-slot=user-message-comments>"),HJe=A("<div data-slot=user-message-attachments>"),jJe=A("<img data-slot=user-message-attachment-image>"),qJe=A("<div data-slot=user-message-attachment>"),BJe=A("<div data-slot=user-message-attachment-file><span data-slot=user-message-attachment-name>"),UJe=A("<div data-slot=user-message-body><div data-slot=user-message-text>"),WJe=A('<span data-slot=user-message-meta class="text-12-regular text-text-weak cursor-default">'),KJe=A('<span data-slot=user-message-meta-sep class="text-12-regular text-text-weak cursor-default"> · '),GJe=A('<span data-slot=user-message-meta-tail class="text-12-regular text-text-weak cursor-default">'),ZJe=A("<span data-slot=user-message-meta-wrap>"),YJe=A("<div data-slot=user-message-copy-wrapper>"),XJe=A("<div data-component=user-message>"),QJe=A("<span>"),qne=A("<span data-slot=apply-patch-directory>"),Bne=A("<div data-slot=apply-patch-trigger-content><div data-slot=apply-patch-file-info><div data-slot=apply-patch-file-name-container><span data-slot=apply-patch-filename></span></div></div><div data-slot=apply-patch-trigger-actions>"),JJe=A("<div data-component=tool-part-wrapper>"),eet=A('<div style=width:100%;display:flex;justify-content:flex-end><span class="text-13-regular text-text-weak cursor-default">'),tet=A('<div data-component=compaction-part><div data-slot=compaction-part-divider><span data-slot=compaction-part-line></span><span data-slot=compaction-part-label class="text-12-regular text-text-weak"></span><span data-slot=compaction-part-line>'),net=A('<span data-slot=text-part-meta class="text-12-regular text-text-weak cursor-default">'),ret=A("<div data-slot=text-part-copy-wrapper>"),iet=A("<div data-component=text-part><div data-slot=text-part-body>"),set=A("<div data-component=reasoning-part>"),oet=A("<div data-component=tool-loaded-file><span> "),RI=A("<div data-component=tool-output data-scrollable tabindex=0 role=region>"),aet=A('<a data-slot=basic-tool-tool-subtitle class="clickable subagent-link"target=_blank rel="noopener noreferrer">'),cet=A("<div data-component=tool-action>"),Une=A("<div data-slot=basic-tool-tool-info-structured><div data-slot=basic-tool-tool-info-main><span data-slot=basic-tool-tool-title>"),uet=A("<span data-component=task-tool-spinner>"),det=A("<div data-component=task-tool-action>"),fet=A("<div data-component=task-tool-card><div data-component=task-tool-surface><div data-slot=basic-tool-tool-info-structured><div data-slot=basic-tool-tool-info-main><span data-component=task-tool-title>"),het=A("<span data-component=task-tool-icon>"),met=A("<div data-component=bash-output><div data-slot=bash-copy></div><div data-slot=bash-scroll data-scrollable tabindex=0 role=region><pre data-slot=bash-pre><code>"),get=A("<div data-component=edit-content>"),pet=A("<div data-component=edit-tool>"),FI=A("<span data-slot=message-part-title-filename>"),NI=A("<div data-slot=message-part-path><span data-slot=message-part-directory>"),Wne=A("<div data-component=edit-trigger><div data-slot=message-part-title-area><div data-slot=message-part-title><span data-slot=message-part-title-text></span></div></div><div data-slot=message-part-actions>"),vet=A("<div data-component=write-content>"),yet=A("<div data-component=write-tool>"),bet=A("<div data-component=write-trigger><div data-slot=message-part-title-area><div data-slot=message-part-title><span data-slot=message-part-title-text></span></div></div><div data-slot=message-part-actions>"),lN=A("<div data-component=apply-patch-file-diff>"),cN=A("<div data-component=apply-patch-tool>"),uN=A("<span data-slot=apply-patch-change data-type=added>"),dN=A("<span data-slot=apply-patch-change data-type=removed>"),fN=A("<span data-slot=apply-patch-change data-type=modified>"),wet=A("<div data-component=todos>"),xet=A("<span data-slot=message-part-todo-content>"),ket=A("<div data-component=question-answers>"),Cet=A("<div data-slot=question-answer-item><div data-slot=question-text></div><div data-slot=answer-text>"),_et=A('<div data-slot=basic-tool-tool-info-structured><div data-slot=basic-tool-tool-info-main><span data-slot=basic-tool-tool-title class="capitalize agent-title">');async function VI(e){const t=typeof document>"u"?void 0:document.body;if(t){const r=document.createElement("textarea");r.value=e,r.setAttribute("readonly",""),r.style.position="fixed",r.style.opacity="0",r.style.pointerEvents="none",t.appendChild(r),r.select();const i=document.execCommand("copy");if(t.removeChild(r),i)return!0}const n=typeof navigator>"u"?void 0:navigator.clipboard;return n?.writeText?n.writeText(e).then(()=>!0,()=>!1):!1}function Tet(e){let t,n;return sn(()=>{e.animate&&requestAnimationFrame(()=>{t&&Fx(t,{width:"auto"},{type:"spring",visualDuration:.25,bounce:0}),n&&Fx(n,{opacity:1,filter:"blur(0px)"},{duration:.32,ease:[.16,1,.3,1]})})}),(()=>{var r=AJe(),i=r.firstChild,s=i.firstChild,o=s.firstChild,a=t;typeof a=="function"?pt(a,i):t=i;var l=n;return typeof l=="function"?pt(l,o):n=o,S(o,()=>e.text),he(c=>{var u=e.animate?"0px":void 0,d=e.animate?{opacity:0,filter:"blur(2px)"}:void 0;return u!==c.e&&Ct(i,"width",c.e=u),c.t=So(o,d,c.t),c},{e:void 0,t:void 0}),r})()}function Kne(e,t){return!e||!t?[]:(e[t]??[]).filter(r=>r.severity===1).slice(0,3)}function Gne(e){const t=Mn();return h(q,{get when(){return e.diagnostics.length>0},get children(){var n=MJe();return S(n,h(Dt,{get each(){return e.diagnostics},children:r=>(()=>{var i=$Je(),s=i.firstChild,o=s.nextSibling,a=o.firstChild,l=a.nextSibling,c=l.nextSibling,u=c.nextSibling;u.nextSibling;var d=o.nextSibling;return S(s,()=>t.t("ui.messagePart.diagnostic.error")),S(o,()=>r.range.start.line+1,l),S(o,()=>r.range.start.character+1,u),S(d,()=>r.message),i})()})),n}})}function OC(e){const t=()=>e.icon==="copy"?"outline-copy":e.icon;return h(q,{get when(){return e.useV2},get fallback(){return h(Ar,{get value(){return e.label},placement:"top",gutter:4,get children(){return h(Ln,{get icon(){return e.icon},size:"normal",variant:"ghost",get disabled(){return e.disabled},get onMouseDown(){return e.onMouseDown},get onClick(){return e.onClick},get"aria-label"(){return e["aria-label"]}})}})},get children(){return h(Qn,{get value(){return e.label},placement:"top",gutter:4,get children(){return h(Lr,{get icon(){return h(on,{get name(){return t()},size:"small"})},size:"normal",variant:"ghost-muted",get disabled(){return e.disabled},get onMouseDown(){return e.onMouseDown},get onClick(){return e.onClick},get"aria-label"(){return e["aria-label"]}})}})}})}const o0={},hN=24,mN=512,Eet=/[\s.,!?;:)\]]/;function Iet(e){return e<=12?2:e<=48?4:e<=96?8:Math.min(256,Math.ceil(e/4))}function Det(e,t){const n=Math.min(e.length,t+Iet(e.length-t)),r=Math.min(e.length,n+8);for(let i=n;i<r;i++)if(Eet.test(e[i]??""))return i+1;return n}function Let(e,t){const[n,r]=De(e());let i=e(),s;const o=()=>{s&&(clearTimeout(s),s=void 0)},a=c=>{i=c,r(c)},l=()=>{s=void 0;const c=e();if(!t?.()){a(c);return}if(!c.startsWith(i)||c.length<=i.length){a(c);return}if(c.length-i.length<=mN){a(c);return}const u=Det(c,i.length);a(c.slice(0,u)),u<c.length&&(s=setTimeout(l,hN))};return ae(()=>{const c=e();if(!t?.()){o(),a(c);return}if(!c.startsWith(i)||c.length<i.length){o(),a(c);return}if(c.length-i.length<=mN){o(),a(c);return}c.length===i.length||s||(s=setTimeout(l,hN))}),Te(()=>{o()}),n}function Zne(e){const t=Let(()=>e.text,()=>e.streaming);return h(q,{get when(){return t()},get children(){return h(Th,{get text(){return t()},get cacheKey(){return e.cacheKey},get streaming(){return e.streaming}})}})}function Yne(e,t){if(!e)return"";if(!t||t==="/"||t==="\\")return e;if(e===t)return"";const n=t.includes("\\")?"\\":"/",r=t.endsWith(n)?t:t+n;return e.startsWith(r)?e.slice(t.length):e}function yl(e){const t=ph();return Yne(hc(e),t.directory)}function Aet(e,t){return t?e.t("ui.tool.agent",{type:t}):e.t("ui.tool.agent.default")}const Met={ask:"var(--icon-agent-ask-base)",build:"var(--icon-agent-build-base)",docs:"var(--icon-agent-docs-base)",plan:"var(--icon-agent-plan-base)"},$et={build:"var(--v2-agent-build-solid)",explore:"var(--v2-agent-explore-solid)",plan:"var(--v2-agent-plan-solid)",review:"var(--v2-agent-review-solid)",writer:"var(--v2-agent-writer-solid)"},Pet={primary:"var(--text-interactive-base)",secondary:"var(--text-base)",accent:"var(--icon-info-base)",success:"var(--icon-success-base)",warning:"var(--icon-warning-base)",error:"var(--icon-critical-base)",info:"var(--icon-info-base)"},Oet={primary:"var(--v2-text-text-accent)",secondary:"var(--v2-text-text-muted)",accent:"var(--v2-icon-icon-accent)",success:"var(--v2-state-fg-success)",warning:"var(--v2-state-fg-warning)",error:"var(--v2-state-fg-danger)",info:"var(--v2-state-fg-info)"},gN=["var(--icon-agent-ask-base)","var(--icon-agent-build-base)","var(--icon-agent-docs-base)","var(--icon-agent-plan-base)","var(--syntax-info)","var(--syntax-success)","var(--syntax-warning)","var(--syntax-property)","var(--syntax-constant)","var(--text-diff-add-base)","var(--text-diff-delete-base)","var(--icon-warning-base)"];function Ret(e){let t=0;for(const n of e)t=t*31+n.charCodeAt(0)>>>0;return gN[t%gN.length]}function Xne(e,t){if(typeof e!="string"||!e)return{};const n=e.toLowerCase(),r=t?.find(a=>a.name===e||a.name.toLowerCase()===n),i=r?.color?void 0:$et[n],s=pN(r?.color,Pet)??Met[n]??Ret(n),o=pN(r?.color,Oet)??i??s;return{name:r?.name??`${e[0].toUpperCase()}${e.slice(1)}`,color:s,v2Color:o}}function pN(e,t){if(e)return t[e]??e}function Hx(){return typeof document<"u"&&document.body.hasAttribute("data-new-layout")}function zI(e){return e==="parallel"?"Parallel Web Search":e==="exa"?"Exa Web Search":"Web Search"}function Qne(e,t={},n={}){const r=Mn();switch(e){case"read":return{icon:"glasses",title:r.t("ui.tool.read"),subtitle:t.filePath?fn(t.filePath):void 0};case"list":return{icon:"bullet-list",title:r.t("ui.tool.list"),subtitle:t.path?fn(t.path):void 0};case"glob":return{icon:"magnifying-glass-menu",title:r.t("ui.tool.glob"),subtitle:t.pattern};case"grep":return{icon:"magnifying-glass-menu",title:r.t("ui.tool.grep"),subtitle:t.pattern};case"webfetch":return{icon:"window-cursor",title:r.t("ui.tool.webfetch"),subtitle:t.url};case"websearch":return{icon:"window-cursor",title:zI(n?.provider),subtitle:t.query};case"task":{const i=typeof t.subagent_type=="string"&&t.subagent_type?t.subagent_type[0].toUpperCase()+t.subagent_type.slice(1):void 0;return{icon:"task",title:Aet(r,i),subtitle:t.description}}case"bash":case"shell":return{icon:"console",title:r.t("ui.tool.shell"),subtitle:t.command};case"edit":return{icon:"code-lines",title:r.t("ui.messagePart.title.edit"),subtitle:t.filePath?fn(t.filePath):void 0};case"write":return{icon:"code-lines",title:r.t("ui.messagePart.title.write"),subtitle:t.filePath?fn(t.filePath):void 0};case"patch":case"apply_patch":return{icon:"code-lines",title:r.t("ui.tool.patch"),subtitle:t.files?.length?`${t.files.length} ${r.t(t.files.length>1?"ui.common.file.other":"ui.common.file.one")}`:void 0};case"todowrite":return{icon:"checklist",title:r.t("ui.tool.todos")};case"question":return{icon:"bubble-5",title:r.t("ui.tool.questions")};case"skill":return{icon:"brain",title:t.name||r.t("ui.tool.skill")};default:return{icon:"mcp",title:e}}}function Fet(e){if(!e)return[];const t=new Set;return[...e.matchAll(/https?:\/\/[^\s<>"'`)\]]+/g)].map(n=>n[0].replace(/[),.;:!?]+$/g,"")).filter(n=>t.has(n)?!1:(t.add(n),!0))}function Jne(e,t,n){if(!e)return;const r=n?.(e);if(r)return r;const i=t.indexOf("/session");if(i!==-1)return`${t.slice(0,i)}/session/${e}`}function Net(e){return e.match(/\/session\/([^/?#]+)/)?.[1]}function Vet(e,t,n,r){const i=Net(t);if(!i)return;const s=typeof e.description=="string"?e.description:"",o=Xne(e.subagent_type,r).name;return(n??[]).filter(a=>a.parentID===i&&!a.time?.archived).filter(a=>s?a.title.startsWith(s):!0).filter(a=>o?a.title.includes(`@${o}`):!0).sort((a,l)=>(l.time.created??0)-(a.time.created??0))[0]?.id}const zet=new Set(["read","glob","grep","list"]),Het=new Set(["todowrite"]);function jet(e,t){return e===t?!0:!e||!t||e.length!==t.length?!1:e.every((n,r)=>n===t[r])}function vN(e,t){return e.messageID===t.messageID&&e.partID===t.partID}function qet(e,t){return e===t?!0:e.key!==t.key||e.type!==t.type?!1:e.type==="part"?t.type!=="part"?!1:vN(e.ref,t.ref):t.type!=="context"||e.refs.length!==t.refs.length?!1:e.refs.every((n,r)=>vN(n,t.refs[r]))}function Bet(e,t){return e===t?!0:!e||!t||e.length!==t.length?!1:e.every((n,r)=>qet(n,t[r]))}function W2(e){const t=[];let n=-1;const r=i=>{if(n<0)return;const s=e[n],o=e[i];if(!s||!o){n=-1;return}t.push({key:`context:${s.part.id}`,type:"context",refs:e.slice(n,i+1).map(a=>({messageID:a.messageID,partID:a.part.id}))}),n=-1};return e.forEach((i,s)=>{if(tre(i.part)){n<0&&(n=s);return}r(s-1),t.push({key:`part:${i.messageID}:${i.part.id}`,type:"part",ref:{messageID:i.messageID,partID:i.part.id}})}),r(e.length-1),t}function Uet(e){return new Map(e.map(t=>[t.id,t]))}function ere(e,t=!0){return e.type==="tool"?Het.has(e.tool)?!1:e.tool==="question"?e.state.status!=="pending"&&e.state.status!=="running":!0:e.type==="text"?!!e.text?.trim():e.type==="reasoning"?t&&!!e.text?.trim():!!o0[e.type]}function Wet(e,t=!1,n=!1){if(e==="bash"||e==="shell")return t;if(e==="edit"||e==="write"||e==="patch"||e==="apply_patch")return n}function Ket(e,t=!1,n=!1){if(e.type==="tool")return Wet(e.tool,t,n)}function tre(e){return e.type==="tool"&&zet.has(e.tool)}function Get(e){const t=Qne(e.tool,e.state.input??{},"metadata"in e.state?e.state.metadata:void 0);if(t.subtitle)return t.subtitle;if(e.state.status==="error")return e.state.error;if((e.state.status==="running"||e.state.status==="completed")&&e.state.title)return e.state.title;const n=e.state.input?.description;if(typeof n=="string")return n}function Zet(e,t){const n=e.state.input??{},r=typeof n.path=="string"?n.path:"/",i=typeof n.filePath=="string"?n.filePath:void 0,s=typeof n.pattern=="string"?n.pattern:void 0,o=typeof n.include=="string"?n.include:void 0,a=typeof n.offset=="number"?n.offset:void 0,l=typeof n.limit=="number"?n.limit:void 0;switch(e.tool){case"read":{const c=[];return a!==void 0&&c.push("offset="+a),l!==void 0&&c.push("limit="+l),{title:t.t("ui.tool.read"),subtitle:i?fn(i):"",args:c}}case"list":return{title:t.t("ui.tool.list"),subtitle:yl(r)};case"glob":return{title:t.t("ui.tool.glob"),subtitle:yl(r),args:s?["pattern="+s]:[]};case"grep":{const c=[];return s&&c.push("pattern="+s),o&&c.push("include="+o),{title:t.t("ui.tool.grep"),subtitle:yl(r),args:c}}default:{const c=Qne(e.tool,n,"metadata"in e.state?e.state.metadata:void 0);return{title:c.title,subtitle:c.subtitle||Get(e),args:[]}}}}function Yet(e){const t=e.filter(i=>i.tool==="read").length,n=e.filter(i=>i.tool==="glob"||i.tool==="grep").length,r=e.filter(i=>i.tool==="list").length;return{read:t,search:n,list:r}}function Xet(e){const t=I(()=>Fet(e.output));return h(q,{get when(){return t().length>0},get children(){var n=PJe(),r=n.firstChild;return S(r,h(Dt,{get each(){return t()},children:i=>(()=>{var s=OJe();return s.$$click=o=>o.stopPropagation(),me(s,"href",i),S(s,i),s})()})),n}})}function Qet(e){return h(Rr,{get children(){return[h(zt,{get when(){return we(()=>e.message.role==="user")()&&e.message},children:t=>h(ett,{get message(){return t()},get parts(){return e.parts},get actions(){return e.actions},get useV2Actions(){return e.useV2Actions},get comments(){return e.comments}})}),h(zt,{get when(){return we(()=>e.message.role==="assistant")()&&e.message},children:t=>h(Jet,{get message(){return t()},get parts(){return e.parts},get showAssistantCopyPartID(){return e.showAssistantCopyPartID},get showReasoningSummaries(){return e.showReasoningSummaries},get useV2Actions(){return e.useV2Actions}})})]}})}function Jet(e){const t=[],n=I(()=>Uet(e.parts)),r=I(()=>W2(e.parts.filter(i=>ere(i,e.showReasoningSummaries??!0)).map(i=>({messageID:e.message.id,part:i}))),[],{equals:Bet});return h(nh,{get each(){return r()},children:i=>{const s=I(()=>i().type);return h(Rr,{get children(){return[h(zt,{get when(){return s()==="context"},get children(){return(()=>{const o=I(()=>{const a=i();return a.type!=="context"?t:a.refs.map(l=>n().get(l.partID)).filter(l=>!!l&&tre(l))},t,{equals:jet});return h(q,{get when(){return o().length>0},get children(){return h(nre,{get parts(){return o()}})}})})()}}),h(zt,{get when(){return s()==="part"},get children(){return(()=>{const o=I(()=>{const a=i();if(a.type==="part")return n().get(a.ref.partID)});return h(q,{get when(){return o()},get children(){return h(rre,{get part(){return o()},get message(){return e.message},get showAssistantCopyPartID(){return e.showAssistantCopyPartID},get useV2Actions(){return e.useV2Actions}})}})})()}})]}})}})}function nre(e){const t=Mn(),[n,r]=De(!1),i=()=>e.open??n(),s=I(()=>!!e.busy||e.parts.some(l=>l.state.status==="pending"||l.state.status==="running")),o=I(()=>Yet(e.parts));return h(Wi,{get open(){return i()},onOpenChange:l=>{e.open===void 0&&r(l),e.onOpenChange?.(l),e.onSizeChange?.()},variant:"ghost",class:"tool-collapsible",get"data-timeline-part-ids"(){return e.parts.map(l=>l.id).join(",")},get children(){return[h(Wi.Trigger,{get children(){var l=RJe(),c=l.firstChild,u=c.firstChild,d=u.nextSibling;return S(u,h(kJe,{get active(){return s()},get activeText(){return t.t("ui.sessionTurn.status.gatheringContext")},get doneText(){return t.t("ui.sessionTurn.status.gatheredContext")},split:!1})),S(d,h(vJe,{get items(){return[{key:"read",count:o().read,one:t.t("ui.messagePart.context.read.one"),other:t.t("ui.messagePart.context.read.other")},{key:"search",count:o().search,one:t.t("ui.messagePart.context.search.one"),other:t.t("ui.messagePart.context.search.other")},{key:"list",count:o().list,one:t.t("ui.messagePart.context.list.one"),other:t.t("ui.messagePart.context.list.other")}]},fallback:""})),S(l,h(Wi.Arrow,{}),null),l}}),h(Wi.Content,{get children(){var l=FJe();return S(l,h(nh,{get each(){return e.parts},children:c=>{const u=I(()=>Zet(c(),t)),d=I(()=>c().state.status==="pending"||c().state.status==="running");return(()=>{var f=NJe(),m=f.firstChild,g=m.firstChild,p=g.firstChild,y=p.firstChild,v=y.firstChild,b=v.firstChild;return S(b,h(xo,{get text(){return u().title},get active(){return d()}})),S(v,h(q,{get when(){return we(()=>!d())()&&u().subtitle},get children(){var w=jne();return S(w,()=>u().subtitle),w}}),null),S(v,h(q,{get when(){return we(()=>!d())()&&u().args?.length},get children(){return h(Dt,{get each(){return u().args},children:w=>(()=>{var x=VJe();return S(x,w),x})()})}}),null),f})()}})),l}})]}})}function yN(e){const t=Mn(),[n,r]=Ze({expanded:!1}),i=I(()=>e.bounded&&!n.expanded?e.comments.slice(0,5):e.comments);return(()=>{var s=zJe();return S(s,h(Dt,{get each(){return i()},children:o=>h(LI,{get comment(){return o.comment},get path(){return o.path},get selection(){return o.selection},get title(){return o.comment},tooltip:!0,wide:!0})}),null),S(s,h(q,{get when(){return we(()=>!!(e.bounded&&e.comments.length>5))()&&!n.expanded},get children(){return h(as,{size:"small",variant:"ghost-muted",onClick:()=>r("expanded",!0),get children(){return t.t("ui.common.showMore")}})}}),null),he(()=>me(s,"data-bounded",e.bounded?"true":void 0)),s})()}function ett(e){const t=ph(),n=Mr(),r=Mn(),[i,s]=Ze({copied:!1,busy:!1}),o=()=>i.copied,a=()=>i.busy,l=I(()=>e.parts?.find(_=>_.type==="text"&&!_.synthetic)),c=I(()=>l()?.text||""),u=I(()=>e.parts?.filter(_=>_.type==="file")??[]),d=I(()=>u().filter(sZe)),f=I(()=>Hx()?e.comments??[]:[]),m=I(()=>u().filter(une)),g=I(()=>e.parts?.filter(_=>_.type==="agent")??[]),p=I(()=>{const _=e.message.model?.providerID,L=e.message.model?.modelID;return!_||!L?"":t.store.provider?.all?.get(_)?.models?.[L]?.name??L}),y=I(()=>new Intl.DateTimeFormat(r.locale(),{timeStyle:"short"})),v=I(()=>{const _=e.message.time?.created;return typeof _!="number"?"":y().format(_)}),b=I(()=>{const _=e.message.agent;return[_?_[0]?.toUpperCase()+_.slice(1):"",p()].filter(O=>!!O).join(" · ")}),w=v,x=(_,L)=>{n.show(()=>h(MI,{src:_,alt:L}))},k=async()=>{const _=c();_&&await VI(_)&&(s("copied",!0),setTimeout(()=>s("copied",!1),2e3))},C=()=>{const _=e.actions?.revert;!_||a()||(s("busy",!0),Promise.resolve().then(()=>_({sessionID:e.message.sessionID,messageID:e.message.id})).finally(()=>s("busy",!1)))},E=()=>h(q,{get when(){return d().length>0},get children(){var _=HJe();return S(_,h(Dt,{get each(){return d()},children:L=>{const O=oZe(L),$=L.filename??r.t("ui.message.attachment.alt");return h(q,{get when(){return Hx()&&O==="file"},get fallback(){return(()=>{var V=qJe();return V.$$click=()=>{O==="image"&&x(L.url,$)},me(V,"data-type",O),me(V,"data-clickable",O==="image"?"true":void 0),me(V,"title",O==="file"?$:void 0),S(V,h(q,{when:O==="image",get fallback(){return(()=>{var P=BJe(),T=P.firstChild;return S(P,h(Dr,{node:{path:$,type:"file"}}),T),S(T,$),P})()},get children(){var P=jJe();return me(P,"alt",$),he(()=>me(P,"src",L.url)),P}})),V})()},get children(){return h(t3,{get title(){return fn($)},hover:$,get clickable(){return!!e.actions?.openAttachment},onClick:()=>e.actions?.openAttachment?.(L),get children(){return AI($,L.mime)}})}})}})),_}});return(()=>{var _=XJe();return S(_,h(q,{get when(){return!e.useV2Actions},get children(){return E()}}),null),S(_,h(q,{get when(){return c()},get fallback(){return h(q,{get when(){return f().length>0},get children(){return h(yN,{get comments(){return f()},bounded:!1})}})},get children(){var L=UJe(),O=L.firstChild;return S(O,h(ttt,{get text(){return c()},get references(){return m()},get agents(){return g()}}),null),S(O,h(q,{get when(){return f().length>0},get children(){return h(yN,{get comments(){return f()},bounded:!0})}}),null),he(()=>me(O,"data-comments",f().length>0?"true":void 0)),L}}),null),S(_,h(q,{get when(){return e.useV2Actions},get children(){return E()}}),null),S(_,h(q,{get when(){return c()||e.useV2Actions&&f().length>0},get children(){var L=YJe();return S(L,h(q,{get when(){return b()||w()},get children(){var O=ZJe();return S(O,h(q,{get when(){return b()},get children(){var $=WJe();return S($,b),$}}),null),S(O,h(q,{get when(){return we(()=>!!b())()&&w()},get children(){return KJe()}}),null),S(O,h(q,{get when(){return w()},get children(){var $=GJe();return S($,w),$}}),null),O}}),null),S(L,h(q,{get when(){return e.actions?.revert},get children(){return h(OC,{icon:"reset",get label(){return r.t("ui.message.revertMessage")},get useV2(){return e.useV2Actions},get disabled(){return!!a()},onMouseDown:O=>O.preventDefault(),onClick:O=>{O.stopPropagation(),C()},get"aria-label"(){return r.t("ui.message.revertMessage")}})}}),null),S(L,h(q,{get when(){return c()},get children(){return h(OC,{get icon(){return o()?"check":"copy"},get label(){return we(()=>!!o())()?r.t("ui.message.copied"):r.t("ui.message.copyMessage")},get useV2(){return e.useV2Actions},onMouseDown:O=>O.preventDefault(),onClick:O=>{O.stopPropagation(),k()},get"aria-label"(){return we(()=>!!o())()?r.t("ui.message.copied"):r.t("ui.message.copyMessage")}})}}),null),L}}),null),he(()=>me(_,"data-timeline-part-id",l()?.id)),_})()}function ttt(e){const t=I(()=>{const n=e.text,r=[...e.references.filter(o=>o.source?.text?.start!==void 0&&o.source?.text?.end!==void 0).map(o=>({start:o.source.text.start,end:o.source.text.end,type:"file"})),...e.agents.filter(o=>o.source?.start!==void 0&&o.source?.end!==void 0).map(o=>({start:o.source.start,end:o.source.end,type:"agent"}))].sort((o,a)=>o.start-a.start),i=[];let s=0;for(const o of r)o.start<s||(o.start>s&&i.push({text:n.slice(s,o.start)}),i.push({text:n.slice(o.start,o.end),type:o.type}),s=o.end);return s<n.length&&i.push({text:n.slice(s)}),i});return h(Dt,{get each(){return t()},children:n=>(()=>{var r=QJe();return S(r,()=>n.text),he(()=>me(r,"data-highlight",n.type)),r})()})}function rre(e){const t=I(()=>o0[e.part.type]);return h(q,{get when(){return t()},get children(){return h(Gi,{get component(){return t()},get part(){return e.part},get message(){return e.message},get hideDetails(){return e.hideDetails},get defaultOpen(){return e.defaultOpen},get toolOpen(){return e.toolOpen},get onToolOpenChange(){return e.onToolOpenChange},get deferToolContent(){return e.deferToolContent},get virtualizeDiff(){return e.virtualizeDiff},get onContentRendered(){return e.onContentRendered},get showAssistantCopyPartID(){return e.showAssistantCopyPartID},get turnDurationMs(){return e.turnDurationMs},get useV2Actions(){return e.useV2Actions}})}})}const ire={};function ntt(e){return ire[e.name]=e,e}function rtt(e){return ire[e==="apply_patch"?"patch":e==="bash"?"shell":e]?.render}const mo={register:ntt,render:rtt};function HI(e){const t=I(()=>e.path||"tool-file");return h(Ei,{multiple:!0,"data-scope":"apply-patch",style:{"--sticky-accordion-offset":"calc(32px + var(--tool-content-gap))"},get defaultValue(){return[t()]},get children(){return h(Ei.Item,{get value(){return t()},get children(){return[h(my,{get children(){return h(Ei.Trigger,{get children(){var n=Bne(),r=n.firstChild,i=r.firstChild,s=i.firstChild,o=r.nextSibling;return S(r,h(Dr,{get node(){return{path:e.path,type:"file"}}}),i),S(i,h(q,{get when(){return e.path.includes("/")},get children(){var a=qne();return S(a,()=>`‪${yl(e.path)}‬`),a}}),s),S(s,()=>fn(e.path)),S(o,()=>e.actions,null),S(o,h(Yt,{name:"chevron-grabber-vertical",size:"small"}),null),n}})}}),h(Ei.Content,{get children(){return e.children}})]}})}})}o0.tool=function(t){const n=ph(),r=Mn(),i=()=>t.part;if(i().tool==="todowrite")return null;const s=I(()=>i().tool==="question"&&(i().state.status==="pending"||i().state.status==="running")),o={},a={},l=()=>i().state?.input??o,c=()=>i().state?.metadata??a,u=I(()=>{if(i().tool!=="task")return;const y=c().sessionId;if(typeof y=="string"&&y)return y}),d=I(()=>{if(i().tool==="task")return Jne(u(),Wa().pathname,n.sessionHref)}),f=I(()=>{if(i().tool!=="task")return;const y=l().description;return typeof y=="string"&&y?y:u()}),m=I(()=>mo.render(i().tool)??JQe),g=()=>t.onToolOpenChange?t.toolOpen??t.defaultOpen:void 0,p=y=>t.onToolOpenChange?.(y);return h(q,{get when(){return!s()},get children(){var y=JJe();return S(y,h(Rr,{get children(){return[h(zt,{get when(){return we(()=>i().state.status==="error")()&&i().state.error},children:v=>{const b=v().replace("Error: ","");return i().tool==="question"&&b.includes("dismissed this question")?(()=>{var w=eet(),x=w.firstChild;return S(x,()=>r.t("ui.messagePart.questions.dismissed")),w})():h(sJe,{get tool(){return i().tool},get error(){return v()},get title(){return we(()=>i().tool==="websearch")()?zI(c().provider):void 0},get defaultOpen(){return t.defaultOpen},get open(){return g()},get onOpenChange(){return t.onToolOpenChange?p:void 0},get subtitle(){return f()},get href(){return d()}})}}),h(zt,{when:!0,get children(){return h(Gi,{get component(){return m()},get input(){return l()},get tool(){return i().tool},get sessionID(){return i().sessionID},get metadata(){return c()},get output(){return i().state.output},get status(){return i().state.status},get hideDetails(){return t.hideDetails},get defaultOpen(){return t.defaultOpen},get open(){return g()},get onOpenChange(){return t.onToolOpenChange?p:void 0},get deferContent(){return t.deferToolContent},get virtualizeDiff(){return t.virtualizeDiff},get onContentRendered(){return t.onContentRendered}})}})]}})),he(()=>me(y,"data-timeline-part-id",i().id)),y}})};function sre(e){return(()=>{var t=tet(),n=t.firstChild,r=n.firstChild,i=r.nextSibling;return S(i,()=>e.label),t})()}o0.compaction=function(){const t=Mn();return h(sre,{get label(){return t.t("ui.messagePart.compaction")}})};o0.text=function(t){const n=ph(),r=Mn(),i=I(()=>new Intl.NumberFormat(r.locale())),s=()=>t.part,o=I(()=>t.message.role==="assistant"&&t.message.error?.name==="MessageAbortedError"),a=I(()=>{if(t.message.role!=="assistant")return"";const v=t.message;return n.store.provider?.all?.get(v.providerID)?.models?.[v.modelID]?.name??v.modelID}),l=I(()=>{if(t.message.role!=="assistant")return"";const v=t.message,b=v.time.completed,w=typeof t.turnDurationMs=="number"?t.turnDurationMs:typeof b=="number"?b-v.time.created:-1;if(!(w>=0))return"";const x=Math.round(w/1e3);if(x<60)return r.t("ui.message.duration.seconds",{count:i().format(x)});const k=Math.floor(x/60),C=x%60;return r.t("ui.message.duration.minutesSeconds",{minutes:i().format(k),seconds:i().format(C)})}),c=I(()=>{if(t.message.role!=="assistant")return"";const v=t.message.agent;return[v?v[0]?.toUpperCase()+v.slice(1):"",a(),l(),o()?r.t("ui.message.interrupted"):""].filter(w=>!!w).join(" · ")}),u=I(()=>t.message.role==="assistant"&&typeof t.message.time.completed!="number"),d=()=>Hne(n.store.part_text_accum_delta,s()),f=I(()=>(n.store.part?.[t.message.id]??[]).filter(b=>b?.type==="text"&&!!b.text?.trim()).at(-1)?.id===s().id),m=I(()=>t.message.role!=="assistant"?f():t.showAssistantCopyPartID===null?!1:typeof t.showAssistantCopyPartID=="string"?t.showAssistantCopyPartID===s().id:f()),[g,p]=De(!1),y=async()=>{const v=d();v&&await VI(v)&&(p(!0),setTimeout(()=>p(!1),2e3))};return h(q,{get when(){return d()},get children(){var v=iet(),b=v.firstChild;return S(b,h(q,{get when(){return u()},get fallback(){return h(Th,{get text(){return d()},get cacheKey(){return s().id},streaming:!1})},get children(){return h(Zne,{get text(){return d()},get cacheKey(){return s().id},get streaming(){return u()}})}})),S(v,h(q,{get when(){return m()},get children(){var w=ret();return S(w,h(OC,{get icon(){return g()?"check":"copy"},get label(){return we(()=>!!g())()?r.t("ui.message.copied"):r.t("ui.message.copyResponse")},get useV2(){return t.useV2Actions},onMouseDown:x=>x.preventDefault(),onClick:y,get"aria-label"(){return we(()=>!!g())()?r.t("ui.message.copied"):r.t("ui.message.copyResponse")}}),null),S(w,h(q,{get when(){return c()},get children(){var x=net();return S(x,c),x}}),null),he(()=>me(w,"data-interrupted",o()?"":void 0)),w}}),null),he(()=>me(v,"data-timeline-part-id",s().id)),v}})};o0.reasoning=function(t){const n=ph(),r=()=>t.part,i=I(()=>t.message.role==="assistant"&&typeof t.message.time.completed!="number"),s=()=>Hne(n.store.part_text_accum_delta,r());return h(q,{get when(){return s()},get children(){var o=set();return S(o,h(q,{get when(){return i()},get fallback(){return h(Th,{get text(){return s()},get cacheKey(){return r().id},streaming:!1})},get children(){return h(Zne,{get text(){return s()},get cacheKey(){return r().id},get streaming(){return i()}})}})),he(()=>me(o,"data-timeline-part-id",r().id)),o}})};mo.register({name:"read",render(e){const t=ph(),n=Mn(),r=[];e.input.offset&&r.push("offset="+e.input.offset),e.input.limit&&r.push("limit="+e.input.limit);const i=I(()=>{if(e.status!=="completed")return[];const s=e.metadata.loaded;return!s||!Array.isArray(s)?[]:s.filter(o=>typeof o=="string")});return[h(Hs,le(e,{icon:"glasses",get trigger(){return{title:n.t("ui.tool.read"),subtitle:e.input.filePath?fn(e.input.filePath):"",args:r}}})),h(Dt,{get each(){return i()},children:s=>(()=>{var o=oet(),a=o.firstChild,l=a.firstChild;return S(o,h(Yt,{name:"enter",size:"small"}),a),S(a,()=>n.t("ui.tool.loaded"),l),S(a,()=>Yne(s,t.directory),null),o})()})]}});mo.register({name:"list",render(e){const t=Mn();return h(Hs,le(e,{icon:"bullet-list",get trigger(){return{title:t.t("ui.tool.list"),subtitle:yl(e.input.path||"/")}},get children(){return h(q,{get when(){return e.output},get children(){var n=RI();return S(n,h(Th,{get text(){return e.output}})),he(()=>me(n,"aria-label",t.t("ui.scrollView.ariaLabel"))),n}})}}))}});mo.register({name:"glob",render(e){const t=Mn();return h(Hs,le(e,{icon:"magnifying-glass-menu",get trigger(){return{title:t.t("ui.tool.glob"),subtitle:yl(e.input.path||"/"),args:e.input.pattern?["pattern="+e.input.pattern]:[]}},get children(){return h(q,{get when(){return e.output},get children(){var n=RI();return S(n,h(Th,{get text(){return e.output}})),he(()=>me(n,"aria-label",t.t("ui.scrollView.ariaLabel"))),n}})}}))}});mo.register({name:"grep",render(e){const t=Mn(),n=[];return e.input.pattern&&n.push("pattern="+e.input.pattern),e.input.include&&n.push("include="+e.input.include),h(Hs,le(e,{icon:"magnifying-glass-menu",get trigger(){return{title:t.t("ui.tool.grep"),subtitle:yl(e.input.path||"/"),args:n}},get children(){return h(q,{get when(){return e.output},get children(){var r=RI();return S(r,h(Th,{get text(){return e.output}})),he(()=>me(r,"aria-label",t.t("ui.scrollView.ariaLabel"))),r}})}}))}});mo.register({name:"webfetch",render(e){const t=Mn(),n=I(()=>e.status==="pending"||e.status==="running"),r=I(()=>{const i=e.input.url;return typeof i!="string"?"":i});return h(Hs,le(e,{hideDetails:!0,icon:"window-cursor",get trigger(){return(()=>{var i=Une(),s=i.firstChild,o=s.firstChild;return S(o,h(xo,{get text(){return t.t("ui.tool.webfetch")},get active(){return n()}})),S(s,h(q,{get when(){return we(()=>!n())()&&r()},get children(){var a=aet();return a.$$click=l=>l.stopPropagation(),S(a,r),he(()=>me(a,"href",r())),a}}),null),S(i,h(q,{get when(){return we(()=>!n())()&&r()},get children(){var a=cet();return S(a,h(Yt,{name:"square-arrow-top-right",size:"small"})),a}}),null),i})()}}))}});mo.register({name:"websearch",render(e){const t=I(()=>{const r=e.input.query;return typeof r!="string"?"":r}),n=I(()=>zI(e.metadata.provider));return h(Hs,le(e,{icon:"window-cursor",get trigger(){return{title:n(),subtitle:t(),subtitleClass:"exa-tool-query"}},get children(){return h(Xet,{get output(){return e.output}})}}))}});mo.register({name:"task",render(e){const t=ph(),n=Mn(),r=Wa(),i=I(()=>{const v=e.metadata.sessionId;return typeof v=="string"&&v?v:Vet(e.input,r.pathname,t.store.session,t.store.agent)}),s=I(()=>Xne(e.input.subagent_type,t.store.agent)),o=I(()=>s().name??n.t("ui.tool.agent.default")),a=I(()=>s().color),l=I(()=>s().v2Color),c=I(()=>{const v=typeof e.input.description=="string"&&e.input.description?e.input.description:i();return v&&(e.metadata.background===!0?`${v} (background)`:v)}),u=I(()=>e.status==="pending"||e.status==="running"),d=I(()=>Jne(i(),r.pathname,t.sessionHref)),f=I(()=>!!(i()&&(t.navigateToSession||d()))),m=()=>{const v=i();if(!v)return;if(t.navigateToSession){t.navigateToSession(v);return}const b=d();b&&window.location.assign(b)},g=v=>{t.navigateToSession&&(v.button!==0||v.altKey||v.ctrlKey||v.metaKey||v.shiftKey||(v.preventDefault(),m()))},p=v=>{!f()||d()||v.key!=="Enter"&&v.key!==" "||(v.preventDefault(),m())},y=()=>(()=>{var v=fet(),b=v.firstChild,w=b.firstChild,x=w.firstChild,k=x.firstChild;return S(x,h(q,{get when(){return u()},get fallback(){return h(q,{get when(){return Hx()},get children(){var C=het();return S(C,h(Yt,{name:"subagent",size:"small"})),C}})},get children(){var C=uet();return S(C,h(q,{get when(){return Hx()},get fallback(){return h(Fd,{})},get children(){return h(ZQ,{get style(){return{color:l()??"light-dark(var(--v2-text-text-base), #ffffff)"}}})}})),he(E=>Ct(C,"color",a()??"var(--icon-interactive-base)")),C}}),k),S(k,o),S(x,h(q,{get when(){return c()},get children(){var C=jne();return S(C,c),C}}),null),S(v,h(q,{get when(){return f()},get children(){var C=det();return S(C,h(Yt,{name:"square-arrow-top-right",size:"small"})),C}}),null),he(C=>{var E=l(),_=a();return E!==C.e&&Ct(v,"--task-agent-color",C.e=E),_!==C.t&&Ct(v,"--task-agent-legacy-color",C.t=_),C},{e:void 0,t:void 0}),v})();return h(Hs,{icon:"task",get status(){return e.status},get trigger(){return y()},hideDetails:!0,triggerAsLink:!0,get triggerHref(){return d()},get clickable(){return f()},onTriggerClick:g,onTriggerKeyDown:p})}});mo.register({name:"shell",render(e){const t=Mn(),n=()=>e.status==="pending"||e.status==="running",r=n(),i=I(()=>{const l=e.input.command??e.metadata.command??"",c=VQe(e.output||e.metadata.output||"").replace(/\r\n?/g,`
1179
1179
  `);return`$ ${l}${c?`
1180
1180
 
1181
- `+c:""}`}),[s,o]=De(!1),a=async()=>{const l=i();l&&await VI(l)&&(o(!0),setTimeout(()=>o(!1),2e3))};return h(Hs,le(e,{icon:"console",allowOpenWhilePending:!0,trigger:l=>(()=>{var c=Une(),u=c.firstChild,d=u.firstChild;return S(d,h(xo,{get text(){return t.t("ui.tool.shell")},get active(){return n()}})),S(u,h(q,{get when(){return we(()=>!l())()&&e.input.command},get children(){return h(Tet,{get text(){return e.input.command},animate:r})}}),null),c})(),get children(){var l=met(),c=l.firstChild,u=c.nextSibling,d=u.firstChild,f=d.firstChild;return S(c,h(Qn,{get value(){return we(()=>!!s())()?t.t("ui.message.copied"):t.t("ui.message.copy")},placement:"top",get children(){return h(Lr,{get icon(){return h(on,{get name(){return s()?"check":"outline-copy"},size:"small"})},size:"normal",variant:"ghost-muted",onMouseDown:m=>m.preventDefault(),onClick:a,get"aria-label"(){return we(()=>!!s())()?t.t("ui.message.copied"):t.t("ui.message.copy")}})}})),S(f,i),he(()=>me(u,"aria-label",t.t("ui.scrollView.ariaLabel"))),l}}))}});mo.register({name:"edit",render(e){const t=Mn(),n=_d(),r=I(()=>Kne(e.metadata.diagnostics,e.input.filePath)),i=I(()=>e.metadata?.filediff?.file||e.input.filePath||""),s=()=>fn(e.input.filePath??""),o=()=>e.status==="pending"||e.status==="running",a=I(()=>{const c=e.metadata?.filediff;if(c)return{file:c.file||e.input.filePath||"",patch:typeof c.patch=="string"?c.patch:void 0,before:typeof c.before=="string"?c.before:void 0,after:typeof c.after=="string"?c.after:void 0}},void 0,{equals:(c,u)=>c?.file===u?.file&&c?.patch===u?.patch&&c?.before===u?.before&&c?.after===u?.after}),l=I(()=>{try{const c=a();if(c){const u=Nne(c);if(u)return{fileDiff:u,hunkSeparators:u.isPartial?"simple":"line-info-basic"}}}catch{}return{before:{name:e.metadata?.filediff?.file||e.input.filePath,contents:e.metadata?.filediff?.before||e.input.oldString||""},after:{name:e.metadata?.filediff?.file||e.input.filePath,contents:e.metadata?.filediff?.after||e.input.newString||""}}});return(()=>{var c=pet();return S(c,h(Hs,le(e,{icon:"code-lines",get defer(){return e.deferContent!==!1},get trigger(){return(()=>{var u=Wne(),d=u.firstChild,f=d.firstChild,m=f.firstChild,g=d.nextSibling;return S(m,h(xo,{get text(){return t.t("ui.messagePart.title.edit")},get active(){return o()}})),S(f,h(q,{get when(){return!o()},get children(){var p=FI();return S(p,s),p}}),null),S(d,h(q,{get when(){return we(()=>!o())()&&e.input.filePath?.includes("/")},get children(){var p=NI(),y=p.firstChild;return S(y,()=>yl(e.input.filePath)),p}}),null),S(g,h(q,{get when(){return we(()=>!o())()&&e.metadata.filediff},get children(){return h(Qc,{get changes(){return e.metadata.filediff}})}})),u})()},get children(){return[h(q,{get when(){return i()},get children(){return h(HI,{get path(){return i()},get actions(){return h(q,{get when(){return we(()=>!o())()&&e.metadata.filediff},get children(){return h(Qc,{get changes(){return e.metadata.filediff}})}})},get children(){var u=get();return S(u,h(Gi,le({component:n,mode:"diff",get virtualize(){return e.virtualizeDiff},get onRendered(){return e.onContentRendered}},l))),u}})}}),h(Gne,{get diagnostics(){return r()}})]}}))),c})()}});mo.register({name:"write",render(e){const t=Mn(),n=_d(),r=I(()=>Kne(e.metadata.diagnostics,e.input.filePath)),i=I(()=>e.input.filePath||""),s=()=>fn(e.input.filePath??""),o=()=>e.status==="pending"||e.status==="running";return(()=>{var a=yet();return S(a,h(Hs,le(e,{icon:"code-lines",get defer(){return e.deferContent!==!1},get trigger(){return(()=>{var l=bet(),c=l.firstChild,u=c.firstChild,d=u.firstChild;return S(d,h(xo,{get text(){return t.t("ui.messagePart.title.write")},get active(){return o()}})),S(u,h(q,{get when(){return!o()},get children(){var f=FI();return S(f,s),f}}),null),S(c,h(q,{get when(){return we(()=>!o())()&&e.input.filePath?.includes("/")},get children(){var f=NI(),m=f.firstChild;return S(m,()=>yl(e.input.filePath)),f}}),null),l})()},get children(){return[h(q,{get when(){return we(()=>!!e.input.content)()&&i()},get children(){return h(HI,{get path(){return i()},get children(){var l=vet();return S(l,h(Gi,{component:n,mode:"text",get file(){return{name:e.input.filePath,contents:e.input.content,cacheKey:so(e.input.content)}},overflow:"scroll",get onRendered(){return e.onContentRendered}})),l}})}}),h(Gne,{get diagnostics(){return r()}})]}}))),a})()}});mo.register({name:"patch",render(e){const t=Mn(),n=_d(),r=I(()=>LJe(e.metadata.files)),i=I(()=>e.status==="pending"||e.status==="running"),s=I(()=>{const u=r();if(u.length===1)return u[0]}),[o,a]=De([]);let l=!1;ae(()=>{const u=r();u.length!==0&&(l||(l=!0,a(u.filter(d=>d.type!=="delete").map(d=>d.filePath))))});const c=I(()=>{const u=r().length;return u===0?"":`${u} ${t.t(u>1?"ui.common.file.other":"ui.common.file.one")}`});return h(q,{get when(){return s()},get fallback(){return(()=>{var u=cN();return S(u,h(Hs,le(e,{icon:"code-lines",get defer(){return e.deferContent!==!1},get trigger(){return{title:t.t("ui.tool.patch"),subtitle:c()}},get children(){return h(q,{get when(){return r().length>0},get children(){return h(Ei,{multiple:!0,"data-scope":"apply-patch",style:{"--sticky-accordion-offset":"calc(32px + var(--tool-content-gap))"},get value(){return o()},onChange:d=>a(Array.isArray(d)?d:d?[d]:[]),get children(){return h(Dt,{get each(){return r()},children:d=>{const f=I(()=>o().includes(d.filePath)),[m,g]=De(!1);return ae(()=>{if(!f()){g(!1);return}requestAnimationFrame(()=>{f()&&g(!0)})}),h(Ei.Item,{get value(){return d.filePath},get"data-type"(){return d.type},get children(){return[h(my,{get children(){return h(Ei.Trigger,{get children(){var p=Bne(),y=p.firstChild,v=y.firstChild,b=v.firstChild,w=y.nextSibling;return S(y,h(Dr,{get node(){return{path:d.relativePath,type:"file"}}}),v),S(v,h(q,{get when(){return d.relativePath.includes("/")},get children(){var x=qne();return S(x,()=>`‪${yl(d.relativePath)}‬`),x}}),b),S(b,()=>fn(d.relativePath)),S(w,h(Rr,{get children(){return[h(zt,{get when(){return d.type==="add"},get children(){var x=uN();return S(x,()=>t.t("ui.patch.action.created")),x}}),h(zt,{get when(){return d.type==="delete"},get children(){var x=dN();return S(x,()=>t.t("ui.patch.action.deleted")),x}}),h(zt,{get when(){return d.type==="move"},get children(){var x=fN();return S(x,()=>t.t("ui.patch.action.moved")),x}}),h(zt,{when:!0,get children(){return h(Qc,{get changes(){return{additions:d.additions,deletions:d.deletions}}})}})]}}),null),S(w,h(Yt,{name:"chevron-grabber-vertical",size:"small"}),null),p}})}}),h(Ei.Content,{get children(){return h(q,{get when(){return e.deferContent===!1||m()},get children(){var p=lN();return S(p,h(Gi,{component:n,mode:"diff",get virtualize(){return e.virtualizeDiff},get fileDiff(){return d.view.fileDiff},get hunkSeparators(){return d.view.fileDiff.isPartial?"simple":"line-info-basic"},get onRendered(){return e.onContentRendered}})),p}})}})]}})}})}})}})}}))),u})()},get children(){var u=cN();return S(u,h(Hs,le(e,{icon:"code-lines",get defer(){return e.deferContent!==!1},get trigger(){return(()=>{var d=Wne(),f=d.firstChild,m=f.firstChild,g=m.firstChild,p=f.nextSibling;return S(g,h(xo,{get text(){return t.t("ui.tool.patch")},get active(){return i()}})),S(m,h(q,{get when(){return!i()},get children(){var y=FI();return S(y,()=>fn(s().relativePath)),y}}),null),S(f,h(q,{get when(){return we(()=>!i())()&&s().relativePath.includes("/")},get children(){var y=NI(),v=y.firstChild;return S(v,()=>yl(s().relativePath)),y}}),null),S(p,h(q,{get when(){return!i()},get children(){return h(Qc,{get changes(){return{additions:s().additions,deletions:s().deletions}}})}})),d})()},get children(){return h(HI,{get path(){return s().relativePath},get actions(){return h(Rr,{get children(){return[h(zt,{get when(){return s().type==="add"},get children(){var d=uN();return S(d,()=>t.t("ui.patch.action.created")),d}}),h(zt,{get when(){return s().type==="delete"},get children(){var d=dN();return S(d,()=>t.t("ui.patch.action.deleted")),d}}),h(zt,{get when(){return s().type==="move"},get children(){var d=fN();return S(d,()=>t.t("ui.patch.action.moved")),d}}),h(zt,{when:!0,get children(){return h(Qc,{get changes(){return{additions:s().additions,deletions:s().deletions}}})}})]}})},get children(){var d=lN();return S(d,h(Gi,{component:n,mode:"diff",get virtualize(){return e.virtualizeDiff},get fileDiff(){return s().view.fileDiff},get onRendered(){return e.onContentRendered}})),d}})}}))),u}})}});mo.register({name:"todowrite",render(e){const t=Mn(),n=I(()=>{const i=e.metadata?.todos;if(Array.isArray(i))return i;const s=e.input.todos;return Array.isArray(s)?s:[]}),r=I(()=>{const i=n();return i.length===0?"":`${i.filter(s=>s.status==="completed").length}/${i.length}`});return h(Hs,le(e,{defaultOpen:!0,icon:"checklist",get trigger(){return{title:t.t("ui.tool.todos"),subtitle:r()}},get children(){return h(q,{get when(){return n().length},get children(){var i=wet();return S(i,h(Dt,{get each(){return n()},children:s=>h(Lne,{readOnly:!0,get checked(){return s.status==="completed"},get children(){var o=xet();return S(o,()=>s.content),he(()=>me(o,"data-completed",s.status==="completed"?"completed":void 0)),o}})})),i}})}}))}});mo.register({name:"question",render(e){const t=Mn(),n=I(()=>e.input.questions??[]),r=I(()=>e.metadata.answers??[]),i=I(()=>r().length>0),s=I(()=>{const o=n().length;return o===0?"":i()?t.t("ui.question.subtitle.answered",{count:o}):`${o} ${t.t(o>1?"ui.common.question.other":"ui.common.question.one")}`});return h(Hs,le(e,{get defaultOpen(){return i()},icon:"bubble-5",get trigger(){return{title:t.t("ui.tool.questions"),subtitle:s()}},get children(){return h(q,{get when(){return i()},get children(){var o=ket();return S(o,h(Dt,{get each(){return n()},children:(a,l)=>{const c=()=>r()[l()]??[];return(()=>{var u=Cet(),d=u.firstChild,f=d.nextSibling;return S(d,()=>a.question),S(f,()=>c().join(", ")||t.t("ui.question.answer.none")),u})()}})),o}})}}))}});mo.register({name:"skill",render(e){const t=Mn(),n=I(()=>e.input.name||t.t("ui.tool.skill")),r=I(()=>e.status==="pending"||e.status==="running"),i=()=>h(xo,{get text(){return n()},get active(){return r()}}),s=()=>(()=>{var o=_et(),a=o.firstChild,l=a.firstChild;return S(l,i),o})();return h(Hs,{icon:"brain",get status(){return e.status},get trigger(){return s()},hideDetails:!0})}});dn(["click"]);var itt=A('<div data-slot=session-turn-retry-message class="cursor-help truncate">'),stt=A('<div class="flex items-start gap-2"><div class=min-w-0>'),ott=A("<div data-slot=session-turn-retry>"),att=A("<div data-slot=session-turn-retry-message>"),ltt=A("<div data-slot=session-turn-retry-info>");function ctt(e){const t=Mn(),n=I(()=>{if(e.status.type==="retry")return e.status}),[r,i]=De(0);ae(vt(n,l=>{if(!l)return;const c=()=>{const d=n()?.next;d&&i(Math.round((d-Date.now())/1e3))};c();const u=setInterval(c,1e3);Te(()=>clearInterval(u))}));const s=I(()=>{const l=n();return l?l.message.includes("exceeded your current quota")&&l.message.includes("gemini")?t.t("ui.sessionTurn.retry.geminiHot"):l.message.length>80?l.message.slice(0,80)+"...":l.message:""}),o=I(()=>{const l=n();return l?l.message.length>80:!1}),a=I(()=>{const l=n();if(!l)return"";const c=Math.max(0,r()),u=c>0?t.t("ui.sessionTurn.retry.inSeconds",{seconds:c}):"",f=[t.t("ui.sessionTurn.retry.retrying"),u].filter(Boolean).join(" ");return f?t.t("ui.sessionTurn.retry.attemptLine",{line:f,attempt:l.attempt}):t.t("ui.sessionTurn.retry.attempt",{attempt:l.attempt})});return h(q,{get when(){return we(()=>!!n())()&&(e.show??!0)},get children(){var l=ott();return S(l,h(OI,{variant:"error",class:"error-card",get children(){var c=stt(),u=c.firstChild;return S(c,h(Fd,{class:"size-4 mt-0.5"}),u),S(u,h(q,{get when(){return o()},get fallback(){return(()=>{var d=att();return S(d,s),d})()},get children(){return h(Ar,{get value(){return n()?.message??""},placement:"top",get children(){var d=itt();return S(d,s),d}})}}),null),S(u,h(q,{get when(){return a()},children:d=>(()=>{var f=ltt();return S(f,d),f})()}),null),c}})),l}})}const utt=e=>e.deltaMode===1?e.deltaY*40:e.deltaMode===2?e.deltaY*e.rootHeight:e.deltaY,dtt=e=>{const t=e.scrollHeight-e.clientHeight;if(t<=1)return!0;if(!e.delta)return!1;if(e.delta<0)return e.scrollTop+e.delta<=0;const n=t-e.scrollTop;return e.delta>n};var ftt=A("<svg><circle cx=8 cy=8 data-slot=progress-circle-background></circle><circle cx=8 cy=8 data-slot=progress-circle-background-overlay></circle><circle cx=8 cy=8 data-slot=progress-circle-progress>");function htt(e){const[t,n]=Ee(e,["percentage","size","strokeWidth","class","classList"]),r=()=>t.size||16,i=()=>t.strokeWidth||3,o=16/2,a=()=>o-i()/2,l=I(()=>2*Math.PI*a()),c=I(()=>{const d=Math.max(0,Math.min(100,t.percentage||0))/100;return l()*(1-d)});return(()=>{var u=ftt(),d=u.firstChild,f=d.nextSibling,m=f.nextSibling;return An(u,le(n,{get width(){return r()},get height(){return r()},viewBox:"0 0 16 16",fill:"none","data-component":"progress-circle",get classList(){return{...t.classList,[t.class??""]:!!t.class}}}),!0,!0),he(g=>{var p=a(),y=i(),v=a(),b=i(),w=a(),x=i(),k=l().toString(),C=c();return p!==g.e&&me(d,"r",g.e=p),y!==g.t&&me(d,"stroke-width",g.t=y),v!==g.a&&me(f,"r",g.a=v),b!==g.o&&me(f,"stroke-width",g.o=b),w!==g.i&&me(m,"r",g.i=w),x!==g.n&&me(m,"stroke-width",g.n=x),k!==g.s&&me(m,"stroke-dasharray",g.s=k),C!==g.h&&me(m,"stroke-dashoffset",g.h=C),g},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0}),u})()}var mtt=A("<svg><circle cx=7 cy=7 data-slot=progress-circle-v2-background></circle><circle cx=7 cy=7 data-slot=progress-circle-v2-progress>");function gtt(e){const[t,n]=Ee(e,["percentage","size","strokeWidth","class","classList"]),r=()=>t.size??14,i=()=>t.strokeWidth??1.5,o=14/2,a=()=>o-i()/2,l=I(()=>2*Math.PI*a()),c=I(()=>l()*(1-Math.max(0,Math.min(100,t.percentage||0))/100));return(()=>{var u=mtt(),d=u.firstChild,f=d.nextSibling;return An(u,le(n,{get width(){return r()},get height(){return r()},viewBox:"0 0 14 14",fill:"none","data-component":"progress-circle-v2",get classList(){return{...t.classList,[t.class??""]:!!t.class}}}),!0,!0),he(m=>{var g=a(),p=i(),y=a(),v=i(),b=l().toString(),w=c();return g!==m.e&&me(d,"r",m.e=g),p!==m.t&&me(d,"stroke-width",m.t=p),y!==m.a&&me(f,"r",m.a=y),v!==m.o&&me(f,"stroke-width",m.o=v),b!==m.i&&me(f,"stroke-dasharray",m.i=b),w!==m.n&&me(f,"stroke-dashoffset",m.n=w),m},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),u})()}var ptt=A('<div class="flex min-w-0 items-center gap-4"><span class="shrink-0 text-v2-text-text-muted"></span><span class="ml-auto min-w-0 truncate text-right text-v2-text-text-base">'),bN=A('<div class="flex items-center justify-center">'),vtt=A('<div class="flex w-[120px] flex-col gap-2">');function r6(e){return(()=>{var t=ptt(),n=t.firstChild,r=n.nextSibling;return S(n,()=>e.name),S(r,()=>e.value),t})()}function ytt(e){e.view.reviewPanel.open(e.view.reviewPanel.opened()?"other":"context-button"),e.layout.fileTree.opened()&&e.layout.fileTree.tab()!=="all"&&e.layout.fileTree.setTab("all"),e.tabs.open("context"),e.tabs.setActive("context")}function RC(e){const t=Ji(),n=ua(),r=li(),i=wt(),s=kr(),o=ar(),a=$d(()=>s().directory),{params:l,tabs:c,view:u}=ga(),d=uu("(min-width: 768px)"),f=I(()=>e.variant??"button"),m=I(()=>e.buttonAppearance??"default"),g=Nd({tabs:c,pathFromTab:n.pathFromTab,normalizeTab:O=>O.startsWith("file://")?n.tab(O):O,fileBrowser:()=>o.general.newLayoutDesigns()&&d()&&!!l.id}),p=I(()=>l.id?t().data.message[l.id]??[]:[]),y=I(()=>l.id?t().session.get(l.id):void 0),v=I(()=>new Intl.NumberFormat(i.intl(),{style:"currency",currency:"USD"})),b=I(()=>jee(p(),[...a.all().values()])),w=I(()=>v().format(y()?.cost??0)),x=I(()=>u().reviewPanel.opened()&&g.activeTab()==="context"),k=I(()=>c().all().some(O=>O!=="context"&&O!=="review")),C=()=>{if(!l.id)return;const O=u();if(x()){c().close("context"),O.reviewPanel.source()==="context-button"&&!k()&&O.reviewPanel.close();return}ytt({view:O,layout:r,tabs:c()})},E=()=>(()=>{var O=bN();return S(O,h(htt,{size:16,strokeWidth:2,get percentage(){return b()?.usage??0},get style(){return f()==="indicator"?{"--progress-circle-background":"var(--v2-background-bg-layer-04, var(--border-weak-base))","--progress-circle-background-overlay":"var(--v2-overlay-simple-overlay-pressed, transparent)","--progress-circle-progress":"var(--v2-icon-icon-base, var(--icon-base))"}:void 0}})),O})(),_=()=>(()=>{var O=bN();return S(O,h(gtt,{get percentage(){return b()?.usage??0}})),O})(),L=()=>(()=>{var O=vtt();return S(O,h(r6,{get name(){return i.t("context.usage.cost")},get value(){return w()}}),null),S(O,h(r6,{get name(){return i.t("context.usage.usage")},get value(){return`${b()?.usage??0}%`}}),null),S(O,h(r6,{get name(){return i.t("context.usage.tokens")},get value(){return b()?.total.toLocaleString(i.intl())??"0"}}),null),O})();return h(q,{get when(){return l.id},get children(){return h(Qn,{get value(){return L()},get placement(){return e.placement??"top"},shift:-8,get children(){return h(Rr,{get children(){return[h(zt,{get when(){return f()==="indicator"},get children(){return E()}}),h(zt,{get when(){return m()==="v2"},get children(){return h(Lr,{type:"button",variant:"ghost-muted",size:"large",get icon(){return _()},onClick:C,get"aria-label"(){return i.t("context.usage.view")}})}}),h(zt,{when:!0,get children(){return h(Kt,{type:"button",variant:"ghost",class:"size-6",onClick:C,get"aria-label"(){return i.t("context.usage.view")},get children(){return E()}})}})]}})}})}})}function btt(e,t){return requestAnimationFrame(()=>{e.isConnected&&t(e)})}function wtt(e,t){let n=!0;const r=(m,g)=>{n&&t(m,g)},i=Mne(e,r),s=e.scrollElement,o=e.targetWindow,a=s?.closest("main")??s?.ownerDocument.body;if(!s||!o||!a)return()=>{n=!1,i?.()};let l=!1,c;const u=()=>{c!==void 0&&(o.cancelAnimationFrame(c),c=void 0)},d=()=>{u();const m=o.performance.now()+e.options.isScrollingResetDelay;let g=0;const p=y=>{if(c=void 0,s.isConnected){const v=e.options.horizontal?s.scrollLeft*(e.options.isRtl?-1:1):s.scrollTop;(e.scrollOffset===null||Math.abs(v-e.scrollOffset)>1)&&r(v,!1)}y>=m&&(g+=1),!(g>=2)&&(c=o.requestAnimationFrame(p))};c=o.requestAnimationFrame(p)},f=new o.MutationObserver(m=>{n&&m.forEach(g=>{g.target===s||s.contains(g.target)||(wN(g.removedNodes,s)&&(l=!0,u()),!(!l||!s.isConnected||!wN(g.addedNodes,s))&&(l=!1,d()))})});return f.observe(a,{childList:!0,subtree:!0}),()=>{n=!1,f.disconnect(),u(),i?.()}}function wN(e,t){return[...e].some(n=>n===t||n.contains(t))}var xi;(e=>{class t extends Cc("TurnGap"){}e.TurnGap=t;class n extends Cc("CommentStrip"){}e.CommentStrip=n;class r extends Cc("UserMessage"){}e.UserMessage=r;class i extends Cc("TurnDivider"){}e.TurnDivider=i;class s extends Cc("AssistantPart"){}e.AssistantPart=s;class o extends Cc("Thinking"){}e.Thinking=o;class a extends Cc("DiffSummary"){}e.DiffSummary=a;class l extends Cc("Error"){}e.Error=l;class c extends Cc("Retry"){}e.Retry=c,e.key=d=>{switch(d._tag){case"TurnGap":return`turn-gap:${d.userMessageID}`;case"CommentStrip":return`comment-strip:${d.userMessageID}`;case"UserMessage":return`user-message:${d.userMessageID}`;case"TurnDivider":return`turn-divider:${d.userMessageID}:${d.label}`;case"AssistantPart":return`assistant-part:${d.userMessageID}:${d.group.key}`;case"Thinking":return`thinking:${d.userMessageID}`;case"DiffSummary":return`diff-summary:${d.userMessageID}`;case"Error":return`error:${d.userMessageID}`;case"Retry":return`retry:${d.userMessageID}`}};function u(d,f){return oa(d,f)}e.equals=u})(xi||(xi={}));function xtt(e,t){if(!e?.length)return t;const n=new Map(e.map(a=>[xi.key(a),a])),r=new Map;e.forEach((a,l)=>{a._tag!=="AssistantPart"||a.group.type!=="context"||a.group.refs.forEach(c=>r.set(`${a.userMessageID}:${c.partID}`,{index:l,row:a}))});const i=new Map;t.forEach((a,l)=>{if(a._tag!=="AssistantPart"||a.group.type!=="context")return;const c=xi.key(a);n.has(c)&&!i.has(c)&&i.set(c,l)});const s=new Set,o=t.map((a,l)=>{const c=ktt(r,i,a,l,s),u=n.get(xi.key(c));return u&&xi.equals(u,c)?u:c});return e.length===o.length&&e.every((a,l)=>a===o[l])?e:o}function ktt(e,t,n,r,i){if(n._tag!=="AssistantPart"||n.group.type!=="context")return n;const s=n.group.refs.reduce((a,l)=>{const c=e.get(`${n.userMessageID}:${l.partID}`);if(!c)return a;const u=xi.key(c.row);if(i.has(u))return a;const d=t.get(u);return d!==void 0&&d!==r?a:!a||c.index<a.index?c:a},void 0);if(!s)return n;const o=xi.key(s.row);return i.add(o),n.group.key===s.row.group.key?n:new xi.AssistantPart({...n,group:{...n.group,key:s.row.group.key}})}function Stt(e){const t=new Set;return(e??[]).reduceRight((n,r)=>{if(!Ctt(r))return n;const i=r.file;return t.has(i)||(t.add(i),n.push(r)),n},[]).reverse()}function Ctt(e){return typeof e.file=="string"}var FC;(e=>{function t(a,l,c,u,d,f,m){const g=[],p=new Map;a.forEach(b=>{const w=l(b.id);if(b.type==="shell"&&w?.role==="user"){const E=l(`${b.id}:assistant`),_={user:w,assistants:E?.role==="assistant"?[E]:[]};g.push(_),p.set(w.id,_);return}if(w?.role==="user"){if(p.has(w.id))return;const E={user:w,assistants:[]};g.push(E),p.set(w.id,E);return}if(w?.role!=="assistant")return;const x=p.get(w.parentID);if(x){x.assistants.push(w);return}const k=l(w.parentID);if(k?.role!=="user")return;const C={user:k,assistants:[w]};g.push(C),p.set(k.id,C)});const y=g.at(-1)?.user.id;m.forEach(b=>{if(p.has(b.id)||y&&b.id<y)return;const w={user:b,assistants:[]};g.push(w),p.set(b.id,w)});const v=g.at(-1)?.user.id;return{activeMessageID:v,rows:g.flatMap((b,w)=>n(b.user,c,b.assistants,w,u,d,b.user.id===v,f))}}e.constructSessionMessageRows=t;function n(a,l,c,u,d,f,m,g){const p=[],y=u>0,v=l(a.id),b=v.flatMap($=>g1.fromPart($)??[]),w=v.some($=>$.type==="compaction"),x=c.findIndex($=>$.error?.name==="MessageAbortedError"),k=x!==-1,C=c.find($=>$.error&&$.error.name!=="MessageAbortedError")?.error,E=c.flatMap(($,V)=>l($.id).filter(P=>ere(P,d)).map(P=>({messageID:$.id,messageIndex:V,part:P}))),_=k&&!w?[...W2(E.filter($=>$.messageIndex<=x)).map($=>({type:"part",group:$})),{type:"interrupted"},...W2(E.filter($=>$.messageIndex>x)).map($=>({type:"part",group:$}))]:W2(E).map($=>({type:"part",group:$}));y&&p.push(new xi.TurnGap({userMessageID:a.id})),b.length>0&&!g&&p.push(new xi.CommentStrip({userMessageID:a.id})),p.push(new xi.UserMessage({userMessageID:a.id,anchor:g||b.length===0})),w&&p.push(new xi.TurnDivider({userMessageID:a.id,label:"compaction"}));let L=0;if(_.forEach($=>{if($.type==="interrupted"){p.push(new xi.TurnDivider({userMessageID:a.id,label:"interrupted"}));return}p.push(new xi.AssistantPart({userMessageID:a.id,group:$.group,previousAssistantPart:L>0})),L+=1}),m&&f==="busy"&&!C&&(!d||E.length===0)){const $=c.flatMap(V=>l(V.id)).map(V=>V.type==="reasoning"&&V.text?r(V.text):void 0).find(V=>!!V);p.push(new xi.Thinking({userMessageID:a.id,reasoningHeading:$}))}m&&f==="retry"&&p.push(new xi.Retry({userMessageID:a.id}));const O=Stt(a.summary?.diffs);if(O.length>0&&(f==="idle"||!m)&&p.push(new xi.DiffSummary({userMessageID:a.id,diffs:O})),C){const $=C.data?.message;p.push(new xi.Error({userMessageID:a.id,text:s(typeof $=="string"?$:$==null?"":String($))}))}return p}e.constructMessageRows=n;function r(a){const l=a.replace(/\r\n?/g,`
1181
+ `+c:""}`}),[s,o]=De(!1),a=async()=>{const l=i();l&&await VI(l)&&(o(!0),setTimeout(()=>o(!1),2e3))};return h(Hs,le(e,{icon:"console",allowOpenWhilePending:!0,trigger:l=>(()=>{var c=Une(),u=c.firstChild,d=u.firstChild;return S(d,h(xo,{get text(){return t.t("ui.tool.shell")},get active(){return n()}})),S(u,h(q,{get when(){return we(()=>!l())()&&e.input.command},get children(){return h(Tet,{get text(){return e.input.command},animate:r})}}),null),c})(),get children(){var l=met(),c=l.firstChild,u=c.nextSibling,d=u.firstChild,f=d.firstChild;return S(c,h(Qn,{get value(){return we(()=>!!s())()?t.t("ui.message.copied"):t.t("ui.message.copy")},placement:"top",get children(){return h(Lr,{get icon(){return h(on,{get name(){return s()?"check":"outline-copy"},size:"small"})},size:"normal",variant:"ghost-muted",onMouseDown:m=>m.preventDefault(),onClick:a,get"aria-label"(){return we(()=>!!s())()?t.t("ui.message.copied"):t.t("ui.message.copy")}})}})),S(f,i),he(()=>me(u,"aria-label",t.t("ui.scrollView.ariaLabel"))),l}}))}});mo.register({name:"edit",render(e){const t=Mn(),n=_d(),r=I(()=>Kne(e.metadata.diagnostics,e.input.filePath)),i=I(()=>e.metadata?.filediff?.file||e.input.filePath||""),s=()=>fn(e.input.filePath??""),o=()=>e.status==="pending"||e.status==="running",a=I(()=>{const c=e.metadata?.filediff;if(c)return{file:c.file||e.input.filePath||"",patch:typeof c.patch=="string"?c.patch:void 0,before:typeof c.before=="string"?c.before:void 0,after:typeof c.after=="string"?c.after:void 0}},void 0,{equals:(c,u)=>c?.file===u?.file&&c?.patch===u?.patch&&c?.before===u?.before&&c?.after===u?.after}),l=I(()=>{try{const c=a();if(c){const u=Nne(c);if(u)return{fileDiff:u,hunkSeparators:u.isPartial?"simple":"line-info-basic"}}}catch{}return{before:{name:e.metadata?.filediff?.file||e.input.filePath,contents:e.metadata?.filediff?.before||e.input.oldString||""},after:{name:e.metadata?.filediff?.file||e.input.filePath,contents:e.metadata?.filediff?.after||e.input.newString||""}}});return(()=>{var c=pet();return S(c,h(Hs,le(e,{icon:"code-lines",get defer(){return e.deferContent!==!1},get trigger(){return(()=>{var u=Wne(),d=u.firstChild,f=d.firstChild,m=f.firstChild,g=d.nextSibling;return S(m,h(xo,{get text(){return t.t("ui.messagePart.title.edit")},get active(){return o()}})),S(f,h(q,{get when(){return!o()},get children(){var p=FI();return S(p,s),p}}),null),S(d,h(q,{get when(){return we(()=>!o())()&&e.input.filePath?.includes("/")},get children(){var p=NI(),y=p.firstChild;return S(y,()=>yl(e.input.filePath)),p}}),null),S(g,h(q,{get when(){return we(()=>!o())()&&e.metadata.filediff},get children(){return h(Qc,{get changes(){return e.metadata.filediff}})}})),u})()},get children(){return[h(q,{get when(){return i()},get children(){return h(HI,{get path(){return i()},get actions(){return h(q,{get when(){return we(()=>!o())()&&e.metadata.filediff},get children(){return h(Qc,{get changes(){return e.metadata.filediff}})}})},get children(){var u=get();return S(u,h(Gi,le({component:n,mode:"diff",get virtualize(){return e.virtualizeDiff},get onRendered(){return e.onContentRendered}},l))),u}})}}),h(Gne,{get diagnostics(){return r()}})]}}))),c})()}});mo.register({name:"write",render(e){const t=Mn(),n=_d(),r=I(()=>Kne(e.metadata.diagnostics,e.input.filePath)),i=I(()=>e.input.filePath||""),s=()=>fn(e.input.filePath??""),o=()=>e.status==="pending"||e.status==="running";return(()=>{var a=yet();return S(a,h(Hs,le(e,{icon:"code-lines",get defer(){return e.deferContent!==!1},get trigger(){return(()=>{var l=bet(),c=l.firstChild,u=c.firstChild,d=u.firstChild;return S(d,h(xo,{get text(){return t.t("ui.messagePart.title.write")},get active(){return o()}})),S(u,h(q,{get when(){return!o()},get children(){var f=FI();return S(f,s),f}}),null),S(c,h(q,{get when(){return we(()=>!o())()&&e.input.filePath?.includes("/")},get children(){var f=NI(),m=f.firstChild;return S(m,()=>yl(e.input.filePath)),f}}),null),l})()},get children(){return[h(q,{get when(){return we(()=>!!e.input.content)()&&i()},get children(){return h(HI,{get path(){return i()},get children(){var l=vet();return S(l,h(Gi,{component:n,mode:"text",get file(){return{name:e.input.filePath,contents:e.input.content,cacheKey:so(e.input.content)}},overflow:"scroll",get onRendered(){return e.onContentRendered}})),l}})}}),h(Gne,{get diagnostics(){return r()}})]}}))),a})()}});mo.register({name:"patch",render(e){const t=Mn(),n=_d(),r=I(()=>LJe(e.metadata.files)),i=I(()=>e.status==="pending"||e.status==="running"),s=I(()=>{const u=r();if(u.length===1)return u[0]}),[o,a]=De([]);let l=!1;ae(()=>{const u=r();u.length!==0&&(l||(l=!0,a(u.filter(d=>d.type!=="delete").map(d=>d.filePath))))});const c=I(()=>{const u=r().length;return u===0?"":`${u} ${t.t(u>1?"ui.common.file.other":"ui.common.file.one")}`});return h(q,{get when(){return s()},get fallback(){return(()=>{var u=cN();return S(u,h(Hs,le(e,{icon:"code-lines",get defer(){return e.deferContent!==!1},get trigger(){return{title:t.t("ui.tool.patch"),subtitle:c()}},get children(){return h(q,{get when(){return r().length>0},get children(){return h(Ei,{multiple:!0,"data-scope":"apply-patch",style:{"--sticky-accordion-offset":"calc(32px + var(--tool-content-gap))"},get value(){return o()},onChange:d=>a(Array.isArray(d)?d:d?[d]:[]),get children(){return h(Dt,{get each(){return r()},children:d=>{const f=I(()=>o().includes(d.filePath)),[m,g]=De(!1);return ae(()=>{if(!f()){g(!1);return}requestAnimationFrame(()=>{f()&&g(!0)})}),h(Ei.Item,{get value(){return d.filePath},get"data-type"(){return d.type},get children(){return[h(my,{get children(){return h(Ei.Trigger,{get children(){var p=Bne(),y=p.firstChild,v=y.firstChild,b=v.firstChild,w=y.nextSibling;return S(y,h(Dr,{get node(){return{path:d.relativePath,type:"file"}}}),v),S(v,h(q,{get when(){return d.relativePath.includes("/")},get children(){var x=qne();return S(x,()=>`‪${yl(d.relativePath)}‬`),x}}),b),S(b,()=>fn(d.relativePath)),S(w,h(Rr,{get children(){return[h(zt,{get when(){return d.type==="add"},get children(){var x=uN();return S(x,()=>t.t("ui.patch.action.created")),x}}),h(zt,{get when(){return d.type==="delete"},get children(){var x=dN();return S(x,()=>t.t("ui.patch.action.deleted")),x}}),h(zt,{get when(){return d.type==="move"},get children(){var x=fN();return S(x,()=>t.t("ui.patch.action.moved")),x}}),h(zt,{when:!0,get children(){return h(Qc,{get changes(){return{additions:d.additions,deletions:d.deletions}}})}})]}}),null),S(w,h(Yt,{name:"chevron-grabber-vertical",size:"small"}),null),p}})}}),h(Ei.Content,{get children(){return h(q,{get when(){return e.deferContent===!1||m()},get children(){var p=lN();return S(p,h(Gi,{component:n,mode:"diff",get virtualize(){return e.virtualizeDiff},get fileDiff(){return d.view.fileDiff},get hunkSeparators(){return d.view.fileDiff.isPartial?"simple":"line-info-basic"},get onRendered(){return e.onContentRendered}})),p}})}})]}})}})}})}})}}))),u})()},get children(){var u=cN();return S(u,h(Hs,le(e,{icon:"code-lines",get defer(){return e.deferContent!==!1},get trigger(){return(()=>{var d=Wne(),f=d.firstChild,m=f.firstChild,g=m.firstChild,p=f.nextSibling;return S(g,h(xo,{get text(){return t.t("ui.tool.patch")},get active(){return i()}})),S(m,h(q,{get when(){return!i()},get children(){var y=FI();return S(y,()=>fn(s().relativePath)),y}}),null),S(f,h(q,{get when(){return we(()=>!i())()&&s().relativePath.includes("/")},get children(){var y=NI(),v=y.firstChild;return S(v,()=>yl(s().relativePath)),y}}),null),S(p,h(q,{get when(){return!i()},get children(){return h(Qc,{get changes(){return{additions:s().additions,deletions:s().deletions}}})}})),d})()},get children(){return h(HI,{get path(){return s().relativePath},get actions(){return h(Rr,{get children(){return[h(zt,{get when(){return s().type==="add"},get children(){var d=uN();return S(d,()=>t.t("ui.patch.action.created")),d}}),h(zt,{get when(){return s().type==="delete"},get children(){var d=dN();return S(d,()=>t.t("ui.patch.action.deleted")),d}}),h(zt,{get when(){return s().type==="move"},get children(){var d=fN();return S(d,()=>t.t("ui.patch.action.moved")),d}}),h(zt,{when:!0,get children(){return h(Qc,{get changes(){return{additions:s().additions,deletions:s().deletions}}})}})]}})},get children(){var d=lN();return S(d,h(Gi,{component:n,mode:"diff",get virtualize(){return e.virtualizeDiff},get fileDiff(){return s().view.fileDiff},get onRendered(){return e.onContentRendered}})),d}})}}))),u}})}});mo.register({name:"todowrite",render(e){const t=Mn(),n=I(()=>{const i=e.metadata?.todos;if(Array.isArray(i))return i;const s=e.input.todos;return Array.isArray(s)?s:[]}),r=I(()=>{const i=n();return i.length===0?"":`${i.filter(s=>s.status==="completed").length}/${i.length}`});return h(Hs,le(e,{defaultOpen:!0,icon:"checklist",get trigger(){return{title:t.t("ui.tool.todos"),subtitle:r()}},get children(){return h(q,{get when(){return n().length},get children(){var i=wet();return S(i,h(Dt,{get each(){return n()},children:s=>h(Lne,{readOnly:!0,get checked(){return s.status==="completed"},get children(){var o=xet();return S(o,()=>s.content),he(()=>me(o,"data-completed",s.status==="completed"?"completed":void 0)),o}})})),i}})}}))}});mo.register({name:"question",render(e){const t=Mn(),n=I(()=>e.input.questions??[]),r=I(()=>e.metadata.answers??[]),i=I(()=>r().length>0),s=I(()=>{const o=n().length;return o===0?"":i()?t.t("ui.question.subtitle.answered",{count:o}):`${o} ${t.t(o>1?"ui.common.question.other":"ui.common.question.one")}`});return h(Hs,le(e,{get defaultOpen(){return i()},icon:"bubble-5",get trigger(){return{title:t.t("ui.tool.questions"),subtitle:s()}},get children(){return h(q,{get when(){return i()},get children(){var o=ket();return S(o,h(Dt,{get each(){return n()},children:(a,l)=>{const c=()=>r()[l()]??[];return(()=>{var u=Cet(),d=u.firstChild,f=d.nextSibling;return S(d,()=>a.question),S(f,()=>c().join(", ")||t.t("ui.question.answer.none")),u})()}})),o}})}}))}});mo.register({name:"skill",render(e){const t=Mn(),n=I(()=>e.input.name||t.t("ui.tool.skill")),r=I(()=>e.status==="pending"||e.status==="running"),i=()=>h(xo,{get text(){return n()},get active(){return r()}}),s=()=>(()=>{var o=_et(),a=o.firstChild,l=a.firstChild;return S(l,i),o})();return h(Hs,{icon:"brain",get status(){return e.status},get trigger(){return s()},hideDetails:!0})}});dn(["click"]);var itt=A('<div data-slot=session-turn-retry-message class="cursor-help truncate">'),stt=A('<div class="flex items-start gap-2"><div class=min-w-0>'),ott=A("<div data-slot=session-turn-retry>"),att=A("<div data-slot=session-turn-retry-message>"),ltt=A("<div data-slot=session-turn-retry-info>");function ctt(e){const t=Mn(),n=I(()=>{if(e.status.type==="retry")return e.status}),[r,i]=De(0);ae(vt(n,l=>{if(!l)return;const c=()=>{const d=n()?.next;d&&i(Math.round((d-Date.now())/1e3))};c();const u=setInterval(c,1e3);Te(()=>clearInterval(u))}));const s=I(()=>{const l=n();return l?l.message.includes("exceeded your current quota")&&l.message.includes("gemini")?t.t("ui.sessionTurn.retry.geminiHot"):l.message.length>80?l.message.slice(0,80)+"...":l.message:""}),o=I(()=>{const l=n();return l?l.message.length>80:!1}),a=I(()=>{const l=n();if(!l)return"";const c=Math.max(0,r()),u=c>0?t.t("ui.sessionTurn.retry.inSeconds",{seconds:c}):"",f=[t.t("ui.sessionTurn.retry.retrying"),u].filter(Boolean).join(" ");return f?t.t("ui.sessionTurn.retry.attemptLine",{line:f,attempt:l.attempt}):t.t("ui.sessionTurn.retry.attempt",{attempt:l.attempt})});return h(q,{get when(){return we(()=>!!n())()&&(e.show??!0)},get children(){var l=ott();return S(l,h(OI,{variant:"error",class:"error-card",get children(){var c=stt(),u=c.firstChild;return S(c,h(Fd,{class:"size-4 mt-0.5"}),u),S(u,h(q,{get when(){return o()},get fallback(){return(()=>{var d=att();return S(d,s),d})()},get children(){return h(Ar,{get value(){return n()?.message??""},placement:"top",get children(){var d=itt();return S(d,s),d}})}}),null),S(u,h(q,{get when(){return a()},children:d=>(()=>{var f=ltt();return S(f,d),f})()}),null),c}})),l}})}const utt=e=>e.deltaMode===1?e.deltaY*40:e.deltaMode===2?e.deltaY*e.rootHeight:e.deltaY,dtt=e=>{const t=e.scrollHeight-e.clientHeight;if(t<=1)return!0;if(!e.delta)return!1;if(e.delta<0)return e.scrollTop+e.delta<=0;const n=t-e.scrollTop;return e.delta>n};var ftt=A("<svg><circle cx=8 cy=8 data-slot=progress-circle-background></circle><circle cx=8 cy=8 data-slot=progress-circle-background-overlay></circle><circle cx=8 cy=8 data-slot=progress-circle-progress>");function htt(e){const[t,n]=Ee(e,["percentage","size","strokeWidth","class","classList"]),r=()=>t.size||16,i=()=>t.strokeWidth||3,o=16/2,a=()=>o-i()/2,l=I(()=>2*Math.PI*a()),c=I(()=>{const d=Math.max(0,Math.min(100,t.percentage||0))/100;return l()*(1-d)});return(()=>{var u=ftt(),d=u.firstChild,f=d.nextSibling,m=f.nextSibling;return An(u,le(n,{get width(){return r()},get height(){return r()},viewBox:"0 0 16 16",fill:"none","data-component":"progress-circle",get classList(){return{...t.classList,[t.class??""]:!!t.class}}}),!0,!0),he(g=>{var p=a(),y=i(),v=a(),b=i(),w=a(),x=i(),k=l().toString(),C=c();return p!==g.e&&me(d,"r",g.e=p),y!==g.t&&me(d,"stroke-width",g.t=y),v!==g.a&&me(f,"r",g.a=v),b!==g.o&&me(f,"stroke-width",g.o=b),w!==g.i&&me(m,"r",g.i=w),x!==g.n&&me(m,"stroke-width",g.n=x),k!==g.s&&me(m,"stroke-dasharray",g.s=k),C!==g.h&&me(m,"stroke-dashoffset",g.h=C),g},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0}),u})()}var mtt=A("<svg><circle cx=7 cy=7 data-slot=progress-circle-v2-background></circle><circle cx=7 cy=7 data-slot=progress-circle-v2-progress>");function gtt(e){const[t,n]=Ee(e,["percentage","size","strokeWidth","class","classList"]),r=()=>t.size??14,i=()=>t.strokeWidth??1.5,o=14/2,a=()=>o-i()/2,l=I(()=>2*Math.PI*a()),c=I(()=>l()*(1-Math.max(0,Math.min(100,t.percentage||0))/100));return(()=>{var u=mtt(),d=u.firstChild,f=d.nextSibling;return An(u,le(n,{get width(){return r()},get height(){return r()},viewBox:"0 0 14 14",fill:"none","data-component":"progress-circle-v2",get classList(){return{...t.classList,[t.class??""]:!!t.class}}}),!0,!0),he(m=>{var g=a(),p=i(),y=a(),v=i(),b=l().toString(),w=c();return g!==m.e&&me(d,"r",m.e=g),p!==m.t&&me(d,"stroke-width",m.t=p),y!==m.a&&me(f,"r",m.a=y),v!==m.o&&me(f,"stroke-width",m.o=v),b!==m.i&&me(f,"stroke-dasharray",m.i=b),w!==m.n&&me(f,"stroke-dashoffset",m.n=w),m},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),u})()}var ptt=A('<div class="flex min-w-0 items-center gap-4"><span class="shrink-0 text-v2-text-text-muted"></span><span class="ml-auto min-w-0 truncate text-right text-v2-text-text-base">'),bN=A('<div class="flex items-center justify-center">'),vtt=A('<div class="flex w-[120px] flex-col gap-2">');function r6(e){return(()=>{var t=ptt(),n=t.firstChild,r=n.nextSibling;return S(n,()=>e.name),S(r,()=>e.value),t})()}function ytt(e){e.view.reviewPanel.open(e.view.reviewPanel.opened()?"other":"context-button"),e.layout.fileTree.opened()&&e.layout.fileTree.tab()!=="all"&&e.layout.fileTree.setTab("all"),e.tabs.open("context"),e.tabs.setActive("context")}function RC(e){const t=Ji(),n=ua(),r=li(),i=wt(),s=kr(),o=ar(),a=$d(()=>s().directory),{params:l,tabs:c,view:u}=ga(),d=uu("(min-width: 768px)"),f=I(()=>e.variant??"button"),m=I(()=>e.buttonAppearance??"default"),g=Nd({tabs:c,pathFromTab:n.pathFromTab,normalizeTab:O=>O.startsWith("file://")?n.tab(O):O,fileBrowser:()=>o.general.newLayoutDesigns()&&d()&&!!l.id}),p=I(()=>l.id?t().data.message[l.id]??[]:[]),y=I(()=>l.id?t().session.get(l.id):void 0),v=I(()=>new Intl.NumberFormat(i.intl(),{style:"currency",currency:"USD"})),b=I(()=>jee(p(),[...a.all().values()])),w=I(()=>v().format(y()?.cost??0)),x=I(()=>u().reviewPanel.opened()&&g.activeTab()==="context"),k=I(()=>c().all().some(O=>O!=="context"&&O!=="review")),C=()=>{if(!l.id)return;const O=u();if(x()){c().close("context"),O.reviewPanel.source()==="context-button"&&!k()&&O.reviewPanel.close();return}ytt({view:O,layout:r,tabs:c()})},E=()=>(()=>{var O=bN();return S(O,h(htt,{size:16,strokeWidth:2,get percentage(){return b()?.usage??0},get style(){return f()==="indicator"?{"--progress-circle-background":"var(--v2-background-bg-layer-04, var(--border-weak-base))","--progress-circle-background-overlay":"var(--v2-overlay-simple-overlay-pressed, transparent)","--progress-circle-progress":"var(--v2-icon-icon-base, var(--icon-base))"}:void 0}})),O})(),_=()=>(()=>{var O=bN();return S(O,h(gtt,{get percentage(){return b()?.usage??0}})),O})(),L=()=>(()=>{var O=vtt();return S(O,h(r6,{get name(){return i.t("context.usage.cost")},get value(){return w()}}),null),S(O,h(r6,{get name(){return i.t("context.usage.usage")},get value(){return`${b()?.usage??0}%`}}),null),S(O,h(r6,{get name(){return i.t("context.usage.tokens")},get value(){return b()?.total.toLocaleString(i.intl())??"0"}}),null),O})();return h(q,{get when(){return l.id},get children(){return h(Qn,{get value(){return L()},get placement(){return e.placement??"top"},shift:-8,get children(){return h(Rr,{get children(){return[h(zt,{get when(){return f()==="indicator"},get children(){return E()}}),h(zt,{get when(){return m()==="v2"},get children(){return h(Lr,{type:"button",variant:"ghost-muted",size:"large",get icon(){return _()},onClick:function(){},get"aria-label"(){return i.t("context.usage.view")}})}}),h(zt,{when:!0,get children(){return h(Kt,{type:"button",variant:"ghost",class:"size-6",onClick:function(){},get"aria-label"(){return i.t("context.usage.view")},get children(){return E()}})}})]}})}})}})}function btt(e,t){return requestAnimationFrame(()=>{e.isConnected&&t(e)})}function wtt(e,t){let n=!0;const r=(m,g)=>{n&&t(m,g)},i=Mne(e,r),s=e.scrollElement,o=e.targetWindow,a=s?.closest("main")??s?.ownerDocument.body;if(!s||!o||!a)return()=>{n=!1,i?.()};let l=!1,c;const u=()=>{c!==void 0&&(o.cancelAnimationFrame(c),c=void 0)},d=()=>{u();const m=o.performance.now()+e.options.isScrollingResetDelay;let g=0;const p=y=>{if(c=void 0,s.isConnected){const v=e.options.horizontal?s.scrollLeft*(e.options.isRtl?-1:1):s.scrollTop;(e.scrollOffset===null||Math.abs(v-e.scrollOffset)>1)&&r(v,!1)}y>=m&&(g+=1),!(g>=2)&&(c=o.requestAnimationFrame(p))};c=o.requestAnimationFrame(p)},f=new o.MutationObserver(m=>{n&&m.forEach(g=>{g.target===s||s.contains(g.target)||(wN(g.removedNodes,s)&&(l=!0,u()),!(!l||!s.isConnected||!wN(g.addedNodes,s))&&(l=!1,d()))})});return f.observe(a,{childList:!0,subtree:!0}),()=>{n=!1,f.disconnect(),u(),i?.()}}function wN(e,t){return[...e].some(n=>n===t||n.contains(t))}var xi;(e=>{class t extends Cc("TurnGap"){}e.TurnGap=t;class n extends Cc("CommentStrip"){}e.CommentStrip=n;class r extends Cc("UserMessage"){}e.UserMessage=r;class i extends Cc("TurnDivider"){}e.TurnDivider=i;class s extends Cc("AssistantPart"){}e.AssistantPart=s;class o extends Cc("Thinking"){}e.Thinking=o;class a extends Cc("DiffSummary"){}e.DiffSummary=a;class l extends Cc("Error"){}e.Error=l;class c extends Cc("Retry"){}e.Retry=c,e.key=d=>{switch(d._tag){case"TurnGap":return`turn-gap:${d.userMessageID}`;case"CommentStrip":return`comment-strip:${d.userMessageID}`;case"UserMessage":return`user-message:${d.userMessageID}`;case"TurnDivider":return`turn-divider:${d.userMessageID}:${d.label}`;case"AssistantPart":return`assistant-part:${d.userMessageID}:${d.group.key}`;case"Thinking":return`thinking:${d.userMessageID}`;case"DiffSummary":return`diff-summary:${d.userMessageID}`;case"Error":return`error:${d.userMessageID}`;case"Retry":return`retry:${d.userMessageID}`}};function u(d,f){return oa(d,f)}e.equals=u})(xi||(xi={}));function xtt(e,t){if(!e?.length)return t;const n=new Map(e.map(a=>[xi.key(a),a])),r=new Map;e.forEach((a,l)=>{a._tag!=="AssistantPart"||a.group.type!=="context"||a.group.refs.forEach(c=>r.set(`${a.userMessageID}:${c.partID}`,{index:l,row:a}))});const i=new Map;t.forEach((a,l)=>{if(a._tag!=="AssistantPart"||a.group.type!=="context")return;const c=xi.key(a);n.has(c)&&!i.has(c)&&i.set(c,l)});const s=new Set,o=t.map((a,l)=>{const c=ktt(r,i,a,l,s),u=n.get(xi.key(c));return u&&xi.equals(u,c)?u:c});return e.length===o.length&&e.every((a,l)=>a===o[l])?e:o}function ktt(e,t,n,r,i){if(n._tag!=="AssistantPart"||n.group.type!=="context")return n;const s=n.group.refs.reduce((a,l)=>{const c=e.get(`${n.userMessageID}:${l.partID}`);if(!c)return a;const u=xi.key(c.row);if(i.has(u))return a;const d=t.get(u);return d!==void 0&&d!==r?a:!a||c.index<a.index?c:a},void 0);if(!s)return n;const o=xi.key(s.row);return i.add(o),n.group.key===s.row.group.key?n:new xi.AssistantPart({...n,group:{...n.group,key:s.row.group.key}})}function Stt(e){const t=new Set;return(e??[]).reduceRight((n,r)=>{if(!Ctt(r))return n;const i=r.file;return t.has(i)||(t.add(i),n.push(r)),n},[]).reverse()}function Ctt(e){return typeof e.file=="string"}var FC;(e=>{function t(a,l,c,u,d,f,m){const g=[],p=new Map;a.forEach(b=>{const w=l(b.id);if(b.type==="shell"&&w?.role==="user"){const E=l(`${b.id}:assistant`),_={user:w,assistants:E?.role==="assistant"?[E]:[]};g.push(_),p.set(w.id,_);return}if(w?.role==="user"){if(p.has(w.id))return;const E={user:w,assistants:[]};g.push(E),p.set(w.id,E);return}if(w?.role!=="assistant")return;const x=p.get(w.parentID);if(x){x.assistants.push(w);return}const k=l(w.parentID);if(k?.role!=="user")return;const C={user:k,assistants:[w]};g.push(C),p.set(k.id,C)});const y=g.at(-1)?.user.id;m.forEach(b=>{if(p.has(b.id)||y&&b.id<y)return;const w={user:b,assistants:[]};g.push(w),p.set(b.id,w)});const v=g.at(-1)?.user.id;return{activeMessageID:v,rows:g.flatMap((b,w)=>n(b.user,c,b.assistants,w,u,d,b.user.id===v,f))}}e.constructSessionMessageRows=t;function n(a,l,c,u,d,f,m,g){const p=[],y=u>0,v=l(a.id),b=v.flatMap($=>g1.fromPart($)??[]),w=v.some($=>$.type==="compaction"),x=c.findIndex($=>$.error?.name==="MessageAbortedError"),k=x!==-1,C=c.find($=>$.error&&$.error.name!=="MessageAbortedError")?.error,E=c.flatMap(($,V)=>l($.id).filter(P=>ere(P,d)).map(P=>({messageID:$.id,messageIndex:V,part:P}))),_=k&&!w?[...W2(E.filter($=>$.messageIndex<=x)).map($=>({type:"part",group:$})),{type:"interrupted"},...W2(E.filter($=>$.messageIndex>x)).map($=>({type:"part",group:$}))]:W2(E).map($=>({type:"part",group:$}));y&&p.push(new xi.TurnGap({userMessageID:a.id})),b.length>0&&!g&&p.push(new xi.CommentStrip({userMessageID:a.id})),p.push(new xi.UserMessage({userMessageID:a.id,anchor:g||b.length===0})),w&&p.push(new xi.TurnDivider({userMessageID:a.id,label:"compaction"}));let L=0;if(_.forEach($=>{if($.type==="interrupted"){p.push(new xi.TurnDivider({userMessageID:a.id,label:"interrupted"}));return}p.push(new xi.AssistantPart({userMessageID:a.id,group:$.group,previousAssistantPart:L>0})),L+=1}),m&&f==="busy"&&!C&&(!d||E.length===0)){const $=c.flatMap(V=>l(V.id)).map(V=>V.type==="reasoning"&&V.text?r(V.text):void 0).find(V=>!!V);p.push(new xi.Thinking({userMessageID:a.id,reasoningHeading:$}))}m&&f==="retry"&&p.push(new xi.Retry({userMessageID:a.id}));const O=Stt(a.summary?.diffs);if(O.length>0&&(f==="idle"||!m)&&p.push(new xi.DiffSummary({userMessageID:a.id,diffs:O})),C){const $=C.data?.message;p.push(new xi.Error({userMessageID:a.id,text:s(typeof $=="string"?$:$==null?"":String($))}))}return p}e.constructMessageRows=n;function r(a){const l=a.replace(/\r\n?/g,`
1182
1182
  `),c=l.match(/<h[1-6][^>]*>([\s\S]*?)<\/h[1-6]>/i);if(c?.[1]){const m=i(c[1].replace(/<[^>]+>/g," "));if(m)return m}const u=l.match(/^\s{0,3}#{1,6}[ \t]+(.+?)(?:[ \t]+#+[ \t]*)?$/m);if(u?.[1]){const m=i(u[1]);if(m)return m}const d=l.match(/^([^\n]+)\n(?:=+|-+)\s*$/m);if(d?.[1]){const m=i(d[1]);if(m)return m}const f=l.match(/^\s*(?:\*\*|__)(.+?)(?:\*\*|__)\s*$/m);if(f?.[1]){const m=i(f[1]);if(m)return m}}function i(a){return a.replace(/`([^`]+)`/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/[*_~]+/g,"").trim()}function s(a){const l=a.replace(/^Error:\s*/,"").trim(),c=p=>{try{return JSON.parse(p)}catch{return}},u=p=>{const y=c(p);return typeof y!="string"?y:c(y.trim())};let d=u(l);if(d===void 0){const p=l.indexOf("{"),y=l.lastIndexOf("}");p!==-1&&y>p&&(d=u(l.slice(p,y+1)))}if(!o(d))return a;const f=o(d.error)?d.error:void 0;if(f){const p=typeof f.type=="string"?f.type:void 0,y=typeof f.message=="string"?f.message:void 0;if(p&&y)return`${p}: ${y}`;if(y)return y;if(p)return p;const v=typeof f.code=="string"?f.code:void 0;if(v)return v}const m=typeof d.message=="string"?d.message:void 0;if(m)return m;const g=typeof d.error=="string"?d.error:void 0;return g||a}function o(a){return!!a&&typeof a=="object"&&!Array.isArray(a)}})(FC||(FC={}));var g1;(e=>{e.fromPart=t=>{if(t.type!=="text"||!t.synthetic)return;const n=xGe(t.metadata)??SGe(t.text);if(n)return{path:n.path,comment:n.comment,selection:n.selection?{startLine:n.selection.startLine,endLine:n.selection.endLine}:void 0}}})(g1||(g1={}));function _tt(e){const t=I(()=>new Map(e.messages().map(u=>[u.id,u]))),n=I(()=>{const u=new Map;return e.messages().forEach(d=>{if(d.role!=="assistant")return;const f=u.get(d.parentID);if(f){f.push(d);return}u.set(d.parentID,[d])}),u}),r=I(()=>FC.constructSessionMessageRows(e.sessionMessages(),u=>t().get(u),e.parts,e.showReasoningSummaries(),e.status().type,e.inlineComments(),e.userMessages())),i=I(()=>r().activeMessageID),s=I(u=>xtt(u,r().rows)),o=I(()=>new Map(s().map(u=>[xi.key(u),u]))),a=I(()=>{const u=new Map;return s().forEach((d,f)=>{!("userMessageID"in d)||u.has(d.userMessageID)||u.set(d.userMessageID,f)}),u}),l=I(()=>{const u=new Map;return s().forEach((d,f)=>{"userMessageID"in d&&u.set(d.userMessageID,f)}),u}),c=I(()=>{const u=new Map;return s().forEach(d=>{d._tag==="AssistantPart"&&u.set(d.userMessageID,d.group.key)}),u});return{activeMessageID:i,assistantMessagesByParent:n,lastAssistantGroupKey:c,messageByID:t,messageRowIndex:a,messageLastRowIndex:l,rowByKey:o,rows:s}}function Ttt(e,t){return e.filter(n=>n>=0&&n<t)}var Ett=A("<div data-slot=session-turn-thinking>"),Itt=A("<span data-slot=session-turn-diffs-toggle>"),Dtt=A("<div data-slot=session-turn-diffs-more>"),Ltt=A("<div data-slot=session-turn-diffs data-component=session-turn-diffs-group><div data-slot=session-turn-diffs-header><span data-slot=session-turn-diffs-label></span></div><div data-component=session-turn-diffs-content>"),Att=A("<span data-slot=session-turn-diff-directory>"),Mtt=A("<div data-slot=session-turn-diff-trigger><span data-slot=session-turn-diff-path><span data-slot=session-turn-diff-filename></span></span><div data-slot=session-turn-diff-meta><span data-slot=session-turn-diff-changes></span><span data-slot=session-turn-diff-chevron>"),$tt=A("<div data-slot=session-turn-diff-view data-scrollable>"),Ptt=A('<div class="flex flex-col gap-4 pl-6 pr-2.5 pb-3"><div class="flex flex-col gap-1"><span class="text-14-regular text-text-strong"></span></div><div class="flex justify-end gap-2">'),Ott=A('<div><div data-component=session-turn class="min-w-0 w-full relative"style=height:auto>'),Rtt=A("<div data-timeline-row=TurnGap aria-hidden=true class=h-6>"),Ftt=A('<div class="w-full px-4 md:px-5 pb-2"><div class="ml-auto max-w-[82%] overflow-x-auto no-scrollbar"><div class="flex w-max min-w-full justify-end gap-2">'),Ntt=A('<div><div class="flex items-center gap-1.5 min-w-0 text-11-medium text-text-strong"><span class=truncate></span></div><div class="pt-1 text-12-regular text-text-strong whitespace-pre-wrap break-words">'),Vtt=A('<span class="shrink-0 text-text-weak">'),ztt=A('<div data-slot=session-turn-message-container class="w-full px-4 md:px-5"><div data-slot=session-turn-message-content aria-live=off>'),Htt=A('<div data-slot=session-turn-message-container class="w-full px-4 md:px-5"><div data-slot=session-turn-compaction>'),jtt=A('<div data-slot=session-turn-message-container class="w-full px-4 md:px-5"><div data-slot=session-turn-assistant-content>'),n2=A('<div data-slot=session-turn-message-container class="w-full px-4 md:px-5">'),qtt=A("<div style=position:absolute;left:0;width:100%;overflow:clip><div>"),Btt=A('<button type=button class="pointer-events-auto flex items-center justify-center w-8 h-7 px-2 py-1.5 rounded-lg border-none cursor-pointer text-v2-text-text-base backdrop-blur-[2px]"style="background:color-mix(in srgb, var(--v2-background-bg-base) 92%, transparent);box-shadow:var(--v2-elevation-raised), 0px 2px 8px var(--v2-background-bg-base)"><svg width=16 height=16 viewBox="0 0 16 16"fill=none aria-hidden=true><path d="M12.3333 8.66665L8 13L3.66667 8.66665M8 12.6667V2.83332"stroke=currentColor stroke-linecap=square>'),Utt=A('<button type=button data-slot=session-title-parent class="min-w-0 max-w-[40%] truncate pl-2 text-[13px] font-[530] leading-4 tracking-[-0.04px] text-v2-text-text-faint transition-colors hover:text-v2-text-text-muted">'),Wtt=A('<span data-slot=session-title-separator class="-translate-y-[0.5px] pl-2 pr-1 text-[11px] font-medium text-v2-text-text-faint"aria-hidden=true>/'),Ktt=A('<div data-session-title><div class="h-12 w-full flex items-center justify-between gap-2"><div><div class="flex items-center min-w-0 flex-1 w-full">'),Gtt=A('<div data-timeline-row=bottom-spacer aria-hidden=true class="h-16 absolute top-0 left-0 w-full">'),Ztt=A("<div data-timeline-virtual-content style=position:relative;width:100%>"),Ytt=A('<div class="relative w-full h-full min-w-0"><div class="absolute left-1/2 -translate-x-1/2 z-[60] pointer-events-none transition-all duration-200 ease-out">'),Xtt=A('<button type=button class="pointer-events-auto flex items-center justify-center w-10 h-8 bg-transparent border-none cursor-pointer p-0 group"><div class="flex items-center justify-center w-8 h-6 rounded-[6px] border border-border-weaker-base bg-[color-mix(in_srgb,var(--surface-raised-stronger-non-alpha)_80%,transparent)] backdrop-blur-[0.75px] transition-colors group-hover:border-[var(--border-weak-base)] group-hover:[--icon-base:var(--icon-hover)]"style="box-shadow:0 51px 60px 0 rgba(0,0,0,0.10), 0 15px 18px 0 rgba(0,0,0,0.12), 0 6.386px 7.513px 0 rgba(0,0,0,0.12), 0 2.31px 2.717px 0 rgba(0,0,0,0.20)">'),Qtt=A("<h1 data-slot=session-title-child>"),Jtt=A(`<div class="flex w-full flex-col gap-1.5 px-0.5 pt-0.5"><div class="select-none text-[13px] font-[530] leading-none tracking-[-0.04px] text-v2-text-text-base [font-variation-settings:'slnt'_0]"></div><div class="select-none text-[13px] font-[440] leading-5 tracking-[-0.04px] text-v2-text-text-muted [font-variation-settings:'slnt'_0]">`),ent=A(`<div class="flex flex-col gap-2"><div class="flex h-8 w-full items-center gap-1.5 rounded-[6px] py-1 pl-2.5 pr-1.5 shadow-[var(--v2-elevation-button-neutral)]"style="background:linear-gradient(180deg, var(--v2-alpha-light-2) 0%, var(--v2-alpha-light-0) 100%), var(--v2-background-bg-button-neutral)"><div class="min-w-0 flex-1 truncate select-text cursor-text text-[13px] font-[440] leading-5 tracking-[-0.04px] text-v2-text-text-base [font-variation-settings:'slnt'_0]"></div></div><div class="flex w-full">`),tnt=A('<div class="flex w-full flex-col gap-2">'),nnt=A("<div>"),rnt=A('<div class="flex flex-col gap-2"><div class="grid grid-cols-2 gap-2">'),int=A('<div class="flex flex-col p-3"><div class="flex flex-col gap-1"><div class="text-13-medium text-text-strong"></div><div class="text-12-regular text-text-weak"></div></div><div class="mt-3 flex flex-col gap-2">');const xN=[],snt=[],ont=[],kN=[],SN={type:"idle"},CN=60,tm=new Map,ant=(e,t)=>{if(e.type!=="tool"||e.tool!=="task"||("metadata"in e.state?e.state.metadata:void 0)?.sessionId!==t)return;const r=e.state.input?.description;if(typeof r=="string"&&r)return r},lnt=(e,t)=>{const r=(t instanceof Element?t:void 0)?.closest("[data-scrollable]");return!r||r===e||!(r instanceof HTMLElement)?e:r},_N=e=>{const t=lnt(e.root,e.target);if(t===e.root){e.onMarkScrollGesture(e.root);return}dtt({delta:e.delta,scrollTop:t.scrollTop,scrollHeight:t.scrollHeight,clientHeight:t.clientHeight})&&e.onMarkScrollGesture(e.root)};function cnt(e){const t=wt();return(()=>{var n=Ett();return S(n,h(xo,{get text(){return t.t("ui.sessionTurn.status.thinking")}}),null),S(n,h(q,{get when(){return!e.showReasoningSummaries},get children(){return h(Ane,{get text(){return e.reasoningHeading},class:"session-turn-thinking-heading",travel:25,duration:700})}}),null),n})()}function unt(e){const t=wt(),n=10,[r,i]=Ze({showAll:!1,expanded:[]}),s=()=>r.showAll,o=()=>r.expanded,a=I(()=>Math.max(0,e.diffs.length-n)),l=I(()=>s()?e.diffs:e.diffs.slice(0,n));return(()=>{var c=Ltt(),u=c.firstChild,d=u.firstChild,f=u.nextSibling;return S(d,()=>t.t(e.diffs.length===1?"ui.sessionTurn.diffs.changed.one":"ui.sessionTurn.diffs.changed.other",{count:String(e.diffs.length)})),S(u,h(Qc,{get changes(){return e.diffs}}),null),S(u,h(q,{get when(){return a()>0},get children(){var m=Itt();return m.$$click=()=>i("showAll",!s()),S(m,(()=>{var g=we(()=>!!s());return()=>g()?t.t("ui.sessionTurn.diffs.showLess"):t.t("ui.sessionTurn.diffs.showAll")})()),m}}),null),S(f,h(Ei,{multiple:!0,style:{"--sticky-accordion-offset":"44px"},get value(){return o()},onChange:m=>i("expanded",Array.isArray(m)?m:m?[m]:[]),get children(){return h(Dt,{get each(){return l()},children:m=>{const g=I(()=>o().includes(m.file));return h(Ei.Item,{get value(){return m.file},get children(){return[h(my,{get children(){return h(Ei.Trigger,{get children(){var p=Mtt(),y=p.firstChild,v=y.firstChild,b=y.nextSibling,w=b.firstChild,x=w.nextSibling;return S(y,h(q,{get when(){return m.file.includes("/")},get children(){var k=Att();return S(k,()=>`‪${hc(m.file)}‬`),k}}),v),S(v,()=>fn(m.file)),S(w,h(Qc,{changes:m})),S(x,h(Yt,{name:"chevron-down",size:"small"})),p}})}}),h(Ei.Content,{get children(){return h(q,{get when(){return g()},get children(){return h(dnt,{diff:m})}})}})]}})}})}}),null),S(f,h(q,{get when(){return we(()=>!s())()&&a()>0},get children(){var m=Dtt();return m.$$click=()=>i("showAll",!0),S(m,()=>t.t("ui.sessionTurn.diffs.more",{count:String(a())})),m}}),null),he(()=>me(c,"data-show-all",s()||void 0)),c})()}function dnt(e){const t=_d(),n=i3(e.diff);return(()=>{var r=$tt();return S(r,h(Gi,{component:t,mode:"diff",virtualize:!1,get fileDiff(){return n.fileDiff}})),r})()}function fnt(e){let t;const n=fs(),r=xs(),i=kr(),s=Ji(),o=ar(),a=ks(),l=Mr(),c=wt(),{params:u,sessionKey:d}=XJ(),f=d(),m=tm.get(f),g=m?.measurements,p=!g?.length&&e.shouldAnchorBottom(),y=Tr(),[v,b]=De(),w=I(()=>u.id),x=I(()=>{const _e=w();return _e?s().data.session_status[_e]??SN:SN}),k=I(()=>w()?s().data.message[w()]??[]:[]),C=I(()=>{const _e=w();if(!_e)return[];const nt=new Set(e.userMessages.map($t=>$t.id)),Ge=k().find($t=>$t.role==="user"&&!nt.has($t.id))?.id,Ye=s().data.session_message[_e]??[];return Ge?Ye.filter($t=>$t.id<Ge):Ye}),E=I(()=>{const _e=w();if(_e)return s().session.get(_e)}),_=I(()=>E()?.title),L=I(()=>Df(_())),O=I(()=>E()?.share?.url),$=I(()=>s().data.config.share!=="disabled"),V=I(()=>E()?.parentID),P=I(()=>{const _e=V();if(_e)return s().session.get(_e)}),T=I(()=>{const _e=V();return _e?s().data.message[_e]??xN:xN}),D=I(()=>Df(P()?.title)??c.t("command.session.new")),N=_e=>s().data.part[_e]??snt,M=(_e,nt)=>N(_e).find(Ge=>Ge.id===nt),F=I(()=>{const _e=w();if(_e)return T().flatMap(nt=>N(nt.id)).map(nt=>ant(nt,_e)).findLast(nt=>!!nt)}),j=I(()=>{if(!V())return L()??"";if(F())return F();const _e=L()?.replace(/\s+\(@[^)]+ subagent\)$/,"");return _e||c.t("command.session.new")}),z=I(()=>!!(_()||V())),W=_tt({messages:k,userMessages:()=>e.userMessages,sessionMessages:C,parts:N,status:x,showReasoningSummaries:o.general.showReasoningSummaries,inlineComments:o.general.newLayoutDesigns}),J=W.activeMessageID,K=W.assistantMessagesByParent,X=W.lastAssistantGroupKey,te=W.messageByID,ve=W.messageLastRowIndex,ne=W.messageRowIndex,ie=W.rowByKey,ke=W.rows;let ge,Pe,Me=!1;const de=()=>{Me=!1,ge=void 0,Pe!==void 0&&(cancelAnimationFrame(Pe),Pe=void 0)},U=()=>{Me=!0,He()},He=()=>{const _e=v();if(!_e)return;const nt=_e.getBoundingClientRect(),Ge=[..._e.querySelectorAll("[data-timeline-key]")].map(Ye=>({element:Ye,rect:Ye.getBoundingClientRect()})).filter(Ye=>Ye.rect.bottom>nt.top&&Ye.rect.top<nt.bottom).sort((Ye,$t)=>Ye.rect.top-$t.rect.top)[0];Ge&&Ge.element.dataset.timelineKey&&(ge={key:Ge.element.dataset.timelineKey,offset:Ge.rect.top-nt.top})},Ue=_e=>{_e&&(Me=!1),Z()},Z=()=>{const _e=v();if(!_e||!ge)return;Pe!==void 0&&cancelAnimationFrame(Pe);let nt=0,Ge=0;const Ye=()=>{Pe=void 0;const $t=ge;if(!$t)return;const Rt=_e.querySelector(`[data-timeline-key="${CSS.escape($t.key)}"]`),Y=Rt?Rt.getBoundingClientRect().top-_e.getBoundingClientRect().top-$t.offset:void 0;if(Y!==void 0&&Math.abs(Y)>.5?(_e.scrollTop+=Y,Ge=0):Ge+=1,nt+=1,Ge>=30||nt>=180){Me||(ge=void 0);return}Pe=requestAnimationFrame(Ye)};Pe=requestAnimationFrame(Ye)},[ce,G]=Ze(m?.toolOpen??{}),[fe,xe]=De(g?.length||p?6:20);let Oe=[],re,pe;const ye=PI({get count(){return ke().length},getScrollElement:()=>v()??null,observeElementOffset:wtt,initialOffset:()=>e.shouldAnchorBottom()?Number.MAX_SAFE_INTEGER:0,initialMeasurementsCache:g,estimateSize:()=>CN,scrollToFn:(_e,nt,Ge)=>{pe&&(pe.style.height=`${Ge.getTotalSize()}px`),$ne(_e,nt,Ge)},get getItemKey(){const _e=ke();return nt=>{const Ge=_e[nt];return Ge?xi.key(Ge):`removed:${nt}`}},anchorTo:"end",followOnAppend:!0,scrollEndThreshold:80,get scrollMargin(){return z()?64:0},overscan:50,paddingEnd:64,rangeExtractor:_e=>{const nt=J(),Ge=nt?ve().get(nt)??-1:-1,Ye=r3({..._e,overscan:fe()});return Ttt([...new Set([...Oe,...Ye,...Ge<0?[]:[Ge]])].sort(($t,Rt)=>$t-Rt),_e.count)}}),Re=ye.resizeItem;let Je=!1;const Xe=()=>{Je||e.hasScrollGesture()||(Je=!0,queueMicrotask(()=>{Je=!1,!(!e.shouldAnchorBottom()||e.hasScrollGesture())&&ye.scrollToEnd()}))};ye.resizeItem=(_e,nt)=>{const Ge=ye.measurementsCache[_e],Ye=Ge?ye.itemSizeCache.get(Ge.key)??Ge.size:void 0,$t=v();if($t&&Ye!==void 0&&Math.abs(nt-Ye)>$t.clientHeight){const Rt=$t.getBoundingClientRect();Oe=[...$t.querySelectorAll("[data-index]")].filter(Y=>{const Ce=Y.getBoundingClientRect();return Ce.bottom>Rt.top&&Ce.top<Rt.bottom}).map(Y=>Number(Y.dataset.index)),re!==void 0&&cancelAnimationFrame(re),re=requestAnimationFrame(()=>{re=requestAnimationFrame(()=>{re=void 0,Oe=[]})})}Re(_e,nt),$t&&e.shouldAnchorBottom()&&Xe()},ye.shouldAdjustScrollPositionOnItemSizeChange=_e=>{if(e.shouldAnchorBottom())return!1;const nt=ye.range?.startIndex;return nt!==void 0&&_e.index<nt};const je=I(()=>new Map(ye.getVirtualItems().map(_e=>[_e.key,_e]))),mt=I(()=>ye.getVirtualItems().map(_e=>_e.key));ae(()=>{e.setRevealMessage?.(_e=>{const nt=ne().get(_e);nt!==void 0&&ye.scrollToIndex(nt,{align:"center"})}),e.setScrollToEnd?.(()=>ye.scrollToEnd()),e.setHistoryAnchor?.({capture:U,restore:Ue})});let Et;sn(()=>{Et=requestAnimationFrame(()=>{e.shouldAnchorBottom()&&ye.scrollToEnd(),Et=requestAnimationFrame(()=>{Et=void 0,fe()<20&&xe(20),e.shouldAnchorBottom()&&ye.scrollToEnd()})})});const Bt=()=>{ke().length!==0&&(!e.shouldAnchorBottom()||e.hasScrollGesture()||(re!==void 0&&cancelAnimationFrame(re),de(),Pe!==void 0&&cancelAnimationFrame(Pe),ye.scrollToEnd()))};let Qe=d();ae(()=>{const _e=d();ke().length,Qe!==_e&&(Qe=_e,ye.measure()),Bt()}),Te(()=>{for(de(),tm.delete(f),tm.set(f,{measurements:ye.takeSnapshot(),toolOpen:{...ce}});tm.size>16;)tm.delete(tm.keys().next().value);re!==void 0&&cancelAnimationFrame(re),Et!==void 0&&cancelAnimationFrame(Et),e.setRevealMessage?.(()=>{}),e.setScrollToEnd?.(()=>{}),e.setHistoryAnchor?.({capture:()=>{},restore:()=>{}})});const[Be,et]=Ze({draft:"",editing:!1,menuOpen:!1,pendingRename:!1,pendingShare:!1});let un;const[xn,In]=Ze({open:!1,dismiss:null});let Hn;const er=_e=>{_e!==v()&&(b(_e),e.setScrollRef(_e))},Lt=_e=>{Me||de();const nt=_e.currentTarget,Ge=utt({deltaY:_e.deltaY,deltaMode:_e.deltaMode,rootHeight:nt.clientHeight});Ge&&_N({root:nt,target:_e.target,delta:Ge,onMarkScrollGesture:e.onMarkScrollGesture})},Nn=_e=>{Me||de(),t=_e.touches[0]?.clientY},Vn=_e=>{const nt=_e.touches[0]?.clientY,Ge=t;if(t=nt,nt===void 0||Ge===void 0)return;const Ye=Ge-nt;Ye&&_N({root:_e.currentTarget,target:_e.target,delta:Ye,onMarkScrollGesture:e.onMarkScrollGesture})},$r=()=>{t=void 0},gs=_e=>{Me||de(),e.onMarkScrollGesture(_e.target)},$n=_e=>{_e.buttons===1&&e.onMarkScrollGesture(_e.target)},Ur=_e=>{const nt=XE(_e);nt&&JE(_e.target,nt)&&QE(_e.currentTarget,_e.target,nt)===_e.currentTarget&&(Me||de(),e.onMarkScrollGesture(_e.currentTarget))},es=_e=>{Me&&He(),e.onScheduleScrollState(_e.currentTarget),e.onHistoryScroll(),e.hasScrollGesture()&&(e.onUserScroll(),e.onAutoScrollHandleScroll(),e.onMarkScrollGesture(_e.currentTarget))};Te(()=>{e.setScrollRef(void 0)});const go=()=>{const _e=O();_e&&y.openLink(_e)},Li=_e=>{if(_e&&typeof _e=="object"&&"data"in _e){const nt=_e.data;if(nt?.message)return nt.message}return _e instanceof Error?_e.message:c.t("common.requestFailed")},Wr=Yo(()=>({mutationFn:_e=>r().client.session.share({sessionID:_e}),onError:_e=>{console.error("Failed to share session",_e)}})),Zr=Yo(()=>({mutationFn:_e=>r().client.session.unshare({sessionID:_e}),onError:_e=>{console.error("Failed to unshare session",_e)}})),bi=Yo(()=>({mutationFn:_e=>i().api.session.rename({sessionID:_e.id,title:_e.title}),onSuccess:(_e,nt)=>{s().set(yt(Ge=>{const Ye=Ge.session.findIndex($t=>$t.id===nt.id);Ye!==-1&&(Ge.session[Ye].title=nt.title)})),et("editing",!1)},onError:_e=>{tn({title:c.t("common.requestFailed"),description:Li(_e)})}})),lr=()=>{const _e=w();!_e||Wr.isPending||$()&&Wr.mutate(_e)},ui=()=>{const _e=w();!_e||Zr.isPending||$()&&Zr.mutate(_e)},js=()=>{const _e=O();_e&&navigator.clipboard.writeText(_e).then(()=>tn({variant:"success",icon:"circle-check",title:c.t("session.share.copy.copied"),description:_e})).catch(nt=>tn({title:c.t("common.requestFailed"),description:Li(nt)}))},Ss=_e=>{const nt=window.getSelection();if(!nt)return;const Ge=document.createRange();Ge.selectNodeContents(_e.currentTarget),nt.removeAllRanges(),nt.addRange(Ge)};ae(vt(d,()=>et({draft:"",editing:!1,menuOpen:!1,pendingRename:!1,pendingShare:!1}),{defer:!0})),ae(vt(()=>[V(),F()],([_e,nt])=>{!_e||nt||s().data.message[_e]===void 0&&s().session.sync(_e)},{defer:!0}));const Ni=()=>{!w()||V()||(et({editing:!0,draft:L()??""}),requestAnimationFrame(()=>{un&&(un.focus(),un.select())}))},$o=()=>{bi.isPending||et("editing",!1)},Pr=()=>{const _e=w();if(!_e||bi.isPending)return;const nt=Be.draft.trim();if(!nt||nt===(L()??"")){et("editing",!1);return}bi.mutate({id:_e,title:nt})},Po=(_e,nt,Ge)=>{if(u.id!==_e)return;const Ye=$t=>u.serverKey?Wf(ra(u.serverKey),$t):Qw(i().directory,$t);if(nt){n(Ye(nt));return}if(Ge){n(Ye(Ge));return}if(u.serverKey){a.newDraft({server:ra(u.serverKey),directory:i().directory});return}n(`/${u.dir}/session`)},pa=async _e=>{const nt=s().session.get(_e);if(!nt||await i().protocol!=="v1")return;const Ge=s().data.session??[],Ye=Ge.findIndex(Rt=>Rt.id===_e),$t=Ye===-1?void 0:Ge[Ye+1]??Ge[Ye-1];await i().client.session.update({sessionID:_e,directory:i().directory,time:{archived:Date.now()}}).then(()=>{s().set(yt(Rt=>{const Y=Rt.session.findIndex(Ce=>Ce.id===_e);Y!==-1&&Rt.session.splice(Y,1)})),s().session.evict(_e),Po(_e,nt.parentID,$t?.id),rC({directory:i().directory,sessionIDs:[_e]})}).catch(Rt=>{tn({title:c.t("common.requestFailed"),description:Li(Rt)})})},Za=async _e=>{const nt=s().session.get(_e);if(!nt)return!1;const Ge=(s().data.session??[]).filter(qe=>!qe.parentID&&!qe.time?.archived),Ye=Ge.findIndex(qe=>qe.id===_e),$t=Ye===-1?void 0:Ge[Ye+1]??Ge[Ye-1];if(!await i().api.session.remove({sessionID:_e}).then(()=>!0).catch(qe=>(tn({title:c.t("session.delete.failed.title"),description:Li(qe)}),!1)))return!1;const Y=new Set([_e]),Ce=new Map;for(const qe of s().data.session){const _t=qe.parentID;if(!_t)continue;const Zt=Ce.get(_t);if(Zt){Zt.push(qe.id);continue}Ce.set(_t,[qe.id])}const Fe=[_e];for(;Fe.length;){const qe=Fe.pop();if(!qe)continue;const _t=Ce.get(qe);if(_t)for(const Zt of _t)Y.has(Zt)||(Y.add(Zt),Fe.push(Zt))}Po(_e,nt.parentID,$t?.id),s().set(yt(qe=>{qe.session=qe.session.filter(_t=>!Y.has(_t.id))}));for(const qe of Y)s().session.evict(qe);return rC({directory:i().directory,sessionIDs:[...Y]}),!0},Oo=()=>{const _e=V();_e&&n(u.serverKey?Wf(ra(u.serverKey),_e):Qw(i().directory,_e))};function Ya(_e){const nt=I(()=>Df(s().session.get(_e.sessionID)?.title)??c.t("command.session.new")),Ge=async()=>{await Za(_e.sessionID),l.close()};return o.general.newLayoutDesigns()?h(pne,{fit:!0,get children(){return[h($I,{hideClose:!0,get children(){return h(KZe,{get title(){return c.t("session.delete.title")},get description(){return c.t("session.delete.confirm",{name:nt()})}})}}),h(fne,{get children(){return[h(as,{variant:"ghost",onClick:()=>l.close(),get children(){return c.t("common.cancel")}}),h(as,{variant:"danger",onClick:Ge,get children(){return c.t("session.delete.button")}})]}})]}}):h(ou,{get title(){return c.t("session.delete.title")},fit:!0,get children(){var Ye=Ptt(),$t=Ye.firstChild,Rt=$t.firstChild,Y=$t.nextSibling;return S(Rt,()=>c.t("session.delete.confirm",{name:nt()})),S(Y,h(Kt,{variant:"ghost",size:"large",onClick:()=>l.close(),get children(){return c.t("common.cancel")}}),null),S(Y,h(Kt,{variant:"primary",size:"large",onClick:Ge,get children(){return c.t("session.delete.button")}}),null),Ye}})}const Ht=_e=>x().type!=="idle"&&J()===_e,Ie=_e=>{const nt=te().get(_e);if(!nt||nt.role!=="user")return;const Ge=(K().get(_e)??kN).reduce((Ye,$t)=>{const Rt=$t.time.completed;return typeof Rt!="number"?Ye:Ye===void 0?Rt:Math.max(Ye,Rt)},void 0);if(typeof Ge=="number"&&!(Ge<nt.time.created))return Ge-nt.time.created},st=_e=>{if(Ht(_e))return null;const nt=K().get(_e)??kN;for(let Ge=nt.length-1;Ge>=0;Ge--){const Ye=nt[Ge];if(!Ye)continue;const $t=N(Ye.id);for(let Rt=$t.length-1;Rt>=0;Rt--){const Y=$t[Rt];if(!(!Y||Y.type!=="text"||!Y.text?.trim()))return Y.id}}},Ft=(_e,nt)=>{if(_e().group.type==="context"){const Rt=I(()=>{const Fe=_e().group;return Fe.type!=="context"?ont:Fe.refs.map(qe=>M(qe.messageID,qe.partID)).filter(qe=>qe?.type==="tool")}),Y=()=>`context:${_e().group.key}`,Ce=I(()=>ce[Y()]===!0);return h(nre,{get parts(){return Rt()},get open(){return Ce()},onOpenChange:Fe=>G(Y(),Fe),get busy(){return we(()=>!!Ht(_e().userMessageID))()&&X().get(_e().userMessageID)===_e().group.key},onSizeChange:nt})}const Ge=I(()=>{const Rt=_e().group;if(Rt.type==="part")return te().get(Rt.ref.messageID)}),Ye=I(()=>{const Rt=_e().group;if(Rt.type==="part")return M(Rt.ref.messageID,Rt.ref.partID)}),$t=I(()=>{const Rt=Ye();if(Rt)return Ket(Rt,o.general.shellToolPartsExpanded(),o.general.editToolPartsExpanded())});return h(q,{get when(){return Ge()},children:Rt=>h(q,{get when(){return Ye()},children:Y=>h(rre,{get part(){return Y()},get message(){return Rt()},get showAssistantCopyPartID(){return st(_e().userMessageID)},get turnDurationMs(){return Ie(_e().userMessageID)},get useV2Actions(){return o.general.newLayoutDesigns()},get defaultOpen(){return $t()},get toolOpen(){return ce[Y().id]??$t()},onToolOpenChange:Ce=>G(Y().id,Ce),deferToolContent:!0,virtualizeDiff:!1,onContentRendered:nt})})})};function Rn(_e){const nt=()=>{const Ye=_e.row();return Ye._tag==="CommentStrip"||Ye._tag==="UserMessage"&&Ye.anchor},Ge=()=>{const Ye=_e.row();return Ye._tag==="AssistantPart"&&Ye.previousAssistantPart};return(()=>{var Ye=Ott(),$t=Ye.firstChild;return S($t,()=>_e.children),he(Rt=>{var Y=nt()?e.anchor(_e.row().userMessageID):void 0,Ce=_e.row().userMessageID,Fe=_e.row()._tag,qe={"min-w-0 w-full max-w-full":!0,"md:max-w-200 2xl:max-w-[1000px]":e.centered,"md:mx-auto":e.centered,"pt-3":Ge()};return Y!==Rt.e&&me(Ye,"id",Rt.e=Y),Ce!==Rt.t&&me(Ye,"data-message-id",Rt.t=Ce),Fe!==Rt.a&&me(Ye,"data-timeline-row",Rt.a=Fe),Rt.o=ct(Ye,qe,Rt.o),Rt},{e:void 0,t:void 0,a:void 0,o:void 0}),Ye})()}const _n=(_e,nt)=>{switch(_e()._tag){case"TurnGap":return Rtt();case"CommentStrip":{const Ge=_e,Ye=I(()=>N(Ge().userMessageID).flatMap($t=>g1.fromPart($t)??[]));return h(Rn,{row:Ge,get children(){var $t=Ftt(),Rt=$t.firstChild,Y=Rt.firstChild;return S(Y,h(nh,{get each(){return Ye()},children:Ce=>(()=>{var Fe=Ntt(),qe=Fe.firstChild,_t=qe.firstChild,Zt=qe.nextSibling;return S(qe,h(Dr,{get node(){return{path:Ce().path,type:"file"}},class:"size-3.5 shrink-0"}),_t),S(_t,()=>fn(Ce().path)),S(qe,h(q,{get when(){return Ce().selection},children:It=>(()=>{var jt=Vtt();return S(jt,(()=>{var Pt=we(()=>It().startLine===It().endLine);return()=>Pt()?`:${It().startLine}`:`:${It().startLine}-${It().endLine}`})()),jt})()}),null),S(Zt,()=>Ce().comment),he(It=>ct(Fe,{"shrink-0 max-w-[260px] rounded-[6px] border-border-weak-base bg-background-stronger px-2.5 py-2":!0,"border-[0.5px]":o.general.newLayoutDesigns(),border:!o.general.newLayoutDesigns()},It)),Fe})()})),$t}})}case"UserMessage":{const Ge=_e,Ye=I(()=>{const Rt=te().get(Ge().userMessageID);if(Rt?.role==="user")return Rt}),$t=I(()=>o.general.newLayoutDesigns()?N(Ge().userMessageID).flatMap(Rt=>g1.fromPart(Rt)??[]):[]);return h(Rn,{row:Ge,get children(){return h(q,{get when(){return Ye()},children:Rt=>(()=>{var Y=ztt(),Ce=Y.firstChild;return S(Ce,h(Qet,{get message(){return Rt()},get parts(){return N(Ge().userMessageID)},get actions(){return e.actions},get useV2Actions(){return o.general.newLayoutDesigns()},get comments(){return $t()}})),Y})()})}})}case"TurnDivider":{const Ge=_e;return h(Rn,{row:Ge,get children(){var Ye=Htt(),$t=Ye.firstChild;return S($t,h(sre,{get label(){return c.t(Ge().label==="compaction"?"ui.messagePart.compaction":"ui.message.interrupted")}})),Ye}})}case"AssistantPart":{const Ge=_e;return h(Rn,{row:Ge,get children(){var Ye=jtt(),$t=Ye.firstChild;return S($t,()=>Ft(Ge,nt)),he(()=>me($t,"aria-hidden",Ht(Ge().userMessageID))),Ye}})}case"Thinking":{const Ge=_e;return h(Rn,{row:Ge,get children(){var Ye=n2();return S(Ye,h(cnt,{get reasoningHeading(){return Ge().reasoningHeading},get showReasoningSummaries(){return o.general.showReasoningSummaries()}})),Ye}})}case"Retry":{const Ge=_e;return h(Rn,{row:Ge,get children(){var Ye=n2();return S(Ye,h(ctt,{get status(){return x()},get show(){return J()===Ge().userMessageID}})),Ye}})}case"DiffSummary":{const Ge=_e;return h(Rn,{row:Ge,get children(){var Ye=n2();return S(Ye,h(unt,{get diffs(){return Ge().diffs}})),Ye}})}case"Error":{const Ge=_e;return h(Rn,{row:Ge,get children(){var Ye=n2();return S(Ye,h(OI,{variant:"error",class:"error-card",get children(){return Ge().text}})),Ye}})}}};function pr(_e){return _n(()=>_e.row,_e.onSizeChange)}function ti(_e){let nt;const Ge=je().get(_e.rowKey),Ye=ie().get(_e.rowKey),$t=I(()=>je().get(_e.rowKey)??Ge),Rt=I(()=>ie().get(_e.rowKey)??Ye),Y=()=>{const Zt=Rt();if(Zt._tag!=="AssistantPart"||Zt.group.type!=="part")return;const It=M(Zt.group.ref.messageID,Zt.group.ref.partID);if(It?.type==="tool")return It},Ce=()=>["edit","write","apply_patch"].includes(Y()?.tool??""),[Fe,qe]=De(Ge.size<=CN||!Ce());let _t;return sn(()=>ye.measureElement(nt)),ae(vt(()=>$t().index,()=>{ye.measureElement(nt)},{defer:!0})),Te(()=>{_t!==void 0&&cancelAnimationFrame(_t)}),(()=>{var Zt=qtt(),It=Zt.firstChild;return pt(jt=>{nt=jt},It),S(It,h(pr,{get row(){return Rt()},onSizeChange:()=>{qe(!0),_t!==void 0&&cancelAnimationFrame(_t),_t=btt(nt,ye.measureElement)}})),he(jt=>{var Pt=_e.rowKey,Tn=`${$t().start-(z()?64:0)}px`,di=`${$t().size}px`,qs=Rt()._tag==="TurnGap"?void 0:"0.5px",Yn=$t().index,Cs=Fe()?void 0:`${Ge.size}px`;return Pt!==jt.e&&me(Zt,"data-timeline-key",jt.e=Pt),Tn!==jt.t&&Ct(Zt,"top",jt.t=Tn),di!==jt.a&&Ct(Zt,"height",jt.a=di),qs!==jt.o&&Ct(Zt,"overflow-clip-margin",jt.o=qs),Yn!==jt.i&&me(It,"data-index",jt.i=Yn),Cs!==jt.n&&Ct(It,"min-height",jt.n=Cs),jt},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),Zt})()}return(()=>{var _e=Ytt(),nt=_e.firstChild;return S(nt,h(q,{get when(){return o.general.newLayoutDesigns()},get fallback(){return(()=>{var Ge=Xtt(),Ye=Ge.firstChild;return cn(Ge,"click",e.onResumeScroll,!0),S(Ye,h(Yt,{name:"arrow-down-to-line",size:"small"})),he(()=>me(Ge,"aria-label",c.t("session.messages.jumpToLatest"))),Ge})()},get children(){var Ge=Btt();return cn(Ge,"click",e.onResumeScroll,!0),he(()=>me(Ge,"aria-label",c.t("session.messages.jumpToLatest"))),Ge}})),S(_e,h(yc,{viewportRef:er,onWheel:Lt,onTouchStart:Nn,onTouchMove:Vn,onTouchEnd:$r,onTouchCancel:$r,onPointerDown:gs,onPointerMove:$n,onKeyDown:Ur,onScroll:es,get onClick(){return e.onAutoScrollInteraction},class:"relative min-w-0 w-full h-full",get style(){return{"--sticky-accordion-top":z()?"48px":"0px"}},get children(){return[h(q,{get when(){return z()},get children(){var Ge=Ktt(),Ye=Ge.firstChild,$t=Ye.firstChild,Rt=$t.firstChild;return S(Rt,h(q,{get when(){return V()},get children(){return[(()=>{var Y=Utt();return Y.$$click=Oo,S(Y,D),Y})(),Wtt()]}}),null),S(Rt,h(q,{get when(){return j()||Be.editing},get children(){return h(q,{get when(){return Be.editing},get fallback(){return(()=>{var Y=Qtt();return Y.$$click=Ni,S(Y,j),he(Ce=>ct(Y,{"truncate text-[13px] font-[530] leading-4 tracking-[-0.04px] text-v2-text-text-base":!0,"w-fit rounded-[6px] px-2 py-1 hover:bg-v2-overlay-simple-overlay-hover":o.general.newLayoutDesigns(),"grow-1 min-w-0":!o.general.newLayoutDesigns()},Ce)),Y})()},get children(){return h(gJ,{ref:Y=>{un=Y},"data-slot":"session-title-child",get value(){return Be.draft},get disabled(){return bi.isPending},get classList(){return{"block text-[13px] font-[530] leading-4 tracking-[-0.04px] text-v2-text-text-base":!0,"w-full flex-1 grow-1 min-w-0 pl-1 -ml-1 rounded-[6px]":!o.general.newLayoutDesigns(),"field-sizing-content self-start rounded-[6px] px-2 py-1 ":o.general.newLayoutDesigns()}},get style(){return{"--inline-input-shadow":o.general.newLayoutDesigns()?"none":"var(--shadow-xs-border-select)"}},onInput:Y=>et("draft",Y.currentTarget.value),onKeyDown:Y=>{if(Y.stopPropagation(),Y.key==="Enter"){Y.preventDefault(),Pr();return}Y.key==="Escape"&&(Y.preventDefault(),$o())},onBlur:$o})}})}}),null),S(Ye,h(q,{get when(){return w()},keyed:!0,children:Y=>(()=>{var Ce=nnt();return S(Ce,h(RC,{placement:"bottom",get buttonAppearance(){return o.general.newLayoutDesigns()?"v2":"default"}}),null),S(Ce,h(q,{get when(){return!V()},get children(){return[h(q,{get when(){return o.general.newLayoutDesigns()},get fallback(){return h(at,{gutter:4,placement:"bottom-end",get open(){return Be.menuOpen},onOpenChange:Fe=>{et("menuOpen",Fe)},get children(){return[h(at.Trigger,{as:Ln,icon:"dot-grid",variant:"ghost",class:"size-6 rounded-md data-[expanded]:bg-surface-base-active",get classList(){return{"bg-surface-base-active":xn.open||Be.pendingShare}},get"aria-label"(){return c.t("common.moreOptions")},get"aria-expanded"(){return Be.menuOpen||xn.open||Be.pendingShare},ref:Fe=>{Hn=Fe}}),h(at.Portal,{get children(){return h(at.Content,{style:{"min-width":"104px"},onCloseAutoFocus:Fe=>{if(Be.pendingRename){Fe.preventDefault(),et("pendingRename",!1),Ni();return}Be.pendingShare&&(Fe.preventDefault(),requestAnimationFrame(()=>{In({open:!0,dismiss:null}),et("pendingShare",!1)}))},get children(){return[h(at.Item,{onSelect:()=>{et("pendingRename",!0),et("menuOpen",!1)},get children(){return h(at.ItemLabel,{get children(){return c.t("common.rename")}})}}),h(q,{get when(){return $()},get children(){return h(at.Item,{onSelect:()=>{et({pendingShare:!0,menuOpen:!1})},get children(){return h(at.ItemLabel,{get children(){return c.t("session.share.action.share")}})}})}}),h(at.Item,{onSelect:()=>void pa(Y),get children(){return h(at.ItemLabel,{get children(){return c.t("common.archive")}})}}),h(at.Separator,{}),h(at.Item,{onSelect:()=>l.show(()=>h(Ya,{sessionID:Y})),get children(){return h(at.ItemLabel,{get children(){return c.t("common.delete")}})}})]}})}})]}})},get children(){return h(Tt,{gutter:6,placement:"bottom-end",get open(){return Be.menuOpen},onOpenChange:Fe=>{et("menuOpen",Fe)},get children(){return[h(Tt.Trigger,{as:Lr,get icon(){return h(on,{name:"outline-dots"})},variant:"ghost-muted",size:"large",get state(){return xn.open||Be.pendingShare?"pressed":void 0},get"aria-label"(){return c.t("common.moreOptions")},get"aria-expanded"(){return Be.menuOpen||xn.open||Be.pendingShare},ref:Fe=>{Hn=Fe}}),h(Tt.Portal,{get children(){return h(Tt.Content,{style:{width:"120px","min-width":"120px"},onCloseAutoFocus:Fe=>{if(Be.pendingRename){Fe.preventDefault(),et("pendingRename",!1),Ni();return}Be.pendingShare&&(Fe.preventDefault(),requestAnimationFrame(()=>{In({open:!0,dismiss:null}),et("pendingShare",!1)}))},get children(){return[h(Tt.Item,{onSelect:()=>{et("pendingRename",!0),et("menuOpen",!1)},get children(){return c.t("common.rename")}}),h(q,{get when(){return $()},get children(){return h(Tt.Item,{onSelect:()=>{et({pendingShare:!0,menuOpen:!1})},get children(){return[we(()=>c.t("session.share.action.share")),"..."]}})}}),h(Tt.Item,{onSelect:()=>void pa(Y),get children(){return c.t("common.archive")}}),h(Tt.Separator,{}),h(Tt.Item,{onSelect:()=>l.show(()=>h(Ya,{sessionID:Y})),get children(){return[we(()=>c.t("common.delete")),"..."]}})]}})}})]}})}}),h(As,{get open(){return xn.open},anchorRef:()=>Hn,placement:"bottom-end",get gutter(){return o.general.newLayoutDesigns()?6:4},modal:!1,onOpenChange:Fe=>{Fe&&In("dismiss",null),In("open",Fe)},get children(){return h(As.Portal,{get children(){return h(As.Content,{"data-component":"popover-content",get classList(){return{"flex w-80 max-w-none flex-col items-start gap-3 rounded-[10px] border-0 bg-v2-background-bg-layer-01 p-3 shadow-[var(--v2-elevation-floating)]":o.general.newLayoutDesigns()}},style:{"min-width":"320px"},onEscapeKeyDown:Fe=>{In({dismiss:"escape",open:!1}),Fe.preventDefault(),Fe.stopPropagation()},onPointerDownOutside:()=>{In({dismiss:"outside",open:!1})},onFocusOutside:()=>{In({dismiss:"outside",open:!1})},onCloseAutoFocus:Fe=>{xn.dismiss==="outside"&&Fe.preventDefault(),In("dismiss",null)},get children(){return h(q,{get when(){return o.general.newLayoutDesigns()},get fallback(){return(()=>{var Fe=int(),qe=Fe.firstChild,_t=qe.firstChild,Zt=_t.nextSibling,It=qe.nextSibling;return S(_t,()=>c.t("session.share.popover.title")),S(Zt,(()=>{var jt=we(()=>!!O());return()=>jt()?c.t("session.share.popover.description.shared"):c.t("session.share.popover.description.unshared")})()),S(It,h(q,{get when(){return O()},get fallback(){return h(Kt,{size:"large",variant:"primary",class:"w-full",onClick:lr,get disabled(){return Wr.isPending},get children(){return we(()=>!!Wr.isPending)()?c.t("session.share.action.publishing"):c.t("session.share.action.publish")}})},get children(){var jt=rnt(),Pt=jt.firstChild;return S(jt,h(Cf,{get value(){return O()??""},readOnly:!0,copyable:!0,copyKind:"link",tabIndex:-1,class:"w-full"}),Pt),S(Pt,h(Kt,{size:"large",variant:"secondary",class:"w-full shadow-none border border-border-weak-base",onClick:ui,get disabled(){return Zr.isPending},get children(){return we(()=>!!Zr.isPending)()?c.t("session.share.action.unpublishing"):c.t("session.share.action.unpublish")}}),null),S(Pt,h(Kt,{size:"large",variant:"primary",class:"w-full",onClick:go,get disabled(){return Zr.isPending},get children(){return c.t("session.share.action.view")}}),null),jt}})),Fe})()},get children(){return[(()=>{var Fe=Jtt(),qe=Fe.firstChild,_t=qe.nextSibling;return S(qe,()=>c.t("session.share.popover.title")),S(_t,(()=>{var Zt=we(()=>!!O());return()=>Zt()?c.t("session.share.popover.description.shared"):c.t("session.share.popover.description.unshared")})()),Fe})(),(()=>{var Fe=tnt();return S(Fe,h(q,{get when(){return O()},get fallback(){return h(as,{variant:"contrast",class:"w-full",onClick:lr,get disabled(){return Wr.isPending},get children(){return we(()=>!!Wr.isPending)()?c.t("session.share.action.publishing"):c.t("session.share.action.publish")}})},get children(){var qe=ent(),_t=qe.firstChild,Zt=_t.firstChild,It=_t.nextSibling;return Zt.$$click=Ss,S(Zt,O),S(_t,h(Lr,{type:"button",size:"small",variant:"ghost-muted",get icon(){return h(on,{name:"outline-copy"})},get"aria-label"(){return c.t("session.share.copy.copyLink")},onClick:js}),null),S(_t,h(Lr,{type:"button",size:"small",variant:"ghost-muted",get icon(){return h(on,{name:"outline-square-arrow"})},get"aria-label"(){return c.t("session.share.action.view")},onClick:go,get disabled(){return Zr.isPending}}),null),S(It,h(as,{variant:"outline",class:"w-full",onClick:ui,get disabled(){return Zr.isPending},get children(){return we(()=>!!Zr.isPending)()?c.t("session.share.action.unpublishing"):c.t("session.share.action.unpublish")}})),qe}})),Fe})()]}})}})}})}})]}}),null),he(Fe=>ct(Ce,{"shrink-0 flex items-center":!0,"gap-2":o.general.newLayoutDesigns(),"gap-3":!o.general.newLayoutDesigns()},Fe)),Ce})()}),null),he(Y=>{var Ce={"sticky top-0 z-30":!0,"bg-[linear-gradient(to_bottom,var(--v2-background-bg-base)_48px,transparent)]":o.general.newLayoutDesigns(),"bg-[linear-gradient(to_bottom,var(--background-stronger)_48px,transparent)]":!o.general.newLayoutDesigns(),"w-full":!0,"pb-4":!0,"pr-3":!0,"pl-2.5":o.general.newLayoutDesigns(),"pl-2 md:pl-4":!o.general.newLayoutDesigns(),"md:max-w-200 md:mx-auto 2xl:max-w-[1000px]":e.centered&&!o.general.newLayoutDesigns()},Fe={"flex items-center gap-1 min-w-0 flex-1":!0,"pr-3":!o.general.newLayoutDesigns()};return Y.e=ct(Ge,Ce,Y.e),Y.t=ct($t,Fe,Y.t),Y},{e:void 0,t:void 0}),Ge}}),(()=>{var Ge=Ztt();return pt(Ye=>{pe=Ye,e.setContentRef(Ye)},Ge),S(Ge,h(Dt,{get each(){return mt()},children:Ye=>h(ti,{rowKey:Ye})}),null),S(Ge,h(q,{get when(){return ke().length>0},get children(){var Ye=Gtt();return he($t=>Ct(Ye,"transform",`translateY(${ye.getTotalSize()-64}px)`)),Ye}}),null),he(Ye=>Ct(Ge,"height",`${ye.getTotalSize()}px`)),Ge})()]}}),null),he(Ge=>ct(nt,{"bottom-8":o.general.newLayoutDesigns(),"bottom-6":!o.general.newLayoutDesigns(),"opacity-100 translate-y-0 scale-100":e.scroll.overflow&&e.scroll.jump,"opacity-0 translate-y-2 pointer-events-none":!e.scroll.overflow||!e.scroll.jump,"scale-[0.8]":(!e.scroll.overflow||!e.scroll.jump)&&o.general.newLayoutDesigns(),"scale-95":(!e.scroll.overflow||!e.scroll.jump)&&!o.general.newLayoutDesigns()},Ge)),_e})()}dn(["click"]);const TN=[],hnt=15e3;function mnt(e){const t=Di(),n=Ji();let r,i;const[s]=ai(()=>e.sessionID(),g=>{if(m(),!g)return;const y=Wt(()=>n().data.message[g]!==void 0)&&!t().session.fresh(g,hnt);return r=requestAnimationFrame(()=>{r=void 0,i=window.setTimeout(()=>{i=void 0,e.sessionID()===g&&Wt(()=>{y&&n().session.sync(g,{force:!0})})},0)}),n().session.sync(g)}),o=I(()=>{const g=e.sessionID();return g?n().data.message[g]??[]:[]}),a=I(()=>{const g=e.sessionID();return!g||pnt(n().data.message[g],t().session.history.loading(g))}),l=I(()=>gnt(o()),TN,{equals:Zc}),c=I(()=>vnt(l(),e.revertMessageID()),TN,{equals:Zc}),u=I(()=>{const g=e.sessionID();return g?n().session.history.more(g):!1}),d=I(()=>{const g=e.sessionID();return g?n().session.history.loading(g):!1}),f=async g=>ynt({sessionID:e.sessionID,more:u,loading:d,loadMore:p=>n().session.history.loadMore(p),before:g?.before,after:g?.after});return Te(m),{history:{loadOlder:f,loading:d,more:u},lastUserMessage:I(()=>c().at(-1)),messages:o,ready:a,resource:s,userMessages:l,visibleUserMessages:c};function m(){r!==void 0&&cancelAnimationFrame(r),i!==void 0&&window.clearTimeout(i),r=void 0,i=void 0}}function gnt(e){return e.filter(t=>t.role==="user")}function pnt(e,t){return e!==void 0&&(e.some(n=>n.role==="user")||!t)}function vnt(e,t){return t?e.filter(n=>n.id<t):e}async function ynt(e){const t=e.sessionID();!t||!e.more()||e.loading()||(e.before?.(),await e.loadMore(t).catch(n=>{throw e.sessionID()===t&&e.after?.(!0),n}),e.sessionID()===t&&e.after?.(!0))}var bnt={};ds(bnt,{Description:()=>Od,ErrorMessage:()=>Rd,Item:()=>lre,ItemControl:()=>jI,ItemDescription:()=>qI,ItemIndicator:()=>BI,ItemInput:()=>cre,ItemLabel:()=>UI,Label:()=>WI,RadioGroup:()=>o3,Root:()=>ure,useRadioGroupContext:()=>s3});var ore=bn();function s3(){const e=hn(ore);if(e===void 0)throw new Error("[kobalte]: `useRadioGroupContext` must be used within a `RadioGroup` component");return e}var are=bn();function a0(){const e=hn(are);if(e===void 0)throw new Error("[kobalte]: `useRadioGroupItemContext` must be used within a `RadioGroup.Item` component");return e}function lre(e){const t=ma(),n=s3(),r=`${t.generateId("item")}-${nr()}`,i=Mt({id:r},e),[s,o]=Ee(i,["value","disabled","onPointerDown"]),[a,l]=De(),[c,u]=De(),[d,f]=De(),[m,g]=De(),[p,y]=De(!1),v=I(()=>n.isDefaultValue(s.value)),b=I(()=>n.isSelectedValue(s.value)),w=I(()=>s.disabled||t.isDisabled()||!1),x=E=>{Nt(E,s.onPointerDown),p()&&E.preventDefault()},k=I(()=>({...t.dataset(),"data-disabled":w()?"":void 0,"data-checked":b()?"":void 0})),C={value:()=>s.value,dataset:k,isDefault:v,isSelected:b,isDisabled:w,inputId:a,labelId:c,descriptionId:d,inputRef:m,select:()=>n.setSelectedValue(s.value),generateId:us(()=>o.id),registerInput:Cr(l),registerLabel:Cr(u),registerDescription:Cr(f),setIsFocused:y,setInputRef:g};return h(are.Provider,{value:C,get children(){return h(Xt,le({as:"div",role:"group",onPointerDown:x},k,o))}})}function jI(e){const t=a0(),n=Mt({id:t.generateId("control")},e),[r,i]=Ee(n,["onClick","onKeyDown"]);return h(Xt,le({as:"div",onClick:a=>{Nt(a,r.onClick),t.select(),t.inputRef()?.focus()},onKeyDown:a=>{Nt(a,r.onKeyDown),a.key===Kx.Space&&(t.select(),t.inputRef()?.focus())}},()=>t.dataset(),i))}function qI(e){const t=a0(),n=Mt({id:t.generateId("description")},e);return ae(()=>Te(t.registerDescription(n.id))),h(Xt,le({as:"div"},()=>t.dataset(),n))}function BI(e){const t=a0(),n=Mt({id:t.generateId("indicator")},e),[r,i]=Ee(n,["ref","forceMount"]),[s,o]=De(),{present:a}=Va({show:()=>r.forceMount||t.isSelected(),element:()=>s()??null});return h(q,{get when(){return a()},get children(){return h(Xt,le({as:"div",ref(l){var c=Cn(o,r.ref);typeof c=="function"&&c(l)}},()=>t.dataset(),i))}})}function cre(e){const t=ma(),n=s3(),r=a0(),i=Mt({id:r.generateId("input")},e),[s,o]=Ee(i,["ref","style","aria-labelledby","aria-describedby","onChange","onFocus","onBlur"]),a=()=>[s["aria-labelledby"],r.labelId(),s["aria-labelledby"]!=null&&o["aria-label"]!=null?o.id:void 0].filter(Boolean).join(" ")||void 0,l=()=>[s["aria-describedby"],r.descriptionId(),n.ariaDescribedBy()].filter(Boolean).join(" ")||void 0,[c,u]=De(!1),d=g=>{if(Nt(g,s.onChange),g.stopPropagation(),!c()){n.setSelectedValue(r.value());const p=g.target;p.checked=r.isSelected()}u(!1)},f=g=>{Nt(g,s.onFocus),r.setIsFocused(!0)},m=g=>{Nt(g,s.onBlur),r.setIsFocused(!1)};return ae(vt([()=>r.isSelected(),()=>r.value()],g=>{if(!g[0]&&g[1]===r.value())return;u(!0);const p=r.inputRef();p?.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!0})),p?.dispatchEvent(new Event("change",{bubbles:!0,cancelable:!0}))},{defer:!0})),ae(()=>Te(r.registerInput(o.id))),h(Xt,le({as:"input",ref(g){var p=Cn(r.setInputRef,s.ref);typeof p=="function"&&p(g)},type:"radio",get name(){return t.name()},get value(){return r.value()},get checked(){return r.isSelected()},get required(){return t.isRequired()},get disabled(){return r.isDisabled()},get readonly(){return t.isReadOnly()},get style(){return cs({...Gx},s.style)},get"aria-labelledby"(){return a()},get"aria-describedby"(){return l()},onChange:d,onFocus:f,onBlur:m},()=>r.dataset(),o))}function UI(e){const t=a0(),n=Mt({id:t.generateId("label")},e);return ae(()=>Te(t.registerLabel(n.id))),h(Xt,le({as:"label",get for(){return t.inputId()}},()=>t.dataset(),n))}function WI(e){return h(cy,le({as:"span"},e))}function ure(e){let t;const n=`radiogroup-${nr()}`,r=Mt({id:n,orientation:"vertical"},e),[i,s,o]=Ee(r,["ref","value","defaultValue","onChange","orientation","aria-labelledby","aria-describedby"],jk),[a,l]=ih({value:()=>i.value,defaultValue:()=>i.defaultValue,onChange:y=>i.onChange?.(y)}),{formControlContext:c}=qk(s);uy(()=>t,()=>l(i.defaultValue??""));const u=()=>c.getAriaLabelledBy(We(s.id),o["aria-label"],i["aria-labelledby"]),d=()=>c.getAriaDescribedBy(i["aria-describedby"]),f=y=>y===e.defaultValue,m=y=>y===a(),p={ariaDescribedBy:d,isDefaultValue:f,isSelectedValue:m,setSelectedValue:y=>{if(!(c.isReadOnly()||c.isDisabled())&&(l(y),t))for(const v of t.querySelectorAll("[type='radio']")){const b=v;b.checked=m(b.value)}}};return h(ly.Provider,{value:c,get children(){return h(ore.Provider,{value:p,get children(){return h(Xt,le({as:"div",ref(y){var v=Cn(b=>t=b,i.ref);typeof v=="function"&&v(y)},role:"radiogroup",get id(){return We(s.id)},get"aria-invalid"(){return c.validationState()==="invalid"||void 0},get"aria-required"(){return c.isRequired()||void 0},get"aria-disabled"(){return c.isDisabled()||void 0},get"aria-readonly"(){return c.isReadOnly()||void 0},get"aria-orientation"(){return i.orientation},get"aria-labelledby"(){return u()},get"aria-describedby"(){return d()}},()=>c.dataset(),o))}})}})}var o3=Object.assign(ure,{Description:Od,ErrorMessage:Rd,Item:lre,ItemControl:jI,ItemDescription:qI,ItemIndicator:BI,ItemInput:cre,ItemLabel:UI,Label:WI}),dre=bn();function fre(){const e=hn(dre);if(e===void 0)throw new Error("[kobalte]: `useSegmentedControlContext` must be used within a `SegmentedControl` component");return e}function wnt(e){const t=fre(),[n,r]=Ee(e,["style"]),[i,s]=De(),[o,a]=De(!1),l=()=>{const u=t.selectedItem();if(!u){s(void 0);return}s({width:`${u.offsetWidth}px`,height:`${u.offsetHeight}px`,transform:c(u),"transition-duration":o()?"0ms":void 0})},c=u=>{const d=getComputedStyle(u.parentElement),f=u.offsetLeft-Number.parseFloat(d.paddingLeft),m=u.offsetTop-Number.parseFloat(d.paddingTop);return`translate(${f}px, ${m}px)`};return ae(vt(t.selectedItem,()=>{a(!i()),l(),a(!1)})),Oa(t.root,()=>{qt(()=>{a(!0),l(),a(!1)})}),h(Xt,le({as:"div",role:"presentation",get style(){return cs(i(),n.style)},get"data-resizing"(){return o()},get"data-orientation"(){return t.orientation()}},r))}var xnt=e=>{const t=s3(),n=fre(),[r,i]=Ee(e,["ref"]),[s,o]=De();return ae(()=>{const a=s();a&&t.isSelectedValue(e.value)&&n.setSelectedItem(a)}),h(o3.Item,le({ref(a){var l=Cn(o,r.ref);typeof l=="function"&&l(a)}},i))},knt=e=>{const t=a0(),[n,r]=Ee(e,["ref"]),[i,s]=De();return uy(i,()=>{requestAnimationFrame(()=>{t.isDefault()&&t.select()})}),h(o3.ItemInput,le({ref(o){var a=Cn(s,n.ref);typeof a=="function"&&a(o)}},r))},Snt=e=>{const t=le({defaultValue:e.value,orientation:"horizontal"},e),[n,r]=Ee(t,["ref"]),[i,s]=De(),[o,a]=De(),l={value:()=>r.value,defaultValue:()=>r.defaultValue,orientation:()=>r.orientation,root:i,selectedItem:o,setSelectedItem:a};return ae(()=>{l.value()||a(void 0)}),h(dre.Provider,{value:l,get children(){return h(o3,le({ref(c){var u=Cn(s,n.ref);typeof u=="function"&&u(c)}},r))}})},q0=Object.assign(Snt,{Description:Od,ErrorMessage:Rd,Indicator:wnt,Item:xnt,ItemControl:jI,ItemDescription:qI,ItemIndicator:BI,ItemInput:knt,ItemLabel:UI,Label:WI}),Cnt=A("<div role=presentation data-slot=radio-group-wrapper><div role=presentation data-slot=radio-group-items>"),_nt=A("<span data-slot=radio-group-item-control>");function Tnt(e){const[t,n]=Ee(e,["class","classList","options","current","defaultValue","value","label","onSelect","size","fill","pad"]),r=o=>t.value?t.value(o):String(o),i=o=>t.label?t.label(o):String(o),s=o=>t.options.find(a=>r(a)===o);return h(q0,le(n,{"data-component":"radio-group",get"data-size"(){return t.size??"medium"},get"data-fill"(){return t.fill?"":void 0},get"data-pad"(){return t.pad??"normal"},get classList(){return{...t.classList,[t.class??""]:!!t.class}},get value(){return we(()=>!!t.current)()?r(t.current):void 0},get defaultValue(){return we(()=>!!t.defaultValue)()?r(t.defaultValue):void 0},onChange:o=>t.onSelect?.(s(o)),get children(){var o=Cnt(),a=o.firstChild;return S(o,h(q0.Indicator,{"data-slot":"radio-group-indicator"}),a),S(a,h(Dt,{get each(){return t.options},children:l=>h(q0.Item,{get value(){return r(l)},"data-slot":"radio-group-item",get"data-value"(){return r(l)},get children(){return[h(q0.ItemInput,{"data-slot":"radio-group-item-input"}),h(q0.ItemLabel,{"data-slot":"radio-group-item-label",get children(){var c=_nt();return S(c,()=>i(l)),c}})]}})})),o}}))}function Ent(e){if(typeof document>"u")return;const t=document.createElement("button");t.type="button",t.ariaLabel=e.label,t.textContent="+",t.style.width="20px",t.style.height="20px",t.style.display="flex",t.style.alignItems="center",t.style.justifyContent="center",t.style.border="none",t.style.borderRadius="var(--radius-md)",t.style.background="var(--icon-interactive-base)",t.style.color="var(--white)",t.style.boxShadow="var(--shadow-xs)",t.style.fontSize="14px",t.style.lineHeight="1",t.style.cursor="pointer",t.style.position="relative",t.style.left="30px",t.style.top="calc((var(--diffs-line-height, 24px) - 20px) / 2)";let n;const r=()=>{const o=e.getHoveredLine();o&&(n=o)},i=()=>{if(!t.isConnected){document.removeEventListener("pointermove",i),document.removeEventListener("scroll",i,!0);return}r()},s=()=>{const o=e.getHoveredLine()??n;o&&e.onSelect(o)};return document.addEventListener("pointermove",i,{passive:!0}),document.addEventListener("scroll",i,{passive:!0,capture:!0}),t.addEventListener("mouseenter",r),t.addEventListener("mousemove",r),t.addEventListener("pointerdown",o=>{o.preventDefault(),o.stopPropagation(),r()}),t.addEventListener("mousedown",o=>{o.preventDefault(),o.stopPropagation(),r()}),t.addEventListener("click",o=>{o.preventDefault(),o.stopPropagation(),s()}),t}var Int=A('<svg><path d="M16.25 3.75H3.75V16.25L6.875 14.4643H16.25V3.75Z"stroke=currentColor stroke-linecap=square></svg>',!1,!0,!1),Dnt=A('<svg data-slot=line-comment-icon viewBox="0 0 20 20"fill=none aria-hidden=true>'),Lnt=A('<svg><path d="M10 5.41699V10.0003M10 10.0003V14.5837M10 10.0003H5.4165M10 10.0003H14.5832"stroke=currentColor stroke-linecap=square></svg>',!1,!0,!1),Ant=A("<div data-slot=line-comment-popover data-inline-body>"),Mnt=A("<div data-component=line-comment data-prevent-autofocus>"),$nt=A("<button type=button data-slot=line-comment-button>"),Pnt=A("<div data-slot=line-comment-popover>"),Ont=A("<div data-slot=line-comment-tools>"),Rnt=A("<div data-slot=line-comment-content><div data-slot=line-comment-head><div data-slot=line-comment-text></div></div><div data-slot=line-comment-label>"),Fnt=A("<div data-slot=line-comment-mention-list>"),Nnt=A("<div data-slot=line-comment-editor><textarea data-slot=line-comment-textarea></textarea><div data-slot=line-comment-actions><div data-slot=line-comment-editor-label>"),Vnt=A("<span data-slot=line-comment-mention-file>"),znt=A("<button type=button data-slot=line-comment-mention-item><div data-slot=line-comment-mention-path><span data-slot=line-comment-mention-dir>"),Hnt=A("<button type=button data-slot=line-comment-action data-variant=ghost>"),jnt=A("<button type=button data-slot=line-comment-action data-variant=primary>");sve();function qnt(e){return(()=>{var t=Dnt();return S(t,h(q,{get when(){return e.icon==="comment"},get fallback(){return Lnt()},get children(){return Int()}})),t})()}const hre=e=>{const t=()=>!e.inline&&e.top===void 0,n=()=>e.variant??"default",r=()=>e.icon??"comment",i=()=>e.inline&&e.hideButton;return(()=>{var s=Mnt();return S(s,h(q,{get when(){return i()},get fallback(){return[(()=>{var o=$nt();return cn(o,"mouseenter",e.onMouseEnter),cn(o,"click",e.onClick),cn(o,"mouseup",a=>a.stopPropagation()),cn(o,"mousedown",a=>a.stopPropagation()),S(o,h(q,{get when(){return e.inline},get fallback(){return h(Yt,{get name(){return r()==="plus"?"plus-small":"comment"},size:"small"})},get children(){return h(qnt,{get icon(){return r()}})}})),he(()=>me(o,"aria-label",e.buttonLabel)),o})(),h(q,{get when(){return e.open},get children(){var o=Pnt();return cn(o,"focusout",e.onPopoverFocusOut),cn(o,"mousedown",a=>a.stopPropagation()),S(o,()=>e.children),he(a=>ct(o,{[e.popoverClass??""]:!!e.popoverClass},a)),o}})]},get children(){var o=Ant();return cn(o,"focusout",e.onPopoverFocusOut),cn(o,"mouseenter",e.onMouseEnter),cn(o,"click",e.onClick),cn(o,"mousedown",a=>a.stopPropagation()),S(o,()=>e.children),he(a=>ct(o,{[e.popoverClass??""]:!!e.popoverClass},a)),o}})),he(o=>{var a=n(),l=e.id,c=e.open?"":void 0,u=e.inline?"":void 0,d={[e.class??""]:!!e.class},f=e.inline?void 0:{top:`${e.top??0}px`,opacity:t()?0:1,"pointer-events":t()?"none":"auto"};return a!==o.e&&me(s,"data-variant",o.e=a),l!==o.t&&me(s,"data-comment-id",o.t=l),c!==o.a&&me(s,"data-open",o.a=c),u!==o.o&&me(s,"data-inline",o.o=u),o.i=ct(s,d,o.i),o.n=So(s,f,o.n),o},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),s})()},Bnt=e=>{const t=Mn(),[n,r]=Ee(e,["comment","selection","actions"]);return h(hre,le(r,{variant:"default",get hideButton(){return e.inline},get children(){var i=Rnt(),s=i.firstChild,o=s.firstChild,a=s.nextSibling;return S(o,()=>n.comment),S(s,h(q,{get when(){return n.actions},get children(){var l=Ont();return S(l,()=>n.actions),l}}),null),S(a,()=>t.t("ui.lineComment.label.prefix"),null),S(a,()=>n.selection,null),S(a,()=>t.t("ui.lineComment.label.suffix"),null),i}}))},mre=e=>{const t=Mn(),[n,r]=Ee(e,["value","selection","onInput","onCancel","onSubmit","placeholder","rows","autofocus","cancelLabel","submitLabel","mention"]),i={textarea:void 0},[s,o]=De(!1);function a(v){if(!v)return;const b=i.textarea,w=m();if(!b||!w)return;const x=`${b.value.slice(0,w.start)}@${v.path} ${b.value.slice(w.end)}`,k=w.start+v.path.length+2;n.onInput(x),f(),requestAnimationFrame(()=>{b.focus(),b.setSelectionRange(k,k)})}const l=th({items:async v=>n.mention?v.trim()?(await n.mention.items(v)).map(w=>({path:w})):[]:[],key:v=>v.path,filterKeys:["path"],skipFilter:()=>!0,onSelect:a}),c=()=>i.textarea?.focus(),u=v=>{v.preventDefault(),v.stopPropagation()},d=v=>b=>{b.stopPropagation(),v()},f=()=>{o(!1),l.clear()},m=()=>{const v=i.textarea;if(!v||!n.mention||v.selectionStart!==v.selectionEnd)return;const b=v.selectionStart,w=v.value.slice(0,b).match(/@(\S*)$/);if(w)return{query:w[1]??"",start:b-w[0].length,end:b}},g=()=>{const v=m();if(!v){f();return}o(!0),l.onInput(v.query)},p=()=>{const v=l.flat();if(v.length===0)return;const b=l.active();a(v.find(w=>w.path===b)??v[0])},y=()=>{const v=n.value.trim();v&&n.onSubmit(v)};return sn(()=>{n.autofocus!==!1&&requestAnimationFrame(c)}),h(hre,le(r,{open:!0,variant:"editor",get hideButton(){return e.inline},onClick:()=>c(),get children(){var v=Nnt(),b=v.firstChild,w=b.nextSibling,x=w.firstChild;return cn(b,"keydown",k=>{const C=k;if(!(C.isComposing||C.keyCode===229)){if(C.stopPropagation(),s()){if(k.key==="Escape"){C.preventDefault(),f();return}if(k.key==="Tab"){if(l.flat().length===0)return;C.preventDefault(),p();return}const E=k.key==="ArrowUp"||k.key==="ArrowDown"||k.key==="Enter",_=C.ctrlKey&&!C.metaKey&&!C.altKey&&!C.shiftKey&&(k.key==="n"||k.key==="p");if((E||_)&&l.flat().length>0){l.onKeyDown(C),C.preventDefault();return}}if(k.key==="Escape"){C.preventDefault(),k.currentTarget.blur(),n.onCancel();return}k.key==="Enter"&&(k.shiftKey||(C.preventDefault(),y()))}}),cn(b,"select",()=>g()),cn(b,"click",()=>g()),cn(b,"input",k=>{const C=k.currentTarget.value;n.onInput(C),g()}),pt(k=>{i.textarea=k},b),S(v,h(q,{get when(){return we(()=>!!s())()&&l.flat().length>0},get children(){var k=Fnt();return S(k,h(Dt,{get each(){return l.flat().slice(0,10)},children:C=>{const E=C.path.endsWith("/")?C.path:hc(C.path),_=C.path.endsWith("/")?"":fn(C.path);return(()=>{var L=znt(),O=L.firstChild,$=O.firstChild;return L.$$click=()=>a(C),L.addEventListener("mouseenter",()=>l.setActive(C.path)),L.$$mousedown=V=>V.preventDefault(),S(L,h(Dr,{get node(){return{path:C.path,type:"file"}},class:"shrink-0 size-4"}),O),S($,E),S(O,h(q,{when:_,get children(){var V=Vnt();return S(V,_),V}}),null),he(()=>me(L,"data-active",l.active()===C.path?"":void 0)),L})()}})),k}}),w),S(x,()=>t.t("ui.lineComment.editorLabel.prefix"),null),S(x,()=>n.selection,null),S(x,()=>t.t("ui.lineComment.editorLabel.suffix"),null),S(w,h(q,{get when(){return!e.inline},get fallback(){return[(()=>{var k=Hnt();return cn(k,"click",d(n.onCancel)),cn(k,"mousedown",u),S(k,()=>n.cancelLabel??t.t("ui.common.cancel")),k})(),(()=>{var k=jnt();return cn(k,"click",d(y)),cn(k,"mousedown",u),S(k,()=>n.submitLabel??t.t("ui.lineComment.submit")),he(()=>k.disabled=n.value.trim().length===0),k})()]},get children(){return[h(Kt,{size:"small",variant:"ghost",get onClick(){return n.onCancel},get children(){return n.cancelLabel??t.t("ui.common.cancel")}}),h(Kt,{size:"small",variant:"primary",get disabled(){return n.value.trim().length===0},onClick:y,get children(){return n.submitLabel??t.t("ui.lineComment.submit")}})]}}),null),he(k=>{var C=n.rows??3,E=n.placeholder??t.t("ui.lineComment.placeholder");return C!==k.e&&me(b,"rows",k.e=C),E!==k.t&&me(b,"placeholder",k.t=E),k},{e:void 0,t:void 0}),he(()=>b.value=n.value),v}}))};dn(["mousedown","click"]);function Unt(e){const t=new Map,n=o=>{if(typeof document>"u")return;const a=document.createElement("div");a.setAttribute("data-prevent-autofocus","");const[l,c]=De(o),u=GC(()=>{const f=l();if(f.kind==="comment"){const g=I(()=>{const p=l();return p.kind!=="comment"?e.renderComment(f.comment):e.renderComment(p.comment)});return e.commentElement(g)}const m=I(()=>{const g=l();return g.kind!=="draft"?e.renderDraft(f.range):e.renderDraft(g.range)});return e.draftElement(m)},a),d={host:a,dispose:u,setMeta:c};return t.set(o.key,d),d};return{render:o=>{const a=o.metadata,l=t.get(a.key)??n(a);if(l)return l.setMeta(a),l.host},reconcile:o=>{const a=new Set(o.map(l=>l.metadata.key));for(const[l,c]of t)a.has(l)||(c.dispose(),t.delete(l))},cleanup:()=>{for(const[,o]of t)o.dispose();t.clear()}}}function Wnt(e){return h(q,{get when(){return e().editor},get fallback(){return h(Bnt,{inline:!0,get id(){return e().id},get open(){return e().open},get comment(){return e().comment},get selection(){return e().selection},get actions(){return e().actions},get onClick(){return e().onClick},get onMouseEnter(){return e().onMouseEnter}})},get children(){return h(mre,{inline:!0,get id(){return e().id},get value(){return e().editor.value},get selection(){return e().editor.selection},get onInput(){return e().editor.onInput},get onCancel(){return e().editor.onCancel},get onSubmit(){return e().editor.onSubmit},get onPopoverFocusOut(){return e().editor.onPopoverFocusOut},get cancelLabel(){return e().editor.cancelLabel},get submitLabel(){return e().editor.submitLabel},get mention(){return e().editor.mention}})}})}function Knt(e){return h(mre,{inline:!0,get value(){return e().value},get selection(){return e().selection},get onInput(){return e().onInput},get onCancel(){return e().onCancel},get onSubmit(){return e().onSubmit},get onPopoverFocusOut(){return e().onPopoverFocusOut},get mention(){return e().mention}})}function gre(e){const[t,n]=Ze({draft:"",editing:null}),r=()=>t.draft,i=b=>n("draft",b),s=()=>t.editing,o=b=>n("editing",typeof b=="function"?()=>b:b),a=b=>b?tc(b):null,l=b=>{const w=a(b);return e.setSelected(w),e.syncSelected?.(a(w)),w},c=b=>{const w=a(b);return e.setCommenting(w),w},u=()=>{e.setOpened(null)},d=()=>{i(""),o(null),c(null)},f=()=>{i(""),o(null),e.setOpened(null),e.setSelected(null),e.setCommenting(null)},m=(b,w,x)=>{x?.cancelDraft&&d(),e.setOpened(b),l(w)},g=(b,w,x)=>{x?.cancelDraft&&d();const k=e.opened()===b?null:b;e.setOpened(k),l(w)},p=b=>{const w=a(b);i(""),o(null),u(),l(w),c(w)},y=(b,w,x)=>{u(),l(w),e.setCommenting(null),o(b),i(x)},v=b=>{const w=a(b);if(w){if(e.hoverSelected){e.hoverSelected(w);return}l(w)}};return{draft:r,setDraft:i,editing:s,opened:e.opened,selected:e.selected,commenting:e.commenting,isOpen:b=>e.opened()===b,isEditing:b=>s()===b,closeComment:u,openComment:m,toggleComment:g,openDraft:p,openEditor:y,hoverComment:v,cancelDraft:d,select:l,reset:f}}function pre(e){const t=Mn(),n=gre(e.state),r="getSide"in e?NC({comments:e.comments,getCommentId:l=>l.id,getCommentSelection:l=>l.selection,draftRange:n.commenting,draftKey:e.draftKey,getSide:e.getSide}):NC({comments:e.comments,getCommentId:l=>l.id,getCommentSelection:l=>l.selection,draftRange:n.commenting,draftKey:e.draftKey}),{renderAnnotation:i}=vre({annotations:r,commentElement:Wnt,draftElement:Knt,renderComment:l=>{const c=()=>n.openEditor(l.id,l.selection,l.comment),u=()=>{n.reset(),e.onDelete?.(l)};return{id:l.id,get open(){return n.isOpen(l.id)||n.isEditing(l.id)},comment:l.comment,selection:Pm(l.selection,t.t),get actions(){return e.renderCommentActions?.(l,{edit:c,remove:u})},get editor(){return n.isEditing(l.id)?{get value(){return n.draft()},selection:Pm(l.selection,t.t),mention:e.mention,onInput:n.setDraft,onCancel:n.cancelDraft,onSubmit:d=>{e.onUpdate?.({id:l.id,comment:d,selection:tc(l.selection)}),n.cancelDraft()},submitLabel:e.editSubmitLabel}:void 0},onMouseEnter:()=>n.hoverComment(l.selection),onClick:()=>{n.isEditing(l.id)||n.toggleComment(l.id,l.selection,{cancelDraft:e.cancelDraftOnCommentToggle})}}},renderDraft:l=>({get value(){return n.draft()},selection:Pm(l,t.t),mention:e.mention,onInput:n.setDraft,onCancel:()=>{n.cancelDraft(),n.select(null)},onSubmit:c=>{e.onSubmit({comment:c,selection:tc(l)}),n.cancelDraft()},onPopoverFocusOut:e.onDraftPopoverFocusOut})}),s=yre({label:e.label,getSelectedRange:()=>n.opened()?null:e.getHoverSelectedRange?.()??n.selected(),onOpenDraft:n.openDraft});return{note:n,annotations:r,renderAnnotation:i,renderGutterUtility:s,onLineSelected:l=>{if(!l){n.select(null),n.cancelDraft();return}n.select(l)},onLineSelectionEnd:l=>{if(!l){e.clearSelectionOnSelectionEndNull&&n.select(null),n.cancelDraft();return}n.openDraft(l)}}}function NC(e){const t=n=>Math.max(n.start,n.end);return"getSide"in e?I(()=>{const n=e.comments().map(i=>{const s=e.getCommentSelection(i);return{side:e.getSide(s),lineNumber:t(s),metadata:{kind:"comment",key:`comment:${e.getCommentId(i)}`,comment:i}}}),r=e.draftRange();return r?[...n,{side:e.getSide(r),lineNumber:t(r),metadata:{kind:"draft",key:`draft:${e.draftKey()}`,range:r}}]:n},[],{equals:EN}):I(()=>{const n=e.comments().map(s=>{const o=e.getCommentSelection(s);return{lineNumber:t(o),metadata:{kind:"comment",key:`comment:${e.getCommentId(s)}`,comment:s}}}),r=e.draftRange();if(!r)return n;const i={lineNumber:t(r),metadata:{kind:"draft",key:`draft:${e.draftKey()}`,range:r}};return[...n,i]},[],{equals:EN})}function EN(e,t){return e.length!==t.length?!1:e.every((n,r)=>{const i=t[r];return n.lineNumber===i.lineNumber&&n.side===i.side&&n.metadata.kind===i.metadata.kind&&n.metadata.key===i.metadata.key&&n.metadata.comment===i.metadata.comment&&n.metadata.range===i.metadata.range})}function vre(e){const t=Unt({renderComment:e.renderComment,renderDraft:e.renderDraft,commentElement:e.commentElement,draftElement:e.draftElement});return ae(()=>{t.reconcile(e.annotations())}),Te(()=>{t.cleanup()}),{renderAnnotation:t.render}}function yre(e){return t=>Ent({label:e.label,getHoveredLine:t,onSelect:n=>{const r=e.getSelectedRange();if(r&&kve(r,n.lineNumber,n.side)){e.onOpenDraft(tc(r));return}const i={start:n.lineNumber,end:n.lineNumber};n.side&&(i.side=n.side),e.onOpenDraft(i)}})}var Gnt=A("<div>"),Znt=A("<div data-slot=session-review-list class=pb-6>"),Ynt=A("<div data-slot=session-review-container>"),Xnt=A("<div data-component=session-review><div data-slot=session-review-header><div data-slot=session-review-title></div><div data-slot=session-review-actions>"),Qnt=A("<span data-slot=session-review-directory>"),Jnt=A("<button data-slot=session-review-view-button type=button>"),ert=A("<div data-slot=session-review-change-group data-type=added><span data-slot=session-review-change data-type=added>"),trt=A("<span data-slot=session-review-change data-type=removed>"),nrt=A("<span data-slot=session-review-change data-type=modified>"),rrt=A("<span data-slot=session-review-diff-chevron>"),irt=A("<div data-slot=session-review-trigger-content><div data-slot=session-review-file-info><div data-slot=session-review-file-name-container><span data-slot=session-review-filename></span></div></div><div data-slot=session-review-trigger-actions>"),srt=A('<div data-slot=session-review-diff-placeholder class="rounded-lg border border-border-weak-base bg-background-stronger/40"style=height:160px>'),ort=A("<div data-slot=session-review-large-diff><div data-slot=session-review-large-diff-title></div><div data-slot=session-review-large-diff-meta></div><div data-slot=session-review-large-diff-actions>"),art=A("<div data-slot=session-review-diff-wrapper>");const IN=500,DN=300;function r2(e){return!e||typeof e!="object"||Array.isArray(e)||!("file"in e)||typeof e.file!="string"||!("additions"in e)||typeof e.additions!="number"||!("deletions"in e)||typeof e.deletions!="number"||"patch"in e&&e.patch!==void 0&&typeof e.patch!="string"||"before"in e&&e.before!==void 0&&typeof e.before!="string"||"after"in e&&e.after!==void 0&&typeof e.after!="string"?!1:!("status"in e)||e.status===void 0?!0:e.status==="added"||e.status==="deleted"||e.status==="modified"}function lrt(e){return Array.isArray(e)&&e.every(r2)?e:Array.isArray(e)?e.filter(r2):r2(e)?[e]:!e||typeof e!="object"?[]:Object.values(e).filter(r2)}function crt(e){return(()=>{var t=Gnt();return t.$$click=n=>n.stopPropagation(),t.$$mousedown=n=>n.stopPropagation(),S(t,h(at,{gutter:4,placement:"bottom-end",get children(){return[h(at.Trigger,{as:Ln,icon:"dot-grid",variant:"ghost",size:"small",class:"size-6 rounded-md",get"aria-label"(){return e.labels.moreLabel}}),h(at.Portal,{get children(){return h(at.Content,{get children(){return[h(at.Item,{get onSelect(){return e.onEdit},get children(){return h(at.ItemLabel,{get children(){return e.labels.editLabel}})}}),h(at.Item,{get onSelect(){return e.onDelete},get children(){return h(at.ItemLabel,{get children(){return e.labels.deleteLabel}})}})]}})}})]}})),t})()}function urt(e){const t=so(e);if(t)return`session-review-diff-${t}`}const drt=e=>{let t,n=0,r;const i=Mn(),s=_d(),o=new Map,a=new Map,[l,c]=Ze({open:[],visible:{},force:{},selection:null,commenting:null,opened:null}),u=()=>l.selection,d=()=>l.commenting,f=()=>l.opened,m=()=>e.open??l.open,g=I(()=>Object.fromEntries(lrt(e.diffs).map(V=>[V.file,{...i3(V),preloaded:V.preloaded}]))),p=I(()=>e.diffs.map(V=>V.file)),y=I(()=>{const V=new Map;for(const P of e.comments??[]){const T=V.get(P.file);if(T){T.push(P);continue}V.set(P.file,[P])}return V}),v=()=>e.diffStyle??(e.split?"split":"unified"),b=()=>p().length>0,w=()=>{if(r=void 0,!t)return;const V=t.getBoundingClientRect(),P=V.top-DN,T=V.bottom+DN,D=new Set(m()),N={};for(const[z,W]of a){if(!D.has(z))continue;const J=W.getBoundingClientRect();J.bottom<P||J.top>T||(N[z]=!0)}const M=Wt(()=>l.visible),F=Object.keys(M),j=Object.keys(N);F.length===j.length&&j.every(z=>M[z])||c("visible",N)},x=()=>{r===void 0&&(r=requestAnimationFrame(w))},k=V=>e.focusedComment?.file===V||e.focusedFile===V||u()?.file===V||d()?.file===V||f()?.file===V,C=V=>{x();const P=e.onScroll;if(P){if(Array.isArray(P)){const[T,D]=P;T(D,V);return}P(V)}};Te(()=>{r!==void 0&&cancelAnimationFrame(r)}),ae(()=>{e.open,p(),x()});const E=V=>{e.onOpenChange?.(V),e.open===void 0&&c("open",V),x()},_=()=>{const V=m().length>0?[]:p();E(V)},L=()=>i.t("ui.sessionReview.openFile"),O=V=>V.endSide??V.side??"additions",$=(V,P)=>{const T=O(P),D=U2(V,T);if(D.length!==0)return Ag(D,P)};return ae(()=>{const V=e.focusedComment;V&&Wt(()=>{n++;const P=n;c("opened",V);const T=(e.comments??[]).find(M=>M.file===V.file&&M.id===V.id);T&&c("selection",{file:T.file,range:tc(T.selection)});const D=m();D.includes(V.file)||E([...D,V.file]);const N=M=>{if(P!==n)return;const F=t;if(!F)return;const j=o.get(V.file),z=j?.querySelector(`[data-comment-id="${V.id}"]`),W=z instanceof HTMLElement&&z.style.pointerEvents!=="none"&&z.style.opacity!=="0",J=W?z:j;if(!J){if(M>=120)return;requestAnimationFrame(()=>N(M+1));return}const K=F.getBoundingClientRect(),X=J.getBoundingClientRect(),te=X.top-K.top,ve=F.scrollTop+te-K.height/2+X.height/2;F.scrollTop=Math.max(0,ve),!W&&(M>=120||requestAnimationFrame(()=>N(M+1)))};requestAnimationFrame(()=>N(0)),requestAnimationFrame(()=>e.onFocusedCommentChange?.(null))})}),(()=>{var V=Xnt(),P=V.firstChild,T=P.firstChild,D=T.nextSibling;return S(T,(()=>{var N=we(()=>e.title===void 0);return()=>N()?i.t("ui.sessionReview.title"):e.title})()),S(D,h(q,{get when(){return we(()=>!!b())()&&e.onDiffStyleChange},get children(){return h(Tnt,{options:["unified","split"],get current(){return v()},size:"small",value:N=>N,label:N=>i.t(N==="unified"?"ui.sessionReview.diffStyle.unified":"ui.sessionReview.diffStyle.split"),onSelect:N=>N&&e.onDiffStyleChange?.(N)})}}),null),S(D,h(q,{get when(){return b()},get children(){return h(Kt,{size:"small",icon:"chevron-grabber-vertical",class:"w-[106px] justify-start",onClick:_,get children(){return h(Rr,{get children(){return[h(zt,{get when(){return m().length>0},get children(){return i.t("ui.sessionReview.collapseAll")}}),h(zt,{when:!0,get children(){return i.t("ui.sessionReview.expandAll")}})]}})}})}}),null),S(D,()=>e.actions,null),S(V,h(yc,{"data-slot":"session-review-scroll",viewportRef:N=>{t=N,e.scrollRef?.(N),x()},onScroll:C,get classList(){return{[e.classes?.root??""]:!!e.classes?.root}},get children(){var N=Ynt();return S(N,h(q,{get when(){return b()},get fallback(){return e.empty},get children(){var M=Znt();return S(M,h(Ei,{multiple:!0,get value(){return m()},onChange:E,get children(){return h(Dt,{get each(){return p()},children:F=>{const j=()=>g()[F],z=()=>j().additions!==0||j().deletions!==0,W=I(()=>m().includes(F)),J=I(()=>W()&&(!!l.visible[F]||k(F))),K=()=>!!l.force[F],X=I(()=>y().get(F)??[]),te=I(()=>X().map(ce=>ce.selection)),ve=()=>U2(j(),"deletions"),ne=()=>U2(j(),"additions"),ie=()=>j().additions+j().deletions,ke=I(()=>c9(F)),ge=I(()=>!W()||K()||ke()?!1:ie()>IN),Pe=()=>j().status==="added"||ve().length===0&&ne().length>0,Me=()=>j().status==="deleted"||ne().length===0&&ve().length>0,de=I(()=>{const ce=u();return!ce||ce.file!==F?null:ce.range}),U=I(()=>{const ce=d();return!ce||ce.file!==F?null:ce.range}),He=pre({comments:X,label:i.t("ui.lineComment.submit"),draftKey:()=>F,mention:e.lineCommentMention,state:{opened:()=>{const ce=f();return!ce||ce.file!==F?null:ce.id},setOpened:ce=>c("opened",ce?{file:F,id:ce}:null),selected:de,setSelected:ce=>c("selection",ce?{file:F,range:ce}:null),commenting:U,setCommenting:ce=>c("commenting",ce?{file:F,range:ce}:null)},getSide:O,clearSelectionOnSelectionEndNull:!1,onSubmit:({comment:ce,selection:G})=>{e.onLineComment?.({file:F,selection:G,comment:ce,preview:$(j(),G)})},onUpdate:({id:ce,comment:G,selection:fe})=>{e.onLineCommentUpdate?.({id:ce,file:F,selection:fe,comment:G,preview:$(j(),fe)})},onDelete:ce=>{e.onLineCommentDelete?.({id:ce.id,file:F})},editSubmitLabel:e.lineCommentActions?.saveLabel,renderCommentActions:e.lineCommentActions?(ce,G)=>h(crt,{get labels(){return e.lineCommentActions},get onEdit(){return G.edit},get onDelete(){return G.remove}}):void 0});Te(()=>{o.delete(F),a.delete(F),x()});const Ue=ce=>{e.onLineComment&&He.onLineSelected(ce)},Z=ce=>{e.onLineComment&&He.onLineSelectionEnd(ce)};return h(Ei.Item,{get value(){return z()?F:null},get id(){return urt(F)},"data-file":F,"data-slot":"session-review-accordion-item",get"data-selected"(){return e.focusedFile===F?"":void 0},get children(){return[h(my,{get children(){return h(Ei.Trigger,{get disabled(){return!z()},class:"cursor-default",get children(){var ce=irt(),G=ce.firstChild,fe=G.firstChild,xe=fe.firstChild,Oe=G.nextSibling;return S(G,h(Dr,{node:{path:F,type:"file"}}),fe),S(fe,h(q,{get when(){return F.includes("/")},get children(){var re=Qnt();return S(re,()=>`‪${hc(F)}‬`),re}}),xe),S(xe,()=>fn(F)),S(fe,h(q,{get when(){return we(()=>!!e.onViewFile)()&&z()},get children(){return h(Ar,{get value(){return L()},placement:"top",gutter:4,get children(){var re=Jnt();return re.$$click=pe=>{pe.stopPropagation(),e.onViewFile?.(F)},S(re,h(Yt,{name:"open-file",size:"small"})),he(()=>me(re,"aria-label",L())),re}})}}),null),S(Oe,h(Rr,{get children(){return[h(zt,{get when(){return Pe()},get children(){var re=ert(),pe=re.firstChild;return S(pe,()=>i.t("ui.sessionReview.change.added")),S(re,h(Qc,{get changes(){return j()}}),null),re}}),h(zt,{get when(){return Me()},get children(){var re=trt();return S(re,()=>i.t("ui.sessionReview.change.removed")),re}}),h(zt,{get when(){return!!ke()},get children(){var re=nrt();return S(re,()=>i.t("ui.sessionReview.change.modified")),re}}),h(zt,{when:!0,get children(){return h(Qc,{get changes(){return j()}})}})]}}),null),S(Oe,h(q,{get when(){return z()},get children(){var re=rrt();return S(re,h(Yt,{name:"chevron-down",size:"small"})),re}}),null),ce}})}}),h(Ei.Content,{"data-slot":"session-review-accordion-content",get children(){var ce=art();return pt(G=>{o.set(F,G),a.set(F,G),x()},ce),S(ce,h(q,{get when(){return W()},get children(){return h(Rr,{get children(){return[h(zt,{get when(){return we(()=>!J())()&&!ge()},get children(){return srt()}}),h(zt,{get when(){return ge()},get children(){var G=ort(),fe=G.firstChild,xe=fe.nextSibling,Oe=xe.nextSibling;return S(fe,()=>i.t("ui.sessionReview.largeDiff.title")),S(xe,()=>i.t("ui.sessionReview.largeDiff.meta",{limit:IN.toLocaleString(),current:ie().toLocaleString()})),S(Oe,h(Kt,{size:"normal",variant:"secondary",onClick:()=>c("force",F,!0),get children(){return i.t("ui.sessionReview.largeDiff.renderAnyway")}})),G}}),h(zt,{when:!0,get children(){return h(Gi,{component:s,mode:"diff",get fileDiff(){return j().fileDiff},get preloadedDiff(){return j().preloaded},get diffStyle(){return v()},onRendered:()=>{e.onDiffRendered?.()},get enableLineSelection(){return e.onLineComment!=null},get enableGutterUtility(){return e.onLineComment!=null},onLineSelected:Ue,onLineSelectionEnd:Z,get annotations(){return He.annotations()},get renderAnnotation(){return He.renderAnnotation},get renderGutterUtility(){return we(()=>!!e.onLineComment)()?He.renderGutterUtility:void 0},get selectedLines(){return de()},get commentedLines(){return te()},get media(){return{mode:"auto",path:F,deleted:j().status==="deleted",readFile:j().status==="deleted"?void 0:e.readFile}}})}})]}})}})),ce}})]}})}})}})),M}})),he(()=>xr(N,e.classes?.container)),N}}),null),he(N=>{var M=e.class,F=e.classList,j=e.classes?.header;return M!==N.e&&xr(V,N.e=M),N.t=ct(V,F,N.t),j!==N.a&&xr(P,N.a=j),N},{e:void 0,t:void 0,a:void 0}),V})()};dn(["mousedown","click"]);function frt(e){let t,n,r=!1,i;const s=kr(),o=li(),a=async f=>s().client.file.read({path:f}).then(m=>m.data).catch(m=>{console.debug("[session-review] failed to read file",{path:f,error:m})}),l=()=>{r=!0,n!==void 0&&(cancelAnimationFrame(n),n=void 0)},c=()=>{n=void 0;const f=t;if(!f||!o.ready()||r||f.clientHeight===0||f.clientWidth===0)return;const m=e.view().scroll("review");if(!m||m.x===0&&m.y===0)return;const g=Math.max(0,f.scrollHeight-f.clientHeight),p=Math.max(0,f.scrollWidth-f.clientWidth),y=Math.min(m.y,g),v=Math.min(m.x,p);f.scrollTop===y&&f.scrollLeft===v||(f.scrollTop!==y&&(f.scrollTop=y),f.scrollLeft!==v&&(f.scrollLeft=v),i={x:f.scrollLeft,y:f.scrollTop})},u=()=>{r||n!==void 0||(n=requestAnimationFrame(c))},d=f=>{const m=f.currentTarget,g=i;if(g&&m.scrollTop===g.y&&m.scrollLeft===g.x){i=void 0;return}i=void 0,l(),o.ready()&&(m.clientHeight===0||m.clientWidth===0||e.view().setScroll("review",{x:m.scrollLeft,y:m.scrollTop}))};return ae(()=>{e.diffs().length,e.diffStyle,o.ready()&&u()}),Te(()=>{n!==void 0&&cancelAnimationFrame(n),e.onScrollRef?.(void 0)}),h(drt,{get title(){return e.title},get empty(){return e.empty},scrollRef:f=>{t=f,an(f,"wheel",l,{passive:!0,capture:!0}),an(f,"mousewheel",l,{passive:!0,capture:!0}),an(f,"pointerdown",l,{passive:!0,capture:!0}),an(f,"touchstart",l,{passive:!0,capture:!0}),an(f,"keydown",l,{capture:!0}),e.onScrollRef?.(f),u()},onScroll:d,onDiffRendered:u,get open(){return e.view().review.open()},get onOpenChange(){return e.view().review.setOpen},get classes(){return{root:e.classes?.root??"pr-3",header:e.classes?.header??"px-3",container:e.classes?.container??"pl-3"}},get diffs(){return e.diffs()},get diffStyle(){return e.diffStyle},get onDiffStyleChange(){return e.onDiffStyleChange},get onViewFile(){return e.onViewFile},get focusedFile(){return e.focusedFile},readFile:a,get onLineComment(){return e.onLineComment},get onLineCommentUpdate(){return e.onLineCommentUpdate},get onLineCommentDelete(){return e.onLineCommentDelete},get lineCommentActions(){return e.lineCommentActions},get lineCommentMention(){return e.commentMentions},get comments(){return e.comments},get focusedComment(){return e.focusedComment},get onFocusedCommentChange(){return e.onFocusedCommentChange}})}const hrt=(e,t)=>{e.session.restore(t)},mrt=(e,t)=>{const n=e.model.current();if(!n)return;const r={providerID:n.provider.id,modelID:n.id,variant:e.model.variant.current()},i=t.model.current();i?.providerID===r.providerID&&i.modelID===r.modelID&&i.variant===r.variant||t.model.set(r)},grt=(e,t)=>{const n=t.model.current();if(!n)return!1;const r=e.model.current();return r?.provider.id===n.providerID&&r.id===n.modelID&&e.model.variant.current()===(n.variant??void 0)||(e.model.set({providerID:n.providerID,modelID:n.modelID}),e.model.variant.set(n.variant??void 0)),!0},bre=450,prt=480,vrt=800;function wre(e){const t=e.split?vrt:prt;return Math.max(bre,e.available-t)}function yrt(e){return e.available===void 0?e.width:Math.min(e.width,wre({available:e.available,split:e.split}))}var brt=A("<span>"),wrt=A('<span class="shrink-0 w-4 text-center text-12-medium">'),xrt=A('<div class="shrink-0 size-1.5 mr-1.5 rounded-full">'),krt=A("<div data-component=filetree>"),Srt=A('<div class="size-4 flex items-center justify-center text-icon-weak">'),Crt=A("<div>"),_rt=A('<div class="w-4 shrink-0">'),Trt=A('<span class="filetree-iconpair size-4">'),Ert=A('<div class="px-2 py-1 text-12-regular text-text-weak">...');const Irt=128;function xre(e){return`file://${Up(e)}`}function Drt(e){return!(e.level!==0||e.dir?.loaded||e.dir?.loading)}function Lrt(e){return e.level!==0?[]:e.filter?[...e.filter.dirs].filter(t=>!e.expanded(t)):[]}const Art=e=>e==="add"?"A":e==="del"?"D":"M",VC=e=>e==="add"?"color: var(--icon-diff-add-base)":e==="del"?"color: var(--icon-diff-delete-base)":"color: var(--icon-diff-modified-base)",Mrt=e=>e==="add"?"background-color: var(--icon-diff-add-base)":e==="del"?"background-color: var(--icon-diff-delete-base)":"background-color: var(--icon-diff-modified-base)",kre=(e,t,n)=>{const r=t?.get(e.path);if(r&&n?.has(e.path))return r},$rt=e=>{const t=e.querySelector('[data-component="file-icon"]')??e.querySelector("svg"),n=e.querySelector("span");if(!t||!n)return;const r=document.createElement("div");return r.className="flex items-center gap-x-2 px-2 py-1 bg-surface-raised-base rounded-md border border-border-base text-12-regular text-text-strong",r.style.position="absolute",r.style.top="-1000px",r.innerHTML=t.outerHTML+n.outerHTML,r},Sre=e=>{const t=$rt(e.currentTarget);t&&(document.body.appendChild(t),e.dataTransfer?.setDragImage(t,0,12),setTimeout(()=>document.body.removeChild(t),0))},LN=e=>{const[t,n]=Ee(e,["node","level","active","nodeClass","draggable","kinds","marks","as","children","class","classList"]),r=()=>kre(t.node,t.kinds,t.marks),i=()=>!!r()&&!t.node.ignored,s=()=>{const o=r();if(o)return VC(o)};return h(Gi,le({get component(){return t.as??"div"},get classList(){return{"w-full min-w-0 h-6 flex items-center justify-start gap-x-1.5 rounded-md px-1.5 py-0 text-left hover:bg-surface-raised-base-hover active:bg-surface-base-active transition-colors cursor-pointer":!0,"bg-surface-base-active":t.node.path===t.active,...t.classList,[t.class??""]:!!t.class,[t.nodeClass??""]:!!t.nodeClass}},get style(){return`padding-left: ${Math.max(0,8+t.level*12-(t.node.type==="file"?24:4))}px`},get draggable(){return t.draggable},onDragStart:o=>{t.draggable&&(o.dataTransfer?.setData("text/plain",`file:${t.node.path}`),o.dataTransfer?.setData("text/uri-list",xre(t.node.path)),o.dataTransfer&&(o.dataTransfer.effectAllowed="copy"),Sre(o))}},n,{get children(){return[we(()=>t.children),(()=>{var o=brt();return S(o,()=>t.node.name),he(a=>{var l={"flex-1 min-w-0 text-12-medium whitespace-nowrap truncate":!0,"text-text-weaker":t.node.ignored,"text-text-weak":!t.node.ignored&&!i()},c=i()?s():void 0;return a.e=ct(o,l,a.e),a.t=So(o,c,a.t),a},{e:void 0,t:void 0}),o})(),we(()=>(()=>{const o=r();return o?t.node.type==="file"?(()=>{var a=wrt();return S(a,()=>Art(o)),he(l=>So(a,VC(o),l)),a})():(()=>{var a=xrt();return he(l=>So(a,Mrt(o),l)),a})():null})())]}}))};function zC(e){const t=ua(),n=e.level??0,r=()=>e.draggable??!0,i=d=>t.normalize(d).replace(/[\\/]+$/,"").replaceAll("\\","/"),s=e._chain?[...e._chain,i(e.path)]:[i(e.path)],o=I(()=>{if(e._filter)return e._filter;const d=e.allowed;if(!d)return;const f=new Set(d),m=new Set;for(const g of d){const y=g.split("/").slice(0,-1);for(const[v]of y.entries()){const b=y.slice(0,v+1).join("/");b&&m.add(b)}}return{files:f,dirs:m}}),a=I(()=>{if(e._marks)return e._marks;const d=new Set;for(const f of e.modified??[])d.add(f);for(const f of e.kinds?.keys()??[])d.add(f);if(d.size!==0)return d}),l=I(()=>e._kinds?e._kinds:e.kinds),c=I(()=>{if(e._deeps)return e._deeps;const d=new Map,f=e.path;if(!(t.tree.state(f)?.expanded??!1))return d;const m=new Set,g=[],p=(y,v)=>{const b=i(y);if(m.has(b))return;m.add(b);const w=t.tree.children(y).filter(x=>x.type==="directory"&&(t.tree.state(x.path)?.expanded??!1)).map(x=>x.path);g.push({dir:y,lvl:v,i:0,kids:w,max:v})};for(p(f,n-1);g.length>0;){const y=g[g.length-1];if(y.i<y.kids.length){const b=y.kids[y.i];y.i++,p(b,y.lvl+1);continue}d.set(y.dir,y.max),g.pop();const v=g[g.length-1];v&&(v.max=Math.max(v.max,y.max))}return d});ae(()=>{const d=o(),f=Lrt({level:n,filter:d,expanded:m=>Wt(()=>t.tree.state(m)?.expanded)??!1});for(const m of f)t.tree.expand(m)}),ae(vt(()=>e.path,d=>{const f=Wt(()=>t.tree.state(d));Drt({level:n,dir:f})&&t.tree.list(d)},{defer:!1}));const u=I(()=>{const d=t.tree.children(e.path),f=o();if(!f)return d;const m=v=>{const b=v.lastIndexOf("/");return b===-1?"":v.slice(0,b)},g=v=>{const b=v.lastIndexOf("/");return b===-1?v:v.slice(b+1)},p=d.filter(v=>v.type==="file"?f.files.has(v.path):f.dirs.has(v.path)),y=new Set(p.map(v=>v.path));for(const v of f.dirs)m(v)===e.path&&(y.has(v)||(p.push({name:g(v),path:v,absolute:v,type:"directory",ignored:!1}),y.add(v)));for(const v of f.files)m(v)===e.path&&(y.has(v)||(p.push({name:g(v),path:v,absolute:v,type:"file",ignored:!1}),y.add(v)));return p.sort((v,b)=>v.type!==b.type?v.type==="directory"?-1:1:v.name.localeCompare(b.name)),p});return(()=>{var d=krt();return S(d,h(Dt,{get each(){return u()},children:f=>{const m=()=>t.tree.state(f.path)?.expanded??!1,g=()=>c().get(f.path)??-1,p=()=>kre(f,l(),a()),y=()=>!!p()&&!f.ignored;return h(Rr,{get children(){return[h(zt,{get when(){return f.type==="directory"},get children(){return h(Wi,{variant:"ghost",class:"w-full","data-scope":"filetree",forceMount:!1,get open(){return m()},onOpenChange:v=>v?t.tree.expand(f.path):t.tree.collapse(f.path),get children(){return[h(Wi.Trigger,{get children(){return h(LN,{node:f,level:n,get active(){return e.active},get nodeClass(){return e.nodeClass},get draggable(){return r()},get kinds(){return l()},get marks(){return a()},get children(){var v=Srt();return S(v,h(Yt,{get name(){return m()?"chevron-down":"chevron-right"},size:"small"})),v}})}}),h(Wi.Content,{class:"relative pt-0.5",get children(){return[(()=>{var v=Crt();return he(b=>{var w={"absolute top-0 bottom-0 w-px pointer-events-none bg-border-weak-base opacity-0 transition-opacity duration-150 ease-out motion-reduce:transition-none":!0,"group-hover/filetree:opacity-100":m()&&g()===n,"group-hover/filetree:opacity-50":!(m()&&g()===n)},x=`left: ${Math.max(0,8+n*12-4)+8}px`;return b.e=ct(v,w,b.e),b.t=So(v,x,b.t),b},{e:void 0,t:void 0}),v})(),h(q,{get when(){return n<Irt&&!s.includes(i(f.path))},get fallback(){return Ert()},get children(){return h(zC,{get path(){return f.path},level:n+1,get allowed(){return e.allowed},get modified(){return e.modified},get kinds(){return e.kinds},get active(){return e.active},get draggable(){return e.draggable},get onFileClick(){return e.onFileClick},get onFileDoubleClick(){return e.onFileDoubleClick},get _filter(){return o()},get _marks(){return a()},get _deeps(){return c()},get _kinds(){return l()},_chain:s})}})]}})]}})}}),h(zt,{get when(){return f.type==="file"},get children(){return h(LN,{node:f,level:n,get active(){return e.active},get nodeClass(){return e.nodeClass},get draggable(){return r()},get kinds(){return l()},get marks(){return a()},as:"button",type:"button",onClick:()=>e.onFileClick?.(f),onDblClick:()=>e.onFileDoubleClick?.(f),get children(){return[_rt(),h(Rr,{get children(){return[h(zt,{get when(){return f.ignored},get children(){return h(Dr,{node:f,class:"size-4 filetree-icon filetree-icon--mono",style:"color: var(--icon-weak-base)",mono:!0})}}),h(zt,{get when(){return y()},get children(){return h(Dr,{node:f,class:"size-4 filetree-icon filetree-icon--mono",get style(){return VC(p())},mono:!0})}}),h(zt,{get when(){return!f.ignored},get children(){var v=Trt();return S(v,h(Dr,{node:f,class:"size-4 filetree-icon filetree-icon--color opacity-0 group-hover/filetree:opacity-100"}),null),S(v,h(Dr,{node:f,class:"size-4 filetree-icon filetree-icon--mono group-hover/filetree:opacity-0",mono:!0}),null),v}})]}})]}})}})]}})}})),he(()=>xr(d,`flex flex-col gap-0.5 ${e.class??""}`)),d})()}function l0(e){return e.replaceAll("\\","/").replace(/^\/+|\/+$/g,"").replace(/\/{2,}/g,"/")}function Prt(e){const t=new Map;e.forEach(r=>{const i=l0(r);if(!i)return;const s=i.split("/");s.forEach((o,a)=>{const l=s.slice(0,a+1).join("/");t.has(l)||t.set(l,{name:o,path:l,absolute:l,type:a===s.length-1?"file":"directory",ignored:!1,originalPath:a===s.length-1?r:l})})});const n=new Map;return t.forEach(r=>{const i=r.path.lastIndexOf("/"),s=i===-1?"":r.path.slice(0,i),o=n.get(s);o?o.push(r):n.set(s,[r])}),n.forEach(r=>r.sort((i,s)=>i.type!==s.type?i.type==="directory"?-1:1:i.name.localeCompare(s.name))),{children:n,total:t.size}}function Ort(e,t){const n=[],r=(e.children.get("")??[]).toReversed().map(i=>({node:i,level:0}));for(;r.length>0;){const i=r.pop();if(n.push(i),i.node.type!=="directory"||!t(i.node.path))continue;const s=e.children.get(i.node.path)??[];for(let o=s.length-1;o>=0;o--)r.push({node:s[o],level:i.level+1})}return n}function Rrt(e,t){const n=[],r=e("").toReversed().map(i=>({node:AN(i),level:0}));for(;r.length>0;){const i=r.pop();if(n.push(i),i.node.type!=="directory"||!t(i.node.path))continue;const s=e(i.node.originalPath);for(let o=s.length-1;o>=0;o--)r.push({node:AN(s[o]),level:i.level+1})}return n}function AN(e){return{...e,path:l0(e.path),originalPath:e.path}}var Frt=A("<div data-component=split-button-v2>"),Nrt=A("<button type=button data-component=split-button-v2-action>"),Vrt=A("<button type=button data-component=split-button-v2-menu-trigger>");function zrt(e){const[t,n]=Ee(e,["class","classList","children"]);return(()=>{var r=Frt();return An(r,le({get classList(){return{...t.classList,[t.class??""]:!!t.class}}},n),!1,!0),S(r,()=>t.children),r})()}function Hrt(e){const[t,n]=Ee(e,["class","classList"]);return(()=>{var r=Nrt();return An(r,le({get classList(){return{...t.classList,[t.class??""]:!!t.class}}},n),!1,!1),r})()}function jrt(e){const[t,n]=Ee(e,["class","classList"]);return(()=>{var r=Vrt();return An(r,le({get classList(){return{...t.classList,[t.class??""]:!!t.class}}},n),!1,!1),r})()}const qrt=[{id:"vscode",label:"session.header.open.app.vscode",icon:"vscode",openWith:"Visual Studio Code"},{id:"cursor",label:"session.header.open.app.cursor",icon:"cursor",openWith:"Cursor"},{id:"zed",label:"session.header.open.app.zed",icon:"zed",openWith:"Zed"},{id:"textmate",label:"session.header.open.app.textmate",icon:"textmate",openWith:"TextMate"},{id:"antigravity",label:"session.header.open.app.antigravity",icon:"antigravity",openWith:"Antigravity"},{id:"terminal",label:"session.header.open.app.terminal",icon:"terminal",openWith:"Terminal"},{id:"iterm2",label:"session.header.open.app.iterm2",icon:"iterm2",openWith:"iTerm"},{id:"ghostty",label:"session.header.open.app.ghostty",icon:"ghostty",openWith:"Ghostty"},{id:"warp",label:"session.header.open.app.warp",icon:"warp",openWith:"Warp"},{id:"xcode",label:"session.header.open.app.xcode",icon:"xcode",openWith:"Xcode"},{id:"android-studio",label:"session.header.open.app.androidStudio",icon:"android-studio",openWith:"Android Studio"},{id:"sublime-text",label:"session.header.open.app.sublimeText",icon:"sublime-text",openWith:"Sublime Text"}],Brt=[{id:"vscode",label:"session.header.open.app.vscode",icon:"vscode",openWith:"code"},{id:"cursor",label:"session.header.open.app.cursor",icon:"cursor",openWith:"cursor"},{id:"zed",label:"session.header.open.app.zed",icon:"zed",openWith:"zed"},{id:"powershell",label:"session.header.open.app.powershell",icon:"powershell",openWith:"powershell"},{id:"sublime-text",label:"session.header.open.app.sublimeText",icon:"sublime-text",openWith:"Sublime Text"}],Urt=[{id:"vscode",label:"session.header.open.app.vscode",icon:"vscode",openWith:"code"},{id:"cursor",label:"session.header.open.app.cursor",icon:"cursor",openWith:"cursor"},{id:"zed",label:"session.header.open.app.zed",icon:"zed",openWith:"zed"},{id:"sublime-text",label:"session.header.open.app.sublimeText",icon:"sublime-text",openWith:"Sublime Text"}];function Wrt(e){if(e.platform==="desktop"&&e.os)return e.os;if(typeof navigator!="object")return"unknown";const t=navigator.platform||navigator.userAgent;return/Mac/i.test(t)?"macos":/Win/i.test(t)?"windows":/Linux/i.test(t)?"linux":"unknown"}function Krt(e){return e==="macos"?{label:"session.header.open.finder",icon:"finder"}:e==="windows"?{label:"session.header.open.fileExplorer",icon:"file-explorer"}:{label:"session.header.open.fileManager",icon:"finder"}}function Grt(e){return e==="macos"?qrt:e==="windows"?Brt:Urt}const MN=(e,t)=>{tn({variant:"error",title:e.t("common.requestFailed"),description:t instanceof Error?t.message:String(t)})};function Zrt(e){const t=Tr(),n=ci(),r=wt(),i=I(()=>Wrt(t)),s=I(()=>Grt(i())),o=I(()=>Krt(i())),[a,l]=Ze({finder:!0});ae(()=>{if(t.platform!=="desktop"||!t.checkAppExists)return;const C=s();l(Object.fromEntries(C.map(E=>[E.id,void 0]))),Promise.all(C.map(E=>Promise.resolve(t.checkAppExists?.(E.openWith)).then(_=>!!_).catch(()=>!1).then(_=>[E.id,_]))).then(E=>{l(Object.fromEntries(E))})});const c=I(()=>[{id:"finder",label:r.t(o().label),icon:o().icon},...s().filter(C=>a[C.id]).map(C=>({...C,label:r.t(C.label)}))]),[u,d]=_r(Jn.global("open.app"),Ze({app:"finder"})),[f,m]=Ze({open:!1}),[g,p]=Ze({app:void 0}),y=I(()=>t.platform==="desktop"&&!!t.openPath&&n.isLocal()),v=I(()=>c().find(C=>C.id===u.app)??c()[0]??{id:"finder",label:o().label,icon:o().icon}),b=I(()=>g.app!==void 0);return{canOpen:y,opening:b,current:v,options:c,menu:f,setMenu:m,openDir:C=>{if(b()||!y()||!t.openPath)return;const E=e.directory();if(!E)return;const _=c().find(O=>O.id===C),L=_&&"openWith"in _?_.openWith:void 0;p("app",C),t.openPath(E,L).catch(O=>MN(r,O)).finally(()=>{p("app",void 0)})},selectApp:C=>{c().some(E=>E.id===C)&&d("app",C)},copyPath:()=>{const C=e.directory();C&&navigator.clipboard.writeText(C).then(()=>{tn({variant:"success",icon:"circle-check",title:r.t("session.share.copy.copied"),description:C})}).catch(E=>MN(r,E))}}}function Yrt(e){const t=wt(),n=Zrt(e);return h(q,{get when(){return we(()=>!!e.directory())()&&n.canOpen()},get children(){return h(zrt,{class:"session-review-v2-open-in-app",onPointerDown:r=>r.stopPropagation(),get children(){return[h(Qn,{placement:"bottom",get value(){return t.t("session.header.open.ariaLabel",{app:n.current().label})},class:"flex items-center",get children(){return h(Hrt,{onPointerDown:r=>r.stopPropagation(),onClick:r=>{r.stopPropagation(),!n.opening()&&n.openDir(n.current().id)},get disabled(){return n.opening()},get"aria-label"(){return t.t("session.header.open.ariaLabel",{app:n.current().label})},get children(){return h(q,{get when(){return n.opening()},get fallback(){return h(Ix,{get id(){return n.current().icon},class:"size-[18px]"})},get children(){return h(Fd,{class:"size-3.5"})}})}})}}),h(Tt,{gutter:4,modal:!1,placement:"bottom-end",get open(){return n.menu.open},onOpenChange:r=>n.setMenu("open",r),get children(){return[h(Tt.Trigger,{as:jrt,get disabled(){return n.opening()},get"aria-label"(){return t.t("session.header.open.menu")},onPointerDown:r=>r.stopPropagation(),get children(){return h(on,{name:"chevron-down",size:"small"})}}),h(Tt.Portal,{get children(){return h(Tt.Content,{class:"open-in-app-v2-menu",get children(){return[h(Tt.Group,{get children(){return[h(Tt.GroupLabel,{get children(){return t.t("session.header.openIn")}}),h(Tt.RadioGroup,{get value(){return n.current().id},onChange:r=>{n.selectApp(r)},get children(){return h(Dt,{get each(){return n.options()},children:r=>h(Tt.RadioItem,{get value(){return r.id},get disabled(){return n.opening()},onSelect:()=>{n.selectApp(r.id),n.setMenu("open",!1),n.openDir(r.id)},get children(){return[h(Ix,{get id(){return r.icon}}),we(()=>r.label)]}})})}})]}}),h(Tt.Separator,{}),h(Tt.Item,{onSelect:()=>{n.setMenu("open",!1),n.copyPath()},get children(){return[h(Yt,{name:"copy",size:"small",class:"text-icon-weak"}),we(()=>t.t("session.header.open.copyPath"))]}})]}})}})]}})]}})}})}const Xrt=e=>{if(!(e.scrollWidth<=e.prevScrollWidth)){if(!e.prevContextOpen&&e.contextOpen)return 0;if(!(e.scrollWidth<=e.clientWidth))return e.scrollWidth-e.clientWidth}},$N=e=>{let t,n=e.el.scrollWidth,r=e.contextOpen();const i=()=>{const l=e.el.scrollWidth,c=e.el.clientWidth,u=e.contextOpen(),d=Xrt({prevScrollWidth:n,scrollWidth:l,clientWidth:c,prevContextOpen:r,contextOpen:u});d!==void 0&&e.el.scrollTo({left:d,behavior:"smooth"}),n=l,r=u},s=()=>{t!==void 0&&cancelAnimationFrame(t),t=requestAnimationFrame(()=>{t=void 0,i()})},o=l=>{Math.abs(l.deltaY)<=Math.abs(l.deltaX)||(e.el.scrollLeft+=l.deltaY>0?50:-50,l.preventDefault())};e.el.addEventListener("wheel",o,{passive:!1});const a=new MutationObserver(s);return a.observe(e.el,{childList:!0}),()=>{e.el.removeEventListener("wheel",o),a.disconnect(),t!==void 0&&cancelAnimationFrame(t)}};var Qrt=A('<svg><path d="M2.5 7.5H3.5V8.5H2.5V7.5Z"stroke=currentColor></path><path d="M7.5 7.5H8.5V8.5H7.5V7.5Z"stroke=currentColor></path><path d="M12.5 7.5H13.5V8.5H12.5V7.5Z"stroke=currentColor>'),Jrt=A("<div><div data-slot=line-comment-v2-shell><div data-slot=line-comment-v2-column><div data-slot=line-comment-v2-text></div><div data-slot=line-comment-v2-meta>"),eit=A("<div data-slot=line-comment-v2-tools>"),tit=A("<div data-slot=line-comment-v2-mention-list>"),nit=A("<div><div data-slot=line-comment-v2-shell><div data-slot=line-comment-v2-field><div data-slot=line-comment-v2-label></div><textarea data-slot=line-comment-v2-textarea></textarea></div><div data-slot=line-comment-v2-footer><div data-slot=line-comment-v2-footer-meta></div><div data-slot=line-comment-v2-footer-actions>"),rit=A("<span data-slot=line-comment-v2-mention-file>"),iit=A("<button type=button data-slot=line-comment-v2-mention-item><div data-slot=line-comment-v2-mention-path><span data-slot=line-comment-v2-mention-dir>");function Cre(e){return(()=>{var t=Qrt();return An(t,le(e,{get width(){return e.width??16},get height(){return e.height??16},viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",get"aria-hidden"(){return e["aria-hidden"]??"true"}}),!0,!0),t})()}function sit(e){const[t,n]=Ee(e,["comment","selection","actions","class","classList"]);return(()=>{var r=Jrt(),i=r.firstChild,s=i.firstChild,o=s.firstChild,a=o.nextSibling;return An(r,le(n,{"data-component":"line-comment-v2","data-variant":"display",get classList(){return{...t.classList,[t.class??""]:!!t.class}}}),!1,!0),S(o,()=>t.comment),S(a,()=>t.selection),S(i,h(q,{get when(){return t.actions},children:l=>(()=>{var c=eit();return S(c,l),c})()}),null),r})()}function oit(e){const t=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\"));return t===-1?e:e.slice(t+1)}function ait(e){const t=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\"));return t===-1?"":e.slice(0,t+1)}function _re(e){let t;const[n,r]=De(!1),[i,s]=Ee(e,["heading","value","onInput","onCancel","onSubmit","selection","placeholder","rows","cancelLabel","submitLabel","autofocus","mention","class","classList"]),o=()=>i.heading??"Comment",a=()=>i.value.trim().length>0,l=()=>{r(!1),d.clear()},c=()=>{const p=t;if(!p||!i.mention||p.selectionStart!==p.selectionEnd)return;const y=p.selectionStart,v=p.value.slice(0,y).match(/@(\S*)$/);if(v)return{query:v[1]??"",start:y-v[0].length,end:y}};function u(p){if(!p)return;const y=t,v=c();if(!y||!v)return;const b=`${y.value.slice(0,v.start)}@${p.path} ${y.value.slice(v.end)}`,w=v.start+p.path.length+2;i.onInput(b),l(),requestAnimationFrame(()=>{y.focus(),y.setSelectionRange(w,w)})}const d=th({items:async p=>i.mention?p.trim()?(await i.mention.items(p)).map(v=>({path:v})):[]:[],key:p=>p.path,filterKeys:["path"],skipFilter:()=>!0,onSelect:u}),f=()=>{const p=c();if(!p){l();return}r(!0),d.onInput(p.query)},m=()=>{const p=d.flat();if(p.length===0)return;const y=d.active();u(p.find(v=>v.path===y)??p[0])},g=()=>{const p=i.value.trim();p&&i.onSubmit(p)};return sn(()=>{i.autofocus!==!1&&requestAnimationFrame(()=>t?.focus())}),(()=>{var p=nit(),y=p.firstChild,v=y.firstChild,b=v.firstChild,w=b.nextSibling,x=v.nextSibling,k=x.firstChild,C=k.nextSibling;return An(p,le(s,{"data-component":"line-comment-v2","data-variant":"editor",get classList(){return{...i.classList,[i.class??""]:!!i.class}}}),!1,!0),S(b,o),w.$$keydown=E=>{if(E.stopPropagation(),!(E.isComposing||E.keyCode===229)){if(n()){if(E.key==="Escape"){E.preventDefault(),l();return}if(E.key==="Tab"){if(d.flat().length===0)return;E.preventDefault(),m();return}const _=E.key==="ArrowUp"||E.key==="ArrowDown"||E.key==="Enter",L=E.ctrlKey&&!E.metaKey&&!E.altKey&&!E.shiftKey&&(E.key==="n"||E.key==="p");if((_||L)&&d.flat().length>0){d.onKeyDown(E),E.preventDefault();return}}if(E.key==="Escape"){E.preventDefault(),E.currentTarget.blur(),i.onCancel();return}E.key==="Enter"&&!E.shiftKey&&(E.preventDefault(),g())}},w.addEventListener("select",()=>f()),w.$$click=()=>f(),w.$$input=E=>{i.onInput(E.currentTarget.value),f()},pt(E=>{t=E},w),S(v,h(q,{get when(){return we(()=>!!n())()&&d.flat().length>0},get children(){var E=tit();return S(E,h(Dt,{get each(){return d.flat().slice(0,10)},children:_=>{const L=_.path.endsWith("/")?_.path:ait(_.path),O=_.path.endsWith("/")?"":oit(_.path);return(()=>{var $=iit(),V=$.firstChild,P=V.firstChild;return $.$$click=()=>u(_),$.addEventListener("mouseenter",()=>d.setActive(_.path)),$.$$mousedown=T=>T.preventDefault(),S($,h(Dr,{get node(){return{path:_.path,type:"file"}},class:"shrink-0 size-4"}),V),S(P,L),S(V,h(q,{when:O,get children(){var T=rit();return S(T,O),T}}),null),he(()=>me($,"data-active",d.active()===_.path?"":void 0)),$})()}})),E}}),null),S(k,()=>i.selection),S(C,h(as,{type:"button",size:"normal",variant:"neutral",onClick:()=>i.onCancel(),get children(){return i.cancelLabel??"Cancel"}}),null),S(C,h(as,{type:"button",size:"normal",variant:"contrast",get disabled(){return!a()},onClick:g,get children(){return i.submitLabel??"Comment"}}),null),he(E=>{var _=i.rows??3,L=i.placeholder??"Add context for this change";return _!==E.e&&me(w,"rows",E.e=_),L!==E.t&&me(w,"placeholder",E.t=L),E},{e:void 0,t:void 0}),he(()=>w.value=i.value),p})()}dn(["input","click","keydown","mousedown"]);var HC=A("<div data-prevent-autofocus>");function lit(e){return h(q,{get when(){return e().editor},get fallback(){return(()=>{var t=HC();return cn(t,"mouseenter",e().onMouseEnter),cn(t,"click",e().onClick,!0),t.$$mousedown=n=>n.stopPropagation(),S(t,h(sit,{get comment(){return e().comment},get selection(){return e().selection},get actions(){return e().actions}})),he(()=>me(t,"data-comment-id",e().id)),t})()},get children(){var t=HC();return t.$$mousedown=n=>n.stopPropagation(),S(t,h(_re,{get value(){return e().editor.value},get selection(){return e().editor.selection},get onInput(){return e().editor.onInput},get onCancel(){return e().editor.onCancel},get onSubmit(){return e().editor.onSubmit},get cancelLabel(){return e().editor.cancelLabel},get submitLabel(){return e().editor.submitLabel},get mention(){return e().editor.mention}})),he(()=>me(t,"data-comment-id",e().id)),t}})}function cit(e){return(()=>{var t=HC();return t.$$mousedown=n=>n.stopPropagation(),S(t,h(_re,{get value(){return e().value},get selection(){return e().selection},get onInput(){return e().onInput},get onCancel(){return e().onCancel},get onSubmit(){return e().onSubmit},get cancelLabel(){return e().cancelLabel},get submitLabel(){return e().submitLabel},get mention(){return e().mention}})),t})()}function Tre(e){const t=Mn(),n=gre(e.state),r=NC({comments:e.comments,getCommentId:c=>c.id,getCommentSelection:c=>c.selection,draftRange:n.commenting,draftKey:e.draftKey,getSide:e.getSide}),{renderAnnotation:i}=vre({annotations:r,commentElement:lit,draftElement:cit,renderComment:c=>{const u=()=>n.openEditor(c.id,c.selection,c.comment),d=()=>{n.reset(),e.onDelete?.(c)};return{id:c.id,comment:c.comment,selection:Pm(c.selection,t.t),get actions(){return e.renderCommentActions?.(c,{edit:u,remove:d})},get editor(){return n.isEditing(c.id)?{get value(){return n.draft()},selection:Pm(c.selection,t.t),onInput:n.setDraft,onCancel:n.cancelDraft,onSubmit:f=>{e.onUpdate?.({id:c.id,comment:f,selection:tc(c.selection)}),n.cancelDraft()},cancelLabel:t.t("ui.lineComment.cancel"),submitLabel:e.editSubmitLabel,mention:e.mention}:void 0},onMouseEnter:()=>n.hoverComment(c.selection),onClick:()=>{n.isEditing(c.id)||n.toggleComment(c.id,c.selection)}}},renderDraft:c=>({get value(){return n.draft()},selection:Pm(c,t.t),onInput:n.setDraft,onCancel:n.cancelDraft,onSubmit:u=>{e.onSubmit({comment:u,selection:tc(c)}),n.cancelDraft()},cancelLabel:t.t("ui.lineComment.cancel"),submitLabel:t.t("ui.lineComment.submit"),mention:e.mention})}),s=yre({label:e.label,getSelectedRange:()=>n.opened()?null:n.selected(),onOpenDraft:n.openDraft});return{note:n,annotations:r,renderAnnotation:i,renderGutterUtility:s,onLineSelected:c=>{if(!c){n.select(null),n.cancelDraft();return}n.select(c)},onLineSelectionEnd:c=>{if(!c){n.cancelDraft();return}n.openDraft(c)},onLineNumberSelectionEnd:c=>{c&&n.openDraft(c)}}}dn(["mousedown","click"]);var Ere=A("<div>"),Ire=A('<div class="relative overflow-hidden pb-40">'),Dre=A('<div class="px-6 py-4 text-text-weak">...'),Lre=A('<div class="mt-3 relative h-full min-h-0">'),Are=A('<div class="px-6 py-4 text-text-weak">');const uit=e=>e.endSide??e.side??"additions";function dit(e){return(()=>{var t=Ere();return t.$$click=n=>n.stopPropagation(),t.$$mousedown=n=>n.stopPropagation(),S(t,h(at,{gutter:4,placement:"bottom-end",get children(){return[h(at.Trigger,{as:Ln,icon:"dot-grid",variant:"ghost",size:"small",class:"size-6 rounded-md",get"aria-label"(){return e.moreLabel}}),h(at.Portal,{get children(){return h(at.Content,{get children(){return[h(at.Item,{get onSelect(){return e.onEdit},get children(){return h(at.ItemLabel,{get children(){return e.editLabel}})}}),h(at.Item,{get onSelect(){return e.onDelete},get children(){return h(at.ItemLabel,{get children(){return e.deleteLabel}})}})]}})}})]}})),t})()}function fit(e){return(()=>{var t=Ere();return t.$$click=n=>n.stopPropagation(),t.$$mousedown=n=>n.stopPropagation(),S(t,h(Tt,{gutter:4,get children(){return[h(Tt.Trigger,{as:"button",type:"button","data-slot":"line-comment-v2-overflow",get"aria-label"(){return e.moreLabel},get children(){return h(Cre,{})}}),h(Tt.Portal,{get children(){return h(Tt.Content,{get children(){return[h(Tt.Item,{get onSelect(){return e.onEdit},get children(){return e.editLabel}}),h(Tt.Item,{get onSelect(){return e.onDelete},get children(){return e.deleteLabel}})]}})}})]}})),t})()}function Mre(e){let t,n,r,i;const[s,o]=De([]),a=()=>{const p=t;if(!p)return[];const y=p.querySelector("diffs-container");if(!(y instanceof HTMLElement))return[];const v=y.shadowRoot;return v?Array.from(v.querySelectorAll("[data-code]")).filter(b=>b instanceof HTMLElement&&b.clientWidth>0):[]},l=p=>{i=p,n===void 0&&(n=requestAnimationFrame(()=>{n=void 0;const y=i;i=void 0,y&&e.view().setScroll(e.tab(),y)}))},c=p=>{const y=t;if(!y)return;const v=p.currentTarget;v instanceof HTMLElement&&l({x:v.scrollLeft,y:y.scrollTop})},u=()=>{const p=a(),y=s();p.length===y.length&&p.every((v,b)=>v===y[b])||o(p)},d=()=>{const p=t;if(!p)return;const y=e.view().scroll(e.tab());if(y){if(u(),s().length>0)for(const v of s())v.scrollLeft!==y.x&&(v.scrollLeft=y.x);p.scrollTop!==y.y&&(p.scrollTop=y.y),!(s().length>0)&&p.scrollLeft!==y.x&&(p.scrollLeft=y.x)}},f=()=>{r===void 0&&(r=requestAnimationFrame(()=>{r=void 0,d()}))},m=p=>{s().length===0&&u(),l({x:s()[0]?.scrollLeft??p.currentTarget.scrollLeft,y:p.currentTarget.scrollTop})};ae(()=>{for(const p of s())an(p,"scroll",c)});const g=p=>{t=p,d()};return Te(()=>{n!==void 0&&cancelAnimationFrame(n),r!==void 0&&cancelAnimationFrame(r)}),{handleScroll:m,queueRestore:f,setViewport:g}}function hit(e){return h(rr.Content,{get value(){return e.tab},get children(){return h($re,{get tab(){return e.tab}})}})}function $re(e){const t=ar();return h(q,{get when(){return t.general.newLayoutDesigns()},get fallback(){return h(mit,{get tab(){return e.tab}})},get children(){return h(git,{get tab(){return e.tab}})}})}function mit(e){const t=ua(),n=q1(),r=wt(),i=Hg(),s=_d(),{sessionKey:o,tabs:a,view:l}=ga(),c=Nd({tabs:a,pathFromTab:t.pathFromTab,normalizeTab:M=>M.startsWith("file://")?t.tab(M):M}).activeFileTab;let u=null;const d={register:M=>{u=M}},f=I(()=>t.pathFromTab(e.tab)),m=I(()=>{const M=f();if(M)return t.get(M)}),g=I(()=>m()?.content?.content??""),p=I(()=>Ew(g())),y=I(()=>{const M=f();return M?t.ready()?t.selectedLines(M)??null:OT(o())?.files[M]??null:null}),v=Mre({tab:()=>e.tab,view:l}),b=(M,F)=>Ag(M,{start:F.startLine,end:F.endLine}),w=(M,F)=>{const j=M===f()?g():t.get(M)?.content?.content;if(j)return b(j,F)},x=M=>{const F=md(M.selection),j=M.preview??w(M.file,F),z=n.add({file:M.file,selection:M.selection,comment:M.comment});i.context.add({type:"file",path:M.file,selection:F,comment:M.comment,commentID:z.id,commentOrigin:M.origin,preview:j})},k=M=>{n.update(M.file,M.id,M.comment);const F=M.file===f()?w(M.file,md(M.selection)):void 0;i.context.updateComment(M.file,M.id,{comment:M.comment,...F?{preview:F}:{}})},C=M=>{n.remove(M.file,M.id),i.context.removeComment(M.file,M.id)},E=I(()=>{const M=f();return M?n.list(M):[]}),_=I(()=>E().map(M=>M.selection)),[L,O]=Ze({openedComment:null,commenting:null,selected:null}),$=M=>{const F=f();F&&t.setSelectedLines(F,M?tc(M):null)},V=()=>L.selected??y(),P=pre({comments:E,label:r.t("ui.lineComment.submit"),draftKey:()=>f()??e.tab,mention:{items:t.searchFilesAndDirectories},state:{opened:()=>L.openedComment,setOpened:M=>O("openedComment",M),selected:()=>L.selected,setSelected:M=>O("selected",M),commenting:()=>L.commenting,setCommenting:M=>O("commenting",M),syncSelected:$,hoverSelected:$},getHoverSelectedRange:V,cancelDraftOnCommentToggle:!0,clearSelectionOnSelectionEndNull:!0,onSubmit:({comment:M,selection:F})=>{const j=f();j&&x({file:j,selection:F,comment:M,origin:"file"})},onUpdate:({id:M,comment:F,selection:j})=>{const z=f();z&&k({id:M,file:z,selection:j,comment:F})},onDelete:M=>{const F=f();F&&C({id:M.id,file:F})},editSubmitLabel:r.t("common.save"),renderCommentActions:(M,F)=>h(dit,{get moreLabel(){return r.t("common.moreOptions")},get editLabel(){return r.t("common.edit")},get deleteLabel(){return r.t("common.delete")},get onEdit(){return F.edit},get onDelete(){return F.remove}})});ae(()=>{if(typeof window>"u")return;an(window,"keydown",F=>{c()===e.tab&&(!(F.metaKey||F.ctrlKey)||F.altKey||F.shiftKey||F.key.toLowerCase()==="f"&&(F.preventDefault(),F.stopPropagation(),u?.focus()))},{capture:!0})}),ae(vt(f,()=>{P.note.reset()},{defer:!0})),ae(()=>{const M=n.focus(),F=f();if(!M||!F||M.file!==F||c()!==e.tab)return;const j=E().find(z=>z.id===M.id);j&&(P.note.openComment(j.id,j.selection,{cancelDraft:!0}),requestAnimationFrame(()=>n.clearFocus()))});let T={loaded:!1,ready:!1,active:!1};ae(()=>{const M=!!m()?.loaded,F=t.ready(),j=c()===e.tab,z=M&&!T.loaded||F&&!T.ready||j&&M&&!T.active;T={loaded:M,ready:F,active:j},z&&v.queueRestore()});const D=M=>(()=>{var F=Ire();return S(F,h(Gi,{component:s,mode:"text",get file(){return{name:f()??"",contents:M,cacheKey:p()}},enableLineSelection:!0,enableGutterUtility:!0,get selectedLines(){return V()},get commentedLines(){return _()},onRendered:()=>{v.queueRestore()},get annotations(){return P.annotations()},get renderAnnotation(){return P.renderAnnotation},get renderGutterUtility(){return P.renderGutterUtility},onLineSelected:j=>{P.onLineSelected(j)},onLineSelectionEnd:j=>{P.onLineSelectionEnd(j)},search:d,class:"select-text",get media(){return{mode:"auto",path:f(),current:m()?.content,onLoad:v.queueRestore,onError:j=>{j.kind==="svg"&&tn({variant:"error",title:r.t("toast.file.loadFailed.title")})}}}})),F})();return(()=>{var M=Lre();return S(M,h(yc,{class:"h-full",get viewportRef(){return v.setViewport},get onScroll(){return v.handleScroll},get children(){return h(Rr,{get children(){return[h(zt,{get when(){return m()?.loaded},get children(){return D(g())}}),h(zt,{get when(){return m()?.loading},get children(){var F=Dre(),j=F.firstChild;return S(F,()=>r.t("common.loading"),j),F}}),h(zt,{get when(){return m()?.error},children:F=>(()=>{var j=Are();return S(j,F),j})()})]}})}})),M})()}function git(e){const t=ua(),n=q1(),r=wt(),i=Hg(),s=_d(),{sessionKey:o,tabs:a,view:l}=ga(),c=Nd({tabs:a,pathFromTab:t.pathFromTab,normalizeTab:M=>M.startsWith("file://")?t.tab(M):M}).activeFileTab;let u=null;const d={register:M=>{u=M}},f=I(()=>t.pathFromTab(e.tab)),m=I(()=>{const M=f();if(M)return t.get(M)}),g=I(()=>m()?.content?.content??""),p=I(()=>Ew(g())),y=I(()=>{const M=f();return M?t.ready()?t.selectedLines(M)??null:OT(o())?.files[M]??null:null}),v=Mre({tab:()=>e.tab,view:l}),b=(M,F)=>Ag(M,{start:F.startLine,end:F.endLine}),w=(M,F)=>{const j=M===f()?g():t.get(M)?.content?.content;if(j)return b(j,md(F))},x=M=>{const F=md(M.selection),j=M.preview??w(M.file,M.selection),z=n.add({file:M.file,selection:M.selection,comment:M.comment});i.context.add({type:"file",path:M.file,selection:F,comment:M.comment,commentID:z.id,commentOrigin:M.origin,preview:j})},k=M=>{n.update(M.file,M.id,M.comment);const F=M.file===f()?w(M.file,M.selection):void 0;i.context.updateComment(M.file,M.id,{comment:M.comment,...F?{preview:F}:{}})},C=M=>{n.remove(M.file,M.id),i.context.removeComment(M.file,M.id)},E=I(()=>{const M=f();return M?n.list(M):[]}),_=I(()=>E().map(M=>M.selection)),[L,O]=Ze({openedComment:null,commenting:null,selected:null}),$=M=>{const F=f();F&&t.setSelectedLines(F,M?tc(M):null)},V=()=>L.selected??y(),P=Tre({comments:E,label:r.t("ui.lineComment.submit"),draftKey:()=>f()??e.tab,mention:{items:t.searchFilesAndDirectories},getSide:uit,state:{opened:()=>L.openedComment,setOpened:M=>O("openedComment",M),selected:()=>L.selected,setSelected:M=>O("selected",M),commenting:()=>L.commenting,setCommenting:M=>O("commenting",M),syncSelected:$,hoverSelected:$},onSubmit:({comment:M,selection:F})=>{const j=f();j&&x({file:j,selection:F,comment:M,origin:"file"})},onUpdate:({id:M,comment:F,selection:j})=>{const z=f();z&&k({id:M,file:z,selection:j,comment:F})},onDelete:M=>{const F=f();F&&C({id:M.id,file:F})},editSubmitLabel:r.t("common.save"),renderCommentActions:(M,F)=>h(fit,{get moreLabel(){return r.t("common.moreOptions")},get editLabel(){return r.t("common.edit")},get deleteLabel(){return r.t("common.delete")},get onEdit(){return F.edit},get onDelete(){return F.remove}})});ae(()=>{if(typeof window>"u")return;an(window,"keydown",F=>{c()===e.tab&&(!(F.metaKey||F.ctrlKey)||F.altKey||F.shiftKey||F.key.toLowerCase()==="f"&&(F.preventDefault(),F.stopPropagation(),u?.focus()))},{capture:!0})}),ae(vt(f,()=>{P.note.reset()},{defer:!0})),ae(()=>{const M=n.focus(),F=f();if(!M||!F||M.file!==F||c()!==e.tab)return;const j=E().find(z=>z.id===M.id);j&&(P.note.openComment(j.id,j.selection,{cancelDraft:!0}),requestAnimationFrame(()=>n.clearFocus()))});let T={loaded:!1,ready:!1,active:!1};ae(()=>{const M=!!m()?.loaded,F=t.ready(),j=c()===e.tab,z=M&&!T.loaded||F&&!T.ready||j&&M&&!T.active;T={loaded:M,ready:F,active:j},z&&v.queueRestore()});const D=M=>(()=>{var F=Ire();return S(F,h(Gi,{component:s,mode:"text",get file(){return{name:f()??"",contents:M,cacheKey:p()}},enableLineSelection:!0,enableGutterUtility:!0,get selectedLines(){return V()},get commentedLines(){return _()},onRendered:()=>{v.queueRestore()},get annotations(){return P.annotations()},get renderAnnotation(){return P.renderAnnotation},get renderGutterUtility(){return P.renderGutterUtility},onLineSelected:j=>{P.onLineSelected(j)},onLineSelectionEnd:j=>{if(!j){P.note.select(null),P.note.cancelDraft();return}P.onLineSelectionEnd(j)},onLineNumberSelectionEnd:j=>{P.onLineNumberSelectionEnd(j)},search:d,class:"select-text",get media(){return{mode:"auto",path:f(),current:m()?.content,onLoad:v.queueRestore,onError:j=>{j.kind==="svg"&&tn({variant:"error",title:r.t("toast.file.loadFailed.title")})}}}})),F})();return(()=>{var M=Lre();return S(M,h(yc,{class:"h-full",get viewportRef(){return v.setViewport},get onScroll(){return v.handleScroll},get children(){return h(Rr,{get children(){return[h(zt,{get when(){return m()?.loaded},get children(){return D(g())}}),h(zt,{get when(){return m()?.loading},get children(){var F=Dre(),j=F.firstChild;return S(F,()=>r.t("common.loading"),j),F}}),h(zt,{get when(){return m()?.error},children:F=>(()=>{var j=Are();return S(j,F),j})()})]}})}})),M})()}dn(["mousedown","click"]);var pit=A("<div data-slot=session-review-v2-toolbar><div data-slot=session-review-v2-toolbar-group class=session-review-v2-toolbar-group--start>"),vit=A("<div data-component=session-review-v2><div data-slot=session-review-v2-body><div data-slot=session-review-v2-preview>"),yit=A("<div data-slot=session-review-v2-toolbar-group class=session-review-v2-toolbar-group--segments>"),bit=A("<div data-slot=session-review-v2-empty>");function Pre(e){return(()=>{var t=vit(),n=t.firstChild,r=n.firstChild;return S(n,()=>e.sidebar,r),S(r,h(q,{get when(){return e.toolbar},get children(){var i=pit(),s=i.firstChild;return S(s,()=>e.toolbarStart),S(i,h(q,{get when(){return e.toolbarEnd},children:o=>(()=>{var a=yit();return S(a,o),a})()}),null),i}}),null),S(r,()=>e.children,null),t})()}function Ore(e){return(()=>{var t=bit();return S(t,()=>e.children),t})()}var wit=A("<div>"),xit=A("<button><span data-slot=segmented-control-v2-item-label>");const Rre=bn();function kit(){const e=hn(Rre);if(!e)throw new Error("SegmentedControlItemV2 must be used inside SegmentedControlV2");return e}function PN(e){const t=I(()=>Object.hasOwn(e,"value")),n=le({allowDeselect:!1,disabled:!1},e),[r,i]=Ee(n,["class","classList","children","value","defaultValue","onChange","allowDeselect","disabled","ref"]),[s,o]=De(r.defaultValue??null),a=I(()=>t()?r.value??null:s()),l=g=>{t()||o(g),r.onChange?.(g)},f={selected:a,groupDisabled:()=>!!r.disabled,select:g=>{l(g)},clearIfAllowed:g=>{!r.allowDeselect||a()!==g||l(null)},focusNext:(g,p)=>{const y=g.closest('[data-slot="segmented-control-v2"]');if(!y)return;const v=Array.from(y.querySelectorAll('button[data-slot="segmented-control-v2-item"]')).filter(x=>!x.disabled),b=v.indexOf(g);v[b+p]?.focus()}},m=g=>{const p=r.ref;typeof p=="function"?p(g):p!=null&&typeof p=="object"&&"value"in p&&(p.value=g)};return h(Rre.Provider,{value:f,get children(){var g=wit();return pt(m,g),An(g,le(i,{role:"group","data-component":"segmented-control-v2","data-slot":"segmented-control-v2",get classList(){return{...r.classList,[r.class??""]:!!r.class}}}),!1,!0),S(g,()=>r.children),g}})}function ON(e,t){typeof e=="function"&&e(t)}function i2(e){const t=le({disabled:!1},e),[n,r]=Ee(t,["class","classList","children","value","disabled","onClick","onKeyDown"]),i=kit(),s=I(()=>i.selected()===n.value),o=I(()=>i.groupDisabled()||!!n.disabled),a=c=>{ON(n.onClick,c),!(c.defaultPrevented||o())&&(s()?i.clearIfAllowed(n.value):i.select(n.value))},l=c=>{if(ON(n.onKeyDown,c),c.defaultPrevented||o())return;const u=c.currentTarget;if(c.key==="ArrowRight")c.preventDefault(),i.focusNext(u,1);else if(c.key==="ArrowLeft")c.preventDefault(),i.focusNext(u,-1);else if(c.key==="Home")c.preventDefault(),u.closest('[data-slot="segmented-control-v2"]')?.querySelector('button[data-slot="segmented-control-v2-item"]:not(:disabled)')?.focus();else if(c.key==="End"){c.preventDefault();const f=u.closest('[data-slot="segmented-control-v2"]')?.querySelectorAll('button[data-slot="segmented-control-v2-item"]:not(:disabled)');f?.[f.length-1]?.focus()}};return(()=>{var c=xit(),u=c.firstChild;return An(c,le(r,{type:"button","data-slot":"segmented-control-v2-item",get"data-pressed"(){return s()?"":void 0},get"aria-pressed"(){return s()},get disabled(){return o()},get classList(){return{...n.classList,[n.class??""]:!!n.class}},onClick:a,onKeyDown:l}),!1,!0),S(u,()=>n.children),c})()}var Sit=A("<span data-slot=text-input-v2-leading-icon>"),Cit=A("<button type=button data-slot=text-input-v2-icon-button>"),_it=A("<div data-component=text-input-v2><div data-slot=text-input-v2-value><input>");function Dp(e){const[t,n]=Ee(e,["class","classList","leadingIcon","showCopyButton","showClearButton","copyLabel","clearLabel","onCopyClick","onClearClick","numeric","invalid","appearance","disabled"]);return(()=>{var r=_it(),i=r.firstChild,s=i.firstChild;return S(i,h(q,{get when(){return t.leadingIcon},get children(){var o=Sit();return S(o,()=>t.leadingIcon),o}}),s),An(s,le(n,{get type(){return n.type??"text"},get disabled(){return t.disabled},get"aria-invalid"(){return t.invalid?!0:void 0},"data-slot":"text-input-v2-input"}),!1,!1),S(r,h(q,{get when(){return t.showClearButton||t.showCopyButton},get children(){var o=Cit();return o.$$click=a=>{if(t.showClearButton){t.onClearClick?.(a);return}t.onCopyClick?.(a)},o.$$mousedown=a=>{t.showClearButton&&a.preventDefault()},S(o,h(on,{get name(){return t.showClearButton?"xmark-small":"copy"}})),he(a=>{var l=t.showClearButton?"clear":"copy",c=t.showClearButton?t.clearLabel??"Clear":t.copyLabel??"Copy",u=t.disabled;return l!==a.e&&me(o,"data-variant",a.e=l),c!==a.t&&me(o,"aria-label",a.t=c),u!==a.a&&(o.disabled=a.a=u),a},{e:void 0,t:void 0,a:void 0}),o}}),null),he(o=>{var a=t.disabled?"":void 0,l=t.invalid?"":void 0,c=t.numeric?"":void 0,u=t.appearance??"base",d=t.leadingIcon?"":void 0,f={...t.classList,[t.class??""]:!!t.class};return a!==o.e&&me(r,"data-disabled",o.e=a),l!==o.t&&me(r,"data-invalid",o.t=l),c!==o.a&&me(r,"data-numeric",o.a=c),u!==o.o&&me(r,"data-appearance",o.o=u),d!==o.i&&me(r,"data-leading-icon",o.i=d),o.n=ct(r,f,o.n),o},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),r})()}dn(["mousedown","click"]);var Tit=A("<aside data-slot=session-review-v2-sidebar><div data-slot=session-review-v2-sidebar-header><div data-slot=session-review-v2-sidebar-title></div></div><div data-slot=session-review-v2-sidebar-filter>"),Eit=A("<div data-slot=session-review-v2-sidebar-resize>"),Iit=A("<div data-component=session-review-v2-sidebar-root>"),Dit=A('<svg width=14 height=14 viewBox="0 0 14 14"fill=none xmlns=http://www.w3.org/2000/svg aria-hidden=true><path d="M12.25 12.25L10.0625 10.0625M11.0833 6.41667C11.0833 8.994 8.994 11.0833 6.41667 11.0833C3.83934 11.0833 1.75 8.994 1.75 6.41667C1.75 3.83934 3.83934 1.75 6.41667 1.75C8.994 1.75 11.0833 3.83934 11.0833 6.41667Z"stroke=currentColor stroke-linecap=square>'),Lit=A("<div data-slot=session-review-v2-toolbar-title>"),Ait=A("<span data-slot=session-review-v2-file-position>/"),Mit=A("<div data-slot=session-review-v2-toolbar-collapsed-meta>"),$it=A('<div class="flex items-center">');const jC=240,KI=200,GI=480;function Fre(e){const t=Mn(),[n,r]=De(!1),i=()=>e.width??jC,s=()=>e.minWidth??KI,o=()=>e.maxWidth??GI;return ae(()=>{if(!n())return;const a=()=>r(!1);an(document,"pointerup",a),an(document,"pointercancel",a)}),(()=>{var a=Iit();return S(a,h(q,{get when(){return e.open},get children(){var l=Tit(),c=l.firstChild,u=c.firstChild,d=c.nextSibling;return S(u,()=>e.title),S(c,()=>e.stats,null),S(d,h(Dp,{type:"search",get value(){return e.filter},onInput:f=>e.onFilterChange(f.currentTarget.value),get onKeyDown(){return e.onFilterKeyDown},get autofocus(){return e.filterAutofocus},ref(f){var m=e.filterRef;typeof m=="function"?m(f):e.filterRef=f},get role(){return e.filterControls?"combobox":void 0},get"aria-autocomplete"(){return e.filterControls?"list":void 0},get"aria-controls"(){return e.filterControls},get"aria-activedescendant"(){return e.filterActiveDescendant},get"aria-expanded"(){return we(()=>!!e.filterControls)()?e.filterExpanded:void 0},get showClearButton(){return e.filter.length>0},get clearLabel(){return t.t("ui.list.clearFilter")},onClearClick:()=>e.onFilterChange(""),get placeholder(){return t.t("ui.sessionReviewV2.filterFiles")},get"aria-label"(){return t.t("ui.sessionReviewV2.filterFiles")},get leadingIcon(){return Dit()}})),S(l,h(yc,{"data-slot":"session-review-v2-sidebar-tree",class:"group/file-tree-v2",thumbVisibility:"scroll",get viewportRef(){return e.viewportRef},get children(){return e.children}}),null),he(f=>{var m=e.transition?"":void 0,g=n()?"":void 0,p=`${i()}px`;return m!==f.e&&me(l,"data-transition",f.e=m),g!==f.t&&me(l,"data-resizing",f.t=g),p!==f.a&&Ct(l,"width",f.a=p),f},{e:void 0,t:void 0,a:void 0}),l}}),null),S(a,h(q,{get when(){return we(()=>!!e.open)()&&e.onWidthChange},get children(){var l=Eit();return l.$$pointerdown=()=>r(!0),S(l,h(Gf,{direction:"horizontal",get size(){return i()},get min(){return s()},get max(){return o()},onResize:c=>e.onWidthChange?.(c),onDblClick:()=>e.onWidthChange?.(jC)})),l}}),null),a})()}function Pit(e){const t=Mn();ae(()=>{$w(e.diffStyle)});const n=()=>{const f=e.files;if(f.length===0)return-1;const m=e.activeFile,g=m?f.indexOf(m):-1;return g>=0?g:0},r=()=>e.files[n()-1],i=()=>e.files[n()+1],s=()=>e.files.length>0,o=()=>e.sidebarOpen===!1,a=I(()=>e.title),l=I(()=>e.stats),c=f=>{f&&e.onSelectFile(f)};an(document,"keydown",f=>{if(f.defaultPrevented||f.ctrlKey||f.metaKey||f.altKey||f.key!=="<"&&f.key!==">")return;const m=f.target;if(m instanceof HTMLElement&&(m.isContentEditable||m.closest("input, textarea, select"))||!e.hasDiffs||!s())return;const g=f.key==="<"?r():i();g&&(f.preventDefault(),c(g))});const u=()=>[h(q,{get when(){return o()},get children(){var f=Mit();return S(f,h(q,{get when(){return a()},get children(){var m=Lit();return S(m,a),m}}),null),S(f,l,null),S(f,h(q,{get when(){return s()},get children(){var m=Ait(),g=m.firstChild;return S(m,()=>n()+1,g),S(m,()=>e.files.length,null),m}}),null),f}}),(()=>{var f=$it();return S(f,h(Qn,{openDelay:2e3,get inactive(){return!r()},get value(){return[we(()=>t.t("ui.sessionReviewV2.previousFile")),h(Eo,{keys:["<"],variant:"neutral"})]},get children(){return h(Ln,{icon:"arrow-left",variant:"ghost",size:"small",class:"session-review-v2-file-nav-button",get disabled(){return!r()},onClick:()=>c(r()),get"aria-label"(){return t.t("ui.sessionReviewV2.previousFile")}})}}),null),S(f,h(Qn,{openDelay:2e3,get inactive(){return!i()},get value(){return[we(()=>t.t("ui.sessionReviewV2.nextFile")),h(Eo,{keys:[">"],variant:"neutral"})]},get children(){return h(Ln,{icon:"arrow-right",variant:"ghost",size:"small",class:"session-review-v2-file-nav-button",get disabled(){return!i()},onClick:()=>c(i()),get"aria-label"(){return t.t("ui.sessionReviewV2.nextFile")}})}}),null),f})()],d=()=>[h(PN,{get value(){return e.expandMode},onChange:f=>{f!=="expand"&&f!=="collapse"||e.onExpandModeChange(f)},class:"session-review-v2-segmented-control session-review-v2-segmented-control--icon",get"aria-label"(){return t.t("ui.sessionReviewV2.expandMode")},get children(){return[h(Qn,{openDelay:2e3,get value(){return t.t("ui.sessionReviewV2.showAllLines")},get children(){return h(i2,{value:"expand",get"aria-label"(){return t.t("ui.sessionReviewV2.showAllLines")},get children(){return h(on,{name:"expand"})}})}}),h(Qn,{openDelay:2e3,get value(){return t.t("ui.sessionReviewV2.hideNonDiffLines")},get children(){return h(i2,{value:"collapse",get"aria-label"(){return t.t("ui.sessionReviewV2.hideNonDiffLines")},get children(){return h(on,{name:"collapse"})}})}})]}}),h(q,{get when(){return e.onDiffStyleChange},get children(){return h(PN,{get value(){return e.diffStyle},onChange:f=>{f!=="unified"&&f!=="split"||e.onDiffStyleChange?.(f)},class:"session-review-v2-segmented-control session-review-v2-segmented-control--icon",get"aria-label"(){return t.t("ui.sessionReviewV2.diffView")},get children(){return[h(Qn,{openDelay:2e3,get value(){return t.t("ui.sessionReviewV2.unifiedDiff")},get children(){return h(i2,{value:"unified",get"aria-label"(){return t.t("ui.sessionReviewV2.unifiedDiff")},get children(){return h(on,{name:"unified"})}})}}),h(Qn,{openDelay:2e3,get value(){return t.t("ui.sessionReviewV2.splitDiff")},get children(){return h(i2,{value:"split",get"aria-label"(){return t.t("ui.sessionReviewV2.splitDiff")},get children(){return h(on,{name:"split"})}})}})]}})}})];return h(Pre,{get sidebar(){return e.sidebar},get toolbar(){return e.hasDiffs},get toolbarStart(){return u()},get toolbarEnd(){return d()},get children(){return h(q,{get when(){return e.hasDiffs},get fallback(){return e.empty},get children(){return h(q,{get when(){return e.activeFile},get fallback(){return h(Ore,{get children(){return e.empty}})},get children(){return e.preview}})}})}})}function Oit(e){const t=Mn();return h(Qn,{get value(){return t.t("ui.sessionReviewV2.toggleSidebar")},get children(){return h(Lr,{variant:"ghost",size:"small",class:"session-review-v2-sidebar-toggle",get"aria-label"(){return t.t("ui.sessionReviewV2.toggleSidebar")},get"aria-expanded"(){return e.opened},get disabled(){return e.disabled},get onClick(){return e.onToggle},get icon(){return h(on,{name:"filetree"})}})}})}dn(["pointerdown"]);function Nre(e){return e?.isConnected?e.closest(".scroll-view__viewport"):null}var Rit=A('<span class="flex-1 min-w-0 text-12-medium whitespace-nowrap truncate">'),Fit=A("<span data-slot=file-tree-v2-change>"),Nit=A("<div data-slot=file-tree-v2-guide>"),Vit=A("<div data-component=file-tree-v2 class=group/file-tree-v2 style=position:relative>"),zit=A("<div style=position:absolute;top:0;left:0;width:100%>"),Hit=A('<div data-slot=file-tree-v2-chevron class="size-4 flex items-center justify-center">'),jit=A('<div class="w-4 shrink-0">'),qit=A('<span class="filetree-iconpair size-4">');const i6=16;function Vre(e,t){return t==="directory"?8+e*i6:e===0?8:8+e*i6-i6}function Bit(e){return Vre(e,"directory")+8}const zre=e=>e==="add"?"A":e==="del"?"D":"M",Hre=e=>e==="add"?"added":e==="del"?"deleted":"modified",RN=e=>{const[t,n]=Ee(e,["node","level","active","draggable","kinds","as","children","class","classList"]),r=()=>t.kinds?.get(l0(t.node.path));return h(Gi,le({get component(){return t.as??"div"},"data-slot":"file-tree-v2-row",get"data-path"(){return t.node.path},get"data-selected"(){return t.node.path===t.active?"":void 0},get"data-ignored"(){return t.node.ignored?"":void 0},get classList(){return{...t.classList,[t.class??""]:!!t.class}},get style(){return`padding-left: ${Vre(t.level,t.node.type)}px`},get draggable(){return t.draggable},onDragStart:i=>{t.draggable&&(i.dataTransfer?.setData("text/plain",`file:${t.node.path}`),i.dataTransfer?.setData("text/uri-list",xre(t.node.path)),i.dataTransfer&&(i.dataTransfer.effectAllowed="copy"),Sre(i))}},n,{get children(){return[we(()=>t.children),(()=>{var i=Rit();return S(i,()=>t.node.name),i})(),we(()=>(()=>{const i=r();return!i||t.node.type!=="file"?null:(()=>{var s=Fit();return S(s,()=>zre(i)),he(()=>me(s,"data-change",Hre(i))),s})()})())]}}))};function FN(e){return h(Dt,{get each(){return Array.from({length:e.level})},children:(t,n)=>(()=>{var r=Nit();return he(i=>So(r,`left: ${Bit(n())}px`,i)),r})()})}function jre(e){const t=ua(),n=()=>e.allowed===void 0,r=()=>e.draggable??!0,i=()=>l0(e.active??""),s=I(()=>n()?void 0:Prt(e.allowed??[])),o=w=>t.tree.state(w)?.expanded??!n(),a=I(()=>n()?Rrt(w=>t.tree.children(w),o):Ort(s(),o)),[l,c]=De(),[u,d]=De(),f=PI({get count(){return a().length},getScrollElement:()=>Nre(l()),initialRect:{width:0,height:600},estimateSize:()=>28,gap:2,overscan:10,get getItemKey(){const w=a();return x=>w[x]?.node.path??x},rangeExtractor:w=>{const x=r3(w),k=u(),C=k?a().findIndex(E=>E.node.path===k):-1;return C<0||x.includes(C)?x:[...x,C].sort((E,_)=>E-_)}});ae(()=>{n()&&t.tree.list("")});let m;ae(()=>{const w=i();if(!w){m=void 0;return}a().findIndex(k=>k.node.path===w)<0||m!==w&&(m=w,queueMicrotask(()=>{const k=a().findIndex(C=>C.node.path===w);k<0||f.range&&k>=f.range.startIndex&&k<=f.range.endIndex||f.scrollToIndex(k,{align:"auto"})}))});const g=(w,x)=>{x?.({...w,path:w.originalPath,absolute:w.originalPath})},p=(w,x)=>{if(o(w)){t.tree.collapse(x);return}t.tree.expand(x,n()?void 0:{list:!1})},y=I(()=>new Map(a().map(w=>[w.node.path,w]))),v=I(()=>new Map(f.getVirtualItems().map(w=>[w.key,w]))),b=I(()=>f.getVirtualItems().map(w=>w.key));return(()=>{var w=Vit();return pt(c,w),S(w,h(Dt,{get each(){return b()},children:x=>h(q,{get when(){return v().get(x)},children:k=>(()=>{var C=zit();return S(C,h(q,{get when(){return y().get(x)},children:E=>h(q,{get when(){return E().node.type==="directory"},get fallback(){return h(RN,{get node(){return E().node},get level(){return E().level},get active(){return i()},get draggable(){return r()},get kinds(){return e.kinds},as:"button",type:"button",class:"relative",onFocus:()=>d(E().node.path),onBlur:()=>d(void 0),onClick:()=>g(E().node,e.onFileClick),onDblClick:()=>g(E().node,e.onFileDoubleClick),get children(){return[h(FN,{get level(){return E().level}}),h(q,{get when(){return E().level>0},get children(){return jit()}}),(()=>{var _=qit();return S(_,h(Dr,{get node(){return E().node},class:"size-4 filetree-icon filetree-icon--color"}),null),S(_,h(Dr,{get node(){return E().node},class:"size-4 filetree-icon filetree-icon--mono",mono:!0}),null),_})()]}})},get children(){return h(RN,{get node(){return E().node},get level(){return E().level},get active(){return i()},get draggable(){return r()},get kinds(){return e.kinds},as:"button",type:"button",class:"relative",onFocus:()=>d(E().node.path),onBlur:()=>d(void 0),get"aria-expanded"(){return o(E().node.path)},onClick:()=>p(E().node.path,E().node.originalPath),get children(){return[h(FN,{get level(){return E().level}}),(()=>{var _=Hit();return S(_,h(on,{name:"chevron-down"})),he(()=>me(_,"data-expanded",o(E().node.path)?"":void 0)),_})()]}})}})})),he(E=>{var _=`${k().size}px`,L=`translateY(${k().start}px)`;return _!==E.e&&Ct(C,"height",E.e=_),L!==E.t&&Ct(C,"transform",E.t=L),E},{e:void 0,t:void 0}),C})()})})),he(x=>{var k=n()?a().length:s().total,C=`${f.getTotalSize()}px`;return k!==x.e&&me(w,"data-total-rows",x.e=k),C!==x.t&&Ct(w,"height",x.t=C),x},{e:void 0,t:void 0}),w})()}function Im(e){return l0(e)}function Uit(e){return typeof e.file=="string"}function qre(e){return e.additions===0&&e.deletions===0?!1:!e.patch||!/^@@ /m.test(e.patch)}function Bre(e){return e==="/"||/^[A-Za-z]:[/\\]?$/.test(e)?e:e.replace(/[/\\]+$/,"")}function Wit(e,t){const n=Im(t),r=n.lastIndexOf("/"),i=e.includes("\\")?"\\":"/",s=Bre(e);return r<0?s:`${s.endsWith(i)?s:s+i}${n.slice(0,r).replaceAll("/",i)}`}function Kit(e){const t=(r,i)=>r?r===i?r:"mix":i,n=new Map;for(const r of e){const i=Im(r.file),s=r.status==="added"?"add":r.status==="deleted"?"del":"mix";n.set(i,s);const o=i.split("/");o.slice(0,-1).forEach((a,l)=>{const c=o.slice(0,l+1).join("/");c&&n.set(c,t(n.get(c),s))})}return n}function Git(e,t){const n=t.trim().toLowerCase();return n?e.filter(r=>r.toLowerCase().includes(n)):e}var Zit=A("<div data-component=file-tree-v2 style=position:relative>"),Yit=A('<div style=position:absolute;top:0;left:0;width:100%><button type=button data-slot=file-tree-v2-row style=padding-left:8px><span class="filetree-iconpair size-4"></span><span class="flex min-w-0 flex-1 items-center overflow-hidden whitespace-nowrap"><span class="text-12-medium text-text-base truncate min-w-0 shrink-0">'),Xit=A('<span class="text-12-medium text-text-muted truncate min-w-0 shrink">'),Qit=A("<span data-slot=file-tree-v2-change>");function Ure(e,t,n,r){if(t.length===0)return;if(e.key==="ArrowDown"||e.key==="ArrowUp"){const s=n?t.indexOf(n):-1,o=e.key==="ArrowDown"?1:-1,a=s===-1?o>0?0:t.length-1:s+o,l=Math.max(0,Math.min(t.length-1,a));r.onHighlight(t[l]),e.preventDefault();return}if(e.key!=="Enter")return;const i=n??t[0];i&&(r.onSelect(i),e.preventDefault())}function Wre(e){const t=()=>Im(e.active??""),n=()=>Im(e.highlighted??""),r=I(()=>e.files.map(Im)),[i,s]=De(),[o,a]=De(),l=PI({get count(){return e.files.length},getScrollElement:()=>Nre(i()),initialRect:{width:0,height:600},estimateSize:()=>28,gap:2,overscan:10,get getItemKey(){const d=e.files;return f=>d[f]??f},rangeExtractor:d=>{const f=r3(d),m=o(),g=m?e.files.indexOf(m):-1;return g<0||f.includes(g)?f:[...f,g].sort((p,y)=>p-y)}});ae(()=>{const d=r().indexOf(n());d<0||queueMicrotask(()=>{l.range&&d>=l.range.startIndex&&d<=l.range.endIndex||l.scrollToIndex(d,{align:"auto"})})});const c=I(()=>new Map(l.getVirtualItems().map(d=>[d.key,d]))),u=I(()=>l.getVirtualItems().map(d=>d.key));return(()=>{var d=Zit();return pt(s,d),S(d,h(Dt,{get each(){return u()},children:f=>{const m=f,g=Im(m),p=()=>n()?n()===g:t()===g,y=()=>n()===g,v=()=>e.kinds?.get(g),b=()=>g.includes("/")?hc(g):void 0,w=()=>fn(g);return h(q,{get when(){return c().get(f)},children:x=>(()=>{var k=Yit(),C=k.firstChild,E=C.firstChild,_=E.nextSibling,L=_.firstChild;return C.$$dblclick=()=>e.onFileDoubleClick?.(m),C.$$click=()=>e.onFileClick(m),C.addEventListener("blur",()=>a(void 0)),C.addEventListener("focus",()=>a(m)),me(C,"data-path",m),S(E,h(Dr,{node:{path:m,type:"file"},class:"size-4 filetree-icon filetree-icon--color"}),null),S(E,h(Dr,{node:{path:m,type:"file"},class:"size-4 filetree-icon filetree-icon--mono",mono:!0}),null),S(_,h(q,{get when(){return b()},children:O=>(()=>{var $=Xit();return S($,O),$})()}),L),S(L,w),S(C,h(q,{get when(){return v()},children:O=>(()=>{var $=Qit();return S($,()=>zre(O())),he(()=>me($,"data-change",Hre(O()))),$})()}),null),he(O=>{var $=`${x().size}px`,V=`translateY(${x().start}px)`,P=e.optionID?.(m),T=e.role?"option":void 0,D=e.role?p():void 0,N=p()?"":void 0,M=y()?"":void 0;return $!==O.e&&Ct(k,"height",O.e=$),V!==O.t&&Ct(k,"transform",O.t=V),P!==O.a&&me(C,"id",O.a=P),T!==O.o&&me(C,"role",O.o=T),D!==O.i&&me(C,"aria-selected",O.i=D),N!==O.n&&me(C,"data-selected",O.n=N),M!==O.s&&me(C,"data-highlighted",O.s=M),O},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0}),k})()})}})),he(f=>{var m=e.id,g=e.role,p=e.files.length,y=`${l.getTotalSize()}px`;return m!==f.e&&me(d,"id",f.e=m),g!==f.t&&me(d,"role",f.t=g),p!==f.a&&me(d,"data-total-rows",f.a=p),y!==f.o&&Ct(d,"height",f.o=y),f},{e:void 0,t:void 0,a:void 0,o:void 0}),d})()}dn(["click","dblclick"]);var Jit=A('<div class="min-h-0 flex-1">'),est=A("<span class=truncate>"),NN=A('<div role=status class="px-2 py-2 text-12-regular text-text-weak">'),tst=A('<div class="flex flex-col items-center gap-3 text-center text-text-weak"><div class="text-14-medium text-text-strong"></div><div class=text-13-regular>');const VN=[];function nst(e){const t=ua(),n=wt(),r=li(),i=kr(),{workspaceKey:s}=ga(),o=`session-file-browser-results-${nr()}`,[a,l]=De(""),[c,u]=De(),d=()=>e.placeholder||e.state.sidebarOpened(),f=I(()=>a().trim()),m=zp(()=>{const k=f();return{queryKey:["session-open-file",s(),k],enabled:k.length>0,queryFn:({signal:C})=>t.searchFiles(k,{limit:200,signal:C})}}),g=I(()=>!f()||m.isPending?VN:[...new Set(m.data??VN)]),p=I(()=>{const k=g();if(k.length===0)return;const C=c();return C&&k.includes(C)?C:k[0]}),y=I(()=>f().length>0&&m.isPending),v=I(()=>{const k=rt(i().directory);return r.projects.list().find(C=>rt(C.worktree)===k||C.sandboxes?.some(E=>rt(E)===k))}),b=I(()=>Ll(v()??{worktree:i().directory})),w=k=>`${o}-option-${g().indexOf(k)}`,x=k=>{if(k.key==="Escape"&&f()){k.preventDefault(),l("");return}f()&&Ure(k,g(),p(),{onHighlight:u,onSelect:e.onSelectPermanent})};return h(Pre,{toolbar:!1,get sidebar(){return h(Fre,{get open(){return d()},get transition(){return e.state.sidebarTransition()},get title(){return(()=>{var k=est();return S(k,b),k})()},get filter(){return a()},onFilterChange:l,onFilterKeyDown:x,get filterAutofocus(){return e.placeholder},get filterRef(){return e.filterRef},filterControls:o,get filterActiveDescendant(){return we(()=>!!p())()?w(p()):void 0},get filterExpanded(){return we(()=>f().length>0)()&&g().length>0},get width(){return e.state.sidebarWidth()},get onWidthChange(){return e.state.resizeSidebar},get children(){return h(q,{get when(){return f()},get fallback(){return h(jre,{get active(){return e.active},get kinds(){return e.kinds},onFileClick:k=>e.onSelect(k.path),onFileDoubleClick:k=>e.onSelectPermanent(k.path)})},get children(){return h(q,{get when(){return!y()},get fallback(){return(()=>{var k=NN();return S(k,()=>n.t("common.loading"),null),S(k,()=>n.t("common.loading.ellipsis"),null),k})()},get children(){return h(q,{get when(){return g().length>0},get fallback(){return(()=>{var k=NN();return S(k,()=>n.t("palette.empty")),k})()},get children(){return h(Wre,{id:o,role:"listbox",optionID:w,get files(){return g()},get kinds(){return e.kinds},get active(){return e.active},get highlighted(){return p()},onFileClick:k=>{u(k),e.onSelect(k)},get onFileDoubleClick(){return e.onSelectPermanent}})}})}})}})}})},get children(){return h(q,{get when(){return!e.placeholder},get fallback(){return h(Ore,{get children(){var k=tst(),C=k.firstChild,E=C.nextSibling;return S(k,h(Yt,{name:"file-tree",size:"large"}),C),S(C,()=>n.t("command.file.open")),S(E,()=>n.t("session.files.selectToOpen")),k}})},get children(){var k=Jit();return S(k,h(q,{get when(){return e.tab},keyed:!0,children:C=>h($re,{tab:C})})),k}})}})}var rst=A('<div class="h-full flex flex-col"><div class="h-6 shrink-0"aria-hidden></div><div class="flex-1 pb-64 flex items-center justify-center text-center"><div class="text-12-regular text-text-weak">'),zN=A('<div class="flex items-center gap-2"><div>'),ist=A('<div class="h-full shrink-0 sticky right-0 z-10 flex items-center justify-center">'),sst=A('<div class="session-review-v2-tabs-bar sticky top-0 shrink-0 flex items-center"><div class="session-review-v2-open-in-app-slot shrink-0 flex items-center pr-3">'),HN=A('<div id=session-side-panel-review-tabpanel role=tabpanel aria-labelledby=session-side-panel-review-tab data-slot=tabs-content class="flex flex-col h-full overflow-hidden contain-strict">'),jN=A('<div class="relative pt-2 flex-1 min-h-0 overflow-hidden"><div class="h-full px-6 pb-42 -mt-4 flex flex-col items-center justify-center text-center gap-6"><div class="text-14-regular text-text-weak max-w-56">'),qN=A('<div class="relative pt-2 flex-1 min-h-0 overflow-hidden">'),ost=A('<div id=session-side-panel-file-browser-tabpanel role=tabpanel data-slot=tabs-content class="h-full min-h-0 overflow-hidden">'),ast=A('<div class="relative min-w-0 h-full flex-1 overflow-hidden"><div class="size-full min-w-0 h-full">'),BN=A("<div>"),lst=A('<div id=file-tree-panel class="relative min-w-0 h-full shrink-0 overflow-hidden"><div class="h-full flex flex-col overflow-hidden group/filetree">'),cst=A('<div class="size-full flex">'),ust=A('<aside id=review-panel class="relative min-w-0 flex overflow-hidden">'),dst=A('<div class="flex items-center gap-1.5"><div>'),fst=A('<div class="h-full shrink-0 sticky right-0 z-10 flex items-center justify-center pr-3">'),hst=A('<div class="sticky top-0 shrink-0 flex">'),UN=A('<div class="flex items-center gap-1.5 italic"><span>'),mst=A("<div data-component=tabs-drag-preview>"),gst=A('<div class="session-review-v2-sidebar-toggle-slot h-full shrink-0 sticky left-0 z-10 flex items-center justify-center bg-v2-background-bg-base">'),pst=A('<div class="px-2 py-2 text-12-regular text-text-weak">');const WN="session-side-panel-review-tab",KN="session-side-panel-review-tabpanel";function vst(e){return typeof e.file=="string"}function GN(e){const t=li(),n=ar(),r=ua(),i=wt(),s=Qi(),o=Mr(),a=kr(),{sessionKey:l,tabs:c,view:u,params:d}=ga(),f=I(()=>a().directory),m=uu("(min-width: 768px)"),g=n.visibility.fileTree,p=I(()=>m()&&u().reviewPanel.opened()),y=I(()=>m()&&YJ({visible:g(),opened:t.fileTree.opened()})),v=I(()=>p()||y()),b=I(()=>m()),w=I(()=>v()?p()?"auto":`${t.fileTree.width()}px`:"0px"),x=I(()=>y()?`${t.fileTree.width()}px`:"0px"),k=I(()=>e.diffs().filter(vst)),C=I(()=>k().map(G=>G.file)),E=I(()=>{const G=(xe,Oe)=>xe?xe===Oe?xe:"mix":Oe,fe=new Map;for(const xe of k()){const Oe=l0(xe.file),re=xe.status==="added"?"add":xe.status==="deleted"?"del":"mix";fe.set(Oe,re);const pe=Oe.split("/");for(const[ye]of pe.slice(0,-1).entries()){const Re=pe.slice(0,ye+1).join("/");Re&&fe.set(Re,G(fe.get(Re),re))}}return fe}),_=G=>(()=>{var fe=rst(),xe=fe.firstChild,Oe=xe.nextSibling,re=Oe.firstChild;return S(re,G),fe})(),L=I(()=>r.tree.state("")?.loaded?r.tree.children("").length===0:!1),O=G=>G.startsWith("file://")?r.tab(G):G,$=()=>{u().reviewPanel.opened()||u().reviewPanel.open()},V=HVe({normalizeTab:O,openTab:c().open,pathFromTab:r.pathFromTab,loadFile:r.load,openReviewPanel:$,setActive:c().setActive}),P=Nd({tabs:c,pathFromTab:r.pathFromTab,normalizeTab:O,review:b,hasReview:e.canReview,fileBrowser:()=>!!e.fileBrowserState}),T=P.contextOpen,D=P.openFileOpen,N=P.panelTabs,M=P.openedTabs,F=P.activeTab,j=P.activeFileTab,z=()=>t.fileTree.tab(),W=G=>{G!=="changes"&&G!=="all"||t.fileTree.setTab(G)},J=()=>{z()==="changes"&&t.fileTree.setTab("all")};let K,X;const te=c().preview,ve=G=>{const fe=O(G);c().previewTab(fe);const xe=r.pathFromTab(fe);xe&&r.load(xe),$(),queueMicrotask(()=>c().setActive(fe))},ne=()=>{ve(ii),queueMicrotask(()=>K?.focus())},ie=G=>{const fe=O(G),xe=r.pathFromTab(fe);xe&&r.load(xe),$(),c().setActive(fe)},ke=I(()=>{if(!e.fileBrowserState)return;const G=F();return G===ii?ii:G&&r.pathFromTab(G)?G:j()}),ge=I(()=>e.fileBrowserState?M().length>0||D()||!!ke():!1),Pe=I(()=>{const G=F();return G!=="review"&&G!=="context"&&G!=="empty"}),Me=I(()=>s.keybindParts("file.open")),de=I(()=>s.keybindParts("tab.close")),[U,He]=Ze({activeDraggable:void 0}),Ue=G=>{const fe=dg(G);fe&&He("activeDraggable",fe)},Z=G=>{const{draggable:fe,droppable:xe}=G;if(!fe||!xe)return;const Oe=c().all(),re=jVe(Oe,fe.id.toString(),xe.id.toString());re!==void 0&&c().move(fe.id.toString(),re)},ce=()=>{He("activeDraggable",void 0)};return ae(()=>{r.ready()&&PT(l(),{files:c().all().reduce((G,fe)=>{const xe=r.pathFromTab(fe);if(!xe)return G;const Oe=r.selectedLines(xe);return G[xe]=Oe&&typeof Oe=="object"&&"start"in Oe&&"end"in Oe?Oe:null,G},{})})}),h(q,{get when(){return we(()=>!!m())()&&!(n.general.newLayoutDesigns()&&!d.id)},get children(){var G=ust();return S(G,h(q,{get when(){return v()},get children(){var fe=cst();return S(fe,h(q,{get when(){return p()},get children(){var xe=ast(),Oe=xe.firstChild;return S(Oe,h(q,{get when(){return e.fileBrowserState},get fallback(){return h(yk,{onDragStart:Ue,onDragEnd:ce,onDragOver:Z,collisionDetector:vk,get children(){return[h(bk,{}),h(pY,{}),h(rr,{get value(){return F()},onChange:ie,get children(){return[(()=>{var re=hst();return S(re,h(rr.List,{ref:pe=>{const ye=$N({el:pe,contextOpen:T});Te(ye)},get children(){return[h(q,{get when(){return we(()=>!!b())()&&e.canReview()},get children(){return h(rr.Trigger,{value:"review",id:WN,get"aria-controls"(){return F()==="review"?KN:void 0},get children(){var pe=dst(),ye=pe.firstChild;return S(ye,()=>i.t("session.tab.review")),S(pe,h(q,{get when(){return e.hasReview()},get children(){var Re=BN();return S(Re,()=>e.reviewCount()),Re}}),null),pe}})}}),h(q,{get when(){return T()},get children(){return h(rr.Trigger,{value:"context",get closeButton(){return h(ws,{get title(){return i.t("common.closeTab")},get keybind(){return s.keybind("tab.close")},placement:"bottom",gutter:10,get children(){return h(Ln,{icon:"close-small",variant:"ghost",class:"h-5 w-5",onClick:()=>c().close("context"),get"aria-label"(){return i.t("common.closeTab")}})}})},hideCloseButton:!0,onMiddleClick:()=>c().close("context"),get children(){var pe=zN(),ye=pe.firstChild;return S(pe,h(RC,{variant:"indicator"}),ye),S(ye,()=>i.t("session.tab.context")),pe}})}}),h(kk,{get ids(){return M()},get children(){return h(Dt,{get each(){return N()},children:pe=>h(q,{when:pe===ii,get fallback(){return h(bqe,{tab:pe,get temporary(){return te()===pe},get onTabClose(){return c().close},get onTabDoubleClick(){return te()===pe?V:void 0}})},get children(){return h(rr.Trigger,{value:ii,get closeButton(){return h(ws,{get title(){return i.t("common.closeTab")},get keybind(){return s.keybind("tab.close")},placement:"bottom",gutter:10,get children(){return h(Ln,{icon:"close-small",variant:"ghost",class:"h-5 w-5",onClick:()=>c().close(ii),get"aria-label"(){return i.t("common.closeTab")}})}})},hideCloseButton:!0,onMiddleClick:()=>c().close(ii),get children(){var ye=UN(),Re=ye.firstChild;return S(ye,h(Yt,{name:"open-file",size:"small"}),Re),S(Re,()=>i.t("command.file.open")),ye}})}})})}}),(()=>{var pe=fst();return S(pe,h(ws,{get title(){return i.t("command.file.open")},get keybind(){return s.keybind("file.open")},class:"flex items-center",get children(){return h(Ln,{icon:"plus-small",variant:"ghost",iconSize:"large",class:"!rounded-md",onClick:()=>{B(()=>import("./dialog-select-file-C52l-3Bc.js"),__vite__mapDeps([118,119,120])).then(ye=>{o.show(()=>h(ye.DialogSelectFile,{mode:"files",onOpenFile:J}))})},get"aria-label"(){return i.t("command.file.open")}})}})),he(ye=>{var Re=!!n.general.newLayoutDesigns(),Je=!n.general.newLayoutDesigns();return Re!==ye.e&&pe.classList.toggle("bg-v2-background-bg-base",ye.e=Re),Je!==ye.t&&pe.classList.toggle("bg-background-stronger",ye.t=Je),ye},{e:void 0,t:void 0}),pe})()]}})),re})(),h(q,{get when(){return we(()=>!!(b()&&e.canReview()))()&&F()==="review"},get children(){var re=HN();return S(re,()=>e.reviewPanel()),he(()=>me(re,"tabindex",e.reviewHasFocusableContent()?void 0:0)),re}}),h(q,{get when(){return F()==="empty"},get children(){return h(rr.Content,{value:"empty",class:"flex flex-col h-full overflow-hidden contain-strict",get children(){var re=jN(),pe=re.firstChild,ye=pe.firstChild;return S(pe,h(m7,{class:"w-14 opacity-10"}),ye),S(ye,()=>i.t("session.files.selectToOpen")),re}})}}),h(q,{get when(){return F()==="context"},get children(){return h(rr.Content,{value:"context",class:"flex flex-col h-full overflow-hidden contain-strict",get children(){var re=qN();return S(re,h(eF,{})),re}})}}),h(q,{get when(){return j()},keyed:!0,children:re=>h(hit,{tab:re})})]}}),h(xk,{get children(){return h(q,{get when(){return U.activeDraggable},keyed:!0,children:re=>{const pe=r.pathFromTab(re);return(()=>{var ye=mst();return S(ye,h(q,{when:pe,children:Re=>h(lI,{active:!0,get path(){return Re()},get temporary(){return te()===re}})})),ye})()}})}})]}})},get children(){return h(Vk,{get sensors(){return[yg.configure({activationConstraints:[new dl.Distance({value:4})],preventActivation:re=>re.target instanceof Element&&(!!re.target.closest('[data-slot="tabs-trigger-close-button"]')||!!re.target.closest(".session-review-v2-open-in-app-slot"))})]},get modifiers(){return[FE,zk.configure({element:()=>X??null})]},plugins:re=>[...re.filter(pe=>pe!==Ok),eh.configure({acceleration:8,threshold:{x:.05,y:0}}),Jf.configure({dropAnimation:null})],onDragEnd:re=>{const pe=re.operation.source;re.canceled||!ko(pe)||pe.initialIndex===pe.index||c().move(pe.id.toString(),pe.index)},get children(){return h(rr,{get value(){return F()},onChange:ie,get children(){return[(()=>{var re=sst(),pe=re.firstChild;return S(re,h(rr.List,{ref:ye=>{X=ye;const Re=$N({el:ye,contextOpen:T});Te(Re)},get children(){return[h(q,{get when(){return e.reviewSidebarToggle},children:ye=>(()=>{var Re=gst();return S(Re,()=>ye()(F()===ii)),Re})()}),h(q,{get when(){return we(()=>!!b())()&&e.canReview()},get children(){return h(rr.Trigger,{value:"review",id:WN,get"aria-controls"(){return F()==="review"?KN:void 0},get children(){return we(()=>!!e.hasReview())()?i.t("session.review.filesChanged",{count:e.reviewCount()}):i.t("session.tab.review")}})}}),h(q,{get when(){return T()},get children(){return h(rr.Trigger,{value:"context",get closeButton(){return h(Qn,{get value(){return[we(()=>i.t("common.closeTab")),h(q,{get when(){return de().length>0},get children(){return h(Eo,{get keys(){return de()},variant:"neutral"})}})]},placement:"bottom",gutter:10,get children(){return h(Ln,{icon:"close-small",variant:"ghost",class:"h-5 w-5",onClick:()=>c().close("context"),get"aria-label"(){return i.t("common.closeTab")}})}})},hideCloseButton:!0,onMiddleClick:()=>c().close("context"),get children(){var ye=zN(),Re=ye.firstChild;return S(ye,h(RC,{variant:"indicator"}),Re),S(Re,()=>i.t("session.tab.context")),ye}})}}),h(Dt,{get each(){return N()},children:ye=>h(q,{when:ye===ii,get fallback(){return h(xqe,{tab:ye,index:()=>c().all().indexOf(ye),get temporary(){return te()===ye},get onTabClose(){return c().close},get onTabDoubleClick(){return te()===ye?V:void 0}})},get children(){return h(rr.Trigger,{value:ii,get closeButton(){return h(Qn,{get value(){return[we(()=>i.t("common.closeTab")),h(q,{get when(){return de().length>0},get children(){return h(Eo,{get keys(){return de()},variant:"neutral"})}})]},placement:"bottom",gutter:10,get children(){return h(Ln,{icon:"close-small",variant:"ghost",class:"h-5 w-5",onClick:()=>c().close(ii),get"aria-label"(){return i.t("common.closeTab")}})}})},hideCloseButton:!0,onMiddleClick:()=>c().close(ii),get children(){var Re=UN(),Je=Re.firstChild;return S(Re,h(Yt,{name:"open-file",size:"small"}),Je),S(Je,()=>i.t("command.file.open")),Re}})}})}),(()=>{var ye=ist();return S(ye,h(Qn,{get value(){return[we(()=>i.t("command.file.open")),h(q,{get when(){return Me().length>0},get children(){return h(Eo,{get keys(){return Me()},variant:"neutral"})}})]},placement:"bottom",class:"flex items-center",get children(){return h(Lr,{get icon(){return h(Yt,{name:"plus-small"})},variant:"ghost-muted",size:"large",onClick:()=>ne(),get"aria-label"(){return i.t("command.file.open")}})}})),he(Re=>{var Je=!!n.general.newLayoutDesigns(),Xe=!n.general.newLayoutDesigns();return Je!==Re.e&&ye.classList.toggle("bg-v2-background-bg-base",Re.e=Je),Xe!==Re.t&&ye.classList.toggle("bg-background-stronger",Re.t=Xe),Re},{e:void 0,t:void 0}),ye})()]}}),pe),pe.$$click=ye=>ye.stopPropagation(),pe.$$pointerdown=ye=>ye.stopPropagation(),S(pe,h(Yrt,{directory:f})),re})(),h(q,{get when(){return we(()=>!!(b()&&e.canReview()))()&&F()==="review"},get children(){var re=HN();return S(re,()=>e.reviewPanel()),he(()=>me(re,"tabindex",e.reviewHasFocusableContent()?void 0:0)),re}}),h(q,{get when(){return F()==="empty"},get children(){return h(rr.Content,{value:"empty",class:"flex flex-col h-full overflow-hidden contain-strict",get children(){var re=jN(),pe=re.firstChild,ye=pe.firstChild;return S(pe,h(m7,{class:"w-14 opacity-10"}),ye),S(ye,()=>i.t("session.files.selectToOpen")),re}})}}),h(q,{get when(){return F()==="context"},get children(){return h(rr.Content,{value:"context",class:"flex flex-col h-full overflow-hidden contain-strict",get children(){var re=qN();return S(re,h(eF,{})),re}})}}),h(q,{get when(){return ge()},get children(){var re=ost();return S(re,h(nst,{get tab(){return ke()??j()??ii},get placeholder(){return(ke()??j()??ii)===ii},get active(){return r.pathFromTab(ke()??j()??"")},get kinds(){return E()},get state(){return e.fileBrowserState},onSelect:pe=>ve(r.tab(pe)),onSelectPermanent:pe=>V(r.tab(pe)),filterRef:pe=>K=pe})),he(pe=>{var ye=!Pe(),Re=!Pe()||void 0;return ye!==pe.e&&re.classList.toggle("hidden",pe.e=ye),Re!==pe.t&&(re.inert=pe.t=Re),pe},{e:void 0,t:void 0}),re}})]}})}})}})),he(re=>{var pe=!!n.general.newLayoutDesigns(),ye=!n.general.newLayoutDesigns(),Re=!!n.general.newLayoutDesigns(),Je=!n.general.newLayoutDesigns();return pe!==re.e&&xe.classList.toggle("bg-v2-background-bg-base",re.e=pe),ye!==re.t&&xe.classList.toggle("bg-background-base",re.t=ye),Re!==re.a&&Oe.classList.toggle("bg-v2-background-bg-base",re.a=Re),Je!==re.o&&Oe.classList.toggle("bg-background-base",re.o=Je),re},{e:void 0,t:void 0,a:void 0,o:void 0}),xe}}),null),S(fe,h(q,{get when(){return y()},get children(){var xe=lst(),Oe=xe.firstChild;return S(Oe,h(rr,{variant:"pill",get value(){return z()},onChange:W,class:"h-full","data-scope":"filetree",get children(){return[h(rr.List,{get children(){return[h(rr.Trigger,{value:"changes",class:"flex-1",classes:{button:"w-full"},get children(){return h(q,{get when(){return n.general.newLayoutDesigns()},get fallback(){return[we(()=>e.reviewCount())," ",we(()=>i.t(e.reviewCount()===1?"session.review.change.one":"session.review.change.other"))]},get children(){return i.t("session.review.filesChanged",{count:e.reviewCount()})}})}}),h(rr.Trigger,{value:"all",class:"flex-1",classes:{button:"w-full"},get children(){return i.t("session.files.all")}})]}}),h(q,{get when(){return z()==="changes"},get children(){return h(rr.Content,{value:"changes",class:"bg-background-stronger px-3 py-0",get children(){return h(Rr,{get children(){return h(zt,{get when(){return e.hasReview()||!e.diffsReady()},get children(){return h(q,{get when(){return e.diffsReady()},get fallback(){return(()=>{var re=pst();return S(re,()=>i.t("common.loading"),null),S(re,()=>i.t("common.loading.ellipsis"),null),re})()},get children(){return h(zC,{path:"",class:"pt-3",get allowed(){return C()},get kinds(){return E()},draggable:!1,get active(){return e.activeDiff},onFileClick:re=>e.focusReviewDiff(re.path)})}})}})}})}})}}),h(q,{get when(){return z()==="all"},get children(){return h(rr.Content,{value:"all",class:"bg-background-stronger px-3 py-0",get children(){return h(Rr,{get children(){return[h(zt,{get when(){return L()},get children(){return _(i.t("session.files.empty"))}}),h(zt,{when:!0,get children(){return h(zC,{path:"",class:"pt-3",get modified(){return C()},get kinds(){return E()},onFileClick:re=>V(r.tab(re.path))})}})]}})}})}})]}})),S(xe,h(q,{get when(){return y()},get children(){var re=BN();return re.$$pointerdown=()=>e.size.start(),S(re,h(Gf,{direction:"horizontal",edge:"start",get size(){return t.fileTree.width()},min:200,max:480,onResize:pe=>{e.size.touch(),t.fileTree.resize(pe)}})),re}}),null),he(re=>{var pe={"transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] will-change-[width] motion-reduce:transition-none":!e.size.active()},ye=x(),Re={"border-l border-border-weaker-base":p()};return re.e=ct(xe,pe,re.e),ye!==re.t&&Ct(xe,"width",re.t=ye),re.a=ct(Oe,Re,re.a),re},{e:void 0,t:void 0,a:void 0}),xe}}),null),he(xe=>ct(fe,{"border-l border-border-weaker-base":!n.general.newLayoutDesigns()},xe)),fe}})),he(fe=>{var xe=i.t("session.panel.reviewAndFiles"),Oe=!v(),re=!v(),pe={"bg-v2-background-bg-base":n.general.newLayoutDesigns(),"bg-background-base":!n.general.newLayoutDesigns(),"h-full shrink-0":!e.stacked,"h-full min-h-0":e.stacked,"pointer-events-none":!v(),"transition-[width] duration-[240ms] ease-[cubic-bezier(0.22,1,0.36,1)] will-change-[width] motion-reduce:transition-none":!e.size.active()&&!e.reviewSnap,"rounded-[10px] shadow-[var(--v2-elevation-raised)] overflow-hidden":n.general.newLayoutDesigns(),"flex-1":p()},ye=w();return xe!==fe.e&&me(G,"aria-label",fe.e=xe),Oe!==fe.t&&me(G,"aria-hidden",fe.t=Oe),re!==fe.a&&(G.inert=fe.a=re),fe.o=ct(G,pe,fe.o),ye!==fe.i&&Ct(G,"width",fe.i=ye),fe},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),G}})}dn(["pointerdown","click"]);function yst(e){return{visible:e.review||e.terminal||e.files,stacked:e.review&&e.terminal}}var bst=A("<div data-slot=session-review-v2-empty-changes><div data-slot=session-review-v2-empty-changes-title></div><div data-slot=session-review-v2-empty-changes-description>");function wst(){const e=Mn();return(()=>{var t=bst(),n=t.firstChild,r=n.nextSibling;return S(t,h(on,{name:"review",size:"large"}),n),S(n,()=>e.t("ui.sessionReviewV2.empty.changes.title")),S(r,()=>e.t("ui.sessionReviewV2.empty.changes.description")),t})()}var xst=A("<div data-slot=session-review-v2-empty-no-git><div data-slot=session-review-v2-empty-no-git-title></div><div data-slot=session-review-v2-empty-no-git-description>");function kst(e){const t=Mn();return(()=>{var n=xst(),r=n.firstChild,i=r.nextSibling;return S(n,h(Dr,{node:{path:".gitignore",type:"file"},mono:!0}),r),S(r,()=>t.t("ui.sessionReviewV2.empty.noGit.title")),S(i,()=>t.t("ui.sessionReviewV2.empty.noGit.description")),S(n,h(as,{variant:"neutral",size:"normal",get disabled(){return e.pending},get onClick(){return e.onInitGit},get children(){return we(()=>!!e.pending)()?t.t("ui.sessionReviewV2.empty.noGit.actionLoading"):t.t("ui.sessionReviewV2.empty.noGit.action")}}),null),n})()}var Sst=A("<div data-component=diff-changes><span data-slot=diff-changes-additions></span><span data-slot=diff-changes-deletions>");function ZI(e){const t=I(()=>Array.isArray(e.changes)?e.changes.reduce((i,s)=>i+(s.additions??0),0):e.changes.additions),n=I(()=>Array.isArray(e.changes)?e.changes.reduce((i,s)=>i+(s.deletions??0),0):e.changes.deletions),r=I(()=>(t()??0)+(n()??0));return h(q,{get when(){return r()>0},get children(){var i=Sst(),s=i.firstChild,o=s.nextSibling;return S(s,()=>`+${t()}`),S(o,()=>`-${n()}`),he(a=>ct(i,{[e.class??""]:!0},a)),i}})}const Cst=500;function _st(e){return Math.max(e.additionLines,e.deletionLines)>Cst}var Tst=A("<div>"),Est=A("<span data-slot=session-review-v2-file-path>"),Ist=A("<div data-slot=session-review-v2-file-header><div data-slot=session-review-v2-file-title><div data-slot=session-review-v2-file-status></div><span data-slot=session-review-v2-file-name></span></div><div data-slot=session-review-v2-file-diff>"),Dst=A("<div data-slot=session-review-v2-diff-scroll>"),Lst=A('<div data-slot=session-review-v2-empty><span class="text-12-regular text-text-weak">');function Ast(e){return e==="added"?"A":e==="deleted"?"D":"M"}function Mst(e){return e==="added"?"added":e==="deleted"?"deleted":"modified"}function Kre(e){return e.endSide??e.side??"additions"}function ZN(e,t){const n=Kre(t),r=U2(e,n);if(r.length!==0)return Ag(r,t)}function $st(e){return(()=>{var t=Tst();return t.$$click=n=>n.stopPropagation(),t.$$mousedown=n=>n.stopPropagation(),S(t,h(Tt,{gutter:4,get children(){return[h(Tt.Trigger,{as:"button",type:"button","data-slot":"line-comment-v2-overflow",get"aria-label"(){return e.labels.moreLabel},get children(){return h(Cre,{})}}),h(Tt.Portal,{get children(){return h(Tt.Content,{get children(){return[h(Tt.Item,{get onSelect(){return e.onEdit},get children(){return e.labels.editLabel}}),h(Tt.Item,{get onSelect(){return e.onDelete},get children(){return e.labels.deleteLabel}})]}})}})]}})),t})()}function Pst(e){const t=Mn(),n=_d();let r,i=0;const[s,o]=Ze({selection:null,commenting:null,opened:null}),a=I(()=>({...i3(e.diff),preloaded:"preloaded"in e.diff?e.diff.preloaded:void 0})),l=I(()=>a().additions!==0||a().deletions!==0),c=I(()=>c9(e.file)),u=I(()=>(e.comments??[]).filter(y=>y.file===e.file)),d=I(()=>u().map(y=>y.selection)),f=()=>e.onLineComment!=null,m=Tre({comments:u,label:t.t("ui.lineComment.submit"),draftKey:()=>e.file,state:{opened:()=>s.opened,setOpened:y=>o("opened",y),selected:()=>s.selection,setSelected:y=>o("selection",y),commenting:()=>s.commenting,setCommenting:y=>o("commenting",y)},getSide:Kre,onSubmit:({comment:y,selection:v})=>{e.onLineComment?.({file:e.file,selection:v,comment:y,preview:ZN(a(),v)})},onUpdate:({id:y,comment:v,selection:b})=>{e.onLineCommentUpdate?.({id:y,file:e.file,selection:b,comment:v,preview:ZN(a(),b)})},onDelete:y=>{e.onLineCommentDelete?.({id:y.id,file:e.file})},editSubmitLabel:e.lineCommentActions?.saveLabel,renderCommentActions:e.lineCommentActions?(y,v)=>h($st,{get labels(){return e.lineCommentActions},get onEdit(){return v.edit},get onDelete(){return v.remove}}):void 0});Te(()=>{i++}),ae(()=>{const y=e.focusedComment;if(y){if(y.file!==e.file){Wt(()=>{const v=i;requestAnimationFrame(()=>{v===i&&e.onFocusedCommentChange?.(null)})});return}Wt(()=>{o("opened",y.id);const v=(e.comments??[]).find(x=>x.file===y.file&&x.id===y.id);v&&o("selection",tc(v.selection)),i++;const b=i,w=x=>{if(b!==i)return;const k=r?.querySelector(`[data-comment-id="${y.id}"]`);if(k instanceof HTMLElement){k.scrollIntoView({block:"center"});return}x>=120||requestAnimationFrame(()=>w(x+1))};requestAnimationFrame(()=>w(0)),requestAnimationFrame(()=>{b===i&&e.onFocusedCommentChange?.(null)})})}});const g=()=>e.expandMode==="expand",p=()=>h(Gi,{component:n,mode:"diff",get fileDiff(){return a().fileDiff},get preloadedDiff(){return a().preloaded},get diffStyle(){return e.diffStyle},get expandUnchanged(){return g()},get virtualize(){return _st({additionLines:a().fileDiff.additionLines.length,deletionLines:a().fileDiff.deletionLines.length})},get hunkSeparators(){return a().fileDiff.isPartial?"simple":"line-info-basic"},get enableLineSelection(){return f()},get enableGutterUtility(){return f()},onLineSelected:y=>{f()&&m.onLineSelected(y)},onLineSelectionEnd:y=>{f()&&m.onLineSelectionEnd(y)},get onLineNumberSelectionEnd(){return m.onLineNumberSelectionEnd},get annotations(){return m.annotations()},get renderAnnotation(){return m.renderAnnotation},get renderGutterUtility(){return we(()=>!!f())()?m.renderGutterUtility:void 0},get selectedLines(){return s.selection},get commentedLines(){return d()},get media(){return{mode:"auto",path:e.file,deleted:a().status==="deleted",readFile:a().status==="deleted"?void 0:e.readFile}}});return[(()=>{var y=Ist(),v=y.firstChild,b=v.firstChild,w=b.nextSibling,x=v.nextSibling;return S(b,()=>Ast(a().status)),S(v,h(Dr,{get node(){return{path:e.file,type:"file"}}}),w),S(w,()=>fn(e.file)),S(v,h(q,{get when(){return e.file.includes("/")},get children(){var k=Est();return S(k,()=>hc(e.file)),k}}),null),S(x,h(ZI,{get changes(){return a()}})),he(()=>me(b,"data-type",Mst(a().status))),y})(),(()=>{var y=Dst();return pt(v=>{r=v},y),S(y,h(q,{get when(){return l()||c()},get fallback(){return(()=>{var v=Lst(),b=v.firstChild;return S(b,()=>t.t("ui.fileMedia.binary.title")),v})()},get children(){return p()}})),y})()]}dn(["mousedown","click"]);var YN=A('<div class="px-2 py-2 text-12-regular text-text-weak">');function Ost(e){const t=kr(),n=I(()=>e.diffs().filter(Uit)),r=I(()=>Git(n().map(m=>m.file),e.state.filter())),i=I(()=>e.state.filter().trim().length>0),s=I(()=>Kit(n())),o=I(()=>new Map([...s()].filter(([,m])=>m!=="mix"))),a=I(()=>{const m=e.focusedComment;if(m&&n().some(y=>y.file===m.file))return m.file;const g=e.activeFile;if(i())return g;const p=r();return g&&p.includes(g)?g:p[0]}),l=I(()=>n().find(m=>m.file===a())),c=I(()=>{const m=l(),g=e.loadDiff;if(!(!m||!g||!qre(m)))return{diff:m,load:g,version:e.diffVersion}}),[u]=ai(c,async({diff:m,load:g,version:p})=>{const y=await g(m.file,p);if(y?.file===m.file)return{source:m,version:p,value:y}}),d=I(()=>{const m=l();if(u.state!=="ready")return m;const g=u();return g&&g.source===m&&g.version===e.diffVersion?g.value:m}),f=async m=>t().client.file.read({path:m}).then(g=>g.data).catch(g=>{console.debug("[session-review-v2] failed to read file",{path:m,error:g})});return h(Pit,{get title(){return e.title},get stats(){return h(ZI,{get changes(){return n()}})},get empty(){return e.empty},get sidebarOpen(){return e.state.sidebarOpened()},get sidebar(){return h(Rst,{get title(){return e.title},get state(){return e.state},get diffsReady(){return e.diffsReady},get onSelectFile(){return e.onSelectFile},diffs:n,filteredFiles:r,searching:i,kinds:o,activeDiff:a})},get activeFile(){return a()},get files(){return r()},get onSelectFile(){return e.onSelectFile},get diffStyle(){return e.diffStyle},get onDiffStyleChange(){return e.onDiffStyleChange},get expandMode(){return e.state.expandMode()},get onExpandModeChange(){return e.state.setExpandMode},get hasDiffs(){return n().length>0},get preview(){return h(q,{get when(){return a()},keyed:!0,children:m=>h(q,{get when(){return d()},children:g=>h(Pst,{file:m,get diff(){return g()},get diffStyle(){return e.diffStyle},get expandMode(){return e.state.expandMode()},readFile:f,get onLineComment(){return e.onLineComment},get onLineCommentUpdate(){return e.onLineCommentUpdate},get onLineCommentDelete(){return e.onLineCommentDelete},get lineCommentActions(){return e.lineCommentActions},get comments(){return e.comments},get focusedComment(){return e.focusedComment},get onFocusedCommentChange(){return e.onFocusedCommentChange}})})})}})}function Rst(e){const t=wt(),[n,r]=De(),i=I(()=>{if(!e.searching())return;const o=e.filteredFiles();if(o.length===0)return;const a=n();return a&&o.includes(a)?a:o[0]});return h(Fre,{get open(){return e.state.sidebarOpened()},get transition(){return e.state.sidebarTransition()},get title(){return e.title},get stats(){return h(ZI,{get changes(){return e.diffs()}})},get filter(){return e.state.filter()},get onFilterChange(){return e.state.setFilter},onFilterKeyDown:o=>{e.searching()&&Ure(o,e.filteredFiles(),i(),{onHighlight:r,onSelect:e.onSelectFile})},get width(){return e.state.sidebarWidth()},get onWidthChange(){return e.state.resizeSidebar},minWidth:KI,maxWidth:GI,get children(){return h(q,{get when(){return e.diffsReady()},get fallback(){return(()=>{var o=YN();return S(o,()=>t.t("common.loading"),null),S(o,()=>t.t("common.loading.ellipsis"),null),o})()},get children(){return h(q,{get when(){return e.searching()},get fallback(){return h(jre,{get allowed(){return e.filteredFiles()},get kinds(){return e.kinds()},draggable:!1,get active(){return e.activeDiff()},onFileClick:o=>e.onSelectFile(o.path)})},get children(){return h(q,{get when(){return e.filteredFiles().length>0},get fallback(){return(()=>{var o=YN();return S(o,()=>t.t("palette.empty")),o})()},get children(){return h(Wre,{get files(){return e.filteredFiles()},get kinds(){return e.kinds()},get active(){return e.activeDiff()},get highlighted(){return i()},onFileClick:o=>{r(o),e.onSelectFile(o)}})}})}})}})}})}function Fst(){const[e,t,,n]=_r(Jn.global("review-panel-v2"),Ze({sidebarOpened:!0,sidebarWidth:jC,expandMode:"collapse"})),[r,i]=De("");return{sidebarOpened:()=>e.sidebarOpened,sidebarWidth:()=>e.sidebarWidth,sidebarTransition:n,filter:r,setFilter:i,expandMode:()=>e.expandMode,setExpandMode:s=>t("expandMode",s),resizeSidebar:s=>t("sidebarWidth",Math.min(GI,Math.max(KI,s))),toggleSidebar:()=>t("sidebarOpened",s=>!s)}}const p1=e=>typeof e=="object"&&e!==null,s6=e=>!(!p1(e)||typeof e.length!="number"||typeof e.cursorX!="number"||typeof e.cursorY!="number"||typeof e.baseY!="number"||typeof e.viewportY!="number"||typeof e.getLine!="function"||typeof e.getNullCell!="function"),XN=e=>{if(!p1(e))return;const t=e.buffer;if(!p1(t))return;const n=s6(t.active)?t.active:void 0,r=s6(t.normal)?t.normal:void 0,i=s6(t.alternate)?t.alternate:void 0;if(!(!n&&!r))return{active:n,normal:r,alternate:i}},Nst=(e,t)=>{if(!p1(e))return!1;const n=e.wasmTerm;return!p1(n)||typeof n.getMode!="function"?!1:n.getMode(t)===!0};function qC(e,t,n){return Math.max(t,Math.min(e,n))}function Vst(e,t){return e.getFgColorMode()===t.getFgColorMode()&&e.getFgColor()===t.getFgColor()}function zst(e,t){return e.getBgColorMode()===t.getBgColorMode()&&e.getBgColor()===t.getBgColor()}function Hst(e,t){return!!e.isInverse()==!!t.isInverse()&&!!e.isBold()==!!t.isBold()&&!!e.isUnderline()==!!t.isUnderline()&&!!e.isBlink()==!!t.isBlink()&&!!e.isInvisible()==!!t.isInvisible()&&!!e.isItalic()==!!t.isItalic()&&!!e.isDim()==!!t.isDim()&&!!e.isStrikethrough()==!!t.isStrikethrough()}class jst{constructor(t){this._buffer=t}serialize(t,n){let r=this._buffer.getNullCell();const i=t.start.y,s=t.end.y,o=t.start.x,a=t.end.x;this._beforeSerialize(s-i+1,i,s);for(let l=i;l<=s;l++){const c=this._buffer.getLine(l);if(c){const u=l===t.start.y?o:0,d=Math.min(a,c.length);for(let f=u;f<d;f++){const m=c.getCell(f);m&&(this._nextCell(m,r,l,f),r=m)}}this._rowEnd(l,l===s)}return this._afterSerialize(),this._serializeString(n)}_nextCell(t,n,r,i){}_rowEnd(t,n){}_beforeSerialize(t,n,r){}_afterSerialize(){}_serializeString(t){return""}}class qst extends jst{constructor(t,n){super(t),this._terminal=n,this._cursorStyle=this._buffer.getNullCell()}_rowIndex=0;_allRows=[];_allRowSeparators=[];_currentRow="";_nullCellCount=0;_cursorStyle;_firstRow=0;_lastCursorRow=0;_lastCursorCol=0;_lastContentCursorRow=0;_lastContentCursorCol=0;_beforeSerialize(t,n,r){this._allRows=Array.from({length:t}),this._allRowSeparators=Array.from({length:t}),this._rowIndex=0,this._currentRow="",this._nullCellCount=0,this._cursorStyle=this._buffer.getNullCell(),this._lastContentCursorRow=n,this._lastCursorRow=n,this._firstRow=n}_rowEnd(t,n){let r="";const s=!!(n?void 0:this._buffer.getLine(t+1))?.isWrapped;this._nullCellCount>0&&s&&(this._currentRow+=" ".repeat(this._nullCellCount)),this._nullCellCount=0,!n&&!s&&(r=`\r
1183
1183
  `,this._lastCursorRow=t+1,this._lastCursorCol=0),this._allRows[this._rowIndex]=this._currentRow,this._allRowSeparators[this._rowIndex++]=r,this._currentRow="",this._nullCellCount=0}_diffStyle(t,n){const r=[],i=!Vst(t,n),s=!zst(t,n),o=!Hst(t,n);if(i||s||o)if(this._isAttributeDefault(t))this._isAttributeDefault(n)||r.push(0);else{if(o&&(!!t.isInverse()!=!!n.isInverse()&&r.push(t.isInverse()?7:27),!!t.isBold()!=!!n.isBold()&&r.push(t.isBold()?1:22),!!t.isUnderline()!=!!n.isUnderline()&&r.push(t.isUnderline()?4:24),!!t.isBlink()!=!!n.isBlink()&&r.push(t.isBlink()?5:25),!!t.isInvisible()!=!!n.isInvisible()&&r.push(t.isInvisible()?8:28),!!t.isItalic()!=!!n.isItalic()&&r.push(t.isItalic()?3:23),!!t.isDim()!=!!n.isDim()&&r.push(t.isDim()?2:22),!!t.isStrikethrough()!=!!n.isStrikethrough()&&r.push(t.isStrikethrough()?9:29)),i){const a=t.getFgColor(),l=t.getFgColorMode();l===2||l===3||l===-1?r.push(38,2,a>>>16&255,a>>>8&255,a&255):l===1?a>=16?r.push(38,5,a):r.push(a&8?90+(a&7):30+(a&7)):r.push(39)}if(s){const a=t.getBgColor(),l=t.getBgColorMode();l===2||l===3||l===-1?r.push(48,2,a>>>16&255,a>>>8&255,a&255):l===1?a>=16?r.push(48,5,a):r.push(a&8?100+(a&7):40+(a&7)):r.push(49)}}return r}_isAttributeDefault(t){const n=t.getFgColorMode(),r=t.getBgColorMode();if(n===0&&r===0)return!t.isBold()&&!t.isItalic()&&!t.isUnderline()&&!t.isBlink()&&!t.isInverse()&&!t.isInvisible()&&!t.isDim()&&!t.isStrikethrough();const i=t.getFgColor(),s=t.getBgColor(),o=this._buffer.getNullCell(),a=o.getFgColor(),l=o.getBgColor();return i===a&&s===l&&!t.isBold()&&!t.isItalic()&&!t.isUnderline()&&!t.isBlink()&&!t.isInverse()&&!t.isInvisible()&&!t.isDim()&&!t.isStrikethrough()}_nextCell(t,n,r,i){if(t.getWidth()===0)return;const o=t.getCode(),l=o>1114111||o>=55296&&o<=57343||o>=61440&&t.getWidth()===1,c=o===0||t.getChars()===""||l,u=this._diffStyle(t,this._cursorStyle);if(u.length>0){this._nullCellCount>0&&(this._currentRow+=" ".repeat(this._nullCellCount),this._nullCellCount=0),this._lastContentCursorRow=this._lastCursorRow=r,this._lastContentCursorCol=this._lastCursorCol=i,this._currentRow+=`\x1B[${u.join(";")}m`;const m=this._buffer.getLine(r)?.getCell(i);m&&(this._cursorStyle=m)}c?this._nullCellCount+=t.getWidth():(this._nullCellCount>0&&(this._currentRow+=" ".repeat(this._nullCellCount),this._nullCellCount=0),this._currentRow+=t.getChars(),this._lastContentCursorRow=this._lastCursorRow=r,this._lastContentCursorCol=this._lastCursorCol=i+t.getWidth())}_serializeString(t){let n=this._allRows.length;this._buffer.length-this._firstRow<=this._terminal.rows&&(n=this._lastContentCursorRow+1-this._firstRow,this._lastCursorCol=this._lastContentCursorCol,this._lastCursorRow=this._lastContentCursorRow);let r="";for(let d=0;d<n;d++)r+=this._allRows[d],d+1<n&&(r+=this._allRowSeparators[d]);if(t)return r;const i=(this._buffer.baseY??0)+this._buffer.cursorY,s=qC(i-this._firstRow+1,1,Number.MAX_SAFE_INTEGER),o=this._buffer.cursorX+1;r+=`\x1B[${s};${o}H`;const a=this._buffer.getLine(i),l=a?.getCell(this._buffer.cursorX),c=l?l.getWidth()!==0?l:this._buffer.cursorX>0?a?.getCell(this._buffer.cursorX-1)??l:l:this._buffer.getNullCell(),u=this._diffStyle(c,this._cursorStyle);return u.length&&(r+=`\x1B[${u.join(";")}m`),r}}class Bst{_terminal;activate(t){this._terminal=t}dispose(){this._terminal=void 0}serialize(t){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");const n=XN(this._terminal);if(!n)return"";const r=n.normal??n.active,i=n.alternate;if(!r)return"";let s=!t?.excludeModes&&Nst(this._terminal,2031)?"\x1B[?2031h":"";if(s+=t?.range?this._serializeBufferByRange(r,t.range,!0):this._serializeBufferByScrollback(r,t?.scrollback),!t?.excludeAltBuffer&&n.active?.type==="alternate"&&i){const o=this._serializeBufferByScrollback(i,void 0);s+=`\x1B[?1049h\x1B[H${o}`}return s}serializeAsText(t){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");const n=XN(this._terminal);if(!n)return"";const r=n.active??n.normal;if(!r)return"";const i=r.length,s=t?.scrollback,o=s===void 0?i:qC(s+this._terminal.rows,0,i),a=i-o,l=i-1,c=[];for(let u=a;u<=l;u++){const d=r.getLine(u);if(d){const f=d.translateToString(t?.trimWhitespace??!0);c.push(f)}}if(t?.trimWhitespace)for(;c.length>0&&c[c.length-1]==="";)c.pop();return c.join(`
1184
1184
  `)}_serializeBufferByScrollback(t,n){const r=t.length,i=this._terminal?.rows??24,s=n===void 0?r:qC(n+i,0,r);return this._serializeBufferByRange(t,{start:r-s,end:r-1},!1)}_serializeBufferByRange(t,n,r){const i=new qst(t,this._terminal),s=this._terminal?.cols??80;return i.serialize({start:{x:0,y:n.start},end:{x:s,y:n.end}},r)}}const jx=e=>typeof e=="object"&&e!==null,Ust=e=>jx(e)&&typeof e.dispose=="function",s2=e=>{Ust(e)&&e.dispose()},Wst=e=>jx(e)&&typeof e.setOption=="function",o2=(e,t,n)=>{Wst(e)&&e.setOption(t,n)},Kst=e=>{if(!jx(e))return;const t=e.currentHoveredLink;if(jx(t)&&typeof t.text=="string")return t.text};function Gst(e,t=queueMicrotask){let n,r,i=!1,s=!1;const o=()=>{if(i||s||n?.length)return;const u=r;if(u?.length){r=void 0;for(const d of u)d()}},a=()=>{if(s)return;i=!1;const u=n;if(!u?.length){o();return}n=void 0,s=!0,e(u.join(""),()=>{if(s=!1,n?.length){if(i)return;i=!0,t(a);return}o()})};return{push:u=>{u&&(n?n.push(u):n=[u],!(i||s)&&(i=!0,t(a)))},flush:u=>{if(!i&&!s&&!n?.length){u?.();return}u&&(r?r.push(u):r=[u]),a()}}}function Zst(e){const t=e.protocol==="v1",n=new URL(`${e.url}${t?`/pty/${e.id}/connect`:`/api/pty/${e.id}/connect`}`);return t?n.searchParams.set("directory",e.directory):n.searchParams.set("location[directory]",e.directory),n.searchParams.set("cursor",String(e.cursor)),n.protocol=n.protocol==="https:"?"wss:":"ws:",e.ticket?(n.searchParams.set("ticket",e.ticket),n):(t&&e.password&&(!e.sameOrigin||e.authToken)&&n.searchParams.set("auth_token",z1({username:e.username,password:e.password})),n)}var Yst=A("<div data-component=terminal data-prevent-autofocus tabindex=-1>");const Xst="terminal.toggle",Qst="ctrl+`";let B0;const Jst=()=>B0||(B0=B(()=>import("./ghostty-web-B1eWozHJ.js"),[]).then(async e=>({mod:e,ghostty:await e.Ghostty.load()})).catch(e=>{throw B0=void 0,e}),B0),eot={light:{background:"#fcfcfc",foreground:"#211e1e",cursor:"#211e1e",selectionBackground:Nl("#211e1e",.2)},dark:{background:"#191515",foreground:"#d4d4d4",cursor:"#d4d4d4",selectionBackground:Nl("#d4d4d4",.25)}},tot=(e,t)=>{let n=e[t];for(let r=0;r<8&&n;r++){const i=/^var\(--([^)]+)\)$/.exec(n.trim());if(!i){const s=n.trim();return/^#[0-9a-fA-F]{8}$/.test(s)?s.slice(0,7):s}n=e[i[1]]}},not=e=>{const t=s=>{const o=e.term.getSelection();if(!o)return;const a=s.clipboardData;a&&(s.preventDefault(),a.setData("text/plain",o))},n=s=>{const o=s.clipboardData,a=o?.getData("text/plain")??o?.getData("text")??"";a&&(s.preventDefault(),s.stopPropagation(),e.term.paste(a))},r=()=>{e.term.options.cursorBlink=!0},i=()=>{e.term.options.cursorBlink=!1};e.container.addEventListener("copy",t,!0),e.cleanups.push(()=>e.container.removeEventListener("copy",t,!0)),e.container.addEventListener("paste",n,!0),e.cleanups.push(()=>e.container.removeEventListener("paste",n,!0)),e.container.addEventListener("pointerdown",e.handlePointerDown),e.cleanups.push(()=>e.container.removeEventListener("pointerdown",e.handlePointerDown)),e.container.addEventListener("click",e.handleLinkClick,{capture:!0}),e.cleanups.push(()=>e.container.removeEventListener("click",e.handleLinkClick,{capture:!0})),e.term.textarea?.addEventListener("focus",r),e.term.textarea?.addEventListener("blur",i),e.cleanups.push(()=>e.term.textarea?.removeEventListener("focus",r)),e.cleanups.push(()=>e.term.textarea?.removeEventListener("blur",i))},rot=e=>{if(!e.addon||!e.onCleanup||!e.term)return;const t=(()=>{try{return e.addon.serialize()}catch{return""}})();e.onCleanup({id:e.id,buffer:t,cursor:e.cursor,rows:e.term.rows,cols:e.term.cols,scrollY:e.term.getViewportY()})},Gre=e=>{const t=Tr(),n=kr(),r=ar(),i=h9(),s=wt(),o=xs()().server,a=n().directory,l=n().url,c=o.http,u=c?.username??"opencode",d=c?.password??"",f=o.type==="http"?o.authToken:!1,m=new URL(l,location.href).origin===location.origin;let g;const[p,y]=Ee(e,["pty","class","classList","autoFocus","onAutoFocus","onConnect","onConnectError"]),v=p.pty.id,b=typeof p.pty.buffer=="string"?p.pty.buffer:"",w=b&&typeof p.pty.cols=="number"&&Number.isSafeInteger(p.pty.cols)&&p.pty.cols>0&&typeof p.pty.rows=="number"&&Number.isSafeInteger(p.pty.rows)&&p.pty.rows>0?{cols:p.pty.cols,rows:p.pty.rows}:void 0,x=typeof p.pty.scrollY=="number"?p.pty.scrollY:void 0;let k,C,E,_,L,O,$,V,P,T=!1;const D=[],N=typeof p.pty.cursor=="number"&&Number.isSafeInteger(p.pty.cursor)?p.pty.cursor:void 0;let M=N??0,F=N!==void 0?N:b?-1:0,j,z,W,J=0;const K=()=>{if(!D.length)return;const de=D.splice(0).reverse();for(const U of de)try{U()}catch{}},X=async(de,U)=>await n().protocol==="v1"?n().client.pty.update({ptyID:v,size:{cols:de,rows:U}}).catch(He=>{}):n().api.pty.update({ptyID:v,location:{directory:a},size:{cols:de,rows:U}}).catch(He=>{}),ve=I(()=>{const de=i.mode()==="dark"?"dark":"light",U=eot[de],He=i.themes()[i.themeId()];if(!He)return U;const Ue=de==="dark"?He.dark:He.light;if(!Ue?.seeds&&!Ue?.palette)return U;const Z=u9(Ue,de==="dark"),ce=Z["text-stronger"]??U.foreground,G=r.general.newLayoutDesigns()?tot(f9(Ue,de==="dark"),"v2-background-bg-base")??U.background:Z["background-stronger"]??U.background,fe=de==="dark"?.25:.2,xe=ce.startsWith("#")?ce:U.foreground,Oe=Nl(xe,fe);return{background:G,foreground:ce,cursor:ce,selectionBackground:Oe}}),ne=()=>{T||_&&O===void 0&&(O=requestAnimationFrame(()=>{O=void 0,!T&&_.fit()}))},ie=(de,U)=>{if(!T){if(P?.cols===de&&P?.rows===U){V=void 0,$!==void 0&&clearTimeout($),$=void 0;return}if(V={cols:de,rows:U},!P){P=V,X(de,U);return}$===void 0&&($=setTimeout(()=>{$=void 0;const He=V;He&&(V=void 0,!T&&(P?.cols===He.cols&&P?.rows===He.rows||(P=He,X(He.cols,He.rows))))},100))}};ae(()=>{const de=ve(),U=i.mode()==="dark"?"dark":"light";C&&(o2(C,"theme",de),o2(C,"colorScheme",U))}),ae(()=>{const de=p$(r.appearance.terminalFont());C&&(o2(C,"fontFamily",de),ne())});let ke=t.webviewZoom?.();ae(()=>{const de=t.webviewZoom?.();de!==void 0&&de!==ke&&(ke=de,ne())});const ge=()=>{const de=C;de&&(de.focus(),de.textarea?.focus(),setTimeout(()=>de.textarea?.focus(),0))},Pe=()=>{const de=document.activeElement;de instanceof HTMLElement&&de!==g&&!g.contains(de)&&de.blur(),ge()},Me=de=>{if(!de.shiftKey&&!de.ctrlKey&&!de.metaKey||de.altKey||de.button!==0)return;const U=C;if(!U)return;const He=Kst(U);He&&(de.preventDefault(),de.stopImmediatePropagation(),t.openLink(He))};return sn(()=>{(async()=>{const U=await Jst();if(T)return;const He=U.mod,Ue=U.ghostty,Z=new He.Terminal({cursorBlink:!0,cursorStyle:"bar",cols:w?.cols,rows:w?.rows,fontSize:14,fontFamily:p$(r.appearance.terminalFont()),allowTransparency:!1,convertEol:!1,theme:ve(),scrollback:1e4,ghostty:Ue});if(D.push(()=>Z.dispose()),T){K();return}C=Z,o2(Z,"colorScheme",i.mode()==="dark"?"dark":"light"),j=Gst((Qe,Be)=>Z.write(Qe,()=>{Be?.()})),Z.attachCustomKeyEventHandler(Qe=>{const Be=Qe.key.toLowerCase();if(Qe.ctrlKey&&Qe.shiftKey&&!Qe.metaKey&&Be==="c")return document.execCommand("copy"),!0;const et=r.keybinds.get(Xst)??Qst,un=Yw(et);return G3e(un,Qe)});const ce=new He.FitAddon,G=new Bst;D.push(()=>s2(ce)),Z.loadAddon(G),Z.loadAddon(ce),_=ce,E=G;const fe=document.activeElement;if(Z.open(g),not({container:g,term:Z,cleanups:D,handlePointerDown:Pe,handleLinkClick:Me}),p.autoFocus===!0&&(ge(),p.onAutoFocus?.()),p.autoFocus!==!0){const Qe=()=>{const et=document.activeElement;et!==g&&!g.contains(et)||(Z.blur(),Z.textarea?.blur(),fe instanceof HTMLElement&&fe.isConnected&&fe.focus())};Qe();const Be=setTimeout(Qe,0);D.push(()=>clearTimeout(Be))}typeof document<"u"&&document.fonts&&document.fonts.ready.then(ne);const xe=Z.onResize(Qe=>{ie(Qe.cols,Qe.rows)});D.push(()=>s2(xe));const Oe=Z.onData(Qe=>{k?.readyState===WebSocket.OPEN&&k.send(Qe)});D.push(()=>s2(Oe));const re=Z.onKey(Qe=>{Qe.key=="Enter"&&e.onSubmit?.()});D.push(()=>s2(re));const pe=()=>{ce.observeResize(),L=ne,window.addEventListener("resize",L),D.push(()=>window.removeEventListener("resize",L))},ye=Qe=>new Promise(Be=>{if(!j){Be();return}j.push(Qe),j.flush(Be)});b&&w?(await ye(b),ce.fit(),ie(Z.cols,Z.rows),x!==void 0&&Z.scrollToLine(x),pe()):(ce.fit(),ie(Z.cols,Z.rows),b&&(await ye(b),x!==void 0&&Z.scrollToLine(x)),pe());const Re={value:!1},Je=new TextDecoder,Xe=Qe=>{T||Re.value||(Re.value=!0,p.onConnectError?.(Qe))},je=async()=>await n().protocol==="v1"?n().client.pty.get({ptyID:v},{throwOnError:!1}).then(Qe=>Qe.response.status===404).catch(Qe=>!1):n().api.pty.get({ptyID:v,location:{directory:a}}).then(Qe=>Qe.data.status==="exited").catch(Qe=>!!(Qe&&typeof Qe=="object"&&"_tag"in Qe&&Qe._tag==="PtyNotFoundError")),mt=async()=>{if(await n().protocol==="v1"){const Qe=await n().client.pty.connectToken({ptyID:v,directory:a},{throwOnError:!1,headers:{"x-opencode-ticket":"1"}}).catch(Be=>{if(!(Be instanceof Error&&Be.message.includes("Request is not supported")))throw Be});if(!Qe)return;if(Qe.response.status===200&&Qe.data?.ticket)return Qe.data.ticket;if(Qe.response.status===404||Qe.response.status===405)return;throw Qe.response.status===403?new Error("PTY connect ticket rejected by origin or CSRF checks. Check the server CORS config."):new Error(`PTY connect ticket failed with ${Qe.response.status}`)}},Et=Qe=>{if(T||W!==void 0)return;const Be=Math.min(250*2**Math.min(J,4),4e3);W=setTimeout(async()=>{if(W=void 0,!T){if(await je()){if(T)return;Xe(Qe);return}T||(J+=1,Bt())}},Be)},Bt=async()=>{if(T)return;z?.();const Qe=await mt().catch(Lt=>{Xe(Lt)}),Be=await n().protocol;if(Re.value||T)return;const et=new WebSocket(Zst({protocol:Be,url:l,id:v,directory:a,cursor:F,ticket:Qe,sameOrigin:m,username:u,password:d,authToken:f}));et.binaryType="arraybuffer",k=et;const un=()=>{T||(J=0,p.onConnect?.(),ie(Z.cols,Z.rows),Z.getMode(2031)&&Z.write("\x1B[?996n"))},xn=Lt=>{if(T)return;if(Lt.data instanceof ArrayBuffer){const Vn=new Uint8Array(Lt.data);if(Vn[0]!==0)return;const $r=Je.decode(Vn.subarray(1));try{const $n=JSON.parse($r)?.cursor;typeof $n=="number"&&Number.isSafeInteger($n)&&$n>=0&&(M=$n,F=$n)}catch{}return}const Nn=typeof Lt.data=="string"?Lt.data:"";Nn&&(j?.push(Nn),M+=Nn.length,F=M)},In=Lt=>{},Hn=()=>{et.removeEventListener("open",un),et.removeEventListener("message",xn),et.removeEventListener("error",In),et.removeEventListener("close",er),k===et&&(k=void 0),z===Hn&&(z=void 0),et.readyState!==WebSocket.CLOSED&&et.readyState!==WebSocket.CLOSING&&et.close(1e3)},er=Lt=>{k===et&&(k=void 0),z===Hn&&(z=void 0),et.removeEventListener("open",un),et.removeEventListener("message",xn),et.removeEventListener("error",In),et.removeEventListener("close",er),!T&&Lt.code!==1e3&&Et(new Error(s.t("terminal.connectionLost.abnormalClose",{code:Lt.code})))};z=Hn,et.addEventListener("open",un),et.addEventListener("message",xn),et.addEventListener("error",In),et.addEventListener("close",er)};Bt()})().catch(U=>{T||(tn({variant:"error",title:s.t("terminal.connectionLost.title"),description:U instanceof Error?U.message:s.t("terminal.connectionLost.description")}),p.onConnectError?.(U))})}),Te(()=>{T=!0,O!==void 0&&cancelAnimationFrame(O),$!==void 0&&clearTimeout($),W!==void 0&&clearTimeout(W),z?.(),k&&k.readyState!==WebSocket.CLOSED&&k.readyState!==WebSocket.CLOSING&&k.close(1e3);const de=()=>{rot({term:C,addon:E,cursor:M,id:v,onCleanup:e.onCleanup}),K()};if(!j){de();return}j.flush(de)}),(()=>{var de=Yst(),U=g;return typeof U=="function"?pt(U,de):g=de,An(de,le({get style(){return{"background-color":ve().background}},get classList(){return{...p.classList,"select-text":!0,"size-full px-6 py-3 font-mono relative overflow-hidden":!0,[p.class??""]:!!p.class}}},y),!1,!1),de})()},BC=e=>{const t=e.title??"",n=e.titleNumber??0,r=Number.isFinite(n)&&n>0&&Ck(t,n);return t&&!r?t:n>0?e.t("terminal.title.numbered",{number:n}):t||e.t("terminal.title")};var iot=A('<div class="h-full flex items-center justify-center">'),sot=A('<div class="flex flex-col h-full"><div class="flex-1 min-h-0 relative">'),oot=A('<div id=terminal-panel role=region class="relative w-full shrink-0 bg-background-stronger"><div class="hidden md:block"></div><div class="absolute inset-x-0 top-0 flex flex-col overflow-hidden">'),aot=A('<div class="flex flex-col h-full pointer-events-none"><div class="h-10 flex items-center gap-2 px-2 border-b border-border-weaker-base bg-background-stronger overflow-hidden"><div class=flex-1></div><div class="text-text-weak pr-2"></div></div><div class="flex-1 flex items-center justify-center text-text-weak">'),lot=A('<div class="px-2 py-1 rounded-md bg-surface-base text-14-regular text-text-weak truncate max-w-40">'),cot=A('<div class="absolute inset-0">'),uot=A('<div class="relative p-1 h-10 flex items-center bg-background-stronger text-14-regular">');function dot(){const e=[120,240],t=li(),n=bh(),r=kr(),i=wt(),s=Qi(),o=ar(),{workspaceKey:a,view:l}=ga(),c=I(()=>l().terminal.opened()),u=eI(),d=I(()=>t.terminal.height()),f=()=>l().terminal.close();let m;Te(()=>n.cancelFocus());const[g,p]=Ze({autoCreated:!1,activeDraggable:void 0,recovered:{},view:typeof window>"u"?1e3:window.visualViewport?.height??window.innerHeight}),y=()=>g.view*.6,v=()=>Math.min(d(),y());sn(()=>{if(typeof window>"u")return;const V=()=>p("view",window.visualViewport?.height??window.innerHeight),P=window.visualViewport;V(),an(window,"resize",V),P&&an(P,"resize",V)}),ae(()=>{if(!c()){p("autoCreated",!1);return}!n.ready()||n.all().length!==0||g.autoCreated||(n.new(),p("autoCreated",!0))}),ae(vt(()=>n.all().length,(V,P)=>{P===void 0||P<=0||V!==0||c()&&f()}));const b=V=>{Bc(V);const P=requestAnimationFrame(()=>{c()&&n.active()===V&&Bc(V)}),T=e.map(D=>window.setTimeout(()=>{c()&&n.active()===V&&Bc(V)},D));return()=>{cancelAnimationFrame(P);for(const D of T)clearTimeout(D)}};ae(vt(()=>[c(),n.active()],([V,P])=>{if(!V||!P)return;const T=b(P);Te(T)})),ae(()=>{if(c())return;const V=document.activeElement;V instanceof HTMLElement&&m?.contains(V)&&V.blur()}),ae(()=>{r().directory&&n.ready()&&(i.locale(),fY(a(),n.all().map(P=>BC({title:P.title,titleNumber:P.titleNumber,t:i.t}))))});const w=I(()=>r().directory?hY(a())??[]:[]),x=n.all,k=I(()=>x().map(V=>V.id)),C=(V,P,T)=>{g.recovered[V]||(p("recovered",V,!0),T(P))},E=V=>String(V.titleNumber||V.title||V.id),_=(V,P,T)=>{p("recovered",V,!1),T(P)},L=V=>{const P=dg(V);P&&p("activeDraggable",P)},O=V=>{const{draggable:P,droppable:T}=V;if(!P||!T)return;const D=n.all(),N=D.findIndex(F=>F.id===P.id.toString()),M=D.findIndex(F=>F.id===T.id.toString());N!==-1&&M!==-1&&N!==M&&n.move(P.id.toString(),M)},$=()=>{p("activeDraggable",void 0);const V=n.active();V&&requestAnimationFrame(()=>{n.active()===V&&Bc(V)})};return(()=>{var V=oot(),P=V.firstChild,T=P.nextSibling,D=m;return typeof D=="function"?pt(D,V):m=V,P.$$pointerdown=()=>u.start(),S(P,h(Gf,{get classList(){return{"-top-1":o.general.newLayoutDesigns()}},direction:"vertical",get size(){return v()},min:100,get max(){return y()},collapseThreshold:50,onResize:N=>{u.touch(),t.terminal.resize(N)},onCollapse:f})),S(T,h(q,{get when(){return n.ready()},get fallback(){return(()=>{var N=aot(),M=N.firstChild,F=M.firstChild,j=F.nextSibling,z=M.nextSibling;return S(M,h(Dt,{get each(){return w()},children:W=>(()=>{var J=lot();return S(J,W),J})()}),F),S(j,()=>i.t("common.loading"),null),S(j,()=>i.t("common.loading.ellipsis"),null),S(z,()=>i.t("terminal.loading")),N})()},get children(){return h(yk,{onDragStart:L,onDragEnd:$,onDragOver:O,collisionDetector:vk,get children(){return[h(bk,{}),h(pY,{}),(()=>{var N=sot(),M=N.firstChild;return S(N,h(rr,{variant:"alt",get value(){return n.active()},onChange:F=>n.open(F),class:"!h-auto !flex-none",get children(){return h(rr.List,{class:"h-10 border-b border-border-weaker-base",get children(){return[h(kk,{get ids(){return k()},get children(){return h(Dt,{get each(){return x()},children:F=>h(_qe,{terminal:F,onClose:f})})}}),(()=>{var F=iot();return S(F,h(ws,{get title(){return i.t("command.terminal.new")},get keybind(){return s.keybind("terminal.new")},class:"flex items-center",get children(){return h(Ln,{icon:"plus-small",variant:"ghost",iconSize:"large",onClick:()=>n.new(),get"aria-label"(){return i.t("command.terminal.new")}})}})),F})()]}})}}),M),S(M,h(q,{get when(){return we(()=>!!c())()&&n.active()},keyed:!0,children:F=>{const j=n.bind();return h(q,{get when(){return x().find(z=>z.id===F)},children:z=>(()=>{var W=cot();return me(W,"id",`terminal-wrapper-${F}`),S(W,h(Gre,{get pty(){return z()},get autoFocus(){return c()},onAutoFocus:()=>n.consumeFocus(F),onConnect:()=>_(E(z()),F,j.trim),get onCleanup(){return j.update},onConnectError:()=>C(E(z()),F,j.clone)})),W})()})}})),N})(),h(xk,{get children(){return h(q,{get when(){return g.activeDraggable},keyed:!0,children:N=>h(q,{get when(){return x().find(M=>M.id===N)},children:M=>(()=>{var F=uot();return S(F,()=>BC({title:M().title,titleNumber:M().titleNumber,t:i.t})),F})()})})}})]}})}})),he(N=>{var M=i.t("terminal.title"),F=!c(),j=!c(),z={"transition-[height] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] will-change-[height] motion-reduce:transition-none":!u.active()},W=c()?`${v()}px`:"0px",J={"border-t border-border-weak-base":c(),"pointer-events-none":!c()},K=`${v()}px`;return M!==N.e&&me(V,"aria-label",N.e=M),F!==N.t&&me(V,"aria-hidden",N.t=F),j!==N.a&&(V.inert=N.a=j),N.o=ct(V,z,N.o),W!==N.i&&Ct(V,"height",N.i=W),N.n=ct(T,J,N.n),K!==N.s&&Ct(T,"height",N.s=K),N},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0}),V})()}dn(["pointerdown"]);var fot=A("<span class=truncate data-slot=terminal-tab-title>"),hot=A(`<div class="absolute inset-0 flex items-center bg-v2-background-bg-layer-01 z-10 pointer-events-auto rounded-[6px] shadow-[inset_0_0_0_0.5px_var(--v2-border-border-muted)] px-2"><input type=text class="bg-transparent border-none outline-none min-w-0 flex-1 p-0 text-[13px] leading-4 tracking-[-0.04px] text-v2-text-text-base [font-weight:440] [font-variation-settings:'slnt'_0] [font-variant-numeric:tabular-nums]">`),mot=A('<div class="outline-none focus:outline-none focus-visible:outline-none">'),got=A("<span>"),pot=A('<div class="absolute inset-0 flex items-center px-3 bg-muted z-10 pointer-events-auto"><input type=text class="bg-transparent border-none outline-none text-sm min-w-0 flex-1">'),vot=A('<div class="relative h-full">');function yot(e){const t=bh(),n=wt(),r=ay({get id(){return e.terminal.id},get index(){return e.index()}}),[i,s]=Ze({editing:!1,title:e.terminal.title,menuOpen:!1,menuPosition:{x:0,y:0},blurEnabled:!1});let o,a,l=!1;const c=()=>{const v=e.terminal.titleNumber;return!Number.isFinite(v)||v<=0?!1:Ck(e.terminal.title,v)},u=()=>{if(n.locale(),e.terminal.title&&!c())return e.terminal.title;const v=e.terminal.titleNumber;return Number.isFinite(v)&&v>0?n.t("terminal.title.numbered",{number:v}):e.terminal.title?e.terminal.title:n.t("terminal.title")},d=()=>{const v=t.all().length;t.close(e.terminal.id),v===1&&e.onClose?.()},f=()=>{if(i.editing)return;t.requestFocus(e.terminal.id),t.open(e.terminal.id),document.activeElement instanceof HTMLElement&&document.activeElement.blur(),Bc(e.terminal.id),document.getElementById(`terminal-wrapper-${e.terminal.id}`)?.querySelector("textarea")===document.activeElement&&t.consumeFocus(e.terminal.id)},m=v=>{v&&(v.stopPropagation(),v.preventDefault()),s("blurEnabled",!1),s("title",e.terminal.title),s("editing",!0)},g=()=>{if(!i.blurEnabled)return;const v=i.title.trim();v&&v!==e.terminal.title&&t.update({id:e.terminal.id,title:v}),s("editing",!1)},p=v=>{if(v.key==="Enter"){v.preventDefault(),g();return}v.key==="Escape"&&(v.preventDefault(),s("editing",!1))},y=v=>{v.preventDefault(),s("menuPosition",{x:v.clientX,y:v.clientY}),s("menuOpen",!0)};return ae(()=>{i.editing&&o&&(o.focus(),o.select(),a!==void 0&&cancelAnimationFrame(a),a=requestAnimationFrame(()=>{a=void 0,s("blurEnabled",!0)}))}),Te(()=>{a!==void 0&&cancelAnimationFrame(a)}),(()=>{var v=mot(),b=r.ref;return typeof b=="function"?pt(b,v):r.ref=v,S(v,h(q,{get when(){return e.newLayout},get fallback(){return(()=>{var w=vot();return S(w,h(rr.Trigger,{get value(){return e.terminal.id},onClick:f,onMouseDown:x=>x.preventDefault(),onContextMenu:y,class:"!shadow-none",classes:{button:"border-0 outline-none focus:outline-none focus-visible:outline-none !shadow-none !ring-0"},get closeButton(){return h(Ln,{icon:"close",variant:"ghost",onClick:x=>{x.stopPropagation(),d()},get"aria-label"(){return n.t("terminal.close")}})},get children(){var x=got();return x.$$dblclick=m,S(x,u),he(()=>x.classList.toggle("invisible",!!i.editing)),x}}),null),S(w,h(q,{get when(){return i.editing},get children(){var x=pot(),k=x.firstChild;k.$$mousedown=E=>E.stopPropagation(),k.$$keydown=p,k.addEventListener("blur",g),k.$$input=E=>s("title",E.currentTarget.value);var C=o;return typeof C=="function"?pt(C,k):o=k,he(()=>k.value=i.title),x}}),null),S(w,h(at,{get open(){return i.menuOpen},onOpenChange:x=>s("menuOpen",x),get children(){return h(at.Portal,{get children(){return h(at.Content,{class:"fixed",get style(){return{left:`${i.menuPosition.x}px`,top:`${i.menuPosition.y}px`}},onCloseAutoFocus:x=>{l&&(x.preventDefault(),l=!1,requestAnimationFrame(()=>m()))},get children(){return[h(at.Item,{onSelect:()=>l=!0,get children(){return[h(Yt,{name:"edit",class:"w-4 h-4 mr-2"}),we(()=>n.t("common.rename"))]}}),h(at.Item,{onSelect:d,get children(){return[h(Yt,{name:"close",class:"w-4 h-4 mr-2"}),we(()=>n.t("common.close"))]}})]}})}})}}),null),w})()},get children(){return h(Tt.Context,{get children(){return[h(Tt.Context.Trigger,{class:"relative",as:"div",get children(){return[h(rr.Trigger,{get value(){return e.terminal.id},onMouseDown:w=>{w.button===0&&(i.editing||f())},onClick:w=>{w.detail>0||f()},get closeButton(){return h(Ln,{icon:"close-small",variant:"ghost",class:"h-5 w-5",onClick:w=>{w.stopPropagation(),d()},get"aria-label"(){return n.t("terminal.close")}})},hideCloseButton:!0,onMiddleClick:d,get children(){var w=fot();return w.$$dblclick=m,S(w,u),he(()=>w.classList.toggle("invisible",!!i.editing)),w}}),h(q,{get when(){return i.editing},get children(){var w=hot(),x=w.firstChild;x.$$mousedown=C=>C.stopPropagation(),x.$$keydown=p,x.addEventListener("blur",g),x.$$input=C=>s("title",C.currentTarget.value);var k=o;return typeof k=="function"?pt(k,x):o=x,he(()=>x.value=i.title),w}})]}}),h(Tt.Context.Portal,{get children(){return h(Tt.Context.Content,{onCloseAutoFocus:w=>{l&&(w.preventDefault(),l=!1,requestAnimationFrame(()=>m()))},get children(){return[h(Tt.Item,{onSelect:()=>l=!0,get children(){return n.t("common.rename")}}),h(Tt.Item,{onSelect:d,get children(){return n.t("common.close")}})]}})}})]}})}})),he(w=>ct(v,{"h-full flex items-center":e.newLayout,"h-full":!e.newLayout},w)),v})()}dn(["dblclick","input","keydown","mousedown"]);var bot=A('<div class="h-full flex items-center justify-center">'),wot=A('<div class="flex flex-col h-full"><div class="flex-1 min-h-0 relative">'),xot=A('<aside id=terminal-panel role=region class="relative shrink-0 overflow-hidden bg-v2-background-bg-base"><div></div><div class="absolute inset-0 flex flex-col overflow-hidden">'),kot=A('<div class="flex flex-col h-full pointer-events-none"><div class="h-10 flex items-center gap-2 px-2 border-b border-border-weaker-base bg-v2-background-bg-base overflow-hidden"><div class=flex-1></div><div class="text-text-weak pr-2"></div></div><div class="flex-1 flex items-center justify-center text-text-weak">'),Sot=A('<div class="px-2 py-1 rounded-md bg-surface-base text-14-regular text-text-weak truncate max-w-40">'),Cot=A('<div class="absolute inset-0">');function _ot(e={}){const t=li(),n=bh(),r=kr(),i=wt(),s=Qi(),o=ar(),{workspaceKey:a,view:l}=ga(),c=uu("(min-width: 768px)"),u=I(()=>o.general.newLayoutDesigns()),d=I(()=>l().terminal.opened()),f=eI(),m=I(()=>t.terminal.height()),g=()=>l().terminal.close();let p,y;Te(()=>n.cancelFocus());const[v,b]=Ze({autoCreated:!1,recovered:{},view:typeof window>"u"?1e3:window.visualViewport?.height??window.innerHeight}),w=()=>v.view*.6,x=()=>Math.min(m(),w()),k=I(()=>c()&&e.stacked),C=I(()=>c()?k()?`${x()}px`:"100%":d()?`${x()}px`:"0px"),E=I(()=>c()?k()?`${x()}px`:"100%":`${x()}px`),_=I(()=>s.keybindParts("terminal.new"));sn(()=>{if(typeof window>"u")return;const D=()=>b("view",window.visualViewport?.height??window.innerHeight),N=window.visualViewport;D(),an(window,"resize",D),N&&an(N,"resize",D)}),ae(()=>{if(!d()){b("autoCreated",!1);return}!n.ready()||n.all().length!==0||v.autoCreated||(n.new(),b("autoCreated",!0))}),ae(vt(()=>n.all().length,(D,N)=>{N===void 0||N<=0||D!==0||d()&&g()})),ae(vt(()=>[d(),n.active(),n.focusRequested(n.active())],([D,N,M])=>{!D||!N||!M||Bc(N)})),ae(()=>{if(d())return;const D=document.activeElement;D instanceof HTMLElement&&p?.contains(D)&&D.blur()}),ae(()=>{r().directory&&n.ready()&&(i.locale(),fY(a(),n.all().map(N=>BC({title:N.title,titleNumber:N.titleNumber,t:i.t}))))});const L=I(()=>r().directory?hY(a())??[]:[]),O=n.all;I(()=>O().map(D=>D.id));const $=(D,N,M)=>{v.recovered[D]||(b("recovered",D,!0),M(N))},V=D=>String(D.titleNumber||D.title||D.id),P=(D,N,M)=>{b("recovered",D,!1),M(N)},T=()=>{const D=n.active();D&&requestAnimationFrame(()=>{n.active()===D&&Bc(D)})};return(()=>{var D=xot(),N=D.firstChild,M=N.nextSibling,F=p;return typeof F=="function"?pt(F,D):p=D,N.$$pointerdown=()=>f.start(),S(N,h(Gf,{get classList(){return{"-top-1":u()}},direction:"vertical",get size(){return x()},min:100,get max(){return w()},collapseThreshold:50,onResize:j=>{f.touch(),t.terminal.resize(j)},onCollapse:g})),S(M,h(q,{get when(){return n.ready()},get fallback(){return(()=>{var j=kot(),z=j.firstChild,W=z.firstChild,J=W.nextSibling,K=z.nextSibling;return S(z,h(Dt,{get each(){return L()},children:X=>(()=>{var te=Sot();return S(te,X),te})()}),W),S(J,()=>i.t("common.loading"),null),S(J,()=>i.t("common.loading.ellipsis"),null),S(K,()=>i.t("terminal.loading")),j})()},get children(){return h(Vk,{get sensors(){return[yg.configure({activationConstraints:[new dl.Distance({value:4})],preventActivation:j=>j.target instanceof Element&&!!j.target.closest('[data-slot="tabs-trigger-close-button"], input, [contenteditable="true"]')})]},get modifiers(){return[FE,zk.configure({element:()=>y??null})]},plugins:j=>[...j.filter(z=>z!==Ok),eh.configure({acceleration:8,threshold:{x:.05,y:0}}),Jf.configure({dropAnimation:null})],onDragEnd:j=>{const z=j.operation.source;!j.canceled&&ko(z)&&z.initialIndex!==z.index&&n.move(z.id.toString(),z.index),T()},get children(){var j=wot(),z=j.firstChild;return S(j,h(rr,{get variant(){return u()?"normal":"alt"},get value(){return n.active()},onChange:W=>n.open(W),get class(){return u()?"!h-[52px] !flex-none":"!h-auto !flex-none"},get children(){return h(rr.List,{ref(W){var J=y;typeof J=="function"?J(W):y=W},get class(){return u()?void 0:"h-10 border-b border-border-weaker-base"},onPointerDown:W=>{const J=document.activeElement;W.target!==J&&J instanceof HTMLInputElement&&W.currentTarget.contains(J)&&J.blur()},get children(){return[h(Dt,{get each(){return O()},children:(W,J)=>h(yot,{terminal:W,index:J,get newLayout(){return u()},onClose:g})}),(()=>{var W=bot();return S(W,h(q,{get when(){return u()},get fallback(){return h(ws,{get title(){return i.t("command.terminal.new")},get keybind(){return s.keybind("terminal.new")},class:"flex items-center",get children(){return h(Ln,{icon:"plus-small",variant:"ghost",iconSize:"large",onClick:()=>n.new({focus:!0}),get"aria-label"(){return i.t("command.terminal.new")}})}})},get children(){return h(Qn,{get value(){return[we(()=>i.t("command.terminal.new")),h(q,{get when(){return _().length>0},get children(){return h(Eo,{get keys(){return _()},variant:"neutral"})}})]},placement:"bottom",class:"flex items-center",get children(){return h(Ln,{icon:"plus-small",variant:"ghost",iconSize:"large",onClick:()=>n.new({focus:!0}),get"aria-label"(){return i.t("command.terminal.new")}})}})}})),W})()]}})}}),z),S(z,h(q,{get when(){return we(()=>!!d())()&&n.active()},keyed:!0,children:W=>{const J=n.bind();return h(q,{get when(){return O().find(K=>K.id===W)},children:K=>(()=>{var X=Cot();return me(X,"id",`terminal-wrapper-${W}`),S(X,h(Gre,{get pty(){return K()},get autoFocus(){return n.focusRequested(W)},onAutoFocus:()=>n.consumeFocus(W),class:"!px-[14px]",onConnect:()=>P(V(K()),W,J.trim),get onCleanup(){return J.update},onConnectError:()=>$(V(K()),W,J.clone)})),X})()})}})),j}})}})),he(j=>{var z=i.t("terminal.title"),W=!d(),J=!d(),K={"w-full":!c()||k(),"min-w-0 h-full flex-1":c()&&d()&&!k(),"w-0 h-full pointer-events-none":c()&&!d(),"rounded-[10px] shadow-[var(--v2-elevation-raised)]":c()&&u(),"transition-[height] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] will-change-[height] motion-reduce:transition-none":!c()&&!f.active()},X=C(),te={"md:hidden":!k(),hidden:k()},ve={"border-t border-border-weak-base":d()&&!c(),"border-t border-border-weaker-base":d()&&k()&&!u(),"border-l border-border-weaker-base":d()&&c()&&!u(),"pointer-events-none":!d()},ne=E();return z!==j.e&&me(D,"aria-label",j.e=z),W!==j.t&&me(D,"aria-hidden",j.t=W),J!==j.a&&(D.inert=j.a=J),j.o=ct(D,K,j.o),X!==j.i&&Ct(D,"height",j.i=X),j.n=ct(N,te,j.n),j.s=ct(M,ve,j.s),ne!==j.h&&Ct(M,"height",j.h=ne),j},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0}),D})()}dn(["pointerdown"]);function YI(e){let t=e(),n=0;const r=()=>{const i=e();i!==t&&(t=i,n++)};return Fs(r),Te(()=>n++),{key:()=>(r(),`${n}:${t}`),capture(){r();const i=n;return{key:`${i}:${t}`,current:()=>(r(),n===i),run(s){if(r(),n===i)return s()}}}}}const QN=e=>t=>({...t,category:e}),Tot=(e={})=>{const t=Qi(),n=Mr(),r=wt(),i=El(),{sessionKey:s}=ga(),o=YI(s),a=e.model??i.model,l=QN(r.t("command.category.model")),c=QN(r.t("command.category.agent")),u=async()=>{const d=o.capture(),f=document.querySelector('[data-component="prompt-input"]'),m=window.getSelection(),g=f&&m?.rangeCount&&f.contains(m.anchorNode)?Ac(f):null,p=()=>{requestAnimationFrame(()=>{const v=document.querySelector('[data-component="prompt-input"]');v&&(v.focus(),g!==null&&rl(v,g))})},{DialogSelectModel:y}=await B(async()=>{const{DialogSelectModel:v}=await Promise.resolve().then(()=>MKe);return{DialogSelectModel:v}},void 0);d.run(()=>{n.show(()=>h(y,{model:a}),p)})};t.register("composer",()=>[l({id:"model.choose",title:r.t("command.model.choose"),description:r.t("command.model.choose.description"),keybind:"mod+'",slash:"model",onSelect:u}),l({id:"model.variant.cycle",title:r.t("command.model.variant.cycle"),description:r.t("command.model.variant.cycle.description"),keybind:"shift+mod+d",onSelect:()=>a.variant.cycle()}),c({id:"agent.cycle",title:r.t("command.agent.cycle"),description:r.t("command.agent.cycle.description"),keybind:"mod+.",slash:"agent",disabled:!i.agent.visible(),onSelect:()=>i.agent.move(1)}),c({id:"agent.cycle.reverse",title:r.t("command.agent.cycle.reverse"),description:r.t("command.agent.cycle.reverse.description"),keybind:"shift+mod+.",disabled:!i.agent.visible(),onSelect:()=>i.agent.move(-1)})])};function Eot(e){const t=e.indexOf("?");if(t===-1)return;const n=new URLSearchParams(e.slice(t+1)),r=Number(n.get("start")),i=Number(n.get("end"));if(!(!Number.isFinite(r)||!Number.isFinite(i)))return{startLine:r,endLine:i,startChar:0,endChar:0}}function Iot(e){return e.filter(n=>n.type==="text").filter(n=>!n.synthetic&&!n.ignored).reduce((n,r)=>!n||r.text.length>n.text.length?r:n,void 0)}function Zre(e,t){const r=Iot(e)?.text??"",i=t?.directory,s=t?.attachmentName??"attachment",o=p=>{if(!i)return p;const y=i.endsWith("/")?i:i+"/";if(p.startsWith(y))return p.slice(y.length);if(p.startsWith(i)){const v=p.slice(i.length);return v.startsWith("/")?v.slice(1):v}return p},a=[],l=[];for(const p of e){if(p.type==="file"){const y=p,v=y.source?.text;if(v){const b=v.value,w=v.start,x=v.end;let k=b;b.startsWith("@")&&(k=b.slice(1)),!b.startsWith("@")&&y.source&&"path"in y.source&&(k=y.source.path),a.push({type:"file",start:w,end:x,value:b,path:o(k),selection:Eot(y.url)});continue}y.url.startsWith("data:")&&l.push({type:"image",id:y.id,filename:y.filename??s,mime:y.mime,dataUrl:y.url})}if(p.type==="agent"){const y=p,v=y.source;if(!v)continue;a.push({type:"agent",start:v.start,end:v.end,value:v.value,name:y.name})}}a.sort((p,y)=>p.start!==y.start?p.start-y.start:p.end-y.end);const c=[];let u=0,d=0;const f=p=>{p&&(c.push({type:"text",content:p,start:u,end:u+p.length}),u+=p.length)},m=p=>{const y=p.value,v={type:"file",path:p.path,content:y,start:u,end:u+y.length,selection:p.selection};c.push(v),u+=y.length},g=p=>{const y=p.value,v={type:"agent",name:p.name,content:y,start:u,end:u+y.length};c.push(v),u+=y.length};for(const p of a){if(p.start<0||p.end<p.start)continue;const y=p.value;if(!y)continue;const v=p.end>r.length||p.start<d||r.slice(p.start,p.end)!==y,b=v?r.indexOf(y,d):p.start;if(b===-1)continue;const w=v?b+y.length:p.end;f(r.slice(d,b)),p.type==="file"&&m(p),p.type==="agent"&&g(p),d=w}return f(r.slice(d)),c.length===0&&c.push({type:"text",content:"",start:0,end:0}),l.length===0?c:[...c,...l]}const ef=e=>t=>({...t,category:e}),Dot=e=>{const t=Qi(),n=Mr(),r=ua(),i=wt(),s=mu(),o=Hg(),a=kr(),l=ar(),c=Ji(),u=bh(),d=li(),f=El(),m=fs(),{params:g,sessionKey:p,tabs:y,view:v}=ga(),b=YI(p),w=async(Be,et)=>{const un=b.capture(),xn=await Be();un.run(()=>et(xn))},x=async Be=>{await Be.request(),Be.updatePrompt(Be.prompt),Be.owner.run(Be.updateViewport)},k=()=>{const Be=g.id;if(Be)return c().session.get(Be)},C=()=>!!g.id,E=Be=>Be.startsWith("file://")?r.tab(Be):Be,_=Nd({tabs:y,pathFromTab:r.pathFromTab,normalizeTab:E,review:e.review,hasReview:C,fileBrowser:e.fileBrowser}),L=_.activeFileTab,O=_.closableTab,$=l.visibility.fileTree,V=()=>{const Be=g.id;return Be?c().data.message[Be]??[]:[]},P=()=>V().filter(Be=>Be.role==="user"),T=()=>{const Be=k()?.revert?.messageID;return Be?P().filter(et=>et.id<Be):P()},D=()=>{d.fileTree.tab()==="changes"&&d.fileTree.setTab("all")},N=(Be,et)=>{const un=r.get(Be)?.content?.content;if(un)return Ag(un,{start:et.startLine,end:et.endLine})},M=(Be,et)=>{const un=N(Be,et);o.context.add({type:"file",path:Be,selection:et,preview:un})},F=()=>{const Be=L();if(!Be)return!1;const et=r.pathFromTab(Be);return et?r.selectedLines(et)!=null:!1},j=e.navigateMessageByOffset,z=e.setActiveMessage,W=e.focusInput,J=ef(i.t("command.category.session")),K=ef(i.t("command.category.file")),X=ef(i.t("command.category.context")),te=ef(i.t("command.category.view")),ve=ef(i.t("command.category.terminal")),ne=ef(i.t("command.category.mcp")),ie=ef(i.t("command.category.permissions")),ke=()=>{const Be=g.id;return Be?s.isAutoAccepting(Be,a().directory):s.isAutoAcceptingDirectory(a().directory)},ge=async Be=>{const et=typeof document>"u"?void 0:document.body;if(et){const xn=document.createElement("textarea");xn.value=Be,xn.setAttribute("readonly",""),xn.style.position="fixed",xn.style.opacity="0",xn.style.pointerEvents="none",et.appendChild(xn),xn.select();const In=document.execCommand("copy");if(et.removeChild(xn),In)return!0}const un=typeof navigator>"u"?void 0:navigator.clipboard;return un?.writeText?un.writeText(Be).then(()=>!0,()=>!1):!1},Pe=async(Be,et)=>{if(!await ge(Be)){tn({title:i.t("toast.session.share.copyFailed.title"),variant:"error"});return}tn({title:et?i.t("session.share.copy.copied"):i.t("toast.session.share.success.title"),description:i.t("toast.session.share.success.description"),variant:"success"})},Me=async()=>{const Be=g.id;if(!Be)return;const et=k()?.share?.url;if(et){await Pe(et,!0);return}const un=await a().client.session.share({sessionID:Be}).then(xn=>xn.data?.share?.url).catch(()=>{});if(!un){tn({title:i.t("toast.session.share.failed.title"),description:i.t("toast.session.share.failed.description"),variant:"error"});return}await Pe(un,!1)},de=async()=>{const Be=g.id;Be&&await a().client.session.unshare({sessionID:Be}).then(()=>tn({title:i.t("toast.session.unshare.success.title"),description:i.t("toast.session.unshare.success.description"),variant:"success"})).catch(()=>tn({title:i.t("toast.session.unshare.failed.title"),description:i.t("toast.session.unshare.failed.description"),variant:"error"}))},U=()=>{w(()=>B(()=>import("./dialog-select-file-C52l-3Bc.js"),__vite__mapDeps([118,119,120])),Be=>n.show(()=>h(Be.DialogSelectFile,{onOpenFile:D})))},He=()=>{const Be=O();Be&&y().close(Be)},Ue=()=>{const Be=L();if(!Be)return;const et=r.pathFromTab(Be);if(!et)return;const un=r.selectedLines(et);if(!un){tn({title:i.t("toast.context.noLineSelection.title"),description:i.t("toast.context.noLineSelection.description")});return}M(et,md(un))},Z=()=>{u.all().length>0&&u.new({focus:!0}),u.all().length===0&&u.requestFocus(),v().terminal.open()},ce=()=>{const Be=u.active();if(!Be)return;const et=u.all().length===1;u.close(Be),et&&v().terminal.close()},G=()=>{w(()=>B(()=>import("./dialog-select-mcp-Dful_uxr.js"),__vite__mapDeps([121,112,105,116])),Be=>n.show(()=>h(Be.DialogSelectMcp,{})))},fe=()=>{const Be=g.id;Be?s.toggleAutoAccept(Be,a().directory):s.toggleAutoAcceptDirectory(a().directory);const et=Be?s.isAutoAccepting(Be,a().directory):s.isAutoAcceptingDirectory(a().directory);tn({title:et?i.t("toast.permissions.autoaccept.on.title"):i.t("toast.permissions.autoaccept.off.title"),description:et?i.t("toast.permissions.autoaccept.on.description"):i.t("toast.permissions.autoaccept.off.description")})},xe=async()=>{const Be=g.id;if(!Be)return;const et=b.capture(),un=a().api.session,xn=a().directory,In=o.capture(),Hn=k()?.revert?.messageID,er=P(),Lt=Tp(er,Vn=>!Hn||Vn.id<Hn);if(!Lt)return;const Nn=c().data.part[Lt.id];c().data.session_working(Be)&&await un.interrupt({sessionID:Be}).catch(()=>{}),await x({owner:et,prompt:In,request:()=>un.revert.stage({sessionID:Be,messageID:Lt.id}),updatePrompt:Vn=>{Nn&&Vn.set(Zre(Nn,{directory:xn}))},updateViewport:()=>z(Tp(er,Vn=>Vn.id<Lt.id))})},Oe=async()=>{const Be=g.id;if(!Be)return;const et=b.capture(),un=a().api.session,xn=P(),In=o.capture(),Hn=k()?.revert?.messageID;if(!Hn)return;const er=xn.find(Lt=>Lt.id>Hn);if(!er){await x({owner:et,prompt:In,request:()=>un.revert.clear({sessionID:Be}),updatePrompt:Lt=>Lt.reset(),updateViewport:()=>z(Tp(xn,Lt=>Lt.id>=Hn))});return}await x({owner:et,prompt:In,request:()=>un.revert.stage({sessionID:Be,messageID:er.id}),updatePrompt:()=>{},updateViewport:()=>z(Tp(xn,Lt=>Lt.id<er.id))})},re=async()=>{const Be=g.id;if(!Be)return;const et=f.model.current();if(!et){tn({title:i.t("toast.model.none.title"),description:i.t("toast.model.none.description")});return}await a().api.session.compact({sessionID:Be,model:{providerID:et.provider.id,modelID:et.id}})},pe=()=>{w(()=>B(()=>import("./dialog-fork-C8rl3Y_v.js"),[]),Be=>n.show(()=>h(Be.DialogFork,{})))},ye=()=>c().data.config.share==="disabled"?[]:[J({id:"session.share",title:k()?.share?.url?i.t("session.share.copy.copyLink"):i.t("command.session.share"),description:k()?.share?.url?i.t("toast.session.share.success.description"):i.t("command.session.share.description"),slash:"share",disabled:!g.id,onSelect:Me}),J({id:"session.unshare",title:i.t("command.session.unshare"),description:i.t("command.session.unshare.description"),slash:"unshare",disabled:!g.id||!k()?.share?.url,onSelect:de})],Re=()=>[J({id:"session.new",title:i.t("command.session.new"),keybind:"mod+shift+s",slash:"new",onSelect:Be=>{if(l.general.newLayoutDesigns()){t.trigger("tab.new",Be);return}m(`/${g.dir}/session`)}}),J({id:"session.undo",title:i.t("command.session.undo"),description:i.t("command.session.undo.description"),slash:"undo",disabled:!g.id||T().length===0,onSelect:xe}),J({id:"session.redo",title:i.t("command.session.redo"),description:i.t("command.session.redo.description"),slash:"redo",disabled:!g.id||!k()?.revert?.messageID,onSelect:Oe}),J({id:"session.compact",title:i.t("command.session.compact"),description:i.t("command.session.compact.description"),slash:"compact",disabled:!g.id||T().length===0,onSelect:re}),J({id:"session.fork",title:i.t("command.session.fork"),description:i.t("command.session.fork.description"),slash:"fork",disabled:!g.id||T().length===0,onSelect:pe})],Je=()=>{const Be=O();return[K({id:"file.open",title:i.t("command.file.open"),description:i.t("palette.search.placeholder"),keybind:"mod+p",slash:"open",onSelect:U}),Be&&K({id:"tab.close",title:i.t("command.tab.close"),keybind:"mod+w",onSelect:He})].filter(et=>!!et)},Xe=()=>[X({id:"context.addSelection",title:i.t("command.context.addSelection"),description:i.t("command.context.addSelection.description"),keybind:"mod+shift+l",disabled:!F(),onSelect:Ue})],je=()=>[te({id:"terminal.toggle",title:i.t("command.terminal.toggle"),keybind:"ctrl+`",slash:"terminal",onSelect:()=>{if(v().terminal.opened()){u.cancelFocus(),v().terminal.close();return}u.requestFocus(u.active()),v().terminal.open()}}),te({id:"review.toggle",title:i.t("command.review.toggle"),keybind:"mod+shift+r",onSelect:()=>v().reviewPanel.toggle()}),...$()?[te({id:"fileTree.toggle",title:i.t("command.fileTree.toggle"),keybind:"mod+\\",onSelect:()=>d.fileTree.toggle()})]:[],te({id:"input.focus",title:i.t("command.input.focus"),keybind:"ctrl+l",onSelect:W})],mt=()=>[ve({id:"terminal.close",title:i.t("terminal.close"),keybind:"mod+w",hidden:!0,when:Be=>Be.target instanceof Element&&!!Be.target.closest('[data-component="terminal"]'),onSelect:ce}),ve({id:"terminal.new",title:i.t("command.terminal.new"),description:i.t("command.terminal.new.description"),keybind:"ctrl+alt+t",onSelect:Z})],Et=()=>[J({id:"message.previous",title:i.t("command.message.previous"),description:i.t("command.message.previous.description"),keybind:"mod+alt+[",disabled:!g.id,onSelect:()=>j(-1)}),J({id:"message.next",title:i.t("command.message.next"),description:i.t("command.message.next.description"),keybind:"mod+alt+]",disabled:!g.id,onSelect:()=>j(1)})],Bt=()=>[ne({id:"mcp.toggle",title:i.t("command.mcp.toggle"),description:i.t("command.mcp.toggle.description"),keybind:"mod+;",slash:"mcp",onSelect:G})],Qe=()=>[ie({id:"permissions.autoaccept",title:ke()?i.t("command.permissions.autoaccept.disable"):i.t("command.permissions.autoaccept.enable"),keybind:"mod+shift+a",disabled:!1,onSelect:fe})];t.register("session",()=>[...Re(),...ye(),...Je(),...Xe(),...je(),...mt(),...Et(),...Bt(),...Qe()])},o6=e=>{const n=(e.startsWith("#")?e.slice(1):e).match(/^message-(.+)$/);if(n)return n[1]},Lot=e=>{const t=I(()=>e.visibleUserMessages()),n=I(()=>new Map(t().map(y=>[y.id,y])));let r="",i=!1;const s=Wa(),o=fs(),a=new Set,l=y=>{const v=requestAnimationFrame(()=>{a.delete(v),y()});a.add(v)},c=()=>{for(const y of a)cancelAnimationFrame(y);a.clear()},u=()=>{c(),e.consumePendingMessage(e.sessionKey()),e.pendingMessage()&&e.setPendingMessage(void 0),s.hash&&(i=!0,o(s.pathname+s.search,{replace:!0}))},d=y=>{const v=`#${e.anchor(y)}`;s.hash!==v&&(i=!1,o(s.pathname+s.search+v,{replace:!0}))},f=(y,v)=>{const b=e.scroller();if(!b)return!1;const w=y.getBoundingClientRect(),x=b.getBoundingClientRect(),k=b.querySelector("[data-session-title]"),C=k instanceof HTMLElement?k.offsetHeight:0,E=Math.max(0,w.top-x.top+b.scrollTop-C);return b.scrollTo({top:E,behavior:v}),!0},m=(y,v,b=4)=>{e.revealMessage?.(y);const w=document.getElementById(e.anchor(y));return w?f(w,v):(b<=0||l(()=>{m(y,v,b-1)}),!1)},g=(y,v="smooth")=>{if(c(),e.currentMessageId()!==y.id&&e.setActiveMessage(y),e.revealMessage?.(y.id),m(y.id,v)){d(y.id);return}d(y.id)},p=y=>{const v=s.hash.slice(1);if(!v){e.autoScroll.forceScrollToBottom();const k=e.scroller();k&&e.scheduleScrollState(k);return}const b=o6(v);if(b){e.autoScroll.pause();const k=n().get(b);if(k){g(k,y);return}return}const w=document.getElementById(v);if(w){e.autoScroll.pause(),f(w,y);return}e.autoScroll.forceScrollToBottom();const x=e.scroller();x&&e.scheduleScrollState(x)};return ae(()=>{s.hash||(i=!1),!(!e.sessionID()||!e.messagesReady())&&(c(),l(()=>p("auto")))}),ae(()=>{if(!e.sessionID()||!e.messagesReady())return;t();let y=e.pendingMessage();if(!y){const w=e.sessionKey();if(r!==w){r=w;const x=e.consumePendingMessage(w);x&&(e.setPendingMessage(x),y=x)}}if(!y&&!i&&(y=o6(s.hash)),!y)return;const v=e.pendingMessage()===y,b=n().get(y);b&&(v&&e.setPendingMessage(void 0),!(e.currentMessageId()===y&&!v)&&(e.autoScroll.pause(),c(),l(()=>g(b,"auto"))))}),ae(()=>{const y=e.sessionID();if(!y||!e.messagesReady())return;t();let v=e.pendingMessage();!v&&!i&&(v=o6(s.hash)),v&&(n().has(v)||!e.historyMore()||e.historyLoading()||e.loadMore(y))}),sn(()=>{typeof window<"u"&&"scrollRestoration"in window.history&&(window.history.scrollRestoration="manual")}),Te(c),{clearMessageHash:u,scrollToMessage:g,applyHash:p}};var Aot=A('<div class="flex flex-col gap-4 pl-6 pr-2.5 pb-3"><div class="flex justify-end gap-2">');function JN(e){const t=Mr(),n=Tr(),r=()=>{e.link&&n.openLink(e.link),e.onClose?.(),t.close()},i=()=>{e.onClose?.(!0),t.close()};return h(ou,{get title(){return e.title},get description(){return e.description},fit:!0,get children(){var s=Aot(),o=s.firstChild;return S(o,h(Kt,{variant:"ghost",size:"large",onClick:i,children:"Don't show again"}),null),S(o,h(Kt,{variant:"primary",size:"large",onClick:r,get children(){return e.actionLabel}}),null),s}})}const Yre="go_upsell_last_seen_at",Xre="go_upsell_dont_show",Qre="go_upsell_account_rate_limit_last_seen_at",Jre="go_upsell_account_rate_limit_dont_show",Mot=864e5,$ot=new Set(["opencode","opencode-go"]);function Pot(e){if(e.type!=="retry"||!e.action)return;const{action:t}=e;if($ot.has(t.provider)){if(t.reason==="free_tier_limit")return{lastSeenAt:Yre,dontShow:Xre};if(t.reason==="account_rate_limit")return{lastSeenAt:Qre,dontShow:Jre}}}function Oot(){const e=kr(),t=Mr(),{params:n}=ga(),{t:r,locale:i}=Mn(),s=()=>i()==="en",[o,a]=_r(Jn.global("go-upsell"),Ze({[Yre]:null,[Xre]:null,[Qre]:null,[Jre]:null}));Te(e().event.on("session.status",l=>{if(l.properties.sessionID!==n.id||l.properties.status.type!=="retry")return;const{action:c}=l.properties.status;if(!c||t.active)return;const u=Pot(l.properties.status);if(!u)return;const d=o[u.lastSeenAt];d&&Date.now()-d<Mot||o[u.dontShow]||(c.reason==="free_tier_limit"?t.show(()=>h(JN,{get title(){return we(()=>!!s())()?c.title:r("dialog.usageExceeded.freeTier.title")},get description(){return we(()=>!!s())()?c.message:r("dialog.usageExceeded.freeTier.description")},get actionLabel(){return we(()=>!!s())()?c.label:r("dialog.usageExceeded.freeTier.actionLabel")},get link(){return c.link},onClose:f=>{a(u.lastSeenAt,Date.now()),f?a(u.dontShow,Date.now()):B(()=>import("./dialog-connect-provider-DLnpNUTc.js").then(m=>m.d),[]).then(m=>{const g=m.useProviderConnectController();g.select("opencode-go"),t.show(()=>h(m.DialogConnectProvider,{controller:g}))})}})):c.reason==="account_rate_limit"&&t.show(()=>h(JN,{get title(){return we(()=>!!s())()?c.title:r("dialog.usageExceeded.accountRateLimit.title")},get description(){return we(()=>!!s())()?c.message:r("dialog.usageExceeded.accountRateLimit.description")},get actionLabel(){return we(()=>!!s())()?c.label:r("dialog.usageExceeded.accountRateLimit.actionLabel")},get link(){return c.link},onClose:f=>{a(u.lastSeenAt,Date.now()),f&&a(u.dontShow,Date.now())}})))}))}var Rot=A('<div class="flex-1 min-h-0 overflow-hidden"><div class="h-full px-6 pb-42 -mt-4 flex flex-col items-center justify-center text-center gap-4"><div class="flex flex-col items-center gap-2"><div class="text-16-medium text-text max-w-md"></div><div class="text-13-regular text-text-weak max-w-md">'),Fot=A('<div class="max-w-full flex flex-col items-center gap-1"><div class="max-w-full text-11-regular text-text-faint break-all"></div><code class="max-w-full rounded-[4px] px-1 py-0.5 font-mono text-xs font-medium leading-4 text-text-base break-all bg-[color-mix(in_oklch,var(--v2-text-text-base)_8%,transparent)]">'),Not=A('<div class="relative size-full overflow-hidden flex flex-col">'),K2=A("<div>"),Vot=A('<div class="h-full pb-64 -mt-4 flex flex-col items-center justify-center text-center gap-6"><div class="text-14-regular text-text-weak max-w-56">'),zot=A('<div><div class="flex flex-col gap-3"><div class="text-14-medium text-text-strong"></div><div class="text-14-regular text-text-base max-w-md"style=line-height:var(--line-height-normal)>'),Hot=A('<div><div class="text-14-regular text-text-weak max-w-56">'),jot=A('<div class="px-6 py-4 text-text-weak">'),qot=A('<div class="flex flex-col h-full overflow-hidden bg-v2-background-bg-base contain-strict">'),Bot=A('<div><div class="relative pt-2 flex-1 min-h-0 overflow-hidden">'),Uot=A('<div class="relative h-full overflow-hidden">'),Wot=A('<div class="flex-1 min-h-0 overflow-hidden">'),Kot=A('<div class="min-h-0 flex-1">'),Got=A('<div class="relative h-2 shrink-0">'),Zot=A('<div class="min-w-0 h-full flex flex-1 flex-col">'),Yot=A('<div class="flex-1 min-h-0 flex flex-col md:flex-row"><div>');const eV=[],tV=()=>({messageId:void 0,mobileTab:"session"});function Xot(e,t){return t?n7e(e,t)||t7e(e,t):!1}async function nV(e){const t=e.capturePrompt(),n=t.current().slice();qt(()=>e.optimistic(t)),await e.request().then(e.complete).catch(r=>{qt(()=>{e.rollback(),t.set(n)}),e.fail(r)})}function eie(){return h(iat,{get children(){return h(sat,{})}})}function Qot(){const e=Br(),t=Di(),n=I(()=>t().session.lineage.peek(e.id)?.session.directory);return h(nat,{directory:n,sessionID:()=>e.id,get children(){return[h(Jot,{}),h(XI,{get sessionID(){return e.id},get serverKey(){return ra(e.serverKey)},padded:!0,get children(){return h(eat,{})}})]}})}function Jot(){return wne(),null}function XI(e){const t=ar();return h(KC,{fallback:n=>t.general.newLayoutDesigns()?h(nie,{get padded(){return e.padded},get children(){return h(UC,{newLayout:!0,get raised(){return!!e.sessionID},get children(){return h(tie,{error:n,get sessionID(){return e.sessionID},get serverKey(){return e.serverKey}})}})}}):h(GE,{error:n}),get children(){return e.children}})}function tie(e){const t=wt(),n=ci(),r=ks(),i=I(()=>{const o=e.serverKey??n.key,a=n.list.find(l=>ut.key(l)===o);return a?hd(a):o}),s=()=>{e.sessionID&&r.removeSessionTab({server:e.serverKey??n.key,sessionId:e.sessionID})};return Xot(e.error,e.sessionID)?(()=>{var o=Rot(),a=o.firstChild,l=a.firstChild,c=l.firstChild,u=c.nextSibling;return S(c,()=>t.t("session.error.notFound")),S(u,()=>t.t("session.error.notFound.description")),S(a,h(q,{get when(){return e.sessionID},children:d=>(()=>{var f=Fot(),m=f.firstChild,g=m.nextSibling;return S(m,i),S(g,d),f})()}),null),S(a,h(as,{variant:"neutral",size:"normal",icon:"xmark-small",onClick:s,get children(){return t.t("session.error.notFound.closeTab")}}),null),o})():h(GE,{get error(){return e.error}})}function eat(){const e=Br(),t=ks(),n=Di(),r=I(()=>ra(e.serverKey)),i=DJ(()=>e.id,()=>n().session.lineage),s=I(()=>i()?.session.directory),o=()=>s();return ae(()=>{const a=i();a&&t.addSessionTab({server:r(),sessionId:a.root.id})}),h(q,{get when(){return s()},get children(){return h(aT,{directory:o,get children(){return h(wT,{directory:o,server:r,get children(){return h(tat,{})}})}})}})}function tat(){const e=kr(),t=xs();return h(q,{get when(){return`${t().scope}\0${e().directory}`},keyed:!0,get children(){return h(eie,{})}})}function nat(e){return[h(rat,{get sessionID(){return e.sessionID}}),h(bT,{get directory(){return e.directory},get children(){return e.children}})]}function rat(e){const t=gh();return ae(()=>{const n=e.sessionID?.();!t.ready()||!n||t.session.unseenCount(n)!==0&&t.session.markViewed(n)}),null}function iat(e){return h(hDe,{get children(){return h(eG,{get children(){return h(dZ,{get children(){return h(qK,{get children(){return e.children}})}})}})}})}function nie(e){return(()=>{var t=Not();return S(t,()=>e.children),he(()=>t.classList.toggle("p-2",!!e.padded)),t})()}function UC(e){return(()=>{var t=K2();return S(t,()=>e.children),he(n=>ct(t,{"flex-1 min-h-0 flex flex-col":!0,"bg-v2-background-bg-base":e.newLayout,"bg-background-stronger":!e.newLayout,"rounded-[10px] overflow-hidden":e.newLayout,"shadow-[var(--v2-elevation-raised)]":e.newLayout&&e.raised},n)),t})()}function sat(){const e=Di(),t=li(),n=El(),r=ua(),i=Ji(),s=ch(),o=Mr(),a=wt(),l=kr(),c=xs(),u=ar(),d=Tr(),f=Hg(),m=q1(),g=Qi();bh();const[p,y]=Id(),v=Wa(),b=fs(),{params:w,sessionKey:x,workspaceKey:k,tabs:C,view:E}=ga(),_=()=>E().review.mode()??"git",L=()=>E().review.file(),O=YI(x),$=I(()=>u.general.newLayoutDesigns());ae(()=>{f.ready()&&Wt(()=>{if(w.id)return;const ee=p.prompt;ee&&(f.set([{type:"text",content:ee,start:0,end:ee.length}],ee.length),y({...p,prompt:void 0}))})});const[V,P]=Ze({pendingMessage:void 0,reviewSnap:!1,scrollGesture:0,scroll:{overflow:!1,bottom:!0,jump:!1}}),T=wQe(),D=bQe({sessionKey:x,sessionID:()=>w.id,queryOptions:e().queryOptions}),N=I(()=>t.tabs(k)),M=I(()=>w.id?`${c().scope}\0${w.id}`:void 0);ae(vt(()=>w.id,(ee,Le)=>{if(!ee||Le)return;const Ve=t.handoff.tabs();if(!Ve)return;if(Date.now()-Ve.at>6e4){t.handoff.clearTabs();return}if(Ve.scope!==c().scope||Ve.id!==ee||(t.handoff.clearTabs(),Ve.dir!==yn(l().directory)))return;const lt=N().tabs();if(lt.all.length===0&&!lt.active)return;const xt=C().tabs();if(xt.all.length>0||xt.active)return;const Un=G(lt.all),vr=lt.active?ce(lt.active):void 0;C().setAll(Un),C().setActive(vr&&Un.includes(vr)?vr:Un[0]),N().setAll([]),N().setActive(void 0)},{defer:!0}));const F=uu("(min-width: 768px)"),j=eI(),z=I(()=>F()&&E().reviewPanel.opened()),W=I(()=>$()&&z()&&!!w.id),J=I(()=>E().terminal.opened()),K=I(()=>F()&&J()),X=I(()=>$()&&K()&&!W()),te=I(()=>F()&&YJ({visible:u.visibility.fileTree(),opened:t.fileTree.opened()})),ve=I(()=>$()?W()||K():z()),ne=I(()=>ve()||te());let ie;const[ke,ge]=De();Oa(()=>ie,({width:ee})=>ge(ee));const Pe=I(()=>($()?W():z())&&t.review.diffStyle()==="split"),Me=I(()=>{const ee=ke();if(ee!==void 0)return ee-(u.general.newLayoutDesigns()?8:0)}),de=I(()=>{const ee=Me();return ee===void 0?1e3:wre({available:ee,split:Pe()})}),U=I(()=>yrt({width:t.session.width(),available:Me(),split:Pe()})),He=I(()=>ne()?ve()?`${U()}px`:`calc(100% - ${t.fileTree.width()}px)`:"100%"),Ue=I(()=>F()&&($()||!z())),Z=I(()=>yst({review:W(),terminal:K(),files:te()}));function ce(ee){return ee.startsWith("file://")?r.tab(ee):ee}function G(ee){const Le=new Set,Ve=[];for(const lt of ee){const xt=ce(lt);Le.has(xt)||(Le.add(xt),Ve.push(xt))}return Ve}const fe=()=>{E().reviewPanel.opened()||E().reviewPanel.open()},xe=I(()=>w.id?i().session.get(w.id):void 0),Oe=I(()=>!!xe()?.parentID),re=I(()=>!!i().project),pe=I(()=>F()),ye=Nd({tabs:C,pathFromTab:r.pathFromTab,normalizeTab:ce,review:pe,hasReview:re}),Re=ye.activeTab,Je=ye.activeFileTab,Xe=I(()=>xe()?.revert?.messageID),je=mnt({sessionID:()=>w.id,revertMessageID:Xe}),mt=je.history.loading,Et=je.history.more,Bt=je.lastUserMessage;je.messages;const Qe=je.ready,Be=je.resource,et=je.userMessages,un=je.visibleUserMessages;ae(()=>{const ee=Je();if(!ee)return;const Le=r.pathFromTab(ee);Le&&r.load(Le)}),ae(vt(()=>Bt()?.id,()=>{const ee=Bt();ee&&hrt(n,ee)}));let xn;ae(()=>{const ee=w.id;!ee||!f.ready()||!n.session.ready()||xn!==ee&&(xn=ee,grt(n,f))||mrt(n,f)}),ae(vt(()=>({dir:l().directory,id:w.id}),(ee,Le)=>{Le&&(ee.dir===Le.dir&&ee.id===Le.id||Le.id&&!ee.id&&n.session.reset())},{defer:!0}));const[In,Hn]=Ze({...tV(),newSessionWorktree:"main",deferRender:!1}),[er,Lt]=_r(Jn.serverWorkspace(c().scope,l().directory,"followup",["followup.v1"]),Ze({items:{},failed:{},paused:{},edit:{}}));Fs(ee=>{const Le=x();if(Le!==ee){Hn("deferRender",!0);const Ve=O.capture();requestAnimationFrame(()=>{setTimeout(()=>Ve.run(()=>Hn("deferRender",!1)),0)})}return Le});let Nn,Vn,$r;Fs(ee=>{const Le=z();return ee===void 0||ee===Le||(Nn!==void 0&&cancelAnimationFrame(Nn),P("reviewSnap",!0),Nn=requestAnimationFrame(()=>{Nn=void 0,P("reviewSnap",!1)})),Le},z());const gs=I(()=>rT(Bt()?.summary?.diffs)),$n=I(()=>{const ee=i().project;return!!ee&&ee.vcs!=="git"}),Ur=I(()=>{const ee=[],Le=i().project,Ve=i().data.vcs;return Le?.vcs==="git"&&ee.push("git"),Le?.vcs==="git"&&Ve?.branch&&Ve?.default_branch&&Ve.branch!==Ve.default_branch&&ee.push("branch"),ee.push("turn"),ee}),es=I(()=>!F()&&In.mobileTab==="changes"),go=I(()=>F()?te()||z()&&(Re()==="review"||$()&&!!Je()):In.mobileTab==="changes"),Li=I(()=>{const ee=_();if(ee==="git"||ee==="branch")return ee}),Wr=I(()=>["session-vcs",l().directory,i().data.vcs?.branch??"",i().data.vcs?.default_branch??""]),Zr=zp(()=>{const ee=Li(),Le=go()&&i().project?.vcs==="git";return{queryKey:[...Wr(),ee],enabled:Le,queryFn:ee?()=>l().api.vcs.diff({location:{directory:l().directory},mode:ee==="git"?"working":ee}).then(Ve=>Ve.data).catch(Ve=>(console.debug("[session-review] failed to load vcs diff",{mode:ee,error:Ve}),[])):_4}}),bi=_Le(()=>void s.invalidateQueries({queryKey:Wr()}),100),lr=()=>_()==="git"||_()==="branch"?Zr.isFetched?Zr.data??[]:[]:gs(),ui=()=>{const ee=lr(),Le=L();return Le&&ee.some(Ve=>Ve.file===Le)?Le:ee[0]?.file},js=()=>lr().length,Ss=()=>js()>0,Ni=()=>_()==="git"||_()==="branch"?!Zr.isPending:!0,$o=async(ee,Le)=>{const Ve=Li();if(!Ve)return;const lt=Bre(i().project?.worktree??l().directory),xt=Wit(lt,ee),Un=lr().find(Nr=>Nr.file===ee),vr=Nr=>{if(!(!Nr||!Un)&&!(Nr.additions!==Un.additions||Nr.deletions!==Un.deletions)&&!qre(Nr))return Nr},Ai=(Nr,Su)=>s.fetchQuery({queryKey:[c().scope,...Wr(),Ve,"directory",Nr,Su,Le],staleTime:Number.POSITIVE_INFINITY,retry:2,queryFn:()=>l().api.vcs.diff({location:{directory:Nr},mode:Ve==="git"?"working":Ve,context:Su}).then(Ah=>Ah.data)}).then(Ah=>Ah.find($ie=>$ie.file===ee));if(xt!==lt)try{const Nr=vr(await Ai(xt));if(Nr)return Nr}catch(Nr){console.debug("[session-review] failed to load scoped vcs diff",{mode:Ve,file:ee,directory:xt,error:Nr})}try{const Nr=vr(await Ai(lt,3));if(Nr)return Nr}catch(Nr){console.debug("[session-review] failed to load bounded vcs diff",{mode:Ve,file:ee,root:lt,error:Nr})}},Pr=I(()=>{if(In.newSessionWorktree==="create")return"create";const ee=i().project;return ee&&l().directory!==ee.worktree?l().directory:"main"}),Po=ee=>{Ge=nt,Hn("messageId",ee?.id)},pa=ee=>`message-${ee}`,Za=()=>{const ee=_n;if(!ee)return In.messageId;const Le=ee.getBoundingClientRect(),Ve=Le.top+100,lt=[...ee.querySelectorAll("[data-message-id]")].map(Ai=>{const Nr=Ai.dataset.messageId;if(!Nr)return;const Su=Ai.getBoundingClientRect();return{id:Nr,top:Su.top,bottom:Su.bottom}}).filter(Ai=>!!Ai),xt=lt.filter(Ai=>Ai.bottom>Le.top&&Ai.top<Le.bottom),Un=xt.find(Ai=>Ai.top<=Ve&&Ai.bottom>=Ve);if(Un)return Un.id;const vr=[...xt].sort((Ai,Nr)=>{const Su=Math.abs(Ai.top-Ve),Ah=Math.abs(Nr.top-Ve);return Su!==Ah?Su-Ah:Ai.top-Nr.top})[0];return vr?vr.id:lt.filter(Ai=>Ai.top<=Ve).at(-1)?.id??lt[0]?.id??In.messageId};function Oo(ee){const Le=un();if(Le.length===0)return;const Ve=In.messageId&&Ge===nt?In.messageId:Za(),lt=Ve?Le.findIndex(vr=>vr.id===Ve):Le.length,Un=(lt===-1?Le.length:lt)+ee;if(!(Un<0||Un>Le.length)){if(Un===Le.length){Ro();return}On.pause(),Aie(Le[Un],"auto")}}function Ya(ee){const Le=e().data.project;i().set("project",ee.id);const Ve=Le.findIndex(xt=>xt.id===ee.id);if(Ve>=0){e().set("project",Le.map((xt,Un)=>Un===Ve?{...xt,...ee}:xt));return}const lt=Le.findIndex(xt=>xt.id>ee.id);if(lt>=0){e().set("project",[...Le.slice(0,lt),ee,...Le.slice(lt)]);return}e().set("project",[...Le,ee])}const Ht=Yo(()=>({mutationFn:()=>l().client.project.initGit(),onSuccess:ee=>{ee.data&&Ya(ee.data)},onError:ee=>{tn({variant:"error",title:a.t("common.requestFailed"),description:Uf(ee,a.t)})}}));function Ie(){Ht.isPending||Ht.mutate()}let st,Ft,Rn=0,_n,pr,ti=ee=>{},_e=()=>{},nt=0,Ge=0;const Ye=250,$t=ee=>{const Le=_n;if(!Le)return;const lt=(ee instanceof Element?ee:void 0)?.closest("[data-scrollable]");lt&&lt!==Le||P("scrollGesture",Date.now())},Rt=()=>Date.now()-V.scrollGesture<Ye;ae(vt(()=>{const ee=w.id;return[l().directory,ee,ee?i().data.session_status[ee]?.type??"idle":"idle",ee?T.blocked():!1]},([ee,Le,Ve,lt])=>{if(Vn!==void 0&&cancelAnimationFrame(Vn),$r!==void 0&&window.clearTimeout($r),Vn=void 0,$r=void 0,!Le||Ve==="idle"&&!lt)return;const xt=Wt(()=>i().data.todo[Le]!==void 0);Vn=requestAnimationFrame(()=>{Vn=void 0,$r=window.setTimeout(()=>{$r=void 0,!(l().directory!==ee||w.id!==Le)&&Wt(()=>{i().session.todo(Le,xt?{force:!0}:void 0)})},0)})},{defer:!0})),ae(vt(()=>un().at(-1)?.id,(ee,Le)=>{ee&&Le&&ee>Le&&Hn("messageId",void 0)},{defer:!0})),ae(vt(x,()=>{Hn(tV()),P("pendingMessage",void 0)},{defer:!0}));const Y=l().event.listen(ee=>{const Le=ee.details;if(Le.type!=="file.watcher.updated"&&Le.type!=="filesystem.changed")return;const Ve=typeof Le.properties=="object"&&Le.properties?Le.properties:void 0,lt=typeof Ve?.file=="string"?Ve.file:void 0;!lt||lt.startsWith(".git/")||bi()});Te(Y),ae(vt(()=>l().directory,ee=>{ee&&Hn("newSessionWorktree","main")},{defer:!0}));const Ce=(ee,Le)=>{const Ve=r.get(ee)?.content?.content;if(Ve)return Ag(Ve,{start:Le.startLine,end:Le.endLine})},Fe=ee=>{const Le=md(ee.selection),Ve=ee.preview??Ce(ee.file,Le),lt=m.add({file:ee.file,selection:ee.selection,comment:ee.comment});f.context.add({type:"file",path:ee.file,selection:Le,comment:ee.comment,commentID:lt.id,commentOrigin:ee.origin,preview:Ve})},qe=ee=>{m.update(ee.file,ee.id,ee.comment),f.context.updateComment(ee.file,ee.id,{comment:ee.comment,...ee.preview?{preview:ee.preview}:{}})},_t=ee=>{m.remove(ee.file,ee.id),f.context.removeComment(ee.file,ee.id)},Zt=I(()=>({moreLabel:a.t("common.moreOptions"),editLabel:a.t("common.edit"),deleteLabel:a.t("common.delete"),saveLabel:a.t("common.save")})),It=ee=>ee instanceof HTMLElement?/^(INPUT|TEXTAREA|SELECT|BUTTON)$/.test(ee.tagName)||ee.isContentEditable:!1,jt=()=>{let ee=document.activeElement;for(;ee instanceof HTMLElement&&ee.shadowRoot?.activeElement;)ee=ee.shadowRoot.activeElement;return ee instanceof HTMLElement?ee:void 0},Pt=ee=>{const Le=ee.composedPath(),Ve=Le.find(vr=>vr instanceof HTMLElement),lt=jt();if(Le.some(vr=>vr instanceof HTMLElement&&vr.closest("[data-prevent-autofocus]")!==null)||It(Ve))return;if(lt){const vr=lt.closest("[data-prevent-autofocus]"),Ai=It(lt);if(vr||Ai)return}if(o.active)return;if(lt===st){ee.key==="Escape"&&st?.blur();return}const Un=XE(ee);if(Un){if(!_n||!JE(Ve??null,Un)||QE(_n,Ve??null,Un)!==_n)return;$t(_n);return}if(ee.key.length===1&&ee.key!=="Unidentified"&&!(ee.ctrlKey||ee.metaKey)){if(T.blocked()||Oe())return;const vr=st;if(!vr)return;vr.focus(),rl(vr,f.cursor()??Ho(f.current()))}};ae(()=>{if(!t.ready()||i().status!=="complete"||!i().project)return;const ee=Ur(),Le=_();if(ee.includes(Le))return;const Ve=ee[0];Ve&&E().review.setMode(Ve)}),ae(vt(()=>i().data.session_status[w.id??""]?.type,(ee,Le)=>{ee!=="idle"||Le===void 0||Le==="idle"||bi()},{defer:!0}));const Tn=()=>t.fileTree.tab(),di=ee=>t.fileTree.setTab(ee),[qs,Yn]=Ze({reviewScroll:void 0,pendingDiff:void 0});ae(vt(x,()=>{Yn({reviewScroll:void 0,pendingDiff:void 0})},{defer:!0}));const Cs=()=>{Tn()==="changes"&&di("all")},Ih=()=>{Oe()||st?.focus()};Tot(),Dot({navigateMessageByOffset:Oo,setActiveMessage:Po,focusInput:Ih,review:pe,fileBrowser:()=>$()&&F()&&!!w.id}),g.register("session-palette",()=>[{id:"command.palette",title:a.t("command.palette"),hidden:!0,onSelect:()=>g.trigger("file.open","palette")}]);const zd=zVe({showAllFiles:Cs,tabForPath:r.tab,openTab:C().open,setActive:C().setActive,loadFile:r.load}),yu=ee=>ee==="git"?a.t("ui.sessionReview.title.git"):ee==="branch"?a.t("ui.sessionReview.title.branch"):a.t("ui.sessionReview.title.lastTurn"),c0=()=>re()?h(aC,{get options(){return Ur()},get current(){return _()},label:yu,onSelect:ee=>ee&&E().review.setMode(ee),variant:"ghost",size:"small",valueClass:"text-14-medium"}):null,bu=()=>re()?h(iVe,{appearance:"inline",get options(){return Ur()},get current(){return _()},label:yu,placement:"bottom-start",gutter:6,onSelect:ee=>ee&&E().review.setMode(ee)}):null,wu=ee=>(()=>{var Le=Vot(),Ve=Le.firstChild;return S(Ve,ee),Le})(),Dh=ee=>(()=>{var Le=zot(),Ve=Le.firstChild,lt=Ve.firstChild,xt=lt.nextSibling;return S(lt,()=>a.t("session.review.noVcs.createGit.title")),S(xt,()=>a.t("session.review.noVcs.createGit.description")),S(Le,h(Kt,{size:"large",get disabled(){return Ht.isPending},onClick:Ie,get children(){return we(()=>!!Ht.isPending)()?a.t("session.review.noVcs.createGit.actionLoading"):a.t("session.review.noVcs.createGit.action")}}),null),he(()=>xr(Le,ee.emptyClass)),Le})(),Xa=I(()=>_()==="git"?a.t("session.review.noUncommittedChanges"):_()==="branch"?a.t("session.review.noBranchChanges"):a.t("session.review.noChanges")),oe=ee=>_()==="git"||_()==="branch"?Ni()?wu(Xa()):(()=>{var Le=K2();return S(Le,()=>a.t("session.review.loadingChanges")),he(()=>xr(Le,ee.loadingClass)),Le})():_()==="turn"?$n()?Dh(ee):wu(Xa()):(()=>{var Le=Hot(),Ve=Le.firstChild;return S(Ve,Xa),he(()=>xr(Le,ee.emptyClass)),Le})(),ue=()=>(_()==="git"||_()==="branch")&&!Ni()?(()=>{var ee=jot();return S(ee,()=>a.t("session.review.loadingChanges")),ee})():_()==="turn"&&$n()?h(kst,{get pending(){return Ht.isPending},onInitGit:Ie}):h(wst,{}),$e=ee=>h(q,{get when(){return!In.deferRender},get children(){return h(frt,{get title(){return c0()},get empty(){return oe(ee)},diffs:lr,view:E,get diffStyle(){return ee.diffStyle},get onDiffStyleChange(){return ee.onDiffStyleChange},onScrollRef:Le=>Yn("reviewScroll",Le),get focusedFile(){return ui()},onLineComment:Le=>Fe({...Le,origin:"review"}),onLineCommentUpdate:qe,onLineCommentDelete:_t,get lineCommentActions(){return Zt()},get commentMentions(){return{items:r.searchFilesAndDirectories}},get comments(){return m.all()},get focusedComment(){return m.focus()},get onFocusedCommentChange(){return m.setFocus},onViewFile:zd,get classes(){return ee.classes}})}}),Ke=Fst(),tt=()=>({get title(){return bu()},get empty(){return ue()},diffs:lr,diffsReady:Ni,get diffVersion(){return Zr.dataUpdatedAt},loadDiff:$o,get activeFile(){return ui()},onSelectFile:Er,get diffStyle(){return t.review.diffStyle()},onDiffStyleChange:t.review.setDiffStyle,state:Ke,onLineComment:ee=>Fe({...ee,origin:"review"}),onLineCommentUpdate:qe,onLineCommentDelete:_t,get lineCommentActions(){return Zt()},get comments(){return m.all()},get focusedComment(){return m.focus()},onFocusedCommentChange:ee=>{if(!ee){const Le=m.focus();Le&&lr().some(Ve=>Ve.file===Le.file)&&Er(Le.file)}m.setFocus(ee)}}),it=I(ee=>ee||!In.deferRender,!1),kt=()=>(()=>{var ee=qot();return S(ee,h(q,{get when(){return it()},get children(){return h(Ost,le(tt))}})),ee})(),Qt=()=>(()=>{var ee=Bot(),Le=ee.firstChild;return S(Le,()=>$e({diffStyle:t.review.diffStyle(),onDiffStyleChange:t.review.setDiffStyle,loadingClass:"px-6 py-4 text-text-weak",emptyClass:"h-full pb-64 -mt-4 flex flex-col items-center justify-center text-center gap-6"})),he(Ve=>ct(ee,{"flex flex-col h-full overflow-hidden contain-strict":!0,"bg-v2-background-bg-base":u.general.newLayoutDesigns(),"bg-background-stronger":!u.general.newLayoutDesigns()},Ve)),ee})();ae(vt(Je,ee=>{ee&&Tn()==="changes"&&Cs()},{defer:!0}));const pn=ee=>{const Le=so(ee);if(Le)return`session-review-diff-${Le}`},nn=ee=>{const Le=qs.reviewScroll;if(!Le)return;const Ve=pn(ee);if(!Ve)return;const lt=document.getElementById(Ve);if(!(lt instanceof HTMLElement)||!Le.contains(lt))return;const xt=lt.getBoundingClientRect(),Un=Le.getBoundingClientRect();return xt.top-Un.top+Le.scrollTop},vn=ee=>{const Le=qs.reviewScroll;if(!Le)return!1;const Ve=nn(ee);return Ve===void 0?!1:(E().setScroll("review",{x:Le.scrollLeft,y:Ve}),Le.scrollTo({top:Ve,behavior:"auto"}),!0)},Er=ee=>{fe(),E().review.openPath(ee),E().review.setFile(ee),Yn("pendingDiff",ee)};ae(()=>{const ee=qs.pendingDiff;if(!ee||!qs.reviewScroll||!Ni())return;const Le=Ve=>{if(qs.pendingDiff!==ee)return;if(Ve>60){Yn("pendingDiff",void 0);return}const lt=qs.reviewScroll;if(!lt){requestAnimationFrame(()=>Le(Ve+1));return}if(!vn(ee)){requestAnimationFrame(()=>Le(Ve+1));return}const xt=nn(ee);if(xt===void 0){requestAnimationFrame(()=>Le(Ve+1));return}if(Math.abs(lt.scrollTop-xt)<=1){Yn("pendingDiff",void 0);return}requestAnimationFrame(()=>Le(Ve+1))};requestAnimationFrame(()=>Le(0))});let Bn;ae(()=>{const ee=l().directory;if(!F()||!t.fileTree.opened()||i().status==="loading")return;Tn();const Le=Bn!==ee;Bn=ee,Le?r.tree.refresh(""):r.tree.list("")}),ae(vt(()=>l().directory,()=>{const ee=Je();if(!ee)return;const Le=r.pathFromTab(ee);Le&&r.load(Le,{force:!0})},{defer:!0}));const On=lRe({working:()=>!0,overflowAnchor:"none"});ae(vt(()=>w.id,(ee,Le)=>{!ee||!Le||ee===Le||v.hash||In.messageId||V.pendingMessage||On.resume()}));let rn,wn,ts;const xu=ee=>Math.max(400,ee.clientHeight),ku=ee=>{const Le=ee.scrollHeight-ee.clientHeight,Ve=Le-ee.scrollTop,lt=Le>1,xt=!lt||Ve<=2,Un=lt&&Ve>xu(ee);V.scroll.overflow===lt&&V.scroll.bottom===xt&&V.scroll.jump===Un||P("scroll",{overflow:lt,bottom:xt,jump:Un})},Bs=ee=>{wn=ee,rn===void 0&&(rn=requestAnimationFrame(()=>{rn=void 0;const Le=wn;wn=void 0,Le&&ku(Le)}))},Ro=()=>{Hn("messageId",void 0),On.resume(),_e(),aD();const ee=_n;ee&&Bs(ee)};ae(vt(On.userScrolled,ee=>{ee||(Hn("messageId",void 0),aD())},{defer:!0}));let Us=()=>{};const Hd=ee=>{_n=ee,On.scrollRef(ee),ee&&(Bs(ee),Us())},Lh=()=>{nt+=1};Oa(()=>pr,()=>{const ee=_n;ee&&Bs(ee),Us()});let ni=()=>{},Fo=ee=>{};const Yr=new Set;let fi;const _s=async()=>{const ee=O.capture();if(mt()||Yr.has(ee.key))return;Yr.add(ee.key);const Le=je.messages().length;try{await je.history.loadOlder({before:()=>ee.run(ni),after:Ve=>ee.run(()=>Fo(Ve))})}finally{Yr.delete(ee.key)}!ee.current()||je.messages().length<=Le||!On.userScrolled()||!_n||_n.scrollTop>=200||!Et()||(fi!==void 0&&cancelAnimationFrame(fi),fi=requestAnimationFrame(()=>{fi=void 0,ee.run(JI)}))},JI=()=>{Yr.has(O.key())||mt()||!On.userScrolled()||!_n||_n.scrollTop>=200||_s()};Te(()=>{fi!==void 0&&cancelAnimationFrame(fi)}),Us=()=>{ts===void 0&&(ts=requestAnimationFrame(()=>{if(ts=void 0,!w.id||!Qe()||On.userScrolled()||mt())return;const ee=_n;ee&&(ee.scrollHeight>ee.clientHeight+1||Et()&&_s())}))},ae(vt(()=>[w.id,Qe(),Et(),mt(),On.userScrolled(),un().length],([ee,Le,Ve,lt,xt])=>{!ee||!Le||lt||xt||Ve&&Us()},{defer:!0}));const l3=ee=>Zre(i().data.part[ee]??[],{directory:l().directory,attachmentName:a.t("common.attachment")}),kie=ee=>{const Le=l3(ee).map(Ve=>Ve.type==="image"?`[image:${Ve.filename}]`:Ve.content).join("").replace(/\s+/g," ").trim();return Le||`[${a.t("common.attachment")}]`},c3=ee=>{tn({variant:"error",title:a.t("common.requestFailed"),description:Uf(ee,a.t)})},by=(ee,Le,Ve=i())=>{const lt=Ve.session.get(ee);lt&&Ve.session.remember({...lt,revert:Le})},u3=ee=>i().data.session_working(ee),d3=I(()=>{const ee=w.id;return ee?er.items[ee]??eV:eV}),eD=I(()=>{const ee=w.id;if(ee)return er.edit[ee]}),wy=Yo(()=>({mutationFn:async ee=>{const Le=O.capture(),Ve=(er.items[ee.sessionID]??[]).find(xt=>xt.id===ee.id);!Ve||(ee.manual&&Lt("paused",ee.sessionID,void 0),Lt("failed",ee.sessionID,void 0),!await lne({api:l().api.session,sync:i(),serverSync:e(),draft:Ve,optimisticBusy:Ve.sessionDirectory===l().directory}).catch(xt=>(Lt("failed",ee.sessionID,ee.id),c3(xt),!1)))||(Lt("items",ee.sessionID,xt=>(xt??[]).filter(Un=>Un.id!==ee.id)),ee.manual&&Le.run(Ro))}})),xy=ee=>wy.isPending&&wy.variables?.sessionID===ee,Sie=I(()=>{const ee=w.id;if(ee&&xy(ee))return wy.variables?.id}),tD=I(()=>{const ee=w.id;return ee?u.general.followup()==="queue"&&u3(ee)&&!T.blocked()&&!Oe():!1}),Cie=ee=>{const Le=ee.prompt.map(Ve=>Ve.type==="image"?`[image:${Ve.filename}]`:Ve.type==="file"?`[file:${Ve.path}]`:Ve.type==="agent"?`@${Ve.name}`:Ve.content).join("").split(/\r?\n/).map(Ve=>Ve.trim()).find(Ve=>!!Ve);return Le||`[${a.t("common.attachment")}]`},nD=ee=>{Lt("items",ee.sessionID,Le=>[...Le??[],{id:wo.ascending("message"),...ee}]),Lt("failed",ee.sessionID,void 0),Lt("paused",ee.sessionID,void 0)},_ie=I(()=>d3().map(ee=>({id:ee.id,text:Cie(ee)}))),rD=(ee,Le,Ve)=>i().session.get(ee)?.parentID||!(er.items[ee]??[]).find(xt=>xt.id===Le)||xy(ee)?Promise.resolve():wy.mutateAsync({sessionID:ee,id:Le,manual:Ve?.manual}),Tie=ee=>{const Le=w.id;if(!Le||xy(Le))return;const Ve=d3().find(lt=>lt.id===ee);Ve&&(Lt("items",Le,lt=>(lt??[]).filter(xt=>xt.id!==ee)),Lt("failed",Le,lt=>lt===ee?void 0:lt),Lt("edit",Le,{id:Ve.id,prompt:Ve.prompt,context:Ve.context}))},iD=()=>{const ee=w.id;ee&&Lt("edit",ee,void 0)},f3=ee=>u3(ee)?l().api.session.interrupt({sessionID:ee}).catch(()=>{}):Promise.resolve(),sD=Yo(()=>({mutationFn:async ee=>{const Le=l().api.session,Ve=i(),lt=Ve.session.get(ee.sessionID)?.revert,xt=l3(ee.messageID);await nV({capturePrompt:f.capture,optimistic:Un=>{by(ee.sessionID,{messageID:ee.messageID},Ve),Un.set(xt)},request:()=>f3(ee.sessionID).then(()=>Le.revert.stage(ee)),complete:()=>{},rollback:()=>by(ee.sessionID,lt,Ve),fail:c3})}})),ky=Yo(()=>({mutationFn:async ee=>{const Le=w.id;if(!Le)return;const Ve=l().api.session,lt=i(),xt=et().find(vr=>vr.id>ee),Un=lt.session.get(Le)?.revert;await nV({capturePrompt:f.capture,optimistic:vr=>{if(by(Le,xt?{messageID:xt.id}:void 0,lt),xt){vr.set(l3(xt.id));return}vr.reset()},request:()=>xt?f3(Le).then(()=>Ve.revert.stage({sessionID:Le,messageID:xt.id}).then(()=>{})):f3(Le).then(()=>Ve.revert.clear({sessionID:Le})),complete:()=>{},rollback:()=>by(Le,Un,lt),fail:c3})}})),h3=I(()=>sD.isPending||ky.isPending),Eie=I(()=>ky.isPending?ky.variables:void 0),Iie=ee=>{if(!h3())return sD.mutateAsync(ee)},Die=ee=>{if(!(!w.id||h3()))return ky.mutateAsync(ee)},oD=I(()=>{const ee=Xe();return ee?et().filter(Le=>Le.id>=ee).map(Le=>({id:Le.id,text:kie(Le.id)})):[]}),Lie={revert:Iie,openAttachment:ee=>{const Le=()=>{const xt=document.createElement("a");xt.href=ee.url,xt.download=fn(ee.filename)||"attachment",xt.click()},Ve=ee.filename??"",lt=Ve.startsWith("/")||Ve.startsWith("\\\\")||/^[a-zA-Z]:[\\/]/.test(Ve);if(d.revealPath&&lt){d.revealPath(Ve).then(xt=>{xt||Le()},()=>Le());return}Le()}};ae(()=>{const ee=w.id;if(!ee)return;const Le=d3()[0];Le&&(xy(ee)||er.failed[ee]!==Le.id&&(er.paused[ee]||Oe()||T.blocked()||u3(ee)||rD(ee,Le.id)))}),Oa(()=>Ft,({height:ee})=>{const Le=Math.ceil(ee);if(Le===Rn)return;const Ve=_n,lt=Le-Rn,xt=Ve?!On.userScrolled()||Ve.scrollHeight-Ve.clientHeight-Ve.scrollTop<10+Math.max(0,lt):!1;Rn=Le,xt&&_e(),Ve&&Bs(Ve),Us()});const{clearMessageHash:aD,scrollToMessage:Aie}=Lot({sessionKey:x,sessionID:()=>w.id,messagesReady:Qe,visibleUserMessages:un,historyMore:Et,historyLoading:mt,loadMore:ee=>i().session.history.loadMore(ee),currentMessageId:()=>In.messageId,pendingMessage:()=>V.pendingMessage,setPendingMessage:ee=>P("pendingMessage",ee),setActiveMessage:Po,autoScroll:{pause:On.pause,forceScrollToBottom:()=>{On.resume(),_e()}},scroller:()=>_n,anchor:pa,revealMessage:ee=>ti(ee),scheduleScrollState:Bs,consumePendingMessage:t.pendingMessage.consume});ae(vt(()=>w.id,ee=>{ee||requestAnimationFrame(()=>st?.focus())})),sn(()=>{an(document,"keydown",Pt)}),Te(()=>{Nn!==void 0&&cancelAnimationFrame(Nn),Vn!==void 0&&cancelAnimationFrame(Vn),$r!==void 0&&window.clearTimeout($r),rn!==void 0&&cancelAnimationFrame(rn),ts!==void 0&&cancelAnimationFrame(ts)}),Oot();const m3=(ee=!1,Le=!1)=>h(rr,{get value(){return In.mobileTab},class:"h-auto",get children(){return h(rr.List,{classList:{"!h-9":ee,"[&::after]:!border-b-0 [&::after]:!border-t [&::after]:!border-border-weak-base":Le},get children(){return[h(rr.Trigger,{value:"session",classList:{"!w-1/2 !max-w-none":!0,"!border-b-0 !border-t !border-border-weak-base [&:has([data-selected])]:!border-t-transparent":Le},classes:{button:ee?"w-full !py-2":"w-full"},onClick:()=>Hn("mobileTab","session"),get children(){return a.t("session.tab.session")}}),h(rr.Trigger,{value:"changes",classList:{"!w-1/2 !max-w-none !border-r-0":!0,"!border-b-0 !border-t !border-border-weak-base [&:has([data-selected])]:!border-t-transparent":Le},classes:{button:ee?"w-full !py-2":"w-full"},onClick:()=>Hn("mobileTab","changes"),get children(){return we(()=>!!Ss())()?a.t("session.review.filesChanged",{count:js()}):a.t("session.review.change.other")}})]}})}}),lD=I(()=>!F()&&u.general.newLayoutDesigns()&&u.general.mobileTitlebarPosition()==="bottom"),Mie=(ee,Le)=>(ae(vt(x,Le,{defer:!0})),h(tie,{error:ee,get sessionID(){return w.id}})),cD=()=>[we(()=>Be()??""),h(q,{get when(){return we(()=>!!(!F()&&w.id&&u.general.newLayoutDesigns()))()&&!lD()},get children(){return m3(!0)}}),(()=>{var ee=Wot();return S(ee,h(Rr,{get children(){return[h(zt,{get when(){return we(()=>!!w.id)()&&es()},get children(){var Le=Uot();return S(Le,()=>$e({diffStyle:"unified",classes:{root:"pb-8 [&_[data-slot=session-review-list]]:pb-0",header:"px-4 !h-16 !pb-4",container:"px-4"},loadingClass:"px-4 py-4 text-text-weak",emptyClass:"h-full pb-64 -mt-4 flex flex-col items-center justify-center text-center gap-6"})),Le}}),h(zt,{get when(){return w.id},get children(){return h(q,{get when(){return we(()=>!!Qe())()?w.id:void 0},keyed:!0,children:Le=>h(fnt,{actions:Lie,get scroll(){return V.scroll},onResumeScroll:Ro,setScrollRef:Hd,onScheduleScrollState:Bs,get onAutoScrollHandleScroll(){return On.handleScroll},onMarkScrollGesture:$t,hasScrollGesture:Rt,onUserScroll:Lh,onHistoryScroll:JI,get onAutoScrollInteraction(){return On.handleInteraction},shouldAnchorBottom:()=>!v.hash&&!In.messageId&&!V.pendingMessage&&!On.userScrolled(),get centered(){return Ue()},setContentRef:Ve=>{pr=Ve,On.contentRef(Ve);const lt=_n;lt&&Bs(lt)},get userMessages(){return un()},setHistoryAnchor:Ve=>{ni=Ve.capture,Fo=Ve.restore},anchor:pa,setRevealMessage:Ve=>{ti=Ve},setScrollToEnd:Ve=>{_e=Ve}})})}}),h(zt,{when:!0,get children(){return h(Iqe,{get worktree(){return Pr()}})}})]}})),ee})(),h(q,{get when(){return we(()=>!!(w.id||!$()))()&&!es()},children:ee=>{const Le=xQe({state:T,sessionKey:x,sessionID:()=>w.id,prompt:f,ready:()=>!In.deferRender&&Qe(),centered:Ue,todo:{collapsed:()=>E().todoCollapsed.get(),onToggle:()=>E().todoCollapsed.set(!E().todoCollapsed.get())},followup:()=>w.id&&!Oe()?{items:_ie(),sending:Sie(),onSend:Ve=>void rD(w.id,Ve,{manual:!0}),onEdit:Tie}:void 0,revert:()=>oD().length>0?{items:oD(),restoring:Eie(),disabled:h3(),onRestore:Die}:void 0,onResponseSubmit:Ro,openParent:()=>{const Ve=xe()?.parentID;Ve&&b(w.serverKey?Wf(ra(w.serverKey),Ve):Qw(l().directory,Ve))},setPromptRef:Ve=>{st=Ve},setDockRef:Ve=>{Ft=Ve}});return h(yQe,{controller:Le,get promptInput(){return h(q,{get when(){return $()},get fallback(){return h(zZe,{get controls(){return D()},ref:Ve=>{st=Ve},get newSessionWorktree(){return Pr()},onNewSessionWorktreeReset:()=>Hn("newSessionWorktree","main"),onSubmit:()=>{m.clear(),Ro()},get edit(){return eD()},onEditLoaded:iD,shouldQueue:tD,onQueue:nD,onAbort:()=>{const Ve=w.id;Ve&&Lt("paused",Ve,!0)}})},children:Ve=>{const lt=JYe({get controls(){return D()},ref:xt=>{st=xt},get newSessionWorktree(){return Pr()},onNewSessionWorktreeReset:()=>Hn("newSessionWorktree","main"),onSubmit:()=>{m.clear(),Ro()},get edit(){return eD()},onEditLoaded:iD,shouldQueue:tD,onQueue:nD,onAbort:()=>{const xt=w.id;xt&&Lt("paused",xt,!0)}});return h(QYe,{controller:lt,borderUnderlay:!0})}})}})}}),h(q,{get when(){return we(()=>!!w.id)()&&lD()},get children(){return m3(!0,!0)}})];return h(nie,{get children(){return[h(hze,{}),(()=>{var ee=Yot(),Le=ee.firstChild,Ve=ie;return typeof Ve=="function"?pt(Ve,ee):ie=ee,S(ee,h(q,{get when(){return we(()=>!!(!F()&&w.id))()&&!u.general.newLayoutDesigns()},get children(){return m3()}}),Le),S(Le,(()=>{var lt=we(()=>!!u.general.newLayoutDesigns());return()=>lt()?h(q,{get when(){return M()},keyed:!0,children:xt=>h(UC,{newLayout:!0,get raised(){return!!w.id},get children(){return h(KC,{fallback:Mie,get children(){return cD()}})}})}):h(UC,{newLayout:!1,get raised(){return!!w.id},get children(){return cD()}})})(),null),S(Le,h(q,{get when(){return ve()},get children(){var lt=K2();return lt.$$pointerdown=()=>j.start(),S(lt,h(Gf,{get classList(){return{"-right-1":u.general.newLayoutDesigns()}},direction:"horizontal",get size(){return U()},min:bre,get max(){return de()},onResize:xt=>{j.touch(),t.session.resize(xt)}})),lt}}),null),S(ee,h(q,{get when(){return we(()=>!$())()&&ne()},get children(){return h(ov,{get children(){return h(GN,{canReview:re,diffs:lr,diffsReady:Ni,empty:Xa,hasReview:Ss,reviewHasFocusableContent:Ss,reviewCount:js,reviewPanel:Qt,get activeDiff(){return ui()},focusReviewDiff:Er,get reviewSnap(){return V.reviewSnap},size:j})}})}}),null),S(ee,h(q,{get when(){return $()},get children(){return h(q,{get when(){return we(()=>!!F())()?Z().visible:J()},get children(){var lt=Zot();return S(lt,h(q,{get when(){return we(()=>!!F())()&&(W()||te())},get children(){var xt=Kot();return S(xt,h(ov,{get children(){return h(GN,{canReview:re,diffs:lr,diffsReady:Ni,empty:Xa,hasReview:Ss,reviewHasFocusableContent:()=>Ss()||Ke.sidebarOpened(),reviewCount:js,reviewPanel:kt,reviewSidebarToggle:Un=>h(Oit,{get opened(){return Ke.sidebarOpened()},disabled:Un,get onToggle(){return Ke.toggleSidebar}}),fileBrowserState:Ke,get activeDiff(){return ui()},focusReviewDiff:Er,get reviewSnap(){return V.reviewSnap},size:j,get stacked(){return Z().stacked}})}})),xt}}),null),S(lt,h(q,{get when(){return Z().stacked},get children(){var xt=Got();return xt.$$pointerdown=()=>j.start(),S(xt,h(Gf,{class:"!relative !inset-auto !h-full !w-full !transform-none",direction:"vertical",get size(){return t.terminal.height()},min:100,get max(){return typeof window>"u"?600:window.innerHeight*.6},collapseThreshold:50,onResize:Un=>{j.touch(),t.terminal.resize(Un)},onCollapse:()=>E().terminal.close()})),xt}}),null),S(lt,h(q,{get when(){return J()},get children(){var xt=K2();return S(xt,h(_ot,{get stacked(){return Z().stacked}})),he(Un=>ct(xt,{"min-h-0 shrink-0":Z().stacked,"min-h-0 flex-1":!Z().stacked},Un)),xt}}),null),lt}})}}),null),he(lt=>{var xt={"gap-2 p-2":u.general.newLayoutDesigns()},Un={"@container relative shrink-0 flex flex-col min-h-0 h-full flex-1 md:flex-none transition-[width]":!0,"duration-[240ms] ease-[cubic-bezier(0.22,1,0.36,1)] will-change-[width] motion-reduce:transition-none":!j.active()&&!V.reviewSnap&&!X()},vr=He();return lt.e=ct(ee,xt,lt.e),lt.t=ct(Le,Un,lt.t),vr!==lt.a&&Ct(Le,"width",lt.a=vr),lt},{e:void 0,t:void 0,a:void 0}),ee})(),h(q,{get when(){return!$()},get children(){return h(dot,{})}})]}})}dn(["pointerdown"]);function oat(){const e=Di(),t=li(),n=ci(),r=ms(),i=ks(),s=t.home.selection,o=I(()=>r.servers.list().find(y=>ut.key(y)===s().server)??n.current),a=I(()=>{const y=o();if(y)return r.ensureServerCtx(y)}),l=()=>a()?.sync??e(),c=I(()=>a()?.projects.list()??t.projects.list()),u=I(()=>a()?.projects.recentlyClosed()??t.projects.recentlyClosed()),d=I(()=>l().data.path.home??""),f=I(()=>c().find(y=>y.worktree===s().directory)),m=I(()=>f()??c().find(y=>y.worktree===a()?.projects.last())??c()[0]);ae(()=>{const y=r.servers.list();if(y.some(b=>ut.key(b)===s().server))return;const v=y.find(b=>ut.key(b)===n.key)??y[0];v&&g({server:ut.key(v)})});function g(y){t.home.setSelection(y)}function p(y,v){const b=r.ensureServerCtx(y);b.projects.open(v),b.projects.touch(v),i.newDraft({server:ut.key(y),directory:v})}return{selection:{value:s,set:g,focusServer:y=>g({server:ut.key(y)})},server:{list:r.servers.list,health:y=>r.servers.health[ut.key(y)],context:y=>r.ensureServerCtx(y),focused:o,focusedContext:a,focusedSync:l},project:{list:c,recentlyClosed:u,homedir:d,selected:f,newSession:m,forServer:y=>r.ensureServerCtx(y).projects.list(),select:(y,v)=>{const b=ut.key(y);r.servers.health[b]?.healthy!==!1&&r.ensureServerCtx(y).projects.list().some(w=>w.worktree===v)&&g(OPe(s(),b,v))},add:(y,v)=>{const b=v[0];if(!b)return;const w=r.ensureServerCtx(y);v.forEach(x=>w.projects.open(x)),w.projects.touch(b),g({server:ut.key(y),directory:b})},openNewSession:()=>{const y=o(),v=m();!y||!v||p(y,v.worktree)},openProjectNewSession:p}}}var aat=A("<span class=text-text-invert-weak>v"),lat=A('<span class="flex items-center gap-2"><span>'),cat=A('<div><div class="flex flex-col items-start min-w-0 w-full"><div class="flex flex-row items-center gap-2 min-w-0 w-full"><span>'),uat=A("<span>v"),dat=A('<div class="flex flex-row gap-3"><span>'),fat=A("<span class=text-text-weak>"),hat=A("<span class=text-text-weaker>"),mat=A("<span class=text-text-weak>••••••••"),gat=A("<div>");function pat(e){const t=wt(),[n,r]=De(!1);let i,s;const o=I(()=>hd(e.conn)),a=()=>{const u=i?i.scrollWidth>i.clientWidth:!1,d=s?s.scrollWidth>s.clientWidth:!1;r(u||d)};ae(()=>{o(),e.conn.http.url,e.status?.version,queueMicrotask(a)}),sn(()=>{typeof ResizeObserver=="function"&&(Oa([i,s],a),a())});const l=()=>(()=>{var u=lat(),d=u.firstChild;return S(d,()=>hd(e.conn,!0)),S(u,h(q,{get when(){return e.status?.version},get children(){var f=aat();return f.firstChild,S(f,()=>e.status?.version,null),f}}),null),u})(),c=Jl(()=>e.badge);return h(Ar,{class:"flex-1 min-w-0",get value(){return l()},contentStyle:{"max-width":"none","white-space":"nowrap"},placement:"top-start",get inactive(){return we(()=>!n())()&&!e.conn.displayName},get children(){var u=cat(),d=u.firstChild,f=d.firstChild,m=f.firstChild,g=i;return typeof g=="function"?pt(g,m):i=m,S(m,o),S(f,h(q,{get when(){return c()},get fallback(){return h(q,{get when(){return e.status?.version},get children(){var p=uat();p.firstChild;var y=s;return typeof y=="function"?pt(y,p):s=p,S(p,()=>e.status?.version,null),he(()=>xr(p,`${e.versionClass??"text-text-weak text-14-regular truncate"} min-w-0`)),p}})},children:p=>p()}),null),S(d,h(q,{get when(){return we(()=>!!(e.showCredentials&&e.conn.type==="http"))()&&e.conn},children:p=>(()=>{var y=dat(),v=y.firstChild;return S(v,(()=>{var b=we(()=>!!p().http.username);return()=>b()?(()=>{var w=fat();return S(w,()=>p().http.username),w})():(()=>{var w=hat();return S(w,()=>t.t("server.row.noUsername")),w})()})()),S(y,(()=>{var b=we(()=>!!p().http.password);return()=>b()&&mat()})(),null),y})()}),null),S(u,()=>e.children,null),he(p=>{var y=e.class,v=!!e.dimmed,b=`${e.nameClass??"truncate"} min-w-0`;return y!==p.e&&xr(u,p.e=y),v!==p.t&&u.classList.toggle("opacity-50",p.t=v),b!==p.a&&xr(m,p.a=b),p},{e:void 0,t:void 0,a:void 0}),u}})}function rie(e){return(()=>{var t=gat();return he(n=>ct(t,{"size-1.5 rounded-full shrink-0 my-[3.5px]":!0,"bg-icon-success-base":e.health?.healthy===!0,"bg-icon-critical-base":e.health?.healthy===!1,"bg-border-weak-base":e.health===void 0},n)),t})()}var vat=A('<div><div class="bg-surface-base rounded-md p-5 flex flex-col gap-3"><div class="flex-1 min-w-0 [&amp;_[data-slot=input-wrapper]]:relative"></div><div class="grid grid-cols-2 gap-2 min-w-0">'),yat=A('<div class="flex flex-1 min-h-0 flex-col px-5">'),bat=A('<div class="flex items-center gap-2 -ml-2"><span>'),iie=A('<div class="flex flex-1 min-h-0 flex-col gap-4"><div class="shrink-0 pb-5">'),wat=A('<div class="flex items-center gap-3 min-w-0 flex-1 w-full group/item"><div class="flex flex-col h-full items-center w-5"></div><div class="flex items-center justify-center gap-4 pl-4">'),xat=A('<span class="text-text-base bg-surface-base text-14-regular px-1.5 rounded-xs">');const a6="opencode";function WC(e,t){tn({variant:"error",title:e.t("common.requestFailed"),description:t instanceof Error?t.message:String(t)})}function kat(){const e=wt(),t=Tr(),[n,r]=ai(async()=>{try{const o=await t.getDefaultServer?.();return o||null}catch(o){return WC(e,o),null}},{initialValue:null}),i=I(()=>!!t.getDefaultServer&&!!t.setDefaultServer);return{defaultKey:()=>n.latest,canDefault:i,setDefault:async o=>{try{await t.setDefaultServer?.(o),r.mutate(o)}catch(a){WC(e,a)}}}}function Sat(){const e=U4(),t=r=>{const i=jv(r);if(!i)return!1;const s=i.replace(/^https?:\/\//,"").split("/")[0];return s?s.includes("localhost")||s.startsWith("127.0.0.1")?!0:s.includes(".")||s.includes(":"):!1};return{previewStatus:async(r,i,s,o)=>{if(o(void 0),!t(r))return;const a=jv(r);if(!a)return;const l={url:a};i&&(l.username=i),s&&(l.password=s);const c=await e(l);o(c.healthy)}}}function Cat(e){const t=wt(),n=r=>{if(r.stopPropagation(),r.key==="Escape"){r.preventDefault(),e.onBack();return}r.key!=="Enter"||r.isComposing||(r.preventDefault(),e.onSubmit())};return(()=>{var r=vat(),i=r.firstChild,s=i.firstChild,o=s.nextSibling;return S(s,h(Cf,{type:"text",get label(){return t.t("dialog.server.add.url")},get placeholder(){return e.placeholder},get value(){return e.value},autofocus:!0,get validationState(){return e.error?"invalid":"valid"},get error(){return e.error},get disabled(){return e.busy},get onChange(){return e.onChange},onKeyDown:n})),S(i,h(Cf,{type:"text",get label(){return t.t("dialog.server.add.name")},get placeholder(){return t.t("dialog.server.add.namePlaceholder")},get value(){return e.name},get disabled(){return e.busy},get onChange(){return e.onNameChange},onKeyDown:n}),o),S(o,h(Cf,{type:"text",get label(){return t.t("dialog.server.add.username")},get placeholder(){return t.t("dialog.server.add.usernamePlaceholder")},get value(){return e.username},get disabled(){return e.busy},get onChange(){return e.onUsernameChange},onKeyDown:n}),null),S(o,h(Cf,{type:"password",get label(){return t.t("dialog.server.add.password")},get placeholder(){return t.t("dialog.server.add.passwordPlaceholder")},get value(){return e.password},get disabled(){return e.busy},get onChange(){return e.onPasswordChange},onKeyDown:n}),null),r})()}function sie(){const e=Mr(),t=a3({onSelect:e.close});return h(ou,{get title(){return t.formTitle()},get children(){var n=yat();return S(n,h(q,{get when(){return t.isFormMode()},get fallback(){return h(oie,{controller:t})},get children(){return h(aie,{controller:t})}})),n}})}function a3(e={}){const t=fs(),n=ci(),r=ks(),i=ms(),s=Tr(),o=wt(),{defaultKey:a,canDefault:l,setDefault:c}=kat(),{previewStatus:u}=Sat(),d=U4(),[f,m]=Ze({addServer:{url:"",name:"",username:a6,password:"",error:"",showForm:!1,status:void 0},editServer:{id:void 0,value:"",name:"",username:"",password:"",error:"",status:void 0}}),g=()=>{m("addServer",{url:"",name:"",username:a6,password:"",error:"",showForm:!1,status:void 0})},p=()=>{m("editServer",{id:void 0,value:"",name:"",username:"",password:"",error:"",status:void 0})},y=Yo(()=>({mutationFn:async ne=>{const ie=jv(ne);if(!ie){g();return}const ke={type:"http",http:{url:ie}};if(f.addServer.name.trim()&&(ke.displayName=f.addServer.name.trim()),f.addServer.password&&(ke.http.password=f.addServer.password),f.addServer.password&&f.addServer.username&&(ke.http.username=f.addServer.username),!(await d(ke.http)).healthy){m("addServer",{error:o.t("dialog.server.add.error")});return}if(!x.general.newLayoutDesigns()&&await Y7(ke.http,s.fetch??globalThis.fetch)==="v2"){m("addServer",{error:o.t("dialog.server.add.error")});return}if(g(),e.navigateOnAdd===!1){n.add(ke),e.onSelect?.();return}await E(ke,!0)}})),v=Yo(()=>({mutationFn:async ne=>{if(ne.original.type!=="http")return;const ie=jv(ne.value);if(!ie){p();return}const ke=f.editServer.name.trim()||void 0,ge=f.editServer.username||void 0,Pe=f.editServer.password||void 0,Me=ne.original.displayName;if(ie===ne.original.http.url&&ke===Me&&ge===ne.original.http.username&&Pe===ne.original.http.password){p();return}const de={type:"http",displayName:ke,http:{url:ie,username:ge,password:Pe}};if(!(await d(de.http)).healthy){m("editServer",{error:o.t("dialog.server.add.error")});return}if(!x.general.newLayoutDesigns()&&await Y7(de.http,s.fetch??globalThis.fetch)==="v2"){m("editServer",{error:o.t("dialog.server.add.error")});return}ie===ne.original.http.url?n.add(de):b(ne.original,de),p()}})),b=(ne,ie)=>{const ke=ut.key(ne),ge=n.key;r.removeServer(ke);const Pe=n.add(ie);if(!Pe)return;const Me=ge===ke?ut.key(Pe):ge;Me&&n.setActive(Me),n.remove(ke)},w=I(()=>{const ne=n.current,ie=n.list;return ne?ie.includes(ne)?[ne,...ie.filter(ke=>ke!==ne)]:[ne,...ie]:ie}),x=ar(),k=I(()=>x.general.newLayoutDesigns()?void 0:w().find(ne=>ut.key(ne)===n.key)??w()[0]),C=I(()=>{const ne=w(),ie=x.general.newLayoutDesigns()?ne:ne.filter(Me=>i.ensureServerCtx(Me).sdk.protocolKind()!=="v2");if(!ie.length)return ie;const ke=k(),ge=new Map(ie.map((Me,de)=>[Me,de])),Pe=Me=>Me?.healthy===!0?0:Me?.healthy===!1?2:1;return ie.slice().sort((Me,de)=>{if(Me===ke)return-1;if(de===ke)return 1;const U=Pe(i.servers.health[ut.key(Me)])-Pe(i.servers.health[ut.key(de)]);return U!==0?U:(ge.get(Me)??0)-(ge.get(de)??0)})});async function E(ne,ie){if(!(!ie&&i.servers.health[ut.key(ne)]?.healthy===!1)){if(e.onSelect?.(),ie&&ne.type==="http"){n.add(ne),t("/");return}t("/"),queueMicrotask(()=>n.setActive(ut.key(ne)))}}const _=ne=>{y.isPending||(m("addServer",{url:ne,error:""}),u(ne,f.addServer.username,f.addServer.password,ie=>m("addServer",{status:ie})))},L=ne=>{y.isPending||m("addServer",{name:ne,error:""})},O=ne=>{y.isPending||(m("addServer",{username:ne,error:""}),u(f.addServer.url,ne,f.addServer.password,ie=>m("addServer",{status:ie})))},$=ne=>{y.isPending||(m("addServer",{password:ne,error:""}),u(f.addServer.url,f.addServer.username,ne,ie=>m("addServer",{status:ie})))},V=ne=>{v.isPending||(m("editServer",{value:ne,error:""}),u(ne,f.editServer.username,f.editServer.password,ie=>m("editServer",{status:ie})))},P=ne=>{v.isPending||m("editServer",{name:ne,error:""})},T=ne=>{v.isPending||(m("editServer",{username:ne,error:""}),u(f.editServer.value,ne,f.editServer.password,ie=>m("editServer",{status:ie})))},D=ne=>{v.isPending||(m("editServer",{password:ne,error:""}),u(f.editServer.value,f.editServer.username,ne,ie=>m("editServer",{status:ie})))},N=I(()=>f.editServer.id?"edit":f.addServer.showForm?"add":"list"),M=I(()=>{if(f.editServer.id)return w().find(ne=>ne.type==="http"&&ne.http.url===f.editServer.id)}),F=()=>{g(),p()},j=()=>{p(),m("addServer",{showForm:!0,url:"",name:"",username:a6,password:"",error:"",status:void 0})},z=ne=>{g(),m("editServer",{id:ne.http.url,value:ne.http.url,name:ne.displayName??"",username:ne.http.username??"",password:ne.http.password??"",error:"",status:i.servers.health[ut.key(ne)]?.healthy})},W=()=>{if(N()==="add"){if(y.isPending)return;m("addServer",{error:""}),y.mutate(f.addServer.url);return}const ne=M();ne&&(v.isPending||(m("editServer",{error:""}),v.mutate({original:ne,value:f.editServer.value})))},J=I(()=>N()!=="list"),K=I(()=>N()==="add"),X=I(()=>K()?y.isPending:v.isPending),te=I(()=>J()?(()=>{var ne=bat(),ie=ne.firstChild;return S(ne,h(Ln,{icon:"arrow-left",variant:"ghost",onClick:F,get"aria-label"(){return o.t("common.goBack")}}),ie),S(ie,(()=>{var ke=we(()=>!!K());return()=>ke()?o.t("dialog.server.add.title"):o.t("dialog.server.edit.title")})()),ne})():o.t("dialog.server.title"));ae(()=>{f.editServer.id&&(M()||p())});async function ve(ne){try{ne.startsWith("wsl:")&&await s.wslServers?.removeServer(ne),r.removeServer(ne),n.remove(ne),await s.getDefaultServer?.()===ne&&await c(null)}catch(ie){WC(o,ie)}}return{defaultKey:a,canDefault:l,current:k,sortedItems:C,status:()=>i.servers.health,isFormMode:J,isAddMode:K,formTitle:te,formBusy:X,formValue:()=>K()?f.addServer.url:f.editServer.value,formName:()=>K()?f.addServer.name:f.editServer.name,formUsername:()=>K()?f.addServer.username:f.editServer.username,formPassword:()=>K()?f.addServer.password:f.editServer.password,formError:()=>K()?f.addServer.error:f.editServer.error,formStatus:()=>K()?f.addServer.status:f.editServer.status,select:E,setDefault:c,startAdd:j,startEdit:z,resetForm:F,submitForm:W,handleRemove:ve,handleFormChange:()=>K()?_:V,handleFormNameChange:()=>K()?L:P,handleFormUsernameChange:()=>K()?O:T,handleFormPasswordChange:()=>K()?$:D}}function oie(e){const t=wt(),n=ar();return(()=>{var r=iie(),i=r.firstChild;return S(r,h(a1,{class:"flex-1 min-h-0 [&_[data-slot=list-search-wrapper]]:w-full [&_[data-slot=list-scroll]]:flex-1 [&_[data-slot=list-scroll]]:overflow-y-auto [&_[data-slot=list-items]]:bg-surface-base [&_[data-slot=list-items]]:rounded-md [&_[data-slot=list-item]]:min-h-14 [&_[data-slot=list-item]]:p-3 [&_[data-slot=list-item]]:!bg-transparent",get search(){return{placeholder:t.t("dialog.server.search.placeholder"),autofocus:!1}},noInitialSelection:!0,get emptyMessage(){return t.t("dialog.server.empty")},get items(){return e.controller.sortedItems},key:s=>s.http.url,onSelect:s=>{s&&!n.general.newLayoutDesigns()&&e.controller.select(s)},divider:!0,children:s=>{const o=ut.key(s);return(()=>{var a=wat(),l=a.firstChild,c=l.nextSibling;return S(l,h(rie,{get health(){return e.controller.status()[o]}})),S(a,h(pat,{conn:s,get dimmed(){return e.controller.status()[o]?.healthy===!1},get status(){return e.controller.status()[o]},class:"flex items-center gap-3 min-w-0 flex-1",get badge(){return h(q,{get when(){return e.controller.defaultKey()===ut.key(s)},get children(){var u=xat();return S(u,()=>t.t("dialog.server.status.default")),u}})},showCredentials:!0}),c),S(c,h(q,{get when(){return we(()=>!!e.controller.current())()&&ut.key(e.controller.current())===o},get children(){return h(Yt,{name:"check",class:"h-6"})}}),null),S(c,h(q,{get when(){return s.type==="http"},get children(){return h(at,{get children(){return[h(at.Trigger,{as:Ln,icon:"dot-grid",variant:"ghost",class:"shrink-0 size-8 hover:bg-surface-base-hover data-[expanded]:bg-surface-base-active",onClick:u=>u.stopPropagation(),onPointerDown:u=>u.stopPropagation()}),h(at.Portal,{get children(){return h(at.Content,{class:"mt-1",get children(){return[h(at.Item,{onSelect:()=>{s.type==="http"&&e.controller.startEdit(s)},get children(){return h(at.ItemLabel,{get children(){return t.t("dialog.server.menu.edit")}})}}),h(q,{get when(){return we(()=>!!e.controller.canDefault())()&&e.controller.defaultKey()!==o},get children(){return h(at.Item,{onSelect:()=>e.controller.setDefault(o),get children(){return h(at.ItemLabel,{get children(){return t.t("dialog.server.menu.default")}})}})}}),h(q,{get when(){return we(()=>!!e.controller.canDefault())()&&e.controller.defaultKey()===o},get children(){return h(at.Item,{onSelect:()=>e.controller.setDefault(null),get children(){return h(at.ItemLabel,{get children(){return t.t("dialog.server.menu.defaultRemove")}})}})}}),h(at.Separator,{}),h(at.Item,{onSelect:()=>e.controller.handleRemove(ut.key(s)),class:"text-text-on-critical-base hover:bg-surface-critical-weak",get children(){return h(at.ItemLabel,{get children(){return t.t("dialog.server.menu.delete")}})}})]}})}})]}})}}),null),a})()}}),i),S(i,h(Kt,{variant:"secondary",icon:"plus-small",size:"large",get onClick(){return e.controller.startAdd},class:"py-1.5 pl-1.5 pr-3 flex items-center gap-1.5",get children(){return t.t("dialog.server.add.button")}})),r})()}function aie(e){const t=wt();return(()=>{var n=iie(),r=n.firstChild;return S(n,h(Cat,{get value(){return e.controller.formValue()},get name(){return e.controller.formName()},get username(){return e.controller.formUsername()},get password(){return e.controller.formPassword()},get placeholder(){return t.t("dialog.server.add.placeholder")},get busy(){return e.controller.formBusy()},get error(){return e.controller.formError()},get status(){return e.controller.formStatus()},get onChange(){return e.controller.handleFormChange()},get onNameChange(){return e.controller.handleFormNameChange()},get onUsernameChange(){return e.controller.handleFormUsernameChange()},get onPasswordChange(){return e.controller.handleFormPasswordChange()},get onSubmit(){return e.controller.submitForm},get onBack(){return e.controller.resetForm}}),r),S(r,h(Kt,{variant:"primary",size:"large",get onClick(){return e.controller.submitForm},get disabled(){return e.controller.formBusy()},class:"px-3 py-1.5",get children(){return we(()=>!!e.controller.formBusy())()?t.t("dialog.server.add.checking"):we(()=>!!e.controller.isAddMode())()?t.t("dialog.server.add.button"):t.t("common.save")}})),n})()}const _at=Object.freeze(Object.defineProperty({__proto__:null,DialogSelectServer:sie,ServerConnectionForm:aie,ServerConnectionList:oie,useServerManagementController:a3},Symbol.toStringTag,{value:"Module"}));var Tat=A("<div>");function Eat(e){const[t,n]=Ee(e,["class","classList"]);return(()=>{var r=Tat();return An(r,le(n,{role:"separator","aria-orientation":"horizontal","data-component":"divider-v2",get classList(){return{...t.classList,[t.class??""]:!!t.class}}}),!1,!1),r})()}var Iat=A("<span class=settings-v2-server-dialog-error>"),Dat=A('<div class="flex w-full min-w-0 flex-col gap-6"><div class="flex w-full min-w-0 flex-col gap-2"><label class=settings-v2-server-dialog-label></label></div><div class="flex w-full min-w-0 flex-col gap-2"><label class=settings-v2-server-dialog-label></label></div><div class="grid w-full min-w-0 grid-cols-2 gap-4"><div class="flex min-w-0 flex-col gap-2"><label class=settings-v2-server-dialog-label></label></div><div class="flex min-w-0 flex-col gap-2"><label class=settings-v2-server-dialog-label>');const Lat=e=>{const t=Mr(),n=wt(),r=a3({onSelect:()=>t.close(),navigateOnAdd:!1}),[i,s]=De(!1);sn(()=>{e.mode==="add"&&r.startAdd(),e.mode==="edit"&&e.server&&r.startEdit(e.server),s(!0)}),Te(()=>{r.resetForm()}),ae(()=>{i()&&(r.isFormMode()||t.close())});const o=c=>{c.key!=="Enter"||c.isComposing||(c.preventDefault(),r.submitForm())},a=()=>e.mode==="add"?n.t("dialog.server.add.title"):n.t("dialog.server.edit.title"),l=()=>r.formBusy()?n.t("dialog.server.add.checking"):e.mode==="add"?n.t("dialog.server.add.button"):n.t("common.save");return h(gne,{fit:!0,class:"settings-v2-server-dialog",get children(){return[h($I,{hideClose:!0,get children(){return h(mne,{get children(){return a()}})}}),h(Eat,{}),h(hne,{class:"flex w-full min-w-0 flex-1 flex-col px-4 pt-4 pb-2",get children(){var c=Dat(),u=c.firstChild,d=u.firstChild,f=u.nextSibling,m=f.firstChild,g=f.nextSibling,p=g.firstChild,y=p.firstChild,v=p.nextSibling,b=v.firstChild;return S(d,()=>n.t("dialog.server.add.url")),S(u,h(Dp,{type:"text",appearance:"large",class:"!w-full self-stretch",get value(){return r.formValue()},get placeholder(){return n.t("dialog.server.add.placeholder")},get invalid(){return!!r.formError()},get disabled(){return r.formBusy()},autofocus:!0,onInput:w=>r.handleFormChange()(w.currentTarget.value),onKeyDown:o}),null),S(u,h(q,{get when(){return r.formError()},get children(){var w=Iat();return S(w,()=>r.formError()),w}}),null),S(m,()=>n.t("dialog.server.add.name")),S(f,h(Dp,{type:"text",appearance:"large",class:"!w-full self-stretch",get value(){return r.formName()},get placeholder(){return n.t("dialog.server.add.namePlaceholder")},get disabled(){return r.formBusy()},onInput:w=>r.handleFormNameChange()(w.currentTarget.value),onKeyDown:o}),null),S(y,()=>n.t("dialog.server.add.username")),S(p,h(Dp,{type:"text",appearance:"large",class:"!w-full self-stretch",get value(){return r.formUsername()},get placeholder(){return n.t("dialog.server.add.usernamePlaceholder")},get disabled(){return r.formBusy()},onInput:w=>r.handleFormUsernameChange()(w.currentTarget.value),onKeyDown:o}),null),S(b,()=>n.t("dialog.server.add.password")),S(v,h(Dp,{type:"password",appearance:"large",class:"!w-full self-stretch",get value(){return r.formPassword()},get placeholder(){return n.t("dialog.server.add.passwordPlaceholder")},get disabled(){return r.formBusy()},onInput:w=>r.handleFormPasswordChange()(w.currentTarget.value),onKeyDown:o}),null),c}}),h(fne,{get children(){return[h(as,{variant:"neutral",get disabled(){return r.formBusy()},onClick:()=>t.close(),get children(){return n.t("common.cancel")}}),h(as,{variant:"contrast",get disabled(){return r.formBusy()},get onClick(){return r.submitForm},get children(){return l()}})]}})]}})};function Aat(e){const t=Tr(),n=Bk(),r=Mr(),i=wt(),s=gh(),o=wne(),a=a3({navigateOnAdd:!1}),[l,c,u,d]=_r(Jn.global("home.servers",["home.servers.v1"]),Ze({collapsed:{}})),[f]=ai(()=>d.promise??Promise.resolve(),p=>p.then(()=>l),{initialValue:l});function m(p){return[p.worktree,...p.sandboxes??[]]}function g(p){return t.platform==="desktop"&&!!t.openPath&&ut.local(p)}return{copy:{language:i},selection:{value:e.selection.value},server:{list:e.server.list,health:e.server.health,projects:e.project.forServer,collapsed:p=>f().collapsed[ut.key(p)]??!1,toggleCollapsed:p=>{const y=ut.key(p);c("collapsed",y,!f().collapsed[y])},canDefault:a.canDefault,defaultKey:a.defaultKey,setDefault:p=>a.setDefault(p?ut.key(p):null),remove:p=>a.handleRemove(ut.key(p)),edit:p=>r.show(()=>h(Lat,{mode:"edit",server:p})),focus:e.selection.focusServer},project:{list:e.project.list,recentlyClosed:e.project.recentlyClosed,homedir:e.project.homedir,select:e.project.select,add:e.project.add,openNewSession:e.project.openProjectNewSession,edit:(p,y)=>{B(async()=>{const{DialogEditProjectV2:v}=await import("./dialog-edit-project-v2-S63kVJ-3.js");return{DialogEditProjectV2:v}},__vite__mapDeps([122,114,123])).then(({DialogEditProjectV2:v})=>{r.show(()=>h(v,{server:p,project:y}))})},unseenCount:(p,y)=>{const v=s.ensureServerState(ut.key(p));return m(y).reduce((b,w)=>b+v.project.unseenCount(w),0)},clearNotifications:(p,y)=>{const v=s.ensureServerState(ut.key(p));m(y).filter(b=>v.project.unseenCount(b)>0).forEach(b=>v.project.markViewed(b))},choose:p=>{e.server.health(p)?.healthy!==!1&&n({server:p,title:i.t("command.project.open"),multiple:!0,onSelect:y=>e.project.add(p,FPe(y))})},close:(p,y)=>{const v=RPe(e.selection.value(),ut.key(p),e.server.context(p).projects,y);v&&e.selection.set(v)},move:(p,y,v)=>{e.server.context(p).projects.move(y,v)},canReveal:g,reveal:(p,y)=>{!t.openPath||!g(p)||t.openPath(y.worktree).catch(v=>tn({title:i.t("common.requestFailed"),description:Jp(v,i.t("common.requestFailed"))}))}},utility:{settings:o,help:()=>t.openLink("https://opencode.ai/desktop-feedback")}}}const edt=e=>{const t=wt(),n=ut.key(e.server);return h(cie,{get server(){return e.server},get labels(){return lie(t)},get canDefault(){return e.controller.canDefault()},get isDefault(){return e.controller.defaultKey()===n},get onEdit(){return e.onEdit},onSetDefault:()=>e.controller.setDefault(n),onRemoveDefault:()=>e.controller.setDefault(null),onRemove:()=>e.controller.handleRemove(n),get open(){return e.open},get onOpenChange(){return e.onOpenChange}})};function lie(e){return{more:e.t("common.moreOptions"),server:e.t("settings.section.server"),edit:e.t("dialog.server.menu.edit"),default:e.t("dialog.server.menu.default"),defaultRemove:e.t("dialog.server.menu.defaultRemove"),delete:e.t("dialog.server.menu.delete")}}const cie=e=>{const t=()=>ut.builtin(e.server),n=()=>e.server.type==="http"?e.server:void 0;return h(Tt,{gutter:6,modal:!1,placement:"bottom-end",get open(){return e.open},get onOpenChange(){return e.onOpenChange},get children(){return[h(Tt.Trigger,{as:Lr,variant:"ghost-muted",size:"small",get icon(){return h(on,{name:"outline-dots"})},get"aria-label"(){return e.labels.more}}),h(Tt.Portal,{get children(){return h(Tt.Content,{get children(){return h(Tt.Group,{get children(){return[h(Tt.GroupLabel,{get children(){return e.labels.server}}),h(Tt.Item,{get disabled(){return t()||!n()},onSelect:()=>{const r=n();r&&e.onEdit(r)},get children(){return e.labels.edit}}),h(q,{get when(){return we(()=>!!e.canDefault)()&&!e.isDefault},get children(){return h(Tt.Item,{get onSelect(){return e.onSetDefault},get children(){return e.labels.default}})}}),h(q,{get when(){return we(()=>!!e.canDefault)()&&e.isDefault},get children(){return h(Tt.Item,{get onSelect(){return e.onRemoveDefault},get children(){return e.labels.defaultRemove}})}}),h(Tt.Separator,{}),h(Tt.Item,{get disabled(){return t()},get onSelect(){return e.onRemove},get children(){return e.labels.delete}})]}})}})}})]}})};var Mat=A('<div class="flex min-w-0 flex-col gap-4 pr-3">'),$at=A('<aside class="mt-6 flex min-h-0 min-w-0 flex-col gap-4 overflow-hidden lg:sticky lg:top-14 lg:mt-14 lg:h-[calc(100cqh-56px)] lg:self-start lg:pt-[52px]"><div class="flex h-7 min-w-0 shrink-0 items-center justify-between pl-1.5 pr-3"><div class="text-v2-text-text-muted [font-weight:530]">'),Pat=A("<div class=pr-3>"),Oat=A('<div class="mx-3 h-px bg-v2-border-border-base">'),QI=A('<div class="flex min-w-0 flex-col gap-1">'),v1=A('<span class="min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap">'),Rat=A("<div>"),Fat=A('<span data-action=home-server-collapse class="-ml-0.5 -mr-1.5 inline-flex size-5 shrink-0 items-center justify-center rounded-[4px] text-v2-icon-icon-muted">'),Nat=A('<div class="flex size-4 shrink-0 items-center justify-center -mr-0.5">'),Vat=A('<span class="flex min-w-0 items-center gap-1"><span class="min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap">'),zat=A('<div class="group/server relative flex h-7 min-w-0 items-center rounded-[6px]"><div class="hover-reveal absolute right-1 top-1/2 flex -translate-y-1/2 items-center gap-1 group-hover/server:opacity-100 focus-within:opacity-100 data-[menu=true]:opacity-100">'),Hat=A('<span class="shrink-0 rounded-[3px] border border-v2-border-border-base px-1 py-0.5 text-[9px] leading-none text-v2-text-text-muted">'),jat=A('<div class="mt-3 flex h-7 min-w-0 shrink-0 items-center pl-1.5 pr-3"><div class="text-v2-text-text-faint [font-weight:530]">'),qat=A('<div class="group/project relative flex h-7 min-w-0 items-center rounded-[6px]"><div class="hover-reveal absolute right-1 top-1/2 flex -translate-y-1/2 items-center gap-1 group-hover/project:opacity-100 focus-within:opacity-100 data-[menu=true]:opacity-100">'),Bat=A("<button>");const Uat=e=>`server:${ut.key(e)}`,Wat=(e,t)=>`project:${ut.key(e)}:${t}`;function Kat(e){const[t,n]=Ze({open:void 0}),r={contextMenuOpen:i=>t.open===i,onSetContextMenuOpen:(i,s)=>n("open",s?i:void 0)};return(()=>{var i=$at(),s=i.firstChild,o=s.firstChild;return i.addEventListener("wheel",a=>{a.target!==a.currentTarget&&e.onWheel(a)}),S(o,()=>e.language.t("home.projects")),S(s,h(q,{get when(){return we(()=>e.servers().length===1)()&&!(e.projects().length===0&&e.recentlyClosed().length>0)},get children(){return h(Qn,{placement:"bottom",get value(){return e.language.t("home.project.add")},get children(){return h(Lr,{"data-action":"home-add-project",variant:"ghost-muted",size:"large",class:"titlebar-icon [&_[data-slot=icon-svg]]:text-v2-icon-icon-muted",get icon(){return h(on,{name:"folder-add-left"})},get disabled(){return e.serverHealth(e.servers()[0])?.healthy===!1},onClick:()=>e.onChooseProject(e.servers()[0]),get"aria-label"(){return e.language.t("home.project.add")}})}})}}),null),S(i,h(yc,{"data-slot":"home-projects-scroll",class:"min-h-0 min-w-0 shrink",get children(){return h(q,{get when(){return e.servers().length>1},get fallback(){return(()=>{var a=Pat();return S(a,h(q,{get when(){return e.projects().length>0},get fallback(){return h(Yat,le(e,{get server(){return e.servers()[0]},get items(){return e.recentlyClosed()}}))},get children(){return h(rV,le(e,r,{get server(){return e.servers()[0]},get items(){return e.projects()}}))}})),a})()},get children(){var a=Mat();return S(a,h(Dt,{get each(){return e.servers()},children:l=>{const c=()=>e.projectsForServer(l),u=()=>!!e.serverHealth(l)?.healthy,d=()=>c().length>0,f=()=>e.collapsed(l);return(()=>{var m=QI();return S(m,h(Gat,le({server:l},e,r,{get selected(){return we(()=>e.selection().server===ut.key(l))()&&!e.selection().directory},get collapsed(){return f()},get health(){return e.serverHealth(l)}})),null),S(m,h(q,{get when(){return we(()=>!!(u()&&d()))()&&!f()},get children(){return[Oat(),h(rV,le(e,r,{server:l,get items(){return c()}}))]}}),null),m})()}})),a}})}}),null),S(i,h(uie,{class:"mb-8 mt-4 hidden shrink-0 lg:flex",get onOpenSettings(){return e.onOpenSettings},get onOpenHelp(){return e.onOpenHelp},get language(){return e.language}}),null),he(()=>me(i,"aria-label",e.language.t("home.projects"))),i})()}function uie(e){return(()=>{var t=Rat();return S(t,h(xg,{type:"button",class:"text-v2-text-text-faint [&>[data-slot=icon-svg]]:text-v2-icon-icon-muted",get onClick(){return e.onOpenSettings},get children(){return[h(on,{name:"settings-gear",size:"small"}),(()=>{var n=v1();return S(n,()=>e.language.t("sidebar.settings")),n})()]}}),null),S(t,h(xg,{type:"button",class:"text-v2-text-text-faint [&>[data-slot=icon-svg]]:text-v2-icon-icon-muted",get onClick(){return e.onOpenHelp},get children(){return[h(on,{name:"help",size:"small"}),(()=>{var n=v1();return S(n,()=>e.language.t("sidebar.help")),n})()]}}),null),he(()=>xr(t,`${e.class??""} min-w-0 flex-col gap-1 pr-3`)),t})()}function Gat(e){const t=()=>!!e.health?.healthy,n=()=>t()&&e.projectsForServer(e.server).length>0,r=()=>Uat(e.server);return Te(()=>{const i=r();e.contextMenuOpen(i)&&e.onSetContextMenuOpen(i,!1)}),(()=>{var i=zat(),s=i.firstChild;return S(i,h(xg,{type:"button",class:"pr-16 disabled:opacity-60",get"data-selected"(){return e.selected?"":void 0},get disabled(){return!t()},onClick:()=>e.onFocusServer(e.server),get children(){return[(()=>{var o=Fat();return o.$$pointerdown=a=>a.preventDefault(),o.$$click=a=>{a.preventDefault(),a.stopPropagation(),n()&&e.onToggleCollapsed(e.server)},S(o,h(on,{name:"chevron-down",size:"small",class:"transition-transform duration-150 ease-in-out",get style(){return{transform:`rotate(${e.collapsed?-90:0}deg)`}}})),he(a=>{var l={"hover:bg-v2-overlay-simple-overlay-hover":n(),"cursor-default opacity-40":!n()},c=e.collapsed?e.language.t("home.server.expand"):e.language.t("home.server.collapse"),u=!n(),d=n()?!e.collapsed:void 0;return a.e=ct(o,l,a.e),c!==a.t&&me(o,"aria-label",a.t=c),u!==a.a&&me(o,"aria-disabled",a.a=u),d!==a.o&&me(o,"aria-expanded",a.o=d),a},{e:void 0,t:void 0,a:void 0,o:void 0}),o})(),(()=>{var o=Nat();return S(o,h(rie,{get health(){return e.health}})),o})(),(()=>{var o=Vat(),a=o.firstChild;return S(a,()=>e.server.displayName??new URL(e.server.http.url).host),S(o,h(q,{get when(){return e.server.label},children:l=>(()=>{var c=Hat();return S(c,l),c})()}),null),o})()]}}),s),S(s,h(cie,{get server(){return e.server},get labels(){return lie(e.language)},get canDefault(){return e.canDefaultServer()},get isDefault(){return e.defaultServerKey()===ut.key(e.server)},get onEdit(){return e.onEditServer},onSetDefault:()=>e.onSetDefaultServer(e.server),onRemoveDefault:()=>e.onSetDefaultServer(void 0),onRemove:()=>e.onRemoveServer(e.server),get open(){return e.contextMenuOpen(r())},onOpenChange:o=>e.onSetContextMenuOpen(r(),o)}),null),S(s,h(Qn,{class:"flex shrink-0 items-center",placement:"bottom",get value(){return e.language.t("home.project.add")},get children(){return h(Lr,{"data-action":"home-add-project",variant:"ghost-muted",size:"small",get icon(){return h(on,{name:"folder-add-left"})},get"aria-label"(){return e.language.t("home.project.add")},get disabled(){return e.health?.healthy===!1},onClick:()=>e.onChooseProject(e.server)})}}),null),he(()=>me(s,"data-menu",e.contextMenuOpen(r()))),i})()}function rV(e){let t;return h(Vk,{sensors:n=>[...n.filter(r=>r!==yg),yg.configure({activationConstraints:r=>r.pointerType==="touch"?[new dl.Delay({value:250,tolerance:5})]:[new dl.Distance({value:4})],preventActivation:r=>r.target instanceof Element&&!!r.target.closest("[data-action]")})],get modifiers(){return[DPe,zk.configure({element:()=>t})]},plugins:n=>[...n.filter(r=>r!==eh&&r!==Jf),eh.configure({acceleration:8,threshold:{x:0,y:.05}}),Jf.configure({dropAnimation:null})],onDragEnd:n=>{const r=n.operation.source;n.canceled||!ko(r)||(r.initialIndex!==r.index&&e.onMoveProject(e.server,r.id.toString(),r.index),e.selection().server!==ut.key(e.server)&&e.onSelectProject(e.server,r.id.toString()))},get children(){var n=QI(),r=t;return typeof r=="function"?pt(r,n):t=n,S(n,h(Dt,{get each(){return e.items.map(i=>i.worktree)},children:(i,s)=>h(Zat,le(e,{worktree:i,index:s}))})),n}})}function Zat(e){const t=e.items.find(r=>r.worktree===e.worktree);if(!t)return;const n=I(r=>e.items.find(i=>i.worktree===e.worktree)??r,t);return h(Qat,le(e,{get project(){return n()},get server(){return e.server},get index(){return e.index},get serverSelected(){return e.selection().server===ut.key(e.server)},get selected(){return we(()=>e.selection().server===ut.key(e.server))()&&e.selection().directory===e.worktree},get unseen(){return e.unseenCount(e.server,n())}}))}function Yat(e){const t=()=>e.serverHealth(e.server)?.healthy===!1;return(()=>{var n=QI();return S(n,h(xg,{type:"button","data-action":"home-add-project-row",class:"disabled:opacity-60 [&>[data-slot=icon-svg]]:text-v2-icon-icon-muted",get disabled(){return t()},onClick:()=>e.onChooseProject(e.server),get children(){return[h(on,{name:"folder-add-left",size:"small"}),(()=>{var r=v1();return S(r,()=>e.language.t("home.project.add")),r})()]}}),null),S(n,h(q,{get when(){return e.items.length>0},get children(){return[(()=>{var r=jat(),i=r.firstChild;return S(i,()=>e.language.t("home.recentlyClosed")),r})(),h(Dt,{get each(){return e.items},children:r=>h(Xat,le(e,{project:r,get server(){return e.server}}))})]}}),null),n})()}function Xat(e){const t=()=>e.serverHealth(e.server)?.healthy===!1,n=()=>{const r=e.homedir(),i=e.project.worktree;return r&&(i===r||i.startsWith(`${r}/`))?`~${i.slice(r.length)}`:i};return h(Qn,{placement:"right",get value(){return n()},get children(){return h(xg,{type:"button","data-component":"home-recently-closed-row",class:"disabled:opacity-60",get disabled(){return t()},onClick:()=>e.onAddProjects(e.server,[e.project.worktree]),get children(){return[h(die,{get project(){return e.project},outline:!0}),(()=>{var r=v1();return S(r,()=>Ll(e.project)),r})()]}})}})}function Qat(e){const t=Tr(),n=()=>e.serverHealth(e.server)?.healthy===!1,r=ay({get id(){return e.project.worktree},get index(){return e.index()}});let i;const s=()=>Wat(e.server,e.project.worktree);return Te(()=>{const o=s();e.contextMenuOpen(o)&&e.onSetContextMenuOpen(o,!1)}),(()=>{var o=qat(),a=o.firstChild,l=r.ref;return typeof l=="function"?pt(l,o):r.ref=o,S(o,h(xg,{type:"button","data-component":"home-project-row",class:"pr-16 disabled:opacity-60",get classList(){return{"bg-v2-background-bg-layer-01 text-v2-text-text-base":r.isDragSource(),"[box-shadow:inset_0_0_0_0.5px_var(--v2-border-border-muted)]":r.isDragSource()}},get"data-selected"(){return e.selected?"":void 0},get"aria-current"(){return e.selected?"page":void 0},get disabled(){return n()},onPointerDown:c=>{i=void 0,!(c.button!==0||c.pointerType==="touch")&&e.serverSelected&&(i=e.selected,e.selected||e.onSelectProject(e.server,e.project.worktree))},onClick:c=>{if(!c.defaultPrevented){if(c.detail===0||i===void 0){e.onSelectProject(e.server,e.project.worktree);return}i&&e.onSelectProject(e.server,e.project.worktree),i=void 0}},get children(){return[h(die,{get project(){return e.project}}),(()=>{var c=v1();return S(c,()=>Ll(e.project)),c})()]}}),a),S(a,h(Tt,{gutter:6,modal:!1,placement:"bottom-end",get open(){return e.contextMenuOpen(s())},onOpenChange:c=>e.onSetContextMenuOpen(s(),c),get children(){return[h(Tt.Trigger,{as:Lr,"data-action":"home-project-menu",variant:"ghost-muted",size:"small",get icon(){return h(on,{name:"outline-dots"})},get"aria-label"(){return e.language.t("common.moreOptions")}}),h(Tt.Portal,{get children(){return h(Tt.Content,{get children(){return[h(Tt.Item,{onSelect:()=>e.onOpenProjectNewSession(e.server,e.project.worktree),get children(){return e.language.t("command.session.new")}}),h(Tt.Item,{onSelect:()=>e.onEditProject(e.server,e.project),get children(){return e.language.t("dialog.project.edit.title")}}),h(q,{get when(){return e.canRevealProject(e.server)},get children(){return h(Tt.Item,{onSelect:()=>e.onRevealProject(e.server,e.project),get children(){return e.language.t(QJ(t.platform==="desktop"?t.os??"unknown":"unknown").actionLabel)}})}}),h(Tt.Item,{get disabled(){return e.unseen===0},onSelect:()=>e.onClearNotifications(e.server,e.project),get children(){return e.language.t("sidebar.project.clearNotifications")}}),h(Tt.Separator,{}),h(Tt.Item,{onSelect:()=>e.onCloseProject(e.server,e.project.worktree),get children(){return e.language.t("common.close")}})]}})}})]}}),null),S(a,h(Lr,{"data-action":"home-project-new-session",variant:"ghost-muted",size:"small",get icon(){return h(on,{name:"edit"})},get"aria-label"(){return e.language.t("command.session.new")},onClick:()=>e.onOpenProjectNewSession(e.server,e.project.worktree)}),null),he(c=>{var u=!!r.isDragSource(),d=e.contextMenuOpen(s());return u!==c.e&&o.classList.toggle("z-10",c.e=u),d!==c.t&&me(a,"data-menu",c.t=d),c},{e:void 0,t:void 0}),o})()}function xg(e){const[t,n]=Ee(e,["class","classList","children"]);return(()=>{var r=Bat();return An(r,le(n,{get class(){return`