@yuriai/web 0.2.0-beta.2 → 0.2.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/assets/{AssistantView-8ju42ZTW.js → AssistantView-AVEdhX2E.js} +3 -3
  2. package/dist/assets/{DiagramView-rw0YYQMb.js → DiagramView-kaRtAbB8.js} +1 -1
  3. package/dist/assets/{GuiPluginSurface-CZyG8VSt.js → GuiPluginSurface-Clv5w8qE.js} +1 -1
  4. package/dist/assets/{MarkdownRenderer-CtlVSzEr.js → MarkdownRenderer-BsZicwlM.js} +2 -2
  5. package/dist/assets/MarkdownRendererImpl-BUhSSjjo.js +10 -0
  6. package/dist/assets/{MarkstreamRendererImpl-Bh0SBb3A.js → MarkstreamRendererImpl-Drf8lHZM.js} +1 -1
  7. package/dist/assets/{MobileDetailNavigation-BmVdW83D.js → MobileDetailNavigation-CtYXRw3B.js} +1 -1
  8. package/dist/assets/{MobileShareBridge-DsEPHal0.js → MobileShareBridge-sU74EJ95.js} +1 -1
  9. package/dist/assets/{MobileTabPageHeader-C3XsN5mD.js → MobileTabPageHeader-BWhQHf6s.js} +1 -1
  10. package/dist/assets/{MultiRunWindow-E69FtA8j.js → MultiRunWindow-9DdpcXYS.js} +1 -1
  11. package/dist/assets/{SettingsView-cAxZUqrO.js → SettingsView-Dm-Zxoje.js} +1 -1
  12. package/dist/assets/{SettingsWindow-lAKvVEKw.js → SettingsWindow-Cgnhlx6v.js} +1 -1
  13. package/dist/assets/{TerminalView-Dk4wVZaD.js → TerminalView-DpkoeLoM.js} +1 -1
  14. package/dist/assets/{ToolOutputDialog-USJ-ZgXn.js → ToolOutputDialog-Cy30GA5T.js} +1 -1
  15. package/dist/assets/{appThemeRegistry-LtxIx7El.js → appThemeRegistry-q9ZHhYPY.js} +1 -1
  16. package/dist/assets/{capgoAdapter-DCIeVZw_.js → capgoAdapter-ClmWgQsn.js} +1 -1
  17. package/dist/assets/{fileMentionTouchSelection-CRlBHcv1.js → fileMentionTouchSelection-C5fQjVCV.js} +1 -1
  18. package/dist/assets/{fileReferenceActions-ZQ5--HF8.js → fileReferenceActions-EkHzD38t.js} +1 -1
  19. package/dist/assets/{gitApi-BKjA7Bpe.js → gitApi-DL9TCObI.js} +1 -1
  20. package/dist/assets/{host-u2MH0QSP.js → host-DeoWZHPC.js} +1 -1
  21. package/dist/assets/{insertionBoundaries-D_wrLY-Q.js → insertionBoundaries-DrjyD1xA.js} +1 -1
  22. package/dist/assets/{main-C4Zc7_s8.js → main-1iPWY6JE.js} +2 -2
  23. package/dist/assets/{main-CkA5yk63.js → main-ClH8U0K_.js} +4 -4
  24. package/dist/assets/{mcpQueries-s9QcLjGw.js → mcpQueries-Am1xehao.js} +1 -1
  25. package/dist/assets/{miniChat-C_wwveSN.js → miniChat-DV5fIjdE.js} +2 -2
  26. package/dist/assets/{mobile-TuU7P2PX.js → mobile-C7hRNLd2.js} +2 -2
  27. package/dist/assets/{mobileBackNavigation-C6OcBTbS.js → mobileBackNavigation-BjN2y4on.js} +1 -1
  28. package/dist/assets/{multirun-cZcReWkT.js → multirun-Dj8jiZnI.js} +1 -1
  29. package/dist/assets/{native-config-DnQvXgu6.js → native-config-6ZcbOTlU.js} +1 -1
  30. package/dist/assets/{projectMeta-DXlpoXd3.js → projectMeta-Bh_8p-5O.js} +1 -1
  31. package/dist/assets/{readiness-m2mD0fyj.js → readiness-6dRSpsKU.js} +1 -1
  32. package/dist/assets/{renderElectronMiniChatApp-COXM_nk2.js → renderElectronMiniChatApp-fvAvjcX3.js} +2 -2
  33. package/dist/assets/{renderMobileApp-CbU3BLr6.js → renderMobileApp-J5PuS_NT.js} +4 -4
  34. package/dist/assets/{runtimeConfig-jHTvOptz.js → runtimeConfig-BndFf_Fb.js} +1 -1
  35. package/dist/assets/runtimeEndpointReset-DlxONsUh.js +149 -0
  36. package/dist/assets/{sessionChangeSummary-C7Y5e238.js → sessionChangeSummary-CUnP0Mge.js} +1 -1
  37. package/dist/assets/{sessionLookup-BscEQpqH.js → sessionLookup-EBl9PXiP.js} +1 -1
  38. package/dist/assets/{speechSettingsQueries-DVKcuOEf.js → speechSettingsQueries-CgSGK19J.js} +1 -1
  39. package/dist/assets/{types-eQY4TOgr.js → types-aeu41u0o.js} +1 -1
  40. package/dist/assets/{useAppFontEffects-DOp_gxxk.js → useAppFontEffects-By2DRO_9.js} +5 -5
  41. package/dist/assets/{useDesktopWindowControlsLayout-CPqgnywT.js → useDesktopWindowControlsLayout-B9xDW29G.js} +1 -1
  42. package/dist/assets/{useEffectiveDirectory-9Efzl9IZ.js → useEffectiveDirectory-C5E5H7K7.js} +1 -1
  43. package/dist/assets/{useMobileNavigationStore-Cwk7wARY.js → useMobileNavigationStore-BDW0aRpC.js} +3 -3
  44. package/dist/assets/{useWorkerHighlightedLines-ClwAu-Q3.js → useWorkerHighlightedLines-5IurZLOp.js} +1 -1
  45. package/dist/index.html +5 -5
  46. package/dist/mini-chat.html +5 -5
  47. package/dist/mobile.html +5 -5
  48. package/package.json +1 -1
  49. package/server/lib/content-search/DOCUMENTATION.md +17 -11
  50. package/server/lib/content-search/index.js +1 -0
  51. package/server/lib/content-search/runtime.js +50 -9
  52. package/server/lib/content-search/runtime.test.js +72 -1
  53. package/server/lib/content-search/service.js +12 -1
  54. package/dist/assets/MarkdownRendererImpl-wN873oJ5.js +0 -10
  55. package/dist/assets/runtimeEndpointReset-BOuzWhtp.js +0 -149
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{it as t,rt as n}from"./vendor-base-ui-CdzJ6My_.js";import{v as r}from"./useUIStore-NMQx_cnG.js";import{n as i}from"./vendor-react-BP2cRVqX.js";import{f as a,r as o,t as s}from"./button-4sNruiRJ.js";import{n as c}from"./useThemeSystem-8jhE4Zyk.js";import{n as l}from"./Icon-BX4GW-k_.js";import{i as u,n as d,t as f}from"./tooltip-Bxj4llmx.js";import{n as p}from"./MarkdownRenderer-CtlVSzEr.js";import{n as m,r as h}from"./toolHelpers-DL452NVK.js";import{t as g}from"./vendor-tanstack-react-virtual-B_EO--9t.js";import{n as _}from"./markdownTheme-DHoKvD6O.js";import{n as v,t as y}from"./markdown-worker-oBGEB9Eg.js";var b=e(t(),1),x=i(),S=n(),C=`w-[min(30rem,calc(100cqw-1rem))] min-w-[280px] max-w-full overflow-hidden rounded-xl shadow-[inset_0_1px_0_0_rgba(255,255,255,0.8),inset_0_0_0_1px_rgba(0,0,0,0.04),0_0_0_1px_rgba(0,0,0,0.10),0_1px_2px_-0.5px_rgba(0,0,0,0.08),0_4px_8px_-2px_rgba(0,0,0,0.08),0_12px_20px_-4px_rgba(0,0,0,0.08)] dark:shadow-[inset_0_1px_0_0_rgba(255,255,255,0.12),inset_0_0_0_1px_rgba(255,255,255,0.08),0_0_0_1px_rgba(0,0,0,0.36),0_1px_1px_-0.5px_rgba(0,0,0,0.22),0_3px_3px_-1.5px_rgba(0,0,0,0.20),0_6px_6px_-3px_rgba(0,0,0,0.16)]`,w={maxWidth:`min(28rem, calc(100cqw - 4ch))`,backgroundColor:`var(--surface-elevated)`,color:`var(--surface-elevated-foreground)`},T=`flex items-center justify-between gap-3 border-b border-[var(--surface-subtle)] px-3 py-2.5`,E=`text-xs font-medium leading-4 text-foreground md:text-[0.8125rem] md:leading-5`,D=`text-xs tabular-nums leading-4 text-muted-foreground md:text-[0.8125rem] md:leading-5`,O=`m-0 list-none divide-y divide-[var(--surface-subtle)] p-0`,k=`${O} max-h-[min(22rem,50vh)] overflow-y-auto`,A=`${O} w-full`,ee={className:`p-0 rounded-none`,maxHeightClass:`max-h-[46vh]`,disableHorizontal:!0},j=`px-2.5 py-1.5 text-xs leading-4 md:py-2 md:text-[0.8125rem] md:leading-5`,M=`flex min-w-0 items-center gap-1 text-xs leading-4 text-muted-foreground md:gap-1.5 md:text-[0.8125rem] md:leading-5`,te=`min-w-0 truncate text-xs leading-4 text-foreground md:text-[0.8125rem] md:leading-5`,ne=`inline-flex shrink-0 items-center gap-1 text-xs leading-4 tabular-nums text-muted-foreground md:text-[0.8125rem] md:leading-5`,re=`h-3 w-3 shrink-0 md:h-3.5 md:w-3.5`,ie={in_progress:`text-foreground`,pending:`text-foreground`,completed:`text-muted-foreground line-through`,cancelled:`text-muted-foreground line-through`},ae={in_progress:`chat.statusRow.todo.status.inProgress`,pending:`chat.statusRow.todo.status.pending`,completed:`chat.statusRow.todo.status.completed`,cancelled:`chat.statusRow.todo.status.cancelled`},N=e=>{let t=(0,x.c)(26),{todo:n,isActive:r,activeRef:i}=e,{t:s}=a(),c=oe.has(n.status)?n.status:`pending`,p=ae[c],m;t[0]!==s||t[1]!==p?(m=s(p),t[0]=s,t[1]=p,t[2]=m):m=t[2];let h=m,g;t[3]===c?g=t[4]:(g=c===`in_progress`?(0,S.jsx)(l,{name:`record-circle`,className:`h-3.5 w-3.5 text-[var(--status-info)]`,"aria-hidden":`true`}):c===`completed`?(0,S.jsx)(l,{name:`checkbox-circle`,className:`h-3.5 w-3.5 text-[var(--status-success)]`,"aria-hidden":`true`}):(0,S.jsx)(l,{name:`time`,className:`h-3.5 w-3.5 text-muted-foreground`,"aria-hidden":`true`}),t[3]=c,t[4]=g);let _=g,v=r?`step`:void 0,y=r&&`bg-[var(--surface-muted)] before:absolute before:inset-y-2 before:left-0 before:w-0.5 before:rounded-full before:bg-[var(--status-info)]`,b;t[5]===y?b=t[6]:(b=o(`group relative grid min-w-0 grid-cols-[1rem_minmax(0,1fr)] items-start gap-2.5`,j,y),t[5]=y,t[6]=b);let C;t[7]!==_||t[8]!==h?(C=(0,S.jsx)(u,{asChild:!0,children:(0,S.jsx)(`span`,{className:`flex size-4 items-center justify-center`,"aria-label":h,children:_})}),t[7]=_,t[8]=h,t[9]=C):C=t[9];let w;t[10]===h?w=t[11]:(w=(0,S.jsx)(d,{side:`left`,sideOffset:6,children:h}),t[10]=h,t[11]=w);let T;t[12]!==C||t[13]!==w?(T=(0,S.jsxs)(f,{children:[C,w]}),t[12]=C,t[13]=w,t[14]=T):T=t[14];let E=ie[c],D;t[15]===E?D=t[16]:(D=o(`block whitespace-normal break-words`,E),t[15]=E,t[16]=D);let O;t[17]!==D||t[18]!==n.content?(O=(0,S.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,S.jsx)(`span`,{className:D,children:n.content})}),t[17]=D,t[18]=n.content,t[19]=O):O=t[19];let k;return t[20]!==i||t[21]!==O||t[22]!==v||t[23]!==b||t[24]!==T?(k=(0,S.jsxs)(`li`,{ref:i,"aria-current":v,className:b,children:[T,O]}),t[20]=i,t[21]=O,t[22]=v,t[23]=b,t[24]=T,t[25]=k):k=t[25],k},oe=new Set([`in_progress`,`pending`,`completed`,`cancelled`]),P=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`),F=e=>e?Object.entries(e).map(([e,t])=>t==null?``:`${e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}:${typeof t==`number`?`${t}px`:t};`).join(``):``,I=(e,t,n)=>{let r=e.querySelector(`pre`);r&&(r.style.margin=`0`,r.style.background=`transparent`,r.style.whiteSpace=t?`pre-wrap`:`pre`,t&&(r.style.wordBreak=`break-word`,r.style.overflowWrap=`break-word`));let i=e.querySelector(`code`);if(i){let e=F(n);e&&i.setAttribute(`style`,`${i.getAttribute(`style`)??``}${e}`)}},L=e=>`<pre><code>${P(e)}</code></pre>`,R=e=>{let t=(0,x.c)(21),{code:n,language:r,className:i,style:a,codeStyle:s,wrap:l}=e,u=l!==void 0&&l,{currentTheme:d}=c(),f=b.useRef(null),p;t[0]===d?p=t[1]:(p=_(d),t[0]=d,t[1]=p);let m=p,h,g;t[2]!==n||t[3]!==s||t[4]!==u?(h=()=>{let e=f.current;e&&(e.innerHTML=L(n),I(e,u,s))},g=[n,u,s],t[2]=n,t[3]=s,t[4]=u,t[5]=h,t[6]=g):(h=t[5],g=t[6]),b.useLayoutEffect(h,g);let v,C;t[7]!==n||t[8]!==s||t[9]!==r||t[10]!==u?(v=()=>{let e=f.current;if(!e)return;let t=!0,i=new AbortController;return y(n,(r||`text`).toLowerCase(),{signal:i.signal,priority:`visible`}).then(n=>{!t||!e||!n||(e.innerHTML=n,I(e,u,s))}),()=>{t=!1,i.abort()}},C=[n,r,u,s],t[7]=n,t[8]=s,t[9]=r,t[10]=u,t[11]=v,t[12]=C):(v=t[11],C=t[12]),b.useEffect(v,C);let w;t[13]===i?w=t[14]:(w=o(`typography-code`,i),t[13]=i,t[14]=w);let T=m,E;t[15]!==a||t[16]!==T?(E={...T,...a},t[15]=a,t[16]=T,t[17]=E):E=t[17];let D;return t[18]!==w||t[19]!==E?(D=(0,S.jsx)(`div`,{ref:f,className:w,style:E}),t[18]=w,t[19]=E,t[20]=D):D=t[20],D},z=e=>{let t=e.replace(/^<file>\s*\n?/,``).replace(/\n?<\/file>\s*$/,``);return t=t.replace(/^\s*\d{5}\|\s?/gm,``),t.trim()},B=(e,t=``)=>{if(typeof e==`string`)return e;if(e==null)return t;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return String(e);try{return JSON.stringify(e)}catch{return t}},V=e=>e?e.includes(`<diagnostics`)||e.includes(`<file_diagnostics>`)||e.includes(`LSP errors detected`)||e.includes(`This file has errors`):!1,H=e=>e?e.replace(/\n{0,2}LSP errors detected[\s\S]*?<diagnostics[^>]*>[\s\S]*?<\/diagnostics>/g,``).replace(/\n{0,2}This file has errors[\s\S]*?<\/file_diagnostics>/g,``).replace(/<diagnostics[^>]*>[\s\S]*?<\/diagnostics>/g,``).replace(/<file_diagnostics>[\s\S]*?<\/file_diagnostics>/g,``).trim():``,U=(e,t)=>!e||typeof e!=`object`?String(e):h(e,t||``),W=e=>{if(typeof e==`string`){let t=e.trim();return t.length>0?t:void 0}if(e&&typeof e==`object`){let t=e.patch;if(typeof t==`string`){let e=t.trim();return e.length>0?e:void 0}}},G=e=>{if(!e||typeof e!=`object`)return;let t=W(e.patch)??W(e.diff);if(t)return t;let n=Array.isArray(e.files)?e.files:[];for(let e of n){if(!e||typeof e!=`object`)continue;let t=W(e.patch)??W(e.diff);if(t)return t}},K=e=>{if(!e||typeof e!=`string`)return{data:null,isJson:!1};let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`)||!t.endsWith(`}`)&&!t.endsWith(`]`)||t.length<2)return{data:null,isJson:!1};try{let e=JSON.parse(t);return typeof e==`object`&&e?{data:e,isJson:!0}:{data:null,isJson:!1}}catch{return{data:null,isJson:!1}}},q=(e,t,n)=>{let r=z(e);if((t===`edit`||t===`multiedit`||t===`write`||t===`apply_patch`)&&V(r)&&(r=H(r)),(t===`edit`||t===`multiedit`||t===`apply_patch`)&&r.trim().length===0){let e=G(n);if(e)return e}return r},se=e=>{let t=e.match(/<type>(file|directory)<\/type>/i)?.[1]?.toLowerCase()??`unknown`,n=(e.match(/<content>([\s\S]*?)<\/content>/i)?.[1]??e).replace(/\r\n/g,`
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{it as t,rt as n}from"./vendor-base-ui-CdzJ6My_.js";import{v as r}from"./useUIStore-NMQx_cnG.js";import{n as i}from"./vendor-react-BP2cRVqX.js";import{f as a,r as o,t as s}from"./button-4sNruiRJ.js";import{n as c}from"./useThemeSystem-8jhE4Zyk.js";import{n as l}from"./Icon-BX4GW-k_.js";import{i as u,n as d,t as f}from"./tooltip-Bxj4llmx.js";import{n as p}from"./MarkdownRenderer-BsZicwlM.js";import{n as m,r as h}from"./toolHelpers-DL452NVK.js";import{t as g}from"./vendor-tanstack-react-virtual-B_EO--9t.js";import{n as _}from"./markdownTheme-DHoKvD6O.js";import{n as v,t as y}from"./markdown-worker-oBGEB9Eg.js";var b=e(t(),1),x=i(),S=n(),C=`w-[min(30rem,calc(100cqw-1rem))] min-w-[280px] max-w-full overflow-hidden rounded-xl shadow-[inset_0_1px_0_0_rgba(255,255,255,0.8),inset_0_0_0_1px_rgba(0,0,0,0.04),0_0_0_1px_rgba(0,0,0,0.10),0_1px_2px_-0.5px_rgba(0,0,0,0.08),0_4px_8px_-2px_rgba(0,0,0,0.08),0_12px_20px_-4px_rgba(0,0,0,0.08)] dark:shadow-[inset_0_1px_0_0_rgba(255,255,255,0.12),inset_0_0_0_1px_rgba(255,255,255,0.08),0_0_0_1px_rgba(0,0,0,0.36),0_1px_1px_-0.5px_rgba(0,0,0,0.22),0_3px_3px_-1.5px_rgba(0,0,0,0.20),0_6px_6px_-3px_rgba(0,0,0,0.16)]`,w={maxWidth:`min(28rem, calc(100cqw - 4ch))`,backgroundColor:`var(--surface-elevated)`,color:`var(--surface-elevated-foreground)`},T=`flex items-center justify-between gap-3 border-b border-[var(--surface-subtle)] px-3 py-2.5`,E=`text-xs font-medium leading-4 text-foreground md:text-[0.8125rem] md:leading-5`,D=`text-xs tabular-nums leading-4 text-muted-foreground md:text-[0.8125rem] md:leading-5`,O=`m-0 list-none divide-y divide-[var(--surface-subtle)] p-0`,k=`${O} max-h-[min(22rem,50vh)] overflow-y-auto`,A=`${O} w-full`,ee={className:`p-0 rounded-none`,maxHeightClass:`max-h-[46vh]`,disableHorizontal:!0},j=`px-2.5 py-1.5 text-xs leading-4 md:py-2 md:text-[0.8125rem] md:leading-5`,M=`flex min-w-0 items-center gap-1 text-xs leading-4 text-muted-foreground md:gap-1.5 md:text-[0.8125rem] md:leading-5`,te=`min-w-0 truncate text-xs leading-4 text-foreground md:text-[0.8125rem] md:leading-5`,ne=`inline-flex shrink-0 items-center gap-1 text-xs leading-4 tabular-nums text-muted-foreground md:text-[0.8125rem] md:leading-5`,re=`h-3 w-3 shrink-0 md:h-3.5 md:w-3.5`,ie={in_progress:`text-foreground`,pending:`text-foreground`,completed:`text-muted-foreground line-through`,cancelled:`text-muted-foreground line-through`},ae={in_progress:`chat.statusRow.todo.status.inProgress`,pending:`chat.statusRow.todo.status.pending`,completed:`chat.statusRow.todo.status.completed`,cancelled:`chat.statusRow.todo.status.cancelled`},N=e=>{let t=(0,x.c)(26),{todo:n,isActive:r,activeRef:i}=e,{t:s}=a(),c=oe.has(n.status)?n.status:`pending`,p=ae[c],m;t[0]!==s||t[1]!==p?(m=s(p),t[0]=s,t[1]=p,t[2]=m):m=t[2];let h=m,g;t[3]===c?g=t[4]:(g=c===`in_progress`?(0,S.jsx)(l,{name:`record-circle`,className:`h-3.5 w-3.5 text-[var(--status-info)]`,"aria-hidden":`true`}):c===`completed`?(0,S.jsx)(l,{name:`checkbox-circle`,className:`h-3.5 w-3.5 text-[var(--status-success)]`,"aria-hidden":`true`}):(0,S.jsx)(l,{name:`time`,className:`h-3.5 w-3.5 text-muted-foreground`,"aria-hidden":`true`}),t[3]=c,t[4]=g);let _=g,v=r?`step`:void 0,y=r&&`bg-[var(--surface-muted)] before:absolute before:inset-y-2 before:left-0 before:w-0.5 before:rounded-full before:bg-[var(--status-info)]`,b;t[5]===y?b=t[6]:(b=o(`group relative grid min-w-0 grid-cols-[1rem_minmax(0,1fr)] items-start gap-2.5`,j,y),t[5]=y,t[6]=b);let C;t[7]!==_||t[8]!==h?(C=(0,S.jsx)(u,{asChild:!0,children:(0,S.jsx)(`span`,{className:`flex size-4 items-center justify-center`,"aria-label":h,children:_})}),t[7]=_,t[8]=h,t[9]=C):C=t[9];let w;t[10]===h?w=t[11]:(w=(0,S.jsx)(d,{side:`left`,sideOffset:6,children:h}),t[10]=h,t[11]=w);let T;t[12]!==C||t[13]!==w?(T=(0,S.jsxs)(f,{children:[C,w]}),t[12]=C,t[13]=w,t[14]=T):T=t[14];let E=ie[c],D;t[15]===E?D=t[16]:(D=o(`block whitespace-normal break-words`,E),t[15]=E,t[16]=D);let O;t[17]!==D||t[18]!==n.content?(O=(0,S.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,S.jsx)(`span`,{className:D,children:n.content})}),t[17]=D,t[18]=n.content,t[19]=O):O=t[19];let k;return t[20]!==i||t[21]!==O||t[22]!==v||t[23]!==b||t[24]!==T?(k=(0,S.jsxs)(`li`,{ref:i,"aria-current":v,className:b,children:[T,O]}),t[20]=i,t[21]=O,t[22]=v,t[23]=b,t[24]=T,t[25]=k):k=t[25],k},oe=new Set([`in_progress`,`pending`,`completed`,`cancelled`]),P=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`),F=e=>e?Object.entries(e).map(([e,t])=>t==null?``:`${e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}:${typeof t==`number`?`${t}px`:t};`).join(``):``,I=(e,t,n)=>{let r=e.querySelector(`pre`);r&&(r.style.margin=`0`,r.style.background=`transparent`,r.style.whiteSpace=t?`pre-wrap`:`pre`,t&&(r.style.wordBreak=`break-word`,r.style.overflowWrap=`break-word`));let i=e.querySelector(`code`);if(i){let e=F(n);e&&i.setAttribute(`style`,`${i.getAttribute(`style`)??``}${e}`)}},L=e=>`<pre><code>${P(e)}</code></pre>`,R=e=>{let t=(0,x.c)(21),{code:n,language:r,className:i,style:a,codeStyle:s,wrap:l}=e,u=l!==void 0&&l,{currentTheme:d}=c(),f=b.useRef(null),p;t[0]===d?p=t[1]:(p=_(d),t[0]=d,t[1]=p);let m=p,h,g;t[2]!==n||t[3]!==s||t[4]!==u?(h=()=>{let e=f.current;e&&(e.innerHTML=L(n),I(e,u,s))},g=[n,u,s],t[2]=n,t[3]=s,t[4]=u,t[5]=h,t[6]=g):(h=t[5],g=t[6]),b.useLayoutEffect(h,g);let v,C;t[7]!==n||t[8]!==s||t[9]!==r||t[10]!==u?(v=()=>{let e=f.current;if(!e)return;let t=!0,i=new AbortController;return y(n,(r||`text`).toLowerCase(),{signal:i.signal,priority:`visible`}).then(n=>{!t||!e||!n||(e.innerHTML=n,I(e,u,s))}),()=>{t=!1,i.abort()}},C=[n,r,u,s],t[7]=n,t[8]=s,t[9]=r,t[10]=u,t[11]=v,t[12]=C):(v=t[11],C=t[12]),b.useEffect(v,C);let w;t[13]===i?w=t[14]:(w=o(`typography-code`,i),t[13]=i,t[14]=w);let T=m,E;t[15]!==a||t[16]!==T?(E={...T,...a},t[15]=a,t[16]=T,t[17]=E):E=t[17];let D;return t[18]!==w||t[19]!==E?(D=(0,S.jsx)(`div`,{ref:f,className:w,style:E}),t[18]=w,t[19]=E,t[20]=D):D=t[20],D},z=e=>{let t=e.replace(/^<file>\s*\n?/,``).replace(/\n?<\/file>\s*$/,``);return t=t.replace(/^\s*\d{5}\|\s?/gm,``),t.trim()},B=(e,t=``)=>{if(typeof e==`string`)return e;if(e==null)return t;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return String(e);try{return JSON.stringify(e)}catch{return t}},V=e=>e?e.includes(`<diagnostics`)||e.includes(`<file_diagnostics>`)||e.includes(`LSP errors detected`)||e.includes(`This file has errors`):!1,H=e=>e?e.replace(/\n{0,2}LSP errors detected[\s\S]*?<diagnostics[^>]*>[\s\S]*?<\/diagnostics>/g,``).replace(/\n{0,2}This file has errors[\s\S]*?<\/file_diagnostics>/g,``).replace(/<diagnostics[^>]*>[\s\S]*?<\/diagnostics>/g,``).replace(/<file_diagnostics>[\s\S]*?<\/file_diagnostics>/g,``).trim():``,U=(e,t)=>!e||typeof e!=`object`?String(e):h(e,t||``),W=e=>{if(typeof e==`string`){let t=e.trim();return t.length>0?t:void 0}if(e&&typeof e==`object`){let t=e.patch;if(typeof t==`string`){let e=t.trim();return e.length>0?e:void 0}}},G=e=>{if(!e||typeof e!=`object`)return;let t=W(e.patch)??W(e.diff);if(t)return t;let n=Array.isArray(e.files)?e.files:[];for(let e of n){if(!e||typeof e!=`object`)continue;let t=W(e.patch)??W(e.diff);if(t)return t}},K=e=>{if(!e||typeof e!=`string`)return{data:null,isJson:!1};let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`)||!t.endsWith(`}`)&&!t.endsWith(`]`)||t.length<2)return{data:null,isJson:!1};try{let e=JSON.parse(t);return typeof e==`object`&&e?{data:e,isJson:!0}:{data:null,isJson:!1}}catch{return{data:null,isJson:!1}}},q=(e,t,n)=>{let r=z(e);if((t===`edit`||t===`multiedit`||t===`write`||t===`apply_patch`)&&V(r)&&(r=H(r)),(t===`edit`||t===`multiedit`||t===`apply_patch`)&&r.trim().length===0){let e=G(n);if(e)return e}return r},se=e=>{let t=e.match(/<type>(file|directory)<\/type>/i)?.[1]?.toLowerCase()??`unknown`,n=(e.match(/<content>([\s\S]*?)<\/content>/i)?.[1]??e).replace(/\r\n/g,`
2
2
  `).split(`
3
3
  `),r=e=>/\(\s*File has more lines\..*offset.*\)/i.test(e.trim());return{type:t,lines:n.map(e=>{let n=e.trim(),i=n.startsWith(`(`)&&n.endsWith(`)`)||r(n);if(t!==`directory`){let t=e.match(/^(\d+):\s?(.*)$/);if(t){let e=t[2],n=e.trim(),i=n.startsWith(`(`)&&n.endsWith(`)`)||r(n);return{lineNumber:i?null:Number(t[1]),text:e,isInfo:i}}}return{lineNumber:null,text:e,isInfo:i}}).filter((e,t,n)=>{if(e.text.trim().length>0)return!0;let r=n[t-1],i=n[t+1],a=!!(r?.isInfo||i?.isInfo),o=e.lineNumber!==null;return!(a&&o)})}},ce=(e,t)=>{try{let n=e.trim().split(`
4
4
  `).filter(Boolean);if(n.length===0)return null;let i=[];return n.forEach(e=>{let t=e.match(/^(\s*)(.+)$/);if(t){let[,e,n]=t,r=Math.floor(e.length/2),a=!n.endsWith(`/`);i.push({name:n.replace(/\/$/,``),depth:r,isFile:a})}}),(0,S.jsx)(`div`,{className:o(`w-full min-w-0 font-mono space-y-0.5`,t?.unstyled?null:`p-3 bg-muted/20 rounded-xl border border-border/30`),style:r.tool.popup,children:i.map((e,t)=>(0,S.jsx)(`div`,{className:`min-w-0`,style:{paddingLeft:`${e.depth*20}px`},children:e.isFile?(0,S.jsx)(`span`,{className:`text-foreground/90 block truncate`,children:e.name}):(0,S.jsxs)(`span`,{className:`font-semibold text-foreground block truncate`,children:[e.name,`/`]})},t))})}catch{return null}},le={backgroundColor:`var(--status-info)`,opacity:.6},ue=(e,t,n)=>{try{let i=e.trim().split(`
package/dist/index.html CHANGED
@@ -560,7 +560,7 @@
560
560
  opacity: 0.72;
561
561
  }
562
562
  </style>
563
- <script type="module" crossorigin src="/assets/main-C4Zc7_s8.js"></script>
563
+ <script type="module" crossorigin src="/assets/main-1iPWY6JE.js"></script>
564
564
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
565
565
  <link rel="modulepreload" crossorigin href="/assets/runtime-auth-ef9W7A43.js">
566
566
  <link rel="modulepreload" crossorigin href="/assets/runtime-switch-CAZiOV2G.js">
@@ -588,10 +588,10 @@
588
588
  <link rel="modulepreload" crossorigin href="/assets/platform-CxNhofMC.js">
589
589
  <link rel="modulepreload" crossorigin href="/assets/terminalApi-Bs5skvIp.js">
590
590
  <link rel="modulepreload" crossorigin href="/assets/runtime-file-download-CwMwe_O9.js">
591
- <link rel="modulepreload" crossorigin href="/assets/types-eQY4TOgr.js">
592
- <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-DCIeVZw_.js">
593
- <link rel="modulepreload" crossorigin href="/assets/native-config-DnQvXgu6.js">
594
- <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-jHTvOptz.js">
591
+ <link rel="modulepreload" crossorigin href="/assets/types-aeu41u0o.js">
592
+ <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-ClmWgQsn.js">
593
+ <link rel="modulepreload" crossorigin href="/assets/native-config-6ZcbOTlU.js">
594
+ <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-BndFf_Fb.js">
595
595
  <link rel="stylesheet" crossorigin href="/assets/src-CZA3gFyl.css">
596
596
  </head>
597
597
  <body class="h-full bg-background text-foreground">
@@ -74,7 +74,7 @@
74
74
  }
75
75
  </style>
76
76
 
77
- <script type="module" crossorigin src="/assets/miniChat-C_wwveSN.js"></script>
77
+ <script type="module" crossorigin src="/assets/miniChat-DV5fIjdE.js"></script>
78
78
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
79
79
  <link rel="modulepreload" crossorigin href="/assets/runtime-auth-ef9W7A43.js">
80
80
  <link rel="modulepreload" crossorigin href="/assets/runtime-switch-CAZiOV2G.js">
@@ -102,10 +102,10 @@
102
102
  <link rel="modulepreload" crossorigin href="/assets/platform-CxNhofMC.js">
103
103
  <link rel="modulepreload" crossorigin href="/assets/terminalApi-Bs5skvIp.js">
104
104
  <link rel="modulepreload" crossorigin href="/assets/runtime-file-download-CwMwe_O9.js">
105
- <link rel="modulepreload" crossorigin href="/assets/types-eQY4TOgr.js">
106
- <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-DCIeVZw_.js">
107
- <link rel="modulepreload" crossorigin href="/assets/native-config-DnQvXgu6.js">
108
- <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-jHTvOptz.js">
105
+ <link rel="modulepreload" crossorigin href="/assets/types-aeu41u0o.js">
106
+ <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-ClmWgQsn.js">
107
+ <link rel="modulepreload" crossorigin href="/assets/native-config-6ZcbOTlU.js">
108
+ <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-BndFf_Fb.js">
109
109
  <link rel="stylesheet" crossorigin href="/assets/src-CZA3gFyl.css">
110
110
  </head>
111
111
  <body class="h-full bg-background text-foreground">
package/dist/mobile.html CHANGED
@@ -63,7 +63,7 @@
63
63
  })();
64
64
  </script>
65
65
 
66
- <script type="module" crossorigin src="/assets/mobile-TuU7P2PX.js"></script>
66
+ <script type="module" crossorigin src="/assets/mobile-C7hRNLd2.js"></script>
67
67
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
68
68
  <link rel="modulepreload" crossorigin href="/assets/runtime-auth-ef9W7A43.js">
69
69
  <link rel="modulepreload" crossorigin href="/assets/runtime-switch-CAZiOV2G.js">
@@ -91,10 +91,10 @@
91
91
  <link rel="modulepreload" crossorigin href="/assets/platform-CxNhofMC.js">
92
92
  <link rel="modulepreload" crossorigin href="/assets/terminalApi-Bs5skvIp.js">
93
93
  <link rel="modulepreload" crossorigin href="/assets/runtime-file-download-CwMwe_O9.js">
94
- <link rel="modulepreload" crossorigin href="/assets/types-eQY4TOgr.js">
95
- <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-DCIeVZw_.js">
96
- <link rel="modulepreload" crossorigin href="/assets/native-config-DnQvXgu6.js">
97
- <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-jHTvOptz.js">
94
+ <link rel="modulepreload" crossorigin href="/assets/types-aeu41u0o.js">
95
+ <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-ClmWgQsn.js">
96
+ <link rel="modulepreload" crossorigin href="/assets/native-config-6ZcbOTlU.js">
97
+ <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-BndFf_Fb.js">
98
98
  <link rel="stylesheet" crossorigin href="/assets/src-CZA3gFyl.css">
99
99
  </head>
100
100
  <body class="h-full bg-background text-foreground">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuriai/web",
3
- "version": "0.2.0-beta.2",
3
+ "version": "0.2.0-beta.4",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./server/index.js",
@@ -3,11 +3,12 @@
3
3
  The Host owns `content-search.sqlite` alongside the session index. This index is
4
4
  independent of browser transcript caches and includes all projects exposed by the
5
5
  active OpenCode runtime. `session.list` is called without a project/directory
6
- filter; opaque cursors are followed until exhausted. The default coverage is
6
+ filter during initial backfill; descending opaque cursors stop at the thirty-day
7
+ boundary or exhaustion. The default coverage is
7
8
  messages created in the last thirty days in recently updated root sessions.
8
9
  Sessions with a non-empty `parentID` (subagents) are excluded before message
9
10
  fetching and progress counting. Only root IDs enter the authoritative pruning
10
- set, so a successful catalog scan also removes previously indexed subagent
11
+ set, so a fully exhausted catalog scan also removes previously indexed subagent
11
12
  messages, FTS entries and checkpoints. Failed catalog reads preserve the old index.
12
13
 
13
14
  Two workers page native `message.list` directly, normalize via the shared server
@@ -31,12 +32,13 @@ and checkpoint until a complete replacement succeeds.
31
32
  `search_coverage` durably records each runtime's `indexStartedAt`,
32
33
  `indexCompletedAt`, `coveredSince`, and `verifiedAt`. These are index operation
33
34
  timestamps, not installation/version timestamps or browser onboarding flags.
34
- An absent completion marker requires initialization. Every startup still walks
35
- the authoritative complete OpenCode catalog and compares each recent session's
36
- updated time and indexed boundary; a prior global completion never bypasses
37
- that check. Missing, stale, or insufficient-coverage checkpoints are refreshed in
38
- the background after the first successful initialization, without clearing its
39
- completion marker or reopening onboarding. Already verified unchanged sessions are reused, including
35
+ An absent completion marker requires initialization. A completed runtime does not
36
+ walk the catalog on startup or on a timer. It resumes only the durable dirty-session
37
+ queue populated by live events. Each dirty session is read by ID and refreshes its
38
+ own messages; unrelated sessions incur no upstream work. Initialization failures
39
+ retry using committed per-session checkpoints. Explicit `sync()` remains deliberate
40
+ catalog reconciliation; automatic scheduling uses incremental mode.
41
+ Already verified unchanged sessions are reused, including
40
42
  sessions with no searchable text. Each session now commits an `indexed_at`
41
43
  completion timestamp atomically with its projection, source update time and
42
44
  coverage boundary. Existing databases gain this nullable column and the coverage
@@ -60,7 +62,7 @@ coverage (for example after a system-clock correction).
60
62
  The status response adds `initializationRequired` and these durable timestamps.
61
63
  `updatedAt` remains the current process's latest completed pass, including partial
62
64
  passes; clients must not confuse it with successful durable completion. A warm
63
- startup may be `pending` with `initializationRequired: false`; discovered gaps
65
+ startup may be `pending` with `initializationRequired: false`; queued dirty sessions
64
66
  remain background work. `initializationRequired` indicates unfinished first-time
65
67
  initialization, not whether the latest incremental pass has caught up. No
66
68
  UI-triggered import or OpenCode database conversion is needed:
@@ -80,8 +82,12 @@ dismissal; runtime changes recheck. Older Hosts without the new status fields
80
82
  keep their existing behavior. VS Code's direct OpenCode connection has no Host
81
83
  FTS service and does not mount this step.
82
84
 
83
- Global upstream events mark sessions dirty and coalesce a scan within one second;
84
- a 30-second reconciliation discovers missed events. Indexing does not depend on
85
+ Global upstream events durably mark sessions dirty and coalesce work within one
86
+ second. Successful writes acknowledge only the captured dirty revision, so an event
87
+ during the fetch survives for another pass. Thirty-second retries are scheduled
88
+ only for unfinished initialization or pending dirty sessions, never idle catalog
89
+ polling. Deleted-session events and confirmed 404 remove that session; a time-bounded
90
+ catalog is not authoritative absence for unvisited IDs. Indexing does not depend on
85
91
  any UI session being opened. Runtime identity is owned by the Host session index;
86
92
  in-flight results are rejected if it changes. Stop aborts reads and drains the
87
93
  active pass before closing SQLite.
@@ -7,6 +7,7 @@ export function createGlobalContentSearch({ dataDir, getRuntimeKey, buildOpenCod
7
7
  const service = createContentSearchService({ dbPath: path.join(dataDir, 'content-search.sqlite') });
8
8
  const client = () => makeOpenCodeV2Client({ baseUrl: buildOpenCodeUrl('/', ''), authHeaders: getOpenCodeAuthHeaders() });
9
9
  const runtime = createContentSearchRuntime({ service, getRuntimeKey,
10
+ getSession: ({ sessionID, signal }) => client().session.get({ sessionID }, { signal: AbortSignal.any([signal, AbortSignal.timeout(30_000)]) }),
10
11
  listSessions: async ({ signal, ...query }) => {
11
12
  await waitForReady();
12
13
  return client().session.list(query, { signal: AbortSignal.any([signal, AbortSignal.timeout(30_000)]) });
@@ -5,7 +5,7 @@ import { normalizeSessionEventType } from '../session-metadata/session-projectio
5
5
  const RETENTION = 30 * 24 * 60 * 60 * 1000;
6
6
  const nextCursor = (page) => typeof page?.cursor?.next === 'string' ? page.cursor.next : null;
7
7
 
8
- export function createContentSearchRuntime({ service, getRuntimeKey, listSessions, listMessages, now = Date.now }) {
8
+ export function createContentSearchRuntime({ service, getRuntimeKey, listSessions, getSession, listMessages, now = Date.now }) {
9
9
  let stopped = false;
10
10
  let flight;
11
11
  let timer;
@@ -16,11 +16,12 @@ export function createContentSearchRuntime({ service, getRuntimeKey, listSession
16
16
  const deleted = new Set();
17
17
  const status = () => {
18
18
  const runtime = getRuntimeKey();
19
+ if (!stopped && state.runtime !== runtime) schedule(0);
19
20
  const coverage = service.coverage(runtime);
20
21
  return { ...(state.runtime === runtime ? state : { runtime, phase: 'pending', since: now() - RETENTION, total: 0, completed: 0, failed: 0, updatedAt: null }),
21
22
  ...coverage, initializationRequired: coverage.indexCompletedAt === null, ...service.stats(runtime) };
22
23
  };
23
- const sync = () => {
24
+ const sync = ({ incremental = false } = {}) => {
24
25
  if (stopped) return Promise.resolve();
25
26
  if (flight) return flight;
26
27
  const runtime = getRuntimeKey();
@@ -32,13 +33,37 @@ export function createContentSearchRuntime({ service, getRuntimeKey, listSession
32
33
  state = { runtime, phase: previous ? 'ready' : 'indexing', since: now() - RETENTION, total: state.total, completed: 0, failed: 0, updatedAt: previous };
33
34
  flight = (async () => {
34
35
  if (service.coverage(runtime).indexCompletedAt === null) service.beginInitialization(runtime, now());
36
+ const revisions = new Map(service.pending(runtime).map(({ id, revision }) => [id, revision]));
37
+ for (const id of revisions.keys()) dirty.add(id);
35
38
  const pendingDirty = new Set(dirty);
39
+ const initialized = service.coverage(runtime).indexCompletedAt !== null;
40
+ const scanCatalog = !incremental || !initialized;
36
41
  const sessions = [];
37
42
  const ids = new Set();
38
43
  let cursor;
44
+ let completeCatalog = scanCatalog;
39
45
  const cursors = new Set();
40
- do {
41
- const page = await listSessions({ limit: 100, ...(cursor ? { cursor } : {}), signal });
46
+ if (!scanCatalog) {
47
+ for (const sessionID of pendingDirty) {
48
+ try {
49
+ const session = await getSession({ sessionID, signal });
50
+ if (!current()) return;
51
+ if (!session?.id || !Number.isFinite(session.time?.updated)) throw new Error('Invalid dirty session');
52
+ if (!session.parentID && session.time.updated >= state.since && !deleted.has(sessionID)) sessions.push(session);
53
+ else {
54
+ service.removeSession(runtime, sessionID);
55
+ dirty.delete(sessionID);
56
+ }
57
+ } catch (error) {
58
+ if (!current()) return;
59
+ if ((error?.status ?? error?.response?.status) === 404) {
60
+ service.removeSession(runtime, sessionID);
61
+ dirty.delete(sessionID);
62
+ } else state.failed++;
63
+ }
64
+ }
65
+ } else do {
66
+ const page = await listSessions({ limit: 100, ...(cursor ? { cursor } : { order: 'desc' }), signal });
42
67
  if (!current()) return;
43
68
  if (!Array.isArray(page?.data)) throw new Error('Invalid global session page');
44
69
  for (const session of page.data) {
@@ -51,11 +76,18 @@ export function createContentSearchRuntime({ service, getRuntimeKey, listSession
51
76
  cursor = nextCursor(page);
52
77
  if (cursor && cursors.has(cursor)) throw new Error('Repeated session cursor');
53
78
  if (cursor) cursors.add(cursor);
79
+ if (page.data.some((session) => session.time.updated < state.since)) {
80
+ completeCatalog = !cursor;
81
+ break;
82
+ }
54
83
  } while (cursor && current());
55
84
  state.total = sessions.length;
56
85
  state.completed = 0;
57
86
  const recentIDs = new Set(sessions.map((session) => session.id));
58
- for (const id of pendingDirty) if (!recentIDs.has(id)) dirty.delete(id);
87
+ if (scanCatalog && completeCatalog) for (const id of pendingDirty) if (!recentIDs.has(id)) {
88
+ dirty.delete(id);
89
+ service.acknowledge(runtime, id, revisions.get(id));
90
+ }
59
91
  if (service.coverage(runtime).indexCompletedAt === null) state.phase = 'indexing';
60
92
  let index = 0;
61
93
  const worker = async () => {
@@ -85,7 +117,10 @@ export function createContentSearchRuntime({ service, getRuntimeKey, listSession
85
117
  // Native pages are newest-first, including control records.
86
118
  if (page.data.length && page.data.every((record) => Number(record.time?.created) < state.since)) break;
87
119
  } while (before && current());
88
- if (current() && !deleted.has(session.id)) service.replaceSession(runtime, session, [...records.values()], state.since, now());
120
+ if (current() && !deleted.has(session.id)) {
121
+ service.replaceSession(runtime, session, [...records.values()], state.since, now());
122
+ if (revisions.has(session.id)) service.acknowledge(runtime, session.id, revisions.get(session.id));
123
+ }
89
124
  state.completed++;
90
125
  } catch {
91
126
  if (!current()) return;
@@ -96,7 +131,7 @@ export function createContentSearchRuntime({ service, getRuntimeKey, listSession
96
131
  };
97
132
  await Promise.all([worker(), worker()]);
98
133
  if (current()) {
99
- service.prune(runtime, state.since, ids);
134
+ service.prune(runtime, state.since, completeCatalog ? ids : undefined);
100
135
  state.phase = state.failed ? 'partial' : 'ready';
101
136
  state.updatedAt = now();
102
137
  if (!state.failed && !dirty.size) service.completeInitialization(runtime, state.since, state.updatedAt);
@@ -110,7 +145,11 @@ export function createContentSearchRuntime({ service, getRuntimeKey, listSession
110
145
  if (stopped || (timer && due <= Date.now() + delay)) return;
111
146
  if (timer) clearTimeout(timer);
112
147
  due = Date.now() + delay;
113
- timer = setTimeout(async () => { timer = undefined; await sync(); schedule(30_000); }, delay);
148
+ timer = setTimeout(async () => {
149
+ timer = undefined;
150
+ await sync({ incremental: true });
151
+ if (service.coverage(getRuntimeKey()).indexCompletedAt === null || service.pending(getRuntimeKey()).length) schedule(30_000);
152
+ }, delay);
114
153
  timer.unref?.();
115
154
  };
116
155
  return {
@@ -118,6 +157,7 @@ export function createContentSearchRuntime({ service, getRuntimeKey, listSession
118
157
  start() { schedule(0); },
119
158
  observe(event) {
120
159
  if (event.runtimeIdentity?.runtimeKey && event.runtimeIdentity.runtimeKey !== getRuntimeKey()) return;
160
+ if (state.runtime !== getRuntimeKey()) schedule(0);
121
161
  const payload = event.payload?.payload ?? event.payload;
122
162
  const type = normalizeSessionEventType(payload?.type ?? '');
123
163
  if (!(type.startsWith('message.') || type.startsWith('session.'))) return;
@@ -125,7 +165,8 @@ export function createContentSearchRuntime({ service, getRuntimeKey, listSession
125
165
  const data = payload.properties ?? payload.data ?? {};
126
166
  const id = data.sessionID ?? data.info?.sessionID ?? data.session?.id ?? (type.startsWith('session.') ? data.id ?? data.info?.id : undefined);
127
167
  if (id && type === 'session.deleted') { dirty.delete(id); deleted.add(id); service.removeSession(getRuntimeKey(), id); }
128
- else if (id) dirty.add(id);
168
+ else if (id) { dirty.add(id); service.markDirty(getRuntimeKey(), id); }
169
+ if (!id) return;
129
170
  // Coalesce bursts; ongoing scans retain dirty IDs for the next pass.
130
171
  schedule(1000);
131
172
  },
@@ -1,7 +1,78 @@
1
- import { expect, test } from 'vitest';
1
+ import { expect, test, vi } from 'vitest';
2
2
  import { createContentSearchService } from './service.js';
3
3
  import { createContentSearchRuntime } from './runtime.js';
4
4
 
5
+ test('warm startup and idle time do not scan history; durable dirty events refresh only their session', async () => {
6
+ vi.useFakeTimers();
7
+ const service = createContentSearchService({ dbPath: ':memory:' });
8
+ service.beginInitialization('host', 1);
9
+ service.completeInitialization('host', 0, 2);
10
+ const listSessions = vi.fn(async () => ({ data: [], cursor: {} }));
11
+ const getSession = vi.fn(async ({ sessionID }) => ({ id: sessionID, time: { updated: Date.now() } }));
12
+ const listMessages = vi.fn(async () => ({ data: [], cursor: {} }));
13
+ let runtime = createContentSearchRuntime({ service, getRuntimeKey: () => 'host', listSessions, getSession, listMessages });
14
+ try {
15
+ runtime.start();
16
+ await vi.advanceTimersByTimeAsync(120_000);
17
+ expect(listSessions).not.toHaveBeenCalled();
18
+ expect(listMessages).not.toHaveBeenCalled();
19
+ runtime.observe({ payload: { type: 'message.updated', data: { sessionID: 'one' } } });
20
+ await runtime.stop();
21
+ runtime = createContentSearchRuntime({ service, getRuntimeKey: () => 'host', listSessions, getSession, listMessages });
22
+ runtime.start();
23
+ await vi.advanceTimersByTimeAsync(120_000);
24
+ expect(listSessions).not.toHaveBeenCalled();
25
+ expect(getSession).toHaveBeenCalledTimes(1);
26
+ expect(getSession.mock.calls[0][0].sessionID).toBe('one');
27
+ expect(listMessages).toHaveBeenCalledTimes(1);
28
+ } finally { await runtime.stop(); service.close(); vi.useRealTimers(); }
29
+ });
30
+
31
+ test('initial history stops at thirty days without pruning unseen sessions as deleted', async () => {
32
+ const service = createContentSearchService({ dbPath: ':memory:' });
33
+ const day = 86400000;
34
+ const now = 40 * day;
35
+ service.replaceSession('host', { id: 'unseen', time: { updated: now } }, [], 0);
36
+ const listSessions = vi.fn(async () => ({ data: [
37
+ { id: 'recent', time: { updated: now } },
38
+ { id: 'old', time: { updated: now - 31 * day } },
39
+ ], cursor: { next: 'older-history' } }));
40
+ const listMessages = vi.fn(async () => ({ data: [], cursor: {} }));
41
+ const runtime = createContentSearchRuntime({ service, getRuntimeKey: () => 'host', now: () => now, listSessions, listMessages });
42
+ try {
43
+ await runtime.sync();
44
+ expect(listSessions).toHaveBeenCalledTimes(1);
45
+ expect(listMessages).toHaveBeenCalledTimes(1);
46
+ expect(listMessages.mock.calls[0][0].sessionID).toBe('recent');
47
+ expect(service.updated('host', 'unseen')).toBe(now);
48
+ expect(runtime.status().initializationRequired).toBe(false);
49
+ } finally { await runtime.stop(); service.close(); }
50
+ });
51
+
52
+ test('an event received while indexing survives acknowledgement and retries only that session', async () => {
53
+ const service = createContentSearchService({ dbPath: ':memory:' });
54
+ service.beginInitialization('host', 1);
55
+ service.completeInitialization('host', 0, 2);
56
+ const listSessions = vi.fn();
57
+ let reads = 0;
58
+ const runtime = createContentSearchRuntime({ service, getRuntimeKey: () => 'host', now: () => 100,
59
+ listSessions, getSession: async ({ sessionID }) => ({ id: sessionID, time: { updated: 10 } }),
60
+ listMessages: async () => {
61
+ if (++reads === 1) runtime.observe({ payload: { type: 'message.updated', data: { sessionID: 's' } } });
62
+ return { data: [], cursor: {} };
63
+ },
64
+ });
65
+ try {
66
+ runtime.observe({ payload: { type: 'message.updated', data: { sessionID: 's' } } });
67
+ await runtime.sync({ incremental: true });
68
+ expect(service.pending('host')).toHaveLength(1);
69
+ await runtime.sync({ incremental: true });
70
+ expect(reads).toBe(2);
71
+ expect(service.pending('host')).toEqual([]);
72
+ expect(listSessions).not.toHaveBeenCalled();
73
+ } finally { await runtime.stop(); service.close(); }
74
+ });
75
+
5
76
  test('indexes only roots and prunes legacy subagents after a complete catalog, including dirty children', async () => {
6
77
  const service = createContentSearchService({ dbPath: ':memory:' });
7
78
  const root = { id: 'root', time: { updated: 10 } };
@@ -22,6 +22,7 @@ export function createContentSearchService({ dbPath }) {
22
22
  CREATE TABLE IF NOT EXISTS search_message(id INTEGER PRIMARY KEY, runtime TEXT, session TEXT, message TEXT, role TEXT, created REAL, body TEXT, UNIQUE(runtime,session,message));
23
23
  CREATE INDEX IF NOT EXISTS search_message_scope ON search_message(runtime,session);
24
24
  CREATE TABLE IF NOT EXISTS search_coverage(runtime TEXT PRIMARY KEY, started_at REAL NOT NULL, completed_at REAL, since REAL, verified_at REAL);
25
+ CREATE TABLE IF NOT EXISTS search_dirty(runtime TEXT, id TEXT, revision INTEGER NOT NULL, PRIMARY KEY(runtime,id));
25
26
  CREATE VIRTUAL TABLE IF NOT EXISTS search_fts USING fts5(body, content='search_message', content_rowid='id', tokenize='trigram');
26
27
  CREATE TRIGGER IF NOT EXISTS search_insert AFTER INSERT ON search_message BEGIN
27
28
  INSERT INTO search_fts(rowid,body) VALUES(new.id,new.body); END;
@@ -40,8 +41,18 @@ export function createContentSearchService({ dbPath }) {
40
41
  const removeSession = db.transaction((runtime, id) => {
41
42
  remove.run(runtime, id);
42
43
  db.prepare('DELETE FROM search_session WHERE runtime=? AND id=?').run(runtime, id);
44
+ db.prepare('DELETE FROM search_dirty WHERE runtime=? AND id=?').run(runtime, id);
43
45
  });
44
46
  return {
47
+ markDirty(runtime, id) {
48
+ db.prepare('INSERT INTO search_dirty(runtime,id,revision) VALUES(?,?,1) ON CONFLICT(runtime,id) DO UPDATE SET revision=revision+1').run(runtime, id);
49
+ },
50
+ pending(runtime) {
51
+ return db.prepare('SELECT id,revision FROM search_dirty WHERE runtime=?').all(runtime);
52
+ },
53
+ acknowledge(runtime, id, revision) {
54
+ return db.prepare('DELETE FROM search_dirty WHERE runtime=? AND id=? AND revision=?').run(runtime, id, revision).changes > 0;
55
+ },
45
56
  coverage(runtime) {
46
57
  return db.prepare('SELECT started_at AS indexStartedAt, completed_at AS indexCompletedAt, since AS coveredSince, verified_at AS verifiedAt FROM search_coverage WHERE runtime=?').get(runtime)
47
58
  ?? { indexStartedAt: null, indexCompletedAt: null, coveredSince: null, verifiedAt: null };
@@ -73,7 +84,7 @@ export function createContentSearchService({ dbPath }) {
73
84
  prune: db.transaction((runtime, since, ids) => {
74
85
  db.prepare('DELETE FROM search_message WHERE runtime=? AND created<?').run(runtime, since);
75
86
  db.prepare('UPDATE search_session SET since=MAX(since,?) WHERE runtime=? AND since IS NOT NULL').run(since, runtime);
76
- for (const row of db.prepare('SELECT id FROM search_session WHERE runtime=?').all(runtime)) {
87
+ if (ids) for (const row of db.prepare('SELECT id FROM search_session WHERE runtime=?').all(runtime)) {
77
88
  if (!ids.has(row.id)) removeSession(runtime, row.id);
78
89
  }
79
90
  }),
@@ -1,10 +0,0 @@
1
- import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{i as n}from"./runtime-switch-CAZiOV2G.js";import{nn as r}from"./persistence-CcGnI3Ek.js";import{it as i,rt as a}from"./vendor-base-ui-CdzJ6My_.js";import{t as o}from"./platform-CxNhofMC.js";import{n as s}from"./useUIStore-NMQx_cnG.js";import{n as c}from"./vendor-react-BP2cRVqX.js";import{g as l}from"./path-utils-QNmCUIdP.js";import{n as u}from"./vendor-katex-DNVSTX6g.js";import{f as d,n as f,r as p}from"./vendor-reactuses-core-BpfIZ1tg.js";import{d as m,f as h,r as g}from"./button-4sNruiRJ.js";import{qi as _}from"./useMobileNavigationStore-Cwk7wARY.js";import{t as v}from"./dualLimitLru-D8Sphgua.js";import{t as y}from"./useThemeSystem-8jhE4Zyk.js";import{a as b,d as x,i as S,t as C}from"./image-loading-ClwkpTt4.js";import{a as w,i as T,n as E,r as D}from"./url-MRa-FtQa.js";import{n as ee}from"./useEffectiveDirectory-9Efzl9IZ.js";import{c as O,i as k,l as te,n as ne,o as A,r as re}from"./FadeInOnReveal-DuelAGXz.js";import{i as ie,r as j,t as ae}from"./markdownHeightCache-Ci4Phpkv.js";import{n as oe,t as M}from"./markdownTheme-DHoKvD6O.js";import{i as N,n as se,t as P}from"./markdown-worker-oBGEB9Eg.js";import{t as ce}from"./vendor-morphdom-BbKiNDAu.js";import{t as F}from"./vendor-dompurify-CeJNOzik.js";import{t as I}from"./vendor-pele-C1WTNWUm.js";import{t as L}from"./vendor-marked-WVekxjAN.js";import{t as R}from"./vendor-remend-C3cXc-tf.js";import{a as le,c as z,f as B,g as V,h as H,i as U,l as ue,n as de,o as W,p as fe,t as pe,u as G}from"./fileReferenceActions-ZQ5--HF8.js";var K=t(i(),1),me=c(),he=new v({maxEntries:100,maxBytes:8388608}),ge=(e,t)=>{let{surface:n,interactive:r,primary:i,status:a}=t.colors,o={bg:n.elevated,fg:n.foreground,muted:n.mutedForeground,line:r.border,surface:n.muted,"surface-alt":n.background,border:r.border,accent:i.base,critical:a.error,error:a.error,"series-1":i.base,"series-2":a.info,"series-3":a.success,"series-4":a.warning,"series-5":a.error,"series-6":i.hover??i.base,"series-7":a.infoForeground,"series-8":a.successForeground},s=JSON.stringify([o,new Date().toDateString(),e]),c=he.get(s);if(c)return c;let l;try{let{svg:t}=I(e,{fontFamily:`system-ui, sans-serif`,autoDirection:!1,links:!1,images:!1}),n=F.sanitize(t,{USE_PROFILES:{svg:!0,svgFilters:!0},RETURN_DOM_FRAGMENT:!0}).querySelector(`svg`);if(!n)throw Error(`Missing diagram SVG`);for(let[e,t]of Object.entries(o))n.style.setProperty(`--pele-${e}`,t);l={svg:n.outerHTML}}catch{l={}}return he.set(s,l,(s.length+(l.svg?.length??0))*2),l},q=`data-md-stream-fence`,_e=`data-md-stream-line`,ve=`data-md-stream-src`,ye=`data-md-stream-applied`,be=(e,t)=>{let n=Math.min(e.length,t.length);for(let r=0;r<n;r+=1)if(e[r]!==t[r])return r;return n},xe=e=>Array.from(e.children).filter(e=>e instanceof HTMLElement&&e.hasAttribute(`data-md-stream-line`)),Se=(e,t)=>{let n=document.createElement(`span`);return n.setAttribute(_e,String(t)),n.className=`line`,n.innerHTML=e,n},Ce=(e,t)=>{let n=xe(e),r=be(n.map(e=>e.innerHTML),t);if(n.length===0&&e.childNodes.length>0&&t.length>0){e.replaceChildren();for(let n=0;n<t.length;n+=1)n>0&&e.appendChild(document.createTextNode(`
2
- `)),e.appendChild(Se(t[n]??``,n));return{reused:0,replaced:0,added:t.length,removed:0}}let i=0;if(r<n.length&&r<t.length){let e=n[r];e&&(e.innerHTML=t[r]??``,e.setAttribute(_e,String(r)),i=1)}let a=0;for(let e=n.length-1;e>=r+i;--e){let t=n[e]?.previousSibling;t?.nodeType===Node.TEXT_NODE&&t.remove(),n[e]?.remove(),a+=1}let o=0;for(let n=r+i;n<t.length;n+=1)n>0&&e.appendChild(document.createTextNode(`
3
- `)),e.appendChild(Se(t[n]??``,n)),o+=1;return{reused:r,replaced:i,added:o,removed:a}},we=e=>{if(e.includes(`data-md-stream-fence=`))return e;let t=e.toLowerCase().lastIndexOf(`<pre`);return t<0?e:`${e.slice(0,t)}${e.slice(t).replace(/<pre\b/i,`<pre ${q}="true"`)}`},Te=(e,t)=>{if(!(e instanceof HTMLElement)||!(t instanceof HTMLElement)||e.getAttribute(`data-md-stream-fence`)!==`true`||t.getAttribute(`data-md-stream-fence`)!==`true`)return!1;let n=e.tagName===`CODE`?e:e.querySelector(`code`),r=t.tagName===`CODE`?t:t.querySelector(`code`);return n instanceof HTMLElement&&r instanceof HTMLElement&&n.setAttribute(ve,r.textContent??``),!0},Ee=e=>e.getAttribute(`data-md-stream-src`)??e.textContent??``,De=e=>{let t=e.querySelectorAll(`pre[${q}="true"]`),n=[];return t.forEach(e=>{let t=e.querySelector(`code`);t instanceof HTMLElement&&n.push(t)}),n},Oe=e=>e.closest(`pre`)?.getAttribute(`data-md-lang`)||e.className.match(/language-([^\s"]+)/)?.[1]||`text`,ke=async(e,t,n)=>{if(n?.signal?.aborted)return;let r=De(e);await Promise.all(r.map(async r=>{let i=Ee(r);if(!i||n?.signal?.aborted||r.getAttribute(`data-md-stream-applied`)===i)return;let a=Oe(r);if(a===`mermaid`)return;let o=await t(i,a,n);if(!(n?.signal?.aborted||!e.contains(r)||Ee(r)!==i)){if(!o){let e=xe(r),t=document.createElement(`span`);Ce(r,i.split(`
4
- `).map((n,r)=>{let i=e[r];return i?.textContent===n?i.innerHTML:(t.textContent=n,t.innerHTML)}));return}Ce(r,o),r.setAttribute(ye,i),r.removeAttribute(ve)}}))},Ae=`text`,je=/^(\d+):(\d+):(.+)$/,Me={ts:`typescript`,mts:`typescript`,cts:`typescript`,tsx:`tsx`,js:`javascript`,mjs:`javascript`,cjs:`javascript`,jsx:`jsx`,vue:`vue`,svelte:`svelte`,astro:`astro`,json:`json`,jsonc:`jsonc`,json5:`json5`,jsonl:`json`,ndjson:`json`,geojson:`json`,yaml:`yaml`,yml:`yaml`,toml:`toml`,ini:`ini`,cfg:`ini`,conf:`ini`,properties:`properties`,env:`dotenv`,css:`css`,scss:`scss`,sass:`sass`,less:`less`,styl:`stylus`,html:`html`,htm:`html`,xml:`xml`,svg:`xml`,md:`markdown`,markdown:`markdown`,mdown:`markdown`,mkd:`markdown`,mdx:`mdx`,py:`python`,pyw:`python`,pyi:`python`,rb:`ruby`,go:`go`,rs:`rust`,java:`java`,kt:`kotlin`,kts:`kotlin`,swift:`swift`,scala:`scala`,c:`c`,h:`c`,cc:`cpp`,cpp:`cpp`,cxx:`cpp`,hpp:`cpp`,hh:`cpp`,m:`objective-c`,mm:`objective-cpp`,cs:`csharp`,fs:`fsharp`,fsx:`fsharp`,vb:`vb`,php:`php`,pl:`perl`,pm:`perl`,lua:`lua`,r:`r`,dart:`dart`,ex:`elixir`,exs:`elixir`,erl:`erlang`,hrl:`erlang`,hs:`haskell`,clj:`clojure`,cljs:`clojure`,cljc:`clojure`,groovy:`groovy`,jl:`julia`,ml:`ocaml`,mli:`ocaml`,zig:`zig`,nix:`nix`,sol:`solidity`,prisma:`prisma`,proto:`proto`,graphql:`graphql`,gql:`graphql`,sql:`sql`,sh:`shellscript`,bash:`shellscript`,zsh:`shellscript`,fish:`shellscript`,ps1:`powershell`,psm1:`powershell`,bat:`bat`,cmd:`bat`,tf:`terraform`,tfvars:`terraform`,hcl:`hcl`,diff:`diff`,patch:`diff`,csv:`csv`,tex:`latex`,vim:`viml`,wgsl:`wgsl`,glsl:`glsl`,wat:`wasm`,mermaid:`mermaid`,mmd:`mermaid`},Ne={dockerfile:`docker`,containerfile:`docker`,makefile:`make`,gnumakefile:`make`,"cmakelists.txt":`cmake`,gemfile:`ruby`,rakefile:`ruby`,podfile:`ruby`,".env":`dotenv`,".bashrc":`shellscript`,".zshrc":`shellscript`,".profile":`shellscript`},Pe=e=>{let t=e.split(/[\\/]/).pop()?.toLowerCase()??``;if(!t)return Ae;let n=Ne[t];if(n)return n;let r=t.lastIndexOf(`.`);return r<=0?Ae:Me[t.slice(r+1)]??Ae},Fe=e=>{let t=e?.trim()??``;if(!t)return{lang:Ae,label:Ae,reference:!1};let n=je.exec(t);if(!n){let e=t.toLowerCase();return{lang:e,label:e,reference:!1}}let[,r=``,i=``,a=``]=n,o=r===i?r:`${r}-${i}`;return{lang:Pe(a),label:`${a}:${o}`,reference:!0}},Ie=e=>e===` `||e===` `||e===`
5
- `||e===`\r`,Le=e=>e!==void 0&&e>=`0`&&e<=`9`,Re=e=>{for(let t=0;t<e.length;t+=1){let n=e.charCodeAt(t);if(n>=11904&&n<=40959||n>=12288&&n<=12351||n>=63744&&n<=64255||n>=65280&&n<=65519)return!0}return!1},ze=e=>{for(let t=0;t<e.length;t+=1){let n=e[t];if(n===`"`||n===`'`||Ie(n))return!0}return!1},Be=e=>{let t=0;for(;t<e.length;){let n=e.indexOf(`$`,t);if(n<0)return;let r=e[n+1];if(r===`$`||r!==void 0&&!Ie(r))return n;t=n+1}},Ve=e=>{if(e[0]===`$`){if(e[1]===`$`){let t=e.indexOf(`$$`,2);return t<0?void 0:{raw:e.slice(0,t+2),text:e.slice(2,t),display:!0}}if(!(e.length<3||Ie(e[1])))for(let t=1;t<e.length;t+=1){let n=e[t];if(n===`\\`){t+=1;continue}if(n==="`")return;if(n!==`$`)continue;if(e[t+1]===`$`||Ie(e[t-1]))return;if(Le(e[t+1]))continue;if(t===1)return;let r=e.slice(1,t);return Re(r)||Le(e[1])&&ze(r)?void 0:{raw:e.slice(0,t+1),text:r,display:!1}}}},J=e=>e.replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`),He=e=>{let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)},Ue=e=>`${He(e.raw)}:${e.mode}:${+!!e.highlight}`,We=e=>/^\[[^\]]+\]:\s+\S+/m.test(e)||/^\[\^[^\]]+\]:\s+/m.test(e),Ge=e=>{let t=e.match(/^[ \t]{0,3}(`{3,}|~{3,})/);if(!t)return!1;let n=t[1];if(!n)return!1;let r=n[0],i=n.length,a=e.trimEnd().split(`
6
- `).at(-1)?.trim()??``;return!RegExp(`^[\\t ]{0,3}${r}{${i},}[\\t ]*$`).test(a)},Ke=e=>{try{return R(e,{linkMode:`text-only`})}catch{return e}},qe=(e,t)=>{let n=t?`live`:`full`;if(We(e))return[{raw:e,src:Ke(e),mode:n,highlight:!0}];let r;try{r=L.lexer(e)}catch{return[{raw:e,src:Ke(e),mode:n,highlight:!0}]}let i=-1;for(let e=r.length-1;e>=0;--e)if(r[e]?.type!==`space`){i=e;break}if(i<0)return[{raw:e,src:Ke(e),mode:n,highlight:!0}];let a=[];for(let e=0;e<r.length;e+=1){let t=r[e];if(!t||t.type===`space`)continue;let o=t.raw??``,s=e===i,c=t.type===`code`&&Ge(o);a.push({raw:o,src:c?o:Ke(o),mode:s?n:`full`,highlight:!c})}return a.length===0?[{raw:e,src:Ke(e),mode:n,highlight:!0}]:a},Je=16,Ye=new Map,Xe=(e,t)=>{let n=`${+!!t}:${e}`,r=Ye.get(n);if(r)return Ye.delete(n),Ye.set(n,r),r;let i=qe(e,t);for(;Ye.size>=Je;){let e=Ye.keys().next().value;if(typeof e!=`string`)break;Ye.delete(e)}return Ye.set(n,i),i},Ze=(e,t,n)=>{try{return u.renderToString(e,{displayMode:n,throwOnError:!1})}catch{return t}},Qe=L.use({gfm:!0,breaks:!1,extensions:[{name:`inlineMath`,level:`inline`,start(e){let t=e.indexOf(`\\(`);return t<0?void 0:t},tokenizer(e){let t=/^\\\(([\s\S]+?)\\\)/.exec(e);if(t)return{type:`inlineMath`,raw:t[0],text:t[1]??``}},renderer(e){let t=e;return Ze(t.text,t.raw,!1)}},{name:`blockMath`,level:`block`,start(e){let t=e.indexOf(`\\[`);return t<0?void 0:t},tokenizer(e){let t=/^\\\[([\s\S]+?)\\\]/.exec(e);if(t)return{type:`blockMath`,raw:t[0],text:t[1]??``}},renderer(e){let t=e;return Ze(t.text,t.raw,!0)}},{name:`dollarMath`,level:`inline`,start(e){return Be(e)},tokenizer(e){let t=Ve(e);if(t)return{type:`dollarMath`,raw:t.raw,text:t.text,display:t.display}},renderer(e){let t=e;return Ze(t.text,t.raw,t.display)}}],renderer:{link({href:e,title:t,text:n}){let r=e??``,i=O(r);if(i)return`<a href="${J(A(i))}" data-yuri-agent-mention="true" class="text-primary hover:underline" target="_blank" rel="noopener noreferrer">${n}</a>`;let a=te(r);if(a)return`<a href="${J(r)}" data-skill-name="${J(a)}" class="text-primary hover:underline">${n}</a>`;let o=t?` title="${J(t)}"`:``;return`<a href="${J(r)}"${o} class="external-link" target="_blank" rel="noopener noreferrer">${n}</a>`}}}),$e=e=>e.replace(/\$\$([\s\S]*?)\$\$/g,(e,t)=>{try{return u.renderToString(t,{displayMode:!0,throwOnError:!1})}catch{return`$$${t}$$`}}),et=e=>e.indexOf(`$`)===-1?e:e.split(/(<(?:pre|code|kbd)[^>]*>[\s\S]*?<\/(?:pre|code|kbd)>)/gi).map((e,t)=>t%2==1?e:$e(e)).join(``),tt=e=>et(Qe.parse(e)),nt=e=>{let t=tt(e.src);return e.highlight?t:we(t)},rt=/<pre><code(?:\s+class="language-([^"]*)")?>([\s\S]*?)<\/code><\/pre>/g,it=1200,at=(e,t)=>{let n=1;for(let r=0;r<e.length;r+=1)if(e.charCodeAt(r)===10&&++n>t)return!0;return!1},ot=e=>e.replace(/&lt;/g,`<`).replace(/&gt;/g,`>`).replace(/&quot;/g,`"`).replace(/&#39;/g,`'`).replace(/&amp;/g,`&`),st=e=>e.reference?`data-md-lang="${J(e.lang)}" data-md-label="${J(e.label)}"`:`data-md-lang="${J(e.lang)}"`,ct=async(e,t,n)=>{if(n.isCancelled?.())return null;let r=[...e.matchAll(rt)];if(r.length===0)return e;let i=e;for(let e of r){if(n.isCancelled?.())return null;let[r,a,o]=e,s=Fe(a);if(s.lang===`mermaid`&&!s.reference)continue;let c=ot(o??``);if(at(c,n.lineLimit)){i=i.replace(r,()=>r.replace(`<pre`,`<pre ${st(s)}`));continue}let l=await t(c,s.lang);if(n.isCancelled?.())return null;if(l){let e=l.replace(/^<pre/,`<pre ${st(s)}`);i=i.replace(r,()=>e)}}return i},lt=(e,t)=>!t&&e.length<=480&&!e.includes("```"),ut={USE_PROFILES:{html:!0,mathMl:!0,svg:!0},ADD_TAGS:[`svg`,`path`,`g`,`rect`,`line`,`polygon`,`polyline`,`circle`,`ellipse`,`text`,`tspan`,`defs`,`marker`],ADD_ATTR:[`d`,`viewBox`,`preserveAspectRatio`,`xmlns`,`target`,`fill`,`stroke`,`stroke-width`,`transform`,`points`,`x`,`y`,`x1`,`y1`,`x2`,`y2`,`cx`,`cy`,`r`,`rx`,`ry`,`style`],FORBID_TAGS:[`script`],FORBID_CONTENTS:[`script`]},dt=!1,ft=()=>{dt||typeof window>`u`||!F.isSupported||(dt=!0,F.addHook(`uponSanitizeAttribute`,(e,t)=>{if(!(e instanceof HTMLImageElement)||t.attrName!==`src`)return;let n=typeof t.attrValue==`string`?t.attrValue:``;/^file:/i.test(n)&&(e.setAttribute(`data-md-image-source`,n),t.keepAttr=!1)}),F.addHook(`afterSanitizeAttributes`,e=>{e instanceof HTMLAnchorElement&&e.target===`_blank`&&e.setAttribute(`rel`,`noopener noreferrer`)}))},pt=e=>F.isSupported?(ft(),F.sanitize(e,ut)):``,mt=`data-md-sanitize-block`,ht=e=>{if(e.length===0)return[];if(e.length===1)return[pt(e[0])];if(!F.isSupported||typeof document>`u`)return e.map(e=>pt(e));let t=e.map((e,t)=>`<div ${mt}="${t}">${e}</div>`).join(``),n=document.createElement(`div`);n.innerHTML=pt(t);let r=e.map(()=>``);return n.querySelectorAll(`[${mt}]`).forEach(e=>{let t=Number(e.getAttribute(mt));Number.isInteger(t)&&t>=0&&t<r.length&&(r[t]=e.innerHTML)}),r},gt=()=>r()?200:it,_t=240,vt=16777216,yt=160,bt=8388608,xt=new v({maxEntries:_t,maxBytes:vt}),St=new v({maxEntries:yt,maxBytes:bt}),Ct=e=>e.length*2,wt=(e,t)=>{xt.set(e,t,Ct(e)+Ct(t.hash)+Ct(t.html))},Tt=async(e,t,n)=>ct(e,(e,r)=>P(e,r,{signal:t,priority:n}),{lineLimit:gt(),isCancelled:()=>!!t?.aborted}),Et=async(e,t,n)=>{if(t?.aborted)return null;let r=nt(e);if(t?.aborted)return null;let i=e.highlight?await Tt(r,t,n):r;if(i===null||t?.aborted)return null;let a=pt(i);return t?.aborted?null:a},Dt=e=>`${He(e)}:${e.length}`,Ot=e=>{let t=St.get(Dt(e));return t?.source===e?t.html:void 0},kt=(e,t)=>{let n=Dt(e);St.set(n,{source:e,html:t},Ct(n)+Ct(e)+Ct(t))},At=e=>{if(!e)return[];let t=Xe(e,!1),n=Array(t.length).fill(``),r=[],i=[];t.forEach((e,t)=>{let a=Ot(e.src);if(a!==void 0){n[t]=a;return}r.push(t),i.push(nt(e))});let a=ht(i);return r.forEach((e,r)=>{let i=a[r]??``;n[e]=i;let o=t[e]?.src;o!==void 0&&kt(o,i)}),n},jt=8,Mt=()=>typeof performance<`u`?performance.now():Date.now(),Nt=e=>e?.aborted?Promise.resolve(!1):new Promise(t=>{let n=!1,r=r=>{n||(n=!0,e?.removeEventListener(`abort`,a),t(r))},i=k(()=>{r(!e?.aborted)},{priority:`visible`}),a=()=>{i(),r(!1)};e?.addEventListener(`abort`,a,{once:!0})}),Pt=(e,t)=>{let n=[];for(let r=0;r<e.length;r+=1){let i=e[r];if(!i)return null;let a=He(i.raw),o=`${t}:${r}:${i.mode}`,s=xt.get(o);if(!s||s.hash!==a)return null;n.push({id:Ue(i),html:s.html})}return n},Ft=(e,t,n)=>{let r=ht(t.map(e=>e.html));return t.map((t,i)=>{let a=e[i],o=r[i]??``;return a&&wt(`${n}:${i}:${a.mode}`,{hash:He(a.raw),html:o}),{id:t.id,html:o}})},It=async(e,t,n,r)=>{let i=n?`visible`:`background`,a=async(e,n)=>{if(r?.aborted)return null;let a=He(e.raw),o=Ue(e),s=`${t}:${n}:${e.mode}`,c=xt.get(s);if(c&&c.hash===a)return{id:o,html:c.html};let l=await Et(e,r,i);return l===null||r?.aborted?null:(wt(s,{hash:a,html:l}),{id:o,html:l})};if(n)return(await Promise.all(e.map(a))).filter(e=>e!==null);let o=[],s=0;for(let t=0;t<e.length&&!r?.aborted;t+=1){let n=e[t];if(!n)continue;if(Mt()>=s){if(!await Nt(r))break;s=Mt()+jt}let i=await a(n,t);i&&o.push(i)}return o},Lt=async(e,t,n,r)=>{if(!e)return[];let i=Xe(e,t),a=Pt(i,n);if(a)return a;let o=t?`visible`:`background`,s=[],c=[];for(let e=0;e<i.length;e+=1){let t=i[e];if(!t)continue;let r=xt.get(`${n}:${e}:${t.mode}`);r&&r.hash===He(t.raw)||(s.push(t),c.push(e))}if(!lt(e,t)&&s.length>0)try{let e=await N({streaming:t,highlight:!0,highlightLineLimit:gt(),signal:r,priority:o,blocks:s});if(r?.aborted)return[];if(e&&e.length===s.length)return Ft(i,i.map((t,r)=>{let i=c.indexOf(r);if(i>=0)return e[i]??{id:Ue(t),html:``,highlight:t.highlight};let a=xt.get(`${n}:${r}:${t.mode}`);return{id:Ue(t),html:a?.html??``,highlight:t.highlight}}),n)}catch{}return It(i,n,t,r)},Y=e=>Number.isFinite(e)&&e>0,Rt=e=>{if(typeof e==`number`)return Y(e)?e:null;if(typeof e!=`string`)return null;let t=e.trim().match(/^([+-]?(?:(?:\d+\.?\d*)|(?:\.\d+))(?:[eE][+-]?\d+)?)(?:px)?$/);if(!t)return null;let n=Number(t[1]);return Y(n)?n:null},zt=(e,t,n)=>Math.min(n,Math.max(t,e)),Bt=6,Vt=1.25,Ht=1.0015,Ut=16,Wt=1e3,Gt=.5,Kt=12,qt=400,Jt=`[data-markdown="mermaid-block"]`,Yt=e=>e.querySelector(Jt)!==null,Xt=e=>[e.x,e.y,e.width,e.height].map(e=>{let t=Number(e.toFixed(Bt));return Object.is(t,-0)?`0`:String(t)}).join(` `),Zt=e=>{let t=e.viewBox?.trim().split(/[\s,]+/).map(e=>Number.parseFloat(e));if(t?.length===4){let[e,n,r,i]=t;if(Number.isFinite(e)&&Number.isFinite(n)&&Y(r)&&Y(i))return{x:e,y:n,width:r,height:i}}let n=Rt(e.width),r=Rt(e.height);return n===null||r===null?null:{x:0,y:0,width:n,height:r}},Qt=e=>{let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)},$t=e=>{let t=e.renderMode||`unknown`,n=e.svgMarkup??``;if(!n){let n=[e.viewBox??``,e.width??``,e.height??``];return n.some(e=>e!==``)?`${t}:bounds:${n.join(`:`)}`:`${t}:no-svg`}return[t,Qt(n)].join(`:`)},en=(e,t)=>{if(!Y(t.width)||!Y(t.height))return e;let n=e.width/e.height,r=t.width/t.height;if(n>r){let t=e.width/r;return{x:e.x,y:e.y-(t-e.height)/2,width:e.width,height:t}}let i=e.height*r;return{x:e.x-(i-e.width)/2,y:e.y,width:i,height:e.height}},tn=({currentBox:e,viewport:t,delta:n})=>!Y(t.width)||!Y(t.height)||!Y(e.width)||!Y(e.height)?e:{x:e.x-n.x/t.width*e.width,y:e.y-n.y/t.height*e.height,width:e.width,height:e.height},nn=(e,t,n)=>{let r=e*(t===1?Ut:t===2?Y(n)?n:0:1);return Number.isFinite(r)?zt(r,-1e3,Wt):0},rn=e=>{let t=null;for(let n of e){if(!t){t=n;continue}return{center:{x:(t.x+n.x)/2,y:(t.y+n.y)/2},distance:Math.hypot(n.x-t.x,n.y-t.y)}}return null},an=(e,t)=>{let n=t.x-e.x,r=t.y-e.y;return n*n+r*r>9},on=({currentBox:e,contentBox:t,viewport:n,pointer:r,zoomFactor:i,minScale:a,maxScale:o})=>{if(!Y(n.width)||!Y(n.height)||!Y(i)||!Y(e.width)||!Y(e.height)||!Y(t.width)||!Y(t.height)||!Y(a)||!Y(o))return e;let s=Math.min(a,o),c=Math.max(a,o),l=en(t,n),u=zt(l.width/e.width*i,s,c),d=l.width/u,f=d/(e.width/e.height),p=zt(r.x/n.width,0,1),m=zt(r.y/n.height,0,1),h=e.x+p*e.width,g=e.y+m*e.height;return{x:h-p*d,y:g-m*f,width:d,height:f}},sn=({currentBox:e,contentBox:t,viewport:n,previousGesture:r,gesture:i,minScale:a,maxScale:o})=>!Y(r.distance)||!Y(i.distance)?e:on({currentBox:tn({currentBox:e,viewport:n,delta:{x:i.center.x-r.center.x,y:i.center.y-r.center.y}}),contentBox:t,viewport:n,pointer:i.center,zoomFactor:i.distance/r.distance,minScale:a,maxScale:o}),cn=new WeakMap,ln=e=>e instanceof HTMLElement?cn.get(e)??null:null,un=e=>e.querySelector(`[data-markdown="mermaid-viewport"]`)??e.querySelector(`[data-markdown="mermaid"]`),dn=e=>{let t=e.querySelector(`[data-markdown="mermaid"] svg`),n=e.querySelector(`[data-markdown="mermaid"]`);return $t({renderMode:e.getAttribute(`data-mermaid-render`),svgMarkup:n?.getAttribute(`data-md-original-svg`)??t?.outerHTML??null,viewBox:t?.getAttribute(`viewBox`),width:t?.getAttribute(`width`),height:t?.getAttribute(`height`)})},fn=e=>{let t=e.getBoundingClientRect();return{width:t.width,height:t.height}},pn=(e,t)=>({x:e.clientX-t.left,y:e.clientY-t.top}),mn=(e,t)=>pn(e,t.getBoundingClientRect()),hn=e=>e instanceof Element&&!!e.closest(`button, a, [role="button"]`),gn=e=>{let t=un(e),n=e.querySelector(`[data-markdown="mermaid"] svg`);if(!t||!n)return null;let r=Zt({viewBox:n.getAttribute(`viewBox`),width:n.getAttribute(`width`),height:n.getAttribute(`height`)});if(!r)return null;let i=r,a=null,o=null,s=null,c=new Map,l=new Set,u=null,d=null,f=e=>{i=e,n.setAttribute(`viewBox`,Xt(e)),n.removeAttribute(`width`),n.removeAttribute(`height`)},p=()=>{f(en(r,fn(t)))},m=(e,n)=>{f(on({currentBox:i,contentBox:r,viewport:fn(t),pointer:e,zoomFactor:n,minScale:Gt,maxScale:Kt}))},h=()=>{let e=fn(t);m({x:e.width/2,y:e.height/2},Vt)},g=()=>{let e=fn(t);m({x:e.width/2,y:e.height/2},1/Vt)},_=e=>{e.preventDefault(),e.stopPropagation();let n=nn(e.deltaY,e.deltaMode,fn(t).height);m(mn(e,t),Ht**+-n)},v=e=>{try{t.setPointerCapture(e),l.add(e)}catch{}},y=e=>{if(l.delete(e))try{t.hasPointerCapture(e)&&t.releasePointerCapture(e)}catch{}},b=()=>{a=null,o=null,s=null,c.clear(),u=null},x=()=>{b(),e.removeAttribute(`data-mermaid-panning`),e.hasAttribute(`data-mermaid-suppress-click`)&&(d=window.setTimeout(()=>{e.removeAttribute(`data-mermaid-suppress-click`),d=null},qt))},S=n=>{if(n.pointerType!==`touch`&&n.button!==0||hn(n.target))return;d!==null&&(window.clearTimeout(d),d=null),e.removeAttribute(`data-mermaid-suppress-click`);let r=mn(n,t);v(n.pointerId),e.setAttribute(`data-mermaid-panning`,`true`),n.pointerType===`touch`?(c.set(n.pointerId,r),c.size>=2?(a=null,o=null,s=null,u=rn(c.values()),e.setAttribute(`data-mermaid-suppress-click`,`true`)):(a=n.pointerId,o=r,s=r)):(a=n.pointerId,o=r,s=r),n.preventDefault()},C=n=>{if(n.pointerType===`touch`){if(!c.has(n.pointerId))return;let a=mn(n,t);if(c.set(n.pointerId,a),c.size>=2){let a=rn(c.values());u&&a&&f(sn({currentBox:i,contentBox:r,viewport:fn(t),previousGesture:u,gesture:a,minScale:Gt,maxScale:Kt})),u=a,e.setAttribute(`data-mermaid-suppress-click`,`true`),n.preventDefault();return}}if(a!==n.pointerId||!s)return;let l=mn(n,t);f(tn({currentBox:i,viewport:fn(t),delta:{x:l.x-s.x,y:l.y-s.y}})),s=l,o&&an(o,l)&&e.setAttribute(`data-mermaid-suppress-click`,`true`),n.preventDefault()},w=e=>{if(e.pointerType===`touch`||c.has(e.pointerId)){if(!c.has(e.pointerId))return;if(c.delete(e.pointerId),u=rn(c.values()),c.size>0){for(let[e,t]of c){a=e,o=t,s=t;break}c.size>=2&&(a=null,o=null,s=null),y(e.pointerId);return}x(),y(e.pointerId);return}a===e.pointerId&&(x(),y(e.pointerId))},T=()=>{p()};t.addEventListener(`wheel`,_,{passive:!1}),t.addEventListener(`pointerdown`,S),t.addEventListener(`pointermove`,C),t.addEventListener(`pointerup`,w),t.addEventListener(`pointercancel`,w),t.addEventListener(`lostpointercapture`,w),window.addEventListener(`resize`,T);let E=typeof ResizeObserver>`u`?null:new ResizeObserver(T);return E?.observe(t),p(),{zoomIn:h,zoomOut:g,fit:p,cleanup:()=>{t.removeEventListener(`wheel`,_),t.removeEventListener(`pointerdown`,S),t.removeEventListener(`pointermove`,C),t.removeEventListener(`pointerup`,w),t.removeEventListener(`pointercancel`,w),t.removeEventListener(`lostpointercapture`,w),window.removeEventListener(`resize`,T),E?.disconnect(),d!==null&&window.clearTimeout(d);for(let e of Array.from(l))y(e);b(),e.removeAttribute(`data-mermaid-panning`),e.removeAttribute(`data-mermaid-suppress-click`),cn.delete(e)}}},_n=e=>{let t=new Map,n=new Map,r=()=>{for(let[r,i]of Array.from(t.entries())){let a=dn(r);(!e.contains(r)||a!==n.get(r))&&(i.cleanup(),t.delete(r),n.delete(r))}for(let r of Array.from(e.querySelectorAll(Jt))){if(t.has(r)||r.querySelector(`[data-markdown="mermaid"] svg`)===null)continue;let e=gn(r);e&&(t.set(r,e),n.set(r,dn(r)),cn.set(r,e))}};return r(),{refresh:r,cleanup:()=>{for(let e of t.values())e.cleanup();t.clear(),n.clear()}}},X=(e,t=`size-3.5`)=>`<svg class="yuri-icon ${t}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><use href="#yuri-${e}"></use></svg>`,vn={copy:X(`file-copy`),check:X(`check`),download:X(`download`),zoomIn:X(`add`),zoomOut:X(`subtract`),fit:X(`refresh`),textWrap:X(`text-wrap`),image:X(`file-image`,`size-10`),imageDownload:X(`download`,`size-3`),imageLoading:X(`loader-4`,`size-3.5 animate-spin motion-reduce:animate-none`)},yn=`p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--interactive-focus-ring)]`,bn=(e,t)=>{e.innerHTML=t},Z=(e,t,n)=>{let r=document.createElement(`button`);return r.type=`button`,r.className=yn,r.setAttribute(`data-md-action`,n),r.setAttribute(`title`,t),r.setAttribute(`aria-label`,t),bn(r,vn[e]),r},xn=(e,t,n)=>{let r=e.querySelector(`[data-md-code-body]`),i=e.querySelector(`pre`),a=e.querySelector(`pre code`),o=e.querySelector(`[data-md-action="toggle-code-wrap"]`);if(e.setAttribute(`data-code-wrap`,t?`true`:`false`),r?.classList.toggle(`overflow-x-auto`,!t),r?.classList.toggle(`overflow-x-hidden`,t),i?.classList.toggle(`whitespace-pre-wrap`,t),i?.classList.toggle(`break-words`,t),a?.classList.toggle(`whitespace-pre-wrap`,t),a?.classList.toggle(`break-words`,t),i&&(i.style.whiteSpace=t?`pre-wrap`:`pre`,i.style.overflowWrap=t?`anywhere`:`normal`),a&&(a.style.whiteSpace=t?`pre-wrap`:`pre`,a.style.overflowWrap=t?`anywhere`:`normal`),o){let e=t?n.disableCodeWrap:n.enableCodeWrap;o.setAttribute(`title`,e),o.setAttribute(`aria-label`,e),o.classList.toggle(`text-foreground`,t),o.classList.toggle(`opacity-100`,t),o.classList.toggle(`text-muted-foreground`,!t),o.classList.toggle(`opacity-65`,!t),o.setAttribute(`aria-pressed`,t?`true`:`false`)}},Sn=e=>{let t=document.createElement(`div`);t.setAttribute(`data-md-code-line-numbers`,``),t.setAttribute(`aria-hidden`,`true`),t.className=`min-w-8 shrink-0 select-none border-r border-border/50 pr-3 text-right font-mono text-[13px] text-muted-foreground/45`;let n=e.textContent??``,r=Math.max(1,n.endsWith(`
7
- `)?n.split(`
8
- `).length-1:n.split(`
9
- `).length);for(let e=1;e<=r;e+=1){let n=document.createElement(`div`);n.className=`tabular-nums`,n.textContent=String(e),t.appendChild(n)}return t},Cn=e=>{let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),r=n.nextNode();for(;r;)t.push(r),r=n.nextNode();return t},wn=(e,t)=>{let n=0;for(let r of e){let e=n+r.data.length;if(t<=e)return{node:r,offset:Math.max(0,t-n)};n=e}let r=e.at(-1);return r?{node:r,offset:r.data.length}:null},Tn=(e,t)=>{let n=1/0,r=-1/0;for(let t=0;t<e.length;t+=1){let i=e[t];!i||i.width===0&&i.height===0||(i.top<n&&(n=i.top),i.bottom>r&&(r=i.bottom))}return!Number.isFinite(n)||r<=n?t:Math.max(t,r-n)},En=e=>Array.from(e.children).filter(e=>e instanceof HTMLElement&&e.classList.contains(`line`)),Dn=(e,t,n)=>{e.style.height=`${t}px`,e.style.lineHeight=`${n}px`},On=(e,t,n)=>{let r=document.createRange();r.setStart(e.node,e.offset),r.setEnd(t.node,t.offset);let i=Math.max(Tn(r.getClientRects(),n),Tn([r.getBoundingClientRect()],n));return r.detach(),i},kn=e=>{let t=e.querySelectorAll(`[data-component="markdown-code"]`);for(let e of Array.from(t)){let t=e.querySelector(`pre code`),n=e.querySelector(`[data-md-code-line-numbers]`);if(!t||!n)continue;let r=Array.from(n.children),i=window.getComputedStyle(t),a=Number.parseFloat(i.lineHeight)||20;n.style.fontFamily=i.fontFamily,n.style.fontSize=i.fontSize,n.style.lineHeight=`${a}px`;let o=En(t);if(o.length===r.length){let e=o.map(e=>e.getBoundingClientRect()),t=e=>(e?.textContent??``).length===0;for(let n=0;n<r.length;n+=1){let i=r[n],s=o[n],c=e[n];if(!i||!s||!c)continue;if(t(s)){Dn(i,a,a);continue}let l=o[n+1],u=e[n+1],d=u&&!t(l)?u.top:c.bottom;Dn(i,Tn([{top:c.top,bottom:d,width:1,height:d-c.top}],a),a)}continue}let s=t.textContent??``,c=Cn(t),l=0;for(let e=0;e<r.length;e+=1){let t=s.indexOf(`
10
- `,l),n=t===-1?s.length:t,i=r[e];if(!i)continue;let o=wn(c,l),u=wn(c,n);!o||!u||l===n?Dn(i,a,a):Dn(i,On(o,u,a),a),l=n+1}}},An=e=>{window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>kn(e))})},jn=(e,t,n)=>{let r=e.querySelectorAll(`[data-component="markdown-code"]`);for(let e of Array.from(r)){let r=e.querySelector(`[data-md-code-body]`),i=e.querySelector(`pre`);r&&i&&!r.querySelector(`[data-md-code-line-numbers]`)&&(r.classList.add(`flex`,`gap-3`),r.insertBefore(Sn(i),i)),xn(e,t,n)}An(e)},Mn=(e,t,n,r)=>{bn(e,vn.check),e.setAttribute(`title`,t),e.setAttribute(`aria-label`,t),window.setTimeout(()=>{bn(e,vn[n]),e.setAttribute(`title`,r),e.setAttribute(`aria-label`,r)},2e3)},Nn=e=>{let t=e.querySelectorAll(`:not(pre) > code`);for(let e of Array.from(t))e.getAttribute(`data-markdown`)!==`inline-code`&&e.setAttribute(`data-markdown`,`inline-code`)},Pn=(e,t)=>{let n=e.querySelectorAll(`pre`);for(let e of Array.from(n)){if(e.querySelector(`code.language-mermaid`))continue;let n=e.parentElement;if(!n||n.closest(`[data-component="markdown-code"]`))continue;let r=e.querySelector(`code`)?.className.match(/language-([^\s"]+)/)?.[1],i=e.getAttribute(`data-md-label`)??e.getAttribute(`data-md-lang`)??Fe(r).label,a=document.createElement(`div`);a.setAttribute(`data-component`,`markdown-code`),a.className=`my-4 group overflow-clip rounded-2xl border border-border/80 bg-[var(--surface-elevated)]`;let o=document.createElement(`div`);o.className=`flex items-center justify-between border-b border-border/70 px-3 py-1.5`;let s=document.createElement(`span`);s.className=`font-mono text-[13px] text-muted-foreground`,s.textContent=i;let c=Z(`copy`,t.labels.copy,`copy-code`),l=Z(`textWrap`,t.codeBlockLineWrap?t.labels.disableCodeWrap:t.labels.enableCodeWrap,`toggle-code-wrap`);o.appendChild(s);let u=document.createElement(`div`);u.className=`flex items-center gap-1`,u.appendChild(l),u.appendChild(c),o.appendChild(u);let d=document.createElement(`div`);d.setAttribute(`data-md-code-body`,``),d.className=`px-3 py-2.5 overflow-x-auto`,n.replaceChild(a,e),e.style.margin=`0`,e.style.background=`transparent`,e.classList.add(`min-w-0`,`w-full`,`flex-1`),d.appendChild(e),a.appendChild(o),a.appendChild(d),xn(a,t.codeBlockLineWrap,t.labels)}},Fn=e=>{let t=e.querySelectorAll(`table`);for(let e of Array.from(t)){if(e.closest(`[data-markdown="table-wrapper"]`))continue;let t=document.createElement(`div`);t.className=`my-4`,t.setAttribute(`data-markdown`,`table-wrapper`);let n=document.createElement(`div`);n.setAttribute(`data-markdown`,`table-scroll`);let r=e.parentElement;if(r){r.replaceChild(t,e),e.setAttribute(`data-markdown`,`table`);for(let t of Array.from(e.querySelectorAll(`tr`)))t.setAttribute(`data-markdown`,`table-row`);for(let t of Array.from(e.querySelectorAll(`th`)))t.setAttribute(`data-markdown`,`table-header-cell`);for(let t of Array.from(e.querySelectorAll(`td`)))t.setAttribute(`data-markdown`,`table-cell`);n.appendChild(e),t.appendChild(n)}}},In=0,Ln=(e,t)=>{let n=e.querySelectorAll(`pre > code.language-mermaid`);for(let e of Array.from(n)){let n=e.parentElement;if(!n)continue;let r=(e.textContent??``).replace(/\s+$/,``),i=t.renderMermaid(r),a=document.createElement(`div`);a.setAttribute(`data-markdown`,`mermaid-block`),a.setAttribute(`data-md-source`,r),a.className=`group relative`;let o=document.createElement(`div`);o.setAttribute(`data-markdown`,`mermaid-scroll`);let s=document.createElement(`div`);if(s.setAttribute(`data-markdown`,`mermaid-toolbar`),s.className=`absolute top-1 right-2 flex items-center gap-1 opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition-opacity`,i.svg){a.setAttribute(`data-mermaid-render`,`svg`);let e=document.createElement(`div`);e.setAttribute(`data-markdown`,`mermaid-viewport`);let n=document.createElement(`div`);n.setAttribute(`data-markdown`,`mermaid`),n.setAttribute(`data-md-original-svg`,i.svg),n.innerHTML=i.svg;let c=n.querySelector(`svg`),l=++In;for(let[e,t]of[[`title[id]`,`aria-labelledby`],[`desc[id]`,`aria-describedby`]]){let n=c?.querySelector(e);n&&(n.id=`yuri-mermaid-${l}-${n.localName}`,c?.setAttribute(t,n.id))}if(e.appendChild(n),o.appendChild(e),t.mermaidControls.showPanZoomControls&&(s.appendChild(Z(`zoomIn`,t.labels.zoomInDiagram,`mermaid-zoom-in`)),s.appendChild(Z(`zoomOut`,t.labels.zoomOutDiagram,`mermaid-zoom-out`)),s.appendChild(Z(`fit`,t.labels.resetDiagramView,`mermaid-fit`))),t.mermaidControls.copy){let e=Z(`copy`,t.labels.copyDiagram,`mermaid-copy`);e.setAttribute(`data-md-source`,r),s.appendChild(e)}if(t.mermaidControls.download){let e=Z(`download`,t.labels.downloadDiagram,`mermaid-download`);e.setAttribute(`data-md-svg`,`1`),s.appendChild(e)}}else{a.setAttribute(`data-mermaid-render`,`source`);let e=document.createElement(`pre`);if(e.setAttribute(`data-markdown`,`mermaid-source`),e.textContent=r,o.appendChild(e),t.mermaidControls.copy){let e=Z(`copy`,t.labels.copyDiagram,`mermaid-copy`);e.setAttribute(`data-md-source`,r),s.appendChild(e)}}a.appendChild(o),a.appendChild(s);let c=n.parentElement;c&&c.replaceChild(a,n)}},Rn=(e,t)=>{let n=e.querySelectorAll(`a[href]`);for(let e of Array.from(n)){if(e.getAttribute(`data-md-link-decorated`)===`true`||e.getAttribute(`data-yuri-file-link`)===`true`)continue;let n=e.getAttribute(`href`)??``;if(!D(n))continue;e.setAttribute(`data-md-link-decorated`,`true`);let r=E(n);if(r){let t=document.createElement(`span`);t.className=`mr-1 inline-flex size-[18px] items-center justify-center rounded border border-[var(--border)] bg-[var(--interactive-hover)] align-middle`;let n=document.createElement(`img`);n.setAttribute(`data-md-link-favicon`,`true`),n.src=r,n.alt=``,n.setAttribute(`aria-hidden`,`true`),n.loading=`lazy`,n.decoding=`async`,n.className=`size-3.5 rounded-sm`,n.addEventListener(`error`,()=>t.remove(),{once:!0}),t.appendChild(n),e.parentNode?.insertBefore(t,e)}if(t.onPreviewLoopback&&T(n)){let r=document.createElement(`button`);r.type=`button`,r.className=`ml-1 align-middle ${yn}`,r.setAttribute(`data-md-action`,`preview-loopback`),r.setAttribute(`data-md-url`,n),r.setAttribute(`title`,t.labels.previewTitle),r.setAttribute(`aria-label`,t.labels.previewLabel),bn(r,vn.download),e.parentNode?.insertBefore(r,e.nextSibling)}}},zn=`img:not([data-md-link-favicon="true"])`,Bn=`[data-md-image-presentation="true"]`,Vn=`data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="576" height="324" viewBox="0 0 576 324"%3E%3C/svg%3E`,Hn=[`block`,`max-w-full`,`rounded-xl`,`border`,`border-border/80`,`bg-[var(--surface-muted)]`,`transition-colors`,`focus-visible:outline`,`focus-visible:outline-2`,`focus-visible:outline-offset-2`,`focus-visible:outline-[var(--interactive-focus-ring)]`],Un=[`cursor-pointer`,`hover:bg-interactive-hover/60`],Wn=[`object-contain`],Gn=e=>{let t=e.parentElement;if(t?.matches(Bn))return t;let n=document.createElement(`span`);n.setAttribute(`data-md-image-presentation`,`true`),n.className=`relative my-4 block w-fit max-w-full`;let r=document.createElement(`span`);r.setAttribute(`data-md-image-placeholder-visual`,`true`),r.setAttribute(`aria-hidden`,`true`),r.className=`pointer-events-none absolute inset-0 flex items-center justify-center text-muted-foreground`,r.classList.add(`yuri-image-loading`),_()&&n.setAttribute(`data-mobile-image`,`true`);let i=document.createElement(`span`);i.className=`relative flex size-14 items-center justify-center rounded-2xl border border-border/80 bg-[var(--surface-elevated)] shadow-sm`,bn(i,vn.image);let a=document.createElement(`span`);a.setAttribute(`data-md-image-download-badge`,`true`),a.className=`absolute -right-1.5 -bottom-1.5 flex size-6 items-center justify-center rounded-full border border-border bg-[var(--surface-elevated)] text-foreground shadow-sm`,bn(a,vn.imageDownload);let o=document.createElement(`span`);return o.setAttribute(`data-md-image-loading-badge`,`true`),o.className=`absolute -right-1.5 -bottom-1.5 hidden size-6 items-center justify-center rounded-full border border-border bg-[var(--surface-elevated)] text-foreground shadow-sm`,bn(o,vn.imageLoading),i.appendChild(a),i.appendChild(o),r.appendChild(i),t?.replaceChild(n,e),n.appendChild(e),n.appendChild(r),n},Kn=e=>{e.src=Vn,e.setAttribute(`data-md-placeholder-source`,Vn),e.setAttribute(`data-md-image-state`,`placeholder`),e.classList.add(...Wn)},qn=e=>{e.removeAttribute(`data-md-image-state`),e.removeAttribute(`data-md-placeholder-source`),e.removeAttribute(`aria-busy`),e.classList.remove(...Wn)},Jn=(e,t)=>{if(!t.imagePreviewEnabled)return;let n=e.querySelectorAll(zn);for(let e of Array.from(n)){let n=e.getAttribute(`data-md-image-source`)??e.getAttribute(`src`)??``,r=b(n,t.imageEffectiveDirectory);if(!S(r)){e.setAttribute(`data-md-image-source`,n),Gn(e),e.setAttribute(`data-md-image-state`,e.complete&&e.naturalWidth>0?`loaded`:`loading`);continue}e.classList.add(...Hn,...Un),e.setAttribute(`role`,`button`),e.setAttribute(`tabindex`,`0`),e.setAttribute(`data-md-image-source`,n),Gn(e),Kn(e)}},Yn=(e,t)=>{Nn(e),Ln(e,t),Pn(e,t),Fn(e),Rn(e,t),Jn(e,t),V(e)},Xn=(e,t,n)=>{let r=new Blob([t],{type:n}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=e,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)},Zn=(e,t)=>{let n=e=>{let n=e.target;if(!(n instanceof Element))return;let r=n.closest(`[data-md-action]`);if(!r)return;let i=r.getAttribute(`data-md-action`)??``;if(i===`copy-code`){let e=r.closest(`[data-component="markdown-code"]`)?.querySelector(`code`)?.textContent??``;e&&m(e).then(()=>Mn(r,t.labels.copied,`copy`,t.labels.copy));return}if(i===`toggle-code-wrap`){e.preventDefault(),t.onToggleCodeBlockLineWrap?.();return}if(i===`mermaid-copy`){let e=r.getAttribute(`data-md-source`)??``;e&&m(e).then(()=>Mn(r,t.labels.copied,`copy`,t.labels.copyDiagram));return}if(i===`mermaid-zoom-in`||i===`mermaid-zoom-out`||i===`mermaid-fit`){e.preventDefault();let t=ln(r.closest(`[data-markdown="mermaid-block"]`));i===`mermaid-zoom-in`?t?.zoomIn():i===`mermaid-zoom-out`?t?.zoomOut():t?.fit();return}if(i===`mermaid-download`){let e=r.closest(`[data-markdown="mermaid-block"]`)?.querySelector(`[data-markdown="mermaid"]`),t=e?.getAttribute(`data-md-original-svg`)??e?.innerHTML??``;t&&Xn(`diagram.svg`,t,`image/svg+xml;charset=utf-8`);return}if(i===`preview-loopback`){e.preventDefault();let n=r.getAttribute(`data-md-url`)??``;n&&t.onPreviewLoopback?.(n);return}};return e.addEventListener(`click`,n),()=>e.removeEventListener(`click`,n)},Qn=e({MarkdownRenderer:()=>Sr,SimpleMarkdownRenderer:()=>Cr}),Q=a(),$n=()=>{let e=(0,me.c)(4),t=y(),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=x(!1),e[0]=n):n=e[0];let r=n,i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=x(!0),e[1]=i):i=e[1];let a=i,o;return e[2]===t?.currentTheme?o=e[3]:(o=t?.currentTheme??(typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?a:r),e[2]=t?.currentTheme,e[3]=o),o},er=e=>{let t=(0,me.c)(4),{containerRef:n,enabled:r,effectiveDirectory:i,openInAppBrowser:a}=e,o;t[0]!==i||t[1]!==r||t[2]!==a?(o=e=>{if(r===!1||e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;let t=e.target;if(!(t instanceof Element)||t.closest($))return;let n=t.closest(`a[href]`);if(!(n instanceof HTMLAnchorElement)||n.getAttribute(`data-yuri-file-link`)===`true`)return;let o=n.getAttribute(`href`)??``;if(H(o)){e.preventDefault(),e.stopPropagation();return}if(!D(o))return;e.preventDefault(),e.stopPropagation();let s=(i||``).trim();if(!_()&&s&&a){a(s,o);return}w(o)},t[0]=i,t[1]=r,t[2]=a,t[3]=o):o=t[3];let s=f(o);p(`click`,s,n)},$=`img:not([data-md-link-favicon="true"])`,tr=e=>e.getAttribute(`data-md-image-source`)??e.getAttribute(`src`)??``,nr=({containerRef:e,effectiveDirectory:t,onShowPopup:r})=>{let i=K.useRef(null);i.current??=n();let a=i.current,o=!!r,s=f(e=>r?.(e)),c=K.useRef(()=>{}),l=K.useRef(new Map),u=K.useRef(null),d=K.useMemo(()=>e=>c.current(e),[]);return K.useLayoutEffect(()=>{let n=l.current;if(u.current!==null&&(clearTimeout(u.current),u.current=null),c.current=()=>{},!o){for(let[e,t]of n)t.controller?.abort(),t.release?.(),n.delete(e);return}let r=e.current;if(!r)return;let i=e=>{let n=Array.from(r.querySelectorAll($));if(n.indexOf(e)<0)return;let i=n.map(e=>({url:tr(e),filename:e.alt||tr(e)||void 0})).filter(e=>e.url),a=tr(e),o=i.findIndex(e=>e.url===a),c=e.alt||a;s({open:!0,title:c,content:``,metadata:{tool:`image-preview`,filename:c},previewSource:e,image:{url:a,filename:c,gallery:i,index:Math.max(0,o),directory:t}})},d=e=>{let t=n.get(e);t&&(t.controller?.abort(),t.release?.(),n.delete(e))},f=e=>{let n=tr(e),r=b(n,t);if(S(r))return`${a}\n${t}\n${n}`},p=e=>{let t=f(e);if(!t){d(e);return}let r=n.get(e);if(r?.key===t)return r;d(e);let i={key:t};return n.set(e,i),i},m=(e,i)=>{if(i.controller||i.objectUrl||!r.contains(e))return;let a=tr(e),o=b(a,t);if(!S(o)){d(e);return}let s=new AbortController;i.controller=s,e.setAttribute(`data-md-image-state`,`loading`),e.setAttribute(`aria-busy`,`true`),C(o.path,s.signal).then(t=>{let r=n.get(e);if(!r||r!==i||r.controller!==s||s.signal.aborted){t.release();return}r.controller=void 0,r.objectUrl=t.url,r.release=t.release,e.src=t.url}).catch(()=>{let t=n.get(e);t===i&&(t.controller=void 0,e.removeAttribute(`aria-busy`),e.setAttribute(`data-md-image-state`,`error`))})};c.current=e=>{for(let[t,r]of n)(!e.contains(t)||f(t)!==r.key)&&d(t);for(let t of Array.from(e.querySelectorAll($))){let e=p(t);e&&!e.objectUrl&&m(t,e)}},c.current(r);let h=e=>{let t=p(e);if(t&&!t.objectUrl){m(e,t);return}i(e)},g=e=>{let t=e.target;if(!(t instanceof Element))return;let n=t.closest($);n&&(e.preventDefault(),e.stopPropagation(),h(n))},_=e=>{if(e.key!==`Enter`&&e.key!==` `)return;let t=e.target;!(t instanceof HTMLImageElement)||!t.matches($)||(e.preventDefault(),e.stopPropagation(),h(t))},v=e=>{let t=e.target;t instanceof Element&&t.closest($)&&(e.preventDefault(),e.stopPropagation())},y=e=>{let t=e.target;!(t instanceof HTMLImageElement)||!t.matches($)||t.getAttribute(`src`)!==t.getAttribute(`data-md-placeholder-source`)&&(qn(t),t.setAttribute(`data-md-image-state`,`loaded`))},x=e=>{let t=e.target;!(t instanceof HTMLImageElement)||!t.matches($)||(t.removeAttribute(`aria-busy`),t.setAttribute(`data-md-image-state`,`error`))};return r.addEventListener(`load`,y,!0),r.addEventListener(`error`,x,!0),r.addEventListener(`click`,g),r.addEventListener(`keydown`,_),r.addEventListener(`contextmenu`,v),()=>{c.current=()=>{},r.removeEventListener(`load`,y,!0),r.removeEventListener(`error`,x,!0),r.removeEventListener(`click`,g),r.removeEventListener(`keydown`,_),r.removeEventListener(`contextmenu`,v),u.current=setTimeout(()=>{u.current=null;for(let e of Array.from(n.keys()))r.contains(e)&&Kn(e),d(e)},0)}},[e,t,o,a]),{reconcileMarkdownImageResources:d,transportIdentity:a}},rr={download:!0,copy:!0,showPanZoomControls:!0},ir=!0,ar=e=>{let t=e.match(/^(?:\uFEFF)?(---|\+\+\+)[^\S\r\n]*\r?\n[\s\S]*?\r?\n\1[^\S\r\n]*(?:\r?\n|$)/);return t?e.slice(t[0].length):e},or=160,sr=e=>{let t=(0,me.c)(8),{containerRef:n,effectiveDirectory:r,editor:i,preferRuntimeEditor:a,onShowPopup:o,enabled:s}=e,c=K.useRef(null),l,u;t[0]!==n||t[1]!==i||t[2]!==r||t[3]!==s||t[4]!==o||t[5]!==a?(l=()=>{let e=n.current;if(!e)return;let t=!1,l=_(),u=U(),d=s,f=wr,p=()=>{let t=e.querySelectorAll(B);for(let e of Array.from(t))f(e)};if(!d){p();return}let m=e=>{let n=e===void 0?0:e;if(c.current!==null&&typeof window<`u`&&window.clearTimeout(c.current),typeof window>`u`){h();return}c.current=window.setTimeout(()=>{c.current=null,window.requestAnimationFrame(()=>{t||h()})},n)},h=()=>{let n=e.querySelectorAll(`[data-markdown="inline-code"], a, ${G}`),i=0;for(let a of Array.from(n)){let n=de(a),o=le(n,r);if(!o){f(a);continue}if(i>=u){f(a);continue}i+=1,(a.getAttribute(`data-yuri-file-link`)!==`true`||a.getAttribute(`data-yuri-file-path`)!==o.resolvedPath)&&z(o.resolvedPath,r).then(n=>{if(t||!e.contains(a))return;let i=de(a),s=le(i,r);if(!(!s||s.resolvedPath!==o.resolvedPath)){if(!ue(s.resolvedPath,n,l)){f(a);return}a.setAttribute(`data-yuri-file-link`,`true`),a.setAttribute(`data-yuri-file-ref`,i),a.setAttribute(`data-yuri-file-path`,s.resolvedPath),a.setAttribute(`data-yuri-file-binary`,String(n.isBinary)),a.setAttribute(`title`,pe),a.tagName.toLowerCase()!==`a`&&(a.setAttribute(`role`,`button`),a.setAttribute(`tabindex`,`0`))}}).catch(Tr)}},g=e=>W(e,{effectiveDirectory:r,editor:i,preferRuntimeEditor:a,onShowPopup:o}),v=e=>{let t=e.target;if(!(t instanceof Element)||t.closest($))return;let n=t.closest(B);n instanceof HTMLElement&&(e.preventDefault(),e.stopPropagation(),g(n))},y=e=>{if(e.key!==`Enter`&&e.key!==` `)return;let t=e.target;!(t instanceof HTMLElement)||t.getAttribute(`data-yuri-file-link`)!==`true`||(e.preventDefault(),e.stopPropagation(),g(t))};m(or);let b=new MutationObserver(()=>{m(or)});return b.observe(e,{childList:!0,subtree:!0}),e.addEventListener(`click`,v),e.addEventListener(`keydown`,y),()=>{t=!0,c.current!==null&&typeof window<`u`&&window.clearTimeout(c.current),c.current=null,b.disconnect(),e.removeEventListener(`click`,v),e.removeEventListener(`keydown`,y)}},u=[n,i,r,o,a,s],t[0]=n,t[1]=i,t[2]=r,t[3]=s,t[4]=o,t[5]=a,t[6]=l,t[7]=u):(l=t[6],u=t[7]),K.useEffect(l,u)},cr=({containerRef:e,onShowPopup:t,enableFullscreen:n,enablePanZoom:r,allowMermaidWheelEvents:i})=>{let a=f(e=>t?.(e)),o=!!t,s=f(t=>{if(!n||!o)return;let r=e.current;if(!r)return;let i=t.target;if(!(i instanceof Element)||i.closest(`button, a, [role="button"]`))return;let s=i.closest(Jt);if(!s)return;if(s instanceof HTMLElement&&s.hasAttribute(`data-mermaid-suppress-click`)){s.removeAttribute(`data-mermaid-suppress-click`);return}let c=Array.from(r.querySelectorAll(Jt)).indexOf(s);if(c<0)return;let l=s instanceof HTMLElement?s.getAttribute(`data-md-source`):null;if(!l||l.trim().length===0)return;let u=`Diagram ${c+1}`;a({open:!0,title:u,content:``,metadata:{tool:`mermaid-preview`,filename:u},mermaid:{url:`data:text/plain;charset=utf-8,${encodeURIComponent(l)}`,source:l,filename:u},previewSource:s instanceof HTMLElement?s:void 0})}),c=f(e=>{if(i||r)return;let t=e.target;t instanceof Element&&t.closest(`[data-markdown="mermaid-block"]`)&&e.stopPropagation()});p(`click`,s,e),K.useEffect(()=>{let t=e.current;if(t)return t.addEventListener(`wheel`,c,{capture:!0,passive:!0}),()=>{t.removeEventListener(`wheel`,c,!0)}},[e])},lr=24,ur=1,dr=12,fr=/[\s.,!?;:)\]]/,pr=(e,t)=>{let n=e<=12?2:e<=48?4:e<=96?8:Math.min(24,Math.ceil(e/8));return Math.max(1,Math.round(t/lr*n))},mr=(e,t)=>pr(e,t)*(1e3/t),hr=(e,t,n)=>{let r=Math.min(e.length,t+n);for(let t=r;t<Math.min(e.length,r+8);t+=1)if(fr.test(e[t]??``))return t+1;return r},gr=(e,t,n)=>{let[r,i]=K.useState(()=>t?0:e.length),a=K.useRef(r),o=K.useRef(0),s=K.useRef(null);return a.current=r,K.useEffect(()=>{if(!t||typeof window>`u`){o.current=0,s.current=null,i(e.length);return}a.current>e.length&&(a.current=e.length,o.current=0,i(e.length));let r=null,c=t=>{let l=Math.min(a.current,e.length);if(l>=e.length){r=null,s.current=null;return}let u=s.current;if(u===null){s.current=t,r=window.requestAnimationFrame(c);return}let d=Math.min(t-u,100);s.current=t,o.current+=mr(e.length-l,n)*(d/1e3);let f=Math.min(dr,Math.floor(o.current));if(f>=ur){o.current-=f;let t=hr(e,l,f);a.current=t,i(t)}r=window.requestAnimationFrame(c)};return a.current<e.length&&(r=window.requestAnimationFrame(c)),()=>{r!==null&&window.cancelAnimationFrame(r)}},[e,t,n]),t?e.slice(0,Math.min(r,e.length)):e},_r=(e,t,r,i=rr,a=n(),o=``,c=!1)=>{let{t:l}=h(),u=K.useMemo(()=>({copy:l(`markdownRenderer.code.actions.copyTitle`),copied:l(`markdownRenderer.code.actions.copiedTitle`),enableCodeWrap:l(`markdownRenderer.code.actions.enableWrapTitle`),disableCodeWrap:l(`markdownRenderer.code.actions.disableWrapTitle`),copyDiagram:l(`markdownRenderer.mermaid.actions.copySourceTitle`),downloadDiagram:l(`markdownRenderer.mermaid.actions.downloadSvgTitle`),zoomInDiagram:l(`markdownRenderer.mermaid.actions.zoomInTitle`),zoomOutDiagram:l(`markdownRenderer.mermaid.actions.zoomOutTitle`),resetDiagramView:l(`markdownRenderer.mermaid.actions.resetViewTitle`),previewLabel:l(`terminalView.preview.open`),previewTitle:l(`terminalView.preview.openTitle`)}),[l]),d=s(e=>e.codeBlockLineWrap),p=s(e=>e.setCodeBlockLineWrap),m=f(()=>{p(!s.getState().codeBlockLineWrap)});return K.useMemo(()=>({labels:u,mermaidControls:i,codeBlockLineWrap:d,deferCodeLineNumberSync:t,onToggleCodeBlockLineWrap:m,renderMermaid:t=>ge(t,e),onPreviewLoopback:r,imageTransportIdentity:a,imageEffectiveDirectory:o,imagePreviewEnabled:c}),[e,u,i,d,t,r,a,o,c])},vr=({containerRef:e,text:t,streaming:n,cacheKey:r,syntaxVars:i,ctx:a,reconcileMarkdownImageResources:o,onRichContentReady:s})=>{K.useEffect(()=>{M()},[]);let c=K.useRef(null),l=f(()=>{s?.()}),u=f(()=>{let t=e.current;if(t){if(!c.current){if(!Yt(t))return;c.current=_n(t);return}c.current.refresh()}});K.useLayoutEffect(()=>{let r=e.current,i=r?.querySelector(`[data-markdown-content]`)??r;if(i&&t&&i.childNodes.length===0){for(let e of At(t)){let t=document.createElement(`div`);t.setAttribute(`data-md-block`,``),t.style.display=`contents`,t.innerHTML=e,Yn(t,a),i.appendChild(t)}o(i),n||l()}},[e,a,o,n,t]),K.useEffect(()=>()=>{c.current?.cleanup(),c.current=null},[]),K.useEffect(()=>{let i=e.current;if(!i)return;let s=i.querySelector(`[data-markdown-content]`)??i,c=!0,d=new AbortController,f=()=>{},p=()=>{},m=()=>{if(!c||n||d.signal.aborted)return;s.replaceChildren();let e=document.createElement(`div`);e.setAttribute(`data-md-block`,``),e.setAttribute(`data-md-render-fallback`,`text`),e.style.display=`contents`;let r=document.createElement(`span`);r.style.whiteSpace=`pre-wrap`,r.textContent=t,e.appendChild(r),s.appendChild(e),o(s),l()},h=e=>{if(!c)return;let t=Array.from(s.children);e.forEach((e,n)=>{let r=t[n];if(r||(r=document.createElement(`div`),r.setAttribute(`data-md-block`,``),r.style.display=`contents`,s.appendChild(r)),r.getAttribute(`data-md-id`)===e.id)return;let i=document.createElement(`div`);i.innerHTML=e.html,Yn(i,a);let o=Yt(r),c=Yt(i);ce(r,i,{childrenOnly:!0,onBeforeElUpdated:(e,t)=>{if(Te(e,t))return!1;if(fe(e,t),e instanceof HTMLImageElement&&t instanceof HTMLImageElement){let n=e.getAttribute(`data-md-image-source`);if(n&&n===t.getAttribute(`data-md-image-source`)){let n=e.getAttribute(`src`);n===null?t.removeAttribute(`src`):t.setAttribute(`src`,n),t.className=e.className;for(let n of[`data-md-image-state`,`data-md-placeholder-source`,`aria-busy`]){let r=e.getAttribute(n);r===null?t.removeAttribute(n):t.setAttribute(n,r)}}}return!e.isEqualNode(t)}}),r.setAttribute(`data-md-id`,e.id),(o||c||Yt(r))&&u()});let n=Yt(s),r=!1;for(let n=t.length-1;n>=e.length;--n){let e=t[n];e&&Yt(e)&&(r=!0),e?.remove()}(r||t.length>e.length&&n)&&u(),o(s),a.deferCodeLineNumberSync||jn(s,a.codeBlockLineWrap,a.labels),ke(s,se,{signal:d.signal,priority:`visible`}),l()},g=e=>{try{h(e)}catch{m()}},_=()=>{Lt(t,n,r,d.signal).then(e=>{if(c){if(n){g(e);return}p=k(()=>g(e),{priority:`visible`})}}).catch(m)};return n?_():f=k(_,{priority:`visible`}),()=>{c=!1,d.abort(),f(),p()}},[e,t,n,r,a,o]),K.useEffect(()=>{let t=e.current;if(t)return Zn(t,a)},[e,a]),K.useEffect(()=>{let t=e.current,n=t?.querySelector(`[data-markdown-content]`)??t;if(n)for(let[e,t]of Object.entries(i))n.style.setProperty(e,t)},[e,i]),K.useEffect(()=>{let t=e.current,n=t?.querySelector(`[data-markdown-content]`)??t;n&&(a.deferCodeLineNumberSync||jn(n,a.codeBlockLineWrap,a.labels))},[e,a.codeBlockLineWrap,a.deferCodeLineNumberSync,a.labels]);let p=K.useRef(null),m=f(()=>{let t=e.current,n=t?.querySelector(`[data-markdown-content]`)??t;n&&(p.current!==null&&window.cancelAnimationFrame(p.current),p.current=window.requestAnimationFrame(()=>{p.current=null,kn(n)}))});d(e,m),K.useEffect(()=>()=>{p.current!==null&&window.cancelAnimationFrame(p.current)},[])},yr=e=>e===`tool`?`markdown-content markdown-tool`:e===`reasoning`?`markdown-content markdown-reasoning`:`markdown-content leading-relaxed`,br=e=>{let t=(0,me.c)(4),[n,r]=K.useState(e),i=K.useRef(e),a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>{i.current||(i.current=!0,r(!0))},t[0]=a):a=t[0];let o=f(a),s;return t[1]!==o||t[2]!==n?(s=[n,o],t[1]=o,t[2]=n,t[3]=s):s=t[3],s},xr=(e,t,n)=>{let r=K.useRef(n);r.current=n;let i=K.useRef(t);i.current=t;let a=f(e=>{if(!r.current)return;let t=e[0];if(!t)return;let n=t.borderBoxSize?.[0],a=n?n.blockSize:t.contentRect.height,o=n?n.inlineSize:t.contentRect.width;j(i.current,a,o)});d(e,a)},Sr=K.memo(e=>{let t=(0,me.c)(54),{content:n,part:r,messageId:i,isAnimated:a,skipFadeIn:s,className:c,isStreaming:u,disableStreamAnimation:d,variant:p,onShowPopup:m,enableFileReferences:h}=e,_=a===void 0||a,v=s!==void 0&&s,y=u!==void 0&&u,b=d!==void 0&&d,x=p===void 0?`assistant`:p,S=h===void 0||h,C=$n(),{editor:w,runtime:T}=l(),E=K.useRef(null),D=ee()??``,O=f(Er),k;t[0]!==D||t[1]!==O?(k=e=>{D&&O(D,e)},t[0]=D,t[1]=O,t[2]=k):k=t[2];let te=f(k),A=y&&!b,j;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(j=re(o()),t[3]=j):j=t[3];let M=gr(n,A,j.markdownPaceMs),[N,se]=br(A),P;t[4]===m?P=t[5]:(P={containerRef:E,onShowPopup:m,enableFullscreen:ir,enablePanZoom:rr.showPanZoomControls},t[4]=m,t[5]=P),cr(P);let ce=S&&!y,F;t[6]!==w||t[7]!==D||t[8]!==m||t[9]!==T.isVSCode||t[10]!==ce?(F={containerRef:E,effectiveDirectory:D,editor:w,preferRuntimeEditor:T.isVSCode,onShowPopup:m,enabled:ce},t[6]=w,t[7]=D,t[8]=m,t[9]=T.isVSCode,t[10]=ce,t[11]=F):F=t[11],sr(F);let I;t[12]!==D||t[13]!==O?(I={containerRef:E,effectiveDirectory:D,openInAppBrowser:O},t[12]=D,t[13]=O,t[14]=I):I=t[14],er(I);let L;t[15]!==D||t[16]!==m?(L={containerRef:E,effectiveDirectory:D,onShowPopup:m},t[15]=D,t[16]=m,t[17]=L):L=t[17];let{reconcileMarkdownImageResources:R,transportIdentity:le}=nr(L),z;t[18]===C?z=t[19]:(z=oe(C),t[18]=C,t[19]=z);let B=z,V=_r(C,A,D?te:void 0,rr,le,D,!!m),H=`markdown-${r?.id?`part-${r.id}`:`message-${i}`}`,U;t[20]!==H||t[21]!==V||t[22]!==A||t[23]!==M||t[24]!==R||t[25]!==se||t[26]!==B?(U={containerRef:E,text:M,streaming:A,cacheKey:H,syntaxVars:B,ctx:V,reconcileMarkdownImageResources:R,onRichContentReady:se},t[20]=H,t[21]=V,t[22]=A,t[23]=M,t[24]=R,t[25]=se,t[26]=B,t[27]=U):U=t[27],vr(U);let ue;t[28]!==n||t[29]!==x?(ue=ae(n,x),t[28]=n,t[29]=x,t[30]=ue):ue=t[30],xr(E,ue,N&&!A);let de=!N||void 0,W;t[31]===c?W=t[32]:(W=g(`relative break-words w-full min-w-0`,c),t[31]=c,t[32]=W);let fe=N?`true`:`false`,pe=N?`ready`:`pending`,G;t[33]!==M||t[34]!==N||t[35]!==x?(G=!N&&(0,Q.jsx)(`div`,{className:g(yr(x),`pointer-events-none absolute inset-0 overflow-clip`),children:(0,Q.jsx)(ie,{content:M})}),t[33]=M,t[34]=N,t[35]=x,t[36]=G):G=t[36];let he=!N||void 0,ge;t[37]!==N||t[38]!==x?(ge=g(yr(x),!N&&`invisible`),t[37]=N,t[38]=x,t[39]=ge):ge=t[39];let q;t[40]!==he||t[41]!==ge?(q=(0,Q.jsx)(`div`,{"aria-hidden":he,className:ge,"data-markdown-content":!0}),t[40]=he,t[41]=ge,t[42]=q):q=t[42];let _e;t[43]!==de||t[44]!==W||t[45]!==fe||t[46]!==pe||t[47]!==G||t[48]!==q?(_e=(0,Q.jsxs)(`div`,{"aria-busy":de,className:W,"data-markdown-ready":fe,"data-markdown-hydration":pe,ref:E,children:[G,q]}),t[43]=de,t[44]=W,t[45]=fe,t[46]=pe,t[47]=G,t[48]=q,t[49]=_e):_e=t[49];let ve=_e;if(_){let e;return t[50]!==H||t[51]!==ve||t[52]!==v?(e=(0,Q.jsx)(ne,{skipAnimation:v,children:ve},H),t[50]=H,t[51]=ve,t[52]=v,t[53]=e):e=t[53],e}return ve},(e,t)=>e.content===t.content&&e.isStreaming===t.isStreaming&&e.disableStreamAnimation===t.disableStreamAnimation&&e.variant===t.variant&&e.isAnimated===t.isAnimated&&e.skipFadeIn===t.skipFadeIn&&e.className===t.className&&e.messageId===t.messageId&&e.onShowPopup===t.onShowPopup&&e.enableFileReferences===t.enableFileReferences&&e.part?.id===t.part?.id),Cr=K.memo(e=>{let t=(0,me.c)(48),{content:n,className:r,variant:i,disableLinkSafety:a,stripFrontmatter:o,onShowPopup:s,mermaidControls:c,mermaidTheme:u,allowMermaidWheelEvents:d,enableFileReferences:p}=e,m=i===void 0?`assistant`:i,h=o!==void 0&&o,_=c===void 0?rr:c,v=d!==void 0&&d,y=p===void 0||p,{editor:b,runtime:x}=l(),S=$n(),C=K.useRef(null),[w,T]=br(!1),E=ee()??``,D;t[0]!==n||t[1]!==h?(D=h?ar(n):n,t[0]=n,t[1]=h,t[2]=D):D=t[2];let O=D,k;t[3]!==v||t[4]!==_.showPanZoomControls||t[5]!==s?(k={containerRef:C,onShowPopup:s,enableFullscreen:ir,enablePanZoom:_.showPanZoomControls,allowMermaidWheelEvents:v},t[3]=v,t[4]=_.showPanZoomControls,t[5]=s,t[6]=k):k=t[6],cr(k);let te=f(Dr),ne;t[7]!==b||t[8]!==E||t[9]!==y||t[10]!==s||t[11]!==x.isVSCode?(ne={containerRef:C,effectiveDirectory:E,editor:b,preferRuntimeEditor:x.isVSCode,onShowPopup:s,enabled:y},t[7]=b,t[8]=E,t[9]=y,t[10]=s,t[11]=x.isVSCode,t[12]=ne):ne=t[12],sr(ne);let A=!a,re;t[13]!==E||t[14]!==te||t[15]!==A?(re={containerRef:C,enabled:A,effectiveDirectory:E,openInAppBrowser:te},t[13]=E,t[14]=te,t[15]=A,t[16]=re):re=t[16],er(re);let j;t[17]!==E||t[18]!==s?(j={containerRef:C,effectiveDirectory:E,onShowPopup:s},t[17]=E,t[18]=s,t[19]=j):j=t[19];let{reconcileMarkdownImageResources:ae,transportIdentity:M}=nr(j),N;t[20]===S?N=t[21]:(N=oe(S),t[20]=S,t[21]=N);let se=N,P=_r(u??S,!1,void 0,_,M,E,!!s),ce=`simple:${m}`,F;t[22]!==P||t[23]!==ae||t[24]!==O||t[25]!==T||t[26]!==se||t[27]!==ce?(F={containerRef:C,text:O,streaming:!1,cacheKey:ce,syntaxVars:se,ctx:P,reconcileMarkdownImageResources:ae,onRichContentReady:T},t[22]=P,t[23]=ae,t[24]=O,t[25]=T,t[26]=se,t[27]=ce,t[28]=F):F=t[28],vr(F);let I=!w||void 0,L;t[29]===r?L=t[30]:(L=g(`relative break-words w-full min-w-0`,r),t[29]=r,t[30]=L);let R=w?`true`:`false`,le=w?`ready`:`pending`,z;t[31]!==O||t[32]!==w||t[33]!==m?(z=!w&&(0,Q.jsx)(`div`,{className:g(yr(m),`pointer-events-none absolute inset-0 overflow-clip`),children:(0,Q.jsx)(ie,{content:O})}),t[31]=O,t[32]=w,t[33]=m,t[34]=z):z=t[34];let B=!w||void 0,V;t[35]!==w||t[36]!==m?(V=g(yr(m),!w&&`invisible`),t[35]=w,t[36]=m,t[37]=V):V=t[37];let H;t[38]!==B||t[39]!==V?(H=(0,Q.jsx)(`div`,{"aria-hidden":B,className:V,"data-markdown-content":!0}),t[38]=B,t[39]=V,t[40]=H):H=t[40];let U;return t[41]!==I||t[42]!==L||t[43]!==R||t[44]!==le||t[45]!==z||t[46]!==H?(U=(0,Q.jsxs)(`div`,{"aria-busy":I,className:L,"data-markdown-ready":R,"data-markdown-hydration":le,ref:C,children:[z,H]}),t[41]=I,t[42]=L,t[43]=R,t[44]=le,t[45]=z,t[46]=H,t[47]=U):U=t[47],U},(e,t)=>{let n=e.mermaidControls??rr,r=t.mermaidControls??rr;return e.content===t.content&&e.variant===t.variant&&e.className===t.className&&e.disableLinkSafety===t.disableLinkSafety&&e.stripFrontmatter===t.stripFrontmatter&&e.onShowPopup===t.onShowPopup&&n.download===r.download&&n.copy===r.copy&&n.showPanZoomControls===r.showPanZoomControls&&e.mermaidTheme===t.mermaidTheme&&e.allowMermaidWheelEvents===t.allowMermaidWheelEvents&&e.enableFileReferences===t.enableFileReferences});function wr(e){e.removeAttribute(`data-yuri-file-link`),e.removeAttribute(`data-yuri-file-ref`),e.removeAttribute(`data-yuri-file-path`),e.removeAttribute(`data-yuri-file-binary`),e.getAttribute(`title`)===`Open file`&&e.removeAttribute(`title`),e.tagName.toLowerCase()!==`a`&&(e.removeAttribute(`role`),e.removeAttribute(`tabindex`))}function Tr(){}function Er(e,t){s.getState().openContextBrowser(e,t)}function Dr(e,t){s.getState().openContextBrowser(e,t)}export{Qn as n,Ve as r,Sr as t};