@pi-chamber/web 1.0.6-rc.2 → 1.0.6-rc.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 (129) hide show
  1. package/dist/assets/{DiagramView-BdDt1SI7.js → DiagramView-BZ--w7Lh.js} +1 -1
  2. package/dist/assets/DiffView-Dtn6otnT.js +18 -0
  3. package/dist/assets/{FileSaveConflictDialog-DpyPjMH1.js → FileSaveConflictDialog-p1ik30al.js} +2 -2
  4. package/dist/assets/FilesView-D0Z0VmQm.js +6 -0
  5. package/dist/assets/{GitHubDetailScaffold-CW2ZqU0Y.js → GitHubDetailScaffold-a27RksFo.js} +4 -4
  6. package/dist/assets/{GitHubLinkPicker-BjJNQ7Ap.js → GitHubLinkPicker-B0CfzNfk.js} +1 -1
  7. package/dist/assets/GitHubListPrimitives-LFdR70l6.js +1 -0
  8. package/dist/assets/GitView-BNkoaVYl.js +9 -0
  9. package/dist/assets/{IssuesSurface-CDZENHrE.js → IssuesSurface-D4kD7_VW.js} +3 -3
  10. package/dist/assets/{JsonTreeView-DpCgOUXg.js → JsonTreeView-CEiJsFnP.js} +1 -1
  11. package/dist/assets/MarkdownRendererImpl-418ChlsN.js +12 -0
  12. package/dist/assets/{PatchDiff-Dcr3EQgA.js → PatchDiff-BtOv_oLB.js} +1 -1
  13. package/dist/assets/{PierreDiffViewer-o_Edh6ny.js → PierreDiffViewer-CkuyY9ne.js} +15 -3
  14. package/dist/assets/{PullRequestsSurface-eSXl6sef.js → PullRequestsSurface-PML07zr-.js} +2 -2
  15. package/dist/assets/SessionSwitcherContent-DkfjRgwv.js +1 -0
  16. package/dist/assets/{SessionSwitcherDropdown-CFj9VWSa.js → SessionSwitcherDropdown-CEw8BEs6.js} +2 -2
  17. package/dist/assets/SessionUnreadDot-DXUn8-ss.js +1 -0
  18. package/dist/assets/SettingsView-BvUeFUqw.js +6 -0
  19. package/dist/assets/{SettingsWindow-BMzUErrM.js → SettingsWindow-D03Z9QyW.js} +1 -1
  20. package/dist/assets/{StickyHorizontalScrollbar-p7EbL2-E.js → StickyHorizontalScrollbar-CONTbZgX.js} +1 -1
  21. package/dist/assets/{ToolOutputDialog-QC8IoeBH.js → ToolOutputDialog-DibddNlz.js} +5 -5
  22. package/dist/assets/{ToolPartDiffPreview-BigGwtul.js → ToolPartDiffPreview-Bx7T1M2f.js} +1 -1
  23. package/dist/assets/{VirtualizedFileDiff-DvLCd7Qq.js → VirtualizedFileDiff-BY-mDMT8.js} +4 -4
  24. package/dist/assets/{Virtualizer-DNJrJKVb.js → Virtualizer-cIf8dSOQ.js} +1 -1
  25. package/dist/assets/{collapsible-0yfy07W2.js → collapsible-BhQdnj8G.js} +1 -1
  26. package/dist/assets/{computeVirtualFileMetrics-aX6tjjqv.js → computeVirtualFileMetrics-CzkFqhaU.js} +1 -1
  27. package/dist/assets/{contextFileOpenGuard-CZKJuHxf.js → contextFileOpenGuard-CjCOK8EB.js} +1 -1
  28. package/dist/assets/fileTreeStatus-CPTpyKOV.js +7 -0
  29. package/dist/assets/gitStatusPredicates-_GNbGCCb.js +1 -0
  30. package/dist/assets/{githubLink-BvevcNay.js → githubLink-CwIFogWd.js} +2 -2
  31. package/dist/assets/index-Cfrwo5uQ.js +11 -0
  32. package/dist/assets/index-D7k62S9M.css +1 -0
  33. package/dist/assets/{index-BMdbHCFt.js → index-DjOKW10B.js} +1 -1
  34. package/dist/assets/main-1wmEZ4Is.js +137 -0
  35. package/dist/assets/{main-BM-b2y8p.js → main-C51a3z3b.js} +2 -2
  36. package/dist/assets/{markdownCore-DbS8DkKw.js → markdownCore-Dsr6dY5C.js} +1 -1
  37. package/dist/assets/{miniChat-DO3DW6kJ.js → miniChat-DCxCx1fF.js} +2 -2
  38. package/dist/assets/{mobile-BgWLkut6.js → mobile-D6Ac2Mu3.js} +2 -2
  39. package/dist/assets/{nativeFileSave-Bhafll_7.js → nativeFileSave-P_Eg5Dgb.js} +1 -1
  40. package/dist/assets/{pi-session-focus-preference-ChYVctYk.js → pi-session-focus-preference-DjDyjZ1C.js} +1 -1
  41. package/dist/assets/{renderDiffWithHighlighter-xlvSvnTf.js → renderDiffWithHighlighter-CK_inhQE.js} +1 -1
  42. package/dist/assets/renderElectronMiniChatApp-wBNgFl0U.js +2 -0
  43. package/dist/assets/{renderFileWithHighlighter-CCoYfC-t.js → renderFileWithHighlighter-B_PFeRW5.js} +1 -1
  44. package/dist/assets/renderMobileApp-B3mhxGnb.js +11 -0
  45. package/dist/assets/runtimeEndpointReset-D8lAOCUB.js +62 -0
  46. package/dist/assets/{runtimeSurface-CJN1oo_1.js → runtimeSurface-C3YPOBlg.js} +1 -1
  47. package/dist/assets/useAppFontEffects-CoFst31H.js +215 -0
  48. package/dist/assets/{useGitHubRemoteSearch-CevR5iLf.js → useGitHubRemoteSearch-C0-6hhMJ.js} +1 -1
  49. package/dist/assets/useSwitcherItems-DHCCg4GF.js +1 -0
  50. package/dist/assets/{vendor-aparajita-capacitor-secure-storage-BLsm9T1Y.js → vendor-aparajita-capacitor-secure-storage-B9_YeZyx.js} +1 -1
  51. package/dist/assets/{vendor-base-ui-C7vVMZTg.js → vendor-base-ui-CKSCJw-4.js} +1 -1
  52. package/dist/assets/{vendor-boot-CoTxysn6.js → vendor-boot-Ciu-Edvy.js} +18 -18
  53. package/dist/assets/{vendor-capacitor-app-NX6DULfp.js → vendor-capacitor-app-Bpy_aPMq.js} +1 -1
  54. package/dist/assets/{vendor-capacitor-keyboard-DJD81I9f.js → vendor-capacitor-keyboard-DO8AIjrZ.js} +1 -1
  55. package/dist/assets/{vendor-capacitor-status-bar-DV24OoQV.js → vendor-capacitor-status-bar-SQkytwUW.js} +1 -1
  56. package/dist/assets/{vendor-codemirror-autocomplete-qsuH4Dh-.js → vendor-codemirror-autocomplete-CInQsE8a.js} +1 -1
  57. package/dist/assets/{vendor-codemirror-lang-angular-ZHWyBf7j.js → vendor-codemirror-lang-angular-QbsN3LGE.js} +1 -1
  58. package/dist/assets/{vendor-codemirror-lang-cpp-pCTOmv-k.js → vendor-codemirror-lang-cpp-BT5U7lxV.js} +1 -1
  59. package/dist/assets/{vendor-codemirror-lang-css-2bFuyM70.js → vendor-codemirror-lang-css-dF-Dxbty.js} +1 -1
  60. package/dist/assets/{vendor-codemirror-lang-go-DrG_c7D7.js → vendor-codemirror-lang-go-e4dp1bar.js} +1 -1
  61. package/dist/assets/{vendor-codemirror-lang-html-BV8lrR8v.js → vendor-codemirror-lang-html-DKcbBVQ4.js} +1 -1
  62. package/dist/assets/{vendor-codemirror-lang-java-DrsvH6T2.js → vendor-codemirror-lang-java-CB2-FWv6.js} +1 -1
  63. package/dist/assets/{vendor-codemirror-lang-javascript-Dkzl3s07.js → vendor-codemirror-lang-javascript-B1zJk7xE.js} +1 -1
  64. package/dist/assets/{vendor-codemirror-lang-jinja-8Nn3bnoP.js → vendor-codemirror-lang-jinja-BsERjdSd.js} +1 -1
  65. package/dist/assets/{vendor-codemirror-lang-json-CsdmtHhi.js → vendor-codemirror-lang-json-C0pZ0NhY.js} +1 -1
  66. package/dist/assets/{vendor-codemirror-lang-less-DJuZ4cZe.js → vendor-codemirror-lang-less-_N9HmR4h.js} +1 -1
  67. package/dist/assets/{vendor-codemirror-lang-liquid-D2RO-Pzr.js → vendor-codemirror-lang-liquid-D02xJRCD.js} +1 -1
  68. package/dist/assets/{vendor-codemirror-lang-markdown-C0Zu3b3n.js → vendor-codemirror-lang-markdown-_6ojeUuZ.js} +1 -1
  69. package/dist/assets/{vendor-codemirror-lang-php-CuDtt2Zj.js → vendor-codemirror-lang-php-DguCnbJA.js} +1 -1
  70. package/dist/assets/{vendor-codemirror-lang-python-Cv2exx_M.js → vendor-codemirror-lang-python-Byr5gw5f.js} +1 -1
  71. package/dist/assets/{vendor-codemirror-lang-rust-C4TxJ6Rg.js → vendor-codemirror-lang-rust-DN6Wh0eK.js} +1 -1
  72. package/dist/assets/{vendor-codemirror-lang-sass-BmtPz8kf.js → vendor-codemirror-lang-sass-DOlEW7q1.js} +1 -1
  73. package/dist/assets/{vendor-codemirror-lang-sql-BF1ZaXqJ.js → vendor-codemirror-lang-sql-BJzE9Dby.js} +1 -1
  74. package/dist/assets/{vendor-codemirror-lang-vue-DZgXrP2k.js → vendor-codemirror-lang-vue-DR8E-2nr.js} +1 -1
  75. package/dist/assets/{vendor-codemirror-lang-wast-DsnaGtL_.js → vendor-codemirror-lang-wast-n6lcDH5S.js} +1 -1
  76. package/dist/assets/{vendor-codemirror-lang-xml-D8DzzFat.js → vendor-codemirror-lang-xml-Cf2lmlmY.js} +1 -1
  77. package/dist/assets/{vendor-codemirror-lang-yaml-D5hBv7m6.js → vendor-codemirror-lang-yaml-DSR_E0yh.js} +1 -1
  78. package/dist/assets/{vendor-codemirror-language-data-vn2RyN9T.js → vendor-codemirror-language-data-CSid5JuX.js} +2 -2
  79. package/dist/assets/{vendor-codemirror-search-BVCYIV0D.js → vendor-codemirror-search-8lY3lt6q.js} +1 -1
  80. package/dist/assets/{vendor-lezer-cpp-vqXSn3lv.js → vendor-lezer-cpp-DZYTDKiD.js} +1 -1
  81. package/dist/assets/{vendor-lezer-css-JnEzSyZR.js → vendor-lezer-css-6qV4fYNQ.js} +1 -1
  82. package/dist/assets/{vendor-lezer-go-dD2gQMIL.js → vendor-lezer-go-BDi_Iblq.js} +1 -1
  83. package/dist/assets/{vendor-lezer-html-Cr3U-1pu.js → vendor-lezer-html-BjqcY-oJ.js} +1 -1
  84. package/dist/assets/{vendor-lezer-java-CRM0IMCo.js → vendor-lezer-java-J2BXqz1h.js} +1 -1
  85. package/dist/assets/{vendor-lezer-javascript-B3s21DIS.js → vendor-lezer-javascript-CiQ9F8yX.js} +1 -1
  86. package/dist/assets/{vendor-lezer-json-DPFM6EBV.js → vendor-lezer-json-BxN83KKR.js} +1 -1
  87. package/dist/assets/{vendor-lezer-lr-Bllrq8hY.js → vendor-lezer-lr-BVsDua_K.js} +1 -1
  88. package/dist/assets/{vendor-lezer-markdown-6-3PLvXG.js → vendor-lezer-markdown-BkMtRQ3X.js} +1 -1
  89. package/dist/assets/{vendor-lezer-php-DOyzfHRl.js → vendor-lezer-php-B3XqnXdP.js} +1 -1
  90. package/dist/assets/{vendor-lezer-python-CdHdN5qt.js → vendor-lezer-python-D342CidI.js} +1 -1
  91. package/dist/assets/{vendor-lezer-rust-CqnW8EMH.js → vendor-lezer-rust-Dbfg_4LA.js} +1 -1
  92. package/dist/assets/{vendor-lezer-sass-BbcF4y6A.js → vendor-lezer-sass-ClxPaFt1.js} +1 -1
  93. package/dist/assets/{vendor-lezer-xml-C31AyWoo.js → vendor-lezer-xml-I_S6FQ1u.js} +1 -1
  94. package/dist/assets/{vendor-lezer-yaml-Cv908yC2.js → vendor-lezer-yaml-COA6HWLP.js} +1 -1
  95. package/dist/assets/{vendor-replit-codemirror-vim-Cwhyn_5f.js → vendor-replit-codemirror-vim-7IE2zVmx.js} +1 -1
  96. package/dist/assets/{web-components-6ORYp3Iv.js → web-components-CzkvK_V5.js} +1 -1
  97. package/dist/index.html +4 -4
  98. package/dist/mini-chat.html +3 -3
  99. package/dist/mobile.html +3 -3
  100. package/package.json +1 -1
  101. package/server/lib/git/DOCUMENTATION.md +1 -0
  102. package/server/lib/git/routes.js +14 -0
  103. package/server/lib/git/routes.test.js +37 -0
  104. package/server/lib/git/service.js +27 -0
  105. package/server/lib/git/service.test.js +32 -0
  106. package/server/lib/pi/routes.js +63 -1
  107. package/server/lib/pi/routes.test.js +77 -0
  108. package/server/lib/pi/session-daemon/DOCUMENTATION.md +1 -1
  109. package/server/lib/pi/session-shelf-store.js +181 -0
  110. package/server/lib/pi/session-shelf-store.test.js +73 -0
  111. package/server/lib/pi/ui-settings-store.js +1 -0
  112. package/dist/assets/DiffView-Dk3VIX9E.js +0 -18
  113. package/dist/assets/FilesView-CumrwioK.js +0 -6
  114. package/dist/assets/GitHubListPrimitives-BcB-cCTs.js +0 -1
  115. package/dist/assets/GitView-BoCaX5AO.js +0 -9
  116. package/dist/assets/MarkdownRendererImpl-BkT5TUWF.js +0 -12
  117. package/dist/assets/SessionSwitcherContent-Dm30bfpn.js +0 -1
  118. package/dist/assets/SessionUnreadDot-CHlK2awX.js +0 -1
  119. package/dist/assets/SettingsView-CcHRUyev.js +0 -6
  120. package/dist/assets/gitStatusPredicates-3i8CcYWJ.js +0 -1
  121. package/dist/assets/index-C2ISrmRR.js +0 -11
  122. package/dist/assets/index-DgwThEwf.css +0 -1
  123. package/dist/assets/main-BXZ561E3.js +0 -137
  124. package/dist/assets/renderElectronMiniChatApp-CgVqxKDm.js +0 -2
  125. package/dist/assets/renderMobileApp-CoY1tsk5.js +0 -11
  126. package/dist/assets/runtimeEndpointReset-fozcAShH.js +0 -62
  127. package/dist/assets/useAppFontEffects-D_gtiA95.js +0 -215
  128. package/dist/assets/useFilesViewSearch-BUxcZj60.js +0 -7
  129. package/dist/assets/useSwitcherItems-kaRkXggX.js +0 -1
@@ -1 +1 @@
1
- import{d9 as M,dz as Z,dA as Fe,dB as Ce,dC as ke,dD as Ie,dE as ze,da as Ne,dF as Oe,B as ee,I as te,dG as Ve}from"./useAppFontEffects-D_gtiA95.js";import{a as ie,s as Pe,b as Se,c as ne,d as ve,g as Be,e as re,f as I,h as De,i as Ue,j as _e,k as We,R as Ge,I as je,p as se,l as $e,m as qe,n as Ke,o as Je,w as Ye,q as ae,u as Xe,r as Qe,t as Ze,v as et,x as oe,S as tt,y as it,z as nt,A as rt,B as ye,C as he,F as st}from"./web-components-6ORYp3Iv.js";import{G as at,u as ot,W as ht,a as lt,b as dt,n as le,t as ct}from"./Virtualizer-DNJrJKVb.js";import{j as C}from"./vendor-boot-CoTxysn6.js";import{o as ut,i as j,f as L,a as ft,q as de,s as pt,t as ce,d as gt,u as ue,b as mt,w as B,x as fe}from"./computeVirtualFileMetrics-aX6tjjqv.js";import{a as F,i as K,l as pe,h as Ct,r as St}from"./renderFileWithHighlighter-CCoYfC-t.js";import{t as H}from"./vendor-hast-util-to-html-O3stl53j.js";import{a as k,R as A}from"./vendor-react-Bz1tRBxM.js";let vt=-1;var yt=class{options;onRenderUpdate;workerManager;__id=`file-renderer:${++vt}`;highlighter;renderCache;computedLang="text";lineAnnotations={};lineCache;textDoucmentCache=new WeakMap;constructor(i={theme:M},e,t){this.options=i,this.onRenderUpdate=e,this.workerManager=t,t?.isWorkingPool()!==!0&&(this.highlighter=ie(i.theme??M)?ut():void 0)}setOptions(i){this.options=i}mergeOptions(i){this.options={...this.options,...i}}setLineAnnotations(i){this.lineAnnotations={};for(const e of i){const t=this.lineAnnotations[e.lineNumber]??[];this.lineAnnotations[e.lineNumber]=t,t.push(e)}}cleanUp(){this.recycle(),this.workerManager=void 0,this.onRenderUpdate=void 0}recycle(){this.clearRenderCache(),this.highlighter=void 0,this.workerManager?.cleanUpTasks(this),this.lineCache=void 0}clearRenderCache(){const i=this.renderCache;this.renderCache=void 0,i!=null&&i.isDirty===!0&&i.file.cacheKey!=null&&this.workerManager?.evictFileFromCache(i.file.cacheKey)}hydrate(i){const{options:e}=this.getRenderOptions(i),t=$(this.getOrCreateLineCache(i).length,this.getTokenizeMaxLength());let n=this.workerManager?.getFileResultCache(i);n!=null&&!F(e,n.options)&&(n=void 0),this.renderCache??={file:i,options:e,highlighted:!t&&!K(i),result:t?void 0:n?.result,renderRange:void 0},this.workerManager?.isWorkingPool()===!0?this.renderCache.result==null&&!t&&this.workerManager.highlightFileAST(this,i):this.highlighter==null&&(this.computedLang=i.lang??j(i.name),this.initializeHighlighter())}getRenderOptions(i){const e=(()=>{if(this.workerManager?.isWorkingPool()===!0)return this.workerManager.getFileRenderOptions();const{theme:n=M,tokenizeMaxLineLength:r=1e3}=this.options;return{theme:n,useTokenTransformer:Pe(this.options),tokenizeMaxLineLength:r}})(),{renderCache:t}=this;return t?.result==null?{options:e,forceHighlight:!0}:!L(i,t.file)||!F(e,t.options)?{options:e,forceHighlight:!0}:{options:e,forceHighlight:!1}}getOrCreateLineCache(i){if(i.cacheKey==null)return this.lineCache=void 0,pe(i.contents);let{lineCache:e}=this;return(e==null||e.cacheKey!==i.cacheKey)&&(e={cacheKey:i.cacheKey,lines:pe(i.contents)}),this.lineCache=e,e.lines}getLineCount(i){return this.textDoucmentCache.get(i)?.lineCount??this.getOrCreateLineCache(i).length}updateRenderCache(i,e){if(this.renderCache==null)return;const{result:t}=this.renderCache;if(t!=null){for(const[n,r]of i)t.code[n]={type:"element",tagName:"div",properties:{"data-line":n+1,"data-line-type":"context","data-line-index":n},children:r.map(([s,a,o])=>s===0&&a===""?o===""?{type:"element",tagName:"br",properties:{},children:[]}:{type:"text",value:o}:{type:"element",tagName:"span",properties:{"data-char":s,style:`--diffs-token-${e}:${a};`},children:[{type:"text",value:o}]})};t.baseThemeType=e,this.renderCache.isDirty=!0}}applyDocumentChange(i){if(this.renderCache==null)return;const{file:e,result:t}=this.renderCache;if(t!=null&&t.code.length!==i.lineCount){t.code.length=Math.min(t.code.length,i.lineCount);for(let n=t.code.length;n<i.lineCount;n++)t.code.push({type:"element",tagName:"div",properties:{"data-line":n+1,"data-line-type":"context","data-line-index":n},children:[{type:"element",tagName:"span",properties:{"data-char":0},children:[{type:"text",value:i.getLineText(n)}]}]});this.renderCache.isDirty=!0}this.textDoucmentCache.set(e,i)}renderFile(i=this.renderCache?.file,e=Z){if(i==null)return;let{options:t,forceHighlight:n}=this.getRenderOptions(i);const r=this.getMatchingWorkerResultCache(i,t);r!=null&&!this.hasHighlightedRenderCache(i,t)&&(this.renderCache={file:i,highlighted:!0,renderRange:void 0,...r},n=!1),this.renderCache??={file:i,highlighted:!1,options:t,result:void 0,renderRange:void 0};const s=this.getOrCreateLineCache(i),a=i.contents.length>0,o=!a||K(i)||$(s.length,this.getTokenizeMaxLength()),h=!L(i,this.renderCache.file),d=!Se(this.renderCache.renderRange,e);if(this.workerManager?.isWorkingPool()===!0)(o||this.renderCache.result==null||!this.renderCache.highlighted&&(h||d))&&(this.renderCache.file=i,this.renderCache.options=t,this.renderCache.highlighted=!1,(this.renderCache.result==null||h||d||n)&&(this.renderCache.result=this.workerManager.getPlainFileAST(i,e.startingLine,e.totalLines,s)),this.renderCache.renderRange=e),!o&&a&&(!this.renderCache.highlighted||n)&&this.workerManager.highlightFileAST(this,i);else{this.computedLang=i.lang??j(i.name);const l=this.highlighter!=null&&ie(t.theme),c=this.highlighter!=null&&ne(this.computedLang),u=!o&&c;if(this.highlighter!=null&&l&&(n||o||!this.renderCache.highlighted&&u||this.renderCache.result==null)){const{result:p,options:f}=this.renderFileWithHighlighter(i,this.highlighter,o||!c);this.renderCache={file:i,options:f,highlighted:u,result:p,renderRange:void 0}}(!l||!o&&!c)&&this.asyncHighlight(i).then(({result:p,options:f})=>{this.renderCache!=null&&(this.renderCache.highlighted=!1),this.onHighlightSuccess(i,p,f,!o)})}return this.renderCache.result!=null?this.processFileResult(this.renderCache.file,e,this.renderCache.result):void 0}async asyncRender(i,e=Z){const{result:t}=await this.asyncHighlight(i);return this.processFileResult(i,e,t)}async asyncHighlight(i){const e=$(this.getOrCreateLineCache(i).length,this.getTokenizeMaxLength());this.computedLang=e?"text":i.lang??j(i.name);const t=this.highlighter!=null&&Ct(ft(this.options.theme)),n=e||this.highlighter!=null&&ne(this.computedLang);return(this.highlighter==null||!t||!n)&&(this.highlighter=await this.initializeHighlighter()),this.renderFileWithHighlighter(i,this.highlighter,e)}renderFileWithHighlighter(i,e,t=!1){const{options:n}=this.getRenderOptions(i);return{result:St(i,e,n,{forcePlainText:t}),options:n}}processFileResult(i,e,{code:t,themeStyles:n,baseThemeType:r}){const s=this.getLineCount(i),{disableFileHeader:a=!1}=this.options,o=[],h=ue(),d=Math.min(e.startingLine+e.totalLines,s);let l=0;const c=ve(e)?Be(this.lineAnnotations):void 0;c!=null&&(h.children.push(de("context","annotation",1)),o.push(re({hunkIndex:-1,lineIndex:-1,annotations:c.map(u=>I(u))})),l++);for(let u=e.startingLine;u<d;u++){const p=u+1,f=t[u];if(f==null){const g="FileRenderer.processFileResult: Line doesnt exist";throw console.error(g,{name:i.name,lineIndex:u,lineNumber:p}),new Error(g)}h.children.push(pt("context",p,`${u}`)),o.push(f),l++;const S=this.lineAnnotations[p];S!=null&&(h.children.push(de("context","annotation",1)),o.push(re({hunkIndex:0,lineIndex:p,annotations:S.map(g=>I(g))})),l++)}return h.properties.style=`grid-row: span ${l}`,{gutterAST:h.children??[],contentAST:o,preAST:this.createPreElement(s),headerAST:a?void 0:this.renderHeader(i),totalLines:s,rowCount:l,themeStyles:n,baseThemeType:r,bufferBefore:e.bufferBefore,bufferAfter:e.bufferAfter,css:""}}renderHeader(i){const{headerRenderMode:e="default",stickyHeader:t=!1}=this.options;return De({fileOrDiff:i,mode:e,stickyHeader:t})}renderFullHTML(i){return H(this.renderFullAST(i))}renderFullAST(i,e=[]){return e.push(ce({tagName:"code",children:this.renderCodeAST(i),properties:{"data-code":""}})),{...i.preAST,children:e}}renderCodeAST(i){const e=ue();return e.children=i.gutterAST,e.properties.style=`grid-row: span ${i.rowCount}`,[e,Ue(i.contentAST,i.rowCount)]}renderPartialHTML(i,e=!1){return e?H(ce({tagName:"code",children:i,properties:{"data-code":""}})):H(i)}async initializeHighlighter(){return this.highlighter=await gt(_e(this.computedLang,this.options)),this.highlighter}onHighlightSuccess(i,e,t,n=!0){if(this.renderCache==null)return;const r=!L(i,this.renderCache.file)||!this.renderCache.highlighted||!F(t,this.renderCache.options);this.renderCache={file:i,options:t,highlighted:n,result:e,renderRange:void 0},r&&this.onRenderUpdate?.()}getMatchingWorkerResultCache(i,e){const t=this.workerManager?.getFileResultCache(i);if(!(t==null||!F(e,t.options)))return t}hasHighlightedRenderCache(i,e){const{renderCache:t}=this;return t?.result!=null&&t.highlighted&&L(i,t.file)&&F(e,t.options)}onHighlightError(i){console.error(i)}getTokenizeMaxLength(){return this.options.tokenizeMaxLength??1e5}createPreElement(i){const{disableLineNumbers:e=!1,overflow:t="scroll"}=this.options;return We({type:"file",diffIndicators:"none",disableBackground:!0,disableLineNumbers:e,overflow:t,split:!1,totalLines:i})}};function $(i,e){return i>e}function Tt(i,e){return i.lineNumber===e.lineNumber&&i.metadata===e.metadata}function ge(i){return{theme:i?.theme,disableLineNumbers:i?.disableLineNumbers,overflow:i?.overflow,themeType:i?.themeType,collapsed:i?.collapsed,disableFileHeader:i?.disableFileHeader,disableVirtualizationBuffers:i?.disableVirtualizationBuffers,stickyHeader:i?.stickyHeader,preferredHighlighter:i?.preferredHighlighter,useCSSClasses:i?.useCSSClasses,useTokenTransformer:i?.useTokenTransformer,tokenizeMaxLineLength:i?.tokenizeMaxLineLength,tokenizeMaxLength:i?.tokenizeMaxLength,unsafeCSS:i?.unsafeCSS,headerRenderMode:i?.renderCustomHeader!=null?"custom":"default"}}const bt=[""];let Rt=-1;var Te=class{options;workerManager;isContainerManaged;static LoadedCustomComponent=!0;__id=`file:${++Rt}`;type="file";fileContainer;spriteSVG;pre;code;bufferBefore;bufferAfter;themeCSSStyle;appliedThemeCSS;hasAdoptedThemeCSS=!1;unsafeCSSStyle;appliedUnsafeCSS;gutterUtilityContent;errorWrapper;placeHolder;lastRenderedHeaderHTML;cachedHeaderHTML;appliedPreAttributes;lastRowCount;mounted=!1;headerElement;headerCustom;headerPrefix;headerFilenameSuffix;headerMetadata;fileRenderer;resizeManager;interactionManager;annotationCache=new Map;lineAnnotations=[];managersDirty=!1;file;renderRange;enabled=!0;editor;constructor(e={theme:M},t,n=!1){this.options=e,this.workerManager=t,this.isContainerManaged=n,this.fileRenderer=new yt(e,this.handleHighlightRender,this.workerManager),this.resizeManager=new Ge,this.interactionManager=new je("file",se(e)),this.workerManager?.subscribeToThemeChanges(this)}handleHighlightRender=()=>{this.rerender()};rerender(){!this.enabled||this.file==null||this.render({file:this.file,forceRender:!0,renderRange:this.renderRange})}onThemeChange(){this.fileRenderer.clearRenderCache(),this.rerender()}setOptions(e){e!=null&&(this.options=e,this.cachedHeaderHTML=void 0,this.syncInteractionOptions())}syncInteractionOptions(){this.interactionManager.setOptions(se(this.options))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){(this.options.themeType??"system")!==e&&(this.mergeOptions({themeType:e}),this.applyCachedThemeState(e))}applyCachedThemeState(e){if(typeof this.options.theme=="string"||this.fileContainer==null||this.appliedThemeCSS==null)return!1;const t=this.appliedThemeCSS.baseThemeType??e;return this.appliedThemeCSS.themeType===t?!1:(this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,e,this.appliedThemeCSS.baseThemeType),!0)}hasThemeChanged(){return this.appliedThemeCSS!=null&&!mt(this.appliedThemeCSS.theme,this.options.theme??M)}getHoveredLine=()=>this.interactionManager.getHoveredLine();setLineAnnotations(e){this.lineAnnotations=e}setSelectedLines(e,t){this.interactionManager.setSelection(e,t)}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}const{overflow:e="scroll"}=this.options;this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,e==="wrap"),this.managersDirty=!1}cleanUp(e=!1){this.emitPostRender(!0),this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.managersDirty=!1,this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,this.isContainerManaged||this.fileContainer?.remove(),this.fileContainer=void 0,this.mounted=!1,e||(this.lineAnnotations=[]),this.annotationCache.clear(),this.pre=void 0,this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.lastRenderedHeaderHTML=void 0,e||(this.cachedHeaderHTML=void 0),this.errorWrapper=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.placeHolder=void 0,this.unsafeCSSStyle=void 0,e?this.fileRenderer.recycle():(this.fileRenderer.cleanUp(),this.workerManager=void 0,this.file=void 0),this.enabled=!1,this.editor?.cleanUp(),this.editor=void 0}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate(e){const{fileContainer:t,prerenderedHTML:n,preventEmit:r=!1,file:s,lineAnnotations:a}=e;this.hydrateElements(t,n),At(this.pre,s,this.options.collapsed)||Lt(this.headerElement,s,this.options.disableFileHeader)?this.render({...e,preventEmit:!0}):this.hydrationSetup({file:s,lineAnnotations:a}),r||this.emitPostRender()}hydrateElements(e,t){this.fileContainer!==e&&this.emitPostRender(!0),$e(e,t);for(const n of Array.from(e.shadowRoot?.children??[])){if(n instanceof SVGElement){this.spriteSVG=n;continue}if(n instanceof HTMLElement){if(n instanceof HTMLPreElement){this.pre=n,this.appliedPreAttributes=void 0;continue}if(n instanceof HTMLStyleElement&&n.hasAttribute("data-theme-css")){this.themeCSSStyle=n;continue}if(n instanceof HTMLStyleElement&&n.hasAttribute("data-unsafe-css")){this.unsafeCSSStyle=n,this.appliedUnsafeCSS=n.textContent;continue}if("diffsHeader"in n.dataset){this.headerElement=n,this.lastRenderedHeaderHTML=void 0;continue}}}this.pre!=null&&(this.syncCodeNodeFromPre(this.pre),this.pre.removeAttribute("data-dehydrated")),this.fileContainer=e,this.hydrateMeasuredScrollbar()}hydrationSetup({file:e,lineAnnotations:t}){this.lineAnnotations=t??this.lineAnnotations,this.file=e,this.fileRenderer.setOptions(ge(this.options)),this.syncInteractionOptions(),this.pre!=null&&(this.fileRenderer.hydrate(e),this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.managersDirty=!0,this.flushManagers())}getOrCreateLineCache(e=this.file){return e!=null?this.fileRenderer.getOrCreateLineCache(e):bt}updateBuffers(e){this.pre!=null&&this.applyBuffers(this.pre,e)}syncRenderViewToEditor(){const e=this.editor,t=this.fileContainer,n=this.file;e!=null&&t!=null&&n!=null&&this.fileRenderer.initializeHighlighter().then(r=>{e.__syncRenderView(r,t,n,this.lineAnnotations,this.renderRange)})}attachEditor(e){return this.editor?.cleanUp(),this.editor=e,this.interactionManager.setEditorAttached(!0),this.syncRenderViewToEditor(),()=>{this.editor=void 0,this.interactionManager.setEditorAttached(!1)}}applyDocumentChange(e,t){this.fileRenderer.applyDocumentChange(e),t!=null&&t!==this.lineAnnotations&&this.file!=null&&(this.setLineAnnotations(t),this.fileRenderer.setLineAnnotations(this.lineAnnotations),this.renderAnnotations())}updateRenderCache(e,t){this.fileRenderer.updateRenderCache(e,t)}render({file:e,fileContainer:t,forceRender:n=!1,preventEmit:r=!1,containerWrapper:s,deferManagers:a=!1,lineAnnotations:o,renderRange:h}){if(!this.enabled)throw new Error("File.render: attempting to call render after cleaned up");this.editor?.__postponeBackgroundTokenizeToNextFrame();const{collapsed:d=!1,themeType:l="system"}=this.options,c=d?void 0:h,u=this.renderRange,p=this.hasThemeChanged(),f=o!=null&&(o.length>0||this.lineAnnotations.length>0)?o!==this.lineAnnotations:!1,S=!L(this.file,e);if(!d&&!n&&Se(c,this.renderRange)&&!S&&!f&&!p)return this.applyCachedThemeState(l);this.renderRange=c,S&&(this.cachedHeaderHTML=void 0),this.file=e,this.fileRenderer.setOptions(ge(this.options)),this.syncInteractionOptions(),o!=null&&this.setLineAnnotations(o),this.fileRenderer.setLineAnnotations(this.lineAnnotations);const{disableErrorHandling:g=!1,disableFileHeader:y=!1}=this.options;if(y&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0),this.clearHeaderSlots()),t=this.getOrCreateFileContainerNode(t,s),this.applyCachedThemeState(l),d){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{const m=this.fileRenderer.renderFile(e,Fe);m!=null&&this.applyThemeState(t,m.themeStyles,l,m.baseThemeType),m?.headerAST!=null&&this.applyHeaderToDOM(m.headerAST,t),this.injectUnsafeCSS()}catch(m){if(g)throw m;console.error(m),m instanceof Error&&this.applyErrorToDOM(m,t)}return r||this.emitPostRender(),!0}try{const m=this.getOrCreatePreNode(t);if(!this.canPartiallyRender(n,f,S||p)||!this.applyPartialRender(u,c)){const v=this.fileRenderer.renderFile(e,c);if(v==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.initialize().then(()=>this.rerender()),!1;this.applyThemeState(t,v.themeStyles,l,v.baseThemeType),v.headerAST!=null&&this.applyHeaderToDOM(v.headerAST,t),this.applyFullRender(v,m)}this.applyBuffers(m,c),this.injectUnsafeCSS(),this.managersDirty=!0,a||this.flushManagers(),this.renderAnnotations(),this.renderGutterUtility(),this.editor!=null&&this.syncRenderViewToEditor()}catch(m){if(g)throw m;console.error(m),m instanceof Error&&this.applyErrorToDOM(m,t)}return r||this.emitPostRender(),!0}emitPostRender(e=!1){const{fileContainer:t,options:{onPostRender:n}}=this;if(e){if(!this.mounted||(this.mounted=!1,t==null))return;n?.(t,this,"unmount");return}if(t==null)return;const r=this.mounted?"update":"mount";this.mounted=!0,n?.(t,this,r)}removeRenderedCode(){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.code?.remove(),this.code=void 0,this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){for(const{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}canPartiallyRender(e,t,n){return!(e||t||n)}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){const t=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:"open"});this.placeHolder=document.createElement("div"),this.placeHolder.dataset.placeholder="",t.appendChild(this.placeHolder)}return this.placeHolder.style.setProperty("height",`${e}px`),!0}primeHighlightCache(){const{file:e,workerManager:t}=this;e==null||e.cacheKey==null||t==null||K(e)||this.fileRenderer.getOrCreateLineCache(e).length>(this.options.tokenizeMaxLength??1e5)||t.primeFileHighlightCache(e)}cleanChildNodes(){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.code?.remove(),this.errorWrapper?.remove(),this.headerElement?.remove(),this.gutterUtilityContent?.remove(),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.pre?.remove(),this.spriteSVG?.remove(),this.themeCSSStyle?.remove(),this.unsafeCSSStyle?.remove(),this.bufferAfter=void 0,this.bufferBefore=void 0,this.code=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.gutterUtilityContent=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.pre=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.lastRenderedHeaderHTML=void 0,this.lastRowCount=void 0,this.mounted=!1}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(const{element:n}of this.annotationCache.values())n.remove();this.annotationCache.clear();return}const e=new Map(this.annotationCache),{renderAnnotation:t}=this.options;if(t!=null&&this.lineAnnotations.length>0)for(const[n,r]of this.lineAnnotations.entries()){const s=`${n}-${I(r)}`;let a=this.annotationCache.get(s);if(a==null||!Tt(r,a.annotation)){a?.element.remove();const o=t(r);if(o==null)continue;a={element:qe(I(r)),annotation:r},a.element.appendChild(o),this.fileContainer.appendChild(a.element),this.annotationCache.set(s,a)}e.delete(s)}for(const[n,{element:r}]of e.entries())this.annotationCache.delete(n),r.remove()}renderGutterUtility(){const{renderGutterUtility:e}=this.options;if(this.fileContainer==null||e==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}const t=e(this.interactionManager.getHoveredLine);if(t!=null&&this.gutterUtilityContent!=null)return;if(t==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}const n=Ke();n.appendChild(t),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}injectUnsafeCSS(){const{unsafeCSS:e}=this.options,t=this.fileContainer?.shadowRoot;if(t!=null){if(e==null||e===""){this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0;return}this.unsafeCSSStyle?.parentNode===t&&this.appliedUnsafeCSS===e||(this.unsafeCSSStyle??=Je(),this.unsafeCSSStyle.parentNode!==t&&t.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=Ye(e),this.appliedUnsafeCSS=e)}}applyThemeState(e,t,n,r){const s=e.shadowRoot??e.attachShadow({mode:"open"}),a=r??n,o=this.options.theme??M,h=typeof o=="string"?o:{...o},d=ae(s);if(this.themeCSSStyle?.parentNode===s&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===a&&this.appliedThemeCSS.scrollbarGutter===d){this.appliedThemeCSS.theme=h;return}if(this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===s){this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:h,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:d};return}this.themeCSSStyle=Xe({shadowRoot:s,currentNode:this.themeCSSStyle,themeCSS:Qe(t,a,d)}),this.appliedThemeCSS=this.themeCSSStyle!=null?{theme:h,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:d}:void 0}hydrateMeasuredScrollbar(){const e=this.fileContainer?.shadowRoot;e==null||this.themeCSSStyle==null||(this.themeCSSStyle.textContent=Ze(this.themeCSSStyle.textContent??"",ae(e)))}applyFullRender(e,t){this.cleanupErrorWrapper(),this.applyPreNodeAttributes(t,e),this.code=et({code:this.code});const n=this.fileRenderer.renderCodeAST(e);if(this.code.childElementCount>=2)for(let r=0;r<2;r++){const s=this.code.children[r],a=n[r];s.innerHTML=H(a.children),s.style.cssText=a.properties.style}else this.code.innerHTML=H(n);t.contains(this.code)||t.replaceChildren(this.code),this.lastRowCount=e.rowCount}applyPartialRender(e,t){if(e==null||t==null)return!1;const{file:n,code:r}=this,s=r!=null?this.getColumns(r):void 0;if(n==null||r==null||s==null)return!1;const a=e.startingLine,o=t.startingLine,h=e.totalLines===1/0?Number.POSITIVE_INFINITY:a+e.totalLines,d=t.totalLines===1/0?Number.POSITIVE_INFINITY:o+t.totalLines,l=Math.max(a,o),c=Math.min(h,d);if(c<=l||!this.trimDOMToOverlap(s.gutter,l,c)||!this.trimDOMToOverlap(s.content,l,c))return!1;let{length:u}=s.content.children;const p=(y,m)=>{if(!(m<=0))return this.fileRenderer.renderFile(n,{startingLine:y,totalLines:m,bufferBefore:0,bufferAfter:0})},f=o<l?p(o,l-o):void 0;if(f===void 0&&o<l)return!1;const S=d===Number.POSITIVE_INFINITY?Number.POSITIVE_INFINITY:Math.max(0,d-c),g=d>c?p(c,S):void 0;return g===void 0&&d>c?!1:(this.cleanupErrorWrapper(),f!=null&&(s.gutter.insertAdjacentHTML("afterbegin",this.fileRenderer.renderPartialHTML(f.gutterAST)),s.content.insertAdjacentHTML("afterbegin",this.fileRenderer.renderPartialHTML(f.contentAST)),u+=f.rowCount),g!=null&&(s.gutter.insertAdjacentHTML("beforeend",this.fileRenderer.renderPartialHTML(g.gutterAST)),s.content.insertAdjacentHTML("beforeend",this.fileRenderer.renderPartialHTML(g.contentAST)),u+=g.rowCount),this.lastRowCount!==u&&(s.gutter.style.setProperty("grid-row",`span ${u}`),s.content.style.setProperty("grid-row",`span ${u}`),this.lastRowCount=u),!0)}getColumns(e){const t=e.children[0],n=e.children[1];if(!(!(t instanceof HTMLElement)||!(n instanceof HTMLElement)||t.dataset.gutter==null||n.dataset.content==null))return{gutter:t,content:n}}trimDOMToOverlap(e,t,n){const r=this.getDOMBoundaryIndices(e,[t,n]),s=r.get(t)??e.children.length,a=r.get(n)??e.children.length;if(s>a)return!1;for(let o=e.children.length-1;o>=a;o-=1)e.children[o]?.remove();for(let o=s-1;o>=0;o-=1)e.children[o]?.remove();return!0}getDOMBoundaryIndices(e,t){const n=[...new Set(t)].sort((h,d)=>h-d),r=new Map;if(n.length===0)return r;let s=0,a=n[s];const{children:o}=e;a===0&&(r.set(0,0),s+=1,a=n[s]);for(let h=0;h<o.length;h+=1){const d=o[h];if(!(d instanceof HTMLElement))continue;const l=this.getLineIndexFromDOMNode(d);if(l!=null){for(;a!=null&&l>=a;)r.set(a,h),s+=1,a=n[s];if(s>=n.length)break}}for(const h of n)r.has(h)||r.set(h,o.length);return r}getLineIndexFromDOMNode(e){const t=e.dataset.lineIndex;if(t==null)return;const n=Number(t);return Number.isNaN(n)?void 0:n}applyBuffers(e,t){if(t==null||this.shouldDisableVirtualizationBuffers()){this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0);return}t.bufferBefore>0?(this.bufferBefore==null&&(this.bufferBefore=document.createElement("div"),this.bufferBefore.dataset.virtualizerBuffer="before",e.before(this.bufferBefore)),this.bufferBefore.style.setProperty("height",`${t.bufferBefore}px`),this.bufferBefore.style.setProperty("contain","strict")):this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),t.bufferAfter>0?(this.bufferAfter==null&&(this.bufferAfter=document.createElement("div"),this.bufferAfter.dataset.virtualizerBuffer="after",e.after(this.bufferAfter)),this.bufferAfter.style.setProperty("height",`${t.bufferAfter}px`),this.bufferAfter.style.setProperty("contain","strict")):this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0)}shouldDisableVirtualizationBuffers(){return this.options.disableVirtualizationBuffers??!1}applyHeaderToDOM(e,t){const{file:n}=this;if(n==null)return;this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;const r=this.cachedHeaderHTML??H(e);if(this.cachedHeaderHTML=r,r!==this.lastRenderedHeaderHTML){const d=document.createElement("div");d.innerHTML=r;const l=d.firstElementChild;if(!(l instanceof HTMLElement))return;this.headerElement!=null?t.shadowRoot?.replaceChild(l,this.headerElement):t.shadowRoot?.prepend(l),this.headerElement=l,this.lastRenderedHeaderHTML=r}if(this.isContainerManaged)return;const{renderHeaderPrefix:s,renderHeaderFilenameSuffix:a,renderCustomHeader:o,renderHeaderMetadata:h}=this.options;if(o!=null){const d=o(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,Ce,d),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0}else{const d=s?.(n)??void 0,l=a?.(n)??void 0,c=h?.(n)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,ke,d),this.headerFilenameSuffix=this.upsertHeaderSlotElement(t,this.headerFilenameSuffix,Ie,l),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,ze,c),this.headerCustom?.remove(),this.headerCustom=void 0}}clearHeaderSlots(){this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0}upsertHeaderSlotElement(e,t,n,r){if(r==null){t?.remove();return}const s=t??this.createHeaderSlotElement(n);return t==null&&e.appendChild(s),this.replaceHeaderSlotContent(s,r),s}replaceHeaderSlotContent(e,t){e.replaceChildren(),t instanceof Element?e.appendChild(t):e.innerText=`${t}`}createHeaderSlotElement(e){const t=document.createElement("div");return t.slot=e,t}getOrCreateFileContainerNode(e,t){const{fileContainer:n}=this,r=e??n??document.createElement("diffs-container"),s=n!==r;return s&&this.emitPostRender(!0),this.fileContainer=r,n!=null&&s&&(this.lastRenderedHeaderHTML=void 0,this.headerElement=void 0),t!=null&&this.fileContainer.parentNode!==t&&t.appendChild(this.fileContainer),s&&this.adoptReusableShellElements(this.fileContainer),this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(e){const{shadowRoot:t}=e;if(t!=null)for(const n of t.children)n instanceof SVGElement?this.spriteSVG??=n:oe(n)&&n.hasAttribute("data-theme-css")?(this.themeCSSStyle??=n,this.hasAdoptedThemeCSS=!0):oe(n)&&n.hasAttribute("data-unsafe-css")&&(this.unsafeCSSStyle??=n,this.appliedUnsafeCSS??=this.options.unsafeCSS??void 0)}ensureSpriteSVG(e){const t=e.shadowRoot??e.attachShadow({mode:"open"});if(this.spriteSVG==null){const n=document.createElement("div");n.innerHTML=tt;const r=n.firstChild;r instanceof SVGElement&&(this.spriteSVG=r)}this.spriteSVG!=null&&this.spriteSVG.parentNode!==t&&t.appendChild(this.spriteSVG)}getOrCreatePreNode(e){const t=e.shadowRoot??e.attachShadow({mode:"open"});return this.pre==null?(this.pre=document.createElement("pre"),this.appliedPreAttributes=void 0,this.code=void 0,t.appendChild(this.pre)):this.pre.parentNode!==t&&(e.shadowRoot?.appendChild(this.pre),this.appliedPreAttributes=void 0),this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodeFromPre(e){this.code=void 0;for(const t of Array.from(e.children))if(t instanceof HTMLElement&&t.hasAttribute("data-code")){this.code=t;return}}applyPreNodeAttributes(e,{totalLines:t}){const{overflow:n="scroll",disableLineNumbers:r=!1}=this.options,s={type:"file",split:!1,overflow:n,disableLineNumbers:r,diffIndicators:"none",disableBackground:!0,totalLines:t};it(s,this.appliedPreAttributes)||(nt(e,s),this.appliedPreAttributes=s)}applyErrorToDOM(e,t){this.cleanupErrorWrapper(),this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;const n=t.shadowRoot??t.attachShadow({mode:"open"});this.errorWrapper??=document.createElement("div"),this.errorWrapper.dataset.errorWrapper="",this.errorWrapper.textContent="",n.appendChild(this.errorWrapper);const r=document.createElement("div");r.dataset.errorMessage="",r.innerText=e.message,this.errorWrapper.appendChild(r);const s=document.createElement("pre");s.dataset.errorStack="",s.innerText=e.stack??"No Error Stack",this.errorWrapper.appendChild(s)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}};function At(i,e,t=!1){return!t&&i==null&&e!=null}function Lt(i,e,t=!1){return i==null&&e!=null&&!t}const Mt=5e3;let Ht=-1;function xt(i,e){return(i.overflow??"scroll")!==(e.overflow??"scroll")||(i.collapsed??!1)!==(e.collapsed??!1)||(i.disableLineNumbers??!1)!==(e.disableLineNumbers??!1)||(i.disableFileHeader??!1)!==(e.disableFileHeader??!1)||i.unsafeCSS!==e.unsafeCSS}var wt=class extends Te{virtualizer;metrics;__id=`virtualized-file:${++Ht}`;top;height=0;cache={heights:new Map,checkpoints:[],fileAnnotationHeight:0};isVisible=!1;isSetup=!1;layoutDirty=!0;forceRenderOverride;currentCollapsed;constructor(i,e,t=Ne,n,r=!1){super(i,n,r),this.virtualizer=e,this.metrics=t}setMetrics(i,e=!1){!e&&rt(this.metrics,i)||(this.metrics=i,this.resetLayoutCache())}setLineAnnotations(i){this.syncLineAnnotations(i)&&this.resetLayoutCache()}syncLineAnnotations(i){return i==null||i===this.lineAnnotations||i.length===0&&this.lineAnnotations.length===0?!1:(super.setLineAnnotations(i),!0)}hasLineAnnotations(){return this.lineAnnotations.some(i=>i.lineNumber>0)}getLineHeight(i,e=!1){const t=this.cache.heights.get(i);if(t!=null)return t;const n=e?2:1;return this.metrics.lineHeight*n}setOptions(i){if(this.isAdvancedMode())throw new Error("VirtualizedFile.setOptions cannot be used inside CodeView. Update CodeView options instead.");if(i==null)return;const{options:e}=this,t=!ye(e,i),n=xt(e,i);super.setOptions(i),n&&this.resetLayoutCache(!0),t&&(this.forceRenderOverride=!0),t&&this.virtualizer.instanceChanged(this,n)}setThemeType(i){if(this.isAdvancedMode())throw new Error("VirtualizedFile.setThemeType cannot be used inside CodeView. Update CodeView options instead.");super.setThemeType(i)}resetLayoutCache(i=!1){this.layoutDirty=!0,this.cache.fileAnnotationHeight=0,this.cache.heights.size>0&&this.cache.heights.clear(),this.cache.checkpoints.length>0&&(this.cache.checkpoints.length=0),this.renderRange!=null&&(this.renderRange=void 0),i&&this.isSimpleMode()&&this.computeApproximateSize()}reconcileHeights(){let i=!1;if(this.fileContainer==null||this.file==null)return this.height!==0&&(i=!0),this.height=0,i;const{overflow:e="scroll"}=this.options;if(this.top=this.getVirtualizedTop(),e==="scroll"&&this.lineAnnotations.length===0&&!this.isResizeDebuggingEnabled()||this.code==null)return i;const t=this.code.children[1];if(!(t instanceof HTMLElement))return i;const n=he(this.lineAnnotations);if(this.renderRange!=null&&n&&ve(this.renderRange)){const r=Et(t)??0;r!==this.cache.fileAnnotationHeight&&(this.cache.fileAnnotationHeight=r,i=!0)}else!n&&this.cache.fileAnnotationHeight!==0&&(this.cache.fileAnnotationHeight=0,i=!0);for(const r of t.children){if(!(r instanceof HTMLElement))continue;const s=r.dataset.lineIndex;if(s==null)continue;const a=Number(s);let o=r.getBoundingClientRect().height,h=!1;r.nextElementSibling instanceof HTMLElement&&("lineAnnotation"in r.nextElementSibling.dataset||"noNewline"in r.nextElementSibling.dataset)&&("noNewline"in r.nextElementSibling.dataset&&(h=!0),o+=r.nextElementSibling.getBoundingClientRect().height);const d=this.getLineHeight(a,h);o!==d&&(i=!0,o===this.metrics.lineHeight*(h?2:1)?this.cache.heights.delete(a):this.cache.heights.set(a,o))}return(i||this.isResizeDebuggingEnabled())&&this.computeApproximateSize(!0),i}onRender=i=>this.fileContainer==null||this.file==null?!1:(i&&(this.top=this.getVirtualizedTop()),this.render({file:this.file}));prepareCodeViewItem(i,e,t,n){const r=this.syncLineAnnotations(n);let s=t?.resetFileLayoutCache===!0||r;t?.metrics!=null&&(this.metrics=t.metrics,s=!0);const{collapsed:a=!1}=this.options;return this.currentCollapsed!==a&&(this.currentCollapsed=a,s=!0),s&&this.resetLayoutCache(),this.file!==i&&(this.layoutDirty=!0),this.file=i,this.top=e,this.computeApproximateSize(),this.height}getLinePosition(i){if(this.file==null||i<1)return;const{disableFileHeader:e=!1,collapsed:t=!1}=this.options,n=this.fileRenderer.getLineCount(this.file)-1;let r=B(this.metrics,e);if(t||n<0)return{top:r,height:0};const s=Math.min(Math.max(i-1,0),n),{overflow:a="scroll"}=this.options,{lineHeight:o}=this.metrics;if(r+=this.cache.fileAnnotationHeight,a==="scroll"&&!this.hasLineAnnotations())return{top:r+s*o,height:o};const h=this.getLayoutCheckpointBeforeLineIndex(s);r=h?.top??r;for(let d=h?.lineIndex??0;d<s;d++)r+=this.getLineHeight(d,!1);return{top:r,height:this.getLineHeight(s,!1)}}getNumericScrollAnchor(i){if(this.file==null||this.renderRange==null)return;const{disableFileHeader:e=!1,collapsed:t=!1,overflow:n="scroll"}=this.options;if(t||this.renderRange.totalLines<=0)return;const r=this.fileRenderer.getLineCount(this.file)-1;if(r<0)return;const s=B(this.metrics,e),a=Math.min(this.renderRange.startingLine,r),o=Math.min(a+this.renderRange.totalLines-1,r);if(o<a)return;const{fileAnnotationHeight:h}=this.cache;if(n==="scroll"&&!this.hasLineAnnotations()){const{lineHeight:l}=this.metrics,c=s+(a===0?h:this.renderRange.bufferBefore),u=a+Math.max(Math.ceil((i-c)/l),0);return u>o?void 0:{lineNumber:u+1,top:s+h+u*l}}let d=s+(a===0?h:this.renderRange.bufferBefore);for(let l=a;l<=o;l++){if(d>=i)return{lineNumber:l+1,top:d};d+=this.getLineHeight(l)}}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(i){if(this.top==null||this.file==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};const e=i!=null?this.computeRenderRangeFromWindow(this.file,this.top,i):this.renderRange;if(e==null)return;const{bufferBefore:t,bufferAfter:n,totalLines:r}=e;let s=0;if(r===0){const a=i??this.virtualizer.getWindowSpecs();this.top<a.top&&(s=n)}return{topOffset:this.top+t+s,height:this.height-(t+n)}}cleanUp(i=!1){this.fileContainer!=null&&this.isSimpleMode()&&this.getSimpleVirtualizer()?.disconnect(this.fileContainer),i||this.resetLayoutCache(),this.isSetup=!1,super.cleanUp(i)}computeApproximateSize(i=!1){const e=this.isResizeDebuggingEnabled();if(!i&&!this.layoutDirty&&!e)return;const t=this.height===0;if(this.height=0,this.cache.checkpoints=[],this.file==null){this.layoutDirty=!1;return}const{disableFileHeader:n=!1,collapsed:r=!1,overflow:s="scroll"}=this.options,{lineHeight:a}=this.metrics,o=this.fileRenderer.getLineCount(this.file),h=B(this.metrics,n),d=fe(this.metrics);if(this.height+=h,r){this.layoutDirty=!1;return}if(this.height+=this.cache.fileAnnotationHeight,s==="scroll"&&!this.hasLineAnnotations())this.height+=o*a;else for(let l=0;l<o;l++)this.addLayoutCheckpoint(l,this.height),this.height+=this.getLineHeight(l,!1);if(o>0&&(this.height+=d),this.fileContainer!=null&&e&&!t){const l=this.fileContainer.getBoundingClientRect();l.height!==this.height?console.log("VirtualizedFile.computeApproximateSize: computed height doesnt match",{name:this.file.name,elementHeight:l.height,computedHeight:this.height}):console.log("VirtualizedFile.computeApproximateSize: computed height IS CORRECT")}this.layoutDirty=!1}setVisibility(i){this.isAdvancedMode()||this.fileContainer==null||(i&&!this.isVisible?(this.top=this.getVirtualizedTop(),this.isVisible=!0):!i&&this.isVisible&&(this.isVisible=!1,this.rerender()))}rerender(){!this.enabled||this.file==null||(this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!1))}applyDocumentChange(i,e,t=!1){const{heights:n,checkpoints:r}=this.cache,s=this.renderRange;if(super.applyDocumentChange(i,e),this.getSimpleVirtualizer()?.markDOMDirty(),this.layoutDirty=!0,n.size>0&&n.clear(),r.length>0&&(r.length=0),this.isSimpleMode()&&this.computeApproximateSize(),t&&s!==void 0&&this.file!==void 0){const a=this.virtualizer.getWindowSpecs(),o=this.computeRenderRangeFromWindow(this.file,this.top??0,a);o.bufferAfter!==s.bufferAfter&&this.updateBuffers(o)}}render({fileContainer:i,file:e,forceRender:t=!1,lineAnnotations:n,...r}){const s=this.file==null||!L(this.file,e),{forceRenderOverride:a,isSetup:o}=this;this.forceRenderOverride=void 0;const h=this.syncLineAnnotations(n);if(h&&this.resetLayoutCache(),this.file=e,i=this.getOrCreateFileContainerNode(i),this.file==null)return console.error("VirtualizedFile.render: attempting to virtually render when we dont have file"),!1;if(o)this.top??=this.getVirtualizedTop(),s&&this.isSimpleMode()&&(this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache(!0));else{this.computeApproximateSize();const u=this.getSimpleVirtualizer();if(this.top??=this.getVirtualizedTop(),this.isAdvancedMode())this.isVisible=!0;else{if(u==null)throw new Error("VirtualizedFile.render: simple virtualizer is not available");u.connect(i,this),this.isVisible=u.isInstanceVisible(this.top??0,this.height)}this.isSetup=!0}if(!this.isVisible&&this.isSimpleMode())return this.renderPlaceholder(this.height);const d=this.virtualizer.getWindowSpecs(),l=this.top??0,c=this.computeRenderRangeFromWindow(this.file,l,d);return super.render({file:this.file,fileContainer:i,renderRange:c,lineAnnotations:n,forceRender:(a??t)||h,...r})}syncVirtualizedTop(){this.top=this.getVirtualizedTop()}shouldDisableVirtualizationBuffers(){return this.isAdvancedMode()||super.shouldDisableVirtualizationBuffers()}isSimpleMode(){return this.virtualizer.type==="simple"}isAdvancedMode(){return this.virtualizer.type==="advanced"}addLayoutCheckpoint(i,e){i%Mt===0&&this.cache.checkpoints.push({lineIndex:i,top:e})}getLayoutCheckpointBeforeLineIndex(i){if(i<=0||this.cache.checkpoints.length===0)return;let e=0,t=this.cache.checkpoints.length-1,n;for(;e<=t;){const r=e+t>>1,s=this.cache.checkpoints[r];if(s==null)throw new Error("VirtualizedFile: invalid checkpoint index");s.lineIndex<=i?(n=s,e=r+1):t=r-1}return n}getLayoutCheckpointBeforeTop(i,e){let t=0,n=this.cache.checkpoints.length-1,r=-1;for(;t<=n;){const s=t+n>>1,a=this.cache.checkpoints[s];if(a==null)throw new Error("VirtualizedFile: invalid checkpoint index");a.top<=i?(r=s,t=s+1):n=s-1}if(e==null)return r>=0?this.cache.checkpoints[r]:void 0;for(let s=r;s>=0;s--){const a=this.cache.checkpoints[s];if(a==null)throw new Error("VirtualizedFile: invalid checkpoint index");if(a.lineIndex%e===0)return a}}getVirtualizedTop(){return this.virtualizer.type==="advanced"?this.virtualizer.getLocalTopForInstance(this):this.fileContainer!=null?this.virtualizer.getOffsetInScrollContainer(this.fileContainer):0}getSimpleVirtualizer(){return this.virtualizer.type==="simple"?this.virtualizer:void 0}isResizeDebuggingEnabled(){return this.getSimpleVirtualizer()?.config.resizeDebugging??!1}computeRenderRangeFromWindow(i,e,{top:t,bottom:n}){const{disableFileHeader:r=!1,overflow:s="scroll"}=this.options,{hunkLineCount:a,lineHeight:o}=this.metrics,h=this.fileRenderer.getLineCount(i),d=this.height,l=B(this.metrics,r),c=h>0?fe(this.metrics):0,{fileAnnotationHeight:u}=this.cache,p=l+u,f=Math.max(0,d-l-u-c),S=he(this.lineAnnotations),g=e+l,y=u>0&&S&&g<n&&g+u>t;if(e<t-d||e>n)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:d-l-c};if(h<=a)return{startingLine:0,totalLines:a,bufferBefore:0,bufferAfter:0};const m=Math.ceil(Math.max(n-t,0)/o),v=Math.ceil(m/a)*a+a*2,z=v/a,D=(t+n)/2;if(s==="scroll"&&!this.hasLineAnnotations()){const R=e+p,P=R+f;if(!y&&!(R<n&&P>t))return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:d-l-c};const w=Math.floor(y&&D<e+p?0:(D-(e+p))/o),b=Math.floor(w/a)-Math.floor(z/2),xe=Math.ceil(h/a),E=Math.max(0,Math.min(b,xe))*a,Q=b<0?v+b*a:v,we=E===0?0:u+E*o,Ee=Math.min(Q,h-E);return{startingLine:E,totalLines:Q,bufferBefore:we,bufferAfter:Math.max(0,(h-E-Ee)*o)}}const be=z,N=[],U=this.getLayoutCheckpointBeforeTop(Math.max(0,t-e-v*o*2),a);let T=e+(U?.top??p),_=U?.lineIndex??0,O,V,x;const Re=U?.lineIndex??0;for(let R=Re;R<h;R++){const P=_%a===0,w=Math.floor(_/a);if(P&&(N[w]=T-(e+p),x!=null)){if(x<=0)break;x--}const b=this.getLineHeight(R,!1);T>t-b&&T<n&&(O??=w),T+b>D&&(V??=w),x==null&&T>=n&&P&&(x=be),_++,T+=b}if(O==null)if(y)O=0,V=0;else return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:d-l-c};V??=O;const W=Math.round(V-z/2),Ae=Math.max(0,Math.ceil(h/a)-z),G=Math.max(0,Math.min(W,Ae)),J=G*a,Y=W<0?v+W*a:v,Le=N[G]??0,Me=J===0?0:u+Le,X=G+Y/a,He=X<N.length?f-N[X]:f-(T-e-p);return{startingLine:J,totalLines:Y,bufferBefore:Me,bufferAfter:Math.max(0,He)}}};function Et(i){let e;for(const t of i.children)t instanceof HTMLElement&&t.dataset.lineAnnotation===st&&(e=Math.max(e??0,t.getBoundingClientRect().height));return e}function Ft({file:i,renderCustomHeader:e,renderHeaderPrefix:t,renderHeaderFilenameSuffix:n,renderHeaderMetadata:r,renderAnnotation:s,lineAnnotations:a,renderGutterUtility:o,getHoveredLine:h}){const d=e?.(i),l=t?.(i),c=n?.(i),u=r?.(i);return C.jsxs(C.Fragment,{children:[d!=null?C.jsx("div",{slot:Ce,children:d}):C.jsxs(C.Fragment,{children:[l!=null&&C.jsx("div",{slot:"header-prefix",children:l}),c!=null&&C.jsx("div",{slot:"header-filename-suffix",children:c}),u!=null&&C.jsx("div",{slot:"header-metadata",children:u})]}),s!=null&&a?.map((p,f)=>C.jsx("div",{slot:I(p),children:s(p)},f)),o!=null&&C.jsx("div",{slot:"gutter-utility-slot",style:at,children:o(h)})]})}const me=typeof window>"u"?k.useEffect:k.useLayoutEffect;function kt({file:i,options:e,lineAnnotations:t,selectedLines:n,prerenderedHTML:r,metrics:s,hasGutterRenderUtility:a,hasCustomHeader:o,disableWorkerPool:h,contentEditable:d}){const l=ot(),c=n!==void 0,u=k.useContext(ht),p=lt(),f=k.useRef(null),S=dt(g=>{if(g!=null){if(f.current!=null)throw new Error("File: An instance should not already exist when a node is created");l!=null?f.current=new wt(q({controlledSelection:c,contentEditable:d,hasCustomHeader:o,hasEditor:p!==void 0,hasGutterRenderUtility:a,options:e}),l,s,h?void 0:u,!0):f.current=new Te(q({controlledSelection:c,contentEditable:d,hasCustomHeader:o,hasEditor:p!==void 0,hasGutterRenderUtility:a,options:e}),h?void 0:u,!0),f.current.hydrate({file:i,fileContainer:g,lineAnnotations:t,prerenderedHTML:r})}else{if(f.current==null)throw new Error("File: A File instance should exist when unmounting");f.current.cleanUp(),f.current=null}});return me(()=>{if(f.current==null)return;const g=q({controlledSelection:c,contentEditable:d,hasCustomHeader:o,hasEditor:p!==void 0,hasGutterRenderUtility:a,options:e}),y=!ye(f.current.options,g);f.current.setOptions(g),f.current.render({file:i,lineAnnotations:t,forceRender:y}),n!==void 0&&f.current.setSelectedLines(n)}),me(()=>{if(d&&f.current!=null){if(p===void 0)throw new Error("File: Editor is not attached");return p.edit(f.current)}},[d,p]),{ref:S,getHoveredLine:k.useCallback(()=>f.current?.getHoveredLine(),[])}}function q({options:i,controlledSelection:e,contentEditable:t,hasCustomHeader:n,hasEditor:r,hasGutterRenderUtility:s}){const a=t&&r,o=e||s||n;if(!o&&!a)return i;let h={...i};return o&&(h={...h,controlledSelection:e,renderCustomHeader:n?le:i?.renderCustomHeader,renderGutterUtility:s?le:i?.renderGutterUtility}),a&&(h={...h,useTokenTransformer:!0,enableGutterUtility:!1,enableLineSelection:!1,lineHoverHighlight:"disabled"}),h}function _t({file:i,lineAnnotations:e,selectedLines:t,options:n,metrics:r,className:s,style:a,renderAnnotation:o,renderCustomHeader:h,renderHeaderPrefix:d,renderHeaderFilenameSuffix:l,renderHeaderMetadata:c,prerenderedHTML:u,renderGutterUtility:p,disableWorkerPool:f=!1,contentEditable:S=!1}){const{ref:g,getHoveredLine:y}=kt({file:i,options:n,metrics:r,lineAnnotations:e,selectedLines:t,prerenderedHTML:u,hasGutterRenderUtility:p!=null,hasCustomHeader:h!=null,disableWorkerPool:f,contentEditable:S});return C.jsx(Oe,{ref:g,className:s,style:a,children:ct(Ft({file:i,renderAnnotation:o,renderCustomHeader:h,renderHeaderPrefix:d,renderHeaderFilenameSuffix:l,renderHeaderMetadata:c,renderGutterUtility:p,lineAnnotations:e,getHoveredLine:y}),u)})}const Wt=A.memo(function({jsonString:e,className:t,maxHeight:n="100%",initiallyExpandedDepth:r=2}){const s=A.useRef(null),[a,o]=A.useState(null),h=A.useMemo(()=>{try{const c=e.trim();if(!c)return o("Empty JSON content"),null;const u=JSON.parse(c);return o(null),u}catch(c){return o(c instanceof Error?c.message:"Invalid JSON"),null}},[e]),d=A.useCallback(()=>{s.current?.expandAll()},[]),l=A.useCallback(()=>{s.current?.collapseAll()},[]);return a?C.jsx("div",{className:t,children:C.jsxs("div",{className:"rounded-md border border-[var(--interactive-border)] bg-[var(--syntax-base-background)] p-4",children:[C.jsx("div",{className:"mb-1 font-medium text-[var(--surface-foreground)]",children:"Invalid JSON"}),C.jsx("div",{className:"font-mono text-xs text-[var(--surface-mutedForeground)]",children:a})]})}):h===null?null:C.jsxs("div",{className:t,children:[C.jsxs("div",{className:"flex items-center gap-1 border-b border-[var(--interactive-border)] px-2 py-1",children:[C.jsxs(ee,{variant:"ghost",size:"xs",onClick:d,className:"gap-1 text-xs text-muted-foreground",children:[C.jsx(te,{name:"arrow-down-s",className:"h-3 w-3"}),"Expand All"]}),C.jsxs(ee,{variant:"ghost",size:"xs",onClick:l,className:"gap-1 text-xs text-muted-foreground",children:[C.jsx(te,{name:"arrow-up-s",className:"h-3 w-3"}),"Collapse All"]})]}),C.jsx("div",{className:"bg-[var(--syntax-base-background)] py-1",style:{maxHeight:n,overflow:"auto"},children:C.jsx(Ve,{ref:s,data:h,maxHeight:n,initiallyExpandedDepth:r})})]})});export{_t as F,Wt as J};
1
+ import{dc as H,dF as Z,dG as Fe,dH as Ce,dI as ke,dJ as Ie,dK as ze,dd as Ne,dL as Oe,B as ee,I as te,dM as Ve}from"./useAppFontEffects-CoFst31H.js";import{a as ie,s as Pe,b as Se,c as ne,d as ve,g as Be,e as re,f as I,h as De,i as Ue,j as _e,k as We,R as Ge,I as je,p as se,l as $e,m as Ke,n as qe,o as Je,w as Ye,q as ae,u as Xe,r as Qe,t as Ze,v as et,x as oe,S as tt,y as it,z as nt,A as rt,B as ye,C as he,F as st}from"./web-components-CzkvK_V5.js";import{G as at,u as ot,W as ht,a as lt,b as dt,n as le,t as ct}from"./Virtualizer-cIf8dSOQ.js";import{j as C}from"./vendor-boot-Ciu-Edvy.js";import{o as ut,i as j,f as M,a as ft,q as de,s as pt,t as ce,d as gt,u as ue,b as mt,w as B,x as fe}from"./computeVirtualFileMetrics-CzkFqhaU.js";import{a as F,i as q,l as pe,h as Ct,r as St}from"./renderFileWithHighlighter-B_PFeRW5.js";import{t as A}from"./vendor-hast-util-to-html-O3stl53j.js";import{a as k,R as L}from"./vendor-react-Bz1tRBxM.js";let vt=-1;var yt=class{options;onRenderUpdate;workerManager;__id=`file-renderer:${++vt}`;highlighter;renderCache;computedLang="text";lineAnnotations={};lineCache;textDoucmentCache=new WeakMap;constructor(i={theme:H},e,t){this.options=i,this.onRenderUpdate=e,this.workerManager=t,t?.isWorkingPool()!==!0&&(this.highlighter=ie(i.theme??H)?ut():void 0)}setOptions(i){this.options=i}mergeOptions(i){this.options={...this.options,...i}}setLineAnnotations(i){this.lineAnnotations={};for(const e of i){const t=this.lineAnnotations[e.lineNumber]??[];this.lineAnnotations[e.lineNumber]=t,t.push(e)}}cleanUp(){this.recycle(),this.workerManager=void 0,this.onRenderUpdate=void 0}recycle(){this.clearRenderCache(),this.highlighter=void 0,this.workerManager?.cleanUpTasks(this),this.lineCache=void 0}clearRenderCache(){const i=this.renderCache;this.renderCache=void 0,i!=null&&i.isDirty===!0&&i.file.cacheKey!=null&&this.workerManager?.evictFileFromCache(i.file.cacheKey)}hydrate(i){const{options:e}=this.getRenderOptions(i),t=$(this.getOrCreateLineCache(i).length,this.getTokenizeMaxLength());let n=this.workerManager?.getFileResultCache(i);n!=null&&!F(e,n.options)&&(n=void 0),this.renderCache??={file:i,options:e,highlighted:!t&&!q(i),result:t?void 0:n?.result,renderRange:void 0},this.workerManager?.isWorkingPool()===!0?this.renderCache.result==null&&!t&&this.workerManager.highlightFileAST(this,i):this.highlighter==null&&(this.computedLang=i.lang??j(i.name),this.initializeHighlighter())}getRenderOptions(i){const e=(()=>{if(this.workerManager?.isWorkingPool()===!0)return this.workerManager.getFileRenderOptions();const{theme:n=H,tokenizeMaxLineLength:r=1e3}=this.options;return{theme:n,useTokenTransformer:Pe(this.options),tokenizeMaxLineLength:r}})(),{renderCache:t}=this;return t?.result==null?{options:e,forceHighlight:!0}:!M(i,t.file)||!F(e,t.options)?{options:e,forceHighlight:!0}:{options:e,forceHighlight:!1}}getOrCreateLineCache(i){if(i.cacheKey==null)return this.lineCache=void 0,pe(i.contents);let{lineCache:e}=this;return(e==null||e.cacheKey!==i.cacheKey)&&(e={cacheKey:i.cacheKey,lines:pe(i.contents)}),this.lineCache=e,e.lines}getLineCount(i){return this.textDoucmentCache.get(i)?.lineCount??this.getOrCreateLineCache(i).length}updateRenderCache(i,e){if(this.renderCache==null)return;const{result:t}=this.renderCache;if(t!=null){for(const[n,r]of i)t.code[n]={type:"element",tagName:"div",properties:{"data-line":n+1,"data-line-type":"context","data-line-index":n},children:r.map(([s,a,o])=>s===0&&a===""?o===""?{type:"element",tagName:"br",properties:{},children:[]}:{type:"text",value:o}:{type:"element",tagName:"span",properties:{"data-char":s,style:`--diffs-token-${e}:${a};`},children:[{type:"text",value:o}]})};t.baseThemeType=e,this.renderCache.isDirty=!0}}applyDocumentChange(i){if(this.renderCache==null)return;const{file:e,result:t}=this.renderCache;if(t!=null&&t.code.length!==i.lineCount){t.code.length=Math.min(t.code.length,i.lineCount);for(let n=t.code.length;n<i.lineCount;n++)t.code.push({type:"element",tagName:"div",properties:{"data-line":n+1,"data-line-type":"context","data-line-index":n},children:[{type:"element",tagName:"span",properties:{"data-char":0},children:[{type:"text",value:i.getLineText(n)}]}]});this.renderCache.isDirty=!0}this.textDoucmentCache.set(e,i)}renderFile(i=this.renderCache?.file,e=Z){if(i==null)return;let{options:t,forceHighlight:n}=this.getRenderOptions(i);const r=this.getMatchingWorkerResultCache(i,t);r!=null&&!this.hasHighlightedRenderCache(i,t)&&(this.renderCache={file:i,highlighted:!0,renderRange:void 0,...r},n=!1),this.renderCache??={file:i,highlighted:!1,options:t,result:void 0,renderRange:void 0};const s=this.getOrCreateLineCache(i),a=i.contents.length>0,o=!a||q(i)||$(s.length,this.getTokenizeMaxLength()),h=!M(i,this.renderCache.file),d=!Se(this.renderCache.renderRange,e);if(this.workerManager?.isWorkingPool()===!0)(o||this.renderCache.result==null||!this.renderCache.highlighted&&(h||d))&&(this.renderCache.file=i,this.renderCache.options=t,this.renderCache.highlighted=!1,(this.renderCache.result==null||h||d||n)&&(this.renderCache.result=this.workerManager.getPlainFileAST(i,e.startingLine,e.totalLines,s)),this.renderCache.renderRange=e),!o&&a&&(!this.renderCache.highlighted||n)&&this.workerManager.highlightFileAST(this,i);else{this.computedLang=i.lang??j(i.name);const l=this.highlighter!=null&&ie(t.theme),c=this.highlighter!=null&&ne(this.computedLang),u=!o&&c;if(this.highlighter!=null&&l&&(n||o||!this.renderCache.highlighted&&u||this.renderCache.result==null)){const{result:p,options:f}=this.renderFileWithHighlighter(i,this.highlighter,o||!c);this.renderCache={file:i,options:f,highlighted:u,result:p,renderRange:void 0}}(!l||!o&&!c)&&this.asyncHighlight(i).then(({result:p,options:f})=>{this.renderCache!=null&&(this.renderCache.highlighted=!1),this.onHighlightSuccess(i,p,f,!o)})}return this.renderCache.result!=null?this.processFileResult(this.renderCache.file,e,this.renderCache.result):void 0}async asyncRender(i,e=Z){const{result:t}=await this.asyncHighlight(i);return this.processFileResult(i,e,t)}async asyncHighlight(i){const e=$(this.getOrCreateLineCache(i).length,this.getTokenizeMaxLength());this.computedLang=e?"text":i.lang??j(i.name);const t=this.highlighter!=null&&Ct(ft(this.options.theme)),n=e||this.highlighter!=null&&ne(this.computedLang);return(this.highlighter==null||!t||!n)&&(this.highlighter=await this.initializeHighlighter()),this.renderFileWithHighlighter(i,this.highlighter,e)}renderFileWithHighlighter(i,e,t=!1){const{options:n}=this.getRenderOptions(i);return{result:St(i,e,n,{forcePlainText:t}),options:n}}processFileResult(i,e,{code:t,themeStyles:n,baseThemeType:r}){const s=this.getLineCount(i),{disableFileHeader:a=!1}=this.options,o=[],h=ue(),d=Math.min(e.startingLine+e.totalLines,s);let l=0;const c=ve(e)?Be(this.lineAnnotations):void 0;c!=null&&(h.children.push(de("context","annotation",1)),o.push(re({hunkIndex:-1,lineIndex:-1,annotations:c.map(u=>I(u))})),l++);for(let u=e.startingLine;u<d;u++){const p=u+1,f=t[u];if(f==null){const g="FileRenderer.processFileResult: Line doesnt exist";throw console.error(g,{name:i.name,lineIndex:u,lineNumber:p}),new Error(g)}h.children.push(pt("context",p,`${u}`)),o.push(f),l++;const S=this.lineAnnotations[p];S!=null&&(h.children.push(de("context","annotation",1)),o.push(re({hunkIndex:0,lineIndex:p,annotations:S.map(g=>I(g))})),l++)}return h.properties.style=`grid-row: span ${l}`,{gutterAST:h.children??[],contentAST:o,preAST:this.createPreElement(s),headerAST:a?void 0:this.renderHeader(i),totalLines:s,rowCount:l,themeStyles:n,baseThemeType:r,bufferBefore:e.bufferBefore,bufferAfter:e.bufferAfter,css:""}}renderHeader(i){const{headerRenderMode:e="default",stickyHeader:t=!1}=this.options;return De({fileOrDiff:i,mode:e,stickyHeader:t})}renderFullHTML(i){return A(this.renderFullAST(i))}renderFullAST(i,e=[]){return e.push(ce({tagName:"code",children:this.renderCodeAST(i),properties:{"data-code":""}})),{...i.preAST,children:e}}renderCodeAST(i){const e=ue();return e.children=i.gutterAST,e.properties.style=`grid-row: span ${i.rowCount}`,[e,Ue(i.contentAST,i.rowCount)]}renderPartialHTML(i,e=!1){return e?A(ce({tagName:"code",children:i,properties:{"data-code":""}})):A(i)}async initializeHighlighter(){return this.highlighter=await gt(_e(this.computedLang,this.options)),this.highlighter}onHighlightSuccess(i,e,t,n=!0){if(this.renderCache==null)return;const r=!M(i,this.renderCache.file)||!this.renderCache.highlighted||!F(t,this.renderCache.options);this.renderCache={file:i,options:t,highlighted:n,result:e,renderRange:void 0},r&&this.onRenderUpdate?.()}getMatchingWorkerResultCache(i,e){const t=this.workerManager?.getFileResultCache(i);if(!(t==null||!F(e,t.options)))return t}hasHighlightedRenderCache(i,e){const{renderCache:t}=this;return t?.result!=null&&t.highlighted&&M(i,t.file)&&F(e,t.options)}onHighlightError(i){console.error(i)}getTokenizeMaxLength(){return this.options.tokenizeMaxLength??1e5}createPreElement(i){const{disableLineNumbers:e=!1,overflow:t="scroll"}=this.options;return We({type:"file",diffIndicators:"none",disableBackground:!0,disableLineNumbers:e,overflow:t,split:!1,totalLines:i})}};function $(i,e){return i>e}function Tt(i,e){return i.lineNumber===e.lineNumber&&i.metadata===e.metadata}function ge(i){return{theme:i?.theme,disableLineNumbers:i?.disableLineNumbers,overflow:i?.overflow,themeType:i?.themeType,collapsed:i?.collapsed,disableFileHeader:i?.disableFileHeader,disableVirtualizationBuffers:i?.disableVirtualizationBuffers,stickyHeader:i?.stickyHeader,preferredHighlighter:i?.preferredHighlighter,useCSSClasses:i?.useCSSClasses,useTokenTransformer:i?.useTokenTransformer,tokenizeMaxLineLength:i?.tokenizeMaxLineLength,tokenizeMaxLength:i?.tokenizeMaxLength,unsafeCSS:i?.unsafeCSS,headerRenderMode:i?.renderCustomHeader!=null?"custom":"default"}}const bt=[""];let Rt=-1;var Te=class{options;workerManager;isContainerManaged;static LoadedCustomComponent=!0;__id=`file:${++Rt}`;type="file";fileContainer;spriteSVG;pre;code;bufferBefore;bufferAfter;themeCSSStyle;appliedThemeCSS;hasAdoptedThemeCSS=!1;unsafeCSSStyle;appliedUnsafeCSS;gutterUtilityContent;errorWrapper;placeHolder;lastRenderedHeaderHTML;cachedHeaderHTML;appliedPreAttributes;lastRowCount;mounted=!1;headerElement;headerCustom;headerPrefix;headerFilenameSuffix;headerMetadata;fileRenderer;resizeManager;interactionManager;annotationCache=new Map;lineAnnotations=[];managersDirty=!1;file;renderRange;enabled=!0;editor;constructor(e={theme:H},t,n=!1){this.options=e,this.workerManager=t,this.isContainerManaged=n,this.fileRenderer=new yt(e,this.handleHighlightRender,this.workerManager),this.resizeManager=new Ge,this.interactionManager=new je("file",se(e)),this.workerManager?.subscribeToThemeChanges(this)}handleHighlightRender=()=>{this.rerender()};rerender(){!this.enabled||this.file==null||this.render({file:this.file,forceRender:!0,renderRange:this.renderRange})}onThemeChange(){this.fileRenderer.clearRenderCache(),this.rerender()}setOptions(e){e!=null&&(this.options=e,this.cachedHeaderHTML=void 0,this.syncInteractionOptions())}syncInteractionOptions(){this.interactionManager.setOptions(se(this.options))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){(this.options.themeType??"system")!==e&&(this.mergeOptions({themeType:e}),this.applyCachedThemeState(e))}applyCachedThemeState(e){if(typeof this.options.theme=="string"||this.fileContainer==null||this.appliedThemeCSS==null)return!1;const t=this.appliedThemeCSS.baseThemeType??e;return this.appliedThemeCSS.themeType===t?!1:(this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,e,this.appliedThemeCSS.baseThemeType),!0)}hasThemeChanged(){return this.appliedThemeCSS!=null&&!mt(this.appliedThemeCSS.theme,this.options.theme??H)}getHoveredLine=()=>this.interactionManager.getHoveredLine();setLineAnnotations(e){this.lineAnnotations=e}setSelectedLines(e,t){this.interactionManager.setSelection(e,t)}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}const{overflow:e="scroll"}=this.options;this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,e==="wrap"),this.managersDirty=!1}cleanUp(e=!1){this.emitPostRender(!0),this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.managersDirty=!1,this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,this.isContainerManaged||this.fileContainer?.remove(),this.fileContainer=void 0,this.mounted=!1,e||(this.lineAnnotations=[]),this.annotationCache.clear(),this.pre=void 0,this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.lastRenderedHeaderHTML=void 0,e||(this.cachedHeaderHTML=void 0),this.errorWrapper=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.placeHolder=void 0,this.unsafeCSSStyle=void 0,e?this.fileRenderer.recycle():(this.fileRenderer.cleanUp(),this.workerManager=void 0,this.file=void 0),this.enabled=!1,this.editor?.cleanUp(),this.editor=void 0}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate(e){const{fileContainer:t,prerenderedHTML:n,preventEmit:r=!1,file:s,lineAnnotations:a}=e;this.hydrateElements(t,n),Lt(this.pre,s,this.options.collapsed)||Mt(this.headerElement,s,this.options.disableFileHeader)?this.render({...e,preventEmit:!0}):this.hydrationSetup({file:s,lineAnnotations:a}),r||this.emitPostRender()}hydrateElements(e,t){this.fileContainer!==e&&this.emitPostRender(!0),$e(e,t);for(const n of Array.from(e.shadowRoot?.children??[])){if(n instanceof SVGElement){this.spriteSVG=n;continue}if(n instanceof HTMLElement){if(n instanceof HTMLPreElement){this.pre=n,this.appliedPreAttributes=void 0;continue}if(n instanceof HTMLStyleElement&&n.hasAttribute("data-theme-css")){this.themeCSSStyle=n;continue}if(n instanceof HTMLStyleElement&&n.hasAttribute("data-unsafe-css")){this.unsafeCSSStyle=n,this.appliedUnsafeCSS=n.textContent;continue}if("diffsHeader"in n.dataset){this.headerElement=n,this.lastRenderedHeaderHTML=void 0;continue}}}this.pre!=null&&(this.syncCodeNodeFromPre(this.pre),this.pre.removeAttribute("data-dehydrated")),this.fileContainer=e,this.hydrateMeasuredScrollbar()}hydrationSetup({file:e,lineAnnotations:t}){this.lineAnnotations=t??this.lineAnnotations,this.file=e,this.fileRenderer.setOptions(ge(this.options)),this.syncInteractionOptions(),this.pre!=null&&(this.fileRenderer.hydrate(e),this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.managersDirty=!0,this.flushManagers())}getOrCreateLineCache(e=this.file){return e!=null?this.fileRenderer.getOrCreateLineCache(e):bt}updateBuffers(e){this.pre!=null&&this.applyBuffers(this.pre,e)}syncRenderViewToEditor(){const e=this.editor,t=this.fileContainer,n=this.file;e!=null&&t!=null&&n!=null&&this.fileRenderer.initializeHighlighter().then(r=>{e.__syncRenderView(r,t,n,this.lineAnnotations,this.renderRange)})}attachEditor(e){return this.editor?.cleanUp(),this.editor=e,this.interactionManager.setEditorAttached(!0),this.syncRenderViewToEditor(),()=>{this.editor=void 0,this.interactionManager.setEditorAttached(!1)}}applyDocumentChange(e,t){this.fileRenderer.applyDocumentChange(e),t!=null&&t!==this.lineAnnotations&&this.file!=null&&(this.setLineAnnotations(t),this.fileRenderer.setLineAnnotations(this.lineAnnotations),this.renderAnnotations())}updateRenderCache(e,t){this.fileRenderer.updateRenderCache(e,t)}render({file:e,fileContainer:t,forceRender:n=!1,preventEmit:r=!1,containerWrapper:s,deferManagers:a=!1,lineAnnotations:o,renderRange:h}){if(!this.enabled)throw new Error("File.render: attempting to call render after cleaned up");this.editor?.__postponeBackgroundTokenizeToNextFrame();const{collapsed:d=!1,themeType:l="system"}=this.options,c=d?void 0:h,u=this.renderRange,p=this.hasThemeChanged(),f=o!=null&&(o.length>0||this.lineAnnotations.length>0)?o!==this.lineAnnotations:!1,S=!M(this.file,e);if(!d&&!n&&Se(c,this.renderRange)&&!S&&!f&&!p)return this.applyCachedThemeState(l);this.renderRange=c,S&&(this.cachedHeaderHTML=void 0),this.file=e,this.fileRenderer.setOptions(ge(this.options)),this.syncInteractionOptions(),o!=null&&this.setLineAnnotations(o),this.fileRenderer.setLineAnnotations(this.lineAnnotations);const{disableErrorHandling:g=!1,disableFileHeader:y=!1}=this.options;if(y&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0),this.clearHeaderSlots()),t=this.getOrCreateFileContainerNode(t,s),this.applyCachedThemeState(l),d){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{const m=this.fileRenderer.renderFile(e,Fe);m!=null&&this.applyThemeState(t,m.themeStyles,l,m.baseThemeType),m?.headerAST!=null&&this.applyHeaderToDOM(m.headerAST,t),this.injectUnsafeCSS()}catch(m){if(g)throw m;console.error(m),m instanceof Error&&this.applyErrorToDOM(m,t)}return r||this.emitPostRender(),!0}try{const m=this.getOrCreatePreNode(t);if(!this.canPartiallyRender(n,f,S||p)||!this.applyPartialRender(u,c)){const v=this.fileRenderer.renderFile(e,c);if(v==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.initialize().then(()=>this.rerender()),!1;this.applyThemeState(t,v.themeStyles,l,v.baseThemeType),v.headerAST!=null&&this.applyHeaderToDOM(v.headerAST,t),this.applyFullRender(v,m)}this.applyBuffers(m,c),this.injectUnsafeCSS(),this.managersDirty=!0,a||this.flushManagers(),this.renderAnnotations(),this.renderGutterUtility(),this.editor!=null&&this.syncRenderViewToEditor()}catch(m){if(g)throw m;console.error(m),m instanceof Error&&this.applyErrorToDOM(m,t)}return r||this.emitPostRender(),!0}emitPostRender(e=!1){const{fileContainer:t,options:{onPostRender:n}}=this;if(e){if(!this.mounted||(this.mounted=!1,t==null))return;n?.(t,this,"unmount");return}if(t==null)return;const r=this.mounted?"update":"mount";this.mounted=!0,n?.(t,this,r)}removeRenderedCode(){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.code?.remove(),this.code=void 0,this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){for(const{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}canPartiallyRender(e,t,n){return!(e||t||n)}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){const t=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:"open"});this.placeHolder=document.createElement("div"),this.placeHolder.dataset.placeholder="",t.appendChild(this.placeHolder)}return this.placeHolder.style.setProperty("height",`${e}px`),!0}primeHighlightCache(){const{file:e,workerManager:t}=this;e==null||e.cacheKey==null||t==null||q(e)||this.fileRenderer.getOrCreateLineCache(e).length>(this.options.tokenizeMaxLength??1e5)||t.primeFileHighlightCache(e)}cleanChildNodes(){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.code?.remove(),this.errorWrapper?.remove(),this.headerElement?.remove(),this.gutterUtilityContent?.remove(),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.pre?.remove(),this.spriteSVG?.remove(),this.themeCSSStyle?.remove(),this.unsafeCSSStyle?.remove(),this.bufferAfter=void 0,this.bufferBefore=void 0,this.code=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.gutterUtilityContent=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.pre=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.lastRenderedHeaderHTML=void 0,this.lastRowCount=void 0,this.mounted=!1}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(const{element:n}of this.annotationCache.values())n.remove();this.annotationCache.clear();return}const e=new Map(this.annotationCache),{renderAnnotation:t}=this.options;if(t!=null&&this.lineAnnotations.length>0)for(const[n,r]of this.lineAnnotations.entries()){const s=`${n}-${I(r)}`;let a=this.annotationCache.get(s);if(a==null||!Tt(r,a.annotation)){a?.element.remove();const o=t(r);if(o==null)continue;a={element:Ke(I(r)),annotation:r},a.element.appendChild(o),this.fileContainer.appendChild(a.element),this.annotationCache.set(s,a)}e.delete(s)}for(const[n,{element:r}]of e.entries())this.annotationCache.delete(n),r.remove()}renderGutterUtility(){const{renderGutterUtility:e}=this.options;if(this.fileContainer==null||e==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}const t=e(this.interactionManager.getHoveredLine);if(t!=null&&this.gutterUtilityContent!=null)return;if(t==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}const n=qe();n.appendChild(t),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}injectUnsafeCSS(){const{unsafeCSS:e}=this.options,t=this.fileContainer?.shadowRoot;if(t!=null){if(e==null||e===""){this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0;return}this.unsafeCSSStyle?.parentNode===t&&this.appliedUnsafeCSS===e||(this.unsafeCSSStyle??=Je(),this.unsafeCSSStyle.parentNode!==t&&t.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=Ye(e),this.appliedUnsafeCSS=e)}}applyThemeState(e,t,n,r){const s=e.shadowRoot??e.attachShadow({mode:"open"}),a=r??n,o=this.options.theme??H,h=typeof o=="string"?o:{...o},d=ae(s);if(this.themeCSSStyle?.parentNode===s&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===a&&this.appliedThemeCSS.scrollbarGutter===d){this.appliedThemeCSS.theme=h;return}if(this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===s){this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:h,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:d};return}this.themeCSSStyle=Xe({shadowRoot:s,currentNode:this.themeCSSStyle,themeCSS:Qe(t,a,d)}),this.appliedThemeCSS=this.themeCSSStyle!=null?{theme:h,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:d}:void 0}hydrateMeasuredScrollbar(){const e=this.fileContainer?.shadowRoot;e==null||this.themeCSSStyle==null||(this.themeCSSStyle.textContent=Ze(this.themeCSSStyle.textContent??"",ae(e)))}applyFullRender(e,t){this.cleanupErrorWrapper(),this.applyPreNodeAttributes(t,e),this.code=et({code:this.code});const n=this.fileRenderer.renderCodeAST(e);if(this.code.childElementCount>=2)for(let r=0;r<2;r++){const s=this.code.children[r],a=n[r];s.innerHTML=A(a.children),s.style.cssText=a.properties.style}else this.code.innerHTML=A(n);t.contains(this.code)||t.replaceChildren(this.code),this.lastRowCount=e.rowCount}applyPartialRender(e,t){if(e==null||t==null)return!1;const{file:n,code:r}=this,s=r!=null?this.getColumns(r):void 0;if(n==null||r==null||s==null)return!1;const a=e.startingLine,o=t.startingLine,h=e.totalLines===1/0?Number.POSITIVE_INFINITY:a+e.totalLines,d=t.totalLines===1/0?Number.POSITIVE_INFINITY:o+t.totalLines,l=Math.max(a,o),c=Math.min(h,d);if(c<=l||!this.trimDOMToOverlap(s.gutter,l,c)||!this.trimDOMToOverlap(s.content,l,c))return!1;let{length:u}=s.content.children;const p=(y,m)=>{if(!(m<=0))return this.fileRenderer.renderFile(n,{startingLine:y,totalLines:m,bufferBefore:0,bufferAfter:0})},f=o<l?p(o,l-o):void 0;if(f===void 0&&o<l)return!1;const S=d===Number.POSITIVE_INFINITY?Number.POSITIVE_INFINITY:Math.max(0,d-c),g=d>c?p(c,S):void 0;return g===void 0&&d>c?!1:(this.cleanupErrorWrapper(),f!=null&&(s.gutter.insertAdjacentHTML("afterbegin",this.fileRenderer.renderPartialHTML(f.gutterAST)),s.content.insertAdjacentHTML("afterbegin",this.fileRenderer.renderPartialHTML(f.contentAST)),u+=f.rowCount),g!=null&&(s.gutter.insertAdjacentHTML("beforeend",this.fileRenderer.renderPartialHTML(g.gutterAST)),s.content.insertAdjacentHTML("beforeend",this.fileRenderer.renderPartialHTML(g.contentAST)),u+=g.rowCount),this.lastRowCount!==u&&(s.gutter.style.setProperty("grid-row",`span ${u}`),s.content.style.setProperty("grid-row",`span ${u}`),this.lastRowCount=u),!0)}getColumns(e){const t=e.children[0],n=e.children[1];if(!(!(t instanceof HTMLElement)||!(n instanceof HTMLElement)||t.dataset.gutter==null||n.dataset.content==null))return{gutter:t,content:n}}trimDOMToOverlap(e,t,n){const r=this.getDOMBoundaryIndices(e,[t,n]),s=r.get(t)??e.children.length,a=r.get(n)??e.children.length;if(s>a)return!1;for(let o=e.children.length-1;o>=a;o-=1)e.children[o]?.remove();for(let o=s-1;o>=0;o-=1)e.children[o]?.remove();return!0}getDOMBoundaryIndices(e,t){const n=[...new Set(t)].sort((h,d)=>h-d),r=new Map;if(n.length===0)return r;let s=0,a=n[s];const{children:o}=e;a===0&&(r.set(0,0),s+=1,a=n[s]);for(let h=0;h<o.length;h+=1){const d=o[h];if(!(d instanceof HTMLElement))continue;const l=this.getLineIndexFromDOMNode(d);if(l!=null){for(;a!=null&&l>=a;)r.set(a,h),s+=1,a=n[s];if(s>=n.length)break}}for(const h of n)r.has(h)||r.set(h,o.length);return r}getLineIndexFromDOMNode(e){const t=e.dataset.lineIndex;if(t==null)return;const n=Number(t);return Number.isNaN(n)?void 0:n}applyBuffers(e,t){if(t==null||this.shouldDisableVirtualizationBuffers()){this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0);return}t.bufferBefore>0?(this.bufferBefore==null&&(this.bufferBefore=document.createElement("div"),this.bufferBefore.dataset.virtualizerBuffer="before",e.before(this.bufferBefore)),this.bufferBefore.style.setProperty("height",`${t.bufferBefore}px`),this.bufferBefore.style.setProperty("contain","strict")):this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),t.bufferAfter>0?(this.bufferAfter==null&&(this.bufferAfter=document.createElement("div"),this.bufferAfter.dataset.virtualizerBuffer="after",e.after(this.bufferAfter)),this.bufferAfter.style.setProperty("height",`${t.bufferAfter}px`),this.bufferAfter.style.setProperty("contain","strict")):this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0)}shouldDisableVirtualizationBuffers(){return this.options.disableVirtualizationBuffers??!1}applyHeaderToDOM(e,t){const{file:n}=this;if(n==null)return;this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;const r=this.cachedHeaderHTML??A(e);if(this.cachedHeaderHTML=r,r!==this.lastRenderedHeaderHTML){const d=document.createElement("div");d.innerHTML=r;const l=d.firstElementChild;if(!(l instanceof HTMLElement))return;this.headerElement!=null?t.shadowRoot?.replaceChild(l,this.headerElement):t.shadowRoot?.prepend(l),this.headerElement=l,this.lastRenderedHeaderHTML=r}if(this.isContainerManaged)return;const{renderHeaderPrefix:s,renderHeaderFilenameSuffix:a,renderCustomHeader:o,renderHeaderMetadata:h}=this.options;if(o!=null){const d=o(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,Ce,d),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0}else{const d=s?.(n)??void 0,l=a?.(n)??void 0,c=h?.(n)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,ke,d),this.headerFilenameSuffix=this.upsertHeaderSlotElement(t,this.headerFilenameSuffix,Ie,l),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,ze,c),this.headerCustom?.remove(),this.headerCustom=void 0}}clearHeaderSlots(){this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0}upsertHeaderSlotElement(e,t,n,r){if(r==null){t?.remove();return}const s=t??this.createHeaderSlotElement(n);return t==null&&e.appendChild(s),this.replaceHeaderSlotContent(s,r),s}replaceHeaderSlotContent(e,t){e.replaceChildren(),t instanceof Element?e.appendChild(t):e.innerText=`${t}`}createHeaderSlotElement(e){const t=document.createElement("div");return t.slot=e,t}getOrCreateFileContainerNode(e,t){const{fileContainer:n}=this,r=e??n??document.createElement("diffs-container"),s=n!==r;return s&&this.emitPostRender(!0),this.fileContainer=r,n!=null&&s&&(this.lastRenderedHeaderHTML=void 0,this.headerElement=void 0),t!=null&&this.fileContainer.parentNode!==t&&t.appendChild(this.fileContainer),s&&this.adoptReusableShellElements(this.fileContainer),this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(e){const{shadowRoot:t}=e;if(t!=null)for(const n of t.children)n instanceof SVGElement?this.spriteSVG??=n:oe(n)&&n.hasAttribute("data-theme-css")?(this.themeCSSStyle??=n,this.hasAdoptedThemeCSS=!0):oe(n)&&n.hasAttribute("data-unsafe-css")&&(this.unsafeCSSStyle??=n,this.appliedUnsafeCSS??=this.options.unsafeCSS??void 0)}ensureSpriteSVG(e){const t=e.shadowRoot??e.attachShadow({mode:"open"});if(this.spriteSVG==null){const n=document.createElement("div");n.innerHTML=tt;const r=n.firstChild;r instanceof SVGElement&&(this.spriteSVG=r)}this.spriteSVG!=null&&this.spriteSVG.parentNode!==t&&t.appendChild(this.spriteSVG)}getOrCreatePreNode(e){const t=e.shadowRoot??e.attachShadow({mode:"open"});return this.pre==null?(this.pre=document.createElement("pre"),this.appliedPreAttributes=void 0,this.code=void 0,t.appendChild(this.pre)):this.pre.parentNode!==t&&(e.shadowRoot?.appendChild(this.pre),this.appliedPreAttributes=void 0),this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodeFromPre(e){this.code=void 0;for(const t of Array.from(e.children))if(t instanceof HTMLElement&&t.hasAttribute("data-code")){this.code=t;return}}applyPreNodeAttributes(e,{totalLines:t}){const{overflow:n="scroll",disableLineNumbers:r=!1}=this.options,s={type:"file",split:!1,overflow:n,disableLineNumbers:r,diffIndicators:"none",disableBackground:!0,totalLines:t};it(s,this.appliedPreAttributes)||(nt(e,s),this.appliedPreAttributes=s)}applyErrorToDOM(e,t){this.cleanupErrorWrapper(),this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;const n=t.shadowRoot??t.attachShadow({mode:"open"});this.errorWrapper??=document.createElement("div"),this.errorWrapper.dataset.errorWrapper="",this.errorWrapper.textContent="",n.appendChild(this.errorWrapper);const r=document.createElement("div");r.dataset.errorMessage="",r.innerText=e.message,this.errorWrapper.appendChild(r);const s=document.createElement("pre");s.dataset.errorStack="",s.innerText=e.stack??"No Error Stack",this.errorWrapper.appendChild(s)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}};function Lt(i,e,t=!1){return!t&&i==null&&e!=null}function Mt(i,e,t=!1){return i==null&&e!=null&&!t}const Ht=5e3;let At=-1;function xt(i,e){return(i.overflow??"scroll")!==(e.overflow??"scroll")||(i.collapsed??!1)!==(e.collapsed??!1)||(i.disableLineNumbers??!1)!==(e.disableLineNumbers??!1)||(i.disableFileHeader??!1)!==(e.disableFileHeader??!1)||i.unsafeCSS!==e.unsafeCSS}var wt=class extends Te{virtualizer;metrics;__id=`virtualized-file:${++At}`;top;height=0;cache={heights:new Map,checkpoints:[],fileAnnotationHeight:0};isVisible=!1;isSetup=!1;layoutDirty=!0;forceRenderOverride;currentCollapsed;constructor(i,e,t=Ne,n,r=!1){super(i,n,r),this.virtualizer=e,this.metrics=t}setMetrics(i,e=!1){!e&&rt(this.metrics,i)||(this.metrics=i,this.resetLayoutCache())}setLineAnnotations(i){this.syncLineAnnotations(i)&&this.resetLayoutCache()}syncLineAnnotations(i){return i==null||i===this.lineAnnotations||i.length===0&&this.lineAnnotations.length===0?!1:(super.setLineAnnotations(i),!0)}hasLineAnnotations(){return this.lineAnnotations.some(i=>i.lineNumber>0)}getLineHeight(i,e=!1){const t=this.cache.heights.get(i);if(t!=null)return t;const n=e?2:1;return this.metrics.lineHeight*n}setOptions(i){if(this.isAdvancedMode())throw new Error("VirtualizedFile.setOptions cannot be used inside CodeView. Update CodeView options instead.");if(i==null)return;const{options:e}=this,t=!ye(e,i),n=xt(e,i);super.setOptions(i),n&&this.resetLayoutCache(!0),t&&(this.forceRenderOverride=!0),t&&this.virtualizer.instanceChanged(this,n)}setThemeType(i){if(this.isAdvancedMode())throw new Error("VirtualizedFile.setThemeType cannot be used inside CodeView. Update CodeView options instead.");super.setThemeType(i)}resetLayoutCache(i=!1){this.layoutDirty=!0,this.cache.fileAnnotationHeight=0,this.cache.heights.size>0&&this.cache.heights.clear(),this.cache.checkpoints.length>0&&(this.cache.checkpoints.length=0),this.renderRange!=null&&(this.renderRange=void 0),i&&this.isSimpleMode()&&this.computeApproximateSize()}reconcileHeights(){let i=!1;if(this.fileContainer==null||this.file==null)return this.height!==0&&(i=!0),this.height=0,i;const{overflow:e="scroll"}=this.options;if(this.top=this.getVirtualizedTop(),e==="scroll"&&this.lineAnnotations.length===0&&!this.isResizeDebuggingEnabled()||this.code==null)return i;const t=this.code.children[1];if(!(t instanceof HTMLElement))return i;const n=he(this.lineAnnotations);if(this.renderRange!=null&&n&&ve(this.renderRange)){const r=Et(t)??0;r!==this.cache.fileAnnotationHeight&&(this.cache.fileAnnotationHeight=r,i=!0)}else!n&&this.cache.fileAnnotationHeight!==0&&(this.cache.fileAnnotationHeight=0,i=!0);for(const r of t.children){if(!(r instanceof HTMLElement))continue;const s=r.dataset.lineIndex;if(s==null)continue;const a=Number(s);let o=r.getBoundingClientRect().height,h=!1;r.nextElementSibling instanceof HTMLElement&&("lineAnnotation"in r.nextElementSibling.dataset||"noNewline"in r.nextElementSibling.dataset)&&("noNewline"in r.nextElementSibling.dataset&&(h=!0),o+=r.nextElementSibling.getBoundingClientRect().height);const d=this.getLineHeight(a,h);o!==d&&(i=!0,o===this.metrics.lineHeight*(h?2:1)?this.cache.heights.delete(a):this.cache.heights.set(a,o))}return(i||this.isResizeDebuggingEnabled())&&this.computeApproximateSize(!0),i}onRender=i=>this.fileContainer==null||this.file==null?!1:(i&&(this.top=this.getVirtualizedTop()),this.render({file:this.file}));prepareCodeViewItem(i,e,t,n){const r=this.syncLineAnnotations(n);let s=t?.resetFileLayoutCache===!0||r;t?.metrics!=null&&(this.metrics=t.metrics,s=!0);const{collapsed:a=!1}=this.options;return this.currentCollapsed!==a&&(this.currentCollapsed=a,s=!0),s&&this.resetLayoutCache(),this.file!==i&&(this.layoutDirty=!0),this.file=i,this.top=e,this.computeApproximateSize(),this.height}getLinePosition(i){if(this.file==null||i<1)return;const{disableFileHeader:e=!1,collapsed:t=!1}=this.options,n=this.fileRenderer.getLineCount(this.file)-1;let r=B(this.metrics,e);if(t||n<0)return{top:r,height:0};const s=Math.min(Math.max(i-1,0),n),{overflow:a="scroll"}=this.options,{lineHeight:o}=this.metrics;if(r+=this.cache.fileAnnotationHeight,a==="scroll"&&!this.hasLineAnnotations())return{top:r+s*o,height:o};const h=this.getLayoutCheckpointBeforeLineIndex(s);r=h?.top??r;for(let d=h?.lineIndex??0;d<s;d++)r+=this.getLineHeight(d,!1);return{top:r,height:this.getLineHeight(s,!1)}}getNumericScrollAnchor(i){if(this.file==null||this.renderRange==null)return;const{disableFileHeader:e=!1,collapsed:t=!1,overflow:n="scroll"}=this.options;if(t||this.renderRange.totalLines<=0)return;const r=this.fileRenderer.getLineCount(this.file)-1;if(r<0)return;const s=B(this.metrics,e),a=Math.min(this.renderRange.startingLine,r),o=Math.min(a+this.renderRange.totalLines-1,r);if(o<a)return;const{fileAnnotationHeight:h}=this.cache;if(n==="scroll"&&!this.hasLineAnnotations()){const{lineHeight:l}=this.metrics,c=s+(a===0?h:this.renderRange.bufferBefore),u=a+Math.max(Math.ceil((i-c)/l),0);return u>o?void 0:{lineNumber:u+1,top:s+h+u*l}}let d=s+(a===0?h:this.renderRange.bufferBefore);for(let l=a;l<=o;l++){if(d>=i)return{lineNumber:l+1,top:d};d+=this.getLineHeight(l)}}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(i){if(this.top==null||this.file==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};const e=i!=null?this.computeRenderRangeFromWindow(this.file,this.top,i):this.renderRange;if(e==null)return;const{bufferBefore:t,bufferAfter:n,totalLines:r}=e;let s=0;if(r===0){const a=i??this.virtualizer.getWindowSpecs();this.top<a.top&&(s=n)}return{topOffset:this.top+t+s,height:this.height-(t+n)}}cleanUp(i=!1){this.fileContainer!=null&&this.isSimpleMode()&&this.getSimpleVirtualizer()?.disconnect(this.fileContainer),i||this.resetLayoutCache(),this.isSetup=!1,super.cleanUp(i)}computeApproximateSize(i=!1){const e=this.isResizeDebuggingEnabled();if(!i&&!this.layoutDirty&&!e)return;const t=this.height===0;if(this.height=0,this.cache.checkpoints=[],this.file==null){this.layoutDirty=!1;return}const{disableFileHeader:n=!1,collapsed:r=!1,overflow:s="scroll"}=this.options,{lineHeight:a}=this.metrics,o=this.fileRenderer.getLineCount(this.file),h=B(this.metrics,n),d=fe(this.metrics);if(this.height+=h,r){this.layoutDirty=!1;return}if(this.height+=this.cache.fileAnnotationHeight,s==="scroll"&&!this.hasLineAnnotations())this.height+=o*a;else for(let l=0;l<o;l++)this.addLayoutCheckpoint(l,this.height),this.height+=this.getLineHeight(l,!1);if(o>0&&(this.height+=d),this.fileContainer!=null&&e&&!t){const l=this.fileContainer.getBoundingClientRect();l.height!==this.height?console.log("VirtualizedFile.computeApproximateSize: computed height doesnt match",{name:this.file.name,elementHeight:l.height,computedHeight:this.height}):console.log("VirtualizedFile.computeApproximateSize: computed height IS CORRECT")}this.layoutDirty=!1}setVisibility(i){this.isAdvancedMode()||this.fileContainer==null||(i&&!this.isVisible?(this.top=this.getVirtualizedTop(),this.isVisible=!0):!i&&this.isVisible&&(this.isVisible=!1,this.rerender()))}rerender(){!this.enabled||this.file==null||(this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!1))}applyDocumentChange(i,e,t=!1){const{heights:n,checkpoints:r}=this.cache,s=this.renderRange;if(super.applyDocumentChange(i,e),this.getSimpleVirtualizer()?.markDOMDirty(),this.layoutDirty=!0,n.size>0&&n.clear(),r.length>0&&(r.length=0),this.isSimpleMode()&&this.computeApproximateSize(),t&&s!==void 0&&this.file!==void 0){const a=this.virtualizer.getWindowSpecs(),o=this.computeRenderRangeFromWindow(this.file,this.top??0,a);o.bufferAfter!==s.bufferAfter&&this.updateBuffers(o)}}render({fileContainer:i,file:e,forceRender:t=!1,lineAnnotations:n,...r}){const s=this.file==null||!M(this.file,e),{forceRenderOverride:a,isSetup:o}=this;this.forceRenderOverride=void 0;const h=this.syncLineAnnotations(n);if(h&&this.resetLayoutCache(),this.file=e,i=this.getOrCreateFileContainerNode(i),this.file==null)return console.error("VirtualizedFile.render: attempting to virtually render when we dont have file"),!1;if(o)this.top??=this.getVirtualizedTop(),s&&this.isSimpleMode()&&(this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache(!0));else{this.computeApproximateSize();const u=this.getSimpleVirtualizer();if(this.top??=this.getVirtualizedTop(),this.isAdvancedMode())this.isVisible=!0;else{if(u==null)throw new Error("VirtualizedFile.render: simple virtualizer is not available");u.connect(i,this),this.isVisible=u.isInstanceVisible(this.top??0,this.height)}this.isSetup=!0}if(!this.isVisible&&this.isSimpleMode())return this.renderPlaceholder(this.height);const d=this.virtualizer.getWindowSpecs(),l=this.top??0,c=this.computeRenderRangeFromWindow(this.file,l,d);return super.render({file:this.file,fileContainer:i,renderRange:c,lineAnnotations:n,forceRender:(a??t)||h,...r})}syncVirtualizedTop(){this.top=this.getVirtualizedTop()}shouldDisableVirtualizationBuffers(){return this.isAdvancedMode()||super.shouldDisableVirtualizationBuffers()}isSimpleMode(){return this.virtualizer.type==="simple"}isAdvancedMode(){return this.virtualizer.type==="advanced"}addLayoutCheckpoint(i,e){i%Ht===0&&this.cache.checkpoints.push({lineIndex:i,top:e})}getLayoutCheckpointBeforeLineIndex(i){if(i<=0||this.cache.checkpoints.length===0)return;let e=0,t=this.cache.checkpoints.length-1,n;for(;e<=t;){const r=e+t>>1,s=this.cache.checkpoints[r];if(s==null)throw new Error("VirtualizedFile: invalid checkpoint index");s.lineIndex<=i?(n=s,e=r+1):t=r-1}return n}getLayoutCheckpointBeforeTop(i,e){let t=0,n=this.cache.checkpoints.length-1,r=-1;for(;t<=n;){const s=t+n>>1,a=this.cache.checkpoints[s];if(a==null)throw new Error("VirtualizedFile: invalid checkpoint index");a.top<=i?(r=s,t=s+1):n=s-1}if(e==null)return r>=0?this.cache.checkpoints[r]:void 0;for(let s=r;s>=0;s--){const a=this.cache.checkpoints[s];if(a==null)throw new Error("VirtualizedFile: invalid checkpoint index");if(a.lineIndex%e===0)return a}}getVirtualizedTop(){return this.virtualizer.type==="advanced"?this.virtualizer.getLocalTopForInstance(this):this.fileContainer!=null?this.virtualizer.getOffsetInScrollContainer(this.fileContainer):0}getSimpleVirtualizer(){return this.virtualizer.type==="simple"?this.virtualizer:void 0}isResizeDebuggingEnabled(){return this.getSimpleVirtualizer()?.config.resizeDebugging??!1}computeRenderRangeFromWindow(i,e,{top:t,bottom:n}){const{disableFileHeader:r=!1,overflow:s="scroll"}=this.options,{hunkLineCount:a,lineHeight:o}=this.metrics,h=this.fileRenderer.getLineCount(i),d=this.height,l=B(this.metrics,r),c=h>0?fe(this.metrics):0,{fileAnnotationHeight:u}=this.cache,p=l+u,f=Math.max(0,d-l-u-c),S=he(this.lineAnnotations),g=e+l,y=u>0&&S&&g<n&&g+u>t;if(e<t-d||e>n)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:d-l-c};if(h<=a)return{startingLine:0,totalLines:a,bufferBefore:0,bufferAfter:0};const m=Math.ceil(Math.max(n-t,0)/o),v=Math.ceil(m/a)*a+a*2,z=v/a,D=(t+n)/2;if(s==="scroll"&&!this.hasLineAnnotations()){const R=e+p,P=R+f;if(!y&&!(R<n&&P>t))return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:d-l-c};const w=Math.floor(y&&D<e+p?0:(D-(e+p))/o),b=Math.floor(w/a)-Math.floor(z/2),xe=Math.ceil(h/a),E=Math.max(0,Math.min(b,xe))*a,Q=b<0?v+b*a:v,we=E===0?0:u+E*o,Ee=Math.min(Q,h-E);return{startingLine:E,totalLines:Q,bufferBefore:we,bufferAfter:Math.max(0,(h-E-Ee)*o)}}const be=z,N=[],U=this.getLayoutCheckpointBeforeTop(Math.max(0,t-e-v*o*2),a);let T=e+(U?.top??p),_=U?.lineIndex??0,O,V,x;const Re=U?.lineIndex??0;for(let R=Re;R<h;R++){const P=_%a===0,w=Math.floor(_/a);if(P&&(N[w]=T-(e+p),x!=null)){if(x<=0)break;x--}const b=this.getLineHeight(R,!1);T>t-b&&T<n&&(O??=w),T+b>D&&(V??=w),x==null&&T>=n&&P&&(x=be),_++,T+=b}if(O==null)if(y)O=0,V=0;else return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:d-l-c};V??=O;const W=Math.round(V-z/2),Le=Math.max(0,Math.ceil(h/a)-z),G=Math.max(0,Math.min(W,Le)),J=G*a,Y=W<0?v+W*a:v,Me=N[G]??0,He=J===0?0:u+Me,X=G+Y/a,Ae=X<N.length?f-N[X]:f-(T-e-p);return{startingLine:J,totalLines:Y,bufferBefore:He,bufferAfter:Math.max(0,Ae)}}};function Et(i){let e;for(const t of i.children)t instanceof HTMLElement&&t.dataset.lineAnnotation===st&&(e=Math.max(e??0,t.getBoundingClientRect().height));return e}function Ft({file:i,renderCustomHeader:e,renderHeaderPrefix:t,renderHeaderFilenameSuffix:n,renderHeaderMetadata:r,renderAnnotation:s,lineAnnotations:a,renderGutterUtility:o,getHoveredLine:h}){const d=e?.(i),l=t?.(i),c=n?.(i),u=r?.(i);return C.jsxs(C.Fragment,{children:[d!=null?C.jsx("div",{slot:Ce,children:d}):C.jsxs(C.Fragment,{children:[l!=null&&C.jsx("div",{slot:"header-prefix",children:l}),c!=null&&C.jsx("div",{slot:"header-filename-suffix",children:c}),u!=null&&C.jsx("div",{slot:"header-metadata",children:u})]}),s!=null&&a?.map((p,f)=>C.jsx("div",{slot:I(p),children:s(p)},f)),o!=null&&C.jsx("div",{slot:"gutter-utility-slot",style:at,children:o(h)})]})}const me=typeof window>"u"?k.useEffect:k.useLayoutEffect;function kt({file:i,options:e,lineAnnotations:t,selectedLines:n,prerenderedHTML:r,metrics:s,hasGutterRenderUtility:a,hasCustomHeader:o,disableWorkerPool:h,contentEditable:d}){const l=ot(),c=n!==void 0,u=k.useContext(ht),p=lt(),f=k.useRef(null),S=dt(g=>{if(g!=null){if(f.current!=null)throw new Error("File: An instance should not already exist when a node is created");l!=null?f.current=new wt(K({controlledSelection:c,contentEditable:d,hasCustomHeader:o,hasEditor:p!==void 0,hasGutterRenderUtility:a,options:e}),l,s,h?void 0:u,!0):f.current=new Te(K({controlledSelection:c,contentEditable:d,hasCustomHeader:o,hasEditor:p!==void 0,hasGutterRenderUtility:a,options:e}),h?void 0:u,!0),f.current.hydrate({file:i,fileContainer:g,lineAnnotations:t,prerenderedHTML:r})}else{if(f.current==null)throw new Error("File: A File instance should exist when unmounting");f.current.cleanUp(),f.current=null}});return me(()=>{if(f.current==null)return;const g=K({controlledSelection:c,contentEditable:d,hasCustomHeader:o,hasEditor:p!==void 0,hasGutterRenderUtility:a,options:e}),y=!ye(f.current.options,g);f.current.setOptions(g),f.current.render({file:i,lineAnnotations:t,forceRender:y}),n!==void 0&&f.current.setSelectedLines(n)}),me(()=>{if(d&&f.current!=null){if(p===void 0)throw new Error("File: Editor is not attached");return p.edit(f.current)}},[d,p]),{ref:S,getHoveredLine:k.useCallback(()=>f.current?.getHoveredLine(),[])}}function K({options:i,controlledSelection:e,contentEditable:t,hasCustomHeader:n,hasEditor:r,hasGutterRenderUtility:s}){const a=t&&r,o=e||s||n;if(!o&&!a)return i;let h={...i};return o&&(h={...h,controlledSelection:e,renderCustomHeader:n?le:i?.renderCustomHeader,renderGutterUtility:s?le:i?.renderGutterUtility}),a&&(h={...h,useTokenTransformer:!0,enableGutterUtility:!1,enableLineSelection:!1,lineHoverHighlight:"disabled"}),h}function _t({file:i,lineAnnotations:e,selectedLines:t,options:n,metrics:r,className:s,style:a,renderAnnotation:o,renderCustomHeader:h,renderHeaderPrefix:d,renderHeaderFilenameSuffix:l,renderHeaderMetadata:c,prerenderedHTML:u,renderGutterUtility:p,disableWorkerPool:f=!1,contentEditable:S=!1}){const{ref:g,getHoveredLine:y}=kt({file:i,options:n,metrics:r,lineAnnotations:e,selectedLines:t,prerenderedHTML:u,hasGutterRenderUtility:p!=null,hasCustomHeader:h!=null,disableWorkerPool:f,contentEditable:S});return C.jsx(Oe,{ref:g,className:s,style:a,children:ct(Ft({file:i,renderAnnotation:o,renderCustomHeader:h,renderHeaderPrefix:d,renderHeaderFilenameSuffix:l,renderHeaderMetadata:c,renderGutterUtility:p,lineAnnotations:e,getHoveredLine:y}),u)})}const Wt=L.memo(function({jsonString:e,className:t,maxHeight:n="100%",initiallyExpandedDepth:r=2}){const s=L.useRef(null),[a,o]=L.useState(null),h=L.useMemo(()=>{try{const c=e.trim();if(!c)return o("Empty JSON content"),null;const u=JSON.parse(c);return o(null),u}catch(c){return o(c instanceof Error?c.message:"Invalid JSON"),null}},[e]),d=L.useCallback(()=>{s.current?.expandAll()},[]),l=L.useCallback(()=>{s.current?.collapseAll()},[]);return a?C.jsx("div",{className:t,children:C.jsxs("div",{className:"rounded-md border border-[var(--interactive-border)] bg-[var(--syntax-base-background)] p-4",children:[C.jsx("div",{className:"mb-1 font-medium text-[var(--surface-foreground)]",children:"Invalid JSON"}),C.jsx("div",{className:"font-mono text-xs text-[var(--surface-mutedForeground)]",children:a})]})}):h===null?null:C.jsxs("div",{className:t,children:[C.jsxs("div",{className:"flex items-center gap-1 border-b border-[var(--interactive-border)] px-2 py-1",children:[C.jsxs(ee,{variant:"ghost",size:"xs",onClick:d,className:"gap-1 text-xs text-muted-foreground",children:[C.jsx(te,{name:"arrow-down-s",className:"h-3 w-3"}),"Expand all"]}),C.jsxs(ee,{variant:"ghost",size:"xs",onClick:l,className:"gap-1 text-xs text-muted-foreground",children:[C.jsx(te,{name:"arrow-up-s",className:"h-3 w-3"}),"Collapse all"]})]}),C.jsx("div",{className:"bg-[var(--syntax-base-background)] py-1",style:{maxHeight:n,overflow:"auto"},children:C.jsx(Ve,{ref:s,data:h,maxHeight:n,initiallyExpandedDepth:r})})]})});export{_t as F,Wt as J};
@@ -0,0 +1,12 @@
1
+ import{j as _}from"./vendor-boot-Ciu-Edvy.js";import{R as y}from"./vendor-react-Bz1tRBxM.js";import{m as Ke}from"./vendor-morphdom-B7dS_VPB.js";import{r as Ze}from"./vendor-beautiful-mermaid-b48gT2g0.js";import{a as Ue,ai as Xe,h as Ae,z as Ge,Q as ee,bY as Ye,f as U,A as te}from"./index-Cfrwo5uQ.js";import{df as ve,dg as Qe,dh as Je,ah as W,bq as et,br as tt,di as rt,dj as nt,dk as ot,dl as re,dm as at,dn as it,dp as st,z as ke,y as Ee,dq as Ce,dr as lt,ar as ct}from"./useAppFontEffects-CoFst31H.js";import{r as dt,s as ut,i as mt,a as ft,b as pt}from"./markdownCore-Dsr6dY5C.js";import{r as ht}from"./registerCustomTheme-C-h6lsYW.js";import{saveOrShareFile as gt}from"./nativeFileSave-P_Eg5Dgb.js";import{i as bt}from"./runtimeSurface-C3YPOBlg.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-elkjs-D1S1RCAO.js";import"./vendor-entities-C3BA0AJP.js";import"./vendor-zustand-CXhN0IMY.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-tailwind-merge-BKkUfl9q.js";import"./vendor-fuse.js-t_7AcMTv.js";import"./vendor-marked-Be78pDn1.js";import"./vendor-dompurify-BGCr_sdL.js";import"./vendor-remend-DcBOpbSu.js";import"./themeResolver-DrfmQi8i.js";import"./vendor-pierre-theming-BO6EPniU.js";import"./vendor-shikijs-core-Ck_OPM_T.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-DPFxvYtK.js";import"./vendor-hast-util-to-html-O3stl53j.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-C40bX6nM.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";const Se="pichamber-md",wt={name:Se,colors:{"editor.background":"transparent","editor.foreground":"var(--md-syntax-foreground)"},tokenColors:[{scope:["comment","punctuation.definition.comment","string.comment"],settings:{foreground:"var(--md-syntax-comment)",fontStyle:"italic"}},{scope:["string","punctuation.definition.string","string.template"],settings:{foreground:"var(--md-syntax-string)"}},{scope:["constant.numeric","constant.language","constant.character","constant"],settings:{foreground:"var(--md-syntax-number)"}},{scope:["keyword","storage","storage.type","storage.modifier","keyword.control"],settings:{foreground:"var(--md-syntax-keyword)"}},{scope:["keyword.operator","punctuation.separator","punctuation.terminator"],settings:{foreground:"var(--md-syntax-operator)"}},{scope:["entity.name.function","support.function","meta.function-call"],settings:{foreground:"var(--md-syntax-function)"}},{scope:["entity.name.type","entity.name.class","support.type","support.class","entity.other.inherited-class"],settings:{foreground:"var(--md-syntax-type)"}},{scope:["variable","variable.other","variable.parameter","meta.definition.variable"],settings:{foreground:"var(--md-syntax-variable)"}},{scope:["variable.other.property","meta.property-name","support.type.property-name"],settings:{foreground:"var(--md-syntax-property)"}},{scope:["entity.name.tag","punctuation.definition.tag"],settings:{foreground:"var(--md-syntax-keyword)"}},{scope:["entity.other.attribute-name"],settings:{foreground:"var(--md-syntax-property)"}},{scope:["markup.bold","punctuation.definition.bold"],settings:{fontStyle:"bold"}},{scope:["markup.italic","punctuation.definition.italic"],settings:{fontStyle:"italic"}},{scope:["markup.heading","markup.heading entity.name"],settings:{foreground:"var(--md-syntax-keyword)",fontStyle:"bold"}},{scope:["markup.inserted","punctuation.definition.inserted"],settings:{foreground:"var(--md-syntax-inserted)"}},{scope:["markup.deleted","punctuation.definition.deleted"],settings:{foreground:"var(--md-syntax-deleted)"}},{scope:["invalid","invalid.illegal"],settings:{foreground:"var(--md-syntax-deleted)"}}]};let ne=!1;const yt=()=>{ne||(ne=!0,ht(Se,()=>Promise.resolve(wt)))},k=e=>Number.isFinite(e)&&e>0,oe=e=>{if(typeof e=="number")return k(e)?e:null;if(typeof e!="string")return null;const t=e.trim().match(/^([+-]?(?:(?:\d+\.?\d*)|(?:\.\d+))(?:[eE][+-]?\d+)?)(?:px)?$/);if(!t)return null;const n=Number(t[1]);return k(n)?n:null},B=(e,t,n)=>Math.min(n,Math.max(t,e)),At=6,ae=1.25,vt=1.0015,kt=.5,Et=12,ie=3,Ct=400,I='[data-markdown="mermaid-block"]',M=e=>e.querySelector(I)!==null,St=e=>[e.x,e.y,e.width,e.height].map(t=>{const n=Number(t.toFixed(At));return Object.is(n,-0)?"0":String(n)}).join(" "),Mt=e=>{const t=e.viewBox?.trim().split(/[\s,]+/).map(s=>Number.parseFloat(s));if(t?.length===4){const[s,o,a,i]=t;if(Number.isFinite(s)&&Number.isFinite(o)&&k(a)&&k(i))return{x:s,y:o,width:a,height:i}}const n=oe(e.width),r=oe(e.height);return n===null||r===null?null:{x:0,y:0,width:n,height:r}},Lt=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)},Nt=e=>{const t=e.renderMode||"unknown",n=e.svgMarkup??"";if(!n){const r=[e.viewBox??"",e.width??"",e.height??""];return r.some(s=>s!=="")?`${t}:bounds:${r.join(":")}`:`${t}:no-svg`}return[t,Lt(n)].join(":")},Me=(e,t)=>{if(!k(t.width)||!k(t.height))return e;const n=e.width/e.height,r=t.width/t.height;if(n>r){const o=e.width/r;return{x:e.x,y:e.y-(o-e.height)/2,width:e.width,height:o}}const s=e.height*r;return{x:e.x-(s-e.width)/2,y:e.y,width:s,height:e.height}},xt=({currentBox:e,viewport:t,delta:n})=>!k(t.width)||!k(t.height)||!k(e.width)||!k(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},Tt=(e,t)=>{const n=t.x-e.x,r=t.y-e.y;return n*n+r*r>ie*ie},Pt=({currentBox:e,contentBox:t,viewport:n,pointer:r,zoomFactor:s,minScale:o,maxScale:a})=>{if(!k(n.width)||!k(n.height)||!k(s)||!k(e.width)||!k(e.height)||!k(t.width)||!k(t.height)||!k(o)||!k(a))return e;const i=Math.min(o,a),l=Math.max(o,a),d=Me(t,n),c=d.width/e.width,m=B(c*s,i,l),f=d.width/m,p=f/(e.width/e.height),h=B(r.x/n.width,0,1),A=B(r.y/n.height,0,1),v=e.x+h*e.width,w=e.y+A*e.height;return{x:v-h*f,y:w-A*p,width:f,height:p}},X=new WeakMap,Rt=e=>e instanceof HTMLElement?X.get(e)??null:null,_t=e=>e.querySelector('[data-markdown="mermaid-viewport"]')??e.querySelector('[data-markdown="mermaid"]'),se=e=>{const t=e.querySelector('[data-markdown="mermaid"] svg'),n=e.querySelector('[data-markdown="mermaid"]');return Nt({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")})},R=e=>{const t=e.getBoundingClientRect();return{width:t.width,height:t.height}},It=(e,t)=>{const n=t.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}},Ft=e=>e instanceof Element&&!!e.closest('button, a, [role="button"]'),Ot=e=>{const t=_t(e),n=e.querySelector('[data-markdown="mermaid"] svg');if(!t||!n)return null;const r=Mt({viewBox:n.getAttribute("viewBox"),width:n.getAttribute("width"),height:n.getAttribute("height")});if(!r)return null;let s=r,o=null,a=null,i=null,l=null;const d=u=>{s=u,n.setAttribute("viewBox",St(u)),n.removeAttribute("width"),n.removeAttribute("height")},c=()=>{d(Me(r,R(t)))},m=(u,E)=>{d(Pt({currentBox:s,contentBox:r,viewport:R(t),pointer:u,zoomFactor:E,minScale:kt,maxScale:Et}))},f=()=>{const u=R(t);m({x:u.width/2,y:u.height/2},ae)},p=()=>{const u=R(t);m({x:u.width/2,y:u.height/2},1/ae)},h=u=>{!u.ctrlKey&&!u.metaKey||(u.preventDefault(),u.stopPropagation(),m(It(u,t),Math.pow(vt,-u.deltaY)))},A=u=>{u.button!==0||Ft(u.target)||(o=u.pointerId,a={x:u.clientX,y:u.clientY},i=a,l!==null&&(window.clearTimeout(l),l=null),e.removeAttribute("data-mermaid-suppress-click"),t.setPointerCapture?.(u.pointerId),e.setAttribute("data-mermaid-panning","true"),u.preventDefault())},v=u=>{if(o!==u.pointerId||!i)return;const E={x:u.clientX,y:u.clientY};d(xt({currentBox:s,viewport:R(t),delta:{x:E.x-i.x,y:E.y-i.y}})),i=E,a&&Tt(a,E)&&e.setAttribute("data-mermaid-suppress-click","true"),u.preventDefault()},w=u=>{o===u.pointerId&&(t.releasePointerCapture?.(u.pointerId),o=null,a=null,i=null,e.removeAttribute("data-mermaid-panning"),e.hasAttribute("data-mermaid-suppress-click")&&(l=window.setTimeout(()=>{e.removeAttribute("data-mermaid-suppress-click"),l=null},Ct)))},g=()=>{c()};t.addEventListener("wheel",h,{passive:!1}),t.addEventListener("pointerdown",A),t.addEventListener("pointermove",v),t.addEventListener("pointerup",w),t.addEventListener("pointercancel",w),window.addEventListener("resize",g);const b=typeof ResizeObserver>"u"?null:new ResizeObserver(g);return b?.observe(t),c(),{zoomIn:f,zoomOut:p,fit:c,cleanup:()=>{t.removeEventListener("wheel",h),t.removeEventListener("pointerdown",A),t.removeEventListener("pointermove",v),t.removeEventListener("pointerup",w),t.removeEventListener("pointercancel",w),window.removeEventListener("resize",g),b?.disconnect(),l!==null&&window.clearTimeout(l),e.removeAttribute("data-mermaid-panning"),e.removeAttribute("data-mermaid-suppress-click"),X.delete(e)}}},Dt=e=>{const t=new Map,n=new Map,r=()=>{for(const[o,a]of Array.from(t.entries())){const i=se(o);(!e.contains(o)||i!==n.get(o))&&(a.cleanup(),t.delete(o),n.delete(o))}for(const o of Array.from(e.querySelectorAll(I))){if(t.has(o)||o.querySelector('[data-markdown="mermaid"] svg')===null)continue;const a=Ot(o);a&&(t.set(o,a),n.set(o,se(o)),X.set(o,a))}},s=()=>{for(const o of t.values())o.cleanup();t.clear(),n.clear()};return r(),{refresh:r,cleanup:s}},x=e=>`<svg class="remixicon size-3.5" viewBox="0 0 24 24" aria-hidden="true"><use href="#oc-${e}"></use></svg>`,q={copy:x("file-copy"),check:x("check"),download:x("download"),zoomIn:x("add"),zoomOut:x("subtract"),fit:x("refresh")},Le="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)]",$=(e,t)=>{e.innerHTML=t},S=(e,t,n)=>{const r=document.createElement("button");return r.type="button",r.className=Le,r.setAttribute("data-md-action",n),r.setAttribute("title",t),r.setAttribute("aria-label",t),$(r,q[e]),r},Ne=e=>{const t=e.querySelector("[data-md-code-body]"),n=e.querySelector("pre"),r=e.querySelector("pre code"),s=e.querySelectorAll("[data-md-code-line-content]");e.setAttribute("data-code-wrap","true"),t?.classList.remove("overflow-x-auto"),t?.classList.add("overflow-x-hidden"),n?.classList.add("whitespace-pre-wrap","break-words"),r?.classList.add("whitespace-pre-wrap","break-words"),n&&(n.style.whiteSpace="pre-wrap",n.style.overflowWrap="anywhere"),r&&(r.style.whiteSpace="pre-wrap",r.style.overflowWrap="anywhere");for(const o of Array.from(s))o.style.whiteSpace="pre-wrap",o.style.overflowWrap="anywhere"},xe=e=>{const t=e.querySelector(":scope > code");if(!t||t.hasAttribute("data-md-code-lines"))return;const n=t.textContent??"",r=n.endsWith(`
2
+ `),s=r?n.slice(0,-1).split(`
3
+ `):n.split(`
4
+ `),o=s.length>0?s:[""],a=Array.from(t.children).filter(d=>d.classList.contains("line"));r&&a.length===o.length+1&&a.at(-1)?.textContent===""&&a.pop();const i=a.length===o.length,l=document.createDocumentFragment();o.forEach((d,c)=>{const m=document.createElement("span");m.setAttribute("data-md-code-line","");const f=document.createElement("span");f.setAttribute("data-md-code-line-number",""),f.setAttribute("aria-hidden","true"),f.textContent=String(c+1);const p=document.createElement("span");if(p.setAttribute("data-md-code-line-content",""),i){const h=a[c];h&&p.append(...Array.from(h.childNodes))}else p.textContent=d;if(m.append(f,p),l.appendChild(m),c<o.length-1||r){const h=document.createElement("span");h.setAttribute("data-md-code-line-break",""),h.textContent=`
5
+ `,l.appendChild(h)}}),t.replaceChildren(l),t.setAttribute("data-md-code-lines",""),t.toggleAttribute("data-md-code-trailing-newline",r)},Te=e=>{const t=Array.from(e.querySelectorAll("[data-md-code-line-content]"));if(t.length===0)return e.textContent??"";const n=t.map(r=>r.textContent??"").join(`
6
+ `);return e.hasAttribute("data-md-code-trailing-newline")?`${n}
7
+ `:n},qt=e=>{const t=e.querySelectorAll('[data-component="markdown-code"]');for(const n of Array.from(t)){const r=n.querySelector("pre");r&&xe(r),Ne(n)}},le=(e,t,n,r)=>{$(e,q.check),e.setAttribute("title",t),e.setAttribute("aria-label",t),window.setTimeout(()=>{$(e,q[n]),e.setAttribute("title",r),e.setAttribute("aria-label",r)},2e3)},$t=e=>{const t=e.querySelectorAll(":not(pre) > code");for(const n of Array.from(t))n.getAttribute("data-markdown")!=="inline-code"&&n.setAttribute("data-markdown","inline-code")},zt=(e,t)=>{const n=e.querySelectorAll("pre");for(const r of Array.from(n)){if(r.querySelector("code.language-mermaid"))continue;const s=r.parentElement;if(!s||s.closest('[data-component="markdown-code"]'))continue;const o=r.querySelector("code")?.className.match(/language-([\w+#.-]+)/)?.[1],a=r.getAttribute("data-md-lang")??o??"text",i=document.createElement("div");i.setAttribute("data-component","markdown-code"),i.className="my-4 group overflow-hidden rounded-2xl border border-border/80 bg-[var(--surface-elevated)]";const l=document.createElement("div");l.className="flex items-center justify-between border-b border-border/70 px-3 py-1.5";const d=document.createElement("span");d.className="font-mono text-[13px] text-muted-foreground",d.textContent=a;const c=S("copy",t.labels.copy,"copy-code");l.appendChild(d);const m=document.createElement("div");m.className="flex items-center gap-1",m.setAttribute("data-md-code-actions",""),m.appendChild(c),l.appendChild(m);const f=document.createElement("div");f.setAttribute("data-md-code-body",""),f.className="px-3 py-2.5 overflow-x-auto",s.replaceChild(i,r),r.style.margin="0",r.style.background="transparent",r.classList.add("min-w-0","w-full","flex-1"),t.deferCodeLineNumberSync||xe(r),f.appendChild(r),i.appendChild(l),i.appendChild(f),Ne(i)}},ce=e=>{const t=[],n=[],r=e.querySelectorAll("thead th");for(const o of Array.from(r))t.push((o.textContent??"").trim());const s=e.querySelectorAll("tbody tr");for(const o of Array.from(s)){const a=Array.from(o.querySelectorAll("td")).map(i=>(i.textContent??"").trim());a.length>0&&n.push(a)}return{headers:t,rows:n}},Ht=e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e,de=({headers:e,rows:t})=>[e,...t].map(n=>n.map(Ht).join(",")).join(`
8
+ `),Wt=({headers:e,rows:t})=>[e,...t].map(n=>n.join(" ")).join(`
9
+ `),ue=({headers:e,rows:t})=>{const n=`| ${e.join(" | ")} |`,r=`| ${e.map(()=>"---").join(" | ")} |`,s=t.map(o=>`| ${o.join(" | ")} |`).join(`
10
+ `);return`${n}
11
+ ${r}
12
+ ${s}`},me=(e,t)=>{const n=document.createElement("div");n.className=`absolute top-full right-0 mt-1 hidden ${et}`,n.style.backgroundColor="var(--surface-elevated)",n.style.color="var(--surface-elevated-foreground)",n.setAttribute("data-md-menu",e);for(const r of t){const s=document.createElement("button");s.type="button",s.className=`w-full text-left ${tt}`,s.setAttribute("data-md-action",`${e}-${r.key}`),s.textContent=r.label,n.appendChild(s)}return n},Bt=(e,t)=>{const n=e.querySelectorAll("table");for(const r of Array.from(n)){if(r.closest('[data-markdown="table-wrapper"]'))continue;const o=document.createElement("div");o.className="group my-4 flex flex-col space-y-2",o.setAttribute("data-markdown","table-wrapper");const a=document.createElement("div");a.className="flex items-center justify-end gap-1";const i=document.createElement("div");i.className="relative",i.appendChild(S("copy",t.copyTable,"table-copy-toggle")),i.appendChild(me("table-copy",[{key:"csv",label:"CSV"},{key:"tsv",label:"TSV"},{key:"markdown",label:"Markdown"}]));const l=document.createElement("div");l.className="relative",l.appendChild(S("download",t.downloadTable,"table-download-toggle")),l.appendChild(me("table-download",[{key:"csv",label:"CSV"},{key:"markdown",label:"Markdown"}])),a.appendChild(i),a.appendChild(l);const d=document.createElement("div");d.className="overflow-x-auto rounded-lg border border-border/80 bg-[var(--surface-elevated)]";const c=r.parentElement;if(!c)continue;c.replaceChild(o,r),r.setAttribute("data-markdown","table"),r.classList.add("w-full","border-collapse","text-sm");for(const f of Array.from(r.querySelectorAll("tr")))f.classList.add("border-b","border-border/60");const m=r.querySelector("tbody tr:last-child");m?.classList.remove("border-b"),m?.classList.add("border-0");for(const f of Array.from(r.querySelectorAll("th")))f.classList.add("border-r","border-border/60","px-4","py-2.5","text-left","align-middle","font-semibold","text-foreground","last:border-r-0");for(const f of Array.from(r.querySelectorAll("td")))f.classList.add("border-r","border-border/60","px-4","py-2.5","align-middle","text-foreground","last:border-r-0");d.appendChild(r),o.appendChild(a),o.appendChild(d)}},Vt=(e,t)=>{const n=e.querySelectorAll("pre > code.language-mermaid");for(const r of Array.from(n)){const s=r.parentElement;if(!s)continue;const o=(r.textContent??"").replace(/\s+$/,""),a=t.renderMermaid(o),i=document.createElement("div");i.setAttribute("data-markdown","mermaid-block"),i.setAttribute("data-md-source",o),i.className="group relative";const l=document.createElement("div");l.setAttribute("data-markdown","mermaid-scroll");const d=document.createElement("div");if(d.setAttribute("data-markdown","mermaid-toolbar"),d.className="absolute top-1 right-2 flex items-center gap-1 opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition-opacity",a.svg){i.setAttribute("data-mermaid-render","svg");const m=document.createElement("div");m.setAttribute("data-markdown","mermaid-viewport");const f=document.createElement("div");if(f.setAttribute("data-markdown","mermaid"),f.setAttribute("data-md-original-svg",a.svg),f.innerHTML=a.svg,m.appendChild(f),l.appendChild(m),t.mermaidControls.showPanZoomControls&&(d.appendChild(S("zoomIn",t.labels.zoomInDiagram,"mermaid-zoom-in")),d.appendChild(S("zoomOut",t.labels.zoomOutDiagram,"mermaid-zoom-out")),d.appendChild(S("fit",t.labels.resetDiagramView,"mermaid-fit"))),t.mermaidControls.copy){const p=S("copy",t.labels.copyDiagram,"mermaid-copy");p.setAttribute("data-md-source",o),d.appendChild(p)}if(t.mermaidControls.download){const p=S("download",t.labels.downloadDiagram,"mermaid-download");p.setAttribute("data-md-svg","1"),d.appendChild(p)}}else{i.setAttribute("data-mermaid-render","svg");const m=document.createElement("pre");if(m.setAttribute("data-markdown","mermaid-ascii"),m.textContent=o,l.appendChild(m),t.mermaidControls.copy){const f=S("copy",t.labels.copyDiagram,"mermaid-copy");f.setAttribute("data-md-source",o),d.appendChild(f)}}i.appendChild(l),i.appendChild(d);const c=s.parentElement;c&&c.replaceChild(i,s)}},jt=(e,t)=>{const n=e.querySelectorAll("a[href]");for(const r of Array.from(n)){if(r.getAttribute("data-md-link-decorated")==="true"||r.getAttribute("data-pichamber-file-link")==="true")continue;const s=r.getAttribute("href")??"";if(!ve(s))continue;r.setAttribute("data-md-link-decorated","true");const o=Qe(s);if(o){const a=document.createElement("span");a.className="mr-1 inline-flex size-[18px] items-center justify-center rounded border border-[var(--border)] bg-[var(--interactive-hover)] align-middle";const i=document.createElement("img");i.src=o,i.alt="",i.setAttribute("aria-hidden","true"),i.loading="lazy",i.decoding="async",i.className="size-3.5 rounded-sm",i.addEventListener("error",()=>a.remove(),{once:!0}),a.appendChild(i),r.parentNode?.insertBefore(a,r)}if(t.onPreviewLoopback&&Je(s)){const a=document.createElement("button");a.type="button",a.className=`ml-1 align-middle ${Le}`,a.setAttribute("data-md-action","preview-loopback"),a.setAttribute("data-md-url",s),a.setAttribute("title",t.labels.previewTitle),a.setAttribute("aria-label",t.labels.previewLabel),$(a,q.download),r.parentNode?.insertBefore(a,r.nextSibling)}}},fe=(e,t)=>{$t(e),Vt(e,t),zt(e,t),Bt(e,t.labels),jt(e,t)},pe=(e,t,n)=>{gt({filename:e,mimeType:n,data:t}).catch(r=>console.warn("[markdown] Download failed",r))},F=e=>{for(const t of Array.from(e.querySelectorAll("[data-md-menu]")))t.classList.add("hidden")},Kt=(e,t)=>{const n=r=>{const s=r.target;if(!(s instanceof Element))return;const o=s.closest("[data-md-action]");if(!o){F(e);return}const a=o.getAttribute("data-md-action")??"";if(a==="copy-code"){const i=o.closest('[data-component="markdown-code"]')?.querySelector("code"),l=i?Te(i):"";l&&W(l).then(()=>le(o,t.labels.copied,"copy",t.labels.copy));return}if(a==="table-copy-toggle"||a==="table-download-toggle"){r.preventDefault();const i=o.parentElement?.querySelector("[data-md-menu]")??null,l=i?.classList.contains("hidden")??!1;F(e),i&&l&&i.classList.remove("hidden");return}if(a.startsWith("table-copy-")){const i=a.replace("table-copy-",""),l=o.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(l instanceof HTMLTableElement){const d=ce(l),c=i==="csv"?de(d):i==="tsv"?Wt(d):ue(d);W(c)}F(e);return}if(a.startsWith("table-download-")){const i=a.replace("table-download-",""),l=o.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(l instanceof HTMLTableElement){const d=ce(l),c=i==="csv"?de(d):ue(d);pe(i==="csv"?"table.csv":"table.md",c,i==="csv"?"text/csv":"text/markdown")}F(e);return}if(a==="mermaid-copy"){const i=o.getAttribute("data-md-source")??"";i&&W(i).then(()=>le(o,t.labels.copied,"copy",t.labels.copyDiagram));return}if(a==="mermaid-zoom-in"||a==="mermaid-zoom-out"||a==="mermaid-fit"){r.preventDefault();const i=o.closest('[data-markdown="mermaid-block"]'),l=Rt(i);a==="mermaid-zoom-in"?l?.zoomIn():a==="mermaid-zoom-out"?l?.zoomOut():l?.fit();return}if(a==="mermaid-download"){const i=o.closest('[data-markdown="mermaid-block"]')?.querySelector('[data-markdown="mermaid"]'),l=i?.getAttribute("data-md-original-svg")??i?.innerHTML??"";l&&pe("diagram.svg",l,"image/svg+xml;charset=utf-8");return}if(a==="preview-loopback"){r.preventDefault();const i=o.getAttribute("data-md-url")??"";i&&t.onPreviewLoopback?.(i);return}};return e.addEventListener("click",n),()=>e.removeEventListener("click",n)},he=(e,t,n)=>{let r=0;for(const o of e){const a=r+o.data.length;if(t<a||t===a&&n==="left")return{node:o,offset:Math.max(0,t-r)};r=a}const s=e.at(-1);return s?{node:s,offset:s.data.length}:null},Zt=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),ge=Array.from(Zt).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),Ut=e=>nt(e),Xt=e=>rt(e),z=e=>{let t=(e||"").trim();return t?((t.startsWith("`")&&t.endsWith("`")||t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"))&&(t=t.slice(1,-1).trim()),t=t.replace(/[.,;!?]+$/g,""),t.endsWith(")")&&!t.includes("(")&&(t=t.slice(0,-1)),t.endsWith("]")&&!t.includes("[")&&(t=t.slice(0,-1)),t):""},O=e=>{let t=z(e);if(!t)return"";const n=t.indexOf(";");n>=0&&(t=t.slice(0,n)),t=t.replace(/#.*$/,"");const r=t.match(/^(.*\.[A-Za-z0-9_-]{1,16}):.*$/);r&&(t=r[1]??t);const s=ge.length>0?t.match(new RegExp(`^(.*(?:/|^)(${ge})):.*$`,"i")):null;return s&&(t=s[1]??t),z(t)},Pe=e=>{const t=z(e);if(!t)return null;const n=t.indexOf(";"),r=n>=0?z(t.slice(0,n)):t;if(!r)return null;const s=r.match(/^(.*?):(\d+)-(\d+)$/);if(s){const l=O(s[1]??""),d=Number.parseInt(s[2]??"",10),c=Number.parseInt(s[3]??"",10);return!l||!Number.isFinite(d)||!Number.isFinite(c)||c<d?null:{path:l,line:d,endLine:c}}const o=r.match(/^(.*)#L(\d+)(?:C(\d+))?$/i);if(o){const l=O(o[1]??""),d=Number.parseInt(o[2]??"",10),c=o[3]?Number.parseInt(o[3],10):void 0;return!l||!Number.isFinite(d)?null:{path:l,line:d,column:Number.isFinite(c??Number.NaN)?c:void 0}}const a=r.match(/^(.*?):(\d+)(?::(\d+))?$/);if(a){const l=O(a[1]??""),d=Number.parseInt(a[2]??"",10),c=a[3]?Number.parseInt(a[3],10):void 0;return!l||!Number.isFinite(d)?null:{path:l,line:d,column:Number.isFinite(c??Number.NaN)?c:void 0}}const i=O(r);return i?{path:i}:null},V=/(?:[A-Za-z]:[\\/])?[\w.\-/@+]*[\w\-/@+]\.[A-Za-z0-9]{1,8}(?::\d+(?:-\d+)?(?::\d+)?)?/g,Re=({containerRef:e,enabled:t})=>{y.useEffect(()=>{if(t===!1)return;const n=e.current;if(!n)return;const r=s=>{if(s.defaultPrevented||s.button!==0||s.metaKey||s.ctrlKey||s.altKey||s.shiftKey)return;const o=s.target;if(!(o instanceof Element))return;const a=o.closest("a[href]");if(!(a instanceof HTMLAnchorElement)||a.getAttribute("data-pichamber-file-link")==="true")return;const i=a.getAttribute("href")??"";ve(i)&&(s.preventDefault(),s.stopPropagation(),ot(i))};return n.addEventListener("click",r),()=>{n.removeEventListener("click",r)}},[e,t])},be='[data-pichamber-file-link="true"]',_e="data-pichamber-block-path-token",Ie=`[${_e}]`,T="data-pichamber-block-paths-scanned",Gt=2e5,Yt=4,Qt=1e3,Jt=80,we=160,L=new Map;let D=0;const ye=[],er=()=>Qt,tr=()=>Jt,rr=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),G=e=>Ut(e),nr=e=>Xt(e),or=(e,t)=>st(e,t),ar=e=>{const t=e.split("/").filter(Boolean).pop()??"";return!t||t.endsWith(".")?!1:/\.[A-Za-z0-9_-]{1,16}$/.test(t)},Fe=e=>{if(!e||e.startsWith("--")||e.includes("://")||/[<>]/.test(e)||/\s{2,}/.test(e))return!1;const t=G(e),n=t.split("/").filter(Boolean).pop()??t;if(!n||n==="."||n==="..")return!1;const r=n.toLowerCase();return rr.has(r)||r.startsWith(".")&&r.length>1?!0:ar(t)},Oe=e=>{const t=Pe(e);return t?Fe(t.path):!1},ir=e=>{const t=e.querySelectorAll(Ie);for(const r of Array.from(t))r.replaceWith(e.ownerDocument.createTextNode(r.textContent??""));const n=e.querySelectorAll(`code[${T}]`);for(const r of Array.from(n))r.removeAttribute(T),r.normalize()},j=e=>{if(e.tagName.toLowerCase()==="a"){const t=e.getAttribute("href")?.trim();if(t&&Oe(t))return t}return(e.textContent||"").trim()},sr=e=>{const t=e.querySelectorAll("pre code");if(t.length===0)return;const n=e.ownerDocument;if(n)for(const r of Array.from(t)){if(r.getAttribute(T)==="true")continue;if((r.textContent??"").length>Gt){r.setAttribute(T,"true");continue}const s=n.createTreeWalker(r,NodeFilter.SHOW_TEXT),o=[];let a=s.nextNode();for(;a;){const c=a;c.parentElement?.closest("[data-md-code-line-number]")||o.push(c),a=s.nextNode()}const i=Te(r);if(!i.includes(".")){r.setAttribute(T,"true");continue}V.lastIndex=0;const l=[];let d=V.exec(i);for(;d;){const c=d[0];c&&Oe(c)&&l.push({start:d.index,end:d.index+c.length,raw:c}),d=V.exec(i)}for(const{start:c,end:m,raw:f}of l.reverse()){const p=he(o,c,"right"),h=he(o,m,"left");if(!p||!h)continue;const A=n.createRange();A.setStart(p.node,p.offset),A.setEnd(h.node,h.offset);const v=n.createElement("span");v.setAttribute(_e,"true"),v.textContent=f,A.deleteContents(),A.insertNode(v)}r.setAttribute(T,"true")}},K=(e,t)=>{const n=Pe(e);if(!n||!Fe(n.path))return null;const r=nr(n.path)?G(n.path):or(t,n.path);return r?{...n,resolvedPath:r}:null},lr=e=>{const t=G(e);if(!t)return Promise.resolve(!1);const n=L.get(t);if(n)return L.delete(t),L.set(t,n),n;const r=new Promise(o=>{const a=()=>{D+=1,Ge(`/api/fs/stat?path=${encodeURIComponent(t)}&optional=true`,{method:"GET",cache:"no-store"}).then(async i=>{if(!i.ok){o(!1);return}const l=await i.json().catch(()=>null);o(l?.exists!==!1)}).catch(()=>o(!1)).finally(()=>{D=Math.max(0,D-1),ye.shift()?.()})};if(D<Yt){a();return}ye.push(a)}),s=er();for(;L.size>=s;){const o=L.keys().next().value;if(typeof o!="string")break;L.delete(o)}return L.set(t,r),r},cr=(e,t)=>e||it(e,t),De=({containerRef:e,effectiveDirectory:t,editor:n,preferRuntimeEditor:r,enabled:s})=>{const o=y.useRef(null);y.useEffect(()=>{const a=e.current;if(!a)return;let i=!1;const l=tr(),d=s&&!bt(),c=g=>{g.removeAttribute("data-pichamber-file-link"),g.removeAttribute("data-pichamber-file-ref"),g.removeAttribute("data-pichamber-file-path"),g.getAttribute("title")==="Open file"&&g.removeAttribute("title"),g.tagName.toLowerCase()!=="a"&&(g.removeAttribute("role"),g.removeAttribute("tabindex"))},m=()=>{const g=a.querySelectorAll(be);for(const b of Array.from(g))c(b);ir(a)};if(!d){m();return}const f=(g=0)=>{if(o.current!==null&&typeof window<"u"&&window.clearTimeout(o.current),typeof window>"u"){p();return}o.current=window.setTimeout(()=>{o.current=null,window.requestAnimationFrame(()=>{i||p()})},g)},p=()=>{d&&sr(a);const g=a.querySelectorAll(`[data-markdown="inline-code"], a, ${Ie}`);let b=0;for(const u of Array.from(g)){const E=j(u),C=K(E,t);if(c(u),!C||b>=l)continue;b+=1,(Ue()&&Xe()&&!re(C.resolvedPath,t)?Promise.resolve(!0):lr(C.resolvedPath)).then(je=>{if(i||!je||!a.contains(u))return;const J=j(u),H=K(J,t);!H||H.resolvedPath!==C.resolvedPath||(u.setAttribute("data-pichamber-file-link","true"),u.setAttribute("data-pichamber-file-ref",J),u.setAttribute("data-pichamber-file-path",H.resolvedPath),u.setAttribute("title","Open file"),u.tagName.toLowerCase()!=="a"&&(u.setAttribute("role","button"),u.setAttribute("tabindex","0")))})}},h=async g=>{const b=g.getAttribute("data-pichamber-file-ref")||j(g),u=K(b,t);if(!u)return;const E=cr(t,u.resolvedPath);re(u.resolvedPath,t)||await at(u.resolvedPath,t);const C=Ae.getState();Number.isFinite(u.line??Number.NaN)?C.openContextFileAtLine(E,u.resolvedPath,Math.max(1,Math.trunc(u.line)),Number.isFinite(u.column??Number.NaN)?Math.max(1,Math.trunc(u.column)):1):C.openContextFile(E,u.resolvedPath)},A=g=>{const b=g.target;if(!(b instanceof Element))return;const u=b.closest(be);u instanceof HTMLElement&&(g.preventDefault(),g.stopPropagation(),h(u))},v=g=>{if(g.key!=="Enter"&&g.key!==" ")return;const b=g.target;!(b instanceof HTMLElement)||b.getAttribute("data-pichamber-file-link")!=="true"||(g.preventDefault(),g.stopPropagation(),h(b))};f(we);const w=new MutationObserver(()=>{f(we)});return w.observe(a,{childList:!0,subtree:!0}),a.addEventListener("click",A),a.addEventListener("keydown",v),()=>{i=!0,o.current!==null&&typeof window<"u"&&window.clearTimeout(o.current),o.current=null,w.disconnect(),a.removeEventListener("click",A),a.removeEventListener("keydown",v)}},[e,n,t,r,s])},P={download:!0,copy:!0,showPanZoomControls:!0},qe=!0,$e=({containerRef:e,onShowPopup:t,enableFullscreen:n,enablePanZoom:r,allowMermaidWheelEvents:s})=>{y.useEffect(()=>{const o=e.current;if(!o)return;const a=l=>{if(!t)return;const d=l.target;if(!(d instanceof Element)||d.closest('button, a, [role="button"]'))return;const c=d.closest(I);if(!c)return;if(c instanceof HTMLElement&&c.hasAttribute("data-mermaid-suppress-click")){c.removeAttribute("data-mermaid-suppress-click");return}const f=Array.from(o.querySelectorAll(I)).indexOf(c);if(f<0)return;const p=c instanceof HTMLElement?c.getAttribute("data-md-source"):null;if(!p||p.trim().length===0)return;const h=`Diagram ${f+1}`;t({open:!0,title:h,content:"",metadata:{tool:"mermaid-preview",filename:h},mermaid:{url:`data:text/plain;charset=utf-8,${encodeURIComponent(p)}`,source:p,filename:h}})},i=l=>{if(s||(l.ctrlKey||l.metaKey)&&r)return;const d=l.target;!(d instanceof Element)||!d.closest(I)||l.stopPropagation()};return o.addEventListener("click",a),o.addEventListener("wheel",i,{capture:!0,passive:!0}),()=>{o.removeEventListener("click",a),o.removeEventListener("wheel",i,!0)}},[s,e,n,r,t])},N=new Map,dr=100,ur=(e,t)=>{const n=N.get(e);if(n)return N.delete(e),N.set(e,n),n;const r=t();if(N.set(e,r),N.size>dr){const s=N.keys().next().value;s&&N.delete(s)}return r},mr=e=>({bg:e.colors.surface.elevated,fg:e.colors.surface.foreground,line:e.colors.interactive.border,accent:e.colors.primary.base,muted:e.colors.surface.mutedForeground,surface:e.colors.surface.muted,border:e.colors.interactive.border,transparent:!0,font:"system-ui, sans-serif"}),ze=()=>{const e=ct(),t=te(!1),n=te(!0);return e?.currentTheme??(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?n:t)},fr=e=>{const 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},He=(e,t,n,r=P)=>{const s=y.useMemo(()=>({copy:"Copy code",copied:"Copied",copyTable:"Copy table",downloadTable:"Download table",copyDiagram:"Copy source",downloadDiagram:"Download SVG",zoomInDiagram:"Zoom in",zoomOutDiagram:"Zoom out",resetDiagramView:"Reset view",previewLabel:"Preview",previewTitle:"Open preview pane"}),[]);return y.useMemo(()=>{const o=mr(e),a=e.metadata?.id??"theme";return{labels:s,mermaidControls:r,deferCodeLineNumberSync:t,renderMermaid:l=>ur(`${a}:svg:${l}`,()=>{try{return{svg:Ze(l,o)}}catch{return{}}}),onPreviewLoopback:n}},[e,s,r,t,n])},We=e=>{e.style.display="contents",e.style.width="",e.style.minWidth="",e.style.maxWidth=""},Z=(e,t)=>{We(e);const n=pt(t);let r=e.querySelector(":scope > [data-md-live]");const s=r?.hasAttribute("data-md-live-pre")===!0;(!r||s!==n)&&(e.replaceChildren(),r=document.createElement(n?"div":"p"),r.setAttribute("data-md-live",""),n&&r.setAttribute("data-md-live-pre",""),r.className=n?"w-full min-w-0 whitespace-pre-wrap break-words":"w-full min-w-0 break-words",r.appendChild(document.createTextNode("")),e.appendChild(r));const o=r.firstChild;if(!(o instanceof globalThis.Text)){r.replaceChildren(document.createTextNode(t));return}if(t.startsWith(o.data)){const a=t.slice(o.data.length);a.length>0&&o.appendData(a);return}o.data=t},Be=({containerRef:e,text:t,streaming:n,cacheKey:r,syntaxVars:s,ctx:o})=>{y.useEffect(()=>{yt()},[]);const a=y.useRef(null),i=y.useRef(null),l=y.useRef(r);l.current!==r&&(l.current=r,i.current=null);const d=y.useCallback(()=>{const c=e.current;if(c){if(!a.current){if(!M(c))return;a.current=Dt(c);return}a.current.refresh()}},[e]);y.useLayoutEffect(()=>{const c=e.current,m=c?.querySelector("[data-markdown-content]")??c;if(m&&t&&m.childNodes.length===0){const f=document.createElement("div");if(f.setAttribute("data-md-block",""),f.style.display="contents",n){Z(f,t),m.appendChild(f);return}f.innerHTML=dt(t),fe(f,o),m.appendChild(f),M(f)&&d()}},[e,t,n,o,d]),y.useEffect(()=>()=>{a.current?.cleanup(),a.current=null},[]),y.useEffect(()=>{const c=e.current;if(!c)return;const m=c.querySelector("[data-markdown-content]")??c;let f=!0;if(n&&i.current){const p=ut(r).update(t);if(mt(i.current,p)){const h=p[p.length-1],A=m.querySelectorAll(":scope > [data-md-block]")[p.length-1];if(h&&A){Z(A,h.raw),A.setAttribute("data-md-id",`live:${p.length-1}`),i.current=i.current.map((v,w)=>w===p.length-1?{...v,raw:h.raw,id:`live:${w}`,mode:"live"}:v);return}}}return ft(t,n,r).then(p=>{if(!f)return;const h=Array.from(m.querySelectorAll(":scope > [data-md-block]"));p.forEach((w,g)=>{let b=h[g];if(b||(b=document.createElement("div"),b.setAttribute("data-md-block",""),b.style.display="contents",m.appendChild(b)),w.mode==="live"){Z(b,w.raw),b.setAttribute("data-md-id",w.id);return}if(We(b),b.getAttribute("data-md-id")===w.id)return;const u=document.createElement("div");u.innerHTML=w.html,fe(u,o);const E=M(b),C=M(u);Ke(b,u,{childrenOnly:!0,onBeforeElUpdated:(Y,Q)=>!Y.isEqualNode(Q)}),b.setAttribute("data-md-id",w.id),(E||C||M(b))&&d()});const A=M(m);let v=!1;for(let w=h.length-1;w>=p.length;w-=1){const g=h[w];g&&M(g)&&(v=!0),g?.remove()}(v||h.length>p.length&&A)&&d(),i.current=p}),()=>{f=!1}},[e,t,n,r,o,d]),y.useEffect(()=>{const c=e.current;if(c)return Kt(c,o)},[e,o]),y.useEffect(()=>{const c=e.current,m=c?.querySelector("[data-markdown-content]")??c;if(m)for(const[f,p]of Object.entries(s))m.style.setProperty(f,p)},[e,s]),y.useEffect(()=>{const c=e.current,m=c?.querySelector("[data-markdown-content]")??c;m&&(o.deferCodeLineNumberSync||qt(m))},[e,o.deferCodeLineNumberSync])},Ve=(e,t)=>U("w-full min-w-0",e==="tool"?"markdown-content markdown-tool":e==="reasoning"?"markdown-content markdown-reasoning":"markdown-content leading-relaxed",t&&"markdown-streaming"),pr=({content:e,part:t,messageId:n,isAnimated:r=!0,skipFadeIn:s=!1,className:o,isStreaming:a=!1,disableStreamAnimation:i=!1,variant:l="assistant",onShowPopup:d,enableFileReferences:c=!0})=>{ee("ui.markdown_renderer.render"),a&&ee("ui.markdown_renderer.render.streaming"),Ye("ui.markdown_renderer.content_len",e.length);const m=ze(),{editor:f}=ke(),p=y.useRef(null),h=Ee()??"",A=Ae(C=>C.openContextPreview),v=y.useCallback(C=>{h&&A(h,C)},[h,A]),w=a&&!i;$e({containerRef:p,onShowPopup:d,enableFullscreen:qe,enablePanZoom:P.showPanZoomControls}),De({containerRef:p,effectiveDirectory:h,editor:f,preferRuntimeEditor:!1,enabled:c&&!a}),Re({containerRef:p});const g=y.useMemo(()=>Ce(m),[m]),b=He(m,w,h?v:void 0,P),u=`markdown-${t?.id?`part-${t.id}`:`message-${n}`}`;Be({containerRef:p,text:e,streaming:w,cacheKey:u,syntaxVars:g,ctx:b});const E=_.jsx("div",{className:U("break-words w-full min-w-0",o),ref:p,children:_.jsx("div",{className:Ve(l,w),"data-markdown-content":!0})});return r?_.jsx(lt,{skipAnimation:s,children:E},u):E},Qr=y.memo(pr,(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),hr=({content:e,className:t,variant:n="assistant",disableLinkSafety:r,stripFrontmatter:s=!1,onShowPopup:o,mermaidControls:a=P,allowMermaidWheelEvents:i=!1,enableFileReferences:l=!0})=>{const{editor:d}=ke(),c=ze(),m=y.useRef(null),f=Ee()??"",p=y.useMemo(()=>s?fr(e):e,[e,s]);$e({containerRef:m,onShowPopup:o,enableFullscreen:qe,enablePanZoom:a.showPanZoomControls,allowMermaidWheelEvents:i}),De({containerRef:m,effectiveDirectory:f,editor:d,preferRuntimeEditor:!1,enabled:l}),Re({containerRef:m,enabled:!r});const h=y.useMemo(()=>Ce(c),[c]),A=He(c,!1,void 0,a);return Be({containerRef:m,text:p,streaming:!1,cacheKey:`simple:${n}`,syntaxVars:h,ctx:A}),_.jsx("div",{className:U("break-words w-full min-w-0",t),ref:m,children:_.jsx("div",{className:Ve(n),"data-markdown-content":!0})})},Jr=y.memo(hr,(e,t)=>{const n=e.mermaidControls??P,r=t.mermaidControls??P;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.allowMermaidWheelEvents===t.allowMermaidWheelEvents&&e.enableFileReferences===t.enableFileReferences});export{Qr as MarkdownRenderer,Jr as SimpleMarkdownRenderer};
@@ -1 +1 @@
1
- import{ef as j,dB as y,dF as D}from"./useAppFontEffects-D_gtiA95.js";import{f as k,B as C}from"./web-components-6ORYp3Iv.js";import{M as P,G as O,u as L,W as A,a as M,b as R,n as E,t as H}from"./Virtualizer-DNJrJKVb.js";import{j as d}from"./vendor-boot-CoTxysn6.js";import{V as _,F as N}from"./VirtualizedFileDiff-DvLCd7Qq.js";import{a as w}from"./vendor-react-Bz1tRBxM.js";function T({hunkIndex:e,lineIndex:t,conflictIndex:n}){return`merge-conflict-action-${e}-${t}-${n}`}function V(e,t){const n=t.hunks[e.hunkIndex];if(n!=null)return{hunkIndex:e.hunkIndex,lineIndex:z(n,e.startContentIndex)}}function z(e,t){let n=e.unifiedLineStart;for(let l=0;l<t;l++){const s=e.hunkContent[l];n+=s.type==="context"?s.lines:s.deletions+s.additions}return n}function U(e){const t=j(e);if(t.length!==1)throw console.error(t),new Error("PatchDiff: Provided patch must include only 1 patch, with 1 diff");const{files:n}=t[0];if(n.length!==1)throw console.error(n),new Error("FileDiff: Provided patch must contain exactly 1 file diff");return n[0]}function $({fileDiff:e,actions:t,renderCustomHeader:n,renderHeaderPrefix:l,renderHeaderFilenameSuffix:s,renderHeaderMetadata:x,renderAnnotation:f,renderGutterUtility:u,renderMergeConflictUtility:o,lineAnnotations:a,getHoveredLine:g,getInstance:m}){const p=n?.(e),c=l?.(e),i=s?.(e),v=x?.(e);return d.jsxs(d.Fragment,{children:[p!=null?d.jsx("div",{slot:y,children:p}):d.jsxs(d.Fragment,{children:[c!=null&&d.jsx("div",{slot:"header-prefix",children:c}),i!=null&&d.jsx("div",{slot:"header-filename-suffix",children:i}),v!=null&&d.jsx("div",{slot:"header-metadata",children:v})]}),f!=null&&a?.map((r,h)=>d.jsx("div",{slot:k(r),children:f(r)},h)),t!=null&&o!=null&&m!=null&&t.map(r=>{if(r==null)return;const h=b(r,e);return d.jsx("div",{slot:h,style:P,children:o(r,m)},h)}),u!=null&&d.jsx("div",{slot:"gutter-utility-slot",style:O,children:u(g)})]})}function b(e,t){const n=V(e,t);return n!=null?T({hunkIndex:n.hunkIndex,lineIndex:n.lineIndex,conflictIndex:e.conflictIndex}):void 0}const S=typeof window>"u"?w.useEffect:w.useLayoutEffect;function B({fileDiff:e,options:t,lineAnnotations:n,selectedLines:l,prerenderedHTML:s,metrics:x,hasGutterRenderUtility:f,hasCustomHeader:u,disableWorkerPool:o,contentEditable:a}){const g=L(),m=l!==void 0,p=w.useContext(A),c=M(),i=w.useRef(null),v=R(r=>{if(r!=null){if(i.current!=null)throw new Error("useFileDiffInstance: An instance should not already exist when a node is created");g!=null?i.current=new _(I({controlledSelection:m,contentEditable:a,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:f,options:t}),g,x,o?void 0:p,!0):i.current=new N(I({controlledSelection:m,contentEditable:a,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:f,options:t}),o?void 0:p,!0),i.current.hydrate({fileDiff:e,fileContainer:r,lineAnnotations:n,prerenderedHTML:s})}else{if(i.current==null)throw new Error("useFileDiffInstance: A FileDiff instance should exist when unmounting");i.current.cleanUp(),i.current=null}});return S(()=>{const{current:r}=i;if(r==null)return;const h=I({controlledSelection:m,contentEditable:a,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:f,options:t}),F=!C(r.options,h);r.setOptions(h),r.render({forceRender:F,fileDiff:e,lineAnnotations:n}),l!==void 0&&r.setSelectedLines(l)}),S(()=>{if(a&&i.current!=null){if(c===void 0)throw new Error("FileDiff: Editor is not attached");return c.edit(i.current)}},[a,c]),{ref:v,getHoveredLine:w.useCallback(()=>i.current?.getHoveredLine(),[])}}function I({options:e,controlledSelection:t,contentEditable:n,hasCustomHeader:l,hasEditor:s,hasGutterRenderUtility:x}){const f=n&&s,u=t||x||l;if(!u&&!f)return e;let o={...e};return u&&(o={...o,controlledSelection:t,renderCustomHeader:l?E:e?.renderCustomHeader,renderGutterUtility:x?E:e?.renderGutterUtility}),f&&(o={...o,useTokenTransformer:!0,enableGutterUtility:!1,enableLineSelection:!1,expandUnchanged:!0,lineHoverHighlight:"disabled"}),o}function Y({patch:e,options:t,metrics:n,lineAnnotations:l,selectedLines:s,className:x,style:f,prerenderedHTML:u,renderAnnotation:o,renderCustomHeader:a,renderHeaderPrefix:g,renderHeaderFilenameSuffix:m,renderHeaderMetadata:p,renderGutterUtility:c,disableWorkerPool:i=!1,contentEditable:v=!1}){const r=G(e),{ref:h,getHoveredLine:F}=B({fileDiff:r,options:t,metrics:n,lineAnnotations:l,selectedLines:s,prerenderedHTML:u,hasGutterRenderUtility:c!=null,hasCustomHeader:a!=null,disableWorkerPool:i,contentEditable:v});return d.jsx(D,{ref:h,className:x,style:f,children:H($({fileDiff:r,renderCustomHeader:a,renderHeaderPrefix:g,renderHeaderFilenameSuffix:m,renderHeaderMetadata:p,renderAnnotation:o,lineAnnotations:l,renderGutterUtility:c,getHoveredLine:F}),u)})}function G(e){return w.useMemo(()=>U(e),[e])}export{Y as P};
1
+ import{ei as j,dH as y,dL as D}from"./useAppFontEffects-CoFst31H.js";import{f as k,B as C}from"./web-components-CzkvK_V5.js";import{M as P,G as L,u as O,W as A,a as H,b as M,n as F,t as R}from"./Virtualizer-cIf8dSOQ.js";import{j as d}from"./vendor-boot-Ciu-Edvy.js";import{V as _,F as N}from"./VirtualizedFileDiff-BY-mDMT8.js";import{a as w}from"./vendor-react-Bz1tRBxM.js";function T({hunkIndex:e,lineIndex:t,conflictIndex:n}){return`merge-conflict-action-${e}-${t}-${n}`}function V(e,t){const n=t.hunks[e.hunkIndex];if(n!=null)return{hunkIndex:e.hunkIndex,lineIndex:z(n,e.startContentIndex)}}function z(e,t){let n=e.unifiedLineStart;for(let l=0;l<t;l++){const s=e.hunkContent[l];n+=s.type==="context"?s.lines:s.deletions+s.additions}return n}function U(e){const t=j(e);if(t.length!==1)throw console.error(t),new Error("PatchDiff: Provided patch must include only 1 patch, with 1 diff");const{files:n}=t[0];if(n.length!==1)throw console.error(n),new Error("FileDiff: Provided patch must contain exactly 1 file diff");return n[0]}function $({fileDiff:e,actions:t,renderCustomHeader:n,renderHeaderPrefix:l,renderHeaderFilenameSuffix:s,renderHeaderMetadata:x,renderAnnotation:f,renderGutterUtility:u,renderMergeConflictUtility:o,lineAnnotations:a,getHoveredLine:g,getInstance:m}){const p=n?.(e),c=l?.(e),i=s?.(e),v=x?.(e);return d.jsxs(d.Fragment,{children:[p!=null?d.jsx("div",{slot:y,children:p}):d.jsxs(d.Fragment,{children:[c!=null&&d.jsx("div",{slot:"header-prefix",children:c}),i!=null&&d.jsx("div",{slot:"header-filename-suffix",children:i}),v!=null&&d.jsx("div",{slot:"header-metadata",children:v})]}),f!=null&&a?.map((r,h)=>d.jsx("div",{slot:k(r),children:f(r)},h)),t!=null&&o!=null&&m!=null&&t.map(r=>{if(r==null)return;const h=b(r,e);return d.jsx("div",{slot:h,style:P,children:o(r,m)},h)}),u!=null&&d.jsx("div",{slot:"gutter-utility-slot",style:L,children:u(g)})]})}function b(e,t){const n=V(e,t);return n!=null?T({hunkIndex:n.hunkIndex,lineIndex:n.lineIndex,conflictIndex:e.conflictIndex}):void 0}const S=typeof window>"u"?w.useEffect:w.useLayoutEffect;function G({fileDiff:e,options:t,lineAnnotations:n,selectedLines:l,prerenderedHTML:s,metrics:x,hasGutterRenderUtility:f,hasCustomHeader:u,disableWorkerPool:o,contentEditable:a}){const g=O(),m=l!==void 0,p=w.useContext(A),c=H(),i=w.useRef(null),v=M(r=>{if(r!=null){if(i.current!=null)throw new Error("useFileDiffInstance: An instance should not already exist when a node is created");g!=null?i.current=new _(E({controlledSelection:m,contentEditable:a,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:f,options:t}),g,x,o?void 0:p,!0):i.current=new N(E({controlledSelection:m,contentEditable:a,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:f,options:t}),o?void 0:p,!0),i.current.hydrate({fileDiff:e,fileContainer:r,lineAnnotations:n,prerenderedHTML:s})}else{if(i.current==null)throw new Error("useFileDiffInstance: A FileDiff instance should exist when unmounting");i.current.cleanUp(),i.current=null}});return S(()=>{const{current:r}=i;if(r==null)return;const h=E({controlledSelection:m,contentEditable:a,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:f,options:t}),I=!C(r.options,h);r.setOptions(h),r.render({forceRender:I,fileDiff:e,lineAnnotations:n}),l!==void 0&&r.setSelectedLines(l)}),S(()=>{if(a&&i.current!=null){if(c===void 0)throw new Error("FileDiff: Editor is not attached");return c.edit(i.current)}},[a,c]),{ref:v,getHoveredLine:w.useCallback(()=>i.current?.getHoveredLine(),[])}}function E({options:e,controlledSelection:t,contentEditable:n,hasCustomHeader:l,hasEditor:s,hasGutterRenderUtility:x}){const f=n&&s,u=t||x||l;if(!u&&!f)return e;let o={...e};return u&&(o={...o,controlledSelection:t,renderCustomHeader:l?F:e?.renderCustomHeader,renderGutterUtility:x?F:e?.renderGutterUtility}),f&&(o={...o,useTokenTransformer:!0,enableGutterUtility:!1,enableLineSelection:!1,expandUnchanged:!0,lineHoverHighlight:"disabled"}),o}function Y({patch:e,options:t,metrics:n,lineAnnotations:l,selectedLines:s,className:x,style:f,prerenderedHTML:u,renderAnnotation:o,renderCustomHeader:a,renderHeaderPrefix:g,renderHeaderFilenameSuffix:m,renderHeaderMetadata:p,renderGutterUtility:c,disableWorkerPool:i=!1,contentEditable:v=!1}){const r=q(e),{ref:h,getHoveredLine:I}=G({fileDiff:r,options:t,metrics:n,lineAnnotations:l,selectedLines:s,prerenderedHTML:u,hasGutterRenderUtility:c!=null,hasCustomHeader:a!=null,disableWorkerPool:i,contentEditable:v});return d.jsx(D,{ref:h,className:x,style:f,children:R($({fileDiff:r,renderCustomHeader:a,renderHeaderPrefix:g,renderHeaderFilenameSuffix:m,renderHeaderMetadata:p,renderAnnotation:o,lineAnnotations:l,renderGutterUtility:c,getHoveredLine:I}),u)})}function q(e){return w.useMemo(()=>U(e),[e])}export{Y as P};
@@ -1,4 +1,4 @@
1
- import{aR as Se,j as z}from"./vendor-boot-CoTxysn6.js";import{a as f,R as ae}from"./vendor-react-Bz1tRBxM.js";import{B as Ee}from"./web-components-6ORYp3Iv.js";import{f as ce}from"./computeVirtualFileMetrics-aX6tjjqv.js";import{V as ke,F as Te}from"./VirtualizedFileDiff-DvLCd7Qq.js";import{ar as xe,aO as Oe}from"./useAppFontEffects-D_gtiA95.js";import{P as ze,S as De}from"./StickyHorizontalScrollbar-p7EbL2-E.js";import{aX as Ce}from"./runtimeEndpointReset-fozcAShH.js";import{ensurePierreThemeRegistered as ue,getResolvedShikiTheme as he}from"./appThemeRegistry-Ca8eGRB9.js";import{A as de,f as fe}from"./index-C2ISrmRR.js";const J=new Set;let ne=null;function E(n){J.add(n),ne??=requestAnimationFrame(be)}function be(n){const e=new Set(J);J.clear();for(const t of e)try{t(n)}catch(r){console.error(r)}J.size>0?ne=requestAnimationFrame(be):ne=null}function ge({scrollTop:n,scrollHeight:e,height:t,fitPerfectly:r=!1,fitPerfectlyOverscroll:i=0,overscrollSize:s}){const h=t+s*2,d=r?t+i*2:h;if(e=Math.max(e,d),h>=e||r){const g=Math.max(n-i,0),y=Math.min(n+d,e);return{top:g,bottom:Math.max(y,g)}}let c=n+t/2-h/2,m=c+h;return c<0&&(c=0),m>e&&(m=e),c=Math.floor(Math.max(c,0)),{top:c,bottom:Math.ceil(Math.max(Math.min(m,e),c))}}function Ie(n,e){return n==null||e==null?n===e:n.top===e.top&&n.bottom===e.bottom}const ye=1e3,Me=ye*4,He=[0,1e-6,.99999,1],Pe={overscrollSize:ye,intersectionObserverMargin:Me,resizeDebugging:!1};let X=0,Le=-1;var _e=class T{static __STOP=!1;static __lastScrollPosition=0;__id=`virtualizer-${++Le}`;config;type="simple";intersectionObserver;scrollTop=0;height=0;scrollHeight=0;windowSpecs={top:0,bottom:0};root;contentContainer;resizeObserver;observers=new Map;visibleInstances=new Map;visibleInstancesDirty=!1;instancesChanged=new Set;scrollDirty=!0;heightDirty=!0;scrollHeightDirty=!0;renderedObservers=0;connectQueue=new Map;constructor(e){this.config={...Pe,...e}}setup(e,t){if(this.root==null){this.root=e,this.resizeObserver=new ResizeObserver(this.handleContainerResize),this.intersectionObserver=new IntersectionObserver(this.handleIntersectionChange,{root:this.root,threshold:He,rootMargin:`${this.config.intersectionObserverMargin}px 0px ${this.config.intersectionObserverMargin}px 0px`}),e instanceof Document?this.setupWindow():this.setupElement(t),window.__INSTANCE=this,window.__TOGGLE=()=>{T.__STOP?(T.__STOP=!1,(this.getScrollContainerElement()??window).scrollTo({top:T.__lastScrollPosition}),E(this.computeRenderRangeAndEmit)):(T.__lastScrollPosition=this.getScrollTop(),T.__STOP=!0)};for(const[r,i]of this.connectQueue.entries())this.connect(r,i);this.connectQueue.clear(),this.markDOMDirty(),E(this.computeRenderRangeAndEmit)}}instanceChanged(e,t){this.instancesChanged.add(e),t&&this.markDOMDirty(),E(this.computeRenderRangeAndEmit)}getWindowSpecs(){return this.windowSpecs.top===0&&this.windowSpecs.bottom===0&&(this.windowSpecs=ge({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),overscrollSize:this.config.overscrollSize})),this.windowSpecs}isInstanceVisible(e,t){const r=this.getScrollTop(),i=this.getHeight(),s=this.config.intersectionObserverMargin,h=r-s,d=r+i+s;return!(e<h-t||e>d)}handleContainerResize=e=>{if(this.root==null)return;let t=!1;for(const r of e){const i=r.borderBoxSize[0].blockSize;this.root instanceof Document?i!==this.scrollHeight&&(this.scrollHeightDirty=!0,t=!0,this.config.resizeDebugging&&(console.log("Virtualizer: content size change",this.__id,{sizeChange:i-X,newSize:i}),X=i)):r.target===this.root?i!==this.height&&(this.heightDirty=!0,t=!0):r.target===this.contentContainer&&(this.scrollHeightDirty=!0,t=!0,this.config.resizeDebugging&&(console.log("Virtualizer: scroller size change",this.__id,{sizeChange:i-X,newSize:i}),X=i))}t&&E(this.computeRenderRangeAndEmit)};setupWindow(){if(this.root==null||!(this.root instanceof Document))throw new Error("Virtualizer.setupWindow: Invalid setup method");window.addEventListener("scroll",this.handleWindowScroll,{passive:!0}),window.addEventListener("resize",this.handleWindowResize,{passive:!0}),this.resizeObserver?.observe(this.root.documentElement)}setupElement(e){if(this.root==null||this.root instanceof Document)throw new Error("Virtualizer.setupElement: Invalid setup method");this.root.addEventListener("scroll",this.handleElementScroll,{passive:!0}),this.resizeObserver?.observe(this.root),e??=this.root.firstElementChild??void 0,e instanceof HTMLElement&&(this.contentContainer=e,this.resizeObserver?.observe(e))}cleanUp(){this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.root?.removeEventListener("scroll",this.handleElementScroll),window.removeEventListener("scroll",this.handleWindowScroll),window.removeEventListener("resize",this.handleWindowResize),this.root=void 0,this.contentContainer=void 0,this.observers.clear(),this.visibleInstances.clear(),this.instancesChanged.clear(),this.connectQueue.clear(),this.visibleInstancesDirty=!1,this.windowSpecs={top:0,bottom:0},this.scrollTop=0,this.height=0,this.scrollHeight=0}getOffsetInScrollContainer(e){return this.getScrollTop()+U(e,this.getScrollContainerElement())}connect(e,t){if(this.observers.has(e))throw new Error("Virtualizer.connect: instance is already connected...");return this.intersectionObserver==null?this.connectQueue.set(e,t):(this.intersectionObserver.observe(e),this.observers.set(e,t),this.instancesChanged.add(t),this.markDOMDirty(),E(this.computeRenderRangeAndEmit)),()=>this.disconnect(e)}disconnect(e){const t=this.observers.get(e);this.connectQueue.delete(e),t!=null&&(this.intersectionObserver?.unobserve(e),this.observers.delete(e),this.visibleInstances.delete(e)&&(this.visibleInstancesDirty=!0),this.markDOMDirty(),E(this.computeRenderRangeAndEmit))}handleWindowResize=()=>{T.__STOP||window.innerHeight===this.height||(this.heightDirty=!0,E(this.computeRenderRangeAndEmit))};handleWindowScroll=()=>{T.__STOP||this.root==null||!(this.root instanceof Document)||(this.scrollDirty=!0,E(this.computeRenderRangeAndEmit))};handleElementScroll=()=>{T.__STOP||this.root==null||this.root instanceof Document||(this.scrollDirty=!0,E(this.computeRenderRangeAndEmit))};computeRenderRangeAndEmit=()=>{if(T.__STOP)return;const e=this.heightDirty||this.scrollHeightDirty;if(!this.scrollDirty&&!this.scrollHeightDirty&&!this.heightDirty&&this.renderedObservers===this.observers.size&&!this.visibleInstancesDirty&&this.instancesChanged.size===0)return;let t=this.instancesChanged.size>0;if(this.instancesChanged.size===0){const s=ge({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),overscrollSize:this.config.overscrollSize});if(!e&&Ie(this.windowSpecs,s)&&this.renderedObservers===this.observers.size&&!this.visibleInstancesDirty)return;this.windowSpecs=s}this.visibleInstancesDirty=!1,this.renderedObservers=this.observers.size;const r=this.getScrollAnchor(this.height),i=new Set;for(const s of e?this.observers.values():this.visibleInstances.values())s.onRender(e)&&i.add(s);for(const s of this.instancesChanged)i.has(s)||s.onRender(e)&&i.add(s);this.scrollFix(r);for(const s of i)s.reconcileHeights();t||=this.instancesChanged.size>0,t&&this.markDOMDirty(),(t||e)&&E(this.computeRenderRangeAndEmit),i.clear(),this.instancesChanged.clear()};scrollFix(e){if(e==null)return;const t=this.getScrollContainerElement(),{lineIndex:r,lineOffset:i,fileElement:s,fileOffset:h,fileTypeOffset:d}=e;if(r!=null&&i!=null){const m=s.shadowRoot?.querySelector(`[data-line][data-line-index="${r}"]`);if(m instanceof HTMLElement){const g=U(m,t);if(g!==i){const y=g-i;this.applyScrollFix(y)}return}}const c=U(s,t);if(d==="top")c!==h&&this.applyScrollFix(c-h);else{const m=c+s.getBoundingClientRect().height;m!==h&&this.applyScrollFix(m-h)}}applyScrollFix(e){this.root==null||this.root instanceof Document?window.scrollTo({top:window.scrollY+e,behavior:"instant"}):this.root.scrollTo({top:this.root.scrollTop+e,behavior:"instant"}),this.markDOMDirty()}getScrollAnchor(e){const t=this.getScrollContainerElement();let r;for(const[i]of this.visibleInstances.entries()){const s=U(i,t),h=s+i.offsetHeight;let d,c;h<=0?(d=h,c="bottom"):(d=s,c="top");let m,g;if(h>0&&s<e)for(const w of i.shadowRoot?.querySelectorAll("[data-line][data-line-index]")??[]){if(!(w instanceof HTMLElement))continue;const B=w.dataset.lineIndex;if(B==null)continue;const D=U(w,t);if(!(D<0)){m=B,g=D;break}}if(r?.lineOffset!=null&&g==null)continue;let y=!1;(r==null||g!=null&&(r.lineOffset==null||g<r.lineOffset)||g==null&&r.lineOffset==null&&(d>=0&&(r.fileOffset<0||d<r.fileOffset)||d<0&&r.fileOffset<0&&d>r.fileOffset))&&(y=!0),y&&(r={fileElement:i,fileTypeOffset:c,fileOffset:d,lineIndex:m,lineOffset:g})}return r}handleIntersectionChange=e=>{this.scrollDirty=!0;for(const{target:t,isIntersecting:r}of e){if(!(t instanceof HTMLElement))throw new Error("Virtualizer.handleIntersectionChange: target not an HTMLElement");const i=this.observers.get(t);i!=null&&(r&&!this.visibleInstances.has(t)?(i.setVisibility(!0),this.visibleInstances.set(t,i),this.visibleInstancesDirty=!0):!r&&this.visibleInstances.has(t)&&(i.setVisibility(!1),this.visibleInstances.delete(t),this.visibleInstancesDirty=!0))}this.visibleInstancesDirty&&E(this.computeRenderRangeAndEmit)};getScrollTop(){if(!this.scrollDirty)return this.scrollTop;this.scrollDirty=!1;let e=this.root==null?0:this.root instanceof Document?window.scrollY:this.root.scrollTop;return e=Math.max(0,Math.min(e,this.getScrollHeight()-this.getHeight())),this.scrollTop=e,e}getScrollHeight(){return this.scrollHeightDirty?(this.scrollHeightDirty=!1,this.scrollHeight=this.root==null?0:this.root instanceof Document?this.root.documentElement.scrollHeight:this.root.scrollHeight,this.scrollHeight):this.scrollHeight}getHeight(){return this.heightDirty?(this.heightDirty=!1,this.height=this.root==null?0:this.root instanceof Document?globalThis.innerHeight:this.root.getBoundingClientRect().height,this.height):this.height}markDOMDirty(){this.scrollDirty=!0,this.scrollHeightDirty=!0,this.heightDirty=!0}getScrollContainerElement(){return this.root==null||this.root instanceof Document?void 0:this.root}};function U(n,e){const t=n.getBoundingClientRect(),r=e?.getBoundingClientRect().top??0;return t.top-r}const pe=5e5,Fe=`
1
+ import{aR as Se,j as z}from"./vendor-boot-Ciu-Edvy.js";import{a as f,R as ae}from"./vendor-react-Bz1tRBxM.js";import{B as Ee}from"./web-components-CzkvK_V5.js";import{f as ce}from"./computeVirtualFileMetrics-CzkFqhaU.js";import{V as ke,F as xe}from"./VirtualizedFileDiff-BY-mDMT8.js";import{ar as Te,aP as Oe}from"./useAppFontEffects-CoFst31H.js";import{P as ze,S as De}from"./StickyHorizontalScrollbar-CONTbZgX.js";import{aY as Ce}from"./runtimeEndpointReset-D8lAOCUB.js";import{ensurePierreThemeRegistered as he,getResolvedShikiTheme as ue}from"./appThemeRegistry-Ca8eGRB9.js";import{A as de,f as fe}from"./index-Cfrwo5uQ.js";const J=new Set;let ne=null;function E(n){J.add(n),ne??=requestAnimationFrame(be)}function be(n){const e=new Set(J);J.clear();for(const t of e)try{t(n)}catch(r){console.error(r)}J.size>0?ne=requestAnimationFrame(be):ne=null}function pe({scrollTop:n,scrollHeight:e,height:t,fitPerfectly:r=!1,fitPerfectlyOverscroll:i=0,overscrollSize:s}){const u=t+s*2,d=r?t+i*2:u;if(e=Math.max(e,d),u>=e||r){const p=Math.max(n-i,0),y=Math.min(n+d,e);return{top:p,bottom:Math.max(y,p)}}let c=n+t/2-u/2,m=c+u;return c<0&&(c=0),m>e&&(m=e),c=Math.floor(Math.max(c,0)),{top:c,bottom:Math.ceil(Math.max(Math.min(m,e),c))}}function Ie(n,e){return n==null||e==null?n===e:n.top===e.top&&n.bottom===e.bottom}const ye=1e3,Me=ye*4,He=[0,1e-6,.99999,1],Pe={overscrollSize:ye,intersectionObserverMargin:Me,resizeDebugging:!1};let Z=0,Le=-1;var _e=class x{static __STOP=!1;static __lastScrollPosition=0;__id=`virtualizer-${++Le}`;config;type="simple";intersectionObserver;scrollTop=0;height=0;scrollHeight=0;windowSpecs={top:0,bottom:0};root;contentContainer;resizeObserver;observers=new Map;visibleInstances=new Map;visibleInstancesDirty=!1;instancesChanged=new Set;scrollDirty=!0;heightDirty=!0;scrollHeightDirty=!0;renderedObservers=0;connectQueue=new Map;constructor(e){this.config={...Pe,...e}}setup(e,t){if(this.root==null){this.root=e,this.resizeObserver=new ResizeObserver(this.handleContainerResize),this.intersectionObserver=new IntersectionObserver(this.handleIntersectionChange,{root:this.root,threshold:He,rootMargin:`${this.config.intersectionObserverMargin}px 0px ${this.config.intersectionObserverMargin}px 0px`}),e instanceof Document?this.setupWindow():this.setupElement(t),window.__INSTANCE=this,window.__TOGGLE=()=>{x.__STOP?(x.__STOP=!1,(this.getScrollContainerElement()??window).scrollTo({top:x.__lastScrollPosition}),E(this.computeRenderRangeAndEmit)):(x.__lastScrollPosition=this.getScrollTop(),x.__STOP=!0)};for(const[r,i]of this.connectQueue.entries())this.connect(r,i);this.connectQueue.clear(),this.markDOMDirty(),E(this.computeRenderRangeAndEmit)}}instanceChanged(e,t){this.instancesChanged.add(e),t&&this.markDOMDirty(),E(this.computeRenderRangeAndEmit)}getWindowSpecs(){return this.windowSpecs.top===0&&this.windowSpecs.bottom===0&&(this.windowSpecs=pe({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),overscrollSize:this.config.overscrollSize})),this.windowSpecs}isInstanceVisible(e,t){const r=this.getScrollTop(),i=this.getHeight(),s=this.config.intersectionObserverMargin,u=r-s,d=r+i+s;return!(e<u-t||e>d)}handleContainerResize=e=>{if(this.root==null)return;let t=!1;for(const r of e){const i=r.borderBoxSize[0].blockSize;this.root instanceof Document?i!==this.scrollHeight&&(this.scrollHeightDirty=!0,t=!0,this.config.resizeDebugging&&(console.log("Virtualizer: content size change",this.__id,{sizeChange:i-Z,newSize:i}),Z=i)):r.target===this.root?i!==this.height&&(this.heightDirty=!0,t=!0):r.target===this.contentContainer&&(this.scrollHeightDirty=!0,t=!0,this.config.resizeDebugging&&(console.log("Virtualizer: scroller size change",this.__id,{sizeChange:i-Z,newSize:i}),Z=i))}t&&E(this.computeRenderRangeAndEmit)};setupWindow(){if(this.root==null||!(this.root instanceof Document))throw new Error("Virtualizer.setupWindow: Invalid setup method");window.addEventListener("scroll",this.handleWindowScroll,{passive:!0}),window.addEventListener("resize",this.handleWindowResize,{passive:!0}),this.resizeObserver?.observe(this.root.documentElement)}setupElement(e){if(this.root==null||this.root instanceof Document)throw new Error("Virtualizer.setupElement: Invalid setup method");this.root.addEventListener("scroll",this.handleElementScroll,{passive:!0}),this.resizeObserver?.observe(this.root),e??=this.root.firstElementChild??void 0,e instanceof HTMLElement&&(this.contentContainer=e,this.resizeObserver?.observe(e))}cleanUp(){this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.root?.removeEventListener("scroll",this.handleElementScroll),window.removeEventListener("scroll",this.handleWindowScroll),window.removeEventListener("resize",this.handleWindowResize),this.root=void 0,this.contentContainer=void 0,this.observers.clear(),this.visibleInstances.clear(),this.instancesChanged.clear(),this.connectQueue.clear(),this.visibleInstancesDirty=!1,this.windowSpecs={top:0,bottom:0},this.scrollTop=0,this.height=0,this.scrollHeight=0}getOffsetInScrollContainer(e){return this.getScrollTop()+U(e,this.getScrollContainerElement())}connect(e,t){if(this.observers.has(e))throw new Error("Virtualizer.connect: instance is already connected...");return this.intersectionObserver==null?this.connectQueue.set(e,t):(this.intersectionObserver.observe(e),this.observers.set(e,t),this.instancesChanged.add(t),this.markDOMDirty(),E(this.computeRenderRangeAndEmit)),()=>this.disconnect(e)}disconnect(e){const t=this.observers.get(e);this.connectQueue.delete(e),t!=null&&(this.intersectionObserver?.unobserve(e),this.observers.delete(e),this.visibleInstances.delete(e)&&(this.visibleInstancesDirty=!0),this.markDOMDirty(),E(this.computeRenderRangeAndEmit))}handleWindowResize=()=>{x.__STOP||window.innerHeight===this.height||(this.heightDirty=!0,E(this.computeRenderRangeAndEmit))};handleWindowScroll=()=>{x.__STOP||this.root==null||!(this.root instanceof Document)||(this.scrollDirty=!0,E(this.computeRenderRangeAndEmit))};handleElementScroll=()=>{x.__STOP||this.root==null||this.root instanceof Document||(this.scrollDirty=!0,E(this.computeRenderRangeAndEmit))};computeRenderRangeAndEmit=()=>{if(x.__STOP)return;const e=this.heightDirty||this.scrollHeightDirty;if(!this.scrollDirty&&!this.scrollHeightDirty&&!this.heightDirty&&this.renderedObservers===this.observers.size&&!this.visibleInstancesDirty&&this.instancesChanged.size===0)return;let t=this.instancesChanged.size>0;if(this.instancesChanged.size===0){const s=pe({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),overscrollSize:this.config.overscrollSize});if(!e&&Ie(this.windowSpecs,s)&&this.renderedObservers===this.observers.size&&!this.visibleInstancesDirty)return;this.windowSpecs=s}this.visibleInstancesDirty=!1,this.renderedObservers=this.observers.size;const r=this.getScrollAnchor(this.height),i=new Set;for(const s of e?this.observers.values():this.visibleInstances.values())s.onRender(e)&&i.add(s);for(const s of this.instancesChanged)i.has(s)||s.onRender(e)&&i.add(s);this.scrollFix(r);for(const s of i)s.reconcileHeights();t||=this.instancesChanged.size>0,t&&this.markDOMDirty(),(t||e)&&E(this.computeRenderRangeAndEmit),i.clear(),this.instancesChanged.clear()};scrollFix(e){if(e==null)return;const t=this.getScrollContainerElement(),{lineIndex:r,lineOffset:i,fileElement:s,fileOffset:u,fileTypeOffset:d}=e;if(r!=null&&i!=null){const m=s.shadowRoot?.querySelector(`[data-line][data-line-index="${r}"]`);if(m instanceof HTMLElement){const p=U(m,t);if(p!==i){const y=p-i;this.applyScrollFix(y)}return}}const c=U(s,t);if(d==="top")c!==u&&this.applyScrollFix(c-u);else{const m=c+s.getBoundingClientRect().height;m!==u&&this.applyScrollFix(m-u)}}applyScrollFix(e){this.root==null||this.root instanceof Document?window.scrollTo({top:window.scrollY+e,behavior:"instant"}):this.root.scrollTo({top:this.root.scrollTop+e,behavior:"instant"}),this.markDOMDirty()}getScrollAnchor(e){const t=this.getScrollContainerElement();let r;for(const[i]of this.visibleInstances.entries()){const s=U(i,t),u=s+i.offsetHeight;let d,c;u<=0?(d=u,c="bottom"):(d=s,c="top");let m,p;if(u>0&&s<e)for(const w of i.shadowRoot?.querySelectorAll("[data-line][data-line-index]")??[]){if(!(w instanceof HTMLElement))continue;const W=w.dataset.lineIndex;if(W==null)continue;const D=U(w,t);if(!(D<0)){m=W,p=D;break}}if(r?.lineOffset!=null&&p==null)continue;let y=!1;(r==null||p!=null&&(r.lineOffset==null||p<r.lineOffset)||p==null&&r.lineOffset==null&&(d>=0&&(r.fileOffset<0||d<r.fileOffset)||d<0&&r.fileOffset<0&&d>r.fileOffset))&&(y=!0),y&&(r={fileElement:i,fileTypeOffset:c,fileOffset:d,lineIndex:m,lineOffset:p})}return r}handleIntersectionChange=e=>{this.scrollDirty=!0;for(const{target:t,isIntersecting:r}of e){if(!(t instanceof HTMLElement))throw new Error("Virtualizer.handleIntersectionChange: target not an HTMLElement");const i=this.observers.get(t);i!=null&&(r&&!this.visibleInstances.has(t)?(i.setVisibility(!0),this.visibleInstances.set(t,i),this.visibleInstancesDirty=!0):!r&&this.visibleInstances.has(t)&&(i.setVisibility(!1),this.visibleInstances.delete(t),this.visibleInstancesDirty=!0))}this.visibleInstancesDirty&&E(this.computeRenderRangeAndEmit)};getScrollTop(){if(!this.scrollDirty)return this.scrollTop;this.scrollDirty=!1;let e=this.root==null?0:this.root instanceof Document?window.scrollY:this.root.scrollTop;return e=Math.max(0,Math.min(e,this.getScrollHeight()-this.getHeight())),this.scrollTop=e,e}getScrollHeight(){return this.scrollHeightDirty?(this.scrollHeightDirty=!1,this.scrollHeight=this.root==null?0:this.root instanceof Document?this.root.documentElement.scrollHeight:this.root.scrollHeight,this.scrollHeight):this.scrollHeight}getHeight(){return this.heightDirty?(this.heightDirty=!1,this.height=this.root==null?0:this.root instanceof Document?globalThis.innerHeight:this.root.getBoundingClientRect().height,this.height):this.height}markDOMDirty(){this.scrollDirty=!0,this.scrollHeightDirty=!0,this.heightDirty=!0}getScrollContainerElement(){return this.root==null||this.root instanceof Document?void 0:this.root}};function U(n,e){const t=n.getBoundingClientRect(),r=e?.getBoundingClientRect().top??0;return t.top-r}const ge=5e5,Fe=`
2
2
  :host {
3
3
  font-family: var(--font-mono);
4
4
  font-size: var(--text-code);
@@ -20,6 +20,18 @@ import{aR as Se,j as z}from"./vendor-boot-CoTxysn6.js";import{a as f,R as ae}fro
20
20
  pre[data-interactive-line-numbers] [data-line-number] {
21
21
  touch-action: manipulation;
22
22
  }
23
+
24
+ /* With wrapping on, a line's later rows hang 4ch in from its first row, so a
25
+ continuation never starts at the code edge where the next line does. The
26
+ +/- marker is absolutely placed, so it stays put, but it is an inline-block
27
+ that would inherit the negative indent and push its glyph out of view. */
28
+ [data-overflow="wrap"] [data-line] {
29
+ padding-inline-start: calc(2ch + 4ch);
30
+ text-indent: -4ch;
31
+ }
32
+ [data-overflow="wrap"] [data-line]:before {
33
+ text-indent: 0;
34
+ }
23
35
  `,me=`
24
36
  ${Fe}
25
37
 
@@ -131,5 +143,5 @@ import{aR as Se,j as z}from"./vendor-boot-CoTxysn6.js";import{a as f,R as ae}fro
131
143
  text-decoration: underline;
132
144
  }
133
145
  }
134
- `;function Ae(n){let e=2166136261;for(let t=0;t<n.length;t+=1)e^=n.charCodeAt(t),e=e+((e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24))>>>0;return e.toString(16)}function ve(n){const e=n.length>400?`${n.slice(0,200)}${n.slice(-200)}`:n;return`${n.length}:${Ae(e)}`}const Ve=n=>n==="auto"||n==="scroll"||n==="overlay",$e=n=>{let e=n?.parentElement??null;for(;e;){const t=window.getComputedStyle(e);if(Ve(t.overflowY))return e;e=e.parentElement}return null},qe=(n,e)=>{if(!n||!e||typeof window>"u")return()=>{};const t=$e(n);if(!t)return()=>{};const r=e.getBoundingClientRect().height;if(!r)return()=>{};const i=n.getBoundingClientRect().top-t.getBoundingClientRect().top,s=e.style.minHeight;e.style.minHeight=`${Math.ceil(r)}px`;let h=!1;return()=>{if(h)return;h=!0,e.style.minHeight=s;const c=n.getBoundingClientRect().top-t.getBoundingClientRect().top-i;c&&(t.scrollTop+=c)}},Be=(n,e)=>{if(typeof window>"u")return()=>{};let t=null,r=null,i=!1;const s=()=>{i||(r?.disconnect(),r=null,t=window.requestAnimationFrame(()=>{t=window.requestAnimationFrame(()=>{i||e()})}))},h=()=>n.querySelector("diffs-container")?.shadowRoot??void 0,d=(c=h())=>!!c?.querySelector("[data-line]");return d()?s():typeof MutationObserver<"u"?(r=new MutationObserver(()=>{const c=h();if(c){if(d(c)){s();return}r?.disconnect(),r=new MutationObserver(()=>{d(c)&&s()}),r.observe(c,{childList:!0,subtree:!0})}}),r.observe(n,{childList:!0,subtree:!0})):t=window.requestAnimationFrame(s),()=>{i=!0,r?.disconnect(),t!==null&&window.cancelAnimationFrame(t)}},Z=new WeakMap,We={lineHeight:24,hunkSeparatorHeight:24,spacing:0};function Ne(n){const e=n.closest("[data-diff-virtual-root]");if(e instanceof HTMLElement){const t=e.querySelector("[data-diff-virtual-content]");return{key:e,root:e,content:t instanceof HTMLElement?t:void 0}}return{key:document,root:document,content:void 0}}function je(n){if(typeof document>"u")return null;const e=Ne(n);let t=Z.get(e.key);if(!t){const i=new _e;i.setup(e.root,e.content),t={virtualizer:i,refs:0},Z.set(e.key,t)}t.refs+=1;let r=!1;return{virtualizer:t.virtualizer,root:e.root,release:()=>{if(r)return;r=!0;const i=Z.get(e.key);i&&(i.refs-=1,!(i.refs>0)&&(i.virtualizer.cleanUp(),Z.delete(e.key)))}}}const Ue=(n,e,t)=>{if(typeof window>"u")return()=>{};const r=[],i=()=>{try{n.rerender()}catch{}const s=e?.root;s instanceof HTMLElement?s.dispatchEvent(new Event("scroll",{bubbles:!1})):document.dispatchEvent(new Event("scroll",{bubbles:!1})),window.dispatchEvent(new Event("resize")),t()};return r.push(window.requestAnimationFrame(i)),r.push(window.requestAnimationFrame(()=>{r.push(window.requestAnimationFrame(i))})),()=>{for(const s of r)window.cancelAnimationFrame(s)}},nt=({original:n,modified:e,fileDiff:t,language:r,fileName:i,renderSideBySide:s,wrapLines:h,layout:d="fill",enableGutterUtility:c=!1,enableLineSelection:m=!1,onGutterUtilityClick:g,onLineSelectionEnd:y,lineAnnotations:w,renderAnnotation:B})=>{const D=xe(),C=D?.currentTheme.metadata.variant==="dark",_=D?.availableThemes.find(o=>o.metadata.id===D.lightThemeId)??de(!1),F=D?.availableThemes.find(o=>o.metadata.id===D.darkThemeId)??de(!0);ue(_),ue(F);const W=`${_.metadata.id}:${F.metadata.id}:${C?"dark":"light"}`,N=f.useMemo(()=>{if(t){const o=t.deletionLines.reduce((a,u)=>a+u.length,0),l=t.additionLines.reduce((a,u)=>a+u.length,0);return Math.max(o,l)>pe}return Math.max(n.length,e.length)>pe},[t,e.length,n.length]),K=f.useRef(null),A=f.useRef(null),V=f.useRef(null),j=f.useRef(null),ee=f.useRef(null),te=f.useRef(null),re=f.useRef(void 0),Q=f.useRef(void 0),Y=f.useRef(void 0),G=f.useRef(void 0),[,se]=ae.useReducer(o=>o+1,0),$=Ce(N?"unified":s?"split":"unified"),I=f.useRef(new Map),ie=f.useRef(B);ie.current=B;const oe=o=>`${o.side}:${o.lineNumber}`,le=f.useCallback(o=>{if(typeof document>"u")return;const l=`${o.side}:${o.lineNumber}`;let a=I.current.get(l);if(!a){const u=document.createElement("div");u.setAttribute("data-pichamber-line-annotation",l),a={root:Se.createRoot(u),element:u},I.current.set(l,a)}return a.root.render(ie.current?.(o)??null),a.element},[]);f.useEffect(()=>{if(!w){for(const[,a]of I.current)a.root.unmount();I.current.clear();return}const o=new Set(w.map(oe));for(const[a,u]of I.current)o.has(a)||(u.root.unmount(),I.current.delete(a));const l=ie.current;if(l)for(const a of w){const u=I.current.get(oe(a));u&&u.root.render(l(a))}},[w]),f.useEffect(()=>{const o=I.current;return()=>{for(const l of o.values())l.root.unmount();o.clear()}},[]);const x=f.useMemo(()=>he(_),[_]),O=f.useMemo(()=>he(F),[F]);ae.useLayoutEffect(()=>{const o=K.current;if(!o)return;const l=o.querySelector("diffs-container");if(!l)return;const a=C?O:x,u=(we,Re)=>we.colors?.[Re],R=u(x,"terminal.ansiGreen"),v=u(x,"terminal.ansiRed"),b=u(x,"terminal.ansiBlue"),P=u(O,"terminal.ansiGreen"),k=u(O,"terminal.ansiRed"),M=u(O,"terminal.ansiBlue");l.style.setProperty("--shiki-light",x.fg),l.style.setProperty("--shiki-light-bg",x.bg),R&&l.style.setProperty("--shiki-light-addition-color",R),v&&l.style.setProperty("--shiki-light-deletion-color",v),b&&l.style.setProperty("--shiki-light-modified-color",b),l.style.setProperty("--shiki-dark",O.fg),l.style.setProperty("--shiki-dark-bg",O.bg),P&&l.style.setProperty("--shiki-dark-addition-color",P),k&&l.style.setProperty("--shiki-dark-deletion-color",k),M&&l.style.setProperty("--shiki-dark-modified-color",M),l.style.setProperty("--diffs-bg",a.bg),l.style.setProperty("--diffs-fg",a.fg);const S=C?P:R,L=C?k:v,q=C?M:b;S&&l.style.setProperty("--diffs-addition-color-override",S),L&&l.style.setProperty("--diffs-deletion-color-override",L),q&&l.style.setProperty("--diffs-modified-color-override",q);const p=l.shadowRoot?.querySelector("pre");p&&(p.style.setProperty("--shiki-light",x.fg),p.style.setProperty("--shiki-light-bg",x.bg),R&&p.style.setProperty("--shiki-light-addition-color",R),v&&p.style.setProperty("--shiki-light-deletion-color",v),b&&p.style.setProperty("--shiki-light-modified-color",b),p.style.setProperty("--shiki-dark",O.fg),p.style.setProperty("--shiki-dark-bg",O.bg),P&&p.style.setProperty("--shiki-dark-addition-color",P),k&&p.style.setProperty("--shiki-dark-deletion-color",k),M&&p.style.setProperty("--shiki-dark-modified-color",M),p.style.setProperty("--diffs-bg",a.bg),p.style.setProperty("--diffs-fg",a.fg),S&&p.style.setProperty("--diffs-addition-color-override",S),L&&p.style.setProperty("--diffs-deletion-color-override",L),q&&p.style.setProperty("--diffs-modified-color-override",q))},[O,W,C,x]);const H=f.useMemo(()=>({theme:{dark:F.metadata.id,light:_.metadata.id},themeType:C?"dark":"light",diffStyle:s?"split":"unified",diffIndicators:"none",hunkSeparators:"line-info-basic",lineDiffType:"none",maxLineDiffLength:N?0:1e3,maxLineLengthForHighlighting:N?1:1e3,tokenizeMaxLineLength:N?1:1e3,collapsedContextThreshold:0,expansionLineCount:20,overflow:h?"wrap":"scroll",disableFileHeader:!0,enableLineSelection:m,enableGutterUtility:c,enableHoverUtility:!1,...g?{onGutterUtilityClick:g}:{},...y?{onLineSelectionEnd:y}:{},renderAnnotation:le,unsafeCSS:d==="inline"?`${me}
135
- ${ze}`:me}),[le,F.metadata.id,c,m,C,N,d,_.metadata.id,g,y,s,h]);return f.useEffect(()=>{const o=A.current;return()=>{V.current?.cleanUp(),V.current=null,j.current?.release(),j.current=null,ee.current=null,te.current=null,re.current=void 0,Q.current=void 0,Y.current=void 0,G.current=void 0,o&&(o.innerHTML="")}},[]),f.useEffect(()=>{if(typeof window>"u")return;const o=A.current,l=K.current;if(!o||!$)return;const a=qe(l,o);let u=j.current;u||(u=je(o),j.current=u),j.current=u;const R=u?.virtualizer??null,v=t?void 0:{name:i||"",contents:n,lang:r,cacheKey:`old:${W}:${i}:${ve(n)}`},b=t?void 0:{name:i||"",contents:e,lang:r,cacheKey:`new:${W}:${i}:${ve(e)}`},P=t?Q.current!==t:Q.current!==void 0||!v||!b||!Y.current||!G.current||!ce(Y.current,v)||!ce(G.current,b),k=V.current,M=!!(k&&(ee.current!==R||te.current!==$||R&&(re.current!==H.hunkSeparators||P)));M&&(k?.cleanUp(),V.current=null,o.innerHTML="");let S=V.current;const L=!M&&k?!Ee(k.options,H):!1;if(S?S.setOptions(H):(S=u?new ke(H,u.virtualizer,We,$):new Te(H,$),V.current=S),ee.current=R,te.current=$,re.current=R?H.hunkSeparators:void 0,Q.current=t,Y.current=v,G.current=b,t)S.render({fileDiff:t,forceRender:L,containerWrapper:o,...w?{lineAnnotations:w}:{}});else{if(!v||!b)return;S.render({oldFile:v,newFile:b,forceRender:L,containerWrapper:o,...w?{lineAnnotations:w}:{}})}const q=Be(o,()=>{a(),Ue(S,u,se)});return()=>{q(),a()}},[W,t,i,r,w,e,H,n,$]),f.useEffect(()=>{const o=A.current;if(!o)return;let l=null,a=null;const R=setTimeout(()=>{const v=o.querySelector("diffs-container");if(!(v instanceof HTMLElement))return;const b=v.shadowRoot;l=new MutationObserver(()=>{a&&cancelAnimationFrame(a),a=requestAnimationFrame(()=>{se(),a=null})}),l.observe(v,{childList:!0,subtree:!0}),b&&l.observe(b,{childList:!0,subtree:!0})},100);return()=>{clearTimeout(R),a&&cancelAnimationFrame(a),l?.disconnect()}},[W,i]),typeof window>"u"?null:d==="fill"?z.jsx("div",{className:fe("flex flex-col relative","size-full"),"data-diff-virtual-root":!0,children:z.jsx("div",{className:"flex-1 relative min-h-0",children:z.jsx(Oe,{outerClassName:"pierre-diff-wrapper size-full",disableHorizontal:!1,fillContainer:!0,"data-diff-virtual-content":!0,children:z.jsx("div",{ref:K,className:"size-full relative",children:z.jsx("div",{ref:A,className:"size-full"})})})})}):z.jsx("div",{className:fe("relative","w-full"),children:z.jsxs("div",{ref:K,className:"pierre-diff-wrapper w-full relative","data-no-drawer-swipe":"true",children:[z.jsx("div",{ref:A,className:"w-full"}),z.jsx(De,{hostRef:A,enabled:!h})]})})};export{nt as P};
146
+ `;function Ae(n){let e=2166136261;for(let t=0;t<n.length;t+=1)e^=n.charCodeAt(t),e=e+((e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24))>>>0;return e.toString(16)}function ve(n){const e=n.length>400?`${n.slice(0,200)}${n.slice(-200)}`:n;return`${n.length}:${Ae(e)}`}const Ve=n=>n==="auto"||n==="scroll"||n==="overlay",$e=n=>{let e=n?.parentElement??null;for(;e;){const t=window.getComputedStyle(e);if(Ve(t.overflowY))return e;e=e.parentElement}return null},qe=(n,e)=>{if(!n||!e||typeof window>"u")return()=>{};const t=$e(n);if(!t)return()=>{};const r=e.getBoundingClientRect().height;if(!r)return()=>{};const i=n.getBoundingClientRect().top-t.getBoundingClientRect().top,s=e.style.minHeight;e.style.minHeight=`${Math.ceil(r)}px`;let u=!1;return()=>{if(u)return;u=!0,e.style.minHeight=s;const c=n.getBoundingClientRect().top-t.getBoundingClientRect().top-i;c&&(t.scrollTop+=c)}},We=(n,e)=>{if(typeof window>"u")return()=>{};let t=null,r=null,i=!1;const s=()=>{i||(r?.disconnect(),r=null,t=window.requestAnimationFrame(()=>{t=window.requestAnimationFrame(()=>{i||e()})}))},u=()=>n.querySelector("diffs-container")?.shadowRoot??void 0,d=(c=u())=>!!c?.querySelector("[data-line]");return d()?s():typeof MutationObserver<"u"?(r=new MutationObserver(()=>{const c=u();if(c){if(d(c)){s();return}r?.disconnect(),r=new MutationObserver(()=>{d(c)&&s()}),r.observe(c,{childList:!0,subtree:!0})}}),r.observe(n,{childList:!0,subtree:!0})):t=window.requestAnimationFrame(s),()=>{i=!0,r?.disconnect(),t!==null&&window.cancelAnimationFrame(t)}},X=new WeakMap,Be={lineHeight:24,hunkSeparatorHeight:24,spacing:0};function Ne(n){const e=n.closest("[data-diff-virtual-root]");if(e instanceof HTMLElement){const t=e.querySelector("[data-diff-virtual-content]");return{key:e,root:e,content:t instanceof HTMLElement?t:void 0}}return{key:document,root:document,content:void 0}}function je(n){if(typeof document>"u")return null;const e=Ne(n);let t=X.get(e.key);if(!t){const i=new _e;i.setup(e.root,e.content),t={virtualizer:i,refs:0},X.set(e.key,t)}t.refs+=1;let r=!1;return{virtualizer:t.virtualizer,root:e.root,release:()=>{if(r)return;r=!0;const i=X.get(e.key);i&&(i.refs-=1,!(i.refs>0)&&(i.virtualizer.cleanUp(),X.delete(e.key)))}}}const Ue=(n,e,t)=>{if(typeof window>"u")return()=>{};const r=[],i=()=>{try{n.rerender()}catch{}const s=e?.root;s instanceof HTMLElement?s.dispatchEvent(new Event("scroll",{bubbles:!1})):document.dispatchEvent(new Event("scroll",{bubbles:!1})),window.dispatchEvent(new Event("resize")),t()};return r.push(window.requestAnimationFrame(i)),r.push(window.requestAnimationFrame(()=>{r.push(window.requestAnimationFrame(i))})),()=>{for(const s of r)window.cancelAnimationFrame(s)}},nt=({original:n,modified:e,fileDiff:t,language:r,fileName:i,renderSideBySide:s,wrapLines:u,layout:d="fill",enableGutterUtility:c=!1,enableLineSelection:m=!1,onGutterUtilityClick:p,onLineSelectionEnd:y,lineAnnotations:w,renderAnnotation:W})=>{const D=Te(),C=D?.currentTheme.metadata.variant==="dark",_=D?.availableThemes.find(o=>o.metadata.id===D.lightThemeId)??de(!1),F=D?.availableThemes.find(o=>o.metadata.id===D.darkThemeId)??de(!0);he(_),he(F);const B=`${_.metadata.id}:${F.metadata.id}:${C?"dark":"light"}`,N=f.useMemo(()=>{if(t){const o=t.deletionLines.reduce((a,h)=>a+h.length,0),l=t.additionLines.reduce((a,h)=>a+h.length,0);return Math.max(o,l)>ge}return Math.max(n.length,e.length)>ge},[t,e.length,n.length]),K=f.useRef(null),A=f.useRef(null),V=f.useRef(null),j=f.useRef(null),ee=f.useRef(null),te=f.useRef(null),re=f.useRef(void 0),Q=f.useRef(void 0),Y=f.useRef(void 0),G=f.useRef(void 0),[,se]=ae.useReducer(o=>o+1,0),$=Ce(N?"unified":s?"split":"unified"),I=f.useRef(new Map),ie=f.useRef(W);ie.current=W;const oe=o=>`${o.side}:${o.lineNumber}`,le=f.useCallback(o=>{if(typeof document>"u")return;const l=`${o.side}:${o.lineNumber}`;let a=I.current.get(l);if(!a){const h=document.createElement("div");h.setAttribute("data-pichamber-line-annotation",l),a={root:Se.createRoot(h),element:h},I.current.set(l,a)}return a.root.render(ie.current?.(o)??null),a.element},[]);f.useEffect(()=>{if(!w){for(const[,a]of I.current)a.root.unmount();I.current.clear();return}const o=new Set(w.map(oe));for(const[a,h]of I.current)o.has(a)||(h.root.unmount(),I.current.delete(a));const l=ie.current;if(l)for(const a of w){const h=I.current.get(oe(a));h&&h.root.render(l(a))}},[w]),f.useEffect(()=>{const o=I.current;return()=>{for(const l of o.values())l.root.unmount();o.clear()}},[]);const T=f.useMemo(()=>ue(_),[_]),O=f.useMemo(()=>ue(F),[F]);ae.useLayoutEffect(()=>{const o=K.current;if(!o)return;const l=o.querySelector("diffs-container");if(!l)return;const a=C?O:T,h=(we,Re)=>we.colors?.[Re],R=h(T,"terminal.ansiGreen"),v=h(T,"terminal.ansiRed"),b=h(T,"terminal.ansiBlue"),P=h(O,"terminal.ansiGreen"),k=h(O,"terminal.ansiRed"),M=h(O,"terminal.ansiBlue");l.style.setProperty("--shiki-light",T.fg),l.style.setProperty("--shiki-light-bg",T.bg),R&&l.style.setProperty("--shiki-light-addition-color",R),v&&l.style.setProperty("--shiki-light-deletion-color",v),b&&l.style.setProperty("--shiki-light-modified-color",b),l.style.setProperty("--shiki-dark",O.fg),l.style.setProperty("--shiki-dark-bg",O.bg),P&&l.style.setProperty("--shiki-dark-addition-color",P),k&&l.style.setProperty("--shiki-dark-deletion-color",k),M&&l.style.setProperty("--shiki-dark-modified-color",M),l.style.setProperty("--diffs-bg",a.bg),l.style.setProperty("--diffs-fg",a.fg);const S=C?P:R,L=C?k:v,q=C?M:b;S&&l.style.setProperty("--diffs-addition-color-override",S),L&&l.style.setProperty("--diffs-deletion-color-override",L),q&&l.style.setProperty("--diffs-modified-color-override",q);const g=l.shadowRoot?.querySelector("pre");g&&(g.style.setProperty("--shiki-light",T.fg),g.style.setProperty("--shiki-light-bg",T.bg),R&&g.style.setProperty("--shiki-light-addition-color",R),v&&g.style.setProperty("--shiki-light-deletion-color",v),b&&g.style.setProperty("--shiki-light-modified-color",b),g.style.setProperty("--shiki-dark",O.fg),g.style.setProperty("--shiki-dark-bg",O.bg),P&&g.style.setProperty("--shiki-dark-addition-color",P),k&&g.style.setProperty("--shiki-dark-deletion-color",k),M&&g.style.setProperty("--shiki-dark-modified-color",M),g.style.setProperty("--diffs-bg",a.bg),g.style.setProperty("--diffs-fg",a.fg),S&&g.style.setProperty("--diffs-addition-color-override",S),L&&g.style.setProperty("--diffs-deletion-color-override",L),q&&g.style.setProperty("--diffs-modified-color-override",q))},[O,B,C,T]);const H=f.useMemo(()=>({theme:{dark:F.metadata.id,light:_.metadata.id},themeType:C?"dark":"light",diffStyle:s?"split":"unified",diffIndicators:"classic",hunkSeparators:"line-info-basic",lineDiffType:"none",maxLineDiffLength:N?0:1e3,maxLineLengthForHighlighting:N?1:1e3,tokenizeMaxLineLength:N?1:1e3,collapsedContextThreshold:0,expansionLineCount:20,overflow:u?"wrap":"scroll",disableFileHeader:!0,enableLineSelection:m,enableGutterUtility:c,enableHoverUtility:!1,...p?{onGutterUtilityClick:p}:{},...y?{onLineSelectionEnd:y}:{},renderAnnotation:le,unsafeCSS:d==="inline"?`${me}
147
+ ${ze}`:me}),[le,F.metadata.id,c,m,C,N,d,_.metadata.id,p,y,s,u]);return f.useEffect(()=>{const o=A.current;return()=>{V.current?.cleanUp(),V.current=null,j.current?.release(),j.current=null,ee.current=null,te.current=null,re.current=void 0,Q.current=void 0,Y.current=void 0,G.current=void 0,o&&(o.innerHTML="")}},[]),f.useEffect(()=>{if(typeof window>"u")return;const o=A.current,l=K.current;if(!o||!$)return;const a=qe(l,o);let h=j.current;h||(h=je(o),j.current=h),j.current=h;const R=h?.virtualizer??null,v=t?void 0:{name:i||"",contents:n,lang:r,cacheKey:`old:${B}:${i}:${ve(n)}`},b=t?void 0:{name:i||"",contents:e,lang:r,cacheKey:`new:${B}:${i}:${ve(e)}`},P=t?Q.current!==t:Q.current!==void 0||!v||!b||!Y.current||!G.current||!ce(Y.current,v)||!ce(G.current,b),k=V.current,M=!!(k&&(ee.current!==R||te.current!==$||R&&(re.current!==H.hunkSeparators||P)));M&&(k?.cleanUp(),V.current=null,o.innerHTML="");let S=V.current;const L=!M&&k?!Ee(k.options,H):!1;if(S?S.setOptions(H):(S=h?new ke(H,h.virtualizer,Be,$):new xe(H,$),V.current=S),ee.current=R,te.current=$,re.current=R?H.hunkSeparators:void 0,Q.current=t,Y.current=v,G.current=b,t)S.render({fileDiff:t,forceRender:L,containerWrapper:o,...w?{lineAnnotations:w}:{}});else{if(!v||!b)return;S.render({oldFile:v,newFile:b,forceRender:L,containerWrapper:o,...w?{lineAnnotations:w}:{}})}const q=We(o,()=>{a(),Ue(S,h,se)});return()=>{q(),a()}},[B,t,i,r,w,e,H,n,$]),f.useEffect(()=>{const o=A.current;if(!o)return;let l=null,a=null;const R=setTimeout(()=>{const v=o.querySelector("diffs-container");if(!(v instanceof HTMLElement))return;const b=v.shadowRoot;l=new MutationObserver(()=>{a&&cancelAnimationFrame(a),a=requestAnimationFrame(()=>{se(),a=null})}),l.observe(v,{childList:!0,subtree:!0}),b&&l.observe(b,{childList:!0,subtree:!0})},100);return()=>{clearTimeout(R),a&&cancelAnimationFrame(a),l?.disconnect()}},[B,i]),typeof window>"u"?null:d==="fill"?z.jsx("div",{className:fe("flex flex-col relative","size-full"),"data-diff-virtual-root":!0,children:z.jsx("div",{className:"flex-1 relative min-h-0",children:z.jsx(Oe,{outerClassName:"pierre-diff-wrapper size-full",disableHorizontal:!1,fillContainer:!0,"data-diff-virtual-content":!0,children:z.jsx("div",{ref:K,className:"size-full relative",children:z.jsx("div",{ref:A,className:"size-full"})})})})}):z.jsx("div",{className:fe("relative","w-full"),children:z.jsxs("div",{ref:K,className:"pierre-diff-wrapper w-full relative","data-no-drawer-swipe":"true",children:[z.jsx("div",{ref:A,className:"w-full"}),z.jsx(De,{hostRef:A,enabled:!u})]})})};export{nt as P};